GENIEGenerator
Loading...
Searching...
No Matches
GHepParticle.h
Go to the documentation of this file.
1//____________________________________________________________________________
2/*!
3
4\class genie::GHepParticle
5
6\brief STDHEP-like event record entry that can fit a particle or a nucleus.
7
8\author Costas Andreopoulos <c.andreopoulos \at cern.ch>
9 University of Liverpool
10
11\created November 18, 2004
12
13\cpright Copyright (c) 2003-2025, The GENIE Collaboration
14 For the full text of the license visit http://copyright.genie-mc.org
15*/
16//____________________________________________________________________________
17
18#ifndef _GHEP_PARTICLE_H_
19#define _GHEP_PARTICLE_H_
20
21#include <string>
22#include <iostream>
23
24#include <TObject.h>
25#include <TLorentzVector.h>
26
28
29class TRootIOCtor;
30
31using std::string;
32using std::ostream;
33
34namespace genie {
35
36class GHepParticle;
37ostream & operator << (ostream & stream, const GHepParticle & p);
38
39class GHepParticle : public TObject {
40
41public :
42 using TObject::Copy; // suppress clang 'hides overloaded virtual function [-Woverloaded-virtual]' warnings
43 using TObject::Compare;
44
46 GHepParticle(const GHepParticle & particle);
47
48 // TParticle-like constructors for compatibility
50 int pdg, GHepStatus_t status,
51 int mother1, int mother2, int daughter1, int daughter2,
52 const TLorentzVector & p, const TLorentzVector & v);
54 int pdg, GHepStatus_t status,
55 int mother1, int mother2, int daughter1, int daughter2,
56 double px, double py, double pz, double E,
57 double x, double y, double z, double t);
58
59 GHepParticle(TRootIOCtor*);
61
62 // Basic properties
63 int Pdg (void) const { return fPdgCode; }
64 GHepStatus_t Status (void) const { return fStatus; }
65 int RescatterCode (void) const { return fRescatterCode; }
66 int FirstMother (void) const { return fFirstMother; }
67 int LastMother (void) const { return fLastMother; }
68 int FirstDaughter (void) const { return fFirstDaughter; }
69 int LastDaughter (void) const { return fLastDaughter; }
70 bool HasDaughters (void) const { return (fFirstDaughter!=-1); }
71 bool IsBound (void) const { return fIsBound; }
72
73 string Name (void) const; ///< Name that corresponds to the PDG code
74 double Mass (void) const; ///< Mass that corresponds to the PDG code
75 double Charge (void) const; ///< Chrg that corresponds to the PDG code
76
77 // Returns the momentum & position 4-vectors
78 const TLorentzVector * P4 (void) const { return fP4; }
79 const TLorentzVector * X4 (void) const { return fX4; }
80 TLorentzVector * P4 (void) { return fP4; }
81 TLorentzVector * X4 (void) { return fX4; }
82
83 // Hand over clones of the momentum & position 4-vectors (+ their ownership)
84 TLorentzVector * GetP4 (void) const;
85 TLorentzVector * GetX4 (void) const;
86
87 // Returns the momentum & position 4-vectors components
88 double Px (void) const { return (fP4) ? fP4->Px() : 0; } ///< Get Px
89 double Py (void) const { return (fP4) ? fP4->Py() : 0; } ///< Get Py
90 double Pz (void) const { return (fP4) ? fP4->Pz() : 0; } ///< Get Pz
91 double E (void) const { return (fP4) ? fP4->Energy() : 0; } ///< Get energy
92 double Energy (void) const { return this->E(); } ///< Get energy
93 double KinE (bool mass_from_pdg = false) const; ///< Get kinetic energy
94 double Vx (void) const { return (fX4) ? fX4->X() : 0; } ///< Get production x
95 double Vy (void) const { return (fX4) ? fX4->Y() : 0; } ///< Get production y
96 double Vz (void) const { return (fX4) ? fX4->Z() : 0; } ///< Get production z
97 double Vt (void) const { return (fX4) ? fX4->T() : 0; } ///< Get production time
98
99 // Return removal energy /set only for bound nucleons/
100 double RemovalEnergy (void) const { return fRemovalEnergy; } ///< Get removal energy
101
102 // Compare with another particle
103 bool Compare (const GHepParticle * p) const;
104 bool ComparePdgCodes (const GHepParticle * p) const;
105 bool CompareStatusCodes (const GHepParticle * p) const;
106 bool CompareFamily (const GHepParticle * p) const;
107 bool CompareMomentum (const GHepParticle * p) const;
108
109 // On/Off "shellness" if mass from PDG != mass from 4-P
110 bool IsOnMassShell (void) const;
111 bool IsOffMassShell (void) const;
112
113 // Relevant if GHEP entry is a nucleus, else=-1 / Decoded from PDG code
114 int Z (void) const;
115 int A (void) const;
116
117 // Get the polarization. Most likely it is only the f/s primary lepton
118 // for which this is usefull and might be set during event generation
119 double PolzPolarAngle (void) const { return fPolzTheta; }
120 double PolzAzimuthAngle (void) const { return fPolzPhi; }
121 bool PolzIsSet (void) const;
122 void GetPolarization (TVector3 & polz);
123
124 // Set pdg code and status codes
125 void SetPdgCode (int c);
127
128 // Set the rescattering code
129 void SetRescatterCode(int code) { fRescatterCode = code; }
130
131 // Set the mother/daughter links
132 void SetFirstMother (int m) { fFirstMother = m; }
133 void SetLastMother (int m) { fLastMother = m; }
134 void SetFirstDaughter (int d) { fFirstDaughter = d; }
135 void SetLastDaughter (int d) { fLastDaughter = d; }
136
137 // Set the momentum & position 4-vectors
138 void SetMomentum (const TLorentzVector & p4);
139 void SetPosition (const TLorentzVector & v4);
140 void SetMomentum (double px, double py, double pz, double E);
141 void SetPosition (double x, double y, double z, double t);
142 void SetEnergy (double E );
143 void SetPx (double px);
144 void SetPy (double py);
145 void SetPz (double pz);
146
147 // Set the polarization angles
148 void SetPolarization(double theta, double phi);
149 void SetPolarization(const TVector3 & polz);
150
151 // Set the bould flag & removal energy (bound flag set automatically
152 // if a positive removal energy is set)
153 void SetBound (bool bound);
154 void SetRemovalEnergy (double Erm);
155
156 // Clean-up, reset, copy, print,...
157 void CleanUp (void);
158 void Reset (void);
159 void Clear (Option_t * option);
160 void Copy (const GHepParticle & particle);
161 void Print (ostream & stream) const;
162 void Print (Option_t * opt) const;
163
164 // Overloaded operators
165 bool operator == (const GHepParticle & p) const;
167 friend ostream & operator << (ostream & stream, const GHepParticle & p);
168
169private:
170
171 void Init(void);
172 void AssertIsKnownParticle(void) const;
173
174 int fPdgCode; ///< particle PDG code
175 GHepStatus_t fStatus; ///< particle status
176 int fRescatterCode; ///< rescattering code
177 int fFirstMother; ///< first mother idx
178 int fLastMother; ///< last mother idx
179 int fFirstDaughter; ///< first daughter idx
180 int fLastDaughter; ///< last daughter idx
181 TLorentzVector * fP4; ///< momentum 4-vector (GeV)
182 TLorentzVector * fX4; ///< position 4-vector (in the target nucleus coordinate system / x,y,z in fm / t from the moment of the primary interaction in ys(yocto second = 10^-24 s)
183 double fPolzTheta; ///< polar polarization angle (rad)
184 double fPolzPhi; ///< azimuthal polarization angle (rad)
185 double fRemovalEnergy; ///< removal energy for bound nucleons (GeV)
186 bool fIsBound; ///< 'is it a bound particle?' flag
187
188ClassDef(GHepParticle, 2)
189
190};
191
192} // genie namespace
193
194#endif // _GHEP_PARTICLE_H_
STDHEP-like event record entry that can fit a particle or a nucleus.
string Name(void) const
Name that corresponds to the PDG code.
GHepStatus_t fStatus
particle status
TLorentzVector * P4(void)
int FirstMother(void) const
double fPolzPhi
azimuthal polarization angle (rad)
void SetPosition(const TLorentzVector &v4)
int fLastDaughter
last daughter idx
void SetLastDaughter(int d)
void SetMomentum(const TLorentzVector &p4)
TLorentzVector * GetP4(void) const
bool operator==(const GHepParticle &p) const
void SetRescatterCode(int code)
bool IsOffMassShell(void) const
int Pdg(void) const
void Copy(const GHepParticle &particle)
void SetFirstMother(int m)
void SetLastMother(int m)
double Vy(void) const
Get production y.
void SetRemovalEnergy(double Erm)
bool ComparePdgCodes(const GHepParticle *p) const
void Clear(Option_t *option)
const TLorentzVector * P4(void) const
double Charge(void) const
Chrg that corresponds to the PDG code.
void SetPz(double pz)
GHepParticle & operator=(const GHepParticle &p)
void AssertIsKnownParticle(void) const
double Mass(void) const
Mass that corresponds to the PDG code.
int LastMother(void) const
double PolzAzimuthAngle(void) const
double RemovalEnergy(void) const
Get removal energy.
const TLorentzVector * X4(void) const
int LastDaughter(void) const
bool IsBound(void) const
double fPolzTheta
polar polarization angle (rad)
void Print(ostream &stream) const
int fFirstDaughter
first daughter idx
double PolzPolarAngle(void) const
TLorentzVector * GetX4(void) const
bool CompareFamily(const GHepParticle *p) const
void SetStatus(GHepStatus_t s)
void SetEnergy(double E)
bool IsOnMassShell(void) const
bool HasDaughters(void) const
double Px(void) const
Get Px.
void SetPy(double py)
int Z(void) const
double E(void) const
Get energy.
double Pz(void) const
Get Pz.
double Py(void) const
Get Py.
friend ostream & operator<<(ostream &stream, const GHepParticle &p)
bool fIsBound
'is it a bound particle?' flag
void SetPolarization(double theta, double phi)
void SetPx(double px)
TLorentzVector * fP4
momentum 4-vector (GeV)
void SetBound(bool bound)
double Vz(void) const
Get production z.
bool CompareStatusCodes(const GHepParticle *p) const
double Energy(void) const
Get energy.
TLorentzVector * fX4
position 4-vector (in the target nucleus coordinate system / x,y,z in fm / t from the moment of the p...
bool PolzIsSet(void) const
int RescatterCode(void) const
int A(void) const
int fFirstMother
first mother idx
int fLastMother
last mother idx
int fPdgCode
particle PDG code
bool CompareMomentum(const GHepParticle *p) const
double fRemovalEnergy
removal energy for bound nucleons (GeV)
void SetFirstDaughter(int d)
double KinE(bool mass_from_pdg=false) const
Get kinetic energy.
GHepStatus_t Status(void) const
double Vx(void) const
Get production x.
double Vt(void) const
Get production time.
void GetPolarization(TVector3 &polz)
int fRescatterCode
rescattering code
int FirstDaughter(void) const
TLorentzVector * X4(void)
bool Compare(const GHepParticle *p) const
Utilities for improving the code readability when using PDG codes.
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
enum genie::EGHepStatus GHepStatus_t
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)