Read from TTree


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hello,

I am trying to read a tree containing Float_t and Char_t branches. Here is a small eaxample:

void analysis_test(){
TFile *file = new TFile(“PhaseSpaceActor1_noshield.root”);
TTree tree = (TTree)file->Get(“PhaseSpace”);

    Float_t Ekine;
    Char_t ParticleName;
    tree->SetBranchAddress("ParticleName",&ParticleName);
    tree->SetBranchAddress("Ekine",&Ekine);

    tree->GetEntry(1);
    tree->Show(1);

    cout << ParticleName << endl;
    cout << E << endl;

}

When setting the branch adress for both Ekine and ParticleName, the value for Ekine gets overwritten:
ParticleName = g
Ekine = 2.73735e+20
When reading only Ekine, the real value Ekine = 0.866 is stored in Ekine.

What could I do to solve this problem?

Thank you! It does work now😊

ptw_logo.jpg

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