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;
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();
357 if ( muonRef->isTrackerMuon() ){
359 bool result = combinedMu->normalizedChi2() < 100.;
364 int nMatches = muonRef->numberOfMatches();
366 quality = laststation && nMuonHits > 12 && nMatches > 1;
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;
465 double relIso = sumPtR03/smallestMuPt;
467 if(relIso<0.1)
return true;
476 if(!muonRef->isTrackerMuon())
return false;
478 if(muonRef->numberOfMatches()<2)
return false;
483 if(combinedMuon->hitPattern().numberOfValidTrackerHits()<11)
return false;
485 if(combinedMuon->hitPattern().numberOfValidPixelHits()==0)
return false;
487 if(combinedMuon->hitPattern().numberOfValidMuonHits()==0)
return false;
498 bool isGL = muonRef->isGlobalMuon();
499 bool isTR = muonRef->isTrackerMuon();
500 bool isST = muonRef->isStandAloneMuon();
502 std::cout<<
" GL: "<<isGL<<
" TR: "<<isTR<<
" ST: "<<isST<<std::endl;
503 std::cout<<
" nMatches "<<muonRef->numberOfMatches()<<std::endl;
505 if ( muonRef->isGlobalMuon() ){
507 std::cout<<
" GL, pt: " << combinedMu->pt()
508 <<
" +/- " << combinedMu->ptError()/combinedMu->pt()
509 <<
" chi**2 GBL : " << combinedMu->normalizedChi2()<<std::endl;
510 std::cout<<
" Total Muon Hits : " << combinedMu->hitPattern().numberOfValidMuonHits()
511 <<
"/" << combinedMu->hitPattern().numberOfLostMuonHits()
512 <<
" DT Hits : " << combinedMu->hitPattern().numberOfValidMuonDTHits()
513 <<
"/" << combinedMu->hitPattern().numberOfLostMuonDTHits()
514 <<
" CSC Hits : " << combinedMu->hitPattern().numberOfValidMuonCSCHits()
515 <<
"/" << combinedMu->hitPattern().numberOfLostMuonCSCHits()
516 <<
" RPC Hits : " << combinedMu->hitPattern().numberOfValidMuonRPCHits()
517 <<
"/" << combinedMu->hitPattern().numberOfLostMuonRPCHits()<<std::endl;
519 std::cout<<
" # of Valid Tracker Hits "<<combinedMu->hitPattern().numberOfValidTrackerHits()<<std::endl;
520 std::cout<<
" # of Valid Pixel Hits "<<combinedMu->hitPattern().numberOfValidPixelHits()<<std::endl;
522 if ( muonRef->isStandAloneMuon() ){
524 std::cout<<
" ST, pt: " << standAloneMu->pt()
525 <<
" +/- " << standAloneMu->ptError()/standAloneMu->pt()
526 <<
" eta : " << standAloneMu->eta()
527 <<
" DT Hits : " << standAloneMu->hitPattern().numberOfValidMuonDTHits()
528 <<
"/" << standAloneMu->hitPattern().numberOfLostMuonDTHits()
529 <<
" CSC Hits : " << standAloneMu->hitPattern().numberOfValidMuonCSCHits()
530 <<
"/" << standAloneMu->hitPattern().numberOfLostMuonCSCHits()
531 <<
" RPC Hits : " << standAloneMu->hitPattern().numberOfValidMuonRPCHits()
532 <<
"/" << standAloneMu->hitPattern().numberOfLostMuonRPCHits()
533 <<
" chi**2 STA : " << standAloneMu->normalizedChi2()<<std::endl;
537 if ( muonRef->isTrackerMuon() ){
540 std::cout<<
" TR, pt: " << trackerMu->pt()
541 <<
" +/- " << trackerMu->ptError()/trackerMu->pt()
542 <<
" chi**2 TR : " << trackerMu->normalizedChi2()<<std::endl;
546 <<
"TMLastStationAngTight "
548 <<
"TMLastStationLoose "
550 <<
"TMLastStationTight "
552 <<
"TMOneStationLoose "
554 <<
"TMOneStationTight "
556 <<
"TMLastStationOptimizedLowPtLoose "
558 <<
"TMLastStationOptimizedLowPtTight "
560 <<
"TMLastStationOptimizedBarrelLowPtLoose "
562 <<
"TMLastStationOptimizedBarrelLowPtTight "
570 <<
"TM2DCompatibilityTight "
575 if ( muonRef->isGlobalMuon() && muonRef->isTrackerMuon() && muonRef->isStandAloneMuon() ){
580 double sigmaCombined = combinedMu->ptError()/(combinedMu->pt()*combinedMu->pt());
581 double sigmaTracker = trackerMu->ptError()/(trackerMu->pt()*trackerMu->pt());
582 double sigmaStandAlone = standAloneMu->ptError()/(standAloneMu->pt()*standAloneMu->pt());
584 bool combined = combinedMu->ptError()/combinedMu->pt() < 0.20;
585 bool tracker = trackerMu->ptError()/trackerMu->pt() < 0.20;
586 bool standAlone = standAloneMu->ptError()/standAloneMu->pt() < 0.20;
588 double delta1 = combined && tracker ?
589 fabs(1./combinedMu->pt() -1./trackerMu->pt())
590 /
sqrt(sigmaCombined*sigmaCombined + sigmaTracker*sigmaTracker) : 100.;
591 double delta2 = combined && standAlone ?
592 fabs(1./combinedMu->pt() -1./standAloneMu->pt())
593 /
sqrt(sigmaCombined*sigmaCombined + sigmaStandAlone*sigmaStandAlone) : 100.;
594 double delta3 = standAlone && tracker ?
595 fabs(1./standAloneMu->pt() -1./trackerMu->pt())
596 /
sqrt(sigmaStandAlone*sigmaStandAlone + sigmaTracker*sigmaTracker) : 100.;
599 standAloneMu->hitPattern().numberOfValidMuonDTHits()+
600 standAloneMu->hitPattern().numberOfValidMuonCSCHits() > 0 ?
603 std::cout <<
"delta = " << delta <<
" delta1 "<<delta1<<
" delta2 "<<delta2<<
" delta3 "<<delta3<<std::endl;
606 combinedMu->ptError()/combinedMu->pt()
607 / (trackerMu->ptError()/trackerMu->pt());
609 std::cout<<
" ratio "<<ratio<<
" combined mu pt "<<combinedMu->pt()<<std::endl;
615 double sumPtR03 = muonRef->isolationR03().sumPt;
616 double emEtR03 = muonRef->isolationR03().emEt;
617 double hadEtR03 = muonRef->isolationR03().hadEt;
618 double relIsoR03 = (sumPtR03 + emEtR03 + hadEtR03)/muonRef->pt();
619 double sumPtR05 = muonRef->isolationR05().sumPt;
620 double emEtR05 = muonRef->isolationR05().emEt;
621 double hadEtR05 = muonRef->isolationR05().hadEt;
622 double relIsoR05 = (sumPtR05 + emEtR05 + hadEtR05)/muonRef->pt();
623 std::cout<<
" 0.3 Radion Rel Iso: "<<relIsoR03<<
" sumPt "<<sumPtR03<<
" emEt "<<emEtR03<<
" hadEt "<<hadEtR03<<std::endl;
624 std::cout<<
" 0.5 Radion Rel Iso: "<<relIsoR05<<
" sumPt "<<sumPtR05<<
" emEt "<<emEtR05<<
" hadEt "<<hadEtR05<<std::endl;
632 return muonTracks(muon,includeSA,maxDPtOPt_);
641 std::vector<reco::Muon::MuonTrackTypePair>
out;
644 if(muon->globalTrack().
isNonnull() && muon->globalTrack()->pt()>0)
645 if(muon->globalTrack()->ptError()/muon->globalTrack()->pt()<dpt)
648 if(muon->innerTrack().
isNonnull() && muon->innerTrack()->pt()>0)
649 if(muon->innerTrack()->ptError()/muon->innerTrack()->pt()<dpt)
652 bool pickyExists=
false;
653 double pickyDpt=99999.;
654 if(muon->pickyTrack().
isNonnull() && muon->pickyTrack()->pt()>0) {
655 pickyDpt = muon->pickyTrack()->ptError()/muon->pickyTrack()->pt();
661 bool dytExists=
false;
662 double dytDpt=99999.;
663 if(muon->dytTrack().
isNonnull() && muon->dytTrack()->pt()>0) {
664 dytDpt = muon->dytTrack()->ptError()/muon->dytTrack()->pt();
674 if(muon->tpfmsTrack().
isNonnull() && muon->tpfmsTrack()->pt()>0) {
675 double tpfmsDpt = muon->tpfmsTrack()->ptError()/muon->tpfmsTrack()->pt();
676 if( ( (pickyExists && tpfmsDpt<pickyDpt) || (!pickyExists) ) &&
677 ( (dytExists && tpfmsDpt<dytDpt) || (!dytExists) ) &&
682 if(includeSA && muon->outerTrack().
isNonnull())
683 if(muon->outerTrack()->ptError()/muon->outerTrack()->pt()<dpt)
701 using namespace reco;
723 std::vector<reco::Muon::MuonTrackTypePair> validTracks = goodMuonTracks(muon);
725 validTracks = goodMuonTracks(muon);
727 validTracks = muonTracks(muon);
729 if( validTracks.size() ==0)
737 TrackRef bestTrack = bestTrackPair.first;
742 MuonTrackTypePair trackPairWithSmallestError = getTrackWithSmallestError(validTracks);
743 TrackRef trackWithSmallestError = trackPairWithSmallestError.first;
746 (!bestTrack->quality(trackQuality_) ||
747 bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt() )) {
748 bestTrack = trackWithSmallestError;
749 trackType = trackPairWithSmallestError.second;
752 bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt()) {
753 bestTrack = trackWithSmallestError;
754 trackType = trackPairWithSmallestError.second;
759 changeTrack(candidate,std::make_pair(bestTrack,trackType));
769 using namespace reco;
773 double px = bestTrack->px();
774 double py = bestTrack->py();
775 double pz = bestTrack->pz();
776 double energy =
sqrt(bestTrack->p()*bestTrack->p() + 0.1057*0.1057);
778 candidate.
setCharge(bestTrack->charge()>0 ? 1 : -1);
799 return *std::min_element(tracks.begin(),tracks.end(),
sorter);
813 for(reco::PFCandidateCollection::const_iterator
i = pfc->begin();
i!=pfc->end();++
i) {
827 using namespace reco;
833 if(pfCosmicsMuonCleanedCandidates_.get() )
834 pfCosmicsMuonCleanedCandidates_->clear();
838 if(pfCleanedTrackerAndGlobalMuonCandidates_.get() )
839 pfCleanedTrackerAndGlobalMuonCandidates_->clear();
843 if( pfFakeMuonCleanedCandidates_.get() )
844 pfFakeMuonCleanedCandidates_->clear();
849 if( pfPunchThroughMuonCleanedCandidates_.get() )
850 pfPunchThroughMuonCleanedCandidates_->clear();
854 if( pfPunchThroughHadronCleanedCandidates_.get() )
855 pfPunchThroughHadronCleanedCandidates_->clear();
861 pfPunchThroughHadronCleanedCandidates_->clear();
863 maskedIndices_.clear();
867 estimateEventQuantities(cands);
870 std::vector<int>
muons;
871 std::vector<int> cosmics;
873 for(
unsigned int i=0;
i<cands->size();++
i) {
880 maskedIndices_.push_back(
i);
881 pfPunchThroughMuonCleanedCandidates_->push_back(cand);
893 double METXCosmics=0;
894 double METYCosmics=0;
895 double SUMETCosmics=0.0;
897 for(
unsigned int i=0;
i<
muons.size();++
i) {
900 if(vertices_->size()>0&& vertices_->at(0).isValid() && ! vertices_->at(0).isFake())
901 origin = pfc.
muonRef()->muonBestTrack()->dxy(vertices_->at(0).position());
903 if( origin> cosmicRejDistance_) {
904 cosmics.push_back(
muons[i]);
905 METXCosmics +=pfc.
px();
906 METYCosmics +=pfc.
py();
907 SUMETCosmics +=pfc.
pt();
910 double MET2Cosmics = METXCosmics*METXCosmics+METYCosmics*METYCosmics;
912 if ( SUMETCosmics > (sumet_-sumetPU_)/eventFactorCosmics_ && MET2Cosmics < METX_*METX_+ METY_*METY_)
913 for(
unsigned int i=0;
i<cosmics.size();++
i) {
914 maskedIndices_.push_back(cosmics[
i]);
915 pfCosmicsMuonCleanedCandidates_->push_back(cands->at(cosmics[i]));
919 for(
unsigned int i=0;
i<
muons.size();++
i) {
922 cleanPunchThroughAndFakes(cands->at(
muons[i]),cands,
muons[
i]);
929 removeDeadCandidates(cands,maskedIndices_);
941 if( pfAddedMuonCandidates_.get() )
942 pfAddedMuonCandidates_->clear();
948 for (
unsigned imu = 0; imu < muons->size(); ++imu ) {
952 for(
unsigned i=0;
i<cands->size();
i++) {
959 if ( pfc.
muonRef()->innerTrack() == muonRef->innerTrack())
964 if ( pfc.
muonRef()->isStandAloneMuon() && muonRef->isStandAloneMuon() ) {
965 double dEta = pfc.
muonRef()->standAloneMuon()->eta() - muonRef->standAloneMuon()->eta();
966 double dPhi = pfc.
muonRef()->standAloneMuon()->phi() - muonRef->standAloneMuon()->phi();
967 double dR =
sqrt(dEta*dEta + dPhi*dPhi);
977 if ( used ||hadron||(!muonRef.
isNonnull()) )
continue;
983 std::vector<reco::Muon::MuonTrackTypePair>
tracks = goodMuonTracks(muonRef,
true);
985 if(tracks.size()>0) {
988 std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksPointingAtMET(tracks);
990 if (tracksThatChangeMET.size()>0) {
994 if((vertices_->size()==0) ||bestTrackType.first->dz(vertices_->at(0).position())<cosmicRejDistance_){
997 int charge = bestTrackType.first->charge()>0 ? 1 : -1;
999 bestTrackType.first->py(),
1000 bestTrackType.first->pz(),
1001 sqrt(bestTrackType.first->p()*bestTrackType.first->p()+0.1057*0.1057));
1007 changeTrack(cands->back(),bestTrackType);
1010 cands->back().setTrackRef( muonRef->track() );
1012 cands->back().setMuonRef(muonRef);
1015 pfAddedMuonCandidates_->push_back(cands->back());
1023 std::pair<double,double>
1025 std::vector<reco::Muon::MuonTrackTypePair>
tracks = goodMuonTracks((pfc.
muonRef()),
true);
1027 double METXNO = METX_-pfc.
px();
1028 double METYNO = METY_-pfc.
py();
1029 std::vector<double> met2;
1030 for (
unsigned int i=0;
i<tracks.size();++
i) {
1031 met2.push_back(
pow(METXNO+tracks.at(
i).first->px(),2)+
pow(METYNO+tracks.at(
i).first->py(),2));
1038 return std::make_pair(*std::min_element(met2.begin(),met2.end()),*std::max_element(met2.begin(),met2.end()));
1040 return std::make_pair(0,0);
1045 using namespace std;
1046 using namespace reco;
1050 double METNOX = METX_ - pfc.
px();
1051 double METNOY = METY_ - pfc.
py();
1052 double SUMETNO = sumet_ -pfc.
pt();
1056 if (pfc.
pt()<minPostCleaningPt_)
1058 std::vector<reco::Muon::MuonTrackTypePair>
tracks = goodMuonTracks(pfc.
muonRef(),
false);
1065 std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksWithBetterMET(
tracks,pfc);
1067 if (tracksThatChangeMET.size()>0) {
1069 changeTrack(pfc,bestTrackType);
1071 pfCleanedTrackerAndGlobalMuonCandidates_->push_back(pfc);
1073 METX_ = METNOX+pfc.
px();
1074 METY_ = METNOY+pfc.
py();
1075 sumet_=SUMETNO+pfc.
pt();
1081 if (!(pfc.
muonRef()->isGlobalMuon() && pfc.
muonRef()->isTrackerMuon())) {
1083 double MET2 = METX_*METX_+METY_*METY_;
1084 double newMET2 = METNOX*METNOX+METNOY*METNOY;
1085 double METSig =
sqrt(MET2)/
sqrt(sumet_-sumetPU_);
1086 if( METSig>metSigForRejection_)
1087 if((newMET2 < MET2/metFactorRejection_) &&
1088 ((SUMETNO-sumetPU_)/(sumet_-sumetPU_)<eventFractionRejection_)) {
1089 pfFakeMuonCleanedCandidates_->push_back(pfc);
1090 maskedIndices_.push_back(i);
1102 std::vector<reco::Muon::MuonTrackTypePair>
1104 std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1106 double METNOX = METX_ - pfc.
px();
1107 double METNOY = METY_ - pfc.
py();
1108 double SUMETNO = sumet_ -pfc.
pt();
1109 double MET2 = METX_*METX_+METY_*METY_;
1111 double newSUMET=0.0;
1112 double METSIG =
sqrt(MET2)/
sqrt(sumet_-sumetPU_);
1115 if(METSIG>metSigForCleaning_)
1116 for(
unsigned int i=0;
i<tracks.size();++
i) {
1118 newSUMET = SUMETNO+tracks.at(
i).first->pt()-sumetPU_;
1119 newMET2 =
pow(METNOX+tracks.at(
i).first->px(),2)+
pow(METNOY+tracks.at(
i).first->py(),2);
1121 if(newSUMET/(sumet_-sumetPU_)>eventFractionCleaning_ && newMET2<MET2/metFactorCleaning_)
1122 outputTracks.push_back(tracks.at(
i));
1126 return outputTracks;
1130 std::vector<reco::Muon::MuonTrackTypePair>
1132 std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1137 for(
unsigned int i=0;
i<tracks.size();++
i) {
1139 newMET2 =
pow(METX_+tracks.at(
i).first->px(),2)+
pow(METY_+tracks.at(
i).first->py(),2);
1141 if(newMET2<(METX_*METX_+METY_*METY_)/metFactorCleaning_)
1142 outputTracks.push_back(tracks.at(
i));
1146 return outputTracks;
1156 using namespace reco;
1160 if (pfc.
pt()<minPostCleaningPt_)
1164 double METXNO = METX_-pfc.
pt();
1165 double METYNO = METY_-pfc.
pt();
1166 double MET2NO = METXNO*METXNO+METYNO*METYNO;
1167 double MET2 = METX_*METX_+METY_*METY_;
1170 std::pair<double,double> met2 = getMinMaxMET2(pfc);
1174 fake1 =fabs ( pfc.
eta() ) > 2.15 &&
1175 met2.first<met2.second/2 &&
1176 MET2NO < MET2/metFactorHighEta_ &&
1177 pfc.
muonRef()->standAloneMuon()->pt() < pfc.
pt()/ptFactorHighEta_;
1179 double factor =
std::max(2.,2000./(sumet_-pfc.
pt()-sumetPU_));
1180 bool fake2 = ( pfc.
pt()/(sumet_-sumetPU_) < 0.25 && MET2NO < MET2/metFactorFake_ && met2.first<met2.second/factor );
1182 bool punchthrough =pfc.
p() > minPunchThroughMomentum_ &&
1185 !isIsolatedMuon(pfc.
muonRef()) && MET2NO < MET2/punchThroughMETFactor_;
1188 if(fake1 || fake2||punchthrough) {
1191 if ( eleInBlocks.size() ) {
1192 PFBlockRef blockRefMuon = eleInBlocks[0].first;
1193 unsigned indexMuon = eleInBlocks[0].second;
1194 if (eleInBlocks.size()>1)
1195 indexMuon = eleInBlocks[1].
second;
1199 bool hadron =
false;
1200 for (
unsigned i = imu+1;
i < cands->size(); ++
i ) {
1203 if ( !ele.size() ) {
1207 unsigned indexHadron = ele[0].second;
1209 if ( blockRefHadron.
key() != blockRefMuon.
key() )
break;
1211 if ( indexHadron == indexMuon &&
1216 if ( hadron )
break;
1221 double rescaleFactor = cands->at(iHad).p()/cands->at(imu).p();
1222 METX_ -= cands->at(imu).px() + cands->at(iHad).px();
1223 METY_ -= cands->at(imu).py() + cands->at(iHad).py();
1224 sumet_ -=cands->at(imu).pt();
1225 cands->at(imu).rescaleMomentum(rescaleFactor);
1226 maskedIndices_.push_back(iHad);
1227 pfPunchThroughHadronCleanedCandidates_->push_back(cands->at(iHad));
1229 pfPunchThroughMuonCleanedCandidates_->push_back(cands->at(imu));
1230 METX_ += cands->at(imu).px();
1231 METY_ += cands->at(imu).py();
1232 sumet_ += cands->at(imu).pt();
1234 }
else if ( fake1 || fake2 ) {
1235 METX_ -= cands->at(imu).px();
1236 METY_ -= cands->at(imu).py();
1237 sumet_ -= cands->at(imu).pt();
1238 maskedIndices_.push_back(imu);
1239 pfFakeMuonCleanedCandidates_->push_back(cands->at(imu));
1250 size_t N = indices.size();
1251 size_t collSize = obj->size();
1253 for (
size_t i = 0 ;
i <
N ; ++
i)
1254 obj->at(indices.at(
i)) = obj->at(collSize-
i-1);
1256 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 > &)
bool isNonnull() const
Checks for non-null.
double rawEcalEnergy() const
return corrected Ecal energy
void addMissingMuons(edm::Handle< reco::MuonCollection >, reco::PFCandidateCollection *cands)
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
key_type key() const
Accessor for product key.
static void printMuonProperties(const reco::MuonRef &muonRef)
std::vector< MuonTrackTypePair > tracksPointingAtMET(const std::vector< MuonTrackTypePair > &)
static bool isGlobalTightMuon(const reco::PFBlockElement &elt)
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
std::vector< ElementInBlock > ElementsInBlocks
bool isLooseMuon(const reco::Muon &)
reco::TrackRef trackRef() const
MuonTrackTypePair getTrackWithSmallestError(const std::vector< MuonTrackTypePair > &)
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void setVertexSource(PFVertexType vt)
reco::Muon::MuonTrackTypePair tevOptimized(const reco::TrackRef &combinedTrack, const reco::TrackRef &trackerTrack, const reco::TrackRef &tpfmsTrack, const reco::TrackRef &pickyTrack, const reco::TrackRef &dytTrack, const double ptThreshold=200., const double tune1=17., const double tune2=40., const double dptcut=0.25)
double dPhi(double phi1, double phi2)
void setMuonTrackType(const reco::Muon::MuonTrackType &type)
set the Best Muon Track Ref
void setParticleType(ParticleType type)
set Particle Type
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
void estimateEventQuantities(const reco::PFCandidateCollection *)
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
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
static bool isLooseMuon(const reco::PFBlockElement &elt)
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
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)