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.3 2001/10/04 15:30:56 hristov
19 Changes to accommodate the set of PHOS folders and tasks (Y.Schutz)
21 Revision 1.2 2001/05/21 17:22:50 buncic
22 Fixed problem with missing AliConfig while reading galice.root
24 Revision 1.1 2001/05/16 14:57:22 alibrary
25 New files for folders and Stack
29 #include "AliConfig.h"
30 #include "AliDetector.h"
31 #include "TObjString.h"
34 #include "AliGenerator.h"
40 AliConfig* AliConfig::fInstance = 0;
42 //____________________________________________________________________________
43 AliConfig* AliConfig::Instance ()
46 // Instance method for singleton class
49 fInstance = new AliConfig ("Folders","Alice data exchange");
55 AliConfig::AliConfig(const char *name, const char *title)
65 fPDGFolder = "Constants/DatabasePDG" ;
66 fGeneratorFolder = "RunMC/Configuration/Generators" ;
67 fMCFolder = "RunMC/Configuration/VirtualMC" ;
68 fModuleFolder = "Run/Configuration/Modules" ;
69 fDetectorFolder = new char*[8] ;
70 fDetectorFolder[0] = "Run/Conditions/Calibration" ;
71 fDetectorFolder[1] = "Run/Event/Data" ;
72 fDetectorFolder[2] = "Run/Event/RecData" ;
73 fDetectorFolder[3] = "RunMC/Event/Data/Hits" ;
74 fDetectorFolder[4] = "RunMC/Event/Data/SDigits" ;
75 fDetectorFolder[5] = "Run/Conditions/QA" ;
76 fDetectorFolder[6] = "RunMC/Event/Data/TrackReferences" ;
77 fDetectorFolder[7] = 0 ;
78 fDetectorTask = new char*[5] ;
79 fDetectorTask[0] = "Tasks/QA" ;
80 fDetectorTask[1] = "Tasks/SDigitizer" ;
81 fDetectorTask[2] = "Tasks/Digitizer" ;
82 fDetectorTask[3] = "Tasks/Reconstructioner" ;
83 fDetectorTask[4] = 0 ;
85 fTopFolder = gROOT->GetRootFolder ()->AddFolder (name,title);
86 fTopFolder->SetOwner() ;
87 gROOT->GetListOfBrowsables ()->Add (fTopFolder, name);
92 fTopFolder->AddFolder ("Constants", "Detector constants");
95 constants->AddFolder ("DatabasePDG", "PDG database");
98 fTopFolder->AddFolder ("Run", "Run dependent folders");
100 TFolder *conditions =
101 run->AddFolder ("Conditions", "Run conditions");
104 conditions->AddFolder ("Calibration","Detector calibration data");
107 conditions->AddFolder ("Aligment", "Detector aligment");
110 conditions->AddFolder ("QA", "Detector QA");
112 TFolder *configuration =
113 run->AddFolder ("Configuration", "Run configuration");
116 configuration->AddFolder ("Modules", "Detector objects");
119 configuration->AddFolder ("Field", "Magnetic field maps");
122 run->AddFolder ("Event", "Event folders");
125 event->AddFolder ("Data", "Detector raw data");
128 event->AddFolder ("RecData", "Detectors reconstucted data");
131 fTopFolder->AddFolder ("RunMC", "MonteCarlo run dependent folders");
133 TFolder *configuration_mc =
134 run_mc->AddFolder ("Configuration","MonteCarlo run configuration");
137 configuration_mc->AddFolder ("Generators","list of generator objects");
140 configuration_mc->AddFolder ("VirtualMC", "the Virtual MC");
143 run_mc->AddFolder ("Event", "MonteCarlo event folders");
146 event_mc->AddFolder ("Header", "MonteCarlo event header");
149 // event_mc->AddFolder ("Kinematics", "MonteCarlo generated particles");
152 event_mc->AddFolder ("Data", "MonteCarlo data");
155 data_mc->AddFolder ("Hits", "MonteCarlo Hits") ;
158 data_mc->AddFolder ("SDigits", "MonteCarlo SDigits") ;
161 data_mc->AddFolder ("TrackReferences", "MonteCarlo track references") ;
165 // Add the tasks to //Folders
167 TFolder * tasksfolder = fTopFolder->AddFolder("Tasks", "ALICE Tasks") ;
169 TTask * qa = new TTask("QA", "Alice QA tasks") ;
170 tasksfolder->Add(qa);
172 TTask * sd = new TTask("SDigitizer", "Alice SDigitizer") ;
173 tasksfolder->Add(sd);
175 TTask * di = new TTask("Digitizer", "Alice Digitizer") ;
176 tasksfolder->Add(di);
178 TTask * re = new TTask("Reconstructioner", "Alice Reconstructioner") ;
179 tasksfolder->Add(re);
183 //____________________________________________________________________________
184 AliConfig::~AliConfig()
186 delete [] fDetectorFolder ;
187 delete fDetectorTask ;
191 //____________________________________________________________________________
192 void AliConfig::AddInFolder (char *dir, TObject *obj)
195 dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
197 folder->Add (static_cast<TObject *>(obj));
200 //____________________________________________________________________________
201 void AliConfig::AddSubFolder(char * dir[], TObject *obj)
207 TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject (dir[iDir++]));
209 TFolder * subfolder = dynamic_cast<TFolder *>(folder->FindObject (obj->GetName()));
211 subfolder = folder->AddFolder (obj->GetName(),obj->GetTitle());
216 //____________________________________________________________________________
217 void AliConfig::AddSubTask(char * dir[], TObject *obj)
223 TTask * task = dynamic_cast<TTask *>(fTopFolder->FindObject (dir[iDir++]));
225 TTask * subtask = static_cast<TTask*>(task->GetListOfTasks()->FindObject (obj->GetName()));
227 subtask = new TTask(obj->GetName(), obj->GetTitle()) ;
234 //____________________________________________________________________________
235 TObject* AliConfig::FindInFolder (char *dir, const char *name)
237 if(!name) return(fTopFolder->FindObject(name));
238 TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
239 if (!folder) return (NULL);
240 return(folder->FindObject(name));
243 //____________________________________________________________________________
244 void AliConfig::Add (AliGenerator * obj)
246 AddInFolder(fGeneratorFolder, obj);
249 //____________________________________________________________________________
250 void AliConfig::Add (AliMC * obj)
252 AddInFolder(fMCFolder, obj);
255 //____________________________________________________________________________
256 void AliConfig::Add (TDatabasePDG * obj)
258 AddInFolder(fPDGFolder, obj);
261 //____________________________________________________________________________
262 void AliConfig::Add (AliModule* obj)
264 AddInFolder(fModuleFolder, obj);
267 //____________________________________________________________________________
268 void AliConfig::Add (AliDetector * obj)
270 AddSubFolder(fDetectorFolder, obj);
271 AddSubTask(fDetectorTask, obj);
275 //____________________________________________________________________________
276 void AliConfig::Add (char *list)
280 const char *conf_path = gSystem->Getenv ("ALICE_CONFIG_PATH");
282 path = new char[strlen (conf_path)];
283 strcpy (path, conf_path);
285 const char *alice = gSystem->Getenv ("ALICE_ROOT");
286 path = new char[strlen (alice) + 32];
290 strcat (path, alice);
292 strcat (path, "/macros/config");
295 char *token = strtok (path, ":");
297 TList *dirlist = new TList;
299 while (token != NULL)
301 dirlist->Add (new TObjString(token));
302 token = strtok (NULL, ":");
305 token = strtok (list, " ");
307 while (token != NULL)
309 cout << "Configuring " << token << ": ";
312 TIter next (dirlist);
313 TString found = "\0";
315 while ((obj = next ()))
317 TString dir(obj->GetName());
318 TString path = dir + "/" + token;
319 TString macro = path + ".C";
320 if (!gSystem->AccessPathName (macro.Data())) {
321 gInterpreter->ExecuteMacro (macro.Data());
322 found = "(" + macro + ")";
323 if (macro.Contains("/")) {
324 TString dirname = gSystem->DirName(macro.Data());
325 TString macroConfigure = dirname + "/Configure.C";
326 if (!gSystem->AccessPathName (macroConfigure.Data())) {
327 gInterpreter->ExecuteMacro (macroConfigure.Data());
328 found += " => Configured";
333 TString macroDefault = path + "/Default.C";
334 if (!gSystem->AccessPathName (macroDefault.Data())) {
335 gInterpreter->ExecuteMacro (macroDefault.Data());
336 found = "(" + macro + ")";
337 TString macroConfigure = path + "/Configure.C";
338 if (!gSystem->AccessPathName (macroConfigure.Data())) {
339 gInterpreter->ExecuteMacro (macroConfigure.Data());
340 found += " => Configured";
347 if (strlen(found.Data())) {
348 cout << found << " => OK" << endl;
350 cout << " => FAILED." << endl;
354 token = strtok (NULL, " ");
357 if (dirlist) delete dirlist;