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