Hello,
I’m currently trying to use a TTreeReaderArray with a TChain. The branch I’m examining (called time_truth) is a variable size array. However, I get an error (I think it results when I declare the TTreeReaderArray) because the branch that the array’s size is linked to has elements of type long.
Here’s my code:
TChain *ch = new TChain("events/events");
TChain *fax_truth = new TChain("fax_truth_sort");
// chain files
TH2D *h = new TH2D("h","Fax_truth vs Fax_t", 350, -500, 3000, 7000, 0, 7000);
TTreeReader r1(ch);
TTreeReaderValue<vector<float>> Fax_t(r1, "Fax_t");
TTreeReader r2(fax_truth);
TTreeReaderArray<double> Fax_truth(r2, "time_truth"); // error occurs here
//TTreeReaderValue<long> pl(r2, "peaks_length");
while(r1.Next() && r2.Next()){
vector<float> fax_t_data = *Fax_t;
for(int i = 0; i < fax_t_data.size(); i++){
if(Fax_truth.GetSize() == 4){
Double_t s1_dt = Fax_truth[2] - Fax_truth[0];
int bin = h->GetBin(s1_dt, fax_t_data.at(i));
h->AddBinContent(bin);
}
}
}
This branch that the size of time_truth is linked to is called peaks_length. Here’s the error I get:
Error in <CreateProxy()>: The branch peaks_length contains data of type long long. It cannot be accessed by a TTreeReaderValue<int>
I’m not sure why ROOT is giving me this error. I’ve changed the type of Fax_truth to Double_t but I get the same error. I appreciate any feedback! Thanks!