Option for kine only simulation added.
[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
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"
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();
cae21299 125
5b188f2f 126 //Quality Assurance
127 Int_t GetDetIndex(const char * detector);
eca4fa66 128 void SetQACycles(AliQAv1::DETECTORINDEX_t det, const Int_t cycles) { AliQAManager::QAManager()->SetCycleLength(det, cycles) ; }
a1b90a73 129 Bool_t RunQA() ;
e3b20d9a 130 Bool_t SetRunQA(TString detAndAction="ALL:ALL") ;
eca4fa66 131 void SetQAWriteExpert(AliQAv1::DETECTORINDEX_t det) { AliQAManager::QAManager()->SetWriteExpert(det) ; }
f1c1204d 132 void SetQARefDefaultStorage(const char* uri);
133 void InitQA();
80636887 134 void SetEventSpecie(AliRecoParam::EventSpecie_t es) { fEventSpecie = es ; }
75373542 135 void SetWriteQAExpert() { fWriteQAExpertData = kTRUE ; }
fc7e1b1c 136
137 void SetWriteGRPEntry(Bool_t flag = kTRUE) { fWriteGRPEntry = flag; }
138 void WriteGRPEntry();
732ee20f 139 void UseVertexFromCDB() {fUseVertexFromCDB = kTRUE;}
140 void UseMagFieldFromGRP() {fUseMagFieldFromGRP = kTRUE;}
141 void SetGRPWriteLocation(char* loc) {fGRPWriteLocation = loc;}
fc7e1b1c 142
475baf89 143 void UseTimeStampFromCDB() {fUseTimeStampFromCDB = kTRUE;}
144 time_t GenerateTimeStamp() const;
145
95601147 146private:
7dd2cbe4 147
148 AliSimulation(const AliSimulation&); // Not implemented
149 AliSimulation& operator = (const AliSimulation&); // Not implemented
150
795e4a22 151 void InitCDB();
152 void InitRunNumber();
153 void SetCDBLock();
154 Bool_t SetRunNumberFromData();
06c7e392 155 AliRunLoader* LoadRun(const char* mode = "UPDATE") const;
05526d44 156 Int_t GetNSignalPerBkgrd(Int_t nEvents = 0) const;
85a5290f 157 Bool_t IsSelected(TString detName, TString& detectors) const;
158
b856a511 159 static AliSimulation *fgInstance; // Static pointer to object
160
35ec1f70 161 Bool_t fRunGeneratorOnly; // run code for a generator only production
85a5290f 162 Bool_t fRunGeneration; // generate prim. particles or not
163 Bool_t fRunSimulation; // simulate detectors (hits) or not
024cf675 164 Bool_t fLoadAlignFromCDB; // Load alignment data from CDB and apply it to geometry or not
25be1e5c 165 TString fLoadAlObjsListOfDets; // Load alignment data from CDB for these detectors
85a5290f 166 TString fMakeSDigits; // create sdigits for these detectors
167 TString fMakeDigits; // create digits for these detectors
28da60d3 168 TString fTriggerConfig; // run trigger for these descriptors
85a5290f 169 TString fMakeDigitsFromHits; // create digits from hits for these detectors
0421c3d1 170 TString fWriteRawData; // write raw data for these detectors
06c7e392 171 TString fRawDataFileName; // file name for the raw data file
172 Bool_t fDeleteIntermediateFiles; // delete intermediate raw data files
67327b72 173 Bool_t fWriteSelRawData; // write detectors raw data in a separate file accoring to the trigger cluster
85a5290f 174 Bool_t fStopOnError; // stop or continue on errors
a5fe2c41 175 Bool_t fUseMonitoring; // monitor simulation timing per volume
85a5290f 176
177 Int_t fNEvents; // number of events
178 TString fConfigFileName; // name of the config file
179 TString fGAliceFileName; // name of the galice file
18b43626 180 TObjArray fEventsPerFile; // number of events per file for given detectors and data types
181
85a5290f 182 TObjArray* fBkgrdFileNames; // names of background files for merging
732ee20f 183 TObjArray* fAlignObjArray; // array with the alignment objects to be applied to the geometry
04bae0a0 184 Bool_t fUseBkgrdVertex; // use vertex from background in case of merging
4df28b43 185 Bool_t fRegionOfInterest; // digitization in region of interest
85a5290f 186
57acd2d2 187 TString fCDBUri; //! Uri of the default CDB storage
732ee20f 188 TString fQARefUri; //! Uri of the default QA reference storage
189 TObjArray fSpecCDBUri; //! Array with detector specific CDB storages
57acd2d2 190 Int_t fRun; //! Run number, will be passed to CDB and gAlice!!
191 Int_t fSeed; //! Seed for random number generator
192 Bool_t fInitCDBCalled; //! flag to check if CDB storages are already initialized
193 Bool_t fInitRunNumberCalled; //! flag to check if run number is already initialized
194 Bool_t fSetRunNumberFromDataCalled; //! flag to check if run number is already loaded from run loader
795e4a22 195
732ee20f 196 Bool_t fEmbeddingFlag; // Flag for embedding
197 AliLego *fLego; //! Pointer to aliLego object if it exists
198 // OCDB
6fc2efbf 199 ULong64_t fKey; //! current CDB key
732ee20f 200 Bool_t fUseVertexFromCDB; // Flag to use Vertex from CDB
201 Bool_t fUseMagFieldFromGRP; // Use magnetic field settings from GRP
202 TString fGRPWriteLocation; // Location to write the GRP entry from simulation
475baf89 203
204 Bool_t fUseTimeStampFromCDB;// Flag to generate event time-stamps according to SOR/EOR from GRP
205 time_t fTimeStart; // SOR time-stamp
206 time_t fTimeEnd; // EOR time-stamp
5b188f2f 207
208 //QA stuff
820b4d9e 209// #ifdef MFT_UPGRADE
210// static const Int_t fgkNDetectors = 16 ; // number of detectors
211// #else
212// static const Int_t fgkNDetectors = 15 ; // number of detectors
213// #endif
214 static const Int_t fgkNDetectors = 16 ; // number of detectors // AU
a1b90a73 215 static const char * fgkDetectorName[fgkNDetectors] ; // names of detectors
e3b20d9a 216 TString fQADetectors ; // list of detectors to be QA'ed
217 TString fQATasks ; // list of QA tasks to be performed
04236e67 218 Bool_t fRunQA ; // Runs the QA at the end of simulation
80636887 219 AliRecoParam::EventSpecie_t fEventSpecie ; // type of event (see AliRecoParam::EventSpecie_t)
75373542 220 Bool_t fWriteQAExpertData ; //! decides wheter or not to write experts QA data; true by default
5b188f2f 221
d97f1dbe 222 TString fGeometryFile; // Geometry file
223
cae21299 224 //HLT
c4affb19 225 TString fRunHLT; //! HLT options, HLT is disabled if empty, default='default'
226 AliHLTSimulation* fpHLT; //! The instance of HLT simulation
cae21299 227
fc7e1b1c 228 Bool_t fWriteGRPEntry; // Write or not GRP entry corresponding to the settings in Config.C
229
6fc2efbf 230 ClassDef(AliSimulation, 13) // class for running generation, simulation and digitization
85a5290f 231};
232
233#endif