Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ALICE3/Core/FastTracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// or submit itself to any jurisdiction.

#include <vector>
#include <string>
#include "TMath.h"
#include "TMatrixD.h"
#include "TRandom.h"
Expand Down Expand Up @@ -187,8 +188,8 @@
for (int i = 0; i < kNPassiveBound; i++) {
AddLayer(Form("tpc_boundary%d", i), rBoundary[i], zLength, radLBoundary[i], xrhoBoundary[i], 0); // dummy errors
}
for (Int_t k = 0; k < tpcRows; k++) {

Check failure on line 191 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
Float_t rowRadius = 0;

Check failure on line 192 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
if (k < innerRows)
rowRadius = rowOneRadius + k * tpcInnerRadialPitch;
else if (k >= innerRows && k < (innerRows + middleRows))
Expand All @@ -214,8 +215,8 @@
if (i == nSteps - 1)
index = 1;
z0 = -4 * sigmaD + i * dz0;
dist += index * (dz0 / 3.) * (1 / o2::math_utils::sqrt(o2::constants::math::TwoPI) / sigmaD) * exp(-z0 * z0 / 2. / sigmaD / sigmaD) * (1 / o2::math_utils::sqrt((z - z0) * (z - z0) + r * r));
dist += index * (dz0 / 3.) * (1 / o2::math_utils::sqrt(o2::constants::math::TwoPI) / sigmaD) * std::exp(-z0 * z0 / 2. / sigmaD / sigmaD) * (1 / o2::math_utils::sqrt((z - z0) * (z - z0) + r * r));
if (index != 4)

Check failure on line 219 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
index = 4;
else
index = 2;
Expand Down Expand Up @@ -295,7 +296,7 @@

// function to provide a reconstructed track from a perfect input track
// returns number of intercepts (generic for now)
int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackParCov& outputTrack, float nch)
int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackParCov& outputTrack, const float nch)
{
hits.clear();
nIntercepts = 0;
Expand Down Expand Up @@ -327,7 +328,7 @@
float targetX = 1e+3;
bool ok = true;
inputTrack.getXatLabR(layers[il].r, targetX, magneticField);
if (targetX > 999)

Check failure on line 331 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
break; // failed to find intercept

ok = inputTrack.propagateTo(targetX, magneticField);
Expand Down Expand Up @@ -373,7 +374,7 @@

// Enlarge covariance matrix
std::array<float, 5> trPars = {0.};
for (int ip = 0; ip < 5; ip++) {

Check failure on line 377 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
trPars[ip] = outputTrack.getParam(ip);
}
std::array<float, 15> largeCov = {0.};
Expand Down Expand Up @@ -434,8 +435,8 @@
// towards adding cluster: move to track alpha
double alpha = inwardTrack.getAlpha();
double xyz1[3]{
TMath::Cos(alpha) * spacePoint[0] + TMath::Sin(alpha) * spacePoint[1],

Check failure on line 438 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
-TMath::Sin(alpha) * spacePoint[0] + TMath::Cos(alpha) * spacePoint[1],

Check failure on line 439 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
spacePoint[2]};
if (!inwardTrack.propagateTo(xyz1[0], magneticField))
continue;
Expand Down Expand Up @@ -541,7 +542,7 @@
if (fcovm[ii][jj] * fcovm[ii][jj] > std::abs(fcovm[ii][ii] * fcovm[jj][jj])) {
rubenConditional = true;
if (makePositiveDefinite) {
fcovm[ii][jj] = TMath::Sign(1, fcovm[ii][jj]) * covMatFactor * sqrt(std::abs(fcovm[ii][ii] * fcovm[jj][jj]));

Check failure on line 545 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
}
}
}
Expand Down Expand Up @@ -579,7 +580,7 @@
for (int j = 0; j < 5; ++j)
val += eigVec[j][ii] * outputTrack.getParam(j);
// smear parameters according to eigenvalues
params_[ii] = gRandom->Gaus(val, sqrt(eigVal[ii]));

Check failure on line 583 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
}

// invert eigenvector matrix
Expand All @@ -592,7 +593,7 @@
outputTrack.setParam(val, ii);
}
// should make a sanity check that par[2] sin(phi) is in [-1, 1]
if (fabs(outputTrack.getParam(2)) > 1.) {

Check failure on line 596 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
LOG(info) << " --- smearTrack failed sin(phi) sanity check: " << outputTrack.getParam(2);
return -2;
}
Expand Down
71 changes: 50 additions & 21 deletions ALICE3/Core/FastTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <fairlogger/Logger.h> // not a system header but megalinter thinks so
#include <vector>
#include <string>
#include "DetLayer.h"
#include "ReconstructionDataFormats/Track.h"

Expand All @@ -34,16 +35,38 @@ class FastTracker
FastTracker();
virtual ~FastTracker() {}

// Layer and layer configuration
void AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi = 0.0f, float resZ = 0.0f, float eff = 0.0f, int type = 0);
DetLayer GetLayer(const int layer, bool ignoreBarrelLayers = true) const;
int GetLayerIndex(const std::string name) const;
void SetRadiationLength(const std::string layerName, float x0) { layers[GetLayerIndex(layerName)].x0 = x0; }
void SetRadius(const std::string layerName, float r) { layers[GetLayerIndex(layerName)].r = r; }
void SetResolutionRPhi(const std::string layerName, float resRPhi) { layers[GetLayerIndex(layerName)].resRPhi = resRPhi; }
void SetResolutionZ(const std::string layerName, float resZ) { layers[GetLayerIndex(layerName)].resZ = resZ; }
void SetResolution(const std::string layerName, float resRPhi, float resZ)
{
SetResolutionRPhi(layerName, resRPhi);
SetResolutionZ(layerName, resZ);
}

void AddSiliconALICE3v4(std::vector<float> pixelResolution);
void AddSiliconALICE3v2(std::vector<float> pixelResolution);
void AddTPC(float phiResMean, float zResMean);

void Print();
int FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackParCov& outputTrack, float nch);

/**
* @brief Performs fast tracking on the input track parameters.
*
* Propagates the given input track through the detector layers, applying
* relevant corrections and updates, and stores the result in outputTrack.
*
* @param inputTrack The input track parameters and covariance (const, by value).
* @param outputTrack Reference to the output track parameters and covariance, to be filled.
* @param nch Charged particle multiplicity (used for hit density calculations).
* @return int i.e. number of intercepts (implementation-defined).
*/
int FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackParCov& outputTrack, const float nch);

// For efficiency calculation
float Dist(float z, float radius);
Expand All @@ -53,18 +76,35 @@ class FastTracker
float HitDensity(float radius);
float ProbGoodChiSqHit(float radius, float searchRadiusRPhi, float searchRadiusZ);

// Setters and getters for configuration
void SetIntegrationTime(float t) { integrationTime = t; }
void SetMaxRadiusOfSlowDetectors(float r) { maxRadiusSlowDet = r; }
void SetAvgRapidity(float y) { avgRapidity = y; }
void SetdNdEtaCent(float d) { dNdEtaCent = d; }
void SetLhcUPCscale(float s) { lhcUPCScale = s; }
void SetBField(float b) { magneticField = b; }
void SetMinRadTrack(float r) { fMinRadTrack = r; }
void SetMagneticField(float b) { magneticField = b; }
void SetApplyZacceptance(bool b) { applyZacceptance = b; }
void SetApplyMSCorrection(bool b) { applyMSCorrection = b; }
void SetApplyElossCorrection(bool b) { applyElossCorrection = b; }

// Getters for the last track
int GetNIntercepts() const { return nIntercepts; }
int GetNSiliconPoints() const { return nSiliconPoints; }
int GetNGasPoints() const { return nGasPoints; }
float GetGoodHitProb(int layer) const { return goodHitProbability[layer]; }
std::size_t GetNHits() const { return hits.size(); }
float GetHitX(const int i) const { return hits[i][0]; }
float GetHitY(const int i) const { return hits[i][1]; }
float GetHitZ(const int i) const { return hits[i][2]; }
uint64_t GetCovMatOK() const { return covMatOK; }
uint64_t GetCovMatNotOK() const { return covMatNotOK; }

private:
// Definition of detector layers
std::vector<DetLayer> layers;
std::vector<std::vector<float>> hits; // bookkeep last added hits
void SetRadiationLength(const std::string layerName, float x0) { layers[GetLayerIndex(layerName)].x0 = x0; }
void SetRadius(const std::string layerName, float r) { layers[GetLayerIndex(layerName)].r = r; }
void SetResolutionRPhi(const std::string layerName, float resRPhi) { layers[GetLayerIndex(layerName)].resRPhi = resRPhi; }
void SetResolutionZ(const std::string layerName, float resZ) { layers[GetLayerIndex(layerName)].resZ = resZ; }
void SetResolution(const std::string layerName, float resRPhi, float resZ)
{
SetResolutionRPhi(layerName, resRPhi);
SetResolutionZ(layerName, resZ);
}

// operational
bool applyZacceptance; // check z acceptance or not
Expand All @@ -87,16 +127,6 @@ class FastTracker
float upcBackgroundMultiplier;
float fMinRadTrack = 132.;

// Setters and getters
void SetIntegrationTime(float t) { integrationTime = t; }
void SetMaxRadiusOfSlowDetectors(float r) { maxRadiusSlowDet = r; }
void SetAvgRapidity(float y) { avgRapidity = y; }
void SetdNdEtaCent(float d) { dNdEtaCent = d; }
void SetLhcUPCscale(float s) { lhcUPCScale = s; }
void SetBField(float b) { magneticField = b; }
void SetMinRadTrack(float r) { fMinRadTrack = r; }
// void SetAtLeastHits(int n) { fMinRadTrack = n; }

uint64_t covMatOK; // cov mat has negative eigenvals
uint64_t covMatNotOK; // cov mat has negative eigenvals

Expand All @@ -105,7 +135,6 @@ class FastTracker
int nSiliconPoints; // silicon-based space points added to track
int nGasPoints; // tpc-based space points added to track
std::vector<float> goodHitProbability;
float GetGoodHitProb(int layer) const { return goodHitProbability[layer]; }

ClassDef(FastTracker, 1);
};
Expand Down
2 changes: 1 addition & 1 deletion ALICE3/TableProducer/OTF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ o2physics_add_dpl_workflow(onthefly-richpid
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats O2Physics::ALICE3Core
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(onthefly-trkpid
o2physics_add_dpl_workflow(on-the-fly-tracker-pid
SOURCES onTheFlyTrackerPid.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats O2Physics::ALICE3Core
COMPONENT_NAME Analysis)
20 changes: 10 additions & 10 deletions ALICE3/TableProducer/OTF/onTheFlyTracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,10 @@ struct OnTheFlyTracker {
rand.SetSeed(seed);

// configure FastTracker
fastTracker.magneticField = magneticField;
fastTracker.applyZacceptance = fastTrackerSettings.applyZacceptance;
fastTracker.applyMSCorrection = fastTrackerSettings.applyMSCorrection;
fastTracker.applyElossCorrection = fastTrackerSettings.applyElossCorrection;
fastTracker.SetMagneticField(magneticField);
fastTracker.SetApplyZacceptance(fastTrackerSettings.applyZacceptance);
fastTracker.SetApplyMSCorrection(fastTrackerSettings.applyMSCorrection);
fastTracker.SetApplyElossCorrection(fastTrackerSettings.applyElossCorrection);

if (fastTrackerSettings.alice3detector == 0) {
fastTracker.AddSiliconALICE3v2(fastTrackerSettings.pixelRes);
Expand Down Expand Up @@ -633,8 +633,8 @@ struct OnTheFlyTracker {
nTPCHits[i] = 0;
if (enableSecondarySmearing) {
nHits[i] = fastTracker.FastTrack(xiDaughterTrackParCovsPerfect[i], xiDaughterTrackParCovsTracked[i], dNdEta);
nSiliconHits[i] = fastTracker.nSiliconPoints;
nTPCHits[i] = fastTracker.nGasPoints;
nSiliconHits[i] = fastTracker.GetNSiliconPoints();
nTPCHits[i] = fastTracker.GetNGasPoints();

if (nHits[i] < 0) { // QA
histos.fill(HIST("hFastTrackerQA"), o2::math_utils::abs(nHits[i]));
Expand All @@ -645,8 +645,8 @@ struct OnTheFlyTracker {
} else {
continue; // extra sure
}
for (uint32_t ih = 0; ih < fastTracker.hits.size(); ih++) {
histos.fill(HIST("hFastTrackerHits"), fastTracker.hits[ih][2], std::hypot(fastTracker.hits[ih][0], fastTracker.hits[ih][1]));
for (uint32_t ih = 0; ih < fastTracker.GetNHits(); ih++) {
histos.fill(HIST("hFastTrackerHits"), fastTracker.GetHitZ(ih), std::hypot(fastTracker.GetHitX(ih), fastTracker.GetHitY(ih)));
}
} else {
isReco[i] = true;
Expand Down Expand Up @@ -1116,8 +1116,8 @@ struct OnTheFlyTracker {
}

// do bookkeeping of fastTracker tracking
histos.fill(HIST("hCovMatOK"), 0.0f, fastTracker.covMatNotOK);
histos.fill(HIST("hCovMatOK"), 1.0f, fastTracker.covMatOK);
histos.fill(HIST("hCovMatOK"), 0.0f, fastTracker.GetCovMatNotOK());
histos.fill(HIST("hCovMatOK"), 1.0f, fastTracker.GetCovMatOK());
} // end process
};

Expand Down
Loading