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;
646 if(muon->globalTrack().
isNonnull() && muon->globalTrack()->pt()>0)
647 if(muon->globalTrack()->ptError()/muon->globalTrack()->pt()<dpt)
650 if(muon->innerTrack().
isNonnull() && muon->innerTrack()->pt()>0)
651 if(muon->innerTrack()->ptError()/muon->innerTrack()->pt()<dpt)
654 bool pickyExists=
false;
655 double pickyDpt=99999.;
656 if(muon->pickyTrack().
isNonnull() && muon->pickyTrack()->pt()>0) {
657 pickyDpt = muon->pickyTrack()->ptError()/muon->pickyTrack()->pt();
663 bool dytExists=
false;
664 double dytDpt=99999.;
665 if(muon->dytTrack().
isNonnull() && muon->dytTrack()->pt()>0) {
666 dytDpt = muon->dytTrack()->ptError()/muon->dytTrack()->pt();
676 if(muon->tpfmsTrack().
isNonnull() && muon->tpfmsTrack()->pt()>0) {
677 double tpfmsDpt = muon->tpfmsTrack()->ptError()/muon->tpfmsTrack()->pt();
678 if( ( (pickyExists && tpfmsDpt<pickyDpt) || (!pickyExists) ) &&
679 ( (dytExists && tpfmsDpt<dytDpt) || (!dytExists) ) &&
684 if(includeSA && muon->outerTrack().
isNonnull())
685 if(muon->outerTrack()->ptError()/muon->outerTrack()->pt()<dpt)
703 using namespace reco;
725 std::vector<reco::Muon::MuonTrackTypePair> validTracks = goodMuonTracks(muon);
727 validTracks = goodMuonTracks(muon);
729 validTracks = muonTracks(muon);
731 if( validTracks.size() ==0)
739 TrackRef bestTrack = bestTrackPair.first;
744 MuonTrackTypePair trackPairWithSmallestError = getTrackWithSmallestError(validTracks);
745 TrackRef trackWithSmallestError = trackPairWithSmallestError.first;
748 (!bestTrack->quality(trackQuality_) ||
749 bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt() )) {
750 bestTrack = trackWithSmallestError;
751 trackType = trackPairWithSmallestError.second;
754 bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt()) {
755 bestTrack = trackWithSmallestError;
756 trackType = trackPairWithSmallestError.second;
761 changeTrack(candidate,std::make_pair(bestTrack,trackType));
771 using namespace reco;
775 double px = bestTrack->px();
776 double py = bestTrack->py();
777 double pz = bestTrack->pz();
778 double energy =
sqrt(bestTrack->p()*bestTrack->p() + 0.1057*0.1057);
780 candidate.
setCharge(bestTrack->charge()>0 ? 1 : -1);
801 return *std::min_element(tracks.begin(),tracks.end(),
sorter);
815 for(reco::PFCandidateCollection::const_iterator
i = pfc->begin();
i!=pfc->end();++
i) {
829 using namespace reco;
835 if(pfCosmicsMuonCleanedCandidates_.get() )
836 pfCosmicsMuonCleanedCandidates_->clear();
840 if(pfCleanedTrackerAndGlobalMuonCandidates_.get() )
841 pfCleanedTrackerAndGlobalMuonCandidates_->clear();
845 if( pfFakeMuonCleanedCandidates_.get() )
846 pfFakeMuonCleanedCandidates_->clear();
851 if( pfPunchThroughMuonCleanedCandidates_.get() )
852 pfPunchThroughMuonCleanedCandidates_->clear();
856 if( pfPunchThroughHadronCleanedCandidates_.get() )
857 pfPunchThroughHadronCleanedCandidates_->clear();
863 pfPunchThroughHadronCleanedCandidates_->clear();
865 maskedIndices_.clear();
869 estimateEventQuantities(cands);
872 std::vector<int>
muons;
873 std::vector<int> cosmics;
875 for(
unsigned int i=0;
i<cands->size();++
i) {
882 maskedIndices_.push_back(
i);
883 pfPunchThroughMuonCleanedCandidates_->push_back(cand);
895 double METXCosmics=0;
896 double METYCosmics=0;
897 double SUMETCosmics=0.0;
899 for(
unsigned int i=0;
i<
muons.size();++
i) {
902 if(vertices_->size()>0&& vertices_->at(0).isValid() && ! vertices_->at(0).isFake())
903 origin = pfc.
muonRef()->muonBestTrack()->dxy(vertices_->at(0).position());
905 if( origin> cosmicRejDistance_) {
906 cosmics.push_back(
muons[i]);
907 METXCosmics +=pfc.
px();
908 METYCosmics +=pfc.
py();
909 SUMETCosmics +=pfc.
pt();
912 double MET2Cosmics = METXCosmics*METXCosmics+METYCosmics*METYCosmics;
914 if ( SUMETCosmics > (sumet_-sumetPU_)/eventFactorCosmics_ && MET2Cosmics < METX_*METX_+ METY_*METY_)
915 for(
unsigned int i=0;
i<cosmics.size();++
i) {
916 maskedIndices_.push_back(cosmics[
i]);
917 pfCosmicsMuonCleanedCandidates_->push_back(cands->at(cosmics[i]));
921 for(
unsigned int i=0;
i<
muons.size();++
i) {
924 cleanPunchThroughAndFakes(cands->at(
muons[i]),cands,
muons[
i]);
931 removeDeadCandidates(cands,maskedIndices_);
943 if( pfAddedMuonCandidates_.get() )
944 pfAddedMuonCandidates_->clear();
950 for (
unsigned imu = 0; imu < muons->size(); ++imu ) {
954 for(
unsigned i=0;
i<cands->size();
i++) {
961 if ( pfc.
muonRef()->innerTrack() == muonRef->innerTrack())
966 if ( pfc.
muonRef()->isStandAloneMuon() && muonRef->isStandAloneMuon() ) {
967 double dEta = pfc.
muonRef()->standAloneMuon()->eta() - muonRef->standAloneMuon()->eta();
968 double dPhi = pfc.
muonRef()->standAloneMuon()->phi() - muonRef->standAloneMuon()->phi();
969 double dR =
sqrt(dEta*dEta + dPhi*dPhi);
979 if ( used ||hadron||(!muonRef.
isNonnull()) )
continue;
985 std::vector<reco::Muon::MuonTrackTypePair>
tracks = goodMuonTracks(muonRef,
true);
987 if(tracks.size()>0) {
990 std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksPointingAtMET(tracks);
992 if (tracksThatChangeMET.size()>0) {
996 if((vertices_->size()==0) ||bestTrackType.first->dz(vertices_->at(0).position())<cosmicRejDistance_){
999 int charge = bestTrackType.first->charge()>0 ? 1 : -1;
1001 bestTrackType.first->py(),
1002 bestTrackType.first->pz(),
1003 sqrt(bestTrackType.first->p()*bestTrackType.first->p()+0.1057*0.1057));
1009 changeTrack(cands->back(),bestTrackType);
1012 cands->back().setTrackRef( muonRef->track() );
1014 cands->back().setMuonRef(muonRef);
1017 pfAddedMuonCandidates_->push_back(cands->back());
1025 std::pair<double,double>
1027 std::vector<reco::Muon::MuonTrackTypePair>
tracks = goodMuonTracks((pfc.
muonRef()),
true);
1029 double METXNO = METX_-pfc.
px();
1030 double METYNO = METY_-pfc.
py();
1031 std::vector<double> met2;
1032 for (
unsigned int i=0;
i<tracks.size();++
i) {
1033 met2.push_back(
pow(METXNO+tracks.at(
i).first->px(),2)+
pow(METYNO+tracks.at(
i).first->py(),2));
1040 return std::make_pair(*std::min_element(met2.begin(),met2.end()),*std::max_element(met2.begin(),met2.end()));
1042 return std::make_pair(0,0);
1047 using namespace std;
1048 using namespace reco;
1052 double METNOX = METX_ - pfc.
px();
1053 double METNOY = METY_ - pfc.
py();
1054 double SUMETNO = sumet_ -pfc.
pt();
1058 if (pfc.
pt()<minPostCleaningPt_)
1060 std::vector<reco::Muon::MuonTrackTypePair>
tracks = goodMuonTracks(pfc.
muonRef(),
false);
1067 std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksWithBetterMET(
tracks,pfc);
1069 if (tracksThatChangeMET.size()>0) {
1071 changeTrack(pfc,bestTrackType);
1073 pfCleanedTrackerAndGlobalMuonCandidates_->push_back(pfc);
1075 METX_ = METNOX+pfc.
px();
1076 METY_ = METNOY+pfc.
py();
1077 sumet_=SUMETNO+pfc.
pt();
1083 if (!(pfc.
muonRef()->isGlobalMuon() && pfc.
muonRef()->isTrackerMuon())) {
1085 double MET2 = METX_*METX_+METY_*METY_;
1086 double newMET2 = METNOX*METNOX+METNOY*METNOY;
1087 double METSig =
sqrt(MET2)/
sqrt(sumet_-sumetPU_);
1088 if( METSig>metSigForRejection_)
1089 if((newMET2 < MET2/metFactorRejection_) &&
1090 ((SUMETNO-sumetPU_)/(sumet_-sumetPU_)<eventFractionRejection_)) {
1091 pfFakeMuonCleanedCandidates_->push_back(pfc);
1092 maskedIndices_.push_back(i);
1104 std::vector<reco::Muon::MuonTrackTypePair>
1106 std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1108 double METNOX = METX_ - pfc.
px();
1109 double METNOY = METY_ - pfc.
py();
1110 double SUMETNO = sumet_ -pfc.
pt();
1111 double MET2 = METX_*METX_+METY_*METY_;
1113 double newSUMET=0.0;
1114 double METSIG =
sqrt(MET2)/
sqrt(sumet_-sumetPU_);
1117 if(METSIG>metSigForCleaning_)
1118 for(
unsigned int i=0;
i<tracks.size();++
i) {
1120 newSUMET = SUMETNO+tracks.at(
i).first->pt()-sumetPU_;
1121 newMET2 =
pow(METNOX+tracks.at(
i).first->px(),2)+
pow(METNOY+tracks.at(
i).first->py(),2);
1123 if(newSUMET/(sumet_-sumetPU_)>eventFractionCleaning_ && newMET2<MET2/metFactorCleaning_)
1124 outputTracks.push_back(tracks.at(
i));
1128 return outputTracks;
1132 std::vector<reco::Muon::MuonTrackTypePair>
1134 std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1139 for(
unsigned int i=0;
i<tracks.size();++
i) {
1141 newMET2 =
pow(METX_+tracks.at(
i).first->px(),2)+
pow(METY_+tracks.at(
i).first->py(),2);
1143 if(newMET2<(METX_*METX_+METY_*METY_)/metFactorCleaning_)
1144 outputTracks.push_back(tracks.at(
i));
1148 return outputTracks;
1154 vertices_ = vertices;
1158 using namespace reco;
1162 if (pfc.
pt()<minPostCleaningPt_)
1166 double METXNO = METX_-pfc.
pt();
1167 double METYNO = METY_-pfc.
pt();
1168 double MET2NO = METXNO*METXNO+METYNO*METYNO;
1169 double MET2 = METX_*METX_+METY_*METY_;
1172 std::pair<double,double> met2 = getMinMaxMET2(pfc);
1176 fake1 =fabs ( pfc.
eta() ) > 2.15 &&
1177 met2.first<met2.second/2 &&
1178 MET2NO < MET2/metFactorHighEta_ &&
1179 pfc.
muonRef()->standAloneMuon()->pt() < pfc.
pt()/ptFactorHighEta_;
1181 double factor =
std::max(2.,2000./(sumet_-pfc.
pt()-sumetPU_));
1182 bool fake2 = ( pfc.
pt()/(sumet_-sumetPU_) < 0.25 && MET2NO < MET2/metFactorFake_ && met2.first<met2.second/factor );
1184 bool punchthrough =pfc.
p() > minPunchThroughMomentum_ &&
1187 !isIsolatedMuon(pfc.
muonRef()) && MET2NO < MET2/punchThroughMETFactor_;
1190 if(fake1 || fake2||punchthrough) {
1193 if ( eleInBlocks.size() ) {
1194 PFBlockRef blockRefMuon = eleInBlocks[0].first;
1195 unsigned indexMuon = eleInBlocks[0].second;
1196 if (eleInBlocks.size()>1)
1197 indexMuon = eleInBlocks[1].
second;
1201 bool hadron =
false;
1202 for (
unsigned i = imu+1;
i < cands->size(); ++
i ) {
1205 if ( !ele.size() ) {
1209 unsigned indexHadron = ele[0].second;
1211 if ( blockRefHadron.
key() != blockRefMuon.
key() )
break;
1213 if ( indexHadron == indexMuon &&
1218 if ( hadron )
break;
1223 double rescaleFactor = cands->at(iHad).p()/cands->at(imu).p();
1224 METX_ -= cands->at(imu).px() + cands->at(iHad).px();
1225 METY_ -= cands->at(imu).py() + cands->at(iHad).py();
1226 sumet_ -=cands->at(imu).pt();
1227 cands->at(imu).rescaleMomentum(rescaleFactor);
1228 maskedIndices_.push_back(iHad);
1229 pfPunchThroughHadronCleanedCandidates_->push_back(cands->at(iHad));
1231 pfPunchThroughMuonCleanedCandidates_->push_back(cands->at(imu));
1232 METX_ += cands->at(imu).px();
1233 METY_ += cands->at(imu).py();
1234 sumet_ += cands->at(imu).pt();
1236 }
else if ( fake1 || fake2 ) {
1237 METX_ -= cands->at(imu).px();
1238 METY_ -= cands->at(imu).py();
1239 sumet_ -= cands->at(imu).pt();
1240 maskedIndices_.push_back(imu);
1241 pfFakeMuonCleanedCandidates_->push_back(cands->at(imu));
1252 size_t N = indices.size();
1253 size_t collSize = obj->size();
1255 for (
size_t i = 0 ;
i <
N ; ++
i)
1256 obj->at(indices.at(
i)) = obj->at(collSize-
i-1);
1258 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)
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
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)
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
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)
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)