7 #include <boost/bind.hpp> 16 else if ( cand.gsfTrackRef().isNonnull() )
return reco::TrackBaseRef(cand.gsfTrackRef());
32 LogDebug(
"TauQCuts") <<
"<ptMin>: Pt = " << track->
pt() <<
", cut = " <<
cut ;
33 return (track->
pt() >
cut);
38 LogDebug(
"TauQCuts") <<
"<ptMin_cand>: Pt = " << cand.
pt() <<
", cut = " <<
cut ;
39 return (cand.
pt() >
cut);
44 LogDebug(
"TauQCuts") <<
"<etMin_cand>: Et = " << cand.
et() <<
", cut = " <<
cut ;
45 return (cand.
et() >
cut);
58 auto track = getTrackRef(cand);
59 if (
track.isNonnull() ) {
63 LogDebug(
"TauQCuts") <<
"<trkPixelHits_cand>: #Pxl hits = N/A, cut = " <<
cut ;
76 auto track = getTrackRef(cand);
77 if (
track.isNonnull() ) {
78 LogDebug(
"TauQCuts") <<
"<trkTrackerHits>: #Trk hits = " <<
track->hitPattern().numberOfValidHits() <<
", cut = " <<
cut ;
81 LogDebug(
"TauQCuts") <<
"<trkTrackerHits>: #Trk hits = N/A, cut = " <<
cut ;
89 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
90 "RecoTauQualityCuts is invalid. - trkTransverseImpactParameter";
93 LogDebug(
"TauQCuts") <<
" track: Pt = " << track->
pt() <<
", eta = " << track->
eta() <<
", phi = " << track->
phi() ;
94 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
95 LogDebug(
"TauQCuts") <<
"--> dxy = " << std::fabs(track->
dxy((*pv)->position())) <<
" (cut = " << cut <<
")" ;
96 return (std::fabs(track->
dxy((*pv)->position())) <=
cut);
101 auto track = getTrackRef(cand);
102 if (
track.isNonnull() ) {
105 LogDebug(
"TauQCuts") <<
"<trkTransverseImpactParameter_cand>: dXY = N/A, cut = " <<
cut ;
113 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
114 "RecoTauQualityCuts is invalid. - trkLongitudinalImpactParameter";
117 LogDebug(
"TauQCuts") <<
" track: Pt = " << track->
pt() <<
", eta = " << track->
eta() <<
", phi = " << track->
phi() ;
118 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
119 LogDebug(
"TauQCuts") <<
"--> dz = " << std::fabs(track->
dz((*pv)->position())) <<
" (cut = " << cut <<
")" ;
120 return (std::fabs(track->
dz((*pv)->position())) <=
cut);
125 auto track = getTrackRef(cand);
126 if (
track.isNonnull() ) {
129 LogDebug(
"TauQCuts") <<
"<trkLongitudinalImpactParameter_cand>: dZ = N/A, cut = " <<
cut ;
137 if ( leadTrack->isNull()) {
138 edm::LogError(
"QCutsNoValidLeadTrack") <<
"Lead track Ref in " <<
139 "RecoTauQualityCuts is invalid. - trkLongitudinalImpactParameterWrtTrack";
142 return (std::fabs(track->
dz((*pv)->position()) - (*leadTrack)->dz((*pv)->position())) <=
cut);
147 auto track = getTrackRef(cand);
155 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
156 "RecoTauQualityCuts is invalid. - minTrackVertexWeight";
159 LogDebug(
"TauQCuts") <<
" track: Pt = " << track->
pt() <<
", eta = " << track->
eta() <<
", phi = " << track->
phi() ;
160 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
161 LogDebug(
"TauQCuts") <<
"--> trackWeight = " << (*pv)->trackWeight(track) <<
" (cut = " << cut <<
")" ;
162 return ((*pv)->trackWeight(track) >=
cut);
167 auto track = getTrackRef(cand);
168 if (
track.isNonnull() ) {
171 LogDebug(
"TauQCuts") <<
"<minTrackVertexWeight_cand>: weight = N/A, cut = " <<
cut ;
184 auto track = getTrackRef(cand);
185 if (
track.isNonnull() ) {
186 LogDebug(
"TauQCuts") <<
"<trkChi2_cand>: chi^2 = " <<
track->normalizedChi2() <<
", cut = " <<
cut ;
189 LogDebug(
"TauQCuts") <<
"<trkChi2_cand>: chi^2 = N/A, cut = " <<
cut ;
198 if ( !
func(track) )
return false;
206 if ( !
func(cand) )
return false;
215 RecoTauQualityCuts::CandQCutFuncMap::const_iterator
cuts = funcMap.find(cand.
particleId());
217 if ( cuts == funcMap.end() )
return false;
218 return AND_cand(cand, cuts->second);
231 std::set<std::string> passedOptionSet;
235 passedOptionSet.insert(option);
238 unsigned int nCuts = 0;
239 auto getDouble = [&qcuts, &passedOptionSet, &nCuts](
const std::string&
name) {
242 passedOptionSet.erase(
name);
247 auto getUint = [&qcuts, &passedOptionSet, &nCuts](
const std::string&
name) ->
unsigned int {
250 passedOptionSet.erase(
name);
257 minTrackPt_ = getDouble(
"minTrackPt");
258 maxTrackChi2_ = getDouble(
"maxTrackChi2");
259 minTrackPixelHits_ = getUint(
"minTrackPixelHits");
260 minTrackHits_ = getUint(
"minTrackHits");
261 maxTransverseImpactParameter_ = getDouble(
"maxTransverseImpactParameter");
262 maxDeltaZ_ = getDouble(
"maxDeltaZ");
263 maxDeltaZToLeadTrack_ = getDouble(
"maxDeltaZToLeadTrack");
265 minTrackVertexWeight_ = getDouble(
"minTrackVertexWeight");
268 checkHitPattern_ = (minTrackHits_ > 0) || (minTrackPixelHits_ > 0);
269 checkPV_ = (maxTransverseImpactParameter_ >= 0) ||
271 (maxDeltaZToLeadTrack_ >= 0) ||
272 (minTrackVertexWeight_ >= 0);
275 minGammaEt_ = getDouble(
"minGammaEt");
278 minNeutralHadronEt_ = getDouble(
"minNeutralHadronEt");
281 if ( !passedOptionSet.empty() ) {
283 bool thereIsABadParameter =
false;
284 BOOST_FOREACH(
const std::string& option, passedOptionSet ) {
286 if ( option ==
"useTracksInsteadOfPFHadrons" ) {
288 if ( qcuts.
getParameter<
bool>(
"useTracksInsteadOfPFHadrons") ) {
290 <<
"The obsolete exception useTracksInsteadOfPFHadrons " 291 <<
"is set to true in the quality cut config." << std::endl;
297 thereIsABadParameter =
true;
299 unParsedOptions +=
option;
300 unParsedOptions +=
"\n";
302 if ( thereIsABadParameter ) {
304 <<
" The PSet passed to the RecoTauQualityCuts class had" 305 <<
" the following unrecognized options: " << std::endl
313 <<
" No options were passed to the quality cut class!" << std::endl;
324 if ( cut ==
"minTrackVertexWeight" ||
325 cut ==
"maxDeltaZ" ||
326 cut ==
"maxDeltaZToLeadTrack" ) {
332 return std::make_pair(puCuts, nonPUCuts);
337 return filterTrack_(track);
342 return filterTrack_(track);
345 template <
typename T>
349 if(minTrackPt_ >= 0 && !(track->
pt() > minTrackPt_))
return false;
350 if(maxTrackChi2_ >= 0 && !(track->
normalizedChi2() <= maxTrackChi2_))
return false;
351 if(checkHitPattern_) {
354 if(minTrackHits_ > 0 && !(hitPattern.
numberOfValidHits() >= minTrackHits_))
return false;
356 if(checkPV_ && pv_.isNull()) {
357 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
358 "RecoTauQualityCuts is invalid. - filterTrack";
362 if(maxTransverseImpactParameter_ >= 0 &&
363 !(std::fabs(track->
dxy(pv_->position())) <= maxTransverseImpactParameter_))
365 if(maxDeltaZ_ >= 0 && !(std::fabs(track->
dz(pv_->position())) <= maxDeltaZ_))
return false;
366 if(maxDeltaZToLeadTrack_ >= 0) {
367 if ( leadTrack_.isNull()) {
368 edm::LogError(
"QCutsNoValidLeadTrack") <<
"Lead track Ref in " <<
369 "RecoTauQualityCuts is invalid. - filterTrack";
373 if(!(std::fabs(track->
dz(pv_->position()) - leadTrack_->dz(pv_->position())) <= maxDeltaZToLeadTrack_))
376 if(minTrackVertexWeight_ > -1.0 && !(pv_->trackWeight(convertRef(trackRef)) >= minTrackVertexWeight_))
return false;
382 if(minGammaEt_ >= 0 && !(cand.
et() > minGammaEt_))
return false;
387 if(minNeutralHadronEt_ >= 0 && !(cand.
et() > minNeutralHadronEt_))
return false;
394 return filterGammaCand(cand);
396 return filterNeutralHadronCand(cand);
414 if(trackRef.isNonnull()) {
415 result = filterTrack_(trackRef);
419 if(gsfTrackRef.isNonnull()) {
420 result = filterTrack_(gsfTrackRef);
424 result = filterCandByType(cand);
435 leadTrack_ = getTrackRef(leadCand);
441 leadTrack_ = getTrackRef(*leadCand);
T getParameter(std::string const &) const
bool filterCandByType(const reco::PFCandidate &cand) const
bool trkLongitudinalImpactParameter_cand(const PFCandidate &cand, const reco::VertexRef *pv, double cut)
bool minTrackVertexWeight(const TrackBaseRef &track, const reco::VertexRef *pv, double cut)
bool isNonnull() const
Checks for non-null.
bool trkTransverseImpactParameter_cand(const PFCandidate &cand, const reco::VertexRef *pv, double cut)
RecoTauQualityCuts(const edm::ParameterSet &qcuts)
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
bool minTrackVertexWeight_cand(const PFCandidate &cand, const reco::VertexRef *pv, double cut)
int numberOfValidHits() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
bool etMin_cand(const PFCandidate &cand, double cut)
double phi() const
azimuthal angle of momentum vector
double pt() const final
transverse momentum
bool trkPixelHits(const TrackBaseRef &track, int cut)
bool filterTrack_(const T &trackRef) const
bool filterNeutralHadronCand(const reco::PFCandidate &cand) const
bool trkTransverseImpactParameter(const TrackBaseRef &track, const reco::VertexRef *pv, double cut)
static std::string const input
std::vector< CandQCutFunc > CandQCutFuncCollection
reco::TrackRef trackRef() const
bool filterGammaCand(const reco::PFCandidate &cand) const
void copyFrom(ParameterSet const &from, std::string const &name)
double eta() const
pseudorapidity of momentum vector
bool trkLongitudinalImpactParameterWrtTrack_cand(const PFCandidate &cand, const reco::TrackBaseRef *leadTrack, const reco::VertexRef *pv, double cut)
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
double et() const final
transverse energy
std::map< PFCandidate::ParticleType, CandQCutFuncCollection > CandQCutFuncMap
double pt() const
track transverse momentum
std::pair< edm::ParameterSet, edm::ParameterSet > factorizePUQCuts(const edm::ParameterSet &inputSet)
std::vector< TrackQCutFunc > TrackQCutFuncCollection
std::vector< std::string > getParameterNames() const
bool ptMin(const TrackBaseRef &track, double cut)
bool isNull() const
Checks for null.
bool trkTrackerHits(const TrackBaseRef &track, int cut)
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
bool trkTrackerHits_cand(const PFCandidate &cand, int cut)
bool mapAndCutByType(const PFCandidate &cand, const RecoTauQualityCuts::CandQCutFuncMap &funcMap)
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
boost::function< bool(const TrackBaseRef &)> TrackQCutFunc
bool ptMin_cand(const PFCandidate &cand, double cut)
bool trkChi2_cand(const PFCandidate &cand, double cut)
boost::function< bool(const PFCandidate &)> CandQCutFunc
bool trkChi2(const TrackBaseRef &track, double cut)
Particle reconstructed by the particle flow algorithm.
bool AND(const TrackBaseRef &track, const RecoTauQualityCuts::TrackQCutFuncCollection &cuts)
bool trkLongitudinalImpactParameter(const TrackBaseRef &track, const reco::VertexRef *pv, double cut)
reco::GsfTrackRef gsfTrackRef() const
bool trkPixelHits_cand(const PFCandidate &cand, int cut)
int numberOfValidPixelHits() const
void setLeadTrack(const reco::TrackRef &leadTrack) const
Update the leading track.
bool trkLongitudinalImpactParameterWrtTrack(const TrackBaseRef &track, const reco::TrackBaseRef *leadTrack, const reco::VertexRef *pv, double cut)
DZ cut, with respect to the current lead rack.
bool filterCand(const reco::PFCandidate &cand) const
Filter a single PFCandidate.
virtual ParticleType particleId() const
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
bool AND_cand(const PFCandidate &cand, const RecoTauQualityCuts::CandQCutFuncCollection &cuts)
bool filterTrack(const reco::TrackBaseRef &track) const
Filter a single Track.