137 <<
"File with maps not found. All prefiring weights set to 0. " << std::endl;
139 TString mapphotonfullname =
"L1prefiring_photonptvseta_" +
dataeraEcal_;
143 <<
"Photon map not found. All photons prefiring weights set to 0. " << std::endl;
146 TString mapjetfullname =
150 edm::LogError(
"L1PrefireWeightProducer") <<
"Jet map not found. All jets prefiring weights set to 0. " << std::endl;
156 edm::FileInPath paramsfilepath(
"PhysicsTools/PatUtils/data/" + fnameMuon);
161 <<
"File with muon parametrizations not found. All prefiring weights set to 0." << std::endl;
163 TString paramName =
"L1prefiring_muonparam_0.0To0.2_" +
dataeraMuon_;
165 paramName =
"L1prefiring_muonparam_0.2To0.3_" +
dataeraMuon_;
167 paramName =
"L1prefiring_muonparam_0.3To0.55_" +
dataeraMuon_;
169 paramName =
"L1prefiring_muonparam_0.55To0.83_" +
dataeraMuon_;
171 paramName =
"L1prefiring_muonparam_0.83To1.24_" +
dataeraMuon_;
173 paramName =
"L1prefiring_muonparam_1.24To1.4_" +
dataeraMuon_;
175 paramName =
"L1prefiring_muonparam_1.4To1.6_" +
dataeraMuon_;
177 paramName =
"L1prefiring_muonparam_1.6To1.8_" +
dataeraMuon_;
179 paramName =
"L1prefiring_muonparam_1.8To2.1_" +
dataeraMuon_;
181 paramName =
"L1prefiring_muonparam_2.1To2.25_" +
dataeraMuon_;
183 paramName =
"L1prefiring_muonparam_2.25To2.4_" +
dataeraMuon_;
194 <<
"Muon parametrization not found for at least one bin. All prefiring weights set to 0." << std::endl;
197 paramName =
"L1prefiring_muonparam_HotSpot_" +
dataeraMuon_;
203 <<
"Year is 2016 and no Muon parametrization is found for hot spot. All prefiring weights set to 0." 224 double nonPrefiringProba[3] = {1., 1., 1.};
225 double nonPrefiringProbaECAL[3] = {1., 1., 1.};
226 double nonPrefiringProbaMuon[7] = {
227 1., 1., 1., 1., 1., 1., 1.};
231 for (
const auto&
photon : thePhotons) {
232 double pt_gam =
photon.pt();
233 double eta_gam =
photon.eta();
236 if (fabs(eta_gam) < 2.)
238 if (fabs(eta_gam) > 3.)
241 nonPrefiringProbaECAL[fluct] *= (1. - prefiringprob_gam);
245 for (
const auto&
jet : theJets) {
246 double pt_jet =
jet.pt();
247 double eta_jet =
jet.eta();
248 double phi_jet =
jet.phi();
251 if (fabs(eta_jet) < 2.)
253 if (fabs(eta_jet) > 3.)
258 double nonprefiringprobfromoverlappingphotons = 1.;
259 bool foundOverlappingPhotons =
false;
260 for (
const auto&
photon : thePhotons) {
261 double pt_gam =
photon.pt();
262 double eta_gam =
photon.eta();
263 double phi_gam =
photon.phi();
266 if (fabs(eta_gam) < 2.)
268 if (fabs(eta_gam) > 3.)
270 double dR2 =
reco::deltaR2(eta_jet, phi_jet, eta_gam, phi_gam);
274 nonprefiringprobfromoverlappingphotons *= (1. - prefiringprob_gam);
275 foundOverlappingPhotons =
true;
279 pt_jet *= (
jet.neutralEmEnergyFraction() +
jet.chargedEmEnergyFraction());
282 if (!foundOverlappingPhotons) {
283 nonPrefiringProbaECAL[fluct] *= nonprefiringprobfromoverlappingjet;
286 else if (nonprefiringprobfromoverlappingphotons > nonprefiringprobfromoverlappingjet) {
287 if (nonprefiringprobfromoverlappingphotons > 0.) {
288 nonPrefiringProbaECAL[fluct] *= nonprefiringprobfromoverlappingjet / nonprefiringprobfromoverlappingphotons;
290 nonPrefiringProbaECAL[fluct] = 0.;
298 for (
const auto&
muon : theMuons) {
303 if (pt < 5 || !
muon.isLooseMuon())
306 nonPrefiringProbaMuon[fluct] *= (1. - prefiringprob_mu);
312 nonPrefiringProba[fluct] = nonPrefiringProbaECAL[fluct] * nonPrefiringProbaMuon[fluct];
315 for (
const auto fluct :
318 for (
const auto&
muon : theMuons) {
323 if (pt < 5 || !
muon.isLooseMuon())
326 nonPrefiringProbaMuon[fluct] *= (1. - prefiringprob_mu);
353 int nbinsy = h_prefmap->GetNbinsY();
354 double maxy = h_prefmap->GetYaxis()->GetBinLowEdge(nbinsy + 1);
357 int thebin = h_prefmap->FindBin(eta, pt);
359 double prefrate = h_prefmap->GetBinContent(thebin);
361 double statuncty = h_prefmap->GetBinError(thebin);
364 if (fluctuation ==
up)
366 else if (fluctuation ==
down)
369 edm::LogWarning(
"L1PrefireWeightProducer") <<
"Found a prefiring probability > 1. Setting to 1." << std::endl;
381 if ((
dataeraMuon_.find(
"2016") != std::string::npos) && (eta > 1.24 && eta < 1.6) &&
382 (phi > 2.44346 && phi < 2.79253)) {
419 LogDebug(
"L1PrefireWeightProducer") <<
"Muon outside of |eta| <= 2.4. Prefiring weight set to 0." << std::endl;
424 if (fluctuation ==
up)
426 else if (fluctuation ==
down)
428 else if (fluctuation ==
upSyst)
429 prefrate =
std::min(1., prefrate + systuncty);
431 prefrate =
std::max(0., prefrate - systuncty);
432 else if (fluctuation ==
upStat)
433 prefrate =
std::min(1., prefrate + statuncty);
435 prefrate =
std::max(0., prefrate - statuncty);
438 edm::LogWarning(
"L1PrefireWeightProducer") <<
"Found a prefiring probability > 1. Setting to 1." << std::endl;
451 desc.
add<
std::string>(
"L1MuonParametrizations",
"L1MuonPrefiringParametriations.root");
454 desc.
add<
bool>(
"UseJetEMPt",
false);
455 desc.
add<
bool>(
"DoMuons",
true);
456 desc.
add<
double>(
"PrefiringRateSystematicUnctyECAL", 0.2);
457 desc.
add<
double>(
"PrefiringRateSystematicUnctyMuon", 0.2);
458 desc.
add<
double>(
"JetMaxMuonFraction", 0.5);
459 descriptions.
add(
"l1PrefiringWeightProducer", desc);
~L1PrefiringWeightProducer() override
const double prefiringRateSystUncMuon_
T getParameter(std::string const &) const
TF1 * parametrization1p8To2p1_
const std::string dataeraMuon_
const edm::EDPutTokenT< double > nonPrefiringProbUpToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownToken_
double getPrefiringRateMuon(double eta, double phi, double pt, fluctuations fluctuation) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TF1 * parametrization1p6To1p8_
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownStatToken_
L1PrefiringWeightProducer(const edm::ParameterSet &)
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpSystToken_
TF1 * parametrization0p2To0p3_
const edm::EDPutTokenT< double > nonPrefiringProbMuonToken_
TF1 * parametrizationHotSpot_
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpToken_
std::unique_ptr< TFile > file_prefiringparams_
const double prefiringRateSystUncEcal_
TF1 * parametrization0p83To1p24_
const edm::EDGetTokenT< std::vector< pat::Photon > > photons_token_
const edm::EDPutTokenT< double > nonPrefiringProbECALDownToken_
TF1 * parametrization2p1To2p25_
double getPrefiringRateEcal(double eta, double pt, TH2F *h_prefmap, fluctuations fluctuation) const
const std::string dataeraEcal_
#define DEFINE_FWK_MODULE(type)
const edm::EDPutTokenT< double > nonPrefiringProbToken_
void produce(edm::Event &, const edm::EventSetup &) override
const edm::EDPutTokenT< double > nonPrefiringProbDownToken_
Abs< T >::type abs(const T &t)
bool get(ProductID const &oid, Handle< PROD > &result) const
TF1 * parametrization2p25To2p4_
const edm::EDPutTokenT< double > nonPrefiringProbECALUpToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
TF1 * parametrization0p3To0p55_
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownSystToken_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpStatToken_
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
TF1 * parametrization0p55To0p83_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
TF1 * parametrization0p0To0p2_
const edm::EDGetTokenT< std::vector< pat::Muon > > muon_token_
const edm::EDGetTokenT< std::vector< pat::Jet > > jets_token_
const edm::EDPutTokenT< double > nonPrefiringProbECALToken_
const double jetMaxMuonFraction_
TF1 * parametrization1p24To1p4_
Power< A, B >::type pow(const A &a, const B &b)
std::unique_ptr< TFile > file_prefiringmaps_
TF1 * parametrization1p4To1p6_