Making a Cut when Projecting a TNtuple?

I have a TNtuple with columns “x” and “y”. I’d like to plot this on a 2D histogram, with “x” on the horizontal axis, and “y” on the vertical axis, using the “colz” option. I understand this is done with the syntax:


Now, I’d like to make a cut, plotting only x and y values under a certain threshold. What would be the syntax for this?

Also, I’d like to save this TNtuple to a ROOT file, then read it back and use the interpreter to project it on a histogram. What would be the syntax for doing so? The ROOT documentation is a bit vague on this.

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


For the drawing part, I’m asking @couet to provide an answer when he is back from vacation.

Regarding writing the TNtuple to a ROOT file, here’s one tutorial:

and here’s another one to read it back and fill a histogram with its contents:

I would also like to mention RDataFrame as a more high-level option to write and read ROOT data. If you are interested, you can have a look at its docs:
and tutorials: