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