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 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::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
 
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 () 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
 
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)
 
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::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 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 20 of file MuonIDTableProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 22 of file MuonIDTableProducer.cc.

22  :
23  name_(iConfig.getParameter<std::string>("name")),
24  src_(consumes<std::vector<pat::Muon>>(iConfig.getParameter<edm::InputTag>("muons"))),
25  srcVtx_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("vertices")))
26  {
27  produces<nanoaod::FlatTable>();
28  }
T getParameter(std::string const &) const
edm::EDGetTokenT< std::vector< reco::Vertex > > srcVtx_
edm::EDGetTokenT< std::vector< pat::Muon > > src_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
MuonIDTableProducer::~MuonIDTableProducer ( )
inlineoverride

Definition at line 30 of file MuonIDTableProducer.cc.

30 {};

Member Function Documentation

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

Definition at line 32 of file MuonIDTableProducer.cc.

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

32  {
34  desc.add<edm::InputTag>("muons")->setComment("input muon collection");
35  desc.add<edm::InputTag>("vertices", edm::InputTag("offlineSlimmedPrimaryVertices"))->setComment("input vertex collection, for dxy/dz");
36  desc.add<std::string>("name")->setComment("name of the muon nanoaod::FlatTable we are extending with IDs");
37  descriptions.add("muonIDTable", desc);
38  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool MuonIDTableProducer::isMediumMuonHIP ( const pat::Muon muon)
staticprivate

Definition at line 85 of file MuonIDTableProducer.cc.

References reco::MuonQuality::chi2LocalPosition, reco::Muon::combinedQuality(), pat::Muon::globalTrack(), pat::Muon::innerTrack(), reco::Muon::isGlobalMuon(), muon::isLooseMuon(), muon::segmentCompatibility(), and reco::MuonQuality::trkKink.

Referenced by produce().

85  {
86  bool goodGlob = mu.isGlobalMuon() &&
87  mu.globalTrack()->normalizedChi2() < 3 &&
88  mu.combinedQuality().chi2LocalPosition < 12 &&
89  mu.combinedQuality().trkKink < 20;
90  bool isMedium = muon::isLooseMuon(mu) &&
91  mu.innerTrack()->validFraction() > 0.49 &&
92  muon::segmentCompatibility(mu) > (goodGlob ? 0.303 : 0.451);
93  return isMedium;
94 }
bool isLooseMuon(const reco::Muon &)
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
const int mu
Definition: Constants.h:22
bool MuonIDTableProducer::isSoftMuonHIP ( const pat::Muon muon,
const reco::Vertex vtx 
)
staticprivate

Definition at line 96 of file MuonIDTableProducer.cc.

References funct::abs(), pat::Muon::innerTrack(), muon::isGoodMuon(), reco::Vertex::position(), and muon::TMOneStationTight.

Referenced by produce().

96  {
98  mu.innerTrack()->hitPattern().trackerLayersWithMeasurement() > 5 &&
99  mu.innerTrack()->hitPattern().pixelLayersWithMeasurement() > 0 &&
100  std::abs(mu.innerTrack()->dxy(vtx.position())) < 0.3 &&
101  std::abs(mu.innerTrack()->dz(vtx.position())) < 20.;
102 }
const Point & position() const
position
Definition: Vertex.h:109
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
bool MuonIDTableProducer::isTrackerHighPt ( const pat::Muon mu,
const reco::Vertex primaryVertex 
)
staticprivate

Definition at line 104 of file MuonIDTableProducer.cc.

References funct::abs(), DEFINE_FWK_MODULE, pat::Muon::innerTrack(), pat::Muon::muonBestTrack(), reco::Muon::numberOfMatchedStations(), and reco::Vertex::position().

Referenced by produce().

104  {
105  return ( mu.numberOfMatchedStations() > 1
106  && (mu.muonBestTrack()->ptError()/mu.muonBestTrack()->pt()) < 0.3
107  && std::abs(mu.muonBestTrack()->dxy(primaryVertex.position())) < 0.2
108  && std::abs(mu.muonBestTrack()->dz(primaryVertex.position())) < 0.5
109  && mu.innerTrack()->hitPattern().numberOfValidPixelHits() > 0
110  && mu.innerTrack()->hitPattern().trackerLayersWithMeasurement() > 5 );
111 }
const Point & position() const
position
Definition: Vertex.h:109
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:73
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int numberOfMatchedStations(ArbitrationType type=SegmentAndTrackArbitration) const
reco::TrackRef muonBestTrack() const override
Track selected to be the best measurement of the muon parameters (including PFlow global information)...
void MuonIDTableProducer::produce ( edm::StreamID  ,
edm::Event ,
edm::EventSetup const &   
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 54 of file MuonIDTableProducer.cc.

References nanoaod::FlatTable::BoolColumn, edm::Event::getByToken(), mps_fire::i, muon::isHighPtMuon(), muon::isMediumMuon(), isMediumMuonHIP(), muon::isSoftMuon(), isSoftMuonHIP(), muon::isTightMuon(), isTrackerHighPt(), eostools::move(), RPCpg::mu, nano_cff::muons, name_, edm::Event::put(), MetAnalyzer::pv(), edm::Event::run(), src_, srcVtx_, nanoaod::FlatTable::UInt8Column, and electrons_cff::vertices.

Referenced by fillDescriptions().

55 {
56 
58  iEvent.getByToken(src_, muons);
60  iEvent.getByToken(srcVtx_, vertices);
61 
62  unsigned int ncand = muons->size();
63 
64  const reco::Vertex & pv = vertices->front(); // consistent with IP information in slimmedLeptons.
65 
66  bool isRun2016BCDEF = (272007 <= iEvent.run() && iEvent.run() <= 278808);
67  std::vector<uint8_t> tight(ncand, 0), highPt(ncand, 0), soft(ncand, 0), medium(ncand, 0);
68  for (unsigned int i = 0; i < ncand; ++i) {
69  const pat::Muon & mu = (*muons)[i];
70  tight[i] = muon::isTightMuon(mu, pv);
71  highPt[i] = muon::isHighPtMuon(mu, pv) ? 2 : isTrackerHighPt(mu,pv);
72  soft[i] = isRun2016BCDEF ? isSoftMuonHIP(mu,pv) : muon::isSoftMuon(mu, pv);
73  medium[i] = isRun2016BCDEF ? isMediumMuonHIP(mu) : muon::isMediumMuon(mu);
74  }
75 
76  auto tab = std::make_unique<nanoaod::FlatTable>(ncand, name_, false, true);
77  tab->addColumn<uint8_t>("tightId", tight, "POG Tight muon ID", nanoaod::FlatTable::BoolColumn);
78  tab->addColumn<uint8_t>("highPtId", highPt, "POG highPt muon ID (1 = tracker high pT, 2 = global high pT, which includes tracker high pT)", nanoaod::FlatTable::UInt8Column);
79  tab->addColumn<uint8_t>("softId", soft, "POG Soft muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)", nanoaod::FlatTable::BoolColumn);
80  tab->addColumn<uint8_t>("mediumId", medium, "POG Medium muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)", nanoaod::FlatTable::BoolColumn);
81 
82  iEvent.put(std::move(tab));
83 }
edm::EDGetTokenT< std::vector< reco::Vertex > > srcVtx_
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
edm::EDGetTokenT< std::vector< pat::Muon > > src_
int iEvent
Definition: GenABIO.cc:230
def pv(vc)
Definition: MetAnalyzer.py:6
const int mu
Definition: Constants.h:22
bool isSoftMuon(const reco::Muon &, const reco::Vertex &, bool run2016_hip_mitigation=false)
static bool isSoftMuonHIP(const pat::Muon &muon, const reco::Vertex &vtx)
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
static bool isMediumMuonHIP(const pat::Muon &muon)
static bool isTrackerHighPt(const pat::Muon &mu, const reco::Vertex &primaryVertex)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
Analysis-level muon class.
Definition: Muon.h:50
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

std::string MuonIDTableProducer::name_
private

Definition at line 43 of file MuonIDTableProducer.cc.

Referenced by produce().

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

Definition at line 44 of file MuonIDTableProducer.cc.

Referenced by produce().

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

Definition at line 45 of file MuonIDTableProducer.cc.

Referenced by produce().