File indexing completed on 2025-08-06 08:12:31
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef MBDReaderV2_h
0009 #define MBDReaderV2_h
0010
0011 #include <TROOT.h>
0012 #include <TChain.h>
0013 #include <TFile.h>
0014
0015
0016
0017 class MBDReaderV2 {
0018 public :
0019 TTree *fChain;
0020 Int_t fCurrent;
0021
0022
0023
0024
0025 Int_t event;
0026 UShort_t clk;
0027 UShort_t femclk;
0028 Bool_t is_min_bias;
0029 Float_t MBD_centrality;
0030 Float_t MBD_z_vtx;
0031 Float_t MBD_south_charge_sum;
0032 Float_t MBD_north_charge_sum;
0033 Float_t MBD_charge_sum;
0034 Float_t MBD_charge_asymm;
0035
0036
0037 TBranch *b_event;
0038 TBranch *b_clk;
0039 TBranch *b_femclk;
0040 TBranch *b_is_min_bias;
0041 TBranch *b_MBD_centrality;
0042 TBranch *b_MBD_z_vtx;
0043 TBranch *b_MBD_south_charge_sum;
0044 TBranch *b_MBD_north_charge_sum;
0045 TBranch *b_MBD_charge_sum;
0046 TBranch *b_MBD_charge_asymm;
0047
0048 MBDReaderV2(TTree *tree=0);
0049 virtual ~MBDReaderV2();
0050 virtual Int_t Cut(Long64_t entry);
0051 virtual Int_t GetEntry(Long64_t entry);
0052 virtual Long64_t LoadTree(Long64_t entry);
0053 virtual void Init(TTree *tree);
0054 virtual void Loop();
0055 virtual Bool_t Notify();
0056 virtual void Show(Long64_t entry = -1);
0057 };
0058
0059 #endif
0060
0061 #ifdef MBDReaderV2_cxx
0062 MBDReaderV2::MBDReaderV2(TTree *tree) : fChain(0)
0063 {
0064
0065
0066 if (tree == 0) {
0067 TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/gpfs/mnt/gpfs02/sphenix/user/cdean/software/analysis/dNdEta_Run2023/macros/centrality_run20869.root");
0068 if (!f || !f->IsOpen()) {
0069 f = new TFile("/gpfs/mnt/gpfs02/sphenix/user/cdean/software/analysis/dNdEta_Run2023/macros/centrality_run20869.root");
0070 }
0071 f->GetObject("EventTree",tree);
0072
0073 }
0074 Init(tree);
0075 }
0076
0077 MBDReaderV2::~MBDReaderV2()
0078 {
0079 if (!fChain) return;
0080 delete fChain->GetCurrentFile();
0081 }
0082
0083 Int_t MBDReaderV2::GetEntry(Long64_t entry)
0084 {
0085
0086 if (!fChain) return 0;
0087 return fChain->GetEntry(entry);
0088 }
0089 Long64_t MBDReaderV2::LoadTree(Long64_t entry)
0090 {
0091
0092 if (!fChain) return -5;
0093 Long64_t centry = fChain->LoadTree(entry);
0094 if (centry < 0) return centry;
0095 if (fChain->GetTreeNumber() != fCurrent) {
0096 fCurrent = fChain->GetTreeNumber();
0097 Notify();
0098 }
0099 return centry;
0100 }
0101
0102 void MBDReaderV2::Init(TTree *tree)
0103 {
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113 if (!tree) return;
0114 fChain = tree;
0115 fCurrent = -1;
0116 fChain->SetMakeClass(1);
0117
0118 fChain->SetBranchAddress("event", &event, &b_event);
0119 fChain->SetBranchAddress("clk", &clk, &b_clk);
0120 fChain->SetBranchAddress("femclk", &femclk, &b_femclk);
0121 fChain->SetBranchAddress("is_min_bias", &is_min_bias, &b_is_min_bias);
0122 fChain->SetBranchAddress("MBD_centrality", &MBD_centrality, &b_MBD_centrality);
0123 fChain->SetBranchAddress("MBD_z_vtx", &MBD_z_vtx, &b_MBD_z_vtx);
0124 fChain->SetBranchAddress("MBD_south_charge_sum", &MBD_south_charge_sum, &b_MBD_south_charge_sum);
0125 fChain->SetBranchAddress("MBD_north_charge_sum", &MBD_north_charge_sum, &b_MBD_north_charge_sum);
0126 fChain->SetBranchAddress("MBD_charge_sum", &MBD_charge_sum, &b_MBD_charge_sum);
0127 fChain->SetBranchAddress("MBD_charge_asymm", &MBD_charge_asymm, &b_MBD_charge_asymm);
0128 Notify();
0129 }
0130
0131 Bool_t MBDReaderV2::Notify()
0132 {
0133
0134
0135
0136
0137
0138
0139 return kTRUE;
0140 }
0141
0142 void MBDReaderV2::Show(Long64_t entry)
0143 {
0144
0145
0146 if (!fChain) return;
0147 fChain->Show(entry);
0148 }
0149 Int_t MBDReaderV2::Cut(Long64_t entry)
0150 {
0151
0152
0153
0154 return 1;
0155 }
0156 #endif