14 else if ( cand.gsfTrackRef().isNonnull() )
return reco::TrackBaseRef(cand.gsfTrackRef());
30 LogDebug(
"TauQCuts") <<
"<ptMin>: Pt = " << track->
pt() <<
", cut = " <<
cut ;
31 return (track->
pt() >
cut);
36 LogDebug(
"TauQCuts") <<
"<ptMin_cand>: Pt = " << cand.
pt() <<
", cut = " <<
cut ;
37 return (cand.
pt() >
cut);
42 LogDebug(
"TauQCuts") <<
"<etMin_cand>: Et = " << cand.
et() <<
", cut = " <<
cut ;
43 return (cand.
et() >
cut);
56 auto track = getTrackRef(cand);
57 if (
track.isNonnull() ) {
61 LogDebug(
"TauQCuts") <<
"<trkPixelHits_cand>: #Pxl hits = N/A, cut = " <<
cut ;
74 auto track = getTrackRef(cand);
75 if (
track.isNonnull() ) {
76 LogDebug(
"TauQCuts") <<
"<trkTrackerHits>: #Trk hits = " <<
track->hitPattern().numberOfValidHits() <<
", cut = " <<
cut ;
79 LogDebug(
"TauQCuts") <<
"<trkTrackerHits>: #Trk hits = N/A, cut = " <<
cut ;
87 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
88 "RecoTauQualityCuts is invalid. - trkTransverseImpactParameter";
91 LogDebug(
"TauQCuts") <<
" track: Pt = " << track->
pt() <<
", eta = " << track->
eta() <<
", phi = " << track->
phi() ;
92 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
93 LogDebug(
"TauQCuts") <<
"--> dxy = " << std::fabs(track->
dxy((*pv)->position())) <<
" (cut = " << cut <<
")" ;
94 return (std::fabs(track->
dxy((*pv)->position())) <=
cut);
99 auto track = getTrackRef(cand);
100 if (
track.isNonnull() ) {
103 LogDebug(
"TauQCuts") <<
"<trkTransverseImpactParameter_cand>: dXY = N/A, cut = " <<
cut ;
111 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
112 "RecoTauQualityCuts is invalid. - trkLongitudinalImpactParameter";
115 LogDebug(
"TauQCuts") <<
" track: Pt = " << track->
pt() <<
", eta = " << track->
eta() <<
", phi = " << track->
phi() ;
116 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
117 LogDebug(
"TauQCuts") <<
"--> dz = " << std::fabs(track->
dz((*pv)->position())) <<
" (cut = " << cut <<
")" ;
118 return (std::fabs(track->
dz((*pv)->position())) <=
cut);
123 auto track = getTrackRef(cand);
124 if (
track.isNonnull() ) {
127 LogDebug(
"TauQCuts") <<
"<trkLongitudinalImpactParameter_cand>: dZ = N/A, cut = " <<
cut ;
135 if ( leadTrack->isNull()) {
136 edm::LogError(
"QCutsNoValidLeadTrack") <<
"Lead track Ref in " <<
137 "RecoTauQualityCuts is invalid. - trkLongitudinalImpactParameterWrtTrack";
140 return (std::fabs(track->
dz((*pv)->position()) - (*leadTrack)->dz((*pv)->position())) <=
cut);
145 auto track = getTrackRef(cand);
153 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
154 "RecoTauQualityCuts is invalid. - minTrackVertexWeight";
157 LogDebug(
"TauQCuts") <<
" track: Pt = " << track->
pt() <<
", eta = " << track->
eta() <<
", phi = " << track->
phi() ;
158 LogDebug(
"TauQCuts") <<
" vertex: x = " << (*pv)->position().x() <<
", y = " << (*pv)->position().y() <<
", z = " << (*pv)->position().z() ;
159 LogDebug(
"TauQCuts") <<
"--> trackWeight = " << (*pv)->trackWeight(track) <<
" (cut = " << cut <<
")" ;
160 return ((*pv)->trackWeight(track) >=
cut);
165 auto track = getTrackRef(cand);
166 if (
track.isNonnull() ) {
169 LogDebug(
"TauQCuts") <<
"<minTrackVertexWeight_cand>: weight = N/A, cut = " <<
cut ;
182 auto track = getTrackRef(cand);
183 if (
track.isNonnull() ) {
184 LogDebug(
"TauQCuts") <<
"<trkChi2_cand>: chi^2 = " <<
track->normalizedChi2() <<
", cut = " <<
cut ;
187 LogDebug(
"TauQCuts") <<
"<trkChi2_cand>: chi^2 = N/A, cut = " <<
cut ;
195 for(
auto const&
func : cuts ) {
196 if ( !
func(track) )
return false;
203 for(
auto const&
func : cuts ) {
204 if ( !
func(cand) )
return false;
213 RecoTauQualityCuts::CandQCutFuncMap::const_iterator
cuts = funcMap.find(cand.
particleId());
215 if ( cuts == funcMap.end() )
return false;
216 return AND_cand(cand, cuts->second);
229 std::set<std::string> passedOptionSet;
232 for(
auto const&
option : passedOptions) {
233 passedOptionSet.insert(
option);
236 unsigned int nCuts = 0;
237 auto getDouble = [&qcuts, &passedOptionSet, &nCuts](
const std::string&
name) {
240 passedOptionSet.erase(
name);
245 auto getUint = [&qcuts, &passedOptionSet, &nCuts](
const std::string&
name) ->
unsigned int {
248 passedOptionSet.erase(
name);
255 minTrackPt_ = getDouble(
"minTrackPt");
256 maxTrackChi2_ = getDouble(
"maxTrackChi2");
257 minTrackPixelHits_ = getUint(
"minTrackPixelHits");
258 minTrackHits_ = getUint(
"minTrackHits");
259 maxTransverseImpactParameter_ = getDouble(
"maxTransverseImpactParameter");
260 maxDeltaZ_ = getDouble(
"maxDeltaZ");
261 maxDeltaZToLeadTrack_ = getDouble(
"maxDeltaZToLeadTrack");
263 minTrackVertexWeight_ = getDouble(
"minTrackVertexWeight");
266 checkHitPattern_ = (minTrackHits_ > 0) || (minTrackPixelHits_ > 0);
267 checkPV_ = (maxTransverseImpactParameter_ >= 0) ||
269 (maxDeltaZToLeadTrack_ >= 0) ||
270 (minTrackVertexWeight_ >= 0);
273 minGammaEt_ = getDouble(
"minGammaEt");
276 minNeutralHadronEt_ = getDouble(
"minNeutralHadronEt");
279 if ( !passedOptionSet.empty() ) {
281 bool thereIsABadParameter =
false;
282 for(
auto const&
option : passedOptionSet ) {
284 if (
option ==
"useTracksInsteadOfPFHadrons" ) {
286 if ( qcuts.
getParameter<
bool>(
"useTracksInsteadOfPFHadrons") ) {
288 <<
"The obsolete exception useTracksInsteadOfPFHadrons " 289 <<
"is set to true in the quality cut config." << std::endl;
295 thereIsABadParameter =
true;
297 unParsedOptions +=
option;
298 unParsedOptions +=
"\n";
300 if ( thereIsABadParameter ) {
302 <<
" The PSet passed to the RecoTauQualityCuts class had" 303 <<
" the following unrecognized options: " << std::endl
311 <<
" No options were passed to the quality cut class!" << std::endl;
321 for(
auto const&
cut : inputNames ) {
322 if (
cut ==
"minTrackVertexWeight" ||
323 cut ==
"maxDeltaZ" ||
324 cut ==
"maxDeltaZToLeadTrack" ) {
330 return std::make_pair(puCuts, nonPUCuts);
335 return filterTrack_(track);
340 return filterTrack_(track);
343 template <
typename T>
347 if(minTrackPt_ >= 0 && !(track->
pt() > minTrackPt_))
return false;
348 if(maxTrackChi2_ >= 0 && !(track->
normalizedChi2() <= maxTrackChi2_))
return false;
349 if(checkHitPattern_) {
352 if(minTrackHits_ > 0 && !(hitPattern.
numberOfValidHits() >= minTrackHits_))
return false;
354 if(checkPV_ && pv_.isNull()) {
355 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
356 "RecoTauQualityCuts is invalid. - filterTrack";
360 if(maxTransverseImpactParameter_ >= 0 &&
361 !(std::fabs(track->
dxy(pv_->position())) <= maxTransverseImpactParameter_))
363 if(maxDeltaZ_ >= 0 && !(std::fabs(track->
dz(pv_->position())) <= maxDeltaZ_))
return false;
364 if(maxDeltaZToLeadTrack_ >= 0) {
365 if ( leadTrack_.isNull()) {
366 edm::LogError(
"QCutsNoValidLeadTrack") <<
"Lead track Ref in " <<
367 "RecoTauQualityCuts is invalid. - filterTrack";
371 if(!(std::fabs(track->
dz(pv_->position()) - leadTrack_->dz(pv_->position())) <= maxDeltaZToLeadTrack_))
374 if(minTrackVertexWeight_ > -1.0 && !(pv_->trackWeight(convertRef(trackRef)) >= minTrackVertexWeight_))
return false;
380 if(minGammaEt_ >= 0 && !(cand.
et() > minGammaEt_))
return false;
385 if(minNeutralHadronEt_ >= 0 && !(cand.
et() > minNeutralHadronEt_))
return false;
392 return filterGammaCand(cand);
394 return filterNeutralHadronCand(cand);
412 if(trackRef.isNonnull()) {
413 result = filterTrack_(trackRef);
417 if(gsfTrackRef.isNonnull()) {
418 result = filterTrack_(gsfTrackRef);
422 result = filterCandByType(cand);
433 leadTrack_ = getTrackRef(leadCand);
439 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.
bool ptMin_cand(const PFCandidate &cand, double cut)
bool trkChi2_cand(const PFCandidate &cand, double cut)
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.