Reading a string from a TTree

I have a TFile with a TTree call “Events” in it. Hidden in there is a string variable which can be seen by running MakeClass on the tree and then looking at the header files. I just want to read that string and nothing else, so I do not want to use the MakeClass to do my work. The following is a root session…

Aside from all the “Not Found” errors at the top (which I just ignored) I would have thought that tmp[0] would have contained “EvtPlaneFromTracksMidEta” which is what Events->Show() gave me. But instead it shows nothing. I have included the root file here. Can somebody give me a hand in understanding why what I did will not work. Thanks for any info.

Justace
Events.h (6.19 KB)
Events.C (1.41 KB)
evtplane_PbPb_RECO.root (191 KB)

Poke…

Hi,

When SetMakeClass(1) is called, you can not read any object (you can realy only ints, floats). I recommend you use MakeProxy instead of MakeClass.

Cheers,
Philippe.

Well, I was only using make class to get a look inside… I would like to read the strings from this tree without the makeclass or any other automated tool. Just load the root file and then setup an array of strings and then just read the entries… I just included the makeclass output for comparison…

Justace

Hi,

The simplest is probably to create two classes that contains only what you need; something like:namespace reco { struct EvtPlane { std::string label_; }; } namespace edm { struct Wrapper { std::vector<EvtPlane> obj_; }; }You will need to also generate and load the dictionary for those 2 classes and then attach an objects of this type to the top level branch (“recoEvtPlanes_hiEvtPlane_recoLevel_RP”) and read just the branch you need (i.e. b_recoEvtPlanes_hiEvtPlane_recoLevel_RP_obj_label_ in your example).

Cheers,
Philippe.