CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecoTauCommonUtilities.cc
Go to the documentation of this file.
2 
6 
7 #include <algorithm>
8 
9 typedef std::vector<reco::PFCandidatePtr> PFCandPtrs;
10 typedef PFCandPtrs::iterator PFCandIter;
11 
12 namespace reco { namespace tau {
13 
14 std::vector<PFCandidatePtr>
15 flattenPiZeros( const std::vector<RecoTauPiZero>& piZeros) {
16  std::vector<PFCandidatePtr> output;
17 
18  for(std::vector<RecoTauPiZero>::const_iterator piZero = piZeros.begin();
19  piZero != piZeros.end(); ++piZero) {
20  for(size_t iDaughter = 0; iDaughter < piZero->numberOfDaughters();
21  ++iDaughter) {
22  output.push_back(PFCandidatePtr(piZero->daughterPtr(iDaughter)));
23  }
24  }
25  return output;
26 }
27 
28 std::vector<reco::PFCandidatePtr> pfCandidates(const reco::PFJet& jet,
29  int particleId, bool sort) {
30  PFCandPtrs pfCands = jet.getPFConstituents();
31  PFCandPtrs selectedPFCands = filterPFCandidates(
32  pfCands.begin(), pfCands.end(), particleId, sort);
33  return selectedPFCands;
34 }
35 
36 std::vector<reco::PFCandidatePtr> pfCandidates(const reco::PFJet& jet,
37  const std::vector<int>& particleIds, bool sort) {
39  // Get each desired candidate type, unsorted for now
40  for(std::vector<int>::const_iterator particleId = particleIds.begin();
41  particleId != particleIds.end(); ++particleId) {
42  PFCandPtrs selectedPFCands = pfCandidates(jet, *particleId, false);
43  output.insert(output.end(), selectedPFCands.begin(), selectedPFCands.end());
44  }
45  if (sort) std::sort(output.begin(), output.end(), SortPFCandsDescendingPt());
46  return output;
47 }
48 
49 std::vector<reco::PFCandidatePtr> pfGammas(const reco::PFJet& jet, bool sort) {
50  return pfCandidates(jet, reco::PFCandidate::gamma, sort);
51 }
52 
53 std::vector<reco::PFCandidatePtr> pfChargedCands(const reco::PFJet& jet,
54  bool sort) {
58  PFCandPtrs chs = pfCandidates(jet, reco::PFCandidate::h, false);
59  output.reserve(mus.size() + es.size() + chs.size());
60  output.insert(output.end(), mus.begin(), mus.end());
61  output.insert(output.end(), es.begin(), es.end());
62  output.insert(output.end(), chs.begin(), chs.end());
63  if (sort) std::sort(output.begin(), output.end(), SortPFCandsDescendingPt());
64  return output;
65 }
66 
67 
68 
69 } }
std::vector< PFCandidatePtr > flattenPiZeros(const std::vector< RecoTauPiZero > &)
Flatten a list of pi zeros into a list of there constituent PFCandidates.
std::vector< PFCandidatePtr > pfGammas(const PFJet &jet, bool sort=true)
Extract all pfGammas from a PFJet.
std::vector< reco::PFCandidatePtr > PFCandPtrs
std::vector< PFCandidatePtr > filterPFCandidates(const Iterator &begin, const Iterator &end, int particleId, bool sort=true)
Jets made from PFObjects.
Definition: PFJet.h:22
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
std::vector< PFCandidatePtr > pfChargedCands(const PFJet &jet, bool sort=true)
Extract all non-neutral candidates from a PFJet.
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:53
PFCandPtrs::iterator PFCandIter
edm::Ptr< PFCandidate > PFCandidatePtr
persistent Ptr to a PFCandidate