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>&);
72 template<
typename RefVectorType,
typename BaseView>
79 typename RefVectorType::member_type>::
value));
81 size_t nElements = view->size();
82 output.reserve(nElements);
84 for (
size_t i = 0;
i < nElements; ++
i) {
85 output.push_back(view->refAt(
i).template castTo<OutputRef>());
96 const InputIterator&
begin,
const InputIterator&
end,
size_t N) {
97 size_t input_size = end -
begin;
98 return (N > input_size) ? end : begin +
N;
102 template<
typename InputIterator,
typename FunctionPtr,
typename ReturnType>
104 FunctionPtr func, ReturnType
init) {
106 for(InputIterator cand = begin; cand !=
end; ++cand) {
108 output += ((**cand).*(func))();
114 InputIterator
begin, InputIterator
end) {
134 InputIterator max_cand =
begin;
135 for(InputIterator cand = begin; cand !=
end; ++cand) {
136 if( (*cand)->pt() > max_pt ) {
137 max_pt = (*cand)->pt();
InputIterator takeNElements(const InputIterator &begin, const InputIterator &end, size_t N)
std::vector< PFCandidatePtr > flattenPiZeros(const std::vector< RecoTauPiZero > &)
Flatten a list of pi zeros into a list of there constituent PFCandidates.
double sumPFCandPt(InputIterator begin, InputIterator end)
Sum the PT of a collection of PFCandidates.
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)
virtual int charge() const
electric charge
Container::value_type value_type
InputIterator leadPFCand(InputIterator begin, InputIterator end)
virtual double pt() const
transverse momentum
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 const LorentzVector & p4() const
four-momentum Lorentz vector
int sumPFCandCharge(InputIterator begin, InputIterator end)
Sum the PT of a collection of PFCandidates.