PFParticle.cxx
Go to the documentation of this file.
2 
3 namespace gar {
4  namespace rec {
5 
6  //--------------------------------------------------------------------------
7  //Default constructor
9  : fType(0),
10  fEnergy(0.),
11  fMass(0.),
12  fCharge(0.),
13  fPdg(0),
14  fGoodness(0.),
15  fParent(-1),
16  fDaughters(0)
17  {
18  // The default constructor is used e.g. by art::DataViewImpl::getHandle
19  // Make sure all Cluster objects are numbered, lest art deep-copy uninitialized
20  // instances and then operator==() evaluates meaninglessly true.
23 
24  fPos[0] = 0.;
25  fPos[1] = 0.;
26  fPos[2] = 0.;
27 
28  fMom[0] = 0.;
29  fMom[1] = 0.;
30  fMom[2] = 0.;
31 
32  return;
33  }
34 
35  //--------------------------------------------------------------------------
36  PFParticle::PFParticle(int type, float energy, float pos[3], float mom[3], float charge, int pdg, float goodness, size_t parent, std::vector<size_t> daughters)
37  : fType(type),
38  fEnergy(energy),
39  fMass(0.),
40  fCharge(charge),
41  fPdg(pdg),
42  fGoodness(goodness),
43  fParent(parent),
44  fDaughters(daughters)
45  {
46  fPos[0] = pos[0];
47  fPos[1] = pos[1];
48  fPos[2] = pos[2];
49 
50  fMom[0] = mom[0];
51  fMom[1] = mom[1];
52  fMom[2] = mom[2];
53  }
54 
55  //--------------------------------------------------------------------------
57  fType = type;
58  }
59 
60  //--------------------------------------------------------------------------
62  fEnergy = energy;
63  }
64 
65  //--------------------------------------------------------------------------
66  void PFParticle::setPosition(const float pos[3]) {
67  fPos[0] = pos[0];
68  fPos[1] = pos[1];
69  fPos[2] = pos[2];
70  }
71 
72  //--------------------------------------------------------------------------
73  void PFParticle::setMomentum(const float mom[3]) {
74  fMom[0] = mom[0];
75  fMom[1] = mom[1];
76  fMom[2] = mom[2];
77  }
78 
79  //--------------------------------------------------------------------------
80  void PFParticle::setMass(float mass) {
81  fMass = mass;
82  }
83 
84  //--------------------------------------------------------------------------
85  void PFParticle::setCharge(float charge) {
86  fCharge = charge;
87  }
88 
89  //--------------------------------------------------------------------------
90  void PFParticle::setParticleID(int pdg, float goodness) {
91  fPdg = pdg;
92  fGoodness = goodness;
93  }
94 
95  //--------------------------------------------------------------------------
97  fParent = parent;
98  }
99 
100  //--------------------------------------------------------------------------
101  void PFParticle::setDaughters(std::vector<size_t> daughters) {
102  fDaughters = daughters;
103  }
104 
105  //--------------------------------------------------------------------------
106  std::ostream& operator<< (std::ostream& o, gar::rec::PFParticle const& h)
107  {
108  o << "Reconstructed Particle "
109  << "\n\tType = "
110  << h.Type()
111  << "\n\tEnergy = "
112  << h.Energy()
113  << "\n\tMomentum = "
114  << h.Momentum()[0] << ", " << h.Momentum()[1] << ", " << h.Momentum()[2] << ")"
115  << "\n\tPID = "
116  << h.Pdg() << ", goodness " << h.GoodnessOfPdg()
117  << "\n\tMass = "
118  << h.Mass()
119  << "\n\tID number = "
120  << h.getIDNumber()
121  << "\n\tPosition = "
122  << h.Position()[0] << ", " << h.Position()[1] << ", " << h.Position()[2] << ")";
123 
124  return o;
125  }
126 
127 
128 
129  //--------------------------------------------------------------------------
130  // ID number methods
131  bool PFParticle::operator==(const PFParticle& rhs) const {
132  return (this->fIDnumero == rhs.fIDnumero);
133  }
134 
135  bool PFParticle::operator!=(const PFParticle& rhs) const {
136  return (this->fIDnumero != rhs.fIDnumero);
137  }
138 
140  }
141 }
float fCharge
charge of the PFParticle
Definition: PFParticle.h:45
int Type() const
Definition: PFParticle.h:90
rec
Definition: tracks.py:88
const float * Momentum() const
Definition: PFParticle.h:93
static gar::rec::IDNumber const FirstNumber
Definition: PFParticle.h:37
void setMass(float mass)
Definition: PFParticle.cxx:80
float Mass() const
Definition: PFParticle.h:94
float fPos[3]
position of the PFParticle (cluster CoG)
Definition: PFParticle.h:42
gar::rec::IDNumber fIDnumero
Definition: PFParticle.h:38
std::vector< size_t > fDaughters
Daughters of the PFParticle.
Definition: PFParticle.h:49
void setEnergy(float energy)
Definition: PFParticle.cxx:61
float Energy() const
Definition: PFParticle.h:91
void setParent(size_t parent)
Definition: PFParticle.cxx:96
int fPdg
PDG of the PFParticle.
Definition: PFParticle.h:46
static IDNumberGen * create(IDNumber iniValue=std::numeric_limits< IDNumber >::max())
Definition: IDNumberGen.cxx:18
float fMass
mass of the PFParticle
Definition: PFParticle.h:44
const float * Position() const
Definition: PFParticle.h:92
bool operator==(const PFParticle &rhs) const
Definition: PFParticle.cxx:131
float fGoodness
Goodness of the PDG of the PFParticle.
Definition: PFParticle.h:47
int Pdg() const
Definition: PFParticle.h:96
float fMom[3]
momentum of the PFParticle in GeV
Definition: PFParticle.h:43
float fEnergy
energy of the PFParticle in GeV
Definition: PFParticle.h:41
bool operator!=(const PFParticle &rhs) const
Definition: PFParticle.cxx:135
int fType
type of the PFParticle
Definition: PFParticle.h:40
General GArSoft Utilities.
void setMomentum(const float mom[3])
Definition: PFParticle.cxx:73
friend std::ostream & operator<<(std::ostream &o, gar::rec::PFParticle const &h)
Definition: PFParticle.cxx:106
void setDaughters(std::vector< size_t > daughters)
Definition: PFParticle.cxx:101
void setPosition(const float pos[3])
Definition: PFParticle.cxx:66
void setCharge(float charge)
Definition: PFParticle.cxx:85
static QCString type
Definition: declinfo.cpp:672
size_t fParent
Parent of the PFParticle.
Definition: PFParticle.h:48
void setParticleID(int pdg, float goodness)
Definition: PFParticle.cxx:90
void setType(int type)
Definition: PFParticle.cxx:56
gar::rec::IDNumber getIDNumber() const
Definition: PFParticle.cxx:139
size_t IDNumber
Definition: IDNumberGen.h:71
def parent(G, child, parent_type)
Definition: graph.py:67
float GoodnessOfPdg() const
Definition: PFParticle.h:97