Skip to content

Commit b0315cb

Browse files
authored
Fix documentation for modules development (QC-318) (#373)
1 parent eec4e5e commit b0315cb

1 file changed

Lines changed: 46 additions & 20 deletions

File tree

doc/ModulesDevelopment.md

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,23 @@ The repository QualityControl contains the _Framework_ and the _Modules_ in the
129129

130130
The Data Sampling code is part of the AliceO2 repository.
131131

132+
### Developing with aliBuild/alienv
133+
134+
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.
135+
136+
The correct way of building is to load the environment with `alienv` and then go to the build directory and run `make` or `ninja`.
137+
138+
```
139+
alienv load QualityControl/latest
140+
cd sw/BUILD/QualityControl-latest/QualityControl
141+
make -j8 install # or ninja -j8 install , also adapt to the number of cores available
142+
```
143+
132144
### User-defined modules
133145

134-
The Quality Control uses _plugins_ to load the actual code to be executed by the _Tasks_ and the _Checkers_. A module, or plugin, can contain one or several _Tasks_ and/or one or several _Checks_. They must subclass `TaskInterface.h` and `CheckInterface.h` respectively. We use the Template Method Design Pattern.
146+
The Quality Control uses _plugins_ to load the actual code to be executed by the _Tasks_ and the _Checks_. A module, or plugin, can contain one or several of these classes, both Tasks and Checks. They must subclass `TaskInterface.h` and `CheckInterface.h` respectively. We use the Template Method Design Pattern.
147+
148+
The same code, the same class, can be run many times in parallel. It means that you can run several qc tasks (no uppercase, i.e. processes) in parallel, each executing the same code defined in the same Task (uppercase, the class).
135149

136150
## Module creation
137151

@@ -159,54 +173,66 @@ Options:
159173
-p PP_NAME create a postprocessing task named PP_NAME
160174
```
161175

162-
For example, if your detector 3-letter code is ABC you might want to do
176+
For example, if your detector 3-letter code is TST you might want to do
163177
```
164178
# we are in ~/alice
165179
cd QualityControl/Modules
166-
./o2-qc-module-configurator.sh -m Abc -t RawDataQcTask # create the module and a task
180+
./o2-qc-module-configurator.sh -m TST -t RawDataQcTask # create the module and a task
167181
```
168182

183+
IMPORTANT: Make sure that your detector code is listed in TaskRunner::validateDetectorName. If it is not, feel free to add it.
184+
185+
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.
186+
169187
## Test run
170188

171189
Now that there is a module, we can build it and test it. First let's build it :
172190
```
173-
# We are in ~/alice and alienv has been called.
191+
# We are in ~/alice, call alienv if not already done
192+
alienv enter QualityControl/latest
174193
# Go to the build directory of QualityControl.
175194
cd sw/BUILD/QualityControl-latest/QualityControl
176-
make -j8 install # replace 8 by the number of cores on your machine
195+
make -j8 install # or ninja, replace 8 by the number of cores on your machine
177196
```
178197

179-
To test whether it works, we are going to run a basic DPL workflow defined in `runBasic.cxx`.
180-
We need to modify slightly the config file to indicate our freshly created module and classes.
181-
The config file is called `basic.json` and is located in `$QUALITYCONTROL_ROOT/etc/`. After installation, if you want to modify the original one, it is in the source directory `Framework`. In case you need it updated in the installation directory, you have to `make install` the project again.
198+
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](QuickStart.md#basic-workflow).
199+
200+
We are going to duplicate the config file we used previously, i.e. `basic.json`:
201+
```
202+
cp ~/alice/QualityControl/Framework/basic.json ~/alice/QualityControl/Modules/TST/basic-tst.json
203+
```
204+
205+
We need to modify it slightly to indicate our freshly created module and classes.
182206
Change the lines as indicated below :
183207

184208
```
185209
"tasks": {
186210
"MyRawDataQcTask": {
187211
"active": "true",
188212
"className": "o2::quality_control_modules::abc::RawDataQcTask",
189-
"moduleName": "QcAbc",
213+
"moduleName": "QcTST",
214+
"detectorName": "TST",
215+
```
216+
and
217+
```
218+
"detectorName": "TST",
219+
"dataSource": [{
220+
"type": "Task",
221+
"name": "MyRawDataQcTask",
190222
```
191223

192224
Now we can run it
193225

194226
```
195-
o2-qc-run-producer | o2-qc --config json://${QUALITYCONTROL_ROOT}/etc/basic.json
227+
o2-qc-run-producer | o2-qc --config json://$HOME/alice/QualityControl/Modules/TST/basic-tst.json
196228
```
197229

198-
You should see the QcTask at qcg-test.cern.ch with an object `Example` updating.
199-
200-
## Modification of a Task
201-
202-
Fill in the methods in RawDataQcTask.cxx. For example, 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).
203-
Once done, recompile it (see section above) and run it. You should see the second object published in the qcg.
230+
You should see an object `example` in `/qc/TST/MyRawDataQcTask` at qcg-test.cern.ch.
204231

205-
TODO give actual steps
232+
## Modification of the Task
206233

207-
You can rename the task by simply changing its name in the config file. Change the name from
208-
`QcTask` to whatever you like and run it again (no need to recompile). You should see the new name
209-
appear in the QCG.
234+
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);`.
235+
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.
210236

211237
## Check
212238

0 commit comments

Comments
 (0)