I have a TTree with quite a few branches, and this one particular which I need to use is an array, but I’m only interested in the first element of the array, in this case it’s B_M.
I know that it’s still not possible to import data from an array in TTree to RooDataSet. So I get the data entry by entry and add them to RooDataSet. But it doesn’t work. As when I plot the data set, it gives 0 entry at all point except point which get all the entries (see the first plot).
This is the code I use right now:
f = TFile("myfile.root")
tree = f.Get("MyTree")
mass = array('d',)
branch = tree.GetBranch("B_M")
numEntry = tree.GetEntries()
m = RooRealVar("B_M","mass",5300., 5450.)
m_arg = RooArgSet(m)
data = RooDataSet("data", "data", m_arg)
for i in range(numEntry):
m = mass
But when I tried the same thing in interactive ROOT, it works normally (see the second plot)