CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
MuonIDTableProducer Class Reference
Inheritance diagram for MuonIDTableProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuonIDTableProducer (const edm::ParameterSet &iConfig)
 
 ~MuonIDTableProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, edm::EventSetup const &) const override
 

Static Private Member Functions

static bool isMediumMuonHIP (const pat::Muon &muon)
 
static bool isSoftMuonHIP (const pat::Muon &muon, const reco::Vertex &vtx)
 
static bool isTrackerHighPt (const pat::Muon &mu, const reco::Vertex &primaryVertex)
 

Private Attributes

std::string name_
 
edm::EDGetTokenT< std::vector< pat::Muon > > src_
 
edm::EDGetTokenT< std::vector< reco::Vertex > > srcVtx_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 19 of file MuonIDTableProducer.cc.

Constructor & Destructor Documentation

◆ MuonIDTableProducer()

MuonIDTableProducer::MuonIDTableProducer ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 21 of file MuonIDTableProducer.cc.

22  : name_(iConfig.getParameter<std::string>("name")),
23  src_(consumes<std::vector<pat::Muon>>(iConfig.getParameter<edm::InputTag>("muons"))),
24  srcVtx_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("vertices"))) {
25  produces<nanoaod::FlatTable>();
26  }

◆ ~MuonIDTableProducer()

MuonIDTableProducer::~MuonIDTableProducer ( )
inlineoverride

Definition at line 28 of file MuonIDTableProducer.cc.

28 {};

Member Function Documentation

◆ fillDescriptions()

static void MuonIDTableProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 30 of file MuonIDTableProducer.cc.

30  {
32  desc.add<edm::InputTag>("muons")->setComment("input muon collection");
33  desc.add<edm::InputTag>("vertices", edm::InputTag("offlineSlimmedPrimaryVertices"))
34  ->setComment("input vertex collection, for dxy/dz");
35  desc.add<std::string>("name")->setComment("name of the muon nanoaod::FlatTable we are extending with IDs");
36  descriptions.add("muonIDTable", desc);
37  }

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

◆ isMediumMuonHIP()

bool MuonIDTableProducer::isMediumMuonHIP ( const pat::Muon muon)
staticprivate

Definition at line 93 of file MuonIDTableProducer.cc.

93  {
94  bool goodGlob = mu.isGlobalMuon() && mu.globalTrack()->normalizedChi2() < 3 &&
95  mu.combinedQuality().chi2LocalPosition < 12 && mu.combinedQuality().trkKink < 20;
96  bool isMedium = muon::isLooseMuon(mu) && mu.innerTrack()->validFraction() > 0.49 &&
97  muon::segmentCompatibility(mu) > (goodGlob ? 0.303 : 0.451);
98  return isMedium;
99 }

References muon::isLooseMuon(), amptDefaultParameters_cff::mu, and muon::segmentCompatibility().

Referenced by produce().

◆ isSoftMuonHIP()

bool MuonIDTableProducer::isSoftMuonHIP ( const pat::Muon muon,
const reco::Vertex vtx 
)
staticprivate

Definition at line 101 of file MuonIDTableProducer.cc.

101  {
103  mu.innerTrack()->hitPattern().trackerLayersWithMeasurement() > 5 &&
104  mu.innerTrack()->hitPattern().pixelLayersWithMeasurement() > 0 &&
105  std::abs(mu.innerTrack()->dxy(vtx.position())) < 0.3 && std::abs(mu.innerTrack()->dz(vtx.position())) < 20.;
106 }

References funct::abs(), muon::isGoodMuon(), amptDefaultParameters_cff::mu, muon::TMOneStationTight, and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by produce().

◆ isTrackerHighPt()

bool MuonIDTableProducer::isTrackerHighPt ( const pat::Muon mu,
const reco::Vertex primaryVertex 
)
staticprivate

Definition at line 108 of file MuonIDTableProducer.cc.

108  {
109  return (mu.numberOfMatchedStations() > 1 && (mu.muonBestTrack()->ptError() / mu.muonBestTrack()->pt()) < 0.3 &&
110  std::abs(mu.muonBestTrack()->dxy(primaryVertex.position())) < 0.2 &&
111  std::abs(mu.muonBestTrack()->dz(primaryVertex.position())) < 0.5 &&
112  mu.innerTrack()->hitPattern().numberOfValidPixelHits() > 0 &&
113  mu.innerTrack()->hitPattern().trackerLayersWithMeasurement() > 5);
114 }

References funct::abs(), amptDefaultParameters_cff::mu, and BeamMonitor_cff::primaryVertex.

Referenced by produce().

◆ produce()

void MuonIDTableProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
edm::EventSetup const &  iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 52 of file MuonIDTableProducer.cc.

52  {
54  iEvent.getByToken(src_, muons);
56  iEvent.getByToken(srcVtx_, vertices);
57 
58  unsigned int ncand = muons->size();
59 
60  const reco::Vertex& pv = vertices->front(); // consistent with IP information in slimmedLeptons.
61 
62  bool isRun2016BCDEF = (272007 <= iEvent.run() && iEvent.run() <= 278808);
63  std::vector<uint8_t> tight(ncand, 0), highPt(ncand, 0), soft(ncand, 0), medium(ncand, 0);
64  for (unsigned int i = 0; i < ncand; ++i) {
65  const pat::Muon& mu = (*muons)[i];
66  tight[i] = muon::isTightMuon(mu, pv);
67  highPt[i] = muon::isHighPtMuon(mu, pv) ? 2 : isTrackerHighPt(mu, pv);
68  soft[i] = isRun2016BCDEF ? isSoftMuonHIP(mu, pv) : muon::isSoftMuon(mu, pv);
69  medium[i] = isRun2016BCDEF ? isMediumMuonHIP(mu) : muon::isMediumMuon(mu);
70  }
71 
72  auto tab = std::make_unique<nanoaod::FlatTable>(ncand, name_, false, true);
73  tab->addColumn<uint8_t>("tightId", tight, "POG Tight muon ID", nanoaod::FlatTable::BoolColumn);
74  tab->addColumn<uint8_t>(
75  "highPtId",
76  highPt,
77  "POG highPt muon ID (1 = tracker high pT, 2 = global high pT, which includes tracker high pT)",
79  tab->addColumn<uint8_t>(
80  "softId",
81  soft,
82  "POG Soft muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)",
84  tab->addColumn<uint8_t>(
85  "mediumId",
86  medium,
87  "POG Medium muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)",
89 
90  iEvent.put(std::move(tab));
91 }

References nanoaod::FlatTable::BoolColumn, mps_fire::i, iEvent, muon::isHighPtMuon(), muon::isMediumMuon(), isMediumMuonHIP(), muon::isSoftMuon(), isSoftMuonHIP(), muon::isTightMuon(), isTrackerHighPt(), eostools::move(), amptDefaultParameters_cff::mu, PDWG_BPHSkim_cff::muons, name_, MetAnalyzer::pv(), src_, srcVtx_, nanoaod::FlatTable::UInt8Column, and pwdgSkimBPark_cfi::vertices.

Member Data Documentation

◆ name_

std::string MuonIDTableProducer::name_
private

Definition at line 42 of file MuonIDTableProducer.cc.

Referenced by produce().

◆ src_

edm::EDGetTokenT<std::vector<pat::Muon> > MuonIDTableProducer::src_
private

Definition at line 43 of file MuonIDTableProducer.cc.

Referenced by produce().

◆ srcVtx_

edm::EDGetTokenT<std::vector<reco::Vertex> > MuonIDTableProducer::srcVtx_
private

Definition at line 44 of file MuonIDTableProducer.cc.

Referenced by produce().

PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
muon::isSoftMuon
bool isSoftMuon(const reco::Muon &, const reco::Vertex &, bool run2016_hip_mitigation=false)
Definition: MuonSelectors.cc:931
muon
Definition: MuonCocktails.h:17
muon::segmentCompatibility
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
Definition: MuonSelectors.cc:61
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
edm::Handle
Definition: AssociativeIterator.h:50
MuonIDTableProducer::srcVtx_
edm::EDGetTokenT< std::vector< reco::Vertex > > srcVtx_
Definition: MuonIDTableProducer.cc:44
BeamMonitor_cff.primaryVertex
primaryVertex
hltOfflineBeamSpot for HLTMON
Definition: BeamMonitor_cff.py:7
muon::isGoodMuon
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
Definition: MuonSelectors.cc:664
muon::isLooseMuon
bool isLooseMuon(const reco::Muon &)
Definition: MuonSelectors.cc:910
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
badGlobalMuonTaggersAOD_cff.vtx
vtx
Definition: badGlobalMuonTaggersAOD_cff.py:5
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
muon::isHighPtMuon
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
Definition: MuonSelectors.cc:947
muon::TMOneStationTight
Definition: MuonSelectors.h:32
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
muon::isTightMuon
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
Definition: MuonSelectors.cc:895
MuonIDTableProducer::isMediumMuonHIP
static bool isMediumMuonHIP(const pat::Muon &muon)
Definition: MuonIDTableProducer.cc:93
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
muon::isMediumMuon
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
Definition: MuonSelectors.cc:914
nanoaod::FlatTable::UInt8Column
Definition: FlatTable.h:41
MuonIDTableProducer::isSoftMuonHIP
static bool isSoftMuonHIP(const pat::Muon &muon, const reco::Vertex &vtx)
Definition: MuonIDTableProducer.cc:101
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
MuonIDTableProducer::isTrackerHighPt
static bool isTrackerHighPt(const pat::Muon &mu, const reco::Vertex &primaryVertex)
Definition: MuonIDTableProducer.cc:108
eostools.move
def move(src, dest)
Definition: eostools.py:511
MuonIDTableProducer::src_
edm::EDGetTokenT< std::vector< pat::Muon > > src_
Definition: MuonIDTableProducer.cc:43
MuonIDTableProducer::name_
std::string name_
Definition: MuonIDTableProducer.cc:42
nanoaod::FlatTable::BoolColumn
Definition: FlatTable.h:42
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:126
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7