I have a “leaf” in the tree tau_N of int type, and array tau_a[tau_N] of floats. So the dimension of tau_a[tau_N] varies (in my case between 0 and 6). I’m tring to acces the values stored in tau_a[tau_N].
Example of what i tried:
#include <iostream>
#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TFile.h>
#include <TTree.h>
#include <TH1F.h>
#include <TBranch.h>
#endif
TFile *f;
TTree *myTree;
Int_t t, N, A;
Int_t a[10]; //this can be the problem
void ReadFile(){
f=TFile::Open("some_file.root");
}
void SumE(){
myTree = (TTree*)f->Get("Cn/t1000");
TBranch *Brt=myTree->GetBranch("tau_N"); // this works
Brt->SetAddress(&t);
TBranch *Bracc = myTree->GetBranch("tau_a"); // may be those two lines are wrong ?
Bracc->SetAddress(a);
N= myTree->GetEntries();
for (Int_t i=0;i<N;i++) {
myTree->GetEntry(i);
A=0;
for (int j=0;j<t;j++) {
if (a[j]) {A++;} // counting how many values of the array a are non zero
}
cout << A << " , " << endl;
}
}
thanks for any help, asen.
PS: I’m not very skilled in C++ so pls. some simple solutions