Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
@@ -26,54 +26,49 @@
// G4PionRadiativeDecayChannel class implementation
// GEANT 4 class header file
//
// Author: P.Gumplinger, 30 July 2007
// Author: P.Gumplinger, 30 July 2007
// Reference: M. Blecher, TRIUMF/PIENU Technote
// "Inclusion of pi->enug in the Monte Carlo"
// "Inclusion of pi->enug in the Monte Carlo"
// --------------------------------------------------------------------
#include "G4PionRadiativeDecayChannel.hh"
#include "G4DecayProducts.hh"
#include "G4LorentzVector.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
#include "G4DecayProducts.hh"
#include "G4LorentzVector.hh"
namespace
{
const G4double beta = 3.6612e-03;
const G4double cib = 1.16141e-03;
const G4double csdp = 3.45055e-02;
const G4double csdm = 5.14122e-03;
const G4double cif = 4.63543e-05;
const G4double cig = 1.78928e-05;
const G4double xl = 2.*0.1*MeV/139.57*MeV;
const G4double yl = ((1.-xl) + std::sqrt((1-xl)*(1-xl)+4*beta*beta))/2.;
const G4double beta = 3.6612e-03;
const G4double cib = 1.16141e-03;
const G4double csdp = 3.45055e-02;
const G4double csdm = 5.14122e-03;
const G4double cif = 4.63543e-05;
const G4double cig = 1.78928e-05;
const G4double xl = 2. * 0.1 * MeV / 139.57 * MeV;
const G4double yl = ((1. - xl) + std::sqrt((1 - xl) * (1 - xl) + 4 * beta * beta)) / 2.;
const G4double xu = 1. - (yl - std::sqrt(yl*yl-4.*beta*beta))/2.;
const G4double yu = 1. + beta*beta;
const G4double xu = 1. - (yl - std::sqrt(yl * yl - 4. * beta * beta)) / 2.;
const G4double yu = 1. + beta * beta;
inline G4double D2W(const G4double x,const G4double y)
{
return cib*(1.-y)*(1.+((1.-x)*(1.-x)))/((x*x)*(x+y-1.)) +
csdp*(1.-x)*((x+y-1.)*(x+y-1.)) +
csdm*(1.-x)*((1.-y)*(1.-y)) +
cif*(x-1.)*(1.-y)/x +
cig*(1.-y)*(1.-x+(x*x)/(x+y-1.))/x;
}
const G4double d2wmax = D2W(xl,yl);
inline G4double D2W(const G4double x, const G4double y)
{
return cib * (1. - y) * (1. + ((1. - x) * (1. - x))) / ((x * x) * (x + y - 1.))
+ csdp * (1. - x) * ((x + y - 1.) * (x + y - 1.)) + csdm * (1. - x) * ((1. - y) * (1. - y))
+ cif * (x - 1.) * (1. - y) / x + cig * (1. - y) * (1. - x + (x * x) / (x + y - 1.)) / x;
}
// --------------------------------------------------------------------
G4PionRadiativeDecayChannel::
G4PionRadiativeDecayChannel(const G4String& theParentName,
G4double theBR)
const G4double d2wmax = D2W(xl, yl);
} // namespace
G4PionRadiativeDecayChannel::G4PionRadiativeDecayChannel(const G4String& theParentName,
G4double theBR)
: G4VDecayChannel("Radiative Pion Decay", 1)
{
// set names for daughter particles
if (theParentName == "pi+")
{
if (theParentName == "pi+") {
SetBR(theBR);
SetParent("pi+");
SetNumberOfDaughters(3);
@@ -81,8 +76,7 @@ G4PionRadiativeDecayChannel(const G4String& theParentName,
SetDaughter(1, "gamma");
SetDaughter(2, "nu_e");
}
else if (theParentName == "pi-")
{
else if (theParentName == "pi-") {
SetBR(theBR);
SetParent("pi-");
SetNumberOfDaughters(3);
@@ -90,13 +84,10 @@ G4PionRadiativeDecayChannel(const G4String& theParentName,
SetDaughter(1, "gamma");
SetDaughter(2, "anti_nu_e");
}
else
{
else {
#ifdef G4VERBOSE
if (GetVerboseLevel()>0)
{
G4cout << "G4RadiativePionDecayChannel::G4PionRadiativeDecayChannel()"
<< G4endl;
if (GetVerboseLevel() > 0) {
G4cout << "G4RadiativePionDecayChannel::G4PionRadiativeDecayChannel()" << G4endl;
G4cout << "Parent particle is not charged pion: ";
G4cout << theParentName << G4endl;
}
@@ -107,8 +98,7 @@ G4PionRadiativeDecayChannel(const G4String& theParentName,
G4PionRadiativeDecayChannel&
G4PionRadiativeDecayChannel::operator=(const G4PionRadiativeDecayChannel& right)
{
if (this != &right)
{
if (this != &right) {
kinematics_name = right.kinematics_name;
verboseLevel = right.verboseLevel;
rbranch = right.rbranch;
@@ -121,13 +111,11 @@ G4PionRadiativeDecayChannel::operator=(const G4PionRadiativeDecayChannel& right)
// recreate array
numberOfDaughters = right.numberOfDaughters;
if ( numberOfDaughters >0 )
{
if (numberOfDaughters > 0) {
if (daughters_name != nullptr) ClearDaughtersName();
daughters_name = new G4String*[numberOfDaughters];
//copy daughters name
for (G4int index=0; index<numberOfDaughters; ++index)
{
// copy daughters name
for (G4int index = 0; index < numberOfDaughters; ++index) {
daughters_name[index] = new G4String(*right.daughters_name[index]);
}
}
@@ -135,13 +123,10 @@ G4PionRadiativeDecayChannel::operator=(const G4PionRadiativeDecayChannel& right)
return *this;
}
// --------------------------------------------------------------------
G4DecayProducts* G4PionRadiativeDecayChannel::DecayIt(G4double)
G4DecayProducts* G4PionRadiativeDecayChannel::DecayIt(G4double)
{
#ifdef G4VERBOSE
if (GetVerboseLevel()>1)
G4cout << "G4PionRadiativeDecayChannel::DecayIt ";
if (GetVerboseLevel() > 1) G4cout << "G4PionRadiativeDecayChannel::DecayIt ";
#endif
CheckAndFillParent();
@@ -153,103 +138,98 @@ G4DecayProducts* G4PionRadiativeDecayChannel::DecayIt(G4double)
G4double EMPI = parentmass;
// daughters'mass
const G4int N_DAUGHTER=3;
G4double daughtermass[N_DAUGHTER];
//G4double sumofdaughtermass = 0.0;
for (G4int index=0; index<N_DAUGHTER; ++index)
{
const G4int N_DAUGHTER = 3;
G4double daughtermass[N_DAUGHTER];
// G4double sumofdaughtermass = 0.0;
for (G4int index = 0; index < N_DAUGHTER; ++index) {
daughtermass[index] = G4MT_daughters[index]->GetPDGMass();
//sumofdaughtermass += daughtermass[index];
// sumofdaughtermass += daughtermass[index];
}
G4double EMASS = daughtermass[0];
// create parent G4DynamicParticle at rest
G4ThreeVector dummy;
auto parentparticle
= new G4DynamicParticle( G4MT_parent, dummy, 0.0);
auto parentparticle = new G4DynamicParticle(G4MT_parent, dummy, 0.0);
// create G4Decayproducts
auto products = new G4DecayProducts(*parentparticle);
delete parentparticle;
G4double x, y;
const std::size_t MAX_LOOP=1000;
const std::size_t MAX_LOOP = 1000;
for (std::size_t loop_counter1=0; loop_counter1<MAX_LOOP; ++loop_counter1)
{
for (std::size_t loop_counter2=0; loop_counter2<MAX_LOOP; ++loop_counter2)
{
x = xl + G4UniformRand()*(xu-xl);
y = yl + G4UniformRand()*(yu-yl);
if (x+y > 1.) break;
for (std::size_t loop_counter1 = 0; loop_counter1 < MAX_LOOP; ++loop_counter1) {
for (std::size_t loop_counter2 = 0; loop_counter2 < MAX_LOOP; ++loop_counter2) {
x = xl + G4UniformRand() * (xu - xl);
y = yl + G4UniformRand() * (yu - yl);
if (x + y > 1.) break;
}
G4double d2w = D2W(x,y);
if (d2w > G4UniformRand()*d2wmax) break;
G4double d2w = D2W(x, y);
if (d2w > G4UniformRand() * d2wmax) break;
}
// Calculate the angle between positron and photon (cosine)
//
G4double cthetaGE = (y*(x-2.)+2.*(1.-x+beta*beta)) /
(x*std::sqrt(y*y-4.*beta*beta));
G4double cthetaGE =
(y * (x - 2.) + 2. * (1. - x + beta * beta)) / (x * std::sqrt(y * y - 4. * beta * beta));
G4double G = x * EMPI/2.;
G4double E = y * EMPI/2.;
G4double G = x * EMPI / 2.;
G4double E = y * EMPI / 2.;
if (E < EMASS) E = EMASS;
// calculate daughter momentum
G4double daughtermomentum[2];
daughtermomentum[0] = std::sqrt(E*E - EMASS*EMASS);
daughtermomentum[0] = std::sqrt(E * E - EMASS * EMASS);
G4double cthetaE = 2.*G4UniformRand()-1.;
G4double sthetaE = std::sqrt(1.-cthetaE*cthetaE);
G4double cthetaE = 2. * G4UniformRand() - 1.;
G4double sthetaE = std::sqrt(1. - cthetaE * cthetaE);
G4double phiE = twopi*G4UniformRand()*rad;
G4double phiE = twopi * G4UniformRand() * rad;
G4double cphiE = std::cos(phiE);
G4double sphiE = std::sin(phiE);
// Coordinates of the decay positron
//
G4double px = sthetaE*cphiE;
G4double py = sthetaE*sphiE;
G4double px = sthetaE * cphiE;
G4double py = sthetaE * sphiE;
G4double pz = cthetaE;
G4ThreeVector direction0(px,py,pz);
G4ThreeVector direction0(px, py, pz);
auto daughterparticle0
= new G4DynamicParticle(G4MT_daughters[0], daughtermomentum[0]*direction0);
auto daughterparticle0 =
new G4DynamicParticle(G4MT_daughters[0], daughtermomentum[0] * direction0);
products->PushProducts(daughterparticle0);
daughtermomentum[1] = G;
G4double sthetaGE = std::sqrt(1.-cthetaGE*cthetaGE);
G4double sthetaGE = std::sqrt(1. - cthetaGE * cthetaGE);
G4double phiGE = twopi*G4UniformRand()*rad;
G4double phiGE = twopi * G4UniformRand() * rad;
G4double cphiGE = std::cos(phiGE);
G4double sphiGE = std::sin(phiGE);
// Coordinates of the decay gamma with respect to the decay positron
//
px = sthetaGE*cphiGE;
py = sthetaGE*sphiGE;
px = sthetaGE * cphiGE;
py = sthetaGE * sphiGE;
pz = cthetaGE;
G4ThreeVector direction1(px,py,pz);
G4ThreeVector direction1(px, py, pz);
direction1.rotateUz(direction0);
auto daughterparticle1
= new G4DynamicParticle(G4MT_daughters[1], daughtermomentum[1]*direction1);
auto daughterparticle1 =
new G4DynamicParticle(G4MT_daughters[1], daughtermomentum[1] * direction1);
products->PushProducts(daughterparticle1);
// output message
#ifdef G4VERBOSE
if (GetVerboseLevel()>1)
{
if (GetVerboseLevel() > 1) {
G4cout << "G4PionRadiativeDecayChannel::DecayIt() -";
G4cout << " create decay products in rest frame " << G4endl;
products->DumpInfo();