I am new to streamer. I want to read from a root file, which is a flat tree containing variable length array branches. I was following the instruction about streamer from root user’s guide, but still got stuck.
I have a root tree, and I automatic generate the class by using
It generates the NanoTree Class. Since it contains variable length array, I modified some variables to be, for example:
Float_t Muon_eta; //[nMuon]
Float_t Muon_mass; //[nMuon]
Float_t Muon_phi; //[nMuon]
Float_t Muon_pt; //[nMuon]
Bool_t Muon_tightId; //[nMuon]
Int_t Muon_charge; //[nMuon]
Float_t *Muon_eta; //[nMuon]
Float_t *Muon_mass; //[nMuon]
Float_t *Muon_phi; //[nMuon]
Float_t *Muon_pt; //[nMuon]
Bool_t *Muon_tightId; //[nMuon]
Int_t *Muon_charge; //[nMuon]
And I set up streamer for the class. However, it does not work. The code complies but it always shows segment fault when I run it. (I understand the automatically generated .h file set the length of the array to be the maximum number of muons that one event could have within that root file. However, I would like to read it depends on the nMuon, because I want the code to work for other root files. )
Here is what I’ve done, please help me check if I missed anything.
I called macro ClassDef(NanoTree,1) at the end of the class declaration in the NanoTree.h file.
I also called macro ClassImp(NanoTree) in the beginning of NanoTree.C file.
I made the EventLinkDef.h and automatically generated the EventDict.cxx. The EventDict.cxx does have the streamer defined. The Makefile is also shown here.
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class NanoTree+;
root-config --cflags --libs
rootcling -f EventDict.cxx -c NanoTree.h EventLinkDef.h
(CC) (CFLAGS) EventDict.cxx NanoTree.C NanoTreeLoop.C -o NanoTreeLoop
(NanoTreeLoop.C is just the main execution for running the analysis code over a list of root files that has the same structure.)
ROOT Version: 6.12/07
Platform: Not Provided
Compiler: Not Provided