ROOT MakeClass


I have a root ntuple file containing muon, electron, jets, and genparticles. I have produced the .C and .h for analyzing it by loading one of the root files (located in
/castor/ and then did

If I try to look at the information stored in the root ntuple now, it
prints ok for muons and electrons, but I get a memory related error
for the jets and genparticles for the same root file for which the .C
and .h were created (!?). I have tried changing the range of the
vectors for jets and genparticles, chaining multiple files before
creating the .C and .h ,nothing seems to cure the bad behaviour.
Basically what I have inside the .C file looks like this:

void lq::Loop(){
Long64_t nentries = fChain->GetEntriesFast();
Float_t muEta, muPhi,muEnergy,jetEta,jetPhi,jetEnergy;
RootNtupleMaker->SetBranchAddress(“caloJetIC5Eta”, &jetEta);

for (int i=0; i < RootNtupleMaker->GetEntries(); i++){
std::cout <<"entry “<<i<<” muonEta "<< muEta<< std::endl;
std::cout <<"entry “<<i<<” jetEta "<< jetEta<< std::endl;

In root executing:

.L lq.C;
lq t;

I get the error:
*** glibc detected *** free(): invalid next size (fast): 0x09446018 ***
If I comment out the jets part (including the SetBranchAddress) and
just print muons and electrons everything works fine. Am I missing
some important piece in there? I can’t see a difference between the
branches from the .C and .h (except in size of course), so I cannot
tell why one branch is ok to look at, and the next not…
I have tried instead of Chain->GetEntriesFast() to use
Chain->GetEntries() (and even both options in the same .C file) but the
same error shows up. I have run out of things to try and need some
expert help on this! The ROOT version I used is this:
Version 5.14/00f 29 May 2007

Thanks in advance for your help!!

Could you try withROOT5.20 or post one file in a public readable are?


I copied one file to
called ZmumuJets_Pt15x20Ntuple_1.root .

Thank you for your help!!


Could you copy your file to a public area, eg /afs/ ?




I cannot reproduce your problem (I tried with version 5.14 and 5.20). I can loop without any problem on the file generated by MakeClass. Are you doing something special in your lq.C file?
Could you post it?


I copied lq.C and lq.h to the public area.
My Root version is different than yours, that might be the problem? It comes automatically with a certain release in CMS… I’ll try setting up 5.20 next, perhaps that would solve the problem.



It seems that you missed the point with teh code generated by MakeClass. You do not have to set branch addreesses again. This is automatically done. Also note that branches like “muonEta”, “eleEta” are arrays with an array count in other branches like muonCount, genCount, etc. You only have to modify the loop as shown in the example below

[code] if (fChain == 0) return;

Long64_t nentries = fChain->GetEntriesFast();

Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
std::cout <<“muonEta[0]= “<< muonEta[0]<<” eleEta= “<<eleEta[0]<<” muonCount=”<<muonCount<< std::endl;


I did try it initially on the loop you wrote and later changed it to a new one thinking that maybe there is something wrong there. But not adding the SetBranchAddress works now!! Thank you very much for you help and explanation!!

Best regards,