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