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,v 1.21 2010/09/28 16:06:32 vnivanch Exp $ |
---|
27 | // GEANT4 tag $Name: geant4-09-03-ref-09 $ |
---|
28 | // |
---|
29 | //--------------------------------------------------------------------- |
---|
30 | // |
---|
31 | // Geant4 class G4Fragment |
---|
32 | // |
---|
33 | // Hadronic Process: Nuclear De-excitations |
---|
34 | // by V. Lara (May 1998) |
---|
35 | // |
---|
36 | // Modifications: |
---|
37 | // 03.05.2010 V.Ivanchenko General cleanup; moved obsolete methods from |
---|
38 | // inline to source |
---|
39 | // 25.09.2010 M. Kelsey -- Change "setprecision" to "setwidth" in printout, |
---|
40 | // add null pointer check. |
---|
41 | |
---|
42 | #include "G4Fragment.hh" |
---|
43 | #include "G4HadronicException.hh" |
---|
44 | #include "G4Gamma.hh" |
---|
45 | #include "G4Electron.hh" |
---|
46 | #include "G4ios.hh" |
---|
47 | #include <iomanip> |
---|
48 | |
---|
49 | G4int G4Fragment::errCount = 0; |
---|
50 | |
---|
51 | // Default constructor |
---|
52 | G4Fragment::G4Fragment() : |
---|
53 | theA(0), |
---|
54 | theZ(0), |
---|
55 | theExcitationEnergy(0.0), |
---|
56 | theGroundStateMass(0.0), |
---|
57 | theMomentum(G4LorentzVector(0,0,0,0)), |
---|
58 | theAngularMomentum(G4ThreeVector(0,0,0)), |
---|
59 | numberOfParticles(0), |
---|
60 | numberOfCharged(0), |
---|
61 | numberOfHoles(0), |
---|
62 | numberOfChargedHoles(0), |
---|
63 | numberOfShellElectrons(0), |
---|
64 | theParticleDefinition(0), |
---|
65 | theCreationTime(0.0) |
---|
66 | {} |
---|
67 | |
---|
68 | // Copy Constructor |
---|
69 | G4Fragment::G4Fragment(const G4Fragment &right) |
---|
70 | { |
---|
71 | theA = right.theA; |
---|
72 | theZ = right.theZ; |
---|
73 | theExcitationEnergy = right.theExcitationEnergy; |
---|
74 | theGroundStateMass = right.theGroundStateMass; |
---|
75 | theMomentum = right.theMomentum; |
---|
76 | theAngularMomentum = right.theAngularMomentum; |
---|
77 | numberOfParticles = right.numberOfParticles; |
---|
78 | numberOfCharged = right.numberOfCharged; |
---|
79 | numberOfHoles = right.numberOfHoles; |
---|
80 | numberOfChargedHoles = right.numberOfChargedHoles; |
---|
81 | numberOfShellElectrons = right.numberOfShellElectrons; |
---|
82 | theParticleDefinition = right.theParticleDefinition; |
---|
83 | theCreationTime = right.theCreationTime; |
---|
84 | } |
---|
85 | |
---|
86 | G4Fragment::~G4Fragment() |
---|
87 | {} |
---|
88 | |
---|
89 | G4Fragment::G4Fragment(G4int A, G4int Z, const G4LorentzVector& aMomentum) : |
---|
90 | theA(A), |
---|
91 | theZ(Z), |
---|
92 | theMomentum(aMomentum), |
---|
93 | theAngularMomentum(G4ThreeVector(0,0,0)), |
---|
94 | numberOfParticles(0), |
---|
95 | numberOfCharged(0), |
---|
96 | numberOfHoles(0), |
---|
97 | numberOfChargedHoles(0), |
---|
98 | numberOfShellElectrons(0), |
---|
99 | theParticleDefinition(0), |
---|
100 | theCreationTime(0.0) |
---|
101 | { |
---|
102 | theExcitationEnergy = 0.0; |
---|
103 | theGroundStateMass = 0.0; |
---|
104 | if(theA > 0) { |
---|
105 | CalculateGroundStateMass(); |
---|
106 | CalculateExcitationEnergy(); |
---|
107 | } |
---|
108 | } |
---|
109 | |
---|
110 | // This constructor is for initialize photons or electrons |
---|
111 | G4Fragment::G4Fragment(const G4LorentzVector& aMomentum, |
---|
112 | G4ParticleDefinition * aParticleDefinition) : |
---|
113 | theA(0), |
---|
114 | theZ(0), |
---|
115 | theMomentum(aMomentum), |
---|
116 | theAngularMomentum(G4ThreeVector(0,0,0)), |
---|
117 | numberOfParticles(0), |
---|
118 | numberOfCharged(0), |
---|
119 | numberOfHoles(0), |
---|
120 | numberOfChargedHoles(0), |
---|
121 | numberOfShellElectrons(0), |
---|
122 | theParticleDefinition(aParticleDefinition), |
---|
123 | theCreationTime(0.0) |
---|
124 | { |
---|
125 | theExcitationEnergy = 0.0; |
---|
126 | if(aParticleDefinition != G4Gamma::Gamma() && |
---|
127 | aParticleDefinition != G4Electron::Electron()) { |
---|
128 | G4String text = "G4Fragment::G4Fragment constructor for gamma used for " |
---|
129 | + aParticleDefinition->GetParticleName(); |
---|
130 | throw G4HadronicException(__FILE__, __LINE__, text); |
---|
131 | } |
---|
132 | theGroundStateMass = aParticleDefinition->GetPDGMass(); |
---|
133 | } |
---|
134 | |
---|
135 | const G4Fragment & G4Fragment::operator=(const G4Fragment &right) |
---|
136 | { |
---|
137 | if (this != &right) { |
---|
138 | theA = right.theA; |
---|
139 | theZ = right.theZ; |
---|
140 | theExcitationEnergy = right.theExcitationEnergy; |
---|
141 | theGroundStateMass = right.theGroundStateMass; |
---|
142 | theMomentum = right.theMomentum; |
---|
143 | theAngularMomentum = right.theAngularMomentum; |
---|
144 | numberOfParticles = right.numberOfParticles; |
---|
145 | numberOfCharged = right.numberOfCharged; |
---|
146 | numberOfHoles = right.numberOfHoles; |
---|
147 | numberOfChargedHoles = right.numberOfChargedHoles; |
---|
148 | numberOfShellElectrons = right.numberOfShellElectrons; |
---|
149 | theParticleDefinition = right.theParticleDefinition; |
---|
150 | theCreationTime = right.theCreationTime; |
---|
151 | } |
---|
152 | return *this; |
---|
153 | } |
---|
154 | |
---|
155 | G4bool G4Fragment::operator==(const G4Fragment &right) const |
---|
156 | { |
---|
157 | return (this == (G4Fragment *) &right); |
---|
158 | } |
---|
159 | |
---|
160 | G4bool G4Fragment::operator!=(const G4Fragment &right) const |
---|
161 | { |
---|
162 | return (this != (G4Fragment *) &right); |
---|
163 | } |
---|
164 | |
---|
165 | std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment) |
---|
166 | { |
---|
167 | if (!theFragment) { |
---|
168 | out << "Fragment: null pointer "; |
---|
169 | return out; |
---|
170 | } |
---|
171 | |
---|
172 | std::ios::fmtflags old_floatfield = out.flags(); |
---|
173 | out.setf(std::ios::floatfield); |
---|
174 | |
---|
175 | out << "Fragment: A = " << std::setw(3) << theFragment->theA |
---|
176 | << ", Z = " << std::setw(3) << theFragment->theZ ; |
---|
177 | out.setf(std::ios::scientific,std::ios::floatfield); |
---|
178 | |
---|
179 | // Store user's precision setting and reset to (3) here: back-compatibility |
---|
180 | std::streamsize floatPrec = out.precision(); |
---|
181 | |
---|
182 | out << std::setprecision(3) |
---|
183 | << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV |
---|
184 | << " MeV" << G4endl |
---|
185 | << " P = (" |
---|
186 | << theFragment->theMomentum.x()/CLHEP::MeV << "," |
---|
187 | << theFragment->theMomentum.y()/CLHEP::MeV << "," |
---|
188 | << theFragment->theMomentum.z()/CLHEP::MeV |
---|
189 | << ") MeV E = " |
---|
190 | << theFragment->theMomentum.t()/CLHEP::MeV << " MeV" |
---|
191 | << G4endl; |
---|
192 | |
---|
193 | // What about Angular momentum??? |
---|
194 | |
---|
195 | if (theFragment->GetNumberOfExcitons() != 0) { |
---|
196 | out << " " |
---|
197 | << "#Particles= " << theFragment->numberOfParticles |
---|
198 | << ", #Charged= " << theFragment->numberOfCharged |
---|
199 | << ", #Holes= " << theFragment->numberOfHoles |
---|
200 | << ", #ChargedHoles= " << theFragment->numberOfChargedHoles |
---|
201 | << G4endl; |
---|
202 | } |
---|
203 | out.setf(old_floatfield,std::ios::floatfield); |
---|
204 | out.precision(floatPrec); |
---|
205 | |
---|
206 | return out; |
---|
207 | } |
---|
208 | |
---|
209 | std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment) |
---|
210 | { |
---|
211 | out << &theFragment; |
---|
212 | return out; |
---|
213 | } |
---|
214 | |
---|
215 | void G4Fragment::ExcitationEnergyWarning() |
---|
216 | { |
---|
217 | if (theExcitationEnergy < -10 * CLHEP::eV) { |
---|
218 | ++errCount; |
---|
219 | if ( errCount <= 10 ) { |
---|
220 | G4cout << "G4Fragment::CalculateExcitationEnergy(): Excitation Energy = " |
---|
221 | << theExcitationEnergy/CLHEP::MeV << " MeV for A = " |
---|
222 | << theA << " and Z= " << theZ << G4endl; |
---|
223 | if( errCount == 10 ) { |
---|
224 | G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!"; |
---|
225 | throw G4HadronicException(__FILE__, __LINE__, text); |
---|
226 | } |
---|
227 | } |
---|
228 | } |
---|
229 | theExcitationEnergy = 0.0; |
---|
230 | } |
---|
231 | |
---|
232 | void G4Fragment::NumberOfExitationWarning(const G4String& value) |
---|
233 | { |
---|
234 | G4cout << "G4Fragment::"<< value << " ERROR " |
---|
235 | << G4endl; |
---|
236 | G4cout << this << G4endl; |
---|
237 | G4String text = "G4Fragment::G4Fragment wrong exciton number "; |
---|
238 | throw G4HadronicException(__FILE__, __LINE__, text); |
---|
239 | } |
---|