Changeset 1340 for trunk/source/processes/hadronic/models/util/src
- Timestamp:
- Nov 5, 2010, 3:45:55 PM (14 years ago)
- Location:
- trunk/source/processes/hadronic/models/util/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/hadronic/models/util/src/G4Fancy3DNucleus.cc
r1196 r1340 61 61 } 62 62 63 63 #if defined(NON_INTEGER_A_Z) 64 64 void G4Fancy3DNucleus::Init(G4double theA, G4double theZ) 65 { 66 G4int intZ = G4int(theZ); 67 G4int intA= ( G4UniformRand()>theA-G4int(theA) ) ? G4int(theA) : G4int(theA)+1; 68 // forward to integer Init() 69 Init(intA, intZ); 70 71 } 72 #endif 73 74 void G4Fancy3DNucleus::Init(G4int theA, G4int theZ) 65 75 { 66 76 // G4cout << "G4Fancy3DNucleus::Init(theA, theZ) called"<<G4endl; … … 70 80 theRWNucleons.clear(); 71 81 72 myZ = G4int(theZ);73 myA= ( G4UniformRand()>theA-G4int(theA) ) ? G4int(theA) : G4int(theA)+1;82 myZ = theZ; 83 myA= theA; 74 84 75 85 theNucleons = new G4Nucleon[myA]; … … 144 154 if (theRWNucleons.size() < 2 ) return; 145 155 146 s ort( theRWNucleons.begin(),theRWNucleons.end(),G4Fancy3DNucleusHelperForSortInZ);156 std::sort( theRWNucleons.begin(),theRWNucleons.end(),G4Fancy3DNucleusHelperForSortInZ); 147 157 148 158 // now copy sorted nucleons to theNucleons array. TheRWNucleons are pointers in theNucleons … … 169 179 170 180 if (theRWNucleons.size() < 2 ) return; 171 s ort( theRWNucleons.begin(),theRWNucleons.end(),G4Fancy3DNucleusHelperForSortInZ);181 std::sort( theRWNucleons.begin(),theRWNucleons.end(),G4Fancy3DNucleusHelperForSortInZ); 172 182 173 183 // now copy sorted nucleons to theNucleons array. TheRWNucleons are pointers in theNucleons -
trunk/source/processes/hadronic/models/util/src/G4Fragment.cc
r1337 r1340 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4Fragment.cc,v 1. 16 2010/05/18 18:52:07vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 4-beta-01$26 // $Id: G4Fragment.cc,v 1.21 2010/09/28 16:06:32 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-03-ref-09 $ 28 28 // 29 29 //--------------------------------------------------------------------- … … 37 37 // 03.05.2010 V.Ivanchenko General cleanup; moved obsolete methods from 38 38 // inline to source 39 // 39 // 25.09.2010 M. Kelsey -- Change "setprecision" to "setwidth" in printout, 40 // add null pointer check. 40 41 41 42 #include "G4Fragment.hh" 42 43 #include "G4HadronicException.hh" 43 #include "G4HadTmpUtil.hh"44 44 #include "G4Gamma.hh" 45 45 #include "G4Electron.hh" 46 #include "G4ios.hh" 47 #include <iomanip> 46 48 47 49 G4int G4Fragment::errCount = 0; … … 53 55 theExcitationEnergy(0.0), 54 56 theGroundStateMass(0.0), 55 theMomentum( 0),56 theAngularMomentum( 0),57 theMomentum(G4LorentzVector(0,0,0,0)), 58 theAngularMomentum(G4ThreeVector(0,0,0)), 57 59 numberOfParticles(0), 60 numberOfCharged(0), 58 61 numberOfHoles(0), 59 numberOfCharged(0), 62 numberOfChargedHoles(0), 63 numberOfShellElectrons(0), 60 64 theParticleDefinition(0), 61 65 theCreationTime(0.0) 62 #ifdef PRECOMPOUND_TEST63 ,theCreatorModel("No name")64 #endif65 66 {} 66 67 … … 75 76 theAngularMomentum = right.theAngularMomentum; 76 77 numberOfParticles = right.numberOfParticles; 78 numberOfCharged = right.numberOfCharged; 77 79 numberOfHoles = right.numberOfHoles; 78 numberOfCharged = right.numberOfCharged; 80 numberOfChargedHoles = right.numberOfChargedHoles; 81 numberOfShellElectrons = right.numberOfShellElectrons; 79 82 theParticleDefinition = right.theParticleDefinition; 80 83 theCreationTime = right.theCreationTime; 81 #ifdef PRECOMPOUND_TEST82 theCreatorModel = right.theCreatorModel;83 #endif84 84 } 85 85 … … 87 87 {} 88 88 89 G4Fragment::G4Fragment( const G4int A, constG4int Z, const G4LorentzVector& aMomentum) :89 G4Fragment::G4Fragment(G4int A, G4int Z, const G4LorentzVector& aMomentum) : 90 90 theA(A), 91 91 theZ(Z), 92 92 theMomentum(aMomentum), 93 theAngularMomentum( 0),93 theAngularMomentum(G4ThreeVector(0,0,0)), 94 94 numberOfParticles(0), 95 numberOfCharged(0), 95 96 numberOfHoles(0), 96 numberOfCharged(0), 97 numberOfChargedHoles(0), 98 numberOfShellElectrons(0), 97 99 theParticleDefinition(0), 98 100 theCreationTime(0.0) 99 #ifdef PRECOMPOUND_TEST100 ,theCreatorModel("No name")101 #endif102 101 { 103 102 theExcitationEnergy = 0.0; … … 107 106 CalculateExcitationEnergy(); 108 107 } 109 /* 110 theExcitationEnergy = theMomentum.mag() - 111 G4ParticleTable::GetParticleTable()->GetIonTable() 112 ->GetIonMass( G4lrint(theZ), G4lrint(theA) ); 113 if (theExcitationEnergy < 0.0) { 114 if (theExcitationEnergy > -10.0 * eV || 0 == G4lrint(theA)) { 115 theExcitationEnergy = 0.0; 116 } else { 117 G4cout << "A, Z, momentum, theExcitationEnergy"<< 118 A<<" "<<Z<<" "<<aMomentum<<" "<<theExcitationEnergy<<G4endl; 119 G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!"; 120 throw G4HadronicException(__FILE__, __LINE__, text); 121 } 122 } 123 */ 124 } 125 108 } 126 109 127 110 // This constructor is for initialize photons or electrons … … 131 114 theZ(0), 132 115 theMomentum(aMomentum), 133 theAngularMomentum( 0),116 theAngularMomentum(G4ThreeVector(0,0,0)), 134 117 numberOfParticles(0), 118 numberOfCharged(0), 135 119 numberOfHoles(0), 136 numberOfCharged(0), 120 numberOfChargedHoles(0), 121 numberOfShellElectrons(0), 137 122 theParticleDefinition(aParticleDefinition), 138 123 theCreationTime(0.0) 139 #ifdef PRECOMPOUND_TEST140 ,theCreatorModel("No name")141 #endif142 124 { 143 125 theExcitationEnergy = 0.0; … … 161 143 theAngularMomentum = right.theAngularMomentum; 162 144 numberOfParticles = right.numberOfParticles; 145 numberOfCharged = right.numberOfCharged; 163 146 numberOfHoles = right.numberOfHoles; 164 numberOfCharged = right.numberOfCharged; 147 numberOfChargedHoles = right.numberOfChargedHoles; 148 numberOfShellElectrons = right.numberOfShellElectrons; 165 149 theParticleDefinition = right.theParticleDefinition; 166 150 theCreationTime = right.theCreationTime; 167 #ifdef PRECOMPOUND_TEST168 theCreatorModel = right.theCreatorModel;169 #endif170 151 } 171 152 return *this; … … 184 165 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment) 185 166 { 167 if (!theFragment) { 168 out << "Fragment: null pointer "; 169 return out; 170 } 171 186 172 std::ios::fmtflags old_floatfield = out.flags(); 187 173 out.setf(std::ios::floatfield); 188 174 189 out 190 << "Fragment: A = " << std::setprecision(3) << theFragment->theA 191 << ", Z = " << std::setprecision(3) << theFragment->theZ ; 175 out << "Fragment: A = " << std::setw(3) << theFragment->theA 176 << ", Z = " << std::setw(3) << theFragment->theZ ; 192 177 out.setf(std::ios::scientific,std::ios::floatfield); 193 out 194 << ", U = " << theFragment->GetExcitationEnergy()/MeV 195 << " MeV" << G4endl 196 << " P = (" 197 << theFragment->theMomentum.x()/MeV << "," 198 << theFragment->theMomentum.y()/MeV << "," 199 << theFragment->theMomentum.z()/MeV 200 << ") MeV E = " 201 << theFragment->theMomentum.t()/MeV << " MeV"; 202 178 179 // Store user's precision setting and reset to (3) here: back-compatibility 180 std::streamsize floatPrec = out.precision(); 181 182 out << std::setprecision(3) 183 << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV 184 << " MeV" << G4endl 185 << " P = (" 186 << theFragment->theMomentum.x()/CLHEP::MeV << "," 187 << theFragment->theMomentum.y()/CLHEP::MeV << "," 188 << theFragment->theMomentum.z()/CLHEP::MeV 189 << ") MeV E = " 190 << theFragment->theMomentum.t()/CLHEP::MeV << " MeV" 191 << G4endl; 192 203 193 // What about Angular momentum??? 204 194 205 195 if (theFragment->GetNumberOfExcitons() != 0) { 206 out << G4endl;207 196 out << " " 208 << "#Particles = " << theFragment->numberOfParticles 209 << ", #Holes = " << theFragment->numberOfHoles 210 << ", #Charged = " << theFragment->numberOfCharged; 197 << "#Particles= " << theFragment->numberOfParticles 198 << ", #Charged= " << theFragment->numberOfCharged 199 << ", #Holes= " << theFragment->numberOfHoles 200 << ", #ChargedHoles= " << theFragment->numberOfChargedHoles 201 << G4endl; 211 202 } 212 203 out.setf(old_floatfield,std::ios::floatfield); 204 out.precision(floatPrec); 213 205 214 206 return out; 215 216 207 } 217 208 … … 222 213 } 223 214 224 void G4Fragment::ExcitationEne gryWarning()225 { 226 if (theExcitationEnergy < -10 .0 *eV) {215 void G4Fragment::ExcitationEnergyWarning() 216 { 217 if (theExcitationEnergy < -10 * CLHEP::eV) { 227 218 ++errCount; 228 219 if ( errCount <= 10 ) { 229 220 G4cout << "G4Fragment::CalculateExcitationEnergy(): Excitation Energy = " 230 << theExcitationEnergy/ MeV << " MeV for A = "231 << theA << " and Z= " << theZ << G4endl;221 << theExcitationEnergy/CLHEP::MeV << " MeV for A = " 222 << theA << " and Z= " << theZ << G4endl; 232 223 if( errCount == 10 ) { 233 224 G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!"; … … 239 230 } 240 231 241 G4ThreeVector G4Fragment::IsotropicRandom3Vector(const G4double Magnitude) const 242 // Create a unit vector with a random direction isotropically distributed 243 { 244 G4double CosTheta = 1.0 - 2.0*G4UniformRand(); 245 G4double SinTheta = std::sqrt(1.0 - CosTheta*CosTheta); 246 G4double Phi = twopi*G4UniformRand(); 247 G4ThreeVector Vector(Magnitude*std::cos(Phi)*SinTheta, 248 Magnitude*std::sin(Phi)*SinTheta, 249 Magnitude*CosTheta); 250 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 232 void G4Fragment::NumberOfExitationWarning(const G4String& value) 233 { 234 G4cout << "G4Fragment::"<< value << " ERROR " 235 << G4endl; 236 G4cout << this << G4endl; 237 G4String text = "G4Fragment::G4Fragment wrong exciton number "; 238 throw G4HadronicException(__FILE__, __LINE__, text); 239 }
Note: See TracChangeset
for help on using the changeset viewer.