1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.2 2001/05/21 17:22:50 buncic
19 Fixed problem with missing AliConfig while reading galice.root
21 Revision 1.1 2001/05/16 14:57:22 alibrary
22 New files for folders and Stack
26 #include "AliConfig.h"
27 #include "AliDetector.h"
28 #include "TObjString.h"
31 #include "AliGenerator.h"
37 AliConfig* AliConfig::fInstance = 0;
39 //____________________________________________________________________________
40 AliConfig* AliConfig::Instance ()
43 // Instance method for singleton class
46 fInstance = new AliConfig ("Folders","Alice data exchange");
52 AliConfig::AliConfig(const char *name, const char *title)
62 fPDGFolder = "Constants/DatabasePDG" ;
63 fGeneratorFolder = "RunMC/Configuration/Generators" ;
64 fMCFolder = "RunMC/Configuration/VirtualMC" ;
65 fModuleFolder = "Run/Configuration/Modules" ;
66 fDetectorFolder = new char*[7] ;
67 fDetectorFolder[0] = "Run/Conditions/Calibration" ;
68 fDetectorFolder[1] = "Run/Event/Data" ;
69 fDetectorFolder[2] = "Run/Event/RecData" ;
70 fDetectorFolder[3] = "RunMC/Event/Data/Hits" ;
71 fDetectorFolder[4] = "RunMC/Event/Data/SDigits" ;
72 fDetectorFolder[5] = "Run/Conditions/QA" ;
73 fDetectorFolder[6] = 0 ;
74 fDetectorTask = new char*[5] ;
75 fDetectorTask[0] = "Tasks/QA" ;
76 fDetectorTask[1] = "Tasks/SDigitizer" ;
77 fDetectorTask[2] = "Tasks/Digitizer" ;
78 fDetectorTask[3] = "Tasks/Reconstructioner" ;
79 fDetectorTask[4] = 0 ;
81 fTopFolder = gROOT->GetRootFolder ()->AddFolder (name,title);
82 fTopFolder->SetOwner() ;
83 gROOT->GetListOfBrowsables ()->Add (fTopFolder, name);
88 fTopFolder->AddFolder ("Constants", "Detector constants");
91 constants->AddFolder ("DatabasePDG", "PDG database");
94 fTopFolder->AddFolder ("Run", "Run dependent folders");
97 run->AddFolder ("Conditions", "Run conditions");
100 conditions->AddFolder ("Calibration","Detector calibration data");
103 conditions->AddFolder ("Aligment", "Detector aligment");
106 conditions->AddFolder ("QA", "Detector QA");
108 TFolder *configuration =
109 run->AddFolder ("Configuration", "Run configuration");
112 configuration->AddFolder ("Modules", "Detector objects");
115 configuration->AddFolder ("Field", "Magnetic field maps");
118 run->AddFolder ("Event", "Event folders");
121 event->AddFolder ("Data", "Detector raw data");
124 event->AddFolder ("RecData", "Detectors reconstucted data");
127 fTopFolder->AddFolder ("RunMC", "MonteCarlo run dependent folders");
129 TFolder *configuration_mc =
130 run_mc->AddFolder ("Configuration","MonteCarlo run configuration");
133 configuration_mc->AddFolder ("Generators","list of generator objects");
136 configuration_mc->AddFolder ("VirtualMC", "the Virtual MC");
139 run_mc->AddFolder ("Event", "MonteCarlo event folders");
142 event_mc->AddFolder ("Header", "MonteCarlo event header");
145 // event_mc->AddFolder ("Kinematics", "MonteCarlo generated particles");
148 event_mc->AddFolder ("Data", "MonteCarlo data");
151 data_mc->AddFolder ("Hits", "MonteCarlo Hits") ;
154 data_mc->AddFolder ("SDigits", "MonteCarlo SDigits") ;
158 // Add the tasks to //Folders
160 TFolder * tasksfolder = fTopFolder->AddFolder("Tasks", "ALICE Tasks") ;
162 TTask * qa = new TTask("QA", "Alice QA tasks") ;
163 tasksfolder->Add(qa);
165 TTask * sd = new TTask("SDigitizer", "Alice SDigitizer") ;
166 tasksfolder->Add(sd);
168 TTask * di = new TTask("Digitizer", "Alice Digitizer") ;
169 tasksfolder->Add(di);
171 TTask * re = new TTask("Reconstructioner", "Alice Reconstructioner") ;
172 tasksfolder->Add(re);
176 //____________________________________________________________________________
177 AliConfig::~AliConfig()
179 delete fDetectorFolder ;
180 delete fDetectorTask ;
184 //____________________________________________________________________________
185 void AliConfig::AddInFolder (char *dir, TObject *obj)
188 dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
190 folder->Add (static_cast<TObject *>(obj));
193 //____________________________________________________________________________
194 void AliConfig::AddSubFolder(char * dir[], TObject *obj)
200 TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject (dir[iDir++]));
202 TFolder * subfolder = dynamic_cast<TFolder *>(folder->FindObject (obj->GetName()));
204 subfolder = folder->AddFolder (obj->GetName(),obj->GetTitle());
209 //____________________________________________________________________________
210 void AliConfig::AddSubTask(char * dir[], TObject *obj)
216 TTask * task = dynamic_cast<TTask *>(fTopFolder->FindObject (dir[iDir++]));
218 TTask * subtask = static_cast<TTask*>(task->GetListOfTasks()->FindObject (obj->GetName()));
220 subtask = new TTask(obj->GetName(), obj->GetTitle()) ;
227 //____________________________________________________________________________
228 TObject* AliConfig::FindInFolder (char *dir, const char *name)
230 if(!name) return(fTopFolder->FindObject(name));
231 TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
232 if (!folder) return (NULL);
233 return(folder->FindObject(name));
236 //____________________________________________________________________________
237 void AliConfig::Add (AliGenerator * obj)
239 AddInFolder(fGeneratorFolder, obj);
242 //____________________________________________________________________________
243 void AliConfig::Add (AliMC * obj)
245 AddInFolder(fMCFolder, obj);
248 //____________________________________________________________________________
249 void AliConfig::Add (TDatabasePDG * obj)
251 AddInFolder(fPDGFolder, obj);
254 //____________________________________________________________________________
255 void AliConfig::Add (AliModule* obj)
257 AddInFolder(fModuleFolder, obj);
260 //____________________________________________________________________________
261 void AliConfig::Add (AliDetector * obj)
263 AddSubFolder(fDetectorFolder, obj);
264 AddSubTask(fDetectorTask, obj);
268 //____________________________________________________________________________
269 void AliConfig::Add (char *list)
273 const char *conf_path = gSystem->Getenv ("ALICE_CONFIG_PATH");
275 path = new char[strlen (conf_path)];
276 strcpy (path, conf_path);
278 const char *alice = gSystem->Getenv ("ALICE_ROOT");
279 path = new char[strlen (alice) + 32];
283 strcat (path, alice);
285 strcat (path, "/macros/config");
288 char *token = strtok (path, ":");
290 TList *dirlist = new TList;
292 while (token != NULL)
294 dirlist->Add (new TObjString(token));
295 token = strtok (NULL, ":");
298 token = strtok (list, " ");
300 while (token != NULL)
302 cout << "Configuring " << token << ": ";
305 TIter next (dirlist);
306 TString found = "\0";
308 while ((obj = next ()))
310 TString dir(obj->GetName());
311 TString path = dir + "/" + token;
312 TString macro = path + ".C";
313 if (!gSystem->AccessPathName (macro.Data())) {
314 gInterpreter->ExecuteMacro (macro.Data());
315 found = "(" + macro + ")";
316 if (macro.Contains("/")) {
317 TString dirname = gSystem->DirName(macro.Data());
318 TString macroConfigure = dirname + "/Configure.C";
319 if (!gSystem->AccessPathName (macroConfigure.Data())) {
320 gInterpreter->ExecuteMacro (macroConfigure.Data());
321 found += " => Configured";
326 TString macroDefault = path + "/Default.C";
327 if (!gSystem->AccessPathName (macroDefault.Data())) {
328 gInterpreter->ExecuteMacro (macroDefault.Data());
329 found = "(" + macro + ")";
330 TString macroConfigure = path + "/Configure.C";
331 if (!gSystem->AccessPathName (macroConfigure.Data())) {
332 gInterpreter->ExecuteMacro (macroConfigure.Data());
333 found += " => Configured";
340 if (strlen(found.Data())) {
341 cout << found << " => OK" << endl;
343 cout << " => FAILED." << endl;
347 token = strtok (NULL, " ");
350 if (dirlist) delete dirlist;