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.1 2001/05/16 14:57:22 alibrary
19 New files for folders and Stack
25 #include "AliConfig.h"
26 #include "AliDetector.h"
33 static char* gPDGFolder=
34 "Constants/DatabasePDG";
36 static char* gGeneratorFolder =
37 "RunMC/Configuration/Generators";
39 static char* gMCFolder =
40 "RunMC/Configuration/VirtualMC";
42 static char* gModuleFolder =
43 "Run/Configuration/Modules";
45 static char* gDetectorFolder[] = {
46 "Run/Conditions/Calibration",
49 "RunMC/Event/Data",0};
51 AliConfig* AliConfig::fInstance = 0;
53 AliConfig* AliConfig::Instance ()
56 // Instance method for singleton class
59 fInstance = new AliConfig ("Folders","Alice data exchange");
65 AliConfig::AliConfig(const char *name, const char *title)
68 // Default constructor
73 fTopFolder = gROOT->GetRootFolder ()->AddFolder (name,title);
75 gROOT->GetListOfBrowsables ()->Add (fTopFolder, name);
80 fTopFolder->AddFolder ("Constants", "Detector constants");
83 constants->AddFolder ("DatabasePDG", "PDG database");
86 fTopFolder->AddFolder ("Run", "Run dependent folders");
89 run->AddFolder ("Conditions", "Run conditions");
92 conditions->AddFolder ("Calibration","Detector calibration data");
95 conditions->AddFolder ("Aligment", "Detector aligment");
97 TFolder *configuration =
98 run->AddFolder ("Configuration", "Run configuration");
101 configuration->AddFolder ("Modules", "Detector objects");
104 configuration->AddFolder ("Field", "Magnetic field maps");
107 run->AddFolder ("Event", "Event folders");
110 event->AddFolder ("Data", "Detector raw data");
113 event->AddFolder ("RecData", "Detectors reconstucted data");
116 fTopFolder->AddFolder ("RunMC", "MonteCarlo run dependent folders");
118 TFolder *configuration_mc =
119 run_mc->AddFolder ("Configuration","MonteCarlo run configuration");
122 configuration_mc->AddFolder ("Generators","list of generator objects");
125 configuration_mc->AddFolder ("VirtualMC", "the Virtual MC");
128 run_mc->AddFolder ("Event", "MonteCarlo event folders");
131 event_mc->AddFolder ("Header", "MonteCarlo event header");
134 // event_mc->AddFolder ("Kinematics", "MonteCarlo generated particles");
137 event_mc->AddFolder ("Data", "MonteCarlo data");
141 AliConfig::~AliConfig()
145 void AliConfig::AddInFolder (char *dir, TObject *obj)
148 (TFolder *) fTopFolder->FindObject (dir);
150 folder->Add ((TObject *)obj);
153 void AliConfig::AddSubFolder(char *dir[], TObject *obj)
159 TFolder * folder = (TFolder *) fTopFolder->FindObject (dir[iDir++]);
161 TFolder * subfolder = (TFolder *) folder->FindObject (obj->GetName());
163 subfolder = folder->AddFolder (obj->GetName(),obj->GetTitle());
169 TObject* AliConfig::FindInFolder (char *dir, const char *name)
171 if(!name) return(fTopFolder->FindObject(name));
172 TFolder * folder = (TFolder *) fTopFolder->FindObject (dir);
173 if (!folder) return (NULL);
174 return(folder->FindObject(name));
177 void AliConfig::Add (AliGenerator * obj)
179 AddInFolder(gGeneratorFolder, (TObject *) obj);
182 void AliConfig::Add (AliMC * obj)
184 AddInFolder(gMCFolder, (TObject *) obj);
187 void AliConfig::Add (TDatabasePDG * obj)
189 AddInFolder(gPDGFolder, (TObject *) obj);
192 void AliConfig::Add (AliModule* obj)
194 AddInFolder(gModuleFolder, (TObject *) obj);
197 void AliConfig::Add (AliDetector * obj)
199 AddSubFolder(gDetectorFolder, (TObject *) obj);
203 void AliConfig::Add (const char *list)
207 const char *conf_path = gSystem->Getenv ("ALICE_CONFIG_PATH");
209 path = new char[strlen (conf_path)];
210 strcpy (path, conf_path);
212 const char *alice = gSystem->Getenv ("ALICE_ROOT");
213 path = new char[strlen (alice) + 32];
217 strcat (path, alice);
219 strcat (path, "/macros/config");
222 char *token = strtok (path, ":");
224 TList *dirlist = new TList;
226 while (token != NULL)
228 dirlist->Add ((TObject *) token);
229 token = strtok (NULL, ":");
232 token = strtok ((char *)list, " ");
234 while (token != NULL)
236 cout << "Configuring " << token << ": ";
239 TIter next (dirlist);
240 TString found = "\0";
242 while ((obj = next ()))
244 TString dir = (char *) obj;
245 TString path = dir + "/" + token;
246 TString macro = path + ".C";
247 if (!gSystem->AccessPathName (macro.Data())) {
248 gInterpreter->ExecuteMacro (macro.Data());
249 found = "(" + macro + ")";
250 if (macro.Contains("/")) {
251 TString dirname = gSystem->DirName(macro.Data());
252 TString macroConfigure = dirname + "/Configure.C";
253 if (!gSystem->AccessPathName (macroConfigure.Data())) {
254 gInterpreter->ExecuteMacro (macroConfigure.Data());
255 found += " => Configured";
260 TString macroDefault = path + "/Default.C";
261 if (!gSystem->AccessPathName (macroDefault.Data())) {
262 gInterpreter->ExecuteMacro (macroDefault.Data());
263 found = "(" + macro + ")";
264 TString macroConfigure = path + "/Configure.C";
265 if (!gSystem->AccessPathName (macroConfigure.Data())) {
266 gInterpreter->ExecuteMacro (macroConfigure.Data());
267 found += " => Configured";
274 if (strlen(found.Data())) {
275 cout << found << " => OK" << endl;
277 cout << " => FAILED." << endl;
281 token = strtok (NULL, " ");
284 if (dirlist) delete dirlist;