From 007c2cab368dbd76a2ea9e9d93c95a0350a88502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 16 Dec 2025 10:40:58 +0100 Subject: [PATCH 1/3] Update FastTracker.cxx --- ALICE3/Core/FastTracker.cxx | 99 ++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 45 deletions(-) diff --git a/ALICE3/Core/FastTracker.cxx b/ALICE3/Core/FastTracker.cxx index ef45e99ca01..1c881e6bb29 100644 --- a/ALICE3/Core/FastTracker.cxx +++ b/ALICE3/Core/FastTracker.cxx @@ -236,6 +236,42 @@ void FastTracker::AddTPC(float phiResMean, float zResMean) } } +std::map> FastTracker::parseTEnvConfiguration(std::string filename) +{ + std::map> configMap; + + TEnv env(filename.c_str()); + THashList* table = env.GetTable(); + std::vector layers; + for (int i = 0; i < table->GetEntries(); ++i) { + const std::string key = table->At(i)->GetName(); + // key should contain exactly one dot + if (key.find('.') == std::string::npos || key.find('.') != key.rfind('.')) { + LOG(fatal) << "Key " << key << " does not contain exactly one dot"; + continue; + } + const std::string firstPart = key.substr(0, key.find('.')); + if (std::find(layers.begin(), layers.end(), firstPart) == layers.end()) { + layers.push_back(firstPart); + } + } + env.Print(); + + // Layers + for (const auto& layer : layers) { + LOG(info) << " Reading layer " << layer; + for (int i = 0; i < table->GetEntries(); ++i) { + const std::string key = table->At(i)->GetName(); + if (key.find(layer + ".") == 0) { + const std::string paramName = key.substr(key.find('.') + 1); + const std::string value = env.GetValue(key.c_str(), ""); + configMap[layer][paramName] = value; + } + } + } + return configMap; +} + void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBManager* ccdbManager) { LOG(info) << " Adding generic detector from file " << filename; @@ -263,53 +299,26 @@ void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBMa return; } - TEnv env(filename.c_str()); - THashList* table = env.GetTable(); - std::vector layers; - for (int i = 0; i < table->GetEntries(); ++i) { - const std::string key = table->At(i)->GetName(); - // key should contain exactly one dot - if (key.find('.') == std::string::npos || key.find('.') != key.rfind('.')) { - LOG(fatal) << "Key " << key << " does not contain exactly one dot"; - continue; - } - const std::string firstPart = key.substr(0, key.find('.')); - if (std::find(layers.begin(), layers.end(), firstPart) == layers.end()) { - layers.push_back(firstPart); - } - } - // env.Print(); + std::map> configMap = parseTEnvConfiguration(filename); // Layers - for (const auto& layer : layers) { - LOG(info) << " Reading layer " << layer; - - auto getKey = [&layer, &env](const std::string& name, const bool required = true) { - std::string key = layer + "." + name; - if (!env.Defined(key.c_str())) { - 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(debug) << " Getting key " << key << " from configuration file"; - return key; - }; - const float r = env.GetValue(getKey("r").c_str(), -1.0f); - LOG(info) << " Layer " << layer << " has radius " << r; - const float z = env.GetValue(getKey("z").c_str(), -1.0f); - const float x0 = env.GetValue(getKey("x0").c_str(), 0.0f); - const float xrho = env.GetValue(getKey("xrho").c_str(), 0.0f); - const float resRPhi = env.GetValue(getKey("resRPhi").c_str(), 0.0f); - 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(), ""); + for (const auto& layer : configMap) { + LOG(info) << " Reading layer " << layer.first; + const float r = std::stof(layer.second.at("r")); + LOG(info) << " Layer " << layer.first << " has radius " << r; + const float z = std::stof(layer.second.at("z")); + const float x0 = std::stof(layer.second.at("x0")); + const float xrho = std::stof(layer.second.at("xrho")); + const float resRPhi = std::stof(layer.second.at("resRPhi")); + const float resZ = std::stof(layer.second.at("resZ")); + const float eff = std::stof(layer.second.at("eff")); + const int type = std::stoi(layer.second.at("type")); + const std::string deadPhiRegions = layer.second.at("deadPhiRegions"); // 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); - LOG(info) << " Adding layer " << layer << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type << " deadPhiRegions=" << deadPhiRegions; + LOG(info) << " Adding layer " << layer.first << " 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 + DetLayer* addedLayer = AddLayer(layer.first.c_str(), r, z, x0, xrho, resRPhi, resZ, eff, type); + if (!deadPhiRegions.empty()) { // 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 @@ -321,7 +330,7 @@ void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBMa addedLayer->setDeadPhiRegions(g); } else { // Taking it as local file - TFile infile(deadPhiRegions, "READ"); + TFile infile(deadPhiRegions.c_str(), "READ"); if (!infile.IsOpen()) { LOG(fatal) << "Cannot open dead phi regions file " << deadPhiRegions; return; @@ -331,7 +340,7 @@ void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBMa addedLayer->setDeadPhiRegions(g); } } else { - LOG(debug) << " No dead phi regions for layer " << layer; + LOG(debug) << " No dead phi regions for layer " << layer.first; } } } From bfb5e13d46a05283bd5db45425faf2f694f40733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 16 Dec 2025 10:41:46 +0100 Subject: [PATCH 2/3] Add parseTEnvConfiguration method Added a method to parse TEnv configuration files. --- ALICE3/Core/FastTracker.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ALICE3/Core/FastTracker.h b/ALICE3/Core/FastTracker.h index d4d88cb13d9..e26ee3a2da0 100644 --- a/ALICE3/Core/FastTracker.h +++ b/ALICE3/Core/FastTracker.h @@ -68,6 +68,14 @@ class FastTracker void AddSiliconALICE3v2(std::vector pixelResolution); void AddSiliconALICE3(float scaleX0VD, std::vector pixelResolution); void AddTPC(float phiResMean, float zResMean); + + /** + * @brief Parses a TEnv configuration file and returns the key-value pairs split per entry + * @param filename Path to the TEnv configuration file + * @return A map where each key is a layer name and the value is another map of key-value pairs for that layer + */ + std::map> parseTEnvConfiguration(std::string filename); + /** * @brief Adds a generic detector configuration from the specified file. * From 5353c223a0d8e68188b62b12e7b5894fcc2d5ada Mon Sep 17 00:00:00 2001 From: ALICE Builder Date: Tue, 16 Dec 2025 10:42:37 +0100 Subject: [PATCH 3/3] Please consider the following formatting changes to #14235 (#14236) --- 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 1c881e6bb29..50a59c92fb8 100644 --- a/ALICE3/Core/FastTracker.cxx +++ b/ALICE3/Core/FastTracker.cxx @@ -319,7 +319,7 @@ void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBMa DetLayer* addedLayer = AddLayer(layer.first.c_str(), r, z, x0, xrho, resRPhi, resZ, eff, type); if (!deadPhiRegions.empty()) { // Taking it as ccdb path or local file - // Check if it begins with ccdb: + // 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) {