CMS 3D CMS Logo

MuonRecoOneHLT.cc
Go to the documentation of this file.
2 
4 
5 #include <string>
6 #include "TMath.h"
7 using namespace std;
8 using namespace edm;
9 
10 // Uncomment to DEBUG
11 //#define DEBUG
12 
14  parameters = pSet;
15 
16  ParameterSet muonparms = parameters.getParameter<edm::ParameterSet>("SingleMuonTrigger");
17  ParameterSet dimuonparms = parameters.getParameter<edm::ParameterSet>("DoubleMuonTrigger");
18  _SingleMuonEventFlag = new GenericTriggerEventFlag(muonparms, consumesCollector(), *this, l1t::UseEventSetupIn::Run);
19  _DoubleMuonEventFlag =
20  new GenericTriggerEventFlag(dimuonparms, consumesCollector(), *this, l1t::UseEventSetupIn::Run);
21 
22  // Trigger Expresions in case de connection to the DB fails
23  singlemuonExpr_ = muonparms.getParameter<std::vector<std::string> >("hltPaths");
24  doublemuonExpr_ = dimuonparms.getParameter<std::vector<std::string> >("hltPaths");
25 
26  theMuonCollectionLabel_ = consumes<reco::MuonCollection>(parameters.getParameter<edm::InputTag>("MuonCollection"));
27  theVertexLabel_ = consumes<reco::VertexCollection>(parameters.getParameter<edm::InputTag>("VertexLabel"));
28  theBeamSpotLabel_ = mayConsume<reco::BeamSpot>(parameters.getParameter<edm::InputTag>("BeamSpotLabel"));
29  theTriggerResultsLabel_ = consumes<TriggerResults>(parameters.getParameter<InputTag>("TriggerResultsLabel"));
30 
31  // Parameters
32  etaBin = parameters.getParameter<int>("etaBin");
33  etaMin = parameters.getParameter<double>("etaMin");
34  etaMax = parameters.getParameter<double>("etaMax");
35  ptBin = parameters.getParameter<int>("ptBin");
36  ptMin = parameters.getParameter<double>("ptMin");
37  ptMax = parameters.getParameter<double>("ptMax");
38  chi2Bin = parameters.getParameter<int>("chi2Bin");
39  chi2Min = parameters.getParameter<double>("chi2Min");
40  chi2Max = parameters.getParameter<double>("chi2Max");
41  phiBin = parameters.getParameter<int>("phiBin");
42  phiMin = parameters.getParameter<double>("phiMin");
43  phiMax = parameters.getParameter<double>("phiMax");
44 }
46  delete _SingleMuonEventFlag;
47  delete _DoubleMuonEventFlag;
48 }
49 void MuonRecoOneHLT::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
50 #ifdef DEBUG
51  cout << "[MuonRecoOneHLT] beginRun " << endl;
52  cout << "[MuonRecoOneHLT] Is MuonEventFlag On? " << _SingleMuonEventFlag->on() << endl;
53 #endif
54 
55  ibooker.cd();
56  ibooker.setCurrentFolder("Muons/MuonRecoOneHLT");
57 
58  muReco = ibooker.book1D("Muon_Reco", "Muon Reconstructed Tracks", 6, 1, 7);
59  muReco->setBinLabel(1, "glb+tk+sta");
60  muReco->setBinLabel(2, "glb+sta");
61  muReco->setBinLabel(3, "tk+sta");
62  muReco->setBinLabel(4, "tk");
63  muReco->setBinLabel(5, "sta");
64  muReco->setBinLabel(6, "calo");
65 
66  // monitoring of eta parameter
67  std::string histname = "GlbMuon_";
68  etaGlbTrack.push_back(ibooker.book1D(histname + "Glb_eta", "#eta_{GLB}", etaBin, etaMin, etaMax));
69  etaGlbTrack.push_back(ibooker.book1D(histname + "Tk_eta", "#eta_{TKfromGLB}", etaBin, etaMin, etaMax));
70  etaGlbTrack.push_back(ibooker.book1D(histname + "Sta_eta", "#eta_{STAfromGLB}", etaBin, etaMin, etaMax));
71  etaTight = ibooker.book1D("TightMuon_eta", "#eta_{GLB}", etaBin, etaMin, etaMax);
72  etaTrack = ibooker.book1D("TkMuon_eta", "#eta_{TK}", etaBin, etaMin, etaMax);
73  etaStaTrack = ibooker.book1D("StaMuon_eta", "#eta_{STA}", etaBin, etaMin, etaMax);
74 
75  // monitoring of phi paramater
76  phiGlbTrack.push_back(ibooker.book1D(histname + "Glb_phi", "#phi_{GLB}", phiBin, phiMin, phiMax));
77  phiGlbTrack[0]->setAxisTitle("rad");
78  phiGlbTrack.push_back(ibooker.book1D(histname + "Tk_phi", "#phi_{TKfromGLB}", phiBin, phiMin, phiMax));
79  phiGlbTrack[1]->setAxisTitle("rad");
80  phiGlbTrack.push_back(ibooker.book1D(histname + "Sta_phi", "#phi_{STAfromGLB}", phiBin, phiMin, phiMax));
81  phiGlbTrack[2]->setAxisTitle("rad");
82  phiTight = ibooker.book1D("TightMuon_phi", "#phi_{GLB}", phiBin, phiMin, phiMax);
83  phiTrack = ibooker.book1D("TkMuon_phi", "#phi_{TK}", phiBin, phiMin, phiMax);
84  phiTrack->setAxisTitle("rad");
85  phiStaTrack = ibooker.book1D("StaMuon_phi", "#phi_{STA}", phiBin, phiMin, phiMax);
86  phiStaTrack->setAxisTitle("rad");
87 
88  // monitoring of the chi2 parameter
89  chi2OvDFGlbTrack.push_back(
90  ibooker.book1D(histname + "Glb_chi2OverDf", "#chi_{2}OverDF_{GLB}", chi2Bin, chi2Min, chi2Max));
91  chi2OvDFGlbTrack.push_back(
92  ibooker.book1D(histname + "Tk_chi2OverDf", "#chi_{2}OverDF_{TKfromGLB}", phiBin, chi2Min, chi2Max));
93  chi2OvDFGlbTrack.push_back(
94  ibooker.book1D(histname + "Sta_chi2OverDf", "#chi_{2}OverDF_{STAfromGLB}", chi2Bin, chi2Min, chi2Max));
95  chi2OvDFTight = ibooker.book1D("TightMuon_chi2OverDf", "#chi_{2}OverDF_{GLB}", chi2Bin, chi2Min, chi2Max);
96  chi2OvDFTrack = ibooker.book1D("TkMuon_chi2OverDf", "#chi_{2}OverDF_{TK}", chi2Bin, chi2Min, chi2Max);
97  chi2OvDFStaTrack = ibooker.book1D("StaMuon_chi2OverDf", "#chi_{2}OverDF_{STA}", chi2Bin, chi2Min, chi2Max);
98 
99  // monitoring of the transverse momentum
100  ptGlbTrack.push_back(ibooker.book1D(histname + "Glb_pt", "pt_{GLB}", ptBin, ptMin, ptMax));
101  ptGlbTrack[0]->setAxisTitle("GeV");
102  ptGlbTrack.push_back(ibooker.book1D(histname + "Tk_pt", "pt_{TKfromGLB}", ptBin, ptMin, ptMax));
103  ptGlbTrack[1]->setAxisTitle("GeV");
104  ptGlbTrack.push_back(ibooker.book1D(histname + "Sta_pt", "pt_{STAfromGLB}", ptBin, ptMin, ptMax));
105  ptGlbTrack[2]->setAxisTitle("GeV");
106  ptTight = ibooker.book1D("TightMuon_pt", "pt_{GLB}", ptBin, ptMin, ptMax);
107  ptTight->setAxisTitle("GeV");
108  ptTrack = ibooker.book1D("TkMuon_pt", "pt_{TK}", ptBin, ptMin, ptMax);
109  ptTrack->setAxisTitle("GeV");
110  ptStaTrack = ibooker.book1D("StaMuon_pt", "pt_{STA}", ptBin, ptMin, ptMax);
111  ptStaTrack->setAxisTitle("GeV");
112 
113  if (_SingleMuonEventFlag->on())
114  _SingleMuonEventFlag->initRun(iRun, iSetup);
115  if (_DoubleMuonEventFlag->on())
116  _DoubleMuonEventFlag->initRun(iRun, iSetup);
117 
118  if (_SingleMuonEventFlag->on() &&
119  _SingleMuonEventFlag->expressionsFromDB(_SingleMuonEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
120  singlemuonExpr_ = _SingleMuonEventFlag->expressionsFromDB(_SingleMuonEventFlag->hltDBKey(), iSetup);
121  if (_DoubleMuonEventFlag->on() &&
122  _DoubleMuonEventFlag->expressionsFromDB(_DoubleMuonEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
123  singlemuonExpr_ = _DoubleMuonEventFlag->expressionsFromDB(_DoubleMuonEventFlag->hltDBKey(), iSetup);
124 }
126  // =================================================================================
127  // Look for the Primary Vertex (and use the BeamSpot instead, if you can't find it):
128  reco::Vertex::Point posVtx;
129  reco::Vertex::Error errVtx;
130  unsigned int theIndexOfThePrimaryVertex = 999.;
131 
133  iEvent.getByToken(theVertexLabel_, vertex);
134  if (vertex.isValid()) {
135  for (unsigned int ind = 0; ind < vertex->size(); ++ind) {
136  if ((*vertex)[ind].isValid() && !((*vertex)[ind].isFake())) {
137  theIndexOfThePrimaryVertex = ind;
138  break;
139  }
140  }
141  }
142 
143  if (theIndexOfThePrimaryVertex < 100) {
144  posVtx = ((*vertex)[theIndexOfThePrimaryVertex]).position();
145  errVtx = ((*vertex)[theIndexOfThePrimaryVertex]).error();
146  } else {
147  LogInfo("RecoMuonValidator") << "reco::PrimaryVertex not found, use BeamSpot position instead\n";
148 
149  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
150  iEvent.getByToken(theBeamSpotLabel_, recoBeamSpotHandle);
151  const reco::BeamSpot& bs = *recoBeamSpotHandle;
152 
153  posVtx = bs.position();
154  errVtx(0, 0) = bs.BeamWidthX();
155  errVtx(1, 1) = bs.BeamWidthY();
156  errVtx(2, 2) = bs.sigmaZ();
157  }
158 
159  const reco::Vertex vtx(posVtx, errVtx);
160 
161  // ==========================================================
162  // READ DATA:
164  iEvent.getByToken(theMuonCollectionLabel_, muons);
165 
167  iEvent.getByToken(theTriggerResultsLabel_, triggerResults);
168 
169  // check if muon collection is valid
170  if (!muons.isValid())
171  return;
172 
173  // Pick the leading lepton.
174  std::map<float, const reco::Muon*> muonMap;
175  for (reco::MuonCollection::const_iterator recoMu = muons->begin(); recoMu != muons->end(); ++recoMu) {
176  muonMap[recoMu->pt()] = &*recoMu;
177  }
178  std::vector<const reco::Muon*> LeadingMuon;
179  for (std::map<float, const reco::Muon*>::reverse_iterator rit = muonMap.rbegin(); rit != muonMap.rend(); ++rit) {
180  LeadingMuon.push_back((*rit).second);
181  }
182 
183  // Pick Trigger information.
184  const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults);
185  const unsigned int nTrig(triggerNames.size());
186  bool _trig_SingleMu = false;
187  bool _trig_DoubleMu = false;
188  for (unsigned int i = 0; i < nTrig; ++i) {
189  if (triggerNames.triggerName(i).find(singlemuonExpr_[0].substr(0, singlemuonExpr_[0].rfind("_v") + 2)) !=
190  std::string::npos &&
191  triggerResults->accept(i))
192  _trig_SingleMu = true;
193  if (triggerNames.triggerName(i).find(doublemuonExpr_[0].substr(0, doublemuonExpr_[0].rfind("_v") + 2)) !=
194  std::string::npos &&
195  triggerResults->accept(i))
196  _trig_DoubleMu = true;
197  }
198 #ifdef DEBUG
199  cout << "[MuonRecoOneHLT] Trigger Fired ? " << (_trig_SingleMu || _trig_DoubleMu) << endl;
200 #endif
201 
202  if (!_trig_SingleMu && !_trig_DoubleMu)
203  return;
204  if (LeadingMuon.empty())
205  return;
206  // if (_MuonEventFlag->on() && !(_MuonEventFlag->accept(iEvent,iSetup))) return;
207 
208  // Check if Muon is Global
209  if ((*LeadingMuon[0]).isGlobalMuon()) {
210  LogTrace(metname) << "[MuonRecoOneHLT] The mu is global - filling the histos";
211  if ((*LeadingMuon[0]).isTrackerMuon() && (*LeadingMuon[0]).isStandAloneMuon())
212  muReco->Fill(1);
213  if (!((*LeadingMuon[0]).isTrackerMuon()) && (*LeadingMuon[0]).isStandAloneMuon())
214  muReco->Fill(2);
215  if (!(*LeadingMuon[0]).isStandAloneMuon())
216  LogTrace(metname) << "[MuonRecoOneHLT] ERROR: the mu is global but not standalone!";
217 
218  // get the track combinig the information from both the Tracker and the Spectrometer
219  reco::TrackRef recoCombinedGlbTrack = (*LeadingMuon[0]).combinedMuon();
220  // get the track using only the tracker data
221  reco::TrackRef recoTkGlbTrack = (*LeadingMuon[0]).track();
222  // get the track using only the mu spectrometer data
223  reco::TrackRef recoStaGlbTrack = (*LeadingMuon[0]).standAloneMuon();
224 
225  etaGlbTrack[0]->Fill(recoCombinedGlbTrack->eta());
226  etaGlbTrack[1]->Fill(recoTkGlbTrack->eta());
227  etaGlbTrack[2]->Fill(recoStaGlbTrack->eta());
228 
229  phiGlbTrack[0]->Fill(recoCombinedGlbTrack->phi());
230  phiGlbTrack[1]->Fill(recoTkGlbTrack->phi());
231  phiGlbTrack[2]->Fill(recoStaGlbTrack->phi());
232 
233  chi2OvDFGlbTrack[0]->Fill(recoCombinedGlbTrack->normalizedChi2());
234  chi2OvDFGlbTrack[1]->Fill(recoTkGlbTrack->normalizedChi2());
235  chi2OvDFGlbTrack[2]->Fill(recoStaGlbTrack->normalizedChi2());
236 
237  ptGlbTrack[0]->Fill(recoCombinedGlbTrack->pt());
238  ptGlbTrack[1]->Fill(recoTkGlbTrack->pt());
239  ptGlbTrack[2]->Fill(recoStaGlbTrack->pt());
240  }
241  // Check if Muon is Tight
242  if (muon::isTightMuon((*LeadingMuon[0]), vtx)) {
243  LogTrace(metname) << "[MuonRecoOneHLT] The mu is tracker only - filling the histos";
244 
245  reco::TrackRef recoCombinedGlbTrack = (*LeadingMuon[0]).combinedMuon();
246 
247  etaTight->Fill(recoCombinedGlbTrack->eta());
248  phiTight->Fill(recoCombinedGlbTrack->phi());
249  chi2OvDFTight->Fill(recoCombinedGlbTrack->normalizedChi2());
250  ptTight->Fill(recoCombinedGlbTrack->pt());
251  }
252 
253  // Check if Muon is Tracker but NOT Global
254  if ((*LeadingMuon[0]).isTrackerMuon() && !((*LeadingMuon[0]).isGlobalMuon())) {
255  LogTrace(metname) << "[MuonRecoOneHLT] The mu is tracker only - filling the histos";
256  if ((*LeadingMuon[0]).isStandAloneMuon())
257  muReco->Fill(3);
258  if (!((*LeadingMuon[0]).isStandAloneMuon()))
259  muReco->Fill(4);
260 
261  // get the track using only the tracker data
262  reco::TrackRef recoTrack = (*LeadingMuon[0]).track();
263 
264  etaTrack->Fill(recoTrack->eta());
265  phiTrack->Fill(recoTrack->phi());
266  chi2OvDFTrack->Fill(recoTrack->normalizedChi2());
267  ptTrack->Fill(recoTrack->pt());
268  }
269 
270  // Check if Muon is STA but NOT Global
271  if ((*LeadingMuon[0]).isStandAloneMuon() && !((*LeadingMuon[0]).isGlobalMuon())) {
272  LogTrace(metname) << "[MuonRecoOneHLT] The mu is STA only - filling the histos";
273  if (!((*LeadingMuon[0]).isTrackerMuon()))
274  muReco->Fill(5);
275 
276  // get the track using only the mu spectrometer data
277  reco::TrackRef recoStaTrack = (*LeadingMuon[0]).standAloneMuon();
278 
279  etaStaTrack->Fill(recoStaTrack->eta());
280  phiStaTrack->Fill(recoStaTrack->phi());
281  chi2OvDFStaTrack->Fill(recoStaTrack->normalizedChi2());
282  ptStaTrack->Fill(recoStaTrack->pt());
283  }
284  // Check if Muon is Only CaloMuon
285  if ((*LeadingMuon[0]).isCaloMuon() && !((*LeadingMuon[0]).isGlobalMuon()) && !((*LeadingMuon[0]).isTrackerMuon()) &&
286  !((*LeadingMuon[0]).isStandAloneMuon()))
287  muReco->Fill(6);
288 }
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
etaBin
int etaBin(const l1t::HGCalMulticluster *cl)
Definition: L1EGammaEEProducer.cc:19
edm::Run
Definition: Run.h:45
BeamMonitor_cff.phiBin
phiBin
Definition: BeamMonitor_cff.py:76
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::Vertex::Error
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
gather_cfg.cout
cout
Definition: gather_cfg.py:144
muonRecoAnalyzer_cfi.chi2Min
chi2Min
Definition: muonRecoAnalyzer_cfi.py:34
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:155
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
l1t::UseEventSetupIn::Run
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle< reco::VertexCollection >
relativeConstraints.error
error
Definition: relativeConstraints.py:53
muonRecoAnalyzer_cfi.ptBin
ptBin
Definition: muonRecoAnalyzer_cfi.py:45
edm::Ref< TrackCollection >
cms::cuda::bs
bs
Definition: HistoContainer.h:127
MuonRecoOneHLT::MuonRecoOneHLT
MuonRecoOneHLT(const edm::ParameterSet &)
Constructor.
Definition: MuonRecoOneHLT.cc:13
AlignmentTrackSelector_cfi.ptMax
ptMax
Definition: AlignmentTrackSelector_cfi.py:12
L1TEGammaOffline_cfi.triggerNames
triggerNames
Definition: L1TEGammaOffline_cfi.py:40
AlignmentTrackSelector_cfi.phiMin
phiMin
Definition: AlignmentTrackSelector_cfi.py:18
reco::BeamSpot
Definition: BeamSpot.h:21
AlignmentTrackSelector_cfi.phiMax
phiMax
Definition: AlignmentTrackSelector_cfi.py:17
MuonRecoOneHLT::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: MuonRecoOneHLT.cc:49
dqm::implementation::NavigatorBase::cd
virtual void cd()
Definition: DQMStore.cc:29
MuonRecoOneHLT::~MuonRecoOneHLT
~MuonRecoOneHLT() override
Destructor.
Definition: MuonRecoOneHLT.cc:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
edm::ParameterSet
Definition: ParameterSet.h:47
GenericTriggerEventFlag
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Definition: GenericTriggerEventFlag.h:42
muon::isTightMuon
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
Definition: MuonSelectors.cc:880
MuonRecoOneHLT::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: MuonRecoOneHLT.cc:125
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
TriggerNames.h
iEvent
int iEvent
Definition: GenABIO.cc:224
muonRecoAnalyzer_cfi.chi2Max
chi2Max
Definition: muonRecoAnalyzer_cfi.py:35
dqm::impl::MonitorElement::setBinLabel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:771
edm::EventSetup
Definition: EventSetup.h:58
reco::Vertex::Point
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
std
Definition: JetResolutionObject.h:76
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
edm::TriggerNames
Definition: TriggerNames.h:55
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MuonRecoOneHLT.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
edm::Event
Definition: Event.h:73
susybsm::HSCParticleType::standAloneMuon
Definition: HSCParticle.h:20
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:800
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
muonRecoAnalyzer_cfi.chi2Bin
chi2Bin
Definition: muonRecoAnalyzer_cfi.py:33
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40