Easy way to Draw TCutG on TH2F in same canvas and write it?


ROOT Version ( 5.34/01 13/07/12):
Platform, compiler ( linuxx8664gcc):


Hello everyone. Im trying to display both a TH2F and a TCutG on the same TCanvas (i have both of them written inside a TFile but without TTree(s) ) and i would like to write them inside this file as TH2F.

I dont know if this is possible to use the Fill method to get such a result… (im getting started with ROOT since a couple of week)

Thank you for your help !

When you draw the histogram specify the name of the cut between “[]”: Example:

h2->Draw("COL [cutg]");

and how to write it in the file ?

edit : i tried what you suggested but it just draw the part of TH2F inside the cut, i want to draw my entire TH2F and the TCutG on it (so you can see the selected area on it)

You said that your histogram and your cut are already stored in a root file … You do not really need to store something else. Just draw the histogram with the option I mentioned earlier.

I do need… I have like 150 TH2F to check with different TCutG available, so if i have all of them stored in 1 file, i just have to clic on it and watch is everything is okay

At filling time you can use the function IsInside from TCutG and fill the histogram only if the (x,y) coordinates you pass to Fill are inside the polygon defined by the cut.

i know it already but i want draw the shape of my TCtuG, you know, having the shape on my entire TH2F and not cut it.

Ah ok. Add it in the list of functions of the histogram in that case.

h->GetListOfFunctions()->Add(cutg,"L");

thank you very much !

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