Skip to content

Commit e2f7af7

Browse files
committed
Use GRP information to influence digitization workflow
We should only digitize detectors which are present in the simulation file (or which are set as active in the GRP). This commit makes a first step into this direction by reading the GRP at startup to influence the workflow setup. It is hence now possible to start the workflow for selected components only. A second way to influence this, might be added later via command line arguments.
1 parent e71ba68 commit e2f7af7

2 files changed

Lines changed: 56 additions & 25 deletions

File tree

Steer/DigitizerWorkflow/src/SimReaderSpec.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ namespace steer
3535
DataProcessorSpec getSimReaderSpec(int fanoutsize, std::shared_ptr<std::vector<int>> tpcsectors,
3636
std::shared_ptr<std::vector<int>> tpcsubchannels)
3737
{
38-
// this container will contain the TPC sector assignment per subchannel per invokation
39-
// it will allow that we snapshot/send exactly one sector assignement per algorithm invokation
38+
// this container will contain the TPC sector assignment per subchannel per invocation
39+
// it will allow that we snapshot/send exactly one sector assignment per algorithm invocation
4040
// to ensure that they all have different timeslice ids
4141
auto tpcsectormessages = std::make_shared<std::vector<std::vector<int>>>();
4242
tpcsectormessages->resize(tpcsubchannels->size());
@@ -120,7 +120,7 @@ DataProcessorSpec getSimReaderSpec(int fanoutsize, std::shared_ptr<std::vector<i
120120
context);
121121
}
122122
counter++;
123-
if (counter == tpcinvocations) {
123+
if (tpcinvocations == 0 || counter == tpcinvocations) {
124124
finished = true;
125125
}
126126
};

Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include "TOFClusterizerSpec.h"
3434
#include "TOFClusterWriterSpec.h"
3535

36+
// GRP
37+
#include "DataFormatsParameters/GRPObject.h"
38+
3639
#include <cstdlib>
3740
// this is somewhat assuming that a DPL workflow will run on one node
3841
#include <thread> // to detect number of hardware threads
@@ -139,47 +142,75 @@ bool wantCollisionTimePrinter()
139142
return false;
140143
}
141144

145+
o2::parameters::GRPObject* readGRP(std::string inputGRP = "o2sim_grp.root")
146+
{
147+
const auto grp = o2::parameters::GRPObject::loadFrom(inputGRP);
148+
if (!grp) {
149+
LOG(ERROR) << "This workflow needs a valid GRP file to start";
150+
}
151+
return grp;
152+
}
153+
142154
/// This function is required to be implemented to define the workflow
143155
/// specifications
144156
WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
145157
{
146158
WorkflowSpec specs;
147159

160+
// we will first of all read the GRP to detect which components need
161+
// instantiations
162+
// (for the moment this assumes the file o2sim_grp.root to be in the current directory)
163+
const auto grp = readGRP();
164+
if (!grp) {
165+
return specs;
166+
}
167+
148168
int fanoutsize = 0;
149169
if (wantCollisionTimePrinter()) {
150170
specs.emplace_back(o2::steer::getCollisionTimePrinter(fanoutsize++));
151171
}
152172

173+
// the TPC part
174+
// we need to instantiate this anyway since TPC is treated a bit special (for the moment)
153175
initTPC();
154176
// keeps track of which subchannels correspond to tpc channels
155177
auto tpclanes = std::make_shared<std::vector<int>>();
156178
// keeps track of which tpc sectors to process
157179
auto tpcsectors = std::make_shared<std::vector<int>>();
158-
extractTPCSectors(*tpcsectors.get(), configcontext);
159-
auto lanes = getNumTPCLanes(*tpcsectors.get(), configcontext);
180+
if (grp->isDetReadOut(o2::detectors::DetID::TPC)) {
160181

161-
for (int l = 0; l < lanes; ++l) {
162-
specs.emplace_back(o2::steer::getTPCDriftTimeDigitizer(fanoutsize));
163-
tpclanes->emplace_back(fanoutsize); // this records that TPC is "listening under this subchannel"
164-
fanoutsize++;
182+
extractTPCSectors(*tpcsectors.get(), configcontext);
183+
auto lanes = getNumTPCLanes(*tpcsectors.get(), configcontext);
184+
185+
for (int l = 0; l < lanes; ++l) {
186+
specs.emplace_back(o2::steer::getTPCDriftTimeDigitizer(fanoutsize));
187+
tpclanes->emplace_back(fanoutsize); // this records that TPC is "listening under this subchannel"
188+
fanoutsize++;
189+
}
190+
191+
// for writing digits to disc
192+
specs.emplace_back(o2::TPC::getTPCDigitRootWriterSpec(lanes));
165193
}
166194

167-
// for writing digits to disc
168-
specs.emplace_back(o2::TPC::getTPCDigitRootWriterSpec(lanes));
169-
170-
// connect the ITS digitization
171-
specs.emplace_back(o2::ITS::getITSDigitizerSpec(fanoutsize++));
172-
// connect ITS digit writer
173-
specs.emplace_back(o2::ITS::getITSDigitWriterSpec());
174-
175-
// connect the TOF digitization
176-
specs.emplace_back(o2::tof::getTOFDigitizerSpec(fanoutsize++));
177-
// add TOF digit writer
178-
specs.emplace_back(o2::tof::getTOFDigitWriterSpec());
179-
// add TOF clusterer
180-
specs.emplace_back(o2::tof::getTOFClusterizerSpec());
181-
// add TOF cluster writer
182-
specs.emplace_back(o2::tof::getTOFClusterWriterSpec());
195+
// the ITS part
196+
if (grp->isDetReadOut(o2::detectors::DetID::ITS)) {
197+
// connect the ITS digitization
198+
specs.emplace_back(o2::ITS::getITSDigitizerSpec(fanoutsize++));
199+
// connect ITS digit writer
200+
specs.emplace_back(o2::ITS::getITSDigitWriterSpec());
201+
}
202+
203+
// the TOF part
204+
if (grp->isDetReadOut(o2::detectors::DetID::TOF)) {
205+
// connect the TOF digitization
206+
specs.emplace_back(o2::tof::getTOFDigitizerSpec(fanoutsize++));
207+
// add TOF digit writer
208+
specs.emplace_back(o2::tof::getTOFDigitWriterSpec());
209+
// add TOF clusterer
210+
specs.emplace_back(o2::tof::getTOFClusterizerSpec());
211+
// add TOF cluster writer
212+
specs.emplace_back(o2::tof::getTOFClusterWriterSpec());
213+
}
183214

184215
// The SIM Reader. NEEDS TO BE LAST
185216
specs.emplace_back(o2::steer::getSimReaderSpec(fanoutsize, tpcsectors, tpclanes));

0 commit comments

Comments
 (0)