Hi,
I am having a problem where I fit the same histogram with two different fits, and plot each fitted histogram on a different pad on the same canvas. It seems to be ignoring the divide, and just drawing the second histogram on an undivided canvas.
TH1* Histogram::qT2FittingTruth( std::string Variable, TFile *File, std::string BDT ){
TF1 *f1;
TF1 *f2;
TH1F *h1;
TH1F *h2;
h1 = (TH1F*)File->Get(Form("TruthMC_dnSig_d%s_%s", Variable.c_str(), BDT.c_str()));
TH1F *hFit = (TH1F*)h1->Clone("hFit");
TH1F *hFit2 =(TH1F*)h1->Clone("hFit2");
TCanvas *c = new TCanvas(Form("qTSquaredFit_%s", Variable.c_str() ), Form( "qTSquaredFit_%s",Variable.c_str() ) , 700, 500);
c->Divide(2,1);
f1 = new TF1("fit_qT2" ,fitqT2Truth,0.0, 400.0, 3);
f1->SetParameters(1,5, 0.0);
f1->SetParLimits(0, 0.0, 3000.0);
f1->SetParLimits(1, 0.0, 100.0);
f1->FixParameter(2, 0.0);
hFit->Fit(f1,"","",0.0 , 400.0);
hFit->Fit(f1,"","",0.0 , 400.0);
c->cd(1);
gPad->SetLogy();
hFit->Draw();
hFit->SetMinimum(0.1);
c->cd(2);
f2 = new TF1("fit_qT2_addParam" ,fitqT2Truth_addParam,0.0, 400.0, 3);
f2->SetParameters(1,5, 0.0);
f2->SetParLimits(0, 0.0, 3000.0);
f2->SetParLimits(1, 0.0, 100.0);
f2->FixParameter(2, 0.0);
hFit2->Fit(f2,"","",0.0 , 400.0);
hFit2->Fit(f2,"","",0.0 , 400.0);
gPad->SetLogy();
hFit2->Draw();
hFit2->SetMinimum(0.1);
c->SaveAs(Form("Fit_qT2_%s_%s_Truth.eps", Variable.c_str(), BDT.c_str() ));
return hFit;
}