From 80f9588d2999adaad46d846efd4cc1716350790d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Fri, 23 May 2025 17:22:29 +0200 Subject: [PATCH] A3 FastTracker: updated data member protection --- ALICE3/Core/FastTracker.cxx | 5 +- ALICE3/Core/FastTracker.h | 71 ++++++++++++++------ ALICE3/TableProducer/OTF/CMakeLists.txt | 2 +- ALICE3/TableProducer/OTF/onTheFlyTracker.cxx | 20 +++--- 4 files changed, 64 insertions(+), 34 deletions(-) diff --git a/ALICE3/Core/FastTracker.cxx b/ALICE3/Core/FastTracker.cxx index 977d80ff547..6b22461c187 100644 --- a/ALICE3/Core/FastTracker.cxx +++ b/ALICE3/Core/FastTracker.cxx @@ -10,6 +10,7 @@ // or submit itself to any jurisdiction. #include +#include #include "TMath.h" #include "TMatrixD.h" #include "TRandom.h" @@ -214,7 +215,7 @@ float FastTracker::Dist(float z, float r) 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) index = 4; else @@ -295,7 +296,7 @@ float FastTracker::ProbGoodChiSqHit(float radius, float searchRadiusRPhi, float // 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; diff --git a/ALICE3/Core/FastTracker.h b/ALICE3/Core/FastTracker.h index aad0c7d51b3..f88b6c5ae85 100644 --- a/ALICE3/Core/FastTracker.h +++ b/ALICE3/Core/FastTracker.h @@ -14,6 +14,7 @@ #include // not a system header but megalinter thinks so #include +#include #include "DetLayer.h" #include "ReconstructionDataFormats/Track.h" @@ -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 pixelResolution); void AddSiliconALICE3v2(std::vector 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); @@ -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 layers; std::vector> 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 @@ -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 @@ -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 goodHitProbability; - float GetGoodHitProb(int layer) const { return goodHitProbability[layer]; } ClassDef(FastTracker, 1); }; diff --git a/ALICE3/TableProducer/OTF/CMakeLists.txt b/ALICE3/TableProducer/OTF/CMakeLists.txt index a2cc6bd3d70..69a4d2ec722 100644 --- a/ALICE3/TableProducer/OTF/CMakeLists.txt +++ b/ALICE3/TableProducer/OTF/CMakeLists.txt @@ -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) diff --git a/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx b/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx index 4499613cd5f..989295f8c54 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx @@ -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); @@ -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])); @@ -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; @@ -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 };