hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
MutableTTree Class Referenceabstract

Reads flat TTree and allows user to create new variables in the TTree. More...

#include <MutableTTree.h>

Inheritance diagram for MutableTTree:
SimpAnaTTree

Public Member Functions

 MutableTTree (TFile *infile, std::string tree_name)
 
int GetEntries ()
 return number of entries in tree
 
void GetEntry (int entry)
 get tree entry
 
void Fill ()
 Fill ttree with new variables included.
 
void shiftVariable (std::string variable, double shift)
 Apply any corrections to specified variable.
 
double getValue (std::string branch_name)
 Get the value of a flat tuple variable.
 
void printEvent ()
 Print TTree Event.
 
void setBranchValue (std::string branch_name, double value)
 Set branch value.
 
void addNewBranch (std::string branch)
 Add new branch to ttree.
 
void defineMassWindow (double lowMass, double highMass)
 Set the mass window within which to read the input ttree.
 
std::vector< std::string > getAllVariables ()
 Get list of all variables defined in ttree.
 
bool variableExists (std::string variable)
 Check if a variable exists in the ttree.
 
virtual void addVariable (std::string variableName, double param)=0
 
void addVariableToTBranch (const std::string &variableName)
 
 ~MutableTTree ()
 

Protected Attributes

TTree * tree_ {nullptr}
 flat ttree
 
TTree * newtree_ {nullptr}
 temporary ttree used to create and fill new branches
 
std::map< std::string, double * > tuple_
 holds all variables and values
 
std::map< std::string, TBranch * > new_branches
 list of new branches added to ttree
 
std::map< std::string, double * > new_variables_
 list of new variables
 
std::map< std::string, std::function< double()> > functions_
 functions that calculate new variables
 
std::map< std::string, std::function< double()> > variable_shifts_
 variable corrections
 

Private Member Functions

void initializeFlatTuple (TTree *tree, std::map< std::string, double * > &tuple_map)
 read in the initial flat TTree
 
void copyTTree ()
 copy the TTree
 

Private Attributes

double lowMass_ {-999.9}
 mass window low
 
double highMass_ {-999.9}
 mass window high
 

Detailed Description

Reads flat TTree and allows user to create new variables in the TTree.

Definition at line 16 of file MutableTTree.h.

Constructor & Destructor Documentation

◆ MutableTTree()

MutableTTree ( TFile *  infile,
std::string  tree_name 
)

Definition at line 3 of file MutableTTree.cxx.

◆ ~MutableTTree()

Member Function Documentation

◆ addNewBranch()

void addNewBranch ( std::string  branch)

Add new branch to ttree.

Parameters
branch

Definition at line 89 of file MutableTTree.cxx.

◆ addVariable()

virtual void addVariable ( std::string  variableName,
double  param 
)
pure virtual

Implemented in SimpAnaTTree.

◆ addVariableToTBranch()

void addVariableToTBranch ( const std::string &  variableName)

Definition at line 113 of file MutableTTree.cxx.

◆ copyTTree()

void copyTTree ( )
private

copy the TTree

Definition at line 21 of file MutableTTree.cxx.

◆ defineMassWindow()

void defineMassWindow ( double  lowMass,
double  highMass 
)

Set the mass window within which to read the input ttree.

Parameters
lowMass
highMass

Definition at line 31 of file MutableTTree.cxx.

◆ Fill()

void Fill ( )

Fill ttree with new variables included.

Definition at line 52 of file MutableTTree.cxx.

◆ getAllVariables()

std::vector< std::string > getAllVariables ( )

Get list of all variables defined in ttree.

Definition at line 43 of file MutableTTree.cxx.

◆ GetEntries()

int GetEntries ( )
inline

return number of entries in tree

Definition at line 25 of file MutableTTree.h.

◆ GetEntry()

void GetEntry ( int  entry)
inline

get tree entry

Parameters
entry

Definition at line 31 of file MutableTTree.h.

◆ getValue()

double getValue ( std::string  branch_name)

Get the value of a flat tuple variable.

Parameters
branch_name
Returns
value

Definition at line 13 of file MutableTTree.cxx.

◆ initializeFlatTuple()

void initializeFlatTuple ( TTree *  tree,
std::map< std::string, double * > &  tuple_map 
)
private

read in the initial flat TTree

Parameters
tree
tuple_map

Definition at line 102 of file MutableTTree.cxx.

◆ printEvent()

void printEvent ( )

Print TTree Event.

Definition at line 95 of file MutableTTree.cxx.

◆ setBranchValue()

void setBranchValue ( std::string  branch_name,
double  value 
)
inline

Set branch value.

Parameters
branch_name
value

Definition at line 62 of file MutableTTree.h.

◆ shiftVariable()

void shiftVariable ( std::string  variable,
double  shift 
)

Apply any corrections to specified variable.

Parameters
variable
correction/shift

Definition at line 81 of file MutableTTree.cxx.

◆ variableExists()

bool variableExists ( std::string  variable)

Check if a variable exists in the ttree.

Parameters
variable
Returns
true
false

Definition at line 36 of file MutableTTree.cxx.

Member Data Documentation

◆ functions_

std::map<std::string,std::function<double()> > functions_
protected

functions that calculate new variables

Definition at line 102 of file MutableTTree.h.

◆ highMass_

double highMass_ {-999.9}
private

mass window high

Definition at line 119 of file MutableTTree.h.

◆ lowMass_

double lowMass_ {-999.9}
private

mass window low

Definition at line 118 of file MutableTTree.h.

◆ new_branches

std::map<std::string,TBranch*> new_branches
protected

list of new branches added to ttree

Definition at line 100 of file MutableTTree.h.

◆ new_variables_

std::map<std::string, double*> new_variables_
protected

list of new variables

Definition at line 101 of file MutableTTree.h.

◆ newtree_

TTree* newtree_ {nullptr}
protected

temporary ttree used to create and fill new branches

Definition at line 98 of file MutableTTree.h.

◆ tree_

TTree* tree_ {nullptr}
protected

flat ttree

Definition at line 97 of file MutableTTree.h.

◆ tuple_

std::map<std::string,double*> tuple_
protected

holds all variables and values

Definition at line 99 of file MutableTTree.h.

◆ variable_shifts_

std::map<std::string,std::function<double()> > variable_shifts_
protected

variable corrections

Definition at line 103 of file MutableTTree.h.


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