15 using namespace boost;
32 if(iConfig.
exists(
"maxDPtOPt"))
37 if(iConfig.
exists(
"minTrackerHits"))
38 minTrackerHits_ = iConfig.
getParameter<
int>(
"minTrackerHits");
42 if(iConfig.
exists(
"minPixelHits"))
43 minPixelHits_ = iConfig.
getParameter<
int>(
"minPixelHits");
47 if(iConfig.
exists(
"trackQuality"))
52 if(iConfig.
exists(
"ptErrorScale"))
53 errorCompScale_ = iConfig.
getParameter<
double>(
"ptErrorScale");
57 if(iConfig.
exists(
"eventFractionForCleaning"))
58 eventFractionCleaning_ = iConfig.
getParameter<
double>(
"eventFractionForCleaning");
60 eventFractionCleaning_ = 0.75;
67 if(iConfig.
exists(
"postMuonCleaning"))
68 postCleaning_ = iConfig.
getParameter<
bool>(
"postMuonCleaning");
70 postCleaning_ =
false;
72 if(iConfig.
exists(
"minPtForPostCleaning"))
73 minPostCleaningPt_ = iConfig.
getParameter<
double>(
"minPtForPostCleaning");
75 minPostCleaningPt_ = 20.;
77 if(iConfig.
exists(
"eventFactorForCosmics"))
78 eventFactorCosmics_ = iConfig.
getParameter<
double>(
"eventFactorForCosmics");
80 eventFactorCosmics_ = 10.;
83 if(iConfig.
exists(
"metSignificanceForCleaning"))
84 metSigForCleaning_ = iConfig.
getParameter<
double>(
"metSignificanceForCleaning");
86 metSigForCleaning_ = 3.;
88 if(iConfig.
exists(
"metSignificanceForRejection"))
89 metSigForRejection_ = iConfig.
getParameter<
double>(
"metSignificanceForRejection");
91 metSigForRejection_ = 4.;
93 if(iConfig.
exists(
"metFactorForCleaning"))
94 metFactorCleaning_ = iConfig.
getParameter<
double>(
"metFactorForCleaning");
96 metFactorCleaning_ = 4.;
98 if(iConfig.
exists(
"eventFractionForRejection"))
99 eventFractionRejection_ = iConfig.
getParameter<
double>(
"eventFractionForRejection");
101 eventFractionRejection_ = 0.75;
103 if(iConfig.
exists(
"metFactorForRejection"))
104 metFactorRejection_ = iConfig.
getParameter<
double>(
"metFactorForRejection");
106 metFactorRejection_ =4.;
108 if(iConfig.
exists(
"metFactorForHighEta"))
109 metFactorHighEta_ = iConfig.
getParameter<
double>(
"metFactorForHighEta");
113 if(iConfig.
exists(
"ptFactorForHighEta"))
114 ptFactorHighEta_ = iConfig.
getParameter<
double>(
"ptFactorForHighEta");
116 ptFactorHighEta_ = 2.;
118 if(iConfig.
exists(
"metFactorForFakes"))
119 metFactorFake_ = iConfig.
getParameter<
double>(
"metFactorForFakes");
123 if(iConfig.
exists(
"minMomentumForPunchThrough"))
124 minPunchThroughMomentum_ = iConfig.
getParameter<
double>(
"minMomentumForPunchThrough");
126 minPunchThroughMomentum_=100.;
128 if(iConfig.
exists(
"minEnergyForPunchThrough"))
129 minPunchThroughEnergy_ = iConfig.
getParameter<
double>(
"minEnergyForPunchThrough");
131 minPunchThroughEnergy_ = 100.;
133 if(iConfig.
exists(
"punchThroughFactor"))
134 punchThroughFactor_ = iConfig.
getParameter<
double>(
"punchThroughFactor");
136 punchThroughFactor_ = 3.;
138 if(iConfig.
exists(
"punchThroughMETFactor"))
139 punchThroughMETFactor_ = iConfig.
getParameter<
double>(
"punchThroughMETFactor");
141 punchThroughMETFactor_ = 4.;
143 if(iConfig.
exists(
"cosmicRejectionDistance"))
144 cosmicRejDistance_ = iConfig.
getParameter<
double>(
"cosmicRejectionDistance");
146 cosmicRejDistance_ = 1.0;
193 return isGlobalTightMuon(muonRef);
206 return isGlobalLooseMuon(muonRef);
219 return isTrackerTightMuon(muonRef);
232 return isIsolatedMuon(muonRef);
239 return isGlobalTightMuon(muonRef) || isTrackerTightMuon(muonRef) || isIsolatedMuon(muonRef);
245 return isGlobalLooseMuon(muonRef) || isTrackerLooseMuon(muonRef);
252 if ( !muonRef.
isNonnull() )
return false;
254 if ( !muonRef->isGlobalMuon() )
return false;
255 if ( !muonRef->isStandAloneMuon() )
return false;
258 if ( muonRef->isTrackerMuon() ) {
263 int nMatches = muonRef->numberOfMatches();
264 bool quality = nMatches > 2 || isTM2DCompatibilityTight;
266 return result && quality;
277 if ( ( standAloneMu->hitPattern().numberOfValidMuonDTHits() < 22 &&
278 standAloneMu->hitPattern().numberOfValidMuonCSCHits() < 15 ) ||
279 standAloneMu->normalizedChi2() > 10. ||
280 standAloneMu->ptError()/standAloneMu->pt() > 0.20 ) {
288 if ( combinedMu->normalizedChi2() > standAloneMu->normalizedChi2() ) {
295 result = standAloneMu->pt() > trackerMu->pt() ;
300 combinedMu->ptError()/combinedMu->pt() <
301 std::min(0.20,standAloneMu->ptError()/standAloneMu->pt());
315 if ( !muonRef.
isNonnull() )
return false;
317 if(!muonRef->isTrackerMuon())
return false;
324 if(nTrackerHits<=12)
return false;
330 if(!isAllArbitrated || !isTM2DCompatibilityTight)
return false;
332 if((trackerMu->ptError()/trackerMu->pt() > 0.10)){
343 if ( !muonRef.
isNonnull() )
return false;
344 if ( !muonRef->isGlobalMuon() )
return false;
345 if ( !muonRef->isStandAloneMuon() )
return false;
352 standAloneMu->hitPattern().numberOfValidMuonDTHits() +
353 2*standAloneMu->hitPattern().numberOfValidMuonCSCHits();
355 bool quality =
false;
357 if ( muonRef->isTrackerMuon() ){
359 bool result = combinedMu->normalizedChi2() < 100.;
364 int nMatches = muonRef->numberOfMatches();
366 quality = laststation && nMuonHits > 12 && nMatches > 1;
368 return result && quality;
375 if ( nMuonHits <=15 ||
376 standAloneMu->normalizedChi2() > 10. ||
377 standAloneMu->ptError()/standAloneMu->pt() > 0.20 ) {
382 if ( combinedMu->normalizedChi2() > standAloneMu->normalizedChi2() ) {
391 if(standAloneMu->pt() > trackerMu->pt() || combinedMu->normalizedChi2()<5.) quality =
true;
396 if(combinedMu->ptError()/combinedMu->pt() <
std::min(0.20,standAloneMu->ptError()/standAloneMu->pt()))
412 if ( !muonRef.
isNonnull() )
return false;
413 if(!muonRef->isTrackerMuon())
return false;
417 if(trackerMu->ptError()/trackerMu->pt() > 0.20)
return false;
420 if(trackerMu->pt()>20.)
return false;
425 bool quality = isAllArbitrated && isTMLastStationAngTight;
435 if ( !muonRef.
isNonnull() )
return false;
436 if ( !muonRef->isIsolationValid() )
return false;
439 if ( !muonRef->isGlobalMuon() )
return false;
445 if ( !muonRef->isTrackerMuon() ){
446 if(standAloneMu->hitPattern().numberOfValidMuonDTHits() == 0 &&
447 standAloneMu->hitPattern().numberOfValidMuonCSCHits() ==0)
return false;
453 double smallestMuPt = combinedMu->pt();
455 if(standAloneMu->pt()<smallestMuPt) smallestMuPt = standAloneMu->pt();
457 if(muonRef->isTrackerMuon())
460 if(trackerMu->pt() < smallestMuPt) smallestMuPt= trackerMu->pt();
463 double sumPtR03 = muonRef->isolationR03().sumPt;
464 double emEtR03 = muonRef->isolationR03().emEt;
465 double hadEtR03 = muonRef->isolationR03().hadEt;
467 double relIso = (sumPtR03 + emEtR03 + hadEtR03)/smallestMuPt;
469 if(relIso<0.1)
return true;
478 if(!muonRef->isTrackerMuon())
return false;
480 if(muonRef->numberOfMatches()<2)
return false;
485 if(combinedMuon->hitPattern().numberOfValidTrackerHits()<11)
return false;
487 if(combinedMuon->hitPattern().numberOfValidPixelHits()==0)
return false;
489 if(combinedMuon->hitPattern().numberOfValidMuonHits()==0)
return false;
500 bool isGL = muonRef->isGlobalMuon();
501 bool isTR = muonRef->isTrackerMuon();
502 bool isST = muonRef->isStandAloneMuon();
504 std::cout<<
" GL: "<<isGL<<
" TR: "<<isTR<<
" ST: "<<isST<<std::endl;
505 std::cout<<
" nMatches "<<muonRef->numberOfMatches()<<std::endl;
507 if ( muonRef->isGlobalMuon() ){
509 std::cout<<
" GL, pt: " << combinedMu->pt()
510 <<
" +/- " << combinedMu->ptError()/combinedMu->pt()
511 <<
" chi**2 GBL : " << combinedMu->normalizedChi2()<<std::endl;
512 std::cout<<
" Total Muon Hits : " << combinedMu->hitPattern().numberOfValidMuonHits()
513 <<
"/" << combinedMu->hitPattern().numberOfLostMuonHits()
514 <<
" DT Hits : " << combinedMu->hitPattern().numberOfValidMuonDTHits()
515 <<
"/" << combinedMu->hitPattern().numberOfLostMuonDTHits()
516 <<
" CSC Hits : " << combinedMu->hitPattern().numberOfValidMuonCSCHits()
517 <<
"/" << combinedMu->hitPattern().numberOfLostMuonCSCHits()
518 <<
" RPC Hits : " << combinedMu->hitPattern().numberOfValidMuonRPCHits()
519 <<
"/" << combinedMu->hitPattern().numberOfLostMuonRPCHits()<<std::endl;
521 std::cout<<
" # of Valid Tracker Hits "<<combinedMu->hitPattern().numberOfValidTrackerHits()<<std::endl;
522 std::cout<<
" # of Valid Pixel Hits "<<combinedMu->hitPattern().numberOfValidPixelHits()<<std::endl;
524 if ( muonRef->isStandAloneMuon() ){
526 std::cout<<
" ST, pt: " << standAloneMu->pt()
527 <<
" +/- " << standAloneMu->ptError()/standAloneMu->pt()
528 <<
" eta : " << standAloneMu->eta()
529 <<
" DT Hits : " << standAloneMu->hitPattern().numberOfValidMuonDTHits()
530 <<
"/" << standAloneMu->hitPattern().numberOfLostMuonDTHits()
531 <<
" CSC Hits : " << standAloneMu->hitPattern().numberOfValidMuonCSCHits()
532 <<
"/" << standAloneMu->hitPattern().numberOfLostMuonCSCHits()
533 <<
" RPC Hits : " << standAloneMu->hitPattern().numberOfValidMuonRPCHits()
534 <<
"/" << standAloneMu->hitPattern().numberOfLostMuonRPCHits()
535 <<
" chi**2 STA : " << standAloneMu->normalizedChi2()<<std::endl;
539 if ( muonRef->isTrackerMuon() ){
542 std::cout<<
" TR, pt: " << trackerMu->pt()
543 <<
" +/- " << trackerMu->ptError()/trackerMu->pt()
544 <<
" chi**2 TR : " << trackerMu->normalizedChi2()<<std::endl;
548 <<
"TMLastStationAngTight "
550 <<
"TMLastStationLoose "
552 <<
"TMLastStationTight "
554 <<
"TMOneStationLoose "
556 <<
"TMOneStationTight "
558 <<
"TMLastStationOptimizedLowPtLoose "
560 <<
"TMLastStationOptimizedLowPtTight "
562 <<
"TMLastStationOptimizedBarrelLowPtLoose "
564 <<
"TMLastStationOptimizedBarrelLowPtTight "
572 <<
"TM2DCompatibilityTight "
577 if ( muonRef->isGlobalMuon() && muonRef->isTrackerMuon() && muonRef->isStandAloneMuon() ){
582 double sigmaCombined = combinedMu->ptError()/(combinedMu->pt()*combinedMu->pt());
583 double sigmaTracker = trackerMu->ptError()/(trackerMu->pt()*trackerMu->pt());
584 double sigmaStandAlone = standAloneMu->ptError()/(standAloneMu->pt()*standAloneMu->pt());
586 bool combined = combinedMu->ptError()/combinedMu->pt() < 0.20;
587 bool tracker = trackerMu->ptError()/trackerMu->pt() < 0.20;
588 bool standAlone = standAloneMu->ptError()/standAloneMu->pt() < 0.20;
590 double delta1 = combined && tracker ?
591 fabs(1./combinedMu->pt() -1./trackerMu->pt())
592 /
sqrt(sigmaCombined*sigmaCombined + sigmaTracker*sigmaTracker) : 100.;
593 double delta2 = combined && standAlone ?
594 fabs(1./combinedMu->pt() -1./standAloneMu->pt())
595 /
sqrt(sigmaCombined*sigmaCombined + sigmaStandAlone*sigmaStandAlone) : 100.;
596 double delta3 = standAlone && tracker ?
597 fabs(1./standAloneMu->pt() -1./trackerMu->pt())
598 /
sqrt(sigmaStandAlone*sigmaStandAlone + sigmaTracker*sigmaTracker) : 100.;
601 standAloneMu->hitPattern().numberOfValidMuonDTHits()+
602 standAloneMu->hitPattern().numberOfValidMuonCSCHits() > 0 ?
605 std::cout <<
"delta = " << delta <<
" delta1 "<<delta1<<
" delta2 "<<delta2<<
" delta3 "<<delta3<<std::endl;
608 combinedMu->ptError()/combinedMu->pt()
609 / (trackerMu->ptError()/trackerMu->pt());
611 std::cout<<
" ratio "<<ratio<<
" combined mu pt "<<combinedMu->pt()<<std::endl;
617 double sumPtR03 = muonRef->isolationR03().sumPt;
618 double emEtR03 = muonRef->isolationR03().emEt;
619 double hadEtR03 = muonRef->isolationR03().hadEt;
620 double relIsoR03 = (sumPtR03 + emEtR03 + hadEtR03)/muonRef->pt();
621 double sumPtR05 = muonRef->isolationR05().sumPt;
622 double emEtR05 = muonRef->isolationR05().emEt;
623 double hadEtR05 = muonRef->isolationR05().hadEt;
624 double relIsoR05 = (sumPtR05 + emEtR05 + hadEtR05)/muonRef->pt();
625 std::cout<<
" 0.3 Radion Rel Iso: "<<relIsoR03<<
" sumPt "<<sumPtR03<<
" emEt "<<emEtR03<<
" hadEt "<<hadEtR03<<std::endl;
626 std::cout<<
" 0.5 Radion Rel Iso: "<<relIsoR05<<
" sumPt "<<sumPtR05<<
" emEt "<<emEtR05<<
" hadEt "<<hadEtR05<<std::endl;
634 return muonTracks(muon,includeSA,maxDPtOPt_);
643 std::vector<reco::Muon::MuonTrackTypePair>
out;
647 if(muon->globalTrack()->ptError()/muon->globalTrack()->pt()<dpt)
651 if(muon->innerTrack()->ptError()/muon->innerTrack()->pt()<dpt)
654 bool pickyExists=
false;
656 if(muon->pickyTrack()->ptError()/muon->pickyTrack()->pt()<dpt)
664 if(muon->tpfmsTrack().
isNonnull() && ((pickyExists && muon->tpfmsTrack()->ptError()/muon->tpfmsTrack()->pt()<muon->pickyTrack()->ptError()/muon->pickyTrack()->pt())||(!pickyExists)) )
665 if(muon->tpfmsTrack()->ptError()/muon->tpfmsTrack()->pt()<dpt)
668 if(includeSA && muon->outerTrack().
isNonnull())
669 if(muon->outerTrack()->ptError()/muon->outerTrack()->pt()<dpt)
687 using namespace reco;
709 std::vector<reco::Muon::MuonTrackTypePair> validTracks = goodMuonTracks(muon);
711 validTracks = goodMuonTracks(muon);
713 validTracks = muonTracks(muon);
715 if( validTracks.size() ==0)
723 TrackRef bestTrack = bestTrackPair.first;
728 MuonTrackTypePair trackPairWithSmallestError = getTrackWithSmallestError(validTracks);
729 TrackRef trackWithSmallestError = trackPairWithSmallestError.first;
732 (!bestTrack->quality(trackQuality_) ||
733 bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt() )) {
734 bestTrack = trackWithSmallestError;
735 trackType = trackPairWithSmallestError.second;
738 bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt()) {
739 bestTrack = trackWithSmallestError;
740 trackType = trackPairWithSmallestError.second;
745 changeTrack(candidate,std::make_pair(bestTrack,trackType));
755 using namespace reco;
759 double px = bestTrack->px();
760 double py = bestTrack->py();
761 double pz = bestTrack->pz();
762 double energy =
sqrt(bestTrack->p()*bestTrack->p() + 0.13957*0.13957);
764 candidate.
setCharge(bestTrack->charge()>0 ? 1 : -1);
783 return *std::min_element(tracks.begin(),tracks.end(),
sorter);
796 for (
unsigned short i=1 ;
i<vertices_->size();++
i ) {
797 if ( !vertices_->at(
i).isValid() || vertices_->at(
i).isFake() )
continue;
800 itr < vertices_->at(
i).tracks_end(); ++itr ) {
801 sumetPU_ += (*itr)->pt();
813 for(reco::PFCandidateCollection::const_iterator
i = pfc->begin();
i!=pfc->end();++
i) {
816 if (vertices_->size()>0 && vertices_->at(0).isValid()&& !vertices_->at(0).isFake()) {
818 if( (
i->charge() !=0 &&
i->trackRef().isNonnull() && vertices_->size()>0&&
i->trackRef()->dz(vertices_->at(0).position())<dzPV_)||(
abs(
i->pdgId())==13)) {
823 else if(
i->charge() !=0 &&
i->trackRef().isNonnull() &&
i->trackRef()->dz(vertices_->at(0).position())>dzPV_) {
828 else if( !(
i->charge() !=0 &&
i->trackRef().isNonnull())) {
837 METX_ = (METXCh+METXNeut);
838 METY_ = (METYCh+METYNeut);
848 using namespace reco;
854 if(pfCosmicsMuonCleanedCandidates_.get() )
855 pfCosmicsMuonCleanedCandidates_->clear();
859 if(pfCleanedTrackerAndGlobalMuonCandidates_.get() )
860 pfCleanedTrackerAndGlobalMuonCandidates_->clear();
864 if( pfFakeMuonCleanedCandidates_.get() )
865 pfFakeMuonCleanedCandidates_->clear();
870 if( pfPunchThroughMuonCleanedCandidates_.get() )
871 pfPunchThroughMuonCleanedCandidates_->clear();
875 if( pfPunchThroughHadronCleanedCandidates_.get() )
876 pfPunchThroughHadronCleanedCandidates_->clear();
882 pfPunchThroughHadronCleanedCandidates_->clear();
884 maskedIndices_.clear();
888 estimateEventQuantities(cands);
891 std::vector<int>
muons;
892 std::vector<int> cosmics;
894 for(
unsigned int i=0;
i<cands->size();++
i)
905 double METXCosmics=0;
906 double METYCosmics=0;
907 double SUMETCosmics=0.0;
909 for(
unsigned int i=0;
i<
muons.size();++
i) {
912 if(vertices_->size()>0&& vertices_->at(0).isValid() && ! vertices_->at(0).isFake())
913 origin = pfc.
muonRef()->muonBestTrack()->dxy(vertices_->at(0).position());
915 if( origin> cosmicRejDistance_) {
916 cosmics.push_back(
muons[i]);
917 METXCosmics +=pfc.
px();
918 METYCosmics +=pfc.
py();
919 SUMETCosmics +=pfc.
pt();
922 double MET2Cosmics = METXCosmics*METXCosmics+METYCosmics*METYCosmics;
924 if ( SUMETCosmics > (sumet_-sumetPU_)/eventFactorCosmics_ && MET2Cosmics < METX_*METX_+ METY_*METY_)
925 for(
unsigned int i=0;
i<cosmics.size();++
i)
926 pfCosmicsMuonCleanedCandidates_->push_back(cands->at(
muons[
i]));
930 for(
unsigned int i=0;i<
muons.size();++
i) {
932 if( cleanMismeasured(cands->at(
muons[i]),
muons[
i]))
934 cleanPunchThroughAndFakes(cands->at(
muons[i]),cands,
muons[
i]);
941 removeDeadCandidates(cands,maskedIndices_);
953 if( pfAddedMuonCandidates_.get() )
954 pfAddedMuonCandidates_->clear();
960 for (
unsigned imu = 0; imu < muons->size(); ++imu ) {
964 for(
unsigned i=0;
i<cands->size();
i++) {
971 if ( pfc.
muonRef()->innerTrack() == muonRef->innerTrack())
976 if ( pfc.
muonRef()->isStandAloneMuon() && muonRef->isStandAloneMuon() ) {
977 double dEta = pfc.
muonRef()->standAloneMuon()->eta() - muonRef->standAloneMuon()->eta();
978 double dPhi = pfc.
muonRef()->standAloneMuon()->phi() - muonRef->standAloneMuon()->phi();
979 double dR =
sqrt(dEta*dEta + dPhi*dPhi);
989 if ( used ||hadron||(!muonRef.
isNonnull()) )
continue;
995 std::vector<reco::Muon::MuonTrackTypePair>
tracks = goodMuonTracks(muonRef,
true);
997 if(tracks.size()>0) {
1000 std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksPointingAtMET(tracks);
1002 if (tracksThatChangeMET.size()>0) {
1006 if((vertices_->size()==0) ||bestTrackType.first->dz(vertices_->at(0).position())<cosmicRejDistance_){
1009 int charge = bestTrackType.first->charge()>0 ? 1 : -1;
1011 bestTrackType.first->py(),
1012 bestTrackType.first->pz(),
1013 sqrt(bestTrackType.first->p()*bestTrackType.first->p()+0.1057*0.1057));
1019 changeTrack(cands->back(),bestTrackType);
1022 cands->back().setTrackRef( muonRef->track() );
1024 cands->back().setMuonRef(muonRef);
1027 pfAddedMuonCandidates_->push_back(cands->back());
1035 std::pair<double,double>
1037 std::vector<reco::Muon::MuonTrackTypePair>
tracks = goodMuonTracks((pfc.
muonRef()),
true);
1039 double METXNO = METX_-pfc.
px();
1040 double METYNO = METY_-pfc.
py();
1041 std::vector<double> met2;
1042 for (
unsigned int i=0;
i<tracks.size();++
i) {
1043 met2.push_back(
pow(METXNO+tracks.at(
i).first->px(),2)+
pow(METYNO+tracks.at(
i).first->py(),2));
1050 return std::make_pair(*std::min_element(met2.begin(),met2.end()),*std::max_element(met2.begin(),met2.end()));
1052 return std::make_pair(0,0);
1057 using namespace std;
1058 using namespace reco;
1062 double METNOX = METX_ - pfc.
px();
1063 double METNOY = METY_ - pfc.
py();
1064 double SUMETNO = sumet_ -pfc.
pt();
1068 if (pfc.
pt()<minPostCleaningPt_)
1070 std::vector<reco::Muon::MuonTrackTypePair>
tracks = goodMuonTracks(pfc.
muonRef(),
false);
1077 std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksWithBetterMET(
tracks,pfc);
1079 if (tracksThatChangeMET.size()>0) {
1081 changeTrack(pfc,bestTrackType);
1083 pfCleanedTrackerAndGlobalMuonCandidates_->push_back(pfc);
1085 METX_ = METNOX+pfc.
px();
1086 METY_ = METNOY+pfc.
py();
1087 sumet_=SUMETNO+pfc.
pt();
1093 if (!(pfc.
muonRef()->isGlobalMuon() && pfc.
muonRef()->isTrackerMuon())) {
1095 double MET2 = METX_*METX_+METY_*METY_;
1096 double newMET2 = METNOX*METNOX+METNOY*METNOY;
1097 double METSig =
sqrt(MET2)/
sqrt(sumet_-sumetPU_);
1098 if( METSig>metSigForRejection_)
1099 if((newMET2 < MET2/metFactorRejection_) &&
1100 ((SUMETNO-sumetPU_)/(sumet_-sumetPU_)<eventFractionRejection_)) {
1101 pfFakeMuonCleanedCandidates_->push_back(pfc);
1102 maskedIndices_.push_back(i);
1114 std::vector<reco::Muon::MuonTrackTypePair>
1116 std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1118 double METNOX = METX_ - pfc.
px();
1119 double METNOY = METY_ - pfc.
py();
1120 double SUMETNO = sumet_ -pfc.
pt();
1121 double MET2 = METX_*METX_+METY_*METY_;
1123 double newSUMET=0.0;
1124 double METSIG =
sqrt(MET2)/
sqrt(sumet_-sumetPU_);
1127 if(METSIG>metSigForCleaning_)
1128 for(
unsigned int i=0;
i<tracks.size();++
i) {
1130 newSUMET = SUMETNO+tracks.at(
i).first->pt()-sumetPU_;
1131 newMET2 =
pow(METNOX+tracks.at(
i).first->px(),2)+
pow(METNOY+tracks.at(
i).first->py(),2);
1133 if(newSUMET/(sumet_-sumetPU_)>eventFractionCleaning_ && newMET2<MET2/metFactorCleaning_)
1134 outputTracks.push_back(tracks.at(
i));
1138 return outputTracks;
1142 std::vector<reco::Muon::MuonTrackTypePair>
1144 std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1149 for(
unsigned int i=0;
i<tracks.size();++
i) {
1151 newMET2 =
pow(METX_+tracks.at(
i).first->px(),2)+
pow(METY_+tracks.at(
i).first->py(),2);
1153 if(newMET2<(METX_*METX_+METY_*METY_)/metFactorCleaning_)
1154 outputTracks.push_back(tracks.at(
i));
1158 return outputTracks;
1164 vertices_ = vertices;
1168 using namespace reco;
1172 if (pfc.
pt()<minPostCleaningPt_)
1176 double METXNO = METX_-pfc.
pt();
1177 double METYNO = METY_-pfc.
pt();
1178 double MET2NO = METXNO*METXNO+METYNO*METYNO;
1179 double MET2 = METX_*METX_+METY_*METY_;
1182 std::pair<double,double> met2 = getMinMaxMET2(pfc);
1186 fake1 =fabs ( pfc.
eta() ) > 2.15 &&
1187 met2.first<met2.second/2 &&
1188 MET2NO < MET2/metFactorHighEta_ &&
1189 pfc.
muonRef()->standAloneMuon()->pt() < pfc.
pt()/ptFactorHighEta_;
1191 double factor =
std::max(2.,2000./(sumet_-pfc.
pt()-sumetPU_));
1192 bool fake2 = ( pfc.
pt()/(sumet_-sumetPU_) < 0.25 && MET2NO < MET2/metFactorFake_ && met2.first<met2.second/factor );
1194 bool punchthrough =pfc.
p() > minPunchThroughMomentum_ &&
1197 !isIsolatedMuon(pfc.
muonRef()) && MET2NO < MET2/punchThroughMETFactor_;
1200 if(fake1 || fake2||punchthrough) {
1203 if ( eleInBlocks.size() ) {
1204 PFBlockRef blockRefMuon = eleInBlocks[0].first;
1205 unsigned indexMuon = eleInBlocks[0].second;
1206 for (
unsigned iele = 1; iele < eleInBlocks.size(); ++iele ) {
1207 indexMuon = eleInBlocks[iele].second;
1213 bool hadron =
false;
1214 for (
unsigned i = imu+1;
i < cands->size(); ++
i ) {
1217 if ( !ele.size() ) {
1221 unsigned indexHadron = ele[0].second;
1223 if ( blockRefHadron.
key() != blockRefMuon.
key() )
break;
1225 if ( indexHadron == indexMuon &&
1230 if ( hadron )
break;
1235 double rescaleFactor = cands->at(iHad).p()/cands->at(imu).p();
1236 METX_ -= cands->at(imu).px() + cands->at(iHad).px();
1237 METY_ -= cands->at(imu).py() + cands->at(iHad).py();
1238 sumet_ -=cands->at(imu).pt();
1239 cands->at(imu).rescaleMomentum(rescaleFactor);
1240 maskedIndices_.push_back(iHad);
1241 pfPunchThroughHadronCleanedCandidates_->push_back(cands->at(iHad));
1243 pfPunchThroughMuonCleanedCandidates_->push_back(cands->at(imu));
1244 METX_ += cands->at(imu).px();
1245 METY_ += cands->at(imu).py();
1246 sumet_ += cands->at(imu).pt();
1248 }
else if ( fake1 || fake2 ) {
1249 METX_ -= cands->at(imu).px();
1250 METY_ -= cands->at(imu).py();
1251 sumet_ -= cands->at(imu).pt();
1252 maskedIndices_.push_back(imu);
1253 pfFakeMuonCleanedCandidates_->push_back(cands->at(imu));
1264 size_t N = indices.size();
1265 size_t collSize = obj->size();
1267 for (
size_t i = 0 ;
i <
N ; ++
i)
1268 obj->at(indices.at(
i)) = obj->at(collSize-
i-1);
1270 obj->resize(collSize - indices.size());
T getParameter(std::string const &) const
Abstract base class for a PFBlock element (track, cluster...)
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
bool cleanMismeasured(reco::PFCandidate &, unsigned int)
virtual double p() const
magnitude of momentum vector
static bool isTightMuonPOG(const reco::MuonRef &muonRef)
void removeDeadCandidates(reco::PFCandidateCollection *, const std::vector< unsigned int > &)
double rawEcalEnergy() const
return corrected Ecal energy
void addMissingMuons(edm::Handle< reco::MuonCollection >, reco::PFCandidateCollection *cands)
virtual float pt() const
transverse momentum
bool isMuon(const Candidate &part)
static bool isMuon(const reco::PFBlockElement &elt)
static bool isTrackerLooseMuon(const reco::PFBlockElement &elt)
virtual void setCharge(Charge q)
set electric charge
void setParameters(const edm::ParameterSet &)
static bool isGlobalLooseMuon(const reco::PFBlockElement &elt)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
bool cleanPunchThroughAndFakes(reco::PFCandidate &, reco::PFCandidateCollection *, unsigned int)
virtual void setP4(const LorentzVector &p4)
set 4-momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
reco::Muon::MuonTrackTypePair MuonTrackTypePair
static void printMuonProperties(const reco::MuonRef &muonRef)
std::vector< MuonTrackTypePair > tracksPointingAtMET(const std::vector< MuonTrackTypePair > &)
static bool isGlobalTightMuon(const reco::PFBlockElement &elt)
std::vector< ElementInBlock > ElementsInBlocks
bool isLooseMuon(const reco::Muon &)
reco::TrackRef trackRef() const
MuonTrackTypePair getTrackWithSmallestError(const std::vector< MuonTrackTypePair > &)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
bool isNonnull() const
Checks for non-null.
reco::Muon::MuonTrackTypePair tevOptimized(const reco::TrackRef &combinedTrack, const reco::TrackRef &trackerTrack, const reco::TrackRef &tpfmsTrack, const reco::TrackRef &pickyTrack, const double ptThreshold=200., const double tune1=17., const double tune2=40., const double dptcut=0.25)
void setVertexSource(PFVertexType vt)
double dPhi(double phi1, double phi2)
void setMuonTrackType(const reco::Muon::MuonTrackType &type)
set the Best Muon Track Ref
virtual float eta() const
momentum pseudorapidity
void setParticleType(ParticleType type)
set Particle Type
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
Abs< T >::type abs(const T &t)
void estimateEventQuantities(const reco::PFCandidateCollection *)
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
void changeTrack(reco::PFCandidate &, const MuonTrackTypePair &)
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
reco::MuonRef muonRef() const
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
static TrackQuality qualityByName(const std::string &name)
virtual double px() const
x coordinate of momentum vector
static bool isLooseMuon(const reco::PFBlockElement &elt)
key_type key() const
Accessor for product key.
std::pair< double, double > getMinMaxMET2(const reco::PFCandidate &)
int numberOfValidTrackerHits() const
Particle reconstructed by the particle flow algorithm.
void setMuonRef(const reco::MuonRef &ref)
set muon reference
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
MuonTrackType
map for Global Muon refitters
const reco::MuonRef & muonRef() const
virtual ParticleType particleId() const
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
std::vector< MuonTrackTypePair > tracksWithBetterMET(const std::vector< MuonTrackTypePair > &, const reco::PFCandidate &)
void postClean(reco::PFCandidateCollection *)
const ElementsInBlocks & elementsInBlocks() const
void setInputsForCleaning(const reco::VertexCollection *)
std::vector< reco::Muon::MuonTrackTypePair > muonTracks(const reco::MuonRef &muon, bool includeSA=false, double dpt=1e+9)
virtual double py() const
y coordinate of momentum vector
Power< A, B >::type pow(const A &a, const B &b)
static bool isTrackerTightMuon(const reco::PFBlockElement &elt)
double rawHcalEnergy() const
return raw Hcal energy
bool reconstructMuon(reco::PFCandidate &, const reco::MuonRef &, bool allowLoose=false)