hi dear friends;
please when i try to evaluate my output by Chi2Test in root; i have this problems:
// Example to use chi2 test for comparing two histograms
// One unweighted histogram is compared with a weighted histogram.
// The normalized residuals are retrieved and plotted in a simple graph.
// The QQ plot of the normalized residual using the
// normal distribution is also plotted.
//
//Authors: Nikolai Gagunashvili, Daniel Haertl, Lorenzo Moneta
#include "TH1.h"
#include "TH1D.h"
#include "TF1.h"
#include "TGraph.h"
#include "TGraphQQ.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TMath.h"
TCanvas * chi2testtt()
{
// Note: The parameter w is used to produce the 2 pictures in
// the TH1::Chi2Test method. The 1st picture is produced with
// w=0 and the 2nd with w=17 (see TH1::Chi2Test() help).
// Define Histograms.
const Int_t n = 200;
TFile* file1= new TFile("tung20.root","READ");
TFile* file= new TFile("specto10.root","READ");
TH1D*h1=(TH1D*) file1->Get("energySpectrumFluenceTrack");
TH1D*h2=(TH1D*) file->Get("energySpectrumFluenceTrack");
double a[h1->GetNbinsX()], y[h1->GetNbinsX()];
for(int i=0;i<200;i++){
a[i]=h1->GetBinCenter(i+1);
y[i]=h1->GetBinContent(i+1);
h1->SetBinContent(i+1,(h1->GetBinContent(i+1)/150000));
}
double e[h2->GetNbinsX()], b[h2->GetNbinsX()];
for(int i=0;i<200;i++){
e[i]=h2->GetBinCenter(i+1);
b[i]=h2->GetBinContent(i+1);
h2->SetBinContent(i+1,(h2->GetBinContent(i+1)/535000));
}
h1->SetEntries(302836);
h2->SetEntries(302836);
//apply the chi2 test and retrieve the residuals
Double_t res[n], x[200];
h1->Chi2Test(h2,"UW P",res);
//Graph for Residuals
for (Int_t i=0; i<n; i++) x[i]= 0.01 +i*0.053/200.+0.053/400.;
TGraph *resgr = new TGraph(n,x,res);
resgr->GetXaxis()->SetRangeUser(0.01,0.1);
resgr->GetYaxis()->SetRangeUser(-3.5,3.5);
resgr->GetYaxis()->SetTitle("Normalized Residuals");
resgr->SetMarkerStyle(21);
resgr->SetMarkerColor(2);
resgr->SetMarkerSize(.6);
resgr->SetTitle("Normalized Residuals");
//Quantile-Quantile plot
TF1 *f = new TF1("f","TMath::Gaus(x,0.01,0.1)",-10,10);
TGraphQQ *qqplot = new TGraphQQ(n,res,f);
qqplot->SetMarkerStyle(23);
qqplot->SetMarkerColor(5);
qqplot->SetMarkerSize(.8);
qqplot->SetTitle("Q-Q plot of Normalized Residuals");
//create Canvas
TCanvas *c1 = new TCanvas("c1","Chistat Plot",10,10,700,600);
c1->SetFillColor(33);
c1->Divide(2,2);
// Draw Histogramms and Graphs
c1->cd(1);
gPad->SetFrameFillColor(21);
h1->SetMarkerColor(4);
h1->SetMarkerStyle(20);
h1->Draw("E");
c1->cd(2);
gPad->SetFrameFillColor(21);
h2->Draw("");
h2->SetMarkerColor(4);
h2->SetMarkerStyle(20);
c1->cd(3);
gPad->SetFrameFillColor(21);
gPad->SetGridy();
resgr->Draw("APL");
c1->cd(4);
gPad->SetFrameFillColor(21);
qqplot->Draw("APK");
c1->cd(0);
c1->Update();
return c1;
}
any help please about the warning problems
thank you