File indexing completed on 2025-08-05 08:11:23
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef ReadEventBase_h
0009 #define ReadEventBase_h
0010
0011 #include <TROOT.h>
0012 #include <TChain.h>
0013 #include <TFile.h>
0014
0015
0016 #include "TObject.h"
0017
0018 class ReadEventBase {
0019 public :
0020 TTree *fChain;
0021 Int_t fCurrent;
0022
0023 static constexpr Int_t kMaxfhitArray = 5955;
0024
0025
0026
0027 UInt_t fUniqueID;
0028 UInt_t fBits;
0029 Int_t evtSeq;
0030 Long64_t bco;
0031 Int_t fNhits;
0032 Int_t fhitArray_;
0033 UInt_t fhitArray_fUniqueID[kMaxfhitArray];
0034 UInt_t fhitArray_fBits[kMaxfhitArray];
0035 Int_t fhitArray_pid[kMaxfhitArray];
0036 Int_t fhitArray_adc[kMaxfhitArray];
0037 Int_t fhitArray_ampl[kMaxfhitArray];
0038 Int_t fhitArray_chip_id[kMaxfhitArray];
0039 Int_t fhitArray_module[kMaxfhitArray];
0040 Int_t fhitArray_chan_id[kMaxfhitArray];
0041 Int_t fhitArray_bco[kMaxfhitArray];
0042 Long64_t fhitArray_bco_full[kMaxfhitArray];
0043 Int_t fhitArray_evt[kMaxfhitArray];
0044 Int_t fhitArray_roc[kMaxfhitArray];
0045 Int_t fhitArray_barrel[kMaxfhitArray];
0046 Int_t fhitArray_layer[kMaxfhitArray];
0047 Int_t fhitArray_ladder[kMaxfhitArray];
0048 Int_t fhitArray_arm[kMaxfhitArray];
0049 Int_t fhitArray_full_fphx[kMaxfhitArray];
0050 Int_t fhitArray_full_roc[kMaxfhitArray];
0051
0052
0053 TBranch *b_event_fUniqueID;
0054 TBranch *b_event_fBits;
0055 TBranch *b_event_evtSeq;
0056 TBranch *b_event_bco;
0057 TBranch *b_event_fNhits;
0058 TBranch *b_event_fhitArray_;
0059 TBranch *b_fhitArray_fUniqueID;
0060 TBranch *b_fhitArray_fBits;
0061 TBranch *b_fhitArray_pid;
0062 TBranch *b_fhitArray_adc;
0063 TBranch *b_fhitArray_ampl;
0064 TBranch *b_fhitArray_chip_id;
0065 TBranch *b_fhitArray_module;
0066 TBranch *b_fhitArray_chan_id;
0067 TBranch *b_fhitArray_bco;
0068 TBranch *b_fhitArray_bco_full;
0069 TBranch *b_fhitArray_evt;
0070 TBranch *b_fhitArray_roc;
0071 TBranch *b_fhitArray_barrel;
0072 TBranch *b_fhitArray_layer;
0073 TBranch *b_fhitArray_ladder;
0074 TBranch *b_fhitArray_arm;
0075 TBranch *b_fhitArray_full_fphx;
0076 TBranch *b_fhitArray_full_roc;
0077
0078 ReadEventBase(TTree *tree=0);
0079 virtual ~ReadEventBase();
0080 virtual Int_t Cut(Long64_t entry);
0081 virtual Int_t GetEntry(Long64_t entry);
0082 virtual Long64_t LoadTree(Long64_t entry);
0083 virtual void Init(TTree *tree);
0084 virtual void Loop();
0085 virtual Bool_t Notify();
0086 virtual void Show(Long64_t entry = -1);
0087 };
0088
0089 #endif
0090
0091 #ifdef ReadEventBase_cxx
0092 ReadEventBase::ReadEventBase(TTree *tree) : fChain(0)
0093 {
0094
0095
0096 if (tree == 0) {
0097 TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("beam_intt2-00020869-0000_event_base.root");
0098 if (!f || !f->IsOpen()) {
0099 f = new TFile("beam_intt2-00020869-0000_event_base.root");
0100 }
0101 f->GetObject("tree",tree);
0102
0103 }
0104 Init(tree);
0105 }
0106
0107 ReadEventBase::~ReadEventBase()
0108 {
0109 if (!fChain) return;
0110 delete fChain->GetCurrentFile();
0111 }
0112
0113 Int_t ReadEventBase::GetEntry(Long64_t entry)
0114 {
0115
0116 if (!fChain) return 0;
0117 return fChain->GetEntry(entry);
0118 }
0119 Long64_t ReadEventBase::LoadTree(Long64_t entry)
0120 {
0121
0122 if (!fChain) return -5;
0123 Long64_t centry = fChain->LoadTree(entry);
0124 if (centry < 0) return centry;
0125 if (fChain->GetTreeNumber() != fCurrent) {
0126 fCurrent = fChain->GetTreeNumber();
0127 Notify();
0128 }
0129 return centry;
0130 }
0131
0132 void ReadEventBase::Init(TTree *tree)
0133 {
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 if (!tree) return;
0144 fChain = tree;
0145 fCurrent = -1;
0146 fChain->SetMakeClass(1);
0147
0148 fChain -> SetBranchStatus("*",0);
0149 fChain -> SetBranchStatus("fNhits",1);
0150 fChain -> SetBranchStatus("fhitArray.chan_id",1);
0151
0152
0153
0154
0155
0156 fChain->SetBranchAddress("fNhits", &fNhits, &b_event_fNhits);
0157 fChain->GetEntry(0);
0158
0159
0160
0161
0162
0163
0164
0165
0166 fChain->SetBranchAddress("fhitArray.chan_id", &fhitArray_chan_id[0], &b_fhitArray_chan_id);
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 Notify();
0178 }
0179
0180 Bool_t ReadEventBase::Notify()
0181 {
0182
0183
0184
0185
0186
0187
0188 return kTRUE;
0189 }
0190
0191 void ReadEventBase::Show(Long64_t entry)
0192 {
0193
0194
0195 if (!fChain) return;
0196 fChain->Show(entry);
0197 }
0198 Int_t ReadEventBase::Cut(Long64_t entry)
0199 {
0200
0201
0202
0203 return 1;
0204 }
0205 #endif