288{
289
290
292 G4double g4d_limit = std::pow(10.,-g4d_order);
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
309
310 if (verboseLevel > 3) {
311 G4cout <<
"G4LowEPPolarizedComptonModel::SampleSecondaries() E(MeV)= "
314 }
315
316
318 return ;
319
320 G4double e0m = photonEnergy0 / electron_mass_c2 ;
322
323
324
325
327
328
329 if (!(photonPolarization0.
isOrthogonal(photonDirection0, 1e-6))||(photonPolarization0.
mag()==0))
330 {
331 photonPolarization0 = GetRandomPolarization(photonDirection0);
332 }
333 else
334 {
335 if ((photonPolarization0.
howOrthogonal(photonDirection0) !=0) && (photonPolarization0.
howOrthogonal(photonDirection0) > g4d_limit))
336 {
337 photonPolarization0 = GetPerpendicularPolarization(photonDirection0,photonPolarization0);
338 }
339 }
340
341
345
346 G4double LowEPPCepsilon0 = 1. / (1. + 2. * e0m);
347 G4double LowEPPCepsilon0Sq = LowEPPCepsilon0 * LowEPPCepsilon0;
348 G4double alpha1 = -std::log(LowEPPCepsilon0);
350
351 G4double wlPhoton = h_Planck*c_light/photonEnergy0;
352
353
359
360 if (verboseLevel > 3) {
361 G4cout <<
"Started loop to sample gamma energy" <<
G4endl;
362 }
363
364 do
365 {
367 {
369 LowEPPCepsilonSq = LowEPPCepsilon * LowEPPCepsilon;
370 }
371 else
372 {
373 LowEPPCepsilonSq = LowEPPCepsilon0Sq + (1. - LowEPPCepsilon0Sq) *
G4UniformRand();
374 LowEPPCepsilon = std::sqrt(LowEPPCepsilonSq);
375 }
376
377 oneCosT = (1. - LowEPPCepsilon) / ( LowEPPCepsilon * e0m);
378 sinT2 = oneCosT * (2. - oneCosT);
379 G4double x = std::sqrt(oneCosT/2.) / (wlPhoton/cm);
380 G4double scatteringFunction = ComputeScatteringFunction(x,
Z);
381 gReject = (1. - LowEPPCepsilon * sinT2 / (1. + LowEPPCepsilonSq)) * scatteringFunction;
382
384
386 G4double sinTheta = std::sqrt(sinT2);
387 G4double phi = SetPhi(LowEPPCepsilon,sinT2);
388 G4double dirx = sinTheta * std::cos(phi);
389 G4double diry = sinTheta * std::sin(phi);
391
392
393
394 G4ThreeVector photonPolarization1 = SetNewPolarization(LowEPPCepsilon,
395 sinT2,
396 phi,
397 cosTheta);
398
399
400
401
402
403
404
405 const G4double vel_c = c_light / (m/s);
406 const G4double momentum_au_to_nat = halfpi* hbar_Planck / Bohr_radius / (kg*m/s);
407 const G4double e_mass_kg = electron_mass_c2 / c_squared / kg ;
408
409 const G4int maxDopplerIterations = 1000;
411 G4double pEIncident = photonEnergy0 ;
416
425
426 if (verboseLevel > 3) {
427 G4cout <<
"Started loop to sample photon energy and electron direction" <<
G4endl;
428 }
429
430 do{
431
432
433
434 do
435 {
436 iteration++;
437
438
439
440
441
442
445
446
448
449
450 G4double ePSI = ePAU * momentum_au_to_nat;
451
452
453 u_temp = sqrt( ((ePSI*ePSI)*(vel_c*vel_c)) / ((e_mass_kg*e_mass_kg)*(vel_c*vel_c)+(ePSI*ePSI)) )/vel_c;
454
455
458
459
460 G4double eEIncident = electron_mass_c2 / sqrt( 1 - (u_temp*u_temp));
461 G4double systemE = eEIncident + pEIncident;
462
463 G4double gamma_temp = 1.0 / sqrt( 1 - (u_temp*u_temp));
464 G4double numerator = gamma_temp*electron_mass_c2*(1 - u_temp * std::cos(e_alpha));
465 G4double subdenom1 = u_temp*cosTheta*std::cos(e_alpha);
466 G4double subdenom2 = u_temp*sinTheta*std::sin(e_alpha)*std::cos(e_beta);
467 G4double denominator = (1.0 - cosTheta) + (gamma_temp*electron_mass_c2*(1 - subdenom1 - subdenom2) / pEIncident);
468 pERecoil = (numerator/denominator);
469 eERecoil = systemE - pERecoil;
470 CE_emission_flag = pEIncident - pERecoil;
471 } while ( (iteration <= maxDopplerIterations) && (CE_emission_flag < bindingE));
472
473
474
475
476
477
478
479
480 G4double a_temp = eERecoil / electron_mass_c2;
481 G4double u_p_temp = sqrt(1 - (1 / (a_temp*a_temp)));
482
483
484 G4double sinAlpha = std::sin(e_alpha);
485 G4double cosAlpha = std::cos(e_alpha);
486 G4double sinBeta = std::sin(e_beta);
487 G4double cosBeta = std::cos(e_beta);
488
489 G4double gamma = 1.0 / sqrt(1 - (u_temp*u_temp));
490 G4double gamma_p = 1.0 / sqrt(1 - (u_p_temp*u_p_temp));
491
492 G4double var_A = pERecoil*u_p_temp*sinTheta;
493 G4double var_B = u_p_temp* (pERecoil*cosTheta-pEIncident);
494 G4double var_C = (pERecoil-pEIncident) - ( (pERecoil*pEIncident) / (gamma_p*electron_mass_c2))*(1 - cosTheta);
495
496 G4double var_D1 = gamma*electron_mass_c2*pERecoil;
497 G4double var_D2 = (1 - (u_temp*cosTheta*cosAlpha) - (u_temp*sinTheta*cosBeta*sinAlpha));
498 G4double var_D3 = ((electron_mass_c2*electron_mass_c2)*(gamma*gamma_p - 1)) - (gamma_p*electron_mass_c2*pERecoil);
499 G4double var_D = var_D1*var_D2 + var_D3;
500
501 G4double var_E1 = ((gamma*gamma_p)*(electron_mass_c2*electron_mass_c2)*(u_temp*u_p_temp)*cosAlpha);
502 G4double var_E2 = gamma_p*electron_mass_c2*pERecoil*u_p_temp*cosTheta;
504
505 G4double var_F1 = ((gamma*gamma_p)*(electron_mass_c2*electron_mass_c2)*(u_temp*u_p_temp)*cosBeta*sinAlpha);
506 G4double var_F2 = (gamma_p*electron_mass_c2*pERecoil*u_p_temp*sinTheta);
508
509 G4double var_G = (gamma*gamma_p)*(electron_mass_c2*electron_mass_c2)*(u_temp*u_p_temp)*sinBeta*sinAlpha;
510
511
512
513 G4double var_W1 = (var_F*var_B - var_E*var_A)*(var_F*var_B - var_E*var_A);
514 G4double var_W2 = (var_G*var_G)*(var_A*var_A) + (var_G*var_G)*(var_B*var_B);
516
517 G4double var_Y = 2.0*(((var_A*var_D-var_F*var_C)*(var_F*var_B-var_E*var_A)) - ((var_G*var_G)*var_B*var_C));
518
519 G4double var_Z1 = (var_A*var_D - var_F*var_C)*(var_A*var_D - var_F*var_C);
520 G4double var_Z2 = (var_G*var_G)*(var_C*var_C) - (var_G*var_G)*(var_A*var_A);
525
526
527
528
529
530 if ((diff < 0.0) && (abs(diff / diff1) < g4d_limit) && (abs(diff / diff2) < g4d_limit) )
531 {
532 diff = 0.0;
533 }
534
535
536 G4double X_p = (-var_Y + sqrt (diff))/(2*var_W);
537 G4double X_m = (-var_Y - sqrt (diff))/(2*var_W);
538
539
540
541
542 if(X_p >1){X_p=1;} if(X_p<-1){X_p=-1;}
543 if(X_m >1){X_m=1;} if(X_m<-1){X_m=-1;}
544
545
547
548
550
551 if (sol_select < 0.5)
552 {
553 ThetaE = std::acos(X_p);
554 }
555 if (sol_select > 0.5)
556 {
557 ThetaE = std::acos(X_m);
558 }
559
560 cosThetaE = std::cos(ThetaE);
561 sinThetaE = std::sin(ThetaE);
562 G4double Theta = std::acos(cosTheta);
563
564
565 G4double iSinThetaE = std::sqrt(1+std::tan((pi/2.0)-ThetaE)*std::tan((pi/2.0)-ThetaE));
566 G4double iSinTheta = std::sqrt(1+std::tan((pi/2.0)-Theta)*std::tan((pi/2.0)-Theta));
567 G4double ivar_A = iSinTheta/ (pERecoil*u_p_temp);
568
569 cosPhiE = (var_C - var_B*cosThetaE)*(ivar_A*iSinThetaE);
570
571
572 } while ( (iteration <= maxDopplerIterations) && (abs(cosPhiE) > 1));
573
574
575 if (iteration >= maxDopplerIterations)
576 {
577 pERecoil = photonEnergy0 ;
578 bindingE = 0.;
579 dirx=0.0;
580 diry=0.0;
581 dirz=1.0;
582 }
583
584
586 SystemOfRefChange(photonDirection0,photonDirection1,
587 photonPolarization0,photonPolarization1);
588
589 if (pERecoil > 0.)
590 {
594
595
597 G4double eDirX = sinThetaE * std::cos(phi+PhiE);
598 G4double eDirY = sinThetaE * std::sin(phi+PhiE);
600
601 G4double eKineticEnergy = pEIncident - pERecoil - bindingE;
602
604 SystemOfRefChangeElect(photonDirection0,eDirection,
605 photonPolarization0);
606
608 eDirection,eKineticEnergy) ;
609 fvect->push_back(dp);
610 }
611 else
612 {
615 }
616
617
618
619 if (verboseLevel > 3) {
620 G4cout <<
"Started atomic de-excitation " << fAtomDeexcitation <<
G4endl;
621 }
622
623 if(fAtomDeexcitation && iteration < maxDopplerIterations) {
626 std::size_t nbefore = fvect->size();
630 std::size_t nafter = fvect->size();
631 if(nafter > nbefore) {
632 for (std::size_t i=nbefore; i<nafter; ++i) {
633
634 if (bindingE >= ((*fvect)[i])->GetKineticEnergy())
635 {
636
637 bindingE -= ((*fvect)[i])->GetKineticEnergy();
638 }
639 else
640 {
641
642
643 delete (*fvect)[i];
644 (*fvect)[i]=nullptr;
645 }
646 }
647 }
648 }
649 }
650
651
652 if(bindingE < 0.0)
653 G4Exception(
"G4LowEPPolarizedComptonModel::SampleSecondaries()",
655
657}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
bool isOrthogonal(const Hep3Vector &v, double epsilon=tolerance) const
double howOrthogonal(const Hep3Vector &v) const
G4double RandomSelectMomentum(G4int Z, G4int shellIndex) const
const G4ThreeVector & GetMomentumDirection() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4ThreeVector & GetPolarization() const
static G4Electron * Electron()
const G4String & GetName() const
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void ProposePolarization(const G4ThreeVector &dir)
void ProposeMomentumDirection(const G4ThreeVector &Pfinal)
G4double BindingEnergy(G4int Z, G4int shellIndex) const
G4int SelectRandomShell(G4int Z) const
G4bool CheckDeexcitationActiveRegion(G4int coupleIndex)
virtual const G4AtomicShell * GetAtomicShell(G4int Z, G4AtomicShellEnumerator shell)=0
void GenerateParticles(std::vector< G4DynamicParticle * > *secVect, const G4AtomicShell *, G4int Z, G4int coupleIndex)
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)