CMS 3D CMS Logo

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 
10 namespace reco::tau::cone {
11 
12 // Predicate class that tests if a candidate lies within some deltaR (min,
13 // max) about a supplied axis
14 template<class CandType>
15 class DeltaRFilter {
16  public:
17  DeltaRFilter(const reco::Candidate::LorentzVector& axis, double min, double max)
18  : eta_(axis.eta()),
19  phi_(axis.phi()),
20  min2_(min < 0. ? -min*min : min*min),
21  max2_(max*max)
22  {}
23  bool operator()(const CandType& b) const
24  {
25  double dR2 = deltaR2(b.eta(), b.phi(), eta_, phi_);
26  return (dR2 >= min2_ && dR2 < max2_);
27  }
28  private:
29  double eta_;
30  double phi_;
31  const double min2_;
32  const double max2_;
33 };
34 
35 // Wrapper around DeltaRFilter to support reference types like Ptr<>
36 template<class CandType>
38  public:
40  double min, double max): filter_(axis, min, max) {}
41  bool operator()(const CandType& b) const { return filter_(*b); }
42  private:
44 };
45 
46 /* Define our filters */
48 typedef boost::filter_iterator< PFCandPtrDRFilter,
49  std::vector<PFCandidatePtr>::const_iterator> PFCandPtrDRFilterIter;
50 
52 typedef boost::filter_iterator< CandPtrDRFilter,
53  std::vector<CandidatePtr>::const_iterator> CandPtrDRFilterIter;
54 
56 typedef boost::filter_iterator< ChargedHadronDRFilter,
57  std::vector<PFRecoTauChargedHadron>::const_iterator> ChargedHadronDRFilterIter;
58 
60 typedef boost::filter_iterator< PiZeroDRFilter,
61  std::vector<RecoTauPiZero>::const_iterator> PiZeroDRFilterIter;
62 
63 } // end namespace reco::tau::cone
64 
65 #endif
DeltaRFilter< PFRecoTauChargedHadron > ChargedHadronDRFilter
Definition: ConeTools.h:55
boost::filter_iterator< PiZeroDRFilter, std::vector< RecoTauPiZero >::const_iterator > PiZeroDRFilterIter
Definition: ConeTools.h:61
boost::filter_iterator< ChargedHadronDRFilter, std::vector< PFRecoTauChargedHadron >::const_iterator > ChargedHadronDRFilterIter
Definition: ConeTools.h:57
bool operator()(const CandType &b) const
Definition: ConeTools.h:41
boost::filter_iterator< CandPtrDRFilter, std::vector< CandidatePtr >::const_iterator > CandPtrDRFilterIter
Definition: ConeTools.h:53
DeltaRPtrFilter(const reco::Candidate::LorentzVector &axis, double min, double max)
Definition: ConeTools.h:39
DeltaRFilter(const reco::Candidate::LorentzVector &axis, double min, double max)
Definition: ConeTools.h:17
T min(T a, T b)
Definition: MathUtil.h:58
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
bool operator()(const CandType &b) const
Definition: ConeTools.h:23
double b
Definition: hdecay.h:120
DeltaRPtrFilter< CandidatePtr > CandPtrDRFilter
Definition: ConeTools.h:51
DeltaRFilter< RecoTauPiZero > PiZeroDRFilter
Definition: ConeTools.h:59
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
boost::filter_iterator< PFCandPtrDRFilter, std::vector< PFCandidatePtr >::const_iterator > PFCandPtrDRFilterIter
Definition: ConeTools.h:49
DeltaRPtrFilter< PFCandidatePtr > PFCandPtrDRFilter
Definition: ConeTools.h:47
DeltaRFilter< typename CandType::value_type > filter_
Definition: ConeTools.h:43