Project
Loading...
Searching...
No Matches
RecoWorkflow.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include <algorithm>
13#include <unordered_map>
14#include <vector>
15
16#include <fairlogger/Logger.h>
17
36
37namespace o2
38{
39
40template <typename T>
41using BranchDefinition = framework::MakeRootTreeWriterSpec::BranchDefinition<T>;
42
43namespace phos
44{
45
46namespace reco_workflow
47{
48
49const std::unordered_map<std::string, InputType> InputMap{
50 {"raw", InputType::Raw},
51 {"digits", InputType::Digits},
52 {"cells", InputType::Cells}};
53
54const std::unordered_map<std::string, OutputType> OutputMap{
55 {"cells", OutputType::Cells},
56 {"clusters", OutputType::Clusters},
57 {"digits", OutputType::Digits}};
58
60 bool disableRootOut,
61 bool propagateMC,
62 std::string const& cfgInput,
63 std::string const& cfgOutput,
64 bool fullCluOut,
65 int flpId,
66 bool defBadMap,
67 bool skipL1phase)
68{
69 InputType inputType;
70
71 try {
72 inputType = InputMap.at(cfgInput);
73 } catch (std::out_of_range&) {
74 throw std::invalid_argument(std::string("invalid input type: ") + cfgInput);
75 }
76 std::vector<OutputType> outputTypes;
77 try {
78 outputTypes = RangeTokenizer::tokenize<OutputType>(cfgOutput, [](std::string const& token) { return OutputMap.at(token); });
79 } catch (std::out_of_range&) {
80 throw std::invalid_argument(std::string("invalid output type: ") + cfgOutput);
81 }
82 auto isEnabled = [&outputTypes](OutputType type) {
83 return std::find(outputTypes.begin(), outputTypes.end(), type) != outputTypes.end();
84 };
85
87
88 // Raw to ....
89 if (inputType == InputType::Raw) {
90 // no explicit raw reader ??
91
92 if (isEnabled(OutputType::Cells)) {
93 specs.emplace_back(o2::phos::reco_workflow::getRawToCellConverterSpec(static_cast<unsigned int>(flpId)));
94 if (!disableRootOut) {
95 specs.emplace_back(o2::phos::getCellWriterSpec(false));
96 }
97 }
98 if (isEnabled(OutputType::Clusters)) {
99 specs.emplace_back(o2::phos::reco_workflow::getRawToCellConverterSpec(static_cast<unsigned int>(flpId)));
100 specs.emplace_back(o2::phos::reco_workflow::getCellClusterizerSpec(false, fullCluOut, defBadMap, skipL1phase)); // no MC propagation
101 if (!disableRootOut) {
102 specs.emplace_back(o2::phos::getClusterWriterSpec(false));
103 }
104 }
105 }
106
107 // Digits to ....
108 if (inputType == InputType::Digits) {
109 if (!disableRootInp) {
110 // specs.emplace_back(o2::phos::getDigitsReaderSpec(propagateMC));
111 specs.emplace_back(o2::phos::getPHOSDigitReaderSpec(propagateMC));
112 }
113 if (isEnabled(OutputType::Cells)) {
114 // add converter for cells
115 specs.emplace_back(o2::phos::reco_workflow::getCellConverterSpec(propagateMC, defBadMap));
116 if (!disableRootOut) {
117 specs.emplace_back(o2::phos::getCellWriterSpec(propagateMC));
118 }
119 } else {
120 if (isEnabled(OutputType::Clusters)) {
121 specs.emplace_back(o2::phos::reco_workflow::getClusterizerSpec(propagateMC, fullCluOut, defBadMap));
122 if (!disableRootOut) {
123 specs.emplace_back(o2::phos::getClusterWriterSpec(propagateMC));
124 }
125 }
126 }
127 }
128
129 // Cells to
130 if (inputType == InputType::Cells) {
131 if (!disableRootInp) {
132 // specs.emplace_back(o2::phos::getCellReaderSpec(propagateMC));
133 specs.emplace_back(o2::phos::getPHOSCellReaderSpec(propagateMC));
134 }
135 if (isEnabled(OutputType::Clusters)) {
136 // add clusterizer
137 specs.emplace_back(o2::phos::reco_workflow::getCellClusterizerSpec(propagateMC, fullCluOut, defBadMap, skipL1phase));
138 if (!disableRootOut) {
139 specs.emplace_back(o2::phos::getClusterWriterSpec(propagateMC));
140 }
141 }
142 }
143
144 return specs;
145}
146
147} // namespace reco_workflow
148
149} // namespace phos
150
151} // namespace o2
Definition of a container to keep Monte Carlo truth external to simulation objects.
Configurable generator for RootTreeWriter processor spec.
Helper function to tokenize sequences and ranges of integral numbers.
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
std::vector< DataProcessorSpec > WorkflowSpec
const std::unordered_map< std::string, InputType > InputMap
framework::WorkflowSpec getWorkflow(bool disableRootInp, bool disableRootOut, bool propagateMC=true, std::string const &cfgInput="hits", std::string const &cfgOutput="clusters", bool fullCluOut=false, int flpId=0, bool defBadMap=false, bool skipL1phase=true)
create the workflow for PHOS reconstruction
framework::DataProcessorSpec getClusterizerSpec(bool propagateMC, bool fillFullClu, bool defBadMap=false)
Creating DataProcessorSpec for the PHOS Clusterizer Spec.
const std::unordered_map< std::string, OutputType > OutputMap
framework::DataProcessorSpec getRawToCellConverterSpec(unsigned int flpId)
Creating DataProcessorSpec for the PHOS Cell Converter Spec.
framework::DataProcessorSpec getCellClusterizerSpec(bool propagateMC, bool fillFullClu, bool defBadMap=false, bool skipL1phase=true)
InputType
define input and output types of the workflow
framework::DataProcessorSpec getCellConverterSpec(bool propagateMC, bool defBadMap)
Creating DataProcessorSpec for the PHOS Cell Converter Spec.
framework::DataProcessorSpec getPHOSDigitReaderSpec(bool useMC=true)
framework::DataProcessorSpec getClusterWriterSpec(bool useMC)
write PHOS clusters to ROOT file
framework::DataProcessorSpec getCellWriterSpec(bool useMC)
framework::DataProcessorSpec getPHOSCellReaderSpec(bool useMC=true)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...