GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2024, 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 
29 class TRootIOCtor;
30 
31 using std::string;
32 using std::ostream;
33 
34 namespace genie {
35 
36 class GHepParticle;
37 ostream & operator << (ostream & stream, const GHepParticle & p);
38 
39 class GHepParticle : public TObject {
40 
41 public :
42  using TObject::Copy; // suppress clang 'hides overloaded virtual function [-Woverloaded-virtual]' warnings
43  using TObject::Compare;
44 
45  GHepParticle();
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*);
60  ~GHepParticle();
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 
169 private:
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 
188 ClassDef(GHepParticle, 2)
189 
190 };
191 
192 } // genie namespace
193 
194 #endif // _GHEP_PARTICLE_H_
int Z(void) const
void SetFirstMother(int m)
Definition: GHepParticle.h:132
int RescatterCode(void) const
Definition: GHepParticle.h:65
TLorentzVector * GetX4(void) const
bool IsOnMassShell(void) const
double E(void) const
Get energy.
Definition: GHepParticle.h:91
void SetPz(double pz)
double fRemovalEnergy
removal energy for bound nucleons (GeV)
Definition: GHepParticle.h:185
const TLorentzVector * P4(void) const
Definition: GHepParticle.h:78
int FirstDaughter(void) const
Definition: GHepParticle.h:68
double PolzPolarAngle(void) const
Definition: GHepParticle.h:119
int fLastDaughter
last daughter idx
Definition: GHepParticle.h:180
int fPdgCode
particle PDG code
Definition: GHepParticle.h:174
static constexpr double s
Definition: Units.h:95
void AssertIsKnownParticle(void) const
void SetBound(bool bound)
void SetMomentum(const TLorentzVector &p4)
double RemovalEnergy(void) const
Get removal energy.
Definition: GHepParticle.h:100
GHepParticle & operator=(const GHepParticle &p)
double Mass(void) const
Mass that corresponds to the PDG code.
void SetPolarization(double theta, double phi)
int fFirstMother
first mother idx
Definition: GHepParticle.h:177
double fPolzPhi
azimuthal polarization angle (rad)
Definition: GHepParticle.h:184
TLorentzVector * P4(void)
Definition: GHepParticle.h:80
bool fIsBound
&#39;is it a bound particle?&#39; flag
Definition: GHepParticle.h:186
GHepStatus_t fStatus
particle status
Definition: GHepParticle.h:175
double Pz(void) const
Get Pz.
Definition: GHepParticle.h:90
GHepStatus_t Status(void) const
Definition: GHepParticle.h:64
void SetPx(double px)
double Energy(void) const
Get energy.
Definition: GHepParticle.h:92
int fFirstDaughter
first daughter idx
Definition: GHepParticle.h:179
double Px(void) const
Get Px.
Definition: GHepParticle.h:88
bool CompareMomentum(const GHepParticle *p) const
bool Compare(const GHepParticle *p) const
int LastMother(void) const
Definition: GHepParticle.h:67
double Vt(void) const
Get production time.
Definition: GHepParticle.h:97
int Pdg(void) const
Definition: GHepParticle.h:63
int FirstMother(void) const
Definition: GHepParticle.h:66
string Name(void) const
Name that corresponds to the PDG code.
void Clear(Option_t *option)
TLorentzVector * fP4
momentum 4-vector (GeV)
Definition: GHepParticle.h:181
void SetPosition(const TLorentzVector &v4)
int LastDaughter(void) const
Definition: GHepParticle.h:69
bool operator==(const GHepParticle &p) const
void SetLastDaughter(int d)
Definition: GHepParticle.h:135
int fRescatterCode
rescattering code
Definition: GHepParticle.h:176
bool HasDaughters(void) const
Definition: GHepParticle.h:70
void SetRescatterCode(int code)
Definition: GHepParticle.h:129
void Copy(const GHepParticle &particle)
TLorentzVector * GetP4(void) const
bool ComparePdgCodes(const GHepParticle *p) const
void Print(ostream &stream) const
TLorentzVector * X4(void)
Definition: GHepParticle.h:81
double Charge(void) const
Chrg that corresponds to the PDG code.
bool PolzIsSet(void) const
bool IsOffMassShell(void) const
void GetPolarization(TVector3 &polz)
bool CompareStatusCodes(const GHepParticle *p) const
void SetRemovalEnergy(double Erm)
TLorentzVector * fX4
position 4-vector (in the target nucleus coordinate system / x,y,z in fm / t from the moment of the p...
Definition: GHepParticle.h:182
bool CompareFamily(const GHepParticle *p) const
double KinE(bool mass_from_pdg=false) const
Get kinetic energy.
void SetLastMother(int m)
Definition: GHepParticle.h:133
double Vz(void) const
Get production z.
Definition: GHepParticle.h:96
const TLorentzVector * X4(void) const
Definition: GHepParticle.h:79
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
void SetStatus(GHepStatus_t s)
Definition: GHepParticle.h:126
bool IsBound(void) const
Definition: GHepParticle.h:71
int fLastMother
last mother idx
Definition: GHepParticle.h:178
friend ostream & operator<<(ostream &stream, const GHepParticle &p)
double fPolzTheta
polar polarization angle (rad)
Definition: GHepParticle.h:183
double Vy(void) const
Get production y.
Definition: GHepParticle.h:95
int A(void) const
double PolzAzimuthAngle(void) const
Definition: GHepParticle.h:120
void SetEnergy(double E)
void SetFirstDaughter(int d)
Definition: GHepParticle.h:134
static constexpr double m
Definition: Units.h:71
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
void SetPy(double py)
enum genie::EGHepStatus GHepStatus_t
double Vx(void) const
Get production x.
Definition: GHepParticle.h:94
void SetPdgCode(int c)
double Py(void) const
Get Py.
Definition: GHepParticle.h:89