CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
PFMuonAlgo Class Reference

#include <PFMuonAlgo.h>

Classes

class  IndexPtComparator
 
class  TrackMETComparator
 
class  TrackPtErrorSorter
 

Public Member Functions

void addMissingMuons (edm::Handle< reco::MuonCollection >, reco::PFCandidateCollection *cands)
 
void changeTrack (reco::PFCandidate &, const MuonTrackTypePair &)
 
 PFMuonAlgo ()
 constructor More...
 
void postClean (reco::PFCandidateCollection *)
 
bool reconstructMuon (reco::PFCandidate &, const reco::MuonRef &, bool allowLoose=false)
 
void setInputsForCleaning (const reco::VertexCollection *)
 
void setParameters (const edm::ParameterSet &)
 
std::auto_ptr
< reco::PFCandidateCollection > & 
transferAddedMuonCandidates ()
 
std::auto_ptr
< reco::PFCandidateCollection > & 
transferCleanedCosmicCandidates ()
 
std::auto_ptr
< reco::PFCandidateCollection > & 
transferCleanedFakeCandidates ()
 
std::auto_ptr
< reco::PFCandidateCollection > & 
transferCleanedTrackerAndGlobalCandidates ()
 
std::auto_ptr
< reco::PFCandidateCollection > & 
transferPunchThroughCleanedHadronCandidates ()
 
std::auto_ptr
< reco::PFCandidateCollection > & 
transferPunchThroughCleanedMuonCandidates ()
 
virtual ~PFMuonAlgo ()
 destructor More...
 

Static Public Member Functions

static bool hasValidTracks (const reco::MuonRef &)
 
static bool isGlobalLooseMuon (const reco::PFBlockElement &elt)
 
static bool isGlobalLooseMuon (const reco::MuonRef &muonRef)
 
static bool isGlobalTightMuon (const reco::PFBlockElement &elt)
 
static bool isGlobalTightMuon (const reco::MuonRef &muonRef)
 
static bool isIsolatedMuon (const reco::PFBlockElement &elt)
 
static bool isIsolatedMuon (const reco::MuonRef &muonRef)
 
static bool isLooseMuon (const reco::PFBlockElement &elt)
 
static bool isLooseMuon (const reco::MuonRef &muonRef)
 
static bool isMuon (const reco::PFBlockElement &elt)
 
static bool isMuon (const reco::MuonRef &muonRef)
 
static bool isTightMuonPOG (const reco::MuonRef &muonRef)
 
static bool isTrackerLooseMuon (const reco::PFBlockElement &elt)
 
static bool isTrackerLooseMuon (const reco::MuonRef &muonRef)
 
static bool isTrackerTightMuon (const reco::PFBlockElement &elt)
 
static bool isTrackerTightMuon (const reco::MuonRef &muonRef)
 
static void printMuonProperties (const reco::MuonRef &muonRef)
 

Private Types

typedef reco::Muon::MuonTrackType MuonTrackType
 
typedef
reco::Muon::MuonTrackTypePair 
MuonTrackTypePair
 

Private Member Functions

bool cleanMismeasured (reco::PFCandidate &, unsigned int)
 
bool cleanPunchThroughAndFakes (reco::PFCandidate &, reco::PFCandidateCollection *, unsigned int)
 
void estimateEventQuantities (const reco::PFCandidateCollection *)
 
std::pair< double, double > getMinMaxMET2 (const reco::PFCandidate &)
 
MuonTrackTypePair getTrackWithSmallestError (const std::vector< MuonTrackTypePair > &)
 
std::vector
< reco::Muon::MuonTrackTypePair
goodMuonTracks (const reco::MuonRef &muon, bool includeSA=false)
 
std::vector
< reco::Muon::MuonTrackTypePair
muonTracks (const reco::MuonRef &muon, bool includeSA=false, double dpt=1e+9)
 
void removeDeadCandidates (reco::PFCandidateCollection *, const std::vector< unsigned int > &)
 
std::vector< MuonTrackTypePairtracksPointingAtMET (const std::vector< MuonTrackTypePair > &)
 
std::vector< MuonTrackTypePairtracksWithBetterMET (const std::vector< MuonTrackTypePair > &, const reco::PFCandidate &)
 

Private Attributes

double cosmicRejDistance_
 
double dzPV_
 
double errorCompScale_
 
double eventFactorCosmics_
 
double eventFractionCleaning_
 
double eventFractionRejection_
 
std::vector< unsigned int > maskedIndices_
 
double maxDPtOPt_
 
double metFactorCleaning_
 
double metFactorFake_
 
double metFactorHighEta_
 
double metFactorRejection_
 
double metSigForCleaning_
 
double metSigForRejection_
 
double METX_
 
double METY_
 
int minPixelHits_
 
double minPostCleaningPt_
 
double minPunchThroughEnergy_
 
double minPunchThroughMomentum_
 
int minTrackerHits_
 
std::auto_ptr
< reco::PFCandidateCollection
pfAddedMuonCandidates_
 the collection of added muon candidates More...
 
std::auto_ptr
< reco::PFCandidateCollection
pfCleanedTrackerAndGlobalMuonCandidates_
 the collection of tracker/global cleaned muon candidates More...
 
std::auto_ptr
< reco::PFCandidateCollection
pfCosmicsMuonCleanedCandidates_
 the collection of cosmics cleaned muon candidates More...
 
std::auto_ptr
< reco::PFCandidateCollection
pfFakeMuonCleanedCandidates_
 the collection of fake cleaned muon candidates More...
 
std::auto_ptr
< reco::PFCandidateCollection
pfPunchThroughHadronCleanedCandidates_
 the collection of punch-through cleaned neutral hadron candidates More...
 
std::auto_ptr
< reco::PFCandidateCollection
pfPunchThroughMuonCleanedCandidates_
 the collection of punch-through cleaned muon candidates More...
 
bool postCleaning_
 
double ptFactorHighEta_
 
double punchThroughFactor_
 
double punchThroughMETFactor_
 
double sumet_
 
double sumetPU_
 
reco::TrackBase::TrackQuality trackQuality_
 
const reco::VertexCollectionvertices_
 

Detailed Description

Definition at line 12 of file PFMuonAlgo.h.

Member Typedef Documentation

Definition at line 15 of file PFMuonAlgo.h.

Definition at line 14 of file PFMuonAlgo.h.

Constructor & Destructor Documentation

PFMuonAlgo::PFMuonAlgo ( )

constructor

Definition at line 17 of file PFMuonAlgo.cc.

17  {
18  pfCosmicsMuonCleanedCandidates_ = std::auto_ptr<reco::PFCandidateCollection>(new reco::PFCandidateCollection);
19  pfCleanedTrackerAndGlobalMuonCandidates_= std::auto_ptr<reco::PFCandidateCollection>(new reco::PFCandidateCollection);
20  pfFakeMuonCleanedCandidates_= std::auto_ptr<reco::PFCandidateCollection>(new reco::PFCandidateCollection);
21  pfPunchThroughMuonCleanedCandidates_= std::auto_ptr<reco::PFCandidateCollection>(new reco::PFCandidateCollection);
22  pfPunchThroughHadronCleanedCandidates_= std::auto_ptr<reco::PFCandidateCollection>(new reco::PFCandidateCollection);
23  pfAddedMuonCandidates_= std::auto_ptr<reco::PFCandidateCollection>(new reco::PFCandidateCollection);
24 
25 }
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughMuonCleanedCandidates_
the collection of punch-through cleaned muon candidates
Definition: PFMuonAlgo.h:139
std::auto_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:137
std::auto_ptr< reco::PFCandidateCollection > pfAddedMuonCandidates_
the collection of added muon candidates
Definition: PFMuonAlgo.h:143
std::auto_ptr< reco::PFCandidateCollection > pfCosmicsMuonCleanedCandidates_
the collection of cosmics cleaned muon candidates
Definition: PFMuonAlgo.h:133
std::auto_ptr< reco::PFCandidateCollection > pfCleanedTrackerAndGlobalMuonCandidates_
the collection of tracker/global cleaned muon candidates
Definition: PFMuonAlgo.h:135
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughHadronCleanedCandidates_
the collection of punch-through cleaned neutral hadron candidates
Definition: PFMuonAlgo.h:141
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
virtual PFMuonAlgo::~PFMuonAlgo ( )
inlinevirtual

destructor

Definition at line 27 of file PFMuonAlgo.h.

27 {;}

Member Function Documentation

void PFMuonAlgo::addMissingMuons ( edm::Handle< reco::MuonCollection muons,
reco::PFCandidateCollection cands 
)

Definition at line 936 of file PFMuonAlgo.cc.

References dPhi(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, i, edm::Ref< C, T, F >::isNonnull(), reco::PFCandidate::mu, reco::PFCandidate::muonRef(), mathSSE::sqrt(), reco::PFCandidate::trackRef(), and testEve_cfg::tracks.

Referenced by PFAlgo::reconstructParticles().

936  {
937  if(!postCleaning_)
938  return;
939 
940 
941  if( pfAddedMuonCandidates_.get() )
942  pfAddedMuonCandidates_->clear();
943  else
945 
946 
947 
948  for ( unsigned imu = 0; imu < muons->size(); ++imu ) {
949  reco::MuonRef muonRef( muons, imu );
950  bool used = false;
951  bool hadron = false;
952  for(unsigned i=0; i<cands->size(); i++) {
953  const PFCandidate& pfc = cands->at(i);
954  if ( !pfc.trackRef().isNonnull() ) continue;
955  if ( pfc.trackRef().isNonnull() && pfc.trackRef() == muonRef->track() )
956  hadron = true;
957  if ( !pfc.muonRef().isNonnull() ) continue;
958 
959  if ( pfc.muonRef()->innerTrack() == muonRef->innerTrack())
960  used = true;
961  else {
962  // Check if the stand-alone muon is not a spurious copy of an existing muon
963  // (Protection needed for HLT)
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);
968  if ( dR < 0.005 ) {
969  used = true;
970  }
971  }
972  }
973 
974  if ( used ) break;
975  }
976 
977  if ( used ||hadron||(!muonRef.isNonnull()) ) continue;
978 
979 
980  TrackMETComparator comparator(METX_,METY_);
981  //Low pt dont need to be cleaned
982 
983  std::vector<reco::Muon::MuonTrackTypePair> tracks = goodMuonTracks(muonRef,true);
984  //If there is at least 1 track choice try to change the track
985  if(tracks.size()>0) {
986 
987  //Find tracks that change dramatically MET or Pt
988  std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksPointingAtMET(tracks);
989  //From those tracks get the one with smallest MET
990  if (tracksThatChangeMET.size()>0) {
991  reco::Muon::MuonTrackTypePair bestTrackType = *std::min_element(tracksThatChangeMET.begin(),tracksThatChangeMET.end(),comparator);
992 
993  //Make sure it is not cosmic
994  if((vertices_->size()==0) ||bestTrackType.first->dz(vertices_->at(0).position())<cosmicRejDistance_){
995 
996  //make a pfcandidate
997  int charge = bestTrackType.first->charge()>0 ? 1 : -1;
998  math::XYZTLorentzVector momentum(bestTrackType.first->px(),
999  bestTrackType.first->py(),
1000  bestTrackType.first->pz(),
1001  sqrt(bestTrackType.first->p()*bestTrackType.first->p()+0.1057*0.1057));
1002 
1003  cands->push_back( PFCandidate( charge,
1004  momentum,
1006 
1007  changeTrack(cands->back(),bestTrackType);
1008 
1009  if (muonRef->track().isNonnull() )
1010  cands->back().setTrackRef( muonRef->track() );
1011 
1012  cands->back().setMuonRef(muonRef);
1013 
1014 
1015  pfAddedMuonCandidates_->push_back(cands->back());
1016 
1017  }
1018  }
1019  }
1020  }
1021 }
int i
Definition: DBlmapReader.cc:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
std::vector< MuonTrackTypePair > tracksPointingAtMET(const std::vector< MuonTrackTypePair > &)
Definition: PFMuonAlgo.cc:1131
std::auto_ptr< reco::PFCandidateCollection > pfAddedMuonCandidates_
the collection of added muon candidates
Definition: PFMuonAlgo.h:143
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
double cosmicRejDistance_
Definition: PFMuonAlgo.h:178
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:48
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
Definition: PFMuonAlgo.cc:631
void changeTrack(reco::PFCandidate &, const MuonTrackTypePair &)
Definition: PFMuonAlgo.cc:768
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
tuple tracks
Definition: testEve_cfg.py:39
double METX_
Definition: PFMuonAlgo.h:181
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
const reco::VertexCollection * vertices_
Definition: PFMuonAlgo.h:149
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:40
bool postCleaning_
Definition: PFMuonAlgo.h:163
double METY_
Definition: PFMuonAlgo.h:182
void PFMuonAlgo::changeTrack ( reco::PFCandidate candidate,
const MuonTrackTypePair track 
)

Definition at line 768 of file PFMuonAlgo.cc.

References reco::Muon::CombinedTrack, reco::Muon::DYT, relval_parameters_module::energy, reco::Muon::InnerTrack, reco::PFCandidate::mu, reco::Muon::Picky, dt_dqm_sourceclient_common_cff::reco, reco::LeafCandidate::setCharge(), reco::PFCandidate::setMuonTrackType(), reco::LeafCandidate::setP4(), reco::PFCandidate::setParticleType(), reco::PFCandidate::setVertexSource(), mathSSE::sqrt(), and reco::Muon::TPFMS.

768  {
769  using namespace reco;
770  reco::TrackRef bestTrack = track.first;
771  MuonTrackType trackType = track.second;
772  //OK Now redefine the canddiate with that track
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);
777 
778  candidate.setCharge(bestTrack->charge()>0 ? 1 : -1);
779  candidate.setP4(math::XYZTLorentzVector(px,py,pz,energy));
781  // candidate.setTrackRef( bestTrack );
782  candidate.setMuonTrackType(trackType);
783  if(trackType == reco::Muon::InnerTrack)
784  candidate.setVertexSource( PFCandidate::kTrkMuonVertex );
785  else if(trackType == reco::Muon::CombinedTrack)
786  candidate.setVertexSource( PFCandidate::kComMuonVertex );
787  else if(trackType == reco::Muon::TPFMS)
788  candidate.setVertexSource( PFCandidate::kTPFMSMuonVertex );
789  else if(trackType == reco::Muon::Picky)
790  candidate.setVertexSource( PFCandidate::kPickyMuonVertex );
791  else if(trackType == reco::Muon::DYT)
792  candidate.setVertexSource( PFCandidate::kDYTMuonVertex );
793  }
virtual void setCharge(Charge q)
set electric charge
Definition: LeafCandidate.h:93
virtual void setP4(const LorentzVector &p4)
set 4-momentum
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
void setVertexSource(PFVertexType vt)
Definition: PFCandidate.h:406
void setMuonTrackType(const reco::Muon::MuonTrackType &type)
set the Best Muon Track Ref
Definition: PFCandidate.h:356
void setParticleType(ParticleType type)
set Particle Type
Definition: PFCandidate.cc:256
T sqrt(T t)
Definition: SSEVec.h:48
MuonTrackType
Definition: MuonTrackType.h:27
bool PFMuonAlgo::cleanMismeasured ( reco::PFCandidate pfc,
unsigned int  i 
)
private

Definition at line 1044 of file PFMuonAlgo.cc.

References reco::PFCandidate::muonRef(), reco::LeafCandidate::pt(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), dt_dqm_sourceclient_common_cff::reco, mathSSE::sqrt(), and testEve_cfg::tracks.

1044  {
1045  using namespace std;
1046  using namespace reco;
1047  bool cleaned=false;
1048 
1049  //First define the MET without this guy
1050  double METNOX = METX_ - pfc.px();
1051  double METNOY = METY_ - pfc.py();
1052  double SUMETNO = sumet_ -pfc.pt();
1053 
1054  TrackMETComparator comparator(METNOX,METNOY);
1055  //Low pt dont need to be cleaned
1056  if (pfc.pt()<minPostCleaningPt_)
1057  return false;
1058  std::vector<reco::Muon::MuonTrackTypePair> tracks = goodMuonTracks(pfc.muonRef(),false);
1059 
1060 
1061 
1062  //If there is more than 1 track choice try to change the track
1063  if(tracks.size()>1) {
1064  //Find tracks that change dramatically MET or Pt
1065  std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksWithBetterMET(tracks,pfc);
1066  //From those tracks get the one with smallest MET
1067  if (tracksThatChangeMET.size()>0) {
1068  reco::Muon::MuonTrackTypePair bestTrackType = *std::min_element(tracksThatChangeMET.begin(),tracksThatChangeMET.end(),comparator);
1069  changeTrack(pfc,bestTrackType);
1070 
1072  //update eventquantities
1073  METX_ = METNOX+pfc.px();
1074  METY_ = METNOY+pfc.py();
1075  sumet_=SUMETNO+pfc.pt();
1076 
1077  }
1078  }
1079 
1080  //Now attempt to kill it
1081  if (!(pfc.muonRef()->isGlobalMuon() && pfc.muonRef()->isTrackerMuon())) {
1082  //define MET significance and SUM ET
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_) &&
1089  pfFakeMuonCleanedCandidates_->push_back(pfc);
1090  maskedIndices_.push_back(i);
1091  METX_ = METNOX;
1092  METY_ = METNOY;
1093  sumet_=SUMETNO;
1094  cleaned=true;
1095  }
1096 
1097  }
1098  return cleaned;
1099 
1100 }
int i
Definition: DBlmapReader.cc:9
double sumet_
Definition: PFMuonAlgo.h:180
double eventFractionRejection_
Definition: PFMuonAlgo.h:169
double metSigForRejection_
Definition: PFMuonAlgo.h:167
double minPostCleaningPt_
Definition: PFMuonAlgo.h:164
std::auto_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:137
virtual double pt() const
transverse momentum
std::auto_ptr< reco::PFCandidateCollection > pfCleanedTrackerAndGlobalMuonCandidates_
the collection of tracker/global cleaned muon candidates
Definition: PFMuonAlgo.h:135
T sqrt(T t)
Definition: SSEVec.h:48
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
Definition: PFMuonAlgo.cc:631
void changeTrack(reco::PFCandidate &, const MuonTrackTypePair &)
Definition: PFMuonAlgo.cc:768
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
double metFactorRejection_
Definition: PFMuonAlgo.h:170
std::vector< unsigned int > maskedIndices_
Definition: PFMuonAlgo.h:145
virtual double px() const
x coordinate of momentum vector
tuple tracks
Definition: testEve_cfg.py:39
double METX_
Definition: PFMuonAlgo.h:181
double sumetPU_
Definition: PFMuonAlgo.h:161
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:40
std::vector< MuonTrackTypePair > tracksWithBetterMET(const std::vector< MuonTrackTypePair > &, const reco::PFCandidate &)
Definition: PFMuonAlgo.cc:1103
virtual double py() const
y coordinate of momentum vector
double METY_
Definition: PFMuonAlgo.h:182
bool PFMuonAlgo::cleanPunchThroughAndFakes ( reco::PFCandidate pfc,
reco::PFCandidateCollection cands,
unsigned int  imu 
)
private

Definition at line 1155 of file PFMuonAlgo.cc.

References reco::PFCandidate::elementsInBlocks(), reco::LeafCandidate::eta(), reco::PFCandidate::h, reco::PFCandidate::h0, i, edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::key(), bookConverter::max, reco::PFCandidate::muonRef(), reco::LeafCandidate::p(), reco::PFCandidate::particleId(), reco::LeafCandidate::pt(), reco::PFCandidate::rawEcalEnergy(), reco::PFCandidate::rawHcalEnergy(), dt_dqm_sourceclient_common_cff::reco, and edm::second().

1155  {
1156  using namespace reco;
1157 
1158  bool cleaned=false;
1159 
1160  if (pfc.pt()<minPostCleaningPt_)
1161  return false;
1162 
1163 
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_;
1168  bool fake1=false;
1169 
1170  std::pair<double,double> met2 = getMinMaxMET2(pfc);
1171 
1172  //Check for Fakes at high pseudorapidity
1173  if(pfc.muonRef()->standAloneMuon().isNonnull())
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_;
1178 
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 );
1181 
1182  bool punchthrough =pfc.p() > minPunchThroughMomentum_ &&
1184  pfc.rawEcalEnergy()+pfc.rawHcalEnergy() > pfc.p()/punchThroughFactor_ &&
1185  !isIsolatedMuon(pfc.muonRef()) && MET2NO < MET2/punchThroughMETFactor_;
1186 
1187 
1188  if(fake1 || fake2||punchthrough) {
1189  // Find the block of the muon
1190  const PFCandidate::ElementsInBlocks& eleInBlocks = pfc.elementsInBlocks();
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;
1196 
1197  // Check if the muon gave rise to a neutral hadron
1198  double iHad = 1E9;
1199  bool hadron = false;
1200  for ( unsigned i = imu+1; i < cands->size(); ++i ) {
1201  const PFCandidate& pfcn = cands->at(i);
1202  const PFCandidate::ElementsInBlocks& ele = pfcn.elementsInBlocks();
1203  if ( !ele.size() ) {
1204  continue;
1205  }
1206  PFBlockRef blockRefHadron = ele[0].first;
1207  unsigned indexHadron = ele[0].second;
1208  // We are out of the block -> exit the loop
1209  if ( blockRefHadron.key() != blockRefMuon.key() ) break;
1210  // Check that this particle is a neutral hadron
1211  if ( indexHadron == indexMuon &&
1212  pfcn.particleId() == reco::PFCandidate::h0 ) {
1213  iHad = i;
1214  hadron = true;
1215  }
1216  if ( hadron ) break;
1217  }
1218 
1219  if ( hadron ) {
1220 
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));
1228  cands->at(imu).setParticleType(reco::PFCandidate::h);
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();
1233 
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));
1240  cleaned=true;
1241  }
1242  }
1243  }
1244  return cleaned;
1245 }
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:224
double punchThroughMETFactor_
Definition: PFMuonAlgo.h:177
int i
Definition: DBlmapReader.cc:9
virtual double p() const
magnitude of momentum vector
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughMuonCleanedCandidates_
the collection of punch-through cleaned muon candidates
Definition: PFMuonAlgo.h:139
double metFactorHighEta_
Definition: PFMuonAlgo.h:171
double sumet_
Definition: PFMuonAlgo.h:180
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
double minPunchThroughMomentum_
Definition: PFMuonAlgo.h:174
double minPunchThroughEnergy_
Definition: PFMuonAlgo.h:175
double rawEcalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:224
double metFactorFake_
Definition: PFMuonAlgo.h:173
key_type key() const
Accessor for product key.
Definition: Ref.h:266
double minPostCleaningPt_
Definition: PFMuonAlgo.h:164
std::auto_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:137
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:386
U second(std::pair< T, U > const &p)
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughHadronCleanedCandidates_
the collection of punch-through cleaned neutral hadron candidates
Definition: PFMuonAlgo.h:141
double punchThroughFactor_
Definition: PFMuonAlgo.h:176
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
double ptFactorHighEta_
Definition: PFMuonAlgo.h:172
std::vector< unsigned int > maskedIndices_
Definition: PFMuonAlgo.h:145
double METX_
Definition: PFMuonAlgo.h:181
std::pair< double, double > getMinMaxMET2(const reco::PFCandidate &)
Definition: PFMuonAlgo.cc:1024
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
double sumetPU_
Definition: PFMuonAlgo.h:161
virtual ParticleType particleId() const
Definition: PFCandidate.h:373
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:682
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:234
double METY_
Definition: PFMuonAlgo.h:182
void PFMuonAlgo::estimateEventQuantities ( const reco::PFCandidateCollection pfc)
private

Definition at line 806 of file PFMuonAlgo.cc.

References i.

807 {
808  //SUM ET
809  sumetPU_ = 0.0;
810  METX_=0.;
811  METY_=0.;
812  sumet_=0.0;
813  for(reco::PFCandidateCollection::const_iterator i = pfc->begin();i!=pfc->end();++i) {
814  sumet_+=i->pt();
815  METX_+=i->px();
816  METY_+=i->py();
817  }
818 
819 }
int i
Definition: DBlmapReader.cc:9
double sumet_
Definition: PFMuonAlgo.h:180
double METX_
Definition: PFMuonAlgo.h:181
double sumetPU_
Definition: PFMuonAlgo.h:161
double METY_
Definition: PFMuonAlgo.h:182
std::pair< double, double > PFMuonAlgo::getMinMaxMET2 ( const reco::PFCandidate pfc)
private

Definition at line 1024 of file PFMuonAlgo.cc.

References i, reco::PFCandidate::muonRef(), funct::pow(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), and testEve_cfg::tracks.

1024  {
1025  std::vector<reco::Muon::MuonTrackTypePair> tracks = goodMuonTracks((pfc.muonRef()),true);
1026 
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));
1032  }
1033 
1034  //PROTECT for cases of only one track. If there is only one track it will crash .
1035  //Has never happened but could likely happen!
1036 
1037  if(tracks.size()>1)
1038  return std::make_pair(*std::min_element(met2.begin(),met2.end()),*std::max_element(met2.begin(),met2.end()));
1039  else
1040  return std::make_pair(0,0);
1041 }
int i
Definition: DBlmapReader.cc:9
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
Definition: PFMuonAlgo.cc:631
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
virtual double px() const
x coordinate of momentum vector
tuple tracks
Definition: testEve_cfg.py:39
double METX_
Definition: PFMuonAlgo.h:181
virtual double py() const
y coordinate of momentum vector
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double METY_
Definition: PFMuonAlgo.h:182
reco::Muon::MuonTrackTypePair PFMuonAlgo::getTrackWithSmallestError ( const std::vector< MuonTrackTypePair > &  tracks)
private

Definition at line 797 of file PFMuonAlgo.cc.

References MCScenario_CRAFT1_22X::sorter().

797  {
798  TrackPtErrorSorter sorter;
799  return *std::min_element(tracks.begin(),tracks.end(),sorter);
800 }
tuple tracks
Definition: testEve_cfg.py:39
std::vector< reco::Muon::MuonTrackTypePair > PFMuonAlgo::goodMuonTracks ( const reco::MuonRef muon,
bool  includeSA = false 
)
private

Definition at line 631 of file PFMuonAlgo.cc.

631  {
632  return muonTracks(muon,includeSA,maxDPtOPt_);
633 }
double maxDPtOPt_
Definition: PFMuonAlgo.h:154
std::vector< reco::Muon::MuonTrackTypePair > muonTracks(const reco::MuonRef &muon, bool includeSA=false, double dpt=1e+9)
Definition: PFMuonAlgo.cc:637
static bool PFMuonAlgo::hasValidTracks ( const reco::MuonRef )
static
bool PFMuonAlgo::isGlobalLooseMuon ( const reco::PFBlockElement elt)
static

Definition at line 198 of file PFMuonAlgo.cc.

References assert(), and reco::PFBlockElementTrack::muonRef().

198  {
199 
200  const reco::PFBlockElementTrack* eltTrack
201  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
202 
203  assert ( eltTrack );
204  reco::MuonRef muonRef = eltTrack->muonRef();
205 
206  return isGlobalLooseMuon(muonRef);
207 
208 }
assert(m_qm.get())
static bool isGlobalLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:198
const reco::MuonRef & muonRef() const
bool PFMuonAlgo::isGlobalLooseMuon ( const reco::MuonRef muonRef)
static

Definition at line 341 of file PFMuonAlgo.cc.

References muon::isGoodMuon(), edm::Ref< C, T, F >::isNonnull(), min(), HLT_25ns14e33_v1_cff::quality, query::result, and muon::TMLastStationAngTight.

341  {
342 
343  if ( !muonRef.isNonnull() ) return false;
344  if ( !muonRef->isGlobalMuon() ) return false;
345  if ( !muonRef->isStandAloneMuon() ) return false;
346 
347  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
348  reco::TrackRef combinedMu = muonRef->combinedMuon();
349  reco::TrackRef trackerMu = muonRef->track();
350 
351  unsigned nMuonHits =
352  standAloneMu->hitPattern().numberOfValidMuonDTHits() +
353  2*standAloneMu->hitPattern().numberOfValidMuonCSCHits();
354 
355  bool quality = false;
356 
357  if ( muonRef->isTrackerMuon() ){
358 
359  bool result = combinedMu->normalizedChi2() < 100.;
360 
361  bool laststation =
363 
364  int nMatches = muonRef->numberOfMatches();
365 
366  quality = laststation && nMuonHits > 12 && nMatches > 1;
367 
368  return result && quality;
369 
370  }
371  else{
372 
373  // Check the quality of the stand-alone muon :
374  // good chi**2 and large number of hits and good pt error
375  if ( nMuonHits <=15 ||
376  standAloneMu->normalizedChi2() > 10. ||
377  standAloneMu->ptError()/standAloneMu->pt() > 0.20 ) {
378  quality = false;
379  }
380  else {
381  // If the stand-alone muon is good, check the global muon
382  if ( combinedMu->normalizedChi2() > standAloneMu->normalizedChi2() ) {
383  // If the combined muon is worse than the stand-alone, it
384  // means that either the corresponding tracker track was not
385  // reconstructed, or that the sta muon comes from a late
386  // pion decay (hence with a momentum smaller than the track)
387  // Take the stand-alone muon only if its momentum is larger
388  // than that of the track
389 
390  // Note that here we even take the standAlone if it has a smaller pT, in contrast to GlobalTight
391  if(standAloneMu->pt() > trackerMu->pt() || combinedMu->normalizedChi2()<5.) quality = true;
392  }
393  else {
394  // If the combined muon is better (and good enough), take the
395  // global muon
396  if(combinedMu->ptError()/combinedMu->pt() < std::min(0.20,standAloneMu->ptError()/standAloneMu->pt()))
397  quality = true;
398 
399  }
400  }
401  }
402 
403 
404  return quality;
405 
406 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
tuple result
Definition: query.py:137
T min(T a, T b)
Definition: MathUtil.h:58
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
bool PFMuonAlgo::isGlobalTightMuon ( const reco::PFBlockElement elt)
static

Definition at line 185 of file PFMuonAlgo.cc.

References assert(), and reco::PFBlockElementTrack::muonRef().

185  {
186 
187  const reco::PFBlockElementTrack* eltTrack
188  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
189 
190  assert ( eltTrack );
191  reco::MuonRef muonRef = eltTrack->muonRef();
192 
193  return isGlobalTightMuon(muonRef);
194 
195 }
assert(m_qm.get())
static bool isGlobalTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:185
const reco::MuonRef & muonRef() const
bool PFMuonAlgo::isGlobalTightMuon ( const reco::MuonRef muonRef)
static

Definition at line 250 of file PFMuonAlgo.cc.

References muon::GlobalMuonPromptTight, muon::isGoodMuon(), edm::Ref< C, T, F >::isNonnull(), min(), HLT_25ns14e33_v1_cff::quality, query::result, and muon::TM2DCompatibilityTight.

250  {
251 
252  if ( !muonRef.isNonnull() ) return false;
253 
254  if ( !muonRef->isGlobalMuon() ) return false;
255  if ( !muonRef->isStandAloneMuon() ) return false;
256 
257 
258  if ( muonRef->isTrackerMuon() ) {
259 
261 
262  bool isTM2DCompatibilityTight = muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight);
263  int nMatches = muonRef->numberOfMatches();
264  bool quality = nMatches > 2 || isTM2DCompatibilityTight;
265 
266  return result && quality;
267 
268  } else {
269 
270  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
271 
272  // No tracker muon -> Request a perfect stand-alone muon, or an even better global muon
273  bool result = false;
274 
275  // Check the quality of the stand-alone muon :
276  // good chi**2 and large number of hits and good pt error
277  if ( ( standAloneMu->hitPattern().numberOfValidMuonDTHits() < 22 &&
278  standAloneMu->hitPattern().numberOfValidMuonCSCHits() < 15 ) ||
279  standAloneMu->normalizedChi2() > 10. ||
280  standAloneMu->ptError()/standAloneMu->pt() > 0.20 ) {
281  result = false;
282  } else {
283 
284  reco::TrackRef combinedMu = muonRef->combinedMuon();
285  reco::TrackRef trackerMu = muonRef->track();
286 
287  // If the stand-alone muon is good, check the global muon
288  if ( combinedMu->normalizedChi2() > standAloneMu->normalizedChi2() ) {
289  // If the combined muon is worse than the stand-alone, it
290  // means that either the corresponding tracker track was not
291  // reconstructed, or that the sta muon comes from a late
292  // pion decay (hence with a momentum smaller than the track)
293  // Take the stand-alone muon only if its momentum is larger
294  // than that of the track
295  result = standAloneMu->pt() > trackerMu->pt() ;
296  } else {
297  // If the combined muon is better (and good enough), take the
298  // global muon
299  result =
300  combinedMu->ptError()/combinedMu->pt() <
301  std::min(0.20,standAloneMu->ptError()/standAloneMu->pt());
302  }
303  }
304 
305  return result;
306  }
307 
308  return false;
309 
310 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
tuple result
Definition: query.py:137
T min(T a, T b)
Definition: MathUtil.h:58
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
bool PFMuonAlgo::isIsolatedMuon ( const reco::PFBlockElement elt)
static

Definition at line 224 of file PFMuonAlgo.cc.

References assert(), and reco::PFBlockElementTrack::muonRef().

Referenced by GreedyMuonPFCandidateFilter::filter(), and PFAlgo::processBlock().

224  {
225 
226  const reco::PFBlockElementTrack* eltTrack
227  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
228 
229  assert ( eltTrack );
230  reco::MuonRef muonRef = eltTrack->muonRef();
231 
232  return isIsolatedMuon(muonRef);
233 
234 }
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:224
assert(m_qm.get())
const reco::MuonRef & muonRef() const
bool PFMuonAlgo::isIsolatedMuon ( const reco::MuonRef muonRef)
static

Definition at line 432 of file PFMuonAlgo.cc.

References edm::Ref< C, T, F >::isNonnull().

432  {
433 
434 
435  if ( !muonRef.isNonnull() ) return false;
436  if ( !muonRef->isIsolationValid() ) return false;
437 
438  // Isolated Muons which are missed by standard cuts are nearly always global+tracker
439  if ( !muonRef->isGlobalMuon() ) return false;
440 
441  // If it's not a tracker muon, only take it if there are valid muon hits
442 
443  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
444 
445  if ( !muonRef->isTrackerMuon() ){
446  if(standAloneMu->hitPattern().numberOfValidMuonDTHits() == 0 &&
447  standAloneMu->hitPattern().numberOfValidMuonCSCHits() ==0) return false;
448  }
449 
450  // for isolation, take the smallest pt available to reject fakes
451 
452  reco::TrackRef combinedMu = muonRef->combinedMuon();
453  double smallestMuPt = combinedMu->pt();
454 
455  if(standAloneMu->pt()<smallestMuPt) smallestMuPt = standAloneMu->pt();
456 
457  if(muonRef->isTrackerMuon())
458  {
459  reco::TrackRef trackerMu = muonRef->track();
460  if(trackerMu->pt() < smallestMuPt) smallestMuPt= trackerMu->pt();
461  }
462 
463  double sumPtR03 = muonRef->isolationR03().sumPt;
464 
465  double relIso = sumPtR03/smallestMuPt;
466 
467  if(relIso<0.1) return true;
468  else return false;
469 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool PFMuonAlgo::isLooseMuon ( const reco::PFBlockElement elt)
static

Definition at line 166 of file PFMuonAlgo.cc.

References assert(), muon::isLooseMuon(), and reco::PFBlockElementTrack::muonRef().

Referenced by GeneralTracksImporter::importToBlock(), and PFAlgo::processBlock().

166  {
167 
168 
169  const reco::PFBlockElementTrack* eltTrack
170  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
171 
172 
173 
174  assert ( eltTrack );
175 
176 
177  reco::MuonRef muonRef = eltTrack->muonRef();
178 
179 
180  return isLooseMuon(muonRef);
181 
182 }
assert(m_qm.get())
static bool isLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:166
const reco::MuonRef & muonRef() const
bool PFMuonAlgo::isLooseMuon ( const reco::MuonRef muonRef)
static

Definition at line 243 of file PFMuonAlgo.cc.

243  {
244 
245  return isGlobalLooseMuon(muonRef) || isTrackerLooseMuon(muonRef);
246 
247 }
static bool isTrackerLooseMuon(const reco::PFBlockElement &elt)
static bool isGlobalLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:198
bool PFMuonAlgo::isMuon ( const reco::PFBlockElement elt)
static

Definition at line 153 of file PFMuonAlgo.cc.

References assert(), reco::isMuon(), and reco::PFBlockElementTrack::muonRef().

Referenced by GeneralTracksImporter::importToBlock(), PFEGammaAlgo::isAMuon(), PFAlgo::processBlock(), and PFElectronAlgo::SetLinks().

153  {
154 
155  const reco::PFBlockElementTrack* eltTrack
156  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
157 
158  assert ( eltTrack );
159  reco::MuonRef muonRef = eltTrack->muonRef();
160 
161  return isMuon(muonRef);
162 
163 }
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:153
assert(m_qm.get())
const reco::MuonRef & muonRef() const
bool PFMuonAlgo::isMuon ( const reco::MuonRef muonRef)
static

Definition at line 237 of file PFMuonAlgo.cc.

237  {
238 
239  return isGlobalTightMuon(muonRef) || isTrackerTightMuon(muonRef) || isIsolatedMuon(muonRef);
240 }
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:224
static bool isGlobalTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:185
static bool isTrackerTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:211
bool PFMuonAlgo::isTightMuonPOG ( const reco::MuonRef muonRef)
static

Definition at line 472 of file PFMuonAlgo.cc.

References muon::GlobalMuonPromptTight, and muon::isGoodMuon().

472  {
473 
474  if(!muon::isGoodMuon(*muonRef,muon::GlobalMuonPromptTight)) return false;
475 
476  if(!muonRef->isTrackerMuon()) return false;
477 
478  if(muonRef->numberOfMatches()<2) return false;
479 
480  //const reco::TrackRef& combinedMuon = muonRef->combinedMuon();
481  const reco::TrackRef& combinedMuon = muonRef->globalTrack();
482 
483  if(combinedMuon->hitPattern().numberOfValidTrackerHits()<11) return false;
484 
485  if(combinedMuon->hitPattern().numberOfValidPixelHits()==0) return false;
486 
487  if(combinedMuon->hitPattern().numberOfValidMuonHits()==0) return false;
488 
489  return true;
490 
491 }
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
static bool PFMuonAlgo::isTrackerLooseMuon ( const reco::PFBlockElement elt)
static
bool PFMuonAlgo::isTrackerLooseMuon ( const reco::MuonRef muonRef)
static

Definition at line 410 of file PFMuonAlgo.cc.

References muon::AllArbitrated, muon::isGoodMuon(), edm::Ref< C, T, F >::isNonnull(), HLT_25ns14e33_v1_cff::quality, and muon::TMLastStationAngTight.

410  {
411 
412  if ( !muonRef.isNonnull() ) return false;
413  if(!muonRef->isTrackerMuon()) return false;
414 
415  reco::TrackRef trackerMu = muonRef->track();
416 
417  if(trackerMu->ptError()/trackerMu->pt() > 0.20) return false;
418 
419  // this doesn't seem to be necessary on the small samples looked at, but keep it around as insurance
420  if(trackerMu->pt()>20.) return false;
421 
422  bool isAllArbitrated = muon::isGoodMuon(*muonRef,muon::AllArbitrated);
423  bool isTMLastStationAngTight = muon::isGoodMuon(*muonRef,muon::TMLastStationAngTight);
424 
425  bool quality = isAllArbitrated && isTMLastStationAngTight;
426 
427  return quality;
428 
429 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
bool PFMuonAlgo::isTrackerTightMuon ( const reco::PFBlockElement elt)
static

Definition at line 211 of file PFMuonAlgo.cc.

References assert(), and reco::PFBlockElementTrack::muonRef().

211  {
212 
213  const reco::PFBlockElementTrack* eltTrack
214  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
215 
216  assert ( eltTrack );
217  reco::MuonRef muonRef = eltTrack->muonRef();
218 
219  return isTrackerTightMuon(muonRef);
220 
221 }
assert(m_qm.get())
const reco::MuonRef & muonRef() const
static bool isTrackerTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:211
bool PFMuonAlgo::isTrackerTightMuon ( const reco::MuonRef muonRef)
static

Definition at line 313 of file PFMuonAlgo.cc.

References muon::AllArbitrated, reco::TrackBase::hitPattern(), muon::isGoodMuon(), edm::Ref< C, T, F >::isNonnull(), reco::HitPattern::numberOfValidTrackerHits(), and muon::TM2DCompatibilityTight.

313  {
314 
315  if ( !muonRef.isNonnull() ) return false;
316 
317  if(!muonRef->isTrackerMuon()) return false;
318 
319  reco::TrackRef trackerMu = muonRef->track();
320  const reco::Track& track = *trackerMu;
321 
322  unsigned nTrackerHits = track.hitPattern().numberOfValidTrackerHits();
323 
324  if(nTrackerHits<=12) return false;
325 
326  bool isAllArbitrated = muon::isGoodMuon(*muonRef,muon::AllArbitrated);
327 
328  bool isTM2DCompatibilityTight = muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight);
329 
330  if(!isAllArbitrated || !isTM2DCompatibilityTight) return false;
331 
332  if((trackerMu->ptError()/trackerMu->pt() > 0.10)){
333  //std::cout<<" PT ERROR > 10 % "<< trackerMu->pt() <<std::endl;
334  return false;
335  }
336  return true;
337 
338 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:384
int numberOfValidTrackerHits() const
Definition: HitPattern.h:739
std::vector< reco::Muon::MuonTrackTypePair > PFMuonAlgo::muonTracks ( const reco::MuonRef muon,
bool  includeSA = false,
double  dpt = 1e+9 
)
private

Definition at line 637 of file PFMuonAlgo.cc.

References reco::Muon::CombinedTrack, reco::Muon::DYT, reco::Muon::InnerTrack, edm::Ref< C, T, F >::isNonnull(), dbtoconf::out, reco::Muon::OuterTrack, reco::Muon::Picky, and reco::Muon::TPFMS.

637  {
638 
639 
640 
641  std::vector<reco::Muon::MuonTrackTypePair> out;
642 
643 
644  if(muon->globalTrack().isNonnull() && muon->globalTrack()->pt()>0)
645  if(muon->globalTrack()->ptError()/muon->globalTrack()->pt()<dpt)
646  out.push_back(std::make_pair(muon->globalTrack(),reco::Muon::CombinedTrack));
647 
648  if(muon->innerTrack().isNonnull() && muon->innerTrack()->pt()>0)
649  if(muon->innerTrack()->ptError()/muon->innerTrack()->pt()<dpt)//Here Loose!@
650  out.push_back(std::make_pair(muon->innerTrack(),reco::Muon::InnerTrack));
651 
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();
656  if(pickyDpt<dpt)
657  out.push_back(std::make_pair(muon->pickyTrack(),reco::Muon::Picky));
658  pickyExists=true;
659  }
660 
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();
665  if(dytDpt<dpt)
666  out.push_back(std::make_pair(muon->dytTrack(),reco::Muon::DYT));
667  dytExists=true;
668  }
669 
670  //Magic: TPFMS is not a really good track especially under misalignment
671  //IT is kind of crap because if mu system is displaced it can make a change
672  //So allow TPFMS if there is no picky or the error of tpfms is better than picky
673  //AND if there is no DYT or the error of tpfms is better than DYT
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) ) &&
678  tpfmsDpt<dpt )
679  out.push_back(std::make_pair(muon->tpfmsTrack(),reco::Muon::TPFMS));
680  }
681 
682  if(includeSA && muon->outerTrack().isNonnull())
683  if(muon->outerTrack()->ptError()/muon->outerTrack()->pt()<dpt)
684  out.push_back(std::make_pair(muon->outerTrack(),reco::Muon::OuterTrack));
685 
686  return out;
687 
688 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
tuple out
Definition: dbtoconf.py:99
void PFMuonAlgo::postClean ( reco::PFCandidateCollection cands)

Definition at line 825 of file PFMuonAlgo.cc.

References reco::PFCandidate::h, i, edm::Ref< C, T, F >::isNonnull(), reco::PFCandidate::mu, reco::PFCandidate::muonRef(), patZpeak::muons, reco::LeafCandidate::p(), reco::PFCandidate::particleId(), reco::LeafCandidate::pt(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::PFCandidate::rawHcalEnergy(), dt_dqm_sourceclient_common_cff::reco, python.multivaluedict::sort(), and reco::PFCandidate::trackRef().

Referenced by PFAlgo::reconstructParticles().

825  {
826  using namespace std;
827  using namespace reco;
828  if (!postCleaning_)
829  return;
830 
831  //Initialize vectors
832 
835  else
837 
840  else
842 
843  if( pfFakeMuonCleanedCandidates_.get() )
845  else
847 
848 
851  else
853 
856  else
858 
859 
860 
862 
863  maskedIndices_.clear();
864 
865  //Estimate MET and SumET
866 
868 
869 
870  std::vector<int> muons;
871  std::vector<int> cosmics;
872  //get the muons
873  for(unsigned int i=0;i<cands->size();++i) {
874  const reco::PFCandidate& cand = (*cands)[i];
875  if ( cand.particleId() == reco::PFCandidate::mu )
876  muons.push_back(i);
877  else if ( cand.particleId() == reco::PFCandidate::h && cand.muonRef().isNonnull()) {
878  //MET cleaning for muons that are not high purity and became charged hadrons
879  if (cand.pt()>100.0 && (!cand.trackRef()->quality(trackQuality_)) && cand.muonRef()->isGlobalMuon() && cand.rawHcalEnergy()<0.05*cand.p()) {
880  maskedIndices_.push_back(i);
881  pfPunchThroughMuonCleanedCandidates_->push_back(cand);
882  }
883  }
884 
885  }
886  //Then sort the muon indicess by decsending pt
887 
888  IndexPtComparator comparator(cands);
889  std::sort(muons.begin(),muons.end(),comparator);
890 
891 
892  //first kill cosmics
893  double METXCosmics=0;
894  double METYCosmics=0;
895  double SUMETCosmics=0.0;
896 
897  for(unsigned int i=0;i<muons.size();++i) {
898  const PFCandidate& pfc = cands->at(muons[i]);
899  double origin=0.0;
900  if(vertices_->size()>0&& vertices_->at(0).isValid() && ! vertices_->at(0).isFake())
901  origin = pfc.muonRef()->muonBestTrack()->dxy(vertices_->at(0).position());
902 
903  if( origin> cosmicRejDistance_) {
904  cosmics.push_back(muons[i]);
905  METXCosmics +=pfc.px();
906  METYCosmics +=pfc.py();
907  SUMETCosmics +=pfc.pt();
908  }
909  }
910  double MET2Cosmics = METXCosmics*METXCosmics+METYCosmics*METYCosmics;
911 
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]));
916  }
917 
918  //Loop on the muons candidates and clean
919  for(unsigned int i=0;i<muons.size();++i) {
920  if( cleanMismeasured(cands->at(muons[i]),muons[i]))
921  continue;
922  cleanPunchThroughAndFakes(cands->at(muons[i]),cands,muons[i]);
923 
924  }
925 
926 
927 
928  //OK Now do the hard job ->remove the candidates that were cleaned
930 
931 
932 
933 
934 }
int i
Definition: DBlmapReader.cc:9
bool cleanMismeasured(reco::PFCandidate &, unsigned int)
Definition: PFMuonAlgo.cc:1044
virtual double p() const
magnitude of momentum vector
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughMuonCleanedCandidates_
the collection of punch-through cleaned muon candidates
Definition: PFMuonAlgo.h:139
double sumet_
Definition: PFMuonAlgo.h:180
void removeDeadCandidates(reco::PFCandidateCollection *, const std::vector< unsigned int > &)
Definition: PFMuonAlgo.cc:1248
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
double eventFactorCosmics_
Definition: PFMuonAlgo.h:165
bool cleanPunchThroughAndFakes(reco::PFCandidate &, reco::PFCandidateCollection *, unsigned int)
Definition: PFMuonAlgo.cc:1155
std::auto_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:137
virtual double pt() const
transverse momentum
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
std::auto_ptr< reco::PFCandidateCollection > pfCosmicsMuonCleanedCandidates_
the collection of cosmics cleaned muon candidates
Definition: PFMuonAlgo.h:133
std::auto_ptr< reco::PFCandidateCollection > pfCleanedTrackerAndGlobalMuonCandidates_
the collection of tracker/global cleaned muon candidates
Definition: PFMuonAlgo.h:135
double cosmicRejDistance_
Definition: PFMuonAlgo.h:178
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughHadronCleanedCandidates_
the collection of punch-through cleaned neutral hadron candidates
Definition: PFMuonAlgo.h:141
void estimateEventQuantities(const reco::PFCandidateCollection *)
Definition: PFMuonAlgo.cc:806
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::vector< unsigned int > maskedIndices_
Definition: PFMuonAlgo.h:145
reco::TrackBase::TrackQuality trackQuality_
Definition: PFMuonAlgo.h:157
virtual double px() const
x coordinate of momentum vector
double METX_
Definition: PFMuonAlgo.h:181
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
tuple muons
Definition: patZpeak.py:38
double sumetPU_
Definition: PFMuonAlgo.h:161
const reco::VertexCollection * vertices_
Definition: PFMuonAlgo.h:149
virtual ParticleType particleId() const
Definition: PFCandidate.h:373
virtual double py() const
y coordinate of momentum vector
bool postCleaning_
Definition: PFMuonAlgo.h:163
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:234
double METY_
Definition: PFMuonAlgo.h:182
void PFMuonAlgo::printMuonProperties ( const reco::MuonRef muonRef)
static

Definition at line 494 of file PFMuonAlgo.cc.

References runregparse::combined, gather_cfg::cout, delta, reco::TrackBase::hitPattern(), muon::isGoodMuon(), edm::Ref< C, T, F >::isNonnull(), bookConverter::max, min(), reco::HitPattern::numberOfValidTrackerHits(), mathSSE::sqrt(), muon::TM2DCompatibilityLoose, muon::TM2DCompatibilityTight, muon::TMLastStationAngLoose, muon::TMLastStationAngTight, muon::TMLastStationLoose, muon::TMLastStationOptimizedBarrelLowPtLoose, muon::TMLastStationOptimizedBarrelLowPtTight, muon::TMLastStationOptimizedLowPtLoose, muon::TMLastStationOptimizedLowPtTight, muon::TMLastStationTight, muon::TMOneStationLoose, muon::TMOneStationTight, and patCandidatesForDimuonsSequences_cff::tracker.

494  {
495 
496  if ( !muonRef.isNonnull() ) return;
497 
498  bool isGL = muonRef->isGlobalMuon();
499  bool isTR = muonRef->isTrackerMuon();
500  bool isST = muonRef->isStandAloneMuon();
501 
502  std::cout<<" GL: "<<isGL<<" TR: "<<isTR<<" ST: "<<isST<<std::endl;
503  std::cout<<" nMatches "<<muonRef->numberOfMatches()<<std::endl;
504 
505  if ( muonRef->isGlobalMuon() ){
506  reco::TrackRef combinedMu = muonRef->combinedMuon();
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;
518 
519  std::cout<<" # of Valid Tracker Hits "<<combinedMu->hitPattern().numberOfValidTrackerHits()<<std::endl;
520  std::cout<<" # of Valid Pixel Hits "<<combinedMu->hitPattern().numberOfValidPixelHits()<<std::endl;
521  }
522  if ( muonRef->isStandAloneMuon() ){
523  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
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;
534  }
535 
536 
537  if ( muonRef->isTrackerMuon() ){
538  reco::TrackRef trackerMu = muonRef->track();
539  const reco::Track& track = *trackerMu;
540  std::cout<<" TR, pt: " << trackerMu->pt()
541  << " +/- " << trackerMu->ptError()/trackerMu->pt()
542  << " chi**2 TR : " << trackerMu->normalizedChi2()<<std::endl;
543  std::cout<<" nTrackerHits "<<track.hitPattern().numberOfValidTrackerHits()<<std::endl;
544  std::cout<< "TMLastStationAngLoose "
545  << muon::isGoodMuon(*muonRef,muon::TMLastStationAngLoose) << std::endl
546  << "TMLastStationAngTight "
547  << muon::isGoodMuon(*muonRef,muon::TMLastStationAngTight) << std::endl
548  << "TMLastStationLoose "
549  << muon::isGoodMuon(*muonRef,muon::TMLastStationLoose) << std::endl
550  << "TMLastStationTight "
551  << muon::isGoodMuon(*muonRef,muon::TMLastStationTight) << std::endl
552  << "TMOneStationLoose "
553  << muon::isGoodMuon(*muonRef,muon::TMOneStationLoose) << std::endl
554  << "TMOneStationTight "
555  << muon::isGoodMuon(*muonRef,muon::TMOneStationTight) << std::endl
556  << "TMLastStationOptimizedLowPtLoose "
558  << "TMLastStationOptimizedLowPtTight "
560  << "TMLastStationOptimizedBarrelLowPtLoose "
562  << "TMLastStationOptimizedBarrelLowPtTight "
564  << std::endl;
565 
566  }
567 
568  std::cout<< "TM2DCompatibilityLoose "
569  << muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityLoose) << std::endl
570  << "TM2DCompatibilityTight "
571  << muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight) << std::endl;
572 
573 
574 
575  if ( muonRef->isGlobalMuon() && muonRef->isTrackerMuon() && muonRef->isStandAloneMuon() ){
576  reco::TrackRef combinedMu = muonRef->combinedMuon();
577  reco::TrackRef trackerMu = muonRef->track();
578  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
579 
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());
583 
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;
587 
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.;
597 
598  double delta =
599  standAloneMu->hitPattern().numberOfValidMuonDTHits()+
600  standAloneMu->hitPattern().numberOfValidMuonCSCHits() > 0 ?
601  std::min(delta3,std::min(delta1,delta2)) : std::max(delta3,std::max(delta1,delta2));
602 
603  std::cout << "delta = " << delta << " delta1 "<<delta1<<" delta2 "<<delta2<<" delta3 "<<delta3<<std::endl;
604 
605  double ratio =
606  combinedMu->ptError()/combinedMu->pt()
607  / (trackerMu->ptError()/trackerMu->pt());
608  //if ( ratio > 2. && delta < 3. ) std::cout << "ALARM ! " << ratio << ", " << delta << std::endl;
609  std::cout<<" ratio "<<ratio<<" combined mu pt "<<combinedMu->pt()<<std::endl;
610  //bool quality3 = ( combinedMu->pt() < 50. || ratio < 2. ) && delta < 3.;
611 
612 
613  }
614 
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;
625  return;
626 
627 }
dbl * delta
Definition: mlp_gen.cc:36
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
T sqrt(T t)
Definition: SSEVec.h:48
T min(T a, T b)
Definition: MathUtil.h:58
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:384
int numberOfValidTrackerHits() const
Definition: HitPattern.h:739
tuple cout
Definition: gather_cfg.py:121
bool PFMuonAlgo::reconstructMuon ( reco::PFCandidate candidate,
const reco::MuonRef muon,
bool  allowLoose = false 
)

Definition at line 699 of file PFMuonAlgo.cc.

References reco::Muon::InnerTrack, muon::isLooseMuon(), reco::isMuon(), edm::Ref< C, T, F >::isNonnull(), dt_dqm_sourceclient_common_cff::reco, reco::PFCandidate::setMuonRef(), and muon::tevOptimized().

Referenced by PFAlgo::reconstructTrack().

699  {
700  using namespace std;
701  using namespace reco;
702 
703  if (!muon.isNonnull())
704  return false;
705 
706 
707 
708  bool isMu=false;
709 
710  if(allowLoose)
711  isMu = isMuon(muon) || isLooseMuon(muon);
712  else
713  isMu = isMuon(muon);
714 
715  if( !isMu)
716  return false;
717 
718  //get the valid tracks(without standalone except we allow loose muons)
719  //MIKE: Here we need to be careful. If we have a muon inside a dense
720  //jet environment often the track is badly measured. In this case
721  //we should not apply Dpt/Pt<1
722 
723  std::vector<reco::Muon::MuonTrackTypePair> validTracks = goodMuonTracks(muon);
724  if (!allowLoose)
725  validTracks = goodMuonTracks(muon);
726  else
727  validTracks = muonTracks(muon);
728 
729  if( validTracks.size() ==0)
730  return false;
731 
732 
733 
734  //check what is the track used.Rerun TuneP
735  reco::Muon::MuonTrackTypePair bestTrackPair = muon::tevOptimized(*muon);
736 
737  TrackRef bestTrack = bestTrackPair.first;
738  MuonTrackType trackType = bestTrackPair.second;
739 
740 
741 
742  MuonTrackTypePair trackPairWithSmallestError = getTrackWithSmallestError(validTracks);
743  TrackRef trackWithSmallestError = trackPairWithSmallestError.first;
744 
745  if( trackType == reco::Muon::InnerTrack &&
746  (!bestTrack->quality(trackQuality_) ||
747  bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt() )) {
748  bestTrack = trackWithSmallestError;
749  trackType = trackPairWithSmallestError.second;
750  }
751  else if (trackType != reco::Muon::InnerTrack &&
752  bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt()) {
753  bestTrack = trackWithSmallestError;
754  trackType = trackPairWithSmallestError.second;
755 
756  }
757 
758 
759  changeTrack(candidate,std::make_pair(bestTrack,trackType));
760  candidate.setMuonRef( muon );
761 
762  return true;
763 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:153
reco::Muon::MuonTrackTypePair MuonTrackTypePair
Definition: PFMuonAlgo.h:14
MuonTrackTypePair getTrackWithSmallestError(const std::vector< MuonTrackTypePair > &)
Definition: PFMuonAlgo.cc:797
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)
Definition: MuonCocktails.cc:9
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
Definition: PFMuonAlgo.cc:631
void changeTrack(reco::PFCandidate &, const MuonTrackTypePair &)
Definition: PFMuonAlgo.cc:768
reco::TrackBase::TrackQuality trackQuality_
Definition: PFMuonAlgo.h:157
static bool isLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:166
void setMuonRef(const reco::MuonRef &ref)
set muon reference
Definition: PFCandidate.cc:436
double errorCompScale_
Definition: PFMuonAlgo.h:159
MuonTrackType
Definition: MuonTrackType.h:27
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:40
std::vector< reco::Muon::MuonTrackTypePair > muonTracks(const reco::MuonRef &muon, bool includeSA=false, double dpt=1e+9)
Definition: PFMuonAlgo.cc:637
void PFMuonAlgo::removeDeadCandidates ( reco::PFCandidateCollection obj,
const std::vector< unsigned int > &  indices 
)
private

Definition at line 1248 of file PFMuonAlgo.cc.

References i, and N.

1249 {
1250  size_t N = indices.size();
1251  size_t collSize = obj->size();
1252 
1253  for (size_t i = 0 ; i < N ; ++i)
1254  obj->at(indices.at(i)) = obj->at(collSize-i-1);
1255 
1256  obj->resize(collSize - indices.size());
1257 }
int i
Definition: DBlmapReader.cc:9
#define N
Definition: blowfish.cc:9
void PFMuonAlgo::setInputsForCleaning ( const reco::VertexCollection vertices)

Definition at line 1151 of file PFMuonAlgo.cc.

References HLT_25ns14e33_v1_cff::vertices.

Referenced by PFAlgo::setPFVertexParameters().

1151  {
1152  vertices_ = vertices;
1153 }
const reco::VertexCollection * vertices_
Definition: PFMuonAlgo.h:149
void PFMuonAlgo::setParameters ( const edm::ParameterSet iConfig)

Definition at line 29 of file PFMuonAlgo.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), reco::TrackBase::qualityByName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by PFAlgo::setPFMuonAndFakeParameters().

30 {
31 
32  if(iConfig.exists("maxDPtOPt"))
33  maxDPtOPt_ = iConfig.getParameter<double>("maxDPtOPt");
34  else
35  maxDPtOPt_=1.0;
36 
37  if(iConfig.exists("minTrackerHits"))
38  minTrackerHits_ = iConfig.getParameter<int>("minTrackerHits");
39  else
40  minTrackerHits_ = 8;
41 
42  if(iConfig.exists("minPixelHits"))
43  minPixelHits_ = iConfig.getParameter<int>("minPixelHits");
44  else
45  minPixelHits_ = 1;
46 
47  if(iConfig.exists("trackQuality"))
49  else
51 
52  if(iConfig.exists("ptErrorScale"))
53  errorCompScale_ = iConfig.getParameter<double>("ptErrorScale");
54  else
55  errorCompScale_ = 4.;
56 
57  if(iConfig.exists("eventFractionForCleaning"))
58  eventFractionCleaning_ = iConfig.getParameter<double>("eventFractionForCleaning");
59  else
61 
62  if(iConfig.exists("dzPV"))
63  dzPV_ = iConfig.getParameter<double>("dzPV");
64  else
65  dzPV_ = 0.2;
66 
67  if(iConfig.exists("postMuonCleaning"))
68  postCleaning_ = iConfig.getParameter<bool>("postMuonCleaning");
69  else
70  postCleaning_ = false; //Disable by default (for HLT)
71 
72  if(iConfig.exists("minPtForPostCleaning"))
73  minPostCleaningPt_ = iConfig.getParameter<double>("minPtForPostCleaning");
74  else
75  minPostCleaningPt_ = 20.;
76 
77  if(iConfig.exists("eventFactorForCosmics"))
78  eventFactorCosmics_ = iConfig.getParameter<double>("eventFactorForCosmics");
79  else
80  eventFactorCosmics_ = 10.;
81 
82 
83  if(iConfig.exists("metSignificanceForCleaning"))
84  metSigForCleaning_ = iConfig.getParameter<double>("metSignificanceForCleaning");
85  else
86  metSigForCleaning_ = 3.;
87 
88  if(iConfig.exists("metSignificanceForRejection"))
89  metSigForRejection_ = iConfig.getParameter<double>("metSignificanceForRejection");
90  else
92 
93  if(iConfig.exists("metFactorForCleaning"))
94  metFactorCleaning_ = iConfig.getParameter<double>("metFactorForCleaning");
95  else
96  metFactorCleaning_ = 4.;
97 
98  if(iConfig.exists("eventFractionForRejection"))
99  eventFractionRejection_ = iConfig.getParameter<double>("eventFractionForRejection");
100  else
102 
103  if(iConfig.exists("metFactorForRejection"))
104  metFactorRejection_ = iConfig.getParameter<double>("metFactorForRejection");
105  else
107 
108  if(iConfig.exists("metFactorForHighEta"))
109  metFactorHighEta_ = iConfig.getParameter<double>("metFactorForHighEta");
110  else
112 
113  if(iConfig.exists("ptFactorForHighEta"))
114  ptFactorHighEta_ = iConfig.getParameter<double>("ptFactorForHighEta");
115  else
116  ptFactorHighEta_ = 2.;
117 
118  if(iConfig.exists("metFactorForFakes"))
119  metFactorFake_ = iConfig.getParameter<double>("metFactorForFakes");
120  else
121  metFactorFake_ = 4.;
122 
123  if(iConfig.exists("minMomentumForPunchThrough"))
124  minPunchThroughMomentum_ = iConfig.getParameter<double>("minMomentumForPunchThrough");
125  else
127 
128  if(iConfig.exists("minEnergyForPunchThrough"))
129  minPunchThroughEnergy_ = iConfig.getParameter<double>("minEnergyForPunchThrough");
130  else
131  minPunchThroughEnergy_ = 100.;
132 
133  if(iConfig.exists("punchThroughFactor"))
134  punchThroughFactor_ = iConfig.getParameter<double>("punchThroughFactor");
135  else
136  punchThroughFactor_ = 3.;
137 
138  if(iConfig.exists("punchThroughMETFactor"))
139  punchThroughMETFactor_ = iConfig.getParameter<double>("punchThroughMETFactor");
140  else
142 
143  if(iConfig.exists("cosmicRejectionDistance"))
144  cosmicRejDistance_ = iConfig.getParameter<double>("cosmicRejectionDistance");
145  else
146  cosmicRejDistance_ = 1.0;
147 }
T getParameter(std::string const &) const
double punchThroughMETFactor_
Definition: PFMuonAlgo.h:177
double metFactorHighEta_
Definition: PFMuonAlgo.h:171
double maxDPtOPt_
Definition: PFMuonAlgo.h:154
double minPunchThroughMomentum_
Definition: PFMuonAlgo.h:174
double minPunchThroughEnergy_
Definition: PFMuonAlgo.h:175
double eventFactorCosmics_
Definition: PFMuonAlgo.h:165
double metFactorFake_
Definition: PFMuonAlgo.h:173
double eventFractionCleaning_
Definition: PFMuonAlgo.h:160
bool exists(std::string const &parameterName) const
checks if a parameter exists
double metSigForCleaning_
Definition: PFMuonAlgo.h:166
double eventFractionRejection_
Definition: PFMuonAlgo.h:169
double metSigForRejection_
Definition: PFMuonAlgo.h:167
double minPostCleaningPt_
Definition: PFMuonAlgo.h:164
double cosmicRejDistance_
Definition: PFMuonAlgo.h:178
double dzPV_
Definition: PFMuonAlgo.h:162
double punchThroughFactor_
Definition: PFMuonAlgo.h:176
double ptFactorHighEta_
Definition: PFMuonAlgo.h:172
double metFactorCleaning_
Definition: PFMuonAlgo.h:168
double metFactorRejection_
Definition: PFMuonAlgo.h:170
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:108
reco::TrackBase::TrackQuality trackQuality_
Definition: PFMuonAlgo.h:157
double errorCompScale_
Definition: PFMuonAlgo.h:159
int minPixelHits_
Definition: PFMuonAlgo.h:156
int minTrackerHits_
Definition: PFMuonAlgo.h:155
bool postCleaning_
Definition: PFMuonAlgo.h:163
std::vector< reco::Muon::MuonTrackTypePair > PFMuonAlgo::tracksPointingAtMET ( const std::vector< MuonTrackTypePair > &  tracks)
private

Definition at line 1131 of file PFMuonAlgo.cc.

References i, and funct::pow().

1131  {
1132  std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1133 
1134 
1135  double newMET2=0.0;
1136 
1137  for( unsigned int i=0;i<tracks.size();++i) {
1138  //calculate new SUM ET and MET2
1139  newMET2 = pow(METX_+tracks.at(i).first->px(),2)+pow(METY_+tracks.at(i).first->py(),2);
1140 
1141  if(newMET2<(METX_*METX_+METY_*METY_)/metFactorCleaning_)
1142  outputTracks.push_back(tracks.at(i));
1143  }
1144 
1145 
1146  return outputTracks;
1147 }
int i
Definition: DBlmapReader.cc:9
double metFactorCleaning_
Definition: PFMuonAlgo.h:168
tuple tracks
Definition: testEve_cfg.py:39
double METX_
Definition: PFMuonAlgo.h:181
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double METY_
Definition: PFMuonAlgo.h:182
std::vector< reco::Muon::MuonTrackTypePair > PFMuonAlgo::tracksWithBetterMET ( const std::vector< MuonTrackTypePair > &  tracks,
const reco::PFCandidate pfc 
)
private

Definition at line 1103 of file PFMuonAlgo.cc.

References i, funct::pow(), reco::LeafCandidate::pt(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), and mathSSE::sqrt().

1103  {
1104  std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1105 
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_;
1110  double newMET2=0.0;
1111  double newSUMET=0.0;
1112  double METSIG = sqrt(MET2)/sqrt(sumet_-sumetPU_);
1113 
1114 
1115  if(METSIG>metSigForCleaning_)
1116  for( unsigned int i=0;i<tracks.size();++i) {
1117  //calculate new SUM ET and MET2
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);
1120 
1121  if(newSUMET/(sumet_-sumetPU_)>eventFractionCleaning_ && newMET2<MET2/metFactorCleaning_)
1122  outputTracks.push_back(tracks.at(i));
1123  }
1124 
1125 
1126  return outputTracks;
1127 }
int i
Definition: DBlmapReader.cc:9
double sumet_
Definition: PFMuonAlgo.h:180
double eventFractionCleaning_
Definition: PFMuonAlgo.h:160
double metSigForCleaning_
Definition: PFMuonAlgo.h:166
virtual double pt() const
transverse momentum
T sqrt(T t)
Definition: SSEVec.h:48
double metFactorCleaning_
Definition: PFMuonAlgo.h:168
virtual double px() const
x coordinate of momentum vector
tuple tracks
Definition: testEve_cfg.py:39
double METX_
Definition: PFMuonAlgo.h:181
double sumetPU_
Definition: PFMuonAlgo.h:161
virtual double py() const
y coordinate of momentum vector
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double METY_
Definition: PFMuonAlgo.h:182
std::auto_ptr<reco::PFCandidateCollection>& PFMuonAlgo::transferAddedMuonCandidates ( )
inline

Definition at line 101 of file PFMuonAlgo.h.

References pfAddedMuonCandidates_.

101  {
102  return pfAddedMuonCandidates_;
103  }
std::auto_ptr< reco::PFCandidateCollection > pfAddedMuonCandidates_
the collection of added muon candidates
Definition: PFMuonAlgo.h:143
std::auto_ptr<reco::PFCandidateCollection>& PFMuonAlgo::transferCleanedCosmicCandidates ( )
inline

Definition at line 81 of file PFMuonAlgo.h.

References pfCosmicsMuonCleanedCandidates_.

81  {
83  }
std::auto_ptr< reco::PFCandidateCollection > pfCosmicsMuonCleanedCandidates_
the collection of cosmics cleaned muon candidates
Definition: PFMuonAlgo.h:133
std::auto_ptr<reco::PFCandidateCollection>& PFMuonAlgo::transferCleanedFakeCandidates ( )
inline

Definition at line 89 of file PFMuonAlgo.h.

References pfFakeMuonCleanedCandidates_.

89  {
91  }
std::auto_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:137
std::auto_ptr<reco::PFCandidateCollection>& PFMuonAlgo::transferCleanedTrackerAndGlobalCandidates ( )
inline

Definition at line 85 of file PFMuonAlgo.h.

References pfCleanedTrackerAndGlobalMuonCandidates_.

85  {
87  }
std::auto_ptr< reco::PFCandidateCollection > pfCleanedTrackerAndGlobalMuonCandidates_
the collection of tracker/global cleaned muon candidates
Definition: PFMuonAlgo.h:135
std::auto_ptr<reco::PFCandidateCollection>& PFMuonAlgo::transferPunchThroughCleanedHadronCandidates ( )
inline

Definition at line 97 of file PFMuonAlgo.h.

References pfPunchThroughHadronCleanedCandidates_.

97  {
99  }
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughHadronCleanedCandidates_
the collection of punch-through cleaned neutral hadron candidates
Definition: PFMuonAlgo.h:141
std::auto_ptr<reco::PFCandidateCollection>& PFMuonAlgo::transferPunchThroughCleanedMuonCandidates ( )
inline

Definition at line 93 of file PFMuonAlgo.h.

References pfPunchThroughMuonCleanedCandidates_.

93  {
95  }
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughMuonCleanedCandidates_
the collection of punch-through cleaned muon candidates
Definition: PFMuonAlgo.h:139

Member Data Documentation

double PFMuonAlgo::cosmicRejDistance_
private

Definition at line 178 of file PFMuonAlgo.h.

double PFMuonAlgo::dzPV_
private

Definition at line 162 of file PFMuonAlgo.h.

double PFMuonAlgo::errorCompScale_
private

Definition at line 159 of file PFMuonAlgo.h.

double PFMuonAlgo::eventFactorCosmics_
private

Definition at line 165 of file PFMuonAlgo.h.

double PFMuonAlgo::eventFractionCleaning_
private

Definition at line 160 of file PFMuonAlgo.h.

double PFMuonAlgo::eventFractionRejection_
private

Definition at line 169 of file PFMuonAlgo.h.

std::vector<unsigned int > PFMuonAlgo::maskedIndices_
private

Definition at line 145 of file PFMuonAlgo.h.

double PFMuonAlgo::maxDPtOPt_
private

Definition at line 154 of file PFMuonAlgo.h.

double PFMuonAlgo::metFactorCleaning_
private

Definition at line 168 of file PFMuonAlgo.h.

double PFMuonAlgo::metFactorFake_
private

Definition at line 173 of file PFMuonAlgo.h.

double PFMuonAlgo::metFactorHighEta_
private

Definition at line 171 of file PFMuonAlgo.h.

double PFMuonAlgo::metFactorRejection_
private

Definition at line 170 of file PFMuonAlgo.h.

double PFMuonAlgo::metSigForCleaning_
private

Definition at line 166 of file PFMuonAlgo.h.

double PFMuonAlgo::metSigForRejection_
private

Definition at line 167 of file PFMuonAlgo.h.

double PFMuonAlgo::METX_
private

Definition at line 181 of file PFMuonAlgo.h.

double PFMuonAlgo::METY_
private

Definition at line 182 of file PFMuonAlgo.h.

int PFMuonAlgo::minPixelHits_
private

Definition at line 156 of file PFMuonAlgo.h.

double PFMuonAlgo::minPostCleaningPt_
private

Definition at line 164 of file PFMuonAlgo.h.

double PFMuonAlgo::minPunchThroughEnergy_
private

Definition at line 175 of file PFMuonAlgo.h.

double PFMuonAlgo::minPunchThroughMomentum_
private

Definition at line 174 of file PFMuonAlgo.h.

int PFMuonAlgo::minTrackerHits_
private

Definition at line 155 of file PFMuonAlgo.h.

std::auto_ptr< reco::PFCandidateCollection > PFMuonAlgo::pfAddedMuonCandidates_
private

the collection of added muon candidates

Definition at line 143 of file PFMuonAlgo.h.

Referenced by transferAddedMuonCandidates().

std::auto_ptr< reco::PFCandidateCollection > PFMuonAlgo::pfCleanedTrackerAndGlobalMuonCandidates_
private

the collection of tracker/global cleaned muon candidates

Definition at line 135 of file PFMuonAlgo.h.

Referenced by transferCleanedTrackerAndGlobalCandidates().

std::auto_ptr< reco::PFCandidateCollection > PFMuonAlgo::pfCosmicsMuonCleanedCandidates_
private

the collection of cosmics cleaned muon candidates

Definition at line 133 of file PFMuonAlgo.h.

Referenced by transferCleanedCosmicCandidates().

std::auto_ptr< reco::PFCandidateCollection > PFMuonAlgo::pfFakeMuonCleanedCandidates_
private

the collection of fake cleaned muon candidates

Definition at line 137 of file PFMuonAlgo.h.

Referenced by transferCleanedFakeCandidates().

std::auto_ptr< reco::PFCandidateCollection > PFMuonAlgo::pfPunchThroughHadronCleanedCandidates_
private

the collection of punch-through cleaned neutral hadron candidates

Definition at line 141 of file PFMuonAlgo.h.

Referenced by transferPunchThroughCleanedHadronCandidates().

std::auto_ptr< reco::PFCandidateCollection > PFMuonAlgo::pfPunchThroughMuonCleanedCandidates_
private

the collection of punch-through cleaned muon candidates

Definition at line 139 of file PFMuonAlgo.h.

Referenced by transferPunchThroughCleanedMuonCandidates().

bool PFMuonAlgo::postCleaning_
private

Definition at line 163 of file PFMuonAlgo.h.

double PFMuonAlgo::ptFactorHighEta_
private

Definition at line 172 of file PFMuonAlgo.h.

double PFMuonAlgo::punchThroughFactor_
private

Definition at line 176 of file PFMuonAlgo.h.

double PFMuonAlgo::punchThroughMETFactor_
private

Definition at line 177 of file PFMuonAlgo.h.

double PFMuonAlgo::sumet_
private

Definition at line 180 of file PFMuonAlgo.h.

double PFMuonAlgo::sumetPU_
private

Definition at line 161 of file PFMuonAlgo.h.

reco::TrackBase::TrackQuality PFMuonAlgo::trackQuality_
private

Definition at line 157 of file PFMuonAlgo.h.

const reco::VertexCollection* PFMuonAlgo::vertices_
private

Definition at line 149 of file PFMuonAlgo.h.