Error with TTree

Hello all,

i am using a TTree called output. I also have some TH1D declared earlier in the code:

TH1D *DirTheta_resto = new TH1D("DirTheta_resto","Theta Distribution;Theta [deg]; # events", 180, 0,180.);

Later I used SetBranchAddress as follows:

    TString* reactores;
    double px_neutrao_r;
    double py_neutrao_r;
    double pz_neutrao_r;

and finally i iterated over the ttree:

for(int i = 0; i<nentries; i++) // iterar sobre a TTree
    cout << SEPARATOR << "\naddress " << 4+i << " before = " << DirTheta_resto << endl;


    cout << "\naddress " << 4+i << " after = " << DirTheta_resto << endl;


The program crashes when i try to fill the TH1D, and the output for those prints is:

address 4 before = 0x7fa397ad9990

address 4 after = 0x0

ENTRY 0: reactor = BRUCE 4; px = 3.54902; py = 5.53718; pz = 4.0301

Can anyone help me? Why is the function GetEntry wiping the pointer to my histogram?

Thank you


The TTree reads into memory that you don’t expect it to write into. That’s very likely because the SetBranchAddress isn’t doing what you expect it to do, which in turn is likely caused by the TTree having different branch types than you expect. Can you post the output of output->Print()?

Cheers, Axel.

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