# Cycle vs Activity?

**URL:** <https://alice-talk.web.cern.ch/t/cycle-vs-activity/534>\
**Category:** O²\
**Created:** [March 14, 2020, 1:41pm UTC](https://alice-talk.web.cern.ch/t/cycle-vs-activity/534 "2020-03-14T13:41:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgcn](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@jgcn](https://alice-talk.web.cern.ch/u/jgcn)\
**Post date:** [March 14, 2020, 1:41pm UTC](https://alice-talk.web.cern.ch/t/cycle-vs-activity/534/1 "2020-03-14T13:41:08Z")

</div>

Dear all

sorry for the ignorance. In the QcTasks I see that there are member functions for start/end of Cycle and Activity. What is a Cycle and what is an Activity? If you could provide an example in the context of a detector the chances that I get it may increase 🙂

thanks a lot and have a nice weekend

guillermo

---

<div class="post-metadata">

**Author:** ![sheckel](https://alice-talk.web.cern.ch/user_avatar/alice-talk.web.cern.ch/sheckel/32/259_2.png) [@sheckel](https://alice-talk.web.cern.ch/u/sheckel)\
**Post date:** [March 16, 2020, 12:04pm UTC](https://alice-talk.web.cern.ch/t/cycle-vs-activity/534/2 "2020-03-16T12:04:07Z")

</div>

Dear Guillermo,

the activity is the overall activity of the QC task, starting the activity means starting, in your QualityControl workflow, the (O2) QC task. When starting the activity, the histograms are reset, hence your start from fresh and empty histograms. The task is then running in cycles, where in each cycle it looks for inputs and processes those within a given time window and after that time window publishes the histograms. Then, a new cycle is started **without** resetting the histograms.

You can find examples for the TPC in: `alice/QualityControl/Modules/TPC/`  
(assuming `"alice"` is your main alice software repository).

E.g. you can have a look at `src/PID.cxx` and a corresponding configuration file `run/tpcQCPID_sampled.json`. In the json file, within the `"tasks"` section, you see the two lines:

```auto
  "cycleDurationSeconds": "10",
  "maxNumberCycles": "-1",

```

This sets the duration of each cycle to 10 seconds and the maximum number of cycles to “-1”, which is infinity, i.e. the task will run forever (unless it is stopped manually).

I hope, this helps!

Cheers,  
Stefan

---

<div class="post-metadata">

**Author:** ![pkonopka](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/p/e47774/32.png) [@pkonopka](https://alice-talk.web.cern.ch/u/pkonopka)\
**Post date:** [March 16, 2020, 2:35pm UTC](https://alice-talk.web.cern.ch/t/cycle-vs-activity/534/3 "2020-03-16T14:35:08Z")

</div>

If may chime in:  
What Stefan said is correct (thank you). Think of Activity as of a one lifetime of a QC task. That might correspond to one data-taking run, or a shorter period, if you keep it running just for half an hour during a longer data-taking run.

> [@sheckel](#):
>
> Then, a new cycle is started **without** resetting the histograms.

That it correct for small setups. However if we run a QC task in parallel on multiple nodes and then its result will have to be merged, we might invoke `TaskInterface::reset()` at the end of each cycle. That should clean the histograms, so we send only the last difference to be merged. Complete MonitorObjects, after merging, will still contain the complete data. These complete, merged MOs will go to Checks.

It is still to be decided if we merge only histogram differences or the full-history versions. If justified, we will support both possibilities.

---

<div class="post-metadata">

**Author:** ![jgcn](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@jgcn](https://alice-talk.web.cern.ch/u/jgcn)\
**Post date:** [March 16, 2020, 2:47pm UTC](https://alice-talk.web.cern.ch/t/cycle-vs-activity/534/4 "2020-03-16T14:47:58Z")

</div>

Dear Stefan, Piotr

thanks a lot for the clarification …  
but I still do not understand very well cycles and the relation with real data taking …

If I understand it correctly, during data taking the data from a given detector will be read out in time frames. Does a time frame should correspond to a cycle (assuming no downscaling from the sampling, that is that QC will process all the data)? If yes, how are they synchronised? (the units of cycles seems to be seconds, not time frames)

thanks again for your help  
greetings from Prague and have a nice afternoon  
guillermo

---

<div class="post-metadata">

**Author:** ![pkonopka](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/p/e47774/32.png) [@pkonopka](https://alice-talk.web.cern.ch/u/pkonopka)\
**Post date:** [March 19, 2020, 9:45am UTC](https://alice-talk.web.cern.ch/t/cycle-vs-activity/534/5 "2020-03-19T09:45:15Z")

</div>

> [@jgcn](#):
>
> If I understand it correctly, during data taking the data from a given detector will be read out in time frames.

As far as I know, that it kind of true, but during the data processing we might actually have different granularity. There might be multiple messages flying around, corresponding to the same Timeframe.

> [@jgcn](#):
>
> Does a time frame should correspond to a cycle (assuming no downscaling from the sampling, that is that QC will process all the data)? If yes, how are they synchronised? (the units of cycles seems to be seconds, not time frames)

These are not synchronised. The idea of “cycle” is to have your MonitorObjects regularly published and checked, in a constant time period which can be configured.  
So QC tasks might receive and process data within certain time domain, but they send the most recent MonitorObjects in regular intervals, even when no input data arrives. Input and output time domains are totally independent.

---

<div class="post-metadata">

**Author:** ![jgcn](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@jgcn](https://alice-talk.web.cern.ch/u/jgcn)\
**Post date:** [March 19, 2020, 10:53am UTC](https://alice-talk.web.cern.ch/t/cycle-vs-activity/534/6 "2020-03-19T10:53:36Z")

</div>

Hi Piotr

thanks a lot, now it is clearer

have a nice day

guillermo
