CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1PrefiringWeightProducer Class Reference

#include <ProdTutorial/L1ECALPrefiringWeightProducer/plugins/L1ECALPrefiringWeightProducer.cc>

Inheritance diagram for L1PrefiringWeightProducer:
edm::stream::EDProducer<>

Public Member Functions

 L1PrefiringWeightProducer (const edm::ParameterSet &)
 
 ~L1PrefiringWeightProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

double getPrefiringRateEcal (double eta, double pt, TH2F *h_prefmap, fluctuations fluctuation) const
 
double getPrefiringRateMuon (double eta, double phi, double pt, fluctuations fluctuation) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const std::string dataeraEcal_
 
const std::string dataeraMuon_
 
const bool doMuons_
 
std::unique_ptr< TFile > file_prefiringmaps_
 
std::unique_ptr< TFile > file_prefiringparams_
 
TH2F * h_prefmap_jet_
 
TH2F * h_prefmap_photon_
 
const double jetMaxMuonFraction_
 
const edm::EDGetTokenT< std::vector< pat::Jet > > jets_token_
 
bool missingInputEcal_
 
bool missingInputMuon_
 
const edm::EDGetTokenT< std::vector< pat::Muon > > muon_token_
 
const edm::EDPutTokenT< double > nonPrefiringProbDownToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbECALDownToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbECALToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbECALUpToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownStatToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownSystToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbMuonToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpStatToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpSystToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbToken_
 
const edm::EDPutTokenT< double > nonPrefiringProbUpToken_
 
TF1 * parametrization0p0To0p2_
 
TF1 * parametrization0p2To0p3_
 
TF1 * parametrization0p3To0p55_
 
TF1 * parametrization0p55To0p83_
 
TF1 * parametrization0p83To1p24_
 
TF1 * parametrization1p24To1p4_
 
TF1 * parametrization1p4To1p6_
 
TF1 * parametrization1p6To1p8_
 
TF1 * parametrization1p8To2p1_
 
TF1 * parametrization2p1To2p25_
 
TF1 * parametrization2p25To2p4_
 
TF1 * parametrizationHotSpot_
 
const edm::EDGetTokenT< std::vector< pat::Photon > > photons_token_
 
const double prefiringRateSystUncEcal_
 
const double prefiringRateSystUncMuon_
 
const bool useEMpt_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 42 of file L1PrefiringWeightProducer.cc.

Constructor & Destructor Documentation

L1PrefiringWeightProducer::L1PrefiringWeightProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 104 of file L1PrefiringWeightProducer.cc.

References dataeraEcal_, dataeraMuon_, file_prefiringmaps_, file_prefiringparams_, alignmentValidation::fname, edm::ParameterSet::getParameter(), h_prefmap_jet_, h_prefmap_photon_, missingInputEcal_, missingInputMuon_, parametrization0p0To0p2_, parametrization0p2To0p3_, parametrization0p3To0p55_, parametrization0p55To0p83_, parametrization0p83To1p24_, parametrization1p24To1p4_, parametrization1p4To1p6_, parametrization1p6To1p8_, parametrization1p8To2p1_, parametrization2p1To2p25_, parametrization2p25To2p4_, parametrizationHotSpot_, AlCaHLTBitMon_QueryRunRegistry::string, and useEMpt_.

105  : photons_token_(consumes<std::vector<pat::Photon> >(iConfig.getParameter<edm::InputTag>("ThePhotons"))),
106  jets_token_(consumes<std::vector<pat::Jet> >(iConfig.getParameter<edm::InputTag>("TheJets"))),
107  muon_token_(consumes<std::vector<pat::Muon> >(iConfig.getParameter<edm::InputTag>("TheMuons"))),
108  nonPrefiringProbToken_(produces<double>("nonPrefiringProb")),
109  nonPrefiringProbUpToken_(produces<double>("nonPrefiringProbUp")),
110  nonPrefiringProbDownToken_(produces<double>("nonPrefiringProbDown")),
111  nonPrefiringProbECALToken_(produces<double>("nonPrefiringProbECAL")),
112  nonPrefiringProbECALUpToken_(produces<double>("nonPrefiringProbECALUp")),
113  nonPrefiringProbECALDownToken_(produces<double>("nonPrefiringProbECALDown")),
114  nonPrefiringProbMuonToken_(produces<double>("nonPrefiringProbMuon")),
115  nonPrefiringProbMuonUpToken_(produces<double>("nonPrefiringProbMuonUp")),
116  nonPrefiringProbMuonDownToken_(produces<double>("nonPrefiringProbMuonDown")),
117  nonPrefiringProbMuonUpSystToken_(produces<double>("nonPrefiringProbMuonSystUp")),
118  nonPrefiringProbMuonDownSystToken_(produces<double>("nonPrefiringProbMuonSystDown")),
119  nonPrefiringProbMuonUpStatToken_(produces<double>("nonPrefiringProbMuonStatUp")),
120  nonPrefiringProbMuonDownStatToken_(produces<double>("nonPrefiringProbMuonStatDown")),
121  dataeraEcal_(iConfig.getParameter<std::string>("DataEraECAL")),
122  dataeraMuon_(iConfig.getParameter<std::string>("DataEraMuon")),
123  useEMpt_(iConfig.getParameter<bool>("UseJetEMPt")),
124  doMuons_(iConfig.getParameter<bool>("DoMuons")),
125  prefiringRateSystUncEcal_(iConfig.getParameter<double>("PrefiringRateSystematicUnctyECAL")),
126  prefiringRateSystUncMuon_(iConfig.getParameter<double>("PrefiringRateSystematicUnctyMuon")),
127  jetMaxMuonFraction_(iConfig.getParameter<double>("JetMaxMuonFraction")) {
128  missingInputEcal_ = false;
129  missingInputMuon_ = false;
130 
131  std::string fname = iConfig.getParameter<std::string>("L1Maps");
132  edm::FileInPath mapsfilepath("PhysicsTools/PatUtils/data/" + fname);
133  file_prefiringmaps_ = std::make_unique<TFile>(mapsfilepath.fullPath().c_str(), "read");
134  if (file_prefiringmaps_ == nullptr) {
135  missingInputEcal_ = true;
136  edm::LogError("L1PrefireWeightProducer")
137  << "File with maps not found. All prefiring weights set to 0. " << std::endl;
138  }
139  TString mapphotonfullname = "L1prefiring_photonptvseta_" + dataeraEcal_;
140  if (!file_prefiringmaps_->Get(mapphotonfullname)) {
141  missingInputEcal_ = true;
142  edm::LogError("L1PrefireWeightProducer")
143  << "Photon map not found. All photons prefiring weights set to 0. " << std::endl;
144  }
145  h_prefmap_photon_ = (TH2F*)file_prefiringmaps_->Get(mapphotonfullname);
146  TString mapjetfullname =
147  (useEMpt_) ? "L1prefiring_jetemptvseta_" + dataeraEcal_ : "L1prefiring_jetptvseta_" + dataeraEcal_;
148  if (!file_prefiringmaps_->Get(mapjetfullname)) {
149  missingInputEcal_ = true;
150  edm::LogError("L1PrefireWeightProducer") << "Jet map not found. All jets prefiring weights set to 0. " << std::endl;
151  }
152  h_prefmap_jet_ = (TH2F*)file_prefiringmaps_->Get(mapjetfullname);
153  file_prefiringmaps_->Close();
154 
155  std::string fnameMuon = iConfig.getParameter<std::string>("L1MuonParametrizations");
156  edm::FileInPath paramsfilepath("PhysicsTools/PatUtils/data/" + fnameMuon);
157  file_prefiringparams_ = std::make_unique<TFile>(paramsfilepath.fullPath().c_str(), "read");
158  if (file_prefiringparams_ == nullptr) {
159  missingInputMuon_ = true;
160  edm::LogError("L1PrefireWeightProducer")
161  << "File with muon parametrizations not found. All prefiring weights set to 0." << std::endl;
162  }
163  TString paramName = "L1prefiring_muonparam_0.0To0.2_" + dataeraMuon_;
164  parametrization0p0To0p2_ = (TF1*)file_prefiringparams_->Get(paramName);
165  paramName = "L1prefiring_muonparam_0.2To0.3_" + dataeraMuon_;
166  parametrization0p2To0p3_ = (TF1*)file_prefiringparams_->Get(paramName);
167  paramName = "L1prefiring_muonparam_0.3To0.55_" + dataeraMuon_;
168  parametrization0p3To0p55_ = (TF1*)file_prefiringparams_->Get(paramName);
169  paramName = "L1prefiring_muonparam_0.55To0.83_" + dataeraMuon_;
170  parametrization0p55To0p83_ = (TF1*)file_prefiringparams_->Get(paramName);
171  paramName = "L1prefiring_muonparam_0.83To1.24_" + dataeraMuon_;
172  parametrization0p83To1p24_ = (TF1*)file_prefiringparams_->Get(paramName);
173  paramName = "L1prefiring_muonparam_1.24To1.4_" + dataeraMuon_;
174  parametrization1p24To1p4_ = (TF1*)file_prefiringparams_->Get(paramName);
175  paramName = "L1prefiring_muonparam_1.4To1.6_" + dataeraMuon_;
176  parametrization1p4To1p6_ = (TF1*)file_prefiringparams_->Get(paramName);
177  paramName = "L1prefiring_muonparam_1.6To1.8_" + dataeraMuon_;
178  parametrization1p6To1p8_ = (TF1*)file_prefiringparams_->Get(paramName);
179  paramName = "L1prefiring_muonparam_1.8To2.1_" + dataeraMuon_;
180  parametrization1p8To2p1_ = (TF1*)file_prefiringparams_->Get(paramName);
181  paramName = "L1prefiring_muonparam_2.1To2.25_" + dataeraMuon_;
182  parametrization2p1To2p25_ = (TF1*)file_prefiringparams_->Get(paramName);
183  paramName = "L1prefiring_muonparam_2.25To2.4_" + dataeraMuon_;
184  parametrization2p25To2p4_ = (TF1*)file_prefiringparams_->Get(paramName);
185 
186  if (parametrization0p0To0p2_ == nullptr || parametrization0p2To0p3_ == nullptr ||
187  parametrization0p3To0p55_ == nullptr || parametrization0p55To0p83_ == nullptr ||
188  parametrization0p83To1p24_ == nullptr || parametrization1p24To1p4_ == nullptr ||
189  parametrization1p4To1p6_ == nullptr || parametrization1p6To1p8_ == nullptr ||
190  parametrization1p8To2p1_ == nullptr || parametrization2p1To2p25_ == nullptr ||
191  parametrization2p25To2p4_ == nullptr) {
192  missingInputMuon_ = true;
193  edm::LogError("L1PrefireWeightProducer")
194  << "Muon parametrization not found for at least one bin. All prefiring weights set to 0." << std::endl;
195  }
196 
197  paramName = "L1prefiring_muonparam_HotSpot_" + dataeraMuon_;
198  parametrizationHotSpot_ = (TF1*)file_prefiringparams_->Get(paramName);
199  file_prefiringparams_->Close();
200  if ((dataeraMuon_.find("2016") != std::string::npos) && parametrizationHotSpot_ == nullptr) {
201  missingInputMuon_ = true;
202  edm::LogError("L1PrefireWeightProducer")
203  << "Year is 2016 and no Muon parametrization is found for hot spot. All prefiring weights set to 0."
204  << std::endl;
205  }
206 }
T getParameter(std::string const &) const
const edm::EDPutTokenT< double > nonPrefiringProbUpToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownStatToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpSystToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpToken_
std::unique_ptr< TFile > file_prefiringparams_
const edm::EDGetTokenT< std::vector< pat::Photon > > photons_token_
const edm::EDPutTokenT< double > nonPrefiringProbECALDownToken_
const edm::EDPutTokenT< double > nonPrefiringProbToken_
const edm::EDPutTokenT< double > nonPrefiringProbDownToken_
const edm::EDPutTokenT< double > nonPrefiringProbECALUpToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownSystToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpStatToken_
string fname
main script
const edm::EDGetTokenT< std::vector< pat::Muon > > muon_token_
const edm::EDGetTokenT< std::vector< pat::Jet > > jets_token_
const edm::EDPutTokenT< double > nonPrefiringProbECALToken_
std::unique_ptr< TFile > file_prefiringmaps_
L1PrefiringWeightProducer::~L1PrefiringWeightProducer ( )
override

Definition at line 208 of file L1PrefiringWeightProducer.cc.

208 {}

Member Function Documentation

void L1PrefiringWeightProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 445 of file L1PrefiringWeightProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), DEFINE_FWK_MODULE, and AlCaHLTBitMon_QueryRunRegistry::string.

445  {
447  desc.add<edm::InputTag>("TheMuons", edm::InputTag("slimmedMuons"));
448  desc.add<edm::InputTag>("ThePhotons", edm::InputTag("slimmedPhotons"));
449  desc.add<edm::InputTag>("TheJets", edm::InputTag("slimmedJets"));
450  desc.add<std::string>("L1Maps", "L1PrefiringMaps.root");
451  desc.add<std::string>("L1MuonParametrizations", "L1MuonPrefiringParametriations.root");
452  desc.add<std::string>("DataEraECAL", "2017BtoF");
453  desc.add<std::string>("DataEraMuon", "2016");
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);
460 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double L1PrefiringWeightProducer::getPrefiringRateEcal ( double  eta,
double  pt,
TH2F *  h_prefmap,
fluctuations  fluctuation 
) const
private

Definition at line 348 of file L1PrefiringWeightProducer.cc.

References down, SiStripPI::max, min(), funct::pow(), prefiringRateSystUncEcal_, mathSSE::sqrt(), and up.

Referenced by produce().

351  {
352  //Check pt is not above map overflow
353  int nbinsy = h_prefmap->GetNbinsY();
354  double maxy = h_prefmap->GetYaxis()->GetBinLowEdge(nbinsy + 1);
355  if (pt >= maxy)
356  pt = maxy - 0.01;
357  int thebin = h_prefmap->FindBin(eta, pt);
358 
359  double prefrate = h_prefmap->GetBinContent(thebin);
360 
361  double statuncty = h_prefmap->GetBinError(thebin);
362  double systuncty = prefiringRateSystUncEcal_ * prefrate;
363 
364  if (fluctuation == up)
365  prefrate = std::min(1., prefrate + sqrt(pow(statuncty, 2) + pow(systuncty, 2)));
366  else if (fluctuation == down)
367  prefrate = std::max(0., prefrate - sqrt(pow(statuncty, 2) + pow(systuncty, 2)));
368  if (prefrate > 1.) {
369  edm::LogWarning("L1PrefireWeightProducer") << "Found a prefiring probability > 1. Setting to 1." << std::endl;
370  return 1.;
371  }
372  return prefrate;
373 }
T sqrt(T t)
Definition: SSEVec.h:18
T min(T a, T b)
Definition: MathUtil.h:58
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double L1PrefiringWeightProducer::getPrefiringRateMuon ( double  eta,
double  phi,
double  pt,
fluctuations  fluctuation 
) const
private

Definition at line 375 of file L1PrefiringWeightProducer.cc.

References funct::abs(), dataeraMuon_, down, downStat, downSyst, LogDebug, SiStripPI::max, min(), parametrization0p0To0p2_, parametrization0p2To0p3_, parametrization0p3To0p55_, parametrization0p55To0p83_, parametrization0p83To1p24_, parametrization1p24To1p4_, parametrization1p4To1p6_, parametrization1p6To1p8_, parametrization1p8To2p1_, parametrization2p1To2p25_, parametrization2p25To2p4_, parametrizationHotSpot_, funct::pow(), prefiringRateSystUncMuon_, mathSSE::sqrt(), up, upStat, and upSyst.

Referenced by produce().

378  {
379  double prefrate;
380  double statuncty;
381  if ((dataeraMuon_.find("2016") != std::string::npos) && (eta > 1.24 && eta < 1.6) &&
382  (phi > 2.44346 && phi < 2.79253)) {
383  prefrate = parametrizationHotSpot_->Eval(pt);
384  statuncty = parametrizationHotSpot_->GetParError(2);
385  } else if (std::abs(eta) < 0.2) {
386  prefrate = parametrization0p0To0p2_->Eval(pt);
387  statuncty = parametrization0p0To0p2_->GetParError(2);
388  } else if (std::abs(eta) < 0.3) {
389  prefrate = parametrization0p2To0p3_->Eval(pt);
390  statuncty = parametrization0p2To0p3_->GetParError(2);
391  } else if (std::abs(eta) < 0.55) {
392  prefrate = parametrization0p3To0p55_->Eval(pt);
393  statuncty = parametrization0p3To0p55_->GetParError(2);
394  } else if (std::abs(eta) < 0.83) {
395  prefrate = parametrization0p55To0p83_->Eval(pt);
396  statuncty = parametrization0p55To0p83_->GetParError(2);
397  } else if (std::abs(eta) < 1.24) {
398  prefrate = parametrization0p83To1p24_->Eval(pt);
399  statuncty = parametrization0p83To1p24_->GetParError(2);
400  } else if (std::abs(eta) < 1.4) {
401  prefrate = parametrization1p24To1p4_->Eval(pt);
402  statuncty = parametrization1p24To1p4_->GetParError(2);
403  } else if (std::abs(eta) < 1.6) {
404  prefrate = parametrization1p4To1p6_->Eval(pt);
405  statuncty = parametrization1p4To1p6_->GetParError(2);
406  } else if (std::abs(eta) < 1.8) {
407  prefrate = parametrization1p6To1p8_->Eval(pt);
408  statuncty = parametrization1p6To1p8_->GetParError(2);
409  } else if (std::abs(eta) < 2.1) {
410  prefrate = parametrization1p8To2p1_->Eval(pt);
411  statuncty = parametrization1p8To2p1_->GetParError(2);
412  } else if (std::abs(eta) < 2.25) {
413  prefrate = parametrization2p1To2p25_->Eval(pt);
414  statuncty = parametrization2p1To2p25_->GetParError(2);
415  } else if (std::abs(eta) < 2.4) {
416  prefrate = parametrization2p25To2p4_->Eval(pt);
417  statuncty = parametrization2p25To2p4_->GetParError(2);
418  } else {
419  LogDebug("L1PrefireWeightProducer") << "Muon outside of |eta| <= 2.4. Prefiring weight set to 0." << std::endl;
420  return 0.;
421  }
422  double systuncty = prefiringRateSystUncMuon_ * prefrate;
423 
424  if (fluctuation == up)
425  prefrate = std::min(1., prefrate + sqrt(pow(statuncty, 2) + pow(systuncty, 2)));
426  else if (fluctuation == down)
427  prefrate = std::max(0., prefrate - sqrt(pow(statuncty, 2) + pow(systuncty, 2)));
428  else if (fluctuation == upSyst)
429  prefrate = std::min(1., prefrate + systuncty);
430  else if (fluctuation == downSyst)
431  prefrate = std::max(0., prefrate - systuncty);
432  else if (fluctuation == upStat)
433  prefrate = std::min(1., prefrate + statuncty);
434  else if (fluctuation == downStat)
435  prefrate = std::max(0., prefrate - statuncty);
436 
437  if (prefrate > 1.) {
438  edm::LogWarning("L1PrefireWeightProducer") << "Found a prefiring probability > 1. Setting to 1." << std::endl;
439  return 1.;
440  }
441  return prefrate;
442 }
#define LogDebug(id)
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void L1PrefiringWeightProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 210 of file L1PrefiringWeightProducer.cc.

References central, reco::deltaR2(), doMuons_, down, downStat, downSyst, edm::Event::emplace(), PVValHelper::eta, edm::Event::get(), getPrefiringRateEcal(), getPrefiringRateMuon(), h_prefmap_jet_, h_prefmap_photon_, metsig::jet, jetMaxMuonFraction_, jets_token_, missingInputEcal_, missingInputMuon_, muon_token_, nonPrefiringProbDownToken_, nonPrefiringProbECALDownToken_, nonPrefiringProbECALToken_, nonPrefiringProbECALUpToken_, nonPrefiringProbMuonDownStatToken_, nonPrefiringProbMuonDownSystToken_, nonPrefiringProbMuonDownToken_, nonPrefiringProbMuonToken_, nonPrefiringProbMuonUpStatToken_, nonPrefiringProbMuonUpSystToken_, nonPrefiringProbMuonUpToken_, nonPrefiringProbToken_, nonPrefiringProbUpToken_, phi, muons2muons_cfi::photon, photons_token_, EnergyCorrector::pt, up, upStat, upSyst, and useEMpt_.

210  {
211  using namespace edm;
212 
213  //Photons
214  const std::vector<pat::Photon>& thePhotons = iEvent.get(photons_token_);
215 
216  //Jets
217  const std::vector<pat::Jet>& theJets = iEvent.get(jets_token_);
218 
219  //Muons
220  const std::vector<pat::Muon>& theMuons = iEvent.get(muon_token_);
221 
222  //Probability for the event NOT to prefire, computed with the prefiring maps per object.
223  //Up and down values correspond to the resulting value when shifting up/down all prefiring rates in prefiring maps.
224  double nonPrefiringProba[3] = {1., 1., 1.}; //0: central, 1: up, 2: down
225  double nonPrefiringProbaECAL[3] = {1., 1., 1.}; //0: central, 1: up, 2: down
226  double nonPrefiringProbaMuon[7] = {
227  1., 1., 1., 1., 1., 1., 1.}; //0: central, 1: up, 2: down, 3: up stat, 4: down stat, 5: up syst, 6: down syst
228 
229  for (const auto fluct : {fluctuations::central, fluctuations::up, fluctuations::down}) {
230  if (!missingInputEcal_) {
231  for (const auto& photon : thePhotons) {
232  double pt_gam = photon.pt();
233  double eta_gam = photon.eta();
234  if (pt_gam < 20.)
235  continue;
236  if (fabs(eta_gam) < 2.)
237  continue;
238  if (fabs(eta_gam) > 3.)
239  continue;
240  double prefiringprob_gam = getPrefiringRateEcal(eta_gam, pt_gam, h_prefmap_photon_, fluct);
241  nonPrefiringProbaECAL[fluct] *= (1. - prefiringprob_gam);
242  }
243 
244  //Now applying the prefiring maps to jets in the affected regions.
245  for (const auto& jet : theJets) {
246  double pt_jet = jet.pt();
247  double eta_jet = jet.eta();
248  double phi_jet = jet.phi();
249  if (pt_jet < 20.)
250  continue;
251  if (fabs(eta_jet) < 2.)
252  continue;
253  if (fabs(eta_jet) > 3.)
254  continue;
255  if (jetMaxMuonFraction_ > 0 && jet.muonEnergyFraction() > jetMaxMuonFraction_)
256  continue;
257  //Loop over photons to remove overlap
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();
264  if (pt_gam < 20.)
265  continue;
266  if (fabs(eta_gam) < 2.)
267  continue;
268  if (fabs(eta_gam) > 3.)
269  continue;
270  double dR2 = reco::deltaR2(eta_jet, phi_jet, eta_gam, phi_gam);
271  if (dR2 > 0.16)
272  continue;
273  double prefiringprob_gam = getPrefiringRateEcal(eta_gam, pt_gam, h_prefmap_photon_, fluct);
274  nonprefiringprobfromoverlappingphotons *= (1. - prefiringprob_gam);
275  foundOverlappingPhotons = true;
276  }
277  //useEMpt =true if one wants to use maps parametrized vs Jet EM pt instead of pt.
278  if (useEMpt_)
279  pt_jet *= (jet.neutralEmEnergyFraction() + jet.chargedEmEnergyFraction());
280  double nonprefiringprobfromoverlappingjet = 1. - getPrefiringRateEcal(eta_jet, pt_jet, h_prefmap_jet_, fluct);
281 
282  if (!foundOverlappingPhotons) {
283  nonPrefiringProbaECAL[fluct] *= nonprefiringprobfromoverlappingjet;
284  }
285  //If overlapping photons have a non prefiring rate larger than the jet, then replace these weights by the jet one
286  else if (nonprefiringprobfromoverlappingphotons > nonprefiringprobfromoverlappingjet) {
287  if (nonprefiringprobfromoverlappingphotons > 0.) {
288  nonPrefiringProbaECAL[fluct] *= nonprefiringprobfromoverlappingjet / nonprefiringprobfromoverlappingphotons;
289  } else {
290  nonPrefiringProbaECAL[fluct] = 0.;
291  }
292  }
293  //Last case: if overlapping photons have a non prefiring rate smaller than the jet, don't consider the jet in the event weight, and do nothing.
294  }
295  }
296  //Now calculate prefiring weights for muons
297  if (!missingInputMuon_ && doMuons_) {
298  for (const auto& muon : theMuons) {
299  double pt = muon.pt();
300  double phi = muon.phi();
301  double eta = muon.eta();
302  // Remove crappy tracker muons which would not have prefired the L1 trigger
303  if (pt < 5 || !muon.isLooseMuon())
304  continue;
305  double prefiringprob_mu = getPrefiringRateMuon(eta, phi, pt, fluct);
306  nonPrefiringProbaMuon[fluct] *= (1. - prefiringprob_mu);
307  }
308  }
309  }
310  // Calculate combined weight as product of the weight for individual objects
311  for (const auto fluct : {fluctuations::central, fluctuations::up, fluctuations::down}) {
312  nonPrefiringProba[fluct] = nonPrefiringProbaECAL[fluct] * nonPrefiringProbaMuon[fluct];
313  }
314  // Calculate statistical and systematic uncertainty separately in the muon case
315  for (const auto fluct :
317  if (!missingInputMuon_ && doMuons_) {
318  for (const auto& muon : theMuons) {
319  double pt = muon.pt();
320  double phi = muon.phi();
321  double eta = muon.eta();
322  // Remove crappy tracker muons which would not have prefired the L1 trigger
323  if (pt < 5 || !muon.isLooseMuon())
324  continue;
325  double prefiringprob_mu = getPrefiringRateMuon(eta, phi, pt, fluct);
326  nonPrefiringProbaMuon[fluct] *= (1. - prefiringprob_mu);
327  }
328  }
329  }
330  //Move global prefire weights, as well as those for muons, photons, and jets, to the event
331  iEvent.emplace(nonPrefiringProbToken_, nonPrefiringProba[0]);
332  iEvent.emplace(nonPrefiringProbUpToken_, nonPrefiringProba[1]);
333  iEvent.emplace(nonPrefiringProbDownToken_, nonPrefiringProba[2]);
334 
335  iEvent.emplace(nonPrefiringProbECALToken_, nonPrefiringProbaECAL[0]);
336  iEvent.emplace(nonPrefiringProbECALUpToken_, nonPrefiringProbaECAL[1]);
337  iEvent.emplace(nonPrefiringProbECALDownToken_, nonPrefiringProbaECAL[2]);
338 
339  iEvent.emplace(nonPrefiringProbMuonToken_, nonPrefiringProbaMuon[0]);
340  iEvent.emplace(nonPrefiringProbMuonUpToken_, nonPrefiringProbaMuon[1]);
341  iEvent.emplace(nonPrefiringProbMuonDownToken_, nonPrefiringProbaMuon[2]);
342  iEvent.emplace(nonPrefiringProbMuonUpStatToken_, nonPrefiringProbaMuon[3]);
343  iEvent.emplace(nonPrefiringProbMuonDownStatToken_, nonPrefiringProbaMuon[4]);
344  iEvent.emplace(nonPrefiringProbMuonUpSystToken_, nonPrefiringProbaMuon[5]);
345  iEvent.emplace(nonPrefiringProbMuonDownSystToken_, nonPrefiringProbaMuon[6]);
346 }
const edm::EDPutTokenT< double > nonPrefiringProbUpToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownToken_
double getPrefiringRateMuon(double eta, double phi, double pt, fluctuations fluctuation) const
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownStatToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpSystToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpToken_
const edm::EDGetTokenT< std::vector< pat::Photon > > photons_token_
const edm::EDPutTokenT< double > nonPrefiringProbECALDownToken_
double getPrefiringRateEcal(double eta, double pt, TH2F *h_prefmap, fluctuations fluctuation) const
const edm::EDPutTokenT< double > nonPrefiringProbToken_
const edm::EDPutTokenT< double > nonPrefiringProbDownToken_
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:326
const edm::EDPutTokenT< double > nonPrefiringProbECALUpToken_
const edm::EDPutTokenT< double > nonPrefiringProbMuonDownSystToken_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
const edm::EDPutTokenT< double > nonPrefiringProbMuonUpStatToken_
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:413
HLT enums.
const edm::EDGetTokenT< std::vector< pat::Muon > > muon_token_
const edm::EDGetTokenT< std::vector< pat::Jet > > jets_token_
const edm::EDPutTokenT< double > nonPrefiringProbECALToken_

Member Data Documentation

const std::string L1PrefiringWeightProducer::dataeraEcal_
private

Definition at line 93 of file L1PrefiringWeightProducer.cc.

Referenced by L1PrefiringWeightProducer().

const std::string L1PrefiringWeightProducer::dataeraMuon_
private

Definition at line 94 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

const bool L1PrefiringWeightProducer::doMuons_
private

Definition at line 96 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

std::unique_ptr<TFile> L1PrefiringWeightProducer::file_prefiringmaps_
private

Definition at line 75 of file L1PrefiringWeightProducer.cc.

Referenced by L1PrefiringWeightProducer().

std::unique_ptr<TFile> L1PrefiringWeightProducer::file_prefiringparams_
private

Definition at line 76 of file L1PrefiringWeightProducer.cc.

Referenced by L1PrefiringWeightProducer().

TH2F* L1PrefiringWeightProducer::h_prefmap_jet_
private

Definition at line 92 of file L1PrefiringWeightProducer.cc.

Referenced by L1PrefiringWeightProducer(), and produce().

TH2F* L1PrefiringWeightProducer::h_prefmap_photon_
private

Definition at line 91 of file L1PrefiringWeightProducer.cc.

Referenced by L1PrefiringWeightProducer(), and produce().

const double L1PrefiringWeightProducer::jetMaxMuonFraction_
private

Definition at line 99 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<std::vector<pat::Jet> > L1PrefiringWeightProducer::jets_token_
private

Definition at line 56 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

bool L1PrefiringWeightProducer::missingInputEcal_
private

Definition at line 100 of file L1PrefiringWeightProducer.cc.

Referenced by L1PrefiringWeightProducer(), and produce().

bool L1PrefiringWeightProducer::missingInputMuon_
private

Definition at line 101 of file L1PrefiringWeightProducer.cc.

Referenced by L1PrefiringWeightProducer(), and produce().

const edm::EDGetTokenT<std::vector<pat::Muon> > L1PrefiringWeightProducer::muon_token_
private

Definition at line 57 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbDownToken_
private

Definition at line 61 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbECALDownToken_
private

Definition at line 65 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbECALToken_
private

Definition at line 63 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbECALUpToken_
private

Definition at line 64 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbMuonDownStatToken_
private

Definition at line 73 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbMuonDownSystToken_
private

Definition at line 71 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbMuonDownToken_
private

Definition at line 69 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbMuonToken_
private

Definition at line 67 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbMuonUpStatToken_
private

Definition at line 72 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbMuonUpSystToken_
private

Definition at line 70 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbMuonUpToken_
private

Definition at line 68 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbToken_
private

Definition at line 59 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const edm::EDPutTokenT<double> L1PrefiringWeightProducer::nonPrefiringProbUpToken_
private

Definition at line 60 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

TF1* L1PrefiringWeightProducer::parametrization0p0To0p2_
private

Definition at line 78 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrization0p2To0p3_
private

Definition at line 79 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrization0p3To0p55_
private

Definition at line 80 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrization0p55To0p83_
private

Definition at line 81 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrization0p83To1p24_
private

Definition at line 82 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrization1p24To1p4_
private

Definition at line 83 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrization1p4To1p6_
private

Definition at line 84 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrization1p6To1p8_
private

Definition at line 85 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrization1p8To2p1_
private

Definition at line 86 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrization2p1To2p25_
private

Definition at line 87 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrization2p25To2p4_
private

Definition at line 88 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

TF1* L1PrefiringWeightProducer::parametrizationHotSpot_
private

Definition at line 89 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon(), and L1PrefiringWeightProducer().

const edm::EDGetTokenT<std::vector<pat::Photon> > L1PrefiringWeightProducer::photons_token_
private

Definition at line 55 of file L1PrefiringWeightProducer.cc.

Referenced by produce().

const double L1PrefiringWeightProducer::prefiringRateSystUncEcal_
private

Definition at line 97 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateEcal().

const double L1PrefiringWeightProducer::prefiringRateSystUncMuon_
private

Definition at line 98 of file L1PrefiringWeightProducer.cc.

Referenced by getPrefiringRateMuon().

const bool L1PrefiringWeightProducer::useEMpt_
private

Definition at line 95 of file L1PrefiringWeightProducer.cc.

Referenced by L1PrefiringWeightProducer(), and produce().