Skip to content

Commit 0fd7d0a

Browse files
Refactor processSwitches initialization and template parameters
1 parent c37cf9d commit 0fd7d0a

1 file changed

Lines changed: 18 additions & 33 deletions

File tree

‎PWGHF/HFC/TableProducer/producerCharmHadronsCharmFemtoDream.cxx‎

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,7 @@ struct HfProducerCharmHadronsCharmFemtoDream {
162162

163163
void init(InitContext const&)
164164
{
165-
const std::array<bool, 8> processSwitches{
166-
static_cast<bool>(doprocessD0D0),
167-
static_cast<bool>(doprocessD0Dstar),
168-
static_cast<bool>(doprocessD0D0Ml),
169-
static_cast<bool>(doprocessD0DstarMl),
170-
static_cast<bool>(doprocessD0D0WithFT0C),
171-
static_cast<bool>(doprocessD0DstarWithFT0C),
172-
static_cast<bool>(doprocessD0D0MlWithFT0C),
173-
static_cast<bool>(doprocessD0DstarMlWithFT0C)};
165+
const std::array<bool, 8> processSwitches{doprocessD0D0, doprocessD0Dstar, doprocessD0D0Ml, doprocessD0DstarMl, doprocessD0D0WithFT0C, doprocessD0DstarWithFT0C, doprocessD0D0MlWithFT0C, doprocessD0DstarMlWithFT0C};
174166
if (std::count(processSwitches.begin(), processSwitches.end(), true) != 1) {
175167
LOGP(fatal, "Enable exactly one charm-charm producer process");
176168
}
@@ -192,9 +184,8 @@ struct HfProducerCharmHadronsCharmFemtoDream {
192184
registry.add("candidates", "Candidates", kTH1F, {candidateSpecies});
193185
}
194186

195-
template <o2::hf_centrality::CentralityEstimator CentEstimator,
196-
typename Collision>
197-
bool acceptCollision(Collision const& col)
187+
template <o2::hf_centrality::CentralityEstimator CentEstimator, typename CollType>
188+
bool acceptCollision(CollType const& col)
198189
{
199190
registry.fill(HIST("events"), 0);
200191
float cent = -1.f; // No centrality for pp MB.
@@ -232,8 +223,8 @@ struct HfProducerCharmHadronsCharmFemtoDream {
232223
return {scores[0], scores[1], scores[2]};
233224
}
234225

235-
template <bool WithMl, typename Collision, typename Candidates>
236-
void fillD0(Collision const& col, Candidates const& candidates)
226+
template <bool WithMl, typename CollType, typename CandsType>
227+
void fillD0(CollType const& col, CandsType const& candidates)
237228
{
238229
const auto timestamp = col.template bc_as<aod::BCsWithTimestamps>().timestamp();
239230
for (const auto& cand : candidates) {
@@ -242,15 +233,13 @@ struct HfProducerCharmHadronsCharmFemtoDream {
242233
// The OR filter accepts the row if either hypothesis passes. Write only
243234
// the passing hypotheses, each with its own flavour and ML scores.
244235
for (int hypothesis = 0; hypothesis < ND0Hypotheses; ++hypothesis) {
245-
if ((hypothesis == 0 ? cand.isSelD0() : cand.isSelD0bar()) <
246-
selectionFlagD0) {
236+
if ((hypothesis == 0 ? cand.isSelD0() : cand.isSelD0bar()) < selectionFlagD0) {
247237
continue;
248238
}
249239
std::array<float, 3> scores{-1.f, -1.f, -1.f};
250240
if constexpr (WithMl) {
251241
if (mlD0.applyMlMode != NoMl) {
252-
scores = hypothesis == 0 ? readScores(cand.mlProbD0())
253-
: readScores(cand.mlProbD0bar());
242+
scores = hypothesis == 0 ? readScores(cand.mlProbD0()) : readScores(cand.mlProbD0bar());
254243
}
255244
if (mlD0.applyMlMode == FillMlFromNewBDT) {
256245
// Do not call the ML response with an out-of-range model index.
@@ -266,18 +255,15 @@ struct HfProducerCharmHadronsCharmFemtoDream {
266255
scores = readScores(output);
267256
}
268257
}
269-
d0Rows(collisions.lastIndex(), timestamp, hypothesis == 0 ? 1 : -1,
270-
p0.globalIndex(), p1.globalIndex(), p0.pt(), p1.pt(), p0.eta(),
271-
p1.eta(), p0.phi(), p1.phi(), 1 << hypothesis, scores[0],
272-
scores[1], scores[2]);
258+
d0Rows(collisions.lastIndex(), timestamp, hypothesis == 0 ? 1 : -1, p0.globalIndex(), p1.globalIndex(), p0.pt(), p1.pt(), p0.eta(), p1.eta(), p0.phi(), p1.phi(), 1 << hypothesis, scores[0], scores[1], scores[2]);
273259
hasD0 = true;
274260
registry.fill(HIST("candidates"), hypothesis);
275261
}
276262
}
277263
}
278264

279-
template <bool WithMl, typename Collision, typename Candidates>
280-
void fillDstar(Collision const& col, Candidates const& candidates)
265+
template <bool WithMl, typename CollType, typename CandsType>
266+
void fillDstar(CollType const& col, CandsType const& candidates)
281267
{
282268
const auto timestamp = col.template bc_as<aod::BCsWithTimestamps>().timestamp();
283269
for (const auto& cand : candidates) {
@@ -302,17 +288,15 @@ struct HfProducerCharmHadronsCharmFemtoDream {
302288
scores = readScores(output);
303289
}
304290
}
305-
dstarRows(collisions.lastIndex(), timestamp, soft.sign(),
306-
p0.globalIndex(), p1.globalIndex(), soft.globalIndex(), p0.pt(),
307-
p1.pt(), soft.pt(), p0.eta(), p1.eta(), soft.eta(), p0.phi(),
308-
p1.phi(), soft.phi(), 1, scores[0], scores[1], scores[2]);
291+
dstarRows(collisions.lastIndex(), timestamp, soft.sign(), p0.globalIndex(), p1.globalIndex(), soft.globalIndex(), p0.pt(), p1.pt(), soft.pt(), p0.eta(), p1.eta(), soft.eta(), p0.phi(), p1.phi(), soft.phi(), 1, scores[0], scores[1], scores[2]);
309292
hasDstar = true;
310293
registry.fill(HIST("candidates"), soft.sign() > 0 ? 2 : 3);
311294
}
312295
}
313296

314297
void processD0D0(Collisions::iterator const& col,
315-
aod::BCsWithTimestamps const&, aod::Tracks const&,
298+
aod::BCsWithTimestamps const&,
299+
aod::Tracks const&,
316300
soa::Filtered<D0s> const& d0s)
317301
{
318302
if (acceptCollision<o2::hf_centrality::CentralityEstimator::None>(col)) {
@@ -323,7 +307,8 @@ struct HfProducerCharmHadronsCharmFemtoDream {
323307
PROCESS_SWITCH(HfProducerCharmHadronsCharmFemtoDream, processD0D0, "D0 only, data", true);
324308

325309
void processD0Dstar(Collisions::iterator const& col,
326-
aod::BCsWithTimestamps const&, aod::Tracks const&,
310+
aod::BCsWithTimestamps const&,
311+
aod::Tracks const&,
327312
soa::Filtered<D0s> const& d0s,
328313
soa::Filtered<Dstars> const& dstars)
329314
{
@@ -336,7 +321,8 @@ struct HfProducerCharmHadronsCharmFemtoDream {
336321
PROCESS_SWITCH(HfProducerCharmHadronsCharmFemtoDream, processD0Dstar, "D0 and Dstar, data", false);
337322

338323
void processD0D0Ml(Collisions::iterator const& col,
339-
aod::BCsWithTimestamps const&, aod::Tracks const&,
324+
aod::BCsWithTimestamps const&,
325+
aod::Tracks const&,
340326
soa::Filtered<D0sMl> const& d0s)
341327
{
342328
if (acceptCollision<o2::hf_centrality::CentralityEstimator::None>(col)) {
@@ -415,6 +401,5 @@ struct HfProducerCharmHadronsCharmFemtoDream {
415401

416402
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
417403
{
418-
return WorkflowSpec{
419-
adaptAnalysisTask<HfProducerCharmHadronsCharmFemtoDream>(cfgc)};
404+
return WorkflowSpec{adaptAnalysisTask<HfProducerCharmHadronsCharmFemtoDream>(cfgc)};
420405
}

0 commit comments

Comments
 (0)