00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef HecEventNTup2002v1_h
00010 #define HecEventNTup2002v1_h
00011
00012 #include <TROOT.h>
00013 #include <TChain.h>
00014 #include <TFile.h>
00015 #include <string>
00016 #include <iostream>
00017
00018 using std::string;
00019 using std::cout;
00020 using std::endl;
00021
00022
00023
00024
00025
00026
00027
00028
00029 class HecEventNTup2002v1 {
00030 public :
00031 TTree *fChain;
00032 Int_t fCurrent;
00033
00034 UInt_t evtno;
00035 UInt_t trig[5];
00036 Int_t nchan;
00037 Float_t signal[1152];
00038 Float_t slop[2];
00039 Float_t pos0[2];
00040 Float_t xcov[3];
00041 Float_t ycov[3];
00042 Float_t tdc_ns;
00043 Float_t Globalcubictime;
00044 Float_t Globalcubictimesigma;
00045
00046
00047 TBranch *b_evtno;
00048 TBranch *b_trig;
00049 TBranch *b_nchan;
00050 TBranch *b_signal;
00051 TBranch *b_slop;
00052 TBranch *b_pos0;
00053 TBranch *b_xcov;
00054 TBranch *b_ycov;
00055 TBranch *b_tdc_ns;
00056 TBranch *b_Globalcubictime;
00057 TBranch *b_Globalcubictimesigma;
00058
00059
00060 HecEventNTup2002v1(TTree *tree=0,string fileName=0);
00061 ~HecEventNTup2002v1();
00062 Int_t Cut(Int_t entry);
00063 Int_t GetEntry(Int_t entry);
00064 Int_t LoadTree(Int_t entry);
00065 void Init(TTree *tree);
00066 void Loop();
00067 Bool_t Notify();
00068 void Show(Int_t entry = -1);
00069 int numEvents();
00070 };
00071
00072 #endif
00073
00074 #ifdef HecEventNTup2002v1_cxx
00075 HecEventNTup2002v1::HecEventNTup2002v1(TTree *tree,string fileName)
00076 {
00077
00078
00079 if (tree == 0) {
00080 TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(fileName.c_str());
00081 if (!f) {
00082 f = new TFile(fileName.c_str());
00083 }
00084 tree = (TTree*)gDirectory->Get("h101");
00085
00086 }
00087 Init(tree);
00088 }
00089
00090 HecEventNTup2002v1::~HecEventNTup2002v1()
00091 {
00092 if (!fChain) return;
00093 delete fChain->GetCurrentFile();
00094 }
00095
00096 Int_t HecEventNTup2002v1::GetEntry(Int_t entry)
00097 {
00098
00099 if (!fChain) return 0;
00100 return fChain->GetEntry(entry);
00101 }
00102 Int_t HecEventNTup2002v1::LoadTree(Int_t entry)
00103 {
00104
00105 if (!fChain) return -5;
00106 Int_t centry = fChain->LoadTree(entry);
00107 if (centry < 0) return centry;
00108 if (fChain->IsA() != TChain::Class()) return centry;
00109 TChain *chain = (TChain*)fChain;
00110 if (chain->GetTreeNumber() != fCurrent) {
00111 fCurrent = chain->GetTreeNumber();
00112 Notify();
00113 }
00114 return centry;
00115 }
00116
00117 void HecEventNTup2002v1::Init(TTree *tree)
00118 {
00119
00120 if (tree == 0) return;
00121 fChain = tree;
00122 fCurrent = -1;
00123 fChain->SetMakeClass(1);
00124
00125 fChain->SetBranchAddress("evtno",&evtno);
00126 fChain->SetBranchAddress("trig",trig);
00127 fChain->SetBranchAddress("nchan",&nchan);
00128 fChain->SetBranchAddress("signal",signal);
00129 fChain->SetBranchAddress("slop",slop);
00130 fChain->SetBranchAddress("pos0",pos0);
00131 fChain->SetBranchAddress("xcov",xcov);
00132 fChain->SetBranchAddress("ycov",ycov);
00133 fChain->SetBranchAddress("tdc_ns",&tdc_ns);
00134 fChain->SetBranchAddress("Globalcubictime",&Globalcubictime);
00135 fChain->SetBranchAddress("Globalcubictimesigma",&Globalcubictimesigma);
00136 Notify();
00137 }
00138
00139 Bool_t HecEventNTup2002v1::Notify()
00140 {
00141
00142
00143 b_evtno = fChain->GetBranch("evtno");
00144 b_trig = fChain->GetBranch("trig");
00145 b_nchan = fChain->GetBranch("nchan");
00146 b_signal = fChain->GetBranch("signal");
00147 b_slop = fChain->GetBranch("slop");
00148 b_pos0 = fChain->GetBranch("pos0");
00149 b_xcov = fChain->GetBranch("xcov");
00150 b_ycov = fChain->GetBranch("ycov");
00151 b_tdc_ns = fChain->GetBranch("tdc_ns");
00152 b_Globalcubictime = fChain->GetBranch("Globalcubictime");
00153 b_Globalcubictimesigma = fChain->GetBranch("Globalcubictimesigma");
00154 return kTRUE;
00155 }
00156
00157 void HecEventNTup2002v1::Show(Int_t entry)
00158 {
00159
00160
00161 if (!fChain) return;
00162 fChain->Show(entry);
00163 }
00164 Int_t HecEventNTup2002v1::Cut(Int_t entry)
00165 {
00166
00167
00168
00169 return 1;
00170 }
00171
00172 int HecEventNTup2002v1::numEvents(){
00173 return int(fChain->GetEntries());
00174 }
00175 #endif // #ifdef HecEventNTup2002v1_cxx
00176