CMS 3D CMS Logo

PFTauDecayMode.cc
Go to the documentation of this file.
2 
3 namespace reco {
5  const CompositeCandidate& piZeroes,
6  const CompositeCandidate& filteredObjects) {
8  piZeroes_ = piZeroes;
10 
11  // determine decay mode
12  unsigned int nCharged = chargedPions_.numberOfDaughters();
13  unsigned int nNeutral = piZeroes_.numberOfDaughters();
14  hadronicTauDecayModes hadronicTauDecayIndex =
15  static_cast<hadronicTauDecayModes>(((nCharged - 1) * (maxNumberOfPiZeroCandidatesAllowed + 1) + nNeutral));
17  hadronicTauDecayIndex = static_cast<hadronicTauDecayModes>(tauDecayOther);
18  this->setDecayMode(hadronicTauDecayIndex);
19 
20  // setup Particle base
21  for (size_type iCand = 0; iCand < nCharged; ++iCand) {
22  const Candidate* theCandToAdd = chargedPions_.daughter(iCand);
23  this->addDaughter(*theCandToAdd);
24  }
25  for (size_type iCand = 0; iCand < nNeutral; ++iCand) {
26  const Candidate* theCandToAdd = piZeroes_.daughter(iCand);
27  this->addDaughter(*theCandToAdd);
28  }
29 
31  this->setP4(chargedPions_.p4() + piZeroes_.p4());
32  this->setStatus(2); //decayed
33  this->setPdgId(12); //everyone's favorite lepton!
34  }
35 
36  PFTauDecayMode* PFTauDecayMode::clone() const { return new PFTauDecayMode(*this); }
37 
39 
41 
43 
44  std::vector<const Candidate*> PFTauDecayMode::chargedPionCandidates() const {
45  size_type numberOfChargedPions = chargedPions_.numberOfDaughters();
46  std::vector<const Candidate*> output;
47  for (size_type iterCand = 0; iterCand < numberOfChargedPions; ++iterCand)
48  output.push_back(chargedPions_.daughter(iterCand));
49  return output;
50  }
51 
52  std::vector<const Candidate*> PFTauDecayMode::neutralPionCandidates() const {
53  size_type numberOfChargedPions = piZeroes_.numberOfDaughters();
54  std::vector<const Candidate*> output;
55  for (size_type iterCand = 0; iterCand < numberOfChargedPions; ++iterCand)
56  output.push_back(piZeroes_.daughter(iterCand));
57  return output;
58  }
59 
60  std::vector<const Candidate*> PFTauDecayMode::decayProductCandidates() const {
61  std::vector<const Candidate*> output = this->chargedPionCandidates();
62  std::vector<const Candidate*> neutralObjects = this->neutralPionCandidates();
63 
64  output.insert(output.end(), neutralObjects.begin(), neutralObjects.end());
65  return output;
66  }
67 
68  std::vector<const Candidate*> PFTauDecayMode::filteredObjectCandidates(int absCharge) const {
69  size_t numberOfFilteredObjects = filteredObjects_.numberOfDaughters();
70  std::vector<const Candidate*> output;
71  for (size_t iFilteredCand = 0; iFilteredCand < numberOfFilteredObjects; ++iFilteredCand) {
72  const Candidate* myCand = filteredObjects_.daughter(iFilteredCand);
73  if (absCharge < 0 || abs(myCand->charge()) == absCharge)
74  output.push_back(myCand);
75  }
76  return output;
77  }
78 
79  std::vector<const Candidate*> PFTauDecayMode::chargedFilteredObjectCandidates() const {
80  return filteredObjectCandidates(1);
81  }
82 
83  std::vector<const Candidate*> PFTauDecayMode::neutralFilteredObjectCandidates() const {
84  return filteredObjectCandidates(0);
85  }
86 
88  if (input->numberOfDaughters() == 0) //we have reached a leaf
89  {
90  if (input->hasMasterClone()) // has a master clone
91  {
92  PFCandidateRef theCandRef = input->masterClone().castTo<PFCandidateRef>();
93  toFill.push_back(theCandRef);
94  } else
95  edm::LogError("PFTauDecayMode")
96  << "Error in pfMasterClones(...) - found a leaf candidate with no Master clone reference!";
97  } else // recurse down composite chain
98  {
100  for (size_type iCand = 0; iCand < numberOfDaughters; ++iCand) {
101  const Candidate* currentCand = input->daughter(iCand);
102  pfMasterClones(currentCand, toFill);
103  }
104  }
105  }
106 
109  const Candidate* input = static_cast<const Candidate*>(&chargedPions_);
110  if (input->numberOfDaughters())
111  pfMasterClones(input, output);
112  return output;
113  }
114 
117  const Candidate* input = static_cast<const Candidate*>(&piZeroes_);
118  if (input->numberOfDaughters())
119  pfMasterClones(input, output);
120  return output;
121  }
122 
125  const Candidate* input = static_cast<const Candidate*>(&filteredObjects_);
126  if (input->numberOfDaughters())
127  pfMasterClones(input, output);
128  return output;
129  }
130 
131 } // namespace reco
std::vector< const Candidate * > chargedFilteredObjectCandidates() const
returns only charged filtered objects
const CompositeCandidate & filteredObjects() const
returns references to PF objects that were filtered
CompositeCandidate piZeroes_
void pfMasterClones(const Candidate *input, PFCandidateRefVector &toFill) const
fills master clones to PF objects (utility function)
size_t size_type
Definition: Candidate.h:30
std::vector< const Candidate * > neutralPionCandidates() const
returns pointers to neutral pions
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
PFTauDecayMode * clone() const override
returns a clone of the candidate
int charge() const final
electric charge
const VertexCompositeCandidate & chargedPions() const
returns collection of charged pions w/ vertex information (tracks are refit)
static std::string const input
Definition: EdmProvDump.cc:48
std::vector< const Candidate * > filteredObjectCandidates(int absCharge=-2) const
returns pointers to filtered objects (i.e. those not included in signal objects)
PFCandidateRefVector associatedChargedPFCandidates() const
returns the PFCandidates associated to the charged signal objects
void setCharge(Charge q) final
set electric charge
const CompositeCandidate & neutralPions() const
returns a collection of merged Pi0s
static const unsigned char maxNumberOfPiZeroCandidatesAllowed
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const LorentzVector & p4() const final
four-momentum Lorentz vector
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
PFCandidateRefVector filteredPFCandidates() const
returns the PFCandidates that were filtered
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
PFCandidateRefVector associatedNeutralPFCandidates() const
returns the PFCandidates associated to the PiZero signal objects (i.e., the unmerged photons) ...
std::vector< const Candidate * > chargedPionCandidates() const
returns pointers to charged pions
virtual const CandidateBaseRef & masterClone() const =0
std::vector< const Candidate * > decayProductCandidates() const
returns pointers to non-filtered objects
CompositeCandidate filteredObjects_
REF castTo() const
Definition: RefToBase.h:257
virtual int charge() const =0
electric charge
fixed size matrix
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
VertexCompositeCandidate chargedPions_
size_type numberOfDaughters() const override
number of daughters
void setStatus(int status) final
set status word
virtual size_type numberOfDaughters() const =0
number of daughters
void setDecayMode(hadronicTauDecayModes theDecayMode)
void setPdgId(int pdgId) final
void setP4(const LorentzVector &p4) final
set 4-momentum
std::vector< const Candidate * > neutralFilteredObjectCandidates() const
returns only netural filtered objects
virtual bool hasMasterClone() const =0