To get Area included in a TCutG object

Hi ROOTers,

I created via the graphics editor a TCutG object, “backg1”,
now I need to get the area of a closed region included in this object.

I saved the cut as text file
then I run this script as a macro and after I tryed to use
in order to obtain the area
root [1] TCutG *cutg = new TCutG(“backg1”,13);
root [2] cutg->SetVarX(“tofp”);
root [3] cutg->SetVarY(“enep”);
root [4] cutg->SetTitle(“Graph”);
root [5] cutg->SetFillColor(1);
root [6] cutg->SetPoint(0,1494.9,1104.17);
root [7] cutg->SetPoint(1,1400.72,1243.06);
root [8] cutg->SetPoint(2,1327.95,1266.2);
root [9] cutg->SetPoint(3,1289.42,1150.46);
root [10] cutg->SetPoint(4,1308.68,953.704);
root [11] cutg->SetPoint(5,1421.07,739.665);
root [12] cutg->SetPoint(6,1469.27,695.374);
root [13] cutg->SetPoint(7,1527.01,652.778);
root [14] cutg->SetPoint(8,1589.08,693.287);
root [15] cutg->SetPoint(9,1619.05,785.222);
root [16] cutg->SetPoint(10,1583.45,934.547);
root [17] cutg->SetPoint(11,1541.99,1023.15);
root [18] cutg->SetPoint(12,1494.9,1104.17);
root [19] cutg->Draw("");
root [20] cutg->Area();
Error: Can’t call TCutG::Area() in current scope (tmpfile):1:
Possible candidates are…
(in TCutG)
(in TGraph)
*** Interpreter error recovered ***

but it doesn’t work…

My question is: does it possible to get the area using the ROOT version 5.18 ???

Thanks and regards


TCutG::Area was introduced only in v5.27. In v5.18, you are going to have to calculate it externally for example by using this function:Double_t TCutG__Area(TCutG *cut) const { // Compute the area inside this TCutG // The algorithm uses Stoke's theorem over the border of the closed polygon. // Just as a reminder: Stoke's theorem reduces a surface integral // to a line integral over the border of the surface integral. Double_t a = 0; Int_t n = cut->GetN(); for (Int_t i=0;i<n-1;i++) { a += (cut->GetX()[i]-cut->GetX[i+1])*(cut->GetY[i]+cut->GetY[i+1]); } a *= 0.5; return a; }


Hi Philippe,
you have cleared up my doubts about the different version.

Many thanks for your answer and suggestion :smiley: