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

Last change on this file since 819 was 819, checked in by garnier, 16 years ago

import all except CVS

File size: 7.4 KB
Line 
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//
27//
28// Hadronic Process: Nuclear De-excitations
29// by V. Lara (May 1998)
30
31#include "G4Fragment.hh"
32#include "G4HadronicException.hh"
33#include "G4HadTmpUtil.hh"
34
35
36// Default constructor
37G4Fragment::G4Fragment() :
38  theA(0),
39  theZ(0),
40  theExcitationEnergy(0.0),
41  theMomentum(0),
42  theAngularMomentum(0),
43  numberOfParticles(0),
44  numberOfHoles(0),
45  numberOfCharged(0),
46  theParticleDefinition(0),
47  theCreationTime(0.0)
48#ifdef PRECOMPOUND_TEST
49  ,theCreatorModel("No name")
50#endif
51{}
52
53// Copy Constructor
54G4Fragment::G4Fragment(const G4Fragment &right) 
55{
56   theA = right.theA;
57   theZ = right.theZ;
58   theExcitationEnergy = right.theExcitationEnergy;
59   theMomentum  = right.theMomentum;
60   theAngularMomentum = right.theAngularMomentum;
61   numberOfParticles = right.numberOfParticles;
62   numberOfHoles = right.numberOfHoles;
63   numberOfCharged = right.numberOfCharged;
64   theParticleDefinition = right.theParticleDefinition;
65   theCreationTime = right.theCreationTime;
66#ifdef PRECOMPOUND_TEST
67   theCreatorModel = right.theCreatorModel;
68#endif
69}
70
71
72G4Fragment::~G4Fragment()
73{
74}
75
76
77G4Fragment::G4Fragment(const G4int A, const G4int Z, const G4LorentzVector aMomentum) :
78  theA(A),
79  theZ(Z),
80  theMomentum(aMomentum),
81  theAngularMomentum(0),
82  numberOfParticles(0),
83  numberOfHoles(0),
84  numberOfCharged(0),
85  theParticleDefinition(0),
86  theCreationTime(0.0)
87#ifdef PRECOMPOUND_TEST
88  ,theCreatorModel("No name")
89#endif
90{
91  theExcitationEnergy = theMomentum.mag() - 
92                        G4ParticleTable::GetParticleTable()->GetIonTable()
93                        ->GetIonMass( G4lrint(theZ), G4lrint(theA) );
94  if (theExcitationEnergy < 0.0) {
95    if (theExcitationEnergy > -10.0 * eV || 0 == G4lrint(theA)) {
96      theExcitationEnergy = 0.0;
97    } else {
98      G4cout << "A, Z, momentum, theExcitationEnergy"<<
99           A<<" "<<Z<<" "<<aMomentum<<" "<<theExcitationEnergy<<G4endl;
100      G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!";
101      throw G4HadronicException(__FILE__, __LINE__, text);
102    }
103  }
104}
105
106
107// This constructor is for initialize photons
108G4Fragment::G4Fragment(const G4LorentzVector aMomentum, G4ParticleDefinition * aParticleDefinition) :
109  theA(0),
110  theZ(0),
111  theMomentum(aMomentum),
112  theAngularMomentum(0),
113  numberOfParticles(0),
114  numberOfHoles(0),
115  numberOfCharged(0),
116  theParticleDefinition(aParticleDefinition),
117  theCreationTime(0.0)
118#ifdef PRECOMPOUND_TEST
119  ,theCreatorModel("No name")
120#endif
121{
122  theExcitationEnergy = CalculateExcitationEnergy(aMomentum);
123}
124
125
126
127const G4Fragment & G4Fragment::operator=(const G4Fragment &right)
128{
129  if (this != &right) {
130    theA = right.theA;
131    theZ = right.theZ;
132    theExcitationEnergy = right.theExcitationEnergy;
133    theMomentum  = right.theMomentum;
134    theAngularMomentum = right.theAngularMomentum;
135    numberOfParticles = right.numberOfParticles;
136    numberOfHoles = right.numberOfHoles;
137    numberOfCharged = right.numberOfCharged;
138    theParticleDefinition = right.theParticleDefinition;
139    theCreationTime = right.theCreationTime;
140#ifdef PRECOMPOUND_TEST
141    theCreatorModel = right.theCreatorModel;
142#endif
143  }
144  return *this;
145}
146
147
148G4bool G4Fragment::operator==(const G4Fragment &right) const
149{
150  return (this == (G4Fragment *) &right);
151}
152
153G4bool G4Fragment::operator!=(const G4Fragment &right) const
154{
155  return (this != (G4Fragment *) &right);
156}
157
158
159std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
160{
161  std::ios::fmtflags old_floatfield = out.flags();
162  out.setf(std::ios::floatfield);
163
164  out
165    << "Fragment: A = " << std::setprecision(3) << theFragment->theA
166    << ", Z = " << std::setprecision(3) << theFragment->theZ ;
167  out.setf(std::ios::scientific,std::ios::floatfield);
168  out
169    << ", U = " << theFragment->GetExcitationEnergy()/MeV
170    << " MeV" << G4endl
171    << "          P = (" 
172    << theFragment->theMomentum.x()/MeV << ","
173    << theFragment->theMomentum.y()/MeV << ","
174    << theFragment->theMomentum.z()/MeV
175    << ") MeV   E = " 
176    << theFragment->theMomentum.t()/MeV << " MeV";
177
178  // What about Angular momentum???
179
180  if (theFragment->GetNumberOfExcitons() != 0) {
181    out << G4endl;
182    out << "          " 
183        << "#Particles = " << theFragment->numberOfParticles
184        << ", #Holes = "   << theFragment->numberOfHoles
185        << ", #Charged = " << theFragment->numberOfCharged;
186  }
187  out.setf(old_floatfield,std::ios::floatfield);
188
189  return out;
190   
191}
192
193std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
194{
195  out << &theFragment;
196  return out; 
197}
198
199
200
201G4double G4Fragment::CalculateExcitationEnergy(const G4LorentzVector value) const
202{
203  static G4int errCount(0);
204  G4double theMaxGroundStateMass = theZ*G4Proton::Proton()->GetPDGMass()+
205                               (theA-theZ)*G4Neutron::Neutron()->GetPDGMass();
206  G4double U = value.m() - std::min(theMaxGroundStateMass, GetGroundStateMass());
207  if( U < 0.0 ) {
208     if( U > -10.0 * eV || 0==G4lrint(theA)){
209        U = 0.0;
210     } else {
211        if ( errCount < 10 ) {
212            G4cerr << "G4Fragment::CalculateExcitationEnergy(): Excitation Energy ="
213               <<U << " for A = "<<theA<<" and Z= "<<theZ<<G4endl
214               << ", mass= " << GetGroundStateMass() << " maxMass= "<<theMaxGroundStateMass<<G4endl; ;
215            errCount++;
216            if (errCount == 10 ) G4cerr << "G4Fragment::CalculateExcitationEnergy():" 
217                                << " further warnings on negative excitation will be supressed" << G4endl;
218        }
219        U=0.0;
220     }
221  }
222  return U;
223}
224
225G4ThreeVector G4Fragment::IsotropicRandom3Vector(const G4double Magnitude) const
226  // Create a unit vector with a random direction isotropically distributed
227{
228
229  G4double CosTheta = 1.0 - 2.0*G4UniformRand();
230  G4double SinTheta = std::sqrt(1.0 - CosTheta*CosTheta);
231  G4double Phi = twopi*G4UniformRand();
232  G4ThreeVector Vector(Magnitude*std::cos(Phi)*SinTheta,
233                       Magnitude*std::sin(Phi)*SinTheta,
234                       Magnitude*CosTheta);
235
236  return Vector;
237               
238}
Note: See TracBrowser for help on using the repository browser.