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