Hello Everyone!
I am trying to plot 2-D histogram for contour making at 1,2 and 3 sigma confidence level.
I am reading data from a .dat file with three columns and i want plot it as a contour at above mentioned confidence levels . Please suggest me how to set 1,2 and 3 sigma confidence levels in my code…
‘’’ #include
#include<math.h> #include <TVirtualFitter.h> #include <TF2.h>
void rootContourPlot()
{
ifstream f1;
TCanvas *c1 = new TCanvas(“c1”,“c1”,600,400);
TH2F *hcont2 = new TH2F(“hcont2”," ",40,-4,-2,40,0,200);
Double_t x[10001]={0.}, y[10001]={0.},z[10001]={0.}, i,j,k;
int ss=0;
The method TVirtualFitter::GetFitter())->GetConfidenceIntervals(hcont2, 0.95) computes the confidence level of your model (fitting) function after having it fitted to an histogram.
I don’t see in your code where you have performed the fit.
If you have an histogram and you want to plot the contour lines, you just need to do hcont2->Draw(“CONT2”)
Hello Thank you for your reply… I have a file with three columns and want to see how z varies with x and y at 1, 2 and 3 sigma levels, i am not getting what function should i use to plot this… A 3D graph or 2DProfile histogram, I want to see only x and y axes… I have made it using Gnuplot but not able to make it from ROOT
.example1.pdf (9.3 KB)
Then what you need to use is hcont2->Draw(“CONT1”). You can set the contour and their level with hcont2->SetContours(n, levels), where n is the number of contours you want and levels are the z values for which you want to draw the contour.
I understood the meaning of your first two lines now… yes I havnt implemented any fitting function…
I performed simply - hcont2->Draw(“CONT2”) but this is not my desired result… i have attached : rootcontour.pdf (36.1 KB)
I want to know how does root calculates confidence levels at 1,2 and 3 sigma values…
For one data file I am getting a plot using the code below but for another data file I am not getting a proper contour plot while both these files are giving contour plots with gnuplot… I am not able to get this…
I am using the code below…
Also I have one more doubt about contour plots… What i know is- If we have three columns x,y,z then we fix a particular value of z=confidence level and plot corresponding x and y… am I correct ?
Please help me out
Thank you…
#include<iostream>
#include<math.h>
#include <TVirtualFitter.h>
#include <TF2.h>
void rootContourPlot()
{
ifstream f1;
TCanvas *c1 = new TCanvas("c1","c1",600,400);
TH2F *hcont2 = new TH2F("hcont2"," ",40,0,360,40,0,0.9);
Double_t x[10001]={0.}, y[10001]={0.},z[10001]={0.},i,j,k;
int ss=0;
double contours[3];
contours[0] = 2.3;
contours[1] = 6.2;
contours[2] = 11.8;
f1.open("test12.dat");
while(!f1.eof())
{
f1>>i>>j>>k;
hcont2->Fill(i,j,k);
}
hcont2->SetContour(3,contours);
hcont2->Draw("CONT1");
// (new TMarker(-3., 90., 30))->Draw(); // Makes the best fit point
c1->Update();
f1.close();
}
In case of test1.dat you are filling the histogram outside its limits. SO all the Fill() you do generate underflow or overflow and the histogram is empty.