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 &)> 
CandQCutFunc
 
typedef std::vector< CandQCutFuncCandQCutFuncCollection
 
typedef std::map
< PFCandidate::ParticleType,
CandQCutFuncCollection
CandQCutFuncMap
 
typedef boost::function< bool(const
TrackBaseRef &)> 
TrackQCutFunc
 
typedef std::vector
< TrackQCutFunc
TrackQCutFuncCollection
 

Public Member Functions

const CandQCutFunccandPredicate () const
 
bool filterCand (const reco::PFCandidate &cand) const
 Filter a single PFCandidate. More...
 
template<typename PFCandRefType >
bool filterCandRef (const PFCandRefType &cand) const
 Filter a PFCandidate held by a smart pointer or Ref. More...
 
template<typename Coll >
Coll filterCandRefs (const Coll &refcoll, bool invert=false) const
 Filter a ref vector of PFCandidates. More...
 
bool filterTrack (const reco::TrackBaseRef &track) const
 Filter a single Track. More...
 
bool filterTrack (const reco::TrackRef &track) const
 
template<typename Coll >
Coll filterTracks (const Coll &coll, bool invert=false) const
 Filter a collection of Tracks. More...
 
 RecoTauQualityCuts (const edm::ParameterSet &qcuts)
 
void setLeadTrack (const reco::TrackRef &leadTrack) const
 Update the leading track. More...
 
void setLeadTrack (const reco::PFCandidate &leadCand) const
 
void setLeadTrack (const reco::PFCandidateRef &leadCand) const
 
void setPV (const reco::VertexRef &vtx) const
 Update the primary vertex. More...
 
const TrackQCutFunctrackPredicate () const
 Get the predicate used to filter. More...
 

Private Attributes

CandQCutFunc candPredicate_
 
CandQCutFuncMap candQCuts_
 
reco::TrackBaseRef leadTrack_
 
reco::VertexRef pv_
 
TrackQCutFunc trackPredicate_
 
TrackQCutFuncCollection trackQCuts_
 

Detailed Description

Definition at line 34 of file RecoTauQualityCuts.h.

Member Typedef Documentation

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

Definition at line 40 of file RecoTauQualityCuts.h.

Definition at line 41 of file RecoTauQualityCuts.h.

Definition at line 42 of file RecoTauQualityCuts.h.

typedef boost::function<bool (const TrackBaseRef&)> reco::tau::RecoTauQualityCuts::TrackQCutFunc

Definition at line 38 of file RecoTauQualityCuts.h.

Definition at line 39 of file RecoTauQualityCuts.h.

Constructor & Destructor Documentation

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

Definition at line 220 of file RecoTauQualityCuts.cc.

References reco::tau::qcuts::AND(), candPredicate_, candQCuts_, reco::PFCandidate::e, reco::tau::qcuts::etMin_cand(), 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, reco::tau::qcuts::ptMin(), pv_, AlCaHLTBitMon_QueryRunRegistry::string, trackPredicate_, trackQCuts_, 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().

221 {
222  // Setup all of our predicates
223  CandQCutFuncCollection chargedHadronCuts;
224  CandQCutFuncCollection gammaCuts;
225  CandQCutFuncCollection neutralHadronCuts;
226 
227  // Make sure there are no extra passed options
228  std::set<std::string> passedOptionSet;
229  std::vector<std::string> passedOptions = qcuts.getParameterNames();
230 
231  BOOST_FOREACH(const std::string& option, passedOptions) {
232  passedOptionSet.insert(option);
233  }
234 
235  // Build all the QCuts for tracks
236  if ( qcuts.exists("minTrackPt") ) {
237  trackQCuts_.push_back(boost::bind(qcuts::ptMin, _1, qcuts.getParameter<double>("minTrackPt")));
238  passedOptionSet.erase("minTrackPt");
239  }
240 
241  if ( qcuts.exists("maxTrackChi2") ) {
242  trackQCuts_.push_back(boost::bind(qcuts::trkChi2, _1, qcuts.getParameter<double>("maxTrackChi2")));
243  passedOptionSet.erase("maxTrackChi2");
244  }
245 
246  if ( qcuts.exists("minTrackPixelHits") ) {
247  uint32_t minTrackPixelHits = qcuts.getParameter<uint32_t>("minTrackPixelHits");
248  if ( minTrackPixelHits >= 1 ) {
249  trackQCuts_.push_back(boost::bind(qcuts::trkPixelHits, _1, minTrackPixelHits));
250  }
251  passedOptionSet.erase("minTrackPixelHits");
252  }
253 
254  if ( qcuts.exists("minTrackHits") ) {
255  uint32_t minTrackHits = qcuts.getParameter<uint32_t>("minTrackHits");
256  if ( minTrackHits >= 1 ) {
257  trackQCuts_.push_back(boost::bind(qcuts::trkTrackerHits, _1, minTrackHits));
258  }
259  passedOptionSet.erase("minTrackHits");
260  }
261 
262  // The impact parameter functions are bound to our member PV, since they
263  // need it to compute the discriminant value.
264  if ( qcuts.exists("maxTransverseImpactParameter") ) {
265  trackQCuts_.push_back(boost::bind(qcuts::trkTransverseImpactParameter, _1, &pv_, qcuts.getParameter<double>("maxTransverseImpactParameter")));
266  passedOptionSet.erase("maxTransverseImpactParameter");
267  }
268 
269  if ( qcuts.exists("maxDeltaZ") ) {
270  trackQCuts_.push_back(boost::bind(qcuts::trkLongitudinalImpactParameter, _1, &pv_, qcuts.getParameter<double>("maxDeltaZ")));
271  passedOptionSet.erase("maxDeltaZ");
272  }
273 
274  if ( qcuts.exists("maxDeltaZToLeadTrack") ) {
275  trackQCuts_.push_back(boost::bind(qcuts::trkLongitudinalImpactParameterWrtTrack, _1, &leadTrack_, &pv_, qcuts.getParameter<double>("maxDeltaZToLeadTrack")));
276  passedOptionSet.erase("maxDeltaZToLeadTrack");
277  }
278 
279  // Require tracks to contribute a minimum weight to the associated vertex.
280  if ( qcuts.exists("minTrackVertexWeight") ) {
281  double minTrackVertexWeight = qcuts.getParameter<double>("minTrackVertexWeight");
282  if ( minTrackVertexWeight > -1. ) {
283  trackQCuts_.push_back(boost::bind(qcuts::minTrackVertexWeight, _1, &pv_, minTrackVertexWeight));
284  }
285  passedOptionSet.erase("minTrackVertexWeight");
286  }
287 
288  // Build the QCuts for gammas
289  if ( qcuts.exists("minGammaEt") ) {
290  gammaCuts.push_back(boost::bind(qcuts::etMin_cand, _1, qcuts.getParameter<double>("minGammaEt")));
291  passedOptionSet.erase("minGammaEt");
292  }
293 
294  // Build QCuts for netural hadrons
295  if ( qcuts.exists("minNeutralHadronEt") ) {
296  neutralHadronCuts.push_back(boost::bind(qcuts::etMin_cand, _1, qcuts.getParameter<double>("minNeutralHadronEt")));
297  passedOptionSet.erase("minNeutralHadronEt");
298  }
299 
300  // Check if there are any remaining unparsed QCuts
301  if ( passedOptionSet.size() ) {
302  std::string unParsedOptions;
303  bool thereIsABadParameter = false;
304  BOOST_FOREACH( const std::string& option, passedOptionSet ) {
305  // Workaround for HLT - TODO FIXME
306  if ( option == "useTracksInsteadOfPFHadrons" ) {
307  // Crash if true - no one should have this option enabled.
308  if ( qcuts.getParameter<bool>("useTracksInsteadOfPFHadrons") ) {
309  throw cms::Exception("DontUseTracksInQcuts")
310  << "The obsolete exception useTracksInsteadOfPFHadrons "
311  << "is set to true in the quality cut config." << std::endl;
312  }
313  continue;
314  }
315 
316  // If we get to this point, there is a real unknown parameter
317  thereIsABadParameter = true;
318 
319  unParsedOptions += option;
320  unParsedOptions += "\n";
321  }
322  if ( thereIsABadParameter ) {
323  throw cms::Exception("BadQualityCutConfig")
324  << " The PSet passed to the RecoTauQualityCuts class had"
325  << " the following unrecognized options: " << std::endl
326  << unParsedOptions;
327  }
328  }
329 
330  // Make sure there are at least some quality cuts
331  size_t nCuts = chargedHadronCuts.size() + gammaCuts.size() + neutralHadronCuts.size() + trackQCuts_.size();
332  if ( !nCuts ) {
333  throw cms::Exception("BadQualityCutConfig")
334  << " No options were passed to the quality cut class!" << std::endl;
335  }
336 
337  // Build final level predicate that works on Tracks
338  trackPredicate_ = boost::bind(qcuts::AND, _1, boost::cref(trackQCuts_));
339 
340  // Map our QCut collections to the particle Ids they are associated to.
341  candQCuts_[PFCandidate::h] = chargedHadronCuts;
342  candQCuts_[PFCandidate::gamma] = gammaCuts;
343  candQCuts_[PFCandidate::h0] = neutralHadronCuts;
344  // We use the same qcuts for muons/electrons and charged hadrons.
345  candQCuts_[PFCandidate::e] = chargedHadronCuts;
346  candQCuts_[PFCandidate::mu] = chargedHadronCuts;
347 
348  // Build a final level predicate that works on any PFCand
349  candPredicate_ = boost::bind(qcuts::mapAndCutByType, _1, boost::cref(candQCuts_));
350 }
T getParameter(std::string const &) const
TrackQCutFuncCollection trackQCuts_
bool minTrackVertexWeight(const TrackBaseRef &track, const reco::VertexRef *pv, double cut)
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool etMin_cand(const PFCandidate &cand, double cut)
bool trkPixelHits(const TrackBaseRef &track, int cut)
bool trkTransverseImpactParameter(const TrackBaseRef &track, const reco::VertexRef *pv, double cut)
std::vector< CandQCutFunc > CandQCutFuncCollection
std::vector< std::string > getParameterNames() const
bool ptMin(const TrackBaseRef &track, double cut)
bool trkTrackerHits(const TrackBaseRef &track, int cut)
bool mapAndCutByType(const PFCandidate &cand, const RecoTauQualityCuts::CandQCutFuncMap &funcMap)
bool trkChi2(const TrackBaseRef &track, double cut)
bool AND(const TrackBaseRef &track, const RecoTauQualityCuts::TrackQCutFuncCollection &cuts)
bool trkLongitudinalImpactParameter(const TrackBaseRef &track, const reco::VertexRef *pv, double cut)
bool trkLongitudinalImpactParameterWrtTrack(const TrackBaseRef &track, const reco::TrackBaseRef *leadTrack, const reco::VertexRef *pv, double cut)
DZ cut, with respect to the current lead rack.

Member Function Documentation

const CandQCutFunc& reco::tau::RecoTauQualityCuts::candPredicate ( ) const
inline

Definition at line 59 of file RecoTauQualityCuts.h.

References candPredicate_.

59 { return candPredicate_; }
bool reco::tau::RecoTauQualityCuts::filterCand ( const reco::PFCandidate cand) const

Filter a single PFCandidate.

Definition at line 375 of file RecoTauQualityCuts.cc.

References candPredicate_, and trackPredicate_.

Referenced by filterCandRef().

376 {
377  auto track = getTrackRef(cand);
378  if ( track.isNonnull() ) return (trackPredicate_(track) & candPredicate_(cand));
379  return candPredicate_(cand);
380 }
template<typename PFCandRefType >
bool reco::tau::RecoTauQualityCuts::filterCandRef ( const PFCandRefType &  cand) const
inline

Filter a PFCandidate held by a smart pointer or Ref.

Definition at line 81 of file RecoTauQualityCuts.h.

References filterCand().

Referenced by filterCandRefs().

81 { return filterCand(*cand); }
bool filterCand(const reco::PFCandidate &cand) const
Filter a single PFCandidate.
template<typename Coll >
Coll reco::tau::RecoTauQualityCuts::filterCandRefs ( const Coll &  refcoll,
bool  invert = false 
) const
inline
bool reco::tau::RecoTauQualityCuts::filterTrack ( const reco::TrackBaseRef track) const

Filter a single Track.

Definition at line 370 of file RecoTauQualityCuts.cc.

References trackPredicate_.

Referenced by filterTracks(), and reco::tau::PFRecoTauChargedHadronFromTrackPlugin::operator()().

371 {
372  return trackPredicate_(track);
373 }
bool reco::tau::RecoTauQualityCuts::filterTrack ( const reco::TrackRef track) const
inline

Definition at line 63 of file RecoTauQualityCuts.h.

References filterTrack().

Referenced by filterTrack().

63 { return filterTrack(reco::TrackBaseRef(track)); }
bool filterTrack(const reco::TrackBaseRef &track) const
Filter a single Track.
template<typename Coll >
Coll reco::tau::RecoTauQualityCuts::filterTracks ( const Coll &  coll,
bool  invert = false 
) const
inline

Filter a collection of Tracks.

Definition at line 67 of file RecoTauQualityCuts.h.

References filterTrack(), and convertSQLitetoXML_cfg::output.

68  {
69  Coll output;
70  BOOST_FOREACH( const typename Coll::value_type track, coll ) {
71  if ( filterTrack(track)^invert ) output.push_back(track);
72  }
73  return output;
74  }
Container::value_type value_type
bool filterTrack(const reco::TrackBaseRef &track) const
Filter a single Track.
void reco::tau::RecoTauQualityCuts::setLeadTrack ( const reco::TrackRef leadTrack) const

Update the leading track.

Definition at line 382 of file RecoTauQualityCuts.cc.

References leadTrack_.

383 {
384  leadTrack_ = reco::TrackBaseRef(leadTrack);
385 }
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:22
void reco::tau::RecoTauQualityCuts::setLeadTrack ( const reco::PFCandidate leadCand) const

Definition at line 387 of file RecoTauQualityCuts.cc.

References leadTrack_.

388 {
389  leadTrack_ = getTrackRef(leadCand);
390 }
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 392 of file RecoTauQualityCuts.cc.

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

393 {
394  if ( leadCand.isNonnull() ) {
395  leadTrack_ = getTrackRef(*leadCand);
396  } else {
397  // Set null
399  }
400 }
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
const TrackQCutFunc& reco::tau::RecoTauQualityCuts::trackPredicate ( ) const
inline

Get the predicate used to filter.

Definition at line 58 of file RecoTauQualityCuts.h.

References trackPredicate_.

58 { return trackPredicate_; }

Member Data Documentation

CandQCutFunc reco::tau::RecoTauQualityCuts::candPredicate_
private

Definition at line 105 of file RecoTauQualityCuts.h.

Referenced by candPredicate(), filterCand(), and RecoTauQualityCuts().

CandQCutFuncMap reco::tau::RecoTauQualityCuts::candQCuts_
private

Definition at line 102 of file RecoTauQualityCuts.h.

Referenced by RecoTauQualityCuts().

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

Definition at line 98 of file RecoTauQualityCuts.h.

Referenced by RecoTauQualityCuts(), and setLeadTrack().

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

Definition at line 96 of file RecoTauQualityCuts.h.

Referenced by RecoTauQualityCuts(), and setPV().

TrackQCutFunc reco::tau::RecoTauQualityCuts::trackPredicate_
private

Definition at line 104 of file RecoTauQualityCuts.h.

Referenced by filterCand(), filterTrack(), RecoTauQualityCuts(), and trackPredicate().

TrackQCutFuncCollection reco::tau::RecoTauQualityCuts::trackQCuts_
private

Definition at line 100 of file RecoTauQualityCuts.h.

Referenced by RecoTauQualityCuts().