Skip to content

Commit e98a378

Browse files
author
Lucia Anna Tarasovicova
committed
using variables instead of hardcoded numbers
1 parent 5f88348 commit e98a378

File tree

1 file changed

+46
-45
lines changed

1 file changed

+46
-45
lines changed

ALICE3/TableProducer/OTF/onTheFlyTracker.cxx

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,10 @@ struct OnTheFlyTracker {
195195
o2::fastsim::FastTracker fastPrimaryTracker;
196196

197197
// V0 names for filling histograms
198-
static constexpr std::string_view kV0names[] = {"K0", "Lambda", "AntiLambda"};
199-
static constexpr std::string_view index[] = {"0", "1", "2", "3"};
198+
static constexpr int NtypesV0 = 3;
199+
static constexpr std::string_view NameV0s[NtypesV0] = {"K0", "Lambda", "AntiLambda"};
200+
static constexpr int NtypesDetectors = 4;
201+
static constexpr std::string_view NameDetectors[NtypesDetectors] = {"0", "1", "2", "3"};
200202

201203
// Class to hold the track information for the O2 vertexing
202204
class TrackAlice3 : public o2::track::TrackParCov
@@ -816,14 +818,13 @@ struct OnTheFlyTracker {
816818
histos.fill(HIST("hGenPrFromLa"), laDecayRadius2D, decayProducts[2].Pt());
817819
}
818820
if (v0DecaySettings.doV0QA && isV0) {
819-
static_for<0, 11>([&](auto i) {
820-
constexpr int Index = i.value / 4;
821-
constexpr int IndexCnfg = i.value % 4;
822-
if (pdg == v0PDGs[Index] && icfg == IndexCnfg) {
823-
824-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/") + HIST(kV0names[Index]) + HIST("/hGen"), v0DecayRadius2D, mcParticle.pt());
825-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/") + HIST(kV0names[Index]) + HIST("/hGenNegDaughterFromV0"), v0DecayRadius2D, v0DecayProducts[0].Pt());
826-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/") + HIST(kV0names[Index]) + HIST("/hGenPosDaughterFromV0"), v0DecayRadius2D, v0DecayProducts[1].Pt());
821+
static_for<0, NtypesV0 * NtypesDetectors - 1>([&](auto i) {
822+
constexpr int IndexV0 = i.value / NtypesDetectors;
823+
constexpr int IndexDetector = i.value % NtypesDetectors;
824+
if (pdg == v0PDGs[IndexV0] && icfg == IndexDetector) {
825+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/") + HIST(NameV0s[IndexV0]) + HIST("/hGen"), v0DecayRadius2D, mcParticle.pt());
826+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/") + HIST(NameV0s[IndexV0]) + HIST("/hGenNegDaughterFromV0"), v0DecayRadius2D, v0DecayProducts[0].Pt());
827+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/") + HIST(NameV0s[IndexV0]) + HIST("/hGenPosDaughterFromV0"), v0DecayRadius2D, v0DecayProducts[1].Pt());
827828
}
828829
});
829830
}
@@ -1116,10 +1117,10 @@ struct OnTheFlyTracker {
11161117
std::vector<int> nV0TPCHits(kv0Prongs); // TPC type
11171118
if (v0DecaySettings.decayV0 && isV0) {
11181119
if (v0DecaySettings.doV0QA) {
1119-
static_for<0, 3>([&](auto j) {
1120-
constexpr int IndexCnfg = j.value;
1121-
if (icfg == IndexCnfg) {
1122-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/hV0Building"), 0.0f);
1120+
static_for<0, NtypesDetectors - 1>([&](auto j) {
1121+
constexpr int IndexDetector = j.value;
1122+
if (icfg == IndexDetector) {
1123+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/hV0Building"), 0.0f);
11231124
}
11241125
});
11251126
}
@@ -1144,10 +1145,10 @@ struct OnTheFlyTracker {
11441145
nV0TPCHits[i] = fastTracker[icfg]->GetNGasPoints();
11451146

11461147
if (nV0Hits[i] < 0) { // QA
1147-
static_for<0, 3>([&](auto j) {
1148-
constexpr int IndexCnfg = j.value;
1149-
if (icfg == IndexCnfg) {
1150-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/hFastTrackerQA"), o2::math_utils::abs(nV0Hits[i]));
1148+
static_for<0, NtypesDetectors - 1>([&](auto j) {
1149+
constexpr int IndexDetector = j.value;
1150+
if (icfg == IndexDetector) {
1151+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/hFastTrackerQA"), o2::math_utils::abs(nV0Hits[i]));
11511152
}
11521153
});
11531154
}
@@ -1158,10 +1159,10 @@ struct OnTheFlyTracker {
11581159
continue; // extra sure
11591160
}
11601161
for (uint32_t ih = 0; ih < fastTracker[icfg]->GetNHits(); ih++) {
1161-
static_for<0, 3>([&](auto j) {
1162-
constexpr int IndexCnfg = j.value;
1163-
if (icfg == IndexCnfg) {
1164-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/hFastTrackerHits"), fastTracker[icfg]->GetHitZ(ih), std::hypot(fastTracker[icfg]->GetHitX(ih), fastTracker[icfg]->GetHitY(ih)));
1162+
static_for<0, NtypesDetectors - 1>([&](auto j) {
1163+
constexpr int IndexDetector = j.value;
1164+
if (icfg == IndexDetector) {
1165+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/hFastTrackerHits"), fastTracker[icfg]->GetHitZ(ih), std::hypot(fastTracker[icfg]->GetHitX(ih), fastTracker[icfg]->GetHitY(ih)));
11651166
}
11661167
});
11671168
}
@@ -1182,18 +1183,18 @@ struct OnTheFlyTracker {
11821183
}
11831184
}
11841185
if (v0DecaySettings.doV0QA) {
1185-
static_for<0, 11>([&](auto i) {
1186-
constexpr int Index = i.value / 4;
1187-
constexpr int IndexCnfg = i.value % 4;
1188-
if (pdg == v0PDGs[Index] && icfg == IndexCnfg) {
1186+
static_for<0, NtypesV0 * NtypesDetectors - 1>([&](auto i) {
1187+
constexpr int IndexV0 = i.value / NtypesDetectors;
1188+
constexpr int IndexDetector = i.value % NtypesDetectors;
1189+
if (pdg == v0PDGs[IndexV0] && icfg == IndexDetector) {
11891190
if (isReco[0] && isReco[1]) {
1190-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/hV0Building"), 1.0f);
1191-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/") + HIST(kV0names[Index]) + HIST("/hReco"), v0DecayRadius2D, mcParticle.pt());
1191+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/hV0Building"), 1.0f);
1192+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/") + HIST(NameV0s[IndexV0]) + HIST("/hReco"), v0DecayRadius2D, mcParticle.pt());
11921193
}
11931194
if (isReco[0])
1194-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/") + HIST(kV0names[Index]) + HIST("/hRecoNegDaughterFromV0"), v0DecayRadius2D, v0DecayProducts[0].Pt());
1195+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/") + HIST(NameV0s[IndexV0]) + HIST("/hRecoNegDaughterFromV0"), v0DecayRadius2D, v0DecayProducts[0].Pt());
11951196
if (isReco[1])
1196-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/") + HIST(kV0names[Index]) + HIST("/hRecoPosDaughterFromV0"), v0DecayRadius2D, v0DecayProducts[1].Pt());
1197+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/") + HIST(NameV0s[IndexV0]) + HIST("/hRecoPosDaughterFromV0"), v0DecayRadius2D, v0DecayProducts[1].Pt());
11971198
}
11981199
});
11991200
}
@@ -1203,10 +1204,10 @@ struct OnTheFlyTracker {
12031204
// V0 building starts here
12041205
if (v0DecaySettings.findV0 && isReco[0] && isReco[1]) {
12051206
if (v0DecaySettings.doV0QA) {
1206-
static_for<0, 3>([&](auto j) {
1207-
constexpr int IndexCnfg = j.value;
1208-
if (icfg == IndexCnfg) {
1209-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/hV0Building"), 2.0f);
1207+
static_for<0, NtypesDetectors - 1>([&](auto j) {
1208+
constexpr int IndexDetector = j.value;
1209+
if (icfg == IndexDetector) {
1210+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/hV0Building"), 2.0f);
12101211
}
12111212
});
12121213
}
@@ -1232,10 +1233,10 @@ struct OnTheFlyTracker {
12321233
// V0 found successfully
12331234
if (dcaFitterOK_V0) {
12341235
if (v0DecaySettings.doV0QA) {
1235-
static_for<0, 3>([&](auto j) {
1236-
constexpr int IndexCnfg = j.value;
1237-
if (icfg == IndexCnfg) {
1238-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/hV0Building"), 3.0f);
1236+
static_for<0, NtypesDetectors - 1>([&](auto j) {
1237+
constexpr int IndexDetector = j.value;
1238+
if (icfg == IndexDetector) {
1239+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/hV0Building"), 3.0f);
12391240
}
12401241
});
12411242
}
@@ -1293,13 +1294,13 @@ struct OnTheFlyTracker {
12931294
}
12941295

12951296
if (v0DecaySettings.doV0QA) {
1296-
static_for<0, 3>([&](auto j) {
1297-
constexpr int IndexCnfg = j.value;
1298-
if (icfg == IndexCnfg) {
1299-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/hV0Building"), 4.0f);
1300-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/K0/hMass"), thisV0.mK0, thisV0.pt);
1301-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/Lambda/hMass"), thisV0.mLambda, thisV0.pt);
1302-
histos.fill(HIST("V0Building_Configuration_") + HIST(index[IndexCnfg]) + HIST("/AntiLambda/hMass"), thisV0.mAntiLambda, thisV0.pt);
1297+
static_for<0, NtypesDetectors - 1>([&](auto j) {
1298+
constexpr int IndexDetector = j.value;
1299+
if (icfg == IndexDetector) {
1300+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/hV0Building"), 4.0f);
1301+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/K0/hMass"), thisV0.mK0, thisV0.pt);
1302+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/Lambda/hMass"), thisV0.mLambda, thisV0.pt);
1303+
histos.fill(HIST("V0Building_Configuration_") + HIST(NameDetectors[IndexDetector]) + HIST("/AntiLambda/hMass"), thisV0.mAntiLambda, thisV0.pt);
13031304
}
13041305
});
13051306
}

0 commit comments

Comments
 (0)