test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Attributes
MuonDxyCut Class Reference
Inheritance diagram for MuonDxyCut:
CutApplicatorWithEventContentBase CutApplicatorBase candidate_functions::CandidateCut

Public Member Functions

CandidateType candidateType () const overridefinal
 
void getEventContent (const edm::EventBase &) overridefinal
 
 MuonDxyCut (const edm::ParameterSet &c)
 
result_type operator() (const reco::MuonPtr &) const overridefinal
 
void setConsumes (edm::ConsumesCollector &) overridefinal
 
double value (const reco::CandidatePtr &) const overridefinal
 
- Public Member Functions inherited from CutApplicatorWithEventContentBase
 CutApplicatorWithEventContentBase ()
 
 CutApplicatorWithEventContentBase (const edm::ParameterSet &c)
 
 CutApplicatorWithEventContentBase (const CutApplicatorWithEventContentBase &)=delete
 
CutApplicatorWithEventContentBaseoperator= (const CutApplicatorWithEventContentBase &)=delete
 
virtual ~CutApplicatorWithEventContentBase ()
 Destructor. More...
 
- Public Member Functions inherited from CutApplicatorBase
virtual result_type asCandidate (const argument_type &) const
 
 CutApplicatorBase ()
 
 CutApplicatorBase (const edm::ParameterSet &c)
 
 CutApplicatorBase (const CutApplicatorBase &)=delete
 
virtual const std::string & name () const
 
virtual result_type operator() (const argument_type &) const final
 
virtual result_type operator() (const reco::GsfElectronPtr &) const
 
virtual result_type operator() (const pat::ElectronPtr &) const
 
virtual result_type operator() (const reco::PhotonPtr &) const
 
virtual result_type operator() (const pat::PhotonPtr &) const
 
virtual result_type operator() (const pat::MuonPtr &) const
 
virtual result_type operator() (const reco::PFTauPtr &) const
 
virtual result_type operator() (const pat::TauPtr &) const
 
CutApplicatorBaseoperator= (const CutApplicatorBase &)=delete
 
virtual ~CutApplicatorBase ()
 Destructor. More...
 
- Public Member Functions inherited from candidate_functions::CandidateCut
 CandidateCut ()
 
virtual ~CandidateCut ()
 

Private Types

enum  BestTrackType { INNERTRACK, MUONBESTTRACK, NONE }
 

Private Attributes

const double maxDxy_
 
enum MuonDxyCut::BestTrackType trackType_
 
edm::Handle
< reco::VertexCollection
vtxs_
 

Additional Inherited Members

- Public Types inherited from CutApplicatorBase
enum  CandidateType {
  NONE, ELECTRON, MUON, PHOTON,
  TAU, PATELECTRON, PATMUON, PATPHOTON,
  PATTAU
}
 
- Protected Attributes inherited from CutApplicatorWithEventContentBase
std::unordered_map
< std::string, edm::InputTag
contentTags_
 
std::unordered_map
< std::string, edm::EDGetToken
contentTokens_
 

Detailed Description

Definition at line 6 of file MuonDxyCut.cc.

Member Enumeration Documentation

Enumerator
INNERTRACK 
MUONBESTTRACK 
NONE 

Definition at line 21 of file MuonDxyCut.cc.

Constructor & Destructor Documentation

MuonDxyCut::MuonDxyCut ( const edm::ParameterSet c)

Definition at line 27 of file MuonDxyCut.cc.

References CutApplicatorWithEventContentBase::contentTags_, edm::ParameterSet::getParameter(), INNERTRACK, MUONBESTTRACK, NONE, AlCaHLTBitMon_QueryRunRegistry::string, and trackType_.

27  :
29  maxDxy_(c.getParameter<double>("maxDxy"))
30 {
31  const std::string trackTypeName = c.getParameter<std::string>("trackType");
32  trackType_ = NONE;
33  if ( trackTypeName == "muonBestTrack" ) trackType_ = MUONBESTTRACK;
34  else if ( trackTypeName == "innerTrack" ) trackType_ = INNERTRACK;
35  else
36  {
37  edm::LogError("MuonDxyCut") << "Wrong cut id name, " << trackTypeName
38  << "Choose among \"muonBestTrack\", \"innerTrack\"";
39  trackType_ = NONE;
40  }
41 
42  contentTags_.emplace("vertices", c.getParameter<edm::InputTag>("vertexSrc"));
43  contentTags_.emplace("verticesMiniAOD", c.getParameter<edm::InputTag>("vertexSrcMiniAOD"));
44 }
T getParameter(std::string const &) const
std::unordered_map< std::string, edm::InputTag > contentTags_
enum MuonDxyCut::BestTrackType trackType_
const double maxDxy_
Definition: MuonDxyCut.cc:20

Member Function Documentation

CandidateType MuonDxyCut::candidateType ( ) const
inlinefinaloverridevirtual

Reimplemented from CutApplicatorBase.

Definition at line 12 of file MuonDxyCut.cc.

References CutApplicatorBase::MUON.

void MuonDxyCut::getEventContent ( const edm::EventBase ev)
finaloverridevirtual

Implements CutApplicatorWithEventContentBase.

Definition at line 52 of file MuonDxyCut.cc.

References CutApplicatorWithEventContentBase::contentTags_, edm::EventBase::getByLabel(), edm::HandleBase::isValid(), and vtxs_.

53 {
54  ev.getByLabel(contentTags_["vertices"], vtxs_);
55  if ( !vtxs_.isValid() ) ev.getByLabel(contentTags_["verticesMiniAOD"], vtxs_);
56 }
std::unordered_map< std::string, edm::InputTag > contentTags_
edm::Handle< reco::VertexCollection > vtxs_
Definition: MuonDxyCut.cc:19
bool isValid() const
Definition: HandleBase.h:75
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:90
CutApplicatorBase::result_type MuonDxyCut::operator() ( const reco::MuonPtr cand) const
finaloverridevirtual

Reimplemented from CutApplicatorBase.

Definition at line 59 of file MuonDxyCut.cc.

References funct::abs(), INNERTRACK, edm::Ref< C, T, F >::isNonnull(), maxDxy_, MUONBESTTRACK, trackType_, and vtxs_.

60 {
61  const auto& vtxPos = vtxs_->at(0).position();
62 
63  reco::TrackRef trackRef;
64  if ( trackType_ == INNERTRACK ) trackRef = cand->innerTrack();
65  else if ( trackType_ == MUONBESTTRACK ) trackRef = cand->muonBestTrack();
66 
67  return trackRef.isNonnull() and std::abs(trackRef->dxy(vtxPos)) <= maxDxy_;
68 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
enum MuonDxyCut::BestTrackType trackType_
edm::Handle< reco::VertexCollection > vtxs_
Definition: MuonDxyCut.cc:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const double maxDxy_
Definition: MuonDxyCut.cc:20
void MuonDxyCut::setConsumes ( edm::ConsumesCollector cc)
finaloverridevirtual

Implements CutApplicatorWithEventContentBase.

Definition at line 46 of file MuonDxyCut.cc.

References edm::ConsumesCollector::consumes(), CutApplicatorWithEventContentBase::contentTags_, and CutApplicatorWithEventContentBase::contentTokens_.

47 {
48  contentTokens_.emplace("vertices", cc.consumes<reco::VertexCollection>(contentTags_["vertices"]));
49  contentTokens_.emplace("verticesMiniAOD", cc.consumes<reco::VertexCollection>(contentTags_["verticesMiniAOD"]));
50 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
std::unordered_map< std::string, edm::InputTag > contentTags_
double MuonDxyCut::value ( const reco::CandidatePtr cand) const
finaloverridevirtual

Implements candidate_functions::CandidateCut.

Definition at line 70 of file MuonDxyCut.cc.

References funct::abs(), INNERTRACK, edm::Ref< C, T, F >::isNull(), metsig::muon, MUONBESTTRACK, trackType_, and vtxs_.

71 {
72  const reco::MuonPtr muon(cand);
73  reco::TrackRef trackRef;
74  if ( trackType_ == INNERTRACK ) trackRef = muon->innerTrack();
75  else if ( trackType_ == MUONBESTTRACK ) trackRef = muon->muonBestTrack();
76  if ( trackRef.isNull() ) return -1;
77 
78  const auto& vtxPos = vtxs_->at(0).position();
79  return std::abs(trackRef->dxy(vtxPos));
80 }
enum MuonDxyCut::BestTrackType trackType_
edm::Handle< reco::VertexCollection > vtxs_
Definition: MuonDxyCut.cc:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isNull() const
Checks for null.
Definition: Ref.h:249

Member Data Documentation

const double MuonDxyCut::maxDxy_
private

Definition at line 20 of file MuonDxyCut.cc.

Referenced by operator()().

enum MuonDxyCut::BestTrackType MuonDxyCut::trackType_
private

Referenced by MuonDxyCut(), operator()(), and value().

edm::Handle<reco::VertexCollection> MuonDxyCut::vtxs_
private

Definition at line 19 of file MuonDxyCut.cc.

Referenced by getEventContent(), operator()(), and value().