Counting the number of entries in a TCutG

Hi, I am having issues with getting the number of entries within a graphical cut. The histogram I am looking at is within a directory in the root file, that is the reason for cd’ing into a directory at the beginning. My cut does not seem to report the number of counts within the cut region, but rather the total number of entries in the entire histogram. All of the tutorials I’ve seen online have done this automatically, so I’m not sure what I’m missing.

void alpha_cut()
    //open the file and cd into the directory where the tof vs energy histogram is
    TFile *sfile = TFile::Open("run2241_raw_histograms.root");

    //get the tof vs energy histogram
    TH2F *tof = (TH2F*)gDirectory->Get("h_tof_e");

    //define the cut we want
    TCutG *cutg = new TCutG("ilikeurcutg",5);

    //draw the plot and the cut region

and here is the output of running this macro in root,

ROOT Version: 6.24.06
Platform: Linux
Compiler: Not Provided


Did you really set VarX to a root file? what does that mean ?

In any case, according to your plot, your cut is a square containing all the histogram data.

The portion of the code where the cut is done is something I just copied and pasted after creating a cut in the TBrowser and generating the .C file. Also I should have mentioned that the number of entries listed in the legend is the number of entries in the entire histogram, not just in my cut. I want the number of entries just within the cut.

I’ve figured out a way to print out the number of counts in the region (~3000), but I was just wondering if there was a way for that to show up graphically.

Ok, can you post the data so we can run your code and see what’s wrong ?