Skip to content

Commit c966efb

Browse files
authored
[PWGDQ] Fixing linter errors in VarManager (#18698)
1 parent ce39597 commit c966efb

3 files changed

Lines changed: 1112 additions & 926 deletions

File tree

‎PWGDQ/Core/DQConstants.h‎

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
//
12+
/// \author Alexander Tiekoetter <alexander.tiekoetter@cern.ch>, Muenster
13+
/// \brief Header file for definition of constants in the DQ framework
14+
/// \file DQConstants.h
15+
16+
#ifndef PWGDQ_CORE_DQCONSTANTS_H_
17+
#define PWGDQ_CORE_DQCONSTANTS_H_
18+
19+
#include <array>
20+
21+
namespace o2::dqconstants
22+
{
23+
// Numerical conventions
24+
inline constexpr float InvalidValueF = -9999.f;
25+
inline constexpr int InvalidValueI = -9999;
26+
inline constexpr int InvalidIndex = -1;
27+
28+
inline constexpr float EmptyVariable = 0.0f;
29+
30+
inline constexpr double MillisecondsPerMinute = 60000.0;
31+
32+
inline constexpr int TwoProng = 2;
33+
inline constexpr int ThreeProng = 3;
34+
inline constexpr int FourProng = 4;
35+
36+
inline constexpr int TPCCalibTypeStart = 0;
37+
inline constexpr int TPCCalibTypeEnd = 2;
38+
39+
inline constexpr float InvalidDCA = 998.0f;
40+
inline constexpr float InvalidStdDev = -1.0;
41+
42+
// Checks
43+
inline constexpr auto IsCoordinateValid = [](float value) constexpr -> bool {
44+
return value < 0.f;
45+
};
46+
47+
inline constexpr auto IsDCAInvalid = [](float value) constexpr -> bool {
48+
return value > InvalidDCA;
49+
};
50+
51+
inline constexpr auto IsStdDevValid = [](float value) constexpr -> bool {
52+
return value < 0.f;
53+
};
54+
55+
inline constexpr auto IsProcCodeInvalid = [](int procCode) constexpr -> bool {
56+
return procCode == 0;
57+
};
58+
59+
inline constexpr auto CheckCalibrationTypeInvalid = [](int type) constexpr -> bool {
60+
return type < TPCCalibTypeStart || type > TPCCalibTypeEnd;
61+
};
62+
63+
inline constexpr auto GetNumDegreesOfFreedom = [](int Ntrk) constexpr -> int {
64+
return 2 * Ntrk - 3;
65+
};
66+
67+
// Shared histogram class names
68+
namespace histograms
69+
{
70+
// Event histograms names
71+
inline constexpr char EventBeforeCuts[] = "Event_BeforeCuts";
72+
inline constexpr char EventAfterCuts[] = "Event_AfterCuts";
73+
inline constexpr char EventMCTruth[] = "Event_MCTruth";
74+
75+
// Track histogram names
76+
inline constexpr char TrackBarrelBeforeCuts[] = "TrackBarrel_BeforeCuts";
77+
inline constexpr char TrackBarrelAfterCuts[] = "TrackBarrel_";
78+
79+
inline constexpr char PairsBarrelSEPM[] = "PairsBarrelSEPM";
80+
inline constexpr char PairsBarrelSEPP[] = "PairsBarrelSEPP";
81+
inline constexpr char PairsBarrelSEMM[] = "PairsBarrelSEMM";
82+
83+
inline constexpr char PairsBarrelMEPM[] = "PairsBarrelMEPM";
84+
inline constexpr char PairsBarrelMEPP[] = "PairsBarrelMEPP";
85+
inline constexpr char PairsBarrelMEMM[] = "PairsBarrelMEMM";
86+
87+
// Muon histogram names
88+
inline constexpr char MuonBeforeCuts[] = "Muons_BeforeCuts";
89+
inline constexpr char TrackMuonBeforeCuts[] = "TrackMuon_BeforeCuts";
90+
inline constexpr char TrackMuonAfterCuts[] = "TrackMuon_";
91+
92+
inline constexpr char PairsMuonSEPM[] = "PairsMuonSEPM";
93+
inline constexpr char PairsMuonSEPP[] = "PairsMuonSEPP";
94+
inline constexpr char PairsMuonSEMM[] = "PairsMuonSEMM";
95+
96+
inline constexpr char PairsMuonMEPM[] = "PairsMuonMEPM";
97+
inline constexpr char PairsMuonMEPP[] = "PairsMuonMEPP";
98+
inline constexpr char PairsMuonMEMM[] = "PairsMuonMEMM";
99+
} // namespace histograms
100+
101+
namespace devices
102+
{
103+
inline constexpr char EventSelection[] = "analysis-event-selection";
104+
inline constexpr char TrackSelection[] = "analysis-track-selection";
105+
inline constexpr char MuonSelection[] = "analysis-muon-selection";
106+
inline constexpr char PrefilterSelection[] = "analysis-prefilter-selection";
107+
inline constexpr char SameEventPairing[] = "analysis-same-event-pairing";
108+
inline constexpr char AsymmetricPairing[] = "analysis-asymmetric-pairing";
109+
inline constexpr char DileptonTrack[] = "analysis-dilepton-track";
110+
inline constexpr char DileptonTrackTrack[] = "analysis-dilepton-track-track";
111+
} // namespace devices
112+
113+
// Defaults
114+
namespace defaults
115+
{
116+
// Event selection defaults
117+
inline constexpr int EventTagStartBit = 56;
118+
inline constexpr float MaxAbsVertexZCm = 10.f;
119+
inline constexpr char DefaultRCTLabel[] = "CBT";
120+
121+
inline constexpr int NumDalitzSelections = 8;
122+
123+
inline constexpr int NumTPCPostCalibrationTypes = 4;
124+
125+
// Track defaults
126+
inline constexpr int NumDCAPars = 2;
127+
inline constexpr int IndexDCAxy = 0;
128+
inline constexpr int IndexDCAz = 1;
129+
inline constexpr double InitialDCA = 1e10;
130+
131+
inline constexpr int RotationType1 = 1;
132+
inline constexpr int RotationType2 = 2;
133+
inline constexpr int RotationType3 = 3;
134+
135+
inline constexpr int BdtSingleClassOutput = 1;
136+
inline constexpr int BdtMultiClassOutput = 3;
137+
138+
// Bimodality defaults
139+
inline constexpr int BimodalMinDataSize = 3;
140+
inline constexpr float BimodalityInvalidBinWidth = -1.0;
141+
inline constexpr float BimodalityBinWidth = 0.005;
142+
143+
// DCA thresholds in cm: 100 µm, 200 µm, 500 µm, 1 mm, 2 mm, 5 mm, 10 mm
144+
inline constexpr std::array<float, 7> BimodalityDCAThresholdsCm{
145+
0.01f, 0.02f, 0.05f, 0.1f,
146+
0.2f, 0.5f, 1.0f};
147+
148+
// KFParticle defaults
149+
inline constexpr int KFParticleMassConstrainedConstruction = 2;
150+
inline constexpr int KFParticleLegacyConstructionMethod = 3;
151+
152+
inline constexpr int TrkCovEntries = 21;
153+
inline constexpr int NumTrkCovPars = 6;
154+
155+
inline constexpr int TrkCovEntriesNoX = 15;
156+
inline constexpr int NumTrkCovParsNoX = 5;
157+
158+
inline constexpr int NumTrkComponents = 3;
159+
160+
// Vertexing defaults
161+
inline constexpr float InvalidVertexingError = 1.e8f;
162+
inline constexpr float VertexingLxyzTolerance = 1.0e-8f;
163+
inline constexpr float InitialShift = 0.0f;
164+
165+
inline constexpr float GJMinMagnitude = 1.e-6f;
166+
167+
// Detector defaults
168+
inline constexpr int PostCalibElectron = 0;
169+
inline constexpr int PostCalibPion = 1;
170+
inline constexpr int PostCalibKaon = 2;
171+
inline constexpr int PostCalibProton = 3;
172+
173+
inline constexpr int TPCPIDCalibrationMeanSigma = 1;
174+
inline constexpr int TPCPIDCalibrationMeanSigmaStatus = 2;
175+
176+
inline constexpr int NumITSLayers = 7;
177+
178+
inline constexpr int NumMFTLayers = 10;
179+
inline constexpr float MuonAbsorberExitZ = -505.; // cm
180+
181+
inline constexpr double InvalidZnEnergy = -1.e12;
182+
inline constexpr int ZDCNeutronNTowers = 4;
183+
184+
inline constexpr float CurvatureNormalizationFactor = 2.466;
185+
186+
// Hadron defaults
187+
inline constexpr float InitialHadronMass = 0.0f;
188+
189+
// Lifetimes
190+
inline constexpr float LifetimeBPlus = 1.638e-12f; // s
191+
inline constexpr float LifetimeB0 = 1.517e-12f; // s
192+
193+
} // namespace defaults
194+
195+
} // namespace o2::dqconstants
196+
197+
#endif // PWGDQ_CORE_DQCONSTANTS_H_

‎PWGDQ/Core/VarManager.cxx‎

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11+
//
12+
/// \author Ionut Cristian Arsene <iarsene@cern.ch, i.c.arsene@fys.uio.no>, Oslo
13+
/// \brief Class to handle analysis variables
14+
/// \file VarManager.cxx
1115

1216
#include "PWGDQ/Core/VarManager.h"
1317

18+
#include "PWGDQ/Core/DQConstants.h"
19+
1420
#include "Common/Core/RecoDecay.h"
1521
#include "Tools/KFparticle/KFUtilities.h"
1622

@@ -34,7 +40,6 @@
3440
#include <KFParticle.h>
3541

3642
#include <Rtypes.h>
37-
#include <RtypesCore.h>
3843

3944
#include <algorithm>
4045
#include <array>
@@ -146,7 +151,7 @@ void VarManager::ResetValues(int startValue, int endValue, float* values)
146151
if (!values) {
147152
values = fgValues;
148153
}
149-
for (Int_t i = startValue; i < endValue; ++i) {
154+
for (int i = startValue; i < endValue; ++i) {
150155
values[i] = -9999.;
151156
}
152157
}
@@ -259,37 +264,37 @@ double VarManager::ComputePIDcalibration(int species, double nSigmaValue)
259264
// species: 0 - electron, 1 - pion, 2 - kaon, 3 - proton
260265
// Depending on the PID calibration type, we use different types of calibration histograms
261266

262-
if (fgCalibrationType == 1) {
267+
if (fgCalibrationType == o2::dqconstants::defaults::TPCPIDCalibrationMeanSigma) {
263268
// get the calibration histograms
264269
CalibObjects calibMean = kTPCElectronMean;
265270
CalibObjects calibSigma = kTPCElectronSigma;
266271
switch (species) {
267-
case 0:
272+
case o2::dqconstants::defaults::PostCalibElectron:
268273
calibMean = kTPCElectronMean;
269274
calibSigma = kTPCElectronSigma;
270275
break;
271-
case 1:
276+
case o2::dqconstants::defaults::PostCalibPion:
272277
calibMean = kTPCPionMean;
273278
calibSigma = kTPCPionSigma;
274279
break;
275-
case 2:
280+
case o2::dqconstants::defaults::PostCalibKaon:
276281
calibMean = kTPCKaonMean;
277282
calibSigma = kTPCKaonSigma;
278283
break;
279-
case 3:
284+
case o2::dqconstants::defaults::PostCalibProton:
280285
calibMean = kTPCProtonMean;
281286
calibSigma = kTPCProtonSigma;
282287
break;
283288
default:
284289
LOG(fatal) << "Invalid species for PID calibration: " << species;
285-
return -999.0; // Return zero if species is invalid
290+
return o2::dqconstants::InvalidValueI; // Return zero if species is invalid
286291
}
287292

288293
TH3F* calibMeanHist = dynamic_cast<TH3F*>(fgCalibs[calibMean]);
289294
TH3F* calibSigmaHist = dynamic_cast<TH3F*>(fgCalibs[calibSigma]);
290295
if (!calibMeanHist || !calibSigmaHist) {
291296
LOG(fatal) << "Calibration histograms not found for species: " << species;
292-
return -999.0; // Return zero if histograms are not found
297+
return o2::dqconstants::InvalidValueI; // Return zero if histograms are not found
293298
}
294299

295300
// Get the bin indices for the calibration histograms
@@ -306,43 +311,43 @@ double VarManager::ComputePIDcalibration(int species, double nSigmaValue)
306311
double mean = calibMeanHist->GetBinContent(binTPCncls, binPin, binEta);
307312
double sigma = calibSigmaHist->GetBinContent(binTPCncls, binPin, binEta);
308313
return (nSigmaValue - mean) / sigma; // Return the calibrated nSigma value
309-
} else if (fgCalibrationType == 2) {
314+
} else if (fgCalibrationType == o2::dqconstants::defaults::TPCPIDCalibrationMeanSigmaStatus) {
310315
// get the calibration histograms
311316
CalibObjects calibMean = kTPCElectronMean;
312317
CalibObjects calibSigma = kTPCElectronSigma;
313318
CalibObjects calibStatus = kTPCElectronStatus;
314319
switch (species) {
315-
case 0:
320+
case o2::dqconstants::defaults::PostCalibElectron:
316321
calibMean = kTPCElectronMean;
317322
calibSigma = kTPCElectronSigma;
318323
calibStatus = kTPCElectronStatus;
319324
break;
320-
case 1:
325+
case o2::dqconstants::defaults::PostCalibPion:
321326
calibMean = kTPCPionMean;
322327
calibSigma = kTPCPionSigma;
323328
calibStatus = kTPCPionStatus;
324329
break;
325-
case 2:
330+
case o2::dqconstants::defaults::PostCalibKaon:
326331
calibMean = kTPCKaonMean;
327332
calibSigma = kTPCKaonSigma;
328333
calibStatus = kTPCKaonStatus;
329334
break;
330-
case 3:
335+
case o2::dqconstants::defaults::PostCalibProton:
331336
calibMean = kTPCProtonMean;
332337
calibSigma = kTPCProtonSigma;
333338
calibStatus = kTPCProtonStatus;
334339
break;
335340
default:
336341
LOG(fatal) << "Invalid species for PID calibration: " << species;
337-
return -999.0; // Return zero if species is invalid
342+
return o2::dqconstants::InvalidValueI; // Return zero if species is invalid
338343
}
339344

340345
THnF* calibMeanHist = dynamic_cast<THnF*>(fgCalibs[calibMean]);
341346
THnF* calibSigmaHist = dynamic_cast<THnF*>(fgCalibs[calibSigma]);
342347
THnF* calibStatusHist = dynamic_cast<THnF*>(fgCalibs[calibStatus]);
343348
if (!calibMeanHist || !calibSigmaHist || !calibStatusHist) {
344349
LOG(fatal) << "Calibration histograms not found for species: " << species;
345-
return -999.0; // Return zero if histograms are not found
350+
return o2::dqconstants::InvalidValueI; // Return zero if histograms are not found
346351
}
347352

348353
// Get the bin indices for the calibration histograms
@@ -540,7 +545,7 @@ std::tuple<float, float, float, float, float> VarManager::BimodalityCoefficientU
540545
// Bimodality coefficient = (skewness^2 + 1) / kurtosis
541546
// return a tuple including the coefficient, mean, RMS, skewness, and kurtosis
542547
size_t n = data.size();
543-
if (n < 3) {
548+
if (n < o2::dqconstants::defaults::BimodalMinDataSize) {
544549
return std::make_tuple(-1.0, -1.0, -1.0, -1.0, -1.0);
545550
}
546551
float mean = std::accumulate(data.begin(), data.end(), 0.0) / n;
@@ -725,7 +730,7 @@ void VarManager::SetDefaultVarNames()
725730
//
726731
// Set default variable names
727732
//
728-
for (Int_t ivar = 0; ivar < kNVars; ++ivar) {
733+
for (int ivar = 0; ivar < kNVars; ++ivar) {
729734
fgVariableNames[ivar] = "DEFAULT NOT DEFINED";
730735
fgVariableUnits[ivar] = "n/a";
731736
}

0 commit comments

Comments
 (0)