Skip to content

Commit 28f7d5f

Browse files
authored
Refactor particle and estimator default arrays
1 parent d4a06da commit 28f7d5f

1 file changed

Lines changed: 95 additions & 97 deletions

File tree

PWGLF/Tasks/QC/mcParticlePrediction.cxx

Lines changed: 95 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -55,73 +55,72 @@ using namespace o2::framework;
5555
using namespace o2::pwglf;
5656

5757
// Particles
58-
static const std::vector<std::string> parameterNames{"Enable", "SelectPrimaries"};
59-
static constexpr int nParameters = 2;
60-
static const int defaultParticles[PIDExtended::NIDsTot][nParameters]{{0, 1}, // Electron
61-
{0, 1}, // Muon
62-
{0, 1}, // Pion
63-
{0, 1}, // Kaon
64-
{0, 1}, // Proton
65-
{0, 1}, // Deuteron
66-
{0, 1}, // Triton
67-
{0, 1}, // Helium3
68-
{0, 1}, // Alpha
69-
{0, 1}, // PI0
70-
{0, 1}, // Photon
71-
{1, 1}, // K0
72-
{0, 1}, // Lambda
73-
{0, 1}, // HyperTriton
74-
{0, 1}, // Hyperhydrog4
75-
{0, 1}, // XiMinus
76-
{0, 1}, // OmegaMinus
77-
{0, 1}, // HyperHelium4
78-
{0, 1}, // HyperHelium5
79-
{0, 1}, // Positron
80-
{0, 1}, // MuonPlus
81-
{0, 1}, // PionMinus
82-
{0, 1}, // KaonMinus
83-
{0, 1}, // AntiProton
84-
{0, 1}, // AntiDeuteron
85-
{0, 1}, // AntiTriton
86-
{0, 1}, // AntiHelium3
87-
{0, 1}, // AntiAlpha
88-
{0, 1}, // AntiLambda
89-
{0, 1}, // AntiHyperTriton
90-
{0, 1}, // AntiHyperhydrog4
91-
{0, 1}, // XiPlus
92-
{0, 1}, // OmegaPlus
93-
{0, 1}, // AntiHyperHelium4
94-
{0, 1}, // AntiHyperHelium5
95-
{0, 1}, // Neutron
96-
{0, 1}, // AntiNeutron
97-
{0, 0}, // Phi
98-
{0, 1}, // BZero
99-
{0, 1}, // BPlus
100-
{0, 1}, // BS
101-
{0, 1}, // D0
102-
{0, 1}, // DPlus
103-
{0, 1}, // DS
104-
{0, 1}, // DStar
105-
{0, 1}, // ChiC1
106-
{0, 1}, // JPsi
107-
{0, 1}, // LambdaB0
108-
{0, 1}, // LambdaCPlus
109-
{0, 1}, // OmegaC0
110-
{0, 1}, // SigmaC0
111-
{0, 1}, // SigmaCPlusPlus
112-
{0, 1}, // X3872
113-
{0, 1}, // Xi0
114-
{0, 1}, // XiB0
115-
{0, 1}, // XiCCPlusPlus
116-
{0, 1}, // XiCPlus
117-
{0, 1}, // XiC0
118-
{0, 0}, // Kstar
119-
{0, 0}, // KstarPM
120-
{0, 1}, // Kshort
121-
{0, 0}, // Xi1530
122-
{0, 0}}; // Lambda1520
123-
bool enabledParticlesArray[PIDExtended::NIDsTot];
124-
bool selectPrimariesArray[PIDExtended::NIDsTot];
58+
static constexpr std::array<std::array<int, 2>, PIDExtended::NIDsTot>
59+
defaultParticles{{{0, 1}, // Electron
60+
{0, 1}, // Muon
61+
{0, 1}, // Pion
62+
{0, 1}, // Kaon
63+
{0, 1}, // Proton
64+
{0, 1}, // Deuteron
65+
{0, 1}, // Triton
66+
{0, 1}, // Helium3
67+
{0, 1}, // Alpha
68+
{0, 1}, // PI0
69+
{0, 1}, // Photon
70+
{1, 1}, // K0
71+
{0, 1}, // Lambda
72+
{0, 1}, // HyperTriton
73+
{0, 1}, // Hyperhydrog4
74+
{0, 1}, // XiMinus
75+
{0, 1}, // OmegaMinus
76+
{0, 1}, // HyperHelium4
77+
{0, 1}, // HyperHelium5
78+
{0, 1}, // Positron
79+
{0, 1}, // MuonPlus
80+
{0, 1}, // PionMinus
81+
{0, 1}, // KaonMinus
82+
{0, 1}, // AntiProton
83+
{0, 1}, // AntiDeuteron
84+
{0, 1}, // AntiTriton
85+
{0, 1}, // AntiHelium3
86+
{0, 1}, // AntiAlpha
87+
{0, 1}, // AntiLambda
88+
{0, 1}, // AntiHyperTriton
89+
{0, 1}, // AntiHyperhydrog4
90+
{0, 1}, // XiPlus
91+
{0, 1}, // OmegaPlus
92+
{0, 1}, // AntiHyperHelium4
93+
{0, 1}, // AntiHyperHelium5
94+
{0, 1}, // Neutron
95+
{0, 1}, // AntiNeutron
96+
{0, 0}, // Phi
97+
{0, 1}, // BZero
98+
{0, 1}, // BPlus
99+
{0, 1}, // BS
100+
{0, 1}, // D0
101+
{0, 1}, // DPlus
102+
{0, 1}, // DS
103+
{0, 1}, // DStar
104+
{0, 1}, // ChiC1
105+
{0, 1}, // JPsi
106+
{0, 1}, // LambdaB0
107+
{0, 1}, // LambdaCPlus
108+
{0, 1}, // OmegaC0
109+
{0, 1}, // SigmaC0
110+
{0, 1}, // SigmaCPlusPlus
111+
{0, 1}, // X3872
112+
{0, 1}, // Xi0
113+
{0, 1}, // XiB0
114+
{0, 1}, // XiCCPlusPlus
115+
{0, 1}, // XiCPlus
116+
{0, 1}, // XiC0
117+
{0, 0}, // Kstar
118+
{0, 0}, // KstarPM
119+
{0, 1}, // Kshort
120+
{0, 0}, // Xi1530
121+
{0, 0}}}; // Lambda1520
122+
std::array<bool, PIDExtended::NIDsTot> enabledParticlesArray = {false};
123+
std::array<bool, PIDExtended::NIDsTot> selectPrimariesArray = {false};
125124

126125
// Estimators
127126
struct Estimators {
@@ -180,29 +179,28 @@ struct Estimators {
180179
return names;
181180
}
182181
};
183-
bool enabledEstimatorsArray[Estimators::nEstimators];
184-
static constexpr int nEstimatorParameters = 1;
185-
static const std::vector<std::string> parameterEstimatorNames{"Enable"};
186-
static const int defaultEstimators[Estimators::nEstimators][nEstimatorParameters]{{0}, // FT0A
187-
{0}, // FT0C
188-
{1}, // FT0AC
189-
{0}, // FV0A
190-
{0}, // FDDA
191-
{0}, // FDDC
192-
{0}, // FDDAC
193-
{0}, // ZNA
194-
{0}, // ZNC
195-
{0}, // ZEM1
196-
{0}, // ZEM2
197-
{0}, // ZPA
198-
{0}, // ZPC
199-
{0}, // ITSIB
200-
{0}, // ETA05
201-
{0}, // ETA08
202-
{0}, // V0A (Run2)
203-
{0}, // V0C (Run2)
204-
{0}, // V0AC (Run2 V0M)
205-
{0}}; // ImpactParamter
182+
std::array<bool, Estimators::nEstimators> enabledEstimatorsArray = {false};
183+
static constexpr std::array<std::array<int, 1>, Estimators::nEstimators>
184+
defaultEstimators{{{0}, // FT0A
185+
{0}, // FT0C
186+
{1}, // FT0AC
187+
{0}, // FV0A
188+
{0}, // FDDA
189+
{0}, // FDDC
190+
{0}, // FDDAC
191+
{0}, // ZNA
192+
{0}, // ZNC
193+
{0}, // ZEM1
194+
{0}, // ZEM2
195+
{0}, // ZPA
196+
{0}, // ZPC
197+
{0}, // ITSIB
198+
{0}, // ETA05
199+
{0}, // ETA08
200+
{0}, // V0A (Run2)
201+
{0}, // V0C (Run2)
202+
{0}, // V0AC (Run2 V0M)
203+
{0}}}; // ImpactParamter
206204

207205
// Histograms
208206
std::array<std::shared_ptr<TH1>, Estimators::nEstimators> hestimators;
@@ -255,10 +253,10 @@ struct McParticlePrediction {
255253
} cfgPrediction;
256254

257255
Configurable<LabeledArray<int>> enabledSpecies{"enabledSpecies",
258-
{defaultParticles[0], PIDExtended::NIDsTot, nParameters, PIDExtended::arrayNames(), parameterNames},
256+
{defaultParticles[0], PIDExtended::NIDsTot, defaultParticles[0].size(), PIDExtended::arrayNames(), {"Enable", "SelectPrimaries"}},
259257
"Particles enabled"};
260258
Configurable<LabeledArray<int>> enabledEstimators{"enabledEstimators",
261-
{defaultEstimators[0], Estimators::nEstimators, nEstimatorParameters, Estimators::arrayNames(), parameterEstimatorNames},
259+
{defaultEstimators[0], Estimators::nEstimators, defaultEstimators[0].size(), Estimators::arrayNames(), {"Enable"}},
262260
"Estimators enabled"};
263261
Configurable<bool> selectInelGt0{"selectInelGt0", true, "Select only inelastic events"};
264262
Configurable<bool> selectPrimariesForMultiplicity{"selectPrimariesForMultiplicity", true, "Select only primary particles for multiplicity computation"};
@@ -280,8 +278,8 @@ struct McParticlePrediction {
280278
Configurable<bool> enableVsImpactParameterHistograms{"enableVsImpactParameterHistograms", true, "Enables the correlation between impact parameter and other estimators"};
281279
Configurable<float> chargetolerance{"chargetolerance", 1e-3, "Tolerance to consider a particle as charged based on its charge"};
282280

283-
Service<o2::framework::O2DatabasePDG> pdgDB;
284-
o2::pwglf::ParticleCounter<o2::framework::O2DatabasePDG> mCounter;
281+
Service<o2::framework::O2DatabasePDG> pdgDB{};
282+
o2::pwglf::ParticleCounter<o2::framework::O2DatabasePDG> mCounter{};
285283

286284
void init(o2::framework::InitContext&)
287285
{
@@ -501,7 +499,7 @@ struct McParticlePrediction {
501499

502500
std::array<float, Estimators::nEstimators> genMult(const auto& mcCollision, const auto& mcParticles)
503501
{
504-
std::array<float, Estimators::nEstimators> nMult;
502+
std::array<float, Estimators::nEstimators> nMult = {0};
505503
if (enabledEstimatorsArray[Estimators::FT0A] || enabledEstimatorsArray[Estimators::FT0AC]) {
506504
nMult[Estimators::FT0A] = mCounter.countFT0A(mcParticles);
507505
}
@@ -816,7 +814,7 @@ struct McParticlePrediction {
816814

817815
const std::array<float, Estimators::nEstimators>& nMult = genMult(mcCollision, particlesInCollision);
818816

819-
float nMultReco[Estimators::nEstimators];
817+
std::array<float, Estimators::nEstimators> nMultReco = {0};
820818
nMultReco[Estimators::FT0A] = collision.multFT0A();
821819
nMultReco[Estimators::FT0C] = collision.multFT0C();
822820
nMultReco[Estimators::FT0AC] = collision.multFT0M();
@@ -828,7 +826,7 @@ struct McParticlePrediction {
828826
nMultReco[Estimators::ZNC] = collision.multZNC();
829827
nMultReco[Estimators::ITSIB] = collision.multNTracksPV();
830828

831-
float nMultRecoMCBC[Estimators::nEstimators] = {0};
829+
std::array<float, Estimators::nEstimators> nMultRecoMCBC = {0};
832830
if (mcBC.has_ft0()) {
833831
const auto& ft0 = mcBC.ft0();
834832
for (const auto& amplitude : ft0.amplitudeA()) {

0 commit comments

Comments
 (0)