Reading Tree failed using TTreeReader

It is in the same path. Please look at README to see how to run. you can produce the problem in few second. ~yelghaza/public/Forward_Electron_Identification

I still don’t understand. I have no issues processing your

~yelghaza/public/Forward_Electron_Identification/single_par10Gev_2000evnt.root

with this piece of code of yours:

void yassine3(){

        TTreeReader *p_R;
        TTreeReaderArray<Float_t> *p_C_eta;

        TChain* ch1 = new TChain("TRKTree");
        ch1->Add("~yelghaza/public/Forward_Electron_Identification/single_par10Gev_2000evnt.root");
        TTreeReader R(ch1); p_R=&R;

        TTreeReaderArray<Float_t>C_eta(R,"cluster_Eta"); p_C_eta=&C_eta;
        while (R.Next()==1){ cout<<" Processing event: " <<p_R->GetCurrentEntry()<< "----"<<endl;
                for (int i=0; i<p_C_eta->GetSize(); i++){
                        cout<<"\tCluser eta: "<<p_C_eta->At(i)<<endl;
                }
        }
}

Or you are asking why you can’t process it with

~yelghaza/public/Forward_Electron_Identification/FwdElectronIdentification.cxx

?

Yes exactly I want to run `FwdElectronIdentification.cxx’

Oh why didn’t you say so.

Anyhow, I figured it out. In line 69 of your program

float deta = p_C_eta->At(cluster)-p_I_eta->At(cluster);

you access the element number cluster of both p_C_eta and p_I_eta arrays. For the first array, this is indeed legit since you can’t go outside of the array dimension (this happens in the loop over elements of that particular array). But for the second array, you go outside of the array dimension as this array in that particular entry #4 is empty. But you try to access pseudorapidity value of track #0 anyway, which does not exist in this event. In other words, the dimensions of p_C_eta and p_I_eta are different (I take it the first one is for clusters and the second one is for tracks), and you have to be careful to not access their non-existing elements.

Thanks a lot that was helpful

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