1 #ifndef RecoTauTag_RecoTau_RecoTauCommonUtilities_h
2 #define RecoTauTag_RecoTau_RecoTauCommonUtilities_h
21 #include <boost/iterator/transform_iterator.hpp>
22 #include <boost/iterator/indirect_iterator.hpp>
23 #include <boost/mem_fn.hpp>
25 #include <boost/type_traits/is_base_of.hpp>
26 #include <boost/static_assert.hpp>
28 namespace reco {
namespace tau {
33 return a->pt() > b->pt();
39 template<
typename Iterator> std::vector<PFCandidatePtr>
41 int particleId,
bool sort=
true) {
42 std::vector<PFCandidatePtr>
output;
45 if (ptr->particleId() == particleId)
46 output.push_back(ptr);
55 int particleId,
bool sort=
true);
59 const std::vector<int>& particleIds,
69 std::vector<PFCandidatePtr>
flattenPiZeros(
const std::vector<RecoTauPiZero>::const_iterator&,
const std::vector<RecoTauPiZero>::const_iterator&);
70 std::vector<PFCandidatePtr>
flattenPiZeros(
const std::vector<RecoTauPiZero>&);
73 template<
typename RefVectorType,
typename BaseView>
80 typename RefVectorType::member_type>::
value));
82 size_t nElements = view->size();
83 output.reserve(nElements);
85 for (
size_t i = 0;
i < nElements; ++
i) {
86 output.push_back(view->refAt(
i).template castTo<OutputRef>());
97 const InputIterator&
begin,
const InputIterator&
end,
size_t N) {
98 size_t input_size = end -
begin;
99 return (N > input_size) ? end : begin +
N;
103 template<
typename InputIterator,
typename FunctionPtr,
typename ReturnType>
105 FunctionPtr
func, ReturnType
init) {
107 for(InputIterator cand = begin; cand !=
end; ++cand) {
109 output += ((**cand).*(
func))();
115 InputIterator
begin, InputIterator
end) {
135 InputIterator max_cand =
begin;
136 for(InputIterator cand = begin; cand !=
end; ++cand) {
137 if( (*cand)->pt() > max_pt ) {
138 max_pt = (*cand)->pt();
InputIterator takeNElements(const InputIterator &begin, const InputIterator &end, size_t N)
double sumPFCandPt(InputIterator begin, InputIterator end)
Sum the pT of a collection of PFCandidates.
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
reco::Candidate::LorentzVector sumPFCandP4(InputIterator begin, InputIterator end)
std::vector< PFCandidatePtr > pfGammas(const PFJet &jet, bool sort=true)
Extract all pfGammas from a PFJet.
RefVectorType castView(const edm::Handle< BaseView > &view)
Convert a BaseView (View<T>) to a TRefVector.
std::vector< PFCandidatePtr > filterPFCandidates(const Iterator &begin, const Iterator &end, int particleId, bool sort=true)
ReturnType sumPFVector(InputIterator begin, InputIterator end, FunctionPtr func, ReturnType init)
Sum the four vectors in a collection of PFCandidates.
Jets made from PFObjects.
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
Container::value_type value_type
InputIterator leadPFCand(InputIterator begin, InputIterator end)
std::vector< PFCandidatePtr > 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.
virtual int charge() const GCC11_FINAL
electric charge
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::vector< PFCandidatePtr > pfChargedCands(const PFJet &jet, bool sort=true)
Extract all non-neutral candidates from a PFJet.
bool operator()(const PFCandidatePtr &a, const PFCandidatePtr &b) const
virtual float pt() const GCC11_FINAL
transverse momentum
int sumPFCandCharge(InputIterator begin, InputIterator end)
Sum the charge of a collection of PFCandidates.