Skip to content

Commit 6bfad0d

Browse files
committed
TPC sector treatment in ChunkedDigitPublisher
1 parent d914785 commit 6bfad0d

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

Detectors/TPC/workflow/src/ChunkedDigitPublisher.cxx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <SimulationDataFormat/MCCompLabel.h>
2424
#include <SimulationDataFormat/MCTruthContainer.h>
2525
#include <SimulationDataFormat/ConstMCTruthContainer.h>
26+
#include "Algorithm/RangeTokenizer.h"
27+
#include "TPCBase/Sector.h"
2628
#include <TFile.h>
2729
#include <TTree.h>
2830
#include <TBranch.h>
@@ -54,6 +56,11 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
5456
workflowOptions.push_back(
5557
ConfigParamSpec{"tpc-lanes", VariantType::Int, defaultlanes, {laneshelp}});
5658

59+
std::string sectorshelp("List of TPC sectors, comma separated ranges, e.g. 0-3,7,9-15");
60+
std::string sectorDefault = "0-" + std::to_string(o2::tpc::Sector::MAXSECTOR - 1);
61+
workflowOptions.push_back(
62+
ConfigParamSpec{"tpc-sectors", VariantType::String, sectorDefault.c_str(), {sectorshelp}});
63+
5764
// option to disable MC truth
5865
workflowOptions.push_back(ConfigParamSpec{"disable-mc", o2::framework::VariantType::Bool, false, {"disable mc-truth"}});
5966
}
@@ -133,7 +140,7 @@ void publishBuffer<MCTruthContainer>(framework::ProcessingContext& pc, int secto
133140
delete accum;
134141
}
135142

136-
void publishMergedTimeframes(std::vector<int> const& lanes, bool domctruth, framework::ProcessingContext& pc)
143+
void publishMergedTimeframes(std::vector<int> const& lanes, std::vector<int> const& tpcsectors, bool domctruth, framework::ProcessingContext& pc)
137144
{
138145
ROOT::EnableThreadSafety();
139146
#ifdef WITH_OPENMP
@@ -151,10 +158,16 @@ void publishMergedTimeframes(std::vector<int> const& lanes, bool domctruth, fram
151158
auto originfile = new TFile(tmp.str().c_str(), "OPEN");
152159
assert(originfile);
153160

154-
auto merge = [originfile, &pc](auto data, auto brprefix) {
161+
auto merge = [&tpcsectors, originfile, &pc](auto data, auto brprefix) {
155162
auto keyslist = originfile->GetListOfKeys();
156163
for (int i = 0; i < keyslist->GetEntries(); ++i) {
157164
auto key = keyslist->At(i);
165+
int sector = atoi(key->GetName());
166+
if (std::find(tpcsectors.begin(), tpcsectors.end(), sector) == tpcsectors.end()) {
167+
// do nothing if sector not wanted
168+
continue;
169+
}
170+
158171
auto oldtree = (TTree*)originfile->Get(key->GetName());
159172
assert(oldtree);
160173
std::stringstream digitbrname;
@@ -166,7 +179,6 @@ void publishMergedTimeframes(std::vector<int> const& lanes, bool domctruth, fram
166179
decltype(data)* chunk = nullptr;
167180
br->SetAddress(&chunk);
168181

169-
int sector = atoi(key->GetName());
170182
using AccumType = std::decay_t<decltype(makePublishBuffer<decltype(data)>(pc, sector))>;
171183
AccumType accum;
172184
#pragma omp critical
@@ -202,7 +214,7 @@ void publishMergedTimeframes(std::vector<int> const& lanes, bool domctruth, fram
202214
class Task
203215
{
204216
public:
205-
Task(std::vector<int> laneConfig, bool mctruth) : mLanes(laneConfig), mDoMCTruth(mctruth)
217+
Task(std::vector<int> laneConfig, std::vector<int> tpcsectors, bool mctruth) : mLanes(laneConfig), mTPCSectors(tpcsectors), mDoMCTruth(mctruth)
206218
{
207219
}
208220

@@ -212,7 +224,7 @@ class Task
212224

213225
TStopwatch w;
214226
w.Start();
215-
publishMergedTimeframes(mLanes, mDoMCTruth, pc);
227+
publishMergedTimeframes(mLanes, mTPCSectors, mDoMCTruth, pc);
216228

217229
pc.services().get<ControlService>().endOfStream();
218230
pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
@@ -228,12 +240,13 @@ class Task
228240
private:
229241
bool mDoMCTruth = true;
230242
std::vector<int> mLanes;
243+
std::vector<int> mTPCSectors;
231244
};
232245

233246
/// create the processor spec
234247
/// describing a processor aggregating digits for various TPC sectors and writing them to file
235248
/// MC truth information is also aggregated and written out
236-
DataProcessorSpec getSpec(std::vector<int> const& laneConfiguration, bool mctruth, bool publish = true)
249+
DataProcessorSpec getSpec(std::vector<int> const& laneConfiguration, std::vector<int> const& tpcsectors, bool mctruth, bool publish = true)
237250
{
238251
//data definitions
239252
using DigitsOutputType = std::vector<o2::tpc::Digit>;
@@ -252,7 +265,7 @@ DataProcessorSpec getSpec(std::vector<int> const& laneConfiguration, bool mctrut
252265
}
253266

254267
return DataProcessorSpec{
255-
"TPCDigitMerger", {}, outputs, AlgorithmSpec{o2::framework::adaptFromTask<Task>(laneConfiguration, mctruth)}, Options{}};
268+
"TPCDigitMerger", {}, outputs, AlgorithmSpec{o2::framework::adaptFromTask<Task>(laneConfiguration, tpcsectors, mctruth)}, Options{}};
256269
}
257270

258271
} // end namespace tpc
@@ -263,9 +276,10 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
263276
WorkflowSpec specs;
264277
auto numlanes = configcontext.options().get<int>("tpc-lanes");
265278
bool mctruth = !configcontext.options().get<bool>("disable-mc");
279+
auto tpcsectors = o2::RangeTokenizer::tokenize<int>(configcontext.options().get<std::string>("tpc-sectors"));
266280

267281
std::vector<int> lanes(numlanes);
268282
std::iota(lanes.begin(), lanes.end(), 0);
269-
specs.emplace_back(o2::tpc::getSpec(lanes, mctruth));
283+
specs.emplace_back(o2::tpc::getSpec(lanes, tpcsectors, mctruth));
270284
return specs;
271285
}

0 commit comments

Comments
 (0)