4040#include < TVectorDfwd.h>
4141
4242#include < Rtypes.h>
43- #include < RtypesCore.h>
4443
4544#include < array>
4645#include < cmath>
5049#include < string>
5150#include < vector>
5251
53- namespace o2
54- {
55- namespace fastsim
52+ namespace o2 ::fastsim
5653{
5754
5855// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
@@ -124,12 +121,11 @@ void FastTracker::addTPC(float phiResMean, float zResMean)
124121 // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L522
125122 // % Radiation Lengths ... Average per TPC row (i.e. total/159 )
126123 const int kNPassiveBound = 2 ;
127- const float radLBoundary[ kNPassiveBound ] = {1.692612e-01 , 8.711904e-02 };
128- const float xrhoBoundary[ kNPassiveBound ] = {6.795774e+00 , 3.111401e+00 };
129- const float rBoundary[ kNPassiveBound ] = {50 , 70.0 }; // cm
124+ const std::array< float , kNPassiveBound > radLBoundary = {1.692612e-01 , 8.711904e-02 };
125+ const std::array< float , kNPassiveBound > xrhoBoundary = {6.795774e+00 , 3.111401e+00 };
126+ const std::array< float , kNPassiveBound > rBoundary = {50 , 70.0 }; // cm
130127
131128 float radLPerRow = 0.000036 ;
132-
133129 float tpcInnerRadialPitch = 0.75 ; // cm
134130 float tpcMiddleRadialPitch = 1.0 ; // cm
135131 float tpcOuterRadialPitch = 1.5 ; // cm
@@ -186,13 +182,13 @@ void FastTracker::addGenericDetector(const o2::fastsim::GeometryEntry& configMap
186182 DetLayer* addedLayer = addLayer (layer.c_str (), r, z, x0, xrho, resRPhi, resZ, eff, type);
187183 if (!deadPhiRegions.empty ()) { // Taking it as ccdb path or local file
188184 // Check if it begins with ccdb:
189- if (std::string ( deadPhiRegions). rfind (" ccdb:" , 0 ) == 0 ) {
190- std::string ccdbPath = std::string ( deadPhiRegions) .substr (5 ); // remove "ccdb:" prefix
185+ if (deadPhiRegions. starts_with (" ccdb:" ) ) {
186+ std::string ccdbPath = deadPhiRegions.substr (5 ); // remove "ccdb:" prefix
191187 if (ccdbManager == nullptr ) {
192188 LOG (fatal) << " CCDB manager is null, cannot retrieve file " << ccdbPath;
193189 return ;
194190 }
195- TGraph* g = ccdbManager->getForTimeStamp <TGraph>(ccdbPath, 1 );
191+ auto g = ccdbManager->getForTimeStamp <TGraph>(ccdbPath, 1 );
196192 addedLayer->setDeadPhiRegions (g);
197193 } else {
198194 // Taking it as local file
@@ -201,7 +197,7 @@ void FastTracker::addGenericDetector(const o2::fastsim::GeometryEntry& configMap
201197 LOG (fatal) << " Cannot open dead phi regions file " << deadPhiRegions;
202198 return ;
203199 }
204- TGraph* g = reinterpret_cast <TGraph*>(infile.Get (infile.GetListOfKeys ()->At (0 )->GetName ()));
200+ auto g = dynamic_cast <TGraph*>(infile.Get (infile.GetListOfKeys ()->At (0 )->GetName ()));
205201 infile.Close ();
206202 addedLayer->setDeadPhiRegions (g);
207203 }
@@ -255,8 +251,9 @@ float FastTracker::integratedHitDensity(float multiplicity, float radius)
255251 // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L712
256252 float zdcHz = luminosity * 1 .e24 * mCrossSectionMinB ;
257253 float den = zdcHz * integrationTime / 1000 . * multiplicity * dist (0 ., radius) / (o2::constants::math::TwoPI * radius);
258- if (den < oneEventHitDensity (multiplicity, radius))
254+ if (den < oneEventHitDensity (multiplicity, radius)) {
259255 den = oneEventHitDensity (multiplicity, radius);
256+ }
260257 return den;
261258}
262259
@@ -265,8 +262,7 @@ float FastTracker::upcHitDensity(float radius)
265262 // porting of DetektorK::UpcHitDensity
266263 // see here:
267264 // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L727
268- float mUPCelectrons = 0 ;
269- mUPCelectrons = lhcUPCScale * 5456 / (radius * radius) / dNdEtaMinB;
265+ float mUPCelectrons = lhcUPCScale * 5456 / (radius * radius) / dNdEtaMinB;
270266 if (mUPCelectrons < 0 ) {
271267 mUPCelectrons = 0.0 ;
272268 }
@@ -302,9 +298,8 @@ float FastTracker::probGoodChiSqHit(float radius, float searchRadiusRPhi, float
302298 // porting of DetektorK::ProbGoodChiSqHit
303299 // see here:
304300 // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L629
305- float sx, goodHit;
306- sx = o2::constants::math::TwoPI * searchRadiusRPhi * searchRadiusZ * hitDensity (radius);
307- goodHit = 1 . / (1 + sx);
301+ const float sx = o2::constants::math::TwoPI * searchRadiusRPhi * searchRadiusZ * hitDensity (radius);
302+ const float goodHit = 1 . / (1 + sx);
308303 return goodHit;
309304}
310305
@@ -317,7 +312,7 @@ int FastTracker::fastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
317312 nIntercepts = 0 ;
318313 nSiliconPoints = 0 ;
319314 nGasPoints = 0 ;
320- std::array<float , 3 > posIni; // provision for != PV
315+ std::array<float , 3 > posIni{} ; // provision for != PV
321316 inputTrack.getXYZGlo (posIni);
322317 const float initialRadius = std::hypot (posIni[0 ], posIni[1 ]);
323318 const float kTrackingMargin = 0.1 ;
@@ -379,24 +374,24 @@ int FastTracker::fastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
379374 ok = inputTrack.correctForMaterial (layers[il].getRadiationLength (), 0 , applyAngularCorrection);
380375 }
381376 if (ok && mApplyElossCorrection && layers[il].getDensity () > 0 ) { // correct in small steps
382- for (int ise = xrhosteps; ise--; ) {
377+ for (int ise = xrhosteps; ise > 0 ; --ise ) {
383378 ok = inputTrack.correctForMaterial (0 , -layers[il].getDensity () / xrhosteps, applyAngularCorrection);
384- if (!ok)
379+ if (!ok) {
385380 break ;
381+ }
386382 }
387383 }
388384 LOGF (debug, " Propagation was %s up to layer %d" , ok ? " successful" : " unsuccessful" , il);
389385
390386 // was there a problem on this layer?
391387 if (!ok && il > 0 ) { // may fail to reach target layer due to the eloss
392- float rad2 = inputTrack.getX () * inputTrack.getX () + inputTrack.getY () * inputTrack.getY ();
393- float maxR = layers[il - 1 ].getRadius () + kTrackingMargin * 2 ;
394- float minRad = (fMinRadTrack > 0 && fMinRadTrack < maxR) ? fMinRadTrack : maxR;
388+ const float rad2 = inputTrack.getX () * inputTrack.getX () + inputTrack.getY () * inputTrack.getY ();
389+ const float maxR = layers[il - 1 ].getRadius () + kTrackingMargin * 2 ;
390+ const float minRad = (fMinRadTrack > 0 && fMinRadTrack < maxR) ? fMinRadTrack : maxR;
395391 if (rad2 - minRad * minRad < kTrackingMargin * kTrackingMargin ) { // check previously reached layer
396392 return -5 ; // did not reach min requested layer
397- } else {
398- break ;
399393 }
394+ break ;
400395 }
401396
402397 if (std::abs (inputTrack.getZ ()) > layers[il].getZ () && mApplyZacceptance ) {
@@ -437,7 +432,7 @@ int FastTracker::fastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
437432 static constexpr float LargeErr2Dir = 0.7 * 0.7 ;
438433 static constexpr float LargeErr2PtI = 30.5 * 30.5 ;
439434 std::array<float , o2::track::kCovMatSize > largeCov = {0 .};
440- for (int ic = o2::track::kCovMatSize ; ic--; ) {
435+ for (int ic = o2::track::kCovMatSize ; ic > 0 ; --ic ) {
441436 largeCov[ic] = 0 .;
442437 }
443438 largeCov[o2::track::CovLabels::kSigY2 ] = largeCov[o2::track::CovLabels::kSigZ2 ] = LargeErr2Coord;
@@ -453,8 +448,9 @@ int FastTracker::fastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
453448
454449 float targetX = 1e+3 ;
455450 inputTrack.getXatLabR (layers[il].getRadius (), targetX, magneticField);
456- if (targetX > InterceptFailed)
451+ if (targetX > InterceptFailed) {
457452 continue ; // failed to find intercept
453+ }
458454
459455 if (!inputTrack.propagateTo (targetX, magneticField)) {
460456 continue ; // failed to propagate
@@ -465,23 +461,22 @@ int FastTracker::fastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
465461 }
466462
467463 // get perfect data point position
468- std::array<float , 3 > spacePoint;
464+ std::array<float , 3 > spacePoint{} ;
469465 inputTrack.getXYZGlo (spacePoint);
470466 std::vector<float > thisHit = {spacePoint[0 ], spacePoint[1 ], spacePoint[2 ]};
471467
472468 // towards adding cluster: move to track alpha
473469 float alpha = inwardTrack.getAlpha ();
474- float xyz1[3 ]{
475- std::cos (alpha) * spacePoint[0 ] + std::sin (alpha) * spacePoint[1 ],
476- -std::sin (alpha) * spacePoint[0 ] + std::cos (alpha) * spacePoint[1 ],
477- spacePoint[2 ]};
470+ std::array<float , 3 > xyz1 = { std::cos (alpha) * spacePoint[0 ] + std::sin (alpha) * spacePoint[1 ],
471+ -std::sin (alpha) * spacePoint[0 ] + std::cos (alpha) * spacePoint[1 ],
472+ spacePoint[2 ]};
478473
479474 if (!inwardTrack.propagateTo (xyz1[0 ], magneticField)) {
480475 continue ;
481476 }
482477
483478 if (!layers[il].isInert ()) { // only update covm for tracker hits
484- const o2::track::TrackParametrization<float >::dim2_t hitpoint = {static_cast < float >( xyz1[1 ]), static_cast < float >( xyz1[2 ]) };
479+ const o2::track::TrackParametrization<float >::dim2_t hitpoint = {xyz1[1 ], xyz1[2 ]};
485480 const o2::track::TrackParametrization<float >::dim3_t hitpointcov = {layers[il].getResolutionRPhi () * layers[il].getResolutionRPhi (), 0 .f , layers[il].getResolutionZ () * layers[il].getResolutionZ ()};
486481
487482 inwardTrack.update (hitpoint, hitpointcov);
@@ -497,7 +492,7 @@ int FastTracker::fastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
497492 }
498493 }
499494 if (mApplyElossCorrection && layers[il].getDensity () > 0 ) {
500- for (int ise = xrhosteps; ise--; ) { // correct in small steps
495+ for (int ise = xrhosteps; ise > 0 ; --ise ) { // correct in small steps
501496 if (!inputTrack.correctForMaterial (0 , layers[il].getDensity () / xrhosteps, applyAngularCorrection)) {
502497 return -7 ;
503498 }
@@ -566,13 +561,13 @@ int FastTracker::fastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
566561 covMat[ii] = outputTrack.getCov ()[ii];
567562 }
568563
564+ // std::array<std::array<double, o2::track::kNParams>, o2::track::kNParams> fcovm{}; // double precision is needed for regularisation
569565 TMatrixDSym m (o2::track::kNParams );
570- double fcovm[o2::track::kNParams ][o2::track::kNParams ]; // double precision is needed for regularisation
571-
566+ double fcovm[o2::track::kNParams ][o2::track::kNParams ];
572567 for (int ii = 0 , k = 0 ; ii < o2::track::kNParams ; ++ii) {
573- for (int j = 0 ; j < ii + 1 ; ++j , ++k) {
574- fcovm[ii][j ] = covMat[k];
575- fcovm[j ][ii] = covMat[k];
568+ for (int jj = 0 ; jj < ii + 1 ; ++jj , ++k) {
569+ fcovm[ii][jj ] = covMat[k];
570+ fcovm[jj ][ii] = covMat[k];
576571 }
577572 }
578573
@@ -595,7 +590,7 @@ int FastTracker::fastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
595590 }
596591
597592 // Should have a valid cov matrix now
598- m.SetMatrixArray (reinterpret_cast < double *>( fcovm));
593+ m.SetMatrixArray (fcovm[ 0 ]. data ( ));
599594 TMatrixDSymEigen eigen (m);
600595 TMatrixD eigVec = eigen.GetEigenVectors ();
601596 const TVectorD& eigVal = eigen.GetEigenValues ();
@@ -621,7 +616,7 @@ int FastTracker::fastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
621616 covMatOK++;
622617
623618 // transform parameter vector and smear
624- float transformedParams[ o2::track::kNParams ] ;
619+ std::array< float , o2::track::kNParams > transformedParams{} ;
625620 for (int ii = 0 ; ii < o2::track::kNParams ; ++ii) {
626621 float val = 0 .;
627622 for (int jj = 0 ; jj < o2::track::kNParams ; ++jj) {
@@ -651,7 +646,6 @@ int FastTracker::fastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
651646}
652647// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
653648
654- } /* namespace fastsim */
655- } /* namespace o2 */
649+ } // namespace o2::fastsim
656650
657651ClassImp (o2::fastsim::FastTracker);
0 commit comments