]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliConfig.cxx
Transition to NewIO
[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   fTopFolder(0x0),
139   fTaskFolder(0x0),
140   fConstFolder(0x0),
141   fDetectorTask(0x0),
142   fDetectorFolder(0x0)
143 {
144   //
145   // Copy constructor, mainly to keep coding conventions
146   //
147   fInstance=0;
148     
149   Fatal("copy ctor",
150    "Copy constructor should not be called for a singleton\n");
151 }
152 //____________________________________________________________________________
153
154 AliConfig::AliConfig(const char *name, const char *title): 
155   TNamed(name,title), 
156   fTopFolder(gROOT->GetRootFolder()->AddFolder(name,title)),
157   fTaskFolder(fTopFolder->AddFolder(fgkTasksFolderName, "ALICE Tasks")),
158   fConstFolder(0x0),
159   fDetectorTask(0x0),
160   fDetectorFolder(new TString[kDetFolderLast+1])
161 {
162 // Constructor
163
164   //Main AliRoot Folder
165   if (fTopFolder == 0x0)
166    {
167      Fatal("AliConfig(const char*, const char*)","Can not create Top Alice Folder.");
168      return;//never reached
169    }
170   fTopFolder->SetOwner();
171   
172   fDetectorFolder[kDetFolderData] = fgkDataFolderName;
173   fDetectorFolder[kDetFolderCalibration] = fgkConditionsFolderName+"/"+fgkCalibrationFolderName;
174   fDetectorFolder[kDetFolderAligmnet] = fgkConditionsFolderName+"/"+fgkAligmentFolderName;
175   fDetectorFolder[kDetFolderQA] = fgkConditionsFolderName+"/"+fgkQAFolderName;
176   fDetectorFolder[kDetFolderLast] = "";
177   
178   gROOT->GetListOfBrowsables()->Add(fTopFolder, name);
179
180   //Constants folder
181   TFolder *fConstFolder = fTopFolder->AddFolder (fgkConstantsFolderName, "Constant parameters");
182   fConstFolder->AddFolder("DatabasePDG", "PDG database");
183   
184   // Add the tasks to //Folders
185   
186   TTask * qa = new TTask(fgkQATaskName, "Alice QA tasks");
187   fTaskFolder->Add(qa); 
188   TTask * sd = new TTask(fgkSDigitizerTaskName, "Alice SDigitizer") ;
189   fTaskFolder->Add(sd); 
190   TTask * di = new TTask(fgkDigitizerTaskName, "Alice Digitizer") ;
191   fTaskFolder->Add(di); 
192   TTask * re = new TTask(fgkReconstructionerTaskName, "Alice Reconstructioner") ;
193   fTaskFolder->Add(re); 
194   TTask * tr = new TTask(fgkTrackerTaskName,"Alice Tracker");
195   fTaskFolder->Add(tr);
196   TTask * pid = new TTask(fgkPIDTaskName,"Alice Particle Identification Task");
197   fTaskFolder->Add(pid);
198   fDetectorTask    =  new TString[kDetTaskLast+1];
199   
200   fDetectorTask[kDetTaskQA] = fgkQATaskName;
201   fDetectorTask[kDetTaskSDigitizer] = fgkSDigitizerTaskName;
202   fDetectorTask[kDetTaskDigitizer] =  fgkDigitizerTaskName;
203   fDetectorTask[kDetTaskRecontructioner] = fgkReconstructionerTaskName;
204   fDetectorTask[kDetTaskTracker] = fgkTrackerTaskName;
205   fDetectorTask[kDetTaskPID] = fgkPIDTaskName;
206   fDetectorTask[kDetTaskLast] = "";
207
208   fInstance=this;
209 }
210
211 //____________________________________________________________________________
212 AliConfig::~AliConfig()
213
214   delete [] fDetectorFolder ;  
215   delete [] fDetectorTask;
216   if (fTopFolder)
217    {
218     fTopFolder->SetOwner();
219     delete fTopFolder; 
220    }
221 }
222 //____________________________________________________________________________
223
224 void AliConfig::AddInFolder (const char *dir, TObject *obj)
225 {
226   TFolder *folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
227   if (folder)
228     folder->Add (static_cast<TObject *>(obj));
229 }
230 //____________________________________________________________________________
231
232 Int_t AliConfig::AddSubTask(const char *taskname, const char* name,const char* title)
233 {
234 //Create new task named 'name' and titled 'title' 
235 //as a subtask of the task named 'taskname'
236
237    if (AliLoader::fgDebug) Info("AddSubTask","Try to get folder named %s",taskname);
238    TObject* obj = fTopFolder->FindObject(taskname);
239    TTask * task = (obj)?dynamic_cast<TTask*>(obj):0x0;
240    if (task)
241      {
242       if (AliLoader::fgDebug) Info("AddSubTask","          Got");
243       TTask * subtask = static_cast<TTask*>(task->GetListOfTasks()->FindObject(name));
244       if (!subtask) 
245         {
246           subtask = new TTask(name,title);
247           task->Add(subtask);
248         }
249       else
250        {
251          Warning("AddSubTask","Task named \"%s\" already exists in Task %s\n",name,taskname);
252        }
253      }
254    else
255      {
256        Error("AddSubTask","Can not find task %s to put a new task in.",taskname);
257        return 1;
258      }
259   return 0;
260 }
261
262 //____________________________________________________________________________
263 TObject* AliConfig::FindInFolder (const char *dir, const char *name)
264 {
265   if(!name) return(fTopFolder->FindObject(name));
266   TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
267   if (!folder) return (NULL);
268   return(folder->FindObject(name));
269 }
270
271 //____________________________________________________________________________
272 void    AliConfig::Add (AliGenerator * obj,const char* eventfolder)
273 {
274   TString path(eventfolder);
275   path = path + "/" + fgkGeneratorsFolderName;
276   AddInFolder(path,obj);
277 }
278
279 //____________________________________________________________________________
280 void AliConfig::Add (TVirtualMC * obj,const char* eventfolder)
281 {
282   TString path(eventfolder);
283   path = path + "/" + fgkMCFolderName;
284   AddInFolder(path, obj);
285 }
286
287 //____________________________________________________________________________
288 void  AliConfig::Add (TDatabasePDG * obj)
289 {
290   AddInFolder(fgkPDGFolderName, obj);
291 }
292
293 //____________________________________________________________________________
294 void AliConfig::Add(AliModule* obj,const char* eventfolder)
295 {
296   
297   TString path(eventfolder);
298   path = path + "/" + fgkModuleFolderName;
299   if (AliLoader::fgDebug)
300     Info("Add(AliModule*)","module name = %s, Ev. Fold. Name is %s.",
301          obj->GetName(),eventfolder);
302   AddInFolder(path, obj);
303 }
304 //____________________________________________________________________________
305
306 Int_t AliConfig::AddDetector(TFolder* evntfolder, const char *name, const char* title)
307 {
308 //creates folders and tasks for the detector 'name'
309  Int_t retval;//returned value
310  retval = CreateDetectorFolders(evntfolder,name,title);
311  if (retval)
312   {
313     Error("AddDetector","CreateDetectorFolders returned error for detector %s",name);
314     return retval;
315   }
316  return 0; 
317 }
318 //____________________________________________________________________________
319
320 Int_t AliConfig::AddDetector(const char* evntfoldername,const char *name, const char* title)
321 {
322 //creates folders and tasks for the detector 'name'
323  Int_t retval;//returned value
324  retval = CreateDetectorFolders(evntfoldername,name,title);
325  if (retval)
326   {
327     Error("AddDetector","CreateDetectorFolders returned error for detector %s",name);
328     return retval;
329   }
330 // retval = CreateDetectorTasks(name,title);
331 // if (retval)
332 //  {
333 //    Error("AddDetector","CreateDetectorTasks returned error for detector %s",name);
334 //    return retval;
335 //  }
336  return 0; 
337 }
338 //____________________________________________________________________________
339
340 void  AliConfig::Add(AliDetector * obj,const char* eventfolder)
341 {
342   if (AliLoader::fgDebug) 
343     Info("Add(AliDetector*)","detector name = %s, Ev. Fold. Name is %s.",
344         obj->GetName(),eventfolder);
345
346   TObject* foundobj = GetTopFolder()->FindObject(eventfolder);
347   TFolder* evfolder = (foundobj)?dynamic_cast<TFolder*>(foundobj):0x0;
348   if (evfolder == 0x0)
349    {
350      Fatal("Add(AliDetector * obj,const char* eventfolder)",
351            "Can not find folder %s while adding detector %s",eventfolder,obj->GetName());
352      return;
353    } 
354   CreateDetectorFolders(evfolder, obj->GetName(), obj->GetTitle());
355   
356 //  CreateDetectorTasks(obj->GetName(),obj->GetTitle());
357
358 }
359 //____________________________________________________________________________
360
361 Int_t  AliConfig::CreateDetectorFolders(const char* evntfoldername,const char *name, const char* title)
362 {
363 //creates a folders for detector named 'name' and titled 'title'
364 //in a event folder named 'evntfoldername'
365 //list of folder names where new folders are created is defined in fDetectorFolder array 
366 //detector folders are named 'name' and titled 'title' as well
367
368  TFolder* evfolder = dynamic_cast<TFolder*>(GetTopFolder()->FindObject(evntfoldername));
369  if (evfolder == 0x0)
370   {
371    Error("CreateDetectorFolders",
372          "Can not find folder %s while adding detector %s",evntfoldername,name);
373    return 1;
374   }
375  return CreateDetectorFolders(evfolder,name,title);
376 }
377 //____________________________________________________________________________
378 Int_t  AliConfig::CreateDetectorFolders(TFolder* evntfolder,const char *name, const char* title)
379 {
380 //creates a folders for detector named 'name' and titled 'title'
381 //in a event folder 'evntfolder'
382 //list of folder names where new folders are created is defined in fDetectorFolder array 
383 //detector folders are named 'name' and titled 'title' as well
384 //Here we add only detector not an modules
385  
386  Int_t tmp;
387  Int_t i = 0;//iterator
388  while(!fDetectorFolder[i].IsNull())
389   {
390     tmp = AddSubFolder(evntfolder,fDetectorFolder[i],name,title);
391     if (tmp)
392      {
393       Error("AddDetector(TFolder*","Failed to create subfolder of %s for detector %s",fDetectorFolder[i].Data(),name);
394       return 1;
395      }
396     i++;
397   }
398  return 0;
399 }
400 //____________________________________________________________________________
401 Int_t AliConfig::CreateDetectorTasks(const char *name, const char* title)
402 {
403    Int_t i = 0;
404    Int_t tmp;
405    while (i < kDetTaskLast)
406     {
407       tmp = AddSubTask(fgkTasksFolderName+"/"+fDetectorTask[i],
408                        name+fDetectorTask[i],(fDetectorTask[i]+" for ")+title);
409       if (tmp)
410        {
411          Error("CreateDetectorTasks","Error occured while creating task for %s in %s.",
412                 name,fDetectorTask[i-1].Data());
413          return 1;
414        }
415       i++;
416     }
417    return 0;
418 }
419
420 //____________________________________________________________________________
421 void    AliConfig::Add (char *list)
422 {
423   char *path;
424   
425   const char   *conf_path = gSystem->Getenv ("ALICE_CONFIG_PATH");
426   if  (conf_path) {
427     path = new char[strlen (conf_path)];
428     strcpy (path, conf_path);
429   } else {
430     const char   *alice = gSystem->Getenv ("ALICE_ROOT");
431     path = new char[strlen (alice) + 32];
432     
433     strcpy (path, ".:");
434     if (alice) {
435       strcat (path, alice);
436     }
437     strcat (path, "/macros/config");
438   }
439   
440   char   *token = strtok (path, ":");
441   
442   TList  *dirlist = new TList;
443   
444   while (token != NULL) 
445     {
446       dirlist->Add (new TObjString(token));
447       token = strtok (NULL, ":");
448     }
449   
450   token = strtok (list, " ");
451   
452   while (token != NULL)
453     { 
454       Info("Add(char *list)","Configuring token=%s",token);
455       
456       TObject *obj;
457       TIter   next (dirlist);
458       TString found = "\0";
459       
460       while ((obj = next ()))
461         {
462           TString dir(obj->GetName());
463           TString path  = dir + "/" + token;
464           TString macro = path + ".C";
465           if (!gSystem->AccessPathName (macro.Data()))  
466            {
467             gInterpreter->ExecuteMacro (macro.Data());                             
468             found = "(" + macro + ")";
469             if (macro.Contains("/")) 
470              {
471                TString dirname = gSystem->DirName(macro.Data());
472                TString macroConfigure = dirname + "/Configure.C";
473                if (!gSystem->AccessPathName (macroConfigure.Data()))
474                 {
475                   gInterpreter->ExecuteMacro (macroConfigure.Data());                               
476                   found += " => Configured";
477                 }                             
478              }
479             break;
480            } 
481           else 
482            {
483             TString macroDefault = path + "/Default.C";
484             if (!gSystem->AccessPathName (macroDefault.Data()))
485               {
486                 gInterpreter->ExecuteMacro (macroDefault.Data());
487                 found = "(" + macro + ")";
488                 TString macroConfigure = path + "/Configure.C";
489                 if (!gSystem->AccessPathName (macroConfigure.Data()))   
490                   {
491                     gInterpreter->ExecuteMacro (macroConfigure.Data());                             
492                     found += " => Configured";
493                   }
494                 break;                              
495               }
496            }
497         }
498       
499       if (strlen(found.Data())) 
500         {
501           Info("Add(char *list)","found=%s  => OK",found.Data());
502         } 
503       else 
504         {
505           Error("Add(char *list)"," => FAILED.");
506           exit(1); 
507         }           
508       
509       token = strtok (NULL," ");
510     }
511   
512   if (dirlist) delete dirlist;
513   
514 }
515
516 /*****************************************************************************/
517
518 TFolder* AliConfig::BuildEventFolder(const char* name,const char* title)
519 {
520 /*
521  creates the folder structure for one event
522  TopFolder_
523          | \
524          |  Tasks
525          |_
526          | \
527          |  Constants
528          |_
529          | \
530          |  Event_
531          |      | \
532          |      |  Modules(detector objects)
533          |      |_
534          |      | \              
535          |      |  Header
536          |      |_
537          |      | \              
538          |      |  Data_
539          |      |     | \ 
540          |      |     |  TPC_
541          |      |     |    | \
542          |      |     |    |  Hits(object;e.g. tree)
543          |      |     |    |_  
544          |      |     |    | \ 
545          |      |     |    |  SDigits(object)
546          |      |     |    |_
547          |      |     |    | \ 
548          |      |     |    |  Digits(object)
549          |      |     |    |_
550          |      |     |    | \ 
551          |      |     |    |  RecPoints(object)
552          |      |     |    |_
553          |      |     |      \ 
554          |      |     |       Tracks(object)
555          |      |     |_ 
556          |      |       \
557          |      |        ITS_
558          |      |          | \
559          |      |          |  Hits(object;e.g. tree)
560          |      |          |_  
561          |      |          | \ 
562          |      |          |  SDigits(object)
563          |      |          |_
564          |      |          | \ 
565          |      |          |  Digits(object)
566          |      |          |_
567          |      |          | \ 
568          |      |          |  RecPoints(object)
569          |      |          |_
570          |      |            \ 
571          |      |             Tracks(object)
572          |      |_         
573          |        \       
574          |         Configuration
575          |               
576          |_
577            \
578             Event2_  (to be merged with event)
579                 |  \
580                 |   Modules(detector objects)
581                 |_
582                 | \              
583                 |  Header
584                 |_
585                 | \              
586                 |  Data_
587                 |     | \ 
588                 |     |  TPC_
589                 |     |    | \
590                 |     |    |  Hits(object;e.g. tree)
591                 |     |    |_  
592                 |     |    | \ 
593                 |     |    |  SDigits(object)
594                 |     |    |_
595                 |     |    | \ 
596                 |     |    |  Digits(object)
597                 |     |    |_
598                 |     |    | \ 
599                 |     |    |  RecPoints(object)
600                 |     |    |_
601                 |     |      \ 
602                 |     |       Tracks(object)
603                 |     |_ 
604                 |       \
605                 |        ITS_
606                 |          | \
607                 |          |  Hits(object;e.g. tree)
608                 |          |_  
609                 |          | \ 
610                 |          |  SDigits(object)
611                 |          |_
612                 |          | \ 
613                 |          |  Digits(object)
614                 |          |_
615                 |          | \ 
616                 |          |  RecPoints(object)
617                 |          |_
618                 |            \ 
619                 |             Tracks(object)
620                 |_         
621                   \       
622                    Configuration
623                          
624 */
625   TFolder* eventfolder = fTopFolder->AddFolder(name,title); 
626    
627   //modules
628   eventfolder->AddFolder(fgkModuleFolderName, "Detector objects");
629   //event data
630   eventfolder->AddFolder(fgkDataFolderName, "Detector data");
631   
632     //Conditions
633   TFolder *conditions = eventfolder->AddFolder(fgkConditionsFolderName, "Run conditions");
634   conditions->AddFolder(fgkCalibrationFolderName,"Detector calibration data");
635   conditions->AddFolder(fgkAligmentFolderName,"Detector aligment");
636   conditions->AddFolder(fgkQAFolderName,"Quality Asurance Output"); //Folder with output of the QA task(s)
637   //Configuration
638   TFolder *configuration = eventfolder->AddFolder(fgkConfigurationFolderName, "Run configuration");
639   configuration->AddFolder(fgkFieldFolderName, "Magnetic field maps");
640   configuration->AddFolder(fgkGeneratorsFolderName,"list of generator objects");
641   configuration->AddFolder(fgkVirtualMCFolderName,"the Virtual MC");
642
643   eventfolder->AddFolder(fgkHeaderFolderName,"MonteCarlo event header");
644
645   eventfolder->SetOwner();
646
647   return eventfolder;
648 }
649
650 /*****************************************************************************/
651
652 TString AliConfig::GetQATaskName() const
653  {
654  //returns task name
655   return fDetectorTask[kDetTaskQA];
656  }
657 /*****************************************************************************/
658  
659 TString AliConfig::GetDigitizerTaskName() const
660  {
661  //returns task name
662   return fDetectorTask[kDetTaskDigitizer];
663  }
664 /*****************************************************************************/
665  
666 TString AliConfig::GetSDigitizerTaskName() const
667  {
668  //returns task name
669   return fDetectorTask[kDetTaskSDigitizer];
670  }
671 /*****************************************************************************/
672
673 TString AliConfig::GetReconstructionerTaskName() const
674  {
675  //returns task name
676   return fDetectorTask[kDetTaskRecontructioner];
677  }
678 /*****************************************************************************/
679
680 TString AliConfig::GetTrackerTaskName() const
681  {
682  //returns task name
683   return fDetectorTask[kDetTaskTracker];
684  }
685 /*****************************************************************************/
686
687 TString AliConfig::GetPIDTaskName() const
688  {
689  //returns task name
690   return fDetectorTask[kDetTaskPID];
691  }
692 /*****************************************************************************/
693
694 const TString& AliConfig::GetQAFolderName() const
695 {
696 //returns pathname of folder with QA output relative to Top Alice Folder
697   return fDetectorFolder[kDetFolderQA];
698 }
699 /*****************************************************************************/
700
701 const TString& AliConfig::GetDataFolderName()
702 {
703 //returns name of data folder path relative to event folder
704  return fgkDataFolderName;
705 }
706 /*****************************************************************************/
707
708 Int_t AliConfig::AddSubFolder(TFolder* topfolder, const char* infoler, 
709                      const char* newfoldname, const char* newfoldtitle)
710 {
711 //helper method
712 //in topfolder looks for folder named 'infolder'
713 //and if it exist it creates inside a new folder named 'newfoldname' and titled 'newfoldtitle'
714
715  if (topfolder == 0x0)//check if exists top folder
716   {
717    Error("AddSubFodler(TFolder*, ....","Parameter TFolder* points to NULL.");
718    return 1;
719   }
720  
721  TObject *obj;
722  TFolder* folder;
723  
724  folder = dynamic_cast<TFolder*>(topfolder->FindObject(infoler));
725  if (folder == 0x0) //check if we got inolder
726   {
727    Error("AddSubFodler(TFolder*, ....","Can not find folder %s in folder %s.",infoler,topfolder->GetName());
728    return 1;
729   }
730  obj = folder->FindObject(newfoldname); //see if such a subfolder already exists
731  if (obj == 0x0) //nope
732   {
733    TFolder *newfolder = folder->AddFolder(newfoldname,newfoldtitle);//add the desired subfolder
734    if (newfolder == 0x0) //check if we managed
735     {
736      Error("AddSubFodler(TFolder*, ....","Can not create folder %s in folder %s",newfoldname,infoler);
737      return 2;
738     }
739    else return 0;//success
740   }
741  else
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     else
751      {
752       Warning("AddSubFodler(TFolder*, ....",
753              "Folder named %s already exists in folder %s",newfoldname,infoler);
754       return 0;
755      }
756   }
757  return 0; //never reached
758 }