Geant4  10.00.p03
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 // $Id: G4Fragment.cc 79213 2014-02-20 14:43:12Z gcosmo $
27 //
28 //---------------------------------------------------------------------
29 //
30 // Geant4 class G4Fragment
31 //
32 // Hadronic Process: Nuclear De-excitations
33 // by V. Lara (May 1998)
34 //
35 // Modifications:
36 // 03.05.2010 V.Ivanchenko General cleanup; moved obsolete methods from
37 // inline to source
38 // 25.09.2010 M. Kelsey -- Change "setprecision" to "setwidth" in printout,
39 // add null pointer check.
40 
41 #include "G4Fragment.hh"
42 #include "G4HadronicException.hh"
43 #include "G4Gamma.hh"
44 #include "G4Electron.hh"
45 #include "G4ios.hh"
46 #include <iomanip>
47 
48 //#define debug_G4Fragment
49 
51 
52 // Default constructor
54  theA(0),
55  theZ(0),
56  theExcitationEnergy(0.0),
57  theGroundStateMass(0.0),
58  theMomentum(G4LorentzVector(0,0,0,0)),
59  theAngularMomentum(G4ThreeVector(0,0,0)),
61  numberOfCharged(0),
62  numberOfHoles(0),
63  numberOfChargedHoles(0),
64  numberOfShellElectrons(0),
65  theParticleDefinition(0),
66  theCreationTime(0.0),
67  isStable(true)
68 {}
69 
70 // Copy Constructor
72 {
73  theA = right.theA;
74  theZ = right.theZ;
77  theMomentum = right.theMomentum;
86  isStable = right.isStable;
87 }
88 
90 {}
91 
93  theA(A),
94  theZ(Z),
95  theMomentum(aMomentum),
96  theAngularMomentum(G4ThreeVector(0,0,0)),
98  numberOfCharged(0),
99  numberOfHoles(0),
100  numberOfChargedHoles(0),
101  numberOfShellElectrons(0),
102  theParticleDefinition(0),
103  theCreationTime(0.0),
104  isStable(true)
105 {
106  theExcitationEnergy = 0.0;
107  theGroundStateMass = 0.0;
108  if(theA > 0) {
111 
112  // default flag of stability for excited fragments is false
113  // it may be overwritten by SetStable(G4bool val) method
114  if(theExcitationEnergy > 0.0) { isStable = false; }
115  }
116 }
117 
118 // This constructor is for initialize photons or electrons
120  G4ParticleDefinition * aParticleDefinition) :
121  theA(0),
122  theZ(0),
123  theMomentum(aMomentum),
124  theAngularMomentum(G4ThreeVector(0,0,0)),
126  numberOfCharged(0),
127  numberOfHoles(0),
128  numberOfChargedHoles(0),
129  numberOfShellElectrons(0),
130  theParticleDefinition(aParticleDefinition),
131  theCreationTime(0.0),
132  isStable(true)
133 {
134  theExcitationEnergy = 0.0;
135  if(aParticleDefinition->GetPDGEncoding() != 22 &&
136  aParticleDefinition->GetPDGEncoding() != 11) {
137  G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
138  + aParticleDefinition->GetParticleName();
139  throw G4HadronicException(__FILE__, __LINE__, text);
140  }
141  theGroundStateMass = aParticleDefinition->GetPDGMass();
142 }
143 
145 {
146  if (this != &right) {
147  theA = right.theA;
148  theZ = right.theZ;
151  theMomentum = right.theMomentum;
160  isStable = right.isStable;
161  }
162  return *this;
163 }
164 
166 {
167  return (this == (G4Fragment *) &right);
168 }
169 
171 {
172  return (this != (G4Fragment *) &right);
173 }
174 
175 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
176 {
177  if (!theFragment) {
178  out << "Fragment: null pointer ";
179  return out;
180  }
181 
182  std::ios::fmtflags old_floatfield = out.flags();
183  out.setf(std::ios::floatfield);
184 
185  out << "Fragment: A = " << std::setw(3) << theFragment->theA
186  << ", Z = " << std::setw(3) << theFragment->theZ ;
187  out.setf(std::ios::scientific,std::ios::floatfield);
188 
189  // Store user's precision setting and reset to (3) here: back-compatibility
190  std::streamsize floatPrec = out.precision();
191 
192  out << std::setprecision(3)
193  << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV
194  << " MeV IsStable= " << theFragment->IsStable() << G4endl
195  << " P = ("
196  << theFragment->theMomentum.x()/CLHEP::MeV << ","
197  << theFragment->theMomentum.y()/CLHEP::MeV << ","
198  << theFragment->theMomentum.z()/CLHEP::MeV
199  << ") MeV E = "
200  << theFragment->theMomentum.t()/CLHEP::MeV << " MeV"
201  << G4endl;
202 
203  // What about Angular momentum???
204 
205  if (theFragment->GetNumberOfExcitons() != 0) {
206  out << " "
207  << "#Particles= " << theFragment->numberOfParticles
208  << ", #Charged= " << theFragment->numberOfCharged
209  << ", #Holes= " << theFragment->numberOfHoles
210  << ", #ChargedHoles= " << theFragment->numberOfChargedHoles
211  << G4endl;
212  }
213  out.setf(old_floatfield,std::ios::floatfield);
214  out.precision(floatPrec);
215 
216  return out;
217 }
218 
219 std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
220 {
221  out << &theFragment;
222  return out;
223 }
224 
226 {
227  if (theExcitationEnergy < -10 * CLHEP::eV) {
228 
229 #ifdef G4VERBOSE
230  G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
231  G4cout << *this << G4endl;
232 #endif
233 
234 #ifdef debug_G4Fragment
236  ed << *this << G4endl;
237  G4Exception("G4Fragment::ExcitationEnergyWarning()", "had777",
238  FatalException,ed);
239 #endif
240  }
241  theExcitationEnergy = 0.0;
242 }
243 
245 {
246  G4cout << "G4Fragment::"<< value << " ERROR "
247  << G4endl;
248  G4cout << this << G4endl;
249  G4String text = "G4Fragment::G4Fragment wrong exciton number ";
250  throw G4HadronicException(__FILE__, __LINE__, text);
251 }
G4int theZ
Definition: G4Fragment.hh:176
G4double theCreationTime
Definition: G4Fragment.hh:202
static const double MeV
Definition: G4SIunits.hh:193
G4double theGroundStateMass
Definition: G4Fragment.hh:180
G4int numberOfCharged
Definition: G4Fragment.hh:190
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
CLHEP::Hep3Vector G4ThreeVector
void ExcitationEnergyWarning()
Definition: G4Fragment.cc:225
G4bool isStable(Cluster const *const c)
True if the cluster is stable.
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4ThreadLocal G4Allocator< G4Fragment > * pFragmentAllocator
Definition: G4Fragment.cc:50
G4int numberOfShellElectrons
Definition: G4Fragment.hh:198
G4GLOB_DLL std::ostream G4cout
G4bool operator==(const G4Fragment &right) const
Definition: G4Fragment.cc:165
bool G4bool
Definition: G4Types.hh:79
static G4ThreadLocal int numberOfParticles
void CalculateExcitationEnergy()
Definition: G4Fragment.hh:227
G4int theA
Definition: G4Fragment.hh:174
G4ThreeVector theAngularMomentum
Definition: G4Fragment.hh:184
static const G4double A[nN]
G4LorentzVector theMomentum
Definition: G4Fragment.hh:182
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int numberOfHoles
Definition: G4Fragment.hh:192
std::ostream & operator<<(std::ostream &out, const G4Fragment *theFragment)
Definition: G4Fragment.cc:175
static const double eV
Definition: G4SIunits.hh:194
G4int numberOfParticles
Definition: G4Fragment.hh:188
G4bool IsStable() const
Definition: G4Fragment.hh:408
G4double GetPDGMass() const
G4int GetNumberOfExcitons() const
Definition: G4Fragment.hh:320
G4ParticleDefinition * theParticleDefinition
Definition: G4Fragment.hh:200
G4bool operator!=(const G4Fragment &right) const
Definition: G4Fragment.cc:170
#define G4endl
Definition: G4ios.hh:61
void NumberOfExitationWarning(const G4String &)
Definition: G4Fragment.cc:244
void CalculateGroundStateMass()
Definition: G4Fragment.hh:233
G4Fragment & operator=(const G4Fragment &right)
Definition: G4Fragment.cc:144
G4bool isStable
Definition: G4Fragment.hh:204
G4int numberOfChargedHoles
Definition: G4Fragment.hh:194
G4double GetExcitationEnergy() const
Definition: G4Fragment.hh:255
G4double theExcitationEnergy
Definition: G4Fragment.hh:178
CLHEP::HepLorentzVector G4LorentzVector