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 Member Functions | Private Attributes
MuonMiniAOD Class Reference

#include <MuonMiniAOD.h>

Inheritance diagram for MuonMiniAOD:
DQMEDAnalyzer edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > > edm::stream::EDAnalyzerBase edm::EDConsumerBase

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...
 
virtual ~MuonMiniAOD ()
 Destructor. More...
 
- Public Member Functions inherited from DQMEDAnalyzer
virtual void beginRun (edm::Run const &, edm::EventSetup const &) final
 
virtual void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer (void)
 
virtual void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
virtual void endRunSummary (edm::Run const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
uint32_t streamId () const
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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 & 
itemsToGetFromEvent () 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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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::VertexCollection
theVertexLabel_
 
std::vector< MonitorElement * > workingPoints
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr
< dqmDetails::NoCache
globalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr
< dqmDetails::NoCache
globalBeginRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, dqmDetails::NoCache *)
 
static void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *, dqmDetails::NoCache *)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 29 of file MuonMiniAOD.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 11 of file MuonMiniAOD.cc.

References HLT_FULL_cff::parameters.

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 }
T getParameter(std::string const &) const
edm::ParameterSet parameters
Definition: MuonMiniAOD.h:46
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 ( )
virtual

Destructor.

Definition at line 23 of file MuonMiniAOD.cc.

23 { }

Member Function Documentation

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

Inizialize parameters for histo binning.

Implements edm::stream::EDAnalyzerBase.

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, patZpeak::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:457
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:75
#define LogTrace(id)
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
tuple muons
Definition: patZpeak.py:38
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
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 &   
)
overridevirtual

Implements DQMEDAnalyzer.

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 cd(void)
Definition: DQMStore.cc:269
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
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 isLooseMuon(const reco::Muon &)
bool isSoftMuon(const reco::Muon &, const reco::Vertex &)
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 isLooseMuon(const reco::Muon &)
bool isSoftMuon(const reco::Muon &, const reco::Vertex &)
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.