GetEntry() crash when loop all over the Tree

Dear ROOTers,
My name is Ryan.
I made a macro that used to calculate the invariant mass and create histograms.
However, an error occurs when using GetEntry to loop all over the Tree.
The error message in the ROOT interactive session is something like:
ERROR leaf:lep_type, len=1068474710 and max=6
ERROR leaf:lep_flag, len=1068474710 and max=6
ERROR leaf:lep_ptcone30, len=1068474710 and max=6

This is very strange as the macro used to be fine before

Here is my macro script:

TFile *f =TFile::Open("C://root_v5.34.36/bin/Task1.root");  
float E,pt,eta,phi;
UInt_t n,type;
//mini is the name of Tree in the root file
		TLorentzVector a;
		TLorentzVector b;
		TH1F *h1 = new TH1F("h1","Invariant Mass of Dielectron",1000,0,400);
		TH1F *h2 = new TH1F("h2","Invariant Mass of Dimuon",1000,0,300);
		TH1F *h3 = new TH1F("h3","Invariant Mass of eemuonmuon",500,0,500);
		h1->GetXaxis()->SetTitle("Dielectron Mass [MeV]");
		h2->GetXaxis()->SetTitle("Dimuon Mass [MeV]");
		for ( int i=0;i<mini->GetEntries();i++) {
			mini->GetEntry(i);   // Crash occur at this line 
    if(n==2&&type==11) {h1->Fill((a+b).Mag());}
    if(n==2&&type==13) {h2->Fill((a+b).Mag());}
    if(n==4) {h3->Fill((a+b).Mag());}

Can anyone please help me find out the mistake in my marco ?
I am using a native version 5.34/36 of ROOT in window.

Many Thanks,

Hi Ryan,

the error may be pointing to some kind of file corruption.
For what concerns the code, this line is ill formed:

there seems to be a typo (“iGetEntries()”)


1 Like

That was just due to the missing formatting; the forum filtered the “HTML tag” <mini->


1 Like

Most likely the variable type and the TTree content do not match what is the result of

1 Like

Thank you for pointing out the issue .My problem is that the variables I want to extract from the Tree file are in float type. If I want to calculate the invariant mass, I have to use the TLorentzVector class but the class requires double_t variables as input. So how can you solve that? Is it possible to convert from float to double type?


compilers do that automatically.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.