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.7 2002/10/23 07:43:00 alibrary
19 Introducing some effective C++ suggestions
21 Revision 1.6 2002/10/22 15:02:15 alibrary
22 Introducing Riostream.h
24 Revision 1.5 2002/10/14 14:57:32 hristov
25 Merging the VirtualMC branch to the main development branch (HEAD)
27 Revision 1.3.8.1 2002/06/10 14:43:06 hristov
30 Revision 1.4 2002/05/27 14:26:59 hristov
31 New folder for track references added
33 Revision 1.3 2001/10/04 15:30:56 hristov
34 Changes to accommodate the set of PHOS folders and tasks (Y.Schutz)
36 Revision 1.2 2001/05/21 17:22:50 buncic
37 Fixed problem with missing AliConfig while reading galice.root
39 Revision 1.1 2001/05/16 14:57:22 alibrary
40 New files for folders and Stack
44 #include <Riostream.h>
45 #include <TDatabasePDG.h>
47 #include <TInterpreter.h>
51 #include "AliConfig.h"
52 #include "AliDetector.h"
53 #include "AliGenerator.h"
54 #include "TObjString.h"
60 AliConfig* AliConfig::fInstance = 0;
62 //____________________________________________________________________________
63 AliConfig* AliConfig::Instance ()
66 // Instance method for singleton class
68 if(!fInstance) fInstance = new AliConfig ("Folders","Alice data exchange");
73 //____________________________________________________________________________
74 AliConfig::AliConfig():
85 // Default constructor, mainly to keep coding conventions
90 "Constructor should not be called for a singleton\n");
93 //____________________________________________________________________________
94 AliConfig::AliConfig(const AliConfig& conf):
106 // Copy constructor, mainly to keep coding conventions
111 "Copy constructor should not be called for a singleton\n");
114 //____________________________________________________________________________
115 AliConfig::AliConfig(const char *name, const char *title):
117 fTopFolder(gROOT->GetRootFolder ()->AddFolder (name,title)),
119 fPDGFolder("Constants/DatabasePDG"),
120 fGeneratorFolder("RunMC/Configuration/Generators"),
121 fMCFolder("RunMC/Configuration/VirtualMC"),
122 fModuleFolder("Run/Configuration/Modules"),
123 fDetectorFolder(new char*[kFolders]),
124 fDetectorTask(new char*[kTasks])
131 fDetectorFolder[0] = "Run/Conditions/Calibration" ;
132 fDetectorFolder[1] = "Run/Event/Data" ;
133 fDetectorFolder[2] = "Run/Event/RecData" ;
134 fDetectorFolder[3] = "RunMC/Event/Data/Hits" ;
135 fDetectorFolder[4] = "RunMC/Event/Data/SDigits" ;
136 fDetectorFolder[5] = "Run/Conditions/QA" ;
137 fDetectorFolder[6] = "RunMC/Event/Data/TrackReferences" ;
138 fDetectorFolder[7] = 0 ;
139 fDetectorTask[0] = "Tasks/QA" ;
140 fDetectorTask[1] = "Tasks/SDigitizer" ;
141 fDetectorTask[2] = "Tasks/Digitizer" ;
142 fDetectorTask[3] = "Tasks/Reconstructioner" ;
143 fDetectorTask[4] = 0 ;
145 fTopFolder->SetOwner() ;
146 gROOT->GetListOfBrowsables ()->Add (fTopFolder, name);
151 fTopFolder->AddFolder ("Constants", "Detector constants");
154 constants->AddFolder ("DatabasePDG", "PDG database");
157 fTopFolder->AddFolder ("Run", "Run dependent folders");
159 TFolder *conditions =
160 run->AddFolder ("Conditions", "Run conditions");
163 conditions->AddFolder ("Calibration","Detector calibration data");
166 conditions->AddFolder ("Aligment", "Detector aligment");
169 conditions->AddFolder ("QA", "Detector QA");
171 TFolder *configuration =
172 run->AddFolder ("Configuration", "Run configuration");
175 configuration->AddFolder ("Modules", "Detector objects");
178 configuration->AddFolder ("Field", "Magnetic field maps");
181 run->AddFolder ("Event", "Event folders");
184 event->AddFolder ("Data", "Detector raw data");
187 event->AddFolder ("RecData", "Detectors reconstucted data");
190 fTopFolder->AddFolder ("RunMC", "MonteCarlo run dependent folders");
192 TFolder *configuration_mc =
193 run_mc->AddFolder ("Configuration","MonteCarlo run configuration");
196 configuration_mc->AddFolder ("Generators","list of generator objects");
199 configuration_mc->AddFolder ("VirtualMC", "the Virtual MC");
202 run_mc->AddFolder ("Event", "MonteCarlo event folders");
205 event_mc->AddFolder ("Header", "MonteCarlo event header");
208 // event_mc->AddFolder ("Kinematics", "MonteCarlo generated particles");
211 event_mc->AddFolder ("Data", "MonteCarlo data");
214 data_mc->AddFolder ("Hits", "MonteCarlo Hits") ;
217 data_mc->AddFolder ("SDigits", "MonteCarlo SDigits") ;
220 data_mc->AddFolder ("TrackReferences", "MonteCarlo track references") ;
224 // Add the tasks to //Folders
226 TFolder * tasksfolder = fTopFolder->AddFolder("Tasks", "ALICE Tasks") ;
228 TTask * qa = new TTask("QA", "Alice QA tasks") ;
229 tasksfolder->Add(qa);
231 TTask * sd = new TTask("SDigitizer", "Alice SDigitizer") ;
232 tasksfolder->Add(sd);
234 TTask * di = new TTask("Digitizer", "Alice Digitizer") ;
235 tasksfolder->Add(di);
237 TTask * re = new TTask("Reconstructioner", "Alice Reconstructioner") ;
238 tasksfolder->Add(re);
242 //____________________________________________________________________________
243 AliConfig::~AliConfig()
245 delete [] fDetectorFolder ;
246 delete fDetectorTask ;
250 //____________________________________________________________________________
251 void AliConfig::AddInFolder (const char *dir, TObject *obj)
254 dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
256 folder->Add (static_cast<TObject *>(obj));
259 //____________________________________________________________________________
260 void AliConfig::AddSubFolder(char * dir[], TObject *obj)
266 TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject (dir[iDir++]));
268 TFolder * subfolder = dynamic_cast<TFolder *>(folder->FindObject (obj->GetName()));
270 subfolder = folder->AddFolder (obj->GetName(),obj->GetTitle());
275 //____________________________________________________________________________
276 void AliConfig::AddSubTask(char * dir[], TObject *obj)
282 TTask * task = dynamic_cast<TTask *>(fTopFolder->FindObject (dir[iDir++]));
284 TTask * subtask = static_cast<TTask*>(task->GetListOfTasks()->FindObject (obj->GetName()));
286 subtask = new TTask(obj->GetName(), obj->GetTitle()) ;
293 //____________________________________________________________________________
294 TObject* AliConfig::FindInFolder (const char *dir, const char *name)
296 if(!name) return(fTopFolder->FindObject(name));
297 TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
298 if (!folder) return (NULL);
299 return(folder->FindObject(name));
302 //____________________________________________________________________________
303 void AliConfig::Add (AliGenerator * obj)
305 AddInFolder(fGeneratorFolder, obj);
308 //____________________________________________________________________________
309 void AliConfig::Add (AliMC * obj)
311 AddInFolder(fMCFolder, obj);
314 //____________________________________________________________________________
315 void AliConfig::Add (TDatabasePDG * obj)
317 AddInFolder(fPDGFolder, obj);
320 //____________________________________________________________________________
321 void AliConfig::Add (AliModule* obj)
323 AddInFolder(fModuleFolder, obj);
326 //____________________________________________________________________________
327 void AliConfig::Add (AliDetector * obj)
329 AddSubFolder(fDetectorFolder, obj);
330 AddSubTask(fDetectorTask, obj);
334 //____________________________________________________________________________
335 void AliConfig::Add (char *list)
339 const char *conf_path = gSystem->Getenv ("ALICE_CONFIG_PATH");
341 path = new char[strlen (conf_path)];
342 strcpy (path, conf_path);
344 const char *alice = gSystem->Getenv ("ALICE_ROOT");
345 path = new char[strlen (alice) + 32];
349 strcat (path, alice);
351 strcat (path, "/macros/config");
354 char *token = strtok (path, ":");
356 TList *dirlist = new TList;
358 while (token != NULL)
360 dirlist->Add (new TObjString(token));
361 token = strtok (NULL, ":");
364 token = strtok (list, " ");
366 while (token != NULL)
368 cout << "Configuring " << token << ": ";
371 TIter next (dirlist);
372 TString found = "\0";
374 while ((obj = next ()))
376 TString dir(obj->GetName());
377 TString tpath = dir + "/" + token;
378 TString macro = tpath + ".C";
379 if (!gSystem->AccessPathName (macro.Data())) {
380 gInterpreter->ExecuteMacro (macro.Data());
381 found = "(" + macro + ")";
382 if (macro.Contains("/")) {
383 TString dirname = gSystem->DirName(macro.Data());
384 TString macroConfigure = dirname + "/Configure.C";
385 if (!gSystem->AccessPathName (macroConfigure.Data())) {
386 gInterpreter->ExecuteMacro (macroConfigure.Data());
387 found += " => Configured";
392 TString macroDefault = tpath + "/Default.C";
393 if (!gSystem->AccessPathName (macroDefault.Data())) {
394 gInterpreter->ExecuteMacro (macroDefault.Data());
395 found = "(" + macro + ")";
396 TString macroConfigure = tpath + "/Configure.C";
397 if (!gSystem->AccessPathName (macroConfigure.Data())) {
398 gInterpreter->ExecuteMacro (macroConfigure.Data());
399 found += " => Configured";
406 if (strlen(found.Data())) {
407 cout << found << " => OK" << endl;
409 cout << " => FAILED." << endl;
413 token = strtok (NULL, " ");
416 if (dirlist) delete dirlist;