1717#include " TMatrixD.h"
1818#include " TMatrixDSymEigen.h"
1919#include " TRandom.h"
20+ #include < TEnv.h>
21+ #include < THashList.h>
22+ #include < TObject.h>
2023
24+ #include < fstream>
25+ #include < map>
2126#include < string>
2227#include < vector>
2328
@@ -30,6 +35,7 @@ namespace fastsim
3035
3136void FastTracker::AddLayer (TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
3237{
38+ LOG (debug) << " Adding layer " << name << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type;
3339 DetLayer newLayer (name, r, z, x0, xrho, resRPhi, resZ, eff, type);
3440 // Check that efficient layers are not inert layers
3541 if (newLayer.getEfficiency () > 0 .0f && newLayer.isInert ()) {
@@ -144,27 +150,42 @@ void FastTracker::AddSiliconALICE3v2(std::vector<float> pixelResolution)
144150 AddLayer (" B10" , 80 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
145151}
146152
147- void FastTracker::AddSiliconALICE3 (std::vector<float > pixelResolution)
153+ void FastTracker::AddSiliconALICE3 (float scaleX0VD, std::vector<float > pixelResolution)
148154{
149- float x0IT = 0.001 ; // 0.1%
155+ float x0Pipe0 = 0.001592 ; // 200 um AlBe
156+ float x0VDL0 = 0.00076 ; // 30 um Si + 50 um glue + carbon foam 0.03%
157+ float x0VDL1 = 0.00096 ; // 30 um Si + 50 um glue + carbon foam 0.05%
158+ float x0VDL2 = 0.00167 ; // 30 um Si + 50 um glue + carbon foam 0.05% + 0.07% Be case
159+ float x0Coldplate = 0 .02f ; // (1.5 mm Al2O3 2%)
160+ float x0Pipe1 = 0 .0023f ; // 800 um Be
150161 float x0OT = 0.01 ; // 1.0%
151- float xrhoIB = 2.3292e-02 ; // 100 mum Si
152- float xrhoOT = 2.3292e-01 ; // 1000 mum Si
153- float eff = 1.00 ;
162+ float x0iTOF = x0OT * 3 .;
154163
155- float resRPhiIT = pixelResolution[0 ];
156- float resZIT = pixelResolution[1 ];
164+ float resRPhiVD = pixelResolution[0 ];
165+ float resZVD = pixelResolution[1 ];
157166 float resRPhiOT = pixelResolution[2 ];
158167 float resZOT = pixelResolution[3 ];
159168
160- AddLayer (" bpipe0" , 0.48 , 250 , 0.00042 , 2.772e-02 , 0 .0f , 0 .0f , 0 .0f , 0 ); // 150 mum Be
161- AddLayer (" B00" , 0.5 , 250 , x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1 );
162- AddLayer (" B01" , 1.2 , 250 , x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1 );
163- AddLayer (" B02" , 2.5 , 250 , x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1 );
164- AddLayer (" bpipe1" , 3.7 , 250 , 0.0014 , 9.24e-02 , 0 .0f , 0 .0f , 0 .0f , 0 ); // 500 mum Be
169+ float xrhoPipe0 = 0 ;
170+ float xrhoVDL0 = 0 ;
171+ float xrhoVDL1 = 0 ;
172+ float xrhoVDL2 = 0 ;
173+ float xrhoColdplate = 0 ;
174+ float xrhoPipe1 = 0 ;
175+ float xrhoOT = 2.3292e-01 ;
176+ float xrhoiTOF = 0.03 ;
177+ float eff = 1.00 ;
178+
179+ AddLayer (" bpipe0" , 0.48 , 250 , x0Pipe0, xrhoPipe0, 0 .0f , 0 .0f , 0 .0f , 0 );
180+ AddLayer (" B00" , 0.5 , 250 , x0VDL0 * scaleX0VD, xrhoVDL0, resRPhiVD, resZVD, eff, 1 );
181+ AddLayer (" B01" , 1.2 , 250 , x0VDL1 * scaleX0VD, xrhoVDL1, resRPhiVD, resZVD, eff, 1 );
182+ AddLayer (" B02" , 2.5 , 250 , x0VDL2 * scaleX0VD, xrhoVDL2, resRPhiVD, resZVD, eff, 1 );
183+ AddLayer (" coldplate" , 2.6 , 250 , x0Coldplate, xrhoColdplate, 0 .0f , 0 .0f , 0 .0f , 0 );
184+ AddLayer (" bpipe1" , 5.7 , 250 , x0Pipe1, xrhoPipe1, 0 .0f , 0 .0f , 0 .0f , 0 );
165185 AddLayer (" B03" , 7 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
166186 AddLayer (" B04" , 9 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
167187 AddLayer (" B05" , 12 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
188+ AddLayer (" iTOF" , 19 , 250 , x0iTOF, xrhoiTOF, resRPhiOT, resZOT, 0 .0f , 0 );
168189 AddLayer (" B06" , 20 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
169190 AddLayer (" B07" , 30 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
170191 AddLayer (" B08" , 45 ., 250 , x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1 );
@@ -217,6 +238,76 @@ void FastTracker::AddTPC(float phiResMean, float zResMean)
217238 }
218239}
219240
241+ void FastTracker::AddGenericDetector (std::string filename, o2::ccdb::BasicCCDBManager* ccdbManager)
242+ {
243+ LOG (info) << " Adding generic detector from file " << filename;
244+ // If the filename starts with ccdb: then take the file from the ccdb
245+ if (filename.rfind (" ccdb:" , 0 ) == 0 ) {
246+ std::string ccdbPath = filename.substr (5 ); // remove "ccdb:" prefix
247+ if (ccdbManager == nullptr ) {
248+ LOG (fatal) << " CCDB manager is null, cannot retrieve file " << ccdbPath;
249+ return ;
250+ }
251+ const std::string outPath = " /tmp/DetGeo/" ;
252+ filename = Form (" %s/%s/snapshot.root" , outPath.c_str (), ccdbPath.c_str ());
253+ std::ifstream checkFile (filename); // Check if file already exists
254+ if (!checkFile.is_open ()) { // File does not exist, retrieve from CCDB
255+ LOG (info) << " --- CCDB source detected for detector geometry " << filename;
256+ std::map<std::string, std::string> metadata;
257+ ccdbManager->getCCDBAccessor ().retrieveBlob (ccdbPath, outPath, metadata, 1 );
258+ // Add CCDB handling logic here if needed
259+ LOG (info) << " --- Now retrieving geometry configuration from CCDB to: " << filename;
260+ } else { // File exists, proceed to load
261+ LOG (info) << " --- Geometry configuration file already exists: " << filename << " . Skipping download." ;
262+ checkFile.close ();
263+ }
264+ AddGenericDetector (filename, nullptr );
265+ return ;
266+ }
267+
268+ TEnv env (filename.c_str ());
269+ THashList* table = env.GetTable ();
270+ std::vector<std::string> layers;
271+ for (int i = 0 ; i < table->GetEntries (); ++i) {
272+ const std::string key = table->At (i)->GetName ();
273+ // key should contain exactly one dot
274+ if (key.find (' .' ) == std::string::npos || key.find (' .' ) != key.rfind (' .' )) {
275+ LOG (fatal) << " Key " << key << " does not contain exactly one dot" ;
276+ continue ;
277+ }
278+ const std::string firstPart = key.substr (0 , key.find (' .' ));
279+ if (std::find (layers.begin (), layers.end (), firstPart) == layers.end ()) {
280+ layers.push_back (firstPart);
281+ }
282+ }
283+ // env.Print();
284+ // Layers
285+ for (const auto & layer : layers) {
286+ LOG (info) << " Reading layer " << layer;
287+
288+ auto getKey = [&layer, &env](const std::string& name) {
289+ std::string key = layer + " ." + name;
290+ if (!env.Defined (key.c_str ())) {
291+ LOG (warning) << " Key " << key << " not defined in configuration file, getting the default value" ;
292+ }
293+ LOG (info) << " Getting key " << key;
294+ return key;
295+ };
296+ const float r = env.GetValue (getKey (" r" ).c_str (), -1 .0f );
297+ LOG (info) << " Layer " << layer << " has radius " << r;
298+ const float z = env.GetValue (getKey (" z" ).c_str (), -1 .0f );
299+ const float x0 = env.GetValue (getKey (" x0" ).c_str (), 0 .0f );
300+ const float xrho = env.GetValue (getKey (" xrho" ).c_str (), 0 .0f );
301+ const float resRPhi = env.GetValue (getKey (" resRPhi" ).c_str (), 0 .0f );
302+ const float resZ = env.GetValue (getKey (" resZ" ).c_str (), 0 .0f );
303+ const float eff = env.GetValue (getKey (" eff" ).c_str (), 0 .0f );
304+ const int type = env.GetValue (getKey (" type" ).c_str (), 0 );
305+
306+ // 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);
307+ AddLayer (layer.c_str (), r, z, x0, xrho, resRPhi, resZ, eff, type);
308+ }
309+ }
310+
220311float FastTracker::Dist (float z, float r)
221312{
222313 // porting of DetektorK::Dist
0 commit comments