Hi,
I do have 64 histograms of the same type. They are all 2D histograms, I can fit them individually using fit2d.C. I tried to make it at once by following code
{
#include "Riostream.h"
Double_t par[3];
TFile file("Scatter.root");
Fit = new TF1("Fit", "pol2", -0.4, 0);
// Create file to write output information.
ofstream OutFile;
OutFile.open("ScatterFitOut.txt",ios::out);
for (Int_t i=0; i<64; i++)
{
TCanvas *Canvas1 = new TCanvas("Canvas1","Scatter Plot");
TCanvas *Canvas2 = new TCanvas("Canvas2","Fit to Plot");
Canvas1->Divide(1,1);
Canvas1->cd(1);
h20[i]->Draw();
Canvas2->Divide(1,1);
Canvas2->cd(1);
//use a TProfile to convert the 2-d to 1-d problem
TProfile *Profile = h20[i]->ProfileX();
Profile->Fit(Fit,"R");
Fit->GetParameters(&par[0]);
OutFile << i << " " << par[0] << " " << -par[1] << " " << +par[2] << endl;
}
}
It gives me the following error.
Error: Symbol h20[i] is not defined in current scope FitAll.C:21:
Error: Failed to evaluate h20[i]->Draw()
How can I resolve this?
Thanks.