Public Member Functions | Private Attributes | List of all members
vectorFromTree< T > Class Template Reference

#include <treeReader.h>

Public Member Functions

 vectorFromTree (TTree *whichTree, string varname, Long64_t *iEntry_in)
 
 vectorFromTree ()
 
vector< T > & getDataVector ()
 
operator() (int i)
 
getData (int i)
 
int size ()
 
vector< int > findIndices (T searchval)
 

Private Attributes

TTree * thisTree
 
string thisVarname
 
Long64_t * iEntry_local
 
vector< T > * vData
 
TBranch * bData
 
Long64_t lastEntry
 

Detailed Description

template<typename T>
class vectorFromTree< T >

Definition at line 111 of file treeReader.h.

Constructor & Destructor Documentation

template<typename T>
vectorFromTree< T >::vectorFromTree ( TTree *  whichTree,
string  varname,
Long64_t *  iEntry_in 
)
inline

Definition at line 117 of file treeReader.h.

117  :
118  thisTree(whichTree),thisVarname(varname),iEntry_local(iEntry_in),
119  vData(NULL),bData(NULL) {
120  // EQUIVALENCE was a bad idea in FORTRAN IV, never mind C++14.
121  try {
122  thisTree->SetBranchAddress(thisVarname.c_str(),&vData,&bData);
123  } catch (...) {
124  throw std::runtime_error("SetBranchAddress fails in vectorFromTree constructor");
125  }
126  lastEntry = -1;
127  }
vector< T > * vData
Definition: treeReader.h:190
string thisVarname
Definition: treeReader.h:188
Long64_t lastEntry
Definition: treeReader.h:192
Long64_t * iEntry_local
Definition: treeReader.h:189
TTree * thisTree
Definition: treeReader.h:187
TBranch * bData
Definition: treeReader.h:191
template<typename T>
vectorFromTree< T >::vectorFromTree ( )
inline

Definition at line 130 of file treeReader.h.

130  {
131  thisTree = NULL; iEntry_local = NULL;
132  vData = NULL; bData = NULL;
133  thisVarname = "";
134  lastEntry = -2;
135  }
vector< T > * vData
Definition: treeReader.h:190
string thisVarname
Definition: treeReader.h:188
Long64_t lastEntry
Definition: treeReader.h:192
Long64_t * iEntry_local
Definition: treeReader.h:189
TTree * thisTree
Definition: treeReader.h:187
TBranch * bData
Definition: treeReader.h:191

Member Function Documentation

template<typename T>
vector<int> vectorFromTree< T >::findIndices ( searchval)
inline

Definition at line 175 of file treeReader.h.

175  {
176  vector<int> retval;
177  int nData = getDataVector().size();
178  for (int iDatum=0; iDatum<nData; ++iDatum) {
179  if ( getDataVector().at(iDatum)==searchval ) retval.push_back(iDatum);
180  }
181  return retval;
182  }
vector< T > & getDataVector()
Definition: treeReader.h:140
template<typename T>
T vectorFromTree< T >::getData ( int  i)
inline

Definition at line 161 of file treeReader.h.

161  {
162  return getDataVector().at(i);
163  }
vector< T > & getDataVector()
Definition: treeReader.h:140
template<typename T>
vector<T>& vectorFromTree< T >::getDataVector ( )
inline

Definition at line 140 of file treeReader.h.

140  {
141  if (*iEntry_local != lastEntry) {
143  try {
144  Long64_t tEntry = thisTree->LoadTree(*iEntry_local);
145  bData->GetEntry(tEntry);
146  } catch (...) {
147  throw std::runtime_error("Can not GetEntry in vectorFromTree.getData()");
148  }
149  }
150  return (*vData);
151  }
vector< T > * vData
Definition: treeReader.h:190
Long64_t lastEntry
Definition: treeReader.h:192
Long64_t * iEntry_local
Definition: treeReader.h:189
TTree * thisTree
Definition: treeReader.h:187
TBranch * bData
Definition: treeReader.h:191
template<typename T>
T vectorFromTree< T >::operator() ( int  i)
inline

Definition at line 157 of file treeReader.h.

157  {
158  return getDataVector().at(i);
159  }
vector< T > & getDataVector()
Definition: treeReader.h:140
template<typename T>
int vectorFromTree< T >::size ( )
inline

Definition at line 168 of file treeReader.h.

168  {
169  return getDataVector().size();
170  }
vector< T > & getDataVector()
Definition: treeReader.h:140

Member Data Documentation

template<typename T>
TBranch* vectorFromTree< T >::bData
private

Definition at line 191 of file treeReader.h.

template<typename T>
Long64_t* vectorFromTree< T >::iEntry_local
private

Definition at line 189 of file treeReader.h.

template<typename T>
Long64_t vectorFromTree< T >::lastEntry
private

Definition at line 192 of file treeReader.h.

template<typename T>
TTree* vectorFromTree< T >::thisTree
private

Definition at line 187 of file treeReader.h.

template<typename T>
string vectorFromTree< T >::thisVarname
private

Definition at line 188 of file treeReader.h.

template<typename T>
vector<T>* vectorFromTree< T >::vData
private

Definition at line 190 of file treeReader.h.


The documentation for this class was generated from the following file: