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:

2 Likes
Access leaves from branches of a tree
Reading vector data from leaves
TClonesArray unable to access member functions
Clone tree, add branches and save new tree
Read from TTree
Initializing Muon Vectors: How to
To read an instance member's value stored in a branch
How to extract the data from a 2D array branch
Illegal pointer type TClonesArray when using SetBranchAddres
Accessing each Leaf in a .root file over a loop to extract its data
Transvers distribution fpdg=21
Access IDs of Entries in a given Tree Selection
Read a String from TTree (Root File)
Open file with TChain
TLorentzVector Fill Problem to a TTree or to a Histogram
Reading a TTree with multiple branches
Problem loading tree with objects
Segmentation Violation Error in ROOT version 6.08/06
Reading all branches of TTree from file
SetBranchAddress with and without splitting of TBranchElements
Help on Method/s to create Tree from multi-fold gamma-ray coincidence data
Duplicate variables definition in header created by MakeClass
Duplicate variables definition in header created by MakeClass
Reading data from custom classes written in TTree
Variable getting mangled during retrieval
ERROR: double free or corruption
Problem in adding a TLorentz vector
Problem in filling a tree branches
Problem in filling a tree branches
Reading a tree with a particular form
Reading a tree with a particular form
SetBranchAddress strange behaviour or bug
:: Unable to read tree :
How to access a leaf nested in a branch of a tree?
Extract data from root tree
How to split primary particles and scattered particles?
Get double entries count in TH1F
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
Wrong Special Characters in ROOT file
Problem with multiple files in TChain with MakeSelector class
Problem with multiple files in TChain with MakeSelector class
Trying to read TLeafs (Tleaves?) containing variable length arrays, getting segfault
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
How do I read my leafs in this case of tchain
Reading from TTree iwth different Branches
Problem with main() and no output root file
Read jagged vectors
How to generate Skelton class from MakeSelector
Access data from a Tree
TChain get entry acceleration
Accessing array-like branches with the type "Float_t"
Accessing array-like branches with the type "Float_t"
SegFault calling GetN() method of a TGraph object
Reading file form NTuple and drawing histogram
How to tell the number of branches in a root file?
Reading from TTree
Particle direction
Particle direction
Accessing a leaf within a branch in a branch
Looping entries doesn't show any values
Reading variable sized array from TTree
Accessing data from Tree
Segmentation violation, Root 6
Error while using TTree->GetEntry()
Unable to fill properly Histogram from TTree
Unable to fill properly Histogram from TTree