test
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 &)
 
bool hasValidTrack (const reco::MuonRef &muonRef, bool loose=false)
 
 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 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:144
std::auto_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:142
std::auto_ptr< reco::PFCandidateCollection > pfAddedMuonCandidates_
the collection of added muon candidates
Definition: PFMuonAlgo.h:148
std::auto_ptr< reco::PFCandidateCollection > pfCosmicsMuonCleanedCandidates_
the collection of cosmics cleaned muon candidates
Definition: PFMuonAlgo.h:138
std::auto_ptr< reco::PFCandidateCollection > pfCleanedTrackerAndGlobalMuonCandidates_
the collection of tracker/global cleaned muon candidates
Definition: PFMuonAlgo.h:140
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughHadronCleanedCandidates_
the collection of punch-through cleaned neutral hadron candidates
Definition: PFMuonAlgo.h:146
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 953 of file PFMuonAlgo.cc.

References RecoTauCleanerPlugins::charge, 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().

953  {
954  if(!postCleaning_)
955  return;
956 
957 
958  if( pfAddedMuonCandidates_.get() )
959  pfAddedMuonCandidates_->clear();
960  else
962 
963 
964 
965  for ( unsigned imu = 0; imu < muons->size(); ++imu ) {
966  reco::MuonRef muonRef( muons, imu );
967  bool used = false;
968  bool hadron = false;
969  for(unsigned i=0; i<cands->size(); i++) {
970  const PFCandidate& pfc = cands->at(i);
971  if ( !pfc.trackRef().isNonnull() ) continue;
972  if ( pfc.trackRef().isNonnull() && pfc.trackRef() == muonRef->track() )
973  hadron = true;
974  if ( !pfc.muonRef().isNonnull() ) continue;
975 
976  if ( pfc.muonRef()->innerTrack() == muonRef->innerTrack())
977  used = true;
978  else {
979  // Check if the stand-alone muon is not a spurious copy of an existing muon
980  // (Protection needed for HLT)
981  if ( pfc.muonRef()->isStandAloneMuon() && muonRef->isStandAloneMuon() ) {
982  double dEta = pfc.muonRef()->standAloneMuon()->eta() - muonRef->standAloneMuon()->eta();
983  double dPhi = pfc.muonRef()->standAloneMuon()->phi() - muonRef->standAloneMuon()->phi();
984  double dR = sqrt(dEta*dEta + dPhi*dPhi);
985  if ( dR < 0.005 ) {
986  used = true;
987  }
988  }
989  }
990 
991  if ( used ) break;
992  }
993 
994  if ( used ||hadron||(!muonRef.isNonnull()) ) continue;
995 
996 
997  TrackMETComparator comparator(METX_,METY_);
998  //Low pt dont need to be cleaned
999 
1000  std::vector<reco::Muon::MuonTrackTypePair> tracks = goodMuonTracks(muonRef,true);
1001  //If there is at least 1 track choice try to change the track
1002  if(tracks.size()>0) {
1003 
1004  //Find tracks that change dramatically MET or Pt
1005  std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksPointingAtMET(tracks);
1006  //From those tracks get the one with smallest MET
1007  if (tracksThatChangeMET.size()>0) {
1008  reco::Muon::MuonTrackTypePair bestTrackType = *std::min_element(tracksThatChangeMET.begin(),tracksThatChangeMET.end(),comparator);
1009 
1010  //Make sure it is not cosmic
1011  if((vertices_->size()==0) ||bestTrackType.first->dz(vertices_->at(0).position())<cosmicRejDistance_){
1012 
1013  //make a pfcandidate
1014  int charge = bestTrackType.first->charge()>0 ? 1 : -1;
1015  math::XYZTLorentzVector momentum(bestTrackType.first->px(),
1016  bestTrackType.first->py(),
1017  bestTrackType.first->pz(),
1018  sqrt(bestTrackType.first->p()*bestTrackType.first->p()+0.1057*0.1057));
1019 
1020  cands->push_back( PFCandidate( charge,
1021  momentum,
1023 
1024  changeTrack(cands->back(),bestTrackType);
1025 
1026  if (muonRef->track().isNonnull() )
1027  cands->back().setTrackRef( muonRef->track() );
1028 
1029  cands->back().setMuonRef(muonRef);
1030 
1031 
1032  pfAddedMuonCandidates_->push_back(cands->back());
1033 
1034  }
1035  }
1036  }
1037  }
1038 }
int i
Definition: DBlmapReader.cc:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
std::vector< MuonTrackTypePair > tracksPointingAtMET(const std::vector< MuonTrackTypePair > &)
Definition: PFMuonAlgo.cc:1148
std::auto_ptr< reco::PFCandidateCollection > pfAddedMuonCandidates_
the collection of added muon candidates
Definition: PFMuonAlgo.h:148
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:183
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
Definition: PFMuonAlgo.cc:649
void changeTrack(reco::PFCandidate &, const MuonTrackTypePair &)
Definition: PFMuonAlgo.cc:792
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:186
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
const reco::VertexCollection * vertices_
Definition: PFMuonAlgo.h:154
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:40
bool postCleaning_
Definition: PFMuonAlgo.h:168
double METY_
Definition: PFMuonAlgo.h:187
void PFMuonAlgo::changeTrack ( reco::PFCandidate candidate,
const MuonTrackTypePair track 
)

Definition at line 792 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.

792  {
793  using namespace reco;
794  reco::TrackRef bestTrack = track.first;
795  MuonTrackType trackType = track.second;
796  //OK Now redefine the canddiate with that track
797  double px = bestTrack->px();
798  double py = bestTrack->py();
799  double pz = bestTrack->pz();
800  double energy = sqrt(bestTrack->p()*bestTrack->p() + 0.1057*0.1057);
801 
802  candidate.setCharge(bestTrack->charge()>0 ? 1 : -1);
803  candidate.setP4(math::XYZTLorentzVector(px,py,pz,energy));
805  // candidate.setTrackRef( bestTrack );
806  candidate.setMuonTrackType(trackType);
807  if(trackType == reco::Muon::InnerTrack)
808  candidate.setVertexSource( PFCandidate::kTrkMuonVertex );
809  else if(trackType == reco::Muon::CombinedTrack)
810  candidate.setVertexSource( PFCandidate::kComMuonVertex );
811  else if(trackType == reco::Muon::TPFMS)
812  candidate.setVertexSource( PFCandidate::kTPFMSMuonVertex );
813  else if(trackType == reco::Muon::Picky)
814  candidate.setVertexSource( PFCandidate::kPickyMuonVertex );
815  else if(trackType == reco::Muon::DYT)
816  candidate.setVertexSource( PFCandidate::kDYTMuonVertex );
817  }
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:18
virtual void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
MuonTrackType
Definition: MuonTrackType.h:27
bool PFMuonAlgo::cleanMismeasured ( reco::PFCandidate pfc,
unsigned int  i 
)
private

Definition at line 1061 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.

1061  {
1062  using namespace std;
1063  using namespace reco;
1064  bool cleaned=false;
1065 
1066  //First define the MET without this guy
1067  double METNOX = METX_ - pfc.px();
1068  double METNOY = METY_ - pfc.py();
1069  double SUMETNO = sumet_ -pfc.pt();
1070 
1071  TrackMETComparator comparator(METNOX,METNOY);
1072  //Low pt dont need to be cleaned
1073  if (pfc.pt()<minPostCleaningPt_)
1074  return false;
1075  std::vector<reco::Muon::MuonTrackTypePair> tracks = goodMuonTracks(pfc.muonRef(),false);
1076 
1077 
1078 
1079  //If there is more than 1 track choice try to change the track
1080  if(tracks.size()>1) {
1081  //Find tracks that change dramatically MET or Pt
1082  std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksWithBetterMET(tracks,pfc);
1083  //From those tracks get the one with smallest MET
1084  if (tracksThatChangeMET.size()>0) {
1085  reco::Muon::MuonTrackTypePair bestTrackType = *std::min_element(tracksThatChangeMET.begin(),tracksThatChangeMET.end(),comparator);
1086  changeTrack(pfc,bestTrackType);
1087 
1089  //update eventquantities
1090  METX_ = METNOX+pfc.px();
1091  METY_ = METNOY+pfc.py();
1092  sumet_=SUMETNO+pfc.pt();
1093 
1094  }
1095  }
1096 
1097  //Now attempt to kill it
1098  if (!(pfc.muonRef()->isGlobalMuon() && pfc.muonRef()->isTrackerMuon())) {
1099  //define MET significance and SUM ET
1100  double MET2 = METX_*METX_+METY_*METY_;
1101  double newMET2 = METNOX*METNOX+METNOY*METNOY;
1102  double METSig = sqrt(MET2)/sqrt(sumet_-sumetPU_);
1103  if( METSig>metSigForRejection_)
1104  if((newMET2 < MET2/metFactorRejection_) &&
1106  pfFakeMuonCleanedCandidates_->push_back(pfc);
1107  maskedIndices_.push_back(i);
1108  METX_ = METNOX;
1109  METY_ = METNOY;
1110  sumet_=SUMETNO;
1111  cleaned=true;
1112  }
1113 
1114  }
1115  return cleaned;
1116 
1117 }
int i
Definition: DBlmapReader.cc:9
double sumet_
Definition: PFMuonAlgo.h:185
double eventFractionRejection_
Definition: PFMuonAlgo.h:174
double metSigForRejection_
Definition: PFMuonAlgo.h:172
double minPostCleaningPt_
Definition: PFMuonAlgo.h:169
std::auto_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:142
std::auto_ptr< reco::PFCandidateCollection > pfCleanedTrackerAndGlobalMuonCandidates_
the collection of tracker/global cleaned muon candidates
Definition: PFMuonAlgo.h:140
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
Definition: PFMuonAlgo.cc:649
virtual double py() const final
y coordinate of momentum vector
void changeTrack(reco::PFCandidate &, const MuonTrackTypePair &)
Definition: PFMuonAlgo.cc:792
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
double metFactorRejection_
Definition: PFMuonAlgo.h:175
std::vector< unsigned int > maskedIndices_
Definition: PFMuonAlgo.h:150
tuple tracks
Definition: testEve_cfg.py:39
double METX_
Definition: PFMuonAlgo.h:186
double sumetPU_
Definition: PFMuonAlgo.h:166
virtual double px() const final
x coordinate of momentum vector
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:40
std::vector< MuonTrackTypePair > tracksWithBetterMET(const std::vector< MuonTrackTypePair > &, const reco::PFCandidate &)
Definition: PFMuonAlgo.cc:1120
virtual double pt() const final
transverse momentum
double METY_
Definition: PFMuonAlgo.h:187
bool PFMuonAlgo::cleanPunchThroughAndFakes ( reco::PFCandidate pfc,
reco::PFCandidateCollection cands,
unsigned int  imu 
)
private

Definition at line 1172 of file PFMuonAlgo.cc.

References reco::PFCandidate::elementsInBlocks(), reco::LeafCandidate::eta(), V0MonitoringClient_cfi::factor, 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().

1172  {
1173  using namespace reco;
1174 
1175  bool cleaned=false;
1176 
1177  if (pfc.pt()<minPostCleaningPt_)
1178  return false;
1179 
1180 
1181  double METXNO = METX_-pfc.pt();
1182  double METYNO = METY_-pfc.pt();
1183  double MET2NO = METXNO*METXNO+METYNO*METYNO;
1184  double MET2 = METX_*METX_+METY_*METY_;
1185  bool fake1=false;
1186 
1187  std::pair<double,double> met2 = getMinMaxMET2(pfc);
1188 
1189  //Check for Fakes at high pseudorapidity
1190  if(pfc.muonRef()->standAloneMuon().isNonnull())
1191  fake1 =fabs ( pfc.eta() ) > 2.15 &&
1192  met2.first<met2.second/2 &&
1193  MET2NO < MET2/metFactorHighEta_ &&
1194  pfc.muonRef()->standAloneMuon()->pt() < pfc.pt()/ptFactorHighEta_;
1195 
1196  double factor = std::max(2.,2000./(sumet_-pfc.pt()-sumetPU_));
1197  bool fake2 = ( pfc.pt()/(sumet_-sumetPU_) < 0.25 && MET2NO < MET2/metFactorFake_ && met2.first<met2.second/factor );
1198 
1199  bool punchthrough =pfc.p() > minPunchThroughMomentum_ &&
1201  pfc.rawEcalEnergy()+pfc.rawHcalEnergy() > pfc.p()/punchThroughFactor_ &&
1202  !isIsolatedMuon(pfc.muonRef()) && MET2NO < MET2/punchThroughMETFactor_;
1203 
1204 
1205  if(fake1 || fake2||punchthrough) {
1206  // Find the block of the muon
1207  const PFCandidate::ElementsInBlocks& eleInBlocks = pfc.elementsInBlocks();
1208  if ( eleInBlocks.size() ) {
1209  PFBlockRef blockRefMuon = eleInBlocks[0].first;
1210  unsigned indexMuon = eleInBlocks[0].second;
1211  if (eleInBlocks.size()>1)
1212  indexMuon = eleInBlocks[1].second;
1213 
1214  // Check if the muon gave rise to a neutral hadron
1215  double iHad = 1E9;
1216  bool hadron = false;
1217  for ( unsigned i = imu+1; i < cands->size(); ++i ) {
1218  const PFCandidate& pfcn = cands->at(i);
1219  const PFCandidate::ElementsInBlocks& ele = pfcn.elementsInBlocks();
1220  if ( !ele.size() ) {
1221  continue;
1222  }
1223  PFBlockRef blockRefHadron = ele[0].first;
1224  unsigned indexHadron = ele[0].second;
1225  // We are out of the block -> exit the loop
1226  if ( blockRefHadron.key() != blockRefMuon.key() ) break;
1227  // Check that this particle is a neutral hadron
1228  if ( indexHadron == indexMuon &&
1229  pfcn.particleId() == reco::PFCandidate::h0 ) {
1230  iHad = i;
1231  hadron = true;
1232  }
1233  if ( hadron ) break;
1234  }
1235 
1236  if ( hadron ) {
1237 
1238  double rescaleFactor = cands->at(iHad).p()/cands->at(imu).p();
1239  METX_ -= cands->at(imu).px() + cands->at(iHad).px();
1240  METY_ -= cands->at(imu).py() + cands->at(iHad).py();
1241  sumet_ -=cands->at(imu).pt();
1242  cands->at(imu).rescaleMomentum(rescaleFactor);
1243  maskedIndices_.push_back(iHad);
1244  pfPunchThroughHadronCleanedCandidates_->push_back(cands->at(iHad));
1245  cands->at(imu).setParticleType(reco::PFCandidate::h);
1246  pfPunchThroughMuonCleanedCandidates_->push_back(cands->at(imu));
1247  METX_ += cands->at(imu).px();
1248  METY_ += cands->at(imu).py();
1249  sumet_ += cands->at(imu).pt();
1250 
1251  } else if ( fake1 || fake2 ) {
1252  METX_ -= cands->at(imu).px();
1253  METY_ -= cands->at(imu).py();
1254  sumet_ -= cands->at(imu).pt();
1255  maskedIndices_.push_back(imu);
1256  pfFakeMuonCleanedCandidates_->push_back(cands->at(imu));
1257  cleaned=true;
1258  }
1259  }
1260  }
1261  return cleaned;
1262 }
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:227
double punchThroughMETFactor_
Definition: PFMuonAlgo.h:182
int i
Definition: DBlmapReader.cc:9
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughMuonCleanedCandidates_
the collection of punch-through cleaned muon candidates
Definition: PFMuonAlgo.h:144
double metFactorHighEta_
Definition: PFMuonAlgo.h:176
double sumet_
Definition: PFMuonAlgo.h:185
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
double minPunchThroughMomentum_
Definition: PFMuonAlgo.h:179
double minPunchThroughEnergy_
Definition: PFMuonAlgo.h:180
double rawEcalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:224
double metFactorFake_
Definition: PFMuonAlgo.h:178
key_type key() const
Accessor for product key.
Definition: Ref.h:264
double minPostCleaningPt_
Definition: PFMuonAlgo.h:169
std::auto_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:142
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:146
double punchThroughFactor_
Definition: PFMuonAlgo.h:181
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
double ptFactorHighEta_
Definition: PFMuonAlgo.h:177
std::vector< unsigned int > maskedIndices_
Definition: PFMuonAlgo.h:150
double METX_
Definition: PFMuonAlgo.h:186
std::pair< double, double > getMinMaxMET2(const reco::PFCandidate &)
Definition: PFMuonAlgo.cc:1041
virtual double p() const final
magnitude of momentum vector
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
double sumetPU_
Definition: PFMuonAlgo.h:166
virtual double eta() const final
momentum pseudorapidity
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
virtual double pt() const final
transverse momentum
double METY_
Definition: PFMuonAlgo.h:187
void PFMuonAlgo::estimateEventQuantities ( const reco::PFCandidateCollection pfc)
private

Definition at line 830 of file PFMuonAlgo.cc.

References i.

831 {
832  //SUM ET
833  sumetPU_ = 0.0;
834  METX_=0.;
835  METY_=0.;
836  sumet_=0.0;
837  for(reco::PFCandidateCollection::const_iterator i = pfc->begin();i!=pfc->end();++i) {
838  sumet_+=i->pt();
839  METX_+=i->px();
840  METY_+=i->py();
841  }
842 
843 }
int i
Definition: DBlmapReader.cc:9
double sumet_
Definition: PFMuonAlgo.h:185
double METX_
Definition: PFMuonAlgo.h:186
double sumetPU_
Definition: PFMuonAlgo.h:166
double METY_
Definition: PFMuonAlgo.h:187
std::pair< double, double > PFMuonAlgo::getMinMaxMET2 ( const reco::PFCandidate pfc)
private

Definition at line 1041 of file PFMuonAlgo.cc.

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

1041  {
1042  std::vector<reco::Muon::MuonTrackTypePair> tracks = goodMuonTracks((pfc.muonRef()),true);
1043 
1044  double METXNO = METX_-pfc.px();
1045  double METYNO = METY_-pfc.py();
1046  std::vector<double> met2;
1047  for (unsigned int i=0;i<tracks.size();++i) {
1048  met2.push_back(pow(METXNO+tracks.at(i).first->px(),2)+pow(METYNO+tracks.at(i).first->py(),2));
1049  }
1050 
1051  //PROTECT for cases of only one track. If there is only one track it will crash .
1052  //Has never happened but could likely happen!
1053 
1054  if(tracks.size()>1)
1055  return std::make_pair(*std::min_element(met2.begin(),met2.end()),*std::max_element(met2.begin(),met2.end()));
1056  else
1057  return std::make_pair(0,0);
1058 }
int i
Definition: DBlmapReader.cc:9
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
Definition: PFMuonAlgo.cc:649
virtual double py() const final
y coordinate of momentum vector
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
tuple tracks
Definition: testEve_cfg.py:39
double METX_
Definition: PFMuonAlgo.h:186
virtual double px() const final
x coordinate of momentum vector
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double METY_
Definition: PFMuonAlgo.h:187
reco::Muon::MuonTrackTypePair PFMuonAlgo::getTrackWithSmallestError ( const std::vector< MuonTrackTypePair > &  tracks)
private

Definition at line 821 of file PFMuonAlgo.cc.

References MCScenario_CRAFT1_22X::sorter().

821  {
822  TrackPtErrorSorter sorter;
823  return *std::min_element(tracks.begin(),tracks.end(),sorter);
824 }
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 649 of file PFMuonAlgo.cc.

649  {
650  return muonTracks(muon,includeSA,maxDPtOPt_);
651 }
double maxDPtOPt_
Definition: PFMuonAlgo.h:159
std::vector< reco::Muon::MuonTrackTypePair > muonTracks(const reco::MuonRef &muon, bool includeSA=false, double dpt=1e+9)
Definition: PFMuonAlgo.cc:655
bool PFMuonAlgo::hasValidTrack ( const reco::MuonRef muonRef,
bool  loose = false 
)

Definition at line 502 of file PFMuonAlgo.cc.

502  {
503  if(loose)
504  return muonTracks(muonRef).size()>0;
505  else
506  return goodMuonTracks(muonRef).size()>0;
507 
508 }
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
Definition: PFMuonAlgo.cc:649
std::vector< reco::Muon::MuonTrackTypePair > muonTracks(const reco::MuonRef &muon, bool includeSA=false, double dpt=1e+9)
Definition: PFMuonAlgo.cc:655
bool PFMuonAlgo::isGlobalLooseMuon ( const reco::PFBlockElement elt)
static

Definition at line 201 of file PFMuonAlgo.cc.

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

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

Definition at line 344 of file PFMuonAlgo.cc.

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

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

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

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

Definition at line 253 of file PFMuonAlgo.cc.

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

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

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

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

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

Definition at line 435 of file PFMuonAlgo.cc.

References edm::Ref< C, T, F >::isNonnull(), and objects.IsoTrackAnalyzer::relIso.

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

Definition at line 168 of file PFMuonAlgo.cc.

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

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

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

Definition at line 246 of file PFMuonAlgo.cc.

246  {
247 
248  return (isGlobalLooseMuon(muonRef) || isTrackerLooseMuon(muonRef));
249 
250 }
static bool isTrackerLooseMuon(const reco::PFBlockElement &elt)
static bool isGlobalLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:201
bool PFMuonAlgo::isMuon ( const reco::PFBlockElement elt)
static

Definition at line 155 of file PFMuonAlgo.cc.

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

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

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

Definition at line 240 of file PFMuonAlgo.cc.

240  {
241 
242  return isGlobalTightMuon(muonRef) || isTrackerTightMuon(muonRef) || isIsolatedMuon(muonRef);
243 }
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:227
static bool isGlobalTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:188
static bool isTrackerTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:214
bool PFMuonAlgo::isTightMuonPOG ( const reco::MuonRef muonRef)
static

Definition at line 479 of file PFMuonAlgo.cc.

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

479  {
480 
481  if(!muon::isGoodMuon(*muonRef,muon::GlobalMuonPromptTight)) return false;
482 
483  if(!muonRef->isTrackerMuon()) return false;
484 
485  if(muonRef->numberOfMatches()<2) return false;
486 
487  //const reco::TrackRef& combinedMuon = muonRef->combinedMuon();
488  const reco::TrackRef& combinedMuon = muonRef->globalTrack();
489 
490  if(combinedMuon->hitPattern().numberOfValidTrackerHits()<11) return false;
491 
492  if(combinedMuon->hitPattern().numberOfValidPixelHits()==0) return false;
493 
494  if(combinedMuon->hitPattern().numberOfValidMuonHits()==0) return false;
495 
496  return true;
497 
498 }
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 413 of file PFMuonAlgo.cc.

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

413  {
414 
415  if ( !muonRef.isNonnull() ) return false;
416  if(!muonRef->isTrackerMuon()) return false;
417 
418  reco::TrackRef trackerMu = muonRef->track();
419 
420  if(trackerMu->ptError()/trackerMu->pt() > 0.20) return false;
421 
422  // this doesn't seem to be necessary on the small samples looked at, but keep it around as insurance
423  if(trackerMu->pt()>20.) return false;
424 
425  bool isAllArbitrated = muon::isGoodMuon(*muonRef,muon::AllArbitrated);
426  bool isTMLastStationAngTight = muon::isGoodMuon(*muonRef,muon::TMLastStationAngTight);
427 
428  bool quality = isAllArbitrated && isTMLastStationAngTight;
429 
430  return quality;
431 
432 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
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 214 of file PFMuonAlgo.cc.

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

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

Definition at line 316 of file PFMuonAlgo.cc.

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

316  {
317 
318  if ( !muonRef.isNonnull() ) return false;
319 
320  if(!muonRef->isTrackerMuon()) return false;
321 
322  reco::TrackRef trackerMu = muonRef->track();
323  const reco::Track& track = *trackerMu;
324 
325  unsigned nTrackerHits = track.hitPattern().numberOfValidTrackerHits();
326 
327  if(nTrackerHits<=12) return false;
328 
329  bool isAllArbitrated = muon::isGoodMuon(*muonRef,muon::AllArbitrated);
330 
331  bool isTM2DCompatibilityTight = muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight);
332 
333  if(!isAllArbitrated || !isTM2DCompatibilityTight) return false;
334 
335  if((trackerMu->ptError()/trackerMu->pt() > 0.10)){
336  //std::cout<<" PT ERROR > 10 % "<< trackerMu->pt() <<std::endl;
337  return false;
338  }
339  return true;
340 
341 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
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:445
int numberOfValidTrackerHits() const
Definition: HitPattern.h:828
std::vector< reco::Muon::MuonTrackTypePair > PFMuonAlgo::muonTracks ( const reco::MuonRef muon,
bool  includeSA = false,
double  dpt = 1e+9 
)
private

Definition at line 655 of file PFMuonAlgo.cc.

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

655  {
656 
657 
658 
659  std::vector<reco::Muon::MuonTrackTypePair> out;
660 
661 
662  if(muon->globalTrack().isNonnull() && muon->globalTrack()->pt()>0)
663  if(muon->globalTrack()->ptError()/muon->globalTrack()->pt()<dpt)
664  out.push_back(std::make_pair(muon->globalTrack(),reco::Muon::CombinedTrack));
665 
666  if(muon->innerTrack().isNonnull() && muon->innerTrack()->pt()>0)
667  if(muon->innerTrack()->ptError()/muon->innerTrack()->pt()<dpt)//Here Loose!@
668  out.push_back(std::make_pair(muon->innerTrack(),reco::Muon::InnerTrack));
669 
670  bool pickyExists=false;
671  double pickyDpt=99999.;
672  if(muon->pickyTrack().isNonnull() && muon->pickyTrack()->pt()>0) {
673  pickyDpt = muon->pickyTrack()->ptError()/muon->pickyTrack()->pt();
674  if(pickyDpt<dpt)
675  out.push_back(std::make_pair(muon->pickyTrack(),reco::Muon::Picky));
676  pickyExists=true;
677  }
678 
679  bool dytExists=false;
680  double dytDpt=99999.;
681  if(muon->dytTrack().isNonnull() && muon->dytTrack()->pt()>0) {
682  dytDpt = muon->dytTrack()->ptError()/muon->dytTrack()->pt();
683  if(dytDpt<dpt)
684  out.push_back(std::make_pair(muon->dytTrack(),reco::Muon::DYT));
685  dytExists=true;
686  }
687 
688  //Magic: TPFMS is not a really good track especially under misalignment
689  //IT is kind of crap because if mu system is displaced it can make a change
690  //So allow TPFMS if there is no picky or the error of tpfms is better than picky
691  //AND if there is no DYT or the error of tpfms is better than DYT
692  if(muon->tpfmsTrack().isNonnull() && muon->tpfmsTrack()->pt()>0) {
693  double tpfmsDpt = muon->tpfmsTrack()->ptError()/muon->tpfmsTrack()->pt();
694  if( ( (pickyExists && tpfmsDpt<pickyDpt) || (!pickyExists) ) &&
695  ( (dytExists && tpfmsDpt<dytDpt) || (!dytExists) ) &&
696  tpfmsDpt<dpt )
697  out.push_back(std::make_pair(muon->tpfmsTrack(),reco::Muon::TPFMS));
698  }
699 
700  if(includeSA && muon->outerTrack().isNonnull())
701  if(muon->outerTrack()->ptError()/muon->outerTrack()->pt()<dpt)
702  out.push_back(std::make_pair(muon->outerTrack(),reco::Muon::OuterTrack));
703 
704  return out;
705 
706 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
void PFMuonAlgo::postClean ( reco::PFCandidateCollection cands)

Definition at line 849 of file PFMuonAlgo.cc.

References ecal_dqm_sourceclient-live_cfg::cosmics, i, reco::PFCandidate::mu, reco::PFCandidate::muonRef(), patZpeak::muons, reco::PFCandidate::particleId(), reco::LeafCandidate::pt(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), and dt_dqm_sourceclient_common_cff::reco.

Referenced by PFAlgo::reconstructParticles().

849  {
850  using namespace std;
851  using namespace reco;
852  if (!postCleaning_)
853  return;
854 
855  //Initialize vectors
856 
859  else
861 
864  else
866 
867  if( pfFakeMuonCleanedCandidates_.get() )
869  else
871 
872 
875  else
877 
880  else
882 
883 
884 
886 
887  maskedIndices_.clear();
888 
889  //Estimate MET and SumET
890 
892 
893 
894  std::vector<int> muons;
895  std::vector<int> cosmics;
896  //get the muons
897  for(unsigned int i=0;i<cands->size();++i) {
898  const reco::PFCandidate& cand = (*cands)[i];
899  if ( cand.particleId() == reco::PFCandidate::mu )
900  muons.push_back(i);
901 
902  }
903  //Then sort the muon indicess by decsending pt
904 
905  IndexPtComparator comparator(cands);
906  std::sort(muons.begin(),muons.end(),comparator);
907 
908 
909  //first kill cosmics
910  double METXCosmics=0;
911  double METYCosmics=0;
912  double SUMETCosmics=0.0;
913 
914  for(unsigned int i=0;i<muons.size();++i) {
915  const PFCandidate& pfc = cands->at(muons[i]);
916  double origin=0.0;
917  if(vertices_->size()>0&& vertices_->at(0).isValid() && ! vertices_->at(0).isFake())
918  origin = pfc.muonRef()->muonBestTrack()->dxy(vertices_->at(0).position());
919 
920  if( origin> cosmicRejDistance_) {
921  cosmics.push_back(muons[i]);
922  METXCosmics +=pfc.px();
923  METYCosmics +=pfc.py();
924  SUMETCosmics +=pfc.pt();
925  }
926  }
927  double MET2Cosmics = METXCosmics*METXCosmics+METYCosmics*METYCosmics;
928 
929  if ( SUMETCosmics > (sumet_-sumetPU_)/eventFactorCosmics_ && MET2Cosmics < METX_*METX_+ METY_*METY_)
930  for(unsigned int i=0;i<cosmics.size();++i) {
931  maskedIndices_.push_back(cosmics[i]);
932  pfCosmicsMuonCleanedCandidates_->push_back(cands->at(cosmics[i]));
933  }
934 
935  //Loop on the muons candidates and clean
936  for(unsigned int i=0;i<muons.size();++i) {
937  if( cleanMismeasured(cands->at(muons[i]),muons[i]))
938  continue;
939  cleanPunchThroughAndFakes(cands->at(muons[i]),cands,muons[i]);
940 
941  }
942 
943 
944 
945  //OK Now do the hard job ->remove the candidates that were cleaned
947 
948 
949 
950 
951 }
int i
Definition: DBlmapReader.cc:9
bool cleanMismeasured(reco::PFCandidate &, unsigned int)
Definition: PFMuonAlgo.cc:1061
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughMuonCleanedCandidates_
the collection of punch-through cleaned muon candidates
Definition: PFMuonAlgo.h:144
double sumet_
Definition: PFMuonAlgo.h:185
void removeDeadCandidates(reco::PFCandidateCollection *, const std::vector< unsigned int > &)
Definition: PFMuonAlgo.cc:1265
double eventFactorCosmics_
Definition: PFMuonAlgo.h:170
bool cleanPunchThroughAndFakes(reco::PFCandidate &, reco::PFCandidateCollection *, unsigned int)
Definition: PFMuonAlgo.cc:1172
std::auto_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:142
std::auto_ptr< reco::PFCandidateCollection > pfCosmicsMuonCleanedCandidates_
the collection of cosmics cleaned muon candidates
Definition: PFMuonAlgo.h:138
std::auto_ptr< reco::PFCandidateCollection > pfCleanedTrackerAndGlobalMuonCandidates_
the collection of tracker/global cleaned muon candidates
Definition: PFMuonAlgo.h:140
double cosmicRejDistance_
Definition: PFMuonAlgo.h:183
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughHadronCleanedCandidates_
the collection of punch-through cleaned neutral hadron candidates
Definition: PFMuonAlgo.h:146
virtual double py() const final
y coordinate of momentum vector
void estimateEventQuantities(const reco::PFCandidateCollection *)
Definition: PFMuonAlgo.cc:830
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::vector< unsigned int > maskedIndices_
Definition: PFMuonAlgo.h:150
double METX_
Definition: PFMuonAlgo.h:186
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
tuple muons
Definition: patZpeak.py:38
double sumetPU_
Definition: PFMuonAlgo.h:166
virtual double px() const final
x coordinate of momentum vector
const reco::VertexCollection * vertices_
Definition: PFMuonAlgo.h:154
virtual ParticleType particleId() const
Definition: PFCandidate.h:373
bool postCleaning_
Definition: PFMuonAlgo.h:168
virtual double pt() const final
transverse momentum
double METY_
Definition: PFMuonAlgo.h:187
void PFMuonAlgo::printMuonProperties ( const reco::MuonRef muonRef)
static

Definition at line 512 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.

512  {
513 
514  if ( !muonRef.isNonnull() ) return;
515 
516  bool isGL = muonRef->isGlobalMuon();
517  bool isTR = muonRef->isTrackerMuon();
518  bool isST = muonRef->isStandAloneMuon();
519 
520  std::cout<<" GL: "<<isGL<<" TR: "<<isTR<<" ST: "<<isST<<std::endl;
521  std::cout<<" nMatches "<<muonRef->numberOfMatches()<<std::endl;
522 
523  if ( muonRef->isGlobalMuon() ){
524  reco::TrackRef combinedMu = muonRef->combinedMuon();
525  std::cout<<" GL, pt: " << combinedMu->pt()
526  << " +/- " << combinedMu->ptError()/combinedMu->pt()
527  << " chi**2 GBL : " << combinedMu->normalizedChi2()<<std::endl;
528  std::cout<< " Total Muon Hits : " << combinedMu->hitPattern().numberOfValidMuonHits()
529  << "/" << combinedMu->hitPattern().numberOfLostMuonHits()
530  << " DT Hits : " << combinedMu->hitPattern().numberOfValidMuonDTHits()
531  << "/" << combinedMu->hitPattern().numberOfLostMuonDTHits()
532  << " CSC Hits : " << combinedMu->hitPattern().numberOfValidMuonCSCHits()
533  << "/" << combinedMu->hitPattern().numberOfLostMuonCSCHits()
534  << " RPC Hits : " << combinedMu->hitPattern().numberOfValidMuonRPCHits()
535  << "/" << combinedMu->hitPattern().numberOfLostMuonRPCHits()<<std::endl;
536 
537  std::cout<<" # of Valid Tracker Hits "<<combinedMu->hitPattern().numberOfValidTrackerHits()<<std::endl;
538  std::cout<<" # of Valid Pixel Hits "<<combinedMu->hitPattern().numberOfValidPixelHits()<<std::endl;
539  }
540  if ( muonRef->isStandAloneMuon() ){
541  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
542  std::cout<<" ST, pt: " << standAloneMu->pt()
543  << " +/- " << standAloneMu->ptError()/standAloneMu->pt()
544  << " eta : " << standAloneMu->eta()
545  << " DT Hits : " << standAloneMu->hitPattern().numberOfValidMuonDTHits()
546  << "/" << standAloneMu->hitPattern().numberOfLostMuonDTHits()
547  << " CSC Hits : " << standAloneMu->hitPattern().numberOfValidMuonCSCHits()
548  << "/" << standAloneMu->hitPattern().numberOfLostMuonCSCHits()
549  << " RPC Hits : " << standAloneMu->hitPattern().numberOfValidMuonRPCHits()
550  << "/" << standAloneMu->hitPattern().numberOfLostMuonRPCHits()
551  << " chi**2 STA : " << standAloneMu->normalizedChi2()<<std::endl;
552  }
553 
554 
555  if ( muonRef->isTrackerMuon() ){
556  reco::TrackRef trackerMu = muonRef->track();
557  const reco::Track& track = *trackerMu;
558  std::cout<<" TR, pt: " << trackerMu->pt()
559  << " +/- " << trackerMu->ptError()/trackerMu->pt()
560  << " chi**2 TR : " << trackerMu->normalizedChi2()<<std::endl;
561  std::cout<<" nTrackerHits "<<track.hitPattern().numberOfValidTrackerHits()<<std::endl;
562  std::cout<< "TMLastStationAngLoose "
563  << muon::isGoodMuon(*muonRef,muon::TMLastStationAngLoose) << std::endl
564  << "TMLastStationAngTight "
565  << muon::isGoodMuon(*muonRef,muon::TMLastStationAngTight) << std::endl
566  << "TMLastStationLoose "
567  << muon::isGoodMuon(*muonRef,muon::TMLastStationLoose) << std::endl
568  << "TMLastStationTight "
569  << muon::isGoodMuon(*muonRef,muon::TMLastStationTight) << std::endl
570  << "TMOneStationLoose "
571  << muon::isGoodMuon(*muonRef,muon::TMOneStationLoose) << std::endl
572  << "TMOneStationTight "
573  << muon::isGoodMuon(*muonRef,muon::TMOneStationTight) << std::endl
574  << "TMLastStationOptimizedLowPtLoose "
576  << "TMLastStationOptimizedLowPtTight "
578  << "TMLastStationOptimizedBarrelLowPtLoose "
580  << "TMLastStationOptimizedBarrelLowPtTight "
582  << std::endl;
583 
584  }
585 
586  std::cout<< "TM2DCompatibilityLoose "
587  << muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityLoose) << std::endl
588  << "TM2DCompatibilityTight "
589  << muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight) << std::endl;
590 
591 
592 
593  if ( muonRef->isGlobalMuon() && muonRef->isTrackerMuon() && muonRef->isStandAloneMuon() ){
594  reco::TrackRef combinedMu = muonRef->combinedMuon();
595  reco::TrackRef trackerMu = muonRef->track();
596  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
597 
598  double sigmaCombined = combinedMu->ptError()/(combinedMu->pt()*combinedMu->pt());
599  double sigmaTracker = trackerMu->ptError()/(trackerMu->pt()*trackerMu->pt());
600  double sigmaStandAlone = standAloneMu->ptError()/(standAloneMu->pt()*standAloneMu->pt());
601 
602  bool combined = combinedMu->ptError()/combinedMu->pt() < 0.20;
603  bool tracker = trackerMu->ptError()/trackerMu->pt() < 0.20;
604  bool standAlone = standAloneMu->ptError()/standAloneMu->pt() < 0.20;
605 
606  double delta1 = combined && tracker ?
607  fabs(1./combinedMu->pt() -1./trackerMu->pt())
608  /sqrt(sigmaCombined*sigmaCombined + sigmaTracker*sigmaTracker) : 100.;
609  double delta2 = combined && standAlone ?
610  fabs(1./combinedMu->pt() -1./standAloneMu->pt())
611  /sqrt(sigmaCombined*sigmaCombined + sigmaStandAlone*sigmaStandAlone) : 100.;
612  double delta3 = standAlone && tracker ?
613  fabs(1./standAloneMu->pt() -1./trackerMu->pt())
614  /sqrt(sigmaStandAlone*sigmaStandAlone + sigmaTracker*sigmaTracker) : 100.;
615 
616  double delta =
617  standAloneMu->hitPattern().numberOfValidMuonDTHits()+
618  standAloneMu->hitPattern().numberOfValidMuonCSCHits() > 0 ?
619  std::min(delta3,std::min(delta1,delta2)) : std::max(delta3,std::max(delta1,delta2));
620 
621  std::cout << "delta = " << delta << " delta1 "<<delta1<<" delta2 "<<delta2<<" delta3 "<<delta3<<std::endl;
622 
623  double ratio =
624  combinedMu->ptError()/combinedMu->pt()
625  / (trackerMu->ptError()/trackerMu->pt());
626  //if ( ratio > 2. && delta < 3. ) std::cout << "ALARM ! " << ratio << ", " << delta << std::endl;
627  std::cout<<" ratio "<<ratio<<" combined mu pt "<<combinedMu->pt()<<std::endl;
628  //bool quality3 = ( combinedMu->pt() < 50. || ratio < 2. ) && delta < 3.;
629 
630 
631  }
632 
633  double sumPtR03 = muonRef->isolationR03().sumPt;
634  double emEtR03 = muonRef->isolationR03().emEt;
635  double hadEtR03 = muonRef->isolationR03().hadEt;
636  double relIsoR03 = (sumPtR03 + emEtR03 + hadEtR03)/muonRef->pt();
637  double sumPtR05 = muonRef->isolationR05().sumPt;
638  double emEtR05 = muonRef->isolationR05().emEt;
639  double hadEtR05 = muonRef->isolationR05().hadEt;
640  double relIsoR05 = (sumPtR05 + emEtR05 + hadEtR05)/muonRef->pt();
641  std::cout<<" 0.3 Radion Rel Iso: "<<relIsoR03<<" sumPt "<<sumPtR03<<" emEt "<<emEtR03<<" hadEt "<<hadEtR03<<std::endl;
642  std::cout<<" 0.5 Radion Rel Iso: "<<relIsoR05<<" sumPt "<<sumPtR05<<" emEt "<<emEtR05<<" hadEt "<<hadEtR05<<std::endl;
643  return;
644 
645 }
dbl * delta
Definition: mlp_gen.cc:36
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
T sqrt(T t)
Definition: SSEVec.h:18
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:445
int numberOfValidTrackerHits() const
Definition: HitPattern.h:828
tuple cout
Definition: gather_cfg.py:145
bool PFMuonAlgo::reconstructMuon ( reco::PFCandidate candidate,
const reco::MuonRef muon,
bool  allowLoose = false 
)

Definition at line 717 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().

717  {
718  using namespace std;
719  using namespace reco;
720 
721  if (!muon.isNonnull())
722  return false;
723 
724 
725 
726 
727  bool isMu=false;
728 
729  if(allowLoose)
730  isMu = isMuon(muon) || isLooseMuon(muon);
731  else
732  isMu = isMuon(muon);
733 
734  if( !isMu)
735  return false;
736 
737 
738 
739 
740 
741  //get the valid tracks(without standalone except we allow loose muons)
742  //MIKE: Here we need to be careful. If we have a muon inside a dense
743  //jet environment often the track is badly measured. In this case
744  //we should not apply Dpt/Pt<1
745 
746  std::vector<reco::Muon::MuonTrackTypePair> validTracks = goodMuonTracks(muon);
747  if (!allowLoose)
748  validTracks = goodMuonTracks(muon);
749  else
750  validTracks = muonTracks(muon);
751 
752  if( validTracks.size() ==0)
753  return false;
754 
755 
756 
757 
758  //check what is the track used.Rerun TuneP
759  reco::Muon::MuonTrackTypePair bestTrackPair = muon::tevOptimized(*muon);
760 
761  TrackRef bestTrack = bestTrackPair.first;
762  MuonTrackType trackType = bestTrackPair.second;
763 
764 
765 
766  MuonTrackTypePair trackPairWithSmallestError = getTrackWithSmallestError(validTracks);
767  TrackRef trackWithSmallestError = trackPairWithSmallestError.first;
768 
769  if( trackType == reco::Muon::InnerTrack &&
770  (!bestTrack->quality(trackQuality_) ||
771  bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt() )) {
772  bestTrack = trackWithSmallestError;
773  trackType = trackPairWithSmallestError.second;
774  }
775  else if (trackType != reco::Muon::InnerTrack &&
776  bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt()) {
777  bestTrack = trackWithSmallestError;
778  trackType = trackPairWithSmallestError.second;
779 
780  }
781 
782 
783  changeTrack(candidate,std::make_pair(bestTrack,trackType));
784  candidate.setMuonRef( muon );
785 
786  return true;
787 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:155
reco::Muon::MuonTrackTypePair MuonTrackTypePair
Definition: PFMuonAlgo.h:14
MuonTrackTypePair getTrackWithSmallestError(const std::vector< MuonTrackTypePair > &)
Definition: PFMuonAlgo.cc:821
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:649
void changeTrack(reco::PFCandidate &, const MuonTrackTypePair &)
Definition: PFMuonAlgo.cc:792
reco::TrackBase::TrackQuality trackQuality_
Definition: PFMuonAlgo.h:162
static bool isLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:168
void setMuonRef(const reco::MuonRef &ref)
set muon reference
Definition: PFCandidate.cc:436
double errorCompScale_
Definition: PFMuonAlgo.h:164
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:655
void PFMuonAlgo::removeDeadCandidates ( reco::PFCandidateCollection obj,
const std::vector< unsigned int > &  indices 
)
private

Definition at line 1265 of file PFMuonAlgo.cc.

References i, and N.

1266 {
1267  size_t N = indices.size();
1268  size_t collSize = obj->size();
1269 
1270  for (size_t i = 0 ; i < N ; ++i)
1271  obj->at(indices.at(i)) = obj->at(collSize-i-1);
1272 
1273  obj->resize(collSize - indices.size());
1274 }
int i
Definition: DBlmapReader.cc:9
#define N
Definition: blowfish.cc:9
void PFMuonAlgo::setInputsForCleaning ( const reco::VertexCollection vertices)

Definition at line 1168 of file PFMuonAlgo.cc.

References HLT_25ns10e33_v2_cff::vertices.

Referenced by PFAlgo::setPFVertexParameters().

1168  {
1169  vertices_ = vertices;
1170 }
const reco::VertexCollection * vertices_
Definition: PFMuonAlgo.h:154
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:182
double metFactorHighEta_
Definition: PFMuonAlgo.h:176
double maxDPtOPt_
Definition: PFMuonAlgo.h:159
double minPunchThroughMomentum_
Definition: PFMuonAlgo.h:179
double minPunchThroughEnergy_
Definition: PFMuonAlgo.h:180
double eventFactorCosmics_
Definition: PFMuonAlgo.h:170
double metFactorFake_
Definition: PFMuonAlgo.h:178
double eventFractionCleaning_
Definition: PFMuonAlgo.h:165
bool exists(std::string const &parameterName) const
checks if a parameter exists
double metSigForCleaning_
Definition: PFMuonAlgo.h:171
double eventFractionRejection_
Definition: PFMuonAlgo.h:174
double metSigForRejection_
Definition: PFMuonAlgo.h:172
double minPostCleaningPt_
Definition: PFMuonAlgo.h:169
double cosmicRejDistance_
Definition: PFMuonAlgo.h:183
double dzPV_
Definition: PFMuonAlgo.h:167
double punchThroughFactor_
Definition: PFMuonAlgo.h:181
double ptFactorHighEta_
Definition: PFMuonAlgo.h:177
double metFactorCleaning_
Definition: PFMuonAlgo.h:173
double metFactorRejection_
Definition: PFMuonAlgo.h:175
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
reco::TrackBase::TrackQuality trackQuality_
Definition: PFMuonAlgo.h:162
double errorCompScale_
Definition: PFMuonAlgo.h:164
int minPixelHits_
Definition: PFMuonAlgo.h:161
int minTrackerHits_
Definition: PFMuonAlgo.h:160
bool postCleaning_
Definition: PFMuonAlgo.h:168
std::vector< reco::Muon::MuonTrackTypePair > PFMuonAlgo::tracksPointingAtMET ( const std::vector< MuonTrackTypePair > &  tracks)
private

Definition at line 1148 of file PFMuonAlgo.cc.

References i, and funct::pow().

1148  {
1149  std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1150 
1151 
1152  double newMET2=0.0;
1153 
1154  for( unsigned int i=0;i<tracks.size();++i) {
1155  //calculate new SUM ET and MET2
1156  newMET2 = pow(METX_+tracks.at(i).first->px(),2)+pow(METY_+tracks.at(i).first->py(),2);
1157 
1158  if(newMET2<(METX_*METX_+METY_*METY_)/metFactorCleaning_)
1159  outputTracks.push_back(tracks.at(i));
1160  }
1161 
1162 
1163  return outputTracks;
1164 }
int i
Definition: DBlmapReader.cc:9
double metFactorCleaning_
Definition: PFMuonAlgo.h:173
tuple tracks
Definition: testEve_cfg.py:39
double METX_
Definition: PFMuonAlgo.h:186
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double METY_
Definition: PFMuonAlgo.h:187
std::vector< reco::Muon::MuonTrackTypePair > PFMuonAlgo::tracksWithBetterMET ( const std::vector< MuonTrackTypePair > &  tracks,
const reco::PFCandidate pfc 
)
private

Definition at line 1120 of file PFMuonAlgo.cc.

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

1120  {
1121  std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1122 
1123  double METNOX = METX_ - pfc.px();
1124  double METNOY = METY_ - pfc.py();
1125  double SUMETNO = sumet_ -pfc.pt();
1126  double MET2 = METX_*METX_+METY_*METY_;
1127  double newMET2=0.0;
1128  double newSUMET=0.0;
1129  double METSIG = sqrt(MET2)/sqrt(sumet_-sumetPU_);
1130 
1131 
1132  if(METSIG>metSigForCleaning_)
1133  for( unsigned int i=0;i<tracks.size();++i) {
1134  //calculate new SUM ET and MET2
1135  newSUMET = SUMETNO+tracks.at(i).first->pt()-sumetPU_;
1136  newMET2 = pow(METNOX+tracks.at(i).first->px(),2)+pow(METNOY+tracks.at(i).first->py(),2);
1137 
1138  if(newSUMET/(sumet_-sumetPU_)>eventFractionCleaning_ && newMET2<MET2/metFactorCleaning_)
1139  outputTracks.push_back(tracks.at(i));
1140  }
1141 
1142 
1143  return outputTracks;
1144 }
int i
Definition: DBlmapReader.cc:9
double sumet_
Definition: PFMuonAlgo.h:185
double eventFractionCleaning_
Definition: PFMuonAlgo.h:165
double metSigForCleaning_
Definition: PFMuonAlgo.h:171
T sqrt(T t)
Definition: SSEVec.h:18
virtual double py() const final
y coordinate of momentum vector
double metFactorCleaning_
Definition: PFMuonAlgo.h:173
tuple tracks
Definition: testEve_cfg.py:39
double METX_
Definition: PFMuonAlgo.h:186
double sumetPU_
Definition: PFMuonAlgo.h:166
virtual double px() const final
x coordinate of momentum vector
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
virtual double pt() const final
transverse momentum
double METY_
Definition: PFMuonAlgo.h:187
std::auto_ptr<reco::PFCandidateCollection>& PFMuonAlgo::transferAddedMuonCandidates ( )
inline

Definition at line 106 of file PFMuonAlgo.h.

References pfAddedMuonCandidates_.

106  {
107  return pfAddedMuonCandidates_;
108  }
std::auto_ptr< reco::PFCandidateCollection > pfAddedMuonCandidates_
the collection of added muon candidates
Definition: PFMuonAlgo.h:148
std::auto_ptr<reco::PFCandidateCollection>& PFMuonAlgo::transferCleanedCosmicCandidates ( )
inline

Definition at line 86 of file PFMuonAlgo.h.

References pfCosmicsMuonCleanedCandidates_.

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

Definition at line 94 of file PFMuonAlgo.h.

References pfFakeMuonCleanedCandidates_.

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

Definition at line 90 of file PFMuonAlgo.h.

References pfCleanedTrackerAndGlobalMuonCandidates_.

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

Definition at line 102 of file PFMuonAlgo.h.

References pfPunchThroughHadronCleanedCandidates_.

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

Definition at line 98 of file PFMuonAlgo.h.

References pfPunchThroughMuonCleanedCandidates_.

98  {
100  }
std::auto_ptr< reco::PFCandidateCollection > pfPunchThroughMuonCleanedCandidates_
the collection of punch-through cleaned muon candidates
Definition: PFMuonAlgo.h:144

Member Data Documentation

double PFMuonAlgo::cosmicRejDistance_
private

Definition at line 183 of file PFMuonAlgo.h.

double PFMuonAlgo::dzPV_
private

Definition at line 167 of file PFMuonAlgo.h.

double PFMuonAlgo::errorCompScale_
private

Definition at line 164 of file PFMuonAlgo.h.

double PFMuonAlgo::eventFactorCosmics_
private

Definition at line 170 of file PFMuonAlgo.h.

double PFMuonAlgo::eventFractionCleaning_
private

Definition at line 165 of file PFMuonAlgo.h.

double PFMuonAlgo::eventFractionRejection_
private

Definition at line 174 of file PFMuonAlgo.h.

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

Definition at line 150 of file PFMuonAlgo.h.

double PFMuonAlgo::maxDPtOPt_
private

Definition at line 159 of file PFMuonAlgo.h.

double PFMuonAlgo::metFactorCleaning_
private

Definition at line 173 of file PFMuonAlgo.h.

double PFMuonAlgo::metFactorFake_
private

Definition at line 178 of file PFMuonAlgo.h.

double PFMuonAlgo::metFactorHighEta_
private

Definition at line 176 of file PFMuonAlgo.h.

double PFMuonAlgo::metFactorRejection_
private

Definition at line 175 of file PFMuonAlgo.h.

double PFMuonAlgo::metSigForCleaning_
private

Definition at line 171 of file PFMuonAlgo.h.

double PFMuonAlgo::metSigForRejection_
private

Definition at line 172 of file PFMuonAlgo.h.

double PFMuonAlgo::METX_
private

Definition at line 186 of file PFMuonAlgo.h.

double PFMuonAlgo::METY_
private

Definition at line 187 of file PFMuonAlgo.h.

int PFMuonAlgo::minPixelHits_
private

Definition at line 161 of file PFMuonAlgo.h.

double PFMuonAlgo::minPostCleaningPt_
private

Definition at line 169 of file PFMuonAlgo.h.

double PFMuonAlgo::minPunchThroughEnergy_
private

Definition at line 180 of file PFMuonAlgo.h.

double PFMuonAlgo::minPunchThroughMomentum_
private

Definition at line 179 of file PFMuonAlgo.h.

int PFMuonAlgo::minTrackerHits_
private

Definition at line 160 of file PFMuonAlgo.h.

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

the collection of added muon candidates

Definition at line 148 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 140 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 138 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 142 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 146 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 144 of file PFMuonAlgo.h.

Referenced by transferPunchThroughCleanedMuonCandidates().

bool PFMuonAlgo::postCleaning_
private

Definition at line 168 of file PFMuonAlgo.h.

double PFMuonAlgo::ptFactorHighEta_
private

Definition at line 177 of file PFMuonAlgo.h.

double PFMuonAlgo::punchThroughFactor_
private

Definition at line 181 of file PFMuonAlgo.h.

double PFMuonAlgo::punchThroughMETFactor_
private

Definition at line 182 of file PFMuonAlgo.h.

double PFMuonAlgo::sumet_
private

Definition at line 185 of file PFMuonAlgo.h.

double PFMuonAlgo::sumetPU_
private

Definition at line 166 of file PFMuonAlgo.h.

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

Definition at line 162 of file PFMuonAlgo.h.

const reco::VertexCollection* PFMuonAlgo::vertices_
private

Definition at line 154 of file PFMuonAlgo.h.