CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
reco::tau::RecoTauQualityCuts Class Reference

#include <RecoTauQualityCuts.h>

Public Types

typedef boost::function< bool(const
PFCandidate &)> 
QCutFunc
 
typedef std::vector< QCutFuncQCutFuncCollection
 
typedef std::map
< PFCandidate::ParticleType,
QCutFuncCollection
QCutFuncMap
 

Public Member Functions

bool filter (const reco::PFCandidate &cand) const
 Filter a single PFCandidate. More...
 
template<typename PFCandRefType >
bool filterRef (const PFCandRefType &cand) const
 Filter a PFCandidate held by a smart pointer or Ref. More...
 
template<typename Coll >
Coll filterRefs (const Coll &refcoll, bool invert=false) const
 Filter a ref vector of PFCandidates. More...
 
const QCutFuncpredicate () const
 Get the predicate used to filter. More...
 
 RecoTauQualityCuts (const edm::ParameterSet &qcuts)
 
void setLeadTrack (const reco::PFCandidate &leadCand) const
 Update the leading track. More...
 
void setLeadTrack (const reco::PFCandidateRef &leadCand) const
 
void setPV (const reco::VertexRef &vtx) const
 Update the primary vertex. More...
 

Private Attributes

reco::TrackBaseRef leadTrack_
 
QCutFunc predicate_
 
reco::VertexRef pv_
 
QCutFuncMap qcuts_
 

Detailed Description

Definition at line 33 of file RecoTauQualityCuts.h.

Member Typedef Documentation

typedef boost::function<bool (const PFCandidate&)> reco::tau::RecoTauQualityCuts::QCutFunc

Definition at line 36 of file RecoTauQualityCuts.h.

Definition at line 37 of file RecoTauQualityCuts.h.

Definition at line 38 of file RecoTauQualityCuts.h.

Constructor & Destructor Documentation

reco::tau::RecoTauQualityCuts::RecoTauQualityCuts ( const edm::ParameterSet qcuts)
explicit

Definition at line 142 of file RecoTauQualityCuts.cc.

References reco::PFCandidate::e, reco::tau::qcuts::etMin(), edm::hlt::Exception, edm::ParameterSet::exists(), reco::PFCandidate::gamma, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), reco::PFCandidate::h, reco::PFCandidate::h0, leadTrack_, reco::tau::qcuts::mapAndCutByType(), reco::tau::qcuts::minTrackVertexWeight(), reco::PFCandidate::mu, predicate_, reco::tau::qcuts::ptMin(), pv_, qcuts_, AlCaHLTBitMon_QueryRunRegistry::string, reco::tau::qcuts::trkChi2(), reco::tau::qcuts::trkLongitudinalImpactParameter(), reco::tau::qcuts::trkLongitudinalImpactParameterWrtTrack(), reco::tau::qcuts::trkPixelHits(), reco::tau::qcuts::trkTrackerHits(), and reco::tau::qcuts::trkTransverseImpactParameter().

142  {
143  // Setup all of our predicates
144  QCutFuncCollection chargedHadronCuts;
145  QCutFuncCollection gammaCuts;
146  QCutFuncCollection neutralHadronCuts;
147 
148  // Make sure there are no extra passed options
149  std::set<std::string> passedOptionSet;
150  std::vector<std::string> passedOptions = qcuts.getParameterNames();
151 
152  BOOST_FOREACH(const std::string& option, passedOptions) {
153  passedOptionSet.insert(option);
154  }
155 
156  // Build all the QCuts for tracks
157  if (qcuts.exists("minTrackPt")) {
158  chargedHadronCuts.push_back(
159  boost::bind(qcuts::ptMin, _1,
160  qcuts.getParameter<double>("minTrackPt")));
161  passedOptionSet.erase("minTrackPt");
162  }
163 
164  if (qcuts.exists("maxTrackChi2")) {
165  chargedHadronCuts.push_back(
166  boost::bind(qcuts::trkChi2, _1,
167  qcuts.getParameter<double>("maxTrackChi2")));
168  passedOptionSet.erase("maxTrackChi2");
169  }
170 
171  if (qcuts.exists("minTrackPixelHits")) {
172  chargedHadronCuts.push_back(boost::bind(
174  qcuts.getParameter<uint32_t>("minTrackPixelHits")));
175  passedOptionSet.erase("minTrackPixelHits");
176  }
177 
178  if (qcuts.exists("minTrackHits")) {
179  chargedHadronCuts.push_back(boost::bind(
181  qcuts.getParameter<uint32_t>("minTrackHits")));
182  passedOptionSet.erase("minTrackHits");
183  }
184 
185  // The impact parameter functions are bound to our member PV, since they
186  // need it to compute the discriminant value.
187  if (qcuts.exists("maxTransverseImpactParameter")) {
188  chargedHadronCuts.push_back(boost::bind(
190  qcuts.getParameter<double>("maxTransverseImpactParameter")));
191  passedOptionSet.erase("maxTransverseImpactParameter");
192  }
193 
194  if (qcuts.exists("maxDeltaZ")) {
195  chargedHadronCuts.push_back(boost::bind(
197  qcuts.getParameter<double>("maxDeltaZ")));
198  passedOptionSet.erase("maxDeltaZ");
199  }
200 
201  if (qcuts.exists("maxDeltaZToLeadTrack")) {
202  chargedHadronCuts.push_back(boost::bind(
204  qcuts.getParameter<double>("maxDeltaZToLeadTrack")));
205  passedOptionSet.erase("maxDeltaZToLeadTrack");
206  }
207 
208  // Require tracks to contribute a minimum weight to the associated vertex.
209  if (qcuts.exists("minTrackVertexWeight")) {
210  chargedHadronCuts.push_back(boost::bind(
212  qcuts.getParameter<double>("minTrackVertexWeight")));
213  passedOptionSet.erase("minTrackVertexWeight");
214  }
215 
216  // Build the QCuts for gammas
217  if (qcuts.exists("minGammaEt")) {
218  gammaCuts.push_back(boost::bind(
219  qcuts::etMin, _1, qcuts.getParameter<double>("minGammaEt")));
220  passedOptionSet.erase("minGammaEt");
221  }
222 
223  // Build QCuts for netural hadrons
224  if (qcuts.exists("minNeutralHadronEt")) {
225  neutralHadronCuts.push_back(boost::bind(
226  qcuts::etMin, _1,
227  qcuts.getParameter<double>("minNeutralHadronEt")));
228  passedOptionSet.erase("minNeutralHadronEt");
229  }
230 
231  // Check if there are any remaining unparsed QCuts
232  if (passedOptionSet.size()) {
233  std::string unParsedOptions;
234  bool thereIsABadParameter = false;
235  BOOST_FOREACH(const std::string& option, passedOptionSet) {
236  // Workaround for HLT - TODO FIXME
237  if (option == "useTracksInsteadOfPFHadrons") {
238  // Crash if true - no one should have this option enabled.
239  if (qcuts.getParameter<bool>("useTracksInsteadOfPFHadrons")) {
240  throw cms::Exception("DontUseTracksInQcuts")
241  << "The obsolete exception useTracksInsteadOfPFHadrons "
242  << "is set to true in the quality cut config." << std::endl;
243  }
244  continue;
245  }
246 
247  // If we get to this point, there is a real unknown parameter
248  thereIsABadParameter = true;
249 
250  unParsedOptions += option;
251  unParsedOptions += "\n";
252  }
253  if (thereIsABadParameter) {
254  throw cms::Exception("BadQualityCutConfig")
255  << " The PSet passed to the RecoTauQualityCuts class had"
256  << " the following unrecognized options: " << std::endl
257  << unParsedOptions;
258  }
259  }
260 
261  // Make sure there are at least some quality cuts
262  size_t nCuts = chargedHadronCuts.size() + gammaCuts.size()
263  + neutralHadronCuts.size();
264  if (!nCuts) {
265  throw cms::Exception("BadQualityCutConfig")
266  << " No options were passed to the quality cut class!" << std::endl;
267  }
268 
269  // Map our QCut collections to the particle Ids they are associated to.
270  qcuts_[PFCandidate::h] = chargedHadronCuts;
271  qcuts_[PFCandidate::gamma] = gammaCuts;
272  qcuts_[PFCandidate::h0] = neutralHadronCuts;
273  // We use the same qcuts for muons/electrons and charged hadrons.
274  qcuts_[PFCandidate::e] = chargedHadronCuts;
275  qcuts_[PFCandidate::mu] = chargedHadronCuts;
276 
277  // Build a final level predicate that works on any PFCand
278  predicate_ = boost::bind(qcuts::mapAndCutByType, _1, boost::cref(qcuts_));
279 }
bool ptMin(const PFCandidate &cand, double cut)
T getParameter(std::string const &) const
bool trkChi2(const PFCandidate &cand, double cut)
bool minTrackVertexWeight(const PFCandidate &cand, const reco::VertexRef *pv, double cut)
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool trkPixelHits(const PFCandidate &cand, int cut)
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)
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.
std::vector< QCutFunc > QCutFuncCollection

Member Function Documentation

bool reco::tau::RecoTauQualityCuts::filter ( const reco::PFCandidate cand) const
inline

Filter a single PFCandidate.

Definition at line 56 of file RecoTauQualityCuts.h.

References predicate_.

Referenced by filterRef(), and reco::tau::RecoTauEnergyRecoveryPlugin::operator()().

56  {
57  return predicate_(cand);
58  }
template<typename PFCandRefType >
bool reco::tau::RecoTauQualityCuts::filterRef ( const PFCandRefType &  cand) const
inline

Filter a PFCandidate held by a smart pointer or Ref.

Definition at line 62 of file RecoTauQualityCuts.h.

References filter().

Referenced by filterRefs().

62 { return filter(*cand); }
bool filter(const reco::PFCandidate &cand) const
Filter a single PFCandidate.
template<typename Coll >
Coll reco::tau::RecoTauQualityCuts::filterRefs ( const Coll &  refcoll,
bool  invert = false 
) const
inline

Filter a ref vector of PFCandidates.

Definition at line 65 of file RecoTauQualityCuts.h.

References filterRef(), and convertSQLitetoXML_cfg::output.

Referenced by reco::tau::RecoTauVertexAssociator::getLeadTrack(), reco::tau::RecoTauBuilderCombinatoricPlugin::operator()(), reco::tau::RecoTauPiZeroTrivialPlugin::operator()(), reco::tau::RecoTauPiZeroCombinatoricPlugin::operator()(), reco::tau::RecoTauBuilderConePlugin::operator()(), reco::tau::RecoTauPiZeroStripPlugin::operator()(), and reco::tau::RecoTauPiZeroStripPlugin2::operator()().

66  {
67  Coll output;
68  BOOST_FOREACH(const typename Coll::value_type cand, refcoll) {
69  if (filterRef(cand)^invert)
70  output.push_back(cand);
71  }
72  return output;
73  }
bool filterRef(const PFCandRefType &cand) const
Filter a PFCandidate held by a smart pointer or Ref.
Container::value_type value_type
const QCutFunc& reco::tau::RecoTauQualityCuts::predicate ( ) const
inline

Get the predicate used to filter.

Definition at line 53 of file RecoTauQualityCuts.h.

References predicate_.

53 { return predicate_; }
void reco::tau::RecoTauQualityCuts::setLeadTrack ( const reco::PFCandidate leadCand) const

Update the leading track.

Definition at line 300 of file RecoTauQualityCuts.cc.

References leadTrack_.

301  {
302  leadTrack_ = getTrackRef(leadCand);
303 }
void reco::tau::RecoTauQualityCuts::setLeadTrack ( const reco::PFCandidateRef leadCand) const

Update the leading track (using reference) If null, this will set the lead track ref null.

Definition at line 305 of file RecoTauQualityCuts.cc.

References edm::Ref< C, T, F >::isNonnull(), and leadTrack_.

306  {
307  if (leadCand.isNonnull()) {
308  leadTrack_ = getTrackRef(*leadCand);
309  } else {
310  // Set null
312  }
313 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:22
void reco::tau::RecoTauQualityCuts::setPV ( const reco::VertexRef vtx) const
inline

Member Data Documentation

reco::TrackBaseRef reco::tau::RecoTauQualityCuts::leadTrack_
mutableprivate

Definition at line 79 of file RecoTauQualityCuts.h.

Referenced by RecoTauQualityCuts(), and setLeadTrack().

QCutFunc reco::tau::RecoTauQualityCuts::predicate_
private

Definition at line 83 of file RecoTauQualityCuts.h.

Referenced by filter(), predicate(), and RecoTauQualityCuts().

reco::VertexRef reco::tau::RecoTauQualityCuts::pv_
mutableprivate

Definition at line 77 of file RecoTauQualityCuts.h.

Referenced by RecoTauQualityCuts(), and setPV().

QCutFuncMap reco::tau::RecoTauQualityCuts::qcuts_
private

Definition at line 81 of file RecoTauQualityCuts.h.

Referenced by RecoTauQualityCuts().