Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 102724 2017-02-20 13:00:39Z 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 
47 const G4double G4Fragment::minFragExcitation = 10.*CLHEP::eV;
48 
49 // Default constructor
51  theA(0),
52  theZ(0),
53  theExcitationEnergy(0.0),
54  theGroundStateMass(0.0),
55  theMomentum(G4LorentzVector(0,0,0,0)),
56  thePolarization(nullptr),
57  creatorModel(-1),
59  numberOfCharged(0),
60  numberOfHoles(0),
61  numberOfChargedHoles(0),
62  numberOfShellElectrons(0),
63  xLevel(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  xLevel(right.xLevel),
84  theParticleDefinition(right.theParticleDefinition),
85  spin(right.spin),
86  theCreationTime(right.theCreationTime)
87 {
88  if(right.thePolarization != nullptr) {
89  thePolarization = new G4NuclearPolarization(*(right.thePolarization));
90  }
91 }
92 
94 {
95  delete thePolarization;
96  thePolarization = nullptr;
97 }
98 
100  theA(A),
101  theZ(Z),
102  theExcitationEnergy(0.0),
103  theGroundStateMass(0.0),
104  theMomentum(aMomentum),
105  thePolarization(nullptr),
106  creatorModel(-1),
108  numberOfCharged(0),
109  numberOfHoles(0),
110  numberOfChargedHoles(0),
111  numberOfShellElectrons(0),
112  xLevel(0),
113  theParticleDefinition(nullptr),
114  spin(0.0),
115  theCreationTime(0.0)
116 {
117  if(theA > 0) {
118  CalculateGroundStateMass();
119  CalculateExcitationEnergy();
120  }
121 }
122 
123 // This constructor is for initialize photons or electrons
125  const G4ParticleDefinition * aParticleDefinition) :
126  theA(0),
127  theZ(0),
128  theExcitationEnergy(0.0),
129  theMomentum(aMomentum),
130  thePolarization(nullptr),
131  creatorModel(-1),
133  numberOfCharged(0),
134  numberOfHoles(0),
135  numberOfChargedHoles(0),
136  numberOfShellElectrons(0),
137  xLevel(0),
138  theParticleDefinition(aParticleDefinition),
139  spin(0.0),
140  theCreationTime(0.0)
141 {
142  if(aParticleDefinition->GetPDGEncoding() != 22 &&
143  aParticleDefinition->GetPDGEncoding() != 11) {
144  G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
145  + aParticleDefinition->GetParticleName();
146  throw G4HadronicException(__FILE__, __LINE__, text);
147  }
148  theGroundStateMass = aParticleDefinition->GetPDGMass();
149 }
150 
152 {
153  if (this != &right) {
154  theA = right.theA;
155  theZ = right.theZ;
156  theExcitationEnergy = right.theExcitationEnergy;
157  theGroundStateMass = right.theGroundStateMass;
158  theMomentum = right.theMomentum;
159  delete thePolarization;
160  thePolarization = nullptr;
161  if(right.thePolarization != nullptr) {
162  thePolarization = new G4NuclearPolarization(*(right.thePolarization));
163  }
164  creatorModel = right.creatorModel;
165  numberOfParticles = right.numberOfParticles;
166  numberOfCharged = right.numberOfCharged;
167  numberOfHoles = right.numberOfHoles;
168  numberOfChargedHoles = right.numberOfChargedHoles;
169  numberOfShellElectrons = right.numberOfShellElectrons;
170  xLevel = right.xLevel;
171  theParticleDefinition = right.theParticleDefinition;
172  spin = right.spin;
173  theCreationTime = right.theCreationTime;
174  }
175  return *this;
176 }
177 
179 {
180  return (this == (G4Fragment *) &right);
181 }
182 
184 {
185  return (this != (G4Fragment *) &right);
186 }
187 
188 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
189 {
190  if (!theFragment) {
191  out << "Fragment: null pointer ";
192  return out;
193  }
194 
195  std::ios::fmtflags old_floatfield = out.flags();
196  out.setf(std::ios::floatfield);
197 
198  out << "Fragment: A = " << std::setw(3) << theFragment->theA
199  << ", Z = " << std::setw(3) << theFragment->theZ ;
200  out.setf(std::ios::scientific,std::ios::floatfield);
201 
202  // Store user's precision setting and reset to (3) here: back-compatibility
203  std::streamsize floatPrec = out.precision();
204 
205  out << std::setprecision(3)
206  << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV
207  << " MeV ";
208  if(theFragment->GetCreatorModelType() >= 0) {
209  out << " creatorModelType= " << theFragment->GetCreatorModelType();
210  }
211  if(theFragment->GetCreationTime() > 0.0) {
212  out << " Time= " << theFragment->GetCreationTime()/CLHEP::ns << " ns";
213  }
214  out << G4endl
215  << " P = ("
216  << theFragment->GetMomentum().x()/CLHEP::MeV << ","
217  << theFragment->GetMomentum().y()/CLHEP::MeV << ","
218  << theFragment->GetMomentum().z()/CLHEP::MeV
219  << ") MeV E = "
220  << theFragment->GetMomentum().t()/CLHEP::MeV << " MeV"
221  << G4endl;
222 
223  out << " #spin= " << theFragment->GetSpin()
224  << " #floatLevelNo= " << theFragment->GetFloatingLevelNumber();
225 
226  if(theFragment->GetNuclearPolarization()) {
227  out << theFragment->GetNuclearPolarization();
228  }
229 
230  if (theFragment->GetNumberOfExcitons() != 0) {
231  out << " "
232  << "#Particles= " << theFragment->GetNumberOfParticles()
233  << ", #Charged= " << theFragment->GetNumberOfCharged()
234  << ", #Holes= " << theFragment->GetNumberOfHoles()
235  << ", #ChargedHoles= " << theFragment->GetNumberOfChargedHoles();
236  }
237  out << G4endl;
238  out.setf(old_floatfield,std::ios::floatfield);
239  out.precision(floatPrec);
240 
241  return out;
242 }
243 
244 std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
245 {
246  out << &theFragment;
247  return out;
248 }
249 
250 void G4Fragment::ExcitationEnergyWarning()
251 {
252 #ifdef G4VERBOSE
253  G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
254  G4cout << *this << G4endl;
255 #endif
256 }
257 
258 void G4Fragment::NumberOfExitationWarning(const G4String& value)
259 {
260  G4cout << "G4Fragment::"<< value << " ERROR "
261  << G4endl;
262  G4cout << this << G4endl;
263  G4String text = "G4Fragment::G4Fragment wrong exciton number ";
264  throw G4HadronicException(__FILE__, __LINE__, text);
265 }
266 
268 {
269  spin = v.mag();
270 }
271 
273 {
274  G4ThreeVector v(0.0,0.0,spin);
275  return v;
276 }
G4int GetFloatingLevelNumber() const
Definition: G4Fragment.hh:427
static int numberOfParticles
static constexpr double ns
G4int GetNumberOfParticles() const
Definition: G4Fragment.hh:345
G4ThreeVector GetAngularMomentum() const
Definition: G4Fragment.cc:272
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4int GetNumberOfHoles() const
Definition: G4Fragment.hh:365
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
G4bool operator==(const G4Fragment &right) const
Definition: G4Fragment.cc:178
const XML_Char int const XML_Char * value
Definition: expat.h:331
G4double GetCreationTime() const
Definition: G4Fragment.hh:448
G4DLLIMPORT G4ThreadLocal G4Allocator< G4Fragment > * pFragmentAllocator
Definition: G4Fragment.cc:46
bool G4bool
Definition: G4Types.hh:79
const G4LorentzVector & GetMomentum() const
Definition: G4Fragment.hh:307
static constexpr double MeV
static constexpr double eV
G4double GetSpin() const
Definition: G4Fragment.hh:417
G4double GetPDGMass() const
G4int GetNumberOfExcitons() const
Definition: G4Fragment.hh:340
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
G4bool operator!=(const G4Fragment &right) const
Definition: G4Fragment.cc:183
#define G4endl
Definition: G4ios.hh:61
G4int GetNumberOfChargedHoles() const
Definition: G4Fragment.hh:370
void SetAngularMomentum(const G4ThreeVector &)
Definition: G4Fragment.cc:267
double G4double
Definition: G4Types.hh:76
double mag() const
G4Fragment & operator=(const G4Fragment &right)
Definition: G4Fragment.cc:151
G4int GetCreatorModelType() const
Definition: G4Fragment.hh:407
G4int GetNumberOfCharged() const
Definition: G4Fragment.hh:350
G4double GetExcitationEnergy() const
Definition: G4Fragment.hh:283
G4NuclearPolarization * GetNuclearPolarization() const
Definition: G4Fragment.hh:458