Skip to content

Commit 7caef03

Browse files
committed
update
1 parent 3b66bc4 commit 7caef03

2 files changed

Lines changed: 55 additions & 64 deletions

File tree

‎ALICE3/Core/FastTracker.cxx‎

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include <TVectorDfwd.h>
4141

4242
#include <Rtypes.h>
43-
#include <RtypesCore.h>
4443

4544
#include <array>
4645
#include <cmath>
@@ -50,9 +49,7 @@
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

657651
ClassImp(o2::fastsim::FastTracker);

‎ALICE3/Core/FastTracker.h‎

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
#include <string>
3434
#include <vector>
3535

36-
namespace o2
37-
{
38-
namespace fastsim
36+
namespace o2::fastsim
3937
{
4038

4139
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
@@ -59,11 +57,11 @@ class FastTracker
5957
/// \param phiStart Start angle of the dead region (in radians)
6058
/// \param phiEnd End angle of the dead region (in radians)
6159
void addDeadPhiRegionInLayer(const std::string& layerName, float phiStart, float phiEnd);
62-
DetLayer getLayer(const int layer) const { return layers[layer]; }
63-
std::vector<DetLayer> getLayers() const { return layers; }
64-
int getLayerIndex(const std::string& name) const;
65-
size_t getNLayers() const { return layers.size(); }
66-
bool isLayerInert(const int layer) const { return layers[layer].isInert(); }
60+
[[nodiscard]] DetLayer getLayer(const int layer) const { return layers[layer]; }
61+
[[nodiscard]] std::vector<DetLayer> getLayers() const { return layers; }
62+
[[nodiscard]] int getLayerIndex(const std::string& name) const;
63+
[[nodiscard]] size_t getNLayers() const { return layers.size(); }
64+
[[nodiscard]] bool isLayerInert(const int layer) const { return layers[layer].isInert(); }
6765
void clearLayers() { layers.clear(); }
6866
void setRadiationLength(const std::string& layerName, float x0) { layers[getLayerIndex(layerName)].setRadiationLength(x0); }
6967
void setRadius(const std::string& layerName, float r) { layers[getLayerIndex(layerName)].setRadius(r); }
@@ -126,17 +124,17 @@ class FastTracker
126124
void setApplyEffCorrection(bool b) { mApplyEffCorrection = b; }
127125

128126
// Getters for the last track
129-
int getNIntercepts() const { return nIntercepts; }
130-
int getNSiliconPoints() const { return nSiliconPoints; }
131-
int getNGasPoints() const { return nGasPoints; }
132-
float getGoodHitProb(int layer) const
127+
[[nodiscard]] int getNIntercepts() const { return nIntercepts; }
128+
[[nodiscard]] int getNSiliconPoints() const { return nSiliconPoints; }
129+
[[nodiscard]] int getNGasPoints() const { return nGasPoints; }
130+
[[nodiscard]] float getGoodHitProb(int layer) const
133131
{
134132
return (layer >= 0 && static_cast<size_t>(layer) < goodHitProbability.size()) ? goodHitProbability[layer] : 0.0f;
135133
}
136-
std::size_t getNHits() const { return hits.size(); }
137-
float getHitX(const int i) const { return hits[i][0]; }
138-
float getHitY(const int i) const { return hits[i][1]; }
139-
float getHitZ(const int i) const { return hits[i][2]; }
134+
[[nodiscard]] std::size_t getNHits() const { return hits.size(); }
135+
[[nodiscard]] float getHitX(const int i) const { return hits[i][0]; }
136+
[[nodiscard]] float getHitY(const int i) const { return hits[i][1]; }
137+
[[nodiscard]] float getHitZ(const int i) const { return hits[i][2]; }
140138
uint64_t getCovMatOK() const { return covMatOK; }
141139
uint64_t getCovMatNotOK() const { return covMatNotOK; }
142140

@@ -152,8 +150,8 @@ class FastTracker
152150
bool mApplyEffCorrection = true; /// Apply correction for hit efficiency
153151
int mVerboseLevel = 0; /// 0: not verbose, >0 more verbose
154152
const float mCrossSectionMinB = 8; /// Minimum bias Cross section for event under study (PbPb MinBias ~ 8 Barns)
155-
int dNdEtaCent = 2200; /// dN/deta e.g. at centrality 0-5% (for 5 TeV PbPb)
156-
int dNdEtaMinB = 1; /// dN/deta for minimum bias events
153+
float dNdEtaCent = 2200.f; /// dN/deta e.g. at centrality 0-5% (for 5 TeV PbPb)
154+
float dNdEtaMinB = 1.f; /// dN/deta for minimum bias events
157155
float integrationTime = 0.02f; /// Integration time in ms
158156
float magneticField = 20.f; /// Magnetic field in kiloGauss (5 = 0.5T, 20 = 2T, etc)
159157
float covMatFactor = 0.99f; /// covmat off-diagonal factor to use for covmat fix (negative: no factor)
@@ -181,7 +179,6 @@ class FastTracker
181179

182180
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
183181

184-
} // namespace fastsim
185-
} // namespace o2
182+
} // namespace o2::fastsim
186183

187184
#endif // ALICE3_CORE_FASTTRACKER_H_

0 commit comments

Comments
 (0)