CMS 3D CMS Logo

PATMuonProducer.cc
Go to the documentation of this file.
1 
56 
57 namespace pat {
58 
60  public:
62 
66 
67  private:
68  std::unique_ptr<const pat::CalculatePtRatioRel> calculatePtRatioRel_;
69  std::unique_ptr<const pat::MuonMvaIDEstimator> muonMvaIDEstimator_;
70  std::unique_ptr<const pat::SoftMuonMvaEstimator> softMuonMvaEstimator_;
71  };
72 
74  class TrackerIsolationPt;
75  class CaloIsolationEnergy;
76 
78  class PATMuonProducer : public edm::stream::EDProducer<edm::GlobalCache<PATMuonHeavyObjectCache>> {
79  public:
81  explicit PATMuonProducer(const edm::ParameterSet& iConfig, PATMuonHeavyObjectCache const*);
83  ~PATMuonProducer() override;
84 
85  static std::unique_ptr<PATMuonHeavyObjectCache> initializeGlobalCache(const edm::ParameterSet& iConfig) {
86  return std::make_unique<PATMuonHeavyObjectCache>(iConfig);
87  }
88 
90 
92  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
94  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
95 
96  private:
99  typedef std::vector<edm::Handle<edm::Association<reco::GenParticleCollection>>> GenAssociations;
100  typedef std::vector<edm::Handle<edm::ValueMap<IsoDeposit>>> IsoDepositMaps;
101  typedef std::vector<edm::Handle<edm::ValueMap<double>>> IsolationValueMaps;
102  typedef std::pair<pat::IsolationKeys, edm::InputTag> IsolationLabel;
103  typedef std::vector<IsolationLabel> IsolationLabels;
104 
106  void fillMuon(Muon& aMuon,
107  const MuonBaseRef& muonRef,
108  const reco::CandidateBaseRef& baseRef,
109  const GenAssociations& genMatches,
110  const IsoDepositMaps& deposits,
111  const IsolationValueMaps& isolationValues) const;
114  template <typename T>
115  void readIsolationLabels(const edm::ParameterSet& iConfig,
116  const char* psetName,
119 
121  double getRelMiniIsoPUCorrected(const pat::Muon& muon, double rho, const std::vector<double>& area);
122 
124  bool isNeutralHadron(long pdgid);
125  bool isChargedHadron(long pdgid);
126  bool isPhoton(long pdgid);
127 
128  // embed various impact parameters with errors
129  // embed high level selection
130  void embedHighLevel(pat::Muon& aMuon,
134  bool primaryVertexIsValid,
136  bool beamspotIsValid);
137  double relMiniIsoPUCorrected(const pat::Muon& aMuon, double rho);
138  std::optional<GlobalPoint> getMuonDirection(const reco::MuonChamberMatch& chamberMatch,
140  const DetId& chamberId);
142  edm::Handle<std::vector<pat::TriggerObjectStandAlone>>& triggerObjects,
143  const edm::TriggerNames& names,
146  edm::Handle<std::vector<pat::TriggerObjectStandAlone>>& triggerObjects,
147  const edm::TriggerNames& names,
148  const std::vector<std::string>& collection_names);
149 
150  private:
153 
154  // for mini-iso calculation
158  std::vector<double> effectiveAreaVec_;
159  std::vector<double> miniIsoParams_;
197  std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection>>> genMatchTokens_;
218  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit>>> isoDepositTokens_;
221  std::vector<edm::EDGetTokenT<edm::ValueMap<double>>> isolationValueTokens_;
230  //PUPPI isolation tokens
234  //PUPPINoLeptons isolation tokens
241  std::unique_ptr<pat::XGBooster> softMuonMvaRun3Booster_;
243  bool useJec_;
248 
258 
261 
266  std::vector<std::string> hltCollectionFilters_;
267 
270 
272  };
273 
274 } // namespace pat
275 
276 template <typename T>
278  const char* psetName,
281  labels.clear();
282 
283  if (iConfig.exists(psetName)) {
285 
286  if (depconf.exists("tracker"))
287  labels.emplace_back(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker"));
288  if (depconf.exists("ecal"))
289  labels.emplace_back(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal"));
290  if (depconf.exists("hcal"))
291  labels.emplace_back(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal"));
292  if (depconf.exists("pfAllParticles")) {
293  labels.emplace_back(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles"));
294  }
295  if (depconf.exists("pfChargedHadrons")) {
296  labels.emplace_back(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons"));
297  }
298  if (depconf.exists("pfChargedAll")) {
299  labels.emplace_back(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll"));
300  }
301  if (depconf.exists("pfPUChargedHadrons")) {
302  labels.emplace_back(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons"));
303  }
304  if (depconf.exists("pfNeutralHadrons")) {
305  labels.emplace_back(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons"));
306  }
307  if (depconf.exists("pfPhotons")) {
308  labels.emplace_back(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons"));
309  }
310  if (depconf.exists("user")) {
311  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag>>("user");
312  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
314  for (; it != ed; ++it, ++key) {
315  labels.push_back(std::make_pair(pat::IsolationKeys(key), *it));
316  }
317  }
318  }
320  return consumes<edm::ValueMap<T>>(label.second);
321  });
322 }
323 
324 using namespace pat;
325 using namespace std;
326 
328  if (iConfig.getParameter<bool>("computeMiniIso")) {
329  float mvaDrMax = iConfig.getParameter<double>("mvaDrMax");
330  calculatePtRatioRel_ = std::make_unique<CalculatePtRatioRel>(mvaDrMax * mvaDrMax);
331  }
332 
333  if (iConfig.getParameter<bool>("computeMuonIDMVA")) {
334  edm::FileInPath mvaIDTrainingFile = iConfig.getParameter<edm::FileInPath>("mvaIDTrainingFile");
335  muonMvaIDEstimator_ = std::make_unique<MuonMvaIDEstimator>(mvaIDTrainingFile);
336  }
337 
338  if (iConfig.getParameter<bool>("computeSoftMuonMVA")) {
339  edm::FileInPath softMvaTrainingFile = iConfig.getParameter<edm::FileInPath>("softMvaTrainingFile");
340  softMuonMvaEstimator_ = std::make_unique<SoftMuonMvaEstimator>(softMvaTrainingFile);
341  }
342 }
343 
345  : relMiniIsoPUCorrected_(0),
346  useUserData_(iConfig.exists("userData")),
347  computeMuonIDMVA_(false),
348  computeSoftMuonMVA_(false),
349  recomputeBasicSelectors_(false),
350  useJec_(false),
351  isolator_(iConfig.getParameter<edm::ParameterSet>("userIsolation"), consumesCollector(), false),
352  geometryToken_{esConsumes()},
353  transientTrackBuilderToken_{esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))},
354  patMuonPutToken_{produces<std::vector<Muon>>()} {
355  // Muon MVA ID wps
356  mvaIDmediumCut_ = iConfig.getParameter<double>("mvaIDwpMedium");
357  mvaIDtightCut_ = iConfig.getParameter<double>("mvaIDwpTight");
358 
359  // input source
360  muonToken_ = consumes<edm::View<reco::Muon>>(iConfig.getParameter<edm::InputTag>("muonSource"));
361  // embedding of tracks
362  embedBestTrack_ = iConfig.getParameter<bool>("embedMuonBestTrack");
363  embedTunePBestTrack_ = iConfig.getParameter<bool>("embedTunePMuonBestTrack");
364  forceEmbedBestTrack_ = iConfig.getParameter<bool>("forceBestTrackEmbedding");
365  embedTrack_ = iConfig.getParameter<bool>("embedTrack");
366  embedCombinedMuon_ = iConfig.getParameter<bool>("embedCombinedMuon");
367  embedStandAloneMuon_ = iConfig.getParameter<bool>("embedStandAloneMuon");
368  // embedding of muon MET correction information
369  embedCaloMETMuonCorrs_ = iConfig.getParameter<bool>("embedCaloMETMuonCorrs");
370  embedTcMETMuonCorrs_ = iConfig.getParameter<bool>("embedTcMETMuonCorrs");
371  caloMETMuonCorrsToken_ =
372  mayConsume<edm::ValueMap<reco::MuonMETCorrectionData>>(iConfig.getParameter<edm::InputTag>("caloMETMuonCorrs"));
373  tcMETMuonCorrsToken_ =
374  mayConsume<edm::ValueMap<reco::MuonMETCorrectionData>>(iConfig.getParameter<edm::InputTag>("tcMETMuonCorrs"));
375  // pflow specific configurables
376  useParticleFlow_ = iConfig.getParameter<bool>("useParticleFlow");
377  embedPFCandidate_ = iConfig.getParameter<bool>("embedPFCandidate");
378  pfMuonToken_ = mayConsume<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfMuonSource"));
379  embedPfEcalEnergy_ = iConfig.getParameter<bool>("embedPfEcalEnergy");
380  // embedding of tracks from TeV refit
381  embedPickyMuon_ = iConfig.getParameter<bool>("embedPickyMuon");
382  embedTpfmsMuon_ = iConfig.getParameter<bool>("embedTpfmsMuon");
383  embedDytMuon_ = iConfig.getParameter<bool>("embedDytMuon");
384  // embedding of inverse beta variable information
385  addInverseBeta_ = iConfig.getParameter<bool>("addInverseBeta");
386  if (addInverseBeta_) {
387  muonTimeExtraToken_ =
388  consumes<edm::ValueMap<reco::MuonTimeExtra>>(iConfig.getParameter<edm::InputTag>("sourceMuonTimeExtra"));
389  }
390  // Monte Carlo matching
391  addGenMatch_ = iConfig.getParameter<bool>("addGenMatch");
392  if (addGenMatch_) {
393  embedGenMatch_ = iConfig.getParameter<bool>("embedGenMatch");
394  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
395  genMatchTokens_.push_back(consumes<edm::Association<reco::GenParticleCollection>>(
396  iConfig.getParameter<edm::InputTag>("genParticleMatch")));
397  } else {
398  genMatchTokens_ = edm::vector_transform(
399  iConfig.getParameter<std::vector<edm::InputTag>>("genParticleMatch"),
400  [this](edm::InputTag const& tag) { return consumes<edm::Association<reco::GenParticleCollection>>(tag); });
401  }
402  }
403  // efficiencies
404  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
405  if (addEfficiencies_) {
406  efficiencyLoader_ =
407  pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
408  }
409  // resolutions
410  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
411  if (addResolutions_) {
412  resolutionLoader_ =
413  pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"), consumesCollector());
414  }
415  // puppi
416  addPuppiIsolation_ = iConfig.getParameter<bool>("addPuppiIsolation");
417  if (addPuppiIsolation_) {
418  PUPPIIsolation_charged_hadrons_ =
419  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationChargedHadrons"));
420  PUPPIIsolation_neutral_hadrons_ =
421  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationNeutralHadrons"));
422  PUPPIIsolation_photons_ =
423  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationPhotons"));
424  //puppiNoLeptons
425  PUPPINoLeptonsIsolation_charged_hadrons_ =
426  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationChargedHadrons"));
427  PUPPINoLeptonsIsolation_neutral_hadrons_ =
428  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationNeutralHadrons"));
429  PUPPINoLeptonsIsolation_photons_ =
430  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationPhotons"));
431  }
432  // read isoDeposit labels, for direct embedding
433  readIsolationLabels(iConfig, "isoDeposits", isoDepositLabels_, isoDepositTokens_);
434  // read isolation value labels, for direct embedding
435  readIsolationLabels(iConfig, "isolationValues", isolationValueLabels_, isolationValueTokens_);
436  // check to see if the user wants to add user data
437  if (useUserData_) {
438  userDataHelper_ = PATUserDataHelper<Muon>(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector());
439  }
440  // embed high level selection variables
441  embedHighLevelSelection_ = iConfig.getParameter<bool>("embedHighLevelSelection");
442  if (embedHighLevelSelection_) {
443  beamLineToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamLineSrc"));
444  pvToken_ = consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("pvSrc"));
445  }
446 
447  //for mini-isolation calculation
448  computeMiniIso_ = iConfig.getParameter<bool>("computeMiniIso");
449 
450  computePuppiCombinedIso_ = iConfig.getParameter<bool>("computePuppiCombinedIso");
451 
452  effectiveAreaVec_ = iConfig.getParameter<std::vector<double>>("effectiveAreaVec");
453 
454  miniIsoParams_ = iConfig.getParameter<std::vector<double>>("miniIsoParams");
455  if (computeMiniIso_ && miniIsoParams_.size() != 9) {
456  throw cms::Exception("ParameterError") << "miniIsoParams must have exactly 9 elements.\n";
457  }
458  if (computeMiniIso_ || computePuppiCombinedIso_)
459  pcToken_ = consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandsForMiniIso"));
460 
461  // standard selectors
462  recomputeBasicSelectors_ = iConfig.getParameter<bool>("recomputeBasicSelectors");
463  computeMuonIDMVA_ = iConfig.getParameter<bool>("computeMuonIDMVA");
464 
465  if (computeMiniIso_) {
466  // pfCombinedInclusiveSecondaryVertexV2BJetTags
467  mvaBTagCollectionTag_ = consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("mvaJetTag"));
468  mvaL1Corrector_ = consumes<reco::JetCorrector>(iConfig.getParameter<edm::InputTag>("mvaL1Corrector"));
469  mvaL1L2L3ResCorrector_ = consumes<reco::JetCorrector>(iConfig.getParameter<edm::InputTag>("mvaL1L2L3ResCorrector"));
470  rho_ = consumes<double>(iConfig.getParameter<edm::InputTag>("rho"));
471  useJec_ = iConfig.getParameter<bool>("useJec");
472  }
473 
474  computeSoftMuonMVA_ = iConfig.getParameter<bool>("computeSoftMuonMVA");
475 
476  // MC info
477  simInfo_ = consumes<edm::ValueMap<reco::MuonSimInfo>>(iConfig.getParameter<edm::InputTag>("muonSimInfo"));
478 
479  if (computeSoftMuonMVA_) {
480  std::string softMvaRun3Model = iConfig.getParameter<string>("softMvaRun3Model");
481  softMuonMvaRun3Booster_ =
482  std::make_unique<pat::XGBooster>(edm::FileInPath(softMvaRun3Model + ".model").fullPath(),
483  edm::FileInPath(softMvaRun3Model + ".features").fullPath());
484  }
485 
486  addTriggerMatching_ = iConfig.getParameter<bool>("addTriggerMatching");
487  if (addTriggerMatching_) {
488  triggerObjects_ =
489  consumes<std::vector<pat::TriggerObjectStandAlone>>(iConfig.getParameter<edm::InputTag>("triggerObjects"));
490  triggerResults_ = consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("triggerResults"));
491  }
492  hltCollectionFilters_ = iConfig.getParameter<std::vector<std::string>>("hltCollectionFilters");
493 }
494 
496 
497 std::optional<GlobalPoint> PATMuonProducer::getMuonDirection(const reco::MuonChamberMatch& chamberMatch,
499  const DetId& chamberId) {
500  const GeomDet* chamberGeometry = geometry->idToDet(chamberId);
501  if (chamberGeometry) {
502  LocalPoint localPosition(chamberMatch.x, chamberMatch.y, 0);
503  return std::optional<GlobalPoint>(std::in_place, chamberGeometry->toGlobal(localPosition));
504  }
505  return std::optional<GlobalPoint>();
506 }
507 
509  edm::Handle<std::vector<pat::TriggerObjectStandAlone>>& triggerObjects,
510  const edm::TriggerNames& names,
512  // L1 trigger object parameters are defined at MB2/ME2. Use the muon
513  // chamber matching information to get the local direction of the
514  // muon trajectory and convert it to a global direction to match the
515  // trigger objects
516 
517  std::optional<GlobalPoint> muonPosition;
518  // Loop over chambers
519  // initialize muonPosition with any available match, just in case
520  // the second station is missing - it's better folling back to
521  // dR matching at IP
522  for (const auto& chamberMatch : aMuon.matches()) {
523  if (chamberMatch.id.subdetId() == MuonSubdetId::DT) {
524  DTChamberId detId(chamberMatch.id.rawId());
525  if (abs(detId.station()) > 3)
526  continue;
527  muonPosition = getMuonDirection(chamberMatch, geometry, detId);
528  if (abs(detId.station()) == 2)
529  break;
530  }
531  if (chamberMatch.id.subdetId() == MuonSubdetId::CSC) {
532  CSCDetId detId(chamberMatch.id.rawId());
533  if (abs(detId.station()) > 3)
534  continue;
535  muonPosition = getMuonDirection(chamberMatch, geometry, detId);
536  if (abs(detId.station()) == 2)
537  break;
538  }
539  }
540  if (not muonPosition)
541  return;
542  for (const auto& triggerObject : *triggerObjects) {
543  if (triggerObject.hasTriggerObjectType(trigger::TriggerL1Mu)) {
544  if (std::abs(triggerObject.eta()) < 0.001) {
545  // L1 is defined in X-Y plain
546  if (deltaPhi(triggerObject.phi(), muonPosition->phi()) > 0.1)
547  continue;
548  } else {
549  // 3D L1
550  if (deltaR(triggerObject.p4(), *muonPosition) > 0.15)
551  continue;
552  }
553  pat::TriggerObjectStandAlone obj(triggerObject);
554  obj.unpackPathNames(names);
555  aMuon.addTriggerObjectMatch(obj);
556  }
557  }
558 }
559 
561  edm::Handle<std::vector<pat::TriggerObjectStandAlone>>& triggerObjects,
562  const edm::TriggerNames& names,
563  const std::vector<std::string>& collection_filter_names) {
564  // WARNING: in a case of close-by muons the dR matching may select both muons.
565  // It's better to select the best match for a given collection.
566  for (const auto& triggerObject : *triggerObjects) {
567  if (triggerObject.hasTriggerObjectType(trigger::TriggerMuon)) {
568  bool keepIt = false;
569  for (const auto& name : collection_filter_names) {
570  if (triggerObject.hasCollection(name)) {
571  keepIt = true;
572  break;
573  }
574  }
575  if (not keepIt)
576  continue;
577  if (deltaR(triggerObject.p4(), muon) > 0.1)
578  continue;
579  pat::TriggerObjectStandAlone obj(triggerObject);
580  obj.unpackPathNames(names);
581  muon.addTriggerObjectMatch(obj);
582  }
583  }
584 }
585 
587  // get the tracking Geometry
588  auto geometry = iSetup.getHandle(geometryToken_);
589  if (!geometry.isValid())
590  throw cms::Exception("FatalError") << "Unable to find GlobalTrackingGeometryRecord in event!\n";
591 
592  // switch off embedding (in unschedules mode)
593  if (iEvent.isRealData()) {
594  addGenMatch_ = false;
595  embedGenMatch_ = false;
596  }
597 
599  iEvent.getByToken(muonToken_, muons);
600 
603  iEvent.getByToken(pcToken_, pc);
604 
605  // get the ESHandle for the transient track builder,
606  // if needed for high level selection embedding
607  TransientTrackBuilder const* trackBuilder = nullptr;
608 
609  if (isolator_.enabled())
610  isolator_.beginEvent(iEvent, iSetup);
615 
617  for (size_t j = 0; j < isoDepositTokens_.size(); ++j) {
618  iEvent.getByToken(isoDepositTokens_[j], deposits[j]);
619  }
620 
622  for (size_t j = 0; j < isolationValueTokens_.size(); ++j) {
624  }
625 
626  //value maps for puppi isolation
627  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_charged_hadrons;
628  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_neutral_hadrons;
629  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_photons;
630  //value maps for puppiNoLeptons isolation
631  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_charged_hadrons;
632  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_neutral_hadrons;
633  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_photons;
634  if (addPuppiIsolation_) {
635  //puppi
636  iEvent.getByToken(PUPPIIsolation_charged_hadrons_, PUPPIIsolation_charged_hadrons);
637  iEvent.getByToken(PUPPIIsolation_neutral_hadrons_, PUPPIIsolation_neutral_hadrons);
638  iEvent.getByToken(PUPPIIsolation_photons_, PUPPIIsolation_photons);
639  //puppiNoLeptons
640  iEvent.getByToken(PUPPINoLeptonsIsolation_charged_hadrons_, PUPPINoLeptonsIsolation_charged_hadrons);
641  iEvent.getByToken(PUPPINoLeptonsIsolation_neutral_hadrons_, PUPPINoLeptonsIsolation_neutral_hadrons);
642  iEvent.getByToken(PUPPINoLeptonsIsolation_photons_, PUPPINoLeptonsIsolation_photons);
643  }
644 
645  // inputs for muon mva
646  edm::Handle<reco::JetTagCollection> mvaBTagCollectionTag;
649  if (computeMiniIso_) {
650  iEvent.getByToken(mvaBTagCollectionTag_, mvaBTagCollectionTag);
653  }
654 
655  // prepare the MC genMatchTokens_
656  GenAssociations genMatches(genMatchTokens_.size());
657  if (addGenMatch_) {
658  for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
659  iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
660  }
661  }
662 
663  // prepare the high level selection: needs beamline
664  // OR primary vertex, depending on user selection
667  bool beamSpotIsValid = false;
668  bool primaryVertexIsValid = false;
670  // get the beamspot
671  edm::Handle<reco::BeamSpot> beamSpotHandle;
672  iEvent.getByToken(beamLineToken_, beamSpotHandle);
673 
674  // get the primary vertex
676  iEvent.getByToken(pvToken_, pvHandle);
677 
678  if (beamSpotHandle.isValid()) {
679  beamSpot = *beamSpotHandle;
680  beamSpotIsValid = true;
681  } else {
682  edm::LogError("DataNotAvailable") << "No beam spot available from EventSetup, not adding high level selection \n";
683  }
684  if (pvHandle.isValid() && !pvHandle->empty()) {
685  primaryVertex = pvHandle->at(0);
686  primaryVertexIsValid = true;
687  } else {
688  edm::LogError("DataNotAvailable")
689  << "No primary vertex available from EventSetup, not adding high level selection \n";
690  }
691  // this is needed by the IPTools methods from the tracking group
692  trackBuilder = &iSetup.getData(transientTrackBuilderToken_);
693  }
694 
695  // MC info
697  bool simInfoIsAvailalbe = iEvent.getByToken(simInfo_, simInfo);
698 
699  // this will be the new object collection
700  std::vector<Muon> patMuons;
701 
703  if (useParticleFlow_) {
704  // get the PFCandidates of type muons
705  iEvent.getByToken(pfMuonToken_, pfMuons);
706 
707  unsigned index = 0;
708  for (reco::PFCandidateConstIterator i = pfMuons->begin(); i != pfMuons->end(); ++i, ++index) {
709  const reco::PFCandidate& pfmu = *i;
710  //const reco::IsolaPFCandidate& pfmu = *i;
711  const reco::MuonRef& muonRef = pfmu.muonRef();
712  assert(muonRef.isNonnull());
713 
714  MuonBaseRef muonBaseRef(muonRef);
715  Muon aMuon(muonBaseRef);
716 
717  if (useUserData_) {
718  userDataHelper_.add(aMuon, iEvent, iSetup);
719  }
720 
721  // embed high level selection
723  // get the tracks
724  reco::TrackRef innerTrack = muonBaseRef->innerTrack();
725  reco::TrackRef globalTrack = muonBaseRef->globalTrack();
726  reco::TrackRef bestTrack = muonBaseRef->muonBestTrack();
727  reco::TrackRef chosenTrack = innerTrack;
728  // Make sure the collection it points to is there
729  if (bestTrack.isNonnull() && bestTrack.isAvailable())
730  chosenTrack = bestTrack;
731 
732  if (chosenTrack.isNonnull() && chosenTrack.isAvailable()) {
733  unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
735 
736  reco::TransientTrack tt = trackBuilder->build(chosenTrack);
737  embedHighLevel(aMuon, chosenTrack, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
738  }
739 
740  if (globalTrack.isNonnull() && globalTrack.isAvailable() && !embedCombinedMuon_) {
741  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
742  aMuon.setNormChi2(norm_chi2);
743  }
744  }
745  reco::PFCandidateRef pfRef(pfMuons, index);
746  //reco::PFCandidatePtr ptrToMother(pfMuons,index);
747  reco::CandidateBaseRef pfBaseRef(pfRef);
748 
749  aMuon.setPFCandidateRef(pfRef);
750  if (embedPFCandidate_)
751  aMuon.embedPFCandidate();
752  fillMuon(aMuon, muonBaseRef, pfBaseRef, genMatches, deposits, isolationValues);
753 
754  if (computeMiniIso_)
755  setMuonMiniIso(aMuon, pc.product());
756 
757  if (addPuppiIsolation_) {
758  aMuon.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[muonBaseRef],
759  (*PUPPIIsolation_neutral_hadrons)[muonBaseRef],
760  (*PUPPIIsolation_photons)[muonBaseRef]);
761 
762  aMuon.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[muonBaseRef],
763  (*PUPPINoLeptonsIsolation_neutral_hadrons)[muonBaseRef],
764  (*PUPPINoLeptonsIsolation_photons)[muonBaseRef]);
765  } else {
766  aMuon.setIsolationPUPPI(-999., -999., -999.);
767  aMuon.setIsolationPUPPINoLeptons(-999., -999., -999.);
768  }
769 
770  if (embedPfEcalEnergy_) {
771  aMuon.setPfEcalEnergy(pfmu.ecalEnergy());
772  }
773 
774  patMuons.push_back(aMuon);
775  }
776  } else {
778  iEvent.getByToken(muonToken_, muons);
779 
780  // embedding of muon MET corrections
782  //edm::ValueMap<reco::MuonMETCorrectionData> caloMETmuCorValueMap;
785  //caloMETmuCorValueMap = *caloMETmuCorValueMap_h;
786  }
788  //edm::ValueMap<reco::MuonMETCorrectionData> tcMETmuCorValueMap;
789  if (embedTcMETMuonCorrs_) {
791  //tcMETmuCorValueMap = *tcMETmuCorValueMap_h;
792  }
793 
795  // get the PFCandidates of type muons
796  iEvent.getByToken(pfMuonToken_, pfMuons);
797  }
798 
800  if (addInverseBeta_) {
801  // get MuonTimerExtra value map
802  iEvent.getByToken(muonTimeExtraToken_, muonsTimeExtra);
803  }
804 
805  for (edm::View<reco::Muon>::const_iterator itMuon = muons->begin(); itMuon != muons->end(); ++itMuon) {
806  // construct the Muon from the ref -> save ref to original object
807  unsigned int idx = itMuon - muons->begin();
808  MuonBaseRef muonRef = muons->refAt(idx);
809  reco::CandidateBaseRef muonBaseRef(muonRef);
810 
811  Muon aMuon(muonRef);
812  fillMuon(aMuon, muonRef, muonBaseRef, genMatches, deposits, isolationValues);
813  if (computeMiniIso_)
814  setMuonMiniIso(aMuon, pc.product());
815  if (addPuppiIsolation_) {
816  aMuon.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[muonRef],
817  (*PUPPIIsolation_neutral_hadrons)[muonRef],
818  (*PUPPIIsolation_photons)[muonRef]);
819  aMuon.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[muonRef],
820  (*PUPPINoLeptonsIsolation_neutral_hadrons)[muonRef],
821  (*PUPPINoLeptonsIsolation_photons)[muonRef]);
822  } else {
823  aMuon.setIsolationPUPPI(-999., -999., -999.);
824  aMuon.setIsolationPUPPINoLeptons(-999., -999., -999.);
825  }
826 
827  // Isolation
828  if (isolator_.enabled()) {
829  //reco::CandidatePtr mother = ptrToMother->sourceCandidatePtr(0);
831  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
832  // better to loop backwards, so the vector is resized less times
833  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(),
834  ed = isolatorTmpStorage_.rend();
835  it != ed;
836  ++it) {
837  aMuon.setIsolation(it->first, it->second);
838  }
839  }
840 
841  // for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
842  // aMuon.setIsoDeposit(isoDepositLabels_[j].first,
843  // (*deposits[j])[muonRef]);
844  // }
845 
846  // add sel to selected
847  edm::Ptr<reco::Muon> muonsPtr = muons->ptrAt(idx);
848  if (useUserData_) {
849  userDataHelper_.add(aMuon, iEvent, iSetup);
850  }
851 
852  // embed high level selection
854  // get the tracks
855  reco::TrackRef innerTrack = itMuon->innerTrack();
856  reco::TrackRef globalTrack = itMuon->globalTrack();
857  reco::TrackRef bestTrack = itMuon->muonBestTrack();
858  reco::TrackRef chosenTrack = innerTrack;
859  // Make sure the collection it points to is there
860  if (bestTrack.isNonnull() && bestTrack.isAvailable())
861  chosenTrack = bestTrack;
862  if (chosenTrack.isNonnull() && chosenTrack.isAvailable()) {
863  unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
865 
866  reco::TransientTrack tt = trackBuilder->build(chosenTrack);
867  embedHighLevel(aMuon, chosenTrack, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
868  }
869 
870  if (globalTrack.isNonnull() && globalTrack.isAvailable()) {
871  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
872  aMuon.setNormChi2(norm_chi2);
873  }
874  }
875 
876  // embed MET muon corrections
878  aMuon.embedCaloMETMuonCorrs((*caloMETMuonCorrs)[muonRef]);
880  aMuon.embedTcMETMuonCorrs((*tcMETMuonCorrs)[muonRef]);
881 
883  if (embedPfEcalEnergy_)
884  aMuon.setPfEcalEnergy(-99.0);
885  unsigned index = 0;
886  for (const reco::PFCandidate& pfmu : *pfMuons) {
887  if (pfmu.muonRef().isNonnull()) {
888  if (pfmu.muonRef().id() != muonRef.id())
889  throw cms::Exception("Configuration")
890  << "Muon reference within PF candidates does not point to the muon collection." << std::endl;
891  if (pfmu.muonRef().key() == muonRef.key()) {
892  reco::PFCandidateRef pfRef(pfMuons, index);
893  aMuon.setPFCandidateRef(pfRef);
894  if (embedPfEcalEnergy_)
895  aMuon.setPfEcalEnergy(pfmu.ecalEnergy());
896  if (embedPFCandidate_)
897  aMuon.embedPFCandidate();
898  break;
899  }
900  }
901  index++;
902  }
903  }
904 
905  if (addInverseBeta_) {
906  aMuon.readTimeExtra((*muonsTimeExtra)[muonRef]);
907  }
908  // MC info
909  aMuon.initSimInfo();
910  if (simInfoIsAvailalbe) {
911  const auto& msi = (*simInfo)[muonBaseRef];
912  aMuon.setSimType(msi.primaryClass);
913  aMuon.setExtSimType(msi.extendedClass);
914  aMuon.setSimFlavour(msi.flavour);
915  aMuon.setSimHeaviestMotherFlavour(msi.heaviestMotherFlavour);
916  aMuon.setSimPdgId(msi.pdgId);
917  aMuon.setSimMotherPdgId(msi.motherPdgId);
918  aMuon.setSimBX(msi.tpBX);
919  aMuon.setSimTpEvent(msi.tpEvent);
920  aMuon.setSimProdRho(msi.vertex.Rho());
921  aMuon.setSimProdZ(msi.vertex.Z());
922  aMuon.setSimPt(msi.p4.pt());
923  aMuon.setSimEta(msi.p4.eta());
924  aMuon.setSimPhi(msi.p4.phi());
925  aMuon.setSimMatchQuality(msi.tpAssoQuality);
926  }
927  patMuons.push_back(aMuon);
928  }
929  }
930 
931  // sort muons in pt
932  std::sort(patMuons.begin(), patMuons.end(), [](auto const& t1, auto const& t2) { return t1.pt() > t2.pt(); });
933 
934  // Store standard muon selection decisions and jet related
935  // quantaties.
936  // Need a separate loop over muons to have all inputs properly
937  // computed and stored in the object.
939  if (computeMiniIso_)
940  iEvent.getByToken(rho_, rho);
941  const reco::Vertex* pv(nullptr);
942  if (primaryVertexIsValid)
943  pv = &primaryVertex;
944 
947  bool triggerObjectsAvailable = false;
948  bool triggerResultsAvailable = false;
949  if (addTriggerMatching_) {
950  triggerObjectsAvailable = iEvent.getByToken(triggerObjects_, triggerObjects);
951  triggerResultsAvailable = iEvent.getByToken(triggerResults_, triggerResults);
952  }
953 
954  for (auto& muon : patMuons) {
955  // trigger info
956  if (addTriggerMatching_ and triggerObjectsAvailable and triggerResultsAvailable) {
957  const edm::TriggerNames& triggerNames(iEvent.triggerNames(*triggerResults));
960  }
961 
963  muon.setSelectors(0);
964  bool isRun2016BCDEF = (272728 <= iEvent.run() && iEvent.run() <= 278808);
965  muon.setSelectors(muon::makeSelectorBitset(muon, pv, isRun2016BCDEF));
966  }
967  float miniIsoValue = -1;
968  if (computeMiniIso_) {
969  // MiniIsolation working points
970 
971  miniIsoValue = getRelMiniIsoPUCorrected(muon, *rho, effectiveAreaVec_);
972 
973  muon.setSelector(reco::Muon::MiniIsoLoose, miniIsoValue < 0.40);
974  muon.setSelector(reco::Muon::MiniIsoMedium, miniIsoValue < 0.20);
975  muon.setSelector(reco::Muon::MiniIsoTight, miniIsoValue < 0.10);
976  muon.setSelector(reco::Muon::MiniIsoVeryTight, miniIsoValue < 0.05);
977  }
978 
979  double puppiCombinedIsolationPAT = -1;
981  puppiCombinedIsolationPAT = puppiCombinedIsolation(muon, pc.product());
982  muon.setSelector(reco::Muon::PuppiIsoLoose, puppiCombinedIsolationPAT < 0.27);
983  muon.setSelector(reco::Muon::PuppiIsoMedium, puppiCombinedIsolationPAT < 0.22);
984  muon.setSelector(reco::Muon::PuppiIsoTight, puppiCombinedIsolationPAT < 0.12);
985  }
986 
987  std::array<float, 2> jetPtRatioRel = {{0.0, 0.0}};
988  if (primaryVertexIsValid && computeMiniIso_) {
989  if (useJec_) {
990  jetPtRatioRel = globalCache()->calculatePtRatioRel().computePtRatioRel(
991  muon, *(mvaBTagCollectionTag.product()), mvaL1Corrector.product(), mvaL1L2L3ResCorrector.product());
992  } else {
993  jetPtRatioRel = globalCache()->calculatePtRatioRel().computePtRatioRel(muon, *mvaBTagCollectionTag);
994  }
995 
996  muon.setJetPtRatio(jetPtRatioRel[0]);
997  muon.setJetPtRel(jetPtRatioRel[1]);
998 
999  // multi-isolation
1000  if (computeMiniIso_) {
1001  muon.setSelector(reco::Muon::MultiIsoMedium,
1002  miniIsoValue < 0.11 && (muon.jetPtRatio() > 0.74 || muon.jetPtRel() > 6.8));
1003  }
1004  }
1005 
1006  // MVA ID
1007  float mvaID = 0.0;
1008  constexpr int MVAsentinelValue = -99;
1009  if (computeMuonIDMVA_) {
1010  if (muon.isLooseMuon()) {
1011  mvaID = globalCache()->muonMvaIDEstimator().computeMVAID(muon)[1];
1012  } else {
1013  mvaID = MVAsentinelValue;
1014  }
1015  muon.setMvaIDValue(mvaID);
1016  muon.setSelector(reco::Muon::MvaIDwpMedium, muon.mvaIDValue() > mvaIDmediumCut_);
1017  muon.setSelector(reco::Muon::MvaIDwpTight, muon.mvaIDValue() > mvaIDtightCut_);
1018  }
1019 
1020  //SOFT MVA
1021  if (computeSoftMuonMVA_) {
1022  float mva = globalCache()->softMuonMvaEstimator().computeMva(muon);
1023  muon.setSoftMvaValue(mva);
1024  //preselection in SoftMuonMvaEstimator.cc
1025  muon.setSelector(reco::Muon::SoftMvaId, muon.softMvaValue() > 0.58); //WP choose for bmm4
1026 
1027  // run3 soft mva
1028  muon.setSoftMvaRun3Value(computeSoftMvaRun3(*softMuonMvaRun3Booster_, muon));
1029  }
1030  }
1031 
1032  // put products in Event
1034 
1035  if (isolator_.enabled())
1036  isolator_.endEvent();
1037 }
1038 
1040  const MuonBaseRef& muonRef,
1041  const reco::CandidateBaseRef& baseRef,
1042  const GenAssociations& genMatches,
1043  const IsoDepositMaps& deposits,
1044  const IsolationValueMaps& isolationValues) const {
1045  // in the particle flow algorithm,
1046  // the muon momentum is recomputed.
1047  // the new value is stored as the momentum of the
1048  // resulting PFCandidate of type Muon, and choosen
1049  // as the pat::Muon momentum
1050  if (useParticleFlow_)
1051  aMuon.setP4(aMuon.pfCandidateRef()->p4());
1052  if (embedTrack_)
1053  aMuon.embedTrack();
1055  aMuon.embedStandAloneMuon();
1056  if (embedCombinedMuon_)
1057  aMuon.embedCombinedMuon();
1058 
1059  // embed the TeV refit track refs (only available for globalMuons)
1060  if (aMuon.isGlobalMuon()) {
1062  aMuon.embedPickyMuon();
1064  aMuon.embedTpfmsMuon();
1066  aMuon.embedDytMuon();
1067  }
1068 
1069  // embed best tracks (at the end, so unless forceEmbedBestTrack_ is true we can save some space not embedding them twice)
1070  if (embedBestTrack_)
1074 
1075  // store the match to the generated final state muons
1076  if (addGenMatch_) {
1077  for (auto const& genMatch : genMatches) {
1078  reco::GenParticleRef genMuon = (*genMatch)[baseRef];
1079  aMuon.addGenParticleRef(genMuon);
1080  }
1081  if (embedGenMatch_)
1082  aMuon.embedGenParticle();
1083  }
1084  if (efficiencyLoader_.enabled()) {
1085  efficiencyLoader_.setEfficiencies(aMuon, muonRef);
1086  }
1087 
1088  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
1089  if (useParticleFlow_) {
1090  if (deposits[j]->contains(baseRef.id())) {
1091  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[baseRef]);
1092  } else if (deposits[j]->contains(muonRef.id())) {
1093  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
1094  } else {
1095  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
1097  }
1098  } else {
1099  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
1100  }
1101  }
1102 
1103  for (size_t j = 0; j < isolationValues.size(); ++j) {
1104  if (useParticleFlow_) {
1105  if (isolationValues[j]->contains(baseRef.id())) {
1107  } else if (isolationValues[j]->contains(muonRef.id())) {
1109  } else {
1110  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
1112  }
1113  } else {
1115  }
1116  }
1117 
1118  if (resolutionLoader_.enabled()) {
1120  }
1121 }
1122 
1125  aMuon.polarP4(),
1126  miniIsoParams_[0],
1127  miniIsoParams_[1],
1128  miniIsoParams_[2],
1129  miniIsoParams_[3],
1130  miniIsoParams_[4],
1131  miniIsoParams_[5],
1132  miniIsoParams_[6],
1133  miniIsoParams_[7],
1134  miniIsoParams_[8]);
1135  aMuon.setMiniPFIsolation(miniiso);
1136 }
1137 
1138 double PATMuonProducer::getRelMiniIsoPUCorrected(const pat::Muon& muon, double rho, const std::vector<double>& area) {
1139  double mindr(miniIsoParams_[0]);
1140  double maxdr(miniIsoParams_[1]);
1141  double kt_scale(miniIsoParams_[2]);
1142  double drcut = pat::miniIsoDr(muon.polarP4(), mindr, maxdr, kt_scale);
1143  return pat::muonRelMiniIsoPUCorrected(muon.miniPFIsolation(), muon.polarP4(), drcut, rho, area);
1144 }
1145 
1147  constexpr double dR_threshold = 0.4;
1148  constexpr double dR2_threshold = dR_threshold * dR_threshold;
1149  constexpr double mix_fraction = 0.5;
1150  enum particleType { CH = 0, NH = 1, PH = 2, OTHER = 100000 };
1151  double val_PuppiWithLep = 0.0;
1152  double val_PuppiWithoutLep = 0.0;
1153 
1154  for (const auto& cand : *pc) { //pat::pat::PackedCandidate loop start
1155 
1156  const particleType pType = isChargedHadron(cand.pdgId()) ? CH
1157  : isNeutralHadron(cand.pdgId()) ? NH
1158  : isPhoton(cand.pdgId()) ? PH
1159  : OTHER;
1160  if (pType == OTHER) {
1161  if (cand.pdgId() != 1 && cand.pdgId() != 2 && abs(cand.pdgId()) != 11 && abs(cand.pdgId()) != 13) {
1162  LogTrace("PATMuonProducer") << "candidate with PDGID = " << cand.pdgId()
1163  << " is not CH/NH/PH/e/mu or 1/2 (and this is removed from isolation calculation)"
1164  << std::endl;
1165  }
1166  continue;
1167  }
1168  double d_eta = std::abs(cand.eta() - muon.eta());
1169  if (d_eta > dR_threshold)
1170  continue;
1171 
1172  double d_phi = std::abs(reco::deltaPhi(cand.phi(), muon.phi()));
1173  if (d_phi > dR_threshold)
1174  continue;
1175 
1176  double dR2 = reco::deltaR2(cand, muon);
1177  if (dR2 > dR2_threshold)
1178  continue;
1179  if (pType == CH && dR2 < 0.0001 * 0.0001)
1180  continue;
1181  if (pType == NH && dR2 < 0.01 * 0.01)
1182  continue;
1183  if (pType == PH && dR2 < 0.01 * 0.01)
1184  continue;
1185  val_PuppiWithLep += cand.pt() * cand.puppiWeight();
1186  val_PuppiWithoutLep += cand.pt() * cand.puppiWeightNoLep();
1187 
1188  } //pat::pat::PackedCandidate loop end
1189 
1190  double reliso_Puppi_withLep = val_PuppiWithLep / muon.pt();
1191  double reliso_Puppi_withoutlep = val_PuppiWithoutLep / muon.pt();
1192  double reliso_Puppi_combined = mix_fraction * reliso_Puppi_withLep + (1.0 - mix_fraction) * reliso_Puppi_withoutlep;
1193  return reliso_Puppi_combined;
1194 }
1195 
1197 
1199 
1200 bool PATMuonProducer::isPhoton(long pdgid) { return pdgid == 22; }
1201 
1202 // ParameterSet description for module
1205  iDesc.setComment("PAT muon producer module");
1206 
1207  // input source
1208  iDesc.add<edm::InputTag>("muonSource", edm::InputTag("no default"))->setComment("input collection");
1209 
1210  // embedding
1211  iDesc.add<bool>("embedMuonBestTrack", true)->setComment("embed muon best track (global pflow)");
1212  iDesc.add<bool>("embedTunePMuonBestTrack", true)->setComment("embed muon best track (muon only)");
1213  iDesc.add<bool>("forceBestTrackEmbedding", true)
1214  ->setComment(
1215  "force embedding separately the best tracks even if they're already embedded e.g. as tracker or global "
1216  "tracks");
1217  iDesc.add<bool>("embedTrack", true)->setComment("embed external track");
1218  iDesc.add<bool>("embedStandAloneMuon", true)->setComment("embed external stand-alone muon");
1219  iDesc.add<bool>("embedCombinedMuon", false)->setComment("embed external combined muon");
1220  iDesc.add<bool>("embedPickyMuon", false)->setComment("embed external picky track");
1221  iDesc.add<bool>("embedTpfmsMuon", false)->setComment("embed external tpfms track");
1222  iDesc.add<bool>("embedDytMuon", false)->setComment("embed external dyt track ");
1223 
1224  // embedding of MET muon corrections
1225  iDesc.add<bool>("embedCaloMETMuonCorrs", true)->setComment("whether to add MET muon correction for caloMET or not");
1226  iDesc.add<edm::InputTag>("caloMETMuonCorrs", edm::InputTag("muonMETValueMapProducer", "muCorrData"))
1227  ->setComment("source of MET muon corrections for caloMET");
1228  iDesc.add<bool>("embedTcMETMuonCorrs", true)->setComment("whether to add MET muon correction for tcMET or not");
1229  iDesc.add<edm::InputTag>("tcMETMuonCorrs", edm::InputTag("muonTCMETValueMapProducer", "muCorrData"))
1230  ->setComment("source of MET muon corrections for tcMET");
1231 
1232  // pf specific parameters
1233  iDesc.add<edm::InputTag>("pfMuonSource", edm::InputTag("pfMuons"))->setComment("particle flow input collection");
1234  iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
1235  iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
1236  iDesc.add<bool>("embedPfEcalEnergy", true)->setComment("add ecal energy as reconstructed by PF");
1237 
1238  // inverse beta computation
1239  iDesc.add<bool>("addInverseBeta", true)->setComment("add combined inverse beta");
1240  iDesc.add<edm::InputTag>("sourceInverseBeta", edm::InputTag("muons", "combined"))
1241  ->setComment("source of inverse beta values");
1242 
1243  // MC matching configurables
1244  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
1245  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
1246  std::vector<edm::InputTag> emptySourceVector;
1247  iDesc
1248  .addNode(edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
1249  edm::ParameterDescription<std::vector<edm::InputTag>>("genParticleMatch", emptySourceVector, true))
1250  ->setComment("input with MC match information");
1251 
1252  // mini-iso
1253  iDesc.add<bool>("computeMiniIso", false)->setComment("whether or not to compute and store electron mini-isolation");
1254  iDesc.add<bool>("computePuppiCombinedIso", false)
1255  ->setComment("whether or not to compute and store puppi combined isolation");
1256 
1257  iDesc.add<edm::InputTag>("pfCandsForMiniIso", edm::InputTag("packedPFCandidates"))
1258  ->setComment("collection to use to compute mini-iso");
1259  iDesc.add<std::vector<double>>("miniIsoParams", std::vector<double>())
1260  ->setComment("mini-iso parameters to use for muons");
1261 
1262  iDesc.add<bool>("addTriggerMatching", false)->setComment("add L1 and HLT matching to offline muon");
1263 
1265 
1266  // IsoDeposit configurables
1267  edm::ParameterSetDescription isoDepositsPSet;
1268  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
1269  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
1270  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
1271  isoDepositsPSet.addOptional<edm::InputTag>("particle");
1272  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
1273  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
1274  isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
1275  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
1276  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
1277  isoDepositsPSet.addOptional<std::vector<edm::InputTag>>("user");
1278  iDesc.addOptional("isoDeposits", isoDepositsPSet);
1279 
1280  // isolation values configurables
1281  edm::ParameterSetDescription isolationValuesPSet;
1282  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
1283  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
1284  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
1285  isolationValuesPSet.addOptional<edm::InputTag>("particle");
1286  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
1287  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
1288  isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
1289  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
1290  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
1291  iDesc.addOptional("isolationValues", isolationValuesPSet);
1292 
1293  iDesc.ifValue(edm::ParameterDescription<bool>("addPuppiIsolation", false, true),
1295  "puppiIsolationChargedHadrons",
1296  edm::InputTag("muonPUPPIIsolation", "h+-DR030-ThresholdVeto000-ConeVeto000"),
1297  true) and
1299  "puppiIsolationNeutralHadrons",
1300  edm::InputTag("muonPUPPIIsolation", "h0-DR030-ThresholdVeto000-ConeVeto001"),
1301  true) and
1303  "puppiIsolationPhotons",
1304  edm::InputTag("muonPUPPIIsolation", "gamma-DR030-ThresholdVeto000-ConeVeto001"),
1305  true) and
1307  "puppiNoLeptonsIsolationChargedHadrons",
1308  edm::InputTag("muonPUPPINoLeptonsIsolation", "h+-DR030-ThresholdVeto000-ConeVeto000"),
1309  true) and
1311  "puppiNoLeptonsIsolationNeutralHadrons",
1312  edm::InputTag("muonPUPPINoLeptonsIsolation", "h0-DR030-ThresholdVeto000-ConeVeto001"),
1313  true) and
1315  "puppiNoLeptonsIsolationPhotons",
1316  edm::InputTag("muonPUPPINoLeptonsIsolation", "gamma-DR030-ThresholdVeto000-ConeVeto001"),
1317  true)) or
1318  false >> edm::EmptyGroupDescription());
1319 
1320  // Efficiency configurables
1321  edm::ParameterSetDescription efficienciesPSet;
1322  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
1323  iDesc.add("efficiencies", efficienciesPSet);
1324  iDesc.add<bool>("addEfficiencies", false);
1325 
1326  // Check to see if the user wants to add user data
1327  edm::ParameterSetDescription userDataPSet;
1329  iDesc.addOptional("userData", userDataPSet);
1330 
1331  edm::ParameterSetDescription isolationPSet;
1332  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
1333  iDesc.add("userIsolation", isolationPSet);
1334 
1335  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
1336  edm::ParameterSetDescription highLevelPSet;
1337  highLevelPSet.setAllowAnything();
1338  iDesc.addNode(edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true))
1339  ->setComment("input with high level selection");
1341  ->setComment("input with high level selection");
1342 
1343  //descriptions.add("PATMuonProducer", iDesc);
1344 }
1345 
1346 // embed various impact parameters with errors
1347 // embed high level selection
1352  bool primaryVertexIsValid,
1354  bool beamspotIsValid) {
1355  // Correct to PV
1356 
1357  // PV2D
1358  aMuon.setDB(track->dxy(primaryVertex.position()),
1359  track->dxyError(primaryVertex.position(), primaryVertex.covariance()),
1360  pat::Muon::PV2D);
1361 
1362  // PV3D
1363  std::pair<bool, Measurement1D> result =
1365  double d0_corr = result.second.value();
1366  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
1367  aMuon.setDB(d0_corr, d0_err, pat::Muon::PV3D);
1368 
1369  // Correct to beam spot
1370 
1371  // BS2D
1372  aMuon.setDB(track->dxy(beamspot), track->dxyError(beamspot), pat::Muon::BS2D);
1373 
1374  // make a fake vertex out of beam spot
1375  reco::Vertex vBeamspot(beamspot.position(), beamspot.rotatedCovariance3D());
1376 
1377  // BS3D
1378  result = IPTools::signedImpactParameter3D(tt, GlobalVector(track->px(), track->py(), track->pz()), vBeamspot);
1379  d0_corr = result.second.value();
1380  d0_err = beamspotIsValid ? result.second.error() : -1.0;
1381  aMuon.setDB(d0_corr, d0_err, pat::Muon::BS3D);
1382 
1383  // PVDZ
1384  aMuon.setDB(
1385  track->dz(primaryVertex.position()), std::hypot(track->dzError(), primaryVertex.zError()), pat::Muon::PVDZ);
1386 }
1387 
1389 
bool embedTpfmsMuon_
embed track from tpfms muon fit into the muon
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
bool useUserData_
add user data to the muon (this will be data members of th muon even w/o embedding) ...
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T >>> &tokens)
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_photons_
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
void setComment(std::string const &value)
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
bool addPuppiIsolation_
add puppi isolation
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void embedDytMuon()
embed reference to the above dyt Track
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
Definition: Matriplex.h:436
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void embedTpfmsMuon()
embed reference to the above tpfms Track
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > tcMETMuonCorrsToken_
source of tcMET muon corrections
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:115
bool embedTcMETMuonCorrs_
embed muon MET correction info for tcMET into the muon
class definition
void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData &t)
edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
input source of the primary vertex
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:55
static const int OTHER
edm::EDGetTokenT< edm::ValueMap< reco::MuonTimeExtra > > muonTimeExtraToken_
input tag for reading inverse beta
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
void embedCombinedMuon()
set reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon...
std::string fullPath() const
Definition: FileInPath.cc:161
edm::EDGetTokenT< double > rho_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
input source
void embedTunePMuonBestTrack(bool force=false)
bool addEfficiencies_
add efficiencies to the muon (this will be data members of th muon even w/o embedding) ...
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > caloMETMuonCorrsToken_
source of caloMET muon corrections
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
enum start value shifted to 81 so as to avoid clashes with PDG codes
void setAllowAnything()
allow any parameter label/value pairs
void setSimFlavour(int f)
Definition: Muon.h:323
bool isAValidMuonTrack(const MuonTrackType &type) const
bool embedCaloMETMuonCorrs_
embed muon MET correction info for caloMET into the muon
bool isChargedHadron(long pdgid)
bool exists(std::string const &parameterName) const
checks if a parameter exists
~PATMuonProducer() override
default destructur
edm::EDGetTokenT< edm::ValueMap< reco::MuonSimInfo > > simInfo_
MC info.
T const * product() const
Definition: Handle.h:70
void embedMuonBestTrack(bool force=false)
std::vector< pat::PackedCandidate > PackedCandidateCollection
void setIsolationPUPPINoLeptons(float chargedhadrons, float neutralhadrons, float photons)
sets PUPPINoLeptons isolations
Definition: Muon.h:207
void setMuonMiniIso(pat::Muon &aMuon, const pat::PackedCandidateCollection *pc)
PATMuonProducer(const edm::ParameterSet &iConfig, PATMuonHeavyObjectCache const *)
default constructir
std::unique_ptr< pat::XGBooster > softMuonMvaRun3Booster_
bool addTriggerMatching_
Trigger.
void setSimBX(int bx)
Definition: Muon.h:327
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
bool embedBestTrack_
embed the track from best muon measurement (global pflow)
CH
LTS and SET for low trigger suppression.
edm::EDGetTokenT< reco::JetCorrector > mvaL1Corrector_
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:81
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackBuilderToken_
bool addResolutions_
add resolutions to the muon (this will be data members of th muon even w/o embedding) ...
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_charged_hadrons_
std::vector< double > miniIsoParams_
void setSimPhi(float phi)
Definition: Muon.h:333
Log< level::Error, false > LogError
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
void setSimProdRho(float rho)
Definition: Muon.h:329
void setSimHeaviestMotherFlavour(int id)
Definition: Muon.h:324
reco::Muon::Selector makeSelectorBitset(reco::Muon const &muon, reco::Vertex const *vertex=nullptr, bool run2016_hip_mitigation=false)
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:212
assert(be >=bs)
void setPFCandidateRef(const reco::PFCandidateRef &ref)
add a reference to the source IsolatedPFCandidate
Definition: Muon.h:141
void embedHighLevel(pat::Muon &aMuon, reco::TrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
std::vector< double > effectiveAreaVec_
const std::string names[nVars_]
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_neutral_hadrons_
void setSimType(reco::MuonSimType type)
Definition: Muon.h:321
void embedStandAloneMuon()
set reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
#define LogTrace(id)
edm::EDGetTokenT< reco::JetTagCollection > mvaBTagCollectionTag_
edm::EDGetTokenT< reco::PFCandidateCollection > pfMuonToken_
input source pfCandidates that will be to be transformed into pat::Muons, when using PF2PAT ...
void setIsolationPUPPI(float chargedhadrons, float neutralhadrons, float photons)
sets PUPPI isolations
Definition: Muon.h:201
ProductID id() const
Definition: RefToBase.h:216
pat::helper::MultiIsolator isolator_
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:84
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
Definition: Lepton.h:191
Definition: HeavyIon.h:7
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
static void fillDescription(edm::ParameterSetDescription &iDesc)
pat::MuonMvaIDEstimator const & muonMvaIDEstimator() const
reco::TransientTrack build(const reco::Track *p) const
std::vector< IsolationLabel > IsolationLabels
edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
input source of the primary vertex/beamspot
bool addInverseBeta_
add combined inverse beta measurement into the muon
bool useParticleFlow_
switch to use particle flow (PF2PAT) or not
pat::PATUserDataHelper< pat::Muon > userDataHelper_
helper class to add userData to the muon
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
char const * label
bool embedStandAloneMuon_
embed track from muon system into the muon
void setComment(std::string const &value)
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
int iEvent
Definition: GenABIO.cc:224
Definition: TTTypes.h:54
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
ALPAKA_FN_ACC static ALPAKA_FN_INLINE float dR2(Position4 pos1, Position4 pos2)
bool embedTrack_
embed the track from inner tracker into the muon
void setDB(double dB, double edB, IPTYPE type=PV2D)
Definition: Muon.h:247
bool addGenMatch_
add generator match information
PATMuonHeavyObjectCache(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
description of config file parameters
float computeSoftMvaRun3(XGBooster &booster, const Muon &muon)
Definition: Muon.py:1
void fillL1TriggerInfo(pat::Muon &muon, edm::Handle< std::vector< pat::TriggerObjectStandAlone >> &triggerObjects, const edm::TriggerNames &names, const edm::ESHandle< GlobalTrackingGeometry > &geometry)
double muonRelMiniIsoPUCorrected(const PFIsolation &iso, const reco::Candidate::PolarLorentzVector &p4, double dr, double rho, const std::vector< double > &area)
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
bool embedPfEcalEnergy_
add ecal PF energy
void embedGenParticle()
Definition: PATObject.h:768
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
void embedPFCandidate()
embed the IsolatedPFCandidate pointed to by pfCandidateRef_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool isAvailable() const
Definition: Ref.h:541
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
everything that needs to be done during the event loop
bool computeMuonIDMVA_
standard muon selectors
def pv(vc)
Definition: MetAnalyzer.py:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double relMiniIsoPUCorrected(const pat::Muon &aMuon, double rho)
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
key
prepare the HTCondor submission files and eventually submit them
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
static void globalEndJob(PATMuonHeavyObjectCache *)
static std::string const triggerResults
Definition: EdmProvDump.cc:47
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void fillMuon(Muon &aMuon, const MuonBaseRef &muonRef, const reco::CandidateBaseRef &baseRef, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const IsolationValueMaps &isolationValues) const
common muon filling, for both the standard and PF2PAT case
double puppiCombinedIsolation(const pat::Muon &muon, const pat::PackedCandidateCollection *pc)
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:221
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
void readTimeExtra(const reco::MuonTimeExtra &t)
std::vector< std::string > hltCollectionFilters_
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
float miniIsoDr(const reco::Candidate::PolarLorentzVector &p4, float mindr, float maxdr, float kt_scale)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
void fillHltTriggerInfo(pat::Muon &muon, edm::Handle< std::vector< pat::TriggerObjectStandAlone >> &triggerObjects, const edm::TriggerNames &names, const std::vector< std::string > &collection_names)
static std::unique_ptr< PATMuonHeavyObjectCache > initializeGlobalCache(const edm::ParameterSet &iConfig)
Definition: DetId.h:17
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:17
void initSimInfo(void)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:751
void setPfEcalEnergy(float pfEcalEnergy)
Definition: Muon.h:277
bool embedTunePBestTrack_
embed the track from best muon measurement (muon only)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
double getRelMiniIsoPUCorrected(const pat::Muon &muon, double rho, const std::vector< double > &area)
void setSimMotherPdgId(int id)
Definition: Muon.h:326
void addTriggerObjectMatch(const TriggerObjectStandAlone &trigObj)
add a trigger match
Definition: PATObject.h:238
void setExtSimType(reco::ExtendedMuonSimType type)
Definition: Muon.h:322
std::vector< MuonChamberMatch > & matches()
get muon matching information
Definition: Muon.h:145
std::unique_ptr< const pat::MuonMvaIDEstimator > muonMvaIDEstimator_
void setMiniPFIsolation(PFIsolation const &iso)
Definition: Lepton.h:217
std::unique_ptr< const pat::SoftMuonMvaEstimator > softMuonMvaEstimator_
bool isValid() const
Definition: HandleBase.h:70
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
double mvaIDtightCut_
working points of the muon MVA ID
edm::EDGetTokenT< reco::JetCorrector > mvaL1L2L3ResCorrector_
void setSimProdZ(float z)
Definition: Muon.h:330
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
pat::helper::EfficiencyLoader efficiencyLoader_
helper class to add efficiencies to the muon
HLT enums.
bool embedPickyMuon_
embed track from picky muon fit into the muon
void setNormChi2(double normChi2)
Definition: Muon.h:262
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
bool embedDytMuon_
embed track from DYT muon fit into the muon
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData &t)
pat::CalculatePtRatioRel const & calculatePtRatioRel() const
void setSimPdgId(int id)
Definition: Muon.h:325
const edm::EDPutTokenT< std::vector< Muon > > patMuonPutToken_
void setSimPt(float pt)
Definition: Muon.h:331
reco::PFCandidateRef pfCandidateRef() const
Calculates a lepton&#39;s calorimetric isolation energy.
bool isPhoton(long pdgid)
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
isolation value pair for temporary storage before being folded into the muon
edm::EDGetTokenT< std::vector< pat::TriggerObjectStandAlone > > triggerObjects_
bool embedGenMatch_
embed the gen match information into the muon
IsolationLabels isoDepositLabels_
input source for isoDeposits
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
input tags for generator match information
PFIsolation getMiniPFIsolation(const pat::PackedCandidateCollection *pfcands, const reco::Candidate::PolarLorentzVector &p4, float mindr=0.05, float maxdr=0.2, float kt_scale=10.0, float ptthresh=0.5, float deadcone_ch=0.0001, float deadcone_pu=0.01, float deadcone_ph=0.01, float deadcone_nh=0.01, float dZ_cut=0.0)
std::unique_ptr< const pat::CalculatePtRatioRel > calculatePtRatioRel_
static constexpr int DT
Definition: MuonSubdetId.h:11
IsolationLabels isolationValueLabels_
input source isolation value maps
void embedPickyMuon()
embed reference to the above picky Track
static constexpr int CSC
Definition: MuonSubdetId.h:12
primaryVertex
hltOfflineBeamSpot for HLTMON
bool forceEmbedBestTrack_
force separate embed of the best track even if already embedded
edm::RefToBase< reco::Muon > MuonBaseRef
typedefs for convenience
bool embedPFCandidate_
embed pfCandidates into the muon
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
void setNumberOfValidHits(unsigned int numberOfValidHits)
Definition: Muon.h:255
void setSimEta(float eta)
Definition: Muon.h:332
bool embedCombinedMuon_
embed track of the combined fit into the muon
Analysis-level muon class.
Definition: Muon.h:51
pat::helper::KinResolutionsLoader resolutionLoader_
helper class to add resolutions to the muon
static std::string const source
Definition: EdmProvDump.cc:49
bool isGlobalMuon() const override
Definition: Muon.h:303
void setP4(const LorentzVector &p4) final
set 4-momentum
pat::SoftMuonMvaEstimator const & softMuonMvaEstimator() const
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
def move(src, dest)
Definition: eostools.py:511
std::optional< GlobalPoint > getMuonDirection(const reco::MuonChamberMatch &chamberMatch, const edm::ESHandle< GlobalTrackingGeometry > &geometry, const DetId &chamberId)
bool isNeutralHadron(long pdgid)
genMatch
add extra information on genMatch
Global3DVector GlobalVector
Definition: GlobalVector.h:10
Calculates a lepton&#39;s tracker isolation pt.
Analysis-level trigger object class (stand-alone)
void setSimMatchQuality(float quality)
Definition: Muon.h:334
void setSimTpEvent(int tpEvent)
Definition: Muon.h:328
bool embedHighLevelSelection_
embed high level selection variables