Skip to content

Commit 76ef566

Browse files
committed
Refactor cmv distribute workflow, create cmv aggregate workflow
1 parent d015580 commit 76ef566

6 files changed

Lines changed: 959 additions & 456 deletions

File tree

Detectors/TPC/workflow/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,9 @@ o2_add_executable(cmv-distribute
304304
SOURCES src/tpc-distribute-cmv.cxx
305305
PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)
306306

307-
add_subdirectory(readers)
307+
o2_add_executable(cmv-aggregate
308+
COMPONENT_NAME tpc
309+
SOURCES src/tpc-aggregate-cmv.cxx
310+
PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)
311+
312+
add_subdirectory(readers)

Detectors/TPC/workflow/README.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ The CMV workflows parse raw TPC data, buffer Common Mode Values per CRU on FLPs,
285285
|---|---|---|
286286
| `o2-tpc-cmv-to-vector` | `TPC/CMVVECTOR` | Parses raw TPC data and creates vectors of CMVs per CRU |
287287
| `o2-tpc-cmv-flp` | `TPC/CMVGROUP` | Buffers N TFs per CRU on the FLP and groups them for forwarding |
288-
| `o2-tpc-cmv-distribute` | TTree / CCDB payload | Merges CRUs over N TFs on the calibration node, serializes the CMVContainer into a TTree, and either writes it to disk (`--dump-cmvs`) or forwards it as a CCDB object (`--enable-CCDB-output`) |
288+
| `o2-tpc-cmv-distribute` | `TPC/CMVAGG*` | Routes grouped CMV batches from the calibration node to the aggregate workflow while preserving buffered TF and lane handling |
289+
| `o2-tpc-cmv-aggregate` | TTree / CCDB payload | Collects all CRUs for each aggregate lane, preprocesses and compresses CMVs per buffered TF slice, then writes the CMVContainer TTree to disk (`--output-dir`) and/or forwards it as a CCDB object (`--enable-CCDB-output`) |
289290
290291
#### `o2-tpc-cmv-to-vector`
291292
@@ -319,20 +320,34 @@ The CMV workflows parse raw TPC data, buffer Common Mode Values per CRU on FLPs,
319320
| `--timeframes` | 2000 | Number of TFs aggregated per calibration interval |
320321
| `--firstTF` | -1 | First time frame index; -1 = auto-detect from first incoming TF; values < -1 set an offset of `\|firstTF\|+1` TFs before the first interval begins |
321322
| `--lanes` | 1 | Number of parallel lanes (CRUs are split evenly across lanes) |
323+
| `--output-lanes` | 1 | Number of aggregate pipelines downstream; these lanes rotate whole CMV aggregation intervals, not CRU subsets |
322324
| `--n-TFs-buffer` | 1 | Number of TFs buffered per group in the upstream `o2-tpc-cmv-flp` (must match that workflow's setting) |
325+
| `--send-precise-timestamp` | false | Forward orbit-reset timing information needed by the aggregate workflow for precise CCDB validity timestamps |
326+
| `--drop-data-after-nTFs` | 0 | Drop data for a relative TF slot after this many TFs have passed without receiving all CRUs; 0 uses the default derived from `--check-data-every-n` |
327+
| `--check-data-every-n` | 0 | Check for missing CRU data every N invocations of the run function; -1 disables checking, 0 uses the default (timeframes/2) |
328+
| `--nFactorTFs` | 1000 | Number of TFs to skip before flushing the oldest incomplete aggregation interval |
329+
330+
#### `o2-tpc-cmv-aggregate`
331+
332+
> **Important:** `--n-TFs-buffer` must be set to the same value as in `o2-tpc-cmv-distribute` and `o2-tpc-cmv-flp`. Mismatched values will silently corrupt the relTF mapping and TTree entry count.
333+
334+
| Option | Default | Description |
335+
|---|---|---|
336+
| `--crus` | `0-359` | Full CRU range expected for each aggregate interval |
337+
| `--timeframes` | 2000 | Number of TFs aggregated per calibration interval |
338+
| `--input-lanes` | 1 | Number of aggregate pipelines; must match `o2-tpc-cmv-distribute --output-lanes` |
339+
| `--n-TFs-buffer` | 1 | Number of real TFs packed into one CMV batch from upstream; **must match** `o2-tpc-cmv-distribute --n-TFs-buffer` |
323340
| `--enable-CCDB-output` | false | Forward the CMVContainer TTree as a CCDB object to `o2-calibration-ccdb-populator-workflow` |
324-
| `--use-precise-timestamp` | false | Fetch orbit-reset and GRPECS from CCDB to compute a precise CCDB validity timestamp |
325-
| `--dump-cmvs` | false | Write the CMVContainer TTree to a local ROOT file on disk |
341+
| `--use-precise-timestamp` | false | Use orbit-reset timing forwarded by the distribute lane (requires `o2-tpc-cmv-distribute --send-precise-timestamp`) for precise CCDB validity start timestamps |
342+
| `--output-dir` | `none` | Output directory for writing the CMVContainer ROOT file; must exist |
343+
| `--nthreads` | 1 | Number of threads used for CMV preprocessing and compression; each thread processes a contiguous slice of buffered TFs |
326344
| `--use-sparse` | false | Sparse encoding: skip zero time bins (raw uint16 values; combine with `--use-compression-varint` or `--use-compression-huffman` for compressed sparse output) |
327345
| `--use-compression-varint` | false | Delta + zigzag + varint compression over all values; combined with `--use-sparse`: varint-encoded exact values at non-zero positions |
328346
| `--use-compression-huffman` | false | Huffman encoding over all values; combined with `--use-sparse`: Huffman-encoded exact values at non-zero positions |
329347
| `--cmv-zero-threshold` | 0 | Zero out CMV values whose magnitude is below this threshold (ADC) after optional rounding and before compression; 0 disables |
330348
| `--cmv-round-integers-threshold` | 0 | Round values to nearest integer ADC for \|v\| ≤ N ADC before compression; 0 disables |
331349
| `--cmv-dynamic-precision-mean` | 1.0 | Gaussian centre in \|CMV\| (ADC) where the strongest fractional-bit trimming is applied |
332350
| `--cmv-dynamic-precision-sigma` | 0 | Gaussian width (ADC) for smooth CMV fractional-bit trimming; 0 disables |
333-
| `--drop-data-after-nTFs` | 0 | Drop data for a relative TF slot after this many TFs have passed without receiving all CRUs; 0 uses the default derived from `--check-data-every-n` |
334-
| `--check-data-every-n` | 0 | Check for missing CRU data every N invocations of the run function; -1 disables checking, 0 uses the default (timeframes/2) |
335-
| `--nFactorTFs` | 1000 | Number of TFs to skip before flushing the oldest incomplete aggregation interval |
336351

337352
### Example 1 — Simple usage for testing
338353

@@ -361,7 +376,12 @@ o2-tpc-cmv-flp $ARGS_ALL \
361376
--crus ${CRUS} |
362377
o2-tpc-cmv-distribute $ARGS_ALL \
363378
--crus ${CRUS} \
364-
--dump-cmvs \
379+
--output-lanes 1 \
380+
--send-precise-timestamp \
381+
|
382+
o2-tpc-cmv-aggregate $ARGS_ALL \
383+
--crus ${CRUS} \
384+
--output-dir ./ \
365385
--enable-CCDB-output \
366386
--cmv-zero-threshold 1.0 \
367387
--cmv-dynamic-precision-mean 1.0 \
@@ -450,7 +470,12 @@ o2-dpl-raw-proxy $ARGS_ALL \
450470
--dataspec "A:TPC/CMVGROUP;A:TPC/CMVORBITINFO" |
451471
o2-tpc-cmv-distribute $ARGS_ALL \
452472
--crus ${CRUS} \
453-
--dump-cmvs \
473+
--output-lanes 1 \
474+
--send-precise-timestamp \
475+
|
476+
o2-tpc-cmv-aggregate $ARGS_ALL \
477+
--crus ${CRUS} \
478+
--output-dir ./ \
454479
--enable-CCDB-output \
455480
--cmv-zero-threshold 1.0 \
456481
--cmv-dynamic-precision-mean 1.0 \
@@ -461,4 +486,4 @@ o2-calibration-ccdb-populator-workflow $ARGS_ALL \
461486
--ccdb-path ccdb-test.cern.ch:8080
462487
```
463488
464-
The aggregator binds the ZeroMQ pull socket and waits for all FLPs to connect. Once `TPC/CMVGROUP` and `TPC/CMVORBITINFO` data arrive, `o2-tpc-cmv-distribute` merges them, applies compression, writes the object to the disk and uploads to the CCDB.
489+
The aggregator binds the ZeroMQ pull socket and waits for all FLPs to connect. Once `TPC/CMVGROUP` and `TPC/CMVORBITINFO` data arrive, `o2-tpc-cmv-distribute` routes the grouped CMV batches, and `o2-tpc-cmv-aggregate` gathers the full CRU set for each interval, applies preprocessing and compression, writes the object to disk, and uploads it to the CCDB.

0 commit comments

Comments
 (0)