Warning, file /estarlight/utils/AnalyzeTree.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef AnalyzeTree_h
0009 #define AnalyzeTree_h
0010
0011 #include <TROOT.h>
0012 #include <TChain.h>
0013 #include <TFile.h>
0014
0015
0016 #include <TLorentzVector.h>
0017 #include <TClonesArray.h>
0018
0019
0020
0021 class AnalyzeTree {
0022 public :
0023 TTree *fChain;
0024 Int_t fCurrent;
0025
0026
0027 TLorentzVector *parent;
0028 TClonesArray *daughters;
0029
0030
0031 TBranch *b_parent;
0032 TBranch *b_daughters;
0033
0034 AnalyzeTree(TString fileName,TString treeName = "esNT");
0035 virtual ~AnalyzeTree();
0036 virtual Int_t Cut(Long64_t entry);
0037 virtual Int_t GetEntry(Long64_t entry);
0038 virtual Long64_t LoadTree(Long64_t entry);
0039 virtual void Init(TTree *tree);
0040 virtual void Loop();
0041 virtual Bool_t Notify();
0042 virtual void Show(Long64_t entry = -1);
0043
0044
0045 float fspt_, fspz_, fsrap_, fsmass_, p1pt_, p1z_, p1prap_, p2pt_, p2z_, p2prap_, kg_, qsq_, xbj_;
0046
0047 };
0048
0049 #endif
0050
0051 #ifdef AnalyzeTree_cxx
0052 AnalyzeTree::AnalyzeTree(TString fileName,TString treeName) : fChain(0)
0053 {
0054
0055
0056 TFile * infile = new TFile(fileName,"read");
0057 TTree * tree = (TTree*) infile->Get( treeName );
0058 Init(tree);
0059 }
0060
0061 AnalyzeTree::~AnalyzeTree()
0062 {
0063 if (!fChain) return;
0064 delete fChain->GetCurrentFile();
0065 }
0066
0067 Int_t AnalyzeTree::GetEntry(Long64_t entry)
0068 {
0069
0070 if (!fChain) return 0;
0071 return fChain->GetEntry(entry);
0072 }
0073 Long64_t AnalyzeTree::LoadTree(Long64_t entry)
0074 {
0075
0076 if (!fChain) return -5;
0077 Long64_t centry = fChain->LoadTree(entry);
0078 if (centry < 0) return centry;
0079 if (fChain->GetTreeNumber() != fCurrent) {
0080 fCurrent = fChain->GetTreeNumber();
0081 Notify();
0082 }
0083 return centry;
0084 }
0085
0086 void AnalyzeTree::Init(TTree *tree)
0087 {
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097 parent = 0;
0098 daughters = 0;
0099
0100 if (!tree) return;
0101 fChain = tree;
0102 fCurrent = -1;
0103 fChain->SetMakeClass(1);
0104
0105 fChain->SetBranchAddress("fspt",&fspt_);
0106 fChain->SetBranchAddress("fsrap",&fsrap_);
0107 fChain->SetBranchAddress("fspz",&fspz_);
0108 fChain->SetBranchAddress("fsmass",&fsmass_);
0109 fChain->SetBranchAddress("p1pt",&p1pt_);
0110 fChain->SetBranchAddress("p1z",&p1z_);
0111 fChain->SetBranchAddress("p1prap",&p1prap_);
0112 fChain->SetBranchAddress("p2pt",&p2pt_);
0113 fChain->SetBranchAddress("p2z",&p2z_);
0114 fChain->SetBranchAddress("p2prap",&p2prap_);
0115 fChain->SetBranchAddress("kg",&kg_);
0116 fChain->SetBranchAddress("qsq",&qsq_);
0117 fChain->SetBranchAddress("xbj",&xbj_);
0118
0119 Notify();
0120 }
0121
0122 Bool_t AnalyzeTree::Notify()
0123 {
0124
0125
0126
0127
0128
0129
0130 return kTRUE;
0131 }
0132
0133 void AnalyzeTree::Show(Long64_t entry)
0134 {
0135
0136
0137 if (!fChain) return;
0138 fChain->Show(entry);
0139 }
0140 Int_t AnalyzeTree::Cut(Long64_t entry)
0141 {
0142
0143
0144
0145 return 1;
0146 }
0147 #endif