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 
7 
8 #include <algorithm>
9 
10 typedef std::vector<reco::PFCandidatePtr> PFCandPtrs;
11 typedef PFCandPtrs::iterator PFCandIter;
12 
13 namespace reco { namespace tau {
14 
15 std::vector<PFCandidatePtr>
16 flattenPiZeros( const std::vector<RecoTauPiZero>& piZeros) {
17  std::vector<PFCandidatePtr> output;
18 
19  for(std::vector<RecoTauPiZero>::const_iterator piZero = piZeros.begin();
20  piZero != piZeros.end(); ++piZero) {
21  for(size_t iDaughter = 0; iDaughter < piZero->numberOfDaughters();
22  ++iDaughter) {
23  output.push_back(PFCandidatePtr(piZero->daughterPtr(iDaughter)));
24  }
25  }
26  return output;
27 }
28 
29 std::vector<reco::PFCandidatePtr> pfCandidates(const reco::PFJet& jet,
30  int particleId, bool sort) {
31  PFCandPtrs pfCands = jet.getPFConstituents();
32  PFCandPtrs selectedPFCands = filterPFCandidates(
33  pfCands.begin(), pfCands.end(), particleId, sort);
34  return selectedPFCands;
35 }
36 
37 std::vector<reco::PFCandidatePtr> pfCandidates(const reco::PFJet& jet,
38  const std::vector<int>& particleIds, bool sort) {
40  // Get each desired candidate type, unsorted for now
41  for(std::vector<int>::const_iterator particleId = particleIds.begin();
42  particleId != particleIds.end(); ++particleId) {
43  PFCandPtrs selectedPFCands = pfCandidates(jet, *particleId, false);
44  output.insert(output.end(), selectedPFCands.begin(), selectedPFCands.end());
45  }
46  if (sort) std::sort(output.begin(), output.end(), SortPFCandsDescendingPt());
47  return output;
48 }
49 
50 std::vector<reco::PFCandidatePtr> pfGammas(const reco::PFJet& jet, bool sort) {
51  return pfCandidates(jet, reco::PFCandidate::gamma, sort);
52 }
53 
54 std::vector<reco::PFCandidatePtr> pfChargedCands(const reco::PFJet& jet,
55  bool sort) {
59  PFCandPtrs chs = pfCandidates(jet, reco::PFCandidate::h, false);
60  output.reserve(mus.size() + es.size() + chs.size());
61  output.insert(output.end(), mus.begin(), mus.end());
62  output.insert(output.end(), es.begin(), es.end());
63  output.insert(output.end(), chs.begin(), chs.end());
64  if (sort) std::sort(output.begin(), output.end(), SortPFCandsDescendingPt());
65  return output;
66 }
67 
68 
69 
70 } }
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