CMS 3D CMS Logo

TrackEfficiencyMonitor.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Jeremy Andrea
5  */
6 
9 //#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
13 
18 #include <string>
19 
20 // needed to compute the efficiency
21 
28 
35 
38 
41 
45 
46 //-----------------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------------
49 {
51 
52  theRadius_ = iConfig.getParameter<double>("theRadius");
53  theMaxZ_ = iConfig.getParameter<double>("theMaxZ");
54  isBFieldOff_ = iConfig.getParameter<bool>("isBFieldOff");
55  trackEfficiency_ = iConfig.getParameter<bool>("trackEfficiency");
56  theTKTracksLabel_ = iConfig.getParameter<edm::InputTag>("TKTrackCollection");
57  theSTATracksLabel_ = iConfig.getParameter<edm::InputTag>("STATrackCollection");
58  muonToken_ = consumes<edm::View<reco::Muon> >(iConfig.getParameter<edm::InputTag>("muoncoll"));
59 
60  theTKTracksToken_ = consumes<reco::TrackCollection>(theTKTracksLabel_);
61  theSTATracksToken_ = consumes<reco::TrackCollection>(theSTATracksLabel_);
62 
63  conf_ = iConfig;
64 }
65 
66 //-----------------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------------
69 {}
70 
71 //-----------------------------------------------------------------------------------
73  edm::Run const& /* iRun */,
74  edm::EventSetup const& /* iSetup */)
75 //-----------------------------------------------------------------------------------
76 {
77  std::string MEFolderName = conf_.getParameter<std::string>("FolderName");
79 
80  ibooker.setCurrentFolder(MEFolderName);
81 
82  //
83  int muonXBin = conf_.getParameter<int>("muonXBin");
84  double muonXMin = conf_.getParameter<double>("muonXMin");
85  double muonXMax = conf_.getParameter<double>("muonXMax");
86 
87  histname = "muonX_";
88  muonX = ibooker.book1D(histname + AlgoName, histname + AlgoName, muonXBin, muonXMin, muonXMax);
89  muonX->setAxisTitle("");
90 
91  //
92  int muonYBin = conf_.getParameter<int>("muonYBin");
93  double muonYMin = conf_.getParameter<double>("muonYMin");
94  double muonYMax = conf_.getParameter<double>("muonYMax");
95 
96  histname = "muonY_";
97  muonY = ibooker.book1D(histname + AlgoName, histname + AlgoName, muonYBin, muonYMin, muonYMax);
98  muonY->setAxisTitle("");
99 
100  //
101  int muonZBin = conf_.getParameter<int>("muonZBin");
102  double muonZMin = conf_.getParameter<double>("muonZMin");
103  double muonZMax = conf_.getParameter<double>("muonZMax");
104 
105  histname = "muonZ_";
106  muonZ = ibooker.book1D(histname + AlgoName, histname + AlgoName, muonZBin, muonZMin, muonZMax);
107  muonZ->setAxisTitle("");
108 
109  //
110  int muonEtaBin = conf_.getParameter<int>("muonEtaBin");
111  double muonEtaMin = conf_.getParameter<double>("muonEtaMin");
112  double muonEtaMax = conf_.getParameter<double>("muonEtaMax");
113 
114  histname = "muonEta_";
115  muonEta = ibooker.book1D(histname + AlgoName, histname + AlgoName, muonEtaBin, muonEtaMin, muonEtaMax);
116  muonEta->setAxisTitle("");
117 
118  //
119  int muonPhiBin = conf_.getParameter<int>("muonPhiBin");
120  double muonPhiMin = conf_.getParameter<double>("muonPhiMin");
121  double muonPhiMax = conf_.getParameter<double>("muonPhiMax");
122 
123  histname = "muonPhi_";
124  muonPhi = ibooker.book1D(histname + AlgoName, histname + AlgoName, muonPhiBin, muonPhiMin, muonPhiMax);
125  muonPhi->setAxisTitle("");
126 
127  //
128  int muonD0Bin = conf_.getParameter<int>("muonD0Bin");
129  double muonD0Min = conf_.getParameter<double>("muonD0Min");
130  double muonD0Max = conf_.getParameter<double>("muonD0Max");
131 
132  histname = "muonD0_";
133  muonD0 = ibooker.book1D(histname + AlgoName, histname + AlgoName, muonD0Bin, muonD0Min, muonD0Max);
134  muonD0->setAxisTitle("");
135 
136  //
137  int muonCompatibleLayersBin = conf_.getParameter<int>("muonCompatibleLayersBin");
138  double muonCompatibleLayersMin = conf_.getParameter<double>("muonCompatibleLayersMin");
139  double muonCompatibleLayersMax = conf_.getParameter<double>("muonCompatibleLayersMax");
140 
141  histname = "muonCompatibleLayers_";
142  muonCompatibleLayers = ibooker.book1D(histname + AlgoName,
143  histname + AlgoName,
144  muonCompatibleLayersBin,
145  muonCompatibleLayersMin,
146  muonCompatibleLayersMax);
148 
149  //------------------------------------------------------------------------------------
150 
151  //
152  int trackXBin = conf_.getParameter<int>("trackXBin");
153  double trackXMin = conf_.getParameter<double>("trackXMin");
154  double trackXMax = conf_.getParameter<double>("trackXMax");
155 
156  histname = "trackX_";
157  trackX = ibooker.book1D(histname + AlgoName, histname + AlgoName, trackXBin, trackXMin, trackXMax);
158  trackX->setAxisTitle("");
159 
160  //
161  int trackYBin = conf_.getParameter<int>("trackYBin");
162  double trackYMin = conf_.getParameter<double>("trackYMin");
163  double trackYMax = conf_.getParameter<double>("trackYMax");
164 
165  histname = "trackY_";
166  trackY = ibooker.book1D(histname + AlgoName, histname + AlgoName, trackYBin, trackYMin, trackYMax);
167  trackY->setAxisTitle("");
168 
169  //
170  int trackZBin = conf_.getParameter<int>("trackZBin");
171  double trackZMin = conf_.getParameter<double>("trackZMin");
172  double trackZMax = conf_.getParameter<double>("trackZMax");
173 
174  histname = "trackZ_";
175  trackZ = ibooker.book1D(histname + AlgoName, histname + AlgoName, trackZBin, trackZMin, trackZMax);
176  trackZ->setAxisTitle("");
177 
178  //
179  int trackEtaBin = conf_.getParameter<int>("trackEtaBin");
180  double trackEtaMin = conf_.getParameter<double>("trackEtaMin");
181  double trackEtaMax = conf_.getParameter<double>("trackEtaMax");
182 
183  histname = "trackEta_";
184  trackEta = ibooker.book1D(histname + AlgoName, histname + AlgoName, trackEtaBin, trackEtaMin, trackEtaMax);
185  trackEta->setAxisTitle("");
186 
187  //
188  int trackPhiBin = conf_.getParameter<int>("trackPhiBin");
189  double trackPhiMin = conf_.getParameter<double>("trackPhiMin");
190  double trackPhiMax = conf_.getParameter<double>("trackPhiMax");
191 
192  histname = "trackPhi_";
193  trackPhi = ibooker.book1D(histname + AlgoName, histname + AlgoName, trackPhiBin, trackPhiMin, trackPhiMax);
194  trackPhi->setAxisTitle("");
195 
196  //
197  int trackD0Bin = conf_.getParameter<int>("trackD0Bin");
198  double trackD0Min = conf_.getParameter<double>("trackD0Min");
199  double trackD0Max = conf_.getParameter<double>("trackD0Max");
200 
201  histname = "trackD0_";
202  trackD0 = ibooker.book1D(histname + AlgoName, histname + AlgoName, trackD0Bin, trackD0Min, trackD0Max);
203  trackD0->setAxisTitle("");
204 
205  //
206  int trackCompatibleLayersBin = conf_.getParameter<int>("trackCompatibleLayersBin");
207  double trackCompatibleLayersMin = conf_.getParameter<double>("trackCompatibleLayersMin");
208  double trackCompatibleLayersMax = conf_.getParameter<double>("trackCompatibleLayersMax");
209 
210  histname = "trackCompatibleLayers_";
211  trackCompatibleLayers = ibooker.book1D(histname + AlgoName,
212  histname + AlgoName,
213  trackCompatibleLayersBin,
214  trackCompatibleLayersMin,
215  trackCompatibleLayersMax);
217 
218  //------------------------------------------------------------------------------------
219 
220  //
221  int deltaXBin = conf_.getParameter<int>("deltaXBin");
222  double deltaXMin = conf_.getParameter<double>("deltaXMin");
223  double deltaXMax = conf_.getParameter<double>("deltaXMax");
224 
225  histname = "deltaX_";
226  deltaX = ibooker.book1D(histname + AlgoName, histname + AlgoName, deltaXBin, deltaXMin, deltaXMax);
227  deltaX->setAxisTitle("");
228 
229  //
230  int deltaYBin = conf_.getParameter<int>("deltaYBin");
231  double deltaYMin = conf_.getParameter<double>("deltaYMin");
232  double deltaYMax = conf_.getParameter<double>("deltaYMax");
233 
234  histname = "deltaY_";
235  deltaY = ibooker.book1D(histname + AlgoName, histname + AlgoName, deltaYBin, deltaYMin, deltaYMax);
236  deltaY->setAxisTitle("");
237 
238  //
239  int signDeltaXBin = conf_.getParameter<int>("signDeltaXBin");
240  double signDeltaXMin = conf_.getParameter<double>("signDeltaXMin");
241  double signDeltaXMax = conf_.getParameter<double>("signDeltaXMax");
242 
243  histname = "signDeltaX_";
244  signDeltaX = ibooker.book1D(histname + AlgoName, histname + AlgoName, signDeltaXBin, signDeltaXMin, signDeltaXMax);
246 
247  //
248  int signDeltaYBin = conf_.getParameter<int>("signDeltaYBin");
249  double signDeltaYMin = conf_.getParameter<double>("signDeltaYMin");
250  double signDeltaYMax = conf_.getParameter<double>("signDeltaYMax");
251 
252  histname = "signDeltaY_";
253  signDeltaY = ibooker.book1D(histname + AlgoName, histname + AlgoName, signDeltaYBin, signDeltaYMin, signDeltaYMax);
255 
256  histname = "GlobalMuonPtEtaPhi_LowPt_";
257  GlobalMuonPtEtaPhiLowPt = ibooker.book2D(histname + AlgoName, histname + AlgoName, 20, -2.4, 2.4, 20, -3.25, 3.25);
259 
260  histname = "StandaloneMuonPtEtaPhi_LowPt_";
262  ibooker.book2D(histname + AlgoName, histname + AlgoName, 20, -2.4, 2.4, 20, -3.25, 3.25);
264 
265  histname = "GlobalMuonPtEtaPhi_HighPt_";
266  GlobalMuonPtEtaPhiHighPt = ibooker.book2D(histname + AlgoName, histname + AlgoName, 20, -2.4, 2.4, 20, -3.25, 3.25);
268 
269  histname = "StandaloneMuonPtEtaPhi_HighPt_";
271  ibooker.book2D(histname + AlgoName, histname + AlgoName, 20, -2.4, 2.4, 20, -3.25, 3.25);
273 }
274 
275 //-----------------------------------------------------------------------------------
277 //-----------------------------------------------------------------------------------
278 {}
279 
280 //-----------------------------------------------------------------------------------
282 //-----------------------------------------------------------------------------------
283 {
285  iEvent.getByToken(theTKTracksToken_, tkTracks);
287  iEvent.getByToken(theSTATracksToken_, staTracks);
289  iSetup.get<NavigationSchoolRecord>().get("CosmicNavigationSchool", nav);
291 
292  //initialize values
293  failedToPropagate = 0;
294  nCompatibleLayers = 0;
295  findDetLayer = false;
296 
297  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", theTTrackBuilder);
298  iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", thePropagator);
299  iSetup.get<IdealMagneticFieldRecord>().get(bField);
302 
304  iEvent.getByToken(muonToken_, muons);
305  if (!muons.isValid())
306  return;
307  for (edm::View<reco::Muon>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
308  if ((*muon).pt() < 5)
309  continue;
310  if (fabs((*muon).eta()) > 2.4)
311  continue;
312  if ((*muon).vertexNormalizedChi2() > 10)
313  continue;
314  if ((*muon).isStandAloneMuon() and (*muon).isGlobalMuon()) {
315  if ((*muon).pt() < 20)
316  GlobalMuonPtEtaPhiLowPt->Fill((*muon).eta(), (*muon).phi());
317  else
318  GlobalMuonPtEtaPhiHighPt->Fill((*muon).eta(), (*muon).phi());
319  }
320  if ((*muon).isStandAloneMuon()) {
321  if ((*muon).pt() < 20)
322  StandaloneMuonPtEtaPhiLowPt->Fill((*muon).eta(), (*muon).phi());
323  else
324  StandaloneMuonPtEtaPhiHighPt->Fill((*muon).eta(), (*muon).phi());
325  }
326  }
327  if (trackEfficiency_) {
328  //---------------------------------------------------
329  // Select muons with good quality
330  // If B field is on, no up-down matching between the muons
331  //---------------------------------------------------
332  bool isGoodMuon = false;
333  double mudd0 = 0., mudphi = 0., muddsz = 0., mudeta = 0.;
334  if (isBFieldOff_) {
335  if (staTracks->size() == 2) {
336  for (unsigned int bindex = 0; bindex < staTracks->size(); ++bindex) {
337  if (0 == bindex) {
338  mudd0 += (*staTracks)[bindex].d0();
339  mudphi += (*staTracks)[bindex].phi();
340  muddsz += (*staTracks)[bindex].dsz();
341  mudeta += (*staTracks)[bindex].eta();
342  }
343  if (1 == bindex) {
344  mudd0 -= (*staTracks)[bindex].d0();
345  mudphi -= (*staTracks)[bindex].phi();
346  muddsz -= (*staTracks)[bindex].dsz();
347  mudeta -= (*staTracks)[bindex].eta();
348  }
349  }
350  if ((fabs(mudd0) < 15.0) && (fabs(mudphi) < 0.045) && (fabs(muddsz) < 20.0) && (fabs(mudeta) < 0.060))
351  isGoodMuon = true;
352  }
353 
354  if (isGoodMuon)
355  testTrackerTracks(tkTracks, staTracks, *nav.product());
356 
357  } else if (staTracks->size() == 1 || staTracks->size() == 2)
358  testTrackerTracks(tkTracks, staTracks, *nav.product());
359  }
360 
361  if (!trackEfficiency_ && tkTracks->size() == 1) {
362  if ((tkTracks->front()).normalizedChi2() < 5 && (tkTracks->front()).hitPattern().numberOfValidHits() > 8)
363  testSTATracks(tkTracks, staTracks);
364  }
365 
366  delete theNavigation;
367 }
368 
369 //-----------------------------------------------------------------------------------
371 //-----------------------------------------------------------------------------------
372 {
373  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
375  if (outputMEsInRootFile) {
376  //dqmStore_->showDirStructure();
377  dqmStore_->save(outputFileName);
378  }
379 
380  //if ( theNavigation ) delete theNavigation;
381 }
382 
383 //-----------------------------------------------------------------------------------
386  const NavigationSchool& navigationSchool)
387 //-----------------------------------------------------------------------------------
388 {
389  const std::string metname = "testStandAloneMuonTracks";
390 
391  //---------------------------------------------------
392  // get the index of the "up" muon
393  // histograms will only be computed for the "up" muon
394  //---------------------------------------------------
395 
396  int nUpMuon = 0;
397  int idxUpMuon = -1;
398  for (unsigned int i = 0; i < staTracks->size(); i++) {
399  if (checkSemiCylinder((*staTracks)[i]) == TrackEfficiencyMonitor::Up) {
400  nUpMuon++;
401  idxUpMuon = i;
402  }
403  }
404 
405  if (nUpMuon == 1) {
406  //---------------------------------------------------
407  //get the muon informations
408  //---------------------------------------------------
409 
410  reco::TransientTrack staTT = theTTrackBuilder->build((*staTracks)[idxUpMuon]);
411  double ipX = staTT.impactPointState().globalPosition().x();
412  double ipY = staTT.impactPointState().globalPosition().y();
413  double ipZ = staTT.impactPointState().globalPosition().z();
414  double eta = staTT.impactPointState().globalDirection().eta();
415  double phi = staTT.impactPointState().globalDirection().phi();
416  double d0 = (*staTracks)[idxUpMuon].d0();
417 
419  TrajectoryStateOnSurface theTSOSCompLayers = staTT.outermostMeasurementState();
420 
421  //---------------------------------------------------
422  //check if the muon is in the tracker acceptance
423  //---------------------------------------------------
424  bool isInTrackerAcceptance = false;
425  isInTrackerAcceptance = trackerAcceptance(theTSOS, theRadius_, theMaxZ_);
426 
427  //---------------------------------------------------st
428  //count the number of compatible layers
429  //---------------------------------------------------
430  nCompatibleLayers = compatibleLayers(navigationSchool, theTSOSCompLayers);
431 
432  if (isInTrackerAcceptance && (*staTracks)[idxUpMuon].hitPattern().numberOfValidHits() > 28) {
433  //---------------------------------------------------
434  //count the number of good muon candidates
435  //---------------------------------------------------
436 
437  TrajectoryStateOnSurface staState;
438  LocalVector diffLocal;
439 
440  bool isTrack = false;
441  if (!tkTracks->empty()) {
442  //---------------------------------------------------
443  //look for associated tracks
444  //---------------------------------------------------
445  float DR2min = 1000;
446  reco::TrackCollection::const_iterator closestTrk = tkTracks->end();
447 
448  for (reco::TrackCollection::const_iterator tkTrack = tkTracks->begin(); tkTrack != tkTracks->end(); ++tkTrack) {
449  reco::TransientTrack tkTT = theTTrackBuilder->build(*tkTrack);
451  staState = thePropagator->propagate(staTT.outermostMeasurementState(), tkInner.surface());
452  failedToPropagate = 1;
453 
454  if (staState.isValid()) {
455  failedToPropagate = 0;
456  diffLocal = tkInner.localPosition() - staState.localPosition();
457  double DR2 = diffLocal.x() * diffLocal.x() + diffLocal.y() * diffLocal.y();
458  if (DR2 < DR2min) {
459  DR2min = DR2;
460  closestTrk = tkTrack;
461  }
462  if (pow(DR2, 0.5) < 100.)
463  isTrack = true;
464  }
465  }
466 
467  if (DR2min != 1000) {
468  reco::TransientTrack tkTT = theTTrackBuilder->build(*closestTrk);
470  staState = thePropagator->propagate(staTT.outermostMeasurementState(), tkInner.surface());
471  deltaX->Fill(diffLocal.x());
472  deltaY->Fill(diffLocal.y());
473  signDeltaX->Fill(diffLocal.x() /
474  (tkInner.localError().positionError().xx() + staState.localError().positionError().xx()));
475  signDeltaY->Fill(diffLocal.y() /
476  (tkInner.localError().positionError().yy() + staState.localError().positionError().yy()));
477  }
478  }
479 
480  if (failedToPropagate == 0) {
481  muonX->Fill(ipX);
482  muonY->Fill(ipY);
483  muonZ->Fill(ipZ);
484  muonEta->Fill(eta);
485  muonPhi->Fill(phi);
486  muonD0->Fill(d0);
488 
489  if (isTrack) {
490  trackX->Fill(ipX);
491  trackY->Fill(ipY);
492  trackZ->Fill(ipZ);
493  trackEta->Fill(eta);
494  trackPhi->Fill(phi);
495  trackD0->Fill(d0);
497  }
498  }
499  }
500  }
501 }
502 
503 //-----------------------------------------------------------------------------------
506 //-----------------------------------------------------------------------------------
507 {
508  reco::TransientTrack tkTT = theTTrackBuilder->build(tkTracks->front());
509  double ipX = tkTT.impactPointState().globalPosition().x();
510  double ipY = tkTT.impactPointState().globalPosition().y();
511  double ipZ = tkTT.impactPointState().globalPosition().z();
512  double eta = tkTT.impactPointState().globalDirection().eta();
513  double phi = tkTT.impactPointState().globalDirection().phi();
514  double d0 = (*tkTracks)[0].d0();
515 
517  LocalVector diffLocal;
518  TrajectoryStateOnSurface staState;
519  bool isTrack = false;
520 
521  if (!staTracks->empty()) {
522  //---------------------------------------------------
523  //look for associated muons
524  //---------------------------------------------------
525 
526  float DR2min = 1000;
527  reco::TrackCollection::const_iterator closestTrk = staTracks->end();
528  //----------------------loop on tracker tracks:
529  for (reco::TrackCollection::const_iterator staTrack = staTracks->begin(); staTrack != staTracks->end();
530  ++staTrack) {
531  if (checkSemiCylinder(*staTrack) == TrackEfficiencyMonitor::Up) {
532  reco::TransientTrack staTT = theTTrackBuilder->build(*staTrack);
533  failedToPropagate = 1;
534  staState = thePropagator->propagate(staTT.outermostMeasurementState(), tkInner.surface());
535 
536  if (staState.isValid()) {
537  failedToPropagate = 0;
538  diffLocal = tkInner.localPosition() - staState.localPosition();
539 
540  double DR2 = diffLocal.x() * diffLocal.x() + diffLocal.y() * diffLocal.y();
541  if (DR2 < DR2min) {
542  DR2min = DR2;
543  closestTrk = staTrack;
544  }
545  if (pow(DR2, 0.5) < 100.)
546  isTrack = true;
547  }
548  }
549  }
550  }
551 
552  if (failedToPropagate == 0) {
553  trackX->Fill(ipX);
554  trackY->Fill(ipY);
555  trackZ->Fill(ipZ);
556  trackEta->Fill(eta);
557  trackPhi->Fill(phi);
558  trackD0->Fill(d0);
559 
560  if (isTrack) {
561  muonX->Fill(ipX);
562  muonY->Fill(ipY);
563  muonZ->Fill(ipZ);
564  muonEta->Fill(eta);
565  muonPhi->Fill(phi);
566  muonD0->Fill(d0);
567  }
568  }
569 }
570 
571 //-----------------------------------------------------------------------------------
573 //-----------------------------------------------------------------------------------
574 {
576 }
577 
578 //-----------------------------------------------------------------------------------
580 //-----------------------------------------------------------------------------------
581 {
582  //---------------------------------------------------
583  // check if the muon is in the tracker acceptance
584  // check the compatibility with a cylinder of radius "theRadius"
585  //---------------------------------------------------
586 
587  //Propagator* theTmpPropagator = new SteppingHelixPropagator(&*bField,anyDirection);
588 
589  //Propagator* theTmpPropagator = &*thePropagator;
590  Propagator* theTmpPropagator = &*thePropagator->clone();
591 
592  if (theTSOS.globalPosition().y() < 0)
593  theTmpPropagator->setPropagationDirection(oppositeToMomentum);
594  else
595  theTmpPropagator->setPropagationDirection(alongMomentum);
596 
599  const Cylinder::CylinderPointer cyl = Cylinder::build(pos0, rot0, theRadius);
600  TrajectoryStateOnSurface tsosAtCyl = theTmpPropagator->propagate(*theTSOS.freeState(), *cyl);
601  double accept = false;
602  if (tsosAtCyl.isValid()) {
603  if (fabs(tsosAtCyl.globalPosition().z()) < theMaxZ) {
606  const Cylinder::CylinderPointer cyl2 = Cylinder::build(pos02, rot02, theRadius - 10);
607  TrajectoryStateOnSurface tsosAtCyl2 = theTmpPropagator->propagate(*tsosAtCyl.freeState(), *cyl2);
608  if (tsosAtCyl2.isValid()) {
611  const Cylinder::CylinderPointer cyl3 = Cylinder::build(pos03, rot03, theRadius);
612  TrajectoryStateOnSurface tsosAtCyl3 = theTmpPropagator->propagate(*tsosAtCyl2.freeState(), *cyl3);
613  if (tsosAtCyl3.isValid()) {
614  accept = true;
615  }
616  }
617  }
618  }
619  delete theTmpPropagator;
620  //muon propagated to the barrel cylinder
621  return accept;
622 }
623 
624 //-----------------------------------------------------------------------------------
626 //-----------------------------------------------------------------------------------
627 {
628  //---------------------------------------------------
629  // check the number of compatible layers
630  //---------------------------------------------------
631 
632  std::vector<const BarrelDetLayer*> barrelTOBLayers = measurementTrackerHandle->geometricSearchTracker()->tobLayers();
633 
634  unsigned int layers = 0;
635  for (unsigned int k = 0; k < barrelTOBLayers.size(); k++) {
636  const DetLayer* firstLay = barrelTOBLayers[barrelTOBLayers.size() - 1 - k];
637 
638  //Propagator* theTmpPropagator = new SteppingHelixPropagator(&*bField,anyDirection);
639 
640  Propagator* theTmpPropagator = &*thePropagator->clone();
641  theTmpPropagator->setPropagationDirection(alongMomentum);
642 
643  TrajectoryStateOnSurface startTSOS = theTmpPropagator->propagate(*theTSOS.freeState(), firstLay->surface());
644 
645  std::vector<const DetLayer*> trackCompatibleLayers;
646 
647  findDetLayer = true;
648  bool isUpMuon = false;
649  bool firstdtep = true;
650 
651  if (startTSOS.isValid()) {
652  if (firstdtep)
653  layers++;
654 
655  int nwhile = 0;
656 
657  //for other compatible layers
658  while (startTSOS.isValid() && firstLay && findDetLayer) {
659  if (firstdtep && startTSOS.globalPosition().y() > 0)
660  isUpMuon = true;
661 
662  if (firstdtep) {
663  std::vector<const DetLayer*> firstCompatibleLayers;
664  firstCompatibleLayers.push_back(firstLay);
665  std::pair<TrajectoryStateOnSurface, const DetLayer*> nextLayer =
666  findNextLayer(theTSOS, firstCompatibleLayers, isUpMuon);
667  firstdtep = false;
668  } else {
669  trackCompatibleLayers = navigationSchool.nextLayers(*firstLay, *(startTSOS.freeState()), alongMomentum);
670  if (!trackCompatibleLayers.empty()) {
671  std::pair<TrajectoryStateOnSurface, const DetLayer*> nextLayer =
672  findNextLayer(startTSOS, trackCompatibleLayers, isUpMuon);
673  if (firstLay != nextLayer.second) {
674  firstLay = nextLayer.second;
675  startTSOS = nextLayer.first;
676  layers++;
677  } else
678  firstLay = nullptr;
679  }
680  }
681  nwhile++;
682  if (nwhile > 100)
683  break;
684  }
685  delete theTmpPropagator;
686  break;
687  }
688  delete theTmpPropagator;
689  }
690  return layers;
691 }
692 
693 //-----------------------------------------------------------------------------------
694 std::pair<TrajectoryStateOnSurface, const DetLayer*> TrackEfficiencyMonitor::findNextLayer(
695  TrajectoryStateOnSurface sTSOS, const std::vector<const DetLayer*>& trackCompatibleLayers, bool isUpMuon)
696 //-----------------------------------------------------------------------------------
697 {
698  //Propagator* theTmpPropagator = new SteppingHelixPropagator(&*bField,anyDirection);
699 
700  Propagator* theTmpPropagator = &*thePropagator->clone();
701  theTmpPropagator->setPropagationDirection(alongMomentum);
702 
703  std::vector<const DetLayer*>::const_iterator itl;
704  findDetLayer = false;
705  for (itl = trackCompatibleLayers.begin(); itl != trackCompatibleLayers.end(); ++itl) {
706  TrajectoryStateOnSurface tsos = theTmpPropagator->propagate(*(sTSOS.freeState()), (**itl).surface());
707  if (tsos.isValid()) {
708  sTSOS = tsos;
709  findDetLayer = true;
710 
711  break;
712  }
713  }
714  std::pair<TrajectoryStateOnSurface, const DetLayer*> blabla;
715  blabla.first = sTSOS;
716  blabla.second = &**itl;
717  delete theTmpPropagator;
718  return blabla;
719 }
720 
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
T getParameter(std::string const &) const
edm::ESHandle< MagneticField > bField
virtual void setPropagationDirection(PropagationDirection dir)
Definition: Propagator.h:130
float xx() const
Definition: LocalError.h:22
virtual Propagator * clone() const =0
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const std::string metname
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
edm::ESHandle< GeometricSearchTracker > theTracker
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
reco::TransientTrack build(const reco::Track *p) const
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
MonitorElement * GlobalMuonPtEtaPhiHighPt
std::vector< BarrelDetLayer const * > const & tobLayers() const
void testTrackerTracks(edm::Handle< TrackCollection > tkTracks, edm::Handle< TrackCollection > staTracks, const NavigationSchool &navigationSchool)
MonitorElement * GlobalMuonPtEtaPhiLowPt
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
LocalError positionError() const
TrajectoryStateOnSurface innermostMeasurementState() const
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
void Fill(long long x)
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
Definition: Cylinder.h:45
MonitorElement * muonCompatibleLayers
int iEvent
Definition: GenABIO.cc:224
const SurfaceType & surface() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
float yy() const
Definition: LocalError.h:24
FreeTrajectoryState const * freeState(bool withErrors=true) const
T z() const
Definition: PV3DBase.h:61
edm::ESHandle< MeasurementTracker > measurementTrackerHandle
MonitorElement * StandaloneMuonPtEtaPhiLowPt
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const LocalTrajectoryError & localError() const
TrajectoryStateOnSurface outermostMeasurementState() const
bool isValid() const
Definition: HandleBase.h:70
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
edm::EDGetTokenT< reco::TrackCollection > theTKTracksToken_
edm::ESHandle< Propagator > thePropagator
std::pair< TrajectoryStateOnSurface, const DetLayer * > findNextLayer(TrajectoryStateOnSurface startTSOS, const std::vector< const DetLayer * > &trackCompatibleLayers, bool isUpMuon)
edm::ESHandle< TransientTrackBuilder > theTTrackBuilder
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&...args) const
MonitorElement * StandaloneMuonPtEtaPhiHighPt
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
const DirectTrackerNavigation * theNavigation
T eta() const
Definition: PV3DBase.h:73
void analyze(const edm::Event &, const edm::EventSetup &) override
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Definition: DQMStore.cc:266
bool trackerAcceptance(TrajectoryStateOnSurface theTSOS, double theRadius, double theMaxZ)
T get() const
Definition: EventSetup.h:73
int compatibleLayers(const NavigationSchool &navigationSchool, TrajectoryStateOnSurface theTSOS)
TrackEfficiencyMonitor(const edm::ParameterSet &)
TrajectoryStateOnSurface impactPointState() const
SemiCylinder checkSemiCylinder(const Track &)
MonitorElement * trackCompatibleLayers
const GeometricSearchTracker * geometricSearchTracker() const
T x() const
Definition: PV3DBase.h:59
T const * product() const
Definition: ESHandle.h:86
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
void save(std::string const &filename, std::string const &path="", std::string const &pattern="", std::string const &rewrite="", uint32_t run=0, uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, std::string const &fileupdate="RECREATE")
Definition: DQMStore.cc:2244
void testSTATracks(edm::Handle< TrackCollection > tkTracks, edm::Handle< TrackCollection > staTracks)
edm::EDGetTokenT< reco::TrackCollection > theSTATracksToken_
Definition: Run.h:45
GlobalVector globalDirection() const
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)