Problem using vector in Filter()

Hello, everyone!
I have a problem while using the Filter() function in rdataframe.
I want to use a vector in Filter() to compare. It can not work:

*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================

But there is no problem without vector, such as Filter_hit().
I put Filter() in a separate user-defined function because I want to call this function multiple times later.
Here are the .cpp file and data file:
coincidence_2F_test.cpp (1.3 KB)
20221011_4_fixed.root (117.8 KB)

Thanks for your help.
Best,
Chenyao

ROOT Version: 6.24/02

Hi @CY_Han ,

thank you for the reproducer. In general in case of a segfault my recommendation would be to:

  1. compile the program with debug symbols (either by adding the appropriate #include and a main function and compiling it as g++ -o program program.cpp $(root-config --libs --cflags) or by running it as root.exe program.cpp+g (note the .exe and the +g – this will also require adding some #includes)
  2. run the program under a debugger, which will tell you exactly what the state of the program was at the point of the crash, which usually shows what the problem is (e.g. gdb ./program or gdb --args root.exe -l -b -q program.cpp+g)

Here is a compilable version of your original macro:
coincidence_2F_test.cpp (1.4 KB)

Running it as gdb ./coincidence_2F_test.cpp I can reproduce the segfault (as you see from the message at the top of the following figure) and printing a couple of variable contents shows that the problem is that you are accessing the 6th element of a vector with size 0 (see the bottom of the figure):

I hope this helps!
Enrico

Thanks for your suggestions!@eguiraud
There is a problem with other parts of my code, which has nothing to do with rdataframe.