CMS 3D CMS Logo

PFMuonAlgo.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFProducer_PFMuonAlgo_h
2 #define RecoParticleFlow_PFProducer_PFMuonAlgo_h
12 
13 class PFMuonAlgo {
16 
17 public:
20 
22 
24  static bool isMuon(const reco::PFBlockElement& elt);
25  static bool isLooseMuon(const reco::PFBlockElement& elt);
26  static bool isGlobalTightMuon(const reco::PFBlockElement& elt);
27  static bool isGlobalLooseMuon(const reco::PFBlockElement& elt);
28  static bool isTrackerTightMuon(const reco::PFBlockElement& elt);
29  static bool isTrackerLooseMuon(const reco::PFBlockElement& elt);
30  static bool isIsolatedMuon(const reco::PFBlockElement& elt);
31  static bool isMuon(const reco::MuonRef& muonRef);
32  static bool isLooseMuon(const reco::MuonRef& muonRef);
33  static bool isGlobalTightMuon(const reco::MuonRef& muonRef);
34  static bool isGlobalLooseMuon(const reco::MuonRef& muonRef);
35 
36  static bool isTrackerTightMuon(const reco::MuonRef& muonRef);
37  static bool isTrackerLooseMuon(const reco::MuonRef& muonRef);
38  static bool isIsolatedMuon(const reco::MuonRef& muonRef);
39  static bool isTightMuonPOG(const reco::MuonRef& muonRef);
40  static void printMuonProperties(const reco::MuonRef& muonRef);
41 
43  static bool hasValidTrack(const reco::MuonRef& muonRef, bool loose, double maxDPtOPt);
44 
45  //Make a PF Muon : Basic method
46  bool reconstructMuon(reco::PFCandidate&, const reco::MuonRef&, bool allowLoose = false);
47 
48  //Assign a different track to the muon
50  //PF Post cleaning algorithm
54  void setVetoes(const reco::PFCandidateCollection& vetoes) { vetoes_ = &vetoes; }
55 
56  std::unique_ptr<reco::PFCandidateCollection> transferCleanedCosmicCandidates() {
58  }
59 
60  std::unique_ptr<reco::PFCandidateCollection> transferCleanedTrackerAndGlobalCandidates() {
62  }
63 
64  std::unique_ptr<reco::PFCandidateCollection> transferCleanedFakeCandidates() {
66  }
67 
68  std::unique_ptr<reco::PFCandidateCollection> transferPunchThroughCleanedMuonCandidates() {
70  }
71 
72  std::unique_ptr<reco::PFCandidateCollection> transferPunchThroughCleanedHadronCandidates() {
74  }
75 
76  std::unique_ptr<reco::PFCandidateCollection> transferAddedMuonCandidates() {
78  }
79 
80  static std::vector<reco::Muon::MuonTrackTypePair> muonTracks(const reco::MuonRef& muon,
81  double maxDPtOPt = 1e+9,
82  bool includeSA = false);
83 
84  static int muAssocToTrack(const reco::TrackRef& trackref, const reco::MuonCollection& muons);
85 
86 private:
87  //Give the track with the smallest Dpt/Pt
88  MuonTrackTypePair getTrackWithSmallestError(const std::vector<MuonTrackTypePair>&);
89 
90  //Estimate MET and SUmET for post cleaning
92 
93  //Post cleaning Sub-methods
94  bool cleanMismeasured(reco::PFCandidate&, unsigned int);
96 
97  void removeDeadCandidates(reco::PFCandidateCollection*, const std::vector<unsigned int>&);
98 
99  //helpers
100  std::pair<double, double> getMinMaxMET2(const reco::PFCandidate&);
101  std::vector<MuonTrackTypePair> tracksWithBetterMET(const std::vector<MuonTrackTypePair>&, const reco::PFCandidate&);
102  std::vector<MuonTrackTypePair> tracksPointingAtMET(const std::vector<MuonTrackTypePair>&);
103 
104  //Output collections for post cleaning
106  std::unique_ptr<reco::PFCandidateCollection> pfCosmicsMuonCleanedCandidates_;
108  std::unique_ptr<reco::PFCandidateCollection> pfCleanedTrackerAndGlobalMuonCandidates_;
110  std::unique_ptr<reco::PFCandidateCollection> pfFakeMuonCleanedCandidates_;
112  std::unique_ptr<reco::PFCandidateCollection> pfPunchThroughMuonCleanedCandidates_;
114  std::unique_ptr<reco::PFCandidateCollection> pfPunchThroughHadronCleanedCandidates_;
116  std::unique_ptr<reco::PFCandidateCollection> pfAddedMuonCandidates_;
117 
118  std::vector<unsigned int> maskedIndices_;
119 
121 
124 
125  //Configurables
126  // for PFMuonAlgo::goodMuonTracks/muonTracks
127  const double maxDPtOPt_;
128  // for PFMuonAlgo::reconstructMuon
130  const double errorCompScale_;
131  // for postCleaning (postClean/addMissingMuons)
132  const bool postCleaning_;
134  const double minPostCleaningPt_;
135  const double eventFactorCosmics_;
136  const double metSigForCleaning_;
137  const double metSigForRejection_;
138  const double metFactorCleaning_;
140  const double metFactorRejection_;
141  const double metFactorHighEta_;
142  const double ptFactorHighEta_;
143  const double metFactorFake_;
146  const double punchThroughFactor_;
148  const double cosmicRejDistance_;
149 
150  double sumetPU_;
151  double sumet_;
152  double METX_;
153  double METY_;
154 
156 
158  public:
159  TrackMETComparator(double METX, double METY) {
160  metx_ = METX;
161  mety_ = METY;
162  }
164 
165  bool operator()(const MuonTrackTypePair& mu1, const MuonTrackTypePair& mu2) {
166  return pow(metx_ + mu1.first->px(), 2) + pow(mety_ + mu1.first->py(), 2) <
167  pow(metx_ + mu2.first->px(), 2) + pow(mety_ + mu2.first->py(), 2);
168  }
169 
170  private:
171  double metx_;
172  double mety_;
173  };
174 
176  public:
179 
180  bool operator()(int mu1, int mu2) { return coll_->at(mu1).pt() > coll_->at(mu2).pt(); }
181 
182  private:
184  };
185 
187  public:
190 
191  bool operator()(const MuonTrackTypePair& mu1, const MuonTrackTypePair& mu2) {
192  return mu1.first->ptError() / mu1.first->pt() < mu2.first->ptError() / mu2.first->pt();
193  }
194  };
195 };
196 
197 #endif
PFMuonAlgo::metFactorFake_
const double metFactorFake_
Definition: PFMuonAlgo.h:143
PFMuonAlgo::cleanMismeasured
bool cleanMismeasured(reco::PFCandidate &, unsigned int)
Definition: PFMuonAlgo.cc:845
PFMuonAlgo::getTrackWithSmallestError
MuonTrackTypePair getTrackWithSmallestError(const std::vector< MuonTrackTypePair > &)
Definition: PFMuonAlgo.cc:614
PFMuonAlgo::IndexPtComparator::~IndexPtComparator
~IndexPtComparator()
Definition: PFMuonAlgo.h:178
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
PFMuonAlgo::isTrackerLooseMuon
static bool isTrackerLooseMuon(const reco::PFBlockElement &elt)
PFMuonAlgo::pfCosmicsMuonCleanedCandidates_
std::unique_ptr< reco::PFCandidateCollection > pfCosmicsMuonCleanedCandidates_
the collection of cosmics cleaned muon candidates
Definition: PFMuonAlgo.h:106
Handle.h
PFMuonAlgo::removeDeadCandidates
void removeDeadCandidates(reco::PFCandidateCollection *, const std::vector< unsigned int > &)
Definition: PFMuonAlgo.cc:1033
PFMuonAlgo::postCleaning_
const bool postCleaning_
Definition: PFMuonAlgo.h:132
reco::Muon::MuonTrackTypePair
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:38
PFMuonAlgo::isIsolatedMuon
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:94
Muon.h
PFMuonAlgo::MuonTrackType
reco::Muon::MuonTrackType MuonTrackType
Definition: PFMuonAlgo.h:15
PFMuonAlgo::TrackPtErrorSorter::operator()
bool operator()(const MuonTrackTypePair &mu1, const MuonTrackTypePair &mu2)
Definition: PFMuonAlgo.h:191
PFMuonAlgo::maskedIndices_
std::vector< unsigned int > maskedIndices_
Definition: PFMuonAlgo.h:118
reco::Muon::MuonTrackType
MuonTrackType
map for Global Muon refitters
Definition: Muon.h:36
loose
constexpr auto loose
Definition: CAHitNtupletGeneratorKernelsImpl.h:182
HLT_FULL_cff.postMuonCleaning
postMuonCleaning
Definition: HLT_FULL_cff.py:13647
PFMuonAlgo::minPunchThroughEnergy_
const double minPunchThroughEnergy_
Definition: PFMuonAlgo.h:145
PFMuonAlgo::metFactorHighEta_
const double metFactorHighEta_
Definition: PFMuonAlgo.h:141
muon
Definition: MuonCocktails.h:17
PFMuonAlgo::transferCleanedCosmicCandidates
std::unique_ptr< reco::PFCandidateCollection > transferCleanedCosmicCandidates()
Definition: PFMuonAlgo.h:56
PFCandidate.h
PFMuonAlgo::TrackPtErrorSorter
Definition: PFMuonAlgo.h:186
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
PFMuonAlgo::tracksPointingAtMET
std::vector< MuonTrackTypePair > tracksPointingAtMET(const std::vector< MuonTrackTypePair > &)
Definition: PFMuonAlgo.cc:924
PFMuonAlgo::tracksWithBetterMET
std::vector< MuonTrackTypePair > tracksWithBetterMET(const std::vector< MuonTrackTypePair > &, const reco::PFCandidate &)
Definition: PFMuonAlgo.cc:899
PFMuonAlgo::TrackPtErrorSorter::~TrackPtErrorSorter
~TrackPtErrorSorter()
Definition: PFMuonAlgo.h:189
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PFMuonAlgo::isGlobalTightMuon
static bool isGlobalTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:67
PFMuonAlgo::TrackMETComparator
Definition: PFMuonAlgo.h:157
PFMuonAlgo::TrackMETComparator::mety_
double mety_
Definition: PFMuonAlgo.h:172
reco::TrackBase::TrackQuality
TrackQuality
track quality
Definition: TrackBase.h:150
PFMuonAlgo::minPostCleaningPt_
const double minPostCleaningPt_
Definition: PFMuonAlgo.h:134
PFMuonAlgo::metSigForRejection_
const double metSigForRejection_
Definition: PFMuonAlgo.h:137
PFMuonAlgo::maxDPtOPt_
const double maxDPtOPt_
Definition: PFMuonAlgo.h:127
PFMuonAlgo::reconstructMuon
bool reconstructMuon(reco::PFCandidate &, const reco::MuonRef &, bool allowLoose=false)
Definition: PFMuonAlgo.cc:537
edm::Handle< reco::MuonCollection >
PFMuonAlgo::metFactorCleaning_
const double metFactorCleaning_
Definition: PFMuonAlgo.h:138
edm::Ref< MuonCollection >
PFMuonAlgo::changeTrack
void changeTrack(reco::PFCandidate &, const MuonTrackTypePair &)
Definition: PFMuonAlgo.cc:596
PFMuonAlgo::isTrackerTightMuon
static bool isTrackerTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:85
PFMuonAlgo::trackQuality_
const reco::TrackBase::TrackQuality trackQuality_
Definition: PFMuonAlgo.h:129
PFMuonAlgo::IndexPtComparator::operator()
bool operator()(int mu1, int mu2)
Definition: PFMuonAlgo.h:180
PFMuonAlgo::vetoes_
const reco::PFCandidateCollection * vetoes_
Definition: PFMuonAlgo.h:120
PFMuonAlgo::pfCleanedTrackerAndGlobalMuonCandidates_
std::unique_ptr< reco::PFCandidateCollection > pfCleanedTrackerAndGlobalMuonCandidates_
the collection of tracker/global cleaned muon candidates
Definition: PFMuonAlgo.h:108
MuonFwd.h
reco::MuonCollection
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
PFBlockElement.h
PFMuonAlgo::TrackMETComparator::TrackMETComparator
TrackMETComparator(double METX, double METY)
Definition: PFMuonAlgo.h:159
PFMuonAlgo::cosmicRejDistance_
const double cosmicRejDistance_
Definition: PFMuonAlgo.h:148
PFMuonAlgo::pfFakeMuonCleanedCandidates_
std::unique_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:110
PFMuonAlgo::minPunchThroughMomentum_
const double minPunchThroughMomentum_
Definition: PFMuonAlgo.h:144
ParameterSetDescription.h
PFMuonAlgo::TrackPtErrorSorter::TrackPtErrorSorter
TrackPtErrorSorter()
Definition: PFMuonAlgo.h:188
PFMuonAlgo::eventFactorCosmics_
const double eventFactorCosmics_
Definition: PFMuonAlgo.h:135
PFMuonAlgo::MuonTrackTypePair
reco::Muon::MuonTrackTypePair MuonTrackTypePair
Definition: PFMuonAlgo.h:14
PFMuonAlgo::metFactorRejection_
const double metFactorRejection_
Definition: PFMuonAlgo.h:140
PFMuonAlgo::IndexPtComparator::coll_
const reco::PFCandidateCollection * coll_
Definition: PFMuonAlgo.h:183
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15161
PFMuonAlgo
Definition: PFMuonAlgo.h:13
PFMuonAlgo::TrackMETComparator::~TrackMETComparator
~TrackMETComparator()
Definition: PFMuonAlgo.h:163
PFMuonAlgo::transferAddedMuonCandidates
std::unique_ptr< reco::PFCandidateCollection > transferAddedMuonCandidates()
Definition: PFMuonAlgo.h:76
PFMuonAlgo::estimateEventQuantities
void estimateEventQuantities(const reco::PFCandidateCollection *)
Definition: PFMuonAlgo.cc:620
PFMuonAlgo::transferCleanedFakeCandidates
std::unique_ptr< reco::PFCandidateCollection > transferCleanedFakeCandidates()
Definition: PFMuonAlgo.h:64
PFMuonAlgo::printMuonProperties
static void printMuonProperties(const reco::MuonRef &muonRef)
Definition: PFMuonAlgo.cc:355
edm::ParameterSet
Definition: ParameterSet.h:47
PFMuonAlgo::isGlobalLooseMuon
static bool isGlobalLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:76
PFMuonAlgo::transferCleanedTrackerAndGlobalCandidates
std::unique_ptr< reco::PFCandidateCollection > transferCleanedTrackerAndGlobalCandidates()
Definition: PFMuonAlgo.h:60
PFMuonAlgo::setInputsForCleaning
void setInputsForCleaning(reco::VertexCollection const &)
Definition: PFMuonAlgo.cc:941
PFMuonAlgo::hasValidTrack
static bool hasValidTrack(const reco::MuonRef &muonRef, bool loose, double maxDPtOPt)
Definition: PFMuonAlgo.cc:348
PFMuonAlgo::errorCompScale_
const double errorCompScale_
Definition: PFMuonAlgo.h:130
PFMuonAlgo::vertices_
const reco::VertexCollection * vertices_
Definition: PFMuonAlgo.h:123
PFMuonAlgo::punchThroughFactor_
const double punchThroughFactor_
Definition: PFMuonAlgo.h:146
PFMuonAlgo::setVetoes
void setVetoes(const reco::PFCandidateCollection &vetoes)
Definition: PFMuonAlgo.h:54
PFMuonAlgo::pfPunchThroughHadronCleanedCandidates_
std::unique_ptr< reco::PFCandidateCollection > pfPunchThroughHadronCleanedCandidates_
the collection of punch-through cleaned neutral hadron candidates
Definition: PFMuonAlgo.h:114
PFMuonAlgo::transferPunchThroughCleanedMuonCandidates
std::unique_ptr< reco::PFCandidateCollection > transferPunchThroughCleanedMuonCandidates()
Definition: PFMuonAlgo.h:68
PFMuonAlgo::METY_
double METY_
Definition: PFMuonAlgo.h:153
PFMuonAlgo::PFMuonAlgo
PFMuonAlgo(edm::ParameterSet const &, bool postMuonCleaning)
constructor
Definition: PFMuonAlgo.cc:17
PFMuonAlgo::sumetPU_
double sumetPU_
Definition: PFMuonAlgo.h:150
reco::PFBlockElement
Abstract base class for a PFBlock element (track, cluster...)
Definition: PFBlockElement.h:26
PFMuonAlgo::IndexPtComparator::IndexPtComparator
IndexPtComparator(const reco::PFCandidateCollection *coll)
Definition: PFMuonAlgo.h:177
PFMuonAlgo::pfPunchThroughMuonCleanedCandidates_
std::unique_ptr< reco::PFCandidateCollection > pfPunchThroughMuonCleanedCandidates_
the collection of punch-through cleaned muon candidates
Definition: PFMuonAlgo.h:112
PFMuonAlgo::sumet_
double sumet_
Definition: PFMuonAlgo.h:151
PFMuonAlgo::TrackMETComparator::metx_
double metx_
Definition: PFMuonAlgo.h:171
PFMuonAlgo::getMinMaxMET2
std::pair< double, double > getMinMaxMET2(const reco::PFCandidate &)
Definition: PFMuonAlgo.cc:826
VertexFwd.h
PFMuonAlgo::pfAddedMuonCandidates_
std::unique_ptr< reco::PFCandidateCollection > pfAddedMuonCandidates_
the collection of added muon candidates
Definition: PFMuonAlgo.h:116
eostools.move
def move(src, dest)
Definition: eostools.py:511
PFMuonAlgo::punchThroughMETFactor_
const double punchThroughMETFactor_
Definition: PFMuonAlgo.h:147
PFMuonAlgo::isMuon
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:48
PFMuonAlgo::TrackMETComparator::operator()
bool operator()(const MuonTrackTypePair &mu1, const MuonTrackTypePair &mu2)
Definition: PFMuonAlgo.h:165
PFMuonAlgo::muAssocToTrack
static int muAssocToTrack(const reco::TrackRef &trackref, const reco::MuonCollection &muons)
Definition: PFMuonAlgo.cc:479
Vertex.h
PFMuonAlgo::eventFractionRejection_
const double eventFractionRejection_
Definition: PFMuonAlgo.h:139
reco::PFCandidateCollection
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
Definition: PFCandidateFwd.h:12
PFMuonAlgo::ptFactorHighEta_
const double ptFactorHighEta_
Definition: PFMuonAlgo.h:142
PFMuonAlgo::addMissingMuons
void addMissingMuons(edm::Handle< reco::MuonCollection >, reco::PFCandidateCollection *cands)
Definition: PFMuonAlgo.cc:724
PFMuonAlgo::eventFractionCleaning_
const double eventFractionCleaning_
Definition: PFMuonAlgo.h:133
PFMuonAlgo::muonTracks
static std::vector< reco::Muon::MuonTrackTypePair > muonTracks(const reco::MuonRef &muon, double maxDPtOPt=1e+9, bool includeSA=false)
Definition: PFMuonAlgo.cc:486
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
PFMuonAlgo::cleanPunchThroughAndFakes
bool cleanPunchThroughAndFakes(reco::PFCandidate &, reco::PFCandidateCollection *, unsigned int)
Definition: PFMuonAlgo.cc:943
PFMuonAlgo::postClean
void postClean(reco::PFCandidateCollection *)
Definition: PFMuonAlgo.cc:633
ParameterSet.h
PFMuonAlgo::IndexPtComparator
Definition: PFMuonAlgo.h:175
PFMuonAlgo::isTightMuonPOG
static bool isTightMuonPOG(const reco::MuonRef &muonRef)
Definition: PFMuonAlgo.cc:323
PFMuonAlgo::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
Definition: PFMuonAlgo.cc:1043
PFMuonAlgo::transferPunchThroughCleanedHadronCandidates
std::unique_ptr< reco::PFCandidateCollection > transferPunchThroughCleanedHadronCandidates()
Definition: PFMuonAlgo.h:72
PFMuonAlgo::metSigForCleaning_
const double metSigForCleaning_
Definition: PFMuonAlgo.h:136
PFMuonAlgo::isLooseMuon
static bool isLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:57
PFMuonAlgo::METX_
double METX_
Definition: PFMuonAlgo.h:152
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37