LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PFParticle.cxx
Go to the documentation of this file.
1 //
3 // \brief Definition of PFParticle object for LArSoft
4 //
5 // \author usher@slac.stanford.edu
6 //
8 
10 
11 #include <iomanip>
12 #include <ostream>
13 #include <utility>
14 
15 namespace recob {
16 
17  PFParticle::PFParticle() : fPdgCode(0), fSelf(0), fParent(PFParticle::kPFParticlePrimary) {}
18 
20  size_t self,
21  size_t parent,
22  const std::vector<size_t>& daughters)
23  : fPdgCode(pdgCode), fSelf(self), fParent(parent), fDaughters(daughters)
24  {}
25 
26  PFParticle::PFParticle(int pdgCode, size_t self, size_t parent, std::vector<size_t>&& daughters)
27  : fPdgCode(pdgCode), fSelf(self), fParent(parent), fDaughters(std::move(daughters))
28  {}
29 
30  //----------------------------------------------------------------------
31  // ostream operator.
32  //
33  std::ostream& operator<<(std::ostream& o, const PFParticle& c)
34  {
35  o << std::setiosflags(std::ios::fixed) << std::setprecision(2);
36  o << "PFParticle hypothesis PDG Code " << std::setw(8) << std::right << c.PdgCode()
37  << ", is primary = " << c.IsPrimary() << ", # Daughters " << std::setw(5) << std::right
38  << c.NumDaughters() << std::endl;
39 
40  return o;
41  }
42 
43  //----------------------------------------------------------------------
44  // less than operator - basically sort in order of index into main collection
45  bool operator<(const PFParticle& a, const PFParticle& b)
46  {
47  return a.Self() < b.Self();
48  }
49 
50 } // namespace
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:102
int NumDaughters() const
Returns the number of daughter particles flowing from this one.
Definition: PFParticle.h:85
Reconstruction base classes.
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:88
STL namespace.
std::vector< size_t > fDaughters
Vector of indices into PFParticle Collection for daughters.
Definition: PFParticle.h:53
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:79
int fPdgCode
A preliminary estimate of the PFParticle type using the PDG code.
Definition: PFParticle.h:50
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:82
friend std::ostream & operator<<(std::ostream &o, const PFParticle &c)
Definition: PFParticle.cxx:33
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
friend bool operator<(const PFParticle &a, const PFParticle &b)
Definition: PFParticle.cxx:45
size_t fSelf
Self reference.
Definition: PFParticle.h:51
PFParticle()
Default constructor necessary for gccxml - not really for public use.
Definition: PFParticle.cxx:17
size_t fParent
Index into PFParticle collection for parent.
Definition: PFParticle.h:52