EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AnalyzeTree.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AnalyzeTree.h
1 
2 // This class has been automatically generated on
3 // Tue Jun 17 14:39:53 2014 by ROOT version 5.34/14
4 // from TTree starlightTree/starlightTree
5 // found on file: starlight.root
7 
8 #ifndef AnalyzeTree_h
9 #define AnalyzeTree_h
10 
11 #include <TROOT.h>
12 #include <TChain.h>
13 #include <TFile.h>
14 
15 // Header file for the classes stored in the TTree if any.
16 #include <TLorentzVector.h>
17 #include <TClonesArray.h>
18 
19 // Fixed size dimensions of array or collections stored in the TTree if any.
20 
21 class AnalyzeTree {
22 public :
23  TTree *fChain;
24  Int_t fCurrent;
25 
26  // Declaration of leaf types
27  TLorentzVector *parent;
28  TClonesArray *daughters;
29 
30  // List of branches
31  TBranch *b_parent;
32  TBranch *b_daughters;
33 
34  AnalyzeTree(TString fileName,TString treeName = "esNT");
35  virtual ~AnalyzeTree();
36  virtual Int_t Cut(Long64_t entry);
37  virtual Int_t GetEntry(Long64_t entry);
38  virtual Long64_t LoadTree(Long64_t entry);
39  virtual void Init(TTree *tree);
40  virtual void Loop();
41  virtual Bool_t Notify();
42  virtual void Show(Long64_t entry = -1);
43 
44  //Data members to be filled
46 
47 };
48 
49 #endif
50 
51 #ifdef AnalyzeTree_cxx
52 AnalyzeTree::AnalyzeTree(TString fileName,TString treeName) : fChain(0)
53 {
54 // if parameter tree is not specified (or zero), connect the file
55 // used to generate this class and read the Tree.
56  TFile * infile = new TFile(fileName,"read");
57  TTree * tree = (TTree*) infile->Get( treeName );
58  Init(tree);
59 }
60 
62 {
63  if (!fChain) return;
64  delete fChain->GetCurrentFile();
65 }
66 
67 Int_t AnalyzeTree::GetEntry(Long64_t entry)
68 {
69 // Read contents of entry.
70  if (!fChain) return 0;
71  return fChain->GetEntry(entry);
72 }
73 Long64_t AnalyzeTree::LoadTree(Long64_t entry)
74 {
75 // Set the environment to read one entry
76  if (!fChain) return -5;
77  Long64_t centry = fChain->LoadTree(entry);
78  if (centry < 0) return centry;
79  if (fChain->GetTreeNumber() != fCurrent) {
80  fCurrent = fChain->GetTreeNumber();
81  Notify();
82  }
83  return centry;
84 }
85 
86 void AnalyzeTree::Init(TTree *tree)
87 {
88  // The Init() function is called when the selector needs to initialize
89  // a new tree or chain. Typically here the branch addresses and branch
90  // pointers of the tree will be set.
91  // It is normally not necessary to make changes to the generated
92  // code, but the routine can be extended by the user if needed.
93  // Init() will be called many times when running on PROOF
94  // (once per file to be processed).
95 
96  // Set object pointer
97  parent = 0;
98  daughters = 0;
99  // Set branch addresses and branch pointers
100  if (!tree) return;
101  fChain = tree;
102  fCurrent = -1;
103  fChain->SetMakeClass(1);
104 
105  fChain->SetBranchAddress("fspt",&fspt_);
106  fChain->SetBranchAddress("fsrap",&fsrap_);
107  fChain->SetBranchAddress("fspz",&fspz_);
108  fChain->SetBranchAddress("fsmass",&fsmass_);
109  fChain->SetBranchAddress("p1pt",&p1pt_);
110  fChain->SetBranchAddress("p1z",&p1z_);
111  fChain->SetBranchAddress("p1prap",&p1prap_);
112  fChain->SetBranchAddress("p2pt",&p2pt_);
113  fChain->SetBranchAddress("p2z",&p2z_);
114  fChain->SetBranchAddress("p2prap",&p2prap_);
115  fChain->SetBranchAddress("kg",&kg_);
116  fChain->SetBranchAddress("qsq",&qsq_);
117  fChain->SetBranchAddress("xbj",&xbj_);
118 
119  Notify();
120 }
121 
122 Bool_t AnalyzeTree::Notify()
123 {
124  // The Notify() function is called when a new file is opened. This
125  // can be either for a new TTree in a TChain or when when a new TTree
126  // is started when using PROOF. It is normally not necessary to make changes
127  // to the generated code, but the routine can be extended by the
128  // user if needed. The return value is currently not used.
129 
130  return kTRUE;
131 }
132 
133 void AnalyzeTree::Show(Long64_t entry)
134 {
135 // Print contents of entry.
136 // If entry is not specified, print current entry
137  if (!fChain) return;
138  fChain->Show(entry);
139 }
140 Int_t AnalyzeTree::Cut(Long64_t entry)
141 {
142 // This function may be called from Loop.
143 // returns 1 if entry is accepted.
144 // returns -1 otherwise.
145  return 1;
146 }
147 #endif // #ifdef AnalyzeTree_cxx