]>
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 | ||
16 | /* | |
17 | $Log$ | |
b16a1b1e | 18 | Revision 1.5 2002/10/14 14:57:32 hristov |
19 | Merging the VirtualMC branch to the main development branch (HEAD) | |
20 | ||
b9d0a01d | 21 | Revision 1.3.8.1 2002/06/10 14:43:06 hristov |
22 | Merged with v3-08-02 | |
23 | ||
24 | Revision 1.4 2002/05/27 14:26:59 hristov | |
25 | New folder for track references added | |
26 | ||
536b07c2 | 27 | Revision 1.3 2001/10/04 15:30:56 hristov |
28 | Changes to accommodate the set of PHOS folders and tasks (Y.Schutz) | |
29 | ||
7e90ff59 | 30 | Revision 1.2 2001/05/21 17:22:50 buncic |
31 | Fixed problem with missing AliConfig while reading galice.root | |
32 | ||
682a4a95 | 33 | Revision 1.1 2001/05/16 14:57:22 alibrary |
34 | New files for folders and Stack | |
35 | ||
9e1a0ddb | 36 | */ |
37 | ||
b16a1b1e | 38 | #include <Riostream.h> |
39 | #include <TDatabasePDG.h> | |
40 | #include <TFolder.h> | |
41 | #include <TInterpreter.h> | |
42 | #include <TROOT.h> | |
43 | #include <TSystem.h> | |
44 | ||
9e1a0ddb | 45 | #include "AliConfig.h" |
46 | #include "AliDetector.h" | |
b16a1b1e | 47 | #include "AliGenerator.h" |
7e90ff59 | 48 | #include "TObjString.h" |
49 | #include "TString.h" | |
50 | #include "TTask.h" | |
9e1a0ddb | 51 | |
52 | ClassImp(AliConfig) | |
53 | ||
9e1a0ddb | 54 | AliConfig* AliConfig::fInstance = 0; |
55 | ||
7e90ff59 | 56 | //____________________________________________________________________________ |
9e1a0ddb | 57 | AliConfig* AliConfig::Instance () |
58 | { | |
59 | // | |
60 | // Instance method for singleton class | |
61 | // | |
b16a1b1e | 62 | if(!fInstance) fInstance = new AliConfig ("Folders","Alice data exchange"); |
63 | ||
64 | return fInstance; | |
65 | } | |
66 | ||
67 | //____________________________________________________________________________ | |
68 | AliConfig::AliConfig(): TNamed("","") | |
69 | { | |
70 | // | |
71 | // Default constructor, mainly to keep coding conventions | |
72 | // | |
73 | fTopFolder=0; | |
74 | fTasks=0; | |
75 | ||
76 | fPDGFolder=0; | |
77 | fGeneratorFolder=0; | |
78 | fMCFolder=0; | |
79 | fModuleFolder=0; | |
80 | fDetectorFolder=0; | |
81 | fDetectorTask=0; | |
82 | fInstance=0; | |
83 | ||
84 | Fatal("ctor", | |
85 | "Constructor should not be called for a singleton\n"); | |
9e1a0ddb | 86 | } |
87 | ||
b16a1b1e | 88 | //____________________________________________________________________________ |
89 | AliConfig::AliConfig(const AliConfig&): TNamed("","") | |
90 | { | |
91 | // | |
92 | // Copy constructor, mainly to keep coding conventions | |
93 | // | |
94 | fTopFolder=0; | |
95 | fTasks=0; | |
9e1a0ddb | 96 | |
b16a1b1e | 97 | fPDGFolder=0; |
98 | fGeneratorFolder=0; | |
99 | fMCFolder=0; | |
100 | fModuleFolder=0; | |
101 | fDetectorFolder=0; | |
102 | fDetectorTask=0; | |
103 | fInstance=0; | |
104 | ||
105 | Fatal("copy ctor", | |
106 | "Copy constructor should not be called for a singleton\n"); | |
107 | } | |
108 | ||
109 | //____________________________________________________________________________ | |
110 | AliConfig::AliConfig(const char *name, const char *title): | |
111 | TNamed(name,title), | |
112 | fTopFolder(gROOT->GetRootFolder ()->AddFolder (name,title)), | |
113 | fTasks(0), | |
114 | fPDGFolder("Constants/DatabasePDG"), | |
115 | fGeneratorFolder("RunMC/Configuration/Generators"), | |
116 | fMCFolder("RunMC/Configuration/VirtualMC"), | |
117 | fModuleFolder("Run/Configuration/Modules"), | |
118 | fDetectorFolder(new char*[kFolders]), | |
119 | fDetectorTask(new char*[kTasks]) | |
9e1a0ddb | 120 | { |
121 | // | |
7e90ff59 | 122 | // Constructor |
9e1a0ddb | 123 | // |
7e90ff59 | 124 | fInstance=this; |
b16a1b1e | 125 | |
7e90ff59 | 126 | fDetectorFolder[0] = "Run/Conditions/Calibration" ; |
127 | fDetectorFolder[1] = "Run/Event/Data" ; | |
128 | fDetectorFolder[2] = "Run/Event/RecData" ; | |
129 | fDetectorFolder[3] = "RunMC/Event/Data/Hits" ; | |
130 | fDetectorFolder[4] = "RunMC/Event/Data/SDigits" ; | |
131 | fDetectorFolder[5] = "Run/Conditions/QA" ; | |
536b07c2 | 132 | fDetectorFolder[6] = "RunMC/Event/Data/TrackReferences" ; |
133 | fDetectorFolder[7] = 0 ; | |
7e90ff59 | 134 | fDetectorTask[0] = "Tasks/QA" ; |
135 | fDetectorTask[1] = "Tasks/SDigitizer" ; | |
136 | fDetectorTask[2] = "Tasks/Digitizer" ; | |
137 | fDetectorTask[3] = "Tasks/Reconstructioner" ; | |
138 | fDetectorTask[4] = 0 ; | |
139 | ||
7e90ff59 | 140 | fTopFolder->SetOwner() ; |
141 | gROOT->GetListOfBrowsables ()->Add (fTopFolder, name); | |
142 | ||
143 | TFolder *subfolder; | |
144 | ||
145 | TFolder *constants = | |
146 | fTopFolder->AddFolder ("Constants", "Detector constants"); | |
147 | ||
148 | subfolder = | |
149 | constants->AddFolder ("DatabasePDG", "PDG database"); | |
150 | ||
151 | TFolder *run = | |
152 | fTopFolder->AddFolder ("Run", "Run dependent folders"); | |
153 | ||
154 | TFolder *conditions = | |
155 | run->AddFolder ("Conditions", "Run conditions"); | |
156 | ||
157 | subfolder = | |
158 | conditions->AddFolder ("Calibration","Detector calibration data"); | |
159 | ||
160 | subfolder = | |
161 | conditions->AddFolder ("Aligment", "Detector aligment"); | |
162 | ||
163 | subfolder = | |
164 | conditions->AddFolder ("QA", "Detector QA"); | |
165 | ||
166 | TFolder *configuration = | |
167 | run->AddFolder ("Configuration", "Run configuration"); | |
168 | ||
169 | subfolder = | |
170 | configuration->AddFolder ("Modules", "Detector objects"); | |
171 | ||
172 | subfolder = | |
173 | configuration->AddFolder ("Field", "Magnetic field maps"); | |
174 | ||
175 | TFolder *event = | |
176 | run->AddFolder ("Event", "Event folders"); | |
177 | ||
178 | subfolder = | |
179 | event->AddFolder ("Data", "Detector raw data"); | |
180 | ||
181 | subfolder = | |
182 | event->AddFolder ("RecData", "Detectors reconstucted data"); | |
183 | ||
184 | TFolder *run_mc = | |
185 | fTopFolder->AddFolder ("RunMC", "MonteCarlo run dependent folders"); | |
186 | ||
187 | TFolder *configuration_mc = | |
188 | run_mc->AddFolder ("Configuration","MonteCarlo run configuration"); | |
189 | ||
190 | subfolder = | |
191 | configuration_mc->AddFolder ("Generators","list of generator objects"); | |
192 | ||
193 | subfolder = | |
194 | configuration_mc->AddFolder ("VirtualMC", "the Virtual MC"); | |
195 | ||
196 | TFolder *event_mc = | |
197 | run_mc->AddFolder ("Event", "MonteCarlo event folders"); | |
198 | ||
199 | subfolder = | |
200 | event_mc->AddFolder ("Header", "MonteCarlo event header"); | |
201 | ||
202 | // subfolder = | |
203 | // event_mc->AddFolder ("Kinematics", "MonteCarlo generated particles"); | |
204 | ||
205 | TFolder *data_mc = | |
206 | event_mc->AddFolder ("Data", "MonteCarlo data"); | |
207 | ||
208 | subfolder = | |
209 | data_mc->AddFolder ("Hits", "MonteCarlo Hits") ; | |
210 | ||
211 | subfolder = | |
212 | data_mc->AddFolder ("SDigits", "MonteCarlo SDigits") ; | |
213 | ||
536b07c2 | 214 | subfolder = |
215 | data_mc->AddFolder ("TrackReferences", "MonteCarlo track references") ; | |
216 | ||
7e90ff59 | 217 | |
218 | ||
219 | // Add the tasks to //Folders | |
220 | ||
221 | TFolder * tasksfolder = fTopFolder->AddFolder("Tasks", "ALICE Tasks") ; | |
222 | ||
223 | TTask * qa = new TTask("QA", "Alice QA tasks") ; | |
224 | tasksfolder->Add(qa); | |
225 | ||
226 | TTask * sd = new TTask("SDigitizer", "Alice SDigitizer") ; | |
227 | tasksfolder->Add(sd); | |
228 | ||
229 | TTask * di = new TTask("Digitizer", "Alice Digitizer") ; | |
230 | tasksfolder->Add(di); | |
231 | ||
232 | TTask * re = new TTask("Reconstructioner", "Alice Reconstructioner") ; | |
233 | tasksfolder->Add(re); | |
9e1a0ddb | 234 | |
235 | } | |
236 | ||
7e90ff59 | 237 | //____________________________________________________________________________ |
9e1a0ddb | 238 | AliConfig::~AliConfig() |
239 | { | |
536b07c2 | 240 | delete [] fDetectorFolder ; |
7e90ff59 | 241 | delete fDetectorTask ; |
242 | delete fTopFolder ; | |
9e1a0ddb | 243 | } |
244 | ||
7e90ff59 | 245 | //____________________________________________________________________________ |
b16a1b1e | 246 | void AliConfig::AddInFolder (char *dir, TObject *obj) |
9e1a0ddb | 247 | { |
7e90ff59 | 248 | TFolder *folder = |
249 | dynamic_cast<TFolder *>(fTopFolder->FindObject(dir)); | |
250 | if (folder) | |
251 | folder->Add (static_cast<TObject *>(obj)); | |
9e1a0ddb | 252 | } |
253 | ||
7e90ff59 | 254 | //____________________________________________________________________________ |
255 | void AliConfig::AddSubFolder(char * dir[], TObject *obj) | |
9e1a0ddb | 256 | { |
7e90ff59 | 257 | int iDir = 0; |
258 | ||
259 | while (dir[iDir]) | |
260 | { | |
261 | TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject (dir[iDir++])); | |
262 | if (folder) { | |
263 | TFolder * subfolder = dynamic_cast<TFolder *>(folder->FindObject (obj->GetName())); | |
264 | if (!subfolder) | |
265 | subfolder = folder->AddFolder (obj->GetName(),obj->GetTitle()); | |
266 | } | |
267 | } | |
268 | } | |
9e1a0ddb | 269 | |
7e90ff59 | 270 | //____________________________________________________________________________ |
271 | void AliConfig::AddSubTask(char * dir[], TObject *obj) | |
272 | { | |
273 | int iDir = 0; | |
274 | ||
275 | while (dir[iDir]) | |
276 | { | |
277 | TTask * task = dynamic_cast<TTask *>(fTopFolder->FindObject (dir[iDir++])); | |
278 | if (task) { | |
279 | TTask * subtask = static_cast<TTask*>(task->GetListOfTasks()->FindObject (obj->GetName())); | |
280 | if (!subtask) { | |
281 | subtask = new TTask(obj->GetName(), obj->GetTitle()) ; | |
282 | task->Add(subtask); | |
283 | } | |
284 | } | |
285 | } | |
9e1a0ddb | 286 | } |
287 | ||
7e90ff59 | 288 | //____________________________________________________________________________ |
9e1a0ddb | 289 | TObject* AliConfig::FindInFolder (char *dir, const char *name) |
290 | { | |
7e90ff59 | 291 | if(!name) return(fTopFolder->FindObject(name)); |
292 | TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir)); | |
293 | if (!folder) return (NULL); | |
294 | return(folder->FindObject(name)); | |
9e1a0ddb | 295 | } |
296 | ||
7e90ff59 | 297 | //____________________________________________________________________________ |
9e1a0ddb | 298 | void AliConfig::Add (AliGenerator * obj) |
299 | { | |
7e90ff59 | 300 | AddInFolder(fGeneratorFolder, obj); |
9e1a0ddb | 301 | } |
302 | ||
7e90ff59 | 303 | //____________________________________________________________________________ |
9e1a0ddb | 304 | void AliConfig::Add (AliMC * obj) |
305 | { | |
7e90ff59 | 306 | AddInFolder(fMCFolder, obj); |
9e1a0ddb | 307 | } |
308 | ||
7e90ff59 | 309 | //____________________________________________________________________________ |
9e1a0ddb | 310 | void AliConfig::Add (TDatabasePDG * obj) |
311 | { | |
7e90ff59 | 312 | AddInFolder(fPDGFolder, obj); |
9e1a0ddb | 313 | } |
314 | ||
7e90ff59 | 315 | //____________________________________________________________________________ |
9e1a0ddb | 316 | void AliConfig::Add (AliModule* obj) |
317 | { | |
7e90ff59 | 318 | AddInFolder(fModuleFolder, obj); |
9e1a0ddb | 319 | } |
320 | ||
7e90ff59 | 321 | //____________________________________________________________________________ |
9e1a0ddb | 322 | void AliConfig::Add (AliDetector * obj) |
323 | { | |
7e90ff59 | 324 | AddSubFolder(fDetectorFolder, obj); |
325 | AddSubTask(fDetectorTask, obj); | |
9e1a0ddb | 326 | } |
327 | ||
9e1a0ddb | 328 | |
7e90ff59 | 329 | //____________________________________________________________________________ |
330 | void AliConfig::Add (char *list) | |
331 | { | |
332 | char *path; | |
333 | ||
334 | const char *conf_path = gSystem->Getenv ("ALICE_CONFIG_PATH"); | |
335 | if (conf_path) { | |
336 | path = new char[strlen (conf_path)]; | |
337 | strcpy (path, conf_path); | |
338 | } else { | |
339 | const char *alice = gSystem->Getenv ("ALICE_ROOT"); | |
340 | path = new char[strlen (alice) + 32]; | |
341 | ||
342 | strcpy (path, ".:"); | |
343 | if (alice) { | |
344 | strcat (path, alice); | |
345 | } | |
346 | strcat (path, "/macros/config"); | |
347 | } | |
348 | ||
349 | char *token = strtok (path, ":"); | |
350 | ||
351 | TList *dirlist = new TList; | |
352 | ||
353 | while (token != NULL) | |
354 | { | |
355 | dirlist->Add (new TObjString(token)); | |
356 | token = strtok (NULL, ":"); | |
357 | } | |
358 | ||
359 | token = strtok (list, " "); | |
360 | ||
361 | while (token != NULL) | |
362 | { | |
363 | cout << "Configuring " << token << ": "; | |
364 | ||
365 | TObject *obj; | |
366 | TIter next (dirlist); | |
367 | TString found = "\0"; | |
368 | ||
369 | while ((obj = next ())) | |
370 | { | |
371 | TString dir(obj->GetName()); | |
372 | TString path = dir + "/" + token; | |
373 | TString macro = path + ".C"; | |
374 | if (!gSystem->AccessPathName (macro.Data())) { | |
375 | gInterpreter->ExecuteMacro (macro.Data()); | |
376 | found = "(" + macro + ")"; | |
377 | if (macro.Contains("/")) { | |
378 | TString dirname = gSystem->DirName(macro.Data()); | |
379 | TString macroConfigure = dirname + "/Configure.C"; | |
380 | if (!gSystem->AccessPathName (macroConfigure.Data())) { | |
381 | gInterpreter->ExecuteMacro (macroConfigure.Data()); | |
382 | found += " => Configured"; | |
383 | } | |
384 | } | |
385 | break; | |
386 | } else { | |
387 | TString macroDefault = path + "/Default.C"; | |
388 | if (!gSystem->AccessPathName (macroDefault.Data())) { | |
389 | gInterpreter->ExecuteMacro (macroDefault.Data()); | |
390 | found = "(" + macro + ")"; | |
391 | TString macroConfigure = path + "/Configure.C"; | |
392 | if (!gSystem->AccessPathName (macroConfigure.Data())) { | |
393 | gInterpreter->ExecuteMacro (macroConfigure.Data()); | |
394 | found += " => Configured"; | |
395 | } | |
396 | break; | |
397 | } | |
398 | } | |
399 | } | |
400 | ||
401 | if (strlen(found.Data())) { | |
402 | cout << found << " => OK" << endl; | |
403 | } else { | |
404 | cout << " => FAILED." << endl; | |
405 | exit(1); | |
406 | } | |
407 | ||
408 | token = strtok (NULL, " "); | |
409 | } | |
410 | ||
411 | if (dirlist) delete dirlist; | |
412 | ||
9e1a0ddb | 413 | } |
414 | ||
415 |