CMS 3D CMS Logo

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