Geant4  10.02.p01
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 92230 2015-08-24 10:57:08Z 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 
46 //#define debug_G4Fragment
47 
50 
51 // Default constructor
53  theA(0),
54  theZ(0),
55  theExcitationEnergy(0.0),
56  theGroundStateMass(0.0),
57  theMomentum(G4LorentzVector(0,0,0,0)),
58  thePolarization(0),
59  creatorModel(-1),
61  numberOfCharged(0),
62  numberOfHoles(0),
63  numberOfChargedHoles(0),
64  numberOfShellElectrons(0),
65  theParticleDefinition(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(0),
77  creatorModel(right.creatorModel),
79  numberOfCharged(right.numberOfCharged),
80  numberOfHoles(right.numberOfHoles),
81  numberOfChargedHoles(right.numberOfChargedHoles),
82  numberOfShellElectrons(right.numberOfShellElectrons),
83  theParticleDefinition(right.theParticleDefinition),
84  theCreationTime(right.theCreationTime)
85 {
86  if(right.thePolarization) {
88  }
89 }
90 
92 {}
93 
95  theA(A),
96  theZ(Z),
97  theExcitationEnergy(0.0),
98  theGroundStateMass(0.0),
99  theMomentum(aMomentum),
100  thePolarization(0),
101  creatorModel(-1),
103  numberOfCharged(0),
104  numberOfHoles(0),
105  numberOfChargedHoles(0),
106  numberOfShellElectrons(0),
107  theParticleDefinition(0),
108  theCreationTime(0.0)
109 {
110  if(theA > 0) {
113  }
114 }
115 
116 // This constructor is for initialize photons or electrons
118  const G4ParticleDefinition * aParticleDefinition) :
119  theA(0),
120  theZ(0),
121  theExcitationEnergy(0.0),
122  theMomentum(aMomentum),
123  thePolarization(0),
124  creatorModel(-1),
126  numberOfCharged(0),
127  numberOfHoles(0),
128  numberOfChargedHoles(0),
129  numberOfShellElectrons(0),
130  theParticleDefinition(aParticleDefinition),
131  theCreationTime(0.0)
132 {
133  if(aParticleDefinition->GetPDGEncoding() != 22 &&
134  aParticleDefinition->GetPDGEncoding() != 11) {
135  G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
136  + aParticleDefinition->GetParticleName();
137  throw G4HadronicException(__FILE__, __LINE__, text);
138  }
139  theGroundStateMass = aParticleDefinition->GetPDGMass();
140 }
141 
143 {
144  if (this != &right) {
145  theA = right.theA;
146  theZ = right.theZ;
149  theMomentum = right.theMomentum;
150  delete thePolarization; thePolarization = 0;
151  if(right.thePolarization) {
153  }
154  creatorModel = right.creatorModel;
162  }
163  return *this;
164 }
165 
167 {
168  return (this == (G4Fragment *) &right);
169 }
170 
172 {
173  return (this != (G4Fragment *) &right);
174 }
175 
176 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
177 {
178  if (!theFragment) {
179  out << "Fragment: null pointer ";
180  return out;
181  }
182 
183  std::ios::fmtflags old_floatfield = out.flags();
184  out.setf(std::ios::floatfield);
185 
186  out << "Fragment: A = " << std::setw(3) << theFragment->theA
187  << ", Z = " << std::setw(3) << theFragment->theZ ;
188  out.setf(std::ios::scientific,std::ios::floatfield);
189 
190  // Store user's precision setting and reset to (3) here: back-compatibility
191  std::streamsize floatPrec = out.precision();
192 
193  out << std::setprecision(3)
194  << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV
195  << " MeV ";
196  if(theFragment->GetCreatorModelType() >= 0) {
197  out << " creatorModelType= " << theFragment->GetCreatorModelType();
198  }
199  out << G4endl
200  << " P = ("
201  << theFragment->GetMomentum().x()/CLHEP::MeV << ","
202  << theFragment->GetMomentum().y()/CLHEP::MeV << ","
203  << theFragment->GetMomentum().z()/CLHEP::MeV
204  << ") MeV E = "
205  << theFragment->GetMomentum().t()/CLHEP::MeV << " MeV"
206  << G4endl;
207 
208  if(theFragment->GetNuclearPolarization()) {
209  out << theFragment->GetNuclearPolarization();
210  }
211 
212  if (theFragment->GetNumberOfExcitons() != 0) {
213  out << " "
214  << "#Particles= " << theFragment->GetNumberOfParticles()
215  << ", #Charged= " << theFragment->GetNumberOfCharged()
216  << ", #Holes= " << theFragment->GetNumberOfHoles()
217  << ", #ChargedHoles= " << theFragment->GetNumberOfChargedHoles()
218  << G4endl;
219  }
220  out.setf(old_floatfield,std::ios::floatfield);
221  out.precision(floatPrec);
222 
223  return out;
224 }
225 
226 std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
227 {
228  out << &theFragment;
229  return out;
230 }
231 
233 {
235 
236 #ifdef G4VERBOSE
237  G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
238  G4cout << *this << G4endl;
239 #endif
240 
241 #ifdef debug_G4Fragment
243  ed << *this << G4endl;
244  G4Exception("G4Fragment::ExcitationEnergyWarning()", "had777",
245  FatalException,ed);
246 #endif
247  }
248  theExcitationEnergy = 0.0;
249 }
250 
252 {
253  G4cout << "G4Fragment::"<< value << " ERROR "
254  << G4endl;
255  G4cout << this << G4endl;
256  G4String text = "G4Fragment::G4Fragment wrong exciton number ";
257  throw G4HadronicException(__FILE__, __LINE__, text);
258 }
259 
261 {
262  std::vector< std::vector<G4complex> > pol;
263  pol.resize(1);
264  pol[0].assign(1, G4complex(v.mag(),0.0));
267 }
268 
270 {
271  G4ThreeVector v(0.0,0.0,((thePolarization->GetPolarization()[0])[0]).real());
272  return v;
273 }
G4int theZ
Definition: G4Fragment.hh:178
G4double theCreationTime
Definition: G4Fragment.hh:203
static const double MeV
Definition: G4SIunits.hh:211
G4double theGroundStateMass
Definition: G4Fragment.hh:182
G4int numberOfCharged
Definition: G4Fragment.hh:194
static int numberOfParticles
G4NuclearPolarization * thePolarization
Definition: G4Fragment.hh:187
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
CLHEP::Hep3Vector G4ThreeVector
void ExcitationEnergyWarning()
Definition: G4Fragment.cc:232
G4int GetNumberOfParticles() const
Definition: G4Fragment.hh:322
G4ThreeVector GetAngularMomentum() const
Definition: G4Fragment.cc:269
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4ThreadLocal G4Allocator< G4Fragment > * pFragmentAllocator
Definition: G4Fragment.cc:48
G4int numberOfShellElectrons
Definition: G4Fragment.hh:199
G4int GetNumberOfHoles() const
Definition: G4Fragment.hh:342
std::complex< G4double > G4complex
Definition: G4Types.hh:81
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
G4bool operator==(const G4Fragment &right) const
Definition: G4Fragment.cc:166
std::vector< std::vector< G4complex > > & GetPolarization()
bool G4bool
Definition: G4Types.hh:79
const G4LorentzVector & GetMomentum() const
Definition: G4Fragment.hh:284
void CalculateExcitationEnergy()
Definition: G4Fragment.hh:234
G4int theA
Definition: G4Fragment.hh:176
G4LorentzVector theMomentum
Definition: G4Fragment.hh:184
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int numberOfHoles
Definition: G4Fragment.hh:195
std::ostream & operator<<(std::ostream &out, const G4Fragment *theFragment)
Definition: G4Fragment.cc:176
static const double eV
Definition: G4SIunits.hh:212
G4int creatorModel
Definition: G4Fragment.hh:190
G4int numberOfParticles
Definition: G4Fragment.hh:193
G4double GetPDGMass() const
G4int GetNumberOfExcitons() const
Definition: G4Fragment.hh:317
G4bool operator!=(const G4Fragment &right) const
Definition: G4Fragment.cc:171
void SetAngularMomentum(G4ThreeVector &)
Definition: G4Fragment.cc:260
#define G4endl
Definition: G4ios.hh:61
const G4double exclimit
Definition: G4Fragment.cc:49
void NumberOfExitationWarning(const G4String &)
Definition: G4Fragment.cc:251
G4int GetNumberOfChargedHoles() const
Definition: G4Fragment.hh:347
double G4double
Definition: G4Types.hh:76
void CalculateGroundStateMass()
Definition: G4Fragment.hh:246
G4Fragment & operator=(const G4Fragment &right)
Definition: G4Fragment.cc:142
G4int GetCreatorModelType() const
Definition: G4Fragment.hh:384
G4int GetNumberOfCharged() const
Definition: G4Fragment.hh:327
G4int numberOfChargedHoles
Definition: G4Fragment.hh:196
G4double GetExcitationEnergy() const
Definition: G4Fragment.hh:268
G4NuclearPolarization * GetNuclearPolarization() const
Definition: G4Fragment.hh:415
const G4ParticleDefinition * theParticleDefinition
Definition: G4Fragment.hh:201
G4double theExcitationEnergy
Definition: G4Fragment.hh:180
CLHEP::HepLorentzVector G4LorentzVector
void SetPolarization(std::vector< std::vector< G4complex > > &p)