00001 ////////////////////////////////////////////////////////// 00002 // This class has been automatically generated 00003 // (Thu May 9 16:45:13 2002 by ROOT version3.01/06) 00004 // from TTree h101/standard 00005 // found on file: hec_adc_11555_nov8_20k.root 00006 ////////////////////////////////////////////////////////// 00007 00008 00009 #ifndef EventNTuple2001v0_h 00010 #define EventNTuple2001v0_h 00011 00012 #include <TROOT.h> 00013 #include <TChain.h> 00014 #include <TFile.h> 00015 #include <string> 00016 00017 /*! -Class: EventNTuple2001v0 00018 - Author: Ian Gable (igable@uvic.ca) 00019 - Date: 05/08/2003 00020 - Description: This class reads the contents of a 2001 Hec Test Beam ntuple 00021 */ 00022 00023 using std::string; 00024 class EventNTuple2001v0 { 00025 public : 00026 TTree *fChain; //pointer to the analyzed TTree or TChain 00027 Int_t fCurrent; //current Tree number in a TChain 00028 //Declaration of leaves types 00029 UInt_t hec_evtno; 00030 UInt_t hec_trig[5]; 00031 Int_t hec_nchan; 00032 Float_t hec_signal[310]; 00033 00034 //List of branches 00035 TBranch *b_hec_evtno; 00036 TBranch *b_hec_trig; 00037 TBranch *b_hec_nchan; 00038 TBranch *b_hec_signal; 00039 00040 EventNTuple2001v0(TTree* tree=0,string fileName=0); 00041 //EventNTuple2001v0(TTree *tree=0); 00042 ~EventNTuple2001v0(); 00043 Int_t Cut(Int_t entry); 00044 Int_t GetEntry(Int_t entry); 00045 Int_t LoadTree(Int_t entry); 00046 void Init(TTree *tree); 00047 void Loop(); 00048 Bool_t Notify(); 00049 void Show(Int_t entry = -1); 00050 00051 int numEvents(); 00052 }; 00053 00054 #endif 00055 00056 #ifdef EventNTuple2001v0_cxx 00057 EventNTuple2001v0::EventNTuple2001v0(TTree *tree,string fileName) 00058 { 00059 // if parameter tree is not specified (or zero), connect the file 00060 // used to generate this class and read the Tree. 00061 if (tree == 0) { 00062 TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(fileName.c_str()); 00063 if (!f) { 00064 f = new TFile(fileName.c_str()); 00065 } 00066 tree = (TTree*)gDirectory->Get("h101"); 00067 00068 } 00069 Init(tree); 00070 } 00071 00072 EventNTuple2001v0::~EventNTuple2001v0() 00073 { 00074 if (!fChain) return; 00075 //delete fChain->GetCurrentFile(); // comented out because of core dump 00076 } 00077 00078 Int_t EventNTuple2001v0::GetEntry(Int_t entry) 00079 { 00080 // Read contents of entry. 00081 if (!fChain) return 0; 00082 return fChain->GetEntry(entry); 00083 } 00084 Int_t EventNTuple2001v0::LoadTree(Int_t entry) 00085 { 00086 // Set the environment to read one entry 00087 if (!fChain) return -5; 00088 Int_t centry = fChain->LoadTree(entry); 00089 if (centry < 0) return centry; 00090 if (fChain->IsA() != TChain::Class()) return centry; 00091 TChain *chain = (TChain*)fChain; 00092 if (chain->GetTreeNumber() != fCurrent) { 00093 fCurrent = chain->GetTreeNumber(); 00094 Notify(); 00095 } 00096 return centry; 00097 } 00098 00099 void EventNTuple2001v0::Init(TTree *tree) 00100 { 00101 // Set branch addresses 00102 if (tree == 0) return; 00103 fChain = tree; 00104 fCurrent = -1; 00105 fChain->SetMakeClass(1); 00106 00107 fChain->SetBranchAddress("hec_evtno",&hec_evtno); 00108 fChain->SetBranchAddress("hec_trig",hec_trig); 00109 fChain->SetBranchAddress("hec_nchan",&hec_nchan); 00110 fChain->SetBranchAddress("hec_signal",hec_signal); 00111 Notify(); 00112 } 00113 00114 Bool_t EventNTuple2001v0::Notify() 00115 { 00116 // called when loading a new file 00117 // get branch pointers 00118 b_hec_evtno = fChain->GetBranch("hec_evtno"); 00119 b_hec_trig = fChain->GetBranch("hec_trig"); 00120 b_hec_nchan = fChain->GetBranch("hec_nchan"); 00121 b_hec_signal = fChain->GetBranch("hec_signal"); 00122 return kTRUE; 00123 } 00124 00125 void EventNTuple2001v0::Show(Int_t entry) 00126 { 00127 // Print contents of entry. 00128 // If entry is not specified, print current entry 00129 if (!fChain) return; 00130 fChain->Show(entry); 00131 } 00132 Int_t EventNTuple2001v0::Cut(Int_t entry) 00133 { 00134 // This function may be called from Loop. 00135 // returns 1 if entry is accepted. 00136 // returns -1 otherwise. 00137 return 1; 00138 } 00139 00140 int EventNTuple2001v0::numEvents(){ 00141 return int(fChain->GetEntries()); 00142 } 00143 #endif // #ifdef EventNTuple2001v0_cxx 00144