CMS 3D CMS Logo

L1TMuonDQMOffline.cc
Go to the documentation of this file.
1 
18 #include "TMath.h"
19 
20 using namespace reco;
21 using namespace trigger;
22 using namespace edm;
23 using namespace std;
24 using namespace l1t;
25 
26 //__________RECO-GMT Muon Pair Helper Class____________________________
27 
29  m_muon = muonGmtPair.m_muon;
30  m_regMu = muonGmtPair.m_regMu;
31 
32  m_eta = muonGmtPair.m_eta;
33  m_phi_bar = muonGmtPair.m_phi_bar;
34  m_phi_end = muonGmtPair.m_phi_end;
35 }
36 
37 double MuonGmtPair::dR() {
38  float dEta = m_regMu ? (m_regMu->eta() - eta()) : 999.;
39  float dPhi = m_regMu ? (m_regMu->phi() - phi()) : 999.;
40  return sqrt(dEta*dEta + dPhi*dPhi);
41 }
42 
46  m_BField = bField;
47  m_propagatorAlong = propagatorAlong;
48  m_propagatorOpposite = propagatorOpposite;
49  TrackRef standaloneMuon = m_muon->outerTrack();
50  TrajectoryStateOnSurface trajectory;
51  trajectory = cylExtrapTrkSam(standaloneMuon, 500); // track at MB2 radius - extrapolation
52  if (trajectory.isValid()) {
53  m_eta = trajectory.globalPosition().eta();
54  m_phi_bar = trajectory.globalPosition().phi();
55  }
56  trajectory = surfExtrapTrkSam(standaloneMuon, 790); // track at ME2+ plane - extrapolation
57  if (trajectory.isValid()) {
58  m_eta = trajectory.globalPosition().eta();
59  m_phi_end = trajectory.globalPosition().phi();
60  }
61  trajectory = surfExtrapTrkSam(standaloneMuon, -790); // track at ME2- disk - extrapolation
62  if (trajectory.isValid()) {
63  m_eta = trajectory.globalPosition().eta();
64  m_phi_end = trajectory.globalPosition().phi();
65  }
66 }
67 
69 {
70  Cylinder::PositionType pos(0, 0, 0);
72  Cylinder::CylinderPointer myCylinder = Cylinder::build(pos, rot, rho);
73 
74  FreeTrajectoryState recoStart = freeTrajStateMuon(track);
75  TrajectoryStateOnSurface recoProp;
76  recoProp = m_propagatorAlong->propagate(recoStart, *myCylinder);
77  if (!recoProp.isValid()) {
78  recoProp = m_propagatorOpposite->propagate(recoStart, *myCylinder);
79  }
80  return recoProp;
81 }
82 
84 {
85  Plane::PositionType pos(0, 0, z);
87  Plane::PlanePointer myPlane = Plane::build(pos, rot);
88 
89  FreeTrajectoryState recoStart = freeTrajStateMuon(track);
90  TrajectoryStateOnSurface recoProp;
91  recoProp = m_propagatorAlong->propagate(recoStart, *myPlane);
92  if (!recoProp.isValid()) {
93  recoProp = m_propagatorOpposite->propagate(recoStart, *myPlane);
94  }
95  return recoProp;
96 }
97 
99 {
100  GlobalPoint innerPoint(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
101  GlobalVector innerVec (track->innerMomentum().x(), track->innerMomentum().y(), track->innerMomentum().z());
102  FreeTrajectoryState recoStart(innerPoint, innerVec, track->charge(), &*m_BField);
103  return recoStart;
104 }
105 
106 //__________DQM_base_class_______________________________________________
108  m_verbose(ps.getUntrackedParameter<bool>("verbose")),
109  m_HistFolder(ps.getUntrackedParameter<string>("histFolder")),
110  m_GmtPtCuts(ps.getUntrackedParameter< vector<int> >("gmtPtCuts")),
111  m_MuonInputTag(consumes<reco::MuonCollection>(ps.getUntrackedParameter<InputTag>("muonInputTag"))),
112  m_GmtInputTag(consumes<l1t::MuonBxCollection>(ps.getUntrackedParameter<InputTag>("gmtInputTag"))),
113  m_VtxInputTag(consumes<VertexCollection>(ps.getUntrackedParameter<InputTag>("vtxInputTag"))),
114  m_BsInputTag(consumes<BeamSpot>(ps.getUntrackedParameter<InputTag>("bsInputTag"))),
115  m_trigInputTag(consumes<trigger::TriggerEvent>(ps.getUntrackedParameter<InputTag>("trigInputTag"))),
116  m_trigProcess(ps.getUntrackedParameter<string>("trigProcess")),
117  m_trigProcess_token(consumes<edm::TriggerResults>(ps.getUntrackedParameter<InputTag>("trigProcess_token"))),
118  m_trigNames(ps.getUntrackedParameter<vector<string> >("triggerNames")),
119  m_effVsPtBins(ps.getUntrackedParameter<std::vector<double>>("efficiencyVsPtBins")),
120  m_effVsPhiBins(ps.getUntrackedParameter<std::vector<double>>("efficiencyVsPhiBins")),
121  m_effVsEtaBins(ps.getUntrackedParameter<std::vector<double>>("efficiencyVsEtaBins"))
122 {
123  if (m_verbose) cout << "[L1TMuonDQMOffline:] ____________ Storage initialization ____________ " << endl;
124  // CB do we need them from cfi?
125  m_MaxMuonEta = 2.4;
126  m_MaxGmtMuonDR = 0.7;
127  m_MaxHltMuonDR = 0.1;
128  // CB ignored at present
129  //m_MinMuonDR = 1.2;
130 }
131 
132 //_____________________________________________________________________
134 //----------------------------------------------------------------------
136  if (m_verbose) cout << "[L1TMuonDQMOffline:] Called beginRun." << endl;
137  bool changed = true;
138  m_hltConfig.init(run,iSetup,m_trigProcess,changed);
139 }
140 
141 //_____________________________________________________________________
143  //book histos
144  bookControlHistos(ibooker);
145  vector<int>::const_iterator gmtPtCutsIt = m_GmtPtCuts.begin();
146  vector<int>::const_iterator gmtPtCutsEnd = m_GmtPtCuts.end();
147 
148  for (; gmtPtCutsIt!=gmtPtCutsEnd; ++ gmtPtCutsIt) {
149  bookEfficiencyHistos(ibooker, (*gmtPtCutsIt));
150  }
151 
152  vector<string>::const_iterator trigNamesIt = m_trigNames.begin();
153  vector<string>::const_iterator trigNamesEnd = m_trigNames.end();
154 
155  for (; trigNamesIt!=trigNamesEnd; ++trigNamesIt) {
156  TString tNameTmp = TString(*trigNamesIt); // use TString as it handles regex
157  TRegexp tNamePattern = TRegexp(tNameTmp,true);
158  int tIndex = -1;
159 
160  for (unsigned ipath = 0; ipath < m_hltConfig.size(); ++ipath) {
161  TString tmpName = TString(m_hltConfig.triggerName(ipath));
162  if (tmpName.Contains(tNamePattern)) {
163  tIndex = int(ipath);
164  m_trigIndices.push_back(tIndex);
165  }
166  }
167  if (tIndex < 0 && m_verbose) cout << "[L1TMuonDQMOffline:] Warning: Could not find trigger " << (*trigNamesIt) << endl;
168  }
169 }
170 
171 //_____________________________________________________________________
173  if(m_verbose) cout << "[L1TMuonDQMOffline:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;
174 }
175 
176 //_____________________________________________________________________
178  if(m_verbose) cout << "[L1TMuonDQMOffline:] Called endLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;
179 }
180 
181 //_____________________________________________________________________
182 void L1TMuonDQMOffline::analyze(const Event & iEvent, const EventSetup & eventSetup){
183 
185  iEvent.getByToken(m_MuonInputTag, muons);
186 
188  iEvent.getByToken(m_BsInputTag, beamSpot);
189 
191  iEvent.getByToken(m_VtxInputTag, vertex);
192 
194  iEvent.getByToken(m_GmtInputTag,gmtCands);
195 
196  Handle<edm::TriggerResults> trigResults;
197  iEvent.getByToken(m_trigProcess_token,trigResults);
198 
200  iEvent.getByToken(m_trigInputTag,trigEvent);
201 
202  eventSetup.get<IdealMagneticFieldRecord>().get(m_BField);
203  eventSetup.get<TrackingComponentsRecord>().get("PropagatorWithMaterial",m_propagatorAlong);
204  eventSetup.get<TrackingComponentsRecord>().get("PropagatorWithMaterialOpposite",m_propagatorOpposite);
205 
206  const Vertex primaryVertex = getPrimaryVertex(vertex,beamSpot);
207 
208  getTightMuons(muons,primaryVertex);
209  getProbeMuons(trigResults,trigEvent); // CB add flag to run on orthogonal datasets (no T&P)
210  getMuonGmtPairs(gmtCands);
211 
212 // MuonCollection::const_iterator muonIt = muons->begin();
213 // MuonCollection::const_iterator muonEnd = muons->end();
214 
215  vector<l1t::Muon> gmtContainer;// = gmtCands->getRecord(0).getGMTCands();
216 
217  for (auto mu = gmtCands->begin(0); mu != gmtCands->end(0); ++mu) {
218  gmtContainer.push_back(*mu);
219  }
220 
221 // vector<l1t::Muon>::const_iterator gmtIt = gmtContainer.begin();
222 // vector<l1t::Muon>::const_iterator gmtEnd = gmtContainer.end();
223 
224  if (m_verbose) cout << "[L1TMuonDQMOffline:] Computing efficiencies" << endl;
225 
226  vector<MuonGmtPair>::const_iterator muonGmtPairsIt = m_MuonGmtPairs.begin();
227  vector<MuonGmtPair>::const_iterator muonGmtPairsEnd = m_MuonGmtPairs.end();
228 
229  for(; muonGmtPairsIt!=muonGmtPairsEnd; ++muonGmtPairsIt) {
230  float eta = muonGmtPairsIt->eta();
231  float phi = muonGmtPairsIt->phi();
232  float pt = muonGmtPairsIt->pt();
233 
234  float gmtPt = muonGmtPairsIt->gmtPt();
235  int qual = muonGmtPairsIt->gmtQual();
236 
237  vector<int>::const_iterator gmtPtCutsIt = m_GmtPtCuts.begin();
238  vector<int>::const_iterator gmtPtCutsEnd = m_GmtPtCuts.end();
239 
240  for (; gmtPtCutsIt!=gmtPtCutsEnd; ++ gmtPtCutsIt) {
241  int gmtPtCut = (*gmtPtCutsIt);
242  bool gmtAboveCut = (gmtPt > gmtPtCut);
243 
244  stringstream ptCutToTag; ptCutToTag << gmtPtCut;
245  string ptTag = ptCutToTag.str();
246 
247  if (fabs(eta) < m_MaxMuonEta) {
248  m_EfficiencyHistos[gmtPtCut]["EffvsPt_" + ptTag + "_Den"]->Fill(pt);
249  m_EfficiencyHistos[gmtPtCut]["EffvsPt_OPEN_" + ptTag + "_Den"]->Fill(pt);
250  m_EfficiencyHistos[gmtPtCut]["EffvsPt_DOUBLE_" + ptTag + "_Den"]->Fill(pt);
251  m_EfficiencyHistos[gmtPtCut]["EffvsPt_SINGLE_" + ptTag + "_Den"]->Fill(pt);
252 
253  if (gmtAboveCut) {
254  m_EfficiencyHistos[gmtPtCut]["EffvsPt_" + ptTag + "_Num"]->Fill(pt);
255 
256  if (qual >= 4) m_EfficiencyHistos[gmtPtCut]["EffvsPt_OPEN_" + ptTag + "_Num"]->Fill(pt);
257  if (qual >= 8) m_EfficiencyHistos[gmtPtCut]["EffvsPt_DOUBLE_" + ptTag + "_Num"]->Fill(pt);
258  if (qual >= 12) m_EfficiencyHistos[gmtPtCut]["EffvsPt_SINGLE_" + ptTag + "_Num"]->Fill(pt);
259  }
260 
261  // efficiency in eta/phi at plateau
262  if (pt > 1.25*gmtPtCut) { // efficiency in eta/phi at plateau
263 
264  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_" + ptTag + "_Den"]->Fill(phi);
265  m_EfficiencyHistos[gmtPtCut]["EffvsEta_" + ptTag + "_Den"]->Fill(eta);
266 
267  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_OPEN_" + ptTag + "_Den"]->Fill(phi);
268  m_EfficiencyHistos[gmtPtCut]["EffvsEta_OPEN_" + ptTag + "_Den"]->Fill(eta);
269 
270  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_DOUBLE_" + ptTag + "_Den"]->Fill(phi);
271  m_EfficiencyHistos[gmtPtCut]["EffvsEta_DOUBLE_" + ptTag + "_Den"]->Fill(eta);
272 
273  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_SINGLE_" + ptTag + "_Den"]->Fill(phi);
274  m_EfficiencyHistos[gmtPtCut]["EffvsEta_SINGLE_" + ptTag + "_Den"]->Fill(eta);
275 
276  if (gmtAboveCut) {
277  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_" + ptTag + "_Num"]->Fill(phi);
278  m_EfficiencyHistos[gmtPtCut]["EffvsEta_" + ptTag + "_Num"]->Fill(eta);
279 
280  if (qual >= 4) {
281  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_OPEN_" + ptTag + "_Num"]->Fill(phi);
282  m_EfficiencyHistos[gmtPtCut]["EffvsEta_OPEN_" + ptTag + "_Num"]->Fill(eta);
283  }
284  if (qual >= 8) {
285  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_DOUBLE_" + ptTag + "_Num"]->Fill(phi);
286  m_EfficiencyHistos[gmtPtCut]["EffvsEta_DOUBLE_" + ptTag + "_Num"]->Fill(eta);
287  }
288  if (qual >= 12) {
289  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_SINGLE_" + ptTag + "_Num"]->Fill(phi);
290  m_EfficiencyHistos[gmtPtCut]["EffvsEta_SINGLE_" + ptTag + "_Num"]->Fill(eta);
291  }
292  }
293  }
294  }
295  }
296  }
297  if (m_verbose) cout << "[L1TMuonDQMOffline:] Computation finished" << endl;
298 }
299 
300 //_____________________________________________________________________
302  if(m_verbose) cout << "[L1TMuonDQMOffline:] Booking Control Plot Histos" << endl;
303 
304  ibooker.setCurrentFolder(m_HistFolder+"/control_variables");
305 
306  string name = "MuonGmtDeltaR";
307  m_ControlHistos[name] = ibooker.book1D(name.c_str(),name.c_str(),25.,0.,2.5);
308 
309  name = "NTightVsAll";
310  m_ControlHistos[name] = ibooker.book2D(name.c_str(),name.c_str(),5,-0.5,4.5,5,-0.5,4.5);
311 
312  name = "NProbesVsTight";
313  m_ControlHistos[name] = ibooker.book2D(name.c_str(),name.c_str(),5,-0.5,4.5,5,-0.5,4.5);
314 
316  string name1 = "TagMuonEta_Histo";
317  m_EfficiencyHistos[0][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
318  string name2 = "TagMuonPhi_Histo";
319  m_EfficiencyHistos[0][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),24,-TMath::Pi(),TMath::Pi());
320  string name3 = "TagMuonPt_Histo";
321  m_EfficiencyHistos[0][name3] = ibooker.book1D(name3.c_str(),name3.c_str(),50,0.,100.);
322 //*****
323  name1 = "ProbeMuonEta_Histo";
324  m_EfficiencyHistos[0][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
325  name2 = "ProbeMuonPhi_Histo";
326  m_EfficiencyHistos[0][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),24,-TMath::Pi(),TMath::Pi());
327  name3 = "ProbeMuonPt_Histo";
328  m_EfficiencyHistos[0][name3] = ibooker.book1D(name3.c_str(),name3.c_str(),50,0.,100.);
329 }
330 
331 //_____________________________________________________________________
333  if(m_verbose) cout << "[L1TMuonDQMOffline:] Booking Efficiency Plot Histos for pt cut = " << ptCut << endl;
334 
335  stringstream ptCutToTag; ptCutToTag << ptCut;
336  string ptTag = ptCutToTag.str();
337 
338  ibooker.setCurrentFolder(m_HistFolder+"/numerators_and_denominators");
339 
340  std::vector<float> effVsPtBins(m_effVsPtBins.begin(), m_effVsPtBins.end());
341  int nEffVsPtBins = effVsPtBins.size() - 1;
342  float* ptBinsArray = &(effVsPtBins[0]);
343 
344  string name1 = "EffvsPt_" + ptTag + "_Den";
345  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsPtBins, ptBinsArray);
346  string name2 = "EffvsPt_" + ptTag + "_Num";
347  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsPtBins, ptBinsArray);
348 
349  name1 = "EffvsPt_OPEN_" + ptTag + "_Den";
350  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsPtBins, ptBinsArray);
351  name2 = "EffvsPt_OPEN_" + ptTag + "_Num";
352  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsPtBins, ptBinsArray);
353 
354  name1 = "EffvsPt_DOUBLE_" + ptTag + "_Den";
355  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsPtBins, ptBinsArray);
356  name2 = "EffvsPt_DOUBLE_" + ptTag + "_Num";
357  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsPtBins, ptBinsArray);
358 
359  name1 = "EffvsPt_SINGLE_" + ptTag + "_Den";
360  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsPtBins, ptBinsArray);
361  name2 = "EffvsPt_SINGLE_" + ptTag + "_Num";
362  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsPtBins, ptBinsArray);
363 
365 
366  std::vector<float> effVsPhiBins(m_effVsPhiBins.begin(), m_effVsPhiBins.end());
367  int nEffVsPhiBins = effVsPhiBins.size() - 1;
368  float* phiBinsArray = &(effVsPhiBins[0]);
369 
370  std::vector<float> effVsEtaBins(m_effVsEtaBins.begin(), m_effVsEtaBins.end());
371  int nEffVsEtaBins = effVsEtaBins.size() - 1;
372  float* etaBinsArray = &(effVsEtaBins[0]);
373 
374  name1 = "EffvsPhi_" + ptTag + "_Den";
375  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsPhiBins, phiBinsArray);
376  name2 = "EffvsPhi_" + ptTag + "_Num";
377  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsPhiBins, phiBinsArray);
378 
379  name1 = "EffvsEta_" + ptTag + "_Den";
380  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsEtaBins, etaBinsArray);
381  name2 = "EffvsEta_" + ptTag + "_Num";
382  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsEtaBins, etaBinsArray);
383 
385 
386  name1 = "EffvsPhi_OPEN_" + ptTag + "_Den";
387  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsPhiBins, phiBinsArray);
388  name2 = "EffvsPhi_OPEN_" + ptTag + "_Num";
389  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsPhiBins, phiBinsArray);
390 
391  name1 = "EffvsEta_OPEN_" + ptTag + "_Den";
392  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsEtaBins, etaBinsArray);
393  name2 = "EffvsEta_OPEN_" + ptTag + "_Num";
394  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsEtaBins, etaBinsArray);
395 
397 
398  name1 = "EffvsPhi_DOUBLE_" + ptTag + "_Den";
399  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsPhiBins, phiBinsArray);
400  name2 = "EffvsPhi_DOUBLE_" + ptTag + "_Num";
401  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsPhiBins, phiBinsArray);
402 
403  name1 = "EffvsEta_DOUBLE_" + ptTag + "_Den";
404  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsEtaBins, etaBinsArray);
405  name2 = "EffvsEta_DOUBLE_" + ptTag + "_Num";
406  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsEtaBins, etaBinsArray);
407 
409 
410  name1 = "EffvsPhi_SINGLE_" + ptTag + "_Den";
411  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsPhiBins, phiBinsArray);
412  name2 = "EffvsPhi_SINGLE_" + ptTag + "_Num";
413  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsPhiBins, phiBinsArray);
414 
415  name1 = "EffvsEta_SINGLE_" + ptTag + "_Den";
416  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(), name1.c_str(), nEffVsEtaBins, etaBinsArray);
417  name2 = "EffvsEta_SINGLE_" + ptTag + "_Num";
418  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(), name2.c_str(), nEffVsEtaBins, etaBinsArray);
419 }
420 
421 //_____________________________________________________________________
424  Vertex::Point posVtx;
425  Vertex::Error errVtx;
426 
427  bool hasPrimaryVertex = false;
428 
429  if (vertex.isValid()) {
430  vector<Vertex>::const_iterator vertexIt = vertex->begin();
431  vector<Vertex>::const_iterator vertexEnd = vertex->end();
432 
433  for (;vertexIt!=vertexEnd;++vertexIt) {
434  if (vertexIt->isValid() && !vertexIt->isFake()) {
435  posVtx = vertexIt->position();
436  errVtx = vertexIt->error();
437  hasPrimaryVertex = true;
438  break;
439  }
440  }
441  }
442 
443  if ( !hasPrimaryVertex ) {
444  posVtx = beamSpot->position();
445  errVtx(0,0) = beamSpot->BeamWidthX();
446  errVtx(1,1) = beamSpot->BeamWidthY();
447  errVtx(2,2) = beamSpot->sigmaZ();
448  }
449  const Vertex primaryVertex(posVtx,errVtx);
450  return primaryVertex;
451 }
452 
453 //_____________________________________________________________________
455 
456  if (m_verbose) cout << "[L1TMuonDQMOffline:] Getting tight muons" << endl;
457  m_TightMuons.clear();
458  MuonCollection::const_iterator muonIt = muons->begin();
459  MuonCollection::const_iterator muonEnd = muons->end();
460 
461  for(; muonIt!=muonEnd; ++muonIt) {
462  if (muon::isTightMuon((*muonIt), vertex)) {
463  m_TightMuons.push_back(&(*muonIt));
464  }
465  }
466  m_ControlHistos["NTightVsAll"]->Fill(muons->size(),m_TightMuons.size());
467 }
468 
469 //_____________________________________________________________________
472 
473  if (m_verbose) cout << "[L1TMuonDQMOffline:] getting probe muons" << endl;
474  m_ProbeMuons.clear();
475 
476  vector<const reco::Muon*>::const_iterator probeCandIt = m_TightMuons.begin();
477 // vector<const reco::Muon*>::const_iterator probeMuIt = m_ProbeMuons.begin();
478  vector<const reco::Muon*>::const_iterator tightMuonsEnd = m_TightMuons.end();
479 
480  for (; probeCandIt!=tightMuonsEnd; ++probeCandIt) {
481  bool tagHasTrig = false;
482  vector<const reco::Muon*>::const_iterator tagCandIt = m_TightMuons.begin();
483  float deltar = 0.;
484 
485  for (; tagCandIt!=tightMuonsEnd; ++tagCandIt) {
486  float eta = (*tagCandIt)->eta();
487  float phi = (*tagCandIt)->phi();
488  float pt = (*tagCandIt)->pt();
489  float dEta = eta - (*probeCandIt)->eta();
490  float dPhi = phi - (*probeCandIt)->phi();
491 
492  deltar = sqrt(dEta*dEta + dPhi*dPhi);
493 
494  if ( (*tagCandIt) == (*probeCandIt) || (deltar<0.7) ) continue; // CB has a little bias for closed-by muons
495  tagHasTrig |= matchHlt(trigEvent,(*tagCandIt));
496  if (tagHasTrig) {
497  m_EfficiencyHistos[0]["TagMuonEta_Histo"]->Fill(eta);
498  m_EfficiencyHistos[0]["TagMuonPhi_Histo"]->Fill(phi);
499  m_EfficiencyHistos[0]["TagMuonPt_Histo"]->Fill(pt);
500  }
501  }
502  if (tagHasTrig) m_ProbeMuons.push_back((*probeCandIt));
503  }
504  m_ControlHistos["NProbesVsTight"]->Fill(m_TightMuons.size(),m_ProbeMuons.size());
505 }
506 
507 //_____________________________________________________________________
509 
510  m_MuonGmtPairs.clear();
511  if (m_verbose) cout << "[L1TMuonDQMOffline:] Getting muon GMT pairs" << endl;
512 
513  vector<const reco::Muon*>::const_iterator probeMuIt = m_ProbeMuons.begin();
514  vector<const reco::Muon*>::const_iterator probeMuEnd = m_ProbeMuons.end();
515  vector<l1t::Muon> gmtContainer;
516 
517  for (auto mu = gmtCands->begin(0); mu != gmtCands->end(0); ++mu) {
518  gmtContainer.push_back(*mu);
519  }
520 
521  vector<l1t::Muon>::const_iterator gmtIt;
522  vector<l1t::Muon>::const_iterator gmtEnd = gmtContainer.end();
523 
524  for (; probeMuIt!=probeMuEnd; ++probeMuIt) {
525  float eta = (*probeMuIt)->eta();
526  float phi = (*probeMuIt)->phi();
527  float pt = (*probeMuIt)->pt();
528 
529  m_EfficiencyHistos[0]["ProbeMuonEta_Histo"]->Fill(eta);
530  m_EfficiencyHistos[0]["ProbeMuonPhi_Histo"]->Fill(phi);
531  m_EfficiencyHistos[0]["ProbeMuonPt_Histo"]->Fill(pt);
532 
533  MuonGmtPair pairBestCand((*probeMuIt),0);
534 // pairBestCand.propagate(m_BField,m_propagatorAlong,m_propagatorOpposite);
535  gmtIt = gmtContainer.begin();
536 
537  for(; gmtIt!=gmtEnd; ++gmtIt) {
538  MuonGmtPair pairTmpCand((*probeMuIt),&(*gmtIt));
539 // pairTmpCand.propagate(m_BField,m_propagatorAlong,m_propagatorOpposite);
540 
541  if ( (pairTmpCand.dR() < m_MaxGmtMuonDR) && (pairTmpCand.dR() < pairBestCand.dR() ) ) {
542  pairBestCand = pairTmpCand;
543  }
544 
545  }
546  m_MuonGmtPairs.push_back(pairBestCand);
547  m_ControlHistos["MuonGmtDeltaR"]->Fill(pairBestCand.dR());
548  }
549 }
550 
551 //_____________________________________________________________________
553 
554  double matchDeltaR = 9999;
555 
556  TriggerObjectCollection trigObjs = triggerEvent->getObjects();
557 
558  vector<int>::const_iterator trigIndexIt = m_trigIndices.begin();
559  vector<int>::const_iterator trigIndexEnd = m_trigIndices.end();
560 
561  for(; trigIndexIt!=trigIndexEnd; ++trigIndexIt) {
562  const vector<string> moduleLabels(m_hltConfig.moduleLabels(*trigIndexIt));
563  const unsigned moduleIndex = m_hltConfig.size((*trigIndexIt))-2;
564  const unsigned hltFilterIndex = triggerEvent->filterIndex(InputTag(moduleLabels[moduleIndex],"",m_trigProcess));
565 
566  if (hltFilterIndex < triggerEvent->sizeFilters()) {
567  const Keys triggerKeys(triggerEvent->filterKeys(hltFilterIndex));
568  const Vids triggerVids(triggerEvent->filterIds(hltFilterIndex));
569  const unsigned nTriggers = triggerVids.size();
570  for (size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
571  const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
572  double dRtmp = deltaR((*mu),trigObject);
573  if (dRtmp < matchDeltaR) matchDeltaR = dRtmp;
574  }
575  }
576  }
577  return (matchDeltaR < m_MaxHltMuonDR);
578 }
579 
580 //define this as a plug-in
unsigned int size() const
number of trigger paths in trigger table
LuminosityBlockID id() const
const_iterator end(int bx) const
const double Pi
edm::ESHandle< Propagator > m_propagatorOpposite
edm::EDGetTokenT< reco::BeamSpot > m_BsInputTag
edm::EDGetTokenT< reco::MuonCollection > m_MuonInputTag
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
const std::string & triggerName(unsigned int triggerIndex) const
virtual void bookEfficiencyHistos(DQMStore::IBooker &ibooker, int ptCut)
edm::EDGetTokenT< edm::TriggerResults > m_trigProcess_token
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
void analyze(const edm::Event &e, const edm::EventSetup &c) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
delete x;
Definition: CaloConfig.h:22
bool matchHlt(edm::Handle< trigger::TriggerEvent > &triggerEvent, const reco::Muon *mu)
std::string m_HistFolder
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
std::vector< const reco::Muon * > m_ProbeMuons
void getProbeMuons(edm::Handle< edm::TriggerResults > &trigResults, edm::Handle< trigger::TriggerEvent > &trigEvent)
std::vector< std::string > m_trigNames
virtual void bookControlHistos(DQMStore::IBooker &)
std::string m_trigProcess
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
Definition: Cylinder.h:51
const l1t::Muon * m_regMu
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:110
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< l1t::MuonBxCollection > m_GmtInputTag
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
std::vector< double > m_effVsPtBins
virtual void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &iSetup) override
T sqrt(T t)
Definition: SSEVec.h:18
static PlanePointer build(Args &&...args)
Definition: Plane.h:33
TrajectoryStateOnSurface cylExtrapTrkSam(reco::TrackRef track, double rho)
const reco::Muon * m_muon
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::map< int, std::map< std::string, MonitorElement * > > m_EfficiencyHistos
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
const int mu
Definition: Constants.h:22
std::vector< MuonGmtPair > m_MuonGmtPairs
bool isValid() const
Definition: HandleBase.h:74
edm::ESHandle< MagneticField > m_BField
edm::ESHandle< Propagator > m_propagatorAlong
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)
FreeTrajectoryState freeTrajStateMuon(reco::TrackRef track)
void getMuonGmtPairs(edm::Handle< l1t::MuonBxCollection > &gmtCands)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
Definition: deltar.py:1
void propagate(edm::ESHandle< MagneticField > bField, edm::ESHandle< Propagator > propagatorAlong, edm::ESHandle< Propagator > propagatorOpposite)
std::vector< size_type > Keys
TrajectoryStateOnSurface surfExtrapTrkSam(reco::TrackRef track, double z)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const T & get() const
Definition: EventSetup.h:56
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
std::vector< int > m_GmtPtCuts
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
HLTConfigProvider m_hltConfig
LuminosityBlockNumber_t luminosityBlock() const
const reco::Vertex getPrimaryVertex(edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
MuonGmtPair(const reco::Muon *muon, const l1t::Muon *regMu)
std::vector< double > m_effVsEtaBins
std::vector< const reco::Muon * > m_TightMuons
T eta() const
Definition: PV3DBase.h:76
fixed size matrix
HLT enums.
std::map< std::string, MonitorElement * > m_ControlHistos
virtual void dqmBeginRun(const edm::Run &run, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< reco::VertexCollection > m_VtxInputTag
edm::EDGetTokenT< trigger::TriggerEvent > m_trigInputTag
const Point & position() const
position
Definition: BeamSpot.h:62
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
const_iterator begin(int bx) const
std::vector< int > Vids
std::vector< int > m_trigIndices
Definition: Run.h:42
void getTightMuons(edm::Handle< reco::MuonCollection > &muons, const reco::Vertex &vertex)