Geant4  10.01.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 85824 2014-11-05 15:26:17Z 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)),
60  creatorModel(-1),
62  numberOfCharged(0),
63  numberOfHoles(0),
64  numberOfChargedHoles(0),
65  numberOfShellElectrons(0),
66  theParticleDefinition(0),
67  theCreationTime(0.0),
68  isStable(true)
69 {}
70 
71 // Copy Constructor
73 {
74  theA = right.theA;
75  theZ = right.theZ;
78  theMomentum = right.theMomentum;
80  creatorModel = right.creatorModel;
88  isStable = right.isStable;
89 }
90 
92 {}
93 
95  theA(A),
96  theZ(Z),
97  theMomentum(aMomentum),
98  theAngularMomentum(G4ThreeVector(0,0,0)),
99  creatorModel(-1),
101  numberOfCharged(0),
102  numberOfHoles(0),
103  numberOfChargedHoles(0),
104  numberOfShellElectrons(0),
105  theParticleDefinition(0),
106  theCreationTime(0.0),
107  isStable(true)
108 {
109  theExcitationEnergy = 0.0;
110  theGroundStateMass = 0.0;
111  if(theA > 0) {
114 
115  // default flag of stability for excited fragments is false
116  // it may be overwritten by SetStable(G4bool val) method
117  if(theExcitationEnergy > 0.0) { isStable = false; }
118  }
119 }
120 
121 // This constructor is for initialize photons or electrons
123  const G4ParticleDefinition * aParticleDefinition) :
124  theA(0),
125  theZ(0),
126  theMomentum(aMomentum),
127  theAngularMomentum(G4ThreeVector(0,0,0)),
128  creatorModel(-1),
130  numberOfCharged(0),
131  numberOfHoles(0),
132  numberOfChargedHoles(0),
133  numberOfShellElectrons(0),
134  theParticleDefinition(aParticleDefinition),
135  theCreationTime(0.0),
136  isStable(true)
137 {
138  theExcitationEnergy = 0.0;
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;
155  theMomentum = right.theMomentum;
157  creatorModel = right.creatorModel;
165  isStable = right.isStable;
166  }
167  return *this;
168 }
169 
171 {
172  return (this == (G4Fragment *) &right);
173 }
174 
176 {
177  return (this != (G4Fragment *) &right);
178 }
179 
180 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
181 {
182  if (!theFragment) {
183  out << "Fragment: null pointer ";
184  return out;
185  }
186 
187  std::ios::fmtflags old_floatfield = out.flags();
188  out.setf(std::ios::floatfield);
189 
190  out << "Fragment: A = " << std::setw(3) << theFragment->theA
191  << ", Z = " << std::setw(3) << theFragment->theZ ;
192  out.setf(std::ios::scientific,std::ios::floatfield);
193 
194  // Store user's precision setting and reset to (3) here: back-compatibility
195  std::streamsize floatPrec = out.precision();
196 
197  out << std::setprecision(3)
198  << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV
199  << " MeV IsStable= " << theFragment->IsStable();
200  if(theFragment->creatorModel >= 0) {
201  out << " creatorModelType= " << theFragment->creatorModel;
202  }
203  out << G4endl
204  << " P = ("
205  << theFragment->theMomentum.x()/CLHEP::MeV << ","
206  << theFragment->theMomentum.y()/CLHEP::MeV << ","
207  << theFragment->theMomentum.z()/CLHEP::MeV
208  << ") MeV E = "
209  << theFragment->theMomentum.t()/CLHEP::MeV << " MeV"
210  << G4endl;
211 
212  // What about Angular momentum???
213  if (theFragment->GetNumberOfExcitons() != 0) {
214  out << " "
215  << "#Particles= " << theFragment->numberOfParticles
216  << ", #Charged= " << theFragment->numberOfCharged
217  << ", #Holes= " << theFragment->numberOfHoles
218  << ", #ChargedHoles= " << theFragment->numberOfChargedHoles
219  << G4endl;
220  }
221  out.setf(old_floatfield,std::ios::floatfield);
222  out.precision(floatPrec);
223 
224  return out;
225 }
226 
227 std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
228 {
229  out << &theFragment;
230  return out;
231 }
232 
234 {
235  if (theExcitationEnergy < -10 * CLHEP::eV) {
236 
237 #ifdef G4VERBOSE
238  G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
239  G4cout << *this << G4endl;
240 #endif
241 
242 #ifdef debug_G4Fragment
244  ed << *this << G4endl;
245  G4Exception("G4Fragment::ExcitationEnergyWarning()", "had777",
246  FatalException,ed);
247 #endif
248  }
249  theExcitationEnergy = 0.0;
250 }
251 
253 {
254  G4cout << "G4Fragment::"<< value << " ERROR "
255  << G4endl;
256  G4cout << this << G4endl;
257  G4String text = "G4Fragment::G4Fragment wrong exciton number ";
258  throw G4HadronicException(__FILE__, __LINE__, text);
259 }
G4int theZ
Definition: G4Fragment.hh:180
G4double theCreationTime
Definition: G4Fragment.hh:206
static const double MeV
Definition: G4SIunits.hh:193
G4double theGroundStateMass
Definition: G4Fragment.hh:184
G4int numberOfCharged
Definition: G4Fragment.hh:195
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
CLHEP::Hep3Vector G4ThreeVector
void ExcitationEnergyWarning()
Definition: G4Fragment.cc:233
G4bool isStable(Cluster const *const c)
True if the cluster is stable.
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4ThreadLocal G4Allocator< G4Fragment > * pFragmentAllocator
Definition: G4Fragment.cc:50
G4int numberOfShellElectrons
Definition: G4Fragment.hh:202
G4GLOB_DLL std::ostream G4cout
G4bool operator==(const G4Fragment &right) const
Definition: G4Fragment.cc:170
bool G4bool
Definition: G4Types.hh:79
static G4ThreadLocal int numberOfParticles
void CalculateExcitationEnergy()
Definition: G4Fragment.hh:231
G4int theA
Definition: G4Fragment.hh:178
G4ThreeVector theAngularMomentum
Definition: G4Fragment.hh:188
static const G4double A[nN]
G4LorentzVector theMomentum
Definition: G4Fragment.hh:186
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int numberOfHoles
Definition: G4Fragment.hh:197
std::ostream & operator<<(std::ostream &out, const G4Fragment *theFragment)
Definition: G4Fragment.cc:180
static const double eV
Definition: G4SIunits.hh:194
G4int creatorModel
Definition: G4Fragment.hh:190
G4int numberOfParticles
Definition: G4Fragment.hh:193
G4bool IsStable() const
Definition: G4Fragment.hh:423
G4double GetPDGMass() const
G4int GetNumberOfExcitons() const
Definition: G4Fragment.hh:325
G4bool operator!=(const G4Fragment &right) const
Definition: G4Fragment.cc:175
#define G4endl
Definition: G4ios.hh:61
void NumberOfExitationWarning(const G4String &)
Definition: G4Fragment.cc:252
void CalculateGroundStateMass()
Definition: G4Fragment.hh:238
G4Fragment & operator=(const G4Fragment &right)
Definition: G4Fragment.cc:148
G4bool isStable
Definition: G4Fragment.hh:208
G4int numberOfChargedHoles
Definition: G4Fragment.hh:199
G4double GetExcitationEnergy() const
Definition: G4Fragment.hh:260
const G4ParticleDefinition * theParticleDefinition
Definition: G4Fragment.hh:204
G4double theExcitationEnergy
Definition: G4Fragment.hh:182
CLHEP::HepLorentzVector G4LorentzVector