49 bool enableDigitsPrinter,
50 int subspecificationIn,
51 int subspecificationOut,
52 std::string
const& cfgInput,
53 std::string
const& cfgOutput,
54 bool disableRootInput,
55 bool disableRootOutput,
56 bool disableDecodingErrors,
57 bool disableTriggerReconstruction)
60 const std::unordered_map<std::string, InputType>
InputMap{
67 const std::unordered_map<std::string, OutputType> OutputMap{
74 std::unordered_map<InputType, std::vector<OutputType>> allowedIO;
83 }
catch (std::out_of_range&) {
84 throw std::invalid_argument(std::string(
"invalid input type: ") + cfgInput);
86 std::vector<OutputType> outputTypes;
88 outputTypes = RangeTokenizer::tokenize<OutputType>(cfgOutput, [&](std::string
const& token) {
return OutputMap.at(token); });
89 }
catch (std::out_of_range&) {
90 throw std::invalid_argument(std::string(
"invalid output type: ") + cfgOutput);
93 return std::find(outputTypes.begin(), outputTypes.end(),
type) != outputTypes.end();
97 const auto& vout = allowedIO[inp];
98 return std::find(vout.begin(), vout.end(), out) != vout.end();
101 auto getOutputTypeName = [&OutputMap](
OutputType out) {
103 for (
const auto&
o : OutputMap) {
104 if (
o.second == out) {
105 str = std::string(
o.first);
112 for (
const auto outType : outputTypes) {
113 if (!isAllowedIOCombination(inputType, outType)) {
114 throw std::runtime_error(fmt::format(
"Input {:s} is not allowed with output {:s}", cfgInput, getOutputTypeName(outType)));
125 using digitInputType = std::vector<o2::emcal::Digit>;
126 if (!disableRootInput) {
127 specs.emplace_back(o2::emcal::getPublisherSpec<digitInputType>(
PublisherConf{
128 "emcal-digit-reader",
131 {
"digitbranch",
"EMCALDigit",
"Digit branch"},
132 {
"digittriggerbranch",
"EMCALDigitTRGR",
"Trigger record branch"},
133 {
"mcbranch",
"EMCALDigitMCTruth",
"MC label branch"},
140 if (enableDigitsPrinter) {
143 }
catch (std::runtime_error& e) {
144 LOG(error) <<
"Cannot create digits printer spec: " << e.what();
148 using cellInputType = std::vector<o2::emcal::Cell>;
149 if (!disableRootInput) {
150 specs.emplace_back(o2::emcal::getPublisherSpec<cellInputType>(
PublisherConf{
154 {
"cellbranch",
"EMCALCell",
"Cell branch"},
155 {
"celltriggerbranch",
"EMCALCellTRGR",
"Trigger record branch"},
156 {
"mcbranch",
"EMCALCellMCTruth",
"MC label branch"},
162 if (enableDigitsPrinter) {
165 }
catch (std::runtime_error& e) {
166 LOG(error) <<
"Cannot create digits printer spec: " << e.what();
191 auto makeWriterSpec = [propagateMC](
const char* processName,
const char* defaultFileName,
const char* defaultTreeName,
192 auto&& databranch,
auto&& triggerbranch,
auto&& mcbranch) {
197 std::move(databranch),
198 std::move(triggerbranch),
199 std::move(mcbranch)));
202 std::move(databranch),
203 std::move(triggerbranch)));
207 auto makeWriterSpec_Cluster = [](
const char* processName,
const char* defaultFileName,
const char* defaultTreeName,
208 auto&& clusterbranch,
auto&& digitindicesbranch,
auto&& clustertriggerbranch,
auto&& indicestriggerbranch) {
211 std::move(clusterbranch),
212 std::move(digitindicesbranch),
213 std::move(clustertriggerbranch),
214 std::move(indicestriggerbranch)));
217 auto makeWriterSpec_AnalysisCluster = [](
const char* processName,
const char* defaultFileName,
const char* defaultTreeName,
218 auto&& analysisclusterbranch) {
221 std::move(analysisclusterbranch)));
224 auto makeWriterSpec_CellsTR = [disableDecodingErrors](
const char* processName,
const char* defaultFileName,
const char* defaultTreeName,
225 auto&& CellsBranch,
auto&& TriggerRecordBranch,
auto&& DecoderErrorsBranch) {
227 std::move(CellsBranch),
228 std::move(TriggerRecordBranch),
229 std::move(DecoderErrorsBranch)));
232 auto makeWriterSpec_CellsTR_noerrors = [](
const char* processName,
const char* defaultFileName,
const char* defaultTreeName,
233 auto&& CellsBranch,
auto&& TriggerRecordBranch) {
235 std::move(CellsBranch),
236 std::move(TriggerRecordBranch)));
259 using DigitOutputType = std::vector<o2::emcal::Cell>;
260 using TriggerOutputType = std::vector<o2::emcal::TriggerRecord>;
261 specs.push_back(makeWriterSpec(
"emcal-cells-writer",
"emccells.root",
"o2sim",
267 "celltrigger-branch-name"},
270 "cellmc-branch-name"})());
272 using CellsDataType = std::vector<o2::emcal::Cell>;
273 using TriggerRecordDataType = std::vector<o2::emcal::TriggerRecord>;
274 if (disableDecodingErrors) {
275 specs.push_back(makeWriterSpec_CellsTR_noerrors(
"emcal-cells-writer",
283 "celltrigger-branch-name"})());
286 using DecoderErrorsDataType = std::vector<o2::emcal::ErrorTypeFEE>;
287 specs.push_back(makeWriterSpec_CellsTR(
"emcal-cells-writer",
295 "celltrigger-branch-name"},
298 "decodererror-branch-name"})());
304 using ClusterOutputType = std::vector<o2::emcal::Cluster>;
305 using ClusterIndicesOutputType = std::vector<o2::emcal::ClusterIndex>;
306 using TriggerOutputType = std::vector<o2::emcal::TriggerRecord>;
308 specs.push_back(makeWriterSpec_Cluster(
"emcal-clusters-writer",
313 "cluster-branch-name"},
315 "EMCALClusterInputIndex",
316 "clusterdigitindices-branch-name"},
319 "clustertrigger-branch-name"},
322 "indicestrigger-branch-name"})());
326 using AnalysisClusterOutputType = std::vector<o2::emcal::AnalysisCluster>;
328 specs.push_back(makeWriterSpec_AnalysisCluster(
"emcal-analysis-clusters-writer",
329 "emcAnalysisClusters.root",
332 "EMCAnalysisCluster",
333 "cluster-branch-name"})());
336 return std::move(specs);
framework::WorkflowSpec getWorkflow(bool propagateMC=true, bool askDISTSTF=true, bool enableDigitsPrinter=false, int subspecificationIn=0, int subspecificationOut=0, std::string const &cfgInput="digits", std::string const &cfgOutput="clusters", bool disableRootInput=false, bool disableRootOutput=false, bool disableDecodingErrors=false, bool disableTriggerReconstruction=false)
create the workflow for EMCAL reconstruction