Skip to content

Commit d96bd26

Browse files
committed
U
1 parent e2c86f5 commit d96bd26

File tree

4 files changed

+36
-51
lines changed

4 files changed

+36
-51
lines changed

ALICE3/Core/FastTracker.cxx

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -251,41 +251,14 @@ void FastTracker::AddTPC(float phiResMean, float zResMean)
251251
}
252252
}
253253

254-
std::map<std::string, std::map<std::string, std::string>> FastTracker::parseTEnvConfiguration(std::string filename)
254+
void FastTracker::AddGenericDetector(std::map<std::string, std::map<std::string, std::string>> configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
255255
{
256-
return GeometryContainer::parseTEnvConfiguration(filename);
257-
}
258-
259-
void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBManager* ccdbManager)
260-
{
261-
LOG(info) << " Adding generic detector from file " << filename;
262-
// If the filename starts with ccdb: then take the file from the ccdb
263-
if (filename.rfind("ccdb:", 0) == 0) {
264-
std::string ccdbPath = filename.substr(5); // remove "ccdb:" prefix
265-
if (ccdbManager == nullptr) {
266-
LOG(fatal) << "CCDB manager is null, cannot retrieve file " << ccdbPath;
267-
return;
268-
}
269-
const std::string outPath = "/tmp/DetGeo/";
270-
filename = Form("%s/%s/snapshot.root", outPath.c_str(), ccdbPath.c_str());
271-
std::ifstream checkFile(filename); // Check if file already exists
272-
if (!checkFile.is_open()) { // File does not exist, retrieve from CCDB
273-
LOG(info) << " --- CCDB source detected for detector geometry " << filename;
274-
std::map<std::string, std::string> metadata;
275-
ccdbManager->getCCDBAccessor().retrieveBlob(ccdbPath, outPath, metadata, 1);
276-
// Add CCDB handling logic here if needed
277-
LOG(info) << " --- Now retrieving geometry configuration from CCDB to: " << filename;
278-
} else { // File exists, proceed to load
279-
LOG(info) << " --- Geometry configuration file already exists: " << filename << ". Skipping download.";
280-
checkFile.close();
281-
}
282-
AddGenericDetector(filename, nullptr);
283-
return;
284-
}
285-
286-
std::map<std::string, std::map<std::string, std::string>> configMap = parseTEnvConfiguration(filename);
287256
// Layers
288257
for (const auto& layer : configMap) {
258+
if (layer.first.find("global") != std::string::npos) { // Layers with global tag are skipped
259+
LOG(info) << " Skipping global configuration entry " << layer.first;
260+
continue;
261+
}
289262
LOG(info) << " Reading layer " << layer.first;
290263
const float r = std::stof(layer.second.at("r"));
291264
LOG(info) << " Layer " << layer.first << " has radius " << r;

ALICE3/Core/FastTracker.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ class GeometryContainer
8585
{
8686
mConfigurations = GeometryContainer::parseTEnvConfiguration(filename);
8787
}
88+
std::map<std::string, std::map<std::string, std::string>> getConfigurations() const { return mConfigurations; }
8889

8990
private:
9091
std::string name; // Filename of the geometry
9192
std::map<std::string, std::map<std::string, std::string>> mConfigurations;
9293
};
9394

94-
void addEntry(const std::string& filename)
95-
{
96-
entries.emplace_back(filename);
97-
}
95+
void addEntry(const std::string& filename) { entries.emplace_back(filename); }
96+
const std::vector<GeometryEntry>& getEntries() const { return entries; }
97+
const GeometryEntry& getEntry(const int id) const { return entries.at(id); }
9898

9999
private:
100100
std::vector<GeometryEntry> entries;
@@ -142,24 +142,16 @@ class FastTracker
142142
void AddSiliconALICE3(float scaleX0VD, std::vector<float> pixelResolution);
143143
void AddTPC(float phiResMean, float zResMean);
144144

145-
/**
146-
* @brief Parses a TEnv configuration file and returns the key-value pairs split per entry
147-
* @param filename Path to the TEnv configuration file
148-
* @return A map where each key is a layer name and the value is another map of key-value pairs for that layer
149-
*/
150-
std::map<std::string, std::map<std::string, std::string>> parseTEnvConfiguration(std::string filename);
151-
152145
/**
153146
* @brief Adds a generic detector configuration from the specified file.
154147
*
155148
* This function loads and integrates a detector configuration into the tracker
156149
* using the provided filename. The file should contain the necessary parameters
157150
* and settings for the detector to be added.
158151
*
159-
* @param filename Path to the configuration file describing the detector.
160-
* @param ccdbManager Pointer to a BasicCCDBManager instance for database access (if needed).
152+
* @param configMap Configuration map describing the detector.
161153
*/
162-
void AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBManager* ccdbManager = nullptr);
154+
void AddGenericDetector(std::map<std::string, std::map<std::string, std::string>> configMap, o2::ccdb::BasicCCDBManager* ccdbManager = nullptr);
163155

164156
void Print();
165157

ALICE3/TableProducer/OTF/onTheFlyDetectorGeometryProvider.cxx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <Framework/AnalysisTask.h>
2323
#include <Framework/runDataProcessing.h>
2424

25+
#include <map>
2526
#include <string>
2627
#include <vector>
2728

@@ -30,10 +31,11 @@ struct OnTheFlyDetectorGeometryProvider {
3031
o2::framework::Configurable<std::vector<std::string>> detectorConfiguration{"detectorConfiguration",
3132
std::vector<std::string>{"a3geo.ini"},
3233
"Paths of the detector geometry configuration files"};
34+
o2::framework::Service<o2::ccdb::BasicCCDBManager> ccdb;
3335
void init(o2::framework::InitContext&)
3436
{
35-
// ccdb->setURL("http://alice-ccdb.cern.ch");
36-
// ccdb->setTimestamp(-1);
37+
ccdb->setURL("http://alice-ccdb.cern.ch");
38+
ccdb->setTimestamp(-1);
3739
}
3840
void run(o2::framework::ProcessingContext& pc)
3941
{
@@ -45,6 +47,22 @@ struct OnTheFlyDetectorGeometryProvider {
4547
}
4648
for (const auto& configFile : detectorConfiguration.value) {
4749
LOG(info) << "Loading detector geometry from configuration file: " << configFile;
50+
// If the filename starts with ccdb: then take the file from the ccdb
51+
if (configFile.rfind("ccdb:", 0) == 0) {
52+
std::string ccdbPath = configFile.substr(5); // remove "ccdb:" prefix
53+
const std::string outPath = "/tmp/DetGeo/";
54+
configFile = Form("%s/%s/snapshot.root", outPath.c_str(), ccdbPath.c_str());
55+
std::ifstream checkFile(configFile); // Check if file already exists
56+
if (!checkFile.is_open()) { // File does not exist, retrieve from CCDB
57+
LOG(info) << " --- CCDB source detected for detector geometry " << configFile;
58+
std::map<std::string, std::string> metadata;
59+
ccdb->getCCDBAccessor().retrieveBlob(ccdbPath, outPath, metadata, 1);
60+
LOG(info) << " --- Now retrieving geometry configuration from CCDB to: " << configFile;
61+
} else { // File exists, proceed to load
62+
LOG(info) << " --- Geometry configuration file already exists: " << configFile << ". Skipping download.";
63+
checkFile.close();
64+
}
65+
}
4866
geometryContainer.addEntry(configFile);
4967
}
5068
pc.services().get<o2::framework::ControlService>().endOfStream();

ALICE3/TableProducer/OTF/onTheFlyTracker.cxx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,12 @@ struct OnTheFlyTracker {
302302
TRandom3 rand;
303303
Service<o2::ccdb::BasicCCDBManager> ccdb;
304304

305-
void init(o2::framework::InitContext&)
305+
void init(o2::framework::InitContext& initContext)
306306
{
307307
ccdb->setURL("http://alice-ccdb.cern.ch");
308308
ccdb->setTimestamp(-1);
309+
o2::fastsim::GeometryContainer geoContainer;
310+
geoContainer.init(initContext);
309311

310312
auto loadLUT = [&](int icfg, int pdg, const std::vector<std::string>& tables) {
311313
LOG(info) << "Loading LUT for pdg " << pdg << " for config " << icfg << " from provided tables with size " << tables.size();
@@ -403,7 +405,7 @@ struct OnTheFlyTracker {
403405
} else if (fastTrackerSettings.alice3geo.value[icfg] == "2") {
404406
fastTracker[icfg]->AddSiliconALICE3(fastTrackerSettings.scaleVD, fastTrackerSettings.pixelRes);
405407
} else {
406-
fastTracker[icfg]->AddGenericDetector(fastTrackerSettings.alice3geo.value[icfg], ccdb.operator->());
408+
fastTracker[icfg]->AddGenericDetector(geoContainer.getEntry(icfg).getConfigurations(), ccdb.operator->());
407409
}
408410
// print fastTracker settings
409411
fastTracker[icfg]->Print();
@@ -585,7 +587,7 @@ struct OnTheFlyTracker {
585587
} else if (fastPrimaryTrackerSettings.alice3geo.value == "2") {
586588
fastPrimaryTracker.AddSiliconALICE3(1., {0.00025, 0.00025, 0.001, 0.001});
587589
} else {
588-
fastPrimaryTracker.AddGenericDetector(fastPrimaryTrackerSettings.alice3geo, ccdb.operator->());
590+
fastTracker[icfg]->AddGenericDetector(geoContainer.getEntry(icfg).getConfigurations(), ccdb.operator->());
589591
}
590592

591593
// print fastTracker settings

0 commit comments

Comments
 (0)