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 int particleId,
bool sort=
true);
37 const std::vector<int>& particleIds,
47 std::vector<PFCandidatePtr>
flattenPiZeros(
const std::vector<RecoTauPiZero>&);
50 template<
typename RefVectorType,
typename BaseView>
57 typename RefVectorType::member_type>::
value));
59 size_t nElements = view->size();
60 output.reserve(nElements);
62 for (
size_t i = 0;
i < nElements; ++
i) {
63 output.push_back(view->refAt(
i).template castTo<OutputRef>());
74 const InputIterator&
begin,
const InputIterator&
end,
size_t N) {
75 size_t input_size = end -
begin;
76 return (N > input_size) ? end : begin +
N;
80 template<
typename InputIterator,
typename FunctionPtr,
typename ReturnType>
82 FunctionPtr func, ReturnType
init) {
84 for(InputIterator cand = begin; cand !=
end; ++cand) {
86 output += ((**cand).*(func))();
92 InputIterator
begin, InputIterator
end) {
112 InputIterator max_cand =
begin;
113 for(InputIterator cand = begin; cand !=
end; ++cand) {
114 if( (*cand)->pt() > max_pt ) {
115 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.
Container::value_type value_type
ReturnType sumPFVector(InputIterator begin, InputIterator end, FunctionPtr func, ReturnType init)
Sum the four vectors in a collection of PFCandidates.
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
virtual int charge() const
electric charge
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.
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
int sumPFCandCharge(InputIterator begin, InputIterator end)
Sum the PT of a collection of PFCandidates.