Home | News | Documentation | Download

Header files for Trees

Dear All,

I need some general guidance, this may turn out to be more of a C++ question, but since i am using ROOT i thought this would be the best place to start. I have a large analysis that i am trying to make more modular. My issue now is that i have probalby about 100 branches in a TTree that i have to
declare at the top of my root macro. so basically i have

void analysis()
{
..
tree->Branch("name1", "title1")
tree->Branch("name2", "title2")
...
...
tree->Branch("name100", "title100")
}

i would love to have these hundred or so lines removed from my code and put into a header file.
i tried this by simply moving these definitions into a file “tree.h” with the proper header file syntax, and got a message:

I read somewhere that this error is because this syntax requires processing and the header file
does not do this. So, if not a header file then how would you best modularize a code so you dont
have 100’s of lines of branch declarations?

Any suggestions for how to achieve this?

Many Thanks,
Cathy

“Most recent” documentation about how to generate and use an “analysis skeleton”:

Notes:

1 Like
Access leaves from branches of a tree
Reading vector data from leaves
Clone tree, add branches and save new tree
TClonesArray unable to access member functions
Initializing Muon Vectors: How to
SetBranchAddress strange behaviour or bug
Transvers distribution fpdg=21
:: Unable to read tree :
How to access a leaf nested in a branch of a tree?
Accessing each Leaf in a .root file over a loop to extract its data
Extract data from root tree
How to split primary particles and scattered particles?
Get double entries count in TH1F
Illegal pointer type TClonesArray when using SetBranchAddres
How to extract the data from a 2D array branch
Reading variable sized array from TTree
Reading from TTree
CloneTree in TSelector (or CopyTree)
Problems with filling a histogram from Tree File
Export leaf histogram to ascii
TTree branch Accessing
How are multiple TTree->Draw()s done?
Read array from TChain
TTreeReader library missing
TChain Problem
Class TChain : public TTree
To read an instance member's value stored in a branch
Wrong Special Characters in ROOT file
Problem with multiple files in TChain with MakeSelector class
Problem with multiple files in TChain with MakeSelector class
Access IDs of Entries in a given Tree Selection
Read a String from TTree (Root File)
Unable to fill properly Histogram from TTree
Reading a tree with a particular form
Reading a tree with a particular form
Problem in filling a tree branches
Problem in filling a tree branches
Problem in adding a TLorentz vector
ERROR: double free or corruption
How to tell the number of branches in a root file?
Variable getting mangled during retrieval
Reading data from custom classes written in TTree
Duplicate variables definition in header created by MakeClass
Unable to fill properly Histogram from TTree
Duplicate variables definition in header created by MakeClass
Trying to read TLeafs (Tleaves?) containing variable length arrays, getting segfault
Particle direction
Access tree in a .root file
TH1F - read and made histogram
Accessing the data inside a Ttree leaf
Loop over multiple ttree in one root file at once
TTree GetEntry Uninitialised
TChain Add multiples files in a tree
Segmentation fault analysing eventtree in 10 root files
Reading a .root file converted from .lhe
Getting Values from TTree events
Accessing TBranch Value
Accessing Delphes Tree leaf variables without delphes installation
"Warning: invalid memory pointer passed to a callee: t_T->GetEntry(ievt);"
Print from sub branch using cout
How does GetEntry work?
Seg fault when accessing std::vector elements in event loop
How to cout a certain value of a branch (only one value) of a tree?
Read un unknown root file
Read from TTree
Help on Method/s to create Tree from multi-fold gamma-ray coincidence data
SetBranchAddress with and without splitting of TBranchElements
Particle direction
Looping entries doesn't show any values
Reading all branches of TTree from file
Segmentation Violation Error in ROOT version 6.08/06
Problem loading tree with objects
Reading a TTree with multiple branches
TLorentzVector Fill Problem to a TTree or to a Histogram
Open file with TChain
Error while using TTree->GetEntry()
Segmentation violation, Root 6
Accessing a leaf within a branch in a branch
Accessing data from Tree