Corrected protection.
[u/mrichter/AliRoot.git] / STEER / AliSimulation.h
CommitLineData
85a5290f 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
af7ba10c 8//
9// class for running generation, simulation and digitization
10// Hits, sdigits and digits are created for all detectors by typing:
af7ba10c 11// AliSimulation sim;
12// sim.Run();
13//
14
85a5290f 15#include <TNamed.h>
16#include <TString.h>
3c166bf6 17#include <TObjArray.h>
4e25ac79 18#include "AliQAv1.h"
b03591ab 19#include "AliQAManager.h"
85a5290f 20
e8d02863 21class AliCDBId;
22class AliCDBParam;
85a5290f 23class AliRunLoader;
3e2e3ece 24class AliLegoGenerator;
25class AliLego;
f7a1cc68 26class AliMagF;
c4affb19 27class AliHLTSimulation;
85a5290f 28
29class AliSimulation: public TNamed {
30public:
95601147 31 AliSimulation(const char* configFileName = "Config.C",
32 const char* name = "AliSimulation",
85a5290f 33 const char* title = "generation, simulation and digitization");
85a5290f 34 virtual ~AliSimulation();
35
b72539fa 36 static AliSimulation *Instance() {if(!fgInstance) fgInstance=new AliSimulation(); return fgInstance;}
b856a511 37
85a5290f 38 void SetNumberOfEvents(Int_t nEvents);
39 void SetConfigFile(const char* fileName);
0421c3d1 40 void SetGAliceFile(const char* fileName);
18b43626 41 void SetEventsPerFile(const char* detector, const char* type,
42 Int_t nEvents);
85a5290f 43
44 void SetRunGeneration(Bool_t run) {fRunGeneration = run;};
45 void SetRunSimulation(Bool_t run) {fRunSimulation = run;};
024cf675 46 void SetLoadAlignFromCDB(Bool_t load) {fLoadAlignFromCDB = load;};
47 void SetLoadAlignData(const char* detectors)
25be1e5c 48 {fLoadAlObjsListOfDets = detectors;};
85a5290f 49 void SetMakeSDigits(const char* detectors)
50 {fMakeSDigits = detectors;};
05526d44 51 void MergeWith(const char* fileName, Int_t nSignalPerBkgrd = 0);
ca30848f 52 void EmbedInto(const char* fileName, Int_t nSignalPerBkgrd = 0);
04bae0a0 53 void SetUseBkgrdVertex(Bool_t useBkgrdVertex)
54 {fUseBkgrdVertex = useBkgrdVertex;};
4df28b43 55 void SetRegionOfInterest(Bool_t flag) {fRegionOfInterest = flag;};
85a5290f 56 void SetMakeDigits(const char* detectors)
57 {fMakeDigits = detectors;};
58 void SetMakeDigitsFromHits(const char* detectors)
59 {fMakeDigitsFromHits = detectors;};
06c7e392 60 void SetWriteRawData(const char* detectors,
61 const char* fileName = NULL,
62 Bool_t deleteIntermediateFiles = kFALSE)
63 {fWriteRawData = detectors; fRawDataFileName = fileName;
64 fDeleteIntermediateFiles = deleteIntermediateFiles;};
67327b72 65 void SetWriteSelRawData(Bool_t sel = kTRUE)
66 {fWriteSelRawData = sel;}
28da60d3 67 void SetTriggerConfig(TString conf) {fTriggerConfig=conf;}
68 const Char_t* GetTriggerConfig() const {return fTriggerConfig.Data();}
024cf675 69 void SetAlignObjArray(TObjArray *array)
6bae477a 70 {fAlignObjArray = array;
71 fLoadAlignFromCDB = kFALSE;}
024cf675 72
6bae477a 73 Bool_t MisalignGeometry(AliRunLoader *runLoader = NULL);
74
795e4a22 75 void SetRunNumber(Int_t run);
76 void SetSeed(Int_t seed);
77
78 void ProcessEnvironmentVars();
024cf675 79
80 // CDB storage activation
ec92bee0 81 void SetDefaultStorage(const char* uri);
00aa02d5 82 void SetSpecificStorage(const char* calibType, const char* uri);
85a5290f 83
84 virtual Bool_t Run(Int_t nEvents = 0);
3e2e3ece 85 virtual Bool_t RunLego(const char *setup="Config.C",Int_t nc1=60,Float_t c1min=2,Float_t c1max=178,
86 Int_t nc2=60,Float_t c2min=0,Float_t c2max=360,Float_t rmin=0,
87 Float_t rmax=430,Float_t zmax=10000, AliLegoGenerator* gener=NULL, Int_t nev = -1);
85a5290f 88
95601147 89 virtual Bool_t RunSimulation(Int_t nEvents = 0);
90 virtual Bool_t RunSDigitization(const char* detectors = "ALL");
8480396b 91 virtual Bool_t RunTrigger(const char* descriptors ="", const char* detectors = "ALL");
007155cc 92 virtual Bool_t WriteTriggerRawData();
95601147 93 virtual Bool_t RunDigitization(const char* detectors = "ALL",
94 const char* excludeDetectors = "");
95 virtual Bool_t RunHitsDigitization(const char* detectors = "ALL");
06c7e392 96 virtual Bool_t WriteRawData(const char* detectors = "ALL",
97 const char* fileName = NULL,
67327b72 98 Bool_t deleteIntermediateFiles = kFALSE,
99 Bool_t selrawdata = kFALSE);
06c7e392 100 virtual Bool_t WriteRawFiles(const char* detectors = "ALL");
67327b72 101 virtual Bool_t ConvertRawFilesToDate(const char* dateFileName = "raw.date",
1b8db7f0 102 const char* rootFileName = "");
06c7e392 103 virtual Bool_t ConvertDateToRoot(const char* dateFileName = "raw.date",
104 const char* rootFileName = "raw.root");
2eab8cf7 105 virtual Bool_t ConvertRaw2SDigits(const char* rawDirectory, const char* esdFile = "", Int_t N=-1);
5b188f2f 106
d97f1dbe 107 // Sets the name of the file from which the geometry is loaded
108 virtual void SetGeometryFile(const Char_t* filename) {fGeometryFile=filename;}
109 virtual const Char_t* GetGeometryFile() const {return fGeometryFile.Data();}
110 virtual Bool_t IsGeometryFromFile() const {return !fGeometryFile.IsNull();}
111
112
cae21299 113 // HLT
114 void SetRunHLT(const char* options) {fRunHLT=options;}
c4affb19 115 virtual Bool_t CreateHLT();
cae21299 116 virtual Bool_t RunHLT();
3e2e3ece 117 virtual Bool_t IsLegoRun() const {return (fLego!=0);}
118 AliLego* Lego() const {return fLego;}
119 virtual void FinishRun();
cae21299 120
5b188f2f 121 //Quality Assurance
122 Int_t GetDetIndex(const char * detector);
eca4fa66 123 void SetQACycles(AliQAv1::DETECTORINDEX_t det, const Int_t cycles) { AliQAManager::QAManager()->SetCycleLength(det, cycles) ; }
a1b90a73 124 Bool_t RunQA() ;
e3b20d9a 125 Bool_t SetRunQA(TString detAndAction="ALL:ALL") ;
eca4fa66 126 void SetQAWriteExpert(AliQAv1::DETECTORINDEX_t det) { AliQAManager::QAManager()->SetWriteExpert(det) ; }
f1c1204d 127 void SetQARefDefaultStorage(const char* uri);
128 void InitQA();
80636887 129 void SetEventSpecie(AliRecoParam::EventSpecie_t es) { fEventSpecie = es ; }
75373542 130 void SetWriteQAExpert() { fWriteQAExpertData = kTRUE ; }
fc7e1b1c 131
132 void SetWriteGRPEntry(Bool_t flag = kTRUE) { fWriteGRPEntry = flag; }
133 void WriteGRPEntry();
732ee20f 134 void UseVertexFromCDB() {fUseVertexFromCDB = kTRUE;}
135 void UseMagFieldFromGRP() {fUseMagFieldFromGRP = kTRUE;}
136 void SetGRPWriteLocation(char* loc) {fGRPWriteLocation = loc;}
fc7e1b1c 137
95601147 138private:
7dd2cbe4 139
140 AliSimulation(const AliSimulation&); // Not implemented
141 AliSimulation& operator = (const AliSimulation&); // Not implemented
142
795e4a22 143 void InitCDB();
144 void InitRunNumber();
145 void SetCDBLock();
146 Bool_t SetRunNumberFromData();
06c7e392 147 AliRunLoader* LoadRun(const char* mode = "UPDATE") const;
05526d44 148 Int_t GetNSignalPerBkgrd(Int_t nEvents = 0) const;
85a5290f 149 Bool_t IsSelected(TString detName, TString& detectors) const;
150
b856a511 151 static AliSimulation *fgInstance; // Static pointer to object
152
85a5290f 153 Bool_t fRunGeneration; // generate prim. particles or not
154 Bool_t fRunSimulation; // simulate detectors (hits) or not
024cf675 155 Bool_t fLoadAlignFromCDB; // Load alignment data from CDB and apply it to geometry or not
25be1e5c 156 TString fLoadAlObjsListOfDets; // Load alignment data from CDB for these detectors
85a5290f 157 TString fMakeSDigits; // create sdigits for these detectors
158 TString fMakeDigits; // create digits for these detectors
28da60d3 159 TString fTriggerConfig; // run trigger for these descriptors
85a5290f 160 TString fMakeDigitsFromHits; // create digits from hits for these detectors
0421c3d1 161 TString fWriteRawData; // write raw data for these detectors
06c7e392 162 TString fRawDataFileName; // file name for the raw data file
163 Bool_t fDeleteIntermediateFiles; // delete intermediate raw data files
67327b72 164 Bool_t fWriteSelRawData; // write detectors raw data in a separate file accoring to the trigger cluster
85a5290f 165 Bool_t fStopOnError; // stop or continue on errors
166
167 Int_t fNEvents; // number of events
168 TString fConfigFileName; // name of the config file
169 TString fGAliceFileName; // name of the galice file
18b43626 170 TObjArray fEventsPerFile; // number of events per file for given detectors and data types
171
85a5290f 172 TObjArray* fBkgrdFileNames; // names of background files for merging
732ee20f 173 TObjArray* fAlignObjArray; // array with the alignment objects to be applied to the geometry
04bae0a0 174 Bool_t fUseBkgrdVertex; // use vertex from background in case of merging
4df28b43 175 Bool_t fRegionOfInterest; // digitization in region of interest
85a5290f 176
57acd2d2 177 TString fCDBUri; //! Uri of the default CDB storage
732ee20f 178 TString fQARefUri; //! Uri of the default QA reference storage
179 TObjArray fSpecCDBUri; //! Array with detector specific CDB storages
57acd2d2 180 Int_t fRun; //! Run number, will be passed to CDB and gAlice!!
181 Int_t fSeed; //! Seed for random number generator
182 Bool_t fInitCDBCalled; //! flag to check if CDB storages are already initialized
183 Bool_t fInitRunNumberCalled; //! flag to check if run number is already initialized
184 Bool_t fSetRunNumberFromDataCalled; //! flag to check if run number is already loaded from run loader
795e4a22 185
732ee20f 186 Bool_t fEmbeddingFlag; // Flag for embedding
187 AliLego *fLego; //! Pointer to aliLego object if it exists
188 // OCDB
189 ULong_t fKey; //! current CDB key
190 Bool_t fUseVertexFromCDB; // Flag to use Vertex from CDB
191 Bool_t fUseMagFieldFromGRP; // Use magnetic field settings from GRP
192 TString fGRPWriteLocation; // Location to write the GRP entry from simulation
5b188f2f 193
194 //QA stuff
a1b90a73 195 static const Int_t fgkNDetectors = 15 ; // number of detectors
196 static const char * fgkDetectorName[fgkNDetectors] ; // names of detectors
e3b20d9a 197 TString fQADetectors ; // list of detectors to be QA'ed
198 TString fQATasks ; // list of QA tasks to be performed
04236e67 199 Bool_t fRunQA ; // Runs the QA at the end of simulation
80636887 200 AliRecoParam::EventSpecie_t fEventSpecie ; // type of event (see AliRecoParam::EventSpecie_t)
75373542 201 Bool_t fWriteQAExpertData ; //! decides wheter or not to write experts QA data; true by default
5b188f2f 202
d97f1dbe 203 TString fGeometryFile; // Geometry file
204
cae21299 205 //HLT
c4affb19 206 TString fRunHLT; //! HLT options, HLT is disabled if empty, default='default'
207 AliHLTSimulation* fpHLT; //! The instance of HLT simulation
cae21299 208
fc7e1b1c 209 Bool_t fWriteGRPEntry; // Write or not GRP entry corresponding to the settings in Config.C
210
d97f1dbe 211 ClassDef(AliSimulation, 11) // class for running generation, simulation and digitization
85a5290f 212};
213
214#endif