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.9 2002/10/29 14:59:45 alibrary
19 Some more code cleanup
21 Revision 1.8 2002/10/29 14:26:49 hristov
22 Code clean-up (F.Carminati)
24 Revision 1.7 2002/10/23 07:43:00 alibrary
25 Introducing some effective C++ suggestions
27 Revision 1.6 2002/10/22 15:02:15 alibrary
28 Introducing Riostream.h
30 Revision 1.5 2002/10/14 14:57:32 hristov
31 Merging the VirtualMC branch to the main development branch (HEAD)
33 Revision 1.3.8.1 2002/06/10 14:43:06 hristov
36 Revision 1.4 2002/05/27 14:26:59 hristov
37 New folder for track references added
39 Revision 1.3 2001/10/04 15:30:56 hristov
40 Changes to accommodate the set of PHOS folders and tasks (Y.Schutz)
42 Revision 1.2 2001/05/21 17:22:50 buncic
43 Fixed problem with missing AliConfig while reading galice.root
45 Revision 1.1 2001/05/16 14:57:22 alibrary
46 New files for folders and Stack
50 #include <Riostream.h>
51 #include <TDatabasePDG.h>
53 #include <TInterpreter.h>
56 #include <TVirtualMC.h>
58 #include "AliConfig.h"
59 #include "AliDetector.h"
60 #include "AliGenerator.h"
61 #include "TObjString.h"
67 AliConfig* AliConfig::fInstance = 0;
69 //____________________________________________________________________________
70 AliConfig* AliConfig::Instance ()
73 // Instance method for singleton class
75 if(!fInstance) fInstance = new AliConfig ("Folders","Alice data exchange");
80 //____________________________________________________________________________
81 AliConfig::AliConfig():
92 // Default constructor, mainly to keep coding conventions
97 "Constructor should not be called for a singleton\n");
100 //____________________________________________________________________________
101 AliConfig::AliConfig(const AliConfig& conf):
113 // Copy constructor, mainly to keep coding conventions
118 "Copy constructor should not be called for a singleton\n");
121 //____________________________________________________________________________
122 AliConfig::AliConfig(const char *name, const char *title):
124 fTopFolder(gROOT->GetRootFolder ()->AddFolder (name,title)),
126 fPDGFolder("Constants/DatabasePDG"),
127 fGeneratorFolder("RunMC/Configuration/Generators"),
128 fMCFolder("RunMC/Configuration/VirtualMC"),
129 fModuleFolder("Run/Configuration/Modules"),
130 fDetectorFolder(new const char*[kFolders]),
131 fDetectorTask(new const char*[kTasks])
138 fDetectorFolder[0] = "Run/Conditions/Calibration" ;
139 fDetectorFolder[1] = "Run/Event/Data" ;
140 fDetectorFolder[2] = "Run/Event/RecData" ;
141 fDetectorFolder[3] = "RunMC/Event/Data/Hits" ;
142 fDetectorFolder[4] = "RunMC/Event/Data/SDigits" ;
143 fDetectorFolder[5] = "Run/Conditions/QA" ;
144 fDetectorFolder[6] = "RunMC/Event/Data/TrackReferences" ;
145 fDetectorFolder[7] = 0 ;
146 fDetectorTask[0] = "Tasks/QA" ;
147 fDetectorTask[1] = "Tasks/SDigitizer" ;
148 fDetectorTask[2] = "Tasks/Digitizer" ;
149 fDetectorTask[3] = "Tasks/Reconstructioner" ;
150 fDetectorTask[4] = 0 ;
152 fTopFolder->SetOwner() ;
153 gROOT->GetListOfBrowsables ()->Add (fTopFolder, name);
158 fTopFolder->AddFolder ("Constants", "Detector constants");
161 constants->AddFolder ("DatabasePDG", "PDG database");
164 fTopFolder->AddFolder ("Run", "Run dependent folders");
166 TFolder *conditions =
167 run->AddFolder ("Conditions", "Run conditions");
170 conditions->AddFolder ("Calibration","Detector calibration data");
173 conditions->AddFolder ("Aligment", "Detector aligment");
176 conditions->AddFolder ("QA", "Detector QA");
178 TFolder *configuration =
179 run->AddFolder ("Configuration", "Run configuration");
182 configuration->AddFolder ("Modules", "Detector objects");
185 configuration->AddFolder ("Field", "Magnetic field maps");
188 run->AddFolder ("Event", "Event folders");
191 event->AddFolder ("Data", "Detector raw data");
194 event->AddFolder ("RecData", "Detectors reconstucted data");
197 fTopFolder->AddFolder ("RunMC", "MonteCarlo run dependent folders");
199 TFolder *configuration_mc =
200 run_mc->AddFolder ("Configuration","MonteCarlo run configuration");
203 configuration_mc->AddFolder ("Generators","list of generator objects");
206 configuration_mc->AddFolder ("VirtualMC", "the Virtual MC");
209 run_mc->AddFolder ("Event", "MonteCarlo event folders");
212 event_mc->AddFolder ("Header", "MonteCarlo event header");
215 // event_mc->AddFolder ("Kinematics", "MonteCarlo generated particles");
218 event_mc->AddFolder ("Data", "MonteCarlo data");
221 data_mc->AddFolder ("Hits", "MonteCarlo Hits") ;
224 data_mc->AddFolder ("SDigits", "MonteCarlo SDigits") ;
227 data_mc->AddFolder ("TrackReferences", "MonteCarlo track references") ;
231 // Add the tasks to //Folders
233 TFolder * tasksfolder = fTopFolder->AddFolder("Tasks", "ALICE Tasks") ;
235 TTask * qa = new TTask("QA", "Alice QA tasks") ;
236 tasksfolder->Add(qa);
238 TTask * sd = new TTask("SDigitizer", "Alice SDigitizer") ;
239 tasksfolder->Add(sd);
241 TTask * di = new TTask("Digitizer", "Alice Digitizer") ;
242 tasksfolder->Add(di);
244 TTask * re = new TTask("Reconstructioner", "Alice Reconstructioner") ;
245 tasksfolder->Add(re);
249 //____________________________________________________________________________
250 AliConfig::~AliConfig()
252 delete [] fDetectorFolder ;
253 delete fDetectorTask ;
257 //____________________________________________________________________________
258 void AliConfig::AddInFolder (const char *dir, TObject *obj)
261 dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
263 folder->Add (static_cast<TObject *>(obj));
266 //____________________________________________________________________________
267 void AliConfig::AddSubFolder(const char * dir[], TObject *obj)
273 TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject (dir[iDir++]));
275 TFolder * subfolder = dynamic_cast<TFolder *>(folder->FindObject (obj->GetName()));
277 subfolder = folder->AddFolder (obj->GetName(),obj->GetTitle());
282 //____________________________________________________________________________
283 void AliConfig::AddSubTask(const char * dir[], TObject *obj)
289 TTask * task = dynamic_cast<TTask *>(fTopFolder->FindObject (dir[iDir++]));
291 TTask * subtask = static_cast<TTask*>(task->GetListOfTasks()->FindObject (obj->GetName()));
293 subtask = new TTask(obj->GetName(), obj->GetTitle()) ;
300 //____________________________________________________________________________
301 TObject* AliConfig::FindInFolder (const char *dir, const char *name)
303 if(!name) return(fTopFolder->FindObject(name));
304 TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
305 if (!folder) return (NULL);
306 return(folder->FindObject(name));
309 //____________________________________________________________________________
310 void AliConfig::Add (AliGenerator * obj)
312 AddInFolder(fGeneratorFolder, obj);
315 //____________________________________________________________________________
316 void AliConfig::Add (TVirtualMC * obj)
318 AddInFolder(fMCFolder, obj);
321 //____________________________________________________________________________
322 void AliConfig::Add (TDatabasePDG * obj)
324 AddInFolder(fPDGFolder, obj);
327 //____________________________________________________________________________
328 void AliConfig::Add (AliModule* obj)
330 AddInFolder(fModuleFolder, obj);
333 //____________________________________________________________________________
334 void AliConfig::Add (AliDetector * obj)
336 AddSubFolder(fDetectorFolder, obj);
337 AddSubTask(fDetectorTask, obj);
341 //____________________________________________________________________________
342 void AliConfig::Add (char *list)
346 const char *conf_path = gSystem->Getenv ("ALICE_CONFIG_PATH");
348 path = new char[strlen (conf_path)];
349 strcpy (path, conf_path);
351 const char *alice = gSystem->Getenv ("ALICE_ROOT");
352 path = new char[strlen (alice) + 32];
356 strcat (path, alice);
358 strcat (path, "/macros/config");
361 char *token = strtok (path, ":");
363 TList *dirlist = new TList;
365 while (token != NULL)
367 dirlist->Add (new TObjString(token));
368 token = strtok (NULL, ":");
371 token = strtok (list, " ");
373 while (token != NULL)
375 cout << "Configuring " << token << ": ";
378 TIter next (dirlist);
379 TString found = "\0";
381 while ((obj = next ()))
383 TString dir(obj->GetName());
384 TString tpath = dir + "/" + token;
385 TString macro = tpath + ".C";
386 if (!gSystem->AccessPathName (macro.Data())) {
387 gInterpreter->ExecuteMacro (macro.Data());
388 found = "(" + macro + ")";
389 if (macro.Contains("/")) {
390 TString dirname = gSystem->DirName(macro.Data());
391 TString macroConfigure = dirname + "/Configure.C";
392 if (!gSystem->AccessPathName (macroConfigure.Data())) {
393 gInterpreter->ExecuteMacro (macroConfigure.Data());
394 found += " => Configured";
399 TString macroDefault = tpath + "/Default.C";
400 if (!gSystem->AccessPathName (macroDefault.Data())) {
401 gInterpreter->ExecuteMacro (macroDefault.Data());
402 found = "(" + macro + ")";
403 TString macroConfigure = tpath + "/Configure.C";
404 if (!gSystem->AccessPathName (macroConfigure.Data())) {
405 gInterpreter->ExecuteMacro (macroConfigure.Data());
406 found += " => Configured";
413 if (strlen(found.Data())) {
414 cout << found << " => OK" << endl;
416 cout << " => FAILED." << endl;
420 token = strtok (NULL, " ");
423 if (dirlist) delete dirlist;