17 if ( pfCandPtr->trackRef().isNonnull() )
return pfCandPtr->trackRef().get();
18 else if ( pfCandPtr->gsfTrackRef().isNonnull() )
return pfCandPtr->gsfTrackRef().get();
33 return pfCandPtr->trackRef();
61 LogDebug(
"TauQCuts") <<
"<ptMin>: Pt = " << track->
pt() <<
", cut = " <<
cut ;
62 return (track->
pt() >
cut);
67 LogDebug(
"TauQCuts") <<
"<ptMin_cand>: Pt = " << cand.
pt() <<
", cut = " <<
cut ;
68 return (cand.
pt() >
cut);
73 LogDebug(
"TauQCuts") <<
"<etMin_cand>: Et = " << cand.
et() <<
", cut = " <<
cut ;
74 return (cand.
et() >
cut);
92 LogDebug(
"TauQCuts") <<
"<trkPixelHits_cand>: #Pxl hits = N/A, cut = " <<
cut ;
107 LogDebug(
"TauQCuts") <<
"<trkTrackerHits>: #Trk hits = " <<
track->hitPattern().numberOfValidHits() <<
", cut = " <<
cut ;
110 LogDebug(
"TauQCuts") <<
"<trkTrackerHits>: #Trk hits = N/A, cut = " <<
cut ;
118 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
119 "RecoTauQualityCuts is invalid. - trkTransverseImpactParameter";
122 LogDebug(
"TauQCuts") <<
" track: Pt = " << track->
pt() <<
", eta = " << track->
eta() <<
", phi = " << track->
phi() ;
123 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
124 LogDebug(
"TauQCuts") <<
"--> dxy = " << std::fabs(track->
dxy((*pv)->position())) <<
" (cut = " << cut <<
")" ;
125 return (std::fabs(track->
dxy((*pv)->position())) <=
cut);
134 LogDebug(
"TauQCuts") <<
"<trkTransverseImpactParameter_cand>: dXY = N/A, cut = " <<
cut ;
142 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
143 "RecoTauQualityCuts is invalid. - trkLongitudinalImpactParameter";
146 LogDebug(
"TauQCuts") <<
" track: Pt = " << track->
pt() <<
", eta = " << track->
eta() <<
", phi = " << track->
phi() ;
147 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
148 LogDebug(
"TauQCuts") <<
"--> dz = " << std::fabs(track->
dz((*pv)->position())) <<
" (cut = " << cut <<
")" ;
149 return (std::fabs(track->
dz((*pv)->position())) <=
cut);
158 LogDebug(
"TauQCuts") <<
"<trkLongitudinalImpactParameter_cand>: dZ = N/A, cut = " <<
cut ;
167 edm::LogError(
"QCutsNoValidLeadTrack") <<
"Lead track Ref in " <<
168 "RecoTauQualityCuts is invalid. - trkLongitudinalImpactParameterWrtTrack";
171 return (std::fabs(track->
dz((*pv)->position()) - leadTrack->
dz((*pv)->position())) <=
cut);
184 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
185 "RecoTauQualityCuts is invalid. - minTrackVertexWeight";
188 LogDebug(
"TauQCuts") <<
" track: Pt = " << track->
pt() <<
", eta = " << track->
eta() <<
", phi = " << track->
phi() ;
189 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
190 LogDebug(
"TauQCuts") <<
"--> trackWeight = " << (*pv)->trackWeight(track) <<
" (cut = " << cut <<
")" ;
191 return ((*pv)->trackWeight(track) >=
cut);
197 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
198 "RecoTauQualityCuts is invalid. - minTrackVertexWeight";
201 LogDebug(
"TauQCuts") <<
" track: Pt = " << track->pt() <<
", eta = " << track->eta() <<
", phi = " << track->phi() ;
202 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
203 LogDebug(
"TauQCuts") <<
"--> trackWeight = " << (*pv)->trackWeight(track) <<
" (cut = " << cut <<
")" ;
204 return ((*pv)->trackWeight(track) >=
cut);
210 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
211 "RecoTauQualityCuts is invalid. - minPackedCandVertexWeight";
221 LogDebug(
"TauQCuts") <<
" packedCand: Pt = " << pCand.
pt() <<
", eta = " << pCand.
eta() <<
", phi = " << pCand.
phi() ;
222 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
223 LogDebug(
"TauQCuts") <<
"--> trackWeight from packedCand = " << weight <<
" (cut = " << cut <<
")" ;
224 return (weight >= cut);
229 auto track = getTrackRef(cand);
230 if (
track.isNonnull() ) {
233 auto gsfTrack = getGsfTrackRef(cand);
234 if ( gsfTrack.isNonnull() ) {
239 if( pCand !=
nullptr && cand.
charge() != 0) {
242 LogDebug(
"TauQCuts") <<
"<minTrackVertexWeight_cand>: weight = N/A, cut = " <<
cut ;
256 LogDebug(
"TauQCuts") <<
"<trkChi2_cand>: chi^2 = " <<
track->normalizedChi2() <<
", cut = " <<
cut ;
259 LogDebug(
"TauQCuts") <<
"<trkChi2_cand>: chi^2 = N/A, cut = " <<
cut ;
267 for(
auto const&
func : cuts ) {
268 if ( !
func(track) )
return false;
275 for(
auto const&
func : cuts ) {
276 if ( !
func(cand) )
return false;
285 RecoTauQualityCuts::CandQCutFuncMap::const_iterator
cuts = funcMap.find(
std::abs(cand.
pdgId()));
287 if ( cuts == funcMap.end() )
return false;
288 return AND_cand(cand, cuts->second);
301 std::set<std::string> passedOptionSet;
304 for(
auto const&
option : passedOptions) {
305 passedOptionSet.insert(
option);
308 unsigned int nCuts = 0;
309 auto getDouble = [&qcuts, &passedOptionSet, &nCuts](
const std::string&
name) {
312 passedOptionSet.erase(
name);
317 auto getUint = [&qcuts, &passedOptionSet, &nCuts](
const std::string&
name) ->
unsigned int {
320 passedOptionSet.erase(
name);
327 minTrackPt_ = getDouble(
"minTrackPt");
328 maxTrackChi2_ = getDouble(
"maxTrackChi2");
329 minTrackPixelHits_ = getUint(
"minTrackPixelHits");
330 minTrackHits_ = getUint(
"minTrackHits");
331 maxTransverseImpactParameter_ = getDouble(
"maxTransverseImpactParameter");
332 maxDeltaZ_ = getDouble(
"maxDeltaZ");
333 maxDeltaZToLeadTrack_ = getDouble(
"maxDeltaZToLeadTrack");
335 minTrackVertexWeight_ = getDouble(
"minTrackVertexWeight");
338 checkHitPattern_ = (minTrackHits_ > 0) || (minTrackPixelHits_ > 0);
339 checkPV_ = (maxTransverseImpactParameter_ >= 0) ||
341 (maxDeltaZToLeadTrack_ >= 0) ||
342 (minTrackVertexWeight_ >= 0);
345 minGammaEt_ = getDouble(
"minGammaEt");
348 minNeutralHadronEt_ = getDouble(
"minNeutralHadronEt");
351 if ( !passedOptionSet.empty() ) {
353 bool thereIsABadParameter =
false;
354 for(
auto const&
option : passedOptionSet ) {
356 if (
option ==
"useTracksInsteadOfPFHadrons" ) {
358 if ( qcuts.
getParameter<
bool>(
"useTracksInsteadOfPFHadrons") ) {
360 <<
"The obsolete exception useTracksInsteadOfPFHadrons " 361 <<
"is set to true in the quality cut config." << std::endl;
367 thereIsABadParameter =
true;
369 unParsedOptions +=
option;
370 unParsedOptions +=
"\n";
372 if ( thereIsABadParameter ) {
374 <<
" The PSet passed to the RecoTauQualityCuts class had" 375 <<
" the following unrecognized options: " << std::endl
383 <<
" No options were passed to the quality cut class!" << std::endl;
393 for(
auto const&
cut : inputNames ) {
394 if (
cut ==
"minTrackVertexWeight" ||
395 cut ==
"maxDeltaZ" ||
396 cut ==
"maxDeltaZToLeadTrack" ) {
402 return std::make_pair(puCuts, nonPUCuts);
407 if (!filterTrack_(track.
get()))
409 if(minTrackVertexWeight_ >= 0. && !(pv_->trackWeight(convertRef(track)) >= minTrackVertexWeight_))
return false;
415 if (!filterTrack_(track.
get()))
417 if(minTrackVertexWeight_ >= 0. && !(pv_->trackWeight(convertRef(track)) >= minTrackVertexWeight_))
return false;
423 return filterTrack_(&track);
428 if(minTrackPt_ >= 0 && !(track->
pt() > minTrackPt_))
return false;
429 if(maxTrackChi2_ >= 0 && !(track->
normalizedChi2() <= maxTrackChi2_))
return false;
430 if(checkHitPattern_) {
433 if(minTrackHits_ > 0 && !(hitPattern.
numberOfValidHits() >= minTrackHits_))
return false;
435 if(checkPV_ && pv_.isNull()) {
436 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
437 "RecoTauQualityCuts is invalid. - filterTrack";
441 if(maxTransverseImpactParameter_ >= 0 &&
442 !(std::fabs(track->
dxy(pv_->position())) <= maxTransverseImpactParameter_))
444 if(maxDeltaZ_ >= 0 && !(std::fabs(track->
dz(pv_->position())) <= maxDeltaZ_))
return false;
445 if(maxDeltaZToLeadTrack_ >= 0) {
447 edm::LogError(
"QCutsNoValidLeadTrack") <<
"Lead track Ref in " <<
448 "RecoTauQualityCuts is invalid. - filterTrack";
452 if(!(std::fabs(track->
dz(pv_->position()) - leadTrack_->dz(pv_->position())) <= maxDeltaZToLeadTrack_))
464 if (pCand ==
nullptr)
470 if (
track !=
nullptr){
471 if (!filterTrack(*
track))
474 if(minTrackPt_ >= 0 && !(pCand->
pt() > minTrackPt_))
return false;
475 if(checkPV_ && pv_.isNull()) {
476 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
477 "RecoTauQualityCuts is invalid. - filterChargedCand";
481 if(maxTransverseImpactParameter_ >= 0 &&
482 !(std::fabs(pCand->
dxy(pv_->position())) <= maxTransverseImpactParameter_))
484 if(maxDeltaZ_ >= 0 && !(std::fabs(pCand->
dz(pv_->position())) <= maxDeltaZ_))
return false;
485 if(maxDeltaZToLeadTrack_ >= 0) {
486 if ( leadTrack_ ==
nullptr) {
487 edm::LogError(
"QCutsNoValidLeadTrack") <<
"Lead track Ref in " <<
488 "RecoTauQualityCuts is invalid. - filterChargedCand";
492 if(!(std::fabs(pCand->
dz(pv_->position()) - leadTrack_->dz(pv_->position())) <= maxDeltaZToLeadTrack_))
496 if(minTrackVertexWeight_ >= 0. &&
504 if(minGammaEt_ >= 0 && !(cand.
et() > minGammaEt_))
return false;
509 if(minNeutralHadronEt_ >= 0 && !(cand.
et() > minNeutralHadronEt_))
return false;
516 return filterGammaCand(cand);
518 return filterNeutralHadronCand(cand);
534 auto trackRef = getTrackRef(cand);
537 if (trackRef.isNonnull()) {
538 result = filterTrack(trackRef);
541 auto gsfTrackRef = getGsfTrackRef(cand);
542 if (gsfTrackRef.isNonnull())
543 result = filterTrack(gsfTrackRef);
544 else if (cand.
charge() != 0) {
545 result = filterChargedCand(cand);
550 result = filterCandByType(cand);
571 leadTrack_ =
nullptr;
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
std::map< int, CandQCutFuncCollection > CandQCutFuncMap
value_type const * get() const
void setLeadTrack(const reco::Track &leadTrack) const
Update the leading track.
T getParameter(std::string const &) const
bool minTrackVertexWeight(const TrackBaseRef &track, const reco::VertexRef *pv, double cut)
bool isNonnull() const
Checks for non-null.
bool AND_cand(const Candidate &cand, const RecoTauQualityCuts::CandQCutFuncCollection &cuts)
bool trkLongitudinalImpactParameterWrtTrack(const Track *track, const Track *leadTrack, const reco::VertexRef *pv, double cut)
DZ cut, with respect to the current lead rack.
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)
int numberOfValidHits() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
double phi() const
azimuthal angle of momentum vector
key_type key() const
Accessor for product key.
bool filterCand(const reco::Candidate &cand) const
Filter a single Candidate.
const reco::VertexRef vertexRef() const
InputIterator leadCand(InputIterator begin, InputIterator end)
bool trkPixelHits_cand(const Candidate &cand, int cut)
static std::string const input
std::vector< CandQCutFunc > CandQCutFuncCollection
virtual double et() const =0
transverse energy
void copyFrom(ParameterSet const &from, std::string const &name)
double eta() const
pseudorapidity of momentum vector
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
const PVAssociationQuality pvAssociationQuality() const
virtual int pdgId() const =0
PDG identifier.
bool trkTrackerHits_cand(const Candidate &cand, int cut)
bool filterCandByType(const reco::Candidate &cand) const
double pt() const
track transverse momentum
bool ptMin_cand(const Candidate &cand, double cut)
Abs< T >::type abs(const T &t)
bool trkChi2_cand(const Candidate &cand, double cut)
virtual const reco::Track & pseudoTrack() const
bool trkChi2(const Track *track, double cut)
double pt() const override
transverse momentum
T const * get() const
Returns C++ pointer to the item.
std::pair< edm::ParameterSet, edm::ParameterSet > factorizePUQCuts(const edm::ParameterSet &inputSet)
bool trkLongitudinalImpactParameter_cand(const Candidate &cand, const reco::VertexRef *pv, double cut)
std::vector< TrackQCutFunc > TrackQCutFuncCollection
std::vector< std::string > getParameterNames() const
bool etMin_cand(const Candidate &cand, double cut)
bool ptMin(const TrackBaseRef &track, double cut)
bool isNull() const
Checks for null.
bool filterTrack_(const reco::Track *track) const
bool mapAndCutByType(const Candidate &cand, const RecoTauQualityCuts::CandQCutFuncMap &funcMap)
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
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...
double eta() const override
momentum pseudorapidity
double phi() const override
momentum azimuthal angle
static const TrackGhostTrackState * getTrack(const BasicGhostTrackState *basic)
bool trkTransverseImpactParameter(const Track *track, const reco::VertexRef *pv, double cut)
bool filterChargedCand(const reco::Candidate &cand) const
or a single charged candidate
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
virtual double pt() const =0
transverse momentum
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
bool filterNeutralHadronCand(const reco::Candidate &cand) const
bool trkTrackerHits(const Track *track, int cut)
virtual int charge() const =0
electric charge
bool trkLongitudinalImpactParameterWrtTrack_cand(const Candidate &cand, const reco::Track *leadTrack, const reco::VertexRef *pv, double cut)
bool trkPixelHits(const Track *track, int cut)
bool AND(const TrackBaseRef &track, const RecoTauQualityCuts::TrackQCutFuncCollection &cuts)
int numberOfValidPixelHits() const
bool filterGammaCand(const reco::Candidate &cand) const
virtual float dxy() const
dxy with respect to the PV ref
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 trkLongitudinalImpactParameter(const TrackBase *track, const reco::VertexRef *pv, double cut)
bool minPackedCandVertexWeight(const pat::PackedCandidate &pCand, const reco::VertexRef *pv, double cut)
bool filterTrack(const reco::TrackBaseRef &track) const
Filter a single Track.
bool minTrackVertexWeight_cand(const Candidate &cand, const reco::VertexRef *pv, double cut)
bool trkTransverseImpactParameter_cand(const Candidate &cand, const reco::VertexRef *pv, double cut)