Issues reading a single value in a Branch

Hi, I’m having an issue when trying to read a single values of a branch in my TTree.
Here is a snippet of my root interpreter where a is my TTree :

a->GetEntry(1125103);
a->Show()
======> EVENT:1125103
 batch_index     = 18
 iteration       = 1195
 iteration_weight = 2.19721e-07

I want to get the iteration_weight value for that event, proceeding as follow :

Double_t iteration_weight;
a->SetBranchAddress("iteration_weight",&iteration_weight);
a->GetEntry(1125103);
iteration_weight

the interpreter return the value “0.000” .
I don’t really know where is the error, did I badly defined ‘iteration_weight’ ? Though ‘iteration_weight’ is declare as a Branch of Double_t values when I look with a->Print().

I’ve tried some different options but I always get the outcome :

(double) 0.000000

How could I get the real value i.e. 2.19721e-07 ?

Thanks, sincerely,

Pierre.

That should work as you describe. Could you post your complete macro?

TFile *_file0 = TFile::Open("benchmark_nuclei_detailed.root")
Double_t iteration_weight;
TTreeReader reader("mas", _file0); //mas is the TTree
TTreeReaderValue<Double_t> my_branch_value(reader, "iteration_weight");
reader.SetEntry(1125103)
*my_branch_value

I’m not using a macro, I’m writing directly in the root interpreter (Cling by default?)

Sorry I tried two options, this was the first one :

TFile *_file0 = TFile::Open("benchmark_nuclei_detailed.root")
TTree* a=(TTree*)_file0->Get("mas")
double iteration_weight;
a->SetBranchAddress("iteration_weight",&iteration_weight);
a->GetEntry(1125103);
iteration_weight

With the same outcome …

I solved it, I missed to import a shared library.