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