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