From 5b177351c582c1eeaeab25ad86e6cd760c11526a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Wed, 24 Sep 2025 17:03:38 +0200 Subject: [PATCH 1/6] Add method to specify dead phi region in layer Added method to define a dead region in phi for a layer. --- ALICE3/Core/FastTracker.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ALICE3/Core/FastTracker.h b/ALICE3/Core/FastTracker.h index ed45d140efe..9941941f07d 100644 --- a/ALICE3/Core/FastTracker.h +++ b/ALICE3/Core/FastTracker.h @@ -42,6 +42,11 @@ class 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); + /// Add a dead region in phi for a specific layer + /// \param layerName Name of the layer to modify + /// \param phiStart Start angle of the dead region (in radians) + /// \param phiEnd End angle of the dead region (in radians) + void addDeadPhiRegionInLayer(const std::string& layerName, float phiStart, float phiEnd); DetLayer GetLayer(const int layer, bool ignoreBarrelLayers = true) const; std::vector GetLayers() const { return layers; } int GetLayerIndex(const std::string& name) const; From 630ef4916c2cd53887add71fca69503d4f90b618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Wed, 24 Sep 2025 17:04:41 +0200 Subject: [PATCH 2/6] Update --- ALICE3/Core/DetLayer.cxx | 31 ++++++++++++++++++++++++++++--- ALICE3/Core/DetLayer.h | 19 +++++++++++++++++-- ALICE3/Core/FastTracker.cxx | 18 ++++++++++++++++-- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/ALICE3/Core/DetLayer.cxx b/ALICE3/Core/DetLayer.cxx index 25e61e6e6d5..61d3dbb3922 100644 --- a/ALICE3/Core/DetLayer.cxx +++ b/ALICE3/Core/DetLayer.cxx @@ -16,11 +16,15 @@ /// \brief Basic struct to hold information regarding a detector layer to be used in fast simulation /// -#include -#include - #include "DetLayer.h" +#include + +#include + +#include +#include + namespace o2::fastsim { @@ -51,6 +55,27 @@ DetLayer::DetLayer(const DetLayer& other) { } +void DetLayer::addDeadPhiRegion(float phiStart, float phiEnd) +{ + static constexpr float kDefaultValue = 2.f; + static constexpr float kPhiTolerance = 1e-4f; + if (mDeadPhiRegions == nullptr) { + mDeadPhiRegions = new TGraph(); + mDeadPhiRegions->SetNameTitle(Form("deadPhiRegions_%s", name.Data()), Form("Dead phi regions for layer %s", name.Data())); + mDeadPhiRegions->AddPoint(0, kDefaultValue); + mDeadPhiRegions->AddPoint(o2::constants::math::TwoPI, kDefaultValue); + } + if (phiStart < 0 || phiStart >= o2::constants::math::TwoPI || phiEnd < 0 || phiEnd >= o2::constants::math::TwoPI) { + LOG(fatal) << "Cannot add dead phi region with invalid range [" << phiStart << ", " << phiEnd << "] to layer " << name; + return; + } + mDeadPhiRegions->AddPoint(phiStart, kDefaultValue); + mDeadPhiRegions->AddPoint(phiEnd, kDefaultValue); + mDeadPhiRegions->AddPoint(phiStart + kPhiTolerance, 0.f); + mDeadPhiRegions->AddPoint(phiEnd - kPhiTolerance, 0.f); + mDeadPhiRegions->Sort(); +} + std::string DetLayer::toString() const { std::string out = ""; diff --git a/ALICE3/Core/DetLayer.h b/ALICE3/Core/DetLayer.h index 2577c73e42d..c6d74d6cde9 100644 --- a/ALICE3/Core/DetLayer.h +++ b/ALICE3/Core/DetLayer.h @@ -19,9 +19,10 @@ #ifndef ALICE3_CORE_DETLAYER_H_ #define ALICE3_CORE_DETLAYER_H_ -#include +#include +#include -#include "TString.h" +#include namespace o2::fastsim { @@ -46,6 +47,7 @@ struct DetLayer { void setResolutionZ(float resZ_) { resZ = resZ_; } void setEfficiency(float eff_) { eff = eff_; } void setType(int type_) { type = type_; } + void addDeadPhiRegion(float phiStart, float phiEnd); // Getters float getRadius() const { return r; } @@ -57,6 +59,7 @@ struct DetLayer { float getEfficiency() const { return eff; } int getType() const { return type; } const TString& getName() const { return name; } + const TGraph* getDeadPhiRegions() const { return mDeadPhiRegions; } // Check layer type bool isInert() const { return type == layerInert; } @@ -70,6 +73,15 @@ struct DetLayer { os << layer.toString(); return os; } + /// @brief Check if a given phi angle is in a dead region + /// @param phi The phi angle to check + /// @return True if the phi angle is in a dead region, false otherwise + bool isInDeadPhiRegion(float phi) const + { + if (mDeadPhiRegions == nullptr) + return false; + return mDeadPhiRegions->Eval(phi) > 1.f; + }; private: // TString for holding name @@ -90,6 +102,9 @@ struct DetLayer { // efficiency float eff; // detection efficiency + // dead regions in phi (in radians) + TGraph* mDeadPhiRegions = nullptr; + // layer type int type; // 0: undefined/inert, 1: silicon, 2: gas/tpc static constexpr int layerInert = 0; // inert/undefined layer diff --git a/ALICE3/Core/FastTracker.cxx b/ALICE3/Core/FastTracker.cxx index 5837d717884..06060166e94 100644 --- a/ALICE3/Core/FastTracker.cxx +++ b/ALICE3/Core/FastTracker.cxx @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -55,6 +54,16 @@ void FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, layers.push_back(newLayer); } +void FastTracker::addDeadPhiRegionInLayer(const std::string& layerName, float phiStart, float phiEnd) +{ + const int layerIdx = GetLayerIndex(layerName); + if (layerIdx < 0) { + LOG(fatal) << "Cannot add dead phi region to non-existing layer " << layerName; + return; + } + layers[layerIdx].addDeadPhiRegion(phiStart, phiEnd); +} + DetLayer FastTracker::GetLayer(int layer, bool ignoreBarrelLayers) const { int layerIdx = layer; @@ -185,7 +194,7 @@ void FastTracker::AddSiliconALICE3(float scaleX0VD, std::vector pixelReso AddLayer("B03", 7., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); AddLayer("B04", 9., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); AddLayer("B05", 12., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); - AddLayer("iTOF", 19, 250, x0iTOF, xrhoiTOF, resRPhiOT, resZOT, 0.0f, 0); + AddLayer("iTOF", 19, 250, x0iTOF, xrhoiTOF, resRPhiOT, resZOT, eff, 0); AddLayer("B06", 20., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); AddLayer("B07", 30., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); AddLayer("B08", 45., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); @@ -493,6 +502,11 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa continue; // inert layer, skip } + if (layers[il].isInDeadPhiRegion(inputTrack.getPhi())) { + LOGF(debug, "Track is in dead region of layer %d", il); + continue; // dead region, skip + } + // layer is reached if (firstLayerReached < 0) { LOGF(debug, "First layer reached: %d", il); From 829edebd293f290749eb5416cc1fbf5a1103cc79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 25 Sep 2025 13:39:28 +0200 Subject: [PATCH 3/6] Update --- ALICE3/Core/DetLayer.cxx | 35 ++++++++++++++++++++++++++ ALICE3/Core/DetLayer.h | 10 ++++++++ ALICE3/Core/FastTracker.cxx | 42 +++++++++++++++++++++++++++---- ALICE3/Core/FastTracker.h | 3 ++- ALICE3/macros/testFastTracker.cxx | 8 ++++-- 5 files changed, 90 insertions(+), 8 deletions(-) diff --git a/ALICE3/Core/DetLayer.cxx b/ALICE3/Core/DetLayer.cxx index 61d3dbb3922..45a93c29ebf 100644 --- a/ALICE3/Core/DetLayer.cxx +++ b/ALICE3/Core/DetLayer.cxx @@ -76,6 +76,41 @@ void DetLayer::addDeadPhiRegion(float phiStart, float phiEnd) mDeadPhiRegions->Sort(); } +void DetLayer::setDeadPhiRegions(TGraph* graph) +{ + LOG(debug) << "Setting dead phi regions for layer " << name << " with graph " << (graph ? graph->GetName() : "nullptr"); + if (mDeadPhiRegions != nullptr) { + LOG(warning) << "Overriding existing dead phi regions for layer " << name; + delete mDeadPhiRegions; + } + mDeadPhiRegions = graph; + if (mDeadPhiRegions->GetN() == 0) { + LOG(warning) << "Dead phi regions graph for layer " << name << " is empty, clearing dead regions"; + mDeadPhiRegions = nullptr; + return; // cleared the dead regions + } + // Check sanity of the graph + if (mDeadPhiRegions != nullptr) { + for (int i = 0; i < mDeadPhiRegions->GetN(); i++) { + const float x = mDeadPhiRegions->GetX()[i]; + const float y = mDeadPhiRegions->GetY()[i]; + // First point has to be at 0, last point has to be at 2PI + if ((i == 0 && x != 0.f) || (i == mDeadPhiRegions->GetN() - 1 && x != o2::constants::math::TwoPI)) { + LOG(fatal) << "Dead phi regions graph for layer " << name << " has invalid x value " << x << " at point " << i << ", first point should be 0 and last point should be 2PI"; + } + LOG(debug) << "Point " << i << ": (" << x << ", " << y << ")"; + if (x < 0 || x > o2::constants::math::TwoPI) { + LOG(fatal) << "Dead phi regions graph for layer " << name << " has invalid x value " << x << " at point " << i; + } + if (y != 0.f && y != 2.f) { + LOG(fatal) << "Dead phi regions graph for layer " << name << " has invalid y value " << y << " at point " << i << ", should be 0 or 2"; + } + } + } else { + LOG(info) << "Cleared dead phi regions for layer " << name; + } +} + std::string DetLayer::toString() const { std::string out = ""; diff --git a/ALICE3/Core/DetLayer.h b/ALICE3/Core/DetLayer.h index c6d74d6cde9..1efc730c0d5 100644 --- a/ALICE3/Core/DetLayer.h +++ b/ALICE3/Core/DetLayer.h @@ -47,8 +47,18 @@ struct DetLayer { void setResolutionZ(float resZ_) { resZ = resZ_; } void setEfficiency(float eff_) { eff = eff_; } void setType(int type_) { type = type_; } + + // Dead areas + + /// @brief Add a dead region in phi for this layer + /// @param phiStart starting angle in radians of the dead region + /// @param phiEnd ending angle in radians of the dead region void addDeadPhiRegion(float phiStart, float phiEnd); + /// @brief Set the dead regions in phi for this layer with a TGraph containing all regions. The graph should have y=2 for dead regions and y=0 for alive regions. + /// @param graph graph of the dead regions. Can be nullptr to clear the dead regions. + void setDeadPhiRegions(TGraph* graph); + // Getters float getRadius() const { return r; } float getZ() const { return z; } diff --git a/ALICE3/Core/FastTracker.cxx b/ALICE3/Core/FastTracker.cxx index 06060166e94..b03a58e6c9e 100644 --- a/ALICE3/Core/FastTracker.cxx +++ b/ALICE3/Core/FastTracker.cxx @@ -32,7 +32,7 @@ namespace fastsim // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ -void FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type) +DetLayer* FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type) { LOG(debug) << "Adding layer " << name << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type; DetLayer newLayer(name, r, z, x0, xrho, resRPhi, resZ, eff, type); @@ -52,6 +52,8 @@ void FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, } // Add the new layer to the layers vector layers.push_back(newLayer); + // Return the last added layer + return &layers.back(); } void FastTracker::addDeadPhiRegionInLayer(const std::string& layerName, float phiStart, float phiEnd) @@ -294,12 +296,15 @@ void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBMa for (const auto& layer : layers) { LOG(info) << " Reading layer " << layer; - auto getKey = [&layer, &env](const std::string& name) { + auto getKey = [&layer, &env](const std::string& name, const bool required = true) { std::string key = layer + "." + name; if (!env.Defined(key.c_str())) { - LOG(warning) << "Key " << key << " not defined in configuration file, getting the default value"; + if (required) { + LOG(fatal) << "Key " << key << " not defined in configuration file"; + } + LOG(debug) << "Key " << key << " not defined in configuration file, getting the default value"; } - LOG(info) << " Getting key " << key; + LOG(debug) << " Getting key " << key << " from configuration file"; return key; }; const float r = env.GetValue(getKey("r").c_str(), -1.0f); @@ -311,9 +316,36 @@ void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBMa const float resZ = env.GetValue(getKey("resZ").c_str(), 0.0f); const float eff = env.GetValue(getKey("eff").c_str(), 0.0f); const int type = env.GetValue(getKey("type").c_str(), 0); + const char* deadPhiRegions = env.GetValue(getKey("deadPhiRegions", false).c_str(), ""); // 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); - AddLayer(layer.c_str(), r, z, x0, xrho, resRPhi, resZ, eff, type); + LOG(info) << " Adding layer " << layer << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type << " deadPhiRegions=" << deadPhiRegions; + + DetLayer* addedLayer = AddLayer(layer.c_str(), r, z, x0, xrho, resRPhi, resZ, eff, type); + if (strlen(deadPhiRegions) > 0) { // Taking it as ccdb path or local file + // Check if it begins with ccdb: + if (std::string(deadPhiRegions).rfind("ccdb:", 0) == 0) { + std::string ccdbPath = std::string(deadPhiRegions).substr(5); // remove "ccdb:" prefix + if (ccdbManager == nullptr) { + LOG(fatal) << "CCDB manager is null, cannot retrieve file " << ccdbPath; + return; + } + TGraph* g = ccdbManager->getForTimeStamp(ccdbPath, -1); + addedLayer->setDeadPhiRegions(g); + } else { + // Taking it as local file + TFile infile(deadPhiRegions, "READ"); + if (!infile.IsOpen()) { + LOG(fatal) << "Cannot open dead phi regions file " << deadPhiRegions; + return; + } + TGraph* g = (TGraph*)infile.Get(infile.GetListOfKeys()->At(0)->GetName()); + infile.Close(); + addedLayer->setDeadPhiRegions(g); + } + } else { + LOG(debug) << " No dead phi regions for layer " << layer; + } } } diff --git a/ALICE3/Core/FastTracker.h b/ALICE3/Core/FastTracker.h index 9941941f07d..dd88d381424 100644 --- a/ALICE3/Core/FastTracker.h +++ b/ALICE3/Core/FastTracker.h @@ -41,7 +41,8 @@ class 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* 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); + /// Add a dead region in phi for a specific layer /// \param layerName Name of the layer to modify /// \param phiStart Start angle of the dead region (in radians) diff --git a/ALICE3/macros/testFastTracker.cxx b/ALICE3/macros/testFastTracker.cxx index ecca4c6de85..f9ec72e0765 100644 --- a/ALICE3/macros/testFastTracker.cxx +++ b/ALICE3/macros/testFastTracker.cxx @@ -15,12 +15,16 @@ #include "ALICE3/Core/FastTracker.h" -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPLHCIFData.h" +#include +#include + +#include void testFastTracker(std::string geometryFile = "a3geo.ini") { + fair::Logger::SetConsoleSeverity(fair::Severity::debug); + // auto& ccdb = o2::ccdb::BasicCCDBManager::instance(); // ccdb.setURL("http://alice-ccdb.cern.ch"); o2::fastsim::FastTracker fastTracker; From 4c50e5bd6d2123885a9f36096adc8f42b46581b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 25 Sep 2025 13:39:45 +0200 Subject: [PATCH 4/6] Rename --- ALICE3/macros/{testFastTracker.cxx => testFastTracker.C} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ALICE3/macros/{testFastTracker.cxx => testFastTracker.C} (100%) diff --git a/ALICE3/macros/testFastTracker.cxx b/ALICE3/macros/testFastTracker.C similarity index 100% rename from ALICE3/macros/testFastTracker.cxx rename to ALICE3/macros/testFastTracker.C From 85cbd305ec8e4b85a19e6afebe6c265d664db451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 25 Sep 2025 17:50:49 +0200 Subject: [PATCH 5/6] Apply suggestion from @vkucera MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Vít Kučera <26327373+vkucera@users.noreply.github.com> --- ALICE3/Core/DetLayer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALICE3/Core/DetLayer.cxx b/ALICE3/Core/DetLayer.cxx index 45a93c29ebf..5b66ec5f704 100644 --- a/ALICE3/Core/DetLayer.cxx +++ b/ALICE3/Core/DetLayer.cxx @@ -20,7 +20,7 @@ #include -#include +#include #include #include From a99cfbd0ec438493846f26ca1382c0924b902f05 Mon Sep 17 00:00:00 2001 From: ALICE Builder Date: Thu, 25 Sep 2025 17:52:17 +0200 Subject: [PATCH 6/6] Please consider the following formatting changes to #13119 (#13139) --- ALICE3/Core/DetLayer.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/ALICE3/Core/DetLayer.cxx b/ALICE3/Core/DetLayer.cxx index 5b66ec5f704..b9757de2d2f 100644 --- a/ALICE3/Core/DetLayer.cxx +++ b/ALICE3/Core/DetLayer.cxx @@ -19,7 +19,6 @@ #include "DetLayer.h" #include - #include #include