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

Avoid fitting empy histograms in PhotonDataCertification #44064

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 13 additions & 2 deletions DQMOffline/EGamma/plugins/PhotonDataCertification.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,25 @@ float PhotonDataCertification::invMassZtest(string path, TString name, DQMStore:
TH1F* TestHist = TestElem->getTH1F();
if (TestHist == nullptr)
return 0;

RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING);
RooRealVar mass("mass", "Mass_{2#gamma}", 0, 200, "GeV");
// Previously, the range of the mass variable was from 0 to 200 GeV. However,
// the fit was restricted to the range 80 to 100 GeV anyway. It's easier to
// define the RooFit variable in only that range to begin with: it avoids
// some overhead from the RooFit::Range() command argument in fitTo(), and we
// can easily check whether there are entries in the fit range by calling
// sumEntries() on the RooDataHist (note that when creating a RooDataHist
// from a TH1, all bins that are not in the variable range are skipped).
RooRealVar mass("mass", "Mass_{2#gamma}", 80, 100, "GeV");
RooRealVar mRes("M_{Z}", "Z Mass", ZMass, 70, 110);
RooRealVar gamma("#Gamma", "#Gamma", ZWidth, 0, 10.0);
RooBreitWigner BreitWigner("BreitWigner", "Breit-Wigner", mass, mRes, gamma);
RooDataHist test(name, name, mass, TestHist);

BreitWigner.fitTo(test, RooFit::Range(80, 100), RooFit::PrintLevel(-1000));
// Only fit if the histogram is not empty
if (test.sumEntries() > 0.0) {
BreitWigner.fitTo(test, RooFit::PrintLevel(-1000));
}

if (std::abs(mRes.getValV() - ZMass) < ZWidth) {
return 1.0;
Expand Down