forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_sim_mft.C
More file actions
116 lines (86 loc) · 2.96 KB
/
run_sim_mft.C
File metadata and controls
116 lines (86 loc) · 2.96 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
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include <TSystem.h>
#include <TMath.h>
#include <TString.h>
#include <TStopwatch.h>
#include <TRandom.h>
#include "FairRunSim.h"
#include "FairRuntimeDb.h"
#include "FairPrimaryGenerator.h"
#include "FairBoxGenerator.h"
#include "FairParRootFileIo.h"
#include "DetectorsPassive/Cave.h"
#include "Field/MagneticField.h"
#include "MFTBase/GeometryTGeo.h"
#include "MFTSimulation/Detector.h"
#endif
extern TSystem *gSystem;
void run_sim_mft(Int_t nEvents = 1, Int_t nMuons = 100, TString mcEngine = "TGeant3")
{
printf("Run simulations: %d ev %d mu %s \n",nEvents,nMuons,mcEngine.Data());
//return;
gRandom->SetSeed(0);
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_%iev_%imu.root", mcEngine.Data(), nEvents, nMuons);
TString outFile = fileout;
// Parameter file name
char filepar[100];
sprintf(filepar, "AliceO2_%s.params_%iev_%imu.root", mcEngine.Data(), nEvents, nMuons);
TString parFile = filepar;
// In general, the following parts need not be touched
// Debug option
gDebug = 0;
// Timer
TStopwatch timer;
timer.Start();
// 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);
o2::field::MagneticField field("field","field +5kG");
run->SetField(&field);
o2::MFT::Detector* mft = new o2::MFT::Detector();
run->AddModule(mft);
// Create PrimaryGenerator
FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
FairBoxGenerator* boxGen = new FairBoxGenerator(13, nMuons);
//boxGen->SetXYZ(0.,0.,0.);
boxGen->SetThetaRange(170.0, 177.0);
boxGen->SetPRange(4., 20.);
boxGen->SetPhiRange(0., 360.);
boxGen->SetDebug(kTRUE);
primGen->AddGenerator(boxGen);
run->SetGenerator(primGen);
run->Init();
// Runtime database
Bool_t kParameterMerged = kTRUE;
FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
parOut->open(parFile.Data());
rtdb->setOutput(parOut);
rtdb->saveOutput();
rtdb->print();
run->Run(nEvents);
run->CreateGeometryFile("geofile_mft.root");
// Finish
timer.Stop();
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
cout << endl << endl;
cout << "Macro finished succesfully." << endl;
cout << "Output file is " << outFile << endl;
cout << "Parameter file is " << parFile << endl;
cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl;
}