CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFTauDecayMode.cc
Go to the documentation of this file.
2 
3 namespace reco{
5  const CompositeCandidate& piZeroes,
6  const CompositeCandidate& filteredObjects)
7  {
9  piZeroes_ = piZeroes;
11 
12  // determine decay mode
13  unsigned int nCharged = chargedPions_.numberOfDaughters();
14  unsigned int nNeutral = piZeroes_.numberOfDaughters();
15  hadronicTauDecayModes hadronicTauDecayIndex = static_cast<hadronicTauDecayModes>( ((nCharged - 1)*(maxNumberOfPiZeroCandidatesAllowed+1) + nNeutral) );
16  if ( nNeutral > maxNumberOfPiZeroCandidatesAllowed)
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  {
23  const Candidate* theCandToAdd = chargedPions_.daughter(iCand);
24  this->addDaughter( *theCandToAdd );
25  }
26  for(size_type iCand = 0; iCand < nNeutral; ++iCand)
27  {
28  const Candidate* theCandToAdd = piZeroes_.daughter(iCand);
29  this->addDaughter( *theCandToAdd );
30  }
31 
33  this->setP4(chargedPions_.p4() + piZeroes_.p4());
34  this->setStatus(2); //decayed
35  this->setPdgId(12); //everyone's favorite lepton!
36  }
37 
40  {
41  return new PFTauDecayMode(*this);
42  }
43 
46  {
47  return chargedPions_;
48  }
49 
50  const CompositeCandidate&
52  {
53  return piZeroes_;
54  }
55 
56  const CompositeCandidate&
58  {
59  return filteredObjects_;
60  }
61 
62  std::vector<const Candidate*>
64  {
65  size_type numberOfChargedPions = chargedPions_.numberOfDaughters();
66  std::vector<const Candidate*> output;
67  for(size_type iterCand = 0; iterCand < numberOfChargedPions; ++iterCand)
68  output.push_back( chargedPions_.daughter(iterCand) );
69  return output;
70  }
71 
72  std::vector<const Candidate*>
74  {
75  size_type numberOfChargedPions = piZeroes_.numberOfDaughters();
76  std::vector<const Candidate*> output;
77  for(size_type iterCand = 0; iterCand < numberOfChargedPions; ++iterCand)
78  output.push_back( piZeroes_.daughter(iterCand) );
79  return output;
80  }
81 
82  std::vector<const Candidate*>
84  {
85  std::vector<const Candidate*> output = this->chargedPionCandidates();
86  std::vector<const Candidate*> neutralObjects = this->neutralPionCandidates();
87 
88  output.insert(output.end(), neutralObjects.begin(), neutralObjects.end());
89  return output;
90  }
91 
92  std::vector<const Candidate*>
94  {
95  size_t numberOfFilteredObjects = filteredObjects_.numberOfDaughters();
96  std::vector<const Candidate*> output;
97  for( size_t iFilteredCand = 0; iFilteredCand < numberOfFilteredObjects; ++iFilteredCand)
98  {
99  const Candidate* myCand = filteredObjects_.daughter(iFilteredCand);
100  if (absCharge < 0 || abs(myCand->charge()) == absCharge)
101  output.push_back(myCand);
102  }
103  return output;
104  }
105 
106  std::vector<const Candidate*>
108  {
109  return filteredObjectCandidates(1);
110  }
111 
112  std::vector<const Candidate*>
114  {
115  return filteredObjectCandidates(0);
116  }
117 
118  void
120  {
121  if (input->numberOfDaughters() == 0) //we have reached a leaf
122  {
123  if (input->hasMasterClone()) // has a master clone
124  {
125  PFCandidateRef theCandRef = input->masterClone().castTo<PFCandidateRef>();
126  toFill.push_back(theCandRef);
127  }
128  else
129  edm::LogError("PFTauDecayMode") << "Error in pfMasterClones(...) - found a leaf candidate with no Master clone reference!";
130  } else // recurse down composite chain
131  {
133  for(size_type iCand = 0; iCand < numberOfDaughters; ++iCand)
134  {
135  const Candidate* currentCand = input->daughter(iCand);
136  pfMasterClones(currentCand, toFill);
137  }
138  }
139  }
140 
143  {
145  const Candidate* input = static_cast<const Candidate*>(&chargedPions_);
146  if (input->numberOfDaughters())
147  pfMasterClones(input, output);
148  return output;
149  }
150 
153  {
155  const Candidate* input = static_cast<const Candidate*>(&piZeroes_);
156  if (input->numberOfDaughters())
157  pfMasterClones(input, output);
158  return output;
159  }
160 
163  {
165  const Candidate* input = static_cast<const Candidate*>(&filteredObjects_);
166  if (input->numberOfDaughters())
167  pfMasterClones(input, output);
168  return output;
169  }
170 
171 }
std::vector< const Candidate * > chargedFilteredObjectCandidates() const
returns only charged filtered objects
const CompositeCandidate & filteredObjects() const
returns references to PF objects that were filtered
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
CompositeCandidate piZeroes_
PFTauDecayMode * clone() const
returns a clone of the candidate
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 void setPdgId(int pdgId) final
const VertexCompositeCandidate & chargedPions() const
returns collection of charged pions w/ vertex information (tracks are refit)
virtual size_type numberOfDaughters() const
number of daughters
static std::string const input
Definition: EdmProvDump.cc:44
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
virtual size_type numberOfDaughters() const =0
number of daughters
virtual bool hasMasterClone() const =0
const CompositeCandidate & neutralPions() const
returns a collection of merged Pi0s
static const unsigned char maxNumberOfPiZeroCandidatesAllowed
virtual int charge() const final
electric charge
Definition: LeafCandidate.h:91
virtual void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual int charge() const =0
electric charge
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 void setStatus(int status) final
set status word
std::vector< const Candidate * > decayProductCandidates() const
returns pointers to non-filtered objects
CompositeCandidate filteredObjects_
unsigned int nCharged(const GenJet &jet)
REF castTo() const
Definition: RefToBase.h:286
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:69
VertexCompositeCandidate chargedPions_
void setDecayMode(hadronicTauDecayModes theDecayMode)
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
std::vector< const Candidate * > neutralFilteredObjectCandidates() const
returns only netural filtered objects
virtual const CandidateBaseRef & masterClone() const =0