Afternoon,
I have a root file containing three fitted histograms. I am using a TGraph to go through each histogram, bin by bin, and calculate the product of the fits for the three histograms for each bin. I then plot the resultant line. I want to calculate the chi2 value of the product of the three fits.
TH1D *h1 = (TH1D*)File->Get("R_29099_N0A2byN0A0;1");
TF1 *h1f1 = h1->GetFunction("f1");
TH1D *h2 = (TH1D*)File->Get("R_29099_N2A4byN2A0");
TF1 *h2f1 = h2->GetFunction("f1");
TH1D *h3 = (TH1D*)File->Get("R_29099_TruthbyN4A0");
TF1 *h3f1 = h3->GetFunction("f1");
TH1D *h4 = (TH1D*)File->Get("R_29099_RecobyTruth");
TF1 *h4f1 = h4->GetFunction("f1");
TGraph *gr3 = new TGraph (50); //number of points
gr3->SetName("M1234");
gr3->SetTitle("M1234"); //set x and y here too
gROOT->GetListOfSpecials()->Add(gr3);
for (int i=0; i<50; i++){ //Loop over bins
double x = h1->GetBinCenter(i+1);
double y1 = h1f1->Eval(x);
double y2 = h2f1->Eval(x);
double y3 = h3f1->Eval(x);
double y4 = h4f1->Eval(x);
double Graph3 = y1 * y2 * y3 * y4;
gr3->SetPoint(i, x, Graph3);
} //closing loop over histogram bins (i)
TCanvas *c3 = new TCanvas ("c3", "c3", 700, 500);
gr3->Draw();
I am not sure how to pull the Chi2 value, as I am not wanting to perform a fit on top.
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided