I’m looping over two containers (jets and electrons) in each event, and I’m storing some kinematic variables of these two objects. However the size of the container is not the same per event (e.g. 7 jets and 4 electrons in a particular event), so I’m storing their variables in two different TTree’s (I think it was recommended, correct me if I’m wrong).
Now I want to calculate some variables, such as the angular separation of electrons and jets in each event, and I was wondering how I can link these two Tree’s. (Or how do you deal with this case in a more efficient way?)
Hi Wile, thanks a lot for your answer, but when I fill the tree it does include all the branches(variables), so how do I fill the branches individually in order to have branches with variable lengths?
E.g :
tree = new TTree(“tree”, “tree”);
tree->Branch(“xp”,&get_xp);
tree->Branch(“yp”,&get_yp); // sometimes there is no value for this variable in an event
for iev in events:
get_xp = x_value(iev);
get_yp = y_value(iev);
tree->Fill();
std::vector<double> xp;
std::vector<double> yp;
tree->Branch("xp",&xp);
tree->Branch("yp",&yp);
for iev in events:
xp.clear();
yp.clear();
if (has value for get xp)
xp.push_back(x_value(iev))
if (has value for get yp)
yp.push_back(y_value(iev))
tree->Fill();