CMS 3D CMS Logo

L1TMuonDQMOffline.cc
Go to the documentation of this file.
1 
12 
13 #include <array>
14 
15 using namespace reco;
16 using namespace trigger;
17 using namespace edm;
18 using namespace std;
19 using namespace l1t;
20 
21 //__________RECO-GMT Muon Pair Helper Class____________________________
22 
23 MuonGmtPair::MuonGmtPair(const reco::Muon *muon, const l1t::Muon *regMu, const PropagateToMuon& propagator, bool useAtVtxCoord) :
24  m_muon(muon), m_regMu(regMu)
25 {
26  if (m_regMu) {
27  if (useAtVtxCoord) {
30  } else {
31  m_gmtEta = m_regMu->eta();
32  m_gmtPhi = m_regMu->phi();
33  }
34  } else {
35  m_gmtEta = -5.;
36  m_gmtPhi = -5.;
37  }
38  if (m_muon) {
39  TrajectoryStateOnSurface trajectory = propagator.extrapolate(*m_muon);
40  if (trajectory.isValid()) {
41  m_eta = trajectory.globalPosition().eta();
42  m_phi = trajectory.globalPosition().phi();
43  }
44  } else {
45  m_eta = 999.;
46  m_phi = 999.;
47  }
48 };
49 
51  m_muon = muonGmtPair.m_muon;
52  m_regMu = muonGmtPair.m_regMu;
53 
54  m_gmtEta = muonGmtPair.m_gmtEta;
55  m_gmtPhi = muonGmtPair.m_gmtPhi;
56 
57  m_eta = muonGmtPair.m_eta;
58  m_phi = muonGmtPair.m_phi;
59 }
60 
61 double MuonGmtPair::dR() {
62  float dEta = m_regMu ? (m_gmtEta - m_eta) : 999.;
63  float dPhi = m_regMu ? reco::deltaPhi(m_gmtPhi, m_phi) : 999.;
64  return sqrt(dEta*dEta + dPhi*dPhi);
65 }
66 
72 }
73 
75  if (type == L1TMuonDQMOffline::kResPt) return (gmtPt() - pt()) / pt();
76  if (type == L1TMuonDQMOffline::kRes1OverPt) return (pt() - gmtPt()) / gmtPt(); // (1/gmtPt - 1/pt) / (1/pt)
77  if (type == L1TMuonDQMOffline::kResQOverPt) return (gmtCharge()*charge()*pt() - gmtPt()) / gmtPt(); // (gmtCharge/gmtPt - charge/pt) / (charge/pt) with gmtCharge/charge = gmtCharge*charge
78  if (type == L1TMuonDQMOffline::kResPhi) return reco::deltaPhi(gmtPhi(), m_phi);
79  if (type == L1TMuonDQMOffline::kResEta) return gmtEta() - m_eta;
80  if (type == L1TMuonDQMOffline::kResCh) return gmtCharge() - charge();
81  return -999.;
82 }
83 
85  if (type == L1TMuonDQMOffline::kEffPt) return pt();
86  if (type == L1TMuonDQMOffline::kEffPhi) return m_phi;
87  if (type == L1TMuonDQMOffline::kEffEta) return m_eta;
88  return -999.;
89 }
90 
91 //__________DQM_base_class_______________________________________________
93  m_propagator(ps.getParameter<edm::ParameterSet>("muProp")),
94  m_effTypes({kEffPt, kEffPhi, kEffEta, kEffVtx}),
98  m_effStrings({ {kEffPt, "pt"}, {kEffPhi, "phi"}, {kEffEta, "eta"}, {kEffVtx, "vtx"} }),
99  m_effLabelStrings({ {kEffPt, "p_{T} (GeV)"}, {kEffPhi, "#phi"}, {kEffEta, "#eta"}, {kEffVtx, "# vertices"} }),
100  m_resStrings({ {kResPt, "pt"}, {kRes1OverPt, "1overpt"}, {kResQOverPt, "qoverpt"}, {kResPhi, "phi"}, {kResEta, "eta"}, {kResCh, "charge"} }),
101  m_resLabelStrings({ {kResPt, "(p_{T}^{L1} - p_{T}^{reco})/p_{T}^{reco}"}, {kRes1OverPt, "(p_{T}^{reco} - p_{T}^{L1})/p_{T}^{L1}"}, {kResQOverPt, "(q^{L1}*q^{reco}*p_{T}^{reco} - p_{T}^{L1})/p_{T}^{L1}"}, {kResPhi, "#phi_{L1} - #phi_{reco}"}, {kResEta, "#eta_{L1} - #eta_{reco}"}, {kResCh, "charge^{L1} - charge^{reco}"} }),
102  m_etaStrings({ {kEtaRegionAll, "etaMin0_etaMax2p4"}, {kEtaRegionBmtf, "etaMin0_etaMax0p83"}, {kEtaRegionOmtf, "etaMin0p83_etaMax1p24"}, {kEtaRegionEmtf, "etaMin1p24_etaMax2p4"} }),
103  m_qualStrings({ {kQualAll, "qualAll"}, {kQualOpen, "qualOpen"}, {kQualDouble, "qualDouble"}, {kQualSingle, "qualSingle"} }),
104  m_verbose(ps.getUntrackedParameter<bool>("verbose")),
105  m_HistFolder(ps.getUntrackedParameter<string>("histFolder")),
106  m_TagPtCut(ps.getUntrackedParameter<double>("tagPtCut")),
107  m_recoToL1PtCutFactor(ps.getUntrackedParameter<double>("recoToL1PtCutFactor")),
108  m_cutsVPSet(ps.getUntrackedParameter<std::vector<edm::ParameterSet>>("cuts")),
109  m_MuonInputTag(consumes<reco::MuonCollection>(ps.getUntrackedParameter<InputTag>("muonInputTag"))),
110  m_GmtInputTag(consumes<l1t::MuonBxCollection>(ps.getUntrackedParameter<InputTag>("gmtInputTag"))),
111  m_VtxInputTag(consumes<VertexCollection>(ps.getUntrackedParameter<InputTag>("vtxInputTag"))),
112  m_BsInputTag(consumes<BeamSpot>(ps.getUntrackedParameter<InputTag>("bsInputTag"))),
113  m_trigInputTag(consumes<trigger::TriggerEvent>(ps.getUntrackedParameter<InputTag>("trigInputTag"))),
114  m_trigProcess(ps.getUntrackedParameter<string>("trigProcess")),
115  m_trigProcess_token(consumes<edm::TriggerResults>(ps.getUntrackedParameter<InputTag>("trigProcess_token"))),
116  m_trigNames(ps.getUntrackedParameter<vector<string> >("triggerNames")),
117  m_effVsPtBins(ps.getUntrackedParameter<std::vector<double>>("efficiencyVsPtBins")),
118  m_effVsPhiBins(ps.getUntrackedParameter<std::vector<double>>("efficiencyVsPhiBins")),
119  m_effVsEtaBins(ps.getUntrackedParameter<std::vector<double>>("efficiencyVsEtaBins")),
120  m_effVsVtxBins(ps.getUntrackedParameter<std::vector<double>>("efficiencyVsVtxBins")),
121  m_useAtVtxCoord(ps.getUntrackedParameter<bool>("useL1AtVtxCoord")),
122  m_maxGmtMuonDR(0.3),
123  m_minTagProbeDR(0.5),
124  m_maxHltMuonDR(0.1)
125 {
126  if (m_verbose) cout << "[L1TMuonDQMOffline:] ____________ Storage initialization ____________ " << endl;
127 
128  for (const auto cutsPSet : m_cutsVPSet) {
129  const auto qCut = cutsPSet.getUntrackedParameter<int>("qualCut");
130  QualLevel qLevel = kQualAll;
131  if (qCut > 11) {
132  qLevel = kQualSingle;
133  } else if (qCut > 7) {
134  qLevel = kQualDouble;
135  } else if (qCut > 3) {
136  qLevel = kQualOpen;
137  }
138  m_cuts.emplace_back(std::make_pair(cutsPSet.getUntrackedParameter<int>("ptCut"), qLevel));
139  }
140 }
141 
142 //_____________________________________________________________________
144 //----------------------------------------------------------------------
146  if (m_verbose) cout << "[L1TMuonDQMOffline:] Called beginRun." << endl;
147  bool changed = true;
148  m_hltConfig.init(run,iSetup,m_trigProcess,changed);
149  m_propagator.init(iSetup);
150 }
151 
152 //_____________________________________________________________________
154  //book histos
155  bookControlHistos(ibooker);
156  bookEfficiencyHistos(ibooker);
157  bookResolutionHistos(ibooker);
158 
159  vector<string>::const_iterator trigNamesIt = m_trigNames.begin();
160  vector<string>::const_iterator trigNamesEnd = m_trigNames.end();
161 
162  for (; trigNamesIt!=trigNamesEnd; ++trigNamesIt) {
163  TString tNameTmp = TString(*trigNamesIt); // use TString as it handles regex
164  TRegexp tNamePattern = TRegexp(tNameTmp,true);
165  int tIndex = -1;
166 
167  for (unsigned ipath = 0; ipath < m_hltConfig.size(); ++ipath) {
168  TString tmpName = TString(m_hltConfig.triggerName(ipath));
169  if (tmpName.Contains(tNamePattern)) {
170  tIndex = int(ipath);
171  m_trigIndices.push_back(tIndex);
172  }
173  }
174  if (tIndex < 0 && m_verbose) cout << "[L1TMuonDQMOffline:] Warning: Could not find trigger " << (*trigNamesIt) << endl;
175  }
176 }
177 
178 //_____________________________________________________________________
180  if(m_verbose) cout << "[L1TMuonDQMOffline:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;
181 }
182 
183 //_____________________________________________________________________
185  if(m_verbose) cout << "[L1TMuonDQMOffline:] Called endLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;
186 }
187 
188 //_____________________________________________________________________
189 void L1TMuonDQMOffline::analyze(const Event & iEvent, const EventSetup & eventSetup){
190 
192  iEvent.getByToken(m_MuonInputTag, muons);
194  iEvent.getByToken(m_BsInputTag, beamSpot);
196  iEvent.getByToken(m_VtxInputTag, vertex);
198  iEvent.getByToken(m_GmtInputTag,gmtCands);
199  Handle<edm::TriggerResults> trigResults;
200  iEvent.getByToken(m_trigProcess_token,trigResults);
202  iEvent.getByToken(m_trigInputTag,trigEvent);
203 
204  const auto nVtx = getNVertices(vertex);
205  const Vertex primaryVertex = getPrimaryVertex(vertex,beamSpot);
206 
207  getTightMuons(muons,primaryVertex);
208  getProbeMuons(trigResults,trigEvent); // CB add flag to run on orthogonal datasets (no T&P)
209 
210  getMuonGmtPairs(gmtCands);
211 
212  if (m_verbose) cout << "[L1TMuonDQMOffline:] Computing efficiencies" << endl;
213 
214  vector<MuonGmtPair>::const_iterator muonGmtPairsIt = m_MuonGmtPairs.begin();
215  vector<MuonGmtPair>::const_iterator muonGmtPairsEnd = m_MuonGmtPairs.end();
216 
217  // To fill once for global eta and once for TF eta region of the L1T muon.
218  // The second entry is a placeholder and will be replaced by the TF eta region of the L1T muon.
219  std::array<EtaRegion, 2> regsToFill { {kEtaRegionAll, kEtaRegionAll} };
220 
221  for(; muonGmtPairsIt!=muonGmtPairsEnd; ++muonGmtPairsIt) {
222  // Fill the resolution histograms
223  if( (muonGmtPairsIt->etaRegion() != kEtaRegionOut) && (muonGmtPairsIt->gmtPt() > 0) ){
224  regsToFill[1] = muonGmtPairsIt->etaRegion();
226  for (const auto var : m_resTypes) {
227  const auto varToFill = muonGmtPairsIt->getDeltaVar(var);
228  std::get<0>(histoKeyRes) = var;
229  // Fill for the global eta and for TF eta region that the probe muon is in
230  for (const auto regToFill : regsToFill) {
231  std::get<1>(histoKeyRes) = regToFill;
232  for (const auto qualLevel : m_qualLevelsRes) {
233  // This assumes that the qualLevel enum has increasing qualities
234  // HW quality levels can be 0, 4, 8, or 12
235  int qualCut = qualLevel * 4;
236  if (muonGmtPairsIt->gmtQual() >= qualCut) {
237  std::get<2>(histoKeyRes) = qualLevel;
238  m_ResolutionHistos[histoKeyRes]->Fill(varToFill);
239  }
240  }
241  }
242  }
243  }
244 
245  // Fill the efficiency numerator and denominator histograms
246  if (muonGmtPairsIt->etaRegion() != kEtaRegionOut) {
247  unsigned int cutsCounter = 0;
248  for (const auto cut : m_cuts) {
249  const auto gmtPtCut = cut.first;
250  const auto qualLevel = cut.second;
251  const bool gmtAboveCut = (muonGmtPairsIt->gmtPt() > gmtPtCut);
252 
253  // default keys
254  m_histoKeyEffDenVarType histoKeyEffDenVar = {kEffPt, gmtPtCut, kEtaRegionAll};
255  m_histoKeyEffNumVarType histoKeyEffNumVar = {kEffPt, gmtPtCut, kEtaRegionAll, qualLevel};
256 
257  regsToFill[1] = muonGmtPairsIt->etaRegion();
258  for(const auto var : m_effTypes) {
259  if(var != kEffPt){
260  if (muonGmtPairsIt->pt() < m_recoToL1PtCutFactor * gmtPtCut) break; // efficiency at plateau
261  }
262  double varToFill;
263  if (var == kEffVtx) {
264  varToFill = static_cast<double>(nVtx);
265  } else {
266  varToFill = muonGmtPairsIt->getVar(var);
267  }
268  // Fill denominators
269  if (var == kEffEta) {
270  m_EfficiencyDenEtaHistos[gmtPtCut]->Fill(varToFill);
271  } else {
272  std::get<0>(histoKeyEffDenVar) = var;
273  // Fill for the global eta and for TF eta region that the probe muon is in
274  for (const auto regToFill : regsToFill) {
275  if (var == kEffPt) {
276  if (cutsCounter == 0) {
277  m_EfficiencyDenPtHistos[regToFill]->Fill(varToFill);
278  }
279  } else {
280  std::get<2>(histoKeyEffDenVar) = regToFill;
281  m_EfficiencyDenVarHistos[histoKeyEffDenVar]->Fill(varToFill);
282  }
283  }
284  }
285  // Fill numerators
286  std::get<0>(histoKeyEffNumVar) = var;
287  // This assumes that the qualLevel enum has increasing qualities
288  if (gmtAboveCut && muonGmtPairsIt->gmtQual() >= qualLevel * 4) {
289  if (var == kEffEta) {
290  m_histoKeyEffNumEtaType histoKeyEffNumEta = {gmtPtCut, qualLevel};
291  m_EfficiencyNumEtaHistos[histoKeyEffNumEta]->Fill(varToFill);
292  } else {
293  std::get<3>(histoKeyEffNumVar) = qualLevel;
294  // Fill for the global eta and for TF eta region that the probe muon is in
295  for (const auto regToFill : regsToFill) {
296  std::get<2>(histoKeyEffNumVar) = regToFill;
297  m_EfficiencyNumVarHistos[histoKeyEffNumVar]->Fill(varToFill);
298  }
299  }
300  }
301  }
302  ++cutsCounter;
303  }
304  }
305  }
306 
307  if (m_verbose) cout << "[L1TMuonDQMOffline:] Computation finished" << endl;
308 }
309 
310 //_____________________________________________________________________
312  if(m_verbose) cout << "[L1TMuonDQMOffline:] Booking Control Plot Histos" << endl;
313 
314  ibooker.setCurrentFolder(m_HistFolder+"/control_variables");
315 
316  m_ControlHistos[kCtrlMuonGmtDeltaR] = ibooker.book1D("MuonGmtDeltaR", "MuonGmtDeltaR; #DeltaR", 50, 0., 0.5);
317  m_ControlHistos[kCtrlNTightVsAll] = ibooker.book2D("NTightVsAll", "NTightVsAll; # muons; # tight muons", 20, -0.5, 19.5, 16, -0.5, 15.5);
318  m_ControlHistos[kCtrlNProbesVsTight] = ibooker.book2D("NProbesVsTight", "NProbesVsTight; # tight muons; # probe muons", 8, -0.5, 7.5, 8, -0.5, 7.5);
319 
320  m_ControlHistos[kCtrlTagPt] = ibooker.book1D("TagMuonPt", "TagMuonPt; p_{T}", 50, 0., 100.);
321  m_ControlHistos[kCtrlTagPhi] = ibooker.book1D("TagMuonPhi", "TagMuonPhi; #phi", 66, -3.3, 3.3);
322  m_ControlHistos[kCtrlTagEta] = ibooker.book1D("TagMuonEta", "TagMuonEta; #eta", 50, -2.5, 2.5);
323 
324  m_ControlHistos[kCtrlProbePt] = ibooker.book1D("ProbeMuonPt", "ProbeMuonPt; p_{T}", 50, 0., 100.);
325  m_ControlHistos[kCtrlProbePhi] = ibooker.book1D("ProbeMuonPhi", "ProbeMuonPhi; #phi", 66, -3.3, 3.3);
326  m_ControlHistos[kCtrlProbeEta] = ibooker.book1D("ProbeMuonEta", "ProbeMuonEta; #eta", 50, -2.5, 2.5);
327 
328  m_ControlHistos[kCtrlTagProbeDr] = ibooker.book1D("TagMuonProbeMuonDeltaR", "TagMuonProbeMuonDeltaR; #DeltaR", 50, 0.,5.0);
329  m_ControlHistos[kCtrlTagHltDr] = ibooker.book1D("TagMuonHltDeltaR", "TagMuonHltDeltaR;#DeltaR", 55, 0., 0.11);
330 }
331 
332 //_____________________________________________________________________
334  ibooker.setCurrentFolder(m_HistFolder+"/numerators_and_denominators");
335 
336  for(const auto var : m_effTypes) {
337  auto histBins = getHistBinsEff(var);
338  // histograms for eta variable get a special treatment
339  if (var == kEffEta) {
340  for (const auto cut : m_cuts) {
341  const auto gmtPtCut = cut.first;
342  const auto qualLevel = cut.second;
343  std::string name = "effDen_"+m_effStrings[var]+"_"+std::to_string(gmtPtCut);
344  m_EfficiencyDenEtaHistos[gmtPtCut] = ibooker.book1D(name, name+";"+m_effLabelStrings[var], histBins.size()-1, &histBins[0]);
345  name = "effNum_"+m_effStrings[var]+"_"+std::to_string(gmtPtCut)+"_"+m_qualStrings[qualLevel];
346  m_histoKeyEffNumEtaType histoKeyEffNumEta = {gmtPtCut, qualLevel};
347  m_EfficiencyNumEtaHistos[histoKeyEffNumEta] = ibooker.book1D(name, name+";"+m_effLabelStrings[var], histBins.size()-1, &histBins[0]);
348  }
349  } else {
350  for (const auto etaReg : m_etaRegions) {
351  // denominator histograms for pt variable get a special treatment
352  if (var == kEffPt) {
353  std::string name = "effDen_"+m_effStrings[var]+"_"+m_etaStrings[etaReg];
354  m_EfficiencyDenPtHistos[etaReg] = ibooker.book1D(name, name+";"+m_effLabelStrings[var], histBins.size()-1, &histBins[0]);
355  } else {
356  for (const auto cut : m_cuts) {
357  const int gmtPtCut = cut.first;
358  std::string name = "effDen_"+m_effStrings[var]+"_"+std::to_string(gmtPtCut)+"_"+m_etaStrings[etaReg];
359  m_histoKeyEffDenVarType histoKeyEffDenVar = {var, gmtPtCut, etaReg};
360  m_EfficiencyDenVarHistos[histoKeyEffDenVar] = ibooker.book1D(name, name+";"+m_effLabelStrings[var], histBins.size()-1, &histBins[0]);
361  }
362  }
363  for (const auto cut : m_cuts) {
364  const auto gmtPtCut = cut.first;
365  const auto qualLevel = cut.second;
366  std::string name = "effNum_"+m_effStrings[var]+"_"+std::to_string(gmtPtCut)+"_"+m_etaStrings[etaReg]+"_"+m_qualStrings[qualLevel];
367  m_histoKeyEffNumVarType histoKeyEffNum = {var, gmtPtCut, etaReg, qualLevel};
368  m_EfficiencyNumVarHistos[histoKeyEffNum] = ibooker.book1D(name, name+";"+m_effLabelStrings[var], histBins.size()-1, &histBins[0]);
369  }
370  }
371  }
372  }
373 }
374 
376  if(m_verbose) cout << "[L1TMuonOffline:] Booking Resolution Plot Histos" << endl;
377  ibooker.setCurrentFolder(m_HistFolder+"/resolution");
378 
379  for (const auto var : m_resTypes) {
380  auto nbins = std::get<0>(getHistBinsRes(var));
381  auto xmin = std::get<1>(getHistBinsRes(var));
382  auto xmax = std::get<2>(getHistBinsRes(var));
383  for (const auto etaReg : m_etaRegions) {
384  for (const auto qualLevel : m_qualLevelsRes) {
385  m_histoKeyResType histoKeyRes = {var, etaReg, qualLevel};
386  std::string name = "resolution_"+m_resStrings[var]+"_"+m_etaStrings[etaReg]+"_"+m_qualStrings[qualLevel];
387  m_ResolutionHistos[histoKeyRes] = ibooker.book1D(name, name+";"+m_resLabelStrings[var], nbins, xmin, xmax);
388  }
389  }
390  }
391 }
392 
393 //_____________________________________________________________________
395  unsigned int nVtx = 0;
396 
397  if (vertex.isValid()) {
398  for (const auto vertexIt : *vertex) {
399  if (vertexIt.isValid() && !vertexIt.isFake()) {
400  ++nVtx;
401  }
402  }
403  }
404  return nVtx;
405 }
406 
407 //_____________________________________________________________________
410  Vertex::Point posVtx;
411  Vertex::Error errVtx;
412 
413  bool hasPrimaryVertex = false;
414 
415  if (vertex.isValid()) {
416  vector<Vertex>::const_iterator vertexIt = vertex->begin();
417  vector<Vertex>::const_iterator vertexEnd = vertex->end();
418 
419  for (;vertexIt!=vertexEnd;++vertexIt) {
420  if (vertexIt->isValid() && !vertexIt->isFake()) {
421  posVtx = vertexIt->position();
422  errVtx = vertexIt->error();
423  hasPrimaryVertex = true;
424  break;
425  }
426  }
427  }
428 
429  if ( !hasPrimaryVertex ) {
430  posVtx = beamSpot->position();
431  errVtx(0,0) = beamSpot->BeamWidthX();
432  errVtx(1,1) = beamSpot->BeamWidthY();
433  errVtx(2,2) = beamSpot->sigmaZ();
434  }
435  const Vertex primaryVertex(posVtx,errVtx);
436  return primaryVertex;
437 }
438 
439 //_____________________________________________________________________
441 
442  if (m_verbose) cout << "[L1TMuonDQMOffline:] Getting tight muons" << endl;
443  m_TightMuons.clear();
444  MuonCollection::const_iterator muonIt = muons->begin();
445  MuonCollection::const_iterator muonEnd = muons->end();
446 
447  for(; muonIt!=muonEnd; ++muonIt) {
448  if (muon::isTightMuon((*muonIt), vertex)) {
449  m_TightMuons.push_back(&(*muonIt));
450  }
451  }
452  m_ControlHistos[kCtrlNTightVsAll]->Fill(muons->size(), m_TightMuons.size());
453 }
454 
455 //_____________________________________________________________________
458 
459  if (m_verbose) cout << "[L1TMuonDQMOffline:] getting probe muons" << endl;
460  m_ProbeMuons.clear();
461  std::vector<const reco::Muon*> tagMuonsInHist;
462 
463  tagMuonsInHist.clear();
464 
465  vector<const reco::Muon*>::const_iterator probeCandIt = m_TightMuons.begin();
466  vector<const reco::Muon*>::const_iterator tightMuonsEnd = m_TightMuons.end();
467 
468  for (; probeCandIt!=tightMuonsEnd; ++probeCandIt) {
469  bool isProbe = false;
470  vector<const reco::Muon*>::const_iterator tagCandIt = m_TightMuons.begin();
471  float deltar = 0.;
472 
473  for (; tagCandIt!=tightMuonsEnd; ++tagCandIt) {
474  bool tagMuonAlreadyInHist = false;
475  bool tagHasTrig = false;
476  float eta = (*tagCandIt)->eta();
477  float phi = (*tagCandIt)->phi();
478  float pt = (*tagCandIt)->pt();
479  float dEta = eta - (*probeCandIt)->eta();
480  float dPhi = phi - (*probeCandIt)->phi();
481  deltar = sqrt(dEta*dEta + dPhi*dPhi);
482 
483  if ( (*tagCandIt) == (*probeCandIt) || deltar<m_minTagProbeDR ) continue; // CB has a little bias for closed-by muons
484  auto matchHltDeltaR = matchHlt(trigEvent,(*tagCandIt));
485  tagHasTrig = (matchHltDeltaR < m_maxHltMuonDR) && (pt > m_TagPtCut);
486  isProbe |= tagHasTrig;
487  if (tagHasTrig) {
488  if (std::distance(m_TightMuons.begin(), m_TightMuons.end()) > 2 ) {
489  for (vector<const reco::Muon*>::const_iterator tagMuonsInHistIt = tagMuonsInHist.begin(); tagMuonsInHistIt!=tagMuonsInHist.end(); ++tagMuonsInHistIt) {
490  if ( (*tagCandIt) == (*tagMuonsInHistIt) ) {
491  tagMuonAlreadyInHist = true;
492  break;
493  }
494  }
495  if (tagMuonAlreadyInHist == false) tagMuonsInHist.push_back((*tagCandIt));
496  }
497  if (tagMuonAlreadyInHist == false) {
498  m_ControlHistos[kCtrlTagEta]->Fill(eta);
499  m_ControlHistos[kCtrlTagPhi]->Fill(phi);
500  m_ControlHistos[kCtrlTagPt]->Fill(pt);
501  m_ControlHistos[kCtrlTagProbeDr]->Fill(deltar);
502  m_ControlHistos[kCtrlTagHltDr]->Fill(matchHltDeltaR);
503  }
504  }
505  }
506  if (isProbe) m_ProbeMuons.push_back((*probeCandIt));
507  }
509 }
510 
511 //_____________________________________________________________________
513 
514  m_MuonGmtPairs.clear();
515  if (m_verbose) cout << "[L1TMuonDQMOffline:] Getting muon GMT pairs" << endl;
516 
517  vector<const reco::Muon*>::const_iterator probeMuIt = m_ProbeMuons.begin();
518  vector<const reco::Muon*>::const_iterator probeMuEnd = m_ProbeMuons.end();
519 
521  l1t::MuonBxCollection::const_iterator gmtEnd = gmtCands->end(0);
522 
523  for (; probeMuIt!=probeMuEnd; ++probeMuIt) {
524  MuonGmtPair pairBestCand((*probeMuIt), nullptr, m_propagator, m_useAtVtxCoord);
525 
526  // Fill the control histograms with the probe muon kinematic variables used
530 
531  gmtIt = gmtCands->begin(0); // use only on L1T muons from BX 0
532 
533  for(; gmtIt!=gmtEnd; ++gmtIt) {
534  MuonGmtPair pairTmpCand((*probeMuIt), &(*gmtIt), m_propagator, m_useAtVtxCoord);
535 
536  if ( (pairTmpCand.dR() < m_maxGmtMuonDR) && (pairTmpCand.dR() < pairBestCand.dR() ) ) {
537  pairBestCand = pairTmpCand;
538  }
539 
540  }
541  m_MuonGmtPairs.push_back(pairBestCand);
542  m_ControlHistos[kCtrlMuonGmtDeltaR]->Fill(pairBestCand.dR());
543  }
544 }
545 
546 //_____________________________________________________________________
548 
549  double matchDeltaR = 9999;
550 
551  TriggerObjectCollection trigObjs = triggerEvent->getObjects();
552 
553  vector<int>::const_iterator trigIndexIt = m_trigIndices.begin();
554  vector<int>::const_iterator trigIndexEnd = m_trigIndices.end();
555 
556  for(; trigIndexIt!=trigIndexEnd; ++trigIndexIt) {
557  const vector<string> moduleLabels(m_hltConfig.moduleLabels(*trigIndexIt));
558  const unsigned moduleIndex = m_hltConfig.size((*trigIndexIt))-2;
559  const unsigned hltFilterIndex = triggerEvent->filterIndex(InputTag(moduleLabels[moduleIndex],"",m_trigProcess));
560 
561  if (hltFilterIndex < triggerEvent->sizeFilters()) {
562  const Keys triggerKeys(triggerEvent->filterKeys(hltFilterIndex));
563  const Vids triggerVids(triggerEvent->filterIds(hltFilterIndex));
564  const unsigned nTriggers = triggerVids.size();
565  for (size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
566  const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
567  double dRtmp = deltaR((*mu),trigObject);
568  if (dRtmp < matchDeltaR) matchDeltaR = dRtmp;
569  }
570  }
571  }
572  return matchDeltaR;
573 }
574 
576  if (eff == kEffPt) {
577  std::vector<float> effVsPtBins(m_effVsPtBins.begin(), m_effVsPtBins.end());
578  return effVsPtBins;
579  }
580  if (eff == kEffPhi) {
581  std::vector<float> effVsPhiBins(m_effVsPhiBins.begin(), m_effVsPhiBins.end());
582  return effVsPhiBins;
583  }
584  if (eff == kEffEta) {
585  std::vector<float> effVsEtaBins(m_effVsEtaBins.begin(), m_effVsEtaBins.end());
586  return effVsEtaBins;
587  }
588  if (eff == kEffVtx) {
589  std::vector<float> effVsVtxBins(m_effVsVtxBins.begin(), m_effVsVtxBins.end());
590  return effVsVtxBins;
591  }
592  return {0., 1.};
593 }
594 
595 std::tuple<int, double, double> L1TMuonDQMOffline::getHistBinsRes(ResType res){
596  if (res == kResPt) return {50, -2., 2.};
597  if (res == kRes1OverPt) return {50, -2., 2.};
598  if (res == kResQOverPt) return {50, -2., 2.};
599  if (res == kResPhi) return {96, -0.2, 0.2};
600  if (res == kResEta) return {100, -0.1, 0.1};
601  if (res == kResCh) return {5, -2, 3};
602  return {1, 0, 1};
603 }
604 
605 //define this as a plug-in
std::map< EffType, std::string > m_effStrings
unsigned int size() const
number of trigger paths in trigger table
LuminosityBlockID id() const
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
const_iterator end(int bx) const
type
Definition: HCALResponse.h:21
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
Extrapolate reco::Track to the muon station 2, return an invalid TSOS if it fails.
edm::EDGetTokenT< reco::BeamSpot > m_BsInputTag
double eta() const final
momentum pseudorapidity
edm::EDGetTokenT< reco::MuonCollection > m_MuonInputTag
const std::string & triggerName(unsigned int triggerIndex) const
std::vector< double > m_effVsVtxBins
std::map< ResType, std::string > m_resLabelStrings
std::map< EtaRegion, std::string > m_etaStrings
edm::EDGetTokenT< edm::TriggerResults > m_trigProcess_token
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
double gmtPt() const
void analyze(const edm::Event &e, const edm::EventSetup &c) override
double getDeltaVar(const L1TMuonDQMOffline::ResType) const
std::map< std::tuple< ResType, EtaRegion, QualLevel >, MonitorElement * > m_ResolutionHistos
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const std::vector< EtaRegion > m_etaRegions
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
virtual void dqmEndLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
std::vector< double > m_effVsPhiBins
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
GlobalPoint globalPosition() const
double getVar(const L1TMuonDQMOffline::EffType) const
std::map< EtaRegion, MonitorElement * > m_EfficiencyDenPtHistos
std::tuple< EffType, int, EtaRegion, QualLevel > m_histoKeyEffNumVarType
delete x;
Definition: CaloConfig.h:22
std::string m_HistFolder
std::pair< int, QualLevel > m_histoKeyEffNumEtaType
Definition: Electron.h:6
std::tuple< ResType, EtaRegion, QualLevel > m_histoKeyResType
std::vector< const reco::Muon * > m_ProbeMuons
std::vector< float > getHistBinsEff(EffType eff)
void getProbeMuons(edm::Handle< edm::TriggerResults > &trigResults, edm::Handle< trigger::TriggerEvent > &trigEvent)
const unsigned int getNVertices(edm::Handle< reco::VertexCollection > &vertex)
~L1TMuonDQMOffline() override
std::vector< std::string > m_trigNames
virtual void bookControlHistos(DQMStore::IBooker &)
std::map< QualLevel, std::string > m_qualStrings
double matchHlt(edm::Handle< trigger::TriggerEvent > &triggerEvent, const reco::Muon *mu)
std::string m_trigProcess
int gmtCharge() const
const l1t::Muon * m_regMu
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:110
std::vector< edm::ParameterSet > m_cutsVPSet
int iEvent
Definition: GenABIO.cc:230
Propagate an object (usually a track) to the second muon station. Support for other muon stations wil...
std::map< EffType, std::string > m_effLabelStrings
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
std::tuple< int, double, double > getHistBinsRes(ResType res)
edm::EDGetTokenT< l1t::MuonBxCollection > m_GmtInputTag
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
std::vector< double > m_effVsPtBins
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &iSetup) override
double gmtPhi() const
T sqrt(T t)
Definition: SSEVec.h:18
std::tuple< EffType, int, EtaRegion > m_histoKeyEffDenVarType
std::map< std::pair< int, QualLevel >, MonitorElement * > m_EfficiencyNumEtaHistos
const reco::Muon * m_muon
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< int, MonitorElement * > m_EfficiencyDenEtaHistos
std::vector< std::pair< int, QualLevel > > m_cuts
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
double etaAtVtx() const
Definition: Muon.h:94
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
const int mu
Definition: Constants.h:22
const std::vector< EffType > m_effTypes
int charge() const
const std::vector< QualLevel > m_qualLevelsRes
std::vector< MuonGmtPair > m_MuonGmtPairs
bool isValid() const
Definition: HandleBase.h:74
std::map< std::tuple< EffType, int, EtaRegion >, MonitorElement * > m_EfficiencyDenVarHistos
Definition: Muon.h:21
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
L1TMuonDQMOffline(const edm::ParameterSet &ps)
void getMuonGmtPairs(edm::Handle< l1t::MuonBxCollection > &gmtCands)
std::map< ResType, std::string > m_resStrings
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
Definition: deltar.py:1
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
virtual void bookResolutionHistos(DQMStore::IBooker &ibooker)
HLTConfigProvider m_hltConfig
LuminosityBlockNumber_t luminosityBlock() const
const reco::Vertex getPrimaryVertex(edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
void init(const edm::EventSetup &iSetup)
Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators...
double pt() const
std::vector< double > m_effVsEtaBins
std::vector< const reco::Muon * > m_TightMuons
T eta() const
Definition: PV3DBase.h:76
fixed size matrix
HLT enums.
const std::vector< ResType > m_resTypes
void dqmBeginRun(const edm::Run &run, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< reco::VertexCollection > m_VtxInputTag
double gmtEta() const
edm::EDGetTokenT< trigger::TriggerEvent > m_trigInputTag
const Point & position() const
position
Definition: BeamSpot.h:62
std::map< std::tuple< EffType, int, EtaRegion, QualLevel >, MonitorElement * > m_EfficiencyNumVarHistos
PropagateToMuon m_propagator
double phiAtVtx() const
Definition: Muon.h:95
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
L1TMuonDQMOffline::EtaRegion etaRegion() const
const_iterator begin(int bx) const
MuonGmtPair(const reco::Muon *muon, const l1t::Muon *regMu, const PropagateToMuon &propagator, bool useAtVtxCoord)
double phi() const final
momentum azimuthal angle
std::map< Control, MonitorElement * > m_ControlHistos
std::vector< int > Vids
std::vector< int > m_trigIndices
Definition: Run.h:44
virtual void bookEfficiencyHistos(DQMStore::IBooker &ibooker)
std::vector< Muon >::const_iterator const_iterator
Definition: BXVector.h:20
void getTightMuons(edm::Handle< reco::MuonCollection > &muons, const reco::Vertex &vertex)