6161#include < utility>
6262#include < vector>
6363
64+ #include < math.h>
65+
6466using namespace o2 ;
6567using namespace o2 ::framework;
6668
@@ -117,9 +119,8 @@ class ToTLUT
117119 ~ToTLUT ()
118120 {
119121 for (const auto & hist_ptr : mLUTHistogramFlat ) {
120- if (hist_ptr) {
121- delete hist_ptr;
122- }
122+
123+ delete hist_ptr;
123124 }
124125 }
125126
@@ -131,7 +132,7 @@ class ToTLUT
131132 LOG (warning) << " Provided filename is empty for PDG " << pdg;
132133 return false ;
133134 }
134- if (filename.rfind (" ccdb:" , 0 ) == 0 ) { // Check if filename starts with "ccdb:"
135+ if (filename.starts_with (" ccdb:" ) ) { // Check if filename starts with "ccdb:"
135136 std::string ccdbPath = filename.substr (5 ); // remove "ccdb:" prefix
136137 const std::string outPath = " /tmp/ToTLUTs/" ;
137138 const std::string localFilename = outPath + ccdbPath + " /snapshot.root" ;
@@ -150,10 +151,9 @@ class ToTLUT
150151 }
151152 testFile.close ();
152153 return load (pdg, localFilename);
153- } else { // File is found, proceed to load it
154- checkFile.close ();
155- return load (pdg, localFilename);
156- }
154+ } // File is found, proceed to load it
155+ checkFile.close ();
156+ return load (pdg, localFilename);
157157 }
158158 // In case the file is already available locally
159159 TFile* f = TFile::Open (filename.c_str ());
@@ -162,7 +162,7 @@ class ToTLUT
162162 return false ;
163163 }
164164
165- int currentPdgIdx;
165+ int currentPdgIdx = 0 ;
166166 auto it = mPdgToIndexMap .find (pdg);
167167 if (it == mPdgToIndexMap .end ()) {
168168 currentPdgIdx = mIndexToPdgMap .size ();
@@ -201,7 +201,7 @@ class ToTLUT
201201
202202 TH1F * histFromFile = dynamic_cast <TH1F *>(f->Get (histName));
203203 if (histFromFile) {
204- TH1F * clonedHist = static_cast <TH1F *>(histFromFile->Clone ());
204+ TH1F * clonedHist = dynamic_cast <TH1F *>(histFromFile->Clone ());
205205 clonedHist->SetDirectory (nullptr );
206206
207207 size_t flatIdx = getFlatIndex (currentPdgIdx, layer, etaBin, pBin);
@@ -299,15 +299,17 @@ struct OnTheFlyTrackerPid {
299299
300300 float calculateNsigma (float measuredToT, float expectedToT, float resolution)
301301 {
302- if (resolution <= 0 )
302+ if (resolution <= 0 ) {
303303 return 999 .f ;
304+ }
304305 return (measuredToT - expectedToT) / resolution;
305306 }
306307
307308 float getToTMeanFromMomentumSlice (const std::shared_ptr<TH2 >& hist, float momentum)
308309 {
309- if (!hist)
310+ if (!hist) {
310311 return -1 .f ;
312+ }
311313 int binX = hist->GetXaxis ()->FindBin (momentum);
312314 TH1D * proj = hist->ProjectionY (" temp" , binX, binX);
313315 if (proj->GetEntries () < kMinEntriesForProjection ) {
@@ -321,8 +323,9 @@ struct OnTheFlyTrackerPid {
321323
322324 float getToTResolutionFromMomentumSlice (const std::shared_ptr<TH2 >& hist, float momentum)
323325 {
324- if (!hist)
326+ if (!hist) {
325327 return -1 .f ;
328+ }
326329 int binX = hist->GetXaxis ()->FindBin (momentum);
327330 TH1D * proj = hist->ProjectionY (" temp" , binX, binX);
328331 if (proj->GetEntries () < kMinEntriesForProjection ) {
@@ -338,7 +341,7 @@ struct OnTheFlyTrackerPid {
338341 {
339342 float length = -100 ;
340343 o2::math_utils::CircleXYf_t trcCircle;
341- float sna, csa;
344+ float sna = NAN , csa = NAN ;
342345 track.getCircleParams (magneticField, trcCircle, sna, csa);
343346
344347 const float centerDistance = std::hypot (trcCircle.xC , trcCircle.yC );
@@ -359,12 +362,12 @@ struct OnTheFlyTrackerPid {
359362 const float point1[2 ] = {radical * ux + displace * vx, radical * uy + displace * vy};
360363 const float point2[2 ] = {radical * ux - displace * vx, radical * uy - displace * vy};
361364
362- std::array<float , 3 > mom;
365+ std::array<float , 3 > mom{} ;
363366 track.getPxPyPzGlo (mom);
364367 const float scalarProduct1 = point1[0 ] * mom[0 ] + point1[1 ] * mom[1 ];
365368 const float scalarProduct2 = point2[0 ] * mom[0 ] + point2[1 ] * mom[1 ];
366369
367- std::array<float , 3 > startPoint;
370+ std::array<float , 3 > startPoint{} ;
368371 track.getXYZGlo (startPoint);
369372
370373 float cosAngle = -1000 , modulus = -1000 ;
@@ -525,24 +528,25 @@ struct OnTheFlyTrackerPid {
525528 for (size_t iTrue = 0 ; iTrue < particleInfo.size (); ++iTrue) {
526529 std::string trueName = particleInfo[iTrue].second ;
527530 std::string trueNamePretty = trueName; // Fallback
528- if (trueName == " Elec" )
531+ if (trueName == " Elec" ) {
529532 trueNamePretty = " #it{e}" ;
530- else if (trueName == " Muon" )
533+ } else if (trueName == " Muon" ) {
531534 trueNamePretty = " #it{#mu}" ;
532- else if (trueName == " Pion" )
535+ } else if (trueName == " Pion" ) {
533536 trueNamePretty = " #it{#pi}" ;
534- else if (trueName == " Kaon" )
537+ } else if (trueName == " Kaon" ) {
535538 trueNamePretty = " #it{K}" ;
536- else if (trueName == " Prot" )
539+ } else if (trueName == " Prot" ) {
537540 trueNamePretty = " #it{p}" ;
538- else if (trueName == " Deut" )
541+ } else if (trueName == " Deut" ) {
539542 trueNamePretty = " #it{d}" ;
540- else if (trueName == " Trit" )
543+ } else if (trueName == " Trit" ) {
541544 trueNamePretty = " #it{t}" ;
542- else if (trueName == " He3" )
545+ } else if (trueName == " He3" ) {
543546 trueNamePretty = " #it{^{3}He}" ;
544- else if (trueName == " Al" )
547+ } else if (trueName == " Al" ) {
545548 trueNamePretty = " #it{^{4}He}" ;
549+ }
546550
547551 if (enableLogPBins.value ) {
548552 const AxisSpec axisMomentumLog{mLogBins , " #it{p/z} (GeV/#it{c})" };
@@ -558,24 +562,25 @@ struct OnTheFlyTrackerPid {
558562 for (size_t iHyp = 0 ; iHyp < particleInfo.size (); ++iHyp) {
559563 std::string hypName = particleInfo[iHyp].second ;
560564 std::string hypNamePretty = hypName; // Fallback
561- if (hypName == " Elec" )
565+ if (hypName == " Elec" ) {
562566 hypNamePretty = " #it{e}" ;
563- else if (hypName == " Muon" )
567+ } else if (hypName == " Muon" ) {
564568 hypNamePretty = " #it{#mu}" ;
565- else if (hypName == " Pion" )
569+ } else if (hypName == " Pion" ) {
566570 hypNamePretty = " #it{#pi}" ;
567- else if (hypName == " Kaon" )
571+ } else if (hypName == " Kaon" ) {
568572 hypNamePretty = " #it{K}" ;
569- else if (hypName == " Prot" )
573+ } else if (hypName == " Prot" ) {
570574 hypNamePretty = " #it{p}" ;
571- else if (hypName == " Deut" )
575+ } else if (hypName == " Deut" ) {
572576 hypNamePretty = " #it{d}" ;
573- else if (hypName == " Trit" )
577+ } else if (hypName == " Trit" ) {
574578 hypNamePretty = " #it{t}" ;
575- else if (hypName == " He3" )
579+ } else if (hypName == " He3" ) {
576580 hypNamePretty = " #it{^{3}He}" ;
577- else if (hypName == " Al" )
581+ } else if (hypName == " Al" ) {
578582 hypNamePretty = " #it{^{4}He}" ;
583+ }
579584
580585 std::string histName = " NSigma/BarrelNsigmaTrue" + trueName + " Vs" + hypName + " Hypothesis" ;
581586 std::string histTitle = " Nsigma (True " + trueNamePretty + " vs Hyp " + hypNamePretty + " ); #it{p/z} (GeV/#it{c}); N#sigma" ;
@@ -613,7 +618,7 @@ struct OnTheFlyTrackerPid {
613618
614619 for (const auto & track : tracks) {
615620 float truncatedMeanToT = -1 .0f ;
616- std::array<float , kNumHypothesisParticles > nSigmaValues;
621+ std::array<float , kNumHypothesisParticles > nSigmaValues{} ;
617622 nSigmaValues.fill (999 .f );
618623
619624 if (!track.has_mcParticle ()) {
@@ -690,7 +695,7 @@ struct OnTheFlyTrackerPid {
690695 std::vector<float > validToTs;
691696
692697 for (int layer = kMinLayerForTruncation ; layer < maxBarrelLayers.value ; ++layer) {
693- if ((hitMap >> layer) & 0x1 ) {
698+ if ((( hitMap >> layer) & 0x1 ) != 0 ) {
694699 TH1F * totHist = mToTLUT ->getHistogramForSampling (truePdgIdx, layer, binnedEta, binnedP);
695700
696701 if (totHist && totHist->GetEntries () > 1 ) {
@@ -704,14 +709,15 @@ struct OnTheFlyTrackerPid {
704709 const size_t nValid = validToTs.size ();
705710 size_t nUse = 0 ;
706711
707- if (nValid == kMidLowValidHits || nValid == kMidHighValidHits )
712+ if (nValid == kMidLowValidHits || nValid == kMidHighValidHits ) {
708713 nUse = kMaxValidHitsForTruncation34 ;
709- else if (nValid == kMinValidHits || nValid == kLowValidHits )
714+ } else if (nValid == kMinValidHits || nValid == kLowValidHits ) {
710715 nUse = kMaxValidHitsForTruncation12 ;
711- else if (nValid == kHighValidHits1 || nValid == kHighValidHits2 )
716+ } else if (nValid == kHighValidHits1 || nValid == kHighValidHits2 ) {
712717 nUse = kMaxValidHitsForTruncation56 ;
713- else if (nValid >= kMaxValidHits )
718+ } else if (nValid >= kMaxValidHits ) {
714719 nUse = kMaxValidHitsForTruncation7Plus ;
720+ }
715721
716722 if (nUse > 0 && nValid >= nUse) {
717723 std::sort (validToTs.begin (), validToTs.end ());
0 commit comments