Changeset 1230 for trunk/examples/extended/electromagnetic/TestEm7/src
- Timestamp:
- Jan 8, 2010, 3:02:48 PM (16 years ago)
- Location:
- trunk/examples/extended/electromagnetic/TestEm7/src
- Files:
-
- 20 edited
-
DetectorConstruction.cc (modified) (9 diffs)
-
DetectorMessenger.cc (modified) (1 diff)
-
EventAction.cc (modified) (1 diff)
-
EventActionMessenger.cc (modified) (1 diff)
-
G4ScreenedNuclearRecoil.cc (modified) (31 diffs)
-
PhysListEmLivermore.cc (modified) (1 diff)
-
PhysListEmPenelope.cc (modified) (1 diff)
-
PhysListEmStandard.cc (modified) (5 diffs)
-
PhysListEmStandardNR.cc (modified) (5 diffs)
-
PhysListEmStandardSS.cc (modified) (4 diffs)
-
PhysicsList.cc (modified) (16 diffs)
-
PhysicsListMessenger.cc (modified) (1 diff)
-
PrimaryGeneratorAction.cc (modified) (1 diff)
-
PrimaryGeneratorMessenger.cc (modified) (1 diff)
-
RunAction.cc (modified) (8 diffs)
-
StepMax.cc (modified) (1 diff)
-
StepMaxMessenger.cc (modified) (1 diff)
-
SteppingAction.cc (modified) (2 diffs)
-
SteppingVerbose.cc (modified) (1 diff)
-
TrackingAction.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/extended/electromagnetic/TestEm7/src/DetectorConstruction.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: DetectorConstruction.cc,v 1. 8 2007/01/11 15:41:46vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 1-patch-02$26 // $Id: DetectorConstruction.cc,v 1.10 2008/04/21 13:13:30 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 45 45 46 46 #include "G4NistManager.hh" 47 48 47 #include "G4UnitsTable.hh" 48 49 #include "G4FieldManager.hh" 50 #include "G4TransportationManager.hh" 51 #include "G4RunManager.hh" 49 52 50 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 117 120 Air->AddElement(N, fractionmass=0.7); 118 121 Air->AddElement(O, fractionmass=0.3); 122 123 density = 1.e-5*g/cm3; 124 pressure = 2.e-2*bar; 125 temperature = STP_Temperature; // From PhysicalConstants.h . 126 G4Material* vac = new G4Material( "TechVacuum", density, 1, 127 kStateGas, temperature, pressure ); 128 vac->AddMaterial( Air, 1. ); 119 129 120 130 density = universe_mean_density; //from PhysicalConstants.h … … 235 245 { 236 246 absorSizeX = value; worldSizeX = 1.2*absorSizeX; 247 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 237 248 } 238 249 … … 243 254 absorSizeYZ = value; 244 255 worldSizeYZ = 1.2*absorSizeYZ; 256 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 245 257 } 246 258 … … 252 264 G4Material* pttoMaterial = 253 265 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 254 if (pttoMaterial) absorMaterial = pttoMaterial; 255 } 256 257 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 258 259 #include "G4FieldManager.hh" 260 #include "G4TransportationManager.hh" 266 if (pttoMaterial) { 267 absorMaterial = pttoMaterial; 268 if(lAbsor) { 269 lAbsor->SetMaterial(absorMaterial); 270 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 271 } 272 } 273 } 274 275 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 261 276 262 277 void DetectorConstruction::SetMagField(G4double fieldValue) … … 285 300 { 286 301 tallySize = value; 302 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 287 303 } 288 304 … … 294 310 G4Material* pttoMaterial = 295 311 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 296 if (pttoMaterial) tallyMaterial = pttoMaterial; 312 if (pttoMaterial) { 313 tallyMaterial = pttoMaterial; 314 if(lTally) { 315 lTally->SetMaterial(tallyMaterial); 316 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 317 } 318 } 297 319 } 298 320 … … 305 327 tallyNumber++; 306 328 } 329 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 307 330 } 308 331 309 332 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 310 311 #include "G4RunManager.hh"312 333 313 334 void DetectorConstruction::UpdateGeometry() 314 335 { 315 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes()); 316 } 317 318 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 336 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 337 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes()); 338 } 339 340 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/DetectorMessenger.cc
r807 r1230 25 25 // 26 26 // $Id: DetectorMessenger.cc,v 1.3 2006/06/29 16:58:13 gunter Exp $ 27 // GEANT4 tag $Name: $27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/EventAction.cc
r807 r1230 25 25 // 26 26 // $Id: EventAction.cc,v 1.4 2006/06/29 16:58:15 gunter Exp $ 27 // GEANT4 tag $Name: $27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/EventActionMessenger.cc
r807 r1230 25 25 // 26 26 // $Id: EventActionMessenger.cc,v 1.4 2006/06/29 16:58:17 gunter Exp $ 27 // GEANT4 tag $Name: $27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/G4ScreenedNuclearRecoil.cc
r807 r1230 25 25 // 26 26 // 27 // $Id: G4ScreenedNuclearRecoil.cc,v 1.5 2008/01/14 12:11:39 vnivanch Exp $28 // GEANT4 tag $Name: $27 // G4ScreenedNuclearRecoil.cc,v 1.57 2008/05/07 11:51:26 marcus Exp 28 // GEANT4 tag 29 29 // 30 30 // … … 84 84 #include "G4ScreenedNuclearRecoil.hh" 85 85 86 const char* G4ScreenedCoulombCrossSectionInfo::CVSFileVers() { return 87 "G4ScreenedNuclearRecoil.cc,v 1.57 2008/05/07 11:51:26 marcus Exp GEANT4 tag "; 88 } 89 86 90 #include "G4ParticleTypes.hh" 87 91 #include "G4ParticleTable.hh" 88 92 #include "G4VParticleChange.hh" 89 #include "G4ParticleChange .hh"93 #include "G4ParticleChangeForLoss.hh" 90 94 #include "G4DataVector.hh" 91 95 #include "G4Track.hh" … … 99 103 #include "G4IsotopeVector.hh" 100 104 105 #include "G4EmProcessSubType.hh" 106 101 107 #include "G4RangeTest.hh" 102 108 #include "G4ParticleDefinition.hh" … … 104 110 #include "G4ProcessManager.hh" 105 111 #include "G4StableIsotopes.hh" 112 #include "G4LindhardPartition.hh" 106 113 107 114 #include "Randomize.hh" … … 112 119 #include <iomanip> 113 120 121 #include "c2_factory.hh" 122 static c2_factory<G4double> c2; // this makes a lot of notation shorter 123 typedef c2_ptr<G4double> c2p; 124 114 125 G4ScreenedCoulombCrossSection::~G4ScreenedCoulombCrossSection() 115 126 { 116 ScreeningMap::iterator tables=screeningData.begin();117 for (;tables != screeningData.end(); tables++) {118 delete (*tables).second.EMphiData;119 }120 127 screeningData.clear(); 121 122 std::map<G4int, c2_function<G4double> *>::iterator mfpit=MFPTables.begin(); 123 for (;mfpit != MFPTables.end(); mfpit++) { 124 delete (*mfpit).second; 125 } 126 MFPTables.clear(); 127 128 MFPTables.clear(); 128 129 } 129 130 … … 248 249 element=elementVector[kel]; 249 250 G4int Z=(G4int)std::floor(element->GetZ()+0.5); 250 c 2_function<G4double> &ifunc=*sigmaMap[Z];251 const G4_c2_function &ifunc=sigmaMap[Z]; 251 252 if(!kel || ifunc.xmin() > emin) emin=ifunc.xmin(); 252 253 if(!kel || ifunc.xmax() < emax) emax=ifunc.xmax(); … … 268 269 element=elementVector[kel]; 269 270 G4int Z=(G4int)std::floor(element->GetZ()+0.5); 270 c 2_function<G4double> &sigma=*sigmaMap[Z];271 const G4_c2_function &sigma=sigmaMap[Z]; 271 272 G4double ndens = atomDensities[kel]; // compute atom fraction for this element in this material 272 273 … … 281 282 } 282 283 // and make a new interpolating function out of the sum 283 MFPTables[matidx] = static_cast<c2_function<G4double> *>(new log_log_interpolating_function<G4double>( 284 evals, mfpvals)); 284 MFPTables[matidx] = c2.log_log_interpolating_function().load(evals, mfpvals,true,0,true,0); 285 285 } 286 287 #ifdef DEBUG288 for (G4int matidx=0; matidx < nMaterials; matidx++) {289 const G4Material* material= (*materialTable)[matidx];290 G4cout << "***** MFP (1MeV) ***** " << material->GetName() << " " << (*MFPTables[matidx])(1.0) << G4endl;291 }292 #endif293 294 286 } 295 287 … … 304 296 recoilCutoff(RecoilCutoff), physicsCutoff(PhysicsCutoff), 305 297 hardeningFraction(0.0), hardeningFactor(1.0), 306 externalCrossSectionConstructor(0) 307 { 298 externalCrossSectionConstructor(0), 299 NIELPartitionFunction(new G4LindhardRobinsonPartition) 300 { 301 // for now, point to class instance of this. Doing it by creating a new one fails 302 // to correctly update NIEL 303 // not even this is needed... done in G4VProcess(). 304 // pParticleChange=&aParticleChange; 305 processMaxEnergy=50000.0*MeV; 308 306 highEnergyLimit=100.0*MeV; 309 307 lowEnergyLimit=physicsCutoff; … … 313 311 AddStage(new G4ScreenedCoulombClassicalKinematics); 314 312 AddStage(new G4SingleScatter); 313 SetProcessSubType(fCoulombScattering); 315 314 } 316 315 317 316 void G4ScreenedNuclearRecoil::ResetTables() 318 317 { 319 std::map<G4int, c2_function<G4double>*>::iterator xh=meanFreePathTables.begin();320 for(;xh != meanFreePathTables.end(); xh++) {321 delete (*xh).second;322 }323 meanFreePathTables.clear();324 318 325 319 std::map<G4int, G4ScreenedCoulombCrossSection*>::iterator xt=crossSectionHandlers.begin(); … … 338 332 339 333 collisionStages.clear(); 334 } 335 336 void G4ScreenedNuclearRecoil::SetNIELPartitionFunction(const G4VNIELPartition *part) 337 { 338 if(NIELPartitionFunction) delete NIELPartitionFunction; 339 NIELPartitionFunction=part; 340 } 341 342 void G4ScreenedNuclearRecoil::DepositEnergy(G4int z1, G4double a1, const G4Material *material, G4double energy) 343 { 344 if(!NIELPartitionFunction) { 345 IonizingLoss+=energy; 346 } else { 347 G4double part=NIELPartitionFunction->PartitionNIEL(z1, a1, material, energy); 348 IonizingLoss+=energy*(1-part); 349 NIEL += energy*part; 350 } 340 351 } 341 352 … … 363 374 G4double G4ScreenedNuclearRecoil::GetMeanFreePath(const G4Track& track, 364 375 G4double, 365 G4ForceCondition* )376 G4ForceCondition* cond) 366 377 { 367 378 const G4DynamicParticle* incoming = track.GetDynamicParticle(); … … 370 381 371 382 G4double meanFreePath; 372 373 if (energy < lowEnergyLimit || energy < recoilCutoff) return 1.0*nanometer; /* stop slow particles! */ 374 else if (energy > highEnergyLimit*a1) energy=highEnergyLimit*a1; /* constant MFP at high energy */ 383 *cond=NotForced; 384 385 if (energy < lowEnergyLimit || energy < recoilCutoff*a1) { 386 *cond=Forced; 387 return 1.0*nm; /* catch and stop slow particles to collect their NIEL! */ 388 } else if (energy > processMaxEnergy*a1) { 389 return DBL_MAX; // infinite mean free path 390 } else if (energy > highEnergyLimit*a1) energy=highEnergyLimit*a1; /* constant MFP at high energy */ 375 391 376 392 G4double fz1=incoming->GetDefinition()->GetPDGCharge(); … … 390 406 size_t materialIndex = materialCouple->GetMaterial()->GetIndex(); 391 407 392 c 2_function<G4double>&mfp=*(*xs)[materialIndex];408 const G4_c2_function &mfp=*(*xs)[materialIndex]; 393 409 394 410 // make absolutely certain we don't get an out-of-range energy … … 403 419 { 404 420 validCollision=1; 405 aParticleChange.Initialize(aTrack);421 pParticleChange->Initialize(aTrack); 406 422 NIEL=0.0; // default is no NIEL deposited 423 IonizingLoss=0.0; 407 424 408 425 // do universal setup … … 413 430 G4double fz1=baseParticle->GetPDGCharge()/eplus; 414 431 G4int z1=(G4int)(fz1+0.5); 432 G4double a1=baseParticle->GetPDGMass()/amu_c2; 415 433 G4double incidentEnergy = incidentParticle->GetKineticEnergy(); 416 434 … … 418 436 const G4MaterialCutsCouple* couple = aTrack.GetMaterialCutsCouple(); 419 437 420 if(incidentEnergy < GetRecoilCutoff()) { // check energy sanity on entry 421 if(!baseParticle->GetProcessManager()-> 422 GetAtRestProcessVector()->size()) 423 aParticleChange.ProposeTrackStatus(fStopAndKill); 424 else 425 aParticleChange.ProposeTrackStatus(fStopButAlive); 426 427 AddToNIEL(incidentEnergy); 428 aParticleChange.ProposeEnergy(0.0); 438 const G4Material* mat = couple->GetMaterial(); 439 440 G4double P=0.0; // the impact parameter of this collision 441 442 if(incidentEnergy < GetRecoilCutoff()*a1) { // check energy sanity on entry 443 DepositEnergy(z1, baseParticle->GetPDGMass()/amu_c2, mat, incidentEnergy); 444 GetParticleChange().ProposeEnergy(0.0); 429 445 // stop the particle and bail out 430 446 validCollision=0; 431 }432 433 const G4Material* mat = couple->GetMaterial();434 G4double numberDensity=mat->GetTotNbOfAtomsPerVolume();435 G4double lattice=0.5/std::pow(numberDensity,1.0/3.0); // typical lattice half-spacing436 G4double length=GetCurrentInteractionLength();437 G4double sigopi=1.0/(CLHEP::pi*numberDensity*length); // this is sigma0/pi438 439 // compute the impact parameter very early, so if is rejected as too far away, little effort is wasted440 // this is the TRIM method for determining an impact parameter based on the flight path441 // this gives a cumulative distribution of N(P)= 1-exp(-pi P^2 n l)442 // which says the probability of NOT hitting a disk of area sigma= pi P^2 =exp(-sigma N l)443 // which may be reasonable444 G4double P;445 if(sigopi < lattice*lattice) {446 // normal long-flight approximation447 P = std::sqrt(-std::log(G4UniformRand()) *sigopi);448 447 } else { 449 // short-flight limit 450 P = std::sqrt(G4UniformRand())*lattice; 451 } 452 453 G4double fraction=GetHardeningFraction(); 454 if(fraction && G4UniformRand() < fraction) { 455 // pick out some events, and increase the central cross section 456 // by reducing the impact parameter 457 P /= std::sqrt(GetHardeningFactor()); 458 } 459 460 461 // check if we are far enough away that the energy transfer must be below cutoff, 462 // and leave everything alone if so, saving a lot of time. 463 if(P*P > sigopi) { 464 if(GetVerboseLevel() > 1) 465 printf("ScreenedNuclear impact reject: length=%.3f P=%.4f limit=%.4f\n", 466 length/angstrom, P/angstrom,std::sqrt(sigopi)/angstrom); 467 // no collision, don't follow up with anything 468 validCollision=0; 448 449 G4double numberDensity=mat->GetTotNbOfAtomsPerVolume(); 450 G4double lattice=0.5/std::pow(numberDensity,1.0/3.0); // typical lattice half-spacing 451 G4double length=GetCurrentInteractionLength(); 452 G4double sigopi=1.0/(CLHEP::pi*numberDensity*length); // this is sigma0/pi 453 454 // compute the impact parameter very early, so if is rejected as too far away, little effort is wasted 455 // this is the TRIM method for determining an impact parameter based on the flight path 456 // this gives a cumulative distribution of N(P)= 1-exp(-pi P^2 n l) 457 // which says the probability of NOT hitting a disk of area sigma= pi P^2 =exp(-sigma N l) 458 // which may be reasonable 459 if(sigopi < lattice*lattice) { 460 // normal long-flight approximation 461 P = std::sqrt(-std::log(G4UniformRand()) *sigopi); 462 } else { 463 // short-flight limit 464 P = std::sqrt(G4UniformRand())*lattice; 465 } 466 467 G4double fraction=GetHardeningFraction(); 468 if(fraction && G4UniformRand() < fraction) { 469 // pick out some events, and increase the central cross section 470 // by reducing the impact parameter 471 P /= std::sqrt(GetHardeningFactor()); 472 } 473 474 475 // check if we are far enough away that the energy transfer must be below cutoff, 476 // and leave everything alone if so, saving a lot of time. 477 if(P*P > sigopi) { 478 if(GetVerboseLevel() > 1) 479 printf("ScreenedNuclear impact reject: length=%.3f P=%.4f limit=%.4f\n", 480 length/angstrom, P/angstrom,std::sqrt(sigopi)/angstrom); 481 // no collision, don't follow up with anything 482 validCollision=0; 483 } 469 484 } 470 485 471 486 // find out what we hit, and record it in our kinematics block. 487 kinematics.targetMaterial=mat; 488 kinematics.a1=a1; 489 472 490 if(validCollision) { 473 491 G4ScreenedCoulombCrossSection *xsect=GetCrossSectionHandlers()[z1]; … … 477 495 kinematics.recoilIon=recoilIon; 478 496 kinematics.impactParameter=P; 479 kinematics.a1=baseParticle->GetPDGMass()/amu_c2;480 497 kinematics.a2=recoilIon->GetPDGMass()/amu_c2; 481 498 } else { 482 499 kinematics.recoilIon=0; 483 500 kinematics.impactParameter=0; 484 kinematics.a1=baseParticle->GetPDGMass()/amu_c2;485 501 kinematics.a2=0; 486 502 } … … 492 508 493 509 if(registerDepositedEnergy) { 494 aParticleChange.ProposeLocalEnergyDeposit(NIEL); 495 aParticleChange.ProposeNonIonizingEnergyDeposit(NIEL); 496 } 510 pParticleChange->ProposeLocalEnergyDeposit(IonizingLoss+NIEL); 511 pParticleChange->ProposeNonIonizingEnergyDeposit(NIEL); 512 //MHM G4cout << "depositing energy, total = " << IonizingLoss+NIEL << " NIEL = " << NIEL << G4endl; 513 } 514 497 515 return G4VDiscreteProcess::PostStepDoIt( aTrack, aStep ); 516 } 517 518 G4ScreenedCoulombClassicalKinematics::G4ScreenedCoulombClassicalKinematics() : 519 // instantiate all the needed functions statically, so no allocation is done at run time 520 // we will be solving x^2 - x phi(x*au)/eps - beta^2 == 0.0 521 // or, for easier scaling, x'^2 - x' au phi(x')/eps - beta^2 au^2 522 // note that only the last of these gets deleted, since it owns the rest 523 phifunc(c2.const_plugin_function()), 524 xovereps(c2.linear(0., 0., 0.)), // will fill this in with the right slope at run time 525 diff(c2.quadratic(0., 0., 0., 1.)-xovereps*phifunc) 526 { 498 527 } 499 528 … … 520 549 } 521 550 522 c2_function<G4double> &phiData=*(screen->EMphiData);523 // instantiate all the needed functions statically, so no allocation is done at run time524 551 // we will be solving x^2 - x phi(x*au)/eps - beta^2 == 0.0 525 552 // or, for easier scaling, x'^2 - x' au phi(x')/eps - beta^2 au^2 526 static c2_plugin_function<G4double> phifunc;527 static c2_quadratic<G4double> xsq(0., 0., 0., 1.); // x^2528 static c2_linear<G4double> xovereps(0., 0., 0.); // will fill this in with the right slope at run time529 static c2_function<G4double> &xphi=xovereps*phifunc;530 static c2_function<G4double> &diff=xsq-xphi;531 532 553 xovereps.reset(0., 0.0, au/eps); // slope of x*au/eps term 533 phifunc.set_function(phiData); // install interpolating table 534 554 phifunc.set_function(&(screen->EMphiData.get())); // install interpolating table 535 555 G4double xx1, phip, phip2; 536 G4int root_error; 537 538 xx1=diff.find_root(phiData.xmin(), std::min(10*xx0*au,phiData.xmax()), 539 std::min(xx0*au, phiData.xmax()), beta*beta*au*au, &root_error, &phip, &phip2)/au; 556 G4int root_error; 557 xx1=diff->find_root(phifunc.xmin(), std::min(10*xx0*au,phifunc.xmax()), 558 std::min(xx0*au, phifunc.xmax()), beta*beta*au*au, &root_error, &phip, &phip2)/au; 540 559 541 560 if(root_error) { 542 561 G4cout << "Screened Coulomb Root Finder Error" << G4endl; 543 562 G4cout << "au " << au << " A " << A << " a1 " << a1 << " xx1 " << xx1 << " eps " << eps << " beta " << beta << G4endl; 544 G4cout << " xmin " << phi Data.xmin() << " xmax " << std::min(10*xx0*au,phiData.xmax()) ;545 G4cout << " f(xmin) " << phifunc(phi Data.xmin()) << " f(xmax) " << phifunc(std::min(10*xx0*au,phiData.xmax())) ;546 G4cout << " xstart " << std::min(xx0*au, phi Data.xmax()) << " target " << beta*beta*au*au ;563 G4cout << " xmin " << phifunc.xmin() << " xmax " << std::min(10*xx0*au,phifunc.xmax()) ; 564 G4cout << " f(xmin) " << phifunc(phifunc.xmin()) << " f(xmax) " << phifunc(std::min(10*xx0*au,phifunc.xmax())) ; 565 G4cout << " xstart " << std::min(xx0*au, phifunc.xmax()) << " target " << beta*beta*au*au ; 547 566 G4cout << G4endl; 548 567 throw c2_exception("Failed root find"); 549 568 } 550 569 551 phifunc.unset_function(); // throws an exception if used without setting again 552 // phiprime is scaled by one factor of au because phi is evaluated at (xx0*au), 570 // phiprime is scaled by one factor of au because phi is evaluated at (xx0*au), 553 571 G4double phiprime=phip*au; 554 572 … … 564 582 G4double x, ff; 565 583 x=xx1/xvals[k]; 566 ff=1.0/std::sqrt(1.0-phi Data(x*au)/(x*eps)-beta*beta/(x*x));584 ff=1.0/std::sqrt(1.0-phifunc(x*au)/(x*eps)-beta*beta/(x*x)); 567 585 alpha+=weights[k]*ff; 568 586 } 569 587 588 phifunc.unset_function(); // throws an exception if used without setting again 589 570 590 G4double thetac1=CLHEP::pi*beta*alpha/xx1; // complement of CM scattering angle 571 591 G4double sintheta=std::sin(thetac1); //note sin(pi-theta)=sin(theta) … … 626 646 kin.eRecoil=eRecoil; 627 647 628 if(incidentEnergy-eRecoil < master->GetRecoilCutoff()) { 629 if(!baseParticle->GetProcessManager()-> 630 GetAtRestProcessVector()->size()) 631 aParticleChange.ProposeTrackStatus(fStopAndKill); 632 else 633 aParticleChange.ProposeTrackStatus(fStopButAlive); 648 if(incidentEnergy-eRecoil < master->GetRecoilCutoff()*a1) { 634 649 aParticleChange.ProposeEnergy(0.0); 635 master-> AddToNIEL(incidentEnergy-eRecoil);650 master->DepositEnergy(int(screen->z1), a1, kin.targetMaterial, incidentEnergy-eRecoil); 636 651 } 637 652 638 if(master->GetEnableRecoils() && eRecoil > master->GetRecoilCutoff() ) {653 if(master->GetEnableRecoils() && eRecoil > master->GetRecoilCutoff() * kin.a2) { 639 654 kin.recoilIon=recoilIon; 640 655 } else { 641 656 kin.recoilIon=0; // this flags no recoil to be generated 642 master-> AddToNIEL(eRecoil) ;657 master->DepositEnergy(Z, A, kin.targetMaterial, eRecoil) ; 643 658 } 644 659 } … … 706 721 #include <vector> 707 722 708 static c2_function<G4double>&ZBLScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)723 G4_c2_function &ZBLScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval) 709 724 { 710 725 static const size_t ncoef=4; … … 729 744 730 745 *auval=au; 731 return *static_cast<c2_function<G4double> *>(new lin_log_interpolating_function<G4double>(r, phi, false, phiprime0));732 } 733 734 static c2_function<G4double>&MoliereScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)746 return c2.lin_log_interpolating_function().load(r, phi, false, phiprime0,true,0); 747 } 748 749 G4_c2_function &MoliereScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval) 735 750 { 736 751 static const size_t ncoef=3; … … 755 770 756 771 *auval=au; 757 return *static_cast<c2_function<G4double> *>(new lin_log_interpolating_function<G4double>(r, phi, false, phiprime0));758 } 759 760 static c2_function<G4double>&LJScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)772 return c2.lin_log_interpolating_function().load(r, phi, false, phiprime0,true,0); 773 } 774 775 G4_c2_function &LJScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval) 761 776 { 762 777 //from Loftager, Besenbacher, Jensen & Sorensen … … 781 796 782 797 *auval=au; 783 return *static_cast<c2_function<G4double> *>(new lin_log_interpolating_function<G4double>(r, phi, false, logphiprime0*phi[0])); 798 return c2.lin_log_interpolating_function().load(r, phi, false, logphiprime0*phi[0],true,0); 799 } 800 801 G4_c2_function &LJZBLScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval) 802 { 803 // hybrid of LJ and ZBL, uses LJ if x < 0.25*auniv, ZBL if x > 1.5*auniv, and 804 /// connector in between. These numbers are selected so the switchover 805 // is very near the point where the functions naturally cross. 806 G4double auzbl, aulj; 807 808 c2p zbl=ZBLScreening(z1, z2, npoints, rMax, &auzbl); 809 c2p lj=LJScreening(z1, z2, npoints, rMax, &aulj); 810 811 G4double au=(auzbl+aulj)*0.5; 812 lj->set_domain(lj->xmin(), 0.25*au); 813 zbl->set_domain(1.5*au,zbl->xmax()); 814 815 c2p conn=c2.connector_function(lj->xmax(), lj, zbl->xmin(), zbl, true,0); 816 c2_piecewise_function_p<G4double> &pw=c2.piecewise_function(); 817 c2p keepit(pw); 818 pw.append_function(lj); 819 pw.append_function(conn); 820 pw.append_function(zbl); 821 822 *auval=au; 823 keepit.release_for_return(); 824 return pw; 784 825 } 785 826 … … 791 832 AddScreeningFunction("lj", LJScreening); 792 833 AddScreeningFunction("mol", MoliereScreening); 834 AddScreeningFunction("ljzbl", LJZBLScreening); 793 835 } 794 836 … … 855 897 856 898 G4double au; 857 c2_function<G4double> &screen=sfunc(z1, Z, 200, 50.0*angstrom, &au); // generate the screening data 858 899 G4_c2_ptr screen=sfunc(z1, Z, 200, 50.0*angstrom, &au); // generate the screening data 859 900 G4ScreeningTables st; 860 st.EMphiData=&screen; // this is our phi table 901 902 st.EMphiData=screen; //save our phi table 861 903 st.z1=z1; st.m1=a1; st.z2=Z; st.m2=a2; st.emin=recoilCutoff; 862 904 st.au=au; … … 869 911 //this rearranges to phi(x0)/(x0*eps) = 2*theta/pi - theta^2/pi^2 870 912 871 c2_linear<G4double> c2au(0.0, 0.0, au); 872 c2_composed_function<G4double> phiau(screen, c2au); // build phi(x*au) for dimensionless phi 873 c2_linear<G4double> c2eps(0.0, 0.0, 0.0); // will store an appropriate eps inside this in loop 874 c2_ratio<G4double> x0func(phiau, c2eps); // this will be phi(x)/(x*eps) when c2eps is correctly set 913 c2_linear_p<G4double> &c2eps=c2.linear(0.0, 0.0, 0.0); // will store an appropriate eps inside this in loop 914 G4_c2_ptr phiau=screen(c2.linear(0.0, 0.0, au)); 915 G4_c2_ptr x0func(phiau/c2eps); // this will be phi(x)/(x*eps) when c2eps is correctly set 916 x0func->set_domain(1e-6*angstrom/au, 0.9999*screen->xmax()/au); // needed for inverse function 917 // use the c2_inverse_function interface for the root finder... it is more efficient for an ordered 918 // computation of values. 919 G4_c2_ptr x0_solution(c2.inverse_function(x0func)); 875 920 876 921 G4double m1c2=a1*amu_c2; … … 897 942 G4double q=theta/pi; 898 943 // G4cout << ee << " " << m1c2 << " " << gamma << " " << eps << " " << theta << " " << q << G4endl; 899 G4double x0= x0func.find_root(1e-6*angstrom/au, 0.9999*screen.xmax()/au, 1.0, 2*q-q*q); 944 // old way using root finder 945 // G4double x0= x0func->find_root(1e-6*angstrom/au, 0.9999*screen.xmax()/au, 1.0, 2*q-q*q); 946 // new way using c2_inverse_function which caches useful information so should be a bit faster 947 // since we are scanning this in strict order. 948 G4double x0=0; 949 try { 950 x0=x0_solution(2*q-q*q); 951 } catch(c2_exception e) { 952 G4Exception( 953 G4String("G4ScreenedNuclearRecoil: failure in inverse solution to generate MFP Tables: ")+e.what() 954 ); 955 } 900 956 G4double betasquared=x0*x0 - x0*phiau(x0)/eps; 901 957 G4double sigma=pi*betasquared*au*au; … … 903 959 data[idx]=sigma; 904 960 } 905 906 961 screeningData[Z]=st; 907 sigmaMap[Z] = static_cast<c2_function<G4double> *>(new log_log_interpolating_function<G4double>( 908 energies, data)); 962 sigmaMap[Z] = c2.log_log_interpolating_function().load(energies, data, true,0,true,0); 909 963 } 910 964 } -
trunk/examples/extended/electromagnetic/TestEm7/src/PhysListEmLivermore.cc
r807 r1230 26 26 // 27 27 // $Id: PhysListEmLivermore.cc,v 1.2 2006/12/11 20:13:53 vnivanch Exp $ 28 // GEANT4 tag $Name: $28 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 29 29 // 30 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/PhysListEmPenelope.cc
r807 r1230 26 26 // 27 27 // $Id: PhysListEmPenelope.cc,v 1.1 2006/11/22 18:56:21 vnivanch Exp $ 28 // GEANT4 tag $Name: $28 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 29 29 // 30 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/PhysListEmStandard.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // 27 // $Id: PhysListEmStandard.cc,v 1.11 2008/01/14 12:11:39 vnivanch Exp $ 28 // GEANT4 tag $Name: $ 26 // $Id: PhysListEmStandard.cc,v 1.19 2008/11/20 20:34:50 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 29 28 // 30 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 39 38 #include "G4PhotoElectricEffect.hh" 40 39 41 #include "G4 MultipleScattering.hh"40 #include "G4eMultipleScattering.hh" 42 41 #include "G4hMultipleScattering.hh" 43 42 … … 51 50 52 51 #include "G4hIonisation.hh" 52 #include "G4hBremsstrahlung.hh" 53 #include "G4hPairProduction.hh" 54 53 55 #include "G4ionIonisation.hh" 54 56 55 57 #include "G4EmProcessOptions.hh" 58 #include "G4MscStepLimitType.hh" 56 59 57 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 86 89 } else if (particleName == "e-") { 87 90 //electron 88 pmanager->AddProcess(new G4 MultipleScattering, -1, 1,1);89 pmanager->AddProcess(new G4eIonisation, -1, 2,2);90 pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);91 pmanager->AddProcess(new G4eMultipleScattering, -1, 1, 1); 92 pmanager->AddProcess(new G4eIonisation, -1, 2, 2); 93 pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3); 91 94 92 95 } else if (particleName == "e+") { 93 96 //positron 94 pmanager->AddProcess(new G4 MultipleScattering, -1, 1,1);95 pmanager->AddProcess(new G4eIonisation, -1, 2,2);96 pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);97 pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,4);97 pmanager->AddProcess(new G4eMultipleScattering, -1, 1, 1); 98 pmanager->AddProcess(new G4eIonisation, -1, 2, 2); 99 pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3); 100 pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 4); 98 101 99 102 } else if( particleName == "mu+" || 100 103 particleName == "mu-" ) { 101 104 //muon 102 pmanager->AddProcess(new G4hMultipleScattering,-1, 1,1); 103 pmanager->AddProcess(new G4MuIonisation, -1, 2,2); 104 pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3,3); 105 pmanager->AddProcess(new G4MuPairProduction, -1, 4,4); 105 pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); 106 pmanager->AddProcess(new G4MuIonisation, -1, 2, 2); 107 pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3, 3); 108 pmanager->AddProcess(new G4MuPairProduction, -1, 4, 4); 109 110 } else if( particleName == "proton" || 111 particleName == "pi-" || 112 particleName == "pi+" ) { 113 //proton 114 pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); 115 pmanager->AddProcess(new G4hIonisation, -1, 2, 2); 116 pmanager->AddProcess(new G4hBremsstrahlung, -1, 3, 3); 117 pmanager->AddProcess(new G4hPairProduction, -1, 4, 4); 106 118 107 } else if( particleName == "alpha" || particleName == "GenericIon" ) { 108 pmanager->AddProcess(new G4hMultipleScattering,-1, 1,1); 109 pmanager->AddProcess(new G4ionIonisation, -1, 2,2); 119 } else if( particleName == "alpha" || 120 particleName == "He3" || 121 particleName == "GenericIon" ) { 122 //Ions 123 pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); 124 pmanager->AddProcess(new G4ionIonisation, -1, 2, 2); 110 125 111 126 } else if ((!particle->IsShortLived()) && … … 113 128 (particle->GetParticleName() != "chargedgeantino")) { 114 129 //all others charged particles except geantino 115 pmanager->AddProcess(new G4hMultipleScattering, -1,1,1);116 pmanager->AddProcess(new G4hIonisation, -1,2,2);130 pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); 131 pmanager->AddProcess(new G4hIonisation, -1, 2, 2); 117 132 } 118 133 } 119 G4EmProcessOptions opt;120 opt.SetStepFunction(0.2, 10*um);121 // opt.SetSkin(1.);122 opt.SetMinEnergy(0.1*keV);123 opt.SetMaxEnergy(100.*GeV);124 opt.SetDEDXBinning(360);125 opt.SetLambdaBinning(360);126 opt.SetLinearLossLimit(1.e-6);127 134 } 128 135 -
trunk/examples/extended/electromagnetic/TestEm7/src/PhysListEmStandardNR.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: PhysListEmStandardNR.cc,v 1. 1 2008/01/14 12:11:39 vnivanch Exp $27 // GEANT4 tag $Name: $26 // $Id: PhysListEmStandardNR.cc,v 1.3 2008/05/09 08:30:59 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 56 56 #include "G4CoulombScattering.hh" 57 57 58 #include "G4DummyModel.hh" 59 58 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 59 61 … … 74 76 75 77 G4ScreenedNuclearRecoil* nucr = new G4ScreenedNuclearRecoil(); 78 G4double energyLimit = 100.*MeV; 79 nucr->SetMaxEnergyForScattering(energyLimit); 76 80 77 81 theParticleIterator->reset(); … … 109 113 110 114 } else if (particleName == "alpha" || particleName == "He3") { 115 G4hMultipleScattering* msc = new G4hMultipleScattering(); 116 G4DummyModel* dm = new G4DummyModel(); 117 dm->SetLowEnergyLimit(0.0); 118 dm->SetHighEnergyLimit(energyLimit); 119 msc->AddEmModel(0, dm); 120 pmanager->AddProcess(msc, -1, 1,1); 121 111 122 G4ionIonisation* ion = new G4ionIonisation(); 112 123 ion->ActivateNuclearStopping(false); 113 pmanager->AddProcess(ion, -1, 1, 1); 124 pmanager->AddProcess(ion, -1, 2, 2); 125 114 126 pmanager->AddDiscreteProcess(nucr); 115 127 116 128 } else if (particleName == "GenericIon" ) { 129 G4hMultipleScattering* msc = new G4hMultipleScattering(); 130 G4DummyModel* dm = new G4DummyModel(); 131 dm->SetLowEnergyLimit(0.0); 132 dm->SetHighEnergyLimit(energyLimit); 133 msc->AddEmModel(0, dm); 134 pmanager->AddProcess(msc, -1, 1,1); 135 117 136 G4ionIonisation* ion = new G4ionIonisation(); 118 137 ion->ActivateNuclearStopping(false); 119 138 ion->SetStepFunction(0.1, um); 120 pmanager->AddProcess(ion, -1, 1, 1); 139 pmanager->AddProcess(ion, -1, 2, 2); 140 121 141 pmanager->AddDiscreteProcess(nucr); 122 142 … … 124 144 particleName == "deuteron" || 125 145 particleName == "triton") { 146 G4hMultipleScattering* msc = new G4hMultipleScattering(); 147 G4DummyModel* dm = new G4DummyModel(); 148 dm->SetLowEnergyLimit(0.0); 149 dm->SetHighEnergyLimit(energyLimit); 150 msc->AddEmModel(0, dm); 151 pmanager->AddProcess(msc, -1, 1,1); 152 126 153 G4hIonisation* hion = new G4hIonisation(); 127 154 hion->SetFluctModel(new G4IonFluctuations()); 128 155 hion->SetStepFunction(0.1, 10.*um); 129 156 hion->ActivateNuclearStopping(false); 130 pmanager->AddProcess(hion, -1, 1,1); 157 pmanager->AddProcess(hion, -1, 2, 2); 158 131 159 pmanager->AddDiscreteProcess(nucr); 132 160 -
trunk/examples/extended/electromagnetic/TestEm7/src/PhysListEmStandardSS.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: PhysListEmStandardSS.cc,v 1. 5 2008/01/14 12:11:39 vnivanchExp $27 // GEANT4 tag $Name: $26 // $Id: PhysListEmStandardSS.cc,v 1.8 2008/11/16 19:17:39 maire Exp $ 27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 38 38 #include "G4PhotoElectricEffect.hh" 39 39 40 #include "G4 MultipleScattering.hh"40 #include "G4CoulombScattering.hh" 41 41 42 42 #include "G4eIonisation.hh" … … 50 50 #include "G4hIonisation.hh" 51 51 #include "G4ionIonisation.hh" 52 #include "G4ionGasIonisation.hh" 53 #include "G4IonFluctuations.hh" 54 #include "G4CoulombScattering.hh" 52 53 #include "G4EmProcessOptions.hh" 55 54 56 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 85 84 } else if (particleName == "e-") { 86 85 //electron 87 pmanager->AddProcess(new G4eIonisation, -1, 1,1);88 pmanager->AddProcess(new G4eBremsstrahlung, -1, 2,2);89 86 pmanager->AddDiscreteProcess(new G4CoulombScattering); 87 pmanager->AddProcess(new G4eIonisation, -1, 1, 1); 88 pmanager->AddProcess(new G4eBremsstrahlung, -1, 2, 2); 90 89 91 90 } else if (particleName == "e+") { 92 91 //positron 93 pmanager->AddProcess(new G4eIonisation, -1, 1,1);94 pmanager->AddProcess(new G4eBremsstrahlung, -1, 2,2);95 pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,3);96 92 pmanager->AddDiscreteProcess(new G4CoulombScattering); 93 pmanager->AddProcess(new G4eIonisation, -1, 1, 1); 94 pmanager->AddProcess(new G4eBremsstrahlung, -1, 2, 2); 95 pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 3); 97 96 98 97 } else if (particleName == "mu+" || 99 98 particleName == "mu-" ) { 100 //muon 101 pmanager->Add Process(new G4MuIonisation, -1, 1,1);102 pmanager->AddProcess(new G4Mu Bremsstrahlung, -1, 2,2);103 pmanager->AddProcess(new G4Mu PairProduction, -1, 3,3);104 pmanager->Add DiscreteProcess(new G4CoulombScattering);99 //muon 100 pmanager->AddDiscreteProcess(new G4CoulombScattering); 101 pmanager->AddProcess(new G4MuIonisation, -1, 1, 1); 102 pmanager->AddProcess(new G4MuBremsstrahlung, -1, 2, 2); 103 pmanager->AddProcess(new G4MuPairProduction, -1, 3, 3); 105 104 106 } else if (particleName == "alpha" || particleName == "He3") { 107 G4ionIonisation* ion = new G4ionIonisation(); 108 ion->SetStepFunction(0.1, um); 109 ion->ActivateNuclearStopping(false); 110 pmanager->AddProcess(ion, -1, 1,1); 111 pmanager->AddDiscreteProcess(new G4CoulombScattering); 112 113 } else if (particleName == "GenericIon" ) { 114 G4ionGasIonisation* ion = new G4ionGasIonisation(); 115 ion->ActivateNuclearStopping(false); 116 ion->SetStepFunction(0.1, um); 117 pmanager->AddProcess(ion, -1, 1,1); 118 G4CoulombScattering* cs = new G4CoulombScattering(); 119 cs->SetBuildTableFlag(false); 120 pmanager->AddDiscreteProcess(cs); 121 105 } else if (particleName == "alpha" || 106 particleName == "He3" || 107 particleName == "GenericIon") { 108 pmanager->AddDiscreteProcess(new G4CoulombScattering); 109 pmanager->AddProcess(new G4ionIonisation, -1, 1, 1); 110 122 111 } else if ((!particle->IsShortLived()) && 123 112 (particle->GetPDGCharge() != 0.0) && 124 113 (particle->GetParticleName() != "chargedgeantino")) { 125 114 //all others charged particles except geantino 126 G4hIonisation* hion = new G4hIonisation();127 hion->SetStepFunction(0.1, 10.*um);128 hion->ActivateNuclearStopping(false);129 pmanager->AddProcess(hion, -1,1,1);130 115 pmanager->AddDiscreteProcess(new G4CoulombScattering); 116 pmanager->AddProcess(new G4hIonisation, -1, 1, 1); 131 117 } 132 118 } 119 120 // Em options 121 // 122 // Main options and setting parameters are shown here. 123 // Several of them have default values. 124 // 125 G4EmProcessOptions emOptions; 126 127 //physics tables 128 // 129 emOptions.SetMinEnergy(100*eV); //default 130 emOptions.SetMaxEnergy(100*TeV); //default 131 emOptions.SetDEDXBinning(12*20); //default=12*7 132 emOptions.SetLambdaBinning(12*20); //default=12*7 133 emOptions.SetSplineFlag(true); //default 134 135 //energy loss 136 // 137 emOptions.SetStepFunction(0.2,50*um); //default=(0.2, 1*mm) 138 emOptions.SetLinearLossLimit(1.e-2); //default 139 140 //ionization 141 // 142 emOptions.SetSubCutoff(false); //default 133 143 } 134 144 -
trunk/examples/extended/electromagnetic/TestEm7/src/PhysicsList.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: PhysicsList.cc,v 1. 28 2008/01/14 12:11:39vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 1-patch-02$26 // $Id: PhysicsList.cc,v 1.36 2008/11/21 12:53:13 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 35 35 #include "PhysListEmStandard.hh" 36 36 #include "PhysListEmStandardSS.hh" 37 #include "PhysListEmStandardIG.hh"38 37 #include "PhysListEmStandardNR.hh" 39 38 #include "PhysListEmLivermore.hh" … … 42 41 #include "G4EmStandardPhysics_option1.hh" 43 42 #include "G4EmStandardPhysics_option2.hh" 43 #include "G4EmStandardPhysics_option3.hh" 44 45 #include "G4DecayPhysics.hh" 44 46 45 47 #include "G4HadronElasticPhysics.hh" … … 50 52 #include "G4IonBinaryCascadePhysics.hh" 51 53 52 #include "G4EmProcessOptions.hh"53 54 54 #include "G4LossTableManager.hh" 55 55 #include "G4UnitsTable.hh" … … 57 57 #include "G4ProcessManager.hh" 58 58 #include "G4Decay.hh" 59 60 #include "StepMax.hh" 61 62 #include "G4IonFluctuations.hh" 63 #include "G4IonParametrisedLossModel.hh" 59 64 60 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 79 84 80 85 // EM physics 81 emPhysicsList = new PhysListEmStandard(emName = "standard"); 82 86 emPhysicsList = new G4EmStandardPhysics(1); 87 emName = G4String("emstandard"); 88 89 // Deacy physics and all particles 90 decPhysicsList = new G4DecayPhysics(); 83 91 } 84 92 … … 89 97 delete pMessenger; 90 98 delete emPhysicsList; 91 for(size_t i=0; i<hadronPhys.size(); i++) delete hadronPhys[i]; 92 } 93 94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 95 96 // Bosons 97 #include "G4ChargedGeantino.hh" 98 #include "G4Geantino.hh" 99 #include "G4Gamma.hh" 100 101 // leptons 102 #include "G4MuonPlus.hh" 103 #include "G4MuonMinus.hh" 104 #include "G4NeutrinoMu.hh" 105 #include "G4AntiNeutrinoMu.hh" 106 107 #include "G4Electron.hh" 108 #include "G4Positron.hh" 109 #include "G4NeutrinoE.hh" 110 #include "G4AntiNeutrinoE.hh" 111 112 // Hadrons 113 #include "G4MesonConstructor.hh" 114 #include "G4BaryonConstructor.hh" 115 #include "G4IonConstructor.hh" 99 delete decPhysicsList; 100 for(size_t i=0; i<hadronPhys.size(); i++) {delete hadronPhys[i];} 101 } 116 102 117 103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 119 105 void PhysicsList::ConstructParticle() 120 106 { 121 // pseudo-particles 122 G4Geantino::GeantinoDefinition(); 123 G4ChargedGeantino::ChargedGeantinoDefinition(); 124 125 // gamma 126 G4Gamma::GammaDefinition(); 127 128 // leptons 129 G4Electron::ElectronDefinition(); 130 G4Positron::PositronDefinition(); 131 G4MuonPlus::MuonPlusDefinition(); 132 G4MuonMinus::MuonMinusDefinition(); 133 134 G4NeutrinoE::NeutrinoEDefinition(); 135 G4AntiNeutrinoE::AntiNeutrinoEDefinition(); 136 G4NeutrinoMu::NeutrinoMuDefinition(); 137 G4AntiNeutrinoMu::AntiNeutrinoMuDefinition(); 138 139 // mesons 140 G4MesonConstructor mConstructor; 141 mConstructor.ConstructParticle(); 142 143 // barions 144 G4BaryonConstructor bConstructor; 145 bConstructor.ConstructParticle(); 146 147 // ions 148 G4IonConstructor iConstructor; 149 iConstructor.ConstructParticle(); 150 } 151 152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 107 decPhysicsList->ConstructParticle(); 108 } 109 110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 111 153 112 void PhysicsList::ConstructProcess() 154 113 { … … 160 119 // 161 120 emPhysicsList->ConstructProcess(); 121 em_config.AddModels(); 122 123 // decay physics list 124 // 125 decPhysicsList->ConstructProcess(); 162 126 163 127 // hadronic physics lists 164 for(size_t i=0; i<hadronPhys.size(); i++) hadronPhys[i]->ConstructProcess(); 165 166 // decay process 167 // 168 G4Decay* fDecayProcess = new G4Decay(); 169 170 theParticleIterator->reset(); 171 while( (*theParticleIterator)() ){ 172 G4ParticleDefinition* particle = theParticleIterator->value(); 173 G4ProcessManager* pmanager = particle->GetProcessManager(); 174 175 if (fDecayProcess->IsApplicable(*particle) && !particle->IsShortLived()) { 176 177 pmanager ->AddProcess(fDecayProcess); 178 179 // set ordering for PostStepDoIt and AtRestDoIt 180 pmanager ->SetProcessOrdering(fDecayProcess, idxPostStep); 181 pmanager ->SetProcessOrdering(fDecayProcess, idxAtRest); 182 183 } 128 for(size_t i=0; i<hadronPhys.size(); i++) { 129 hadronPhys[i]->ConstructProcess(); 184 130 } 185 131 186 132 // step limitation (as a full process) 187 133 // 188 AddStepMax(); 189 190 G4EmProcessOptions opt; 191 opt.SetDEDXBinning(480); 134 AddStepMax(); 192 135 } 193 136 … … 196 139 void PhysicsList::AddPhysicsList(const G4String& name) 197 140 { 198 if (verboseLevel> -1) {141 if (verboseLevel>1) { 199 142 G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl; 200 143 } … … 202 145 if (name == emName) return; 203 146 204 if (name == "standard ") {147 if (name == "standard_local") { 205 148 206 149 emName = name; … … 212 155 emName = name; 213 156 delete emPhysicsList; 214 emPhysicsList = new G4EmStandardPhysics( );157 emPhysicsList = new G4EmStandardPhysics(1); 215 158 216 159 } else if (name == "emstandard_opt1") { … … 225 168 delete emPhysicsList; 226 169 emPhysicsList = new G4EmStandardPhysics_option2(); 170 171 } else if (name == "emstandard_opt3") { 172 173 emName = name; 174 delete emPhysicsList; 175 emPhysicsList = new G4EmStandardPhysics_option3(); 227 176 228 177 } else if (name == "standardSS") { … … 238 187 emPhysicsList = new PhysListEmStandardNR(name); 239 188 240 } else if (name == "standardIG") { 241 242 emName = name; 243 delete emPhysicsList; 244 emPhysicsList = new PhysListEmStandardIG(name); 189 } else if (name == "standardICRU73") { 190 191 emName = name; 192 delete emPhysicsList; 193 emPhysicsList = new PhysListEmStandard(name); 194 em_config.SetExtraEmModel("GenericIon","ionIoni", 195 new G4IonParametrisedLossModel(), 196 "",0.0, 100.0*TeV, 197 new G4IonFluctuations()); 198 G4cout << "standardICRU73" << G4endl; 245 199 246 200 } else if (name == "livermore") { … … 288 242 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 289 243 290 #include "StepMax.hh"291 292 244 void PhysicsList::AddStepMax() 293 245 { … … 297 249 theParticleIterator->reset(); 298 250 while ((*theParticleIterator)()){ 299 G4ParticleDefinition* particle = theParticleIterator->value();300 G4ProcessManager* pmanager = particle->GetProcessManager();301 302 if (stepMaxProcess->IsApplicable(*particle) && pmanager)303 {304 pmanager ->AddDiscreteProcess(stepMaxProcess);305 }251 G4ParticleDefinition* particle = theParticleIterator->value(); 252 G4ProcessManager* pmanager = particle->GetProcessManager(); 253 254 if (stepMaxProcess->IsApplicable(*particle) && pmanager) 255 { 256 pmanager ->AddDiscreteProcess(stepMaxProcess); 257 } 306 258 } 307 259 } -
trunk/examples/extended/electromagnetic/TestEm7/src/PhysicsListMessenger.cc
r807 r1230 25 25 // 26 26 // $Id: PhysicsListMessenger.cc,v 1.3 2006/06/29 16:58:37 gunter Exp $ 27 // GEANT4 tag $Name: $27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/PrimaryGeneratorAction.cc
r807 r1230 25 25 // 26 26 // $Id: PrimaryGeneratorAction.cc,v 1.2 2006/06/29 16:58:39 gunter Exp $ 27 // GEANT4 tag $Name: $27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/PrimaryGeneratorMessenger.cc
r807 r1230 25 25 // 26 26 // $Id: PrimaryGeneratorMessenger.cc,v 1.3 2006/06/29 16:58:41 gunter Exp $ 27 // GEANT4 tag $Name: $27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/RunAction.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: RunAction.cc,v 1.2 1 2008/01/14 12:11:39vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 1-patch-02$26 // $Id: RunAction.cc,v 1.24 2008/08/22 18:30:27 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 42 42 43 43 #include "Randomize.hh" 44 45 #ifdef G4ANALYSIS_USE 46 #include "AIDA/AIDA.h" 47 #endif 44 #include "Histo.hh" 48 45 49 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 51 48 RunAction::RunAction(DetectorConstruction* det, PhysicsList* phys, 52 49 PrimaryGeneratorAction* kin) 53 :detector(det), physics(phys), kinematic(kin) , af(0), tree(0)50 :detector(det), physics(phys), kinematic(kin) 54 51 { 55 52 tallyEdep = new G4double[MaxTally]; 56 53 binLength = offsetX = 0.; 57 histo[0] = 0; 58 59 #ifdef G4ANALYSIS_USE 60 // Creating the analysis factory 61 af = AIDA_createAnalysisFactory(); 62 if(!af) { 63 G4cout << "RunAction::RunAction() :" 64 << " problem creating the AIDA analysis factory." 65 << G4endl; 66 } 67 #endif 54 histo = new Histo(); 55 histo->setFileName("testem7"); 56 histo->add1D("1","Edep (MeV/mm) along absorber (mm)", 100, 0, 100); 57 histo->add1D("2","Edep (MeV/mm) along absorber zoomed (mm)", 100, 0, 100); 58 histo->add1D("3","Projectile range (mm)", 100, 0, 100); 68 59 } 69 60 … … 73 64 { 74 65 delete [] tallyEdep; 75 76 #ifdef G4ANALYSIS_USE 77 delete af; 78 #endif 79 } 80 81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 82 83 void RunAction::bookHisto() 84 { 85 length = detector->GetAbsorSizeX(); 86 G4double stepMax = physics->GetStepMaxProcess()->GetMaxStep(); 87 const G4int nbmin = 100; 88 G4int nbBins = (int)(0.5 + length/stepMax); 89 if (nbBins < nbmin) nbBins = nbmin; 90 binLength = length/nbBins; 91 offsetX = 0.5*length; 92 93 #ifdef G4ANALYSIS_USE 94 if (!af) return; 95 96 // Create a tree mapped to an hbook file. 97 G4bool readOnly = false; 98 G4bool createNew = true; 99 G4String options = "--noErrors uncompress"; 100 AIDA::ITreeFactory* tf = af->createTreeFactory(); 101 tree = tf->create("testem7.hbook","hbook", readOnly, createNew, options); 102 //tree = tf->create("testem7.root", "root",readOnly, createNew, options); 103 //tree = tf->create("testem7.XML" , "XML" ,readOnly, createNew, options); 104 delete tf; 105 if (!tree) { 106 G4cout << "RunAction::bookHisto()" << G4endl; 107 return; 108 } 109 110 // Create a histogram factory, whose histograms will be handled by the tree 111 AIDA::IHistogramFactory* hf = af->createHistogramFactory(*tree); 112 113 // Create histogram 114 histo[0] = hf->createHistogram1D("1","Edep (MeV/mm) along absorber (mm)", 115 nbBins, 0, length/mm); 116 117 delete hf; 118 G4cout << "\n----> Histogram Tree opened" << G4endl; 119 #endif 120 } 121 122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 123 124 void RunAction::cleanHisto() 125 { 126 #ifdef G4ANALYSIS_USE 127 tree->commit(); // Writing the histograms to the file 128 tree->close(); // and closing the tree (and the file) 129 delete tree; 130 tree = 0; 131 132 G4cout << "\n----> Histogram Tree saved" << G4endl; 133 #endif 66 delete histo; 134 67 } 135 68 … … 138 71 void RunAction::FillHisto(G4int ih, G4double x, G4double weight) 139 72 { 140 #ifdef G4ANALYSIS_USE 141 if(histo[ih]) histo[ih]->fill(x, weight); 142 #endif 73 histo->fill(ih, x, weight); 143 74 } 144 75 … … 156 87 // 157 88 nPrimarySteps = 0; 89 nRange = 0; 158 90 projRange = projRange2 = 0.; 159 91 edeptot = eniel = 0.; 160 92 for (G4int j=0; j<MaxTally; j++) tallyEdep[j] = 0.; 161 93 kinematic->ResetEbeamCumul(); 162 bookHisto(); 94 95 // define "1" histogram binning 96 length = detector->GetAbsorSizeX(); 97 G4double stepMax = physics->GetStepMaxProcess()->GetMaxStep(); 98 const G4int nbmin = 100; 99 G4int nbBins = (G4int)(0.5 + length/stepMax); 100 if (nbBins < nbmin) nbBins = nbmin; 101 binLength = length/nbBins; 102 offsetX = 0.5*length; 103 104 // histogram "1" is defined by the length of the target 105 // zoomed histograms are defined by UI command 106 histo->setHisto1D(0, nbBins, 0, length, mm); 107 108 histo->book(); 163 109 } 164 110 … … 186 132 //compute projected range and straggling 187 133 // 188 projRange /= NbofEvents; projRange2 /= NbofEvents; 134 if(nRange > 0) { 135 projRange /= nRange; 136 projRange2 /= nRange; 137 } 189 138 G4double rms = projRange2 - projRange*projRange; 190 139 if (rms>0.) rms = std::sqrt(rms); else rms = 0.; … … 227 176 } 228 177 229 #ifdef G4ANALYSIS_USE230 178 // normalize histogram 231 179 G4double fac = (mm/MeV)/(NbofEvents * binLength); 232 histo[0]->scale(fac); 233 #endif 234 180 for (G4int j=0; j<3; j++) {histo->scale(j, fac);} 235 181 236 182 // save and clean histo 237 cleanHisto();183 histo->save(); 238 184 239 185 // show Rndm status -
trunk/examples/extended/electromagnetic/TestEm7/src/StepMax.cc
r807 r1230 25 25 // 26 26 // $Id: StepMax.cc,v 1.5 2006/06/29 16:58:45 gunter Exp $ 27 // GEANT4 tag $Name: $27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/StepMaxMessenger.cc
r807 r1230 25 25 // 26 26 // $Id: StepMaxMessenger.cc,v 1.3 2006/06/29 16:58:47 gunter Exp $ 27 // GEANT4 tag $Name: $27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/SteppingAction.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: SteppingAction.cc,v 1.1 2 2008/01/14 12:11:39vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 1-patch-02$26 // $Id: SteppingAction.cc,v 1.14 2008/08/22 18:30:27 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 51 51 void SteppingAction::UserSteppingAction(const G4Step* aStep) 52 52 { 53 G4double edep = aStep->GetTotalEnergyDeposit();54 if (edep <= 0.) return;53 G4double edep = aStep->GetTotalEnergyDeposit(); 54 if (edep <= 0.) return; 55 55 56 // G4cout << "edep= " << edep << "NIEL= " << aStep->GetNonIonizingEnergyDeposit()<<G4endl;56 // G4cout << "edep= " << edep << "NIEL= " << aStep->GetNonIonizingEnergyDeposit()<<G4endl; 57 57 58 runAction->FillEdep(edep,aStep->GetNonIonizingEnergyDeposit());58 runAction->FillEdep(edep,aStep->GetNonIonizingEnergyDeposit()); 59 59 60 if(aStep->GetTrack()->GetTrackID() == 1) runAction->AddPrimaryStep();60 if(aStep->GetTrack()->GetTrackID() == 1) runAction->AddPrimaryStep(); 61 61 62 //Bragg curve63 //64 G4StepPoint* prePoint = aStep->GetPreStepPoint();65 G4StepPoint* postPoint = aStep->GetPostStepPoint();62 //Bragg curve 63 // 64 G4StepPoint* prePoint = aStep->GetPreStepPoint(); 65 G4StepPoint* postPoint = aStep->GetPostStepPoint(); 66 66 67 G4double x1 = prePoint->GetPosition().x(), x2 = postPoint->GetPosition().x(); 68 G4double x = runAction->GetOffsetX() + x1 + G4UniformRand()*(x2-x1); 69 runAction->FillHisto(0, x/mm , edep); 67 G4double x1 = prePoint->GetPosition().x(), x2 = postPoint->GetPosition().x(); 68 G4double x = runAction->GetOffsetX() + x1 + G4UniformRand()*(x2-x1); 69 runAction->FillHisto(0, x/mm , edep); 70 runAction->FillHisto(1, x/mm , edep); 70 71 71 //fill tallies72 //73 G4TouchableHandle touchable = prePoint->GetTouchableHandle();74 G4LogicalVolume* lVolume = touchable->GetVolume()->GetLogicalVolume();75 if (lVolume == detector->GetLogicalTally())76 runAction->FillTallyEdep(touchable->GetCopyNumber(), edep);72 //fill tallies 73 // 74 G4TouchableHandle touchable = prePoint->GetTouchableHandle(); 75 G4LogicalVolume* lVolume = touchable->GetVolume()->GetLogicalVolume(); 76 if (lVolume == detector->GetLogicalTally()) 77 runAction->FillTallyEdep(touchable->GetCopyNumber(), edep); 77 78 } 78 79 -
trunk/examples/extended/electromagnetic/TestEm7/src/SteppingVerbose.cc
r807 r1230 25 25 // 26 26 // $Id: SteppingVerbose.cc,v 1.3 2006/06/29 16:58:51 gunter Exp $ 27 // GEANT4 tag $Name: $27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -
trunk/examples/extended/electromagnetic/TestEm7/src/TrackingAction.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: TrackingAction.cc,v 1. 3 2006/11/22 17:58:11vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 1-patch-02$26 // $Id: TrackingAction.cc,v 1.5 2008/08/22 18:30:27 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 28 28 // 29 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... … … 50 50 G4double x = aTrack->GetPosition().x() + runAction->GetOffsetX(); 51 51 if(x > runAction->GetLength()) x = runAction->GetLength(); 52 runAction->AddProjRange(x); 52 //G4cout << " range= " << x << " x= " << aTrack->GetPosition().x() 53 // << " ofset= " << runAction->GetOffsetX() << G4endl; 54 if(x > 0.0) runAction->AddProjRange(x); 55 runAction->FillHisto(2, x/mm, 1.0); 53 56 } 54 57 }
Note:
See TracChangeset
for help on using the changeset viewer.
