ROOT Version: 6.20/06
Platform: Linux
Compiler: ROOT macro
I’ve been having an issue with reading a .root ntuple into a TChain. I had been using a TFile to get a TTree, like this:
TFile* file = new TFile();
file = TFile::Open(filename);
TTree* originalTree = (TTree*)file->Get(TString::Format("%s", tree.c_str()));
where “tree” is a variable passed into the code. This worked fine, but I wanted to change this to using a TChain to be able to handle adding multiple files. However, using the new line:
TChain* originalTree = new TChain(tree.c_str());
originalTree->Add("filename");
I add the branch with:
originalTree->SetBranchAddress("failJvt_jet_isTrueHS",&failJvt_jet_isTrueHS);
and I build an index to match events with truth; this eventNumber is how I know I’m looking at the same events for me to see the error. I now find that the length of one of my variables, a vector, is now 0 for a specific event where I can see there is an instance (ie, size() = 1).
* Row * Instance * eventNumb * jet_isTru * failJvt_j * failJvt_j *
***********************************************************************
* 111 * 0 * 124382 * * 0 * 23580.431 *
***********************************************************************
There should be the ‘0’ returned when I call (int) failJvt_jet_isTrueHS->at(i) for i=0, but instead I get a range error:
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
Is there a reason TChain would be dropping this event? Am I adding the files incorrectly? I’ve used TChain before with this method and never had an issue, so I’m somewhat confused. Any advice would be greatly appreciated.