forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_sim_emcal.C
More file actions
134 lines (104 loc) · 3.59 KB
/
Copy pathrun_sim_emcal.C
File metadata and controls
134 lines (104 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include <TSystem.h>
#include <TMath.h>
#include <TString.h>
#include <TStopwatch.h>
#include "FairRunSim.h"
#include "FairRuntimeDb.h"
#include "FairPrimaryGenerator.h"
#include "FairBoxGenerator.h"
#include "FairParRootFileIo.h"
#include "TGeoManager.h"
#include "DetectorsPassive/Cave.h"
#include "Field/MagneticField.h"
#include "EMCALSimulation/Detector.h"
#endif
extern TSystem *gSystem;
double radii2Turbo(double rMin, double rMid, double rMax, double sensW)
{
// compute turbo angle from radii and sensor width
return TMath::ASin((rMax * rMax - rMin * rMin) / (2 * rMid * sensW)) * TMath::RadToDeg();
}
void run_sim_emcal(Int_t nEvents = 1, TString mcEngine = "TGeant3")
{
FairLogger::GetLogger()->SetLogScreenLevel("DEBUG2");
TString dir = getenv("VMCWORKDIR");
TString geom_dir = dir + "/Detectors/Geometry/";
gSystem->Setenv("GEOMPATH",geom_dir.Data());
TString tut_configdir = dir + "/Detectors/gconfig";
gSystem->Setenv("CONFIG_DIR",tut_configdir.Data());
// Output file name
char fileout[100];
sprintf(fileout, "AliceO2_%s.mc_%i_event.root", mcEngine.Data(), nEvents);
TString outFile = fileout;
// Parameter file name
char filepar[100];
sprintf(filepar, "AliceO2_%s.params_%i.root", mcEngine.Data(), nEvents);
TString parFile = filepar;
// In general, the following parts need not be touched
// Debug option
gDebug = 0;
// Timer
TStopwatch timer;
timer.Start();
// CDB manager
// o2::ccdb::Manager *cdbManager = o2::ccdb::Manager::Instance();
// cdbManager->setDefaultStorage("local://$ALICEO2/tpc/dirty/o2cdb");
// cdbManager->setRun(0);
// Create simulation run
FairRunSim* run = new FairRunSim();
run->SetName(mcEngine); // Transport engine
run->SetOutputFile(outFile); // Output file
FairRuntimeDb* rtdb = run->GetRuntimeDb();
// Create media
run->SetMaterials("media.geo"); // Materials
// Create geometry
o2::passive::Cave* cave = new o2::passive::Cave("CAVE");
cave->SetGeometryFileName("cave.geo");
run->AddModule(cave);
/*FairConstField field;
field.SetField(0., 0., 5.); //in kG
field.SetFieldRegion(-5000.,5000.,-5000.,5000.,-5000.,5000.); //in c
*/
o2::field::MagneticField field("field","field +5kG");
run->SetField(&field);
o2::emcal::Detector* emcal = new o2::emcal::Detector(kTRUE);
run->AddModule(emcal);
// Create PrimaryGenerator
FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
FairBoxGenerator* boxGen = new FairBoxGenerator(11, 100); // electrons
//boxGen->SetThetaRange(0.0, 90.0);
boxGen->SetEtaRange(-0.9,0.9);
boxGen->SetPtRange(5, 5.01);
boxGen->SetPhiRange(0., 360.);
boxGen->SetDebug(kFALSE);
primGen->AddGenerator(boxGen);
run->SetGenerator(primGen);
run->SetStoreTraj(kTRUE);
// store track trajectories
//run->SetStoreTraj(kTRUE);
// Initialize simulation run
run->Init();
// Runtime database
Bool_t kParameterMerged = kTRUE;
FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
parOut->open(parFile.Data());
rtdb->setOutput(parOut);
rtdb->saveOutput();
rtdb->print();
// Start run
run->Run(nEvents);
delete run;
// Finish
timer.Stop();
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
// Write geometry
gGeoManager->Export("geometry.root", "geometry");
cout << "Output file is " << outFile << endl;
cout << "Parameter file is " << parFile << endl;
cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl;
cout << endl << endl;
cout << "Macro finished succesfully." << endl;
cout << endl << endl;
}