4 std::cout <<
"[MutableTTree]::Reading in tree: " << tree_name << std::endl;
5 tree_ = (TTree*)infile->Get(tree_name.c_str());
7 std::cout <<
"[MutableTTree]::ERROR READING TREE " << tree_name <<
" from file " << std::endl;
18 return *
tuple_[branch_name];
23 int nBr =
tree_->GetListOfBranches()->GetEntries();
24 for(
int iBr = 0; iBr < nBr; iBr++){
25 TBranch *br =
dynamic_cast<TBranch*
>(
tree_->GetListOfBranches()->At(iBr));
26 std::string varname = (std::string)br->GetFullName();
27 newtree_->Branch(varname.c_str(),
tuple_[varname],(varname+
"/D").c_str());
44 std::vector<std::string> variables;
45 for(std::map<std::string,double*>::iterator it =
tuple_.begin(); it !=
tuple_.end(); it++){
46 variables.push_back(it->first);
54 for(
int e=0; e <
tree_->GetEntries(); e++){
64 for(std::map<std::string,std::function<
double()>>::iterator it =
variable_shifts_.begin();
82 std::cout <<
"[MutableTTree]::Shifting Variable " << variable <<
" by " << shift << std::endl;
83 std::function<double()> shiftVariableFunc = [&,shift]()->
double{
90 double* value =
new double{999.9};
92 tree_->Branch(branch.c_str(),
tuple_[branch],(branch+
"/D").c_str());
96 for(std::map<std::string,double*>::iterator it =
tuple_.begin(); it !=
tuple_.end(); it ++){
97 std::cout << it->first <<
": " << *it->second << std::endl;
99 std::cout <<
"[MutableTree}::End print" << std::endl;
103 int nBr = tree->GetListOfBranches()->GetEntries();
104 for(
int iBr = 0; iBr < nBr; iBr++){
105 TBranch *br =
dynamic_cast<TBranch*
>(tree->GetListOfBranches()->At(iBr));
106 double* value =
new double;
107 std::string varname = (std::string)br->GetFullName();
108 tuple_map[varname] = value;
109 tree->SetBranchAddress(varname.c_str(),tuple_map[varname]);
114 double* variable =
new double{999.9};
115 tuple_[variableName] = variable;
116 newtree_->Branch(variableName.c_str(),
tuple_[variableName], (variableName+
"/D").c_str());
void initializeFlatTuple(TTree *tree, std::map< std::string, double * > &tuple_map)
read in the initial flat TTree
void defineMassWindow(double lowMass, double highMass)
Set the mass window within which to read the input ttree.
double getValue(std::string branch_name)
Get the value of a flat tuple variable.
void shiftVariable(std::string variable, double shift)
Apply any corrections to specified variable.
TTree * newtree_
temporary ttree used to create and fill new branches
std::vector< std::string > getAllVariables()
Get list of all variables defined in ttree.
void addNewBranch(std::string branch)
Add new branch to ttree.
MutableTTree(TFile *infile, std::string tree_name)
void copyTTree()
copy the TTree
void printEvent()
Print TTree Event.
std::map< std::string, double * > tuple_
holds all variables and values
void addVariableToTBranch(const std::string &variableName)
bool variableExists(std::string variable)
Check if a variable exists in the ttree.
double lowMass_
mass window low
double highMass_
mass window high
std::map< std::string, std::function< double()> > variable_shifts_
variable corrections
std::map< std::string, std::function< double()> > functions_
functions that calculate new variables
void Fill()
Fill ttree with new variables included.
std::map< std::string, double * > new_variables_
list of new variables