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::one::EDProducer< edm::EndRunProducer, edm::one::WatchRuns, edm::EndLuminosityBlockProducer, edm::one::WatchLuminosityBlocks, edm::Accumulator > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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
 
virtual void analyze (edm::Event const &, edm::EventSetup const &)
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual void dqmBeginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
virtual void dqmEndLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void dqmEndRun (edm::Run const &, edm::EventSetup const &)
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &, edm::EventSetup const &) final
 
void endRunProduce (edm::Run &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndRunProducer, edm::one::WatchRuns, edm::EndLuminosityBlockProducer, edm::one::WatchLuminosityBlocks, edm::Accumulator >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () 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 () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

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::one::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
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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)
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Definition at line 25 of file MuonMiniAOD.h.

Constructor & Destructor Documentation

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 }
edm::EDGetTokenT< edm::View< pat::Muon > > theMuonCollectionLabel_
Definition: MuonMiniAOD.h:42
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotLabel_
Definition: MuonMiniAOD.h:56
edm::EDGetTokenT< reco::VertexCollection > theVertexLabel_
Definition: MuonMiniAOD.h:55
MuonMiniAOD::~MuonMiniAOD ( )
override

Destructor.

Definition at line 16 of file MuonMiniAOD.cc.

16 {}

Member Function Documentation

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

Inizialize parameters for histo binning.

Definition at line 76 of file MuonMiniAOD.cc.

References reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthY(), relativeConstraints::error, edm::Event::getByToken(), edm::HandleBase::isValid(), LogTrace, metname, beam_dqm_sourceclient-live_cfg::monitor, PDWG_BPHSkim_cff::muons, reco::BeamSpot::position(), position, reco::BeamSpot::sigmaZ(), bphysicsOniaDQM_cfi::vertex, and mvaElectronID_Fall17_iso_V2_cff::workingPoints.

76  {
77  LogTrace(metname) << "[MuonMiniAOD] Analyze the mu";
78 
79  // Take the muon container
81  iEvent.getByToken(theMuonCollectionLabel_, muons);
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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
edm::EDGetTokenT< edm::View< pat::Muon > > theMuonCollectionLabel_
Definition: MuonMiniAOD.h:42
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:82
bool isValid() const
Definition: HandleBase.h:70
#define LogTrace(id)
double sigmaZ() const
sigma z
Definition: BeamSpot.h:76
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:84
std::vector< MonitorElement * > workingPoints
Definition: MuonMiniAOD.h:47
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
static int position[264][3]
Definition: ReadPGInfo.cc:289
const Point & position() const
position
Definition: BeamSpot.h:59
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
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::dqmstoreimpl::DQMStore::IBooker::book2D(), dqm::dqmstoreimpl::DQMStore::IBooker::cd(), beam_dqm_sourceclient-live_cfg::monitor, dqm::dqmstoreimpl::DQMStore::IBooker::setCurrentFolder(), and mvaElectronID_Fall17_iso_V2_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 }
std::vector< MonitorElement * > workingPoints
Definition: MuonMiniAOD.h:47
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)
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 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 }

Member Data Documentation

bool MuonMiniAOD::doPVCheck_
private

Definition at line 54 of file MuonMiniAOD.h.

std::string MuonMiniAOD::metname
private

Definition at line 44 of file MuonMiniAOD.h.

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

Definition at line 56 of file MuonMiniAOD.h.

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

Definition at line 42 of file MuonMiniAOD.h.

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

Definition at line 55 of file MuonMiniAOD.h.

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

Definition at line 47 of file MuonMiniAOD.h.