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 */
6 /* $Id: AliSimulation.h 63170 2013-06-24 14:20:10Z morsch $ */
9 // class for running generation, simulation and digitization
10 // Hits, sdigits and digits are created for all detectors by typing:
17 #include <TObjArray.h>
19 #include "AliQAManager.h"
25 class AliLegoGenerator;
28 class AliHLTSimulation;
30 class AliSimulation: public TNamed {
32 AliSimulation(const char* configFileName = "Config.C",
33 const char* name = "AliSimulation",
34 const char* title = "generation, simulation and digitization");
35 virtual ~AliSimulation();
37 static AliSimulation *Instance() {if(!fgInstance) fgInstance=new AliSimulation(); return fgInstance;}
39 void SetNumberOfEvents(Int_t nEvents);
40 void SetConfigFile(const char* fileName);
41 void SetGAliceFile(const char* fileName);
42 void SetEventsPerFile(const char* detector, const char* type,
45 void SetRunGeneratorOnly(Bool_t val) {fRunGeneratorOnly = val;};
46 void SetRunGeneration(Bool_t run) {fRunGeneration = run;};
47 void SetRunSimulation(Bool_t run) {fRunSimulation = run;};
48 void SetLoadAlignFromCDB(Bool_t load) {fLoadAlignFromCDB = load;};
49 void SetLoadAlignData(const char* detectors)
50 {fLoadAlObjsListOfDets = detectors;};
51 void SetMakeSDigits(const char* detectors)
52 {fMakeSDigits = detectors;};
53 void MergeWith(const char* fileName, Int_t nSignalPerBkgrd = 0);
54 void EmbedInto(const char* fileName, Int_t nSignalPerBkgrd = 0);
55 void SetUseBkgrdVertex(Bool_t useBkgrdVertex)
56 {fUseBkgrdVertex = useBkgrdVertex;};
57 void SetRegionOfInterest(Bool_t flag) {fRegionOfInterest = flag;};
58 void SetMakeDigits(const char* detectors)
59 {fMakeDigits = detectors;};
60 void SetMakeDigitsFromHits(const char* detectors)
61 {fMakeDigitsFromHits = detectors;};
62 void SetWriteRawData(const char* detectors,
63 const char* fileName = NULL,
64 Bool_t deleteIntermediateFiles = kFALSE)
65 {fWriteRawData = detectors; fRawDataFileName = fileName;
66 fDeleteIntermediateFiles = deleteIntermediateFiles;};
67 void SetWriteSelRawData(Bool_t sel = kTRUE)
68 {fWriteSelRawData = sel;}
69 void SetTriggerConfig(TString conf) {fTriggerConfig=conf;}
70 const Char_t* GetTriggerConfig() const {return fTriggerConfig.Data();}
71 void SetAlignObjArray(TObjArray *array)
72 {fAlignObjArray = array;
73 fLoadAlignFromCDB = kFALSE;}
74 void SetUseMonitoring(Bool_t flag=kTRUE) {fUseMonitoring = flag;}
76 Bool_t MisalignGeometry(AliRunLoader *runLoader = NULL);
78 void SetRunNumber(Int_t run);
79 void SetSeed(Int_t seed);
81 void ProcessEnvironmentVars();
83 // CDB storage activation
84 void SetDefaultStorage(const char* uri);
85 void SetSpecificStorage(const char* calibType, const char* uri);
86 void SetCDBSnapshotMode(const char* snapshotFileName) {AliCDBManager::Instance()->SetSnapshotMode(snapshotFileName);}
88 virtual Bool_t Run(Int_t nEvents = 0);
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);
93 virtual Bool_t RunSimulation(Int_t nEvents = 0);
94 virtual Bool_t RunGeneratorOnly();
95 virtual Bool_t RunSDigitization(const char* detectors = "ALL");
96 virtual Bool_t RunTrigger(const char* descriptors ="", const char* detectors = "ALL");
97 virtual Bool_t WriteTriggerRawData();
98 virtual Bool_t RunDigitization(const char* detectors = "ALL",
99 const char* excludeDetectors = "");
100 virtual Bool_t RunHitsDigitization(const char* detectors = "ALL");
101 virtual Bool_t WriteRawData(const char* detectors = "ALL",
102 const char* fileName = NULL,
103 Bool_t deleteIntermediateFiles = kFALSE,
104 Bool_t selrawdata = kFALSE);
105 virtual Bool_t WriteRawFiles(const char* detectors = "ALL");
106 virtual Bool_t ConvertRawFilesToDate(const char* dateFileName = "raw.date",
107 const char* rootFileName = "");
108 virtual Bool_t ConvertDateToRoot(const char* dateFileName = "raw.date",
109 const char* rootFileName = "raw.root");
110 virtual Int_t ConvertRaw2SDigits(const char* rawDirectory, const char* esdFile = "", Int_t N=-1, Int_t nSkip=0);
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();}
119 void SetRunHLT(const char* options) {fRunHLT=options;}
120 virtual Bool_t CreateHLT();
121 virtual Bool_t RunHLT();
122 virtual Bool_t IsLegoRun() const {return (fLego!=0);}
123 AliLego* Lego() const {return fLego;}
124 virtual void FinishRun();
126 void StoreUsedCDBMaps() const;
129 Int_t GetDetIndex(const char * detector);
130 void SetQACycles(AliQAv1::DETECTORINDEX_t det, const Int_t cycles) { AliQAManager::QAManager()->SetCycleLength(det, cycles) ; }
132 Bool_t SetRunQA(TString detAndAction="ALL:ALL") ;
133 void SetQAWriteExpert(AliQAv1::DETECTORINDEX_t det) { AliQAManager::QAManager()->SetWriteExpert(det) ; }
134 void SetQARefDefaultStorage(const char* uri);
136 void SetEventSpecie(AliRecoParam::EventSpecie_t es) { fEventSpecie = es ; }
137 void SetWriteQAExpert() { fWriteQAExpertData = kTRUE ; }
139 void SetWriteGRPEntry(Bool_t flag = kTRUE) { fWriteGRPEntry = flag; }
140 void WriteGRPEntry();
141 void UseVertexFromCDB() {fUseVertexFromCDB = kTRUE;}
142 void UseMagFieldFromGRP() {fUseMagFieldFromGRP = kTRUE;}
143 void SetGRPWriteLocation(char* loc) {fGRPWriteLocation = loc;}
145 void UseTimeStampFromCDB() {fUseTimeStampFromCDB = kTRUE;}
146 time_t GenerateTimeStamp() const;
150 AliSimulation(const AliSimulation&); // Not implemented
151 AliSimulation& operator = (const AliSimulation&); // Not implemented
154 void InitRunNumber();
156 Bool_t SetRunNumberFromData();
157 AliRunLoader* LoadRun(const char* mode = "UPDATE") const;
158 Int_t GetNSignalPerBkgrd(Int_t nEvents = 0) const;
159 Bool_t IsSelected(TString detName, TString& detectors) const;
161 static AliSimulation *fgInstance; // Static pointer to object
163 Bool_t fRunGeneratorOnly; // run code for a generator only production
164 Bool_t fRunGeneration; // generate prim. particles or not
165 Bool_t fRunSimulation; // simulate detectors (hits) or not
166 Bool_t fLoadAlignFromCDB; // Load alignment data from CDB and apply it to geometry or not
167 TString fLoadAlObjsListOfDets; // Load alignment data from CDB for these detectors
168 TString fMakeSDigits; // create sdigits for these detectors
169 TString fMakeDigits; // create digits for these detectors
170 TString fTriggerConfig; // run trigger for these descriptors
171 TString fMakeDigitsFromHits; // create digits from hits for these detectors
172 TString fWriteRawData; // write raw data for these detectors
173 TString fRawDataFileName; // file name for the raw data file
174 Bool_t fDeleteIntermediateFiles; // delete intermediate raw data files
175 Bool_t fWriteSelRawData; // write detectors raw data in a separate file accoring to the trigger cluster
176 Bool_t fStopOnError; // stop or continue on errors
177 Bool_t fUseMonitoring; // monitor simulation timing per volume
179 Int_t fNEvents; // number of events
180 TString fConfigFileName; // name of the config file
181 TString fGAliceFileName; // name of the galice file
182 TObjArray fEventsPerFile; // number of events per file for given detectors and data types
184 TObjArray* fBkgrdFileNames; // names of background files for merging
185 TObjArray* fAlignObjArray; // array with the alignment objects to be applied to the geometry
186 Bool_t fUseBkgrdVertex; // use vertex from background in case of merging
187 Bool_t fRegionOfInterest; // digitization in region of interest
189 TString fCDBUri; //! Uri of the default CDB storage
190 TString fQARefUri; //! Uri of the default QA reference storage
191 TObjArray fSpecCDBUri; //! Array with detector specific CDB storages
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
198 Bool_t fEmbeddingFlag; // Flag for embedding
199 AliLego *fLego; //! Pointer to aliLego object if it exists
201 ULong64_t fKey; //! current CDB key
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
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
211 static const Int_t fgkNDetectors = 18 ; // number of detectors +FIT // alla
212 static const char * fgkDetectorName[fgkNDetectors] ; // names of detectors
213 TString fQADetectors ; // list of detectors to be QA'ed
214 TString fQATasks ; // list of QA tasks to be performed
215 Bool_t fRunQA ; // Runs the QA at the end of simulation
216 AliRecoParam::EventSpecie_t fEventSpecie ; // type of event (see AliRecoParam::EventSpecie_t)
217 Bool_t fWriteQAExpertData ; //! decides wheter or not to write experts QA data; true by default
219 TString fGeometryFile; // Geometry file
222 TString fRunHLT; //! HLT options, HLT is disabled if empty, default='default'
223 AliHLTSimulation* fpHLT; //! The instance of HLT simulation
225 Bool_t fWriteGRPEntry; // Write or not GRP entry corresponding to the settings in Config.C
227 ClassDef(AliSimulation, 13) // class for running generation, simulation and digitization