Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some minor RooFit user errors #44069

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Alignment/OfflineValidation/bin/Zmumumerge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ FitOut ZMassBinFit_OldTool(TH1D* th1d_input, TString s_name = "zmumu_fitting", T
c1->Print(Form("%s/fitResultPlot/%s_oldtool.root", output_path.Data(), s_name.Data()));

FitOut fitRes(
fitter->mean()->getValV(), fitter->mean()->getError(), fitter->sigma()->getValV(), fitter->sigma()->getError());
fitter->mean()->getVal(), fitter->mean()->getError(), fitter->sigma()->getVal(), fitter->sigma()->getError());

return fitRes;
}
Expand Down
4 changes: 2 additions & 2 deletions DQMOffline/Alignment/src/DiMuonMassBiasClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ diMuonMassBias::fitOutputs DiMuonMassBiasClient::fitBWTimesCB(TH1* hist) const
}
delete c1;

Measurement1D resultM(fitter->mean()->getValV(), fitter->mean()->getError());
Measurement1D resultW(fitter->sigma()->getValV(), fitter->sigma()->getError());
Measurement1D resultM(fitter->mean()->getVal(), fitter->mean()->getError());
Measurement1D resultW(fitter->sigma()->getVal(), fitter->sigma()->getError());

return diMuonMassBias::fitOutputs(resultM, resultW);
}
Expand Down
4 changes: 2 additions & 2 deletions DQMOffline/EGamma/plugins/PhotonDataCertification.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ float PhotonDataCertification::invMassZtest(string path, TString name, DQMStore:

BreitWigner.fitTo(test, RooFit::Range(80, 100), RooFit::PrintLevel(-1000));

if (std::abs(mRes.getValV() - ZMass) < ZWidth) {
if (std::abs(mRes.getVal() - ZMass) < ZWidth) {
return 1.0;
} else if (std::abs(mRes.getValV() - ZMass) < gamma.getValV()) {
} else if (std::abs(mRes.getVal() - ZMass) < gamma.getVal()) {
return 0.9;
} else {
return 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class FitWithRooFit {
// Fit with likelihood
if (!useChi2_) {
if (sumW2Error)
model->fitTo(*dh, RooFit::Save(), RooFit::SumW2Error(kTRUE));
model->fitTo(*dh, RooFit::SumW2Error(true));
else
model->fitTo(*dh);
}
Expand Down
13 changes: 4 additions & 9 deletions PhysicsTools/TagAndProbe/src/TagProbeFitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -553,22 +553,19 @@ void TagProbeFitter::doFitEfficiency(RooWorkspace* w, string pdfName, RooRealVar
std::unique_ptr<RooFitResult> res;

RooAbsData* data = w->data("data");
std::unique_ptr<RooDataHist> bdata;
if (binnedFit) {
// get variables from data, which contain also other binning or expression variables
const RooArgSet* dataObs = data->get(0);
// remove everything which is not a dependency of the pdf
RooArgSet* obs = w->pdf("simPdf")->getObservables(dataObs);
bdata = std::make_unique<RooDataHist>("data_binned", "data_binned", *obs, *data);
w->import(*bdata);
std::unique_ptr<RooArgSet> obs{w->pdf("simPdf")->getObservables(dataObs)};
w->import(RooDataHist{"data_binned", "data_binned", *obs, *data});
data = w->data("data_binned");
delete obs;
}

double totPassing = data->sumEntries("_efficiencyCategory_==_efficiencyCategory_::Passed");
double totFailing = data->sumEntries("_efficiencyCategory_==_efficiencyCategory_::Failed");

RooAbsReal* simNLL = w->pdf("simPdf")->createNLL(*data, Extended(true), NumCPU(numCPU));
std::unique_ptr<RooAbsReal> simNLL{w->pdf("simPdf")->createNLL(*data, Extended(true), NumCPU(numCPU))};

RooMinimizer minimizer(*simNLL); // we are going to use this for 'scan'
minimizer.setStrategy(1);
Expand Down Expand Up @@ -701,8 +698,6 @@ void TagProbeFitter::doFitEfficiency(RooWorkspace* w, string pdfName, RooRealVar
efficiency.setAsymError(-cerr, 0);
}
}

delete simNLL;
}

void TagProbeFitter::createPdf(RooWorkspace* w, vector<string>& pdfCommands) {
Expand Down Expand Up @@ -1044,7 +1039,7 @@ void TagProbeFitter::makeEfficiencyPlot2D(RooDataSet& eff,
effName.Data()));
h->SetOption("colztexte");
h->GetZaxis()->SetRangeUser(-0.001, 1.001);
h->SetStats(kFALSE);
h->SetStats(false);
for (int i = 0; i < eff.numEntries(); i++) {
const RooArgSet* entry = eff.get(i);
if (catName != nullptr && entry->getCatIndex(catName) != catIndex)
Expand Down
4 changes: 2 additions & 2 deletions Validation/MtdValidation/macros/Pt_residuals_fit.C
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ void fit_to_data(TH1D* h_TrackMatchedTP, TString str) {
// The PDF fit to that data set using an un-binned maximum likelihood fit
// Then the data are visualized with the PDF overlaid

// Perform extended ML fit of PDF to data and save results in a pointer
RooFitResult* r1 = model->fitTo(*h_, Save());
// Perform extended ML fit of PDF to data
model->fitTo(*h_);

// Retrieve values from the fit
Double_t mean_fit = mean.getVal();
Expand Down