BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnDataToRoot.cxx
Go to the documentation of this file.
1#if !defined(__CLING__) || defined(__MAKECLING__)
2// ROOT includes
3#include "BmnEnums.h"
4#include "BmnRawDataDecoder.h"
5#include "TROOT.h"
6#include "TStopwatch.h"
7#include "TString.h"
8#include "TSystem.h"
9
10#include <iostream>
11using namespace std;
12#endif
13
14void BmnDataToRoot(TString file = "",
15 TString outfile = "",
16 Long_t nEvents = 0,
17 UInt_t period = 8,
18 Bool_t doConvert = kTRUE,
19 Bool_t doHoldRawRoot = kFALSE)
20{
21 gSystem->ExpandPathName(file);
22 gSystem->ExpandPathName(outfile);
23
24 Int_t iVerbose = 1; ///<- Verbosity level: 0 - Progress Bar; 1 - short info on passed events
25
26 BmnRawDataDecoder* decoder = new BmnRawDataDecoder(file, outfile, nEvents, period);
27 // use kSRCSETUP for Short-Range Correlation program and kBMNSETUP otherwise
28 BmnSetup stp = kBMNSETUP; //(decoder->GetRunId() >= 2041 && decoder->GetRunId() <= 3588) ? kSRCSETUP : kBMNSETUP;
29 decoder->SetBmnSetup(stp);
30 decoder->SetVerbose(iVerbose);
31
32 std::map<DetectorId, bool> setup; // flags to determine BM@N setup
33 setup.insert(std::make_pair(kBC, 1)); // TRIGGERS
34 setup.insert(std::make_pair(kMWPC, 0)); // MWPC
35 setup.insert(std::make_pair(kSILICON, 1)); // SILICON
36 setup.insert(std::make_pair(kGEM, 1)); // GEM
37 setup.insert(std::make_pair(kTOF1, 0)); // TOF-400
38 setup.insert(std::make_pair(kTOF, 0)); // TOF-700
39 setup.insert(std::make_pair(kDCH, 0)); // DCH
40 setup.insert(std::make_pair(kZDC, 0)); // ZDC
41 setup.insert(std::make_pair(kECAL, 0)); // ECAL
42 setup.insert(std::make_pair(kCSC, 0)); // CSC
43 setup.insert(std::make_pair(kSCWALL, 0)); // SCWALL
44 setup.insert(std::make_pair(kFHCAL, 0)); // FHCAL
45 setup.insert(std::make_pair(kHODO, 0)); // HODO
46 setup.insert(std::make_pair(kSiBT, 1)); // SiBD
47 decoder->SetDetectorSetup(setup);
48
49 if (doConvert)
50 decoder
51 ->ConvertRawToRoot(); // Convert raw data in .data format into adc-,tdc-, ..., sync-digits in .root format
52
53 TString PeriodSetupExt = Form("%d%s.txt", period, ((stp == kBMNSETUP) ? "" : "_SRC"));
54 decoder->SetTrigPlaceMapping(TString("Trig_PlaceMap_Run") + PeriodSetupExt);
55 decoder->SetTrigChannelMapping(TString("Trig_map_Run") + PeriodSetupExt);
56 decoder->SetSiliconMapping(TString("SILICON_map_run") + PeriodSetupExt);
57 decoder->SetSiBTMapping(TString("SiBT_map_period") + PeriodSetupExt);
58 decoder->SetGemMapping(TString("GEM_map_run") + PeriodSetupExt);
59 decoder->SetCSCMapping(TString("CSC_map_period") + PeriodSetupExt);
60 decoder->SetMSCMapping(TString("MSC_map_Run") + PeriodSetupExt);
61 // in case comment out the line decoder->SetTof400Mapping("...")
62 // the maps of TOF400 will be read from DB (only for JINR network)
63 decoder->SetTOF700ReferenceRun(-1);
64 decoder->SetTof700Geom(TString("TOF700_geometry_run") + PeriodSetupExt);
65 decoder->SetTof400Mapping(TString("TOF400_PlaceMap_RUN") + PeriodSetupExt,
66 TString("TOF400_StripMap_RUN") + PeriodSetupExt);
67 if (decoder->GetRunId() >= 4278 && decoder->GetPeriodId() == 7)
68 decoder->SetTof700Mapping(TString("TOF700_map_period_") + Form("%d_from_run_4278.txt", period));
69 else
70 decoder->SetTof700Mapping(TString("TOF700_map_period_") + Form("%d.txt", period));
71 // decoder->SetZDCMapping("ZDC_map_period_5.txt");
72 // decoder->SetZDCCalibration("zdc_muon_calibration.txt");
73 decoder->SetScWallMapping(TString("SCWALL_map_period") + PeriodSetupExt);
74 decoder->SetScWallCalibration(TString("SCWALL_calibration_period") + PeriodSetupExt);
75 decoder->SetFHCalMapping(TString("FHCAL_map_period") + PeriodSetupExt);
76 decoder->SetFHCalCalibration(TString("FHCAL_calibration_period") + PeriodSetupExt);
77 decoder->SetHodoMapping(TString("HODO_Q_map_period") + PeriodSetupExt);
78 decoder->SetHodoCalibration(TString("HODO_Q_calibration_period") + PeriodSetupExt);
79 decoder->SetNdetMapping(TString("NDET_map_period") + PeriodSetupExt);
80 decoder->SetNdetCalibration(TString("NDET_calibration_period") + PeriodSetupExt);
81 // decoder->SetECALMapping(TString("ECAL_map_period_") + PeriodSetupExt);
82 // decoder->SetECALCalibration("");
83 // decoder->SetMwpcMapping(TString("MWPC_map_period") + ((period == 6 && decoder->GetRunId() < 1397) ? 5 :
84 // PeriodSetupExt));
85
86 decoder->SetApplyThreshold(kTRUE); // set kFALSE to check pedestals
87 // if (doConvert) decoder->ConvertRawToRoot(); // Convert raw data in .data format into adc-,tdc-, ..., sync-digits
88 // in .root format
89 BmnStatus decoStatus = decoder->DecodeDataToDigi(); // Decode data into detector-digits using current mappings.
90 if (decoStatus == kBMNSUCCESS) {
91 if (!doHoldRawRoot)
92 gSystem->Exec(TString::Format("rm -f %s", decoder->GetRootFileName().Data()));
93 printf("\tMacro finished successfully!\n\n"); // marker of successfully execution for software testing systems
94 }
95
96 delete decoder;
97}
98
99int main(int argc, char** arg)
100{
102 return 1;
103}
bool Bool_t
int Int_t
long Long_t
unsigned int UInt_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
@ kBC
@ kSILICON
@ kGEM
@ kTOF
@ kTOF1
@ kFHCAL
@ kSCWALL
@ kCSC
@ kMWPC
@ kDCH
@ kECAL
@ kSiBT
@ kZDC
@ kHODO
BmnStatus
Define status code.
Definition BmnEnums.h:93
@ kBMNSUCCESS
Success.
Definition BmnEnums.h:94
BmnSetup
Define experimental setup.
Definition BmnEnums.h:165
@ kBMNSETUP
Definition BmnEnums.h:166
void SetDetectorSetup(std::map< DetectorId, bool > setup)
void SetVerbose(Int_t v)
void SetBmnSetup(BmnSetup v)
UInt_t GetRunId() const
UInt_t GetPeriodId() const
void SetApplyThreshold(bool b)
const char * Data() const
static TString Format(const char *fmt,...)
void BmnDataToRoot(TString file="", TString outfile="", Long_t nEvents=0, UInt_t period=8, Bool_t doConvert=kTRUE, Bool_t doHoldRawRoot=kFALSE)
Definition json.hpp:4446
int main(void)
Definition test_FC.cpp:33