# Error in \<TRint::HandleTermInput()\>: std::out\_of\_range caught: vector

**URL:** <https://root-forum.cern.ch/t/error-in-trint-handleterminput-std-out-of-range-caught-vector/42229>\
**Category:** Newbie\
**Created:** [November 11, 2020, 9:27am UTC](https://root-forum.cern.ch/t/error-in-trint-handleterminput-std-out-of-range-caught-vector/42229 "2020-11-11T09:27:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![odylalalaaa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/odylalalaaa/32/16600_2.png) [@odylalalaaa](https://root-forum.cern.ch/u/odylalalaaa)\
**Post date:** [November 11, 2020, 9:27am UTC](https://root-forum.cern.ch/t/error-in-trint-handleterminput-std-out-of-range-caught-vector/42229/1 "2020-11-11T09:27:39Z")

</div>

* * *

hi, im trying to da a HZZ4L exercise with delphes tree and came upon this error  
since it does not show which line is the problem, im not quite sure where i should fix

attached is my macro file, thanks!

_Please read [tips for efficient and successful posting](https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292) and [posting code](https://root-forum.cern.ch/t/posting-code-read-this-first/28293)_

_ROOT Version:_ 6.22  
_Platform:_ mac osx catalina 15.15.7  
_Compiler:_ Apple clang version 11.0.3 (clang-1103.0.32.29)

* * *

[Audiya4lAnalyzer.C](https://root-forum.cern.ch/uploads/short-url/f7C6OPDVCs37tWdcICItbNLyIcW.C) (48.4 KB)

---

<div class="post-metadata">

**Author:** ![odylalalaaa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/odylalalaaa/32/16600_2.png) [@odylalalaaa](https://root-forum.cern.ch/u/odylalalaaa)\
**Post date:** [November 11, 2020, 9:58am UTC](https://root-forum.cern.ch/t/error-in-trint-handleterminput-std-out-of-range-caught-vector/42229/2 "2020-11-11T09:58:30Z")

</div>

i tried this and

```auto
std::cout << "debug" << muons->size() << " " << electrons->size() << std::endl;

```

and i got this output

```auto
Reading Event 0
debug0 2
debug0 2
debug0 2
debug0 2
debug0 1
Error in <TRint::HandleTermInput()>: std::out_of_range caught: vector

```

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [November 11, 2020, 10:39am UTC](https://root-forum.cern.ch/t/error-in-trint-handleterminput-std-out-of-range-caught-vector/42229/3 "2020-11-11T10:39:33Z")

</div>

Hi,  
you can run your program within `gdb` to quickly check what line throws the exception.

Given that the exception is typically thrown by `std::vector::at`, I quickly checked your code for such calls and I found this:

```cpp
    if(electrons->size() >= 2) continue;
    {
        //define leading and subleading leptons
        elec1 = electrons->at(0);
        elec2 = electrons->at(1);

```

That spurious `continue;` in the first line makes it so that the code below is executed every time `electrons->size()` is _not_ greater than 1. I guess that’s the bug?

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![odylalalaaa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/odylalalaaa/32/16600_2.png) [@odylalalaaa](https://root-forum.cern.ch/u/odylalalaaa)\
**Post date:** [November 11, 2020, 11:31am UTC](https://root-forum.cern.ch/t/error-in-trint-handleterminput-std-out-of-range-caught-vector/42229/4 "2020-11-11T11:31:29Z")

</div>

thanks alot!! its working now
