107 nonPrefiringProbToken_(produces<
float>(
"nonPrefiringProb")),
108 nonPrefiringProbUpToken_(produces<
float>(
"nonPrefiringProbUp")),
109 nonPrefiringProbDownToken_(produces<
float>(
"nonPrefiringProbDown")),
110 nonPrefiringProbECALToken_(produces<
float>(
"nonPrefiringProbECAL")),
111 nonPrefiringProbECALUpToken_(produces<
float>(
"nonPrefiringProbECALUp")),
112 nonPrefiringProbECALDownToken_(produces<
float>(
"nonPrefiringProbECALDown")),
113 nonPrefiringProbMuonToken_(produces<
float>(
"nonPrefiringProbMuon")),
114 nonPrefiringProbMuonUpToken_(produces<
float>(
"nonPrefiringProbMuonUp")),
115 nonPrefiringProbMuonDownToken_(produces<
float>(
"nonPrefiringProbMuonDown")),
116 nonPrefiringProbMuonUpSystToken_(produces<
float>(
"nonPrefiringProbMuonSystUp")),
117 nonPrefiringProbMuonDownSystToken_(produces<
float>(
"nonPrefiringProbMuonSystDown")),
118 nonPrefiringProbMuonUpStatToken_(produces<
float>(
"nonPrefiringProbMuonStatUp")),
119 nonPrefiringProbMuonDownStatToken_(produces<
float>(
"nonPrefiringProbMuonStatDown")),
120 dataeraEcal_(iConfig.getParameter<
std::
string>(
"DataEraECAL")),
121 dataeraMuon_(iConfig.getParameter<
std::
string>(
"DataEraMuon")),
122 useEMpt_(iConfig.getParameter<
bool>(
"UseJetEMPt")),
123 prefiringRateSystUncEcal_(iConfig.getParameter<double>(
"PrefiringRateSystematicUnctyECAL")),
124 prefiringRateSystUncMuon_(iConfig.getParameter<double>(
"PrefiringRateSystematicUnctyMuon")),
125 jetMaxMuonFraction_(iConfig.getParameter<double>(
"JetMaxMuonFraction")) {
135 <<
"File with maps not found. All prefiring weights set to 0. " << std::endl;
137 TString mapphotonfullname =
"L1prefiring_photonptvseta_" +
dataeraEcal_;
141 <<
"Photon map not found. All photons prefiring weights set to 0. " << std::endl;
144 TString mapjetfullname =
148 edm::LogError(
"L1PrefireWeightProducer") <<
"Jet map not found. All jets prefiring weights set to 0. " << std::endl;
154 edm::FileInPath paramsfilepath(
"PhysicsTools/PatUtils/data/" + fnameMuon);
159 <<
"File with muon parametrizations not found. All prefiring weights set to 0." << std::endl;
161 TString paramName =
"L1prefiring_muonparam_0.0To0.2_" +
dataeraMuon_;
163 paramName =
"L1prefiring_muonparam_0.2To0.3_" +
dataeraMuon_;
165 paramName =
"L1prefiring_muonparam_0.3To0.55_" +
dataeraMuon_;
167 paramName =
"L1prefiring_muonparam_0.55To0.83_" +
dataeraMuon_;
169 paramName =
"L1prefiring_muonparam_0.83To1.24_" +
dataeraMuon_;
171 paramName =
"L1prefiring_muonparam_1.24To1.4_" +
dataeraMuon_;
173 paramName =
"L1prefiring_muonparam_1.4To1.6_" +
dataeraMuon_;
175 paramName =
"L1prefiring_muonparam_1.6To1.8_" +
dataeraMuon_;
177 paramName =
"L1prefiring_muonparam_1.8To2.1_" +
dataeraMuon_;
179 paramName =
"L1prefiring_muonparam_2.1To2.25_" +
dataeraMuon_;
181 paramName =
"L1prefiring_muonparam_2.25To2.4_" +
dataeraMuon_;
192 <<
"Muon parametrization not found for at least one bin. All prefiring weights set to 0." << std::endl;
195 paramName =
"L1prefiring_muonparam_HotSpot_" +
dataeraMuon_;
201 <<
"Year is 2016 and no Muon parametrization is found for hot spot. All prefiring weights set to 0."
222 double nonPrefiringProba[3] = {1., 1., 1.};
223 double nonPrefiringProbaECAL[3] = {1., 1., 1.};
224 double nonPrefiringProbaMuon[7] = {
225 1., 1., 1., 1., 1., 1., 1.};
229 for (
const auto&
photon : thePhotons) {
230 double pt_gam =
photon.pt();
231 double eta_gam =
photon.eta();
234 if (fabs(eta_gam) < 2.)
236 if (fabs(eta_gam) > 3.)
239 nonPrefiringProbaECAL[fluct] *= (1. - prefiringprob_gam);
243 for (
const auto&
jet : theJets) {
244 double pt_jet =
jet.pt();
245 double eta_jet =
jet.eta();
246 double phi_jet =
jet.phi();
249 if (fabs(eta_jet) < 2.)
251 if (fabs(eta_jet) > 3.)
256 double nonprefiringprobfromoverlappingphotons = 1.;
257 bool foundOverlappingPhotons =
false;
258 for (
const auto&
photon : thePhotons) {
259 double pt_gam =
photon.pt();
260 double eta_gam =
photon.eta();
261 double phi_gam =
photon.phi();
264 if (fabs(eta_gam) < 2.)
266 if (fabs(eta_gam) > 3.)
268 double dR2 =
reco::deltaR2(eta_jet, phi_jet, eta_gam, phi_gam);
272 nonprefiringprobfromoverlappingphotons *= (1. - prefiringprob_gam);
273 foundOverlappingPhotons =
true;
277 pt_jet *= (
jet.neutralEmEnergyFraction() +
jet.chargedEmEnergyFraction());
280 if (!foundOverlappingPhotons) {
281 nonPrefiringProbaECAL[fluct] *= nonprefiringprobfromoverlappingjet;
284 else if (nonprefiringprobfromoverlappingphotons > nonprefiringprobfromoverlappingjet) {
285 if (nonprefiringprobfromoverlappingphotons > 0.) {
286 nonPrefiringProbaECAL[fluct] *= nonprefiringprobfromoverlappingjet / nonprefiringprobfromoverlappingphotons;
288 nonPrefiringProbaECAL[fluct] = 0.;
296 for (
const auto&
muon : theMuons) {
301 if (
pt < 5 || !
muon.isLooseMuon())
304 nonPrefiringProbaMuon[fluct] *= (1. - prefiringprob_mu);
310 nonPrefiringProba[fluct] = nonPrefiringProbaECAL[fluct] * nonPrefiringProbaMuon[fluct];
313 for (
const auto fluct :
316 for (
const auto&
muon : theMuons) {
321 if (
pt < 5 || !
muon.isLooseMuon())
324 nonPrefiringProbaMuon[fluct] *= (1. - prefiringprob_mu);
351 int nbinsy = h_prefmap->GetNbinsY();
352 double maxy = h_prefmap->GetYaxis()->GetBinLowEdge(nbinsy + 1);
355 int thebin = h_prefmap->FindBin(
eta,
pt);
357 double prefrate = h_prefmap->GetBinContent(thebin);
359 double statuncty = h_prefmap->GetBinError(thebin);
362 if (fluctuation ==
up)
364 else if (fluctuation ==
down)
367 edm::LogWarning(
"L1PrefireWeightProducer") <<
"Found a prefiring probability > 1. Setting to 1." << std::endl;
380 (
phi > 2.44346 &&
phi < 2.79253)) {
417 LogDebug(
"L1PrefireWeightProducer") <<
"Muon outside of |eta| <= 2.4. Prefiring weight set to 0." << std::endl;
422 if (fluctuation ==
up)
424 else if (fluctuation ==
down)
426 else if (fluctuation ==
upSyst)
427 prefrate =
std::min(1., prefrate + systuncty);
429 prefrate =
std::max(0., prefrate - systuncty);
430 else if (fluctuation ==
upStat)
431 prefrate =
std::min(1., prefrate + statuncty);
433 prefrate =
std::max(0., prefrate - statuncty);
436 edm::LogWarning(
"L1PrefireWeightProducer") <<
"Found a prefiring probability > 1. Setting to 1." << std::endl;
449 desc.add<
std::string>(
"L1MuonParametrizations",
"L1MuonPrefiringParametriations.root");
452 desc.add<
bool>(
"UseJetEMPt",
false);
453 desc.add<
double>(
"PrefiringRateSystematicUnctyECAL", 0.2);
454 desc.add<
double>(
"PrefiringRateSystematicUnctyMuon", 0.2);
455 desc.add<
double>(
"JetMaxMuonFraction", 0.5);
456 descriptions.
add(
"l1PrefiringWeightProducer",
desc);