Skip to content

Commit 1e64c7f

Browse files
Preet PatiPreet Pati
authored andcommitted
Fix on cpp-check errors related to Labelled arrays
1 parent 919cc6d commit 1e64c7f

1 file changed

Lines changed: 47 additions & 28 deletions

File tree

PWGCF/TwoParticleCorrelations/Tasks/corrReso.cxx

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ using namespace constants::math;
6868

6969
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, (DEFAULT), (HELP)}; // NOLINT(bugprone-macro-parentheses)
7070

71+
template <typename T, typename P>
72+
auto readMatrix(Array2D<T> const& mat, P& array)
73+
{
74+
for (auto i = 0; i < static_cast<int>(mat.rows); ++i) {
75+
for (auto j = 0; j < static_cast<int>(mat.cols); ++j) {
76+
array[i][j] = mat(i, j);
77+
}
78+
}
79+
80+
return;
81+
}
82+
7183
static constexpr std::array<std::array<float, 3>, 20> LongArrayFloat = {{{{1.1, 2.1, 3.1}}, {{1.2, 2.2, 3.2}}, {{1.3, 2.3, 3.3}}, {{-1.1, -2.1, -3.1}}, {{-1.2, -2.2, -3.2}}, {{-1.3, -2.3, -3.3}}, {{1.1, 1.1, 1.1}}, {{1.2, 1.2, 1.2}}, {{1.3, 1.3, 1.3}}, {{-1.1, -1.1, -1.1}}, {{-1.2, -1.2, -1.2}}, {{-1.3, -1.3, -1.3}}, {{1.1, 1.1, 1.1}}, {{1.2, 1.2, 1.2}}, {{1.3, 1.3, 1.3}}, {{-1.1, -1.1, -1.1}}, {{-1.2, -1.2, -1.2}}, {{-1.3, -1.3, -1.3}}, {{1.1, 1.1, 1.1}}, {{1.2, 1.2, 1.2}}}};
7284
static constexpr std::array<std::array<int, 3>, 20> LongArrayInt = {{{{1, 2, 3}}, {{1, 2, 3}}, {{1, 2, 3}}, {{0, 0, 0}}, {{0, 0, 0}}, {{0, 0, 0}}, {{1, 1, 1}}, {{1, 1, 1}}, {{1, 1, 1}}, {{0, 0, 0}}, {{0, 0, 0}}, {{0, 0, 0}}, {{1, 1, 1}}, {{1, 1, 1}}, {{1, 1, 1}}, {{0, 0, 0}}, {{0, 0, 0}}, {{0, 0, 0}}, {{1, 1, 1}}, {{1, 1, 1}}}};
7385

@@ -215,6 +227,10 @@ struct CorrReso {
215227

216228
HistogramRegistry registry{"registry"};
217229

230+
// For Labelled array value containers
231+
std::array<std::array<float, 3>, 13> resoCutVals{};
232+
std::array<std::array<int, 3>, 6> resoSwitchVals{};
233+
218234
// define global variables
219235
TRandom3* gRandom = new TRandom3();
220236

@@ -331,26 +347,29 @@ struct CorrReso {
331347
return;
332348
}
333349

350+
readMatrix(cfgPIDConfigs.cfgResoCuts->getData(), resoCutVals);
351+
readMatrix(cfgPIDConfigs.cfgResoSwitches->getData(), resoSwitchVals);
352+
334353
// Creating mass axis depending on particle - 4 = kshort, 5 = lambda, 6 = phi
335354
AxisSpec axisInvMass = {10, 0, 1, "mass"};
336355
if (cfgPIDConfigs.cfgPIDParticle == kK0) {
337-
const auto bins = cfgPIDConfigs.cfgResoSwitches->getData()[kMassBins][iK0];
338-
const auto min = cfgPIDConfigs.cfgResoCuts->getData()[kMassMin][iK0];
339-
const auto max = cfgPIDConfigs.cfgResoCuts->getData()[kMassMax][iK0];
356+
const auto bins = resoSwitchVals[kMassBins][iK0];
357+
const auto min = resoCutVals[kMassMin][iK0];
358+
const auto max = resoCutVals[kMassMax][iK0];
340359

341360
axisInvMass = {bins, min, max, "M_{#pi^{+}#pi^{-}} (GeV/c^{2})"};
342361
}
343362
if (cfgPIDConfigs.cfgPIDParticle == kLambda) {
344-
const auto bins = cfgPIDConfigs.cfgResoSwitches->getData()[kMassBins][iLambda];
345-
const auto min = cfgPIDConfigs.cfgResoCuts->getData()[kMassMin][iLambda];
346-
const auto max = cfgPIDConfigs.cfgResoCuts->getData()[kMassMax][iLambda];
363+
const auto bins = resoSwitchVals[kMassBins][iLambda];
364+
const auto min = resoCutVals[kMassMin][iLambda];
365+
const auto max = resoCutVals[kMassMax][iLambda];
347366

348367
axisInvMass = {bins, min, max, "M_{p#pi} (GeV/c^{2})"};
349368
}
350369
if (cfgPIDConfigs.cfgPIDParticle == kPhi) {
351-
const auto bins = cfgPIDConfigs.cfgResoSwitches->getData()[kMassBins][iPhi];
352-
const auto min = cfgPIDConfigs.cfgResoCuts->getData()[kMassMin][iPhi];
353-
const auto max = cfgPIDConfigs.cfgResoCuts->getData()[kMassMax][iPhi];
370+
const auto bins = resoSwitchVals[kMassBins][iPhi];
371+
const auto min = resoCutVals[kMassMin][iPhi];
372+
const auto max = resoCutVals[kMassMax][iPhi];
354373

355374
axisInvMass = {bins, min, max, "M_{K^{+}K^{-}} (GeV/c^{2})"};
356375
}
@@ -1065,38 +1084,38 @@ struct CorrReso {
10651084
auto negtrack = candidate.template negTrack_as<FilteredTracks>();
10661085

10671086
registry.fill(HIST("hK0Count"), 0.5);
1068-
if (postrack.pt() < cfgPIDConfigs.cfgResoCuts->getData()[kPosTrackPt][iK0] || negtrack.pt() < cfgPIDConfigs.cfgResoCuts->getData()[kNegTrackPt][iK0])
1087+
if (postrack.pt() < resoCutVals[kPosTrackPt][iK0] || negtrack.pt() < resoCutVals[kNegTrackPt][iK0])
10691088
return false;
10701089
registry.fill(HIST("hK0Count"), 1.5);
1071-
if (mk0 < cfgPIDConfigs.cfgResoCuts->getData()[kMassMin][iK0] || mk0 > cfgPIDConfigs.cfgResoCuts->getData()[kMassMax][iK0])
1090+
if (mk0 < resoCutVals[kMassMin][iK0] || mk0 > resoCutVals[kMassMax][iK0])
10721091
return false;
10731092
registry.fill(HIST("hK0Count"), 2.5);
10741093
// Rapidity correction
1075-
if (std::abs(candidate.yK0Short()) > cfgPIDConfigs.cfgResoCuts->getData()[kRapidity][iK0])
1094+
if (std::abs(candidate.yK0Short()) > resoCutVals[kRapidity][iK0])
10761095
return false;
10771096
registry.fill(HIST("hK0Count"), 3.5);
10781097
// DCA cuts for K0short
1079-
if (std::abs(candidate.dcapostopv()) < cfgPIDConfigs.cfgResoCuts->getData()[kDCAPosToPVMin][iK0] || std::abs(candidate.dcanegtopv()) < cfgPIDConfigs.cfgResoCuts->getData()[kDCANegToPVMin][iK0])
1098+
if (std::abs(candidate.dcapostopv()) < resoCutVals[kDCAPosToPVMin][iK0] || std::abs(candidate.dcanegtopv()) < resoCutVals[kDCANegToPVMin][iK0])
10801099
return false;
10811100
registry.fill(HIST("hK0Count"), 4.5);
1082-
if (cfgPIDConfigs.cfgResoSwitches->getData()[kUseDCABetDaug][iK0] && std::abs(candidate.dcaV0daughters()) > cfgPIDConfigs.cfgResoCuts->getData()[kDCABetDaug][iK0])
1101+
if (resoSwitchVals[kUseDCABetDaug][iK0] && std::abs(candidate.dcaV0daughters()) > resoCutVals[kDCABetDaug][iK0])
10831102
return false;
10841103
registry.fill(HIST("hK0Count"), 5.5);
10851104
// v0 radius cuts
1086-
if (cfgPIDConfigs.cfgResoSwitches->getData()[kUseV0Radius][iK0] && (candidate.v0radius() < cfgPIDConfigs.cfgResoCuts->getData()[kRadiusMin][iK0] || candidate.v0radius() > cfgPIDConfigs.cfgResoCuts->getData()[kRadiusMax][iK0]))
1105+
if (resoSwitchVals[kUseV0Radius][iK0] && (candidate.v0radius() < resoCutVals[kRadiusMin][iK0] || candidate.v0radius() > resoCutVals[kRadiusMax][iK0]))
10871106
return false;
10881107
registry.fill(HIST("hK0Count"), 6.5);
10891108
// cosine pointing angle cuts
1090-
if (cfgPIDConfigs.cfgResoSwitches->getData()[kUseCosPA][iK0] && candidate.v0cosPA() < cfgPIDConfigs.cfgResoCuts->getData()[kCosPA][iK0])
1109+
if (resoSwitchVals[kUseCosPA][iK0] && candidate.v0cosPA() < resoCutVals[kCosPA][iK0])
10911110
return false;
10921111
registry.fill(HIST("hK0Count"), 7.5);
10931112
// Proper lifetime
10941113
float cTauK0 = candidate.distovertotmom(posX, posY, posZ) * massK0Short;
1095-
if (cfgPIDConfigs.cfgResoSwitches->getData()[kUseProperLifetime][iK0] && cTauK0 > cfgPIDConfigs.cfgResoCuts->getData()[kLifeTime][iK0])
1114+
if (resoSwitchVals[kUseProperLifetime][iK0] && cTauK0 > resoCutVals[kLifeTime][iK0])
10961115
return false;
10971116
registry.fill(HIST("hK0Count"), 8.5);
10981117
// ArmenterosPodolanskiCut
1099-
if (cfgPIDConfigs.cfgResoSwitches->getData()[kUseArmPodCut][iK0] && (candidate.qtarm() / std::abs(candidate.alpha())) < cfgPIDConfigs.cfgResoCuts->getData()[kArmPodMinVal][iK0])
1118+
if (resoSwitchVals[kUseArmPodCut][iK0] && (candidate.qtarm() / std::abs(candidate.alpha())) < resoCutVals[kArmPodMinVal][iK0])
11001119
return false;
11011120
registry.fill(HIST("hK0Count"), 9.5);
11021121
// Selection on V0 daughters
@@ -1128,13 +1147,13 @@ struct CorrReso {
11281147
auto negtrack = candidate.template negTrack_as<FilteredTracks>();
11291148

11301149
registry.fill(HIST("hLambdaCount"), 0.5);
1131-
if (postrack.pt() < cfgPIDConfigs.cfgResoCuts->getData()[kPosTrackPt][iLambda] || negtrack.pt() < cfgPIDConfigs.cfgResoCuts->getData()[kNegTrackPt][iLambda])
1150+
if (postrack.pt() < resoCutVals[kPosTrackPt][iLambda] || negtrack.pt() < resoCutVals[kNegTrackPt][iLambda])
11321151
return false;
11331152

11341153
registry.fill(HIST("hLambdaCount"), 1.5);
1135-
if (mlambda > cfgPIDConfigs.cfgResoCuts->getData()[kMassMin][iLambda] && mlambda < cfgPIDConfigs.cfgResoCuts->getData()[kMassMax][iLambda])
1154+
if (mlambda > resoCutVals[kMassMin][iLambda] && mlambda < resoCutVals[kMassMax][iLambda])
11361155
isL = true;
1137-
if (mantilambda > cfgPIDConfigs.cfgResoCuts->getData()[kMassMin][iLambda] && mantilambda < cfgPIDConfigs.cfgResoCuts->getData()[kMassMax][iLambda])
1156+
if (mantilambda > resoCutVals[kMassMin][iLambda] && mantilambda < resoCutVals[kMassMax][iLambda])
11381157
isAL = true;
11391158

11401159
if (!isL && !isAL) {
@@ -1143,35 +1162,35 @@ struct CorrReso {
11431162
registry.fill(HIST("hLambdaCount"), 2.5);
11441163

11451164
// Rapidity correction
1146-
if (std::abs(candidate.yLambda()) > cfgPIDConfigs.cfgResoCuts->getData()[kRapidity][iLambda])
1165+
if (std::abs(candidate.yLambda()) > resoCutVals[kRapidity][iLambda])
11471166
return false;
11481167
registry.fill(HIST("hLambdaCount"), 3.5);
11491168

11501169
// DCA cuts for lambda and antilambda
1151-
if (isL && (std::abs(candidate.dcapostopv()) < cfgPIDConfigs.cfgResoCuts->getData()[kDCAPosToPVMin][iLambda] || std::abs(candidate.dcanegtopv()) < cfgPIDConfigs.cfgResoCuts->getData()[kDCANegToPVMin][iLambda])) {
1170+
if (isL && (std::abs(candidate.dcapostopv()) < resoCutVals[kDCAPosToPVMin][iLambda] || std::abs(candidate.dcanegtopv()) < resoCutVals[kDCANegToPVMin][iLambda])) {
11521171
isL = false;
11531172
}
1154-
if (isAL && (std::abs(candidate.dcapostopv()) < cfgPIDConfigs.cfgResoCuts->getData()[kDCANegToPVMin][iLambda] || std::abs(candidate.dcanegtopv()) < cfgPIDConfigs.cfgResoCuts->getData()[kDCAPosToPVMin][iLambda])) {
1173+
if (isAL && (std::abs(candidate.dcapostopv()) < resoCutVals[kDCANegToPVMin][iLambda] || std::abs(candidate.dcanegtopv()) < resoCutVals[kDCAPosToPVMin][iLambda])) {
11551174
isAL = false;
11561175
}
11571176
if (!isL && !isAL) {
11581177
return false;
11591178
}
11601179
registry.fill(HIST("hLambdaCount"), 4.5);
1161-
if (cfgPIDConfigs.cfgResoSwitches->getData()[kUseDCABetDaug][iLambda] && std::abs(candidate.dcaV0daughters()) > cfgPIDConfigs.cfgResoCuts->getData()[kDCABetDaug][iLambda])
1180+
if (resoSwitchVals[kUseDCABetDaug][iLambda] && std::abs(candidate.dcaV0daughters()) > resoCutVals[kDCABetDaug][iLambda])
11621181
return false;
11631182
registry.fill(HIST("hLambdaCount"), 5.5);
11641183
// v0 radius cuts
1165-
if (cfgPIDConfigs.cfgResoSwitches->getData()[kUseV0Radius][iLambda] && (candidate.v0radius() < cfgPIDConfigs.cfgResoCuts->getData()[kRadiusMin][iLambda] || candidate.v0radius() > cfgPIDConfigs.cfgResoCuts->getData()[kRadiusMax][iLambda]))
1184+
if (resoSwitchVals[kUseV0Radius][iLambda] && (candidate.v0radius() < resoCutVals[kRadiusMin][iLambda] || candidate.v0radius() > resoCutVals[kRadiusMax][iLambda]))
11661185
return false;
11671186
registry.fill(HIST("hLambdaCount"), 6.5);
11681187
// cosine pointing angle cuts
1169-
if (cfgPIDConfigs.cfgResoSwitches->getData()[kUseCosPA][iLambda] && candidate.v0cosPA() < cfgPIDConfigs.cfgResoCuts->getData()[kCosPA][iLambda])
1188+
if (resoSwitchVals[kUseCosPA][iLambda] && candidate.v0cosPA() < resoCutVals[kCosPA][iLambda])
11701189
return false;
11711190
registry.fill(HIST("hLambdaCount"), 7.5);
11721191
// Proper lifetime
11731192
float cTauLambda = candidate.distovertotmom(posX, posY, posZ) * massLambda;
1174-
if (cfgPIDConfigs.cfgResoSwitches->getData()[kUseProperLifetime][iLambda] && cTauLambda > cfgPIDConfigs.cfgResoCuts->getData()[kLifeTime][iLambda])
1193+
if (resoSwitchVals[kUseProperLifetime][iLambda] && cTauLambda > resoCutVals[kLifeTime][iLambda])
11751194
return false;
11761195
registry.fill(HIST("hLambdaCount"), 8.5);
11771196

0 commit comments

Comments
 (0)