Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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
40#include "G4Fragment.hh"
42#include "G4ios.hh"
43#include <iomanip>
44
46{
48 return _instance;
49}
50
51const G4double G4Fragment::minFragExcitation = 10.*CLHEP::eV;
52
53// Default constructor
55 theA(0),
56 theZ(0),
57 theExcitationEnergy(0.0),
58 theGroundStateMass(0.0),
59 theMomentum(G4LorentzVector(0,0,0,0)),
60 thePolarization(nullptr),
61 creatorModel(-1),
62 numberOfParticles(0),
63 numberOfCharged(0),
64 numberOfHoles(0),
65 numberOfChargedHoles(0),
66 numberOfShellElectrons(0),
67 xLevel(0),
68 theParticleDefinition(nullptr),
69 spin(0.0),
70 theCreationTime(0.0)
71{}
72
73// Copy Constructor
75 theA(right.theA),
76 theZ(right.theZ),
77 theExcitationEnergy(right.theExcitationEnergy),
78 theGroundStateMass(right.theGroundStateMass),
79 theMomentum(right.theMomentum),
80 thePolarization(right.thePolarization),
81 creatorModel(right.creatorModel),
82 numberOfParticles(right.numberOfParticles),
83 numberOfCharged(right.numberOfCharged),
84 numberOfHoles(right.numberOfHoles),
85 numberOfChargedHoles(right.numberOfChargedHoles),
86 numberOfShellElectrons(right.numberOfShellElectrons),
87 xLevel(right.xLevel),
88 theParticleDefinition(right.theParticleDefinition),
89 spin(right.spin),
90 theCreationTime(right.theCreationTime)
91{}
92
94{}
95
96G4Fragment::G4Fragment(G4int A, G4int Z, const G4LorentzVector& aMomentum, G4bool warning) :
97 theA(A),
98 theZ(Z),
99 theExcitationEnergy(0.0),
100 theGroundStateMass(0.0),
101 theMomentum(aMomentum),
102 thePolarization(nullptr),
103 creatorModel(-1),
104 numberOfParticles(0),
105 numberOfCharged(0),
106 numberOfHoles(0),
107 numberOfChargedHoles(0),
108 numberOfShellElectrons(0),
109 xLevel(0),
110 theParticleDefinition(nullptr),
111 spin(0.0),
112 theCreationTime(0.0)
113{
114 if(theA > 0) {
115 CalculateGroundStateMass();
116 CalculateExcitationEnergy(warning);
117 }
118}
119
120// This constructor is for initialize photons or electrons
122 const G4ParticleDefinition * aParticleDefinition) :
123 theA(0),
124 theZ(0),
125 theExcitationEnergy(0.0),
126 theMomentum(aMomentum),
127 thePolarization(nullptr),
128 creatorModel(-1),
129 numberOfParticles(0),
130 numberOfCharged(0),
131 numberOfHoles(0),
132 numberOfChargedHoles(0),
133 numberOfShellElectrons(0),
134 xLevel(0),
135 theParticleDefinition(aParticleDefinition),
136 spin(0.0),
137 theCreationTime(0.0)
138{
139 if(aParticleDefinition->GetPDGEncoding() != 22 &&
140 aParticleDefinition->GetPDGEncoding() != 11) {
141 G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
142 + aParticleDefinition->GetParticleName();
143 throw G4HadronicException(__FILE__, __LINE__, text);
144 }
145 theGroundStateMass = aParticleDefinition->GetPDGMass();
146}
147
149{
150 if (this != &right) {
151 theA = right.theA;
152 theZ = right.theZ;
153 theExcitationEnergy = right.theExcitationEnergy;
154 theGroundStateMass = right.theGroundStateMass;
155 theMomentum = right.theMomentum;
156 thePolarization = right.thePolarization;
157 creatorModel = right.creatorModel;
158 numberOfParticles = right.numberOfParticles;
159 numberOfCharged = right.numberOfCharged;
160 numberOfHoles = right.numberOfHoles;
161 numberOfChargedHoles = right.numberOfChargedHoles;
162 numberOfShellElectrons = right.numberOfShellElectrons;
163 xLevel = right.xLevel;
164 theParticleDefinition = right.theParticleDefinition;
165 spin = right.spin;
166 theCreationTime = right.theCreationTime;
167 }
168 return *this;
169}
170
172{
173 return (this == (G4Fragment *) &right);
174}
175
177{
178 return (this != (G4Fragment *) &right);
179}
180
181std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
182{
183 std::ios::fmtflags old_floatfield = out.flags();
184 out.setf(std::ios::floatfield);
185
186 out << "Fragment: A = " << std::setw(3) << theFragment.theA
187 << ", Z = " << std::setw(3) << theFragment.theZ ;
188 out.setf(std::ios::scientific,std::ios::floatfield);
189
190 // Store user's precision setting and reset to (3) here: back-compatibility
191 std::streamsize floatPrec = out.precision();
192
193 out << std::setprecision(3)
194 << ", U = " << theFragment.GetExcitationEnergy()/CLHEP::MeV
195 << " MeV ";
196 if(theFragment.GetCreatorModelType() >= 0) {
197 out << " creatorModelType= " << theFragment.GetCreatorModelType();
198 }
199 if(theFragment.GetCreationTime() > 0.0) {
200 out << " Time= " << theFragment.GetCreationTime()/CLHEP::ns << " ns";
201 }
202 out << G4endl
203 << " P = ("
204 << theFragment.GetMomentum().x()/CLHEP::MeV << ","
205 << theFragment.GetMomentum().y()/CLHEP::MeV << ","
206 << theFragment.GetMomentum().z()/CLHEP::MeV
207 << ") MeV E = "
208 << theFragment.GetMomentum().t()/CLHEP::MeV << " MeV"
209 << G4endl;
210
211 out << " #spin= " << theFragment.GetSpin()
212 << " #floatLevelNo= " << theFragment.GetFloatingLevelNumber() << " ";
213
214 if (theFragment.GetNumberOfExcitons() != 0) {
215 out << " "
216 << "#Particles= " << theFragment.GetNumberOfParticles()
217 << ", #Charged= " << theFragment.GetNumberOfCharged()
218 << ", #Holes= " << theFragment.GetNumberOfHoles()
219 << ", #ChargedHoles= " << theFragment.GetNumberOfChargedHoles();
220 }
221 out << G4endl;
222 if(theFragment.GetNuclearPolarization()) {
223 out << *(theFragment.GetNuclearPolarization());
224 }
225 //out << G4endl;
226 out.setf(old_floatfield,std::ios::floatfield);
227 out.precision(floatPrec);
228
229 return out;
230}
231
232void G4Fragment::ExcitationEnergyWarning()
233{
234#ifdef G4VERBOSE
235 G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
236 G4cout << *this << G4endl;
237#endif
238}
239
240void G4Fragment::NumberOfExitationWarning(const G4String& value)
241{
242 G4cout << "G4Fragment::"<< value << " ERROR "
243 << G4endl;
244 G4cout << this << G4endl;
245 G4String text = "G4Fragment::G4Fragment wrong exciton number ";
246 throw G4HadronicException(__FILE__, __LINE__, text);
247}
248
250{
251 spin = v.mag();
252}
253
255{
256 G4ThreeVector v(0.0,0.0,spin);
257 return v;
258}
double A(double temperature)
G4Allocator< G4Fragment > *& pFragmentAllocator()
Definition: G4Fragment.cc:45
std::ostream & operator<<(std::ostream &out, const G4Fragment &theFragment)
Definition: G4Fragment.cc:181
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
double mag() const
G4int GetNumberOfParticles() const
Definition: G4Fragment.hh:337
G4int GetNumberOfHoles() const
Definition: G4Fragment.hh:357
G4NuclearPolarization * GetNuclearPolarization() const
Definition: G4Fragment.hh:455
G4int GetNumberOfChargedHoles() const
Definition: G4Fragment.hh:362
G4double GetExcitationEnergy() const
Definition: G4Fragment.hh:275
const G4LorentzVector & GetMomentum() const
Definition: G4Fragment.hh:299
G4double GetCreationTime() const
Definition: G4Fragment.hh:440
G4double GetSpin() const
Definition: G4Fragment.hh:409
G4bool operator!=(const G4Fragment &right) const
Definition: G4Fragment.cc:176
G4int GetFloatingLevelNumber() const
Definition: G4Fragment.hh:419
G4int GetNumberOfExcitons() const
Definition: G4Fragment.hh:332
G4int GetCreatorModelType() const
Definition: G4Fragment.hh:399
G4ThreeVector GetAngularMomentum() const
Definition: G4Fragment.cc:254
G4Fragment & operator=(const G4Fragment &right)
Definition: G4Fragment.cc:148
G4int GetNumberOfCharged() const
Definition: G4Fragment.hh:342
G4bool operator==(const G4Fragment &right) const
Definition: G4Fragment.cc:171
void SetAngularMomentum(const G4ThreeVector &)
Definition: G4Fragment.cc:249
const G4String & GetParticleName() const
#define G4ThreadLocalStatic
Definition: tls.hh:76