10 #include "RooDataHist.h" 11 #include "RooExponential.h" 12 #include "RooGaussian.h" 14 #include "RooRealVar.h" 15 #include "RooVoigtian.h" 19 : TopFolder_(iConfig.getParameter<
std::
string>(
"FolderName")),
20 fitBackground_(iConfig.getParameter<
bool>(
"fitBackground")),
21 debugMode_(iConfig.getParameter<
bool>(
"debugMode")),
25 edm::LogInfo(
"DiMuonMassBiasClient") <<
"DiMuonMassBiasClient::Constructing DiMuonMassBiasClient ";
47 edm::LogInfo(
"DiMuonMassBiasClient") <<
"DiMuonMassBiasClient::Deleting DiMuonMassBiasClient ";
54 edm::LogInfo(
"DiMuonMassBiasClient") <<
"DiMuonMassBiasClient::beginJob done";
61 edm::LogInfo(
"DiMuonMassBiasClient") <<
"DiMuonMassBiasClient:: Begining of Run";
71 edm::LogError(
"DiMuonMassBiasClient") <<
"could not find MonitorElement for key: " <<
key << std::endl;
75 const auto&
title =
ME->getTitle();
76 const auto&
xtitle =
ME->getAxisTitle(1);
77 const auto&
ytitle =
ME->getAxisTitle(2);
78 const auto&
nbins =
ME->getNbinsX();
79 const auto&
xmin =
ME->getAxisMin(1);
80 const auto&
xmax =
ME->getAxisMax(1);
101 if (toHarvest ==
nullptr) {
102 edm::LogError(
"DiMuonMassBiasClient") <<
"could not find input MonitorElement: " << inFolder + hname << std::endl;
114 edm::LogInfo(
"DiMuonMassBiasClient") <<
"DiMuonMassBiasClient::endLuminosityBlock";
121 edm::LogPrint(
"DiMuonMassBiasClient") <<
"dealing with key: " <<
key << std::endl;
122 TH2F* bareHisto =
ME->getTH2F();
125 edm::LogPrint(
"DiMuonMassBiasClient") <<
"dealing with bin: " <<
bin << std::endl;
126 TH1D* Proj = bareHisto->ProjectionY(Form(
"%s_proj_%i",
key.c_str(),
bin),
bin,
bin);
147 edm::LogWarning(
"DiMuonMassBiasClient") <<
" Input histogram:" <<
hist->GetName() <<
" has not enough entries (" 148 <<
hist->GetEntries() <<
") for a meaningful Voigtian fit!\n" 154 TCanvas*
c1 =
new TCanvas();
157 c1->SetLeftMargin(0.15);
158 c1->SetRightMargin(0.10);
164 Double_t
xmin =
hist->GetXaxis()->GetXmin();
165 Double_t
xmax =
hist->GetXaxis()->GetXmax();
168 edm::LogPrint(
"DiMuonMassBiasClient") <<
"fitting range: (" <<
xmin <<
"-" <<
xmax <<
")" << std::endl;
171 RooRealVar InvMass(
"InvMass",
"di-muon mass M(#mu^{+}#mu^{-}) [GeV]",
xmin,
xmax);
172 RooPlot*
frame = InvMass.frame();
173 RooDataHist datahist(
"datahist",
"datahist", InvMass, RooFit::Import(*
hist));
174 datahist.plotOn(
frame);
176 RooRealVar
mean(
"#mu",
"mean", meanConfig_[0], meanConfig_[1], meanConfig_[2]);
177 RooRealVar
width(
"width",
"width", widthConfig_[0], widthConfig_[1], widthConfig_[2]);
178 RooRealVar sigma(
"#sigma",
"sigma", sigmaConfig_[0], sigmaConfig_[1], sigmaConfig_[2]);
179 RooVoigtian voigt(
"voigt",
"voigt", InvMass,
mean,
width, sigma);
181 RooRealVar lambda(
"#lambda",
"slope", -0.01, -100., 1.);
182 RooExponential expo(
"expo",
"expo", InvMass, lambda);
184 RooRealVar
b(
"N_{b}",
"Number of background events", 0,
hist->GetEntries() / 10.);
185 RooRealVar
s(
"N_{s}",
"Number of signal events", 0,
hist->GetEntries());
187 RooAddPdf fullModel(
"fullModel",
"Signal + Background Model", RooArgList(voigt, expo), RooArgList(
s,
b));
188 if (fitBackground_) {
190 fullModel.plotOn(
frame, RooFit::LineColor(kRed));
191 fullModel.plotOn(
frame, RooFit::Components(expo), RooFit::LineStyle(kDashed));
192 fullModel.paramOn(
frame, RooFit::Layout(0.65, 0.90, 0.90));
195 voigt.plotOn(
frame, RooFit::LineColor(kRed));
196 voigt.paramOn(
frame, RooFit::Layout(0.65, 0.90, 0.90));
200 datahist.plotOn(
frame);
201 frame->GetYaxis()->SetTitle(
"n. of events");
202 TString histName =
hist->GetName();
203 frame->SetName(
"frame" + histName);
208 c1->Print(
"fit_debug" + histName +
".pdf");
212 float mass_mean =
mean.getVal();
213 float mass_sigma = sigma.getVal();
215 float mass_mean_err =
mean.getError();
216 float mass_sigma_err = sigma.getError();
230 desc.add<
bool>(
"fitBackground",
false);
231 desc.add<
bool>(
"debugMode",
false);
234 fit_par.add<std::vector<double>>(
"mean_par",
239 fit_par.add<std::vector<double>>(
"width_par",
244 fit_par.add<std::vector<double>>(
"sigma_par",
251 desc.add<std::vector<std::string>>(
"MEtoHarvest",
252 {
"DiMuMassVsMuMuPhi",
254 "DiMuMassVsMuPlusPhi",
255 "DiMuMassVsMuPlusEta",
256 "DiMuMassVsMuMinusPhi",
257 "DiMuMassVsMuMinusEta",
258 "DiMuMassVsMuMuDeltaEta",
259 "DiMuMassVsCosThetaCS"});
void getMEsToHarvest(DQMStore::IGetter &igetter)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
virtual void setCurrentFolder(std::string const &fullpath)
static PFTauRenderPlugin instance
PixelRecoRange< float > Range
~DiMuonMassBiasClient() override
Destructor.
const std::string TopFolder_
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
BeginRun.
Log< level::Error, false > LogError
std::map< std::string, MonitorElement * > harvestTargets_
std::map< std::string, MonitorElement * > meanProfiles_
std::map< std::string, MonitorElement * > widthProfiles_
#define DEFINE_FWK_MODULE(type)
std::vector< std::string > MEtoHarvest_
Log< level::Warning, true > LogPrint
void dqmEndJob(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_) override
EndJob.
void beginJob(void) override
BeginJob.
Log< level::Info, false > LogInfo
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static constexpr int minimumHits
virtual MonitorElement * get(std::string const &fullpath) const
DiMuonMassBiasClient(const edm::ParameterSet &ps)
Constructor.
void bookMEs(DQMStore::IBooker &ibooker)
book MEs
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
void fillArrayF(float *x, const edm::ParameterSet &cfg, const char *name)
diMuonMassBias::fitOutputs fitVoigt(TH1 *hist, const bool &fitBackground=false) const