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:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

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 DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr< DQMEDAnalyzerGlobalCacheinitializeGlobalCache (edm::ParameterSet const &)
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 25 of file MuonMiniAOD.h.

Constructor & Destructor Documentation

◆ MuonMiniAOD()

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

Constructor.

Definition at line 6 of file MuonMiniAOD.cc.

6  {
7  parameters = pSet;
8 
9  // the services:
10 
11  theMuonCollectionLabel_ = consumes<edm::View<pat::Muon> >(parameters.getParameter<edm::InputTag>("MuonCollection"));
12  theVertexLabel_ = consumes<reco::VertexCollection>(parameters.getParameter<edm::InputTag>("VertexLabel"));
13  theBeamSpotLabel_ = mayConsume<reco::BeamSpot>(parameters.getParameter<edm::InputTag>("BeamSpotLabel"));
14 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< edm::View< pat::Muon > > theMuonCollectionLabel_
Definition: MuonMiniAOD.h:42
edm::ParameterSet parameters
Definition: MuonMiniAOD.h:40
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotLabel_
Definition: MuonMiniAOD.h:56
edm::EDGetTokenT< reco::VertexCollection > theVertexLabel_
Definition: MuonMiniAOD.h:55

◆ ~MuonMiniAOD()

MuonMiniAOD::~MuonMiniAOD ( )
override

Destructor.

Definition at line 16 of file MuonMiniAOD.cc.

16 {}

Member Function Documentation

◆ analyze()

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

Inizialize parameters for histo binning.

Reimplemented from DQMEDAnalyzer.

Definition at line 76 of file MuonMiniAOD.cc.

References cms::cuda::bs, relativeConstraints::error, iEvent, LogTrace, metname, beam_dqm_sourceclient-live_cfg::monitor, DiMuonV_cfg::muons, position, bphysicsOniaDQM_cfi::vertex, and PDWG_TauSkim_cff::workingPoints.

76  {
77  LogTrace(metname) << "[MuonMiniAOD] Analyze the mu";
78 
79  // Take the muon container
82 
83  //Vertex information
85  iEvent.getByToken(theVertexLabel_, vertex);
86 
87  if (!muons.isValid())
88  return;
89 
90  reco::Vertex::Point posVtx;
91  reco::Vertex::Error errVtx;
92  unsigned int theIndexOfThePrimaryVertex = 999.;
93  if (!vertex.isValid()) {
94  LogTrace(metname) << "[EfficiencyAnalyzer] Could not find vertex collection" << std::endl;
95  for (unsigned int ind = 0; ind < vertex->size(); ++ind) {
96  if ((*vertex)[ind].isValid() && !((*vertex)[ind].isFake())) {
97  theIndexOfThePrimaryVertex = ind;
98  break;
99  }
100  }
101  }
102 
103  if (theIndexOfThePrimaryVertex < 100) {
104  posVtx = ((*vertex)[theIndexOfThePrimaryVertex]).position();
105  errVtx = ((*vertex)[theIndexOfThePrimaryVertex]).error();
106  } else {
107  LogInfo("RecoMuonValidator") << "reco::PrimaryVertex not found, use BeamSpot position instead\n";
108 
109  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
110  iEvent.getByToken(theBeamSpotLabel_, recoBeamSpotHandle);
111  reco::BeamSpot bs = *recoBeamSpotHandle;
112 
113  posVtx = bs.position();
114  errVtx(0, 0) = bs.BeamWidthX();
115  errVtx(1, 1) = bs.BeamWidthY();
116  errVtx(2, 2) = bs.sigmaZ();
117  }
118 
119  const reco::Vertex thePrimaryVertex(posVtx, errVtx);
120 
121  for (edm::View<pat::Muon>::const_iterator muon1 = muons->begin(); muon1 != muons->end(); ++muon1) {
122  for (std::vector<MonitorElement*>::iterator monitor = workingPoints.begin(); monitor != workingPoints.end();
123  ++monitor) {
124  int Pass_A = 0;
125  int Pass_B = 0;
126  if (PassesCut_A(muon1, thePrimaryVertex, (*monitor)->getName()))
127  Pass_A = 1;
128  else
129  Pass_A = 2;
130  if (PassesCut_B(muon1, thePrimaryVertex, (*monitor)->getName()))
131  Pass_B = 1;
132  else
133  Pass_B = 2;
134 
135  (*monitor)->Fill(Pass_A, Pass_B);
136  }
137  }
138 }
std::string metname
Definition: MuonMiniAOD.h:44
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:45
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::View< pat::Muon > > theMuonCollectionLabel_
Definition: MuonMiniAOD.h:42
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
Log< level::Info, false > LogInfo
std::vector< MonitorElement * > workingPoints
Definition: MuonMiniAOD.h:47
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
static int position[264][3]
Definition: ReadPGInfo.cc:289
bool PassesCut_A(edm::View< pat::Muon >::const_iterator, reco::Vertex, TString)
Definition: MuonMiniAOD.cc:38
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotLabel_
Definition: MuonMiniAOD.h:56
bool PassesCut_B(edm::View< pat::Muon >::const_iterator, reco::Vertex, TString)
Definition: MuonMiniAOD.cc:57
edm::EDGetTokenT< reco::VertexCollection > theVertexLabel_
Definition: MuonMiniAOD.h:55

◆ bookHistograms()

void MuonMiniAOD::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  ,
edm::EventSetup const &   
)
overridevirtual

Implements DQMEDAnalyzer.

Definition at line 17 of file MuonMiniAOD.cc.

References dqm::implementation::IBooker::book2D(), dqm::implementation::NavigatorBase::cd(), beam_dqm_sourceclient-live_cfg::monitor, dqm::implementation::NavigatorBase::setCurrentFolder(), and PDWG_TauSkim_cff::workingPoints.

19  {
20  ibooker.cd();
21  ibooker.setCurrentFolder("Muons_miniAOD/MuonMiniAOD");
22 
23  workingPoints.push_back(ibooker.book2D("tightMuons", "Tight Muons", 2, 1, 3, 2, 1, 3));
24  workingPoints.push_back(ibooker.book2D("mediumMuons", "Medium Muons", 2, 1, 3, 2, 1, 3));
25  workingPoints.push_back(ibooker.book2D("looseMuons", "Loose Muons", 2, 1, 3, 2, 1, 3));
26  workingPoints.push_back(ibooker.book2D("highPtMuons", "High Pt Muons", 2, 1, 3, 2, 1, 3));
27  workingPoints.push_back(ibooker.book2D("softMuons", "Soft Muons", 2, 1, 3, 2, 1, 3));
28 
29  for (std::vector<MonitorElement*>::iterator monitor = workingPoints.begin(); monitor != workingPoints.end();
30  ++monitor) {
31  (*monitor)->setBinLabel(1, "Pass", 1);
32  (*monitor)->setBinLabel(2, "No Pass", 1);
33  (*monitor)->setBinLabel(1, "Pass", 2);
34  (*monitor)->setBinLabel(2, "No Pass", 2);
35  }
36 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
std::vector< MonitorElement * > workingPoints
Definition: MuonMiniAOD.h:47

◆ PassesCut_A()

bool MuonMiniAOD::PassesCut_A ( edm::View< pat::Muon >::const_iterator  muon1,
reco::Vertex  thePrimaryVertex,
TString  WorkingPoint 
)
private

Definition at line 38 of file MuonMiniAOD.cc.

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

40  {
41  if (WorkingPoint == "tightMuons")
42  return muon::isTightMuon(*muon1, thePrimaryVertex);
43  else if (WorkingPoint == "mediumMuons")
44  return muon::isMediumMuon(*muon1);
45  else if (WorkingPoint == "looseMuons")
46  return muon::isLooseMuon(*muon1);
47  else if (WorkingPoint == "highPtMuons")
48  return muon::isHighPtMuon(*muon1, thePrimaryVertex);
49  else if (WorkingPoint == "softMuons")
50  return muon::isSoftMuon(*muon1, thePrimaryVertex);
51  else {
52  LogInfo("RecoMuonValidator") << "[MuonMiniAOD]: MuonMiniAOD. Unknown WP, returning false.\n";
53  return false;
54  }
55 }
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)
Log< level::Info, false > LogInfo
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)

◆ PassesCut_B()

bool MuonMiniAOD::PassesCut_B ( edm::View< pat::Muon >::const_iterator  muon1,
reco::Vertex  thePrimaryVertex,
TString  WorkingPoint 
)
private

Definition at line 57 of file MuonMiniAOD.cc.

59  {
60  if (WorkingPoint == "tightMuons")
61  return muon1->isTightMuon(thePrimaryVertex);
62  else if (WorkingPoint == "mediumMuons")
63  return muon1->isMediumMuon();
64  else if (WorkingPoint == "looseMuons")
65  return muon1->isLooseMuon();
66  else if (WorkingPoint == "highPtMuons")
67  return muon1->isHighPtMuon(thePrimaryVertex);
68  else if (WorkingPoint == "softMuons")
69  return muon1->isSoftMuon(thePrimaryVertex);
70  else {
71  LogInfo("RecoMuonValidator") << "[MuonMiniAOD]: MuonMiniAOD. Unknown WP, returning false.\n";
72  return false;
73  }
74 }
Log< level::Info, false > LogInfo

Member Data Documentation

◆ doPVCheck_

bool MuonMiniAOD::doPVCheck_
private

Definition at line 54 of file MuonMiniAOD.h.

◆ metname

std::string MuonMiniAOD::metname
private

Definition at line 44 of file MuonMiniAOD.h.

◆ parameters

edm::ParameterSet MuonMiniAOD::parameters
private

Definition at line 40 of file MuonMiniAOD.h.

◆ theBeamSpotLabel_

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

Definition at line 56 of file MuonMiniAOD.h.

◆ theMuonCollectionLabel_

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

Definition at line 42 of file MuonMiniAOD.h.

◆ theVertexLabel_

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

Definition at line 55 of file MuonMiniAOD.h.

◆ workingPoints

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

Definition at line 47 of file MuonMiniAOD.h.