CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ConeTools.h
Go to the documentation of this file.
1 #ifndef RecoTauTag_RecoTau_ConeTools_h
2 #define RecoTauTag_RecoTau_ConeTools_h
3 
5 #include <boost/iterator/filter_iterator.hpp>
9 #include <functional>
10 
11 namespace reco { namespace tau { namespace cone {
12 
13 // Predicate class that tests if a candidate lies within some deltaR (min,
14 // max) about a supplied axis
15 template<class CandType>
16 class DeltaRFilter : public std::unary_function<CandType, bool> {
17  public:
18  DeltaRFilter(const reco::Candidate::LorentzVector& axis, double min, double max)
19  : eta_(axis.eta()),
20  phi_(axis.phi()),
21  min2_(min < 0. ? -min*min : min*min),
22  max2_(max*max)
23  {}
24  bool operator()(const CandType& b) const
25  {
26  double dR2 = deltaR2(b.eta(), b.phi(), eta_, phi_);
27  return (dR2 >= min2_ && dR2 < max2_);
28  }
29  private:
30  double eta_;
31  double phi_;
32  const double min2_;
33  const double max2_;
34 };
35 
36 // Wrapper around DeltaRFilter to support reference types like Ptr<>
37 template<class CandType>
38 class DeltaRPtrFilter : public std::unary_function<CandType, bool> {
39  public:
41  double min, double max): filter_(axis, min, max) {}
42  bool operator()(const CandType& b) const { return filter_(*b); }
43  private:
45 };
46 
47 /* Define our filters */
49 typedef boost::filter_iterator< PFCandPtrDRFilter,
50  std::vector<PFCandidatePtr>::const_iterator> PFCandPtrDRFilterIter;
51 
53 typedef boost::filter_iterator< ChargedHadronDRFilter,
54  std::vector<PFRecoTauChargedHadron>::const_iterator> ChargedHadronDRFilterIter;
55 
57 typedef boost::filter_iterator< PiZeroDRFilter,
58  std::vector<RecoTauPiZero>::const_iterator> PiZeroDRFilterIter;
59 
60 }}} // end namespace reco::tau::cone
61 
62 #endif
DeltaRFilter< PFRecoTauChargedHadron > ChargedHadronDRFilter
Definition: ConeTools.h:52
boost::filter_iterator< PiZeroDRFilter, std::vector< RecoTauPiZero >::const_iterator > PiZeroDRFilterIter
Definition: ConeTools.h:58
boost::filter_iterator< ChargedHadronDRFilter, std::vector< PFRecoTauChargedHadron >::const_iterator > ChargedHadronDRFilterIter
Definition: ConeTools.h:54
bool operator()(const CandType &b) const
Definition: ConeTools.h:42
DeltaRPtrFilter(const reco::Candidate::LorentzVector &axis, double min, double max)
Definition: ConeTools.h:40
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
DeltaRFilter(const reco::Candidate::LorentzVector &axis, double min, double max)
Definition: ConeTools.h:18
T min(T a, T b)
Definition: MathUtil.h:58
bool operator()(const CandType &b) const
Definition: ConeTools.h:24
double b
Definition: hdecay.h:120
DeltaRFilter< RecoTauPiZero > PiZeroDRFilter
Definition: ConeTools.h:56
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
Geom::Phi< T > phi() const
boost::filter_iterator< PFCandPtrDRFilter, std::vector< PFCandidatePtr >::const_iterator > PFCandPtrDRFilterIter
Definition: ConeTools.h:50
DeltaRPtrFilter< PFCandidatePtr > PFCandPtrDRFilter
Definition: ConeTools.h:48
DeltaRFilter< typename CandType::value_type > filter_
Definition: ConeTools.h:44