Changeset 1315 for trunk/source/processes/hadronic/models/util
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (14 years ago)
- Location:
- trunk/source/processes/hadronic/models/util
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/hadronic/models/util/History
r1228 r1315 15 15 --------------------------------------------------------------- 16 16 17 19 May 2010 Vladimir Ivanchenko hadr-mod-util-V09-03-01 18 - G4Fragment - minor speedup by adding member and access method 19 to GroundStateMass; 20 21 10 May 2010 Vladimir Ivanchenko hadr-mod-util-V09-03-00 22 - G4Fragment cleanup: only 1 return left in inline methods; 23 do not add any shift to excitation energy but use direct 24 computation (this is needed to avoid infinite loop in gamma 25 deexcitation); use G4NucleiProperties to access or compute 26 ground state mass; added inline method ComputeGroundStateMass; 27 added Get/Set methods for integer Z and A; added 28 ExcitationEnergyWarning method; allowed e- as a fragment 29 17 30 10 December 2009 Gunter Folger hadr-mod-util-V09-02-07 18 - G4NuclearFermiDensity.hh: ch nage value of prtection in GetDeriv() to lower31 - G4NuclearFermiDensity.hh: change value of prtection in GetDeriv() to lower 19 32 value 20 33 -
trunk/source/processes/hadronic/models/util/include/G4Fragment.hh
r819 r1315 24 24 // ******************************************************************** 25 25 // 26 // 27 // 28 // Hadronic Process: Nuclear De-excitations 26 // $Id: G4Fragment.hh,v 1.11 2010/05/19 10:23:00 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 // 29 //--------------------------------------------------------------------- 30 // 31 // Geant4 header G4Fragment 32 // 29 33 // by V. Lara (May 1998) 34 // 35 // Modifications: 36 // 03.05.2010 V.Ivanchenko General cleanup of inline functions: objects 37 // are accessed by reference; remove double return 38 // tolerance of excitation energy at modent it is computed; 39 // safe computation of excitation for exotic fragments 40 // 18.05.2010 V.Ivanchenko added member theGroundStateMass and inline 41 // method which allowing to compute this value once and use 42 // many times 30 43 31 44 #ifndef G4Fragment_h … … 38 51 #include "globals.hh" 39 52 #include "G4LorentzVector.hh" 40 #include "G4ParticleMomentum.hh"53 //#include "G4ParticleMomentum.hh" 41 54 #include "G4ThreeVector.hh" 42 55 #include "G4NucleiProperties.hh" … … 61 74 // ============= CONSTRUCTORS ================== 62 75 63 // Default constructor 76 // Default constructor - obsolete 64 77 G4Fragment(); 65 78 … … 70 83 G4Fragment(const G4Fragment &right); 71 84 72 // Several constructors 73 74 // A,Z and 4-momentum 75 G4Fragment(const G4int A, const G4int Z, const G4LorentzVector aMomentum); 85 // A,Z and 4-momentum - main constructor for fragment 86 G4Fragment(const G4int A, const G4int Z, const G4LorentzVector& aMomentum); 76 87 77 88 // 4-momentum and pointer to G4particleDefinition (for gammas) 78 G4Fragment(const G4LorentzVector aMomentum, G4ParticleDefinition * aParticleDefinition);89 G4Fragment(const G4LorentzVector& aMomentum, G4ParticleDefinition * aParticleDefinition); 79 90 80 91 // ============= OPERATORS ================== … … 89 100 // ============= METHODS ================== 90 101 91 inline G4double GetA(void) const; 92 void SetA(const G4double value); 93 94 G4double GetZ(void) const; 95 void SetZ(const G4double value); 96 97 G4double GetExcitationEnergy(void) const; 102 inline G4double GetA() const; 103 inline void SetA(const G4double value); 104 105 inline G4double GetZ() const; 106 inline void SetZ(const G4double value); 107 108 inline G4int GetZ_asInt() const; 109 inline G4int GetA_asInt() const; 110 inline void SetZandA_asInt(G4int Znew, G4int Anew); 111 112 inline G4double GetExcitationEnergy() const; 98 113 void SetExcitationEnergy(const G4double value); 99 114 100 const G4LorentzVector GetMomentum(void) const; 101 void SetMomentum(const G4LorentzVector value); 102 103 const G4ThreeVector GetAngularMomentum(void) const; 104 void SetAngularMomentum(const G4ThreeVector value); 105 106 G4int GetNumberOfExcitons(void) const; 107 // void SetNumberOfExcitons(const G4int value); 108 109 G4int GetNumberOfHoles(void) const; 110 void SetNumberOfHoles(const G4int value); 111 112 G4int GetNumberOfCharged(void) const; 115 inline const G4LorentzVector& GetMomentum() const; 116 inline void SetMomentum(const G4LorentzVector& value); 117 118 inline const G4ThreeVector& GetAngularMomentum() const; 119 inline void SetAngularMomentum(const G4ThreeVector& value); 120 121 inline G4int GetNumberOfExcitons() const; 122 123 inline G4int GetNumberOfHoles() const; 124 inline void SetNumberOfHoles(const G4int value); 125 126 inline G4int GetNumberOfCharged() const; 113 127 void SetNumberOfCharged(const G4int value); 114 128 115 G4int GetNumberOfParticles(void) const;116 void SetNumberOfParticles(const G4int value);117 118 inline G4ParticleDefinition * GetParticleDefinition( void) const;119 void SetParticleDefinition(G4ParticleDefinition * aParticleDefinition);120 121 G4double GetCreationTime(void) const;122 void SetCreationTime(const G4double time);123 124 125 // Some utility methods 126 127 inline G4double GetGroundStateMass(void) const; 128 129 inline G4double GetBindingEnergy(void) const;129 inline G4int GetNumberOfParticles() const; 130 inline void SetNumberOfParticles(const G4int value); 131 132 inline G4ParticleDefinition * GetParticleDefinition() const; 133 inline void SetParticleDefinition(G4ParticleDefinition * aParticleDefinition); 134 135 inline G4double GetCreationTime() const; 136 inline void SetCreationTime(const G4double time); 137 138 inline G4double GetGroundStateMass() const; 139 140 inline G4double GetBindingEnergy() const; 141 142 // computation of mass for any Z and A 143 inline G4double ComputeGroundStateMass(const G4int Z, const G4int A) const; 130 144 131 145 #ifdef PRECOMPOUND_TEST 132 G4String GetCreatorModel() const { return theCreatorModel; } 133 void SetCreatorModel(const G4String & aModel) 134 { theCreatorModel = aModel; } 146 G4String GetCreatorModel() const; 147 void SetCreatorModel(const G4String & aModel); 135 148 #endif 136 149 137 150 private: 138 151 139 G4double CalculateExcitationEnergy(const G4LorentzVector value) const; 152 void ExcitationEnegryWarning(); 153 154 inline void CalculateGroundStateMass(); 155 156 inline void CalculateExcitationEnergy(); 140 157 141 158 G4ThreeVector IsotropicRandom3Vector(const G4double Magnitude = 1.0) const; 142 159 143 144 160 // ============= DATA MEMBERS ================== 145 161 146 G4double theA; 147 148 G4double theZ; 162 static G4int errCount; 163 164 G4int theA; 165 166 G4int theZ; 149 167 150 168 G4double theExcitationEnergy; 151 169 170 G4double theGroundStateMass; 171 152 172 G4LorentzVector theMomentum; 153 173 … … 159 179 160 180 G4int numberOfCharged; 161 162 181 163 182 // Gamma evaporation requeriments … … 173 192 174 193 // Class G4Fragment 194 inline void G4Fragment::CalculateGroundStateMass() 195 { 196 theGroundStateMass = G4NucleiProperties::GetNuclearMass(theA, theZ); 197 } 175 198 176 199 inline G4double G4Fragment::GetA() const 177 200 { 201 return G4double(theA); 202 } 203 204 inline void G4Fragment::SetA(const G4double value) 205 { 206 theA = G4lrint(value); 207 CalculateGroundStateMass(); 208 } 209 210 inline G4double G4Fragment::GetZ() const 211 { 212 return G4double(theZ); 213 } 214 215 inline void G4Fragment::SetZ(const G4double value) 216 { 217 theZ = G4lrint(value); 218 CalculateGroundStateMass(); 219 } 220 221 inline G4int G4Fragment::GetA_asInt() const 222 { 178 223 return theA; 179 224 } 180 225 181 inline void G4Fragment::SetA(const G4double value) 182 { 183 theA = value; 184 } 185 186 inline G4double G4Fragment::GetZ() const 226 inline G4int G4Fragment::GetZ_asInt() const 187 227 { 188 228 return theZ; 189 229 } 190 230 191 inline void G4Fragment::SetZ(const G4double value) 192 { 193 theZ = value; 231 inline void G4Fragment::SetZandA_asInt(G4int Znew, G4int Anew) 232 { 233 theZ = Znew; 234 theA = Anew; 235 CalculateGroundStateMass(); 194 236 } 195 237 … … 200 242 // HPW Apr 1999 @@@@@@@ 201 243 202 if(std::abs(theExcitationEnergy)<10*eV) return 0;244 //VI if(std::abs(theExcitationEnergy)<10*eV) return 0; 203 245 return theExcitationEnergy; 204 246 } 205 247 206 inline void G4Fragment::SetExcitationEnergy(const G4double ) 207 { 208 // theExcitationEnergy = value; 209 G4cout << "Warning: G4Fragment::SetExcitationEnergy() is a dummy method. Please, avoid to use it." << G4endl; 210 } 211 212 inline const G4LorentzVector G4Fragment::GetMomentum() const 248 inline const G4LorentzVector& G4Fragment::GetMomentum() const 213 249 { 214 250 return theMomentum; 215 251 } 216 252 217 inline void G4Fragment::SetMomentum(const G4LorentzVector value) 218 { 219 theMomentum = value; 220 theExcitationEnergy = CalculateExcitationEnergy(value); 221 } 222 223 inline const G4ThreeVector G4Fragment::GetAngularMomentum() const 253 inline const G4ThreeVector& G4Fragment::GetAngularMomentum() const 224 254 { 225 255 return theAngularMomentum; 226 256 } 227 257 228 inline void G4Fragment::SetAngularMomentum(const G4ThreeVector value)258 inline void G4Fragment::SetAngularMomentum(const G4ThreeVector& value) 229 259 { 230 260 theAngularMomentum = value; … … 258 288 inline void G4Fragment::SetNumberOfCharged(const G4int value) 259 289 { 260 if (value <= numberOfParticles) numberOfCharged = value;290 if (value <= numberOfParticles) { numberOfCharged = value; } 261 291 else 262 292 { 263 G4String text = "G4Fragment::SetNumberOfCharged: Number of charged particles can't be greater than number of particles";264 293 G4String text = "G4Fragment::SetNumberOfCharged: Number of charged particles can't be greater than number of particles"; 294 throw G4HadronicException(__FILE__, __LINE__, text); 265 295 } 266 296 } … … 271 301 } 272 302 273 274 303 inline G4ParticleDefinition * G4Fragment::GetParticleDefinition(void) const 275 304 { … … 282 311 } 283 312 284 285 inline G4double G4Fragment::GetCreationTime(void) const 313 inline G4double G4Fragment::GetCreationTime() const 286 314 { 287 315 return theCreationTime; … … 293 321 } 294 322 295 inline G4double G4Fragment::GetGroundStateMass(void) const 296 { 297 if (theA == 0) return 0.0; // photon 298 else return G4ParticleTable::GetParticleTable()-> 299 GetIonTable()->GetIonMass(G4lrint(theZ),G4lrint(theA)); 323 inline G4double G4Fragment::GetGroundStateMass() const 324 { 325 return theGroundStateMass; 326 } 327 328 inline G4double 329 G4Fragment::ComputeGroundStateMass(const G4int Z, const G4int A) const 330 { 331 return G4NucleiProperties::GetNuclearMass(A, Z); 332 } 333 334 inline void G4Fragment::CalculateExcitationEnergy() 335 { 336 theExcitationEnergy = theMomentum.mag() - theGroundStateMass; 337 if(theExcitationEnergy < 0.0) { ExcitationEnegryWarning(); } 300 338 } 301 339 302 inline G4double G4Fragment::GetBindingEnergy(void) const 303 { 304 return -GetGroundStateMass()+(theA-theZ)*G4Neutron::Neutron()->GetPDGMass() 305 + theZ*G4Proton::Proton()->GetPDGMass(); 306 } 307 340 inline G4double G4Fragment::GetBindingEnergy() const 341 { 342 return (theA-theZ)*CLHEP::neutron_mass_c2 + theZ*CLHEP::proton_mass_c2 343 - theGroundStateMass; 344 } 345 346 inline void G4Fragment::SetMomentum(const G4LorentzVector& value) 347 { 348 theMomentum = value; 349 CalculateExcitationEnergy(); 350 } 308 351 309 352 #endif -
trunk/source/processes/hadronic/models/util/src/G4Fragment.cc
r819 r1315 24 24 // ******************************************************************** 25 25 // 26 // 26 // $Id: G4Fragment.cc,v 1.16 2010/05/18 18:52:07 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 // 29 //--------------------------------------------------------------------- 30 // 31 // Geant4 class G4Fragment 27 32 // 28 33 // Hadronic Process: Nuclear De-excitations 29 34 // by V. Lara (May 1998) 35 // 36 // Modifications: 37 // 03.05.2010 V.Ivanchenko General cleanup; moved obsolete methods from 38 // inline to source 39 // 30 40 31 41 #include "G4Fragment.hh" 32 42 #include "G4HadronicException.hh" 33 43 #include "G4HadTmpUtil.hh" 34 44 #include "G4Gamma.hh" 45 #include "G4Electron.hh" 46 47 G4int G4Fragment::errCount = 0; 35 48 36 49 // Default constructor … … 39 52 theZ(0), 40 53 theExcitationEnergy(0.0), 54 theGroundStateMass(0.0), 41 55 theMomentum(0), 42 56 theAngularMomentum(0), … … 57 71 theZ = right.theZ; 58 72 theExcitationEnergy = right.theExcitationEnergy; 73 theGroundStateMass = right.theGroundStateMass; 59 74 theMomentum = right.theMomentum; 60 75 theAngularMomentum = right.theAngularMomentum; … … 69 84 } 70 85 71 72 86 G4Fragment::~G4Fragment() 73 { 74 } 75 76 77 G4Fragment::G4Fragment(const G4int A, const G4int Z, const G4LorentzVector aMomentum) : 87 {} 88 89 G4Fragment::G4Fragment(const G4int A, const G4int Z, const G4LorentzVector& aMomentum) : 78 90 theA(A), 79 91 theZ(Z), … … 89 101 #endif 90 102 { 103 theExcitationEnergy = 0.0; 104 theGroundStateMass = 0.0; 105 if(theA > 0) { 106 CalculateGroundStateMass(); 107 CalculateExcitationEnergy(); 108 } 109 /* 91 110 theExcitationEnergy = theMomentum.mag() - 92 111 G4ParticleTable::GetParticleTable()->GetIonTable() … … 102 121 } 103 122 } 104 } 105 106 107 // This constructor is for initialize photons 108 G4Fragment::G4Fragment(const G4LorentzVector aMomentum, G4ParticleDefinition * aParticleDefinition) : 123 */ 124 } 125 126 127 // This constructor is for initialize photons or electrons 128 G4Fragment::G4Fragment(const G4LorentzVector& aMomentum, 129 G4ParticleDefinition * aParticleDefinition) : 109 130 theA(0), 110 131 theZ(0), … … 120 141 #endif 121 142 { 122 theExcitationEnergy = CalculateExcitationEnergy(aMomentum); 123 } 124 125 143 theExcitationEnergy = 0.0; 144 if(aParticleDefinition != G4Gamma::Gamma() && 145 aParticleDefinition != G4Electron::Electron()) { 146 G4String text = "G4Fragment::G4Fragment constructor for gamma used for " 147 + aParticleDefinition->GetParticleName(); 148 throw G4HadronicException(__FILE__, __LINE__, text); 149 } 150 theGroundStateMass = aParticleDefinition->GetPDGMass(); 151 } 126 152 127 153 const G4Fragment & G4Fragment::operator=(const G4Fragment &right) … … 131 157 theZ = right.theZ; 132 158 theExcitationEnergy = right.theExcitationEnergy; 159 theGroundStateMass = right.theGroundStateMass; 133 160 theMomentum = right.theMomentum; 134 161 theAngularMomentum = right.theAngularMomentum; … … 145 172 } 146 173 147 148 174 G4bool G4Fragment::operator==(const G4Fragment &right) const 149 175 { … … 155 181 return (this != (G4Fragment *) &right); 156 182 } 157 158 183 159 184 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment) … … 197 222 } 198 223 199 200 201 G4double 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; 224 void G4Fragment::ExcitationEnegryWarning() 225 { 226 if (theExcitationEnergy < -10.0 * eV) { 227 ++errCount; 228 if ( errCount <= 10 ) { 229 G4cout << "G4Fragment::CalculateExcitationEnergy(): Excitation Energy = " 230 << theExcitationEnergy/MeV << " MeV for A = " 231 <<theA << " and Z= " << theZ << G4endl; 232 if( errCount == 10 ) { 233 G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!"; 234 throw G4HadronicException(__FILE__, __LINE__, text); 235 } 236 } 237 } 238 theExcitationEnergy = 0.0; 223 239 } 224 240 … … 226 242 // Create a unit vector with a random direction isotropically distributed 227 243 { 228 229 244 G4double CosTheta = 1.0 - 2.0*G4UniformRand(); 230 245 G4double SinTheta = std::sqrt(1.0 - CosTheta*CosTheta); … … 234 249 Magnitude*CosTheta); 235 250 236 return Vector; 237 238 } 251 return Vector; 252 } 253 254 void G4Fragment::SetExcitationEnergy(const G4double ) 255 { 256 // theExcitationEnergy = value; 257 G4cout << "Warning: G4Fragment::SetExcitationEnergy() is a dummy method. Please, avoid to use it." << G4endl; 258 } 259 260 #ifdef PRECOMPOUND_TEST 261 G4String G4Fragment::GetCreatorModel() const 262 { 263 return theCreatorModel; 264 } 265 266 void G4Fragment::SetCreatorModel(const G4String & aModel) 267 { 268 theCreatorModel = aModel; 269 } 270 #endif
Note: See TracChangeset
for help on using the changeset viewer.