- Timestamp:
- Apr 6, 2009, 12:30:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/hadronic/models/coherent_elastic/src/G4HadronElastic.cc
r819 r962 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4HadronElastic.cc,v 1. 56.2.1 2008/04/23 14:14:55 gcosmoExp $27 // GEANT4 tag $Name: geant4-09-0 1-patch-02 $26 // $Id: G4HadronElastic.cc,v 1.61 2008/08/05 07:37:39 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-02-ref-02 $ 28 28 // 29 29 // … … 100 100 thePionPlus = G4PionPlus::PionPlus(); 101 101 thePionMinus= G4PionMinus::PionMinus(); 102 103 nnans = 0; 104 npos = 0; 105 nneg = 0; 106 neneg = 0; 102 107 } 103 108 … … 105 110 { 106 111 delete hElastic; 112 if( (nnans + npos + nneg + neneg) > 0 ) { 113 G4cout << "### G4HadronElastic destructor Warnings: "; 114 if(nnans > 0) G4cout << "### N(nans) = " << nnans; 115 if(npos > 0) G4cout << "### N(cost > 1)= " << npos; 116 if(nneg > 0) G4cout << "### N(cost <-1)= " << nneg; 117 if(neneg > 0) G4cout << "### N(E < 0)= " << neneg; 118 G4cout << "###" << G4endl; 119 } 107 120 } 108 121 … … 148 161 G4int N = A - Z; 149 162 G4int projPDG = theParticle->GetPDGEncoding(); 150 if (verboseLevel>1) 163 if (verboseLevel>1) { 151 164 G4cout << "G4HadronElastic for " << theParticle->GetParticleName() 152 165 << " PDGcode= " << projPDG << " on nucleus Z= " << Z 153 166 << " A= " << A << " N= " << N 154 167 << G4endl; 155 168 } 156 169 G4ParticleDefinition * theDef = 0; 157 170 … … 180 193 181 194 // Q-elastic for p,n scattering on H and He 182 if (theParticle == theProton || theParticle == theNeutron) 195 if (theParticle == theProton || theParticle == theNeutron) { 183 196 // && Z <= 2 && ekin >= lowEnergyLimitQ) 184 197 gtype = fQElastic; 185 198 186 else {199 } else { 187 200 // S-wave for very low energy 188 201 if(plab < plabLowLimit) gtype = fSWave; 189 202 // HE-elastic for energetic projectile mesons 190 203 else if(ekin >= lowEnergyLimitHE && theParticle->GetBaryonNumber() == 0) 191 gtype = fHElastic;204 { gtype = fHElastic; } 192 205 } 193 206 … … 212 225 213 226 if(gtype == fLElastic) { 214 t = GeV*GeV*SampleT(ptot,m1,m2,aTarget); 227 G4double g2 = GeV*GeV; 228 t = g2*SampleT(tmax/g2,m1,m2,aTarget); 215 229 } 216 230 … … 234 248 } 235 249 t = 0.0; 250 nnans++; 236 251 } 237 252 238 253 if(gtype == fSWave) t = G4UniformRand()*tmax; 239 254 240 if(verboseLevel>1) 255 if(verboseLevel>1) { 241 256 G4cout <<"type= " << gtype <<" t= " << t << " tmax= " << tmax 242 257 << " ptot= " << ptot << G4endl; 243 258 } 244 259 // Sampling in CM system 245 260 G4double phi = G4UniformRand()*twopi; … … 247 262 G4double sint; 248 263 249 if( cost >= 1.0 || cost < -1 )250 {264 // problem in sampling 265 if(cost >= 1.0) { 251 266 cost = 1.0; 252 267 sint = 0.0; 253 } 254 else 255 { 268 npos++; 269 } else if(cost < -1 ) { 270 /* 271 G4cout << "G4HadronElastic:WARNING: Z= " << Z << " N= " 272 << N << " " << aParticle->GetDefinition()->GetParticleName() 273 << " mom(GeV)= " << plab/GeV 274 << " the model type " << gtype; 275 if(gtype == fQElastic) G4cout << " CHIPS "; 276 else if(gtype == fLElastic) G4cout << " LElastic "; 277 else if(gtype == fHElastic) G4cout << " HElastic "; 278 G4cout << " cost= " << cost 279 << G4endl; 280 */ 281 cost = 1.0; 282 sint = 0.0; 283 nneg++; 284 285 // normal situation 286 } else { 256 287 sint = std::sqrt((1.0-cost)*(1.0+cost)); 257 288 } 258 if (verboseLevel>1) 289 if (verboseLevel>1) { 259 290 G4cout << "cos(t)=" << cost << " std::sin(t)=" << sint << G4endl; 260 291 } 261 292 G4ThreeVector v1(sint*std::cos(phi),sint*std::sin(phi),cost); 262 293 v1 *= ptot; … … 273 304 } 274 305 if(eFinal <= lowestEnergyLimit) { 275 if(eFinal < 0.0) { 306 if(eFinal < 0.0 && verboseLevel > 0) { 307 neneg++; 276 308 G4cout << "G4HadronElastic WARNING ekin= " << eFinal 277 309 << " after scattering of " … … 308 340 309 341 G4double 310 G4HadronElastic::SampleT(G4double , G4double, G4double, G4double atno2)342 G4HadronElastic::SampleT(G4double tmax, G4double, G4double, G4double atno2) 311 343 { 312 344 // G4cout << "Entering elastic scattering 2"<<G4endl; … … 315 347 // parameterized functions and a Monte Carlo method to invert the CDF. 316 348 317 G4double ran = G4UniformRand();349 // G4double ran = G4UniformRand(); 318 350 G4double aa, bb, cc, dd, rr; 319 351 if (atno2 <= 62.) { … … 330 362 aa = aa/bb; 331 363 cc = cc/dd; 364 G4double ran, t1, t2; 365 do { 366 ran = G4UniformRand(); 367 t1 = -std::log(ran)/bb; 368 t2 = -std::log(ran)/dd; 369 } while(t1 > tmax || t2 > tmax); 370 332 371 rr = (aa + cc)*ran; 372 333 373 if (verboseLevel > 1) { 334 374 G4cout << "DoIt: aa,bb,cc,dd,rr" << G4endl; 335 375 G4cout << aa << " " << bb << " " << cc << " " << dd << " " << rr << G4endl; 336 }337 G4double t1 = -std::log(ran)/bb;338 G4double t2 = -std::log(ran)/dd;339 if (verboseLevel > 1) {340 376 G4cout << "t1,Fctcos " << t1 << " " << Fctcos(t1, aa, bb, cc, dd, rr) << G4endl; 341 377 G4cout << "t2,Fctcos " << t2 << " " << Fctcos(t2, aa, bb, cc, dd, rr) << G4endl; … … 348 384 aa, bb, cc, dd, rr); 349 385 if (verboseLevel > 1) { 350 G4cout << "From Rtmi, ier1=" << ier1 << G4endl;386 G4cout << "From Rtmi, ier1=" << ier1 << " t= " << t << G4endl; 351 387 G4cout << "t, Fctcos " << t << " " << Fctcos(t, aa, bb, cc, dd, rr) << G4endl; 352 388 }
Note: See TracChangeset
for help on using the changeset viewer.