1 #ifndef RecoTauTag_RecoTau_RecoTauCommonUtilities_h 2 #define RecoTauTag_RecoTau_RecoTauCommonUtilities_h 24 #include <boost/iterator/transform_iterator.hpp> 25 #include <boost/iterator/indirect_iterator.hpp> 26 #include <boost/mem_fn.hpp> 28 #include <boost/type_traits/is_base_of.hpp> 30 namespace reco {
namespace tau {
35 return a->pt() > b->pt();
41 template<
typename Iterator> std::vector<CandidatePtr>
43 int pdgId,
bool sort=
true) {
44 std::vector<CandidatePtr>
output;
48 output.push_back(ptr);
61 const std::vector<int>& particleIds,
67 int pdgId,
bool sort=
true);
71 const std::vector<int>& pdgIds,
78 std::vector<CandidatePtr>
pfGammas(
const Jet& jet,
bool sort=
true);
81 std::vector<CandidatePtr>
flattenPiZeros(
const std::vector<RecoTauPiZero>::const_iterator&,
const std::vector<RecoTauPiZero>::const_iterator&);
82 std::vector<CandidatePtr>
flattenPiZeros(
const std::vector<RecoTauPiZero>&);
85 template<
typename RefVectorType,
typename BaseView>
92 typename RefVectorType::member_type>::
value));
94 size_t nElements = view->size();
95 output.reserve(nElements);
97 for (
size_t i = 0;
i < nElements; ++
i) {
98 output.push_back(view->refAt(
i).template castTo<OutputRef>());
110 const InputIterator&
begin,
const InputIterator&
end,
size_t N) {
111 size_t input_size = end -
begin;
112 return (N > input_size) ? end : begin +
N;
116 template<
typename InputIterator,
typename FunctionPtr,
typename ReturnType>
122 output += ((**cand).*(
func))();
128 InputIterator
begin, InputIterator
end) {
145 template<
typename InputIterator> InputIterator
leadCand(InputIterator
begin,
148 InputIterator max_cand =
begin;
150 if( (*cand)->pt() > max_pt ) {
151 max_pt = (*cand)->pt();
std::vector< CandidatePtr > pfCandidatesByPdgId(const Jet &jet, int pdgId, bool sort=true)
std::vector< CandidatePtr > pfCandidates(const Jet &jet, int particleId, bool sort=true)
InputIterator takeNElements(const InputIterator &begin, const InputIterator &end, size_t N)
math::XYZPointF atECALEntrance(const reco::Candidate *part, double bField)
double sumPFCandPt(InputIterator begin, InputIterator end)
Sum the pT of a collection of PFCandidates.
reco::Candidate::LorentzVector sumPFCandP4(InputIterator begin, InputIterator end)
RefVectorType castView(const edm::Handle< BaseView > &view)
Convert a BaseView (View<T>) to a TRefVector.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
std::vector< CandidatePtr > pfChargedCands(const Jet &jet, bool sort=true)
Extract all non-neutral candidates from a PFJet.
ReturnType sumPFVector(InputIterator begin, InputIterator end, FunctionPtr func, ReturnType init)
Sum the four vectors in a collection of PFCandidates.
InputIterator leadCand(InputIterator begin, InputIterator end)
std::vector< CandidatePtr > flattenPiZeros(const std::vector< RecoTauPiZero >::const_iterator &, const std::vector< RecoTauPiZero >::const_iterator &)
Flatten a list of pi zeros into a list of there constituent PFCandidates.
bool operator()(const CandidatePtr &a, const CandidatePtr &b) const
Container::value_type value_type
std::map< DetId, double > ReturnType
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
Abs< T >::type abs(const T &t)
virtual double pt() const =0
transverse momentum
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual int charge() const =0
electric charge
int sumPFCandCharge(InputIterator begin, InputIterator end)
Sum the charge of a collection of PFCandidates.
std::vector< CandidatePtr > filterPFCandidates(const Iterator &begin, const Iterator &end, int pdgId, bool sort=true)
std::vector< CandidatePtr > pfGammas(const Jet &jet, bool sort=true)
Extract all pfGammas from a PFJet.