QualityControl
1.5.1
O2 Data Quality Control Framework
|
← Go back to Quickstart | ../README.md "↑ Go to the Table of Content ↑" | Continue to Post-processing →
Before developing a module, one should have a bare idea of what the QualityControl is and how it is designed. The following sections explore these aspects.
The main data flow is represented in blue. Data samples are selected by the Data Sampling (not represented) and sent to the QC tasks, either on the same machines or on other machines. The tasks produce TObjects, usually histograms, encapsulated in a MonitorObject that are merged (if needed) and then checked. The checkers output a QualityObject along with the MonitorObjects which might have been modified. The MonitorObjects and the QualityObjects are stored in the repository. The QualityObjects can also optionally be aggregated by the Aggregators to produce additional QualityObjects that are also saved in the database.
Asynchronously, the Post-processing can retrieve MonitorObjects from the database when certain events happen (new version of an object, new run) and produce new TObjects such as a trending plot.
https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/README.md "Data Processing Layer" is a software framework developed as a part of O2 project. It structurizes the computing into units called Data Processors - processes that communicate with each other via messages. DPL takes care of generating and running the processing topology out of user declaration code, serializing and deserializing messages, providing the data processors with all the anticipated messages for a given timestamp and much more. Each piece of data is characterized by its DataHeader
, which consists (among others) of dataOrigin
, dataDescription
and SubSpecification
- for example {"MFT", "TRACKS", 0}
.
An example of a workflow definition which describes the processing steps (Data Processors), their inputs and their outputs can be seen in runBasic.cxx. In the QC we define the workflows in files whose names are prefixed with run
.
The Data Sampling provides the possibility to sample data in DPL workflows, based on certain conditions ( 5% randomly, when payload is greater than 4234 bytes or others, including custom conditions). The job of passing the right data is done by a data processor called Dispatcher
. A desired data stream is specified in the form of Data Sampling Policies, defined in the QC JSON configuration file. Please refer to the main Data Sampling readme for more details.
Data Sampling is used by Quality Control to feed the tasks with data. Below we present an example of a configuration file. It instructs Data Sampling to provide a QC task with 10% randomly selected data that has the header {"ITS", "RAWDATA", 0}
. The data will be accessible inside the QC task by the binding "raw"
.
An example of using the data sampling in a DPL workflow is visible in runAdvanced.cxx.
If needed, a custom data selection can be performed by inheriting the DataSamplingCondition
class and implementing the configure
and decide
methods. Then, to use it, one needs to specify the library and class names in the config file.
The class ExampleCondition presents the how to write one's own condition, while in example-default.json the policy ex1
shows how it should be configured.
In case one needs to sample at a very high rate, or even monitor 100% of the data, the Data Sampling can be omitted altogether. As a result the task is connected directly to the the Device producing the data to be monitored. To do so, change the dataSource's type in the config file from dataSamplingPolicy
to direct
. In addition, add the information about the type of data that is expected (dataOrigin, binding, etc...) and remove the dataSamplingPolicies :
The file basic-no-sampling.json
is provided as an example. To test it, you can run o2-qc
with that configuration file instead of basic.json
.
To use multiple direct data sources, just place them one after another in the value of "query"
, separated with a semicolon. For example:
The repository QualityControl contains the Framework and the Modules in the respectively named directories.
The Data Sampling code is part of the AliceO2 repository.
One can of course build using aliBuild
(aliBuild build --defaults o2 QualityControl
). However, that will take quite some time as it checks all dependencies and builds everything.
After the initial use of aliBuild
, which is necessary, the correct way of building is to load the environment with alienv
and then go to the build directory and run make
or ninja
.
If you need to use the QCG or Readout, load O2Suite
instead of QualityControl
.
The Quality Control uses plugins to load the actual code to be executed by the Tasks, the Checks, the Aggregators and the PostProcessing. A module, or plugin, can contain one or several of these classes. They must subclass the corresponding interfaces, for example TaskInterface.h
or CheckInterface.h
. We use the Template Method Design Pattern.
The same code, the same class, can be run many times in parallel. It means that one can run several copies of the same qc Task in parallel, each executing the same code but on different data samples, typically on different nodes.
QC results (MonitorObjects and QualityObjects) are stored in a repository that we usually call the QCDB. Indeed, the underlying technology is the one of the CCDB (Condition and Calibration DataBase). As a matter of fact we use the test instance of the CCDB for the tests and development (ccdb-test.cern.ch:8080). In production, we will have a different instance distinct from the CCDB.
We use a consistent system of path for the objects we store in the QCDB:
qc/<detectorCode>/MO/<taskName>/<moName>
qc/<detectorCode>/QO/<checkName>[/<moName>]
The last, optional, part depends on the policy (read more about that later).Before starting to develop the code, one should create a new module if it does not exist yet. Typically each detector team should prepare a module.
The script o2-qc-module-configurator.sh
, in the directory Modules, is able to prepare a new module or to add a new Task, Check, Aggregator or PostProcessing task to an existing module. It must be run from within QualityControl/Modules. See the help message below:
For example, if your detector 3-letter code is TST you might want to do
IMPORTANT: Make sure that your detector code is listed in TaskRunner::validateDetectorName. If it is not, feel free to add it.
We will refer in the following section to the module as Tst
and the task as RawDataQcTask
. Make sure to use your own code and names.
Now that there is a module, we can build it and test it. First let's build it :
To test whether it works, we are going to run a basic workflow made of a producer and the qc, which corresponds to the one we saw in the QuickStart.
We are going to duplicate the config file we used previously, i.e. basic.json
:
We need to modify it slightly to indicate our freshly created module and classes. Change the lines as indicated below :
and
Now we can run it
You should see an object example
in /qc/TST/MO/MyRawDataQcTask
at qcg-test.cern.ch.
When debugging and developping, and only in this case, it can be handy to save the objects being produced to a file. Simply add the parameter saveObjectsToFile
to the task definition and set it to file name with or without a path. For example:
We are going to modify our task to make it publish a second histogram. Objects must be published only once and they will then be updated automatically every cycle (10 seconds for our example, 1 minute in general). Modify RawDataQcTask.cxx
and its header to add a new histogram, build it and publish it with getObjectsManager()->startPublishing(mHistogram);
. Once done, recompile it (see section above, make -j8 install
in the build directory) and run it (same as above). You should see the second object published in the qcg.
A Check is a function that determines the quality of the Monitor Objects produced in the previous step - Task. It can receive multiple Monitor Objects from several Tasks.
check
will be triggered whenever a new MonitorObject is received.check
inputAfter the creation of the module described in the above section, every Check functionality requires a separate implementation. The module might implement several Check classes.
The check
function is called whenever the policy is satisfied. It gets a map with all declared MonitorObjects. It is expected to return Quality of the given MonitorObjects.
The beautify
function is called after the check
function if there is a single dataSource
of type Task
in the configuration of the check. If there is more than one, the beautify()
is not called in this check.
The Aggregators are able to collect the QualityObjects produced by the checks or other Aggregators and to produce new Qualities. This is especially useful to determine the overall quality of a detector or a set of detectors.
One can try it with this simple example:
Notice the AggregatorRunner after the CheckRunner.
A more complex example with a producer and the o2-qc
:
check
will be triggered whenever a new QualityObject is received.check
inputWith o2-qc-module-configurator.sh
(see here), create a new Aggregator that can be then used in the config file.
An aggregator inherits from AggregatorInterface
and in particular this method:
The aggregate
method is called whenever the policy is satisfied. It gets a map with all the declared QualityObjects. It is expected to return a new Quality based on the inputs.
To commit your new or modified code, please follow this procedure
git clone https://github.com/<yourIdentifier>/QualityControl.git
git checkout -b feature-new-stuff
git push --set-upstream origin feature-new-stuff
git add Abc.cxx ; git commit Abc.cxx
git push
For a new feature, just create a new branch for it and use the same procedure. Do not fork again. You can work on several features at the same time by having parallel branches.
General ALICE Git guidelines can be accessed here.
In the final system, the qc gets real data from the DPL devices or the readout processes. During development a number of possibilities are available for the detector teams to develop their QC. We list them below.
When connecting the QC directly to the readout using the o2-qc-run-readout
proxy, remember to add this consumer to the config file of the readout and to enable it:
Random data
Add one or several dummy equipments:
Live detector data
If a part or the whole detector is ready and connected to 1 or several CRUs in the FLP, configure the readout to get data from there. The exact configuration items should be discussed with the readout experts.
This is the most realistic test one can do but it is also not very practical as you have to control the data taking and be on the machine equipped with a CRU. See the next section to alleviate this situation.
Detector data file
To record a data file with readout while getting data from a CRU, add the following piece to the readout configuration file:
To read it back with readout, for instance on another machine, add:
When plugging the QC on a DPL workflow to monitor the output of one or several devices, one should of course have some data producer in the workflow itself. Several options exist, listed below.
Random data
As shown earlier in this documentation we provide a random data generator. The binary is called o2-qc-run-producer
and many options are available (use --help
to see them).
Data file
To write and read data files in the DPL, please refer to the RawFileWriter and RawFileReader.
On the same page, there are instructions to write such file from Simulation.
Another option to read a raw data file, produced by Simulation or recorded with readout.exe
per instance, is to use directly the program o2-raw-file-reader-workflow
in O2 as described here (the config file is described earlier in the page).
Live detector data
If the detector is ready and connected to the CRU(s), one can of course start the full data taking workflow, including the SubTimeFrameBuilder and the DPL processing and plug the QC onto it.
A more complete example is available. The config file is called advanced.json. The workflow is made of 3 sources, intermediate processing steps, 3 sinks and a Dispatcher connecting two QC tasks to a number of these steps and 2 checks. The topology doesn't mean to represent any particular physics processing, it is just an example with multiple data processors.
To run it do either
or
← Go back to Quickstart | ../README.md "↑ Go to the Table of Content ↑" | Continue to Post-processing →