1111
1212#include " FastTracker.h"
1313
14- #include " ReconstructionDataFormats/TrackParametrization.h"
14+ #include " Common/Core/TableHelper.h"
15+
16+ #include < ReconstructionDataFormats/TrackParametrization.h>
1517
16- #include " TMath.h"
17- #include " TMatrixD.h"
18- #include " TMatrixDSymEigen.h"
19- #include " TRandom.h"
2018#include < TEnv.h>
2119#include < THashList.h>
20+ #include < TMath.h>
21+ #include < TMatrixD.h>
22+ #include < TMatrixDSymEigen.h>
2223#include < TObject.h>
24+ #include < TRandom.h>
25+ #include < TSystem.h>
2326
2427#include < fstream>
2528#include < map>
@@ -31,6 +34,81 @@ namespace o2
3134namespace fastsim
3235{
3336
37+ std::map<std::string, std::map<std::string, std::string>> GeometryContainer::parseTEnvConfiguration (std::string filename, std::vector<std::string>& layers)
38+ {
39+ std::map<std::string, std::map<std::string, std::string>> configMap;
40+ filename = gSystem ->ExpandPathName (filename.c_str ());
41+ TEnv env (filename.c_str ());
42+ THashList* table = env.GetTable ();
43+ layers.clear ();
44+ for (int i = 0 ; i < table->GetEntries (); ++i) {
45+ const std::string key = table->At (i)->GetName ();
46+ // key should contain exactly one dot
47+ if (key.find (' .' ) == std::string::npos || key.find (' .' ) != key.rfind (' .' )) {
48+ LOG (fatal) << " Key " << key << " does not contain exactly one dot" ;
49+ continue ;
50+ }
51+ const std::string firstPart = key.substr (0 , key.find (' .' ));
52+ if (std::find (layers.begin (), layers.end (), firstPart) == layers.end ()) {
53+ layers.push_back (firstPart);
54+ }
55+ }
56+ env.Print ();
57+ // Layers
58+ for (const auto & layer : layers) {
59+ LOG (info) << " Reading layer " << layer;
60+ for (int i = 0 ; i < table->GetEntries (); ++i) {
61+ const std::string key = table->At (i)->GetName ();
62+ if (key.find (layer + " ." ) == 0 ) {
63+ const std::string paramName = key.substr (key.find (' .' ) + 1 );
64+ const std::string value = env.GetValue (key.c_str (), " " );
65+ configMap[layer][paramName] = value;
66+ }
67+ }
68+ }
69+ return configMap;
70+ }
71+
72+ void GeometryContainer::init (o2::framework::InitContext& initContext)
73+ {
74+ std::vector<std::string> detectorConfiguration;
75+ const bool found = common::core::getTaskOptionValue (initContext, " on-the-fly-detector-geometry-provider" , " detectorConfiguration" , detectorConfiguration, false );
76+ if (!found) {
77+ LOG (fatal) << " Could not retrieve detector configuration from OnTheFlyDetectorGeometryProvider task." ;
78+ return ;
79+ }
80+ LOG (info) << " Size of detector configuration: " << detectorConfiguration.size ();
81+ for (const auto & configFile : detectorConfiguration) {
82+ LOG (info) << " Detector geometry configuration file used: " << configFile;
83+ addEntry (configFile);
84+ }
85+ }
86+
87+ std::map<std::string, std::string> GeometryContainer::GeometryEntry::getConfiguration (const std::string& layerName) const
88+ {
89+ auto it = mConfigurations .find (layerName);
90+ if (it != mConfigurations .end ()) {
91+ return it->second ;
92+ } else {
93+ LOG (fatal) << " Layer " << layerName << " not found in geometry configurations." ;
94+ return {};
95+ }
96+ }
97+
98+ std::string GeometryContainer::GeometryEntry::getValue (const std::string& layerName, const std::string& key, bool require) const
99+ {
100+ auto layer = getConfiguration (layerName);
101+ auto entry = layer.find (key);
102+ if (entry != layer.end ()) {
103+ return layer.at (key);
104+ } else if (require) {
105+ LOG (fatal) << " Key " << key << " not found in layer " << layerName << " configurations." ;
106+ return " " ;
107+ } else {
108+ return " " ;
109+ }
110+ }
111+
34112// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
35113
36114DetLayer* FastTracker::AddLayer (TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
0 commit comments