File indexing completed on 2025-08-03 08:20:22
0001
0002
0003
0004
0005 #include <fstream>
0006 #include <TChain.h>
0007
0008 #include <mbd/MbdDefs.h>
0009 #include <mbd/MbdOut.h>
0010 #include <mbd/MbdPmtContainer.h>
0011 #include <mbd/MbdPmtHit.h>
0012
0013 #if defined(__CLING__)
0014 R__LOAD_LIBRARY(libmbd_io.so)
0015 #endif
0016
0017
0018 Int_t f_evt{0};
0019 UShort_t f_clk{0};
0020 UShort_t f_femclk{0};
0021 Short_t f_npmt;
0022 Float_t f_tt[MbdDefs::MBD_N_PMT];
0023 Float_t f_tq[MbdDefs::MBD_N_PMT];
0024 Float_t f_q[MbdDefs::MBD_N_PMT];
0025
0026 Short_t f_bn[MbdDefs::MBD_N_ARMS];
0027 Float_t f_bq[MbdDefs::MBD_N_ARMS];
0028 Float_t f_bt[MbdDefs::MBD_N_ARMS];
0029 Float_t f_bz;
0030 Float_t f_bt0;
0031
0032 MbdOut *mbdout{nullptr};
0033 MbdPmtContainer *mbdpmts{nullptr};
0034
0035 TFile *tfile {nullptr};
0036 TTree *tree {nullptr};
0037
0038 void dstmbd_GetEntry(const int ientry)
0039 {
0040 tree->GetEntry(ientry);
0041
0042 f_evt = mbdout->get_evt();
0043 f_clk = mbdout->get_clock();
0044 f_femclk = mbdout->get_femclock();
0045 f_bz = mbdout->get_zvtx();
0046 f_bt0 = mbdout->get_t0();
0047 for (int iarm=0; iarm<2; iarm++)
0048 {
0049 f_bn[iarm] = mbdout->get_npmt(iarm);
0050 f_bq[iarm] = mbdout->get_q(iarm);
0051 f_bt[iarm] = mbdout->get_time(iarm);
0052 }
0053 f_npmt = f_bn[0] + f_bn[1];
0054
0055
0056 for (int ipmt=0; ipmt<128; ipmt++)
0057 {
0058 f_q[ipmt] = 0.;
0059 f_tt[ipmt] = NAN;
0060 f_tq[ipmt] = NAN;
0061 }
0062
0063
0064 for (int ipmt=0; ipmt<mbdpmts->get_npmt(); ipmt++)
0065 {
0066 MbdPmtHit* mbdpmt = mbdpmts->get_pmt(ipmt);
0067
0068 f_q[ipmt] = mbdpmt->get_q();
0069 f_tt[ipmt] = mbdpmt->get_tt();
0070 f_tq[ipmt] = mbdpmt->get_tq();
0071 }
0072 }
0073
0074 void read_dstmbd(const char *tfname = "beam_mbd-00009184-0000_mbd.root")
0075 {
0076 cout << "tfname " << tfname << endl;
0077
0078
0079 int is_dst = 0;
0080 tfile = new TFile(tfname,"READ");
0081 tree = (TTree*)tfile->Get("T");
0082
0083 tree->SetBranchAddress("DST#MBD#MbdOut",&mbdout);
0084 tree->SetBranchAddress("DST#MBD#MbdPmtContainer",&mbdpmts);
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 int nentries = tree->GetEntries();
0105 cout << "checking output of dst file " << tfname << endl;
0106 cout << "nentries = " << nentries << endl;
0107 for (int ientry=0; ientry<10; ientry++)
0108 {
0109
0110 dstmbd_GetEntry(ientry);
0111
0112
0113 if (ientry<10)
0114 {
0115
0116 cout << f_evt << "\t" << f_q[0] << "\t" << f_tt[0] << endl;
0117 cout << "\t" << f_q[127] << "\t" << f_tt[127] << endl;
0118 cout << "\t" << f_bz << endl;
0119 }
0120
0121 }
0122
0123 }
0124