]>
Commit | Line | Data |
---|---|---|
9e1a0ddb | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
acd84897 | 16 | /* $Id$ */ |
9e1a0ddb | 17 | |
88cb7938 | 18 | // Description: |
19 | // This class is responsible for creating folder structure | |
20 | // All stuff of aliroot sits in one folder with name defined by | |
21 | // fgkTopFolderName data wich do not very trough event to event are | |
22 | // sitting in directly in "top folder" all data which changes from | |
23 | // event to event are sitting in one folder (which has more subfolders) | |
24 | // Idea is to have more than one event in folder structure which allows | |
25 | // usage of standard procedures in merging | |
26 | // Add(AliDetector*) calls Add(AliModule*) as AliDetector is a AliModule | |
27 | // as well and should be listed in module list | |
5d8718b8 | 28 | |
b16a1b1e | 29 | #include <TDatabasePDG.h> |
30 | #include <TFolder.h> | |
31 | #include <TInterpreter.h> | |
88cb7938 | 32 | #include <TObjString.h> |
b16a1b1e | 33 | #include <TROOT.h> |
88cb7938 | 34 | #include <TString.h> |
b16a1b1e | 35 | #include <TSystem.h> |
98490ea9 | 36 | #include <TVirtualMC.h> |
b16a1b1e | 37 | |
9e1a0ddb | 38 | #include "AliConfig.h" |
39 | #include "AliDetector.h" | |
b16a1b1e | 40 | #include "AliGenerator.h" |
88cb7938 | 41 | #include "AliLoader.h" |
21bf7095 | 42 | #include "AliLog.h" |
88cb7938 | 43 | |
88cb7938 | 44 | enum |
45 | { | |
46 | kDetFolderData = 0, | |
47 | kDetFolderCalibration, | |
48 | kDetFolderAligmnet, | |
88cb7938 | 49 | kDetFolderLast |
50 | }; | |
9e1a0ddb | 51 | ClassImp(AliConfig) |
52 | ||
d0d4a6b3 | 53 | AliConfig* AliConfig::fgInstance = 0; |
88cb7938 | 54 | |
55 | //0 level folder | |
56 | const TString AliConfig::fgkTopFolderName("Folders"); | |
57 | ||
58 | //1st level folder | |
88cb7938 | 59 | const TString AliConfig::fgkConstantsFolderName("Constants"); |
60 | const TString AliConfig::fgkDefaultEventFolderName("Event"); //default folder for event, always used except merging | |
61 | ||
62 | //2st level folder | |
63 | //subfolder of event folder | |
64 | const TString AliConfig::fgkDataFolderName("Data");//folder for data (hits, digits, points, tracks) grouped by detectors | |
65 | const TString AliConfig::fgkModuleFolderName("Modules");//folder with modules objects | |
66 | const TString AliConfig::fgkConditionsFolderName("Conditions");//folder with conditions (mag. field etc.) | |
67 | const TString AliConfig::fgkConfigurationFolderName("Configuration");//folder with configuration (setup) of the detector | |
68 | const TString AliConfig::fgkHeaderFolderName("Header");//folder with header and other MC information | |
69 | ||
88cb7938 | 70 | //3rd level folder |
71 | //fgkConditionsFolderName subfolders | |
72 | const TString AliConfig::fgkCalibrationFolderName("Calibration"); | |
73 | const TString AliConfig::fgkAligmentFolderName("Aligment"); | |
88cb7938 | 74 | |
75 | //3rd level folder | |
76 | //fgkConfigurationFolderName subfolders | |
77 | const TString AliConfig::fgkFieldFolderName("Field"); | |
78 | const TString AliConfig::fgkGeneratorsFolderName("Generators"); | |
79 | const TString AliConfig::fgkVirtualMCFolderName("VirtualMC"); | |
80 | ||
81 | ||
82 | const TString AliConfig::fgkPDGFolderName("Constants/DatabasePDG");//folder with PDG Database | |
83 | const TString AliConfig::fgkGeneratorFolderName("Configuration/Generators");//folder with generators | |
84 | const TString AliConfig::fgkMCFolderName("Configuration/VirtualMC"); | |
9e1a0ddb | 85 | |
7e90ff59 | 86 | //____________________________________________________________________________ |
9e1a0ddb | 87 | AliConfig* AliConfig::Instance () |
88 | { | |
89 | // | |
90 | // Instance method for singleton class | |
91 | // | |
d0d4a6b3 | 92 | if(fgInstance == 0) |
88cb7938 | 93 | { |
d0d4a6b3 | 94 | fgInstance = new AliConfig (fgkTopFolderName,"Alice data exchange board"); |
88cb7938 | 95 | } |
d0d4a6b3 | 96 | return fgInstance; |
b16a1b1e | 97 | } |
d0d4a6b3 | 98 | //____________________________________________________________________________ |
99 | ||
b16a1b1e | 100 | AliConfig::AliConfig(const char *name, const char *title): |
101 | TNamed(name,title), | |
88cb7938 | 102 | fTopFolder(gROOT->GetRootFolder()->AddFolder(name,title)), |
88cb7938 | 103 | fConstFolder(0x0), |
88cb7938 | 104 | fDetectorFolder(new TString[kDetFolderLast+1]) |
9e1a0ddb | 105 | { |
88cb7938 | 106 | // Constructor |
107 | ||
108 | //Main AliRoot Folder | |
109 | if (fTopFolder == 0x0) | |
110 | { | |
21bf7095 | 111 | AliFatal("Can not create Top Alice Folder."); |
88cb7938 | 112 | return;//never reached |
113 | } | |
114 | fTopFolder->SetOwner(); | |
7e90ff59 | 115 | |
88cb7938 | 116 | fDetectorFolder[kDetFolderData] = fgkDataFolderName; |
117 | fDetectorFolder[kDetFolderCalibration] = fgkConditionsFolderName+"/"+fgkCalibrationFolderName; | |
118 | fDetectorFolder[kDetFolderAligmnet] = fgkConditionsFolderName+"/"+fgkAligmentFolderName; | |
88cb7938 | 119 | fDetectorFolder[kDetFolderLast] = ""; |
7e90ff59 | 120 | |
88cb7938 | 121 | gROOT->GetListOfBrowsables()->Add(fTopFolder, name); |
7e90ff59 | 122 | |
88cb7938 | 123 | //Constants folder |
07c4aae4 | 124 | fConstFolder = fTopFolder->AddFolder (fgkConstantsFolderName, "Constant parameters"); |
88cb7938 | 125 | fConstFolder->AddFolder("DatabasePDG", "PDG database"); |
7e90ff59 | 126 | |
d0d4a6b3 | 127 | fgInstance=this; |
9e1a0ddb | 128 | } |
129 | ||
7e90ff59 | 130 | //____________________________________________________________________________ |
9e1a0ddb | 131 | AliConfig::~AliConfig() |
132 | { | |
d0d4a6b3 | 133 | // destructor |
536b07c2 | 134 | delete [] fDetectorFolder ; |
88cb7938 | 135 | if (fTopFolder) |
136 | { | |
137 | fTopFolder->SetOwner(); | |
138 | delete fTopFolder; | |
139 | } | |
9e1a0ddb | 140 | } |
7e90ff59 | 141 | //____________________________________________________________________________ |
88cb7938 | 142 | |
e2afb3b6 | 143 | void AliConfig::AddInFolder (const char *dir, TObject *obj) |
9e1a0ddb | 144 | { |
d0d4a6b3 | 145 | // Adds object "obj" to folder "dir" |
88cb7938 | 146 | TFolder *folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir)); |
7e90ff59 | 147 | if (folder) |
148 | folder->Add (static_cast<TObject *>(obj)); | |
9e1a0ddb | 149 | } |
9e1a0ddb | 150 | |
7e90ff59 | 151 | //____________________________________________________________________________ |
e2afb3b6 | 152 | TObject* AliConfig::FindInFolder (const char *dir, const char *name) |
9e1a0ddb | 153 | { |
d0d4a6b3 | 154 | // Finds object with name "name" in folder "dir" |
7e90ff59 | 155 | if(!name) return(fTopFolder->FindObject(name)); |
156 | TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir)); | |
157 | if (!folder) return (NULL); | |
158 | return(folder->FindObject(name)); | |
9e1a0ddb | 159 | } |
160 | ||
7e90ff59 | 161 | //____________________________________________________________________________ |
88cb7938 | 162 | void AliConfig::Add (AliGenerator * obj,const char* eventfolder) |
9e1a0ddb | 163 | { |
d0d4a6b3 | 164 | // Adds generator "obj" to the event folder "eventfolder" |
88cb7938 | 165 | TString path(eventfolder); |
166 | path = path + "/" + fgkGeneratorsFolderName; | |
167 | AddInFolder(path,obj); | |
9e1a0ddb | 168 | } |
169 | ||
7e90ff59 | 170 | //____________________________________________________________________________ |
88cb7938 | 171 | void AliConfig::Add (TVirtualMC * obj,const char* eventfolder) |
9e1a0ddb | 172 | { |
d0d4a6b3 | 173 | // Adds TVirtualMC object to the event folder |
88cb7938 | 174 | TString path(eventfolder); |
175 | path = path + "/" + fgkMCFolderName; | |
176 | AddInFolder(path, obj); | |
9e1a0ddb | 177 | } |
178 | ||
7e90ff59 | 179 | //____________________________________________________________________________ |
88cb7938 | 180 | void AliConfig::Add (TDatabasePDG * obj) |
9e1a0ddb | 181 | { |
d0d4a6b3 | 182 | // Adds TDataBase object |
88cb7938 | 183 | AddInFolder(fgkPDGFolderName, obj); |
9e1a0ddb | 184 | } |
185 | ||
7e90ff59 | 186 | //____________________________________________________________________________ |
88cb7938 | 187 | void AliConfig::Add(AliModule* obj,const char* eventfolder) |
9e1a0ddb | 188 | { |
d0d4a6b3 | 189 | // Adds module to the event folder |
88cb7938 | 190 | TString path(eventfolder); |
191 | path = path + "/" + fgkModuleFolderName; | |
21bf7095 | 192 | AliDebug(1, Form("module name = %s, Ev. Fold. Name is %s.", |
193 | obj->GetName(),eventfolder)); | |
88cb7938 | 194 | AddInFolder(path, obj); |
9e1a0ddb | 195 | } |
88cb7938 | 196 | //____________________________________________________________________________ |
9e1a0ddb | 197 | |
88cb7938 | 198 | Int_t AliConfig::AddDetector(TFolder* evntfolder, const char *name, const char* title) |
199 | { | |
f21fc003 | 200 | //creates folders for the detector 'name' |
88cb7938 | 201 | Int_t retval;//returned value |
202 | retval = CreateDetectorFolders(evntfolder,name,title); | |
203 | if (retval) | |
204 | { | |
21bf7095 | 205 | AliError(Form("CreateDetectorFolders returned error for detector %s",name)); |
88cb7938 | 206 | return retval; |
207 | } | |
208 | return 0; | |
209 | } | |
7e90ff59 | 210 | //____________________________________________________________________________ |
88cb7938 | 211 | |
212 | Int_t AliConfig::AddDetector(const char* evntfoldername,const char *name, const char* title) | |
9e1a0ddb | 213 | { |
f21fc003 | 214 | //creates folders for the detector 'name' |
88cb7938 | 215 | Int_t retval;//returned value |
216 | retval = CreateDetectorFolders(evntfoldername,name,title); | |
217 | if (retval) | |
218 | { | |
21bf7095 | 219 | AliError(Form("CreateDetectorFolders returned error for detector %s",name)); |
88cb7938 | 220 | return retval; |
221 | } | |
88cb7938 | 222 | return 0; |
9e1a0ddb | 223 | } |
88cb7938 | 224 | //____________________________________________________________________________ |
9e1a0ddb | 225 | |
88cb7938 | 226 | void AliConfig::Add(AliDetector * obj,const char* eventfolder) |
227 | { | |
d0d4a6b3 | 228 | // Adds new AliDetector objest to the correspondent event folder |
21bf7095 | 229 | AliDebug(1, Form("detector name = %s, Ev. Fold. Name is %s.", |
230 | obj->GetName(),eventfolder)); | |
88cb7938 | 231 | |
232 | TObject* foundobj = GetTopFolder()->FindObject(eventfolder); | |
233 | TFolder* evfolder = (foundobj)?dynamic_cast<TFolder*>(foundobj):0x0; | |
234 | if (evfolder == 0x0) | |
235 | { | |
21bf7095 | 236 | AliFatal(Form("Can not find folder %s while adding detector %s",eventfolder,obj->GetName())); |
88cb7938 | 237 | return; |
238 | } | |
239 | CreateDetectorFolders(evfolder, obj->GetName(), obj->GetTitle()); | |
240 | ||
88cb7938 | 241 | } |
242 | //____________________________________________________________________________ | |
243 | ||
244 | Int_t AliConfig::CreateDetectorFolders(const char* evntfoldername,const char *name, const char* title) | |
245 | { | |
246 | //creates a folders for detector named 'name' and titled 'title' | |
247 | //in a event folder named 'evntfoldername' | |
248 | //list of folder names where new folders are created is defined in fDetectorFolder array | |
249 | //detector folders are named 'name' and titled 'title' as well | |
250 | ||
251 | TFolder* evfolder = dynamic_cast<TFolder*>(GetTopFolder()->FindObject(evntfoldername)); | |
252 | if (evfolder == 0x0) | |
253 | { | |
21bf7095 | 254 | AliError(Form("Can not find folder %s while adding detector %s",evntfoldername,name)); |
88cb7938 | 255 | return 1; |
256 | } | |
257 | return CreateDetectorFolders(evfolder,name,title); | |
258 | } | |
259 | //____________________________________________________________________________ | |
260 | Int_t AliConfig::CreateDetectorFolders(TFolder* evntfolder,const char *name, const char* title) | |
261 | { | |
262 | //creates a folders for detector named 'name' and titled 'title' | |
263 | //in a event folder 'evntfolder' | |
264 | //list of folder names where new folders are created is defined in fDetectorFolder array | |
265 | //detector folders are named 'name' and titled 'title' as well | |
266 | //Here we add only detector not an modules | |
267 | ||
268 | Int_t tmp; | |
269 | Int_t i = 0;//iterator | |
270 | while(!fDetectorFolder[i].IsNull()) | |
271 | { | |
272 | tmp = AddSubFolder(evntfolder,fDetectorFolder[i],name,title); | |
273 | if (tmp) | |
274 | { | |
21bf7095 | 275 | AliError(Form("Failed to create subfolder of %s for detector %s",fDetectorFolder[i].Data(),name)); |
88cb7938 | 276 | return 1; |
277 | } | |
278 | i++; | |
279 | } | |
280 | return 0; | |
281 | } | |
9e1a0ddb | 282 | |
88cb7938 | 283 | /*****************************************************************************/ |
284 | ||
285 | TFolder* AliConfig::BuildEventFolder(const char* name,const char* title) | |
286 | { | |
287 | /* | |
288 | creates the folder structure for one event | |
f21fc003 | 289 | TopFolder |
88cb7938 | 290 | |_ |
291 | | \ | |
292 | | Constants | |
293 | |_ | |
294 | | \ | |
295 | | Event_ | |
296 | | | \ | |
297 | | | Modules(detector objects) | |
298 | | |_ | |
299 | | | \ | |
300 | | | Header | |
301 | | |_ | |
302 | | | \ | |
303 | | | Data_ | |
304 | | | | \ | |
305 | | | | TPC_ | |
306 | | | | | \ | |
307 | | | | | Hits(object;e.g. tree) | |
308 | | | | |_ | |
309 | | | | | \ | |
310 | | | | | SDigits(object) | |
311 | | | | |_ | |
312 | | | | | \ | |
313 | | | | | Digits(object) | |
314 | | | | |_ | |
315 | | | | | \ | |
316 | | | | | RecPoints(object) | |
317 | | | | |_ | |
318 | | | | \ | |
319 | | | | Tracks(object) | |
320 | | | |_ | |
321 | | | \ | |
322 | | | ITS_ | |
323 | | | | \ | |
324 | | | | Hits(object;e.g. tree) | |
325 | | | |_ | |
326 | | | | \ | |
327 | | | | SDigits(object) | |
328 | | | |_ | |
329 | | | | \ | |
330 | | | | Digits(object) | |
331 | | | |_ | |
332 | | | | \ | |
333 | | | | RecPoints(object) | |
334 | | | |_ | |
335 | | | \ | |
336 | | | Tracks(object) | |
337 | | |_ | |
338 | | \ | |
339 | | Configuration | |
340 | | | |
341 | |_ | |
342 | \ | |
343 | Event2_ (to be merged with event) | |
344 | | \ | |
345 | | Modules(detector objects) | |
346 | |_ | |
347 | | \ | |
348 | | Header | |
349 | |_ | |
350 | | \ | |
351 | | Data_ | |
352 | | | \ | |
353 | | | TPC_ | |
354 | | | | \ | |
355 | | | | Hits(object;e.g. tree) | |
356 | | | |_ | |
357 | | | | \ | |
358 | | | | SDigits(object) | |
359 | | | |_ | |
360 | | | | \ | |
361 | | | | Digits(object) | |
362 | | | |_ | |
363 | | | | \ | |
364 | | | | RecPoints(object) | |
365 | | | |_ | |
366 | | | \ | |
367 | | | Tracks(object) | |
368 | | |_ | |
369 | | \ | |
370 | | ITS_ | |
371 | | | \ | |
372 | | | Hits(object;e.g. tree) | |
373 | | |_ | |
374 | | | \ | |
375 | | | SDigits(object) | |
376 | | |_ | |
377 | | | \ | |
378 | | | Digits(object) | |
379 | | |_ | |
380 | | | \ | |
381 | | | RecPoints(object) | |
382 | | |_ | |
383 | | \ | |
384 | | Tracks(object) | |
385 | |_ | |
386 | \ | |
387 | Configuration | |
388 | ||
389 | */ | |
390 | TFolder* eventfolder = fTopFolder->AddFolder(name,title); | |
391 | ||
392 | //modules | |
393 | eventfolder->AddFolder(fgkModuleFolderName, "Detector objects"); | |
394 | //event data | |
395 | eventfolder->AddFolder(fgkDataFolderName, "Detector data"); | |
396 | ||
397 | //Conditions | |
398 | TFolder *conditions = eventfolder->AddFolder(fgkConditionsFolderName, "Run conditions"); | |
399 | conditions->AddFolder(fgkCalibrationFolderName,"Detector calibration data"); | |
400 | conditions->AddFolder(fgkAligmentFolderName,"Detector aligment"); | |
88cb7938 | 401 | //Configuration |
402 | TFolder *configuration = eventfolder->AddFolder(fgkConfigurationFolderName, "Run configuration"); | |
403 | configuration->AddFolder(fgkFieldFolderName, "Magnetic field maps"); | |
404 | configuration->AddFolder(fgkGeneratorsFolderName,"list of generator objects"); | |
091e67f3 | 405 | //PH configuration->AddFolder(fgkVirtualMCFolderName,"the Virtual MC"); |
88cb7938 | 406 | |
407 | eventfolder->AddFolder(fgkHeaderFolderName,"MonteCarlo event header"); | |
408 | ||
409 | eventfolder->SetOwner(); | |
410 | ||
411 | return eventfolder; | |
412 | } | |
413 | ||
414 | /*****************************************************************************/ | |
9e1a0ddb | 415 | |
d0d4a6b3 | 416 | const TString& AliConfig::GetDataFolderName() const |
88cb7938 | 417 | { |
418 | //returns name of data folder path relative to event folder | |
419 | return fgkDataFolderName; | |
420 | } | |
f21fc003 | 421 | |
88cb7938 | 422 | /*****************************************************************************/ |
423 | ||
424 | Int_t AliConfig::AddSubFolder(TFolder* topfolder, const char* infoler, | |
425 | const char* newfoldname, const char* newfoldtitle) | |
426 | { | |
427 | //helper method | |
428 | //in topfolder looks for folder named 'infolder' | |
429 | //and if it exist it creates inside a new folder named 'newfoldname' and titled 'newfoldtitle' | |
430 | ||
431 | if (topfolder == 0x0)//check if exists top folder | |
432 | { | |
21bf7095 | 433 | AliError("Parameter TFolder* points to NULL."); |
88cb7938 | 434 | return 1; |
435 | } | |
436 | ||
437 | TObject *obj; | |
438 | TFolder* folder; | |
439 | ||
440 | folder = dynamic_cast<TFolder*>(topfolder->FindObject(infoler)); | |
441 | if (folder == 0x0) //check if we got inolder | |
442 | { | |
21bf7095 | 443 | AliError(Form("Can not find folder %s in folder %s.",infoler,topfolder->GetName())); |
88cb7938 | 444 | return 1; |
445 | } | |
446 | obj = folder->FindObject(newfoldname); //see if such a subfolder already exists | |
447 | if (obj == 0x0) //nope | |
448 | { | |
449 | TFolder *newfolder = folder->AddFolder(newfoldname,newfoldtitle);//add the desired subfolder | |
450 | if (newfolder == 0x0) //check if we managed | |
451 | { | |
21bf7095 | 452 | AliError(Form("Can not create folder %s in folder %s",newfoldname,infoler)); |
88cb7938 | 453 | return 2; |
454 | } | |
455 | else return 0;//success | |
456 | } | |
0798b21e | 457 | //such an object already exists |
458 | TFolder* fol = dynamic_cast<TFolder*>(obj); | |
459 | if (fol == 0x0) | |
460 | { | |
21bf7095 | 461 | AliError(Form("Object named %s already exists in folder %s AND IT IS NOT A FOLDER",newfoldname,infoler)); |
0798b21e | 462 | return 3; |
463 | } | |
21bf7095 | 464 | AliWarning(Form("Folder named %s already exists in folder %s",newfoldname,infoler)); |
0798b21e | 465 | return 0; |
88cb7938 | 466 | } |