@@ -43,26 +43,33 @@ namespace emcal
4343namespace reco_workflow
4444{
4545
46- const std::unordered_map<std::string, InputType> InputMap{
47- {" digitizer" , InputType::Digitizer},
48- {" digits" , InputType::Digits},
49- {" cells" , InputType::Cells},
50- {" raw" , InputType::Raw},
51- {" clusters" , InputType::Clusters},
52- };
53-
54- const std::unordered_map<std::string, OutputType> OutputMap{
55- {" digits" , OutputType::Digits},
56- {" cells" , OutputType::Cells},
57- {" raw" , OutputType::Raw},
58- {" clusters" , OutputType::Clusters},
59- {" analysisclusters" , OutputType::AnalysisClusters}};
60-
6146o2::framework::WorkflowSpec getWorkflow (bool propagateMC,
6247 bool enableDigitsPrinter,
6348 std::string const & cfgInput,
64- std::string const & cfgOutput)
49+ std::string const & cfgOutput,
50+ bool disableRootInput,
51+ bool disableRootOutput)
6552{
53+
54+ const std::unordered_map<std::string, InputType> InputMap{
55+ {" digits" , InputType::Digits},
56+ {" cells" , InputType::Cells},
57+ {" raw" , InputType::Raw},
58+ {" clusters" , InputType::Clusters},
59+ };
60+
61+ const std::unordered_map<std::string, OutputType> OutputMap{
62+ {" digits" , OutputType::Digits},
63+ {" cells" , OutputType::Cells},
64+ {" raw" , OutputType::Raw},
65+ {" clusters" , OutputType::Clusters},
66+ {" analysisclusters" , OutputType::AnalysisClusters}};
67+
68+ std::unordered_map<InputType, std::vector<OutputType>> allowedIO;
69+ allowedIO[InputType::Digits] = std::vector<OutputType>{OutputType::Cells, OutputType::Clusters, OutputType::AnalysisClusters};
70+ allowedIO[InputType::Cells] = std::vector<OutputType>{OutputType::Clusters, OutputType::AnalysisClusters};
71+ allowedIO[InputType::Raw] = std::vector<OutputType>{OutputType::Cells};
72+
6673 InputType inputType;
6774
6875 try {
@@ -72,28 +79,56 @@ o2::framework::WorkflowSpec getWorkflow(bool propagateMC,
7279 }
7380 std::vector<OutputType> outputTypes;
7481 try {
75- outputTypes = RangeTokenizer::tokenize<OutputType>(cfgOutput, [](std::string const & token) { return OutputMap.at (token); });
82+ outputTypes = RangeTokenizer::tokenize<OutputType>(cfgOutput, [& ](std::string const & token) { return OutputMap.at (token); });
7683 } catch (std::out_of_range&) {
7784 throw std::invalid_argument (std::string (" invalid output type: " ) + cfgOutput);
7885 }
7986 auto isEnabled = [&outputTypes](OutputType type) {
8087 return std::find (outputTypes.begin (), outputTypes.end (), type) != outputTypes.end ();
8188 };
8289
90+ auto isAllowedIOCombination = [&allowedIO](InputType inp, OutputType out) {
91+ const auto & vout = allowedIO[inp];
92+ return std::find (vout.begin (), vout.end (), out) != vout.end ();
93+ };
94+
95+ auto getOutputTypeName = [&OutputMap](OutputType out) {
96+ std::string str;
97+ for (const auto & o : OutputMap) {
98+ if (o.second == out) {
99+ str = std::string (o.first );
100+ }
101+ }
102+ return str;
103+ };
104+
105+ // make sure inputs/outputs combinatios are enabled
106+ for (const auto outType : outputTypes) {
107+ if (!isAllowedIOCombination (inputType, outType)) {
108+ throw std::runtime_error (fmt::format (" Input {:s} is not allowed with output {:s}" , cfgInput, getOutputTypeName (outType)));
109+ }
110+ }
111+
112+ if (inputType == InputType::Raw) {
113+ propagateMC = false ;
114+ }
115+
83116 o2::framework::WorkflowSpec specs;
84117
85118 if (inputType == InputType::Digits) {
86119 using digitInputType = std::vector<o2::emcal::Digit>;
87- specs.emplace_back (o2::emcal::getPublisherSpec<digitInputType>(PublisherConf{
88- " emcal-digit-reader" ,
89- " o2sim" ,
90- {" digitbranch" , " EMCALDigit" , " Digit branch" },
91- {" digittriggerbranch" , " EMCALDigitTRGR" , " Trigger record branch" },
92- {" mcbranch" , " EMCALDigitMCTruth" , " MC label branch" },
93- o2::framework::OutputSpec{" EMC" , " DIGITS" },
94- o2::framework::OutputSpec{" EMC" , " DIGITSTRGR" },
95- o2::framework::OutputSpec{" EMC" , " DIGITSMCTR" }},
96- propagateMC));
120+ if (!disableRootInput) {
121+ specs.emplace_back (o2::emcal::getPublisherSpec<digitInputType>(PublisherConf{
122+ " emcal-digit-reader" ,
123+ " o2sim" ,
124+ {" digitbranch" , " EMCALDigit" , " Digit branch" },
125+ {" digittriggerbranch" , " EMCALDigitTRGR" , " Trigger record branch" },
126+ {" mcbranch" , " EMCALDigitMCTruth" , " MC label branch" },
127+ o2::framework::OutputSpec{" EMC" , " DIGITS" },
128+ o2::framework::OutputSpec{" EMC" , " DIGITSTRGR" },
129+ o2::framework::OutputSpec{" EMC" , " DIGITSMCTR" }},
130+ propagateMC));
131+ }
97132
98133 if (enableDigitsPrinter) {
99134 try {
@@ -102,57 +137,49 @@ o2::framework::WorkflowSpec getWorkflow(bool propagateMC,
102137 LOG (ERROR) << " Cannot create digits printer spec: " << e.what ();
103138 }
104139 }
105-
106- if (isEnabled (OutputType::Cells)) {
107- // add converter for cells
108- specs.emplace_back (o2::emcal::reco_workflow::getCellConverterSpec (propagateMC));
109- }
110-
111- if (isEnabled (OutputType::Clusters)) {
112- // add clusterizer
113- specs.emplace_back (o2::emcal::reco_workflow::getClusterizerSpec (true ));
114- }
115- if (isEnabled (OutputType::AnalysisClusters)) {
116- // add clusters from cells
117- specs.emplace_back (o2::emcal::reco_workflow::getAnalysisClusterSpec (true ));
118- }
119140 } else if (inputType == InputType::Cells) {
120141 using cellInputType = std::vector<o2::emcal::Cell>;
121- specs.emplace_back (o2::emcal::getPublisherSpec<cellInputType>(PublisherConf{
122- " emcal-cell-reader" ,
123- " o2sim" ,
124- {" cellbranch" , " EMCALCell" , " Cell branch" },
125- {" celltriggerbranch" , " EMCALCellTRGR" , " Trigger record branch" },
126- {" mcbranch" , " EMCALCellMCTruth" , " MC label branch" },
127- o2::framework::OutputSpec{" EMC" , " CELLS" },
128- o2::framework::OutputSpec{" EMC" , " CELLSTRGR" },
129- o2::framework::OutputSpec{" EMC" , " CELLSMCTR" }},
130- propagateMC));
142+ if (!disableRootInput) {
143+ specs.emplace_back (o2::emcal::getPublisherSpec<cellInputType>(PublisherConf{
144+ " emcal-cell-reader" ,
145+ " o2sim" ,
146+ {" cellbranch" , " EMCALCell" , " Cell branch" },
147+ {" celltriggerbranch" , " EMCALCellTRGR" , " Trigger record branch" },
148+ {" mcbranch" , " EMCALCellMCTruth" , " MC label branch" },
149+ o2::framework::OutputSpec{" EMC" , " CELLS" },
150+ o2::framework::OutputSpec{" EMC" , " CELLSTRGR" },
151+ o2::framework::OutputSpec{" EMC" , " CELLSMCTR" }},
152+ propagateMC));
153+ }
131154 if (enableDigitsPrinter) {
132155 try {
133156 specs.emplace_back (o2::emcal::reco_workflow::getEmcalDigitsPrinterSpec (" cells" ));
134157 } catch (std::runtime_error& e) {
135158 LOG (ERROR) << " Cannot create digits printer spec: " << e.what ();
136159 }
137160 }
161+ }
138162
139- if (isEnabled (OutputType::Clusters)) {
140- // add clusterizer from cells
141- specs.emplace_back (o2::emcal::reco_workflow::getClusterizerSpec (false ));
142- }
143- if (isEnabled (OutputType::AnalysisClusters)) {
144- // add clusters from cells
145- specs.emplace_back (o2::emcal::reco_workflow::getAnalysisClusterSpec (false ));
146- }
147- } else if (inputType == InputType::Raw) {
148-
149- // Subcscribe to Readout data using o2-readout-proxy
150- if (isEnabled (OutputType::Cells)) {
151- // add converter for cells
163+ if (isEnabled (OutputType::Cells)) {
164+ // add converter for cells
165+ if (inputType == InputType::Digits) {
166+ specs.emplace_back (o2::emcal::reco_workflow::getCellConverterSpec (propagateMC));
167+ } else {
168+ // raw data will come from upstream
152169 specs.emplace_back (o2::emcal::reco_workflow::getRawToCellConverterSpec ());
153170 }
154171 }
155172
173+ if (isEnabled (OutputType::Clusters)) {
174+ // add clusterizer
175+ specs.emplace_back (o2::emcal::reco_workflow::getClusterizerSpec (inputType == InputType::Digits));
176+ }
177+
178+ if (isEnabled (OutputType::AnalysisClusters)) {
179+ // add clusters from cells
180+ specs.emplace_back (o2::emcal::reco_workflow::getAnalysisClusterSpec (inputType == InputType::Digits));
181+ }
182+
156183 // check if the process is ready to quit
157184 // this is decided upon the meta information in the EMCAL block header, the operation is set
158185 // value kNoPayload in case of no data or no operation
@@ -217,7 +244,7 @@ o2::framework::WorkflowSpec getWorkflow(bool propagateMC,
217244 std::move (TriggerRecordBranch)));
218245 };
219246
220- if (isEnabled (OutputType::Digits)) {
247+ if (isEnabled (OutputType::Digits) && !disableRootOutput ) {
221248 using DigitOutputType = std::vector<o2::emcal::Digit>;
222249 using TriggerOutputType = std::vector<o2::emcal::TriggerRecord>;
223250 using MCLabelContainer = o2::dataformats::MCTruthContainer<o2::MCCompLabel>;
@@ -265,7 +292,7 @@ o2::framework::WorkflowSpec getWorkflow(bool propagateMC,
265292 }
266293 }
267294
268- if (isEnabled (OutputType::Clusters)) {
295+ if (isEnabled (OutputType::Clusters) && !disableRootOutput ) {
269296 using ClusterOutputType = std::vector<o2::emcal::Cluster>;
270297 using ClusterIndicesOutputType = std::vector<o2::emcal::ClusterIndex>;
271298 using TriggerOutputType = std::vector<o2::emcal::TriggerRecord>;
@@ -274,20 +301,20 @@ o2::framework::WorkflowSpec getWorkflow(bool propagateMC,
274301 " emcclusters.root" ,
275302 " o2sim" ,
276303 BranchDefinition<ClusterOutputType>{o2::framework::InputSpec{" clusters" , " EMC" , " CLUSTERS" , 0 },
277- " EMCCluster " ,
304+ " EMCALCluster " ,
278305 " cluster-branch-name" },
279306 BranchDefinition<ClusterIndicesOutputType>{o2::framework::InputSpec{" clusterindices" , " EMC" , " INDICES" , 0 },
280- " EMCClusterInputIndex " ,
307+ " EMCALClusterInputIndex " ,
281308 " clusterdigitindices-branch-name" },
282309 BranchDefinition<TriggerOutputType>{o2::framework::InputSpec{" clusterTRGR" , " EMC" , " CLUSTERSTRGR" , 0 },
283- " EMCClusterTRGR " ,
310+ " EMCALClusterTRGR " ,
284311 " clustertrigger-branch-name" },
285312 BranchDefinition<TriggerOutputType>{o2::framework::InputSpec{" indicesTRGR" , " EMC" , " INDICESTRGR" , 0 },
286313 " EMCIndicesTRGR" ,
287314 " indicestrigger-branch-name" })());
288315 }
289316
290- if (isEnabled (OutputType::AnalysisClusters)) {
317+ if (isEnabled (OutputType::AnalysisClusters) && !disableRootOutput ) {
291318 using AnalysisClusterOutputType = std::vector<o2::emcal::AnalysisCluster>;
292319
293320 specs.push_back (makeWriterSpec_AnalysisCluster (" emcal-analysis-clusters-writer" ,
@@ -298,20 +325,6 @@ o2::framework::WorkflowSpec getWorkflow(bool propagateMC,
298325 " cluster-branch-name" })());
299326 }
300327
301- if (isEnabled (OutputType::Cells) && inputType == InputType::Raw) {
302- using CellsDataType = std::vector<o2::emcal::Cell>;
303- using TriggerRecordDataType = std::vector<o2::emcal::TriggerRecord>;
304- specs.push_back (makeWriterSpec_CellsTR (" emcal-cells-writer" ,
305- " emccells.root" ,
306- " o2sim" ,
307- BranchDefinition<CellsDataType>{o2::framework::InputSpec{" data" , " EMC" , " CELLS" , 0 },
308- " EMCCell" ,
309- " cell-branch-name" },
310- BranchDefinition<TriggerRecordDataType>{o2::framework::InputSpec{" trigger" , " EMC" , " CELLSTRGR" , 0 },
311- " EMCACellTRGR" ,
312- " celltrigger-branch-name" })());
313- }
314-
315328 return std::move (specs);
316329}
317330
0 commit comments