I am trying to perform a double gaussian fit to a weighted histogram, my code is
respProjection[i]->Fit("gaus", "Q");
TF1* fit1 = respProjection[i]->GetFunction("gaus");
double mean1 = fit1->GetParameter(1);
double sig1 = fit1->GetParameter(2);
double lowBound1 = mean1 - (2 * sig1);
double highBound1 = mean1 + (2 * sig1);
respProjection[i]->Fit("gaus", "Q", "SAME", lowBound1, highBound1);
respProjection[i]->GetXaxis()->SetTitle("MC Response");
//respProjection[i]->GetYaxis()->SetTitle("# Jets");
respProjection[i]->SetTitle(label);
respProjection[i]->SetStats(0);
//respProjection[i]->Draw();
TFitResultPtr r = respProjection[i]->Fit("gaus", "S", "SAME", lowBound1, highBound1);
correctionFile << temp << ":" << r->Parameters()[1] << "\n";
This is meant to run over several projections from a 2-D histogram and fit a gaussian, then re fit to +/- 2sigma. I receive the error:
Warning in <ROOT::Fit::FillData>: fit range is outside histogram range, no fit data for xaxis
Warning in <Fit>: Fit data is empty
Error in <TFitResultPtr>: TFitResult is empty - use the fit option S
This is a weighted histogram, where the values range from O(10E-8) to O(1). When I tried this code on a similar but unweighted histogram, it worked fine.
Let me know If I should provide more information,
Thanks!