CMS 3D CMS Logo

L1TEfficiencyMuons_Offline.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  if (m_verbose) cout << "[L1TEfficiencyMuons_Offline:] ____________ Storage initialization ____________ " << endl;
110 
111  // Initializing config params
112  m_GmtPtCuts = ps.getUntrackedParameter< vector<int> >("gmtPtCuts");
113  m_MuonInputTag = consumes<reco::MuonCollection>(ps.getUntrackedParameter<InputTag>("muonInputTag"));
114  m_GmtInputTag = consumes<l1t::MuonBxCollection>(ps.getUntrackedParameter<InputTag>("gmtInputTag"));
115  m_VtxInputTag = consumes<VertexCollection>(ps.getUntrackedParameter<InputTag>("vtxInputTag"));
116  m_BsInputTag = consumes<BeamSpot>(ps.getUntrackedParameter<InputTag>("bsInputTag"));
117  m_trigInputTag = consumes<trigger::TriggerEvent>(ps.getUntrackedParameter<InputTag>("trigInputTag"));
118  m_trigProcess = ps.getUntrackedParameter<string>("trigProcess");
119  m_trigProcess_token = consumes<edm::TriggerResults>(ps.getUntrackedParameter<InputTag>("trigProcess_token"));
120  m_trigNames = ps.getUntrackedParameter<vector<string> >("triggerNames");
121 
122  // CB do we need them from cfi?
123  m_MaxMuonEta = 2.4;
124  m_MaxGmtMuonDR = 0.7;
125  m_MaxHltMuonDR = 0.1;
126  // CB ignored at present
127  //m_MinMuonDR = 1.2;
128 }
129 
130 //_____________________________________________________________________
132 //----------------------------------------------------------------------
134  if (m_verbose) cout << "[L1TEfficiencyMuons_Offline:] Called beginRun." << endl;
135  bool changed = true;
136  m_hltConfig.init(run,iSetup,m_trigProcess,changed);
137 }
138 
139 //_____________________________________________________________________
141  //book histos
142  bookControlHistos(ibooker);
143  vector<int>::const_iterator gmtPtCutsIt = m_GmtPtCuts.begin();
144  vector<int>::const_iterator gmtPtCutsEnd = m_GmtPtCuts.end();
145 
146  for (; gmtPtCutsIt!=gmtPtCutsEnd; ++ gmtPtCutsIt) {
147  bookEfficiencyHistos(ibooker, (*gmtPtCutsIt));
148  }
149 
150  vector<string>::const_iterator trigNamesIt = m_trigNames.begin();
151  vector<string>::const_iterator trigNamesEnd = m_trigNames.end();
152 
153  for (; trigNamesIt!=trigNamesEnd; ++trigNamesIt) {
154  TString tNameTmp = TString(*trigNamesIt); // use TString as it handles regex
155  TRegexp tNamePattern = TRegexp(tNameTmp,true);
156  int tIndex = -1;
157 
158  for (unsigned ipath = 0; ipath < m_hltConfig.size(); ++ipath) {
159  TString tmpName = TString(m_hltConfig.triggerName(ipath));
160  if (tmpName.Contains(tNamePattern)) {
161  tIndex = int(ipath);
162  m_trigIndices.push_back(tIndex);
163  }
164  }
165  if (tIndex < 0 && m_verbose) cout << "[L1TEfficiencyMuons_Offline:] Warning: Could not find trigger " << (*trigNamesIt) << endl;
166  }
167 }
168 
169 //_____________________________________________________________________
171  if(m_verbose) cout << "[L1TEfficiencyMuons_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;
172 }
173 
174 //_____________________________________________________________________
176  if(m_verbose) cout << "[L1TEfficiencyMuons_Offline:] Called endLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;
177 }
178 
179 //_____________________________________________________________________
180 void L1TEfficiencyMuons_Offline::analyze(const Event & iEvent, const EventSetup & eventSetup){
181 
183  iEvent.getByToken(m_MuonInputTag, muons);
184 
186  iEvent.getByToken(m_BsInputTag, beamSpot);
187 
189  iEvent.getByToken(m_VtxInputTag, vertex);
190 
192  iEvent.getByToken(m_GmtInputTag,gmtCands);
193 
194  Handle<edm::TriggerResults> trigResults;
195  iEvent.getByToken(m_trigProcess_token,trigResults);
196 
198  iEvent.getByToken(m_trigInputTag,trigEvent);
199 
200  eventSetup.get<IdealMagneticFieldRecord>().get(m_BField);
201  eventSetup.get<TrackingComponentsRecord>().get("PropagatorWithMaterial",m_propagatorAlong);
202  eventSetup.get<TrackingComponentsRecord>().get("PropagatorWithMaterialOpposite",m_propagatorOpposite);
203 
204  const Vertex primaryVertex = getPrimaryVertex(vertex,beamSpot);
205 
206  getTightMuons(muons,primaryVertex);
207  getProbeMuons(trigResults,trigEvent); // CB add flag to run on orthogonal datasets (no T&P)
208  getMuonGmtPairs(gmtCands);
209 
210 // MuonCollection::const_iterator muonIt = muons->begin();
211 // MuonCollection::const_iterator muonEnd = muons->end();
212 
213  vector<l1t::Muon> gmtContainer;// = gmtCands->getRecord(0).getGMTCands();
214 
215  for (auto mu = gmtCands->begin(0); mu != gmtCands->end(0); ++mu) {
216  gmtContainer.push_back(*mu);
217  }
218 
219 // vector<l1t::Muon>::const_iterator gmtIt = gmtContainer.begin();
220 // vector<l1t::Muon>::const_iterator gmtEnd = gmtContainer.end();
221 
222  if (m_verbose) cout << "[L1TEfficiencyMuons_Offline:] Computing efficiencies" << endl;
223 
224  vector<MuonGmtPair>::const_iterator muonGmtPairsIt = m_MuonGmtPairs.begin();
225  vector<MuonGmtPair>::const_iterator muonGmtPairsEnd = m_MuonGmtPairs.end();
226 
227  for(; muonGmtPairsIt!=muonGmtPairsEnd; ++muonGmtPairsIt) {
228  float eta = muonGmtPairsIt->eta();
229  float phi = muonGmtPairsIt->phi();
230  float pt = muonGmtPairsIt->pt();
231 
232  float gmtPt = muonGmtPairsIt->gmtPt();
233  int qual = muonGmtPairsIt->gmtQual();
234 
235  vector<int>::const_iterator gmtPtCutsIt = m_GmtPtCuts.begin();
236  vector<int>::const_iterator gmtPtCutsEnd = m_GmtPtCuts.end();
237 
238  for (; gmtPtCutsIt!=gmtPtCutsEnd; ++ gmtPtCutsIt) {
239  int gmtPtCut = (*gmtPtCutsIt);
240  bool gmtAboveCut = (gmtPt > gmtPtCut);
241 
242  stringstream ptCutToTag; ptCutToTag << gmtPtCut;
243  string ptTag = ptCutToTag.str();
244 
245  if (fabs(eta) < m_MaxMuonEta) {
246  m_EfficiencyHistos[gmtPtCut]["EffvsPt" + ptTag + "Den"]->Fill(pt);
247  m_EfficiencyHistos[gmtPtCut]["EffvsPt_OPEN_" + ptTag + "Den"]->Fill(pt);
248  m_EfficiencyHistos[gmtPtCut]["EffvsPt_DOUBLE_" + ptTag + "Den"]->Fill(pt);
249  m_EfficiencyHistos[gmtPtCut]["EffvsPt_SINGLE_" + ptTag + "Den"]->Fill(pt);
250 
251  if (gmtAboveCut) {
252  m_EfficiencyHistos[gmtPtCut]["EffvsPt" + ptTag + "Num"]->Fill(pt);
253 
254  if (qual >= 4) m_EfficiencyHistos[gmtPtCut]["EffvsPt_OPEN_" + ptTag + "Num"]->Fill(pt);
255  if (qual >= 8) m_EfficiencyHistos[gmtPtCut]["EffvsPt_DOUBLE_" + ptTag + "Num"]->Fill(pt);
256  if (qual >= 12) m_EfficiencyHistos[gmtPtCut]["EffvsPt_SINGLE_" + ptTag + "Num"]->Fill(pt);
257  }
258 
259  // efficiency in eta/phi at plateau
260  if (pt > 1.25*gmtPtCut) { // efficiency in eta/phi at plateau
261 
262  m_EfficiencyHistos[gmtPtCut]["EffvsPhi" + ptTag + "Den"]->Fill(phi);
263  m_EfficiencyHistos[gmtPtCut]["EffvsEta" + ptTag + "Den"]->Fill(eta);
264 
265  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_OPEN_" + ptTag + "Den"]->Fill(phi);
266  m_EfficiencyHistos[gmtPtCut]["EffvsEta_OPEN_" + ptTag + "Den"]->Fill(eta);
267 
268  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_DOUBLE_" + ptTag + "Den"]->Fill(phi);
269  m_EfficiencyHistos[gmtPtCut]["EffvsEta_DOUBLE_" + ptTag + "Den"]->Fill(eta);
270 
271  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_SINGLE_" + ptTag + "Den"]->Fill(phi);
272  m_EfficiencyHistos[gmtPtCut]["EffvsEta_SINGLE_" + ptTag + "Den"]->Fill(eta);
273 
274  if (gmtAboveCut) {
275  m_EfficiencyHistos[gmtPtCut]["EffvsPhi" + ptTag + "Num"]->Fill(phi);
276  m_EfficiencyHistos[gmtPtCut]["EffvsEta" + ptTag + "Num"]->Fill(eta);
277 
278  if (qual >= 4) {
279  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_OPEN_" + ptTag + "Num"]->Fill(phi);
280  m_EfficiencyHistos[gmtPtCut]["EffvsEta_OPEN_" + ptTag + "Num"]->Fill(eta);
281  }
282  if (qual >= 8) {
283  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_DOUBLE_" + ptTag + "Num"]->Fill(phi);
284  m_EfficiencyHistos[gmtPtCut]["EffvsEta_DOUBLE_" + ptTag + "Num"]->Fill(eta);
285  }
286  if (qual >= 12) {
287  m_EfficiencyHistos[gmtPtCut]["EffvsPhi_SINGLE_" + ptTag + "Num"]->Fill(phi);
288  m_EfficiencyHistos[gmtPtCut]["EffvsEta_SINGLE_" + ptTag + "Num"]->Fill(eta);
289  }
290  }
291  }
292  }
293  }
294  }
295  if (m_verbose) cout << "[L1TEfficiencyMuons_Offline:] Computation finished" << endl;
296 }
297 
298 //_____________________________________________________________________
300  if(m_verbose) cout << "[L1TEfficiencyMuons_Offline:] Booking Control Plot Histos" << endl;
301 
302  ibooker.setCurrentFolder("L1T/Efficiency/Muons/Control");
303 
304  string name = "MuonGmtDeltaR";
305  m_ControlHistos[name] = ibooker.book1D(name.c_str(),name.c_str(),25.,0.,2.5);
306 
307  name = "NTightVsAll";
308  m_ControlHistos[name] = ibooker.book2D(name.c_str(),name.c_str(),5,-0.5,4.5,5,-0.5,4.5);
309 
310  name = "NProbesVsTight";
311  m_ControlHistos[name] = ibooker.book2D(name.c_str(),name.c_str(),5,-0.5,4.5,5,-0.5,4.5);
312 
314  string name1 = "TagMuonEta_Histo";
315  m_EfficiencyHistos[0][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
316  string name2 = "TagMuonPhi_Histo";
317  m_EfficiencyHistos[0][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),24,-TMath::Pi(),TMath::Pi());
318  string name3 = "TagMuonPt_Histo";
319  m_EfficiencyHistos[0][name3] = ibooker.book1D(name3.c_str(),name3.c_str(),50,0.,100.);
320 //*****
321  name1 = "ProbeMuonEta_Histo";
322  m_EfficiencyHistos[0][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
323  name2 = "ProbeMuonPhi_Histo";
324  m_EfficiencyHistos[0][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),24,-TMath::Pi(),TMath::Pi());
325  name3 = "ProbeMuonPt_Histo";
326  m_EfficiencyHistos[0][name3] = ibooker.book1D(name3.c_str(),name3.c_str(),50,0.,100.);
327 }
328 
329 //_____________________________________________________________________
331  if(m_verbose) cout << "[L1TEfficiencyMuons_Offline:] Booking Efficiency Plot Histos for pt cut = " << ptCut << endl;
332 
333  stringstream ptCutToTag; ptCutToTag << ptCut;
334  string ptTag = ptCutToTag.str();
335 
336  ibooker.setCurrentFolder("L1T/Efficiency/Muons/");
337  float xbins[33] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 55, 60, 65, 70, 80, 90, 100};
338 
339  string name1 = "EffvsPt" + ptTag + "Den";
340  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),32,xbins);
341  string name2 = "EffvsPt" + ptTag + "Num";
342  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),32,xbins);
343 
344  name1 = "EffvsPt_OPEN_" + ptTag + "Den";
345  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),32,xbins);
346  name2 = "EffvsPt_OPEN_" + ptTag + "Num";
347  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),32,xbins);
348 
349  name1 = "EffvsPt_DOUBLE_" + ptTag + "Den";
350  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),32, xbins);
351  name2 = "EffvsPt_DOUBLE_" + ptTag + "Num";
352  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),32, xbins);
353 
354  name1 = "EffvsPt_SINGLE_" + ptTag + "Den";
355  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),32,xbins);
356  name2 = "EffvsPt_SINGLE_" + ptTag + "Num";
357  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),32,xbins);
358 
360 
361  name1 = "EffvsPhi" + ptTag + "Den";
362  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),24,-TMath::Pi(),TMath::Pi());
363  name2 = "EffvsPhi" + ptTag + "Num";
364  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),24,-TMath::Pi(),TMath::Pi());
365 
366  name1 = "EffvsEta" + ptTag + "Den";
367  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
368  name2 = "EffvsEta" + ptTag + "Num";
369  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),50,-2.5,2.5);
370 
372 
373  name1 = "EffvsPhi_OPEN_" + ptTag + "Den";
374  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),24,-TMath::Pi(),TMath::Pi());
375  name2 = "EffvsPhi_OPEN_" + ptTag + "Num";
376  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),24,-TMath::Pi(),TMath::Pi());
377 
378  name1 = "EffvsEta_OPEN_" + ptTag + "Den";
379  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
380  name2 = "EffvsEta_OPEN_" + ptTag + "Num";
381  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),50,-2.5,2.5);
382 
384 
385  name1 = "EffvsPhi_DOUBLE_" + ptTag + "Den";
386  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),24,-TMath::Pi(),TMath::Pi());
387  name2 = "EffvsPhi_DOUBLE_" + ptTag + "Num";
388  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),24,-TMath::Pi(),TMath::Pi());
389 
390  name1 = "EffvsEta_DOUBLE_" + ptTag + "Den";
391  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
392  name2 = "EffvsEta_DOUBLE_" + ptTag + "Num";
393  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),50,-2.5,2.5);
394 
396 
397  name1 = "EffvsPhi_SINGLE_" + ptTag + "Den";
398  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),24,-TMath::Pi(),TMath::Pi());
399  name2 = "EffvsPhi_SINGLE_" + ptTag + "Num";
400  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),24,-TMath::Pi(),TMath::Pi());
401 
402 
403  name1 = "EffvsEta_SINGLE_" + ptTag + "Den";
404  m_EfficiencyHistos[ptCut][name1] = ibooker.book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
405  name2 = "EffvsEta_SINGLE_" + ptTag + "Num";
406  m_EfficiencyHistos[ptCut][name2] = ibooker.book1D(name2.c_str(),name2.c_str(),50,-2.5,2.5);
407 }
408 
409 //_____________________________________________________________________
412  Vertex::Point posVtx;
413  Vertex::Error errVtx;
414 
415  bool hasPrimaryVertex = false;
416 
417  if (vertex.isValid()) {
418  vector<Vertex>::const_iterator vertexIt = vertex->begin();
419  vector<Vertex>::const_iterator vertexEnd = vertex->end();
420 
421  for (;vertexIt!=vertexEnd;++vertexIt) {
422  if (vertexIt->isValid() && !vertexIt->isFake()) {
423  posVtx = vertexIt->position();
424  errVtx = vertexIt->error();
425  hasPrimaryVertex = true;
426  break;
427  }
428  }
429  }
430 
431  if ( !hasPrimaryVertex ) {
432  posVtx = beamSpot->position();
433  errVtx(0,0) = beamSpot->BeamWidthX();
434  errVtx(1,1) = beamSpot->BeamWidthY();
435  errVtx(2,2) = beamSpot->sigmaZ();
436  }
437  const Vertex primaryVertex(posVtx,errVtx);
438  return primaryVertex;
439 }
440 
441 //_____________________________________________________________________
443 
444  if (m_verbose) cout << "[L1TEfficiencyMuons_Offline:] Getting tight muons" << endl;
445  m_TightMuons.clear();
446  MuonCollection::const_iterator muonIt = muons->begin();
447  MuonCollection::const_iterator muonEnd = muons->end();
448 
449  for(; muonIt!=muonEnd; ++muonIt) {
450  if (muon::isTightMuon((*muonIt), vertex)) {
451  m_TightMuons.push_back(&(*muonIt));
452  }
453  }
454  m_ControlHistos["NTightVsAll"]->Fill(muons->size(),m_TightMuons.size());
455 }
456 
457 //_____________________________________________________________________
460 
461  if (m_verbose) cout << "[L1TEfficiencyMuons_Offline:] getting probe muons" << endl;
462  m_ProbeMuons.clear();
463 
464  vector<const reco::Muon*>::const_iterator probeCandIt = m_TightMuons.begin();
465 // vector<const reco::Muon*>::const_iterator probeMuIt = m_ProbeMuons.begin();
466  vector<const reco::Muon*>::const_iterator tightMuonsEnd = m_TightMuons.end();
467 
468  for (; probeCandIt!=tightMuonsEnd; ++probeCandIt) {
469  bool tagHasTrig = false;
470  vector<const reco::Muon*>::const_iterator tagCandIt = m_TightMuons.begin();
471  float deltar = 0.;
472 
473  for (; tagCandIt!=tightMuonsEnd; ++tagCandIt) {
474  float eta = (*tagCandIt)->eta();
475  float phi = (*tagCandIt)->phi();
476  float pt = (*tagCandIt)->pt();
477  float dEta = eta - (*probeCandIt)->eta();
478  float dPhi = phi - (*probeCandIt)->phi();
479 
480  deltar = sqrt(dEta*dEta + dPhi*dPhi);
481 
482  if ( (*tagCandIt) == (*probeCandIt) || (deltar<0.7) ) continue; // CB has a little bias for closed-by muons
483  tagHasTrig |= matchHlt(trigEvent,(*tagCandIt));
484  if (tagHasTrig) {
485  m_EfficiencyHistos[0]["TagMuonEta_Histo"]->Fill(eta);
486  m_EfficiencyHistos[0]["TagMuonPhi_Histo"]->Fill(phi);
487  m_EfficiencyHistos[0]["TagMuonPt_Histo"]->Fill(pt);
488  }
489  }
490  if (tagHasTrig) m_ProbeMuons.push_back((*probeCandIt));
491  }
492  m_ControlHistos["NProbesVsTight"]->Fill(m_TightMuons.size(),m_ProbeMuons.size());
493 }
494 
495 //_____________________________________________________________________
497 
498  m_MuonGmtPairs.clear();
499  if (m_verbose) cout << "[L1TEfficiencyMuons_Offline:] Getting muon GMT pairs" << endl;
500 
501  vector<const reco::Muon*>::const_iterator probeMuIt = m_ProbeMuons.begin();
502  vector<const reco::Muon*>::const_iterator probeMuEnd = m_ProbeMuons.end();
503  vector<l1t::Muon> gmtContainer;
504 
505  for (auto mu = gmtCands->begin(0); mu != gmtCands->end(0); ++mu) {
506  gmtContainer.push_back(*mu);
507  }
508 
509  vector<l1t::Muon>::const_iterator gmtIt;
510  vector<l1t::Muon>::const_iterator gmtEnd = gmtContainer.end();
511 
512  for (; probeMuIt!=probeMuEnd; ++probeMuIt) {
513  float eta = (*probeMuIt)->eta();
514  float phi = (*probeMuIt)->phi();
515  float pt = (*probeMuIt)->pt();
516 
517  m_EfficiencyHistos[0]["ProbeMuonEta_Histo"]->Fill(eta);
518  m_EfficiencyHistos[0]["ProbeMuonPhi_Histo"]->Fill(phi);
519  m_EfficiencyHistos[0]["ProbeMuonPt_Histo"]->Fill(pt);
520 
521  MuonGmtPair pairBestCand((*probeMuIt),0);
522 // pairBestCand.propagate(m_BField,m_propagatorAlong,m_propagatorOpposite);
523  gmtIt = gmtContainer.begin();
524 
525  for(; gmtIt!=gmtEnd; ++gmtIt) {
526  MuonGmtPair pairTmpCand((*probeMuIt),&(*gmtIt));
527 // pairTmpCand.propagate(m_BField,m_propagatorAlong,m_propagatorOpposite);
528 
529  if ( (pairTmpCand.dR() < m_MaxGmtMuonDR) && (pairTmpCand.dR() < pairBestCand.dR() ) ) {
530  pairBestCand = pairTmpCand;
531  }
532 
533  }
534  m_MuonGmtPairs.push_back(pairBestCand);
535  m_ControlHistos["MuonGmtDeltaR"]->Fill(pairBestCand.dR());
536  }
537 }
538 
539 //_____________________________________________________________________
541 
542  double matchDeltaR = 9999;
543 
544  TriggerObjectCollection trigObjs = triggerEvent->getObjects();
545 
546  vector<int>::const_iterator trigIndexIt = m_trigIndices.begin();
547  vector<int>::const_iterator trigIndexEnd = m_trigIndices.end();
548 
549  for(; trigIndexIt!=trigIndexEnd; ++trigIndexIt) {
550  const vector<string> moduleLabels(m_hltConfig.moduleLabels(*trigIndexIt));
551  const unsigned moduleIndex = m_hltConfig.size((*trigIndexIt))-2;
552  const unsigned hltFilterIndex = triggerEvent->filterIndex(InputTag(moduleLabels[moduleIndex],"",m_trigProcess));
553 
554  if (hltFilterIndex < triggerEvent->sizeFilters()) {
555  const Keys triggerKeys(triggerEvent->filterKeys(hltFilterIndex));
556  const Vids triggerVids(triggerEvent->filterIds(hltFilterIndex));
557  const unsigned nTriggers = triggerVids.size();
558  for (size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
559  const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
560  double dRtmp = deltaR((*mu),trigObject);
561  if (dRtmp < matchDeltaR) matchDeltaR = dRtmp;
562  }
563  }
564  }
565  return (matchDeltaR < m_MaxHltMuonDR);
566 }
567 
568 //define this as a plug-in
LuminosityBlockID id() const
const_iterator end(int bx) const
const double Pi
T getUntrackedParameter(std::string const &, T const &) const
virtual void bookEfficiencyHistos(DQMStore::IBooker &ibooker, int ptCut)
void getTightMuons(edm::Handle< reco::MuonCollection > &muons, const reco::Vertex &vertex)
void getMuonGmtPairs(edm::Handle< l1t::MuonBxCollection > &gmtCands)
const reco::Vertex getPrimaryVertex(edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
const double xbins[]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#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
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
virtual void dqmBeginRun(const edm::Run &run, const edm::EventSetup &iSetup) override
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
GlobalPoint globalPosition() const
void analyze(const edm::Event &e, const edm::EventSetup &c) override
delete x;
Definition: CaloConfig.h:22
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
Definition: Cylinder.h:51
const l1t::Muon * m_regMu
virtual void dqmEndLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:110
int iEvent
Definition: GenABIO.cc:230
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
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
virtual void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &iSetup) override
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
L1TEfficiencyMuons_Offline(const edm::ParameterSet &ps)
const int mu
Definition: Constants.h:22
void getProbeMuons(edm::Handle< edm::TriggerResults > &trigResults, edm::Handle< trigger::TriggerEvent > &trigEvent)
bool isValid() const
Definition: HandleBase.h:74
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
FreeTrajectoryState freeTrajStateMuon(reco::TrackRef track)
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
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)
virtual void bookControlHistos(DQMStore::IBooker &)
const T & get() const
Definition: EventSetup.h:56
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
LuminosityBlockNumber_t luminosityBlock() const
MuonGmtPair(const reco::Muon *muon, const l1t::Muon *regMu)
T eta() const
Definition: PV3DBase.h:76
fixed size matrix
HLT enums.
const Point & position() const
position
Definition: BeamSpot.h:62
bool matchHlt(edm::Handle< trigger::TriggerEvent > &triggerEvent, const reco::Muon *mu)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
const_iterator begin(int bx) const
std::vector< int > Vids
Definition: Run.h:42