From 3e9db0fbbf35bbd73c09f5c83c50b83c18b90108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 5 Feb 2026 09:03:45 +0100 Subject: [PATCH 1/4] Add hasValue and replaceValue methods to GeometryEntry --- ALICE3/Core/FastTracker.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ALICE3/Core/FastTracker.cxx b/ALICE3/Core/FastTracker.cxx index 41c6637d59b..35ca53f42bc 100644 --- a/ALICE3/Core/FastTracker.cxx +++ b/ALICE3/Core/FastTracker.cxx @@ -38,6 +38,7 @@ std::map> GeometryContainer::par { std::map> configMap; filename = gSystem->ExpandPathName(filename.c_str()); + LOG(info) << "Parsing TEnv configuration file: " << filename; TEnv env(filename.c_str()); THashList* table = env.GetTable(); layers.clear(); @@ -95,6 +96,16 @@ std::map GeometryContainer::GeometryEntry::getConfigur } } +bool GeometryContainer::GeometryEntry::hasValue(const std::string& layerName, const std::string& key) const +{ + auto layerIt = mConfigurations.find(layerName); + if (layerIt != mConfigurations.end()) { + auto keyIt = layerIt->second.find(key); + return keyIt != layerIt->second.end(); + } + return false; +} + std::string GeometryContainer::GeometryEntry::getValue(const std::string& layerName, const std::string& key, bool require) const { auto layer = getConfiguration(layerName); @@ -109,6 +120,14 @@ std::string GeometryContainer::GeometryEntry::getValue(const std::string& layerN } } +void GeometryContainer::GeometryEntry::replaceValue(const std::string& layerName, const std::string& key, const std::string& value) +{ + if (!hasValue(layerName, key)) { // check that the key exists + LOG(fatal) << "Key " << key << " does not exist in layer " << layerName << ". Cannot replace value."; + } + setValue(layerName, key, value); +} + // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ DetLayer* FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type) From e41656b1e6b72064eb4a8f0f3415dcdeeacb14aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 5 Feb 2026 09:14:28 +0100 Subject: [PATCH 2/4] Refactor FastTracker to use member variables --- ALICE3/Core/FastTracker.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ALICE3/Core/FastTracker.h b/ALICE3/Core/FastTracker.h index 8703269296e..aeb22490b1a 100644 --- a/ALICE3/Core/FastTracker.h +++ b/ALICE3/Core/FastTracker.h @@ -42,27 +42,32 @@ class GeometryContainer * @param layers Vector to store the order of the layers as they appear in the file * @return A map where each key is a layer name and the value is another map of key-value pairs for that layer */ - static std::map> parseTEnvConfiguration(std::string filename, std::vector& layers); + static std::map> parseTEnvConfiguration(std::string& filename, std::vector& layers); // A container for the geometry info struct GeometryEntry { // Default constructor GeometryEntry() = default; - explicit GeometryEntry(std::string filename) : name(filename) + explicit GeometryEntry(std::string filename) { - mConfigurations = GeometryContainer::parseTEnvConfiguration(filename, layerNames); + mFileName = filename; + mConfigurations = GeometryContainer::parseTEnvConfiguration(mFileName, mLayerNames); + LOG(info) << "Loaded geometry configuration from file: " << filename << " with " << mLayerNames.size() << " layers."; } std::map> getConfigurations() const { return mConfigurations; } std::map getConfiguration(const std::string& layerName) const; - std::vector getLayerNames() const { return layerNames; } + std::vector getLayerNames() const { return mLayerNames; } + bool hasValue(const std::string& layerName, const std::string& key) const; std::string getValue(const std::string& layerName, const std::string& key, bool require = true) const; + void setValue(const std::string& layerName, const std::string& key, const std::string& value) { mConfigurations[layerName][key] = value; } + void replaceValue(const std::string& layerName, const std::string& key, const std::string& value); float getFloatValue(const std::string& layerName, const std::string& key) const { return std::stof(getValue(layerName, key)); } int getIntValue(const std::string& layerName, const std::string& key) const { return std::stoi(getValue(layerName, key)); } private: - std::string name; // Filename of the geometry - std::map> mConfigurations; - std::vector layerNames; // Ordered names of the layers + std::string mFileName; // Filename of the geometry + std::map> mConfigurations; // Layer configurations + std::vector mLayerNames; // Ordered names of the layers }; // Add a geometry entry from a configuration file @@ -79,6 +84,7 @@ class GeometryContainer std::map getConfiguration(const int id, const std::string& layerName) const { return entries.at(id).getConfiguration(layerName); } // Get specific values + std::string getValue(const int id, const std::string& layerName, const std::string& key, bool require = true) const { return entries.at(id).getValue(layerName, key, require); }; float getFloatValue(const int id, const std::string& layerName, const std::string& key) const { return entries.at(id).getFloatValue(layerName, key); } private: From 9a4a89a4eee76f1de1e3e5a1eade2974171496ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 5 Feb 2026 09:28:15 +0100 Subject: [PATCH 3/4] Log warning for empty layer names in configuration Added warning log for empty layer names in geometry configuration. --- ALICE3/Core/FastTracker.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ALICE3/Core/FastTracker.h b/ALICE3/Core/FastTracker.h index aeb22490b1a..f0f27e7c4c6 100644 --- a/ALICE3/Core/FastTracker.h +++ b/ALICE3/Core/FastTracker.h @@ -53,6 +53,9 @@ class GeometryContainer mFileName = filename; mConfigurations = GeometryContainer::parseTEnvConfiguration(mFileName, mLayerNames); LOG(info) << "Loaded geometry configuration from file: " << filename << " with " << mLayerNames.size() << " layers."; + if (mLayerNames.empty()) { + LOG(warning) << "No layers found in geometry configuration file: " << filename; + } } std::map> getConfigurations() const { return mConfigurations; } std::map getConfiguration(const std::string& layerName) const; @@ -84,7 +87,7 @@ class GeometryContainer std::map getConfiguration(const int id, const std::string& layerName) const { return entries.at(id).getConfiguration(layerName); } // Get specific values - std::string getValue(const int id, const std::string& layerName, const std::string& key, bool require = true) const { return entries.at(id).getValue(layerName, key, require); }; + std::string getValue(const int id, const std::string& layerName, const std::string& key, bool require = true) const { return entries.at(id).getValue(layerName, key, require); } float getFloatValue(const int id, const std::string& layerName, const std::string& key) const { return entries.at(id).getFloatValue(layerName, key); } private: From bd0c0189d3fb5d0ef49c41d7249f0172e7da3185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 5 Feb 2026 10:15:35 +0100 Subject: [PATCH 4/4] Change filename parameter to reference in parseTEnvConfiguration --- ALICE3/Core/FastTracker.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALICE3/Core/FastTracker.cxx b/ALICE3/Core/FastTracker.cxx index 35ca53f42bc..e20eb4b4227 100644 --- a/ALICE3/Core/FastTracker.cxx +++ b/ALICE3/Core/FastTracker.cxx @@ -34,7 +34,7 @@ namespace o2 namespace fastsim { -std::map> GeometryContainer::parseTEnvConfiguration(std::string filename, std::vector& layers) +std::map> GeometryContainer::parseTEnvConfiguration(std::string& filename, std::vector& layers) { std::map> configMap; filename = gSystem->ExpandPathName(filename.c_str());