7 #include <boost/bind.hpp>
15 if (!ret) ret = cand.gsfTrackRef().get();
20 if (cand.trackRef().isNonnull())
22 else if (cand.gsfTrackRef().isNonnull()) {
33 return cand.
pt() >
cut;
37 return cand.
et() >
cut;
43 if (!trk)
return false;
44 return trk->hitPattern().numberOfValidPixelHits() >=
cut;
49 if (!trk)
return false;
50 return trk->hitPattern().numberOfValidHits() >=
cut;
57 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
58 "RecoTauQualityCuts is invalid. - trkTransverseImpactParameter";
62 if (!trk)
return false;
63 return std::abs(trk->dxy((*pv)->position())) <=
cut;
70 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
71 "RecoTauQualityCuts is invalid. - trkLongitudinalImpactParameter";
75 if (!trk)
return false;
76 double difference =
std::abs(trk->dz((*pv)->position()));
79 return difference <=
cut;
86 edm::LogError(
"QCutsNoValidLeadTrack") <<
"Lead track Ref in " <<
87 "RecoTauQualityCuts is invalid. - trkLongitudinalImpactParameterWrtTrack";
91 if (!candTrk)
return false;
92 double difference =
std::abs((*trk)->vz() - candTrk->vz());
93 return difference <=
cut;
100 edm::LogError(
"QCutsNoPrimaryVertex") <<
"Primary vertex Ref in " <<
101 "RecoTauQualityCuts is invalid. - minTrackVertexWeight";
104 auto trk = getTrackRef(cand);
105 if (!trk)
return false;
106 double weight = (*pv)->trackWeight(trk);
107 return weight >=
cut;
112 if (!trk)
return false;
113 return trk->normalizedChi2() <=
cut;
130 RecoTauQualityCuts::QCutFuncMap::const_iterator
cuts =
133 if (cuts == funcMap.end())
137 return AND(cand, cuts->second);
149 std::set<std::string> passedOptionSet;
152 BOOST_FOREACH(
const std::string& option, passedOptions) {
153 passedOptionSet.insert(option);
157 if (qcuts.
exists(
"minTrackPt")) {
158 chargedHadronCuts.push_back(
161 passedOptionSet.erase(
"minTrackPt");
164 if (qcuts.
exists(
"maxTrackChi2")) {
165 chargedHadronCuts.push_back(
168 passedOptionSet.erase(
"maxTrackChi2");
171 if (qcuts.
exists(
"minTrackPixelHits")) {
172 chargedHadronCuts.push_back(boost::bind(
175 passedOptionSet.erase(
"minTrackPixelHits");
178 if (qcuts.
exists(
"minTrackHits")) {
179 chargedHadronCuts.push_back(boost::bind(
182 passedOptionSet.erase(
"minTrackHits");
187 if (qcuts.
exists(
"maxTransverseImpactParameter")) {
188 chargedHadronCuts.push_back(boost::bind(
190 qcuts.
getParameter<
double>(
"maxTransverseImpactParameter")));
191 passedOptionSet.erase(
"maxTransverseImpactParameter");
194 if (qcuts.
exists(
"maxDeltaZ")) {
195 chargedHadronCuts.push_back(boost::bind(
198 passedOptionSet.erase(
"maxDeltaZ");
201 if (qcuts.
exists(
"maxDeltaZToLeadTrack")) {
202 chargedHadronCuts.push_back(boost::bind(
205 passedOptionSet.erase(
"maxDeltaZToLeadTrack");
209 if (qcuts.
exists(
"minTrackVertexWeight")) {
210 chargedHadronCuts.push_back(boost::bind(
213 passedOptionSet.erase(
"minTrackVertexWeight");
217 if (qcuts.
exists(
"minGammaEt")) {
218 gammaCuts.push_back(boost::bind(
220 passedOptionSet.erase(
"minGammaEt");
224 if (qcuts.
exists(
"minNeutralHadronEt")) {
225 neutralHadronCuts.push_back(boost::bind(
228 passedOptionSet.erase(
"minNeutralHadronEt");
232 if (passedOptionSet.size()) {
234 bool thereIsABadParameter =
false;
235 BOOST_FOREACH(
const std::string& option, passedOptionSet) {
237 if (option ==
"useTracksInsteadOfPFHadrons") {
239 if (qcuts.
getParameter<
bool>(
"useTracksInsteadOfPFHadrons")) {
241 <<
"The obsolete exception useTracksInsteadOfPFHadrons "
242 <<
"is set to true in the quality cut config." << std::endl;
248 thereIsABadParameter =
true;
250 unParsedOptions += option;
251 unParsedOptions +=
"\n";
253 if (thereIsABadParameter) {
255 <<
" The PSet passed to the RecoTauQualityCuts class had"
256 <<
" the following unrecognized options: " << std::endl
262 size_t nCuts = chargedHadronCuts.size() + gammaCuts.size()
263 + neutralHadronCuts.size();
266 <<
" No options were passed to the quality cut class!" << std::endl;
289 if (cut ==
"minTrackVertexWeight" || cut ==
"maxDeltaZ"
290 || cut ==
"maxDeltaZToLeadTrack") {
296 return std::make_pair(puCuts, nonPUCuts);
bool ptMin(const PFCandidate &cand, double cut)
T getParameter(std::string const &) const
virtual double et() const GCC11_FINAL
transverse energy
bool AND(const PFCandidate &cand, const RecoTauQualityCuts::QCutFuncCollection &cuts)
bool trkChi2(const PFCandidate &cand, double cut)
RecoTauQualityCuts(const edm::ParameterSet &qcuts)
boost::function< bool(const PFCandidate &)> QCutFunc
reco::TrackBaseRef leadTrack_
bool minTrackVertexWeight(const PFCandidate &cand, const reco::VertexRef *pv, double cut)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void setLeadTrack(const reco::PFCandidate &leadCand) const
Update the leading track.
bool isNonnull() const
Checks for non-null.
void copyFrom(ParameterSet const &from, std::string const &name)
bool isNull() const
Checks for null.
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
bool trkPixelHits(const PFCandidate &cand, int cut)
std::map< PFCandidate::ParticleType, QCutFuncCollection > QCutFuncMap
std::pair< edm::ParameterSet, edm::ParameterSet > factorizePUQCuts(const edm::ParameterSet &inputSet)
bool mapAndCutByType(const PFCandidate &cand, const RecoTauQualityCuts::QCutFuncMap &funcMap)
std::vector< std::string > getParameterNames() const
bool trkLongitudinalImpactParameter(const PFCandidate &cand, const reco::VertexRef *pv, double cut)
bool etMin(const PFCandidate &cand, double cut)
bool trkTransverseImpactParameter(const PFCandidate &cand, const reco::VertexRef *pv, double cut)
Particle reconstructed by the particle flow algorithm.
const reco::TrackBaseRef getTrack(const reco::PFCandidate &cand)
bool trkTrackerHits(const PFCandidate &cand, int cut)
bool trkLongitudinalImpactParameterWrtTrack(const PFCandidate &cand, const reco::TrackBaseRef *trk, double cut)
DZ cut, with respect to the current lead rack.
virtual ParticleType particleId() const
virtual float pt() const GCC11_FINAL
transverse momentum
std::vector< QCutFunc > QCutFuncCollection