source: trunk/source/processes/hadronic/models/util/src/G4Fragment.cc@ 1347

Last change on this file since 1347 was 1340, checked in by garnier, 15 years ago

update ti head

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