RootBranch Class Reference

#include <RootBranch.h>

Collaboration diagram for RootBranch:

Collaboration graph
TLeafTBranch
[legend]
List of all members.

Detailed Description

A class to read data from a ROOT TBranch.

Requests:
@@ support ROOT Char_t and others.
Author:
Kaustuv <kaustuv@stanford.edu>

Paul F. Kunz <Paul_Kunz@slac.stanford.edu>

Definition at line 40 of file RootBranch.h.

Public Member Functions

double * doubleArrayAt (unsigned int row)
 Returns pointer to a double array in given row.
bool empty () const
 Returns true, if RootBranch is empty, i.e.
float * floatArrayAt (unsigned int row)
 Returns pointer to a float array type in given row.
unsigned int getRank () const
 Gives the dimensionality of the data stored in each row of this branch.
const std::vector< int > & getShape ()
 Vector of the number of entries in the multidimensional data.
TBranchgetTBranch ()
 Returns the TBranch which was used to initialize this branch.
hippodraw::RootData::Type getType () const
 Returns the type of the data in this branch.
int * intArrayAt (unsigned int row)
 Returns pointer to a int array type in given row.
bool isFilled () const
bool isMultiDimensional () const
 Returns true if data sitting in the rows of this branch is and array.
bool isUseable () const
 Returns true if the branch is usable.
int numberOfElements () const
 Number of elements in this branch.
 RootBranch (TBranch *)
 The constructor.
void setReleventIndex (const std::vector< unsigned int > &index)
 In case we are dealing with multidimensional data in rows of this branch we would like to deal with on one entry of this multidimensional data.
unsigned int size () const
 Returns the size of the slice for the next to last dimension.
unsigned int * uintArrayAt (unsigned int row)
 Returns pointer to a unsigned int array type in given row.
double valueAt (unsigned int row) const
 Returns the value of the leaf at index row.
 ~RootBranch ()
 The destructor.

Private Member Functions

void initShape (const char *title)
 From the root title, which is of format "name[x][y][z]", gets the sizes of various dimension.
 RootBranch ()
 The default constructor.
 RootBranch (const RootBranch &)
 The copy constructor.
void setBranchAddress () const
 Sets the address where the ROOT TBranch will put its data.

Private Attributes

TBranchm_branch
 The ROOT TBranch from which the data will be obtained.
bool m_branch_set
 Set true when branch address has been set.
Double_t m_double_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Double_t.
Float_t m_float_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Float_t.
Int_t m_int_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Int_t.
TLeafm_leaf
 The ROOT TLeaf which described the data in this branch.
hippodraw::RootData::Type m_leaf_type
 The ROOT type name for this branch if single TLeaf is on this branch.
Long64_t m_long64_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Long64_t.
int m_number_elements
 The number of elements in the Leaf array or 0 if not an array.
int m_number_leaves
 The number of TLeaf objects on this TBranch.
int m_releventIndex
 In case the data quantity is vector/matrix we would like just to take one element out of it.
std::vector< int > m_shape
 In case the data quantity we are dealing with is a vector/matrix store its dimensions of each axis in this vector.
Short_t m_short_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Short_t.
UInt_t m_uint_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT UInt_t.
ULong64_t m_ulong64_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT ULong64_t.
bool m_useable
 Set to false if the branch is not usable.
UShort_t m_ushort_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT UShort_t.
Double_t * m_vector_double_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Double_t.
Float_t * m_vector_float_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Float_t.
Int_t * m_vector_int_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Int_t.
Long64_t * m_vector_long64_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Long64_t.
Short_t * m_vector_short_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Short_t.
UInt_t * m_vector_uint_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT UInt_t.
ULong64_t * m_vector_ulong64_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT ULong64_t.
UShort_t * m_vector_ushort_data
 The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT UShort_t.


Constructor & Destructor Documentation

RootBranch ( TBranch branch  ) 

The constructor.

Requests:
@@@ Should make this branch unuseable instead of throwing exception if the data type is not supported.

Definition at line 27 of file RootBranch.cxx.

References hippodraw::RootData::Double, hippodraw::RootData::Float, RootBranch::initShape(), hippodraw::RootData::Int, hippodraw::RootData::Long64, RootBranch::m_leaf, RootBranch::m_leaf_type, RootBranch::m_number_elements, RootBranch::m_number_leaves, RootBranch::m_useable, hippodraw::RootData::Short, num_util::type(), hippodraw::RootData::UInt, hippodraw::RootData::ULong64, and hippodraw::RootData::UShort.

RootBranch ( const RootBranch  )  [private]

The copy constructor.

RootBranch (  )  [private]

The default constructor.

Definition at line 70 of file RootBranch.cxx.

~RootBranch (  ) 

The destructor.

Definition at line 78 of file RootBranch.cxx.


Member Function Documentation

double * doubleArrayAt ( unsigned int  row  ) 

Returns pointer to a double array in given row.

Returns pointer to a double array in given row. Converts from the ROOT type to double if necessary.

Requests:
Add the conversion feature to other xxxArrayAt member functions.

Definition at line 364 of file RootBranch.cxx.

References hippodraw::RootData::Double, hippodraw::RootData::Float, hippodraw::RootData::Int, hippodraw::RootData::Long64, RootBranch::m_branch, RootBranch::m_branch_set, RootBranch::m_leaf_type, RootBranch::m_number_elements, RootBranch::m_vector_double_data, RootBranch::m_vector_float_data, RootBranch::m_vector_int_data, RootBranch::m_vector_long64_data, RootBranch::m_vector_short_data, RootBranch::m_vector_uint_data, RootBranch::m_vector_ulong64_data, RootBranch::m_vector_ushort_data, RootBranch::setBranchAddress(), hippodraw::RootData::Short, hippodraw::RootData::UInt, hippodraw::RootData::ULong64, and hippodraw::RootData::UShort.

bool empty (  )  const

Returns true, if RootBranch is empty, i.e.

has no data.

Definition at line 94 of file RootBranch.cxx.

float * floatArrayAt ( unsigned int  row  ) 

Returns pointer to a float array type in given row.

Definition at line 421 of file RootBranch.cxx.

References RootBranch::m_branch, RootBranch::m_branch_set, RootBranch::m_vector_float_data, and RootBranch::setBranchAddress().

unsigned int getRank (  )  const

Gives the dimensionality of the data stored in each row of this branch.

A scalar entry in each row means we're dealing with rank 0 data, A Vector entry in each row means we're dealing with rank 1 data, A Matrix entry in each row means we're dealing with rank 2 data, so on and so forth.

Definition at line 239 of file RootBranch.cxx.

References RootBranch::m_shape, and RootBranch::size().

Referenced by RootBranch::setReleventIndex().

const vector< int > & getShape (  ) 

Vector of the number of entries in the multidimensional data.

Note:
Chose vector of int to be compatible num_util.

Definition at line 248 of file RootBranch.cxx.

References RootBranch::m_shape.

TBranch * getTBranch (  ) 

Returns the TBranch which was used to initialize this branch.

Definition at line 123 of file RootBranch.cxx.

References RootBranch::m_branch.

RootData::Type getType (  )  const

Returns the type of the data in this branch.

Definition at line 457 of file RootBranch.cxx.

References RootBranch::m_leaf_type.

void initShape ( const char *  title  )  [private]

From the root title, which is of format "name[x][y][z]", gets the sizes of various dimension.

Stores the information as private data member.

Definition at line 130 of file RootBranch.cxx.

References RootBranch::m_shape.

Referenced by RootBranch::RootBranch().

int * intArrayAt ( unsigned int  row  ) 

Returns pointer to a int array type in given row.

Definition at line 433 of file RootBranch.cxx.

References RootBranch::m_branch, RootBranch::m_branch_set, RootBranch::m_vector_int_data, and RootBranch::setBranchAddress().

bool isFilled (  )  const

Definition at line 101 of file RootBranch.cxx.

bool isMultiDimensional (  )  const

Returns true if data sitting in the rows of this branch is and array.

Definition at line 108 of file RootBranch.cxx.

References RootBranch::m_number_elements.

bool isUseable (  )  const

Returns true if the branch is usable.

Definition at line 464 of file RootBranch.cxx.

References RootBranch::m_useable.

int numberOfElements (  )  const

Number of elements in this branch.

Since we are just dealing with the single leaf branches this entry in case of array shows total number of elements in that array.

Definition at line 116 of file RootBranch.cxx.

References RootBranch::m_number_elements.

void setBranchAddress (  )  const [private]

Sets the address where the ROOT TBranch will put its data.

Definition at line 159 of file RootBranch.cxx.

References hippodraw::RootData::Double, hippodraw::RootData::Float, hippodraw::RootData::Int, hippodraw::RootData::Long64, RootBranch::m_branch, RootBranch::m_branch_set, RootBranch::m_double_data, RootBranch::m_float_data, RootBranch::m_int_data, RootBranch::m_leaf_type, RootBranch::m_number_elements, RootBranch::m_uint_data, RootBranch::m_ulong64_data, RootBranch::m_vector_double_data, RootBranch::m_vector_float_data, RootBranch::m_vector_int_data, RootBranch::m_vector_long64_data, RootBranch::m_vector_short_data, RootBranch::m_vector_uint_data, RootBranch::m_vector_ulong64_data, RootBranch::m_vector_ushort_data, hippodraw::RootData::Short, hippodraw::RootData::UInt, hippodraw::RootData::ULong64, and hippodraw::RootData::UShort.

Referenced by RootBranch::doubleArrayAt(), RootBranch::floatArrayAt(), RootBranch::intArrayAt(), RootBranch::uintArrayAt(), and RootBranch::valueAt().

void setReleventIndex ( const std::vector< unsigned int > &  index  ) 

In case we are dealing with multidimensional data in rows of this branch we would like to deal with on one entry of this multidimensional data.

So here we set this relevant entry

Definition at line 255 of file RootBranch.cxx.

References RootBranch::getRank(), RootBranch::m_releventIndex, and RootBranch::m_shape.

unsigned int size (  )  const

Returns the size of the slice for the next to last dimension.

Definition at line 84 of file RootBranch.cxx.

Referenced by RootBranch::getRank().

unsigned int * uintArrayAt ( unsigned int  row  ) 

Returns pointer to a unsigned int array type in given row.

Definition at line 445 of file RootBranch.cxx.

References RootBranch::m_branch, RootBranch::m_branch_set, RootBranch::m_vector_uint_data, and RootBranch::setBranchAddress().

double valueAt ( unsigned int  row  )  const

Returns the value of the leaf at index row.

Definition at line 273 of file RootBranch.cxx.

References hippodraw::RootData::Double, hippodraw::RootData::Float, hippodraw::RootData::Int, hippodraw::RootData::Long64, RootBranch::m_branch, RootBranch::m_branch_set, RootBranch::m_double_data, RootBranch::m_float_data, RootBranch::m_int_data, RootBranch::m_leaf_type, RootBranch::m_long64_data, RootBranch::m_number_elements, RootBranch::m_releventIndex, RootBranch::m_short_data, RootBranch::m_uint_data, RootBranch::m_ulong64_data, RootBranch::m_ushort_data, RootBranch::m_vector_double_data, RootBranch::m_vector_float_data, RootBranch::m_vector_int_data, RootBranch::m_vector_long64_data, RootBranch::m_vector_short_data, RootBranch::m_vector_uint_data, RootBranch::m_vector_ulong64_data, RootBranch::m_vector_ushort_data, RootBranch::setBranchAddress(), hippodraw::RootData::Short, hippodraw::RootData::UInt, hippodraw::RootData::ULong64, and hippodraw::RootData::UShort.


Member Data Documentation

TBranch* m_branch [mutable, private]

The ROOT TBranch from which the data will be obtained.

Definition at line 47 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::floatArrayAt(), RootBranch::getTBranch(), RootBranch::intArrayAt(), RootBranch::setBranchAddress(), RootBranch::uintArrayAt(), and RootBranch::valueAt().

bool m_branch_set [mutable, private]

Set true when branch address has been set.

Definition at line 186 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::floatArrayAt(), RootBranch::intArrayAt(), RootBranch::setBranchAddress(), RootBranch::uintArrayAt(), and RootBranch::valueAt().

Double_t m_double_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Double_t.

So root finally stores the double data in this variable.

Definition at line 71 of file RootBranch.h.

Referenced by RootBranch::setBranchAddress(), and RootBranch::valueAt().

Float_t m_float_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Float_t.

So root finally stores the float data in this variable.

Definition at line 77 of file RootBranch.h.

Referenced by RootBranch::setBranchAddress(), and RootBranch::valueAt().

Int_t m_int_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Int_t.

So root finally stores the integer data in this variable.

Definition at line 83 of file RootBranch.h.

Referenced by RootBranch::setBranchAddress(), and RootBranch::valueAt().

TLeaf* m_leaf [private]

The ROOT TLeaf which described the data in this branch.

Definition at line 51 of file RootBranch.h.

Referenced by RootBranch::RootBranch().

hippodraw::RootData::Type m_leaf_type [private]

The ROOT type name for this branch if single TLeaf is on this branch.

Definition at line 56 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::getType(), RootBranch::RootBranch(), RootBranch::setBranchAddress(), and RootBranch::valueAt().

Long64_t m_long64_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Long64_t.

So root finally stores the integer data in this variable.

Definition at line 106 of file RootBranch.h.

Referenced by RootBranch::valueAt().

int m_number_elements [private]

The number of elements in the Leaf array or 0 if not an array.

Definition at line 65 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::isMultiDimensional(), RootBranch::numberOfElements(), RootBranch::RootBranch(), RootBranch::setBranchAddress(), and RootBranch::valueAt().

int m_number_leaves [private]

The number of TLeaf objects on this TBranch.

Definition at line 60 of file RootBranch.h.

Referenced by RootBranch::RootBranch().

int m_releventIndex [private]

In case the data quantity is vector/matrix we would like just to take one element out of it.

This index represents that particular relevant entry of the vector/matrix when flattened out as a 1-d vector.

Definition at line 182 of file RootBranch.h.

Referenced by RootBranch::setReleventIndex(), and RootBranch::valueAt().

std::vector< int > m_shape [private]

In case the data quantity we are dealing with is a vector/matrix store its dimensions of each axis in this vector.

Definition at line 176 of file RootBranch.h.

Referenced by RootBranch::getRank(), RootBranch::getShape(), RootBranch::initShape(), and RootBranch::setReleventIndex().

Short_t m_short_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Short_t.

So root finally stores the integer data in this variable.

Definition at line 94 of file RootBranch.h.

Referenced by RootBranch::valueAt().

UInt_t m_uint_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT UInt_t.

So root finally stores the integer data in this variable.

Definition at line 89 of file RootBranch.h.

Referenced by RootBranch::setBranchAddress(), and RootBranch::valueAt().

ULong64_t m_ulong64_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT ULong64_t.

So root finally stores the integer data in this variable.

Definition at line 112 of file RootBranch.h.

Referenced by RootBranch::setBranchAddress(), and RootBranch::valueAt().

bool m_useable [private]

Set to false if the branch is not usable.

A branch is not usable. It is not usable if it contains a array what has variable length. In such a case, the DataSource does not have a fixed number of columns. It is also not usable if it contains a data type that is not supported.

Definition at line 194 of file RootBranch.h.

Referenced by RootBranch::isUseable(), and RootBranch::RootBranch().

UShort_t m_ushort_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT UShort_t.

So root finally stores the integer data in this variable.

Definition at line 100 of file RootBranch.h.

Referenced by RootBranch::valueAt().

Double_t* m_vector_double_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Double_t.

So root finally stores the data in this address pointed by this variable.

Requests:
Could this be a vector instead of pointer.

Definition at line 121 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::setBranchAddress(), and RootBranch::valueAt().

Float_t* m_vector_float_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Float_t.

So root finally stores the data in this address pointed by this variable.

Definition at line 128 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::floatArrayAt(), RootBranch::setBranchAddress(), and RootBranch::valueAt().

Int_t* m_vector_int_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Int_t.

So root finally stores the data in this address pointed by this variable.

Definition at line 135 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::intArrayAt(), RootBranch::setBranchAddress(), and RootBranch::valueAt().

Long64_t* m_vector_long64_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Long64_t.

So root finally stores the data in this address pointed by this variable.

Definition at line 164 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::setBranchAddress(), and RootBranch::valueAt().

Short_t* m_vector_short_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT Short_t.

So root finally stores the data in this address pointed by this variable.

Definition at line 150 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::setBranchAddress(), and RootBranch::valueAt().

UInt_t* m_vector_uint_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT UInt_t.

So root finally stores the data in this address pointed by this variable.

Definition at line 142 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::setBranchAddress(), RootBranch::uintArrayAt(), and RootBranch::valueAt().

ULong64_t* m_vector_ulong64_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT ULong64_t.

So root finally stores the data in this address pointed by this variable.

Definition at line 171 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::setBranchAddress(), and RootBranch::valueAt().

UShort_t* m_vector_ushort_data [mutable, private]

The address of the following variable is given to ROOT TTree as the branch address for this branch if the type is ROOT UShort_t.

So root finally stores the data in this address pointed by this variable.

Definition at line 157 of file RootBranch.h.

Referenced by RootBranch::doubleArrayAt(), RootBranch::setBranchAddress(), and RootBranch::valueAt().


The documentation for this class was generated from the following files:
Generated for HippoDraw Class Library by doxygen