Saving TCutg of 2D histograms

Please I need help. I have a 2D histograms already fill and save in a root file. I opened it and create a Tcutg of area 20,2500 on both X and Y. I can do the X and Y projection of the cutg area and draw it in 1D histogram. But I want to draw the 2D histogram of the cutg area alone and also save it in a rootfile.

In the documentation for TCutg, there is an example of using it inside a TTree::Draw(), like this:

TCutG *mycutg;
mycutg = (TCutG*)gROOT->GetListOfSpecials()->FindObject("CUTG");

tree.Draw("x:y","mycutg && z>0 && sqrt(x)>1");

Maybe you can try a similar approach to draw your 2D histogram. I’m not sure how you are applying this cut, but if it’s directly on the entries that filled the 2D histogram and not on the final result, then it may not be possible to recover information from the saved histogram alone.

If you have a 2D histogram h2 you can apply a TCutg on it:


Thanks so much for helping.
The 2D is fill from raw data not tree. I was able to draw using all your suggestion. I want to save the cutg area in a new rootfile so that I can subtract it from another different 2D.


Thanks so much.
How can I save the h2 mycutg area in a new 2D say h3 to a rootfile.

I am afraid this option is purely graphics.

thanks so much. I have another question. I have for instance 2D h2 with bin 0-1000 and I want to save it another 2D say h3 but only want bin content 0-850.
Second question plz I have h2 and h3 both 2D with bin 0-1000, how can I subtract only 0-800 bin content of of h2 from h3.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.