BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
run_ana_bmn.C
Go to the documentation of this file.
1// Macro for physics analysis of simulated and experimental BM@N events
2//
3// dstFileName - input DST file with data (MC or exp. data)
4// anaFileName - output file with analysis results
5// nStartEvent - number of first event to process (starts with zero), default: 0
6// nEvents - number of events to process after nStartEvent, 0 - all events of the given file after nStartEvent to
7// process
8R__ADD_INCLUDE_PATH($VMCWORKDIR)
9
11 TString dstFileName = "/eos/eosnica.jinr.ru/nica/bmn/exp/dst/run8/24.04.0/mpd_run_Top_7329_ev0_p3.root",
12 TString anaFileName = "pairs.root",
13 Int_t nStartEvent = 0,
14 Int_t nEvents = 0)
15{
16 gDebug = 0; // Debug option
17 // Verbosity level (0 = summary only, 1 = event-level, 2 = track-level, 3 = full debug)
18 Int_t iVerbose = 0;
19 FairLogger::GetLogger()->SetLogScreenLevel("info");
20
21 // ----- Timer ---------------------------------------------------------
22 TStopwatch timer;
23 timer.Start();
24
25 // check input file exists
26 if (!BmnFunctionSet::CheckFileExist(dstFileName, 1))
27 exit(-1);
28
29 // ----- Analysis run --------------------------------------------
30 FairRunAna* fRunAna = new FairRunAna();
31 // fRunAna->SetEventHeader(new AnaEventHeader());
32
33 Bool_t isExp = (BmnFunctionSet::isSimulationFile(dstFileName)
34 == 0); // flag for FairRunAna tasks whether simulation or experimental data are used
35
36 Int_t fieldType = -1;
37 Double_t fieldScale = 0.;
38 FairField* magField = BmnFunctionAna::GetDSTField(dstFileName, fieldScale, fieldType);
39 if (magField != nullptr)
40 fRunAna->SetField(magField);
41
42 // Declare input source as simulation file or experimental data
43 // FairSource* fFileSource = new FairFileSource(dstFileName);
44 Int_t run_period = 8, run_number = -1;
45 FairSource* fFileSource = new BmnFileSource(dstFileName, run_period, run_number);
46 fRunAna->SetSource(fFileSource);
47
48 // GeoSetup gSetup;
49 // gSetup.LoadSetupToGeoManager(gSetup.GetLastApprovedSetupTag(TString::Format("run%d", run_period).Data()));
50
51 // if directory for the output file does not exist, then create
52 if (BmnFunctionSet::CreateDirectoryTree(anaFileName, 1) < 0)
53 exit(-2);
54 fRunAna->SetSink(new FairRootFileSink(anaFileName));
55 fRunAna->SetGenerateRunInfo(false);
56
57 // if nEvents is equal 0 then all events of the given file starting with "nStartEvent" should be processed
58 if (nEvents == 0)
59 nEvents = MpdGetNumEvents::GetNumROOTEvents((char*)dstFileName.Data()) - nStartEvent;
60
61 // Digitisation files.
62 // Add TObjectString file names to a TList which is passed as input to the FairParAsciiFileIo.
63 // The FairParAsciiFileIo will create on fly a concatenated input parameter file, which is then used during the
64 // reconstruction.
65 TList* parFileNameList = new TList();
66
67 // ====================================================================== //
68 // === Analysis Tasks === //
69 // ====================================================================== //
70
71 FairTask* hypNucl = new BmnHypNuclPairFinder("H3L");
72 fRunAna->AddTask(hypNucl);
73
74 // remove(geoFileName.Data());
75
76 // ----- Parameter database --------------------------------------------
77 FairRuntimeDb* rtdb = fRunAna->GetRuntimeDb();
78 FairParRootFileIo* parIo1 = new FairParRootFileIo();
79 FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
80 parIo1->open(dstFileName.Data());
81 parIo2->open(parFileNameList, "in");
82 rtdb->setFirstInput(parIo1);
83 rtdb->setSecondInput(parIo2);
84 rtdb->setOutput(parIo1);
85 rtdb->saveOutput();
86 // -------------------------------------------------------------------------
87
88 // ----- Initialize and run --------------------------------------------
89 fRunAna->GetMainTask()->SetVerbose(iVerbose);
90 fRunAna->Init();
91 fRunAna->Run(nStartEvent, nStartEvent + nEvents);
92 // -------------------------------------------------------------------------
93
94 // ----- Finish --------------------------------------------------------
95 timer.Stop();
96 Double_t rtime = timer.RealTime();
97 Double_t ctime = timer.CpuTime();
98 cout << endl << endl;
99 cout << "Macro finished successfully." << endl; // marker of successful execution
100 cout << "Input file is " + dstFileName << endl;
101 cout << "Output file is " + anaFileName << endl;
102 cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
103 cout << endl;
104 // ------------------------------------------------------------------------
105}
bool Bool_t
int Int_t
Int_t gDebug
double Double_t
#define R__ADD_INCLUDE_PATH(PATH)
BmnFileSource.h.
static FairField * GetDSTField(TString fileName, Double_t &fieldScale, Int_t &fieldType, TString *beam=nullptr, TString *target=nullptr, Double_t *beam_energy=nullptr, Int_t *beam_a=nullptr, Int_t *beam_z=nullptr, Int_t *target_a=nullptr, Int_t *target_z=nullptr)
static int CreateDirectoryTree(TString &fileName, int iVerbose=0, EAccessMode mode=kWritePermission)
static int isSimulationFile(TString fileName="")
static int CheckFileExist(TString &fileName, int iVerbose=0, EAccessMode mode=kFileExists)
static Int_t GetNumROOTEvents(const char *filename, const char *treename="", int iVerbose=2)
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
Double_t CpuTime()
void Stop()
void run_ana_bmn(TString dstFileName="/eos/eosnica.jinr.ru/nica/bmn/exp/dst/run8/24.04.0/mpd_run_Top_7329_ev0_p3.root", TString anaFileName="pairs.root", Int_t nStartEvent=0, Int_t nEvents=0)
Definition run_ana_bmn.C:10