Geant4  10.02.p02
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 97617 2016-06-06 12:47: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 "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 
96  theA(A),
97  theZ(Z),
98  theExcitationEnergy(0.0),
99  theGroundStateMass(0.0),
100  theMomentum(aMomentum),
101  thePolarization(nullptr),
102  creatorModel(-1),
104  numberOfCharged(0),
105  numberOfHoles(0),
106  numberOfChargedHoles(0),
107  numberOfShellElectrons(0),
108  theParticleDefinition(nullptr),
109  spin(0.0),
110  theCreationTime(0.0)
111 {
112  if(theA > 0) {
115  }
116 }
117 
118 // This constructor is for initialize photons or electrons
120  const G4ParticleDefinition * aParticleDefinition) :
121  theA(0),
122  theZ(0),
123  theExcitationEnergy(0.0),
124  theMomentum(aMomentum),
125  thePolarization(nullptr),
126  creatorModel(-1),
128  numberOfCharged(0),
129  numberOfHoles(0),
130  numberOfChargedHoles(0),
131  numberOfShellElectrons(0),
132  theParticleDefinition(aParticleDefinition),
133  spin(0.0),
134  theCreationTime(0.0)
135 {
136  if(aParticleDefinition->GetPDGEncoding() != 22 &&
137  aParticleDefinition->GetPDGEncoding() != 11) {
138  G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
139  + aParticleDefinition->GetParticleName();
140  throw G4HadronicException(__FILE__, __LINE__, text);
141  }
142  theGroundStateMass = aParticleDefinition->GetPDGMass();
143 }
144 
146 {
147  if (this != &right) {
148  theA = right.theA;
149  theZ = right.theZ;
152  theMomentum = right.theMomentum;
153  delete thePolarization;
154  thePolarization = nullptr;
155  if(right.thePolarization != nullptr) {
157  }
158  creatorModel = right.creatorModel;
165  spin = right.spin;
167  }
168  return *this;
169 }
170 
172 {
173  return (this == (G4Fragment *) &right);
174 }
175 
177 {
178  return (this != (G4Fragment *) &right);
179 }
180 
181 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
182 {
183  if (!theFragment) {
184  out << "Fragment: null pointer ";
185  return out;
186  }
187 
188  std::ios::fmtflags old_floatfield = out.flags();
189  out.setf(std::ios::floatfield);
190 
191  out << "Fragment: A = " << std::setw(3) << theFragment->theA
192  << ", Z = " << std::setw(3) << theFragment->theZ ;
193  out.setf(std::ios::scientific,std::ios::floatfield);
194 
195  // Store user's precision setting and reset to (3) here: back-compatibility
196  std::streamsize floatPrec = out.precision();
197 
198  out << std::setprecision(3)
199  << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV
200  << " MeV ";
201  if(theFragment->GetCreatorModelType() >= 0) {
202  out << " creatorModelType= " << theFragment->GetCreatorModelType();
203  }
204  if(theFragment->GetCreationTime() > 0.0) {
205  out << " Time= " << theFragment->GetCreationTime()/CLHEP::ns << " ns";
206  }
207  out << G4endl
208  << " P = ("
209  << theFragment->GetMomentum().x()/CLHEP::MeV << ","
210  << theFragment->GetMomentum().y()/CLHEP::MeV << ","
211  << theFragment->GetMomentum().z()/CLHEP::MeV
212  << ") MeV E = "
213  << theFragment->GetMomentum().t()/CLHEP::MeV << " MeV"
214  << G4endl;
215 
216  if(theFragment->GetNuclearPolarization()) {
217  out << theFragment->GetNuclearPolarization();
218  }
219 
220  if (theFragment->GetNumberOfExcitons() != 0) {
221  out << " "
222  << "#Particles= " << theFragment->GetNumberOfParticles()
223  << ", #Charged= " << theFragment->GetNumberOfCharged()
224  << ", #Holes= " << theFragment->GetNumberOfHoles()
225  << ", #ChargedHoles= " << theFragment->GetNumberOfChargedHoles()
226  << ", #spin= " << theFragment->GetSpin()
227  << G4endl;
228  }
229  out.setf(old_floatfield,std::ios::floatfield);
230  out.precision(floatPrec);
231 
232  return out;
233 }
234 
235 std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
236 {
237  out << &theFragment;
238  return out;
239 }
240 
242 {
243  const G4double exclimit = -10*CLHEP::eV;
244  if (theExcitationEnergy < exclimit) {
245 
246 #ifdef G4VERBOSE
247  G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
248  G4cout << *this << G4endl;
249 #endif
250 
251 #ifdef debug_G4Fragment
253  ed << *this << G4endl;
254  G4Exception("G4Fragment::ExcitationEnergyWarning()", "had777",
255  FatalException,ed);
256 #endif
257  }
258  theExcitationEnergy = 0.0;
259 }
260 
262 {
263  G4cout << "G4Fragment::"<< value << " ERROR "
264  << G4endl;
265  G4cout << this << G4endl;
266  G4String text = "G4Fragment::G4Fragment wrong exciton number ";
267  throw G4HadronicException(__FILE__, __LINE__, text);
268 }
269 
271 {
272  spin = v.mag();
273 }
274 
276 {
277  G4ThreeVector v(0.0,0.0,spin);
278  return v;
279 }
G4int theZ
Definition: G4Fragment.hh:182
G4double theCreationTime
Definition: G4Fragment.hh:208
static const double MeV
Definition: G4SIunits.hh:211
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:241
G4int GetNumberOfParticles() const
Definition: G4Fragment.hh:327
G4ThreeVector GetAngularMomentum() const
Definition: G4Fragment.cc:275
#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:171
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
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:181
static const double eV
Definition: G4SIunits.hh:212
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:176
void SetAngularMomentum(G4ThreeVector &)
Definition: G4Fragment.cc:270
#define G4endl
Definition: G4ios.hh:61
void NumberOfExitationWarning(const G4String &)
Definition: G4Fragment.cc:261
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:145
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