BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
run_sim.C
Go to the documentation of this file.
1// --------------------------------------------------------------------------
2//
3// Macro for standard transport simulation using UrQMD input and GEANT3
4// Standard CBM setup with MVD, STS, RICH, TRD, TOF and ECAL
5//
6// V. Friese 22/02/2007
7//
8// --------------------------------------------------------------------------
9#include <TGDMLParse.h>
10
11void run_sim(Int_t nEvents = 2)
12{
13
14 gRandom->SetSeed(1);
15 // ========================================================================
16 // Adjust this part according to your requirements
17
18 // ----- Paths and file names --------------------------------------------
19 // TString inDir = gSystem->Getenv("VMCWORKDIR");
20 TString inDir = "/home/zinchenk/bmon/urqmd/";
21 // TString inFile = inDir + "/AuAu_urqmd_3.3p1_4.0_gev__10000_ev__mbias__seed_0.ftn14";
22 TString inFile = inDir + "auau.ek45gev.0_3fm.10k.0012.f14.gz";
23 // TString inFile = inDir + "CC/cc.ek45gev.0_3fm.10k.0001.f14.gz";
24 // TString inFile = "urqmd_4_mb.f14.gz";
25 TString outDir = "./";
26 TString outFile = outDir + "/mc.root";
27 TString parFile = outDir + "/AuAu_urqmd_3.3p1_4.0_gev__10000_ev__mbias__seed_0_params.root";
28
29 // ----- Geometries -----------------------------------------------------
30 TString caveGeom = "cave.geo";
31 TString targetGeom = "target_au_250mu.geo";
32 // TString pipeGeom = "pipe_Be_kompozit_gap75cm_3.geo";
33 TString pipeGeom = "";
34 // TString magnetGeom = "";
35 TString magnetGeom = "magnet_modified.root";
36 // TString magnetGeom = "magnet_SP41mod_v1245.geo";
37 // TString stsGeom = "vv/gem_bmn_40_VV.geo";
38 // TString stsGeom = "gem_bmn_40_3st.geo";
39 // TString stsGeom = "gems_1st_80.geo";
40 // TString stsGeom = "gems_var_fr.geo";
41 // TString stsGeom = "GEMS_v2_AZ.root";
42 // TString stsGeom = "GEMS_v2_hf.root";
43 // TString stsGeom = "GEMS_v15_AZ.root";
44 TString stsGeom = "GEMS_v17_AZ.root";
45 // TString stsGeom = "GEMS_v17_SI.root";
46 // TString stsGeom = "GEMS_v2.root";
47 // TString stsGeom = "mwpc.geo";
48 // TString stsGeom = "";
49 // TString tofGeom = "vv/ecal.geo";
50 // TString tofGeom = "tof_4_7.geo";
51 TString tofGeom = "";
52
53 // ----- Magnetic field -----------------------------------------------
54 TString fieldMap = "field_sp41v1"; // name of field map
55 Double_t fieldZ = 124.5; // field centre z position
56 // Double_t fieldZ = 165.; // field centre z position
57 // Double_t fieldScale = 0.88; // field scaling factor
58 Double_t fieldScale = 0.44; // field scaling factor
59
60 // In general, the following parts need not be touched
61 // ========================================================================
62
63 // ---- Debug option -------------------------------------------------
64 gDebug = 0;
65 // ------------------------------------------------------------------------
66
67 // ----- Timer --------------------------------------------------------
68 TStopwatch timer;
69 timer.Start();
70 // ------------------------------------------------------------------------
71
72 // ---- Load libraries -------------------------------------------------
73 gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
74 basiclibs();
75 gSystem->Load("libFairTools");
76 gSystem->Load("libGeoBase");
77 gSystem->Load("libParBase");
78 gSystem->Load("libBase");
79 // gSystem->Load("libMCStack");
80 // gSystem->Load("libCbmBase");
81 // gSystem->Load("libCbmData");
82 gSystem->Load("libBmnData");
83 // gSystem->Load("libCbmGenerators");
84 // gSystem->Load("libField");
85 gSystem->Load("libBmnField");
86 gSystem->Load("libGen");
87 gSystem->Load("libPassive");
88 // gSystem->Load("libEcal");
89 // gSystem->Load("libKF");
90 // gSystem->Load("libMvd");
91 gSystem->Load("libSts");
92 // gSystem->Load("libLittrack");
93 // gSystem->Load("libRich");
94 // gSystem->Load("libTrd");
95 gSystem->Load("libTof");
96 // -----------------------------------------------------------------------
97
98 // ----- Create simulation run ----------------------------------------
99 FairRunSim* fRun = new FairRunSim();
100 fRun->SetName("TGeant3"); // Transport engine
101 fRun->SetOutputFile(outFile); // Output file
102 FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
103 // ------------------------------------------------------------------------
104
105 // ----- Create media -------------------------------------------------
106 // fRun->SetMaterials("media_FT_old.geo"); // Materials
107 fRun->SetMaterials("media.geo"); // Materials
108 // ------------------------------------------------------------------------
109
110 // ----- Create detectors and passive volumes -------------------------
111 if (caveGeom != "") {
112 // FairModule* cave = new CbmCave("CAVE");
113 FairModule* cave = new FairCave("CAVE");
114 cave->SetGeometryFileName(caveGeom);
115 fRun->AddModule(cave);
116 }
117
118 if (pipeGeom != "") {
119 // FairModule* pipe = new CbmPipe("PIPE");
120 FairModule* pipe = new FairPipe("PIPE");
121 pipe->SetGeometryFileName(pipeGeom);
122 fRun->AddModule(pipe);
123 }
124
125 if (targetGeom != "") {
126 // FairModule* target = new CbmTarget("Target");
127 FairModule* target = new FairTarget("Target");
128 target->SetGeometryFileName(targetGeom);
129 fRun->AddModule(target);
130 }
131
132 if (magnetGeom != "") {
133 // FairModule* magnet = new CbmMagnet("MAGNET");
134 FairModule* magnet = new FairMagnet("MAGNET");
135 magnet->SetGeometryFileName(magnetGeom);
136 fRun->AddModule(magnet);
137 }
138
139 if (stsGeom != "") {
140 FairDetector* sts = new CbmSts("STS", kTRUE);
141 sts->SetGeometryFileName(stsGeom);
142 fRun->AddModule(sts);
143 // sts->SetVerboseLevel(2);
144 }
145
146 if (tofGeom != "") {
147 FairDetector* tof = new CbmTof("TOF", kTRUE);
148 tof->SetGeometryFileName(tofGeom);
149 fRun->AddModule(tof);
150 }
151
152 /*
153 if ( ecalGeom != "" ) {
154 FairDetector* ecal = new CbmEcal("ECAL", kTRUE, ecalGeom.Data());
155 fRun->AddModule(ecal);
156 }
157 */
158 // ------------------------------------------------------------------------
159
160 // ----- Create magnetic field ----------------------------------------
161 // CbmFieldMap* magField = new CbmFieldMapSym3(fieldMap);
162 // BmnFieldMap* magField = new BmnFieldMapSym3("field_sp41v1_ascii", "A");
163 // BmnFieldMap* magField = new BmnFieldMapSym3("field_sp41v1_ascii_noExtrap.dat");
164 BmnFieldMap* magField = new BmnFieldMapSym3("field_sp41v1_ascii_Extrap.dat");
165 magField->SetPosition(0., 0., fieldZ);
166 magField->SetScale(fieldScale);
167 fRun->SetField(magField);
168 // ------------------------------------------------------------------------
169
170 // Use theexperiment specific MC Event header instead of the default one
171 // This one stores additional information about the reaction plane
172 // CbmMCEventHeader* mcHeader = new CbmMCEventHeader();
173 // fRun->SetMCEventHeader(mcHeader);
174
175 // ----- Create PrimaryGenerator --------------------------------------
176 FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
177 fRun->SetGenerator(primGen);
178 /*
179 // Use the CbmUrqmdGenrator which calculates a reaction plane and
180 // rotate all particles accordingly
181 //CbmUrqmdGenerator* urqmdGen = new CbmUrqmdGenerator(inFile);
182 FairUrqmdGenerator* urqmdGen = new FairUrqmdGenerator(inFile);
183 urqmdGen->SetEventPlane(0. , 360.);
184 */
185 MpdUrqmdGenerator* urqmdGen = new MpdUrqmdGenerator(inFile);
186 primGen->AddGenerator(urqmdGen);
187
188 //*
189 // TString laqGSM = "/home/zinchenk/laqgsm/LAQGSM_AuAu_4_mb_100K_mer.r12";
190 TString laqGSM = "/home/zinchenk/laqgsm/AuAu4_5mb_1.r12";
191 // MpdLAQGSMGenerator* laq = new MpdLAQGSMGenerator(laqGSM, kFALSE, 3);
192 // laq->SkipEvents(20000);
193 // primGen->AddGenerator(laq);
194 //*/
195
196 /*
197 CbmAnaHypYPtGenerator *hypGen = new CbmAnaHypYPtGenerator(3122); // lambda
198 hypGen->SetDistributionPt(0.155); // 4 GeV
199 hypGen->SetDistributionY(1.186,0.645); // BMN
200 //primGen->AddGenerator(hypGen);
201 */
202
203 MpdHypYPtGenerator* hypGen = new MpdHypYPtGenerator(333); // phi0
204 hypGen->SetDistributionPt(0.153); //
205 hypGen->SetDistributionY(1.24, 0.46); // BMN
206 // primGen->AddGenerator(hypGen);
207
208 MpdHypYPtGenerator* hypGen = new MpdHypYPtGenerator(3122); // lambda
209 hypGen->SetDistributionPt(0.180); // 4 GeV
210 hypGen->SetDistributionY(1.22, 0.50); // BMN
211 // primGen->AddGenerator(hypGen);
212
213 MpdHypYPtGenerator* hypGen = new MpdHypYPtGenerator(3312); // Xi-
214 hypGen->SetDistributionPt(0.160); // 4 GeV
215 hypGen->SetDistributionY(1.22, 0.43); // BMN
216 // primGen->AddGenerator(hypGen);
217
218 MpdHypYPtGenerator* hypGen = new MpdHypYPtGenerator(321, 10); // K+
219 hypGen->SetDistributionPt(0.158); // exper.
220 hypGen->SetDistributionY(1.17, 0.7); // BMN
221 // primGen->AddGenerator(hypGen);
222
223 // FairBoxGenerator* boxGen = new FairBoxGenerator(-13, 1); // 13 = muon; 1 = multipl.
224 FairBoxGenerator* boxGen = new FairBoxGenerator(-211, 5); // 13 = muon; 1 = multipl.
225 boxGen->SetPRange(0.1, 7.0); // GeV/c //setPRange vs setPtRange
226 boxGen->SetPhiRange(0, 360); // Azimuth angle range [degree]
227 // boxGen->SetThetaRange(10.0, 30); // Polar angle in lab system range [degree]
228 boxGen->SetThetaRange(0.1, 60); // Polar angle in lab system range [degree]
229 // boxGen->SetEtaRange(-1.3, 1.3); // Eta
230 boxGen->SetXYZ(0., 0., 0.); // mm o cm ??
231 // primGen->AddGenerator(boxGen);
232
233 // FairBoxGenerator* boxGen1 = new FairBoxGenerator(13, 1); // 13 = muon; 1 = multipl.
234 FairBoxGenerator* boxGen1 = new FairBoxGenerator(211, 1); // 13 = muon; 1 = multipl.
235 boxGen1->SetPRange(0.1, 7.0); // GeV/c //setPRange vs setPtRange
236 boxGen1->SetPhiRange(0, 360); // Azimuth angle range [degree]
237 boxGen1->SetThetaRange(0.1, 60); // Polar angle in lab system range [degree]
238 // boxGen1->SetThetaRange(0., 0); // Polar angle in lab system range [degree]
239 // boxGen1->SetEtaRange(-1.3, 1.3); // Eta
240 boxGen1->SetXYZ(0., 0., 0.); // mm o cm ??
241 // primGen->AddGenerator(boxGen1);
242
243 // ------------------------------------------------------------------------
244
245 // -Trajectories Visualization (TGeoManager Only )
246 // Switch this on if you want to visualize tracks in the
247 // eventdisplay.
248 // This is normally switch off, because of the huge files created
249 // when it is switched on.
250 // fRun->SetStoreTraj(kTRUE);
251
252 // ----- Run initialisation -------------------------------------------
253 fRun->Init();
254
255 // Add user decays
256 // gROOT->LoadMacro("./UserDecay.C");
257 // UserDecay();
258
259 // ------------------------------------------------------------------------
260
261 // Set cuts for storing the trajectories.
262 // Switch this on only if trajectories are stored.
263 // Choose this cuts according to your needs, but be aware
264 // that the file size of the output file depends on these cuts
265
266 // FairTrajFilter* trajFilter = FairTrajFilter::Instance();
267 // trajFilter->SetStepSizeCut(0.01); // 1 cm
268 // trajFilter->SetVertexCut(-2000., -2000., 4., 2000., 2000., 100.);
269 // trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV
270 // trajFilter->SetEnergyCut(0., 1.02); // 0 < Etot < 1.04 GeV
271 // trajFilter->SetStorePrimaries(kTRUE);
272 // trajFilter->SetStoreSecondaries(kTRUE);
273
274 // ----- Runtime database ---------------------------------------------
275 // CbmFieldPar* fieldPar = (CbmFieldPar*) rtdb->getContainer("CbmFieldPar");
276 BmnFieldPar* fieldPar = (BmnFieldPar*)rtdb->getContainer("BmnFieldPar");
277 fieldPar->SetParameters(magField);
278 fieldPar->setChanged();
279 fieldPar->setInputVersion(fRun->GetRunId(), 1);
280 Bool_t kParameterMerged = kTRUE;
281 FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
282 // parOut->open(parFile.Data());
283 parOut->open(gFile);
284 rtdb->setOutput(parOut);
285 rtdb->saveOutput();
286 rtdb->print();
287 // ------------------------------------------------------------------------
288
289 // ----- Start run ----------------------------------------------------
290 fRun->Run(nEvents);
291 // ------------------------------------------------------------------------
292 fRun->CreateGeometryFile("data/geofile_full.root");
293
294 // ----- Finish -------------------------------------------------------
295 timer.Stop();
296 Double_t rtime = timer.RealTime();
297 Double_t ctime = timer.CpuTime();
298 cout << endl << endl;
299 cout << "Macro finished succesfully." << endl;
300 cout << "Output file is " << outFile << endl;
301 cout << "Parameter file is " << parFile << endl;
302 cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl;
303 // ------------------------------------------------------------------------
304
305 cout << " Test passed" << endl;
306 cout << " All ok " << endl;
307}
bool Bool_t
int Int_t
Int_t gDebug
double Double_t
constexpr Bool_t kTRUE
#define gFile
#define gROOT
R__EXTERN TRandom * gRandom
R__EXTERN TSystem * gSystem
BmnFieldMapSym3.h.
void SetPosition(Double_t x, Double_t y, Double_t z)
Set the position of the field centre.
void SetScale(Double_t factor)
Set a global field scaling factor.
Definition BmnFieldMap.h:55
void SetParameters(FairField *field)
Set parameters from BmnField.
CbmSts.h.
Definition CbmSts.h:23
void SetDistributionPt(Double_t T=0.223)
void SetDistributionY(Double_t y0=0, Double_t sigma=0.72)
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
Double_t CpuTime()
void Stop()
void run_sim(Int_t nEvents=2)
Definition run_sim.C:11