Draw the same histogram, only filtered

ROOT Version: 6.26.10
Platform: Windows


Hi everyone!

I was wondering if there is a possible way to draw a histogram that you already created, only filtered.

More particularly, I used the ProjectionX function to create a projection of a 2-dimensional histogram:

hist_projection = hist.ProjectionX(projection_name, start_y_bin, end_y_bin)\

Now I am wondering if there is a way to create the projection but only for the results that satisfy some condition “QEL==True”, without “filtering” the result before the projection function.

I’m using PyRoot.

Thank you in advance!
K

Hello @Kirill_Sm,

I’m not sure if you can filter an already-created histogram (maybe @couet knows more about this).

If you are able to use RDataFrame to produce the histogram, you can achieve what you want very easily by defining a new column and filtering it through your condition. This is a non-destructive operation that preserves the other column and would allow you to plot both the 2d histo (if needed) and the filtered projected version.