]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliSimulation.h
Base class (AliMisaligner); each detector will provide its derived class,
[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 #include "AliQADataMakerSteer.h"
20
21 class AliCDBId;
22 class AliCDBParam;
23 class AliRunLoader;
24 class AliLegoGenerator;
25 class AliLego;
26 class AliMagF;
27
28 class AliSimulation: public TNamed {
29 public:
30   AliSimulation(const char* configFileName = "Config.C",
31                 const char* name = "AliSimulation", 
32                 const char* title = "generation, simulation and digitization");
33   virtual ~AliSimulation();
34
35   static AliSimulation *Instance() {return fgInstance;}
36
37   void           SetNumberOfEvents(Int_t nEvents);
38   void           SetConfigFile(const char* fileName);
39   void           SetGAliceFile(const char* fileName);
40   void           SetEventsPerFile(const char* detector, const char* type, 
41                                   Int_t nEvents);
42
43   void           SetRunGeneration(Bool_t run) {fRunGeneration = run;};
44   void           SetRunSimulation(Bool_t run) {fRunSimulation = run;};
45   void           SetLoadAlignFromCDB(Bool_t load)  {fLoadAlignFromCDB = load;};
46   void           SetLoadAlignData(const char* detectors) 
47                    {fLoadAlObjsListOfDets = detectors;};
48   void           SetMakeSDigits(const char* detectors) 
49                    {fMakeSDigits = detectors;};
50   void           MergeWith(const char* fileName, Int_t nSignalPerBkgrd = 0);
51   void           EmbedInto(const char* fileName, Int_t nSignalPerBkgrd = 0);
52   void           SetUseBkgrdVertex(Bool_t useBkgrdVertex)
53                    {fUseBkgrdVertex = useBkgrdVertex;};
54   void           SetRegionOfInterest(Bool_t flag) {fRegionOfInterest = flag;};
55   void           SetMakeDigits(const char* detectors)
56                    {fMakeDigits = detectors;};
57   void           SetMakeTrigger(const char* descriptors)
58                    {fMakeTrigger = descriptors;};
59   void           SetMakeDigitsFromHits(const char* detectors)
60                    {fMakeDigitsFromHits = detectors;};
61   void           SetWriteRawData(const char* detectors, 
62                                  const char* fileName = NULL,
63                                  Bool_t deleteIntermediateFiles = kFALSE)
64                    {fWriteRawData = detectors; fRawDataFileName = fileName;
65                    fDeleteIntermediateFiles = deleteIntermediateFiles;};
66   void           SetWriteSelRawData(Bool_t sel = kTRUE)
67                    {fWriteSelRawData = sel;}
68   void           SetAlignObjArray(TObjArray *array)
69                    {fAlignObjArray = array;
70                    fLoadAlignFromCDB = kFALSE;}
71
72   Bool_t         MisalignGeometry(AliRunLoader *runLoader = NULL);
73
74   void           SetRunNumber(Int_t run);
75   void           SetSeed(Int_t seed);
76     
77   void           ProcessEnvironmentVars();
78                    
79   // CDB storage activation
80   void SetDefaultStorage(const char* uri);
81   void SetSpecificStorage(const char* calibType, const char* uri);
82
83   virtual Bool_t Run(Int_t nEvents = 0);
84   virtual Bool_t RunLego(const char *setup="Config.C",Int_t nc1=60,Float_t c1min=2,Float_t c1max=178,
85                          Int_t nc2=60,Float_t c2min=0,Float_t c2max=360,Float_t rmin=0,
86                          Float_t rmax=430,Float_t zmax=10000, AliLegoGenerator* gener=NULL, Int_t nev = -1);
87
88   virtual Bool_t RunSimulation(Int_t nEvents = 0);
89   virtual Bool_t RunSDigitization(const char* detectors = "ALL");
90   virtual Bool_t RunTrigger(const char* descriptors ="", const char* detectors = "ALL");
91   virtual Bool_t WriteTriggerRawData();
92   virtual Bool_t RunDigitization(const char* detectors = "ALL",
93                                  const char* excludeDetectors = "");
94   virtual Bool_t RunHitsDigitization(const char* detectors = "ALL");
95   virtual Bool_t WriteRawData(const char* detectors = "ALL",
96                               const char* fileName = NULL,
97                               Bool_t deleteIntermediateFiles = kFALSE,
98                               Bool_t selrawdata = kFALSE);
99   virtual Bool_t WriteRawFiles(const char* detectors = "ALL");
100   virtual Bool_t ConvertRawFilesToDate(const char* dateFileName = "raw.date",
101                                        const char* rootFileName = "");
102   virtual Bool_t ConvertDateToRoot(const char* dateFileName = "raw.date",
103                                    const char* rootFileName = "raw.root");
104   virtual Bool_t ConvertRaw2SDigits(const char* rawDirectory, const char* esdFile = "");
105
106   // HLT
107   void SetRunHLT(const char* options) {fRunHLT=options;}
108   virtual Bool_t RunHLT();
109   virtual  Bool_t IsLegoRun() const {return (fLego!=0);}
110   AliLego* Lego() const {return fLego;}
111   virtual  void  FinishRun();
112
113   //Quality Assurance
114   Int_t       GetDetIndex(const char * detector);
115   void        SetQACycles(AliQA::DETECTORINDEX_t det, const Int_t cycles) {  fQASteer->SetCycleLength(det, cycles) ; }
116   Bool_t      RunQA() ;
117   Bool_t      SetRunQA(TString detAndAction="ALL:ALL") ; 
118   void        SetQAWriteExpert(AliQA::DETECTORINDEX_t det) { fQASteer->SetWriteExpert(det) ; }
119
120   void SetWriteGRPEntry(Bool_t flag = kTRUE) { fWriteGRPEntry = flag; }
121   void WriteGRPEntry();
122
123 private:
124
125   AliSimulation(const AliSimulation&); // Not implemented
126   AliSimulation& operator = (const AliSimulation&); // Not implemented
127
128   void           InitCDB();
129   void           InitRunNumber();
130   void           SetCDBLock();
131   Bool_t         SetRunNumberFromData();
132   AliRunLoader*  LoadRun(const char* mode = "UPDATE") const;
133   Int_t          GetNSignalPerBkgrd(Int_t nEvents = 0) const;
134   Bool_t         IsSelected(TString detName, TString& detectors) const;
135
136   static AliSimulation *fgInstance;    // Static pointer to object
137
138   Bool_t         fRunGeneration;      // generate prim. particles or not
139   Bool_t         fRunSimulation;      // simulate detectors (hits) or not
140   Bool_t         fLoadAlignFromCDB;   // Load alignment data from CDB and apply it to geometry or not
141   TString        fLoadAlObjsListOfDets;   // Load alignment data from CDB for these detectors
142   TString        fMakeSDigits;        // create sdigits for these detectors
143   TString        fMakeDigits;         // create digits for these detectors
144   TString        fMakeTrigger;        // run trigger for these descriptors
145   TString        fMakeDigitsFromHits; // create digits from hits for these detectors
146   TString        fWriteRawData;       // write raw data for these detectors
147   TString        fRawDataFileName;    // file name for the raw data file
148   Bool_t         fDeleteIntermediateFiles; // delete intermediate raw data files
149   Bool_t         fWriteSelRawData;    // write detectors raw data in a separate file accoring to the trigger cluster
150   Bool_t         fStopOnError;        // stop or continue on errors
151
152   Int_t          fNEvents;            // number of events
153   TString        fConfigFileName;     // name of the config file
154   TString        fGAliceFileName;     // name of the galice file
155   TObjArray      fEventsPerFile;      // number of events per file for given detectors and data types
156
157   TObjArray*     fBkgrdFileNames;     // names of background files for merging
158   TObjArray*       fAlignObjArray;      // array with the alignment objects to be applied to the geometry
159   Bool_t         fUseBkgrdVertex;     // use vertex from background in case of merging
160   Bool_t         fRegionOfInterest;   // digitization in region of interest
161
162   TString        fCDBUri;                            //! Uri of the default CDB storage
163   TObjArray  fSpecCDBUri;                  //! Array with detector specific CDB storages
164   Int_t            fRun;                                     //! Run number, will be passed to CDB and gAlice!!
165   Int_t            fSeed;                        //! Seed for random number generator 
166   Bool_t           fInitCDBCalled;               //! flag to check if CDB storages are already initialized
167   Bool_t           fInitRunNumberCalled;         //! flag to check if run number is already initialized
168   Bool_t           fSetRunNumberFromDataCalled;  //! flag to check if run number is already loaded from run loader
169   
170   Bool_t     fEmbeddingFlag;      // Flag for embedding
171   AliLego       *fLego;              //! Pointer to aliLego object if it exists
172   
173   //QA stuff
174   static const Int_t   fgkNDetectors = 15 ;             // number of detectors
175   static const char *  fgkDetectorName[fgkNDetectors] ; // names of detectors
176   TString              fQADetectors ;                   // list of detectors to be QA'ed        
177   TString              fQATasks ;                       // list of QA tasks to be performed     
178   AliQADataMakerSteer * fQASteer ;                      // steering object to run QA
179   Bool_t               fRunQA ;                         // Runs the QA at the end of simulation
180   AliRecoParam::EventSpecie_t fEventSpecie ;                   // type of event (see AliRecoParam::EventSpecie_t)
181
182   //HLT
183   TString        fRunHLT;             // HLT options, HLT is disabled if empty, default='default'
184
185   Bool_t         fWriteGRPEntry;      // Write or not GRP entry corresponding to the settings in Config.C
186
187   ClassDef(AliSimulation, 8)  // class for running generation, simulation and digitization
188 };
189
190 #endif