@@ -36,132 +36,6 @@ namespace o2
3636namespace fastsim
3737{
3838
39- std::map<std::string, std::map<std::string, std::string>> GeometryContainer::parseTEnvConfiguration(std::string& filename, std::vector<std::string>& layers)
40- {
41- std::map<std::string, std::map<std::string, std::string>> configMap;
42- filename = gSystem->ExpandPathName(filename.c_str());
43- LOG(info) << "Parsing TEnv configuration file: " << filename;
44- TEnv env(filename.c_str());
45- THashList* table = env.GetTable();
46- layers.clear();
47- for (int i = 0; i < table->GetEntries(); ++i) {
48- const std::string key = table->At(i)->GetName();
49- // key should contain exactly one dot
50- if (key.find('.') == std::string::npos || key.find('.') != key.rfind('.')) {
51- LOG(fatal) << "Key " << key << " does not contain exactly one dot";
52- continue;
53- }
54- const std::string firstPart = key.substr(0, key.find('.'));
55- if (std::find(layers.begin(), layers.end(), firstPart) == layers.end()) {
56- layers.push_back(firstPart);
57- }
58- }
59- env.Print();
60- // Layers
61- for (const auto& layer : layers) {
62- LOG(info) << " Reading layer " << layer;
63- for (int i = 0; i < table->GetEntries(); ++i) {
64- const std::string key = table->At(i)->GetName();
65- if (key.find(layer + ".") == 0) {
66- const std::string paramName = key.substr(key.find('.') + 1);
67- const std::string value = env.GetValue(key.c_str(), "");
68- configMap[layer][paramName] = value;
69- }
70- }
71- }
72- return configMap;
73- }
74-
75- void GeometryContainer::init(o2::framework::InitContext& initContext)
76- {
77- std::vector<std::string> detectorConfiguration;
78- const bool foundDetectorConfiguration = common::core::getTaskOptionValue(initContext, "on-the-fly-detector-geometry-provider", "detectorConfiguration", detectorConfiguration, false);
79- if (!foundDetectorConfiguration) {
80- LOG(fatal) << "Could not retrieve detector configuration from OnTheFlyDetectorGeometryProvider task.";
81- return;
82- }
83- LOG(info) << "Size of detector configuration: " << detectorConfiguration.size();
84-
85- bool cleanLutWhenLoaded;
86- const bool foundCleanLutWhenLoaded = common::core::getTaskOptionValue(initContext, "on-the-fly-detector-geometry-provider", "cleanLutWhenLoaded", cleanLutWhenLoaded, false);
87- if (!foundCleanLutWhenLoaded) {
88- LOG(fatal) << "Could not retrieve foundCleanLutWhenLoaded option from OnTheFlyDetectorGeometryProvider task.";
89- return;
90- }
91-
92- for (std::string& configFile : detectorConfiguration) {
93- if (configFile.rfind("ccdb:", 0) == 0) {
94- LOG(info) << "ccdb source detected from on-the-fly-detector-geometry-provider";
95- const std::string ccdbPath = configFile.substr(5); // remove "ccdb:" prefix
96- const std::string outPath = "./.ALICE3/Configuration/";
97- configFile = Form("%s/%s/snapshot.root", outPath.c_str(), ccdbPath.c_str());
98-
99- int timeout = 600; // Wait max 10 minutes
100- while (--timeout > 0) {
101- std::ifstream file(configFile);
102- if (file.good()) {
103- break;
104- }
105-
106- std::this_thread::sleep_for(std::chrono::seconds(1));
107- }
108-
109- std::ifstream checkFile(configFile);
110- if (!checkFile.good()) {
111- LOG(fatal) << "Timed out waiting for geometry snapshot: " << configFile;
112- return;
113- }
114- }
115-
116- LOG(info) << "Detector geometry configuration file used: " << configFile;
117- addEntry(configFile);
118- setLutCleanupSetting(cleanLutWhenLoaded);
119- }
120- }
121-
122- std::map<std::string, std::string> GeometryContainer::GeometryEntry::getConfiguration(const std::string& layerName) const
123- {
124- auto it = mConfigurations.find(layerName);
125- if (it != mConfigurations.end()) {
126- return it->second;
127- } else {
128- LOG(fatal) << "Layer " << layerName << " not found in geometry configurations.";
129- return {};
130- }
131- }
132-
133- bool GeometryContainer::GeometryEntry::hasValue(const std::string& layerName, const std::string& key) const
134- {
135- auto layerIt = mConfigurations.find(layerName);
136- if (layerIt != mConfigurations.end()) {
137- auto keyIt = layerIt->second.find(key);
138- return keyIt != layerIt->second.end();
139- }
140- return false;
141- }
142-
143- std::string GeometryContainer::GeometryEntry::getValue(const std::string& layerName, const std::string& key, bool require) const
144- {
145- auto layer = getConfiguration(layerName);
146- auto entry = layer.find(key);
147- if (entry != layer.end()) {
148- return layer.at(key);
149- } else if (require) {
150- LOG(fatal) << "Key " << key << " not found in layer " << layerName << " configurations.";
151- return "";
152- } else {
153- return "";
154- }
155- }
156-
157- void GeometryContainer::GeometryEntry::replaceValue(const std::string& layerName, const std::string& key, const std::string& value)
158- {
159- if (!hasValue(layerName, key)) { // check that the key exists
160- LOG(fatal) << "Key " << key << " does not exist in layer " << layerName << ". Cannot replace value.";
161- }
162- setValue(layerName, key, value);
163- }
164-
16539// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
16640
16741DetLayer* FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
@@ -267,7 +141,7 @@ void FastTracker::AddTPC(float phiResMean, float zResMean)
267141 }
268142}
269143
270- void FastTracker::AddGenericDetector(GeometryContainer ::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
144+ void FastTracker::AddGenericDetector(o2::fastsim ::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
271145{
272146 // Layers
273147 for (const auto& layer : configMap.getLayerNames()) {
0 commit comments