BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
testRaw2DigitMwpc.C
Go to the documentation of this file.
1using namespace std;
2
3void testRaw2DigitMwpc(char* fname = "/nica/data4mpd1/dataBMN/bmnroot/EB+HRB/bmn_run0607_eb+hrb.root")
4{
5 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
6 bmnloadlibs();
7 /////////////////////////////////////////////////////////////////////////////////////
8 int RUN;
9 sscanf(&fname[strlen(fname) - 16], "%d", &RUN);
10 const char* mapping;
11 if (RUN < 189)
12 mapping = "DCH_map_Feb20_Feb25.txt";
13 else if (RUN >= 189 && RUN < 470)
14 mapping = "DCH_map_Mar4.txt";
15 else if (RUN >= 470 && RUN < 689)
16 mapping = "DCH_map_Mar11.txt";
17 else
18 mapping = "DCH_map_Run4.txt";
19 BmnDchRaw2Digit DCH(mapping);
20 DCH.print();
21
22 BmnZDCRaw2Digit ZDC("ZDC_map_Feb20.txt");
23 ZDC.print();
24
25 if (RUN < 470)
26 mapping = "TOF700_map_Feb20_Mar11.txt";
27 else
28 mapping = "TOF700_map_Mar11.txt";
29 BmnTof2Raw2Digit TOF2(mapping);
30 TOF2.print();
31
32 if (RUN < 470)
33 mapping = "TOF400_map_Mar4.txt";
34 else
35 mapping = "TOF400_map_Mar11.txt";
36 BmnTof1Raw2Digit TOF1(mapping);
37 TOF1.print();
38
39 cout << "Process RUN: " << RUN << endl;
40
41 /////////////////////////////////////////////////////////////////////////////////////
42 TFile* _f_in = new TFile(fname, "READ");
43 TTree* _t_in = (TTree*)_f_in->Get("BMN_RAW");
44 TClonesArray* t0_raw = new TClonesArray("BmnTDCDigit");
45 TClonesArray* sync_raw = new TClonesArray("BmnSyncDigit");
46 TClonesArray* dch_raw = new TClonesArray("BmnTDCDigit");
47 TClonesArray* tof1_raw = new TClonesArray("BmnTDCDigit");
48 TClonesArray* tof2_raw = new TClonesArray("BmnTDCDigit");
49 TClonesArray* zdc_raw = new TClonesArray("BmnADCDigit");
50 TClonesArray* ecal_raw = new TClonesArray("BmnADCDigit");
51 TClonesArray* mwpc = new TClonesArray("BmnMwpcDigit");
52 _t_in->SetBranchAddress("bmn_mwpc", &mwpc);
53 _t_in->SetBranchAddress("bmn_t0", &t0_raw);
54 _t_in->SetBranchAddress("bmn_sync", &sync_raw);
55 _t_in->SetBranchAddress("bmn_dch", &dch_raw);
56 _t_in->SetBranchAddress("bmn_tof400", &tof1_raw);
57 _t_in->SetBranchAddress("bmn_tof700", &tof2_raw);
58 _t_in->SetBranchAddress("bmn_zdc", &zdc_raw);
59 _t_in->SetBranchAddress("bmn_ecal", &ecal_raw);
60 /////////////////////////////////////////////////////////////////////////////////////
61 unsigned long EVENT, TIME_SEC, TIME_NS;
62 float T0;
63 char str[100];
64 sprintf(str, "bmn_run%04d_digit.root", RUN);
65 TFile* _f_out = new TFile(str, "RECREATE");
66 _f_out->SetCompressionLevel(1);
67 TTree* _t_out = new TTree("BMN_DIGIT", "test_bmn");
68 TClonesArray* dch_digit = new TClonesArray("BmnDchDigit");
69 TClonesArray* zdc_digit = new TClonesArray("BmnZDCDigit");
70 TClonesArray* tof2_digit = new TClonesArray("BmnTof2Digit");
71 TClonesArray* tof1_digit = new TClonesArray("BmnTof1Digit");
72 _t_out->Branch("bmn_run", &RUN, "bmn_run/I");
73 _t_out->Branch("bmn_event", &EVENT, "bmn_event/I");
74 _t_out->Branch("bmn_time_sec", &TIME_SEC, "bmn_time_sec/I");
75 _t_out->Branch("bmn_time_ns", &TIME_NS, "bmn_time_ns/I");
76 _t_out->Branch("bmn_t0", &T0, "bmn_t0/F");
77 _t_out->Branch("bmn_dch_digit", &dch_digit);
78 _t_out->Branch("bmn_zdc_digit", &zdc_digit);
79 _t_out->Branch("bmn_tof2_digit", &tof2_digit);
80 _t_out->Branch("bmn_tof1_digit", &tof1_digit);
81 _t_out->Branch("bmn_mwpc_digit", &mwpc);
82 /////////////////////////////////////////////////////////////////////////////////////
83
84 for (int ev = 0; ev < _t_in->GetEntries(); ev++) {
85 if ((ev % 100) == 0)
86 printf("%d\n", EVENT);
87 sync_raw->Clear();
88 t0_raw->Clear();
89 dch_raw->Clear();
90 mwpc->Clear();
91 tof1_raw->Clear();
92 tof2_raw->Clear();
93 zdc_raw->Clear();
94 ecal_raw->Clear();
95
96 dch_digit->Clear();
97 zdc_digit->Clear();
98 tof2_digit->Clear();
99 tof1_digit->Clear();
100
101 _t_in->GetEntry(ev);
102
103 DCH.fillEvent(dch_raw, sync_raw, t0_raw, dch_digit);
104 DCH.getEventInfo(&EVENT, &TIME_SEC, &TIME_NS);
105 TOF2.fillEvent(tof2_raw, sync_raw, t0_raw, tof2_digit);
106 TOF1.fillEvent(tof1_raw, sync_raw, t0_raw, tof1_digit);
107 ZDC.FillEvent(zdc_raw, zdc_digit);
108 T0 = DCH.get_t0();
109 if (DCH.get_t0() == 0 || EVENT == 0)
110 continue;
111 _t_out->Fill();
112 }
113 /////////////////////////////////////////////////////////////////////////////////////
114
115 _f_in->Close();
116 _t_out->Print();
117 _t_out->Write();
118 _f_out->Close();
119}
#define gROOT
void FillEvent(TClonesArray *data, TClonesArray *zdcdigit)
void Clear(Option_t *option="") override
T * Get(const char *namecycle)
virtual void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
void Close(Option_t *option="") override
virtual Int_t Fill()
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
void Print(Option_t *option="") const override
virtual Long64_t GetEntries() const
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99)
void testRaw2DigitMwpc(char *fname="/nica/data4mpd1/dataBMN/bmnroot/EB+HRB/bmn_run0607_eb+hrb.root")
Definition json.hpp:4446