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:

N->Draw("x:y","colz");

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


Hi,

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:
https://root.cern/doc/master/basic_8C.html

and here’s another one to read it back and fill a histogram with its contents:
https://root.cern/doc/master/hsimpleReader_8C.html

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:
https://root.cern/doc/master/classROOT_1_1RDataFrame.html
and tutorials:
https://root.cern/doc/master/group__tutorial__dataframe.html