CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/RecoTauTag/RecoTau/interface/ConeTools.h

Go to the documentation of this file.
00001 #ifndef RecoTauTag_RecoTau_ConeTools_h
00002 #define RecoTauTag_RecoTau_ConeTools_h
00003 
00004 #include "DataFormats/Math/interface/deltaR.h"
00005 #include <boost/iterator/filter_iterator.hpp>
00006 #include "DataFormats/TauReco/interface/PFTau.h"
00007 #include "DataFormats/TauReco/interface/RecoTauPiZero.h"
00008 #include <functional>
00009 
00010 namespace reco { namespace tau { namespace cone {
00011 
00012 // Predicate class that tests if a candidate lies within some deltaR (min,
00013 // max) about a supplied axis
00014 template<class CandType>
00015 class DeltaRFilter : public std::unary_function<CandType, bool> {
00016   public:
00017     DeltaRFilter(const reco::Candidate::LorentzVector& axis,
00018                  double min, double max): axis_(axis), min_(min), max_(max) {}
00019     bool operator()(const CandType& b) const {
00020       double deltaR = reco::deltaR<reco::Candidate::LorentzVector>
00021           (axis_, b.p4());
00022       return(deltaR >= min_ && deltaR < max_);
00023     }
00024   private:
00025     reco::Candidate::LorentzVector axis_;
00026     const double min_;
00027     const double max_;
00028 };
00029 
00030 // Wrapper around DeltaRFilter to support reference types like Ptr<>
00031 template<class CandType>
00032 class DeltaRPtrFilter : public std::unary_function<CandType, bool> {
00033   public:
00034     DeltaRPtrFilter(const reco::Candidate::LorentzVector& axis,
00035                     double min, double max): filter_(axis, min, max) {}
00036     bool operator()(const CandType& b) const { return filter_(*b); }
00037   private:
00038     DeltaRFilter<typename CandType::value_type> filter_;
00039 };
00040 
00041 /* Define our filters */
00042 typedef DeltaRPtrFilter<PFCandidatePtr> PFCandPtrDRFilter;
00043 typedef boost::filter_iterator< PFCandPtrDRFilter,
00044         std::vector<PFCandidatePtr>::const_iterator> PFCandPtrDRFilterIter;
00045 
00046 typedef DeltaRFilter<RecoTauPiZero> PiZeroDRFilter;
00047 typedef boost::filter_iterator< PiZeroDRFilter,
00048         std::vector<RecoTauPiZero>::const_iterator> PiZeroDRFilterIter;
00049 
00050 }}}  // end namespace reco::tau::cone
00051 
00052 #endif