CMS 3D CMS Logo

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