I would like to use TTree::SetBranchAddress with the attached ROOT file. The attached ROOT file contains a tree with the following branches:
root [0] TFile *f1 = new TFile("trial.root","READ")
root [1] f1->ls()
TFile** trial.root
TFile* trial.root
KEY: TTree t;1 reduced Tree
root [2] t->Print()
******************************************************************************
*Tree :t : reduced Tree *
*Entries : 1148 : Total = 906244 bytes File Size = 137216 *
* : : Tree compression factor = 6.63 *
******************************************************************************
*Br 0 : energy_DSSD_low : E_DSSD_low[2][16]/I *
*Entries : 1148 : Total Size= 147888 bytes File Size = 12840 *
*Baskets : 5 : Basket Size= 32000 bytes Compression= 11.48 *
*............................................................................*
*Br 1 : time_DSSD_low : t_DSSD_low[2][16]/D *
*Entries : 1148 : Total Size= 295285 bytes File Size = 23480 *
*Baskets : 10 : Basket Size= 32000 bytes Compression= 12.55 *
*............................................................................*
*Br 2 :multiplicity_DSSD_low : multiplicity_DSSD_low[2]/I *
*Entries : 1148 : Total Size= 9813 bytes File Size = 1165 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 7.96 *
*............................................................................*
*Br 3 :energy_DSSD_high : E_DSSD_high[2][16]/I *
*Entries : 1148 : Total Size= 147861 bytes File Size = 34473 *
*Baskets : 5 : Basket Size= 32000 bytes Compression= 4.27 *
*............................................................................*
*Br 4 :time_DSSD_high : t_DSSD_high[2][16]/D *
*Entries : 1148 : Total Size= 295211 bytes File Size = 62520 *
*Baskets : 10 : Basket Size= 32000 bytes Compression= 4.71 *
*............................................................................*
*Br 5 :multiplicity_DSSD_high : multiplicity_DSSD_high[2]/I *
*Entries : 1148 : Total Size= 9818 bytes File Size = 1600 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.79 *
*............................................................................*
I can use TTree::SetBranchAddress for all branches except energy_DSSD_low and time_DSSD_low. For example, if I try
#include "TFile.h"
#include "TTree.h"
void showError(){
TFile *fIn = new TFile("trial.root","READ");
TTree *t = (TTree*) fIn->Get("t");
int energyDSSD_low[2][16] = {{0}};
double timeDSSD_low[2][16] = {{0.0}};
int multiplicityDSSD_low[2] = {0};
int energyDSSD_high[2][16] = {{0}};
double timeDSSD_high[2][16] = {{0.0}};
int multiplicityDSSD_high[2] = {0};
int nEntries = t->GetEntries();
for (int i=0; i<nEntries; i++){
t->SetBranchAddress("energy_DSSD_low", &energyDSSD_low);
t->SetBranchAddress("time_DSSD_low", &timeDSSD_low);
t->SetBranchAddress("multiplicity_DSSD_low", &multiplicityDSSD_low);
t->SetBranchAddress("energy_DSSD_high", &energyDSSD_high);
t->SetBranchAddress("time_DSSD_high", &timeDSSD_high);
t->SetBranchAddress("multiplicity_DSSD_high", &multiplicityDSSD_high);
}
}
then I get
Error in <TTree::SetBranchAddress>: unknown branch -> energy_DSSD_low
Error in <TTree::SetBranchAddress>: unknown branch -> time_DSSD_low
If I try TTree::GetListOfBranches()->FindObject() for energy_DSSD_low or time_DSSD_low, null is returned. If I try TTree::GetBranchStatus() for energy_DSSD_low or time_DSSD_low, 0 is returned. Why then can I draw from these branches to make a histogram?
root [0] TFile *f1 = new TFile("trial.root")
root [1] t->GetListOfBranches()->FindObject("energy_DSSD_low")
(const class TObject*)0x0
root [2] t->GetListOfBranches()->FindObject("time_DSSD_low")
(const class TObject*)0x0
root [3] t->GetBranchStatus("energy_DSSD_low")
(const Bool_t)0
root [4] t->GetBranchStatus("time_DSSD_low")
(const Bool_t)0
root [5] t->Draw("E_DSSD_low[1][8]>>h1(30000,1,30001)","","")
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
(Long64_t)1148
These two branches are created in the same way as all the other branches, so I do not understand why these two branches are causing trouble. If anyone has any ideas about what is happening or how to proceed from here, that would be greatly appreciated. Thanks
trial.root (139 KB)