Go to the documentation of this file.00001 #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h"
00002 #include "DataFormats/VertexReco/interface/Vertex.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004
00005 #include <boost/bind.hpp>
00006
00007 namespace reco { namespace tau {
00008
00009
00010 namespace qcuts {
00011
00012 bool ptMin(const PFCandidate& cand, double cut) {
00013 return cand.pt() > cut;
00014 }
00015
00016 bool etMin(const PFCandidate& cand, double cut) {
00017 return cand.et() > cut;
00018 }
00019
00020 bool trkPixelHits(const PFCandidate& cand, int cut) {
00021
00022 TrackRef trk = cand.trackRef();
00023 if (!trk) return false;
00024 return trk->hitPattern().numberOfValidPixelHits() >= cut;
00025 }
00026
00027 bool trkTrackerHits(const PFCandidate& cand, int cut) {
00028 TrackRef trk = cand.trackRef();
00029 if (!trk) return false;
00030 return trk->hitPattern().numberOfValidHits() >= cut;
00031 }
00032
00033 bool trkTransverseImpactParameter(const PFCandidate& cand,
00034 const reco::VertexRef* pv,
00035 double cut) {
00036 if (pv->isNull()) {
00037 edm::LogError("QCutsNoPrimaryVertex") << "Primary vertex Ref in " <<
00038 "RecoTauQualityCuts is invalid. - trkTransverseImpactParameter";
00039 return false;
00040 }
00041 TrackRef trk = cand.trackRef();
00042 if (!trk) return false;
00043 return std::abs(trk->dxy((*pv)->position())) <= cut;
00044 }
00045
00046 bool trkLongitudinalImpactParameter(const PFCandidate& cand,
00047 const reco::VertexRef* pv,
00048 double cut) {
00049 if (pv->isNull()) {
00050 edm::LogError("QCutsNoPrimaryVertex") << "Primary vertex Ref in " <<
00051 "RecoTauQualityCuts is invalid. - trkLongitudinalImpactParameter";
00052 return false;
00053 }
00054 TrackRef trk = cand.trackRef();
00055 if (!trk) return false;
00056 return std::abs(trk->dz((*pv)->position())) <= cut;
00057 }
00058
00059 bool trkChi2(const PFCandidate& cand, double cut) {
00060 TrackRef trk = cand.trackRef();
00061 if (!trk) return false;
00062 return trk->normalizedChi2() <= cut;
00063 }
00064
00065
00066 bool AND(const PFCandidate& cand,
00067 const RecoTauQualityCuts::QCutFuncCollection& cuts) {
00068 BOOST_FOREACH(const RecoTauQualityCuts::QCutFunc& func, cuts) {
00069 if (!func(cand))
00070 return false;
00071 }
00072 return true;
00073 }
00074
00075
00076 bool mapAndCutByType(const PFCandidate& cand,
00077 const RecoTauQualityCuts::QCutFuncMap& funcMap) {
00078
00079 RecoTauQualityCuts::QCutFuncMap::const_iterator cuts =
00080 funcMap.find(cand.particleId());
00081
00082 if (cuts == funcMap.end())
00083 return false;
00084 else
00085
00086 return AND(cand, cuts->second);
00087 }
00088
00089 }
00090
00091 RecoTauQualityCuts::RecoTauQualityCuts(const edm::ParameterSet &qcuts) {
00092
00093 QCutFuncCollection chargedHadronCuts;
00094 QCutFuncCollection gammaCuts;
00095 QCutFuncCollection neutralHadronCuts;
00096
00097
00098 if (qcuts.exists("minTrackPt"))
00099 chargedHadronCuts.push_back(
00100 boost::bind(qcuts::ptMin, _1,
00101 qcuts.getParameter<double>("minTrackPt")));
00102
00103 if (qcuts.exists("maxTrackChi2"))
00104 chargedHadronCuts.push_back(
00105 boost::bind(qcuts::trkChi2, _1,
00106 qcuts.getParameter<double>("maxTrackChi2")));
00107
00108 if (qcuts.exists("minTrackPixelHits"))
00109 chargedHadronCuts.push_back(boost::bind(
00110 qcuts::trkPixelHits, _1,
00111 qcuts.getParameter<uint32_t>("minTrackPixelHits")));
00112
00113 if (qcuts.exists("minTrackHits"))
00114 chargedHadronCuts.push_back(boost::bind(
00115 qcuts::trkTrackerHits, _1,
00116 qcuts.getParameter<uint32_t>("minTrackHits")));
00117
00118
00119
00120 if (qcuts.exists("maxTransverseImpactParameter"))
00121 chargedHadronCuts.push_back(boost::bind(
00122 qcuts::trkTransverseImpactParameter, _1, &pv_,
00123 qcuts.getParameter<double>("maxTransverseImpactParameter")));
00124
00125 if (qcuts.exists("maxDeltaZ"))
00126 chargedHadronCuts.push_back(boost::bind(
00127 qcuts::trkLongitudinalImpactParameter, _1, &pv_,
00128 qcuts.getParameter<double>("maxDeltaZ")));
00129
00130
00131 if (qcuts.exists("minGammaEt"))
00132 gammaCuts.push_back(boost::bind(
00133 qcuts::etMin, _1, qcuts.getParameter<double>("minGammaEt")));
00134
00135
00136 if (qcuts.exists("minNeutralHadronEt"))
00137 neutralHadronCuts.push_back(boost::bind(
00138 qcuts::etMin, _1,
00139 qcuts.getParameter<double>("minNeutralHadronEt")));
00140
00141
00142 qcuts_[PFCandidate::h] = chargedHadronCuts;
00143 qcuts_[PFCandidate::gamma] = gammaCuts;
00144 qcuts_[PFCandidate::h0] = neutralHadronCuts;
00145
00146 qcuts_[PFCandidate::e] = chargedHadronCuts;
00147 qcuts_[PFCandidate::mu] = chargedHadronCuts;
00148
00149
00150 predicate_ = boost::bind(qcuts::mapAndCutByType, _1, boost::cref(qcuts_));
00151 }
00152
00153 }}