CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
BadGlobalMuonTagger Class Reference
Inheritance diagram for BadGlobalMuonTagger:
edm::global::EDFilter<> edm::global::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 BadGlobalMuonTagger (const edm::ParameterSet &iConfig)
 
bool filter (edm::StreamID iID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
 ~BadGlobalMuonTagger () override
 
- Public Member Functions inherited from edm::global::EDFilter<>
 EDFilter ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilterBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

bool outInOnly (const reco::Muon &mu) const
 
bool partnerId (const reco::Muon &mu) const
 
bool preselection (const reco::Muon &mu) const
 
bool safeId (const reco::Muon &mu) const
 
bool tighterId (const reco::Muon &mu) const
 
bool tightGlobal (const reco::Muon &mu) const
 

Private Attributes

edm::EDGetTokenT< edm::View< reco::Muon > > muons_
 
double ptCut_
 
bool selectClones_
 
bool taggingMode_
 
bool verbose_
 
edm::EDGetTokenT< std::vector< reco::Vertex > > vtx_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDFilterBase
typedef EDFilterBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 14 of file BadGlobalMuonTagger.cc.

Constructor & Destructor Documentation

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

Definition at line 49 of file BadGlobalMuonTagger.cc.

49  :
51  vtx_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("vtx"))),
52  ptCut_(iConfig.getParameter<double>("muonPtCut")),
53  selectClones_(iConfig.getParameter<bool>("selectClones")),
54  taggingMode_(iConfig.getParameter<bool> ("taggingMode")),
55  verbose_(iConfig.getUntrackedParameter<bool> ("verbose",false))
56 {
57  produces<edm::PtrVector<reco::Muon>>("bad");
58  produces<bool>("notBadEvent");
59 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::View< reco::Muon > > muons_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< reco::Vertex > > vtx_
BadGlobalMuonTagger::~BadGlobalMuonTagger ( )
inlineoverride

Definition at line 17 of file BadGlobalMuonTagger.cc.

References filter(), and iEvent.

17 {}

Member Function Documentation

bool BadGlobalMuonTagger::filter ( edm::StreamID  iID,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
override

Definition at line 63 of file BadGlobalMuonTagger.cc.

References funct::abs(), DEFINE_FWK_MODULE, reco::deltaR2(), PVValHelper::eta, runEdmFileComparison::found, edm::Event::getByToken(), mps_fire::i, min(), eostools::move(), RPCpg::mu, extraflags_cff::muons, muons_, gen::n, MillePedeFileConverter_cfg::out, partnerId(), phi, preselection(), EnergyCorrector::pt, ptCut_, edm::Event::put(), nanoDQM_cfi::PV, safeId(), reco::Muon::SegmentArbitration, selectClones_, muon::sharedSegments(), taggingMode_, tighterId(), tightGlobal(), verbose_, extraflags_cff::vtx, and vtx_.

Referenced by ~BadGlobalMuonTagger().

63  {
64  using namespace edm;
65 
66  // read input
69  std::vector<int> goodMuon;
70 
71  iEvent.getByToken(vtx_, vtx);
72  assert(!vtx->empty());
73  const auto &PV = vtx->front().position();
74 
75  std::unique_ptr<edm::PtrVector<reco::Muon>> out(new edm::PtrVector<reco::Muon>());
76  iEvent.getByToken(muons_, hmuons);
77  const edm::View<reco::Muon> & muons = *hmuons;
78  for (const reco::Muon & mu : muons) {
79  if (!mu.isPFMuon() || mu.innerTrack().isNull()) {
80  goodMuon.push_back(-1); // bad but we don't care
81  continue;
82  }
83  if (preselection(mu)) {
84  float dxypv = std::abs(mu.innerTrack()->dxy(PV));
85  float dzpv = std::abs(mu.innerTrack()->dz(PV));
86  if (tighterId(mu)) {
87  bool ipLoose = ((dxypv < 0.5 && dzpv < 2.0) || mu.innerTrack()->hitPattern().pixelLayersWithMeasurement() >= 2);
88  goodMuon.push_back(ipLoose || (!selectClones_ && tightGlobal(mu)));
89  } else if (safeId(mu)) {
90  bool ipTight = (dxypv < 0.2 && dzpv < 0.5);
91  goodMuon.push_back(ipTight);
92  } else {
93  goodMuon.push_back(0);
94  }
95  } else {
96  goodMuon.push_back(3); // maybe good, maybe bad, but we don't care
97  }
98  }
99 
100  bool found = false;
101  for (unsigned int i = 0, n = muons.size(); i < n; ++i) {
102  if (muons[i].pt() < ptCut_ || goodMuon[i] != 0) continue;
103  if (verbose_) printf("potentially bad muon %d of pt %.1f eta %+.3f phi %+.3f\n", int(i+1), muons[i].pt(), muons[i].eta(), muons[i].phi());
104  bool bad = true;
105  if (selectClones_) {
106  bad = false; // unless proven otherwise
107  unsigned int n1 = muons[i].numberOfMatches(reco::Muon::SegmentArbitration);
108  for (unsigned int j = 0; j < n; ++j) {
109  if (j == i || goodMuon[j] <= 0 || !partnerId(muons[j])) continue;
110  unsigned int n2 = muons[j].numberOfMatches(reco::Muon::SegmentArbitration);
111  if (deltaR2(muons[i],muons[j]) < 0.16 || (n1 > 0 && n2 > 0 && muon::sharedSegments(muons[i],muons[j]) >= 0.5*std::min(n1,n2))) {
112  if (verbose_) printf(" tagged as clone of muon %d of pt %.1f eta %+.3f phi %+.3f\n", int(j+1), muons[j].pt(), muons[j].eta(), muons[j].phi());
113  bad = true;
114  break;
115  }
116  }
117  }
118  if (bad) {
119  found = true;
120  out->push_back(muons.ptrAt(i));
121  }
122  }
123 
124  iEvent.put(std::move(out), "bad");
125  iEvent.put(std::unique_ptr<bool>(new bool(!found)), "notBadEvent");
126  return taggingMode_ || found;
127 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool tighterId(const reco::Muon &mu) const
bool safeId(const reco::Muon &mu) const
edm::EDGetTokenT< edm::View< reco::Muon > > muons_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
bool partnerId(const reco::Muon &mu) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
bool tightGlobal(const reco::Muon &mu) const
T min(T a, T b)
Definition: MathUtil.h:58
edm::EDGetTokenT< std::vector< reco::Vertex > > vtx_
int sharedSegments(const reco::Muon &muon1, const reco::Muon &muon2, unsigned int segmentArbitrationMask=reco::MuonSegmentMatch::BestInChamberByDR)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
bool preselection(const reco::Muon &mu) const
HLT enums.
def move(src, dest)
Definition: eostools.py:511
bool BadGlobalMuonTagger::outInOnly ( const reco::Muon mu) const
inlineprivate

Definition at line 27 of file BadGlobalMuonTagger.cc.

References reco::TrackBase::algoMask(), reco::Muon::innerTrack(), reco::TrackBase::isAlgoInMask(), and reco::TrackBase::muonSeededStepOutIn.

Referenced by badGlobalMuonTaggerFWLite.BadGlobalMuonTagger::preselection(), and preselection().

27  {
28  const reco::Track &tk = *mu.innerTrack();
29  return tk.algoMask().count() == 1 && tk.isAlgoInMask(reco::Track::muonSeededStepOutIn);
30  }
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool isAlgoInMask(TrackAlgorithm a) const
Definition: TrackBase.h:395
AlgoMask algoMask() const
Definition: TrackBase.h:393
bool BadGlobalMuonTagger::partnerId ( const reco::Muon mu) const
inlineprivate

Definition at line 44 of file BadGlobalMuonTagger.cc.

References reco::Muon::numberOfMatchedStations(), and reco::LeafCandidate::pt().

Referenced by badGlobalMuonTaggerFWLite.BadGlobalMuonTagger::badMuons(), and filter().

44  {
45  return mu.pt() >= 10 && mu.numberOfMatchedStations() >= 1;
46  }
double pt() const final
transverse momentum
int numberOfMatchedStations(ArbitrationType type=SegmentAndTrackArbitration) const
bool BadGlobalMuonTagger::preselection ( const reco::Muon mu) const
inlineprivate

Definition at line 31 of file BadGlobalMuonTagger.cc.

References outInOnly().

Referenced by badGlobalMuonTaggerFWLite.BadGlobalMuonTagger::badMuons(), and filter().

31  {
32  return (!selectClones_ || outInOnly(mu));
33  }
bool outInOnly(const reco::Muon &mu) const
bool BadGlobalMuonTagger::safeId ( const reco::Muon mu) const
inlineprivate

Definition at line 40 of file BadGlobalMuonTagger.cc.

References reco::Muon::muonBestTrack(), reco::Muon::numberOfMatchedStations(), and tightGlobal().

Referenced by badGlobalMuonTaggerFWLite.BadGlobalMuonTagger::badMuons(), and filter().

40  {
41  if (mu.muonBestTrack()->ptError() > 0.2 * mu.muonBestTrack()->pt()) { return false; }
42  return mu.numberOfMatchedStations() >= 1 || tightGlobal(mu);
43  }
virtual TrackRef muonBestTrack() const
Definition: Muon.h:63
bool tightGlobal(const reco::Muon &mu) const
int numberOfMatchedStations(ArbitrationType type=SegmentAndTrackArbitration) const
bool BadGlobalMuonTagger::tighterId ( const reco::Muon mu) const
inlineprivate

Definition at line 34 of file BadGlobalMuonTagger.cc.

References muon::isMediumMuon(), and reco::Muon::numberOfMatchedStations().

Referenced by badGlobalMuonTaggerFWLite.BadGlobalMuonTagger::badMuons(), and filter().

34  {
35  return muon::isMediumMuon(mu) && mu.numberOfMatchedStations() >= 2;
36  }
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
int numberOfMatchedStations(ArbitrationType type=SegmentAndTrackArbitration) const
bool BadGlobalMuonTagger::tightGlobal ( const reco::Muon mu) const
inlineprivate

Definition at line 37 of file BadGlobalMuonTagger.cc.

References reco::Muon::globalTrack(), and reco::Muon::isGlobalMuon().

Referenced by badGlobalMuonTaggerFWLite.BadGlobalMuonTagger::badMuons(), filter(), badGlobalMuonTaggerFWLite.BadGlobalMuonTagger::safeId(), and safeId().

37  {
38  return mu.isGlobalMuon() && (mu.globalTrack()->hitPattern().muonStationsWithValidHits() >= 3 && mu.globalTrack()->normalizedChi2() <= 20);
39  }
bool isGlobalMuon() const override
Definition: Muon.h:291
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:54

Member Data Documentation

edm::EDGetTokenT<edm::View<reco::Muon> > BadGlobalMuonTagger::muons_
private

Definition at line 22 of file BadGlobalMuonTagger.cc.

Referenced by filter().

double BadGlobalMuonTagger::ptCut_
private
bool BadGlobalMuonTagger::selectClones_
private
bool BadGlobalMuonTagger::taggingMode_
private

Definition at line 25 of file BadGlobalMuonTagger.cc.

Referenced by filter().

bool BadGlobalMuonTagger::verbose_
private

Definition at line 25 of file BadGlobalMuonTagger.cc.

Referenced by filter().

edm::EDGetTokenT<std::vector<reco::Vertex> > BadGlobalMuonTagger::vtx_
private

Definition at line 23 of file BadGlobalMuonTagger.cc.

Referenced by filter().