2424#include < TRandom.h>
2525#include < TSystem.h>
2626
27+ #include < chrono>
2728#include < fstream>
2829#include < map>
2930#include < string>
31+ #include < thread>
3032#include < vector>
3133
3234namespace o2
3335{
3436namespace fastsim
3537{
3638
37- std::map<std::string, std::map<std::string, std::string>> GeometryContainer::parseTEnvConfiguration (std::string filename, std::vector<std::string>& layers)
39+ std::map<std::string, std::map<std::string, std::string>> GeometryContainer::parseTEnvConfiguration (std::string& filename, std::vector<std::string>& layers)
3840{
3941 std::map<std::string, std::map<std::string, std::string>> configMap;
4042 filename = gSystem ->ExpandPathName (filename.c_str ());
43+ LOG (info) << " Parsing TEnv configuration file: " << filename;
4144 TEnv env (filename.c_str ());
4245 THashList* table = env.GetTable ();
4346 layers.clear ();
@@ -78,7 +81,30 @@ void GeometryContainer::init(o2::framework::InitContext& initContext)
7881 return ;
7982 }
8083 LOG (info) << " Size of detector configuration: " << detectorConfiguration.size ();
81- for (const auto & configFile : detectorConfiguration) {
84+ for (std::string& configFile : detectorConfiguration) {
85+ if (configFile.rfind (" ccdb:" , 0 ) == 0 ) {
86+ LOG (info) << " ccdb source detected from on-the-fly-detector-geometry-provider" ;
87+ const std::string ccdbPath = configFile.substr (5 ); // remove "ccdb:" prefix
88+ const std::string outPath = " ./.ALICE3/Configuration/" ;
89+ configFile = Form (" %s/%s/snapshot.root" , outPath.c_str (), ccdbPath.c_str ());
90+
91+ int timeout = 600 ; // Wait max 10 minutes
92+ while (--timeout > 0 ) {
93+ std::ifstream file (configFile);
94+ if (file.good ()) {
95+ break ;
96+ }
97+
98+ std::this_thread::sleep_for (std::chrono::seconds (1 ));
99+ }
100+
101+ std::ifstream checkFile (configFile);
102+ if (!checkFile.good ()) {
103+ LOG (fatal) << " Timed out waiting for geometry snapshot: " << configFile;
104+ return ;
105+ }
106+ }
107+
82108 LOG (info) << " Detector geometry configuration file used: " << configFile;
83109 addEntry (configFile);
84110 }
@@ -95,6 +121,16 @@ std::map<std::string, std::string> GeometryContainer::GeometryEntry::getConfigur
95121 }
96122}
97123
124+ bool GeometryContainer::GeometryEntry::hasValue (const std::string& layerName, const std::string& key) const
125+ {
126+ auto layerIt = mConfigurations .find (layerName);
127+ if (layerIt != mConfigurations .end ()) {
128+ auto keyIt = layerIt->second .find (key);
129+ return keyIt != layerIt->second .end ();
130+ }
131+ return false ;
132+ }
133+
98134std::string GeometryContainer::GeometryEntry::getValue (const std::string& layerName, const std::string& key, bool require) const
99135{
100136 auto layer = getConfiguration (layerName);
@@ -109,6 +145,14 @@ std::string GeometryContainer::GeometryEntry::getValue(const std::string& layerN
109145 }
110146}
111147
148+ void GeometryContainer::GeometryEntry::replaceValue (const std::string& layerName, const std::string& key, const std::string& value)
149+ {
150+ if (!hasValue (layerName, key)) { // check that the key exists
151+ LOG (fatal) << " Key " << key << " does not exist in layer " << layerName << " . Cannot replace value." ;
152+ }
153+ setValue (layerName, key, value);
154+ }
155+
112156// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
113157
114158DetLayer* FastTracker::AddLayer (TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
@@ -169,106 +213,6 @@ void FastTracker::Print()
169213 LOG (info) << " +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+" ;
170214}
171215
172- void FastTracker::AddSiliconALICE3v4 (std::vector<float > pixelResolution)
173- {
174- LOG (info) << " ALICE 3: Adding v4 tracking layers" ;
175- float x0IT = 0.001 ; // 0.1%
176- float x0OT = 0.005 ; // 0.5%
177- float xrhoIB = 1.1646e-02 ; // 50 mum Si
178- float xrhoOT = 1.1646e-01 ; // 500 mum Si
179- float eff = 1.00 ;
180-
181- float resRPhiIT = pixelResolution[0 ];
182- float resZIT = pixelResolution[1 ];
183- float resRPhiOT = pixelResolution[2 ];
184- float resZOT = pixelResolution[3 ];
185-
186- AddLayer (" bpipe0" , 0.48 , 250 , 0.00042 , 2.772e-02 , 0 .0f , 0 .0f , 0 .0f , 0 ); // 150 mum Be
187- AddLayer (" ddd0" , 0.5 , 250 , x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1 );
188- AddLayer (" ddd1" , 1.2 , 250 , x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1 );
189- AddLayer (" ddd2" , 2.5 , 250 , x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1 );
190- AddLayer (" bpipe1" , 5.7 , 250 , 0.0014 , 9.24e-02 , 0 .0f , 0 .0f , 0 .0f , 0 ); // 500 mum Be
191- AddLayer (" ddd3" , 7 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
192- AddLayer (" ddd4" , 10 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
193- AddLayer (" ddd5" , 13 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
194- AddLayer (" ddd6" , 16 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
195- AddLayer (" ddd7" , 25 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
196- AddLayer (" ddd8" , 40 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
197- AddLayer (" ddd9" , 45 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
198- }
199-
200- void FastTracker::AddSiliconALICE3v2 (std::vector<float > pixelResolution)
201- {
202- LOG (info) << " ALICE 3: Adding v2 tracking layers;" ;
203- float x0IT = 0.001 ; // 0.1%
204- float x0OT = 0.01 ; // 1.0%
205- float xrhoIB = 2.3292e-02 ; // 100 mum Si
206- float xrhoOT = 2.3292e-01 ; // 1000 mum Si
207- float eff = 1.00 ;
208-
209- float resRPhiIT = pixelResolution[0 ];
210- float resZIT = pixelResolution[1 ];
211- float resRPhiOT = pixelResolution[2 ];
212- float resZOT = pixelResolution[3 ];
213-
214- AddLayer (" bpipe0" , 0.48 , 250 , 0.00042 , 2.772e-02 , 0 .0f , 0 .0f , 0 .0f , 0 ); // 150 mum Be
215- AddLayer (" B00" , 0.5 , 250 , x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1 );
216- AddLayer (" B01" , 1.2 , 250 , x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1 );
217- AddLayer (" B02" , 2.5 , 250 , x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1 );
218- AddLayer (" bpipe1" , 3.7 , 250 , 0.0014 , 9.24e-02 , 0 .0f , 0 .0f , 0 .0f , 0 ); // 500 mum Be
219- AddLayer (" B03" , 3.75 , 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
220- AddLayer (" B04" , 7 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
221- AddLayer (" B05" , 12 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
222- AddLayer (" B06" , 20 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
223- AddLayer (" B07" , 30 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
224- AddLayer (" B08" , 45 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
225- AddLayer (" B09" , 60 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
226- AddLayer (" B10" , 80 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
227- }
228-
229- void FastTracker::AddSiliconALICE3 (float scaleX0VD, std::vector<float > pixelResolution)
230- {
231- float x0Pipe0 = 0.001592 ; // 200 um AlBe
232- float x0VDL0 = 0.00076 ; // 30 um Si + 50 um glue + carbon foam 0.03%
233- float x0VDL1 = 0.00096 ; // 30 um Si + 50 um glue + carbon foam 0.05%
234- float x0VDL2 = 0.00167 ; // 30 um Si + 50 um glue + carbon foam 0.05% + 0.07% Be case
235- float x0Coldplate = 0 .02f ; // (1.5 mm Al2O3 2%)
236- float x0Pipe1 = 0 .0023f ; // 800 um Be
237- float x0OT = 0.01 ; // 1.0%
238- float x0iTOF = x0OT * 3 .;
239-
240- float resRPhiVD = pixelResolution[0 ];
241- float resZVD = pixelResolution[1 ];
242- float resRPhiOT = pixelResolution[2 ];
243- float resZOT = pixelResolution[3 ];
244-
245- float xrhoPipe0 = 0 ;
246- float xrhoVDL0 = 0 ;
247- float xrhoVDL1 = 0 ;
248- float xrhoVDL2 = 0 ;
249- float xrhoColdplate = 0 ;
250- float xrhoPipe1 = 0 ;
251- float xrhoOT = 2.3292e-01 ;
252- float xrhoiTOF = 0.03 ;
253- float eff = 1.00 ;
254-
255- AddLayer (" bpipe0" , 0.48 , 250 , x0Pipe0, xrhoPipe0, 0 .0f , 0 .0f , 0 .0f , 0 );
256- AddLayer (" B00" , 0.5 , 250 , x0VDL0 * scaleX0VD, xrhoVDL0, resRPhiVD, resZVD, eff, 1 );
257- AddLayer (" B01" , 1.2 , 250 , x0VDL1 * scaleX0VD, xrhoVDL1, resRPhiVD, resZVD, eff, 1 );
258- AddLayer (" B02" , 2.5 , 250 , x0VDL2 * scaleX0VD, xrhoVDL2, resRPhiVD, resZVD, eff, 1 );
259- AddLayer (" coldplate" , 2.6 , 250 , x0Coldplate, xrhoColdplate, 0 .0f , 0 .0f , 0 .0f , 0 );
260- AddLayer (" bpipe1" , 5.7 , 250 , x0Pipe1, xrhoPipe1, 0 .0f , 0 .0f , 0 .0f , 0 );
261- AddLayer (" B03" , 7 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
262- AddLayer (" B04" , 9 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
263- AddLayer (" B05" , 12 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
264- AddLayer (" iTOF" , 19 , 250 , x0iTOF, xrhoiTOF, resRPhiOT, resZOT, eff, 0 );
265- AddLayer (" B06" , 20 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
266- AddLayer (" B07" , 30 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
267- AddLayer (" B08" , 45 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
268- AddLayer (" B09" , 60 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
269- AddLayer (" B10" , 80 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
270- }
271-
272216void FastTracker::AddTPC (float phiResMean, float zResMean)
273217{
274218 LOG (info) << " Adding standard time projection chamber" ;
0 commit comments