Skip to content

Commit 7689f52

Browse files
committed
Enum for eventType bins
1 parent 73f1d5b commit 7689f52

1 file changed

Lines changed: 33 additions & 21 deletions

File tree

PWGLF/TableProducer/Strangeness/cascqaanalysis.cxx

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <TString.h>
5252

5353
#include <algorithm>
54+
#include <array>
5455
#include <cmath>
5556
#include <cstdint>
5657
#include <cstdlib>
@@ -76,6 +77,19 @@ struct Cascqaanalysis {
7677

7778
HistogramRegistry registry{"registry"};
7879

80+
enum EventTypeBin {
81+
kINEL = 0,
82+
kINELgt0,
83+
kINELgt1,
84+
kNEventTypeBins
85+
};
86+
87+
static constexpr std::array<std::pair<EventTypeBin, const char*>, kNEventTypeBins> EventTypeBinLabels{{
88+
{kINEL, "INEL"},
89+
{kINELgt0, "INEL>0"},
90+
{kINELgt1, "INEL>1"},
91+
}};
92+
7993
// Axes
8094
ConfigurableAxis ptAxis{"ptAxis", {200, 0.0f, 10.0f}, "#it{p}_{T} (GeV/#it{c})"};
8195
ConfigurableAxis rapidityAxis{"rapidityAxis", {200, -2.0f, 2.0f}, "y"};
@@ -85,7 +99,7 @@ struct Cascqaanalysis {
8599
ConfigurableAxis centFV0AAxis{"centFV0AAxis",
86100
{VARIABLE_WIDTH, 0., 0.01, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 105.5},
87101
"FV0A (%)"};
88-
ConfigurableAxis eventTypeAxis{"eventTypeAxis", {3, -0.5f, 2.5f}, "Event Type"};
102+
ConfigurableAxis eventTypeAxis{"eventTypeAxis", {kNEventTypeBins, -0.5f, static_cast<float>(kNEventTypeBins) - 0.5f}, "Event Type"};
89103

90104
ConfigurableAxis nAssocCollAxis{"nAssocCollAxis", {5, -0.5f, 4.5f}, "N_{assoc.}"};
91105
ConfigurableAxis nChargedFT0MGenAxis{"nChargedFT0MGenAxis", {300, 0, 300}, "N_{FT0M, gen.}"};
@@ -199,9 +213,8 @@ struct Cascqaanalysis {
199213
template <typename TAxisType>
200214
static void setEventTypeAxisLabels(TAxisType* axis)
201215
{
202-
const char* labels[] = {"INEL", "INEL>0", "INEL>1"};
203-
for (int i = 0; i < static_cast<int>(sizeof(labels) / sizeof(labels[0])); ++i) {
204-
axis->SetBinLabel(i + 1, labels[i]);
216+
for (const auto& [bin, label] : EventTypeBinLabels) {
217+
axis->SetBinLabel(static_cast<int>(bin) + 1, label);
205218
}
206219
}
207220

@@ -363,20 +376,19 @@ struct Cascqaanalysis {
363376
}
364377

365378
template <typename TCollision>
366-
int getEventTypeFlag(TCollision const& collision)
379+
EventTypeBin getEventTypeBin(TCollision const& collision)
367380
{
368-
// 0 - INEL, 1 - INEL>0, 2 - INEL>1
369-
int evFlag = 0;
381+
EventTypeBin evTypeBin = kINEL;
370382
registry.fill(HIST("hNEvents"), 11.5); // INEL
371383
if (collision.isInelGt0()) {
372-
evFlag += 1;
384+
evTypeBin = kINELgt0;
373385
registry.fill(HIST("hNEvents"), 12.5); // INEL>0
374386
}
375387
if (collision.isInelGt1()) {
376-
evFlag += 1;
388+
evTypeBin = kINELgt1;
377389
registry.fill(HIST("hNEvents"), 13.5); // INEL>1
378390
}
379-
return evFlag;
391+
return evTypeBin;
380392
}
381393

382394
template <typename TCollision>
@@ -480,7 +492,7 @@ struct Cascqaanalysis {
480492
return;
481493
}
482494

483-
int evType = getEventTypeFlag(collision);
495+
EventTypeBin evType = getEventTypeBin(collision);
484496

485497
auto tracksGroupedPVcontr = pvContribTracksIUEta1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache);
486498
int nTracksPVcontr = tracksGroupedPVcontr.size();
@@ -578,15 +590,15 @@ struct Cascqaanalysis {
578590
uint16_t nchFT0 = getGenNchInFT0Mregion(mcPartSlice);
579591
uint16_t nchFV0 = getGenNchInFV0Aregion(mcPartSlice);
580592

581-
int genEvType = 0;
593+
EventTypeBin genEvType = kINEL;
582594
if (pwglf::isINELgtNmc(mcPartSlice, 0, pdgDB)) {
583-
genEvType++;
595+
genEvType = kINELgt0;
584596
}
585597
if (pwglf::isINELgtNmc(mcPartSlice, 1, pdgDB)) {
586-
genEvType++;
598+
genEvType = kINELgt1;
587599
}
588600

589-
const int recoEvType = getEventTypeFlag(collision);
601+
const EventTypeBin recoEvType = getEventTypeBin(collision);
590602

591603
registry.fill(HIST("hCentFT0M_rec"), mcCollision.centFT0M(), recoEvType);
592604
registry.fill(HIST("hZCollisionRecVsGen"), collision.posZ(), mcCollision.posZ());
@@ -682,20 +694,20 @@ struct Cascqaanalysis {
682694
registry.fill(HIST("hNEventsMC"), 1.5);
683695

684696
// Define the type of generated MC collision
685-
int evType = 0;
697+
EventTypeBin evType = kINEL;
686698
uint8_t flagsGen = 0;
687699
flagsGen |= o2::aod::myMCcascades::EvFlags::EvINEL;
688700
registry.fill(HIST("hNEventsMC"), 2.5);
689701
// Generated collision is INEL>0
690702
if (pwglf::isINELgtNmc(mcParticles, 0, pdgDB)) {
691703
flagsGen |= o2::aod::myMCcascades::EvFlags::EvINELgt0;
692-
evType++;
704+
evType = kINELgt0;
693705
registry.fill(HIST("hNEventsMC"), 3.5);
694706
}
695707
// Generated collision is INEL>1
696708
if (pwglf::isINELgtNmc(mcParticles, 1, pdgDB)) {
697709
flagsGen |= o2::aod::myMCcascades::EvFlags::EvINELgt1;
698-
evType++;
710+
evType = kINELgt1;
699711
registry.fill(HIST("hNEventsMC"), 4.5);
700712
}
701713

@@ -751,15 +763,15 @@ struct Cascqaanalysis {
751763
const auto evtReconstructedAndINELgt1 = std::count_if(selectedEvents.begin(), selectedEvents.end(), isAssocToINELgt1);
752764

753765
switch (evType) {
754-
case 0: {
766+
case kINEL: {
755767
registry.fill(HIST("hNchFT0MNAssocMCCollisionsSameType"), nchFT0, evtReconstructedAndINEL, evType);
756768
break;
757769
}
758-
case 1: {
770+
case kINELgt0: {
759771
registry.fill(HIST("hNchFT0MNAssocMCCollisionsSameType"), nchFT0, evtReconstructedAndINELgt0, evType);
760772
break;
761773
}
762-
case 2: {
774+
case kINELgt1: {
763775
registry.fill(HIST("hNchFT0MNAssocMCCollisionsSameType"), nchFT0, evtReconstructedAndINELgt1, evType);
764776
break;
765777
}

0 commit comments

Comments
 (0)