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