CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h

Go to the documentation of this file.
00001 #ifndef RecoTauTag_RecoTau_RecoTauQualityCuts_h
00002 #define RecoTauTag_RecoTau_RecoTauQualityCuts_h
00003 
00004 /*
00005  * RecoTauQualityCuts
00006  *
00007  * Author: Evan K. Friis
00008  *
00009  * Constructs a number of independent requirements on PFCandidates by building
00010  * binary predicate functions.  These are held in a number of lists of
00011  * functions.  Each of these lists is mapped to a PFCandidate particle type
00012  * (like hadron, gamma, etc).  When a PFCandidate is passed to filter(),
00013  * the correct list is looked up, and the result is the AND of all the predicate
00014  * functions.  See the .cc files for the QCut functions.
00015  *
00016  * Note that for some QCuts, the primary vertex must be updated every event.
00017  *
00018  */
00019 
00020 #include <boost/function.hpp>
00021 #include <boost/foreach.hpp>
00022 
00023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00024 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00025 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00026 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00027 
00028 namespace reco { namespace tau {
00029 
00030 class RecoTauQualityCuts {
00031   public:
00032     // Quality cut types
00033     typedef boost::function<bool (const PFCandidate&)> QCutFunc;
00034     typedef std::vector<QCutFunc> QCutFuncCollection;
00035     typedef std::map<PFCandidate::ParticleType, QCutFuncCollection> QCutFuncMap;
00036 
00037     explicit RecoTauQualityCuts(const edm::ParameterSet &qcuts);
00039     void setPV(const reco::VertexRef& vtx) const { pv_ = vtx; }
00041     const QCutFunc& predicate() const { return predicate_; }
00043     bool filter(const reco::PFCandidate& cand) const {
00044       return predicate_(cand);
00045     }
00047     template<typename PFCandRefType>
00048     bool filterRef(const PFCandRefType& cand) const { return filter(*cand); }
00049 
00051     template<typename Coll> Coll filterRefs(
00052         const Coll& refcoll, bool invert=false) const {
00053       Coll output;
00054       BOOST_FOREACH(const typename Coll::value_type cand, refcoll) {
00055         if (filterRef(cand)^invert)
00056           output.push_back(cand);
00057       }
00058       return output;
00059     }
00060 
00061   private:
00062     // The current primary vertex
00063     mutable reco::VertexRef pv_;
00064     // A mapping from particle type to a set of QCuts
00065     QCutFuncMap qcuts_;
00066     // Our entire predicate function
00067     QCutFunc predicate_;
00068 };
00069 
00070 }}  // end reco::tau:: namespace
00071 #endif