AliRoot Core  3dc7879 (3dc7879)
AliSimulation.h
Go to the documentation of this file.
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: AliSimulation.h 63170 2013-06-24 14:20:10Z morsch $ */
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 "AliQAv1.h"
19 #include "AliQAManager.h"
20 #include <time.h>
21 #include <algorithm>
22 
23 class AliCDBId;
24 class AliCDBParam;
25 class AliRunLoader;
26 class AliLegoGenerator;
27 class AliLego;
28 class AliMagF;
29 class AliHLTSimulation;
30 
31 class AliSimulation: public TNamed {
32 public:
33  AliSimulation(const char* configFileName = "Config.C",
34  const char* name = "AliSimulation",
35  const char* title = "generation, simulation and digitization");
36  virtual ~AliSimulation();
37 
39 
40  void SetNumberOfEvents(Int_t nEvents);
41  void SetConfigFile(const char* fileName);
42  void SetGAliceFile(const char* fileName);
43  void SetEventsPerFile(const char* detector, const char* type,
44  Int_t nEvents);
45 
46  void SetRunGeneratorOnly(Bool_t val) {fRunGeneratorOnly = val;};
47  void SetRunGeneration(Bool_t run) {fRunGeneration = run;};
48  void SetRunSimulation(Bool_t run) {fRunSimulation = run;};
49  void SetLoadAlignFromCDB(Bool_t load) {fLoadAlignFromCDB = load;};
50  void SetLoadAlignData(const char* detectors)
51  {fLoadAlObjsListOfDets = detectors;};
52  void SetMakeSDigits(const char* detectors)
53  {fMakeSDigits = detectors;};
54  void MergeWith(const char* fileName, Int_t nSignalPerBkgrd = 0);
55  void EmbedInto(const char* fileName, Int_t nSignalPerBkgrd = 0);
56 
57  Bool_t GetEmbeddingFlag() const {return fEmbeddingFlag;}
58 
59  void SetUseBkgrdVertex(Bool_t useBkgrdVertex)
60  {fUseBkgrdVertex = useBkgrdVertex;};
61  void SetRegionOfInterest(Bool_t flag) {fRegionOfInterest = flag;};
62  void SetMakeDigits(const char* detectors)
63  {fMakeDigits = detectors;};
64  void SetMakeDigitsFromHits(const char* detectors)
65  {fMakeDigitsFromHits = detectors;};
66  void SetWriteRawData(const char* detectors,
67  const char* fileName = NULL,
68  Bool_t deleteIntermediateFiles = kFALSE)
69  {fWriteRawData = detectors; fRawDataFileName = fileName;
70  fDeleteIntermediateFiles = deleteIntermediateFiles;};
71  void SetWriteSelRawData(Bool_t sel = kTRUE)
72  {fWriteSelRawData = sel;}
73  void SetTriggerConfig(TString conf) {fTriggerConfig=conf;}
74  const Char_t* GetTriggerConfig() const {return fTriggerConfig.Data();}
77  fLoadAlignFromCDB = kFALSE;}
78  void SetUseMonitoring(Bool_t flag=kTRUE) {fUseMonitoring = flag;}
79 
80  Bool_t MisalignGeometry(AliRunLoader *runLoader = NULL);
81 
82  void SetRunNumber(Int_t run);
83  void SetSeed(Int_t seed);
84 
86 
87  // CDB storage activation
88  void SetDefaultStorage(const char* uri);
89  void SetSpecificStorage(const char* calibType, const char* uri);
90  void SetCDBSnapshotMode(const char* snapshotFileName) {AliCDBManager::Instance()->SetSnapshotMode(snapshotFileName);}
91 
92  virtual Bool_t Run(Int_t nEvents = 0);
93  virtual Bool_t RunLego(const char *setup="Config.C",Int_t nc1=60,Float_t c1min=2,Float_t c1max=178,
94  Int_t nc2=60,Float_t c2min=0,Float_t c2max=360,Float_t rmin=0,
95  Float_t rmax=430,Float_t zmax=10000, AliLegoGenerator* gener=NULL, Int_t nev = -1);
96 
97  virtual Bool_t RunSimulation(Int_t nEvents = 0);
98  virtual Bool_t RunGeneratorOnly();
99  virtual Bool_t RunSDigitization(const char* detectors = "ALL");
100  virtual Bool_t RunTrigger(const char* descriptors ="", const char* detectors = "ALL");
101  virtual Bool_t WriteTriggerRawData();
102  virtual Bool_t RunDigitization(const char* detectors = "ALL",
103  const char* excludeDetectors = "");
104  virtual Bool_t RunHitsDigitization(const char* detectors = "ALL");
105  virtual Bool_t WriteRawData(const char* detectors = "ALL",
106  const char* fileName = NULL,
107  Bool_t deleteIntermediateFiles = kFALSE,
108  Bool_t selrawdata = kFALSE);
109  virtual Bool_t WriteRawFiles(const char* detectors = "ALL");
110  virtual Bool_t ConvertRawFilesToDate(const char* dateFileName = "raw.date",
111  const char* rootFileName = "");
112  virtual Bool_t ConvertDateToRoot(const char* dateFileName = "raw.date",
113  const char* rootFileName = "raw.root");
114  virtual Int_t ConvertRaw2SDigits(const char* rawDirectory, const char* esdFile = "", Int_t N=-1, Int_t nSkip=0);
115 
116  // Sets the name of the file from which the geometry is loaded
117  virtual void SetGeometryFile(const Char_t* filename) {fGeometryFile=filename;}
118  virtual const Char_t* GetGeometryFile() const {return fGeometryFile.Data();}
119  virtual Bool_t IsGeometryFromFile() const {return !fGeometryFile.IsNull();}
120 
122 
123  // HLT
124  void SetRunHLT(const char* options) {fRunHLT=options;}
125  virtual Bool_t CreateHLT();
126  virtual Bool_t RunHLT();
127  virtual Bool_t IsLegoRun() const {return (fLego!=0);}
128  AliLego* Lego() const {return fLego;}
129  virtual void FinishRun();
130  //
131  void StoreUsedCDBMapsAndEmbPaths() const;
132 
133  //Quality Assurance
134  Int_t GetDetIndex(const char * detector);
135  void SetQACycles(AliQAv1::DETECTORINDEX_t det, const Int_t cycles) { AliQAManager::QAManager()->SetCycleLength(det, cycles) ; }
136  Bool_t RunQA() ;
137  Bool_t SetRunQA(TString detAndAction="ALL:ALL") ;
139  void SetQARefDefaultStorage(const char* uri);
140  void InitQA();
143 
144  void SetWriteGRPEntry(Bool_t flag = kTRUE) { fWriteGRPEntry = flag; }
145  void WriteGRPEntry();
148  void SetGRPWriteLocation(char* loc) {fGRPWriteLocation = loc;}
149 
151  void UseTimeStampFromCDB(Double_t decayTimeHours=-1);
152  time_t GenerateTimeStamp() const;
153  //
155  void SetUseDetectorsFromGRP(Bool_t v=kTRUE) {fUseDetectorsFromGRP = v;}
156  //
157 
158  private:
159 
160  AliSimulation(const AliSimulation&); // Not implemented
161  AliSimulation& operator = (const AliSimulation&); // Not implemented
162 
163  void InitCDB();
164  void InitRunNumber();
165  void SetCDBLock();
166  Bool_t SetRunNumberFromData();
167  AliRunLoader* LoadRun(const char* mode = "UPDATE") const;
168  Int_t GetNSignalPerBkgrd(Int_t nEvents = 0) const;
169  Bool_t IsSelected(TString detName, TString& detectors) const;
170 
171  static AliSimulation *fgInstance; // Static pointer to object
172 
173  Bool_t fRunGeneratorOnly; // run code for a generator only production
174  Bool_t fRunGeneration; // generate prim. particles or not
175  Bool_t fRunSimulation; // simulate detectors (hits) or not
176  Bool_t fLoadAlignFromCDB; // Load alignment data from CDB and apply it to geometry or not
177  TString fLoadAlObjsListOfDets; // Load alignment data from CDB for these detectors
178  TString fMakeSDigits; // create sdigits for these detectors
179  TString fMakeDigits; // create digits for these detectors
180  TString fTriggerConfig; // run trigger for these descriptors
181  TString fMakeDigitsFromHits; // create digits from hits for these detectors
182  TString fWriteRawData; // write raw data for these detectors
183  TString fRawDataFileName; // file name for the raw data file
184  Bool_t fDeleteIntermediateFiles; // delete intermediate raw data files
185  Bool_t fWriteSelRawData; // write detectors raw data in a separate file accoring to the trigger cluster
186  Bool_t fStopOnError; // stop or continue on errors
187  Bool_t fUseMonitoring; // monitor simulation timing per volume
188 
189  Int_t fNEvents; // number of events
190  TString fConfigFileName; // name of the config file
191  TString fGAliceFileName; // name of the galice file
192  TObjArray fEventsPerFile; // number of events per file for given detectors and data types
193 
194  TObjArray* fBkgrdFileNames; // names of background files for merging
195  TObjArray* fAlignObjArray; // array with the alignment objects to be applied to the geometry
196  Bool_t fUseBkgrdVertex; // use vertex from background in case of merging
197  Bool_t fRegionOfInterest; // digitization in region of interest
198 
199  TString fCDBUri;
200  TString fQARefUri;
202  Int_t fRun;
203  Int_t fSeed;
204  Bool_t fInitCDBCalled;
207 
208  Bool_t fEmbeddingFlag; // Flag for embedding
210  // OCDB
211  ULong64_t fKey;
212  Bool_t fUseVertexFromCDB; // Flag to use Vertex from CDB
213  Bool_t fUseMagFieldFromGRP; // Use magnetic field settings from GRP
214  TString fGRPWriteLocation; // Location to write the GRP entry from simulation
215 
216  Bool_t fUseDetectorsFromGRP; // do not simulate detectors absent in the GRP
217 
218  Int_t fUseTimeStampFromCDB;// Flag to generate event time-stamps: see GenerateTimeStamp()
219  time_t fTimeStart; // SOR time-stamp
220  time_t fTimeEnd; // EOR time-stamp
221  Float_t fLumiDecayH; // luminosity decay time in hours
222  std::vector<time_t> fOrderedTimeStamps;
223 
224  //QA stuff
225  static const Int_t fgkNDetectors = 18 ; // number of detectors +FIT // alla
226  static const char * fgkDetectorName[fgkNDetectors] ; // names of detectors
227  TString fQADetectors ; // list of detectors to be QA'ed
228  TString fQATasks ; // list of QA tasks to be performed
229  Bool_t fRunQA ; // Runs the QA at the end of simulation
230  AliRecoParam::EventSpecie_t fEventSpecie ; // type of event (see AliRecoParam::EventSpecie_t)
232 
233  TString fGeometryFile; // Geometry file
234 
235  //HLT
236  TString fRunHLT;
238 
239  Bool_t fWriteGRPEntry; // Write or not GRP entry corresponding to the settings in Config.C
240 
241  static const Char_t *fgkRunHLTAuto; // flag for automatic HLT mode detection
242  static const Char_t *fgkHLTDefConf; // default configuration to run HLT
243  ClassDef(AliSimulation, 15) // class for running generation, simulation and digitization
244 };
245 
246 #endif
void SetMakeDigitsFromHits(const char *detectors)
Definition: AliSimulation.h:64
Bool_t fEmbeddingFlag
flag to check if run number is already loaded from run loader
void UseTimeStampFromCDB(Double_t decayTimeHours=-1)
virtual Bool_t WriteRawFiles(const char *detectors="ALL")
AliRunLoader * LoadRun(const char *mode="UPDATE") const
static const Char_t * fgkRunHLTAuto
void SetRunGeneratorOnly(Bool_t val)
Definition: AliSimulation.h:46
TString fMakeDigitsFromHits
static AliQAManager * QAManager(AliQAv1::MODE_t=AliQAv1::kNULLMODE, TMap *entryCache=NULL, Int_t run=-1)
virtual ~AliSimulation()
void SetNumberOfEvents(Int_t nEvents)
Bool_t GetEmbeddingFlag() const
Definition: AliSimulation.h:57
Bool_t MisalignGeometry(AliRunLoader *runLoader=NULL)
void SetWriteQAExpert()
TString fQATasks
Int_t fUseTimeStampFromCDB
void SetUseMonitoring(Bool_t flag=kTRUE)
Definition: AliSimulation.h:78
#define TObjArray
void SetAlignObjArray(TObjArray *array)
Definition: AliSimulation.h:75
void SetSpecificStorage(const char *calibType, const char *uri)
Int_t GetUseTimeStampFromCDB() const
Int_t GetNSignalPerBkgrd(Int_t nEvents=0) const
void SetRunHLT(const char *options)
void SetGAliceFile(const char *fileName)
void SetRunNumber(Int_t run)
TString fMakeSDigits
TString fConfigFileName
virtual Bool_t ConvertDateToRoot(const char *dateFileName="raw.date", const char *rootFileName="raw.root")
TString fMakeDigits
Bool_t fInitRunNumberCalled
flag to check if CDB storages are already initialized
virtual Bool_t Run(Int_t nEvents=0)
ULong64_t fKey
Pointer to aliLego object if it exists.
TString fQARefUri
Uri of the default CDB storage.
void SetWriteExpert(const AliQAv1::DETECTORINDEX_t det)
Definition: AliQAManager.h:73
TString fLoadAlObjsListOfDets
void SetDefaultStorage(const char *uri)
static const Int_t fgkNDetectors
optional ordered time stamps
void SetRunGeneration(Bool_t run)
Definition: AliSimulation.h:47
TString fGRPWriteLocation
Bool_t SetRunNumberFromData()
TString fQADetectors
Bool_t GetUseDetectorsFromGRP() const
void SetRegionOfInterest(Bool_t flag)
Definition: AliSimulation.h:61
AliHLTSimulation * fpHLT
HLT options, HLT is disabled if empty, default=&#39;default&#39;.
virtual Bool_t RunGeneratorOnly()
TString fWriteRawData
Bool_t IsSelected(TString detName, TString &detectors) const
TObjArray * fAlignObjArray
TString fRawDataFileName
const Char_t * GetTriggerConfig() const
Definition: AliSimulation.h:74
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
void SetWriteGRPEntry(Bool_t flag=kTRUE)
TObjArray * fBkgrdFileNames
static AliSimulation * fgInstance
Bool_t fUseBkgrdVertex
void SetQAWriteExpert(AliQAv1::DETECTORINDEX_t det)
TObjArray * array
Definition: AnalyzeLaser.C:12
virtual void FinishRun()
void SetSeed(Int_t seed)
void SetUseBkgrdVertex(Bool_t useBkgrdVertex)
Definition: AliSimulation.h:59
Bool_t fRunGeneratorOnly
Bool_t fInitCDBCalled
Seed for random number generator.
time_t GenerateTimeStamp() const
virtual const Char_t * GetGeometryFile() const
void SetQARefDefaultStorage(const char *uri)
virtual Bool_t RunSDigitization(const char *detectors="ALL")
Int_t fRun
Array with detector specific CDB storages.
virtual Bool_t RunLego(const char *setup="Config.C", Int_t nc1=60, Float_t c1min=2, Float_t c1max=178, Int_t nc2=60, Float_t c2min=0, Float_t c2max=360, Float_t rmin=0, Float_t rmax=430, Float_t zmax=10000, AliLegoGenerator *gener=NULL, Int_t nev=-1)
Bool_t fRegionOfInterest
AliLego * Lego() const
void SetTriggerConfig(TString conf)
Definition: AliSimulation.h:73
void SetMakeDigits(const char *detectors)
Definition: AliSimulation.h:62
Bool_t fRunSimulation
void SetEventSpecie(AliRecoParam::EventSpecie_t es)
virtual Bool_t ConvertRawFilesToDate(const char *dateFileName="raw.date", const char *rootFileName="")
void SetMakeSDigits(const char *detectors)
Definition: AliSimulation.h:52
Bool_t fWriteQAExpertData
static AliSimulation * Instance()
Definition: AliSimulation.h:38
void SetGRPWriteLocation(char *loc)
void SetConfigFile(const char *fileName)
void DeactivateDetectorsAbsentInGRP(TObjArray *detArr)
Bool_t fUseVertexFromCDB
current CDB key
TString fGeometryFile
decides wheter or not to write experts QA data; true by default
Bool_t fUseDetectorsFromGRP
virtual Bool_t WriteRawData(const char *detectors="ALL", const char *fileName=NULL, Bool_t deleteIntermediateFiles=kFALSE, Bool_t selrawdata=kFALSE)
Bool_t SetRunQA(TString detAndAction="ALL:ALL")
virtual Bool_t RunHLT()
void SetWriteSelRawData(Bool_t sel=kTRUE)
Definition: AliSimulation.h:71
static UInt_t seed
Definition: pdc06_config.C:131
void UseMagFieldFromGRP()
virtual Bool_t RunDigitization(const char *detectors="ALL", const char *excludeDetectors="")
Int_t GetDetIndex(const char *detector)
TString fTriggerConfig
static const char * fgkDetectorName[fgkNDetectors]
Bool_t fRunGeneration
Bool_t fUseMonitoring
void SetQACycles(AliQAv1::DETECTORINDEX_t det, const Int_t cycles)
TObjArray fSpecCDBUri
Uri of the default QA reference storage.
std::vector< time_t > fOrderedTimeStamps
virtual Bool_t RunSimulation(Int_t nEvents=0)
void SetLoadAlignFromCDB(Bool_t load)
Definition: AliSimulation.h:49
AliSimulation(const char *configFileName="Config.C", const char *name="AliSimulation", const char *title="generation, simulation and digitization")
virtual Bool_t RunHitsDigitization(const char *detectors="ALL")
void SetLoadAlignData(const char *detectors)
Definition: AliSimulation.h:50
DETECTORINDEX_t
Definition: AliQAv1.h:23
Float_t fLumiDecayH
AliSimulation & operator=(const AliSimulation &)
virtual Bool_t RunTrigger(const char *descriptors="", const char *detectors="ALL")
void SetEventsPerFile(const char *detector, const char *type, Int_t nEvents)
void ProcessEnvironmentVars()
virtual Bool_t IsLegoRun() const
AliLego * fLego
Bool_t fDeleteIntermediateFiles
TObjArray fEventsPerFile
virtual Bool_t CreateHLT()
Bool_t fSetRunNumberFromDataCalled
flag to check if run number is already initialized
Bool_t fStopOnError
virtual void SetGeometryFile(const Char_t *filename)
virtual Int_t ConvertRaw2SDigits(const char *rawDirectory, const char *esdFile="", Int_t N=-1, Int_t nSkip=0)
AliRecoParam::EventSpecie_t fEventSpecie
void SetCDBSnapshotMode(const char *snapshotFileName)
Definition: AliSimulation.h:90
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
void SetRunSimulation(Bool_t run)
Definition: AliSimulation.h:48
Bool_t fLoadAlignFromCDB
void StoreUsedCDBMapsAndEmbPaths() const
Bool_t fWriteGRPEntry
The instance of HLT simulation.
void MergeWith(const char *fileName, Int_t nSignalPerBkgrd=0)
Bool_t SetSnapshotMode(const char *snapshotFileName="OCDB.root")
virtual Bool_t IsGeometryFromFile() const
void SetCycleLength(const AliQAv1::DETECTORINDEX_t det, const Int_t cycle)
Definition: AliQAManager.h:72
void SetUseDetectorsFromGRP(Bool_t v=kTRUE)
Bool_t fUseMagFieldFromGRP
static const Char_t * fgkHLTDefConf
void SetWriteRawData(const char *detectors, const char *fileName=NULL, Bool_t deleteIntermediateFiles=kFALSE)
Definition: AliSimulation.h:66
TString fGAliceFileName
Int_t fSeed
Run number, will be passed to CDB and gAlice!!
Bool_t fWriteSelRawData
void UseVertexFromCDB()
void EmbedInto(const char *fileName, Int_t nSignalPerBkgrd=0)
virtual Bool_t WriteTriggerRawData()