BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
run_reco_TOF1.C
Go to the documentation of this file.
1// --------------------------------------------------------------------------
2// Macro for reconstruction of simulated events
3//
4// inFile - input file with MC data, default: evetest.root. To process experimental data, you can use 'runNNN:' prefix.
5// The geometry is obtained from the Unified Database. outFile - output file with reconstructed data, default:
6// mpddst.root nStartEvent - number (start with zero) of first event to process, default: 0 nEvents - number of events
7// to process, 0 - all events of given file will be proccessed, default: 1
8void run_reco_TOF1(TString inFile = "run689:$VMCWORKDIR/macro/run/tof1digit_bmn_run0084_raw.root",
9 TString outFile = "$VMCWORKDIR/macro/run/bmndstDigit.root",
10 Int_t nStartEvent = 0,
11 Int_t nEvents = 1000,
12 Bool_t isPrimary = kTRUE,
13 Bool_t gemCF = kTRUE)
14// void run_reco_TOF1(TString inFile = "$VMCWORKDIR/macro/run/evetest.root", TString outFile =
15// "$VMCWORKDIR/macro/run/bmndst.root", Int_t nStartEvent = 0, Int_t nEvents = 1, Bool_t isPrimary = kTRUE, Bool_t gemCF
16// = kTRUE)
17{
18 // ========================================================================
19 // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
20 Int_t iVerbose = 0;
21
22 // ---- Debug option -------------------------------------------------
23 gDebug = 0;
24 // ------------------------------------------------------------------------
25
26 // ---- Load libraries -------------------------------------------------
27 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
28 bmnloadlibs(); // load BmnRoot libraries
29 // ------------------------------------------------------------------------
30
31 // ----- Timer --------------------------------------------------------
32 TStopwatch timer;
33 timer.Start();
34
35 // Set input source as simulation file or experimental data (if 'runN:' prefix)
36 FairSource* fFileSource;
37 Ssiz_t indColon = inFile.First(':');
38 // for experimental datasource
39 if ((indColon >= 0) && (inFile.BeginsWith("run"))) {
40 // get run number
41 TString number_string(inFile(3, indColon - 3));
42 Int_t run_number = number_string.Atoi();
43 inFile.Remove(0, indColon + 1);
44
45 if (!CheckFileExist(inFile))
46 return;
47 fFileSource = new BmnFileSource(inFile);
48
49 // get geometry for run from the Geometry Database
50 GeoSetup gSetup;
51 string setupTag = gSetup.GetLastApprovedSetupTag("run6");
52 Int_t res_code = gSetup.LoadSetupToGeoManager(setupTag);
53 if (res_code != 0) {
54 cout << "\nGeometry '" << setupTag << "' can't be loaded from the Geometry Database" << endl;
55 exit(-1);
56 }
57 } // for simulated files
58 else
59 {
60 if (!CheckFileExist(inFile))
61 return;
62 fFileSource = new FairFileSource(inFile);
63 }
64
65 // Parameter file
66 TString parFile = inFile;
67
68 // Digitisation files.
69 // Add TObjectString containing the different file names to
70 // a TList which is passed as input to the FairParAsciiFileIo.
71 // The FairParAsciiFileIo will take care to create on the fly
72 // a concatenated input parameter file which is then used during
73 // the reconstruction.
74 TList* parFileList = new TList();
75 TObjString stsDigiFile = "$VMCWORKDIR/parameters/sts_v15a_gem.digi.par";
76 parFileList->Add(&stsDigiFile);
77
78 TObjString tofDigiFile = "$VMCWORKDIR/parameters/tof_standard.geom.par";
79 parFileList->Add(&tofDigiFile);
80
81 // ----- Reconstruction run -------------------------------------------
82 FairRunAna* fRun = new FairRunAna();
83 fRun->SetSource(fFileSource);
84 fRun->SetOutputFile(outFile);
85 fRun->SetGenerateRunInfo(false);
86 // ------------------------------------------------------------------------
87
88 // ====================================================================== //
89 // === TOF1 hit finder === //
90 // ====================================================================== //
91 // BmnTof1HitProducerIdeal(const char *name = "TOF1 Ideal HitProducer", Bool_t useMCdata = true, Int_t verbose = 1,
92 // Bool_t DoTest = false, Bool_t DoMergeHits = false); BmnTof1HitProducer(const char *name = "TOF1 HitProducer",
93 // Bool_t useMCdata = true, Int_t verbose = 1, Bool_t DoTest = false);
94 BmnTof1HitProducer* tof1HP = new BmnTof1HitProducer("Tof1HitProducer", false, 1, true);
95 // tof1HP->SetOnlyPrimary(kTRUE);
96 fRun->AddTask(tof1HP);
97
98 // ----- Parameter database --------------------------------------------
99 FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
100 FairParRootFileIo* parIo1 = new FairParRootFileIo();
101 FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
102 parIo1->open(parFile.Data());
103 parIo2->open(parFileList, "in");
104 gSystem->Unlink(parIo2->getFilename()); // drop concatenated all_<pid>.par
105 rtdb->setFirstInput(parIo1);
106 rtdb->setSecondInput(parIo2);
107 rtdb->setOutput(parIo1);
108 rtdb->saveOutput();
109 // ------------------------------------------------------------------------
110
111 // ----- Initialize and run --------------------------------------------
112 fRun->Init();
113 cout << "Starting run" << endl;
114 fRun->Run(nStartEvent, nStartEvent + nEvents);
115 // ------------------------------------------------------------------------
116
117 // ----- Finish -------------------------------------------------------
118
119 timer.Stop();
120 Double_t rtime = timer.RealTime();
121 Double_t ctime = timer.CpuTime();
122 cout << endl << endl;
123 cout << "Macro finished successfully." << endl;
124 cout << "Output file is " << outFile << endl;
125 cout << "Parameter file is " << parFile << endl;
126 cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
127 cout << endl;
128 // ------------------------------------------------------------------------
129}
bool Bool_t
int Int_t
Int_t gDebug
int Ssiz_t
double Double_t
constexpr Bool_t kTRUE
#define gROOT
R__EXTERN TSystem * gSystem
BmnFileSource.h.
GeoSetup class.
Definition GeoSetup.h:40
int LoadSetupToGeoManager(string_view setup_tag)
Load selected geometry setup from the Local Geometry Database and create gGeoManager instance.
Definition GeoSetup.cxx:512
string GetLastApprovedSetupTag(string_view tag_prefix)
Get tag for the last approved setup corresponding to the pattern.
Definition GeoSetup.cxx:122
void Add(TObject *obj) override
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
Double_t CpuTime()
void Stop()
Int_t Atoi() const
const char * Data() const
void run_reco_TOF1(TString inFile="run689:$VMCWORKDIR/macro/run/tof1digit_bmn_run0084_raw.root", TString outFile="$VMCWORKDIR/macro/run/bmndstDigit.root", Int_t nStartEvent=0, Int_t nEvents=1000, Bool_t isPrimary=kTRUE, Bool_t gemCF=kTRUE)