CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonMiniAOD Class Reference

#include <MuonMiniAOD.h>

Inheritance diagram for MuonMiniAOD:
one::DQMEDAnalyzer< T > one::dqmimplementation::DQMBaseClass< T... >

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 Inizialize parameters for histo binning. More...
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
 MuonMiniAOD (const edm::ParameterSet &)
 Constructor. More...
 
 ~MuonMiniAOD () override
 Destructor. More...
 
- Public Member Functions inherited from one::DQMEDAnalyzer< T >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

Private Member Functions

bool PassesCut_A (edm::View< pat::Muon >::const_iterator, reco::Vertex, TString)
 
bool PassesCut_B (edm::View< pat::Muon >::const_iterator, reco::Vertex, TString)
 

Private Attributes

bool doPVCheck_
 
std::string metname
 
edm::ParameterSet parameters
 
edm::EDGetTokenT< reco::BeamSpottheBeamSpotLabel_
 
edm::EDGetTokenT< edm::View< pat::Muon > > theMuonCollectionLabel_
 
edm::EDGetTokenT< reco::VertexCollectiontheVertexLabel_
 
std::vector< MonitorElement * > workingPoints
 

Detailed Description

Definition at line 29 of file MuonMiniAOD.h.

Constructor & Destructor Documentation

MuonMiniAOD::MuonMiniAOD ( const edm::ParameterSet pSet)

Constructor.

Definition at line 11 of file MuonMiniAOD.cc.

11  {
12  parameters = pSet;
13 
14  // the services:
15 
16  theMuonCollectionLabel_ = consumes<edm::View<pat::Muon> > (parameters.getParameter<edm::InputTag>("MuonCollection"));
17  theVertexLabel_ = consumes<reco::VertexCollection>(parameters.getParameter<edm::InputTag>("VertexLabel"));
18  theBeamSpotLabel_ = mayConsume<reco::BeamSpot> (parameters.getParameter<edm::InputTag>("BeamSpotLabel"));
19 
20 }
edm::EDGetTokenT< edm::View< pat::Muon > > theMuonCollectionLabel_
Definition: MuonMiniAOD.h:48
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotLabel_
Definition: MuonMiniAOD.h:62
edm::EDGetTokenT< reco::VertexCollection > theVertexLabel_
Definition: MuonMiniAOD.h:61
MuonMiniAOD::~MuonMiniAOD ( )
override

Destructor.

Definition at line 23 of file MuonMiniAOD.cc.

23 { }

Member Function Documentation

void MuonMiniAOD::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Inizialize parameters for histo binning.

Definition at line 87 of file MuonMiniAOD.cc.

References reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthY(), relativeConstraints::error, edm::Event::getByToken(), edm::HandleBase::isValid(), LogTrace, metname, extraflags_cff::muons, reco::BeamSpot::position(), position, and reco::BeamSpot::sigmaZ().

87  {
88  LogTrace(metname)<<"[MuonMiniAOD] Analyze the mu";
89 
90 
91  // Take the muon container
93  iEvent.getByToken(theMuonCollectionLabel_,muons);
94 
95  //Vertex information
97  iEvent.getByToken(theVertexLabel_, vertex);
98 
99 
100  if(!muons.isValid()) return;
101 
102  reco::Vertex::Point posVtx;
103  reco::Vertex::Error errVtx;
104  unsigned int theIndexOfThePrimaryVertex = 999.;
105  if (!vertex.isValid()) {
106  LogTrace(metname) << "[EfficiencyAnalyzer] Could not find vertex collection" << std::endl;
107  for (unsigned int ind=0; ind<vertex->size(); ++ind) {
108  if ( (*vertex)[ind].isValid() && !((*vertex)[ind].isFake()) ) {
109  theIndexOfThePrimaryVertex = ind;
110  break;
111  }
112  }
113  }
114 
115  if (theIndexOfThePrimaryVertex<100) {
116  posVtx = ((*vertex)[theIndexOfThePrimaryVertex]).position();
117  errVtx = ((*vertex)[theIndexOfThePrimaryVertex]).error();
118  }
119  else {
120  LogInfo("RecoMuonValidator") << "reco::PrimaryVertex not found, use BeamSpot position instead\n";
121 
122  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
123  iEvent.getByToken(theBeamSpotLabel_,recoBeamSpotHandle);
124  reco::BeamSpot bs = *recoBeamSpotHandle;
125 
126  posVtx = bs.position();
127  errVtx(0,0) = bs.BeamWidthX();
128  errVtx(1,1) = bs.BeamWidthY();
129  errVtx(2,2) = bs.sigmaZ();
130  }
131 
132 
133 
134  const reco::Vertex thePrimaryVertex(posVtx,errVtx);
135 
136  for (edm::View<pat::Muon>::const_iterator muon1 = muons->begin(); muon1 != muons->end(); ++muon1){
137 
138  for (std::vector<MonitorElement*>::iterator monitor = workingPoints.begin();
139  monitor != workingPoints.end(); ++monitor){
140  int Pass_A = 0;
141  int Pass_B = 0;
142  if (PassesCut_A(muon1, thePrimaryVertex,(*monitor)->getName()))
143  Pass_A = 1;
144  else
145  Pass_A = 2;
146  if (PassesCut_B(muon1, thePrimaryVertex,(*monitor)->getName()))
147  Pass_B = 1;
148  else
149  Pass_B = 2;
150 
151  (*monitor)->Fill(Pass_A,Pass_B);
152  }
153 
154  }
155 }
std::string metname
Definition: MuonMiniAOD.h:50
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
edm::EDGetTokenT< edm::View< pat::Muon > > theMuonCollectionLabel_
Definition: MuonMiniAOD.h:48
bool isValid() const
Definition: HandleBase.h:74
#define LogTrace(id)
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::vector< MonitorElement * > workingPoints
Definition: MuonMiniAOD.h:53
const Point & position() const
position
Definition: BeamSpot.h:62
bool PassesCut_A(edm::View< pat::Muon >::const_iterator, reco::Vertex, TString)
Definition: MuonMiniAOD.cc:48
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotLabel_
Definition: MuonMiniAOD.h:62
bool PassesCut_B(edm::View< pat::Muon >::const_iterator, reco::Vertex, TString)
Definition: MuonMiniAOD.cc:67
edm::EDGetTokenT< reco::VertexCollection > theVertexLabel_
Definition: MuonMiniAOD.h:61
void MuonMiniAOD::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  ,
edm::EventSetup const &   
)
override

Definition at line 24 of file MuonMiniAOD.cc.

References DQMStore::IBooker::book2D(), DQMStore::IBooker::cd(), and DQMStore::IBooker::setCurrentFolder().

26  {
27 
28  ibooker.cd();
29  ibooker.setCurrentFolder("Muons_miniAOD/MuonMiniAOD");
30 
31 
32  workingPoints.push_back(ibooker.book2D("tightMuons" ,"Tight Muons" ,2,1,3,2,1,3));
33  workingPoints.push_back(ibooker.book2D("mediumMuons","Medium Muons" ,2,1,3,2,1,3));
34  workingPoints.push_back(ibooker.book2D("looseMuons" ,"Loose Muons" ,2,1,3,2,1,3));
35  workingPoints.push_back(ibooker.book2D("highPtMuons","High Pt Muons",2,1,3,2,1,3));
36  workingPoints.push_back(ibooker.book2D("softMuons" ,"Soft Muons" ,2,1,3,2,1,3));
37 
38  for (std::vector<MonitorElement*>::iterator monitor = workingPoints.begin();
39  monitor != workingPoints.end(); ++monitor){
40  (*monitor)-> setBinLabel(1,"Pass",1);
41  (*monitor) -> setBinLabel(2,"No Pass",1);
42  (*monitor) -> setBinLabel(1,"Pass",2);
43  (*monitor) -> setBinLabel(2,"No Pass",2);
44  }
45 
46 }
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
std::vector< MonitorElement * > workingPoints
Definition: MuonMiniAOD.h:53
bool MuonMiniAOD::PassesCut_A ( edm::View< pat::Muon >::const_iterator  muon1,
reco::Vertex  thePrimaryVertex,
TString  WorkingPoint 
)
private

Definition at line 48 of file MuonMiniAOD.cc.

References muon::isHighPtMuon(), muon::isLooseMuon(), muon::isMediumMuon(), muon::isSoftMuon(), and muon::isTightMuon().

48  {
49 
50  if (WorkingPoint == "tightMuons")
51  return muon::isTightMuon(*muon1,thePrimaryVertex);
52  else if (WorkingPoint == "mediumMuons")
53  return muon::isMediumMuon(*muon1);
54  else if (WorkingPoint == "looseMuons")
55  return muon::isLooseMuon(*muon1);
56  else if (WorkingPoint == "highPtMuons")
57  return muon::isHighPtMuon(*muon1,thePrimaryVertex);
58  else if (WorkingPoint == "softMuons")
59  return muon::isSoftMuon(*muon1,thePrimaryVertex);
60  else{
61  LogInfo("RecoMuonValidator") << "[MuonMiniAOD]: MuonMiniAOD. Unknown WP, returning false.\n";
62  return false;
63  }
64 
65 }
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
bool isLooseMuon(const reco::Muon &)
bool isSoftMuon(const reco::Muon &, const reco::Vertex &, bool run2016_hip_mitigation=false)
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
bool MuonMiniAOD::PassesCut_B ( edm::View< pat::Muon >::const_iterator  muon1,
reco::Vertex  thePrimaryVertex,
TString  WorkingPoint 
)
private

Definition at line 67 of file MuonMiniAOD.cc.

References muon::isHighPtMuon(), muon::isLooseMuon(), muon::isMediumMuon(), muon::isSoftMuon(), and muon::isTightMuon().

67  {
68 
69  if (WorkingPoint == "tightMuons")
70  return muon1 -> isTightMuon(thePrimaryVertex);
71  else if (WorkingPoint == "mediumMuons")
72  return muon1 -> isMediumMuon();
73  else if (WorkingPoint == "looseMuons")
74  return muon1 -> isLooseMuon();
75  else if (WorkingPoint == "highPtMuons")
76  return muon1 -> isHighPtMuon(thePrimaryVertex);
77  else if (WorkingPoint == "softMuons")
78  return muon1 -> isSoftMuon(thePrimaryVertex);
79  else{
80  LogInfo("RecoMuonValidator") << "[MuonMiniAOD]: MuonMiniAOD. Unknown WP, returning false.\n";
81  return false;
82  }
83 
84 }
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
bool isLooseMuon(const reco::Muon &)
bool isSoftMuon(const reco::Muon &, const reco::Vertex &, bool run2016_hip_mitigation=false)
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)

Member Data Documentation

bool MuonMiniAOD::doPVCheck_
private

Definition at line 60 of file MuonMiniAOD.h.

std::string MuonMiniAOD::metname
private

Definition at line 50 of file MuonMiniAOD.h.

edm::ParameterSet MuonMiniAOD::parameters
private
edm::EDGetTokenT<reco::BeamSpot> MuonMiniAOD::theBeamSpotLabel_
private

Definition at line 62 of file MuonMiniAOD.h.

edm::EDGetTokenT< edm::View<pat::Muon> > MuonMiniAOD::theMuonCollectionLabel_
private

Definition at line 48 of file MuonMiniAOD.h.

edm::EDGetTokenT<reco::VertexCollection> MuonMiniAOD::theVertexLabel_
private

Definition at line 61 of file MuonMiniAOD.h.

std::vector<MonitorElement*> MuonMiniAOD::workingPoints
private

Definition at line 53 of file MuonMiniAOD.h.