Skip to content

Commit a1c2523

Browse files
Supporting all input and output types in the TPC reco workflow
- Converting the DigitPublisher into a more generic TPC lane publisher The generic publisher is suitable for all publishers of the TPC workflow - Adding writer and corresponding reader specs for decoded (native) clusters and raw clusters, adding writer for digits - Conditional handling of MC labels also between digit reader and clusterer - Minor improvement of tracker info message, printing a range of numbers instead the bit pattern of active sectors Raw and native clusters are in binary format, using the ability of the RootFileWriter to write binary chunks in ROOT files. MC labels are written to apropriate branches. Branches are separated per sector.
1 parent 40fbeb8 commit a1c2523

12 files changed

Lines changed: 411 additions & 406 deletions

Detectors/TPC/workflow/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ set(MODULE_BUCKET_NAME TPC_workflow_bucket)
1414
O2_SETUP(NAME ${MODULE_NAME})
1515
set(SRCS
1616
src/RecoWorkflow.cxx
17-
src/DigitReaderSpec.cxx
18-
src/ClusterReaderSpec.cxx
17+
src/PublisherSpec.cxx
1918
src/ClustererSpec.cxx
2019
src/ClusterConverterSpec.cxx
2120
src/ClusterDecoderRawSpec.cxx
@@ -38,3 +37,14 @@ O2_GENERATE_EXECUTABLE(
3837
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
3938
BUCKET_NAME ${BUCKET_NAME}
4039
)
40+
41+
set(TEST_SRCS
42+
test/test_TPCWorkflow.cxx
43+
)
44+
45+
O2_GENERATE_TESTS(
46+
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
47+
BUCKET_NAME ${BUCKET_NAME}
48+
TEST_SRCS ${TEST_SRCS}
49+
TIMEOUT 60
50+
)

Detectors/TPC/workflow/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,31 @@ tpc-reco-workflow --infile tpcdigits.root --tpc-sectors 0-15 --disable-mc 1
6464

6565
### Global workflow options:
6666
```
67-
--input-type arg (=digits) digitizer, digits, clusters, raw
68-
--output-type arg (=tracks) clusters, raw, decoded-clusters, tracks
67+
--input-type arg (=digits) digitizer, digits, clusters, raw, decoded-clusters
68+
--output-type arg (=tracks) digits, clusters, raw, decoded-clusters, tracks
6969
--disable-mc arg (=0) disable sending of MC information
7070
--tpc-lanes arg (=1) number of parallel lanes up to the tracker
7171
--tpc-sectors arg (=0-35) TPC sector range, e.g. 5-7,8,9
7272
```
7373

7474
#### Input Type
75-
The input and output types `raw` have not yet been implemented.
76-
7775
Input type `digitizer` will create the clusterers with dangling input, this is used
7876
to connect the reconstruction workflow directly to the digitizer workflow.
7977

78+
All other input types will create a publisher process reading data from branches of
79+
a ROOT file. File and branch names are configurable. The MC labels are always read
80+
from a parallel branch, the sequence of data and MC objects is assumed to be identical.
81+
8082
#### Output Type
8183
The output type selects up to which final product the workflow is executed. Multiple outputs
8284
are supported in order to write data at intermediate steps, e.g.
8385
```
8486
--output-type clusters,tracks
8587
```
8688

89+
MC label data are stored in corresponding branches per sector. The sequence of MC objects must match
90+
the sequence of data objects.
91+
8792
#### Parallel processing
8893
Parallel processing is controlled by the option `--tpc-lanes n`. The digit reader will fan out to n processing
8994
lanes, each with clusterer, converter and decoder. The tracker will fan in from the parallel lanes.
@@ -107,8 +112,6 @@ bz= magnetic field
107112
```
108113

109114
### Current limitations/TODO
110-
* input and output types `raw` are not yet implemented
111-
112115
* the propagation of MC labels goes together with multiple rearrangements and thus copy
113116

114117
* sequential workflow where the TPC sectors are processed individually and the data is buffered in the

Detectors/TPC/workflow/include/TPCWorkflow/RecoWorkflow.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ namespace TPC
2525
namespace RecoWorkflow
2626
{
2727
/// define input and output types of the workflow
28-
enum struct InputType { Digitizer, // directly read digits from {TPC:DIGITS}
29-
Digits, // read digits from file
30-
Clusters, // read clusters from file
28+
enum struct InputType { Digitizer, // directly read digits from {TPC:DIGITS}
29+
Digits, // read digits from file
30+
Clusters, // read clusters from file
31+
DecodedClusters, // read decoded clusters from file
3132
Raw };
32-
enum struct OutputType { Clusters,
33+
enum struct OutputType { Digits,
34+
Clusters,
3335
Raw,
3436
DecodedClusters,
3537
Tracks };

Detectors/TPC/workflow/src/CATrackerSpec.cxx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,40 @@ DataProcessorSpec getCATrackerSpec(bool processMC, size_t fanIn)
168168
}
169169
assert(processMC == false || validMcInputs == validInputs);
170170
if (verbosity > 0) {
171-
LOG(INFO) << "running tracking for sectors " << validInputs;
171+
// make human readable information from the bitfield
172+
std::string bitInfo;
173+
auto nActiveBits = validInputs.count();
174+
if (((uint64_t)0x1 << nActiveBits) == validInputs.to_ulong() + 1) {
175+
// sectors 0 to some upper bound are active
176+
bitInfo = "0-" + std::to_string(nActiveBits - 1);
177+
} else {
178+
int rangeStart = -1;
179+
int rangeEnd = -1;
180+
for (size_t sector = 0; sector < validInputs.size(); sector++) {
181+
if (validInputs.test(sector)) {
182+
if (rangeStart < 0) {
183+
if (rangeEnd >= 0) {
184+
bitInfo += ",";
185+
}
186+
bitInfo += std::to_string(sector);
187+
if (nActiveBits == 1) {
188+
break;
189+
}
190+
rangeStart = sector;
191+
}
192+
rangeEnd = sector;
193+
} else {
194+
if (rangeStart >= 0 && rangeEnd > rangeStart) {
195+
bitInfo += "-" + std::to_string(rangeEnd);
196+
}
197+
rangeStart = -1;
198+
}
199+
}
200+
if (rangeStart >= 0 && rangeEnd > rangeStart) {
201+
bitInfo += "-" + std::to_string(rangeEnd);
202+
}
203+
}
204+
LOG(INFO) << "running tracking for sector(s) " << bitInfo;
172205
}
173206
ClusterNativeAccessFullTPC clusterIndex;
174207
memset(&clusterIndex, 0, sizeof(clusterIndex));

Detectors/TPC/workflow/src/ClusterReaderSpec.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

Detectors/TPC/workflow/src/ClustererSpec.cxx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ DataProcessorSpec getClustererSpec(bool sendMC)
8282
}
8383
return;
8484
}
85-
auto inMCLabels = pc.inputs().get<const MCLabelContainer*>("mclabels");
85+
std::unique_ptr<const MCLabelContainer> inMCLabels;
86+
if (sendMC) {
87+
inMCLabels = std::move(pc.inputs().get<const MCLabelContainer*>("mclabels"));
88+
}
8689
auto inDigits = pc.inputs().get<const std::vector<o2::TPC::Digit>>("digits");
87-
if (verbosity > 0) {
90+
if (verbosity > 0 && inMCLabels) {
8891
LOG(INFO) << "received " << inDigits.size() << " digits, "
8992
<< inMCLabels->getIndexedSize() << " MC label objects";
9093
}
@@ -122,6 +125,17 @@ DataProcessorSpec getClustererSpec(bool sendMC)
122125
return processingFct;
123126
};
124127

128+
auto createInputSpecs = [](bool makeMcInput) {
129+
std::vector<InputSpec> inputSpecs{
130+
InputSpec{ "digits", gDataOriginTPC, "DIGITS", 0, Lifetime::Timeframe },
131+
};
132+
if (makeMcInput) {
133+
constexpr o2::header::DataDescription datadesc("DIGITSMCTR");
134+
inputSpecs.emplace_back("mclabels", gDataOriginTPC, datadesc, 0, Lifetime::Timeframe);
135+
}
136+
return std::move(inputSpecs);
137+
};
138+
125139
auto createOutputSpecs = [](bool makeMcOutput) {
126140
std::vector<OutputSpec> outputSpecs{
127141
OutputSpec{ { "clusters" }, gDataOriginTPC, "CLUSTERSIM", 0, Lifetime::Timeframe },
@@ -136,8 +150,7 @@ DataProcessorSpec getClustererSpec(bool sendMC)
136150
};
137151

138152
return DataProcessorSpec{ processorName,
139-
{ InputSpec{ "digits", gDataOriginTPC, "DIGITS", 0, Lifetime::Timeframe },
140-
InputSpec{ "mclabels", gDataOriginTPC, "DIGITSMCTR", 0, Lifetime::Timeframe } },
153+
{ createInputSpecs(sendMC) },
141154
{ createOutputSpecs(sendMC) },
142155
AlgorithmSpec(initFunction) };
143156
}

0 commit comments

Comments
 (0)