Getting value from the leaf


Please read tips for efficient and successful posting and posting code

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


Hello everyone, I am trying to get nDigiHF value from the hcalnano_calib.root, It’s a leaf.

    TFile  *input = new TFile("hcalnano_calib.root","read"); //Root binary file that includes events
    TTree *tree = (TTree*)input->Get("Events"); //Reads file and gets events

    double nDigiHF;
    float DigiHF_fc0,DigiHF_fc1,DigiHF_fc2;
    tree->SetBranchAddress("nDigiHF",&nDigiHF);
    tree->SetBranchAddress("DigiHF_fc0",&DigiHF_fc0);
    tree->SetBranchAddress("DigiHF_fc1",&DigiHF_fc1);
    tree->SetBranchAddress("DigiHF_fc2",&DigiHF_fc2);

    int entries = tree->GetEntries();
    cout << entries << endl;
    for(Int_t i = 1; i<=entries; i++)
    {
        tree->GetEntry(i);
        cout << i << " : " << nDigiHF(i) << endl;
    }

There is just 2 entries, I want to see each of them so I can do calculation with it but I am getting an error.

ts_vs_fc.C:62:31: error: called object type 'double' is not a function or function pointer
        cout << i << " : " << nDigiHF(i) << endl;

Could someone help me with this problem that I have ? Thanks in advance

        cout << i << " : " << nDigiHF << endl;

I tried that while trying to solve the problem, getting this error.

Error in <TTree::SetBranchAddress>: The pointer type given "Double_t" (8) does not correspond to the type needed "Int_t" (3) by the branch: nDigiHF
2

 *** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)

So, correct that, the error message is clear, use Int_t for that one.

Yess, this time I get the value that I want but with an error.

ERROR leaf:DigiHF_pedestalfc0, len=1097541098 and max=3456
ERROR leaf:DigiHF_ok0, len=1097541098 and max=3456
ERROR leaf:DigiHF_fc1, len=1097541098 and max=3456
ERROR leaf:DigiHF_pedestalfc1, len=1097518483 and max=3456
ERROR leaf:DigiHF_ok1, len=1097518483 and max=3456
ERROR leaf:DigiHF_fc2, len=1097518483 and max=3456
ERROR leaf:DigiHF_pedestalfc2, len=1099908152 and max=3456
ERROR leaf:DigiHF_ok2, len=1099908152 and max=3456

 *** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)