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);
~L1PrefiringWeightProducer() override
const double prefiringRateSystUncMuon_
TF1 * parametrization1p8To2p1_
const std::string dataeraMuon_
T getParameter(std::string const &) const
const edm::EDPutTokenT< float > nonPrefiringProbDownToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TF1 * parametrization1p6To1p8_
const edm::EDPutTokenT< float > nonPrefiringProbECALUpToken_
L1PrefiringWeightProducer(const edm::ParameterSet &)
const edm::EDPutTokenT< float > nonPrefiringProbMuonDownSystToken_
TF1 * parametrization0p2To0p3_
const edm::EDPutTokenT< float > nonPrefiringProbMuonToken_
TF1 * parametrizationHotSpot_
Log< level::Error, false > LogError
std::unique_ptr< TFile > file_prefiringparams_
const double prefiringRateSystUncEcal_
TF1 * parametrization0p83To1p24_
const edm::EDGetTokenT< std::vector< pat::Photon > > photons_token_
TF1 * parametrization2p1To2p25_
const std::string dataeraEcal_
double getPrefiringRateMuon(double eta, double phi, double pt, fluctuations fluctuation) const
const edm::EDPutTokenT< float > nonPrefiringProbECALToken_
const edm::EDPutTokenT< float > nonPrefiringProbECALDownToken_
void produce(edm::Event &, const edm::EventSetup &) override
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
TF1 * parametrization2p25To2p4_
const edm::EDPutTokenT< float > nonPrefiringProbMuonUpSystToken_
const edm::EDPutTokenT< float > nonPrefiringProbMuonUpStatToken_
TF1 * parametrization0p3To0p55_
const edm::EDPutTokenT< float > nonPrefiringProbMuonUpToken_
const edm::EDPutTokenT< float > nonPrefiringProbToken_
const edm::EDPutTokenT< float > nonPrefiringProbUpToken_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double getPrefiringRateEcal(double eta, double pt, TH2F *h_prefmap, fluctuations fluctuation) const
const edm::EDPutTokenT< float > nonPrefiringProbMuonDownToken_
TF1 * parametrization0p55To0p83_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDPutTokenT< float > nonPrefiringProbMuonDownStatToken_
TF1 * parametrization0p0To0p2_
const edm::EDGetTokenT< std::vector< pat::Muon > > muon_token_
const edm::EDGetTokenT< std::vector< pat::Jet > > jets_token_
Log< level::Warning, false > LogWarning
const double jetMaxMuonFraction_
TF1 * parametrization1p24To1p4_
std::unique_ptr< TFile > file_prefiringmaps_
TF1 * parametrization1p4To1p6_