]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliConfig.cxx
Change of coordinate system x->-x, z->-z
[u/mrichter/AliRoot.git] / STEER / AliConfig.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
18 //  Description:
19 //  This class is responsible for creating folder structure
20 //  All stuff of aliroot sits in one folder with name defined by
21 //  fgkTopFolderName data wich do not very trough event to event are
22 //  sitting in directly in "top folder" all data which changes from
23 //  event to event are sitting in one folder (which has more subfolders)
24 //  Idea is to have more than one event in folder structure which allows
25 //  usage of standard procedures in merging
26 //  Add(AliDetector*) calls Add(AliModule*) as AliDetector is a AliModule
27 //  as well and should be listed in module list
28
29 #include <TDatabasePDG.h>
30 #include <TFolder.h>
31 #include <TInterpreter.h>
32 #include <TObjString.h>
33 #include <TROOT.h>
34 #include <TString.h>
35 #include <TSystem.h>
36 #include <TTask.h>
37 #include <TVirtualMC.h>
38
39 #include "AliConfig.h"
40 #include "AliDetector.h"
41 #include "AliGenerator.h" 
42 #include "AliLoader.h"
43
44 enum 
45  {
46   kDetTaskQA = 0,
47   kDetTaskSDigitizer,
48   kDetTaskDigitizer,
49   kDetTaskRecontructioner,
50   kDetTaskTracker,
51   kDetTaskPID,
52   kDetTaskLast
53  };
54
55 enum
56  {
57    kDetFolderData = 0,
58    kDetFolderCalibration,
59    kDetFolderAligmnet,
60    kDetFolderQA,
61    kDetFolderLast
62  };
63 ClassImp(AliConfig)
64
65 AliConfig* AliConfig::fInstance = 0;
66
67 //0 level folder
68 const TString AliConfig::fgkTopFolderName("Folders");
69
70 //1st level folder
71 const TString AliConfig::fgkTasksFolderName("Tasks"); //task folder, commn
72 const TString AliConfig::fgkConstantsFolderName("Constants");
73 const TString AliConfig::fgkDefaultEventFolderName("Event");  //default folder for event, always used except merging
74
75 //2st level folder
76 //subfolder of event folder
77 const TString AliConfig::fgkDataFolderName("Data");//folder for data (hits, digits, points, tracks) grouped by detectors
78 const TString AliConfig::fgkModuleFolderName("Modules");//folder with modules objects
79 const TString AliConfig::fgkConditionsFolderName("Conditions");//folder with conditions (mag. field etc.)
80 const TString AliConfig::fgkConfigurationFolderName("Configuration");//folder with configuration (setup) of the detector
81 const TString AliConfig::fgkHeaderFolderName("Header");//folder with header and other MC information
82
83 //Tasks names, goes into fgkTasksFolderName folder
84 const TString AliConfig::fgkDigitizerTaskName("Digitizer");
85 const TString AliConfig::fgkSDigitizerTaskName("SDigitizer");
86 const TString AliConfig::fgkReconstructionerTaskName("Reconstructioner");
87 const TString AliConfig::fgkTrackerTaskName("Tracker");
88 const TString AliConfig::fgkPIDTaskName("PIDTask");//;=) PIDer???
89 const TString AliConfig::fgkQATaskName("QAtask");
90
91 //3rd level folder
92 //fgkConditionsFolderName subfolders
93 const TString AliConfig::fgkCalibrationFolderName("Calibration");
94 const TString AliConfig::fgkAligmentFolderName("Aligment");
95 const TString AliConfig::fgkQAFolderName("QAout");
96   
97 //3rd level folder
98 //fgkConfigurationFolderName subfolders
99 const TString AliConfig::fgkFieldFolderName("Field");
100 const TString AliConfig::fgkGeneratorsFolderName("Generators");
101 const TString AliConfig::fgkVirtualMCFolderName("VirtualMC");
102
103
104 const TString AliConfig::fgkPDGFolderName("Constants/DatabasePDG");//folder with PDG Database
105 const TString AliConfig::fgkGeneratorFolderName("Configuration/Generators");//folder with generators
106 const TString AliConfig::fgkMCFolderName("Configuration/VirtualMC");
107
108 //____________________________________________________________________________
109 AliConfig* AliConfig::Instance ()
110 {
111   //
112   // Instance method for singleton class
113   //
114    if(fInstance == 0) 
115     {
116      fInstance = new AliConfig (fgkTopFolderName,"Alice data exchange board");
117     }
118    return fInstance;
119 }
120
121 //____________________________________________________________________________
122 AliConfig::AliConfig():
123   fTopFolder(0x0),
124   fTaskFolder(0x0),
125   fConstFolder(0x0),
126   fDetectorTask(0x0),
127   fDetectorFolder(0x0)
128 {
129   //
130   // Default constructor, mainly to keep coding conventions
131   //
132   fInstance=0;//never mind, its going to exit in next step
133   Fatal("ctor","Constructor should not be called for a singleton\n");
134 }
135 //____________________________________________________________________________
136
137 AliConfig::AliConfig(const AliConfig& conf):
138   TNamed(conf),
139   fTopFolder(0x0),
140   fTaskFolder(0x0),
141   fConstFolder(0x0),
142   fDetectorTask(0x0),
143   fDetectorFolder(0x0)
144 {
145   //
146   // Copy constructor, mainly to keep coding conventions
147   //
148   fInstance=0;
149     
150   Fatal("copy ctor",
151    "Copy constructor should not be called for a singleton\n");
152 }
153 //____________________________________________________________________________
154
155 AliConfig::AliConfig(const char *name, const char *title): 
156   TNamed(name,title), 
157   fTopFolder(gROOT->GetRootFolder()->AddFolder(name,title)),
158   fTaskFolder(fTopFolder->AddFolder(fgkTasksFolderName, "ALICE Tasks")),
159   fConstFolder(0x0),
160   fDetectorTask(0x0),
161   fDetectorFolder(new TString[kDetFolderLast+1])
162 {
163 // Constructor
164
165   //Main AliRoot Folder
166   if (fTopFolder == 0x0)
167    {
168      Fatal("AliConfig(const char*, const char*)","Can not create Top Alice Folder.");
169      return;//never reached
170    }
171   fTopFolder->SetOwner();
172   
173   fDetectorFolder[kDetFolderData] = fgkDataFolderName;
174   fDetectorFolder[kDetFolderCalibration] = fgkConditionsFolderName+"/"+fgkCalibrationFolderName;
175   fDetectorFolder[kDetFolderAligmnet] = fgkConditionsFolderName+"/"+fgkAligmentFolderName;
176   fDetectorFolder[kDetFolderQA] = fgkConditionsFolderName+"/"+fgkQAFolderName;
177   fDetectorFolder[kDetFolderLast] = "";
178   
179   gROOT->GetListOfBrowsables()->Add(fTopFolder, name);
180
181   //Constants folder
182   TFolder *fConstFolder = fTopFolder->AddFolder (fgkConstantsFolderName, "Constant parameters");
183   fConstFolder->AddFolder("DatabasePDG", "PDG database");
184   
185   // Add the tasks to //Folders
186   
187   TTask * qa = new TTask(fgkQATaskName, "Alice QA tasks");
188   fTaskFolder->Add(qa); 
189   TTask * sd = new TTask(fgkSDigitizerTaskName, "Alice SDigitizer") ;
190   fTaskFolder->Add(sd); 
191   TTask * di = new TTask(fgkDigitizerTaskName, "Alice Digitizer") ;
192   fTaskFolder->Add(di); 
193   TTask * re = new TTask(fgkReconstructionerTaskName, "Alice Reconstructioner") ;
194   fTaskFolder->Add(re); 
195   TTask * tr = new TTask(fgkTrackerTaskName,"Alice Tracker");
196   fTaskFolder->Add(tr);
197   TTask * pid = new TTask(fgkPIDTaskName,"Alice Particle Identification Task");
198   fTaskFolder->Add(pid);
199   fDetectorTask    =  new TString[kDetTaskLast+1];
200   
201   fDetectorTask[kDetTaskQA] = fgkQATaskName;
202   fDetectorTask[kDetTaskSDigitizer] = fgkSDigitizerTaskName;
203   fDetectorTask[kDetTaskDigitizer] =  fgkDigitizerTaskName;
204   fDetectorTask[kDetTaskRecontructioner] = fgkReconstructionerTaskName;
205   fDetectorTask[kDetTaskTracker] = fgkTrackerTaskName;
206   fDetectorTask[kDetTaskPID] = fgkPIDTaskName;
207   fDetectorTask[kDetTaskLast] = "";
208
209   fInstance=this;
210 }
211
212 //____________________________________________________________________________
213 AliConfig::~AliConfig()
214
215   delete [] fDetectorFolder ;  
216   delete [] fDetectorTask;
217   if (fTopFolder)
218    {
219     fTopFolder->SetOwner();
220     delete fTopFolder; 
221    }
222 }
223 //____________________________________________________________________________
224
225 void AliConfig::AddInFolder (const char *dir, TObject *obj)
226 {
227   TFolder *folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
228   if (folder)
229     folder->Add (static_cast<TObject *>(obj));
230 }
231 //____________________________________________________________________________
232
233 Int_t AliConfig::AddSubTask(const char *taskname, const char* name,const char* title)
234 {
235 //Create new task named 'name' and titled 'title' 
236 //as a subtask of the task named 'taskname'
237
238    if (AliLoader::fgDebug) Info("AddSubTask","Try to get folder named %s",taskname);
239    TObject* obj = fTopFolder->FindObject(taskname);
240    TTask * task = (obj)?dynamic_cast<TTask*>(obj):0x0;
241    if (task)
242      {
243       if (AliLoader::fgDebug) Info("AddSubTask","          Got");
244       TTask * subtask = static_cast<TTask*>(task->GetListOfTasks()->FindObject(name));
245       if (!subtask) 
246         {
247           subtask = new TTask(name,title);
248           task->Add(subtask);
249         }
250       else
251        {
252          Warning("AddSubTask","Task named \"%s\" already exists in Task %s\n",name,taskname);
253        }
254      }
255    else
256      {
257        Error("AddSubTask","Can not find task %s to put a new task in.",taskname);
258        return 1;
259      }
260   return 0;
261 }
262
263 //____________________________________________________________________________
264 TObject* AliConfig::FindInFolder (const char *dir, const char *name)
265 {
266   if(!name) return(fTopFolder->FindObject(name));
267   TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
268   if (!folder) return (NULL);
269   return(folder->FindObject(name));
270 }
271
272 //____________________________________________________________________________
273 void    AliConfig::Add (AliGenerator * obj,const char* eventfolder)
274 {
275   TString path(eventfolder);
276   path = path + "/" + fgkGeneratorsFolderName;
277   AddInFolder(path,obj);
278 }
279
280 //____________________________________________________________________________
281 void AliConfig::Add (TVirtualMC * obj,const char* eventfolder)
282 {
283   TString path(eventfolder);
284   path = path + "/" + fgkMCFolderName;
285   AddInFolder(path, obj);
286 }
287
288 //____________________________________________________________________________
289 void  AliConfig::Add (TDatabasePDG * obj)
290 {
291   AddInFolder(fgkPDGFolderName, obj);
292 }
293
294 //____________________________________________________________________________
295 void AliConfig::Add(AliModule* obj,const char* eventfolder)
296 {
297   
298   TString path(eventfolder);
299   path = path + "/" + fgkModuleFolderName;
300   if (AliLoader::fgDebug)
301     Info("Add(AliModule*)","module name = %s, Ev. Fold. Name is %s.",
302          obj->GetName(),eventfolder);
303   AddInFolder(path, obj);
304 }
305 //____________________________________________________________________________
306
307 Int_t AliConfig::AddDetector(TFolder* evntfolder, const char *name, const char* title)
308 {
309 //creates folders and tasks for the detector 'name'
310  Int_t retval;//returned value
311  retval = CreateDetectorFolders(evntfolder,name,title);
312  if (retval)
313   {
314     Error("AddDetector","CreateDetectorFolders returned error for detector %s",name);
315     return retval;
316   }
317  return 0; 
318 }
319 //____________________________________________________________________________
320
321 Int_t AliConfig::AddDetector(const char* evntfoldername,const char *name, const char* title)
322 {
323 //creates folders and tasks for the detector 'name'
324  Int_t retval;//returned value
325  retval = CreateDetectorFolders(evntfoldername,name,title);
326  if (retval)
327   {
328     Error("AddDetector","CreateDetectorFolders returned error for detector %s",name);
329     return retval;
330   }
331 // retval = CreateDetectorTasks(name,title);
332 // if (retval)
333 //  {
334 //    Error("AddDetector","CreateDetectorTasks returned error for detector %s",name);
335 //    return retval;
336 //  }
337  return 0; 
338 }
339 //____________________________________________________________________________
340
341 void  AliConfig::Add(AliDetector * obj,const char* eventfolder)
342 {
343   if (AliLoader::fgDebug) 
344     Info("Add(AliDetector*)","detector name = %s, Ev. Fold. Name is %s.",
345         obj->GetName(),eventfolder);
346
347   TObject* foundobj = GetTopFolder()->FindObject(eventfolder);
348   TFolder* evfolder = (foundobj)?dynamic_cast<TFolder*>(foundobj):0x0;
349   if (evfolder == 0x0)
350    {
351      Fatal("Add(AliDetector * obj,const char* eventfolder)",
352            "Can not find folder %s while adding detector %s",eventfolder,obj->GetName());
353      return;
354    } 
355   CreateDetectorFolders(evfolder, obj->GetName(), obj->GetTitle());
356   
357 //  CreateDetectorTasks(obj->GetName(),obj->GetTitle());
358
359 }
360 //____________________________________________________________________________
361
362 Int_t  AliConfig::CreateDetectorFolders(const char* evntfoldername,const char *name, const char* title)
363 {
364 //creates a folders for detector named 'name' and titled 'title'
365 //in a event folder named 'evntfoldername'
366 //list of folder names where new folders are created is defined in fDetectorFolder array 
367 //detector folders are named 'name' and titled 'title' as well
368
369  TFolder* evfolder = dynamic_cast<TFolder*>(GetTopFolder()->FindObject(evntfoldername));
370  if (evfolder == 0x0)
371   {
372    Error("CreateDetectorFolders",
373          "Can not find folder %s while adding detector %s",evntfoldername,name);
374    return 1;
375   }
376  return CreateDetectorFolders(evfolder,name,title);
377 }
378 //____________________________________________________________________________
379 Int_t  AliConfig::CreateDetectorFolders(TFolder* evntfolder,const char *name, const char* title)
380 {
381 //creates a folders for detector named 'name' and titled 'title'
382 //in a event folder 'evntfolder'
383 //list of folder names where new folders are created is defined in fDetectorFolder array 
384 //detector folders are named 'name' and titled 'title' as well
385 //Here we add only detector not an modules
386  
387  Int_t tmp;
388  Int_t i = 0;//iterator
389  while(!fDetectorFolder[i].IsNull())
390   {
391     tmp = AddSubFolder(evntfolder,fDetectorFolder[i],name,title);
392     if (tmp)
393      {
394       Error("AddDetector(TFolder*","Failed to create subfolder of %s for detector %s",fDetectorFolder[i].Data(),name);
395       return 1;
396      }
397     i++;
398   }
399  return 0;
400 }
401 //____________________________________________________________________________
402 Int_t AliConfig::CreateDetectorTasks(const char *name, const char* title)
403 {
404    Int_t i = 0;
405    Int_t tmp;
406    while (i < kDetTaskLast)
407     {
408       tmp = AddSubTask(fgkTasksFolderName+"/"+fDetectorTask[i],
409                        name+fDetectorTask[i],(fDetectorTask[i]+" for ")+title);
410       if (tmp)
411        {
412          Error("CreateDetectorTasks","Error occured while creating task for %s in %s.",
413                 name,fDetectorTask[i-1].Data());
414          return 1;
415        }
416       i++;
417     }
418    return 0;
419 }
420
421 //____________________________________________________________________________
422 void    AliConfig::Add (char *list)
423 {
424   char *path;
425   
426   const char   *conf_path = gSystem->Getenv ("ALICE_CONFIG_PATH");
427   if  (conf_path) {
428     path = new char[strlen (conf_path)];
429     strcpy (path, conf_path);
430   } else {
431     const char   *alice = gSystem->Getenv ("ALICE_ROOT");
432     path = new char[strlen (alice) + 32];
433     
434     strcpy (path, ".:");
435     if (alice) {
436       strcat (path, alice);
437     }
438     strcat (path, "/macros/config");
439   }
440   
441   char   *token = strtok (path, ":");
442   
443   TList  *dirlist = new TList;
444   
445   while (token != NULL) 
446     {
447       dirlist->Add (new TObjString(token));
448       token = strtok (NULL, ":");
449     }
450   
451   token = strtok (list, " ");
452   
453   while (token != NULL)
454     { 
455       Info("Add(char *list)","Configuring token=%s",token);
456       
457       TObject *obj;
458       TIter   next (dirlist);
459       TString found = "\0";
460       
461       while ((obj = next ()))
462         {
463           TString dir(obj->GetName());
464           TString path  = dir + "/" + token;
465           TString macro = path + ".C";
466           if (!gSystem->AccessPathName (macro.Data()))  
467            {
468             gInterpreter->ExecuteMacro (macro.Data());                             
469             found = "(" + macro + ")";
470             if (macro.Contains("/")) 
471              {
472                TString dirname = gSystem->DirName(macro.Data());
473                TString macroConfigure = dirname + "/Configure.C";
474                if (!gSystem->AccessPathName (macroConfigure.Data()))
475                 {
476                   gInterpreter->ExecuteMacro (macroConfigure.Data());                               
477                   found += " => Configured";
478                 }                             
479              }
480             break;
481            } 
482           else 
483            {
484             TString macroDefault = path + "/Default.C";
485             if (!gSystem->AccessPathName (macroDefault.Data()))
486               {
487                 gInterpreter->ExecuteMacro (macroDefault.Data());
488                 found = "(" + macro + ")";
489                 TString macroConfigure = path + "/Configure.C";
490                 if (!gSystem->AccessPathName (macroConfigure.Data()))   
491                   {
492                     gInterpreter->ExecuteMacro (macroConfigure.Data());                             
493                     found += " => Configured";
494                   }
495                 break;                              
496               }
497            }
498         }
499       
500       if (strlen(found.Data())) 
501         {
502           Info("Add(char *list)","found=%s  => OK",found.Data());
503         } 
504       else 
505         {
506           Error("Add(char *list)"," => FAILED.");
507           exit(1); 
508         }           
509       
510       token = strtok (NULL," ");
511     }
512   
513   if (dirlist) delete dirlist;
514   
515 }
516
517 /*****************************************************************************/
518
519 TFolder* AliConfig::BuildEventFolder(const char* name,const char* title)
520 {
521 /*
522  creates the folder structure for one event
523  TopFolder_
524          | \
525          |  Tasks
526          |_
527          | \
528          |  Constants
529          |_
530          | \
531          |  Event_
532          |      | \
533          |      |  Modules(detector objects)
534          |      |_
535          |      | \              
536          |      |  Header
537          |      |_
538          |      | \              
539          |      |  Data_
540          |      |     | \ 
541          |      |     |  TPC_
542          |      |     |    | \
543          |      |     |    |  Hits(object;e.g. tree)
544          |      |     |    |_  
545          |      |     |    | \ 
546          |      |     |    |  SDigits(object)
547          |      |     |    |_
548          |      |     |    | \ 
549          |      |     |    |  Digits(object)
550          |      |     |    |_
551          |      |     |    | \ 
552          |      |     |    |  RecPoints(object)
553          |      |     |    |_
554          |      |     |      \ 
555          |      |     |       Tracks(object)
556          |      |     |_ 
557          |      |       \
558          |      |        ITS_
559          |      |          | \
560          |      |          |  Hits(object;e.g. tree)
561          |      |          |_  
562          |      |          | \ 
563          |      |          |  SDigits(object)
564          |      |          |_
565          |      |          | \ 
566          |      |          |  Digits(object)
567          |      |          |_
568          |      |          | \ 
569          |      |          |  RecPoints(object)
570          |      |          |_
571          |      |            \ 
572          |      |             Tracks(object)
573          |      |_         
574          |        \       
575          |         Configuration
576          |               
577          |_
578            \
579             Event2_  (to be merged with event)
580                 |  \
581                 |   Modules(detector objects)
582                 |_
583                 | \              
584                 |  Header
585                 |_
586                 | \              
587                 |  Data_
588                 |     | \ 
589                 |     |  TPC_
590                 |     |    | \
591                 |     |    |  Hits(object;e.g. tree)
592                 |     |    |_  
593                 |     |    | \ 
594                 |     |    |  SDigits(object)
595                 |     |    |_
596                 |     |    | \ 
597                 |     |    |  Digits(object)
598                 |     |    |_
599                 |     |    | \ 
600                 |     |    |  RecPoints(object)
601                 |     |    |_
602                 |     |      \ 
603                 |     |       Tracks(object)
604                 |     |_ 
605                 |       \
606                 |        ITS_
607                 |          | \
608                 |          |  Hits(object;e.g. tree)
609                 |          |_  
610                 |          | \ 
611                 |          |  SDigits(object)
612                 |          |_
613                 |          | \ 
614                 |          |  Digits(object)
615                 |          |_
616                 |          | \ 
617                 |          |  RecPoints(object)
618                 |          |_
619                 |            \ 
620                 |             Tracks(object)
621                 |_         
622                   \       
623                    Configuration
624                          
625 */
626   TFolder* eventfolder = fTopFolder->AddFolder(name,title); 
627    
628   //modules
629   eventfolder->AddFolder(fgkModuleFolderName, "Detector objects");
630   //event data
631   eventfolder->AddFolder(fgkDataFolderName, "Detector data");
632   
633     //Conditions
634   TFolder *conditions = eventfolder->AddFolder(fgkConditionsFolderName, "Run conditions");
635   conditions->AddFolder(fgkCalibrationFolderName,"Detector calibration data");
636   conditions->AddFolder(fgkAligmentFolderName,"Detector aligment");
637   conditions->AddFolder(fgkQAFolderName,"Quality Asurance Output"); //Folder with output of the QA task(s)
638   //Configuration
639   TFolder *configuration = eventfolder->AddFolder(fgkConfigurationFolderName, "Run configuration");
640   configuration->AddFolder(fgkFieldFolderName, "Magnetic field maps");
641   configuration->AddFolder(fgkGeneratorsFolderName,"list of generator objects");
642   configuration->AddFolder(fgkVirtualMCFolderName,"the Virtual MC");
643
644   eventfolder->AddFolder(fgkHeaderFolderName,"MonteCarlo event header");
645
646   eventfolder->SetOwner();
647
648   return eventfolder;
649 }
650
651 /*****************************************************************************/
652
653 TString AliConfig::GetQATaskName() const
654  {
655  //returns task name
656   return fDetectorTask[kDetTaskQA];
657  }
658 /*****************************************************************************/
659  
660 TString AliConfig::GetDigitizerTaskName() const
661  {
662  //returns task name
663   return fDetectorTask[kDetTaskDigitizer];
664  }
665 /*****************************************************************************/
666  
667 TString AliConfig::GetSDigitizerTaskName() const
668  {
669  //returns task name
670   return fDetectorTask[kDetTaskSDigitizer];
671  }
672 /*****************************************************************************/
673
674 TString AliConfig::GetReconstructionerTaskName() const
675  {
676  //returns task name
677   return fDetectorTask[kDetTaskRecontructioner];
678  }
679 /*****************************************************************************/
680
681 TString AliConfig::GetTrackerTaskName() const
682  {
683  //returns task name
684   return fDetectorTask[kDetTaskTracker];
685  }
686 /*****************************************************************************/
687
688 TString AliConfig::GetPIDTaskName() const
689  {
690  //returns task name
691   return fDetectorTask[kDetTaskPID];
692  }
693 /*****************************************************************************/
694
695 const TString& AliConfig::GetQAFolderName() const
696 {
697 //returns pathname of folder with QA output relative to Top Alice Folder
698   return fDetectorFolder[kDetFolderQA];
699 }
700 /*****************************************************************************/
701
702 const TString& AliConfig::GetDataFolderName()
703 {
704 //returns name of data folder path relative to event folder
705  return fgkDataFolderName;
706 }
707 /*****************************************************************************/
708
709 Int_t AliConfig::AddSubFolder(TFolder* topfolder, const char* infoler, 
710                      const char* newfoldname, const char* newfoldtitle)
711 {
712 //helper method
713 //in topfolder looks for folder named 'infolder'
714 //and if it exist it creates inside a new folder named 'newfoldname' and titled 'newfoldtitle'
715
716  if (topfolder == 0x0)//check if exists top folder
717   {
718    Error("AddSubFodler(TFolder*, ....","Parameter TFolder* points to NULL.");
719    return 1;
720   }
721  
722  TObject *obj;
723  TFolder* folder;
724  
725  folder = dynamic_cast<TFolder*>(topfolder->FindObject(infoler));
726  if (folder == 0x0) //check if we got inolder
727   {
728    Error("AddSubFodler(TFolder*, ....","Can not find folder %s in folder %s.",infoler,topfolder->GetName());
729    return 1;
730   }
731  obj = folder->FindObject(newfoldname); //see if such a subfolder already exists
732  if (obj == 0x0) //nope
733   {
734    TFolder *newfolder = folder->AddFolder(newfoldname,newfoldtitle);//add the desired subfolder
735    if (newfolder == 0x0) //check if we managed
736     {
737      Error("AddSubFodler(TFolder*, ....","Can not create folder %s in folder %s",newfoldname,infoler);
738      return 2;
739     }
740    else return 0;//success
741   }
742  //such an object already exists
743  TFolder* fol = dynamic_cast<TFolder*>(obj);
744  if (fol == 0x0)
745    {
746      Error("AddSubFodler(TFolder*, ....",
747            "Object named %s already exists in folder %s AND IT IS NOT A FOLDER",newfoldname,infoler);
748      return 3;
749    }
750  Warning("AddSubFodler(TFolder*, ....",
751          "Folder named %s already exists in folder %s",newfoldname,infoler);
752  return 0;
753 }