Geant4-11
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4Fragment.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//---------------------------------------------------------------------
28//
29// Geant4 class G4Fragment
30//
31// Hadronic Process: Nuclear De-excitations
32// by V. Lara (May 1998)
33//
34// Modifications:
35// 03.05.2010 V.Ivanchenko General cleanup; moved obsolete methods from
36// inline to source
37// 25.09.2010 M. Kelsey -- Change "setprecision" to "setwidth" in printout,
38// add null pointer check.
39// 27.10.2021 A.Ribon extension for hypernuclei.
40
41#include "G4Fragment.hh"
43#include "G4ios.hh"
44#include <iomanip>
45
47{
49 return _instance;
50}
51
53
54// Default constructor
56 theA(0),
57 theZ(0),
58 theL(0),
59 theExcitationEnergy(0.0),
60 theGroundStateMass(0.0),
61 theMomentum(G4LorentzVector(0,0,0,0)),
62 thePolarization(nullptr),
63 creatorModel(-1),
65 numberOfCharged(0),
66 numberOfHoles(0),
67 numberOfChargedHoles(0),
68 numberOfShellElectrons(0),
69 xLevel(0),
70 theParticleDefinition(nullptr),
71 spin(0.0),
72 theCreationTime(0.0)
73{}
74
75// Copy Constructor
77 theA(right.theA),
78 theZ(right.theZ),
79 theL(right.theL),
80 theExcitationEnergy(right.theExcitationEnergy),
81 theGroundStateMass(right.theGroundStateMass),
82 theMomentum(right.theMomentum),
83 thePolarization(right.thePolarization),
84 creatorModel(right.creatorModel),
86 numberOfCharged(right.numberOfCharged),
87 numberOfHoles(right.numberOfHoles),
88 numberOfChargedHoles(right.numberOfChargedHoles),
89 numberOfShellElectrons(right.numberOfShellElectrons),
90 xLevel(right.xLevel),
91 theParticleDefinition(right.theParticleDefinition),
92 spin(right.spin),
93 theCreationTime(right.theCreationTime)
94{}
95
97{}
98
100 theA(A),
101 theZ(Z),
102 theL(0),
103 theExcitationEnergy(0.0),
104 theGroundStateMass(0.0),
105 theMomentum(aMomentum),
106 thePolarization(nullptr),
107 creatorModel(-1),
109 numberOfCharged(0),
110 numberOfHoles(0),
111 numberOfChargedHoles(0),
112 numberOfShellElectrons(0),
113 xLevel(0),
114 theParticleDefinition(nullptr),
115 spin(0.0),
116 theCreationTime(0.0)
117{
118 if(theA > 0) {
121 }
122}
123
124G4Fragment::G4Fragment(G4int A, G4int Z, G4int numberOfLambdas, const G4LorentzVector& aMomentum, G4bool warning) :
125 theA(A),
126 theZ(Z),
127 theL(std::max(numberOfLambdas,0)),
128 theExcitationEnergy(0.0),
129 theGroundStateMass(0.0),
130 theMomentum(aMomentum),
131 thePolarization(nullptr),
132 creatorModel(-1),
134 numberOfCharged(0),
135 numberOfHoles(0),
136 numberOfChargedHoles(0),
137 numberOfShellElectrons(0),
138 xLevel(0),
139 theParticleDefinition(nullptr),
140 spin(0.0),
141 theCreationTime(0.0)
142{
143 if(theA > 0) {
146 }
147}
148
149// This constructor is for initialize photons or electrons
151 const G4ParticleDefinition * aParticleDefinition) :
152 theA(0),
153 theZ(0),
154 theL(0),
155 theExcitationEnergy(0.0),
156 theMomentum(aMomentum),
157 thePolarization(nullptr),
158 creatorModel(-1),
160 numberOfCharged(0),
161 numberOfHoles(0),
162 numberOfChargedHoles(0),
163 numberOfShellElectrons(0),
164 xLevel(0),
165 theParticleDefinition(aParticleDefinition),
166 spin(0.0),
167 theCreationTime(0.0)
168{
169 if(aParticleDefinition->GetPDGEncoding() != 22 &&
170 aParticleDefinition->GetPDGEncoding() != 11) {
171 G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
172 + aParticleDefinition->GetParticleName();
173 throw G4HadronicException(__FILE__, __LINE__, text);
174 }
175 theGroundStateMass = aParticleDefinition->GetPDGMass();
176}
177
179{
180 if (this != &right) {
181 theA = right.theA;
182 theZ = right.theZ;
183 theL = right.theL;
186 theMomentum = right.theMomentum;
194 xLevel = right.xLevel;
196 spin = right.spin;
198 }
199 return *this;
200}
201
203{
204 return (this == (G4Fragment *) &right);
205}
206
208{
209 return (this != (G4Fragment *) &right);
210}
211
212std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
213{
214 std::ios::fmtflags old_floatfield = out.flags();
215 out.setf(std::ios::floatfield);
216
217 out << "Fragment: A = " << std::setw(3) << theFragment.theA
218 << ", Z = " << std::setw(3) << theFragment.theZ
219 << ", numberOfLambdas = " << std::setw(3) << theFragment.theL ;
220 out.setf(std::ios::scientific,std::ios::floatfield);
221
222 // Store user's precision setting and reset to (3) here: back-compatibility
223 std::streamsize floatPrec = out.precision();
224
225 out << std::setprecision(3)
226 << ", U = " << theFragment.GetExcitationEnergy()/CLHEP::MeV
227 << " MeV ";
228 if(theFragment.GetCreatorModelID() >= 0) {
229 out << " creatorModelID= " << theFragment.GetCreatorModelID();
230 }
231 if(theFragment.GetCreationTime() > 0.0) {
232 out << " Time= " << theFragment.GetCreationTime()/CLHEP::ns << " ns";
233 }
234 out << G4endl
235 << " P = ("
236 << theFragment.GetMomentum().x()/CLHEP::MeV << ","
237 << theFragment.GetMomentum().y()/CLHEP::MeV << ","
238 << theFragment.GetMomentum().z()/CLHEP::MeV
239 << ") MeV E = "
240 << theFragment.GetMomentum().t()/CLHEP::MeV << " MeV"
241 << G4endl;
242
243 out << " #spin= " << theFragment.GetSpin()
244 << " #floatLevelNo= " << theFragment.GetFloatingLevelNumber() << " ";
245
246 if (theFragment.GetNumberOfExcitons() != 0) {
247 out << " "
248 << "#Particles= " << theFragment.GetNumberOfParticles()
249 << ", #Charged= " << theFragment.GetNumberOfCharged()
250 << ", #Holes= " << theFragment.GetNumberOfHoles()
251 << ", #ChargedHoles= " << theFragment.GetNumberOfChargedHoles();
252 }
253 out << G4endl;
254 if(theFragment.GetNuclearPolarization()) {
255 out << *(theFragment.GetNuclearPolarization());
256 }
257 //out << G4endl;
258 out.setf(old_floatfield,std::ios::floatfield);
259 out.precision(floatPrec);
260
261 return out;
262}
263
265{
266#ifdef G4VERBOSE
267 G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
268 G4cout << *this << G4endl;
269#endif
270}
271
273{
274 G4cout << "G4Fragment::"<< value << " ERROR "
275 << G4endl;
276 G4cout << this << G4endl;
277 G4String text = "G4Fragment::G4Fragment wrong exciton number ";
278 throw G4HadronicException(__FILE__, __LINE__, text);
279}
280
282{
283 spin = v.mag();
284}
285
287{
288 G4ThreeVector v(0.0,0.0,spin);
289 return v;
290}
G4Allocator< G4Fragment > *& pFragmentAllocator()
Definition: G4Fragment.cc:46
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
const G4int Z[17]
const G4double A[17]
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static int numberOfParticles
double mag() const
G4double theCreationTime
Definition: G4Fragment.hh:225
G4double theGroundStateMass
Definition: G4Fragment.hh:202
void ExcitationEnergyWarning()
Definition: G4Fragment.cc:264
G4int GetNumberOfParticles() const
Definition: G4Fragment.hh:361
G4int GetCreatorModelID() const
Definition: G4Fragment.hh:423
G4int GetNumberOfHoles() const
Definition: G4Fragment.hh:381
G4NuclearPolarization * GetNuclearPolarization() const
Definition: G4Fragment.hh:479
void NumberOfExitationWarning(const G4String &)
Definition: G4Fragment.cc:272
G4int numberOfChargedHoles
Definition: G4Fragment.hh:216
G4int GetNumberOfChargedHoles() const
Definition: G4Fragment.hh:386
G4double GetExcitationEnergy() const
Definition: G4Fragment.hh:299
const G4LorentzVector & GetMomentum() const
Definition: G4Fragment.hh:323
G4double GetCreationTime() const
Definition: G4Fragment.hh:464
G4double GetSpin() const
Definition: G4Fragment.hh:433
G4int theZ
Definition: G4Fragment.hh:196
G4NuclearPolarization * thePolarization
Definition: G4Fragment.hh:207
G4bool operator!=(const G4Fragment &right) const
Definition: G4Fragment.cc:207
G4int GetFloatingLevelNumber() const
Definition: G4Fragment.hh:443
G4int GetNumberOfExcitons() const
Definition: G4Fragment.hh:356
G4int numberOfParticles
Definition: G4Fragment.hh:213
G4ThreeVector GetAngularMomentum() const
Definition: G4Fragment.cc:286
void CalculateExcitationEnergy(G4bool warning=true)
Definition: G4Fragment.hh:249
G4int numberOfHoles
Definition: G4Fragment.hh:215
G4int theA
Definition: G4Fragment.hh:194
const G4ParticleDefinition * theParticleDefinition
Definition: G4Fragment.hh:222
G4int theL
Definition: G4Fragment.hh:198
G4double theExcitationEnergy
Definition: G4Fragment.hh:200
G4Fragment & operator=(const G4Fragment &right)
Definition: G4Fragment.cc:178
G4int creatorModel
Definition: G4Fragment.hh:210
G4int numberOfCharged
Definition: G4Fragment.hh:214
G4int GetNumberOfCharged() const
Definition: G4Fragment.hh:366
G4int numberOfShellElectrons
Definition: G4Fragment.hh:219
G4bool operator==(const G4Fragment &right) const
Definition: G4Fragment.cc:202
void SetAngularMomentum(const G4ThreeVector &)
Definition: G4Fragment.cc:281
G4double spin
Definition: G4Fragment.hh:224
G4LorentzVector theMomentum
Definition: G4Fragment.hh:204
void CalculateGroundStateMass()
Definition: G4Fragment.hh:265
G4int xLevel
Definition: G4Fragment.hh:220
static const G4double minFragExcitation
Definition: G4Fragment.hh:227
const G4String & GetParticleName() const
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
static constexpr double MeV
static constexpr double ns
static constexpr double eV
T max(const T t1, const T t2)
brief Return the largest of the two arguments
#define G4ThreadLocalStatic
Definition: tls.hh:76