BmnRoot 26.10.0-19-g6979a6c6
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
run_sim_prefilter.C
Go to the documentation of this file.
1R__ADD_INCLUDE_PATH($VMCWORKDIR)
2R__ADD_INCLUDE_PATH($SIMPATH / include / fairmq)
3
4#include "macro/run/geometry_run/geometry_run7.C"
5
6#include <cstdint>
7
8#define GEANT3 // Choose: GEANT3 GEANT4
9// enumeration of generator names corresponding input files
20
21void run_sim_prefilter(TString dir = "/ncx/eos/nica/bmn/sim/gen/DCMQGSM/ArAl_3.2AGeV_mb/",
22 TString outFile = "$VMCWORKDIR/macro/run/Filtered_ArAl_3.2AGeV.root",
23 Int_t SelPDG = 3122)
24{
25 TStopwatch timer;
26 timer.Start();
27 gDebug = 0;
28 Int_t fVerbose = 2;
29
30 // ----- Create simulation run ----------------------------------------
31 BmnFairRunSim* fRun = new BmnFairRunSim();
32
33 // Choose the Geant Navigation System
34#ifdef GEANT3
35 fRun->SetName("TGeant3");
36#else
37 fRun->SetName("TGeant4");
38#endif
39
40 // geometry(fRun); // load BM@N geometry
41 // Set Material file Name
42 fRun->SetMaterials("media.geo");
43
44 // ----- Create passive volumes -------------------------
45 FairModule* cave = new FairCave("CAVE");
46 cave->SetGeometryFileName("cave.geo");
47 fRun->AddModule(cave);
48
49 FairModule* magnet = new FairMagnet("MAGNET");
50 magnet->SetGeometryFileName("magnet_modified.root");
51 fRun->AddModule(magnet);
52
53 // Create and Set Event Generator
54 FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
55 fRun->SetGenerator(primGen);
56
57 // Smearing of beam interaction point, if needed, and primary vertex position
58 // DO NOT do it in corresponding gen. sections to avoid incorrect summation!!!
59 primGen->SetBeam(0.0, 0.0, 0.0, 0.0);
60 primGen->SetTarget(0.0, 0.0);
61 primGen->SmearVertexZ(kFALSE);
62 primGen->SmearVertexXY(kFALSE);
63 // FairMQProxy * sink = new FairMQProxy();
64 // fRun->SetSink((FairSink*)sink);
65 FairRootFileSink* sink = new FairRootFileSink(outFile.Data());
66 fRun->SetSink(sink);
67 sink->InitSink();
68 fRun->SetIsMT(false);
69
70 // Int_t lastSlash = dir.Last('/');
71 // TString simDir = (lastSlash == TString::kNPOS) ? "" : TString(dir(0, lastSlash + 1));
72 vector<TString> fileVec = BmnRecoTools::GetFileVecFromDir(dir);
73 printf("Found %lu files\n", fileVec.size());
74 MpdLAQGSMGeneratorExt* guGen = new MpdLAQGSMGeneratorExt(fileVec, kFALSE, 0, 0, SelPDG, kTRUE);
75 guGen->SetRunSimInst(fRun);
76
77 primGen->AddGenerator(guGen);
78
79 // ----- Create magnetic field ----------------------------------------
80 BmnFieldMap* magField = new BmnNewFieldMap("field_sp41v4_ascii_Extrap.root");
81 Double_t fieldScale = 1200. / 900.;
82 magField->SetScale(fieldScale);
83 fRun->SetField(magField);
84
85 fRun->SetStoreTraj(kTRUE);
86 fRun->SetRadLenRegister(kFALSE); // radiation length manager
87
88 fRun->Init();
89 magField->Print();
90 // // Trajectories Visualization (TGeoManager only)
91 // FairTrajFilter* trajFilter = FairTrajFilter::Instance();
92 // // Set cuts for storing the trajectories
93 // trajFilter->SetStepSizeCut(0.01); // 1 cm
94 // trajFilter->SetVertexCut(-200., -200., -150., 200., 200., 1100.);
95 // trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV
96 // trajFilter->SetEnergyCut(0., 4.); // 0 < Etot < 1.04 GeV //
97 // trajFilter->SetStorePrimaries(kTRUE);
98 // trajFilter->SetStoreSecondaries(kTRUE); //kFALSE
99 // Fill the Parameter containers for this run
100 FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
101
102 BmnFieldPar* fieldPar = (BmnFieldPar*)rtdb->getContainer("BmnFieldPar");
103 fieldPar->SetParameters(magField);
104 fieldPar->setChanged();
105 fieldPar->setInputVersion(fRun->GetRunId(), 1);
106 Bool_t kParameterMerged = kTRUE;
107 FairParRootFileIo* output = new FairParRootFileIo(kParameterMerged);
108 // AZ output->open(parFile.Data());
109 output->open(gFile);
110 rtdb->setOutput(output);
111
112 rtdb->saveOutput();
113 rtdb->print();
114
115 Int_t doNEvents = 1000000; // INT32_MAX;
116 TTree* tree = sink->GetOutTree();
117 TFile* fRootFile = tree->GetCurrentFile();
118 printf("frootfile name %s\n", fRootFile->GetName());
119 fRootFile->cd();
120 fRun->Run(doNEvents);
121
122 timer.Stop();
123 Double_t rtime = timer.RealTime(), ctime = timer.CpuTime();
124 printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
125 cout << "Macro finished successfully." << endl; // marker of successfully execution for software testing systems
126}
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
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.
Field Map does not have any symmetries w.r.t coordinate axises.
static vector< TString > GetFileVecFromDir(TString dir)
void SetRunSimInst(BmnFairRunSim *v)
Bool_t cd() override
const char * GetName() const override
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
Double_t CpuTime()
void Stop()
TFile * GetCurrentFile() const
enumGenerators
@ PART
@ QGSM
@ HSD
@ URQMD
@ ION
@ DQGSM
void run_sim_prefilter(TString dir="/ncx/eos/nica/bmn/sim/gen/DCMQGSM/ArAl_3.2AGeV_mb/", TString outFile="$VMCWORKDIR/macro/run/Filtered_ArAl_3.2AGeV.root", Int_t SelPDG=3122)