BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
run_sim_bmn.C
Go to the documentation of this file.
1#include <Rtypes.h>
2R__ADD_INCLUDE_PATH($VMCWORKDIR)
3#include "macro/alignment/QA/geometry.C"
4#include "macro/run/bmnloadlibs.C"
5
6void run_sim_bmn(TString inFile = "",
7 TString outFile = "evetest_RUN7_GEM.root",
8 Int_t nStartEvent = 0,
9 Int_t nEvents = 1000,
10 Bool_t flag_store_FairRadLenPoint = kFALSE,
11 Bool_t isFieldMap = kTRUE)
12{
13 TStopwatch timer;
14 timer.Start();
15 gDebug = 0;
16
17 bmnloadlibs(); // load libraries
18
19 // ----- Create simulation run ----------------------------------------
20 FairRunSim* fRun = new FairRunSim();
21
22 fRun->SetName("TGeant3");
23
24 geometry(fRun); // load bmn geometry
25
26 FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
27 fRun->SetGenerator(primGen);
28
29 gRandom->SetSeed(0);
30 FairBoxGenerator* boxGen = new FairBoxGenerator(2212, 10); // 13 = muon; 1 = multipl.
31 boxGen->SetPRange(1., 1.); // GeV/c, setPRange vs setPtRange
32 boxGen->SetPhiRange(0, 360); // Azimuth angle range [degree]
33 boxGen->SetThetaRange(10, 15); // Polar angle in lab system range [degree]
34 boxGen->SetXYZ(0.5, -4.6, -2.3); // Approximate position of target (RunSpring2017)
35 primGen->AddGenerator(boxGen);
36
37 fRun->SetOutputFile(outFile.Data());
38
39 // ----- Create magnetic field ----------------------------------------
40 BmnFieldMap* magField = NULL;
41 if (isFieldMap) {
42 Double_t fieldScale = 0.;
43 // magField = new BmnNewFieldMap("field_sp41v2_ascii_noExtrap.dat");
44 magField = new BmnNewFieldMap("field_sp41v4_ascii_Extrap.root");
45 // Double_t fieldZ = 124.5; // field centre z position
46 // magField->SetPosition(0., 0., fieldZ);
47 magField->SetScale(fieldScale);
48 fRun->SetField(magField);
49 } else {
50 BmnFieldConst* magField = new BmnFieldConst();
51 magField->SetFieldRegion(-300., 300., -300., 300., -300., 300);
52 magField->SetField(0., -9. * 0.44, 0.);
53 fRun->SetField(magField);
54 }
55
56 fRun->SetStoreTraj(kTRUE);
57 fRun->SetRadLenRegister(flag_store_FairRadLenPoint); // radiation length manager
58
59 BmnGemStripConfiguration::GEM_CONFIG gem_config = BmnGemStripConfiguration::RunSpring2018_misAlign;
61 gemDigit->SetCurrentConfig(gem_config);
62 gemDigit->SetOnlyPrimary(kFALSE);
63 gemDigit->SetStripMatching(kTRUE);
64 fRun->AddTask(gemDigit);
65
66 fRun->Init();
67 if (isFieldMap)
68 magField->Print();
69
70 // Trajectories Visualization (TGeoManager only)
71 FairTrajFilter* trajFilter = FairTrajFilter::Instance();
72 // Set cuts for storing the trajectories
73 trajFilter->SetStepSizeCut(0.01); // 1 cm
74 trajFilter->SetVertexCut(-200., -200., -150., 200., 200., 1100.);
75 trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV
76 trajFilter->SetEnergyCut(0., 4.); // 0 < Etot < 1.04 GeV //
77 trajFilter->SetStorePrimaries(kTRUE);
78 trajFilter->SetStoreSecondaries(kTRUE); // kFALSE
79
80 // Fill the Parameter containers for this run
81 FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
82
83 BmnFieldPar* fieldPar = (BmnFieldPar*)rtdb->getContainer("BmnFieldPar");
84 fieldPar->SetParameters(magField);
85 fieldPar->setChanged();
86 fieldPar->setInputVersion(fRun->GetRunId(), 1);
87 Bool_t kParameterMerged = kTRUE;
88 FairParRootFileIo* output = new FairParRootFileIo(kParameterMerged);
89 // AZ output->open(parFile.Data());
90 output->open(gFile);
91 rtdb->setOutput(output);
92
93 rtdb->saveOutput();
94 rtdb->print();
95
96 // Transport nEvents
97 fRun->Run(nEvents);
98
99 fRun->CreateGeometryFile("geofile_full.root"); // save the result setup geometry to the additional file
100
101 timer.Stop();
102 Double_t rtime = timer.RealTime(), ctime = timer.CpuTime();
103 printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
104 cout << "Macro finished successfully." << endl; // marker of successfully execution for CDASH
105}
bool Bool_t
int Int_t
Int_t gDebug
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
#define R__ADD_INCLUDE_PATH(PATH)
#define gFile
R__EXTERN TRandom * gRandom
void SetField(Double_t bX, Double_t bY, Double_t bZ)
Set the field values.
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Set the field region.
void SetScale(Double_t factor)
Set a global field scaling factor.
Definition BmnFieldMap.h:55
virtual void Print(Option_t *) const
Screen output.
void SetParameters(FairField *field)
Set parameters from BmnField.
void SetCurrentConfig(BmnGemStripConfiguration::GEM_CONFIG config)
void SetStripMatching(Bool_t opt=kTRUE)
void SetOnlyPrimary(Bool_t opt=kFALSE)
Field Map does not have any symmetries w.r.t coordinate axises.
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
Double_t CpuTime()
void Stop()
void run_sim_bmn(TString inFile="", TString outFile="evetest_RUN7_GEM.root", Int_t nStartEvent=0, Int_t nEvents=1000, Bool_t flag_store_FairRadLenPoint=kFALSE, Bool_t isFieldMap=kTRUE)
Definition run_sim_bmn.C:6