CMS 3D CMS Logo

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

#include <MuonPFAnalyzer.h>

Inheritance diagram for MuonPFAnalyzer:
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 Types

typedef std::vector< RecoGenPairRecoGenCollection
 
typedef std::pair< const reco::Muon *, const reco::GenParticle * > RecoGenPair
 
- 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
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
 MuonPFAnalyzer (const edm::ParameterSet &)
 Constructor. More...
 
 ~MuonPFAnalyzer () 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

void bookHistos (DQMStore::IBooker &, const std::string &)
 
float combRelIso (const reco::Muon *muon)
 
float fDeltaPhi (float phi1, float phi2)
 
void fillInRange (MonitorElement *plot, int nAxis, double x, double y=0)
 
MonitorElementgetPlot (const std::string &group, const std::string &type)
 
const reco::Vertex getPrimaryVertex (edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
 
int muonTrackType (const reco::Muon *muon, bool usePF)
 
void recoToGenMatch (edm::Handle< reco::MuonCollection > &reco, edm::Handle< reco::GenParticleCollection > &gen)
 
void setCodeLabels (MonitorElement *plot, int nAxis)
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpottheBeamSpotLabel_
 
std::string theFolder
 
edm::EDGetTokenT< reco::GenParticleCollectiontheGenLabel_
 
double theHighPtTh
 
double theIsoCut
 
std::vector< std::string > theMuonKinds
 
std::map< std::string, std::map< std::string, MonitorElement * > > thePlots
 
RecoGenCollection theRecoGen
 
double theRecoGenR
 
edm::EDGetTokenT< reco::MuonCollectiontheRecoLabel_
 
bool theRunOnMC
 
edm::EDGetTokenT< reco::VertexCollectiontheVertexLabel_
 

Additional Inherited Members

- 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 30 of file MuonPFAnalyzer.h.

Member Typedef Documentation

Definition at line 33 of file MuonPFAnalyzer.h.

typedef std::pair<const reco::Muon *, const reco::GenParticle *> MuonPFAnalyzer::RecoGenPair

Definition at line 32 of file MuonPFAnalyzer.h.

Constructor & Destructor Documentation

MuonPFAnalyzer::MuonPFAnalyzer ( const edm::ParameterSet pSet)
explicit

Constructor.

Definition at line 39 of file MuonPFAnalyzer.cc.

References edm::ParameterSet::getParameter(), and LogTrace.

39  {
40  LogTrace("MuonPFAnalyzer") << "[MuonPFAnalyzer] Initializing configuration from parameterset.\n";
41 
42  theGenLabel_ = consumes<GenParticleCollection>(pSet.getParameter<InputTag>("inputTagGenParticles"));
43  theRecoLabel_ = consumes<MuonCollection>(pSet.getParameter<InputTag>("inputTagMuonReco"));
44  theVertexLabel_ = consumes<VertexCollection>(pSet.getParameter<InputTag>("inputTagVertex"));
45  theBeamSpotLabel_ = consumes<BeamSpot>(pSet.getParameter<InputTag>("inputTagBeamSpot"));
46 
47  theHighPtTh = pSet.getParameter<double>("highPtThreshold");
48  theRecoGenR = pSet.getParameter<double>("recoGenDeltaR");
49  theIsoCut = pSet.getParameter<double>("relCombIsoCut");
50  theRunOnMC = pSet.getParameter<bool>("runOnMC");
51 
52  theFolder = pSet.getParameter<string>("folder");
53 
54  theMuonKinds.push_back(""); // all TUNEP/PF muons
55  theMuonKinds.push_back("Tight"); // tight TUNEP/PF muons
56  theMuonKinds.push_back("TightIso"); // tight/iso TUNEP/PF muons
57 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > theVertexLabel_
edm::EDGetTokenT< reco::MuonCollection > theRecoLabel_
edm::EDGetTokenT< reco::GenParticleCollection > theGenLabel_
std::vector< std::string > theMuonKinds
#define LogTrace(id)
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotLabel_
std::string theFolder
MuonPFAnalyzer::~MuonPFAnalyzer ( )
override

Destructor.

Definition at line 59 of file MuonPFAnalyzer.cc.

References LogTrace.

59 { LogTrace("MuonPFAnalyzer") << "[MuonPFAnalyzer] Destructor called.\n"; }
#define LogTrace(id)

Member Function Documentation

void MuonPFAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup context 
)
override

Definition at line 77 of file MuonPFAnalyzer.cc.

References pwdgSkimBPark_cfi::beamSpot, PVValHelper::eta, runTauDisplay::genMuons, PFJetFilter_cfi::genPt, watchdog::group, reco::Muon::innerTrack(), edm::Ref< C, T, F >::isNull(), reco::Muon::isPFMuon(), muon::isTightMuon(), CalibrationSummaryClient_cfi::kind, PDWG_BPHSkim_cff::muons, reco::LeafCandidate::p4(), BeamMonitor_cff::primaryVertex, DiDispStaMuonMonitor_cfi::pt, reco::LeafCandidate::pt(), reco::Muon::tunePMuonBestTrack(), and bphysicsOniaDQM_cfi::vertex.

77  {
79  event.getByToken(theRecoLabel_, muons);
80 
82  event.getByToken(theGenLabel_, genMuons);
83 
85  event.getByToken(theBeamSpotLabel_, beamSpot);
86 
88  event.getByToken(theVertexLabel_, vertex);
89 
90  const Vertex primaryVertex = getPrimaryVertex(vertex, beamSpot);
91 
92  recoToGenMatch(muons, genMuons);
93 
94  RecoGenCollection::const_iterator recoGenIt = theRecoGen.begin();
95  RecoGenCollection::const_iterator recoGenEnd = theRecoGen.end();
96 
97  for (; recoGenIt != recoGenEnd; ++recoGenIt) {
98  const Muon *muon = recoGenIt->first;
99  TrackRef tunePTrack = muon->tunePMuonBestTrack();
100 
101  const GenParticle *genMuon = recoGenIt->second;
102 
103  vector<string>::const_iterator kindIt = theMuonKinds.begin();
104  vector<string>::const_iterator kindEnd = theMuonKinds.end();
105 
106  for (; kindIt != kindEnd; ++kindIt) {
107  const string &kind = (*kindIt);
108 
109  if (kind.find("Tight") != string::npos && !muon::isTightMuon((*muon), primaryVertex))
110  continue;
111 
112  if (kind.find("Iso") != string::npos && combRelIso(muon) > theIsoCut)
113  continue;
114 
115  if (theRunOnMC && genMuon && !muon->innerTrack().isNull()) // has matched gen muon
116  {
117  if (!tunePTrack.isNull()) {
118  string group = "TUNEP" + kind;
119 
120  float pt = tunePTrack->pt();
121  float phi = tunePTrack->phi();
122  float eta = tunePTrack->eta();
123 
124  float genPt = genMuon->pt();
125  float genPhi = genMuon->p4().phi();
126  float genEta = genMuon->p4().eta();
127 
128  float dPtOverPt = (pt / genPt) - 1;
129 
130  if (pt < theHighPtTh) {
131  fillInRange(getPlot(group, "code"), 1, muonTrackType(muon, false));
132  fillInRange(getPlot(group, "deltaPtOverPt"), 1, dPtOverPt);
133  } else {
134  fillInRange(getPlot(group, "codeHighPt"), 1, muonTrackType(muon, false));
135  fillInRange(getPlot(group, "deltaPtOverPtHighPt"), 1, dPtOverPt);
136  }
137 
138  fillInRange(getPlot(group, "deltaPt"), 1, (pt - genPt));
139  fillInRange(getPlot(group, "deltaPhi"), 1, fDeltaPhi(genPhi, phi));
140  fillInRange(getPlot(group, "deltaEta"), 1, genEta - eta);
141  }
142 
143  if (muon->isPFMuon()) {
144  string group = "PF" + kind;
145 
146  // Assumes that default in muon is PF
147  float pt = muon->pt();
148  float phi = muon->p4().phi();
149  float eta = muon->p4().eta();
150 
151  float genPt = genMuon->pt();
152  float genPhi = genMuon->p4().phi();
153  float genEta = genMuon->p4().eta();
154 
155  float dPtOverPt = (pt / genPt) - 1;
156 
157  if (pt < theHighPtTh) {
158  fillInRange(getPlot(group, "code"), 1, muonTrackType(muon, true));
159  fillInRange(getPlot(group, "deltaPtOverPt"), 1, dPtOverPt);
160  } else {
161  fillInRange(getPlot(group, "codeHighPt"), 1, muonTrackType(muon, true));
162  fillInRange(getPlot(group, "deltaPtOverPtHighPt"), 1, dPtOverPt);
163  }
164 
165  fillInRange(getPlot(group, "deltaPt"), 1, pt - genPt);
166  fillInRange(getPlot(group, "deltaPhi"), 1, fDeltaPhi(genPhi, phi));
167  fillInRange(getPlot(group, "deltaEta"), 1, genEta - eta);
168  }
169  }
170 
171  if (muon->isPFMuon() && !tunePTrack.isNull() && !muon->innerTrack().isNull()) // Compare PF with TuneP + Tracker
172  { // No gen matching needed
173 
174  string group = "PFvsTUNEP" + kind;
175 
176  float pt = tunePTrack->pt();
177  float phi = tunePTrack->phi();
178  float eta = tunePTrack->eta();
179 
180  // Assumes that default in muon is PF
181  float pfPt = muon->pt();
182  float pfPhi = muon->p4().phi();
183  float pfEta = muon->p4().eta();
184  float dPtOverPt = (pfPt / pt) - 1; // TUNEP vs PF pt used as denum.
185 
186  if (pt < theHighPtTh) {
187  fillInRange(getPlot(group, "code"), 2, muonTrackType(muon, false), muonTrackType(muon, true));
188  fillInRange(getPlot(group, "deltaPtOverPt"), 1, dPtOverPt);
189  } else {
190  fillInRange(getPlot(group, "codeHighPt"), 2, muonTrackType(muon, false), muonTrackType(muon, true));
191  fillInRange(getPlot(group, "deltaPtOverPtHighPt"), 1, dPtOverPt);
192  }
193 
194  fillInRange(getPlot(group, "deltaPt"), 1, pfPt - pt);
195  fillInRange(getPlot(group, "deltaPhi"), 1, fDeltaPhi(pfPhi, phi));
196  fillInRange(getPlot(group, "deltaEta"), 1, pfEta - eta);
197 
198  if (theRunOnMC && genMuon) // has a matched gen muon
199 
200  {
201  float genPt = genMuon->pt();
202  float dPtOverPtGen = (pt / genPt) - 1;
203  float dPtOverPtGenPF = (pfPt / genPt) - 1;
204 
205  if (pt < theHighPtTh) {
206  fillInRange(getPlot(group, "deltaPtOverPtPFvsTUNEP"), 2, dPtOverPtGen, dPtOverPtGenPF);
207  } else {
208  fillInRange(getPlot(group, "deltaPtOverPtHighPtPFvsTUNEP"), 2, dPtOverPtGen, dPtOverPtGenPF);
209  }
210  }
211  }
212  }
213  }
214 }
int muonTrackType(const reco::Muon *muon, bool usePF)
const reco::Vertex getPrimaryVertex(edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
edm::EDGetTokenT< reco::VertexCollection > theVertexLabel_
virtual TrackRef innerTrack() const
Definition: Muon.h:45
double pt() const final
transverse momentum
MonitorElement * getPlot(const std::string &group, const std::string &type)
edm::EDGetTokenT< reco::MuonCollection > theRecoLabel_
RecoGenCollection theRecoGen
edm::EDGetTokenT< reco::GenParticleCollection > theGenLabel_
std::vector< std::string > theMuonKinds
void fillInRange(MonitorElement *plot, int nAxis, double x, double y=0)
Definition: Muon.py:1
float combRelIso(const reco::Muon *muon)
const LorentzVector & p4() const final
four-momentum Lorentz vector
bool isNull() const
Checks for null.
Definition: Ref.h:235
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotLabel_
float fDeltaPhi(float phi1, float phi2)
void recoToGenMatch(edm::Handle< reco::MuonCollection > &reco, edm::Handle< reco::GenParticleCollection > &gen)
bool isPFMuon() const
Definition: Muon.h:302
virtual TrackRef tunePMuonBestTrack() const
Definition: Muon.h:62
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
primaryVertex
hltOfflineBeamSpot for HLTMON
void MuonPFAnalyzer::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  ,
edm::EventSetup const &   
)
overridevirtual

Implements DQMEDAnalyzer.

Definition at line 62 of file MuonPFAnalyzer.cc.

References bookHistos().

62  {
63  if (theRunOnMC) {
64  bookHistos(ibooker, "PF");
65  bookHistos(ibooker, "PFTight");
66  bookHistos(ibooker, "PFTightIso");
67  bookHistos(ibooker, "TUNEP");
68  bookHistos(ibooker, "TUNEPTight");
69  bookHistos(ibooker, "TUNEPTightIso");
70  }
71 
72  bookHistos(ibooker, "PFvsTUNEP");
73  bookHistos(ibooker, "PFvsTUNEPTight");
74  bookHistos(ibooker, "PFvsTUNEPTightIso");
75 }
void bookHistos(DQMStore::IBooker &, const std::string &)
void MuonPFAnalyzer::bookHistos ( DQMStore::IBooker ,
const std::string &   
)
private

Definition at line 216 of file MuonPFAnalyzer.cc.

References dqm::dqmstoreimpl::DQMStore::IBooker::book1D(), dqm::dqmstoreimpl::DQMStore::IBooker::book2D(), watchdog::group, LogTrace, plotFactory::plot, and dqm::dqmstoreimpl::DQMStore::IBooker::setCurrentFolder().

216  {
217  LogTrace("MuonPFAnalyzer") << "[MuonPFAnalyzer] Booking histos for group :" << group << "\n";
218 
219  ibooker.setCurrentFolder(string(theFolder) + group);
220 
221  bool isPFvsTUNEP = group.find("PFvsTUNEP") != string::npos;
222 
223  string hName;
224 
225  hName = "deltaPtOverPt" + group;
226  thePlots[group]["deltaPtOverPt"] = ibooker.book1D(hName.c_str(), hName.c_str(), 101, -1.01, 1.01);
227 
228  hName = "deltaPtOverPtHighPt" + group;
229  thePlots[group]["deltaPtOverPtHighPt"] = ibooker.book1D(hName.c_str(), hName.c_str(), 101, -1.01, 1.01);
230 
231  hName = "deltaPt" + group;
232  thePlots[group]["deltaPt"] = ibooker.book1D(hName.c_str(), hName.c_str(), 201., -10.25, 10.25);
233 
234  hName = "deltaPhi" + group;
235  thePlots[group]["deltaPhi"] = ibooker.book1D(hName.c_str(), hName.c_str(), 51., 0, .0102);
236 
237  hName = "deltaEta" + group;
238  thePlots[group]["deltaEta"] = ibooker.book1D(hName.c_str(), hName.c_str(), 101., -.00505, .00505);
239 
240  if (isPFvsTUNEP) {
241  hName = "code" + group;
242  MonitorElement *plot = ibooker.book2D(hName.c_str(), hName.c_str(), 7, -.5, 6.5, 7, -.5, 6.5);
243  thePlots[group]["code"] = plot;
244  setCodeLabels(plot, 1);
245  setCodeLabels(plot, 2);
246 
247  hName = "codeHighPt" + group;
248  plot = ibooker.book2D(hName.c_str(), hName.c_str(), 7, -.5, 6.5, 7, -.5, 6.5);
249  thePlots[group]["codeHighPt"] = plot;
250  setCodeLabels(plot, 1);
251  setCodeLabels(plot, 2);
252 
253  if (theRunOnMC) {
254  hName = "deltaPtOverPtPFvsTUNEP" + group;
255  thePlots[group]["deltaPtOverPtPFvsTUNEP"] =
256  ibooker.book2D(hName.c_str(), hName.c_str(), 101, -1.01, 1.01, 101, -1.01, 1.01);
257 
258  hName = "deltaPtOverPtHighPtPFvsTUNEP" + group;
259  thePlots[group]["deltaPtOverPtHighPtPFvsTUNEP"] =
260  ibooker.book2D(hName.c_str(), hName.c_str(), 101, -1.01, 1.01, 101, -1.01, 1.01);
261  }
262  } else {
263  hName = "code" + group;
264  MonitorElement *plot = ibooker.book1D(hName.c_str(), hName.c_str(), 7, -.5, 6.5);
265  thePlots[group]["code"] = plot;
266  setCodeLabels(plot, 1);
267 
268  hName = "codeHighPt" + group;
269  plot = ibooker.book1D(hName.c_str(), hName.c_str(), 7, -.5, 6.5);
270  thePlots[group]["codeHighPt"] = plot;
271  setCodeLabels(plot, 1);
272  }
273 }
void setCodeLabels(MonitorElement *plot, int nAxis)
#define LogTrace(id)
std::string theFolder
std::map< std::string, std::map< std::string, MonitorElement * > > thePlots
float MuonPFAnalyzer::combRelIso ( const reco::Muon muon)
inlineprivate

Definition at line 292 of file MuonPFAnalyzer.cc.

References reco::MuonIsolation::emEt, reco::MuonIsolation::hadEt, reco::Muon::isolationR03(), reco::LeafCandidate::pt(), and reco::MuonIsolation::sumPt.

292  {
293  MuonIsolation iso = muon->isolationR03();
294  float combRelIso = (iso.emEt + iso.hadEt + iso.sumPt) / muon->pt();
295 
296  return combRelIso;
297 }
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:8
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:6
double pt() const final
transverse momentum
float combRelIso(const reco::Muon *muon)
float emEt
ecal sum-Et
Definition: MuonIsolation.h:7
const MuonIsolation & isolationR03() const
Definition: Muon.h:166
float MuonPFAnalyzer::fDeltaPhi ( float  phi1,
float  phi2 
)
inlineprivate

Definition at line 299 of file MuonPFAnalyzer.cc.

References funct::cos().

299  {
300  float fPhiDiff = fabs(acos(cos(phi1 - phi2)));
301  return fPhiDiff;
302 }
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void MuonPFAnalyzer::fillInRange ( MonitorElement plot,
int  nAxis,
double  x,
double  y = 0 
)
private

Definition at line 328 of file MuonPFAnalyzer.cc.

References dqm::impl::MonitorElement::Fill(), dqm::impl::MonitorElement::getTH1(), timingPdfMaker::histo, mps_fire::i, edm::max(), and edm::min().

328  {
329  TH1 *histo = plot->getTH1();
330 
331  TAxis *axis[2] = {nullptr, nullptr};
332  axis[0] = histo->GetXaxis();
333  if (nAxis == 2)
334  axis[1] = histo->GetYaxis();
335 
336  double value[2] = {0, 0};
337  value[0] = x;
338  value[1] = y;
339 
340  for (int i = 0; i < nAxis; ++i) {
341  double min = axis[i]->GetXmin();
342  double max = axis[i]->GetXmax();
343 
344  if (value[i] <= min)
345  value[i] = axis[i]->GetBinCenter(1);
346 
347  if (value[i] >= max)
348  value[i] = axis[i]->GetBinCenter(axis[i]->GetNbins());
349  }
350 
351  if (nAxis == 2)
352  plot->Fill(value[0], value[1]);
353  else
354  plot->Fill(value[0]);
355 }
void Fill(long long x)
Definition: value.py:1
T min(T a, T b)
Definition: MathUtil.h:58
virtual TH1 * getTH1() const
MuonPFAnalyzer::MonitorElement * MuonPFAnalyzer::getPlot ( const std::string &  group,
const std::string &  type 
)
private

Definition at line 275 of file MuonPFAnalyzer.cc.

References LogTrace.

275  {
276  map<string, map<string, MonitorElement *> >::iterator groupIt = thePlots.find(group);
277  if (groupIt == thePlots.end()) {
278  LogTrace("MuonPFAnalyzer") << "[MuonPFAnalyzer] GROUP : " << group << " is not a valid plot group. Returning 0.\n";
279  return nullptr;
280  }
281 
282  map<string, MonitorElement *>::iterator typeIt = groupIt->second.find(type);
283  if (typeIt == groupIt->second.end()) {
284  LogTrace("MuonPFAnalyzer") << "[MuonPFAnalyzer] TYPE : " << type << " is not a valid type for GROUP : " << group
285  << ". Returning 0.\n";
286  return nullptr;
287  }
288 
289  return typeIt->second;
290 }
type
Definition: HCALResponse.h:21
#define LogTrace(id)
std::map< std::string, std::map< std::string, MonitorElement * > > thePlots
const reco::Vertex MuonPFAnalyzer::getPrimaryVertex ( edm::Handle< reco::VertexCollection > &  vertex,
edm::Handle< reco::BeamSpot > &  beamSpot 
)
private

Definition at line 416 of file MuonPFAnalyzer.cc.

References reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthY(), DEFINE_FWK_MODULE, edm::HandleBase::isValid(), reco::BeamSpot::position(), BeamMonitor_cff::primaryVertex, and reco::BeamSpot::sigmaZ().

416  {
417  Vertex::Point posVtx;
418  Vertex::Error errVtx;
419 
420  bool hasPrimaryVertex = false;
421 
422  if (vertex.isValid()) {
423  vector<Vertex>::const_iterator vertexIt = vertex->begin();
424  vector<Vertex>::const_iterator vertexEnd = vertex->end();
425 
426  for (; vertexIt != vertexEnd; ++vertexIt) {
427  if (vertexIt->isValid() && !vertexIt->isFake()) {
428  posVtx = vertexIt->position();
429  errVtx = vertexIt->error();
430  hasPrimaryVertex = true;
431  break;
432  }
433  }
434  }
435 
436  if (!hasPrimaryVertex) {
437  LogInfo("MuonPFAnalyzer") << "[MuonPFAnalyzer] PrimaryVertex not found, use BeamSpot position instead.\n";
438 
439  posVtx = beamSpot->position();
440  errVtx(0, 0) = beamSpot->BeamWidthX();
441  errVtx(1, 1) = beamSpot->BeamWidthY();
442  errVtx(2, 2) = beamSpot->sigmaZ();
443  }
444 
445  const Vertex primaryVertex(posVtx, errVtx);
446 
447  return primaryVertex;
448 }
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:82
bool isValid() const
Definition: HandleBase.h:70
double sigmaZ() const
sigma z
Definition: BeamSpot.h:76
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:84
const Point & position() const
position
Definition: BeamSpot.h:59
primaryVertex
hltOfflineBeamSpot for HLTMON
int MuonPFAnalyzer::muonTrackType ( const reco::Muon muon,
bool  usePF 
)
private

Definition at line 357 of file MuonPFAnalyzer.cc.

References reco::Muon::muonBestTrackType(), None, and reco::Muon::tunePMuonBestTrackType().

357  {
358  switch (usePF ? muon->muonBestTrackType() : muon->tunePMuonBestTrackType()) {
359  case Muon::InnerTrack:
360  return 0;
361  case Muon::OuterTrack:
362  return 1;
363  case Muon::CombinedTrack:
364  return 2;
365  case Muon::TPFMS:
366  return 3;
367  case Muon::Picky:
368  return 4;
369  case Muon::DYT:
370  return 5;
371  case Muon::None:
372  return 6;
373  }
374 
375  return 6;
376 }
virtual MuonTrackType muonBestTrackType() const
Definition: Muon.h:61
virtual MuonTrackType tunePMuonBestTrackType() const
Definition: Muon.h:63
void MuonPFAnalyzer::recoToGenMatch ( edm::Handle< reco::MuonCollection > &  reco,
edm::Handle< reco::GenParticleCollection > &  gen 
)
private

Definition at line 378 of file MuonPFAnalyzer.cc.

References funct::abs(), PbPb_ZMuSkimMuonDPG_cff::deltaR, HGC3DClusterGenMatchSelector_cfi::dR, edm::HandleBase::isValid(), HLTObjectMonitor_cfi::muonEta, and HLTObjectMonitor_cfi::muonPhi.

378  {
379  theRecoGen.clear();
380 
381  if (muons.isValid()) {
382  MuonCollection::const_iterator muonIt = muons->begin();
383  MuonCollection::const_iterator muonEnd = muons->end();
384 
385  for (; muonIt != muonEnd; ++muonIt) {
386  float bestDR = 999.;
387  const GenParticle *bestGen = nullptr;
388 
389  if (theRunOnMC && gens.isValid()) {
390  GenParticleCollection::const_iterator genIt = gens->begin();
391  GenParticleCollection::const_iterator genEnd = gens->end();
392 
393  for (; genIt != genEnd; ++genIt) {
394  if (abs(genIt->pdgId()) == 13) {
395  float muonPhi = muonIt->phi();
396  float muonEta = muonIt->eta();
397 
398  float genPhi = genIt->phi();
399  float genEta = genIt->eta();
400 
401  float dR = deltaR(muonEta, muonPhi, genEta, genPhi);
402 
403  if (dR < theRecoGenR && dR < bestDR) {
404  bestDR = dR;
405  bestGen = &(*genIt);
406  }
407  }
408  }
409  }
410 
411  theRecoGen.push_back(RecoGenPair(&(*muonIt), bestGen));
412  }
413  }
414 }
RecoGenCollection theRecoGen
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::pair< const reco::Muon *, const reco::GenParticle * > RecoGenPair
void MuonPFAnalyzer::setCodeLabels ( MonitorElement plot,
int  nAxis 
)
private

Definition at line 304 of file MuonPFAnalyzer.cc.

References dqm::impl::MonitorElement::getTH1(), and timingPdfMaker::histo.

304  {
305  TAxis *axis = nullptr;
306 
307  TH1 *histo = plot->getTH1();
308  if (!histo)
309  return;
310 
311  if (nAxis == 1)
312  axis = histo->GetXaxis();
313  else if (nAxis == 2)
314  axis = histo->GetYaxis();
315 
316  if (!axis)
317  return;
318 
319  axis->SetBinLabel(1, "Inner Track");
320  axis->SetBinLabel(2, "Outer Track");
321  axis->SetBinLabel(3, "Combined");
322  axis->SetBinLabel(4, "TPFMS");
323  axis->SetBinLabel(5, "Picky");
324  axis->SetBinLabel(6, "DYT");
325  axis->SetBinLabel(7, "None");
326 }
virtual TH1 * getTH1() const

Member Data Documentation

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

Definition at line 76 of file MuonPFAnalyzer.h.

std::string MuonPFAnalyzer::theFolder
private

Definition at line 89 of file MuonPFAnalyzer.h.

edm::EDGetTokenT<reco::GenParticleCollection> MuonPFAnalyzer::theGenLabel_
private

Definition at line 73 of file MuonPFAnalyzer.h.

double MuonPFAnalyzer::theHighPtTh
private

Definition at line 83 of file MuonPFAnalyzer.h.

double MuonPFAnalyzer::theIsoCut
private

Definition at line 85 of file MuonPFAnalyzer.h.

std::vector<std::string> MuonPFAnalyzer::theMuonKinds
private

Definition at line 78 of file MuonPFAnalyzer.h.

std::map<std::string, std::map<std::string, MonitorElement *> > MuonPFAnalyzer::thePlots
private

Definition at line 80 of file MuonPFAnalyzer.h.

RecoGenCollection MuonPFAnalyzer::theRecoGen
private

Definition at line 81 of file MuonPFAnalyzer.h.

double MuonPFAnalyzer::theRecoGenR
private

Definition at line 84 of file MuonPFAnalyzer.h.

edm::EDGetTokenT<reco::MuonCollection> MuonPFAnalyzer::theRecoLabel_
private

Definition at line 74 of file MuonPFAnalyzer.h.

bool MuonPFAnalyzer::theRunOnMC
private

Definition at line 87 of file MuonPFAnalyzer.h.

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

Definition at line 75 of file MuonPFAnalyzer.h.