@@ -51,60 +51,89 @@ enum ColHist {
5151 kCentVsMult ,
5252 kCentVsSphericity ,
5353 kMultVsSphericity ,
54+ // mc
55+ kMcCent ,
56+ kMcMult ,
5457 kColHistLast
5558};
5659
5760constexpr std::string_view ColAnalysisDir = " Collisions/Analysis/" ;
5861constexpr std::string_view ColQaDir = " Collisions/QA/" ;
62+ constexpr std::string_view ColMcDir = " Collisions/MC/" ;
5963
6064constexpr std::array<histmanager::HistInfo<ColHist>, kColHistLast > HistTable = {
6165 {
6266 {kPosZ , o2::framework::kTH1F , " hPosZ" , " Vertex Z; V_{Z} (cm); Entries" },
6367 {kMult , o2::framework::kTH1F , " hMult" , " Multiplicity; Multiplicity; Entries" },
6468 {kCent , o2::framework::kTH1F , " hCent" , " Centrality; Centrality (%); Entries" },
6569 {kMagField , o2::framework::kTH1F , " hMagField" , " Magnetic Field; B (kG); Entries" },
70+ // qa
6671 {kPosX , o2::framework::kTH1F , " hPosX" , " Vertex X; V_{X} (cm); Entries" },
67- {kPosY , o2::framework::kTH1F , " hPosY" , " Vertex Z ; V_{Y} (cm); Entries" },
72+ {kPosY , o2::framework::kTH1F , " hPosY" , " Vertex Y ; V_{Y} (cm); Entries" },
6873 {kPos , o2::framework::kTH1F , " hPos" , " Primary vertex; V_{pos} (cm); Entries" },
6974 {kSphericity , o2::framework::kTH1F , " hSphericity" , " Sphericity; Sphericity; Entries" },
7075 {kOccupancy , o2::framework::kTH1F , " hOccupancy" , " Occupancy; Occupancy; Entries" },
76+ // 2d
7177 {kPoszVsMult , o2::framework::kTH2F , " hPoszVsMult" , " Vertex Z vs Multiplicity; V_{Z} (cm); Multiplicity" },
7278 {kPoszVsCent , o2::framework::kTH2F , " hPoszVsCent" , " Vertex Z vs Centrality; V_{Z} (cm); Centrality (%)" },
7379 {kCentVsMult , o2::framework::kTH2F , " hCentVsMult" , " Centrality vs Multiplicity; Centrality (%); Multiplicity" },
7480 {kMultVsSphericity , o2::framework::kTH2F , " hMultVsSphericity" , " Multiplicity vs Sphericity; Multiplicity; Sphericity" },
7581 {kCentVsSphericity , o2::framework::kTH2F , " hCentVsSphericity" , " Centrality vs Sphericity; Centrality (%); Sphericity" },
82+ // mc
83+ {kMcCent , o2::framework::kTH1F , " hMcCent" , " Monte Carlo Centrality; Centrality (%); Entries" },
84+ {kMcMult , o2::framework::kTH1F , " hMcMult" , " Monte Carlo Multiplicity; Multiplicity; Entries" },
7685 }};
7786
87+ #define COL_HIST_ANALYSIS_MAP (conf ) \
88+ {kPosZ , {conf.vtxZ }}, \
89+ {kMult , {conf.mult }}, \
90+ {kCent , {conf.cent }}, \
91+ {kMagField , {conf.magField }},
92+
93+ #define COL_HIST_QA_MAP (confAnalysis, confQa ) \
94+ {kPosX , {confQa.vtxXY }}, \
95+ {kPosY , {confQa.vtxXY }}, \
96+ {kPos , {confQa.vtx }}, \
97+ {kSphericity , {confQa.sphericity }}, \
98+ {kOccupancy , {confQa.occupancy }}, \
99+ {kPoszVsMult , {confAnalysis.vtxZ , confAnalysis.mult }}, \
100+ {kPoszVsCent , {confAnalysis.vtxZ , confAnalysis.cent }}, \
101+ {kCentVsMult , {confAnalysis.cent , confAnalysis.mult }}, \
102+ {kMultVsSphericity , {confAnalysis.mult , confQa.sphericity }}, \
103+ {kCentVsSphericity , {confBinningAnalysis.cent , confQa.sphericity }},
104+
105+ #define COL_HIST_MC_QA_MAP (conf ) \
106+ {kMcMult , {conf.mult }}, \
107+ {kMcCent , {conf.cent }},
108+
78109template <typename T>
79110auto makeColHistSpecMap (const T& confBinningAnalysis)
80111{
81112 return std::map<ColHist, std::vector<framework::AxisSpec>>{
82- {kPosZ , {confBinningAnalysis.vtxZ }},
83- {kMult , {confBinningAnalysis.mult }},
84- {kCent , {confBinningAnalysis.cent }},
85- {kMagField , {confBinningAnalysis.magField }}};
113+ COL_HIST_ANALYSIS_MAP (confBinningAnalysis)};
86114}
87115
88116template <typename T1, typename T2>
89117auto makeColQaHistSpecMap (const T1& confBinningAnalysis, const T2& confBinningQa)
90118{
91119 return std::map<ColHist, std::vector<framework::AxisSpec>>{
92- {kPosZ , {confBinningAnalysis.vtxZ }},
93- {kMult , {confBinningAnalysis.mult }},
94- {kCent , {confBinningAnalysis.cent }},
95- {kMagField , {confBinningAnalysis.magField }},
96- {kPosX , {confBinningQa.vtxXY }},
97- {kPosY , {confBinningQa.vtxXY }},
98- {kPos , {confBinningQa.vtx }},
99- {kSphericity , {confBinningQa.sphericity }},
100- {kOccupancy , {confBinningQa.occupancy }},
101- {kPoszVsMult , {confBinningAnalysis.vtxZ , confBinningAnalysis.mult }},
102- {kPoszVsCent , {confBinningAnalysis.vtxZ , confBinningAnalysis.cent }},
103- {kCentVsMult , {confBinningAnalysis.cent , confBinningAnalysis.mult }},
104- {kMultVsSphericity , {confBinningAnalysis.mult , confBinningQa.sphericity }},
105- {kCentVsSphericity , {confBinningAnalysis.cent , confBinningQa.sphericity }}};
120+ COL_HIST_ANALYSIS_MAP (confBinningAnalysis)
121+ COL_HIST_QA_MAP (confBinningAnalysis, confBinningQa)};
122+ }
123+
124+ template <typename T1, typename T2>
125+ auto makeColMcQaHistSpecMap (const T1& confBinningAnalysis, const T2& confBinningQa)
126+ {
127+ return std::map<ColHist, std::vector<framework::AxisSpec>>{
128+ COL_HIST_ANALYSIS_MAP (confBinningAnalysis)
129+ COL_HIST_QA_MAP (confBinningAnalysis, confBinningQa)
130+ COL_HIST_MC_QA_MAP (confBinningAnalysis)};
106131}
107132
133+ #undef COL_HIST_ANALYSIS_MAP
134+ #undef COL_HIST_QA_MAP
135+ #undef COL_HIST_MC_QA_MAP
136+
108137struct ConfCollisionBinning : o2::framework::ConfigurableGroup {
109138 std::string prefix = std::string(" CollisionBinning" );
110139 o2::framework::ConfigurableAxis vtxZ{" vtxZ" , {200 , -10 , 10 }, " Vertex Z binning" };
@@ -122,14 +151,13 @@ struct ConfCollisionQaBinning : o2::framework::ConfigurableGroup {
122151 o2::framework::ConfigurableAxis occupancy{" occupancy" , {500 , 0 .f , 5000 .f }, " Spericity Binning" };
123152};
124153
125- template <modes::Mode mode>
126154class CollisionHistManager
127155{
128156 public:
129157 CollisionHistManager () = default ;
130158 ~CollisionHistManager () = default ;
131- // / Initializes histograms for the task
132- // / \param registry Histogram registry to be passed
159+
160+ template <modes::Mode mode>
133161 void init (o2::framework::HistogramRegistry* registry, std::map<ColHist, std::vector<o2::framework::AxisSpec>> const & Specs)
134162 {
135163 mHistogramRegistry = registry;
@@ -139,6 +167,9 @@ class CollisionHistManager
139167 if constexpr (isFlagSet (mode, modes::Mode::kQa )) {
140168 initQa (Specs);
141169 }
170+ if constexpr (isFlagSet (mode, modes::Mode::kMc )) {
171+ initMc (Specs);
172+ }
142173 }
143174
144175 template <typename T>
@@ -147,14 +178,14 @@ class CollisionHistManager
147178 mPlot2d = ConfBinningQa.plot2d .value ;
148179 }
149180
150- template <typename T>
181+ template <modes::Mode mode, typename T>
151182 void init (o2::framework::HistogramRegistry* registry, std::map<ColHist, std::vector<o2::framework::AxisSpec>> const & Specs, T const & ConfBinningQa)
152183 {
153184 enableOptionalHistograms (ConfBinningQa);
154- init (registry, Specs);
185+ this -> template init <mode> (registry, Specs);
155186 }
156187
157- template <typename T>
188+ template <modes::Mode mode, typename T>
158189 void fill (T const & col)
159190 {
160191 if constexpr (isFlagSet (mode, modes::Mode::kAnalysis )) {
@@ -165,6 +196,20 @@ class CollisionHistManager
165196 }
166197 }
167198
199+ template <modes::Mode mode, typename T1, typename T2>
200+ void fill (T1 const & col, T2 const & mcCols)
201+ {
202+ if constexpr (isFlagSet (mode, modes::Mode::kAnalysis )) {
203+ fillAnalysis (col);
204+ }
205+ if constexpr (isFlagSet (mode, modes::Mode::kQa )) {
206+ fillQa (col);
207+ }
208+ if constexpr (isFlagSet (mode, modes::Mode::kMc )) {
209+ fillMc (col, mcCols);
210+ }
211+ }
212+
168213 private:
169214 void initAnalysis (std::map<ColHist, std::vector<o2::framework::AxisSpec>> const & Specs)
170215 {
@@ -192,6 +237,13 @@ class CollisionHistManager
192237 }
193238 }
194239
240+ void initMc (std::map<ColHist, std::vector<o2::framework::AxisSpec>> const & Specs)
241+ {
242+ std::string mcDir = std::string (ColMcDir);
243+ mHistogramRegistry ->add (mcDir + getHistNameV2 (kMcMult , HistTable), getHistDesc (kMcMult , HistTable), getHistType (kMcMult , HistTable), {Specs.at (kMcMult )});
244+ mHistogramRegistry ->add (mcDir + getHistNameV2 (kMcCent , HistTable), getHistDesc (kMcCent , HistTable), getHistType (kMcCent , HistTable), {Specs.at (kMcCent )});
245+ }
246+
195247 template <typename T>
196248 void fillAnalysis (T const & col)
197249 {
@@ -218,6 +270,14 @@ class CollisionHistManager
218270 }
219271 }
220272
273+ template <typename T1, typename T2>
274+ void fillMc (T1 const & col, T2 const & /* mcCols*/ )
275+ {
276+ auto genCol = col.template fMcCol_as <T2>();
277+ mHistogramRegistry ->fill (HIST (ColMcDir) + HIST (getHistName (kMcMult , HistTable)), genCol.multMc ());
278+ mHistogramRegistry ->fill (HIST (ColMcDir) + HIST (getHistName (kMcCent , HistTable)), genCol.centMc ());
279+ }
280+
221281 o2::framework::HistogramRegistry* mHistogramRegistry = nullptr ;
222282 bool mPlot2d = true ;
223283}; // namespace femtounitedcolhistmanager
0 commit comments