1515
1616#include " Framework/ConfigParamRegistry.h"
1717#include " Framework/ControlService.h"
18- #include " Framework/DataSpecUtils.h"
1918#include " TPCWorkflow/PublisherSpec.h"
2019#include " Headers/DataHeader.h"
21- #include " DPLUtils/RootTreeReader.h"
2220#include " TPCBase/Sector.h"
2321#include " DataFormatsTPC/TPCSectorHeader.h"
2422#include < memory> // for make_shared, make_unique, unique_ptr
@@ -39,7 +37,7 @@ namespace tpc
3937// / read data from multiple tree branches from ROOT file and publish
4038// / data are expected to be stored in separated branches per sector, the default
4139// / branch name is configurable, sector number is apended as extension '_n'
42- DataProcessorSpec getPublisherSpec (PublisherConf const & config, bool propagateMC)
40+ DataProcessorSpec createPublisherSpec (PublisherConf const & config, bool propagateMC, workflow_reader::Creator creator )
4341{
4442 if (config.tpcSectors .size () == 0 || config.outputIds .size () == 0 ) {
4543 throw std::invalid_argument (" need TPC sector and output id configuration" );
@@ -54,7 +52,7 @@ DataProcessorSpec getPublisherSpec(PublisherConf const& config, bool propagateMC
5452 bool finished = false ;
5553 };
5654
57- auto initFunction = [config, propagateMC](InitContext& ic) {
55+ auto initFunction = [config, propagateMC, creator ](InitContext& ic) {
5856 // get the option from the init context
5957 auto filename = ic.options ().get <std::string>(" infile" );
6058 auto treename = ic.options ().get <std::string>(" treename" );
@@ -88,7 +86,6 @@ DataProcessorSpec getPublisherSpec(PublisherConf const& config, bool propagateMC
8886 // set up the tree interface
8987 // TODO: parallelism on sectors needs to be implemented as selector in the reader
9088 // the data is now in parallel branches, as first attempt use an array of readers
91- constexpr auto persistency = Lifetime::Timeframe;
9289 auto outputId = outputIds.begin ();
9390 for (size_t sector = 0 ; sector < NSectors; ++sector) {
9491 if ((activeSectors & ((uint64_t )0x1 << sector)) == 0 ) {
@@ -103,27 +100,14 @@ DataProcessorSpec getPublisherSpec(PublisherConf const& config, bool propagateMC
103100 }
104101 std::string clusterbranchname = clbrName + " _" + std::to_string (sector);
105102 std::string mcbranchname = mcbrName + " _" + std::to_string (sector);
106- auto dto = DataSpecUtils::asConcreteDataTypeMatcher (config.dataoutput );
107- auto mco = DataSpecUtils::asConcreteDataTypeMatcher (config.mcoutput );
108- if (propagateMC) {
109- readers[sector] = std::make_shared<RootTreeReader>(treename.c_str (), // tree name
110- sectorfile.c_str (), // input file name
111- nofEvents, // number of entries to publish
112- publishingMode,
113- Output{mco.origin , mco.description , subSpec, persistency},
114- mcbranchname.c_str (), // name of mc label branch
115- Output{dto.origin , dto.description , subSpec, persistency},
116- clusterbranchname.c_str () // name of cluster branch
117- );
118- } else {
119- readers[sector] = std::make_shared<RootTreeReader>(treename.c_str (), // tree name
120- sectorfile.c_str (), // input file name
121- nofEvents, // number of entries to publish
122- publishingMode,
123- Output{dto.origin , dto.description , subSpec, persistency},
124- clusterbranchname.c_str () // name of cluster branch
125- );
126- }
103+ readers[sector] = creator (treename.c_str (), // tree name
104+ sectorfile.c_str (), // input file name
105+ nofEvents, // number of entries to publish
106+ publishingMode,
107+ subSpec,
108+ clusterbranchname.c_str (), // name of data branch
109+ mcbranchname.c_str () // name of mc label branch
110+ );
127111 if (++outputId == outputIds.end ()) {
128112 outputId = outputIds.begin ();
129113 }
0 commit comments