]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliSimulation.h
Announce changed
[u/mrichter/AliRoot.git] / STEER / AliSimulation.h
1 #ifndef ALISIMULATION_H
2 #define ALISIMULATION_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 //
9 // class for running generation, simulation and digitization
10 // Hits, sdigits and digits are created for all detectors by typing:
11 //   AliSimulation sim;
12 //   sim.Run();
13 //
14
15 #include <TNamed.h>
16 #include <TString.h>
17 #include <TObjArray.h>
18 #include "AliQA.h"
19
20 class AliCDBId;
21 class AliCDBParam;
22 class AliRunLoader;
23 class AliQADataMakerSteer ; 
24
25 class AliSimulation: public TNamed {
26 public:
27   AliSimulation(const char* configFileName = "Config.C",
28                 const char* name = "AliSimulation", 
29                 const char* title = "generation, simulation and digitization");
30   AliSimulation(const AliSimulation& sim);
31   AliSimulation& operator = (const AliSimulation& sim);
32   virtual ~AliSimulation();
33
34   static AliSimulation *GetInstance() {return fgInstance;}
35
36   void           SetNumberOfEvents(Int_t nEvents);
37   void           SetConfigFile(const char* fileName);
38   void           SetGAliceFile(const char* fileName);
39   void           SetEventsPerFile(const char* detector, const char* type, 
40                                   Int_t nEvents);
41
42   void           SetRunGeneration(Bool_t run) {fRunGeneration = run;};
43   void           SetRunSimulation(Bool_t run) {fRunSimulation = run;};
44   void           SetLoadAlignFromCDB(Bool_t load)  {fLoadAlignFromCDB = load;};
45   void           SetLoadAlignData(const char* detectors) 
46                    {fLoadAlObjsListOfDets = detectors;};
47   void           SetMakeSDigits(const char* detectors) 
48                    {fMakeSDigits = detectors;};
49   void           MergeWith(const char* fileName, Int_t nSignalPerBkgrd = 0);
50   void           EmbedInto(const char* fileName, Int_t nSignalPerBkgrd = 0);
51   void           SetUseBkgrdVertex(Bool_t useBkgrdVertex)
52                    {fUseBkgrdVertex = useBkgrdVertex;};
53   void           SetRegionOfInterest(Bool_t flag) {fRegionOfInterest = flag;};
54   void           SetMakeDigits(const char* detectors)
55                    {fMakeDigits = detectors;};
56   void           SetMakeTrigger(const char* descriptors)
57                    {fMakeTrigger = descriptors;};
58   void           SetMakeDigitsFromHits(const char* detectors)
59                    {fMakeDigitsFromHits = detectors;};
60   void           SetWriteRawData(const char* detectors, 
61                                  const char* fileName = NULL,
62                                  Bool_t deleteIntermediateFiles = kFALSE)
63                    {fWriteRawData = detectors; fRawDataFileName = fileName;
64                    fDeleteIntermediateFiles = deleteIntermediateFiles;};
65   void           SetAlignObjArray(TObjArray *array)
66                    {fAlignObjArray = array;
67                    fLoadAlignFromCDB = kFALSE;}
68
69   Bool_t         MisalignGeometry(AliRunLoader *runLoader = NULL);
70
71   void           SetRunNumber(Int_t run);
72   void           SetSeed(Int_t seed);
73     
74   void           ProcessEnvironmentVars();
75                    
76   // CDB storage activation
77   void SetDefaultStorage(const char* uri);
78   void SetSpecificStorage(const char* calibType, const char* uri);
79
80   virtual Bool_t Run(Int_t nEvents = 0);
81
82   virtual Bool_t RunSimulation(Int_t nEvents = 0);
83   virtual Bool_t RunSDigitization(const char* detectors = "ALL");
84   virtual Bool_t RunTrigger(const char* descriptors ="", const char* detectors = "ALL");
85   virtual Bool_t WriteTriggerRawData();
86   virtual Bool_t RunDigitization(const char* detectors = "ALL",
87                                  const char* excludeDetectors = "");
88   virtual Bool_t RunHitsDigitization(const char* detectors = "ALL");
89   virtual Bool_t WriteRawData(const char* detectors = "ALL",
90                               const char* fileName = NULL,
91                               Bool_t deleteIntermediateFiles = kFALSE);
92   virtual Bool_t WriteRawFiles(const char* detectors = "ALL");
93   virtual Bool_t ConvertRawFilesToDate(const char* dateFileName = "raw.date");
94   virtual Bool_t ConvertDateToRoot(const char* dateFileName = "raw.date",
95                                    const char* rootFileName = "raw.root");
96   virtual Bool_t ConvertRaw2SDigits(const char* rawDirectory, const char* esdFile = "");
97
98   // HLT
99   void SetRunHLT(const char* options) {fRunHLT=options;}
100   virtual Bool_t RunHLT();
101
102   //Quality Assurance
103   Int_t       GetDetIndex(const char * detector);
104   const Int_t GetQACycles(const char * detector) { return fQACycles[GetDetIndex(detector)] ; }
105   void        SetQACycles(const char * detector, const Int_t cycles) { fQACycles[GetDetIndex(detector)] = cycles ; }
106   Bool_t      RunQA() ;
107   void        SetQA(const Bool_t val) { fRunQA = val ; } 
108   
109 private:
110   void           InitCDB();
111   void           InitRunNumber();
112   void           SetCDBLock();
113   Bool_t         SetRunNumberFromData();
114   AliRunLoader*  LoadRun(const char* mode = "UPDATE") const;
115   Int_t          GetNSignalPerBkgrd(Int_t nEvents = 0) const;
116   Bool_t         IsSelected(TString detName, TString& detectors) const;
117
118   static AliSimulation *fgInstance;    // Static pointer to object
119
120   Bool_t         fRunGeneration;      // generate prim. particles or not
121   Bool_t         fRunSimulation;      // simulate detectors (hits) or not
122   Bool_t         fLoadAlignFromCDB;   // Load alignment data from CDB and apply it to geometry or not
123   TString        fLoadAlObjsListOfDets;   // Load alignment data from CDB for these detectors
124   TString        fMakeSDigits;        // create sdigits for these detectors
125   TString        fMakeDigits;         // create digits for these detectors
126   TString        fMakeTrigger;        // run trigger for these descriptors
127   TString        fMakeDigitsFromHits; // create digits from hits for these detectors
128   TString        fWriteRawData;       // write raw data for these detectors
129   TString        fRawDataFileName;    // file name for the raw data file
130   Bool_t         fDeleteIntermediateFiles; // delete intermediate raw data files
131   Bool_t         fStopOnError;        // stop or continue on errors
132
133   Int_t          fNEvents;            // number of events
134   TString        fConfigFileName;     // name of the config file
135   TString        fGAliceFileName;     // name of the galice file
136   TObjArray      fEventsPerFile;      // number of events per file for given detectors and data types
137
138   TObjArray*     fBkgrdFileNames;     // names of background files for merging
139   TObjArray*     fAlignObjArray;      // array with the alignment objects to be applied to the geometry
140   Bool_t         fUseBkgrdVertex;     // use vertex from background in case of merging
141   Bool_t         fRegionOfInterest;   // digitization in region of interest
142
143   TString        fCDBUri;             //! Uri of the default CDB storage
144   TObjArray      fSpecCDBUri;         //! Array with detector specific CDB storages
145   Int_t          fRun;                //! Run number, will be passed to CDB and gAlice!!
146   Int_t          fSeed;               //! Seed for random number generator 
147   Bool_t         fInitCDBCalled;      //! flag to check if CDB storages are already initialized
148   Bool_t         fInitRunNumberCalled;  //! flag to check if run number is already initialized
149   Bool_t         fSetRunNumberFromDataCalled;  //! flag to check if run number is already loaded from run loader
150   
151   Bool_t         fEmbeddingFlag;      // Flag for embedding
152   
153   //QA stuff
154   static const Int_t   fgkNDetectors = 15 ;             // number of detectors
155   static const char *  fgkDetectorName[fgkNDetectors] ; // names of detectors
156   Int_t                fQACycles[fgkNDetectors] ;       // cycle length (# events) over which QA data are accumulated
157   Bool_t               fRunQA ;                         // Runs the QA at the end of simulation
158
159   //HLT
160   TString        fRunHLT;             // HLT options, HLT is disabled if empty, default='default'
161
162   ClassDef(AliSimulation, 7)  // class for running generation, simulation and digitization
163 };
164
165 #endif