Last week this forum gave me some assistance in reading my TTree, you kindly pointed out that MakeClass was the place to start.
Following these instruction I generated a class from my tree, there where some errors in the auto-generated code (from MakeClass) but once they were fixed it ran.
I can now reliably read all values from the TTree apart from the ones that are TRefArrays.
The TRefArrays appear empty, although to have strong reason to suspect they are not.
Attached are the tree, the class and it’s header. example.zip (892.7 KB)
If you put them all in a folder and do;
$ root
root [0] TFile f("tag_1_delphes_events.root")
root [1] TTree * t = (TTree *) f.Get("Delphes")
root [2] .L $ROOTSYS/test/libEvent.so // need to have run make in $ROOTSYS/test/ for this library to exist
root [3] // Bunch of errors but ignore for now
root [4] .L madgraphDefaults.C
root [5] madgraphDefaults reader
root [6] reader.GetEntry(2)
root [7] reader.Jet_Pt // its an array of Float_t
root [8] // works beautifully, list of floats.
root [9] reader.Jet_Constituents // its a TRefArray
root [10] // appears empty... but I am relatively certain that it isn't
My confidence that there should be entries in Jet_Constituents comes from playing with another tool,
ExRootAnalysis, which was able to pick the momentum vectors of tracks in the jets.
If ExRootAnalysis could do this then information about which track is in which jet
must be found somewhere in the TTree.
How can I get the values of Jet_Constituents?
Thanks, H
P.S. I think my problem is the same as Reading TRefArray from PyROOT but if I try that I get AttributeError: 'TObject' object has no attribute 'Constituents'
Ok, so again the auto generated code had some issues with identifying the right types for the variables, but after fixing that it runs.
Again I can use it to read out all variables but the TRefArrays.
The issue this time isn’t that they look empty, it’s that calling the methods of the TRefArray seems to cause a seg fault.
Edit;
So the TTree created by $ROOTSYS/tutorial/jets.C also has a TRefArray in it, and it’s reasonable to assume this tree is well formed.
I have the same problems (seg fault) trying to read the TRefArray in that TTree using code generated by MakeSelector. I can read the other branches just not the TRefArray branches (e.g. fJets_fPt works fine but fJets_fTracks causes seg faults).