Geant4  10.03
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 97799 2016-06-13 12:13:11Z 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 "G4ios.hh"
44 #include <iomanip>
45 
46 //#define debug_G4Fragment
47 
49 
50 // Default constructor
52  theA(0),
53  theZ(0),
54  theExcitationEnergy(0.0),
55  theGroundStateMass(0.0),
56  theMomentum(G4LorentzVector(0,0,0,0)),
57  thePolarization(nullptr),
58  creatorModel(-1),
60  numberOfCharged(0),
61  numberOfHoles(0),
62  numberOfChargedHoles(0),
63  numberOfShellElectrons(0),
64  theParticleDefinition(nullptr),
65  spin(0.0),
66  theCreationTime(0.0)
67 {}
68 
69 // Copy Constructor
71  theA(right.theA),
72  theZ(right.theZ),
73  theExcitationEnergy(right.theExcitationEnergy),
74  theGroundStateMass(right.theGroundStateMass),
75  theMomentum(right.theMomentum),
76  thePolarization(nullptr),
77  creatorModel(right.creatorModel),
79  numberOfCharged(right.numberOfCharged),
80  numberOfHoles(right.numberOfHoles),
81  numberOfChargedHoles(right.numberOfChargedHoles),
82  numberOfShellElectrons(right.numberOfShellElectrons),
83  theParticleDefinition(right.theParticleDefinition),
84  spin(right.spin),
85  theCreationTime(right.theCreationTime)
86 {
87  if(right.thePolarization != nullptr) {
89  }
90 }
91 
93 {
94  delete thePolarization;
95 }
96 
98  theA(A),
99  theZ(Z),
100  theExcitationEnergy(0.0),
101  theGroundStateMass(0.0),
102  theMomentum(aMomentum),
103  thePolarization(nullptr),
104  creatorModel(-1),
106  numberOfCharged(0),
107  numberOfHoles(0),
108  numberOfChargedHoles(0),
109  numberOfShellElectrons(0),
110  theParticleDefinition(nullptr),
111  spin(0.0),
112  theCreationTime(0.0)
113 {
114  if(theA > 0) {
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),
130  numberOfCharged(0),
131  numberOfHoles(0),
132  numberOfChargedHoles(0),
133  numberOfShellElectrons(0),
134  theParticleDefinition(aParticleDefinition),
135  spin(0.0),
136  theCreationTime(0.0)
137 {
138  if(aParticleDefinition->GetPDGEncoding() != 22 &&
139  aParticleDefinition->GetPDGEncoding() != 11) {
140  G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
141  + aParticleDefinition->GetParticleName();
142  throw G4HadronicException(__FILE__, __LINE__, text);
143  }
144  theGroundStateMass = aParticleDefinition->GetPDGMass();
145 }
146 
148 {
149  if (this != &right) {
150  theA = right.theA;
151  theZ = right.theZ;
154  theMomentum = right.theMomentum;
155  delete thePolarization;
156  thePolarization = nullptr;
157  if(right.thePolarization != nullptr) {
159  }
160  creatorModel = right.creatorModel;
167  spin = right.spin;
169  }
170  return *this;
171 }
172 
174 {
175  return (this == (G4Fragment *) &right);
176 }
177 
179 {
180  return (this != (G4Fragment *) &right);
181 }
182 
183 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
184 {
185  if (!theFragment) {
186  out << "Fragment: null pointer ";
187  return out;
188  }
189 
190  std::ios::fmtflags old_floatfield = out.flags();
191  out.setf(std::ios::floatfield);
192 
193  out << "Fragment: A = " << std::setw(3) << theFragment->theA
194  << ", Z = " << std::setw(3) << theFragment->theZ ;
195  out.setf(std::ios::scientific,std::ios::floatfield);
196 
197  // Store user's precision setting and reset to (3) here: back-compatibility
198  std::streamsize floatPrec = out.precision();
199 
200  out << std::setprecision(3)
201  << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV
202  << " MeV ";
203  if(theFragment->GetCreatorModelType() >= 0) {
204  out << " creatorModelType= " << theFragment->GetCreatorModelType();
205  }
206  if(theFragment->GetCreationTime() > 0.0) {
207  out << " Time= " << theFragment->GetCreationTime()/CLHEP::ns << " ns";
208  }
209  out << G4endl
210  << " P = ("
211  << theFragment->GetMomentum().x()/CLHEP::MeV << ","
212  << theFragment->GetMomentum().y()/CLHEP::MeV << ","
213  << theFragment->GetMomentum().z()/CLHEP::MeV
214  << ") MeV E = "
215  << theFragment->GetMomentum().t()/CLHEP::MeV << " MeV"
216  << G4endl;
217 
218  if(theFragment->GetNuclearPolarization()) {
219  out << theFragment->GetNuclearPolarization();
220  }
221 
222  if (theFragment->GetNumberOfExcitons() != 0) {
223  out << " "
224  << "#Particles= " << theFragment->GetNumberOfParticles()
225  << ", #Charged= " << theFragment->GetNumberOfCharged()
226  << ", #Holes= " << theFragment->GetNumberOfHoles()
227  << ", #ChargedHoles= " << theFragment->GetNumberOfChargedHoles()
228  << ", #spin= " << theFragment->GetSpin()
229  << G4endl;
230  }
231  out.setf(old_floatfield,std::ios::floatfield);
232  out.precision(floatPrec);
233 
234  return out;
235 }
236 
237 std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
238 {
239  out << &theFragment;
240  return out;
241 }
242 
244 {
245  const G4double exclimit = -10*CLHEP::eV;
246  if (theExcitationEnergy < exclimit) {
247 
248 #ifdef G4VERBOSE
249  G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
250  G4cout << *this << G4endl;
251 #endif
252 
253 #ifdef debug_G4Fragment
255  ed << *this << G4endl;
256  G4Exception("G4Fragment::ExcitationEnergyWarning()", "had777",
257  FatalException,ed);
258 #endif
259  }
260  theExcitationEnergy = 0.0;
261 }
262 
264 {
265  G4cout << "G4Fragment::"<< value << " ERROR "
266  << G4endl;
267  G4cout << this << G4endl;
268  G4String text = "G4Fragment::G4Fragment wrong exciton number ";
269  throw G4HadronicException(__FILE__, __LINE__, text);
270 }
271 
273 {
274  spin = v.mag();
275 }
276 
278 {
279  G4ThreeVector v(0.0,0.0,spin);
280  return v;
281 }
G4int theZ
Definition: G4Fragment.hh:182
G4double theCreationTime
Definition: G4Fragment.hh:208
G4double theGroundStateMass
Definition: G4Fragment.hh:186
G4int numberOfCharged
Definition: G4Fragment.hh:198
static int numberOfParticles
G4NuclearPolarization * thePolarization
Definition: G4Fragment.hh:191
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
CLHEP::Hep3Vector G4ThreeVector
void ExcitationEnergyWarning()
Definition: G4Fragment.cc:243
G4int GetNumberOfParticles() const
Definition: G4Fragment.hh:327
G4ThreeVector GetAngularMomentum() const
Definition: G4Fragment.cc:277
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4ThreadLocal G4Allocator< G4Fragment > * pFragmentAllocator
Definition: G4Fragment.cc:48
G4int numberOfShellElectrons
Definition: G4Fragment.hh:203
G4int GetNumberOfHoles() const
Definition: G4Fragment.hh:347
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
G4bool operator==(const G4Fragment &right) const
Definition: G4Fragment.cc:173
G4double GetCreationTime() const
Definition: G4Fragment.hh:420
bool G4bool
Definition: G4Types.hh:79
const G4LorentzVector & GetMomentum() const
Definition: G4Fragment.hh:289
G4double spin
Definition: G4Fragment.hh:207
static constexpr double eV
Definition: G4SIunits.hh:215
void CalculateExcitationEnergy()
Definition: G4Fragment.hh:239
G4int theA
Definition: G4Fragment.hh:180
G4LorentzVector theMomentum
Definition: G4Fragment.hh:188
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4double GetSpin() const
Definition: G4Fragment.hh:399
G4int numberOfHoles
Definition: G4Fragment.hh:199
std::ostream & operator<<(std::ostream &out, const G4Fragment *theFragment)
Definition: G4Fragment.cc:183
G4int creatorModel
Definition: G4Fragment.hh:194
G4int numberOfParticles
Definition: G4Fragment.hh:197
G4double GetPDGMass() const
G4int GetNumberOfExcitons() const
Definition: G4Fragment.hh:322
G4bool operator!=(const G4Fragment &right) const
Definition: G4Fragment.cc:178
void SetAngularMomentum(G4ThreeVector &)
Definition: G4Fragment.cc:272
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
void NumberOfExitationWarning(const G4String &)
Definition: G4Fragment.cc:263
G4int GetNumberOfChargedHoles() const
Definition: G4Fragment.hh:352
double G4double
Definition: G4Types.hh:76
void CalculateGroundStateMass()
Definition: G4Fragment.hh:251
G4Fragment & operator=(const G4Fragment &right)
Definition: G4Fragment.cc:147
G4int GetCreatorModelType() const
Definition: G4Fragment.hh:389
#define ns
Definition: xmlparse.cc:614
G4int GetNumberOfCharged() const
Definition: G4Fragment.hh:332
G4int numberOfChargedHoles
Definition: G4Fragment.hh:200
G4double GetExcitationEnergy() const
Definition: G4Fragment.hh:273
G4NuclearPolarization * GetNuclearPolarization() const
Definition: G4Fragment.hh:430
const G4ParticleDefinition * theParticleDefinition
Definition: G4Fragment.hh:205
G4double theExcitationEnergy
Definition: G4Fragment.hh:184
CLHEP::HepLorentzVector G4LorentzVector