@@ -314,88 +314,31 @@ void FastTracker::AddTPC(float phiResMean, float zResMean)
314314 }
315315}
316316
317- std::map<std::string, std::map<std::string, std::string>> FastTracker::parseTEnvConfiguration (std::string filename )
317+ void FastTracker::AddGenericDetector (GeometryContainer::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager )
318318{
319- std::map<std::string, std::map<std::string, std::string>> configMap;
320-
321- TEnv env (filename.c_str ());
322- THashList* table = env.GetTable ();
323- std::vector<std::string> layers;
324- for (int i = 0 ; i < table->GetEntries (); ++i) {
325- const std::string key = table->At (i)->GetName ();
326- // key should contain exactly one dot
327- if (key.find (' .' ) == std::string::npos || key.find (' .' ) != key.rfind (' .' )) {
328- LOG (fatal) << " Key " << key << " does not contain exactly one dot" ;
319+ // Layers
320+ for (const auto & layer : configMap.getLayerNames ()) {
321+ if (layer.find (" global" ) != std::string::npos) { // Layers with global tag are skipped
322+ LOG (info) << " Skipping global configuration entry " << layer;
329323 continue ;
330324 }
331- const std::string firstPart = key.substr (0 , key.find (' .' ));
332- if (std::find (layers.begin (), layers.end (), firstPart) == layers.end ()) {
333- layers.push_back (firstPart);
334- }
335- }
336- env.Print ();
337325
338- // Layers
339- for (const auto & layer : layers) {
340326 LOG (info) << " Reading layer " << layer;
341- for (int i = 0 ; i < table->GetEntries (); ++i) {
342- const std::string key = table->At (i)->GetName ();
343- if (key.find (layer + " ." ) == 0 ) {
344- const std::string paramName = key.substr (key.find (' .' ) + 1 );
345- const std::string value = env.GetValue (key.c_str (), " " );
346- configMap[layer][paramName] = value;
347- }
348- }
349- }
350- return configMap;
351- }
352-
353- void FastTracker::AddGenericDetector (std::string filename, o2::ccdb::BasicCCDBManager* ccdbManager)
354- {
355- LOG (info) << " Adding generic detector from file " << filename;
356- // If the filename starts with ccdb: then take the file from the ccdb
357- if (filename.rfind (" ccdb:" , 0 ) == 0 ) {
358- std::string ccdbPath = filename.substr (5 ); // remove "ccdb:" prefix
359- if (ccdbManager == nullptr ) {
360- LOG (fatal) << " CCDB manager is null, cannot retrieve file " << ccdbPath;
361- return ;
362- }
363- const std::string outPath = " /tmp/DetGeo/" ;
364- filename = Form (" %s/%s/snapshot.root" , outPath.c_str (), ccdbPath.c_str ());
365- std::ifstream checkFile (filename); // Check if file already exists
366- if (!checkFile.is_open ()) { // File does not exist, retrieve from CCDB
367- LOG (info) << " --- CCDB source detected for detector geometry " << filename;
368- std::map<std::string, std::string> metadata;
369- ccdbManager->getCCDBAccessor ().retrieveBlob (ccdbPath, outPath, metadata, 1 );
370- // Add CCDB handling logic here if needed
371- LOG (info) << " --- Now retrieving geometry configuration from CCDB to: " << filename;
372- } else { // File exists, proceed to load
373- LOG (info) << " --- Geometry configuration file already exists: " << filename << " . Skipping download." ;
374- checkFile.close ();
375- }
376- AddGenericDetector (filename, nullptr );
377- return ;
378- }
379-
380- std::map<std::string, std::map<std::string, std::string>> configMap = parseTEnvConfiguration (filename);
381- // Layers
382- for (const auto & layer : configMap) {
383- LOG (info) << " Reading layer " << layer.first ;
384- const float r = std::stof (layer.second .at (" r" ));
385- LOG (info) << " Layer " << layer.first << " has radius " << r;
386- const float z = std::stof (layer.second .at (" z" ));
387- const float x0 = std::stof (layer.second .at (" x0" ));
388- const float xrho = std::stof (layer.second .at (" xrho" ));
389- const float resRPhi = std::stof (layer.second .at (" resRPhi" ));
390- const float resZ = std::stof (layer.second .at (" resZ" ));
391- const float eff = std::stof (layer.second .at (" eff" ));
392- const int type = std::stoi (layer.second .at (" type" ));
393- const std::string deadPhiRegions = layer.second .at (" deadPhiRegions" );
327+ const float r = configMap.getFloatValue (layer, " r" );
328+ LOG (info) << " Layer " << layer << " has radius " << r;
329+ const float z = configMap.getFloatValue (layer, " z" );
330+ const float x0 = configMap.getFloatValue (layer, " x0" );
331+ const float xrho = configMap.getFloatValue (layer, " xrho" );
332+ const float resRPhi = configMap.getFloatValue (layer, " resRPhi" );
333+ const float resZ = configMap.getFloatValue (layer, " resZ" );
334+ const float eff = configMap.getFloatValue (layer, " eff" );
335+ const int type = configMap.getIntValue (layer, " type" );
336+ const std::string deadPhiRegions = configMap.getValue (layer, " deadPhiRegions" , false );
394337
395338 // 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);
396- LOG (info) << " Adding layer " << layer. first << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type << " deadPhiRegions=" << deadPhiRegions;
339+ LOG (info) << " Adding layer " << layer << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type << " deadPhiRegions=" << deadPhiRegions;
397340
398- DetLayer* addedLayer = AddLayer (layer.first . c_str (), r, z, x0, xrho, resRPhi, resZ, eff, type);
341+ DetLayer* addedLayer = AddLayer (layer.c_str (), r, z, x0, xrho, resRPhi, resZ, eff, type);
399342 if (!deadPhiRegions.empty ()) { // Taking it as ccdb path or local file
400343 // Check if it begins with ccdb:
401344 if (std::string (deadPhiRegions).rfind (" ccdb:" , 0 ) == 0 ) {
@@ -418,7 +361,7 @@ void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBMa
418361 addedLayer->setDeadPhiRegions (g);
419362 }
420363 } else {
421- LOG (debug) << " No dead phi regions for layer " << layer. first ;
364+ LOG (debug) << " No dead phi regions for layer " << layer;
422365 }
423366 }
424367}
0 commit comments