BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnPreRunTester.C
Go to the documentation of this file.
2#include "updateContent.C"
3
4/**
5 * Macro for processing test data before beam available
6 * @param input raw binary data
7 * @param output output DST file
8 * @param nEvents events to process
9 * @param period
10 * @param doConvert
11 * @param doHoldRawRoot
12 * @return
13 */
14int BmnPreRunTester(TString input = "",
15 TString output = "",
16 Long_t nEvents = 0,
17 UInt_t period = 9,
18 bool doConvert = true,
19 bool doHoldRawRoot = true)
20{
21 gSystem->ExpandPathName(input);
22 gSystem->ExpandPathName(output);
23
24 Int_t iVerbose = 0; ///<- Verbosity level: 0 - summary info on progress; 1 - event level, 2 - event objects level,
25 ///< 3 - full debug output
26 FairLogger::GetLogger()->SetLogToScreen(true);
27 FairLogger::GetLogger()->SetLogScreenLevel("info"); // for info write "INFO"
28 BmnSetup stp = kBMNSETUP;
29
30 TStopwatch timer;
31 TStopwatch timer_conv;
32 timer.Start();
33 TString root_file_name;
34 BmnRawSource* conv = new BmnRawSource(input, "", nEvents, period);
35 root_file_name = conv->GetRootFileName();
36 if (doConvert) {
37 timer_conv.Start();
38 BmnStatus convert_status = conv->ConvertRawToRoot();
39 delete conv;
40 timer_conv.Stop();
41 if (convert_status == kBMNERROR) {
42 printf("Converter failed!\n");
43 return -1;
44 }
45 }
46 // else
47 // root_file_name = file;
48 TString root_file_name_marked_ped = TString("marked_ped_") + root_file_name;
49 if (updateContent(root_file_name, root_file_name_marked_ped)) {
50 printf("updateContent failed!\n");
51 return -2;
52 }
53 BmnDecoder* decoder = new BmnDecoder(root_file_name_marked_ped, "", nEvents, period);
54 decoder->SetBmnSetup(stp);
55 decoder->SetVerbose(iVerbose);
56
57 std::map<DetectorId, bool> setup; // flags to determine BM@N setup
58 setup.insert(std::make_pair(kBC, 0)); // TRIGGERS
59 // setup.insert(std::make_pair(kMWPC, 0)); // MWPC
60 setup.insert(std::make_pair(kSILICON, 0)); // SILICON
61 setup.insert(std::make_pair(kGEM, 1)); // GEM
62 setup.insert(std::make_pair(kTOF1, 0)); // TOF-400
63 setup.insert(std::make_pair(kTOF, 0)); // TOF-700
64 setup.insert(std::make_pair(kTOF701, 0)); // TOF-701
65 setup.insert(std::make_pair(kDCH, 0)); // DCH
66 // setup.insert(std::make_pair(kZDC, 0)); // ZDC
67 // setup.insert(std::make_pair(kECAL, 0)); // ECAL
68 setup.insert(std::make_pair(kCSC, 0)); // CSC
69 setup.insert(std::make_pair(kSCWALL, 0)); // SCWALL
70 setup.insert(std::make_pair(kFHCAL, 0)); // FHCAL
71 setup.insert(std::make_pair(kHODO, 0)); // HODO
72 setup.insert(std::make_pair(kNDET, 0)); // Neutron Calorimeter Prototype
73 setup.insert(std::make_pair(kHGND, 0)); // Neutron Calorimeter
74 setup.insert(std::make_pair(kSiBT, 0)); // SiBD
75 decoder->SetDetectorSetup(setup);
76
77 // Set converter/decoder general parameters
78 decoder->SetDecoderConfigFileName(string(getenv("VMCWORKDIR")) + "/config/bmnconf.json");
79
80 TString PeriodSetupExt = Form("%d%s.txt", period, ((stp == kBMNSETUP) ? "" : "_SRC"));
81 decoder->SetTrigPlaceMapping(TString("Trig_PlaceMap_Run") + PeriodSetupExt);
82 decoder->SetTrigChannelMapping(TString("Trig_map_Run") + PeriodSetupExt);
83 decoder->SetSiliconMapping(TString("SILICON_map_run") + PeriodSetupExt);
84 decoder->SetSiBTMapping(TString("SiBT_map_period") + PeriodSetupExt);
85 decoder->SetGemMapping(TString("GEM_map_run") + PeriodSetupExt);
86 decoder->SetCSCMapping(TString("CSC_map_period")
87 + Form("%d%s%s.txt", period, ((stp == kBMNSETUP) ? "" : "_SRC"),
88 (decoder->GetRunId() < 7013 ? "_before_run_7013" : "")));
89 decoder->SetMSCMapping(TString("MSC_map_Run") + PeriodSetupExt);
90 // in case comment out the line decoder->SetTof400Mapping("...")
91 // the maps of TOF400 will be read from DB (only for JINR network)
92 decoder->SetTof400Mapping(TString("TOF400_PlaceMap_RUN") + PeriodSetupExt,
93 TString("TOF400_StripMap_RUN") + PeriodSetupExt);
94 decoder->SetTof701Mapping(TString("TOF701_PlaceMap_RUN") + PeriodSetupExt,
95 TString("TOF701_StripMap_RUN") + PeriodSetupExt);
96 // decoder->SetZDCMapping("ZDC_map_period_5.txt");
97 // decoder->SetZDCCalibration("zdc_muon_calibration.txt");
98 decoder->SetScWallMapping(TString("SCWALL_map_period") + PeriodSetupExt);
99 decoder->SetScWallCalibration(TString("SCWALL_calibration_period") + PeriodSetupExt);
100 decoder->SetFHCalMapping(TString("FHCAL_map_period") + PeriodSetupExt);
101 decoder->SetFHCalCalibration(TString("FHCAL_calibration_period") + PeriodSetupExt);
102 decoder->SetHodoMapping(TString("HODO_Q_map_period") + PeriodSetupExt);
103 decoder->SetHodoCalibration(TString("HODO_Q_calibration_period") + PeriodSetupExt);
104 decoder->SetNdetMapping(TString("NDET_map_period") + PeriodSetupExt);
105 if ((decoder->GetRunId() >= 7506 && decoder->GetRunId() <= 7534)
106 || (decoder->GetRunId() >= 8203 && decoder->GetRunId() <= 8258))
107 decoder->SetNdetCalibration(TString("NDET_calibration_period")
108 + Form("%d_run_7506_7534_or_8203_8258.txt", period));
109 else
110 decoder->SetNdetCalibration(TString("NDET_calibration_period") + PeriodSetupExt);
111 // decoder->SetECALMapping(TString("ECAL_map_period_") + PeriodSetupExt);
112 // decoder->SetECALCalibration("");
113 // decoder->SetMwpcMapping(TString("MWPC_map_period") + ((period == 6 && decoder->GetRunId() < 1397) ? 5 :
114 // PeriodSetupExt));
115
116 decoder->SetApplyThreshold(kTRUE); // set kFALSE to check pedestals
117 decoder->SetUseCalibFile(kFALSE); // set kTRUE to save and load strip signal calibration data
118 BmnStatus decoStatus = decoder->DecodeDataToDigi(); // Decode data into detector-digits using current mappings.
119 timer.Stop();
120 if (decoStatus == kBMNSUCCESS) {
121 if (!doHoldRawRoot)
122 gSystem->Exec(TString::Format("rm -f %s", decoder->GetRootFileName().Data()));
123 printf("\tMacro finished successfully!\n\n"); // marker of successfully execution for software testing systems
124 if (doConvert) {
125 Double_t rtime_conv = timer_conv.RealTime();
126 Double_t ctime_conv = timer_conv.CpuTime();
127 printf("Converter: Real time %f s, CPU time %f s\n", rtime_conv, ctime_conv);
128 }
129 Double_t rtime = timer.RealTime();
130 Double_t ctime = timer.CpuTime();
131 printf("All steps: Real time %f s, CPU time %f s\n", rtime, ctime);
132 }
133 TString digi_file_name = decoder->GetDigiFileName();
134 delete decoder;
135 run_reco_bmn(digi_file_name, output, 0, nEvents);
136 return 0;
137}
int Int_t
long Long_t
unsigned int UInt_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
void run_reco_bmn(TString inFileName="$VMCWORKDIR/macro/run/bmnsim.root", TString dstFileName="$VMCWORKDIR/macro/run/bmndst.root", Int_t nStartEvent=0, Int_t nEvents=0, enumTracking tracking=VectorFinder)
@ kBC
@ kSILICON
@ kNDET
@ kGEM
@ kTOF
@ kHGND
@ kTOF1
@ kFHCAL
@ kSCWALL
@ kCSC
@ kTOF701
@ kDCH
@ kSiBT
@ kHODO
BmnStatus
Define status code.
Definition BmnEnums.h:93
@ kBMNERROR
Error.
Definition BmnEnums.h:95
@ kBMNSUCCESS
Success.
Definition BmnEnums.h:94
BmnSetup
Define experimental setup.
Definition BmnEnums.h:165
@ kBMNSETUP
Definition BmnEnums.h:166
void SetApplyThreshold(bool b)
Definition BmnDecoder.h:128
void SetBmnSetup(BmnSetup v)
Definition BmnDecoder.h:235
void SetFHCalCalibration(TString cal)
Definition BmnDecoder.h:207
void SetDetectorSetup(std::map< DetectorId, bool > setup)
Definition BmnDecoder.h:229
TString GetDigiFileName()
Definition BmnDecoder.h:274
void SetFHCalMapping(TString map)
Definition BmnDecoder.h:205
void SetMSCMapping(TString map)
Definition BmnDecoder.h:225
void SetTof701Mapping(TString PlaceMap, TString StripMap)
Definition BmnDecoder.h:184
void SetDecoderConfigFileName(string FileName)
Definition BmnDecoder.h:276
void SetUseCalibFile(bool v)
Definition BmnDecoder.h:243
void SetNdetCalibration(TString cal)
Definition BmnDecoder.h:215
void SetTrigPlaceMapping(TString map)
Definition BmnDecoder.h:160
UInt_t GetRunId() const
Definition BmnDecoder.h:132
void SetGemMapping(TString map)
Definition BmnDecoder.h:174
BmnStatus DecodeDataToDigi()
void SetHodoCalibration(TString cal)
Definition BmnDecoder.h:211
void SetTrigChannelMapping(TString file)
Definition BmnDecoder.h:168
void SetScWallMapping(TString map)
Definition BmnDecoder.h:201
void SetCSCMapping(TString map)
Definition BmnDecoder.h:166
void SetSiliconMapping(TString map)
Definition BmnDecoder.h:162
void SetVerbose(Int_t v)
Definition BmnDecoder.h:239
void SetTof400Mapping(TString PlaceMap, TString StripMap)
Definition BmnDecoder.h:178
void SetScWallCalibration(TString cal)
Definition BmnDecoder.h:203
TString GetRootFileName()
Definition BmnDecoder.h:227
void SetHodoMapping(TString map)
Definition BmnDecoder.h:209
void SetNdetMapping(TString map)
Definition BmnDecoder.h:213
void SetSiBTMapping(TString map)
Definition BmnDecoder.h:164
BmnStatus ConvertRawToRoot()
TString GetRootFileName()
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
Double_t CpuTime()
void Stop()
const char * Data() const
static TString Format(const char *fmt,...)
int updateContent(TString fileName="", TString destName="", Int_t nPedsMax=100, TString treeName="BMN_RAW")
updateContent.C
int BmnPreRunTester(TString input="", TString output="", Long_t nEvents=0, UInt_t period=9, bool doConvert=true, bool doHoldRawRoot=true)
Macro for processing test data before beam available.