I had been using this macro to dump information from root files into a TTree. Suddenly when I increased the number of branches, I get this error:
Error in <TRint::HandleTermInput()>: std::out_of_range caught: vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
I have never seen this error before and my guess is that I need to allocate memory or increase the size of my vector, but I don’t know how to do that.
I have attached the root macro.
I’d appreciate any help. Please let me know if you need any more info.
demo_ReadEvent.C (10.9 KB)
In your macro, you unconditionally access pointers without prior checking that they are not null (e.g. in
mctrack_vec(*mctrack_handle) you do not check “mctrack_handle”).
You also unconditionally access vector elements without prior checking that its size is big enough (e.g. in
a.at(0).X() in you do not check that
a.size() > 0).
You can easily “reproduce” your error:
root  std::vector<double> v;
root  std::cout << v.size() << std::endl;
root  std::cout << v.at(0) << std::endl;
Thank you @Wile_E_Coyote. Indeed for many cases I found that a.size()==0 which causes this error. Now I simply used an IF condition to skip over a.size()==0 events.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.