Extracting contour from a contour plot and fitting it

Hi guys,

I was wondering whether or not it is possible to extract a particular contour from a contour plot in order to perform a straight line one dimensional fit. Attached is the very simple code I have so far just to create a basic contour plot with the attached data.
What I am trying to do is extract the 0.95 contour and fit it with a straight line between say 7 km and 16 km.

Is it possible to do this? I’ve had a good look around the forums and can’t seem to find a solution.

Thanks for any help!

[code]{

gROOT->Reset();
gROOT->SetStyle(“Modern”);
gStyle->SetPalette(1);
//gStyle->SetOptFit(1);
gStyle->SetFitFormat(“5.2g”);
gStyle->SetStatFormat(“7.4g”);

gStyle->SetOptStat(1110);
//gStyle->SetOptStat(0);

gStyle->SetTitleSize(0.035,“XYZ”);
gStyle->SetLabelSize(0.035,“XYZ”);
gStyle->SetTitleOffset(1.4,“XYZ”);

gStyle->SetFuncWidth(2);
gStyle->SetFuncColor(1);
gStyle->SetFuncStyle(1);
gStyle->SetTitleBorderSize(0);
gStyle->SetTitleX(0.05);
gStyle->SetTitleY(1);

TGraph2D * contGraph = new TGraph2D(180);

ifstream in(“coreDistZenith120degPhiCoreCut70degPhiRangewithTrigger10sigma.dat”,ios::in);

if(!in) {
cerr << “bad” << endl;
return;
}

Float_t a,b,c;
int i=0;

while (!in.eof()) {
in >> a >> b >> c;
contGraph->SetPoint(i,a/1000,log10(b),c);
i++;
}
in.close();

TCanvas* canvas2 = new TCanvas(“canvas2”,“Canvas2”,0,0,800,600);
//canvas2->SetGrid();
contGraph->GetXaxis()->SetTitle(“Core distance [km]”);
contGraph->GetYaxis()->SetTitle(“log10( Energy [eV] )”);
contGraph->SetTitle();
contGraph->Draw(“CONT4Z”);

}[/code]

coreDistZenith120degPhiCoreCut70degPhiRangewithTrigger10sigma.dat (13.2 KB)

The LIST histograms’ plotting option
[url=https://root-forum.cern.ch/t/histogram-contours-hide-grid-if-drawn-with-same/14112/1 contours hide grid if drawn with “SAME”[/url]
TGraph2D::GetContourList

Fantastic! That worked perfectly, thankyou.