Error in <TRint::HandleTermInput()>: std::out_of_range caught: vector


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 and posting code

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 (48.4 KB)

i tried this and

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

and i got this output

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

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:

    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

thanks alot!! its working now