Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
@@ -30,26 +30,26 @@
//
// ---------------- GFlashHitMaker ----------------
//
// Authors: E.Barberio & Joanna Weng
// Authors: E.Barberio & Joanna Weng
// ------------------------------------------------------------
#include "G4ios.hh"
#include "G4TransportationManager.hh"
#include "G4VSensitiveDetector.hh"
#include "G4TouchableHandle.hh"
#include "G4VGFlashSensitiveDetector.hh"
#include "GFlashHitMaker.hh"
#include "G4GFlashSpot.hh"
#include "G4Step.hh"
#include "G4StepPoint.hh"
#include "G4TouchableHandle.hh"
#include "G4TransportationManager.hh"
#include "G4VGFlashSensitiveDetector.hh"
#include "G4VSensitiveDetector.hh"
#include "G4ios.hh"
GFlashHitMaker::GFlashHitMaker()
{
fTouchableHandle = new G4TouchableHistory(); // talk to ?@@@
fpNavigator = new G4Navigator();
fNaviSetup = false;
fWorldWithSdName = "";
fTouchableHandle = new G4TouchableHistory(); // talk to ?@@@
fpNavigator = new G4Navigator();
fNaviSetup = false;
fWorldWithSdName = "";
fpSpotS = new G4Step();
fpSpotP = new G4StepPoint();
// N.B. Pre and Post step points are common.
@@ -66,52 +66,49 @@ GFlashHitMaker::~GFlashHitMaker()
delete fpSpotS;
}
void GFlashHitMaker::make(GFlashEnergySpot * aSpot, const G4FastTrack * aT)
void GFlashHitMaker::make(GFlashEnergySpot* aSpot, const G4FastTrack* aT)
{
// Locate the spot
if (!fNaviSetup)
{
// Choose the world volume that contains the sensitive detector based on its name (empty name for mass geometry)
if (!fNaviSetup) {
// Choose the world volume that contains the sensitive detector based on its name (empty name
// for mass geometry)
G4VPhysicalVolume* worldWithSD = nullptr;
if(fWorldWithSdName.empty()) {
worldWithSD = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
} else {
worldWithSD = G4TransportationManager::GetTransportationManager()->GetParallelWorld(fWorldWithSdName);
if (fWorldWithSdName.empty()) {
worldWithSD = G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking()
->GetWorldVolume();
}
else {
worldWithSD =
G4TransportationManager::GetTransportationManager()->GetParallelWorld(fWorldWithSdName);
}
fpNavigator->SetWorldVolume(worldWithSD);
fpNavigator->
LocateGlobalPointAndUpdateTouchable(aSpot->GetPosition(),
fTouchableHandle(), false);
fpNavigator->LocateGlobalPointAndUpdateTouchable(aSpot->GetPosition(), fTouchableHandle(),
false);
fNaviSetup = true;
}
else
{
fpNavigator->
LocateGlobalPointAndUpdateTouchable(aSpot->GetPosition(),
fTouchableHandle());
else {
fpNavigator->LocateGlobalPointAndUpdateTouchable(aSpot->GetPosition(), fTouchableHandle());
}
//--------------------------------------
// Produce Hits
// call sensitive part: taken/adapted from the stepping:
// Send G4Step information to Hit/Dig if the volume is sensitive
//--------------G4TouchableHistory----------------------------------------
G4VPhysicalVolume* pCurrentVolume = fTouchableHandle()->GetVolume();
G4VPhysicalVolume* pCurrentVolume = fTouchableHandle()->GetVolume();
G4VSensitiveDetector* pSensitive;
if( pCurrentVolume != 0 )
{
if (pCurrentVolume != 0) {
pSensitive = pCurrentVolume->GetLogicalVolume()->GetSensitiveDetector();
G4VGFlashSensitiveDetector * gflashSensitive =
dynamic_cast<G4VGFlashSensitiveDetector * > (pSensitive);
if( gflashSensitive )
{
G4VGFlashSensitiveDetector* gflashSensitive =
dynamic_cast<G4VGFlashSensitiveDetector*>(pSensitive);
if (gflashSensitive) {
// set spot information:
G4GFlashSpot theSpot(aSpot, aT, fTouchableHandle);
gflashSensitive->Hit(&theSpot);
}
else if( pSensitive )
{
else if (pSensitive) {
fpSpotS->SetTotalEnergyDeposit(aSpot->GetEnergy());
fpSpotS->SetTrack(const_cast<G4Track*>(aT->GetPrimaryTrack()));
fpSpotP->SetWeight(aT->GetPrimaryTrack()->GetWeight());
@@ -125,10 +122,9 @@ void GFlashHitMaker::make(GFlashEnergySpot * aSpot, const G4FastTrack * aT)
pSensitive->Hit(fpSpotS);
}
}
else
{
#ifdef GFLASH_DEBUG
G4cout << "GFlashHitMaker::Out of volume "<< G4endl;
#endif
else {
#ifdef GFLASH_DEBUG
G4cout << "GFlashHitMaker::Out of volume " << G4endl;
#endif
}
}
@@ -44,18 +44,26 @@
#include "G4Material.hh"
#include "G4MaterialTable.hh"
GFlashHomoShowerParameterisation::
GFlashHomoShowerParameterisation(G4Material * aMat,
GVFlashHomoShowerTuning * aPar)
GFlashHomoShowerParameterisation::GFlashHomoShowerParameterisation(G4Material* aMat,
GVFlashHomoShowerTuning* aPar)
: GVFlashShowerParameterisation(),
ConstantResolution(0.), NoiseResolution(0.), SamplingResolution(0.),
AveLogAlphah(0.), AveLogTmaxh(0.), SigmaLogAlphah(0.), SigmaLogTmaxh(0.),
Rhoh(0.), Alphah(0.), Tmaxh(0.), Betah(0.)
ConstantResolution(0.),
NoiseResolution(0.),
SamplingResolution(0.),
AveLogAlphah(0.),
AveLogTmaxh(0.),
SigmaLogAlphah(0.),
SigmaLogTmaxh(0.),
Rhoh(0.),
Alphah(0.),
Tmaxh(0.),
Betah(0.)
{
if(!aPar) {
{
if (!aPar) {
thePar = new GVFlashHomoShowerTuning;
} else {
}
else {
thePar = aPar;
}
@@ -64,91 +72,94 @@ GFlashHomoShowerParameterisation(G4Material * aMat,
/********************************************/
/* Homo Calorimeter */
/********************************************/
/********************************************/
// Longitudinal Coefficients for a homogenious calo
// shower max
//
ParAveT1 = thePar->ParAveT1(); // ln (ln y -0.812)
ParAveA1 = thePar->ParAveA1(); // ln a (0.81 + (0.458 + 2.26/Z)ln y)
ParAveA2 = thePar->ParAveA2();
ParAveA3 = thePar->ParAveA3();
ParAveT1 = thePar->ParAveT1(); // ln (ln y -0.812)
ParAveA1 = thePar->ParAveA1(); // ln a (0.81 + (0.458 + 2.26/Z)ln y)
ParAveA2 = thePar->ParAveA2();
ParAveA3 = thePar->ParAveA3();
// Variance of shower max
ParSigLogT1 = thePar->ParSigLogT1(); // Sigma T1 (-1.4 + 1.26 ln y)**-1
ParSigLogT1 = thePar->ParSigLogT1(); // Sigma T1 (-1.4 + 1.26 ln y)**-1
ParSigLogT2 = thePar->ParSigLogT2();
// variance of 'alpha'
//
ParSigLogA1 = thePar->ParSigLogA1(); // Sigma a (-0.58 + 0.86 ln y)**-1
ParSigLogA1 = thePar->ParSigLogA1(); // Sigma a (-0.58 + 0.86 ln y)**-1
ParSigLogA2 = thePar->ParSigLogA2();
// correlation alpha%T
//
ParRho1 = thePar->ParRho1(); // Rho = 0.705 -0.023 ln y
ParRho2 = thePar->ParRho2();
ParRho1 = thePar->ParRho1(); // Rho = 0.705 -0.023 ln y
ParRho2 = thePar->ParRho2();
// Radial Coefficients
// r_C (tau)= z_1 +z_2 tau
// r_t (tau)= k1 (std::exp (k3(tau -k2 ))+std::exp (k_4 (tau- k_2))))
//
ParRC1 = thePar->ParRC1(); // z_1 = 0.0251 + 0.00319 ln E
ParRC2 = thePar->ParRC2();
ParRC1 = thePar->ParRC1(); // z_1 = 0.0251 + 0.00319 ln E
ParRC2 = thePar->ParRC2();
ParRC3 = thePar->ParRC3(); // z_2 = 0.1162 + - 0.000381 Z
ParRC4 = thePar->ParRC4();
ParRC3 = thePar->ParRC3(); // z_2 = 0.1162 + - 0.000381 Z
ParRC4 = thePar->ParRC4();
ParWC1 = thePar->ParWC1();
ParWC2 = thePar->ParWC2();
ParWC3 = thePar->ParWC3();
ParWC4 = thePar->ParWC4();
ParWC5 = thePar->ParWC5();
ParWC5 = thePar->ParWC5();
ParWC6 = thePar->ParWC6();
ParRT1 = thePar->ParRT1();
ParRT2 = thePar->ParRT2();
ParRT3 = thePar->ParRT3();
ParRT4 = thePar->ParRT4();
ParRT4 = thePar->ParRT4();
ParRT5 = thePar->ParRT5();
ParRT6 = thePar->ParRT6();
// Coeff for fluctueted radial profiles for a uniform media
//
ParSpotT1 = thePar->ParSpotT1(); // T_spot = T_hom =(0.698 + 0.00212)
ParSpotT2 = thePar->ParSpotT2();
ParSpotT1 = thePar->ParSpotT1(); // T_spot = T_hom =(0.698 + 0.00212)
ParSpotT2 = thePar->ParSpotT2();
ParSpotA1 = thePar->ParSpotA1(); // a_spot= a_hom (0.639 + 0.00334)
ParSpotA2 = thePar->ParSpotA2();
ParSpotA1 = thePar->ParSpotA1(); // a_spot= a_hom (0.639 + 0.00334)
ParSpotA2 = thePar->ParSpotA2();
ParSpotN1 = thePar->ParSpotN1(); // N_Spot 93 * ln(Z) E ** 0.876
ParSpotN2 = thePar->ParSpotN2();
ParSpotN1 = thePar->ParSpotN1(); // N_Spot 93 * ln(Z) E ** 0.876
ParSpotN2 = thePar->ParSpotN2();
// Inits
NSpot = 0.00;
AlphaNSpot = 0.00;
TNSpot = 0.00;
BetaNSpot = 0.00;
NSpot = 0.00;
AlphaNSpot = 0.00;
TNSpot = 0.00;
BetaNSpot = 0.00;
RadiusCore = 0.00;
WeightCore = 0.00;
RadiusTail = 0.00;
RadiusCore = 0.00;
WeightCore = 0.00;
RadiusTail = 0.00;
G4cout << "/********************************************/ " << G4endl;
G4cout << " - GFlashHomoShowerParameterisation::Constructor - " << G4endl;
G4cout << " - GFlashHomoShowerParameterisation::Constructor - " << G4endl;
G4cout << "/********************************************/ " << G4endl;
}
void GFlashHomoShowerParameterisation::SetMaterial(G4Material *mat)
void GFlashHomoShowerParameterisation::SetMaterial(G4Material* mat)
{
material= mat;
material = mat;
Z = GetEffZ(material);
A = GetEffA(material);
density = material->GetDensity()/(g/cm3);
X0 = material->GetRadlen();
Ec = 2.66 * std::pow((X0 * Z / A),1.1);
G4double Es = 21*MeV;
Rm = X0*Es/Ec;
// PrintMaterial();
density = material->GetDensity() / (g / cm3);
X0 = material->GetRadlen();
// O. I. Dovzhenkko and A. A. Pommanskii
Ec = 2.66 * std::pow((X0 * Z / A), 1.1);
// // Rossi appriximation
// Ec = 610.0 * MeV / (Z + 1.24);
const G4double Es = 21.2 * MeV;
Rm = X0 * Es / Ec;
// PrintMaterial();
}
GFlashHomoShowerParameterisation::~GFlashHomoShowerParameterisation()
@@ -156,59 +167,56 @@ GFlashHomoShowerParameterisation::~GFlashHomoShowerParameterisation()
delete thePar;
}
void GFlashHomoShowerParameterisation::
GenerateLongitudinalProfile(G4double Energy)
void GFlashHomoShowerParameterisation::GenerateLongitudinalProfile(G4double Energy)
{
if (material==0)
{
G4Exception("GFlashHomoShowerParameterisation::GenerateLongitudinalProfile()",
"InvalidSetup", FatalException, "No material initialized!");
if (material == 0) {
G4Exception("GFlashHomoShowerParameterisation::GenerateLongitudinalProfile()", "InvalidSetup",
FatalException, "No material initialized!");
}
G4double y = Energy/Ec;
ComputeLongitudinalParameters(y);
G4double y = Energy / Ec;
ComputeLongitudinalParameters(y);
GenerateEnergyProfile(y);
GenerateNSpotProfile(y);
}
void
GFlashHomoShowerParameterisation::ComputeLongitudinalParameters(G4double y)
void GFlashHomoShowerParameterisation::ComputeLongitudinalParameters(G4double y)
{
AveLogTmaxh = std::log(ParAveT1 + std::log(y));
//ok <ln T hom>
AveLogAlphah = std::log(ParAveA1 + (ParAveA2+ParAveA3/Z)*std::log(y));
//ok <ln alpha hom>
AveLogTmaxh = std::log(ParAveT1 + std::log(y));
// ok <ln T hom>
AveLogAlphah = std::log(ParAveA1 + (ParAveA2 + ParAveA3 / Z) * std::log(y));
// ok <ln alpha hom>
SigmaLogTmaxh = 1.00/( ParSigLogT1 + ParSigLogT2*std::log(y)) ;
//ok sigma (ln T hom)
SigmaLogAlphah = 1.00/( ParSigLogA1 + ParSigLogA2*std::log(y));
//ok sigma (ln alpha hom)
Rhoh = ParRho1+ParRho2*std::log(y); //ok
SigmaLogTmaxh = 1.00 / (ParSigLogT1 + ParSigLogT2 * std::log(y));
// ok sigma (ln T hom)
SigmaLogAlphah = 1.00 / (ParSigLogA1 + ParSigLogA2 * std::log(y));
// ok sigma (ln alpha hom)
Rhoh = ParRho1 + ParRho2 * std::log(y); // ok
}
void GFlashHomoShowerParameterisation::GenerateEnergyProfile(G4double /* y */)
{
G4double Correlation1h = std::sqrt((1+Rhoh)/2);
G4double Correlation2h = std::sqrt((1-Rhoh)/2);
{
G4double Correlation1h = std::sqrt((1 + Rhoh) / 2);
G4double Correlation2h = std::sqrt((1 - Rhoh) / 2);
G4double Random1 = G4RandGauss::shoot();
G4double Random2 = G4RandGauss::shoot();
// Parameters for Enenrgy Profile including correaltion and sigmas
Tmaxh = std::exp( AveLogTmaxh + SigmaLogTmaxh *
(Correlation1h*Random1 + Correlation2h*Random2) );
Alphah = std::exp( AveLogAlphah + SigmaLogAlphah *
(Correlation1h*Random1 - Correlation2h*Random2) );
Betah = (Alphah-1.00)/Tmaxh;
// Parameters for Enenrgy Profile including correaltion and sigmas
Tmaxh =
std::exp(AveLogTmaxh + SigmaLogTmaxh * (Correlation1h * Random1 + Correlation2h * Random2));
Alphah =
std::exp(AveLogAlphah + SigmaLogAlphah * (Correlation1h * Random1 - Correlation2h * Random2));
Betah = (Alphah - 1.00) / Tmaxh;
}
void GFlashHomoShowerParameterisation::GenerateNSpotProfile(const G4double y)
{
TNSpot = Tmaxh * (ParSpotT1+ParSpotT2*Z); // ok
AlphaNSpot = Alphah * (ParSpotA1+ParSpotA2*Z);
BetaNSpot = (AlphaNSpot-1.00)/TNSpot; // ok
NSpot = ParSpotN1 * std::log(Z)*std::pow((y*Ec)/GeV,ParSpotN2 ); // ok
TNSpot = Tmaxh * (ParSpotT1 + ParSpotT2 * Z); // ok
AlphaNSpot = Alphah * (ParSpotA1 + ParSpotA2 * Z);
BetaNSpot = (AlphaNSpot - 1.00) / TNSpot; // ok
NSpot = ParSpotN1 * std::log(Z) * std::pow((y * Ec) / GeV, ParSpotN2); // ok
}
G4double GFlashHomoShowerParameterisation::
@@ -222,75 +230,68 @@ IntegrateEneLongitudinal(G4double LongitudinalStep)
return DEne;
}
G4double GFlashHomoShowerParameterisation::
IntegrateNspLongitudinal(G4double LongitudinalStep)
G4double GFlashHomoShowerParameterisation::IntegrateNspLongitudinal(G4double LongitudinalStep)
{
G4double LongitudinalStepInX0 = LongitudinalStep / X0;
G4float x1 = BetaNSpot*LongitudinalStepInX0;
G4double LongitudinalStepInX0 = LongitudinalStep / X0;
G4float x1 = BetaNSpot * LongitudinalStepInX0;
G4float x2 = AlphaNSpot;
G4float x3 = gam(x1,x2);
G4float x3 = gam(x1, x2);
G4double DNsp = x3;
return DNsp;
}
G4double GFlashHomoShowerParameterisation::
GenerateRadius(G4int ispot, G4double Energy, G4double LongitudinalPosition)
G4double GFlashHomoShowerParameterisation::GenerateRadius(G4int ispot, G4double Energy,
G4double LongitudinalPosition)
{
if(ispot < 1)
{
if (ispot < 1) {
// Determine lateral parameters in the middle of the step.
// They depend on energy & position along step.
//
G4double Tau = ComputeTau(LongitudinalPosition);
ComputeRadialParameters(Energy,Tau);
ComputeRadialParameters(Energy, Tau);
}
G4double Radius;
G4double Random1 = G4UniformRand();
G4double Random2 = G4UniformRand();
G4double Random2 = G4UniformRand();
if(Random1 <WeightCore) //WeightCore = p < w_i
if (Random1 < WeightCore) // WeightCore = p < w_i
{
Radius = Rm * RadiusCore * std::sqrt( Random2/(1. - Random2) );
Radius = Rm * RadiusCore * std::sqrt(Random2 / (1. - Random2));
}
else
{
Radius = Rm * RadiusTail * std::sqrt( Random2/(1. - Random2) );
}
Radius = std::min(Radius,DBL_MAX);
else {
Radius = Rm * RadiusTail * std::sqrt(Random2 / (1. - Random2));
}
Radius = std::min(Radius, DBL_MAX);
return Radius;
}
G4double GFlashHomoShowerParameterisation::
ComputeTau(G4double LongitudinalPosition)
G4double GFlashHomoShowerParameterisation::ComputeTau(G4double LongitudinalPosition)
{
G4double tau = LongitudinalPosition / Tmaxh / X0 //<t> = T* a /(a - 1)
* (Alphah-1.00) /Alphah *
std::exp(AveLogAlphah)/(std::exp(AveLogAlphah)-1.); //ok
G4double tau = LongitudinalPosition / Tmaxh / X0 //<t> = T* a /(a - 1)
* (Alphah - 1.00) / Alphah * std::exp(AveLogAlphah)
/ (std::exp(AveLogAlphah) - 1.); // ok
return tau;
}
void GFlashHomoShowerParameterisation::
ComputeRadialParameters(G4double Energy, G4double Tau)
void GFlashHomoShowerParameterisation::ComputeRadialParameters(G4double Energy, G4double Tau)
{
G4double z1 = ParRC1 + ParRC2* std::log(Energy/GeV) ; //ok
G4double z2 = ParRC3+ParRC4*Z ; //ok
RadiusCore = z1 + z2 * Tau ; //ok
G4double z1 = ParRC1 + ParRC2 * std::log(Energy / GeV); // ok
G4double z2 = ParRC3 + ParRC4 * Z; // ok
RadiusCore = z1 + z2 * Tau; // ok
G4double p1 = ParWC1+ParWC2*Z; //ok
G4double p2 = ParWC3+ParWC4*Z; //ok
G4double p3 = ParWC5+ParWC6*std::log(Energy/GeV); //ok
G4double p1 = ParWC1 + ParWC2 * Z; // ok
G4double p2 = ParWC3 + ParWC4 * Z; // ok
G4double p3 = ParWC5 + ParWC6 * std::log(Energy / GeV); // ok
WeightCore = p1 * std::exp( (p2-Tau)/p3 - std::exp( (p2-Tau) /p3) ); //ok
WeightCore = p1 * std::exp((p2 - Tau) / p3 - std::exp((p2 - Tau) / p3)); // ok
G4double k1 = ParRT1+ParRT2*Z; // ok
G4double k2 = ParRT3; // ok
G4double k3 = ParRT4; // ok
G4double k4 = ParRT5+ParRT6* std::log(Energy/GeV); // ok
G4double k1 = ParRT1 + ParRT2 * Z; // ok
G4double k2 = ParRT3; // ok
G4double k3 = ParRT4; // ok
G4double k4 = ParRT5 + ParRT6 * std::log(Energy / GeV); // ok
RadiusTail = k1*(std::exp(k3*(Tau-k2)) +
std::exp(k4*(Tau-k2)) ); //ok
RadiusTail = k1 * (std::exp(k3 * (Tau - k2)) + std::exp(k4 * (Tau - k2))); // ok
}
G4double GFlashHomoShowerParameterisation::
@@ -39,72 +39,68 @@
#include "G4Electron.hh"
#include "G4Positron.hh"
GFlashParticleBounds::GFlashParticleBounds()
{
{
// e+e- defaults
EMinEneToParametrise = 0.10*GeV;
EMaxEneToParametrise = 10000.00*GeV;
EEneToKill = 0.1*GeV; // Energie at which electrons are killed
EMinEneToParametrise = 0.10 * GeV;
EMaxEneToParametrise = 10000.00 * GeV;
EEneToKill = 0.1 * GeV; // Energie at which electrons are killed
}
GFlashParticleBounds::~GFlashParticleBounds()
{
}
void GFlashParticleBounds::
SetMinEneToParametrise(G4ParticleDefinition &particleType, G4double enemin)
{
if( &particleType == G4Electron::ElectronDefinition()||
&particleType == G4Positron::PositronDefinition())
EMinEneToParametrise = enemin;
}
void GFlashParticleBounds::
SetMaxEneToParametrise(G4ParticleDefinition &particleType, G4double enemax)
void GFlashParticleBounds::SetMinEneToParametrise(G4ParticleDefinition& particleType,
G4double enemin)
{
if( &particleType == G4Electron::ElectronDefinition()||
&particleType == G4Positron::PositronDefinition())
EMaxEneToParametrise = enemax;
if (&particleType == G4Electron::ElectronDefinition()
|| &particleType == G4Positron::PositronDefinition())
EMinEneToParametrise = enemin;
}
void GFlashParticleBounds::
SetEneToKill(G4ParticleDefinition &particleType, G4double enekill)
void GFlashParticleBounds::SetMaxEneToParametrise(G4ParticleDefinition& particleType,
G4double enemax)
{
if( &particleType == G4Electron::ElectronDefinition()||
&particleType == G4Positron::PositronDefinition())
EEneToKill = enekill;
if (&particleType == G4Electron::ElectronDefinition()
|| &particleType == G4Positron::PositronDefinition())
EMaxEneToParametrise = enemax;
}
G4double GFlashParticleBounds::
GetMinEneToParametrise(G4ParticleDefinition &particleType)
{
void GFlashParticleBounds::SetEneToKill(G4ParticleDefinition& particleType, G4double enekill)
{
if (&particleType == G4Electron::ElectronDefinition()
|| &particleType == G4Positron::PositronDefinition())
EEneToKill = enekill;
}
G4double GFlashParticleBounds::GetMinEneToParametrise(G4ParticleDefinition& particleType)
{
G4double result = DBL_MAX;
if( &particleType == G4Electron::ElectronDefinition()||
&particleType == G4Positron::PositronDefinition())
if (&particleType == G4Electron::ElectronDefinition()
|| &particleType == G4Positron::PositronDefinition())
{
result = EMinEneToParametrise;
}
return result;
}
G4double GFlashParticleBounds::
GetMaxEneToParametrise(G4ParticleDefinition &particleType)
{
G4double result = 0;
if( &particleType == G4Electron::ElectronDefinition()||
&particleType == G4Positron::PositronDefinition())
{
result = EMaxEneToParametrise;
}
return result;
}
G4double GFlashParticleBounds::
GetEneToKill(G4ParticleDefinition & particleType)
G4double GFlashParticleBounds::GetMaxEneToParametrise(G4ParticleDefinition& particleType)
{
if (&particleType == G4Electron::ElectronDefinition() ||
&particleType == G4Positron::PositronDefinition())
return EEneToKill;
else return (-DBL_MAX);
G4double result = 0;
if (&particleType == G4Electron::ElectronDefinition()
|| &particleType == G4Positron::PositronDefinition())
{
result = EMaxEneToParametrise;
}
return result;
}
G4double GFlashParticleBounds::GetEneToKill(G4ParticleDefinition& particleType)
{
if (&particleType == G4Electron::ElectronDefinition()
|| &particleType == G4Positron::PositronDefinition())
return EEneToKill;
else
return (-DBL_MAX);
}
@@ -43,110 +43,136 @@
#include "G4Material.hh"
#include "G4MaterialTable.hh"
GFlashSamplingShowerParameterisation::
GFlashSamplingShowerParameterisation(G4Material* aMat1, G4Material* aMat2,
G4double dd1, G4double dd2,
GFlashSamplingShowerTuning* aPar)
GFlashSamplingShowerParameterisation::GFlashSamplingShowerParameterisation(
G4Material* aMat1, G4Material* aMat2, G4double dd1, G4double dd2,
GFlashSamplingShowerTuning* aPar)
: GVFlashShowerParameterisation(),
ParAveT2(0.), ParSigLogT1(0.), ParSigLogT2(0.),
ParSigLogA1(0.), ParSigLogA2(0.), ParRho1(0.), ParRho2(0.), ParsAveA2(0.),
AveLogAlphah(0.), AveLogTmaxh(0.), SigmaLogAlphah(0.), SigmaLogTmaxh(0.),
Rhoh(0.), Alphah(0.), Tmaxh(0.), Betah(0.), AveLogAlpha(0.), AveLogTmax(0.),
SigmaLogAlpha(0.), SigmaLogTmax(0.), Rho(0.), Alpha(0.), Tmax(0.), Beta(0.)
{
if(!aPar) {
ParAveT2(0.),
ParSigLogT1(0.),
ParSigLogT2(0.),
ParSigLogA1(0.),
ParSigLogA2(0.),
ParRho1(0.),
ParRho2(0.),
ParsAveA2(0.),
AveLogAlphah(0.),
AveLogTmaxh(0.),
SigmaLogAlphah(0.),
SigmaLogTmaxh(0.),
Rhoh(0.),
Alphah(0.),
Tmaxh(0.),
Betah(0.),
AveLogAlpha(0.),
AveLogTmax(0.),
SigmaLogAlpha(0.),
SigmaLogTmax(0.),
Rho(0.),
Alpha(0.),
Tmax(0.),
Beta(0.)
{
if (!aPar) {
thePar = new GFlashSamplingShowerTuning;
} else {
}
else {
thePar = aPar;
}
SetMaterial(aMat1,aMat2 );
d1=dd1;
d2=dd2;
SetMaterial(aMat1, aMat2);
d1 = dd1;
d2 = dd2;
// Longitudinal Coefficients for a homogenious calo
// shower max
ParAveT1 = thePar->ParAveT1(); // ln (ln y -0.812)
ParAveA1 = thePar->ParAveA1(); // ln a (0.81 + (0.458 + 2.26/Z)ln y)
ParAveA2 = thePar->ParAveA2();
ParAveA3 = thePar->ParAveA3();
ParAveT1 = thePar->ParAveT1(); // ln (ln y -0.812)
ParAveA1 = thePar->ParAveA1(); // ln a (0.81 + (0.458 + 2.26/Z)ln y)
ParAveA2 = thePar->ParAveA2();
ParAveA3 = thePar->ParAveA3();
// Variance of shower max sampling
ParSigLogT1 = thePar->ParsSigLogT1(); // Sigma T1 (-1.4 + 1.26 ln y)**-1 --> bug : these two lines were missing,
ParSigLogT1 =
thePar
->ParsSigLogT1(); // Sigma T1 (-1.4 + 1.26 ln y)**-1 --> bug : these two lines were missing,
ParSigLogT2 = thePar->ParsSigLogT2(); // leaving ParSigLogT1, ParSigLogT2 as 0.0
// variance of 'alpha'
ParSigLogA1 = thePar->ParSigLogA1(); // Sigma a (-0.58 + 0.86 ln y)**-1 --> bug : these two lines were missing
ParSigLogA2 = thePar->ParSigLogA2(); // leaving ParSigLogA1 ParSigLogAé as 0.0
ParSigLogA1 =
thePar
->ParSigLogA1(); // Sigma a (-0.58 + 0.86 ln y)**-1 --> bug : these two lines were missing
ParSigLogA2 = thePar->ParSigLogA2(); // leaving ParSigLogA1 ParSigLogAé as 0.0
// correlation alpha%T
ParRho1 = thePar->ParRho1(); // Rho = 0.705 -0.023 ln y --> bug : these two lines were missing,
ParRho2 = thePar->ParRho2(); // leaving ParRho1 and ParRho2 being 0.0
ParRho1 = thePar->ParRho1(); // Rho = 0.705 -0.023 ln y --> bug : these two lines were missing,
ParRho2 = thePar->ParRho2(); // leaving ParRho1 and ParRho2 being 0.0
// Sampling
ParsAveT1 = thePar->ParsAveT1(); // T_sam = log(exp( log T_hom) + t1*Fs-1 + t2*(1-ehat));
ParsAveT2 = thePar->ParsAveT2();
ParsAveA1 = thePar->ParsAveA1();
ParsAveT1 = thePar->ParsAveT1(); // T_sam = log(exp( log T_hom) + t1*Fs-1 + t2*(1-ehat));
ParsAveT2 = thePar->ParsAveT2();
ParsAveA1 = thePar->ParsAveA1();
// Variance of shower max sampling
ParsSigLogT1 = thePar->ParsSigLogT1(); // Sigma T1 (-2.5 + 1.25 ln y)**-1 --> bug ParSigLogT1() was called instead of ParsSigLogT1(); Same for T2.
ParsSigLogT1 = thePar->ParsSigLogT1(); // Sigma T1 (-2.5 + 1.25 ln y)**-1 --> bug ParSigLogT1()
// was called instead of ParsSigLogT1(); Same for T2.
ParsSigLogT2 = thePar->ParsSigLogT2();
// variance of 'alpha'
ParsSigLogA1 = thePar->ParsSigLogA1(); // Sigma a (-0.82 + 0.79 ln y)**-1 --> bug ParSigLogA1() was called instead of ParsSigLogA1(); Same for A2
ParsSigLogA1 = thePar->ParsSigLogA1(); // Sigma a (-0.82 + 0.79 ln y)**-1 --> bug ParSigLogA1()
// was called instead of ParsSigLogA1(); Same for A2
ParsSigLogA2 = thePar->ParsSigLogA2();
// correlation alpha%T
ParsRho1 = thePar->ParsRho1(); // Rho = 0.784 -0.023 ln y --> bug was using ParRho1() and ParRho2()
ParsRho2 = thePar->ParsRho2();
ParsRho1 =
thePar->ParsRho1(); // Rho = 0.784 -0.023 ln y --> bug was using ParRho1() and ParRho2()
ParsRho2 = thePar->ParsRho2();
// Radial Coefficients
// r_C (tau)= z_1 +z_2 tau
// r_t (tau)= k1 (std::exp (k3(tau -k2 ))+std::exp (k_4 (tau- k_2))))
ParRC1 = thePar->ParRC1(); // z_1 = 0.0251 + 0.00319 ln E
ParRC2 = thePar->ParRC2();
ParRC3 = thePar->ParRC3(); // z_2 = 0.1162 + - 0.000381 Z
ParRC4 = thePar->ParRC4();
ParRC1 = thePar->ParRC1(); // z_1 = 0.0251 + 0.00319 ln E
ParRC2 = thePar->ParRC2();
ParRC3 = thePar->ParRC3(); // z_2 = 0.1162 + - 0.000381 Z
ParRC4 = thePar->ParRC4();
ParWC1 = thePar->ParWC1();
ParWC2 = thePar->ParWC2();
ParWC3 = thePar->ParWC3();
ParWC4 = thePar->ParWC4();
ParWC5 = thePar->ParWC5();
ParWC5 = thePar->ParWC5();
ParWC6 = thePar->ParWC6();
ParRT1 = thePar->ParRT1();
ParRT2 = thePar->ParRT2();
ParRT3 = thePar->ParRT3();
ParRT4 = thePar->ParRT4();
ParRT4 = thePar->ParRT4();
ParRT5 = thePar->ParRT5();
ParRT6 = thePar->ParRT6();
//additional sampling parameter
ParsRC1= thePar->ParsRC1();
ParsRC2= thePar->ParsRC2();
ParsWC1= thePar->ParsWC1();
ParsWC2= thePar->ParsWC2();
ParsRT1= thePar->ParsRT1();
ParsRT2= thePar->ParsRT2();
// additional sampling parameter
ParsRC1 = thePar->ParsRC1();
ParsRC2 = thePar->ParsRC2();
ParsWC1 = thePar->ParsWC1();
ParsWC2 = thePar->ParsWC2();
ParsRT1 = thePar->ParsRT1();
ParsRT2 = thePar->ParsRT2();
// Coeff for fluctuedted radial profiles for a sampling media
ParsSpotT1 = thePar->ParSpotT1(); // T_spot = T_hom =(0.698 + 0.00212)
ParsSpotT2 = thePar->ParSpotT2();
ParsSpotA1 = thePar->ParSpotA1(); // a_spot= a_hom (0.639 + 0.00334)
ParsSpotA2 = thePar->ParSpotA2();
ParsSpotN1 = thePar->ParSpotN1(); // N_Spot 93 * ln(Z) E ** 0.876
ParsSpotN2 = thePar->ParSpotN2();
SamplingResolution = thePar->SamplingResolution();
ConstantResolution = thePar->ConstantResolution();
NoiseResolution = thePar->NoiseResolution();
ParsSpotT1 = thePar->ParSpotT1(); // T_spot = T_hom =(0.698 + 0.00212)
ParsSpotT2 = thePar->ParSpotT2();
ParsSpotA1 = thePar->ParSpotA1(); // a_spot= a_hom (0.639 + 0.00334)
ParsSpotA2 = thePar->ParSpotA2();
ParsSpotN1 = thePar->ParSpotN1(); // N_Spot 93 * ln(Z) E ** 0.876
ParsSpotN2 = thePar->ParSpotN2();
SamplingResolution = thePar->SamplingResolution();
ConstantResolution = thePar->ConstantResolution();
NoiseResolution = thePar->NoiseResolution();
// Inits
NSpot = 0.00;
AlphaNSpot = 0.00;
TNSpot = 0.00;
BetaNSpot = 0.00;
RadiusCore = 0.00;
WeightCore = 0.00;
RadiusTail = 0.00;
NSpot = 0.00;
AlphaNSpot = 0.00;
TNSpot = 0.00;
BetaNSpot = 0.00;
RadiusCore = 0.00;
WeightCore = 0.00;
RadiusTail = 0.00;
ComputeZAX0EFFetc();
G4cout << "/********************************************/ " << G4endl;
G4cout << " - GFlashSamplingShowerParameterisation::Constructor - " << G4endl;
G4cout << "/********************************************/ " << G4endl;
G4cout << "/********************************************/ " << G4endl;
}
// ------------------------------------------------------------
@@ -158,26 +184,27 @@ GFlashSamplingShowerParameterisation::~GFlashSamplingShowerParameterisation()
// ------------------------------------------------------------
void GFlashSamplingShowerParameterisation::
SetMaterial(G4Material *mat1, G4Material *mat2)
void GFlashSamplingShowerParameterisation::SetMaterial(G4Material* mat1, G4Material* mat2)
{
G4double Es = 21*MeV;
material1= mat1;
const G4double Es = 21.2 * MeV;
material1 = mat1;
Z1 = GetEffZ(material1);
A1 = GetEffA(material1);
density1 = material1->GetDensity();
X01 = material1->GetRadlen();
Ec1 = 2.66 * std::pow((X01 * Z1 / A1),1.1);
Rm1 = X01*Es/Ec1;
X01 = material1->GetRadlen();
Ec1 = 2.66 * std::pow((X01 * Z1 / A1), 1.1);
// Ec1 = 610.0 * MeV / (Z1 + 1.24);
Rm1 = X01 * Es / Ec1;
material2= mat2;
material2 = mat2;
Z2 = GetEffZ(material2);
A2 = GetEffA(material2);
density2 = material2->GetDensity();
X02 = material2->GetRadlen();
Ec2 = 2.66 * std::pow((X02 * Z2 / A2),1.1);
Rm2 = X02*Es/Ec2;
// PrintMaterial();
X02 = material2->GetRadlen();
Ec2 = 2.66 * std::pow((X02 * Z2 / A2), 1.1);
// Ec2 = 610.0 * MeV / (Z2 + 1.24);
Rm2 = X02 * Es / Ec2;
// PrintMaterial();
}
// ------------------------------------------------------------
@@ -187,154 +214,158 @@ void GFlashSamplingShowerParameterisation::ComputeZAX0EFFetc()
G4cout << "/************ ComputeZAX0EFFetc ************/" << G4endl;
G4cout << " - GFlashSamplingShowerParameterisation::Material - " << G4endl;
G4double Es = 21*MeV; //constant
const G4double Es = 21.2 * MeV;
// material and geometry parameters for a sampling calorimeter
G4double denominator = (d1*density1 + d2*density2);
G4double W1 = (d1*density1) / denominator;
G4double W2 = (d2*density2) / denominator;
Zeff = ( W1*Z1 ) + ( W2*Z2 ); //X0*Es/Ec;
Aeff = ( W1*A1 ) + ( W2*A2 );
Rhoeff = ( ( d1*density1 ) + ( d2*density2 ) ) / ( d1 + d2 ); // --> was G4double ( d2 + d1 );
X0eff = (W1 * Rhoeff) / (X01 * density1) + (W2 * Rhoeff) / (X02 * density2 );
X0eff = 1./ X0eff;
Rmeff = 1./ ( ( ((W1*Ec1)/X01) + ((W2*Ec2)/X02) ) / Es ) ;
Eceff = X0eff * ( (W1*Ec1)/X01 + (W2*Ec2)/X02 );
Fs = X0eff/(d1+d2);// --> was G4double ((d1/mm )+(d2/mm) ); Can't understand if dividing by mm makes sense... looks weird.
ehat = ( 1. / ( 1 + 0.007*(Z1- Z2) ) );
G4double denominator = (d1 * density1 + d2 * density2);
G4double W1 = (d1 * density1) / denominator;
G4double W2 = (d2 * density2) / denominator;
Zeff = (W1 * Z1) + (W2 * Z2); // X0*Es/Ec;
Aeff = (W1 * A1) + (W2 * A2);
Rhoeff = ((d1 * density1) + (d2 * density2)) / (d1 + d2); // --> was G4double ( d2 + d1 );
X0eff = (W1 * Rhoeff) / (X01 * density1) + (W2 * Rhoeff) / (X02 * density2);
X0eff = 1. / X0eff;
Rmeff = 1. / ((((W1 * Ec1) / X01) + ((W2 * Ec2) / X02)) / Es);
Eceff = X0eff * ((W1 * Ec1) / X01 + (W2 * Ec2) / X02);
Fs = X0eff / (d1 + d2); // --> was G4double ((d1/mm )+(d2/mm) ); Can't understand if dividing by
// mm makes sense... looks weird.
ehat = (1. / (1 + 0.007 * (Z1 - Z2)));
G4cout << "W1= " << W1 << G4endl;
G4cout << "W2= " << W2 << G4endl;
G4cout << "effective quantities Zeff = "<<Zeff<< G4endl;
G4cout << "effective quantities Aeff = "<<Aeff<< G4endl;
G4cout << "effective quantities Rhoeff = "<<Rhoeff/g *cm3<<" g/cm3" << G4endl;
G4cout << "effective quantities X0eff = "<<X0eff/cm <<" cm" << G4endl;
G4cout << "effective quantities Zeff = " << Zeff << G4endl;
G4cout << "effective quantities Aeff = " << Aeff << G4endl;
G4cout << "effective quantities Rhoeff = " << Rhoeff / g * cm3 << " g/cm3" << G4endl;
G4cout << "effective quantities X0eff = " << X0eff / cm << " cm" << G4endl;
X0eff = X0eff * Rhoeff;
G4cout << "effective quantities X0eff = "<<X0eff/g*cm2 <<" g/cm2" << G4endl;
X0eff = X0eff /Rhoeff;
G4cout << "effective quantities RMeff = "<<Rmeff/cm<<" cm" << G4endl;
Rmeff = Rmeff* Rhoeff;
G4cout << "effective quantities RMeff = "<<Rmeff/g *cm2<<" g/cm2" << G4endl;
Rmeff = Rmeff/ Rhoeff;
G4cout << "effective quantities Eceff = "<<Eceff/MeV<< " MeV"<< G4endl;
G4cout << "effective quantities Fs = "<<Fs<<G4endl;
G4cout << "effective quantities ehat = "<<ehat<<G4endl;
G4cout << "/********************************************/ " <<G4endl;
G4cout << "effective quantities X0eff = " << X0eff / g * cm2 << " g/cm2" << G4endl;
X0eff = X0eff / Rhoeff;
G4cout << "effective quantities RMeff = " << Rmeff / cm << " cm" << G4endl;
Rmeff = Rmeff * Rhoeff;
G4cout << "effective quantities RMeff = " << Rmeff / g * cm2 << " g/cm2" << G4endl;
Rmeff = Rmeff / Rhoeff;
G4cout << "effective quantities Eceff = " << Eceff / MeV << " MeV" << G4endl;
G4cout << "effective quantities Fs = " << Fs << G4endl;
G4cout << "effective quantities ehat = " << ehat << G4endl;
G4cout << "/********************************************/ " << G4endl;
}
// ------------------------------------------------------------
void GFlashSamplingShowerParameterisation::
GenerateLongitudinalProfile(G4double Energy)
void GFlashSamplingShowerParameterisation::GenerateLongitudinalProfile(G4double Energy)
{
if ((material1==0) || (material2 ==0))
{
if ((material1 == 0) || (material2 == 0)) {
G4Exception("GFlashSamplingShowerParameterisation::GenerateLongitudinalProfile()",
"InvalidSetup", FatalException, "No material initialized!");
}
G4double y = Energy/Eceff;
ComputeLongitudinalParameters(y);
}
G4double y = Energy / Eceff;
ComputeLongitudinalParameters(y);
GenerateEnergyProfile(y);
GenerateNSpotProfile(y);
}
// ------------------------------------------------------------
void
GFlashSamplingShowerParameterisation::ComputeLongitudinalParameters(G4double y)
void GFlashSamplingShowerParameterisation::ComputeLongitudinalParameters(G4double y)
{
AveLogTmaxh = std::log( std::max( ParAveT1 + std::log(y), 0.1 ) ); // ok
AveLogAlphah = std::log( std::max( ParAveA1 + (ParAveA2+ParAveA3/Zeff)*std::log(y), 0.1 ) ); // ok
AveLogTmaxh = std::log(std::max(ParAveT1 + std::log(y), 0.1)); // ok
AveLogAlphah =
std::log(std::max(ParAveA1 + (ParAveA2 + ParAveA3 / Zeff) * std::log(y), 0.1)); // ok
// hom
SigmaLogTmaxh = std::min( 0.5, 1.00/( ParSigLogT1 + ParSigLogT2*std::log(y) ) ); // ok
SigmaLogAlphah = std::min( 0.5, 1.00/( ParSigLogA1 + ParSigLogA2*std::log(y) ) ); // ok
Rhoh = ParRho1 + ParRho2*std::log(y); //ok
// if sampling
AveLogTmax = std::max( 0.1, std::log(std::exp(AveLogTmaxh) + ParsAveT1/Fs + ParsAveT2*(1-ehat)) ); // ok
AveLogAlpha = std::max( 0.1, std::log(std::exp(AveLogAlphah) + ParsAveA1/Fs) ); // ok
SigmaLogTmaxh = std::min(0.5, 1.00 / (ParSigLogT1 + ParSigLogT2 * std::log(y))); // ok
SigmaLogAlphah = std::min(0.5, 1.00 / (ParSigLogA1 + ParSigLogA2 * std::log(y))); // ok
Rhoh = ParRho1 + ParRho2 * std::log(y); // ok
// if sampling
AveLogTmax =
std::max(0.1, std::log(std::exp(AveLogTmaxh) + ParsAveT1 / Fs + ParsAveT2 * (1 - ehat))); // ok
AveLogAlpha = std::max(0.1, std::log(std::exp(AveLogAlphah) + ParsAveA1 / Fs)); // ok
//
SigmaLogTmax = std::min( 0.5, 1.00 / (ParsSigLogT1 + ParsSigLogT2*std::log(y)) ); // ok
SigmaLogAlpha = std::min( 0.5, 1.00 / (ParsSigLogA1 + ParsSigLogA2*std::log(y)) ); // ok
Rho = ParsRho1 + ParsRho2*std::log(y); // ok
SigmaLogTmax = std::min(0.5, 1.00 / (ParsSigLogT1 + ParsSigLogT2 * std::log(y))); // ok
SigmaLogAlpha = std::min(0.5, 1.00 / (ParsSigLogA1 + ParsSigLogA2 * std::log(y))); // ok
Rho = ParsRho1 + ParsRho2 * std::log(y); // ok
if (0) {
G4cout << " y = " << y << G4endl;
G4cout << " std::log(std::exp(AveLogTmaxh) + ParsAveT1/Fs + ParsAveT2*(1-ehat)) = "
<< " std::log(" << std::exp(AveLogTmaxh) << " + " << ParsAveT1/Fs << " + " << ParsAveT2*(1-ehat) << ") = "
<< " std::log(" << std::exp(AveLogTmaxh) << " + " << ParsAveT1 << "/" << Fs << " + " << ParsAveT2 << "*" << (1-ehat) << ") = "
<< " std::log(" << std::exp(AveLogTmaxh) + ParsAveT1/Fs + ParsAveT2*(1-ehat) << ")" << G4endl;
G4cout << " AveLogTmaxh " << AveLogTmaxh << G4endl;
G4cout << " AveLogAlphah " << AveLogAlphah << G4endl;
G4cout << " SigmaLogTmaxh " << SigmaLogTmaxh << G4endl;
G4cout << " 1.00/( ParSigLogT1 + ParSigLogT2*std::log(y) ) = " << 1.00 << "/" << ( ParSigLogT1 + ParSigLogT2*std::log(y) ) << " = "
<< 1.00 << "/" << "(" << ParSigLogT1 << " + " << ParSigLogT2*std::log(y) << " ) = "
<< 1.00 << "/" << "(" << ParSigLogT1 << " + " << ParSigLogT2 << "*" << std::log(y) << " ) "
<< G4endl;
G4cout << " SigmaLogAlphah " << SigmaLogAlphah << G4endl;
G4cout << " Rhoh " << Rhoh << G4endl;
G4cout << " AveLogTmax " << AveLogTmax << G4endl;
G4cout << " AveLogAlpha " << AveLogAlpha << G4endl;
G4cout << " SigmaLogTmax " << SigmaLogTmax << G4endl;
G4cout << " SigmaLogAlpha " << SigmaLogAlpha << G4endl;
G4cout << " Rho " << Rho << G4endl;
<< " std::log(" << std::exp(AveLogTmaxh) << " + " << ParsAveT1 / Fs << " + "
<< ParsAveT2 * (1 - ehat) << ") = "
<< " std::log(" << std::exp(AveLogTmaxh) << " + " << ParsAveT1 << "/" << Fs << " + "
<< ParsAveT2 << "*" << (1 - ehat) << ") = "
<< " std::log(" << std::exp(AveLogTmaxh) + ParsAveT1 / Fs + ParsAveT2 * (1 - ehat) << ")"
<< G4endl;
G4cout << " AveLogTmaxh " << AveLogTmaxh << G4endl;
G4cout << " AveLogAlphah " << AveLogAlphah << G4endl;
G4cout << " SigmaLogTmaxh " << SigmaLogTmaxh << G4endl;
G4cout << " 1.00/( ParSigLogT1 + ParSigLogT2*std::log(y) ) = " << 1.00 << "/"
<< (ParSigLogT1 + ParSigLogT2 * std::log(y)) << " = " << 1.00 << "/" << "("
<< ParSigLogT1 << " + " << ParSigLogT2 * std::log(y) << " ) = " << 1.00 << "/" << "("
<< ParSigLogT1 << " + " << ParSigLogT2 << "*" << std::log(y) << " ) " << G4endl;
G4cout << " SigmaLogAlphah " << SigmaLogAlphah << G4endl;
G4cout << " Rhoh " << Rhoh << G4endl;
G4cout << " AveLogTmax " << AveLogTmax << G4endl;
G4cout << " AveLogAlpha " << AveLogAlpha << G4endl;
G4cout << " SigmaLogTmax " << SigmaLogTmax << G4endl;
G4cout << " SigmaLogAlpha " << SigmaLogAlpha << G4endl;
G4cout << " Rho " << Rho << G4endl;
}
}
// ------------------------------------------------------------
void GFlashSamplingShowerParameterisation::GenerateEnergyProfile(G4double /* y */)
{
G4double Correlation1 = std::sqrt( (1+Rho )/2 );
G4double Correlation2 = std::sqrt( (1-Rho )/2 );
G4double Correlation1h = std::sqrt( (1+Rhoh)/2 );
G4double Correlation2h = std::sqrt( (1-Rhoh)/2 );
{
G4double Correlation1 = std::sqrt((1 + Rho) / 2);
G4double Correlation2 = std::sqrt((1 - Rho) / 2);
G4double Correlation1h = std::sqrt((1 + Rhoh) / 2);
G4double Correlation2h = std::sqrt((1 - Rhoh) / 2);
G4double Random1 = G4RandGauss::shoot();
G4double Random2 = G4RandGauss::shoot();
Tmax = std::max( 1., std::exp( AveLogTmax + SigmaLogTmax * (Correlation1*Random1 + Correlation2*Random2) ) );
Alpha = std::max( 1.1, std::exp( AveLogAlpha + SigmaLogAlpha * (Correlation1*Random1 - Correlation2*Random2) ) );
Beta = (Alpha-1.00)/Tmax;
//Parameters for Enenrgy Profile including correaltion and sigmas
Tmaxh = std::exp( AveLogTmaxh + SigmaLogTmaxh *
(Correlation1h*Random1 + Correlation2h*Random2) );
Alphah = std::exp( AveLogAlphah + SigmaLogAlphah *
(Correlation1h*Random1 - Correlation2h*Random2) );
Betah = (Alphah-1.00)/Tmaxh;
Tmax = std::max(
1., std::exp(AveLogTmax + SigmaLogTmax * (Correlation1 * Random1 + Correlation2 * Random2)));
Alpha = std::max(
1.1, std::exp(AveLogAlpha + SigmaLogAlpha * (Correlation1 * Random1 - Correlation2 * Random2)));
Beta = (Alpha - 1.00) / Tmax;
// Parameters for Enenrgy Profile including correaltion and sigmas
Tmaxh =
std::exp(AveLogTmaxh + SigmaLogTmaxh * (Correlation1h * Random1 + Correlation2h * Random2));
Alphah =
std::exp(AveLogAlphah + SigmaLogAlphah * (Correlation1h * Random1 - Correlation2h * Random2));
Betah = (Alphah - 1.00) / Tmaxh;
}
// ------------------------------------------------------------
void GFlashSamplingShowerParameterisation::GenerateNSpotProfile(const G4double y)
{
TNSpot = Tmaxh * (ParsSpotT1+ParsSpotT2*Zeff); //ok.
TNSpot = std::max(0.5,Tmaxh * (ParsSpotT1+ParsSpotT2*Zeff));
AlphaNSpot = Alphah * (ParsSpotA1+ParsSpotA2*Zeff);
BetaNSpot = (AlphaNSpot-1.00)/TNSpot; // ok
NSpot = ParsSpotN1 /SamplingResolution * std::pow(y*Eceff/GeV,ParsSpotN2 );
TNSpot = Tmaxh * (ParsSpotT1 + ParsSpotT2 * Zeff); // ok.
TNSpot = std::max(0.5, Tmaxh * (ParsSpotT1 + ParsSpotT2 * Zeff));
AlphaNSpot = Alphah * (ParsSpotA1 + ParsSpotA2 * Zeff);
BetaNSpot = (AlphaNSpot - 1.00) / TNSpot; // ok
NSpot = ParsSpotN1 / SamplingResolution * std::pow(y * Eceff / GeV, ParsSpotN2);
}
// ------------------------------------------------------------
G4double
GFlashSamplingShowerParameterisation::
ApplySampling(const G4double DEne, const G4double )
G4double GFlashSamplingShowerParameterisation::ApplySampling(const G4double DEne, const G4double)
{
G4double DEneFluctuated = DEne;
G4double Resolution = std::pow(SamplingResolution,2);
G4double Resolution = std::pow(SamplingResolution, 2);
// +pow(NoiseResolution,2)/ //@@@@@@@@ FIXME
// +pow(NoiseResolution,2)/ //@@@@@@@@ FIXME
// Energy*(1.*MeV)+
// pow(ConstantResolution,2)*
// Energy/(1.*MeV);
if(Resolution >0.0 && DEne > 0.00)
{
G4float x1=DEne/Resolution;
G4float x2 = G4RandGamma::shoot(x1, 1.0)*Resolution;
DEneFluctuated=x2;
if (Resolution > 0.0 && DEne > 0.00) {
// G4float x1 = DEne / Resolution;
// G4float x2 = G4RandGamma::shoot(x1, 1.0) * Resolution;
// DEneFluctuated = x2;
G4double x1 = DEne / Resolution;
G4double x2 = 1.0 / Resolution;
DEneFluctuated = G4RandGamma::shoot(x1, x2);
}
return DEneFluctuated;
}
@@ -354,85 +385,78 @@ IntegrateEneLongitudinal(G4double LongitudinalStep)
// ------------------------------------------------------------
G4double GFlashSamplingShowerParameterisation::
IntegrateNspLongitudinal(G4double LongitudinalStep)
G4double GFlashSamplingShowerParameterisation::IntegrateNspLongitudinal(G4double LongitudinalStep)
{
G4double LongitudinalStepInX0 = LongitudinalStep / X0eff;
G4float x1 = BetaNSpot*LongitudinalStepInX0;
G4double LongitudinalStepInX0 = LongitudinalStep / X0eff;
G4float x1 = BetaNSpot * LongitudinalStepInX0;
G4float x2 = AlphaNSpot;
G4float x3 = gam(x1,x2);
G4float x3 = gam(x1, x2);
G4double DNsp = x3;
return DNsp;
}
// ------------------------------------------------------------
G4double GFlashSamplingShowerParameterisation::
GenerateRadius(G4int ispot, G4double Energy, G4double LongitudinalPosition)
G4double GFlashSamplingShowerParameterisation::GenerateRadius(G4int ispot, G4double Energy,
G4double LongitudinalPosition)
{
if(ispot < 1)
{
if (ispot < 1) {
// Determine lateral parameters in the middle of the step.
// They depend on energy & position along step
//
G4double Tau = ComputeTau(LongitudinalPosition);
ComputeRadialParameters(Energy,Tau);
ComputeRadialParameters(Energy, Tau);
}
G4double Radius;
G4double Random1 = G4UniformRand();
G4double Random2 = G4UniformRand();
if(Random1 <WeightCore) //WeightCore = p < w_i
G4double Random2 = G4UniformRand();
if (Random1 < WeightCore) // WeightCore = p < w_i
{
Radius = Rmeff * RadiusCore * std::sqrt( Random2/(1. - Random2) );
Radius = Rmeff * RadiusCore * std::sqrt(Random2 / (1. - Random2));
}
else
{
Radius = Rmeff * RadiusTail * std::sqrt( Random2/(1. - Random2) );
}
Radius = std::min(Radius,DBL_MAX);
else {
Radius = Rmeff * RadiusTail * std::sqrt(Random2 / (1. - Random2));
}
Radius = std::min(Radius, DBL_MAX);
return Radius;
}
// ------------------------------------------------------------
G4double
GFlashSamplingShowerParameterisation::
ComputeTau(G4double LongitudinalPosition)
G4double GFlashSamplingShowerParameterisation::ComputeTau(G4double LongitudinalPosition)
{
G4double tau = LongitudinalPosition / Tmax/ X0eff //<t> = T* a /(a - 1)
* (Alpha-1.00) /Alpha
* std::exp(AveLogAlpha)/(std::exp(AveLogAlpha)-1.); //ok
G4double tau = LongitudinalPosition / Tmax / X0eff //<t> = T* a /(a - 1)
* (Alpha - 1.00) / Alpha * std::exp(AveLogAlpha)
/ (std::exp(AveLogAlpha) - 1.); // ok
return tau;
}
// ------------------------------------------------------------
void GFlashSamplingShowerParameterisation::
ComputeRadialParameters(G4double Energy, G4double Tau)
void GFlashSamplingShowerParameterisation::ComputeRadialParameters(G4double Energy, G4double Tau)
{
G4double z1 = ParRC1 + ParRC2* std::log(Energy/GeV); //ok
G4double z2 = ParRC3+ParRC4*Zeff; //ok
RadiusCore = z1 + z2 * Tau; //ok
G4double p1 = ParWC1+ParWC2*Zeff; //ok
G4double p2 = ParWC3+ParWC4*Zeff; //ok
G4double p3 = ParWC5+ParWC6*std::log(Energy/GeV); //ok
WeightCore = p1 * std::exp( (p2-Tau)/p3- std::exp( (p2-Tau) /p3) ); //ok
G4double k1 = ParRT1+ParRT2*Zeff; // ok
G4double k2 = ParRT3; // ok
G4double k3 = ParRT4; // ok
G4double k4 = ParRT5+ParRT6* std::log(Energy/GeV); // ok
RadiusTail = k1*(std::exp(k3*(Tau-k2))
+ std::exp(k4*(Tau-k2)) ); //ok
G4double z1 = ParRC1 + ParRC2 * std::log(Energy / GeV); // ok
G4double z2 = ParRC3 + ParRC4 * Zeff; // ok
RadiusCore = z1 + z2 * Tau; // ok
G4double p1 = ParWC1 + ParWC2 * Zeff; // ok
G4double p2 = ParWC3 + ParWC4 * Zeff; // ok
G4double p3 = ParWC5 + ParWC6 * std::log(Energy / GeV); // ok
WeightCore = p1 * std::exp((p2 - Tau) / p3 - std::exp((p2 - Tau) / p3)); // ok
// sampling calorimeter
G4double k1 = ParRT1 + ParRT2 * Zeff; // ok
G4double k2 = ParRT3; // ok
G4double k3 = ParRT4; // ok
G4double k4 = ParRT5 + ParRT6 * std::log(Energy / GeV); // ok
RadiusCore = RadiusCore + ParsRC1*(1-ehat) + ParsRC2/Fs*std::exp(-Tau); //ok
WeightCore = WeightCore + (1-ehat)
* (ParsWC1+ParsWC2/Fs * std::exp(-std::pow((Tau-1.),2))); //ok
RadiusTail = RadiusTail + (1-ehat)* ParsRT1+ ParsRT2/Fs *std::exp(-Tau); //ok
RadiusTail = k1 * (std::exp(k3 * (Tau - k2)) + std::exp(k4 * (Tau - k2))); // ok
// sampling calorimeter
RadiusCore = RadiusCore + ParsRC1 * (1 - ehat) + ParsRC2 / Fs * std::exp(-Tau); // ok
WeightCore =
WeightCore + (1 - ehat) * (ParsWC1 + ParsWC2 / Fs * std::exp(-std::pow((Tau - 1.), 2))); // ok
RadiusTail = RadiusTail + (1 - ehat) * ParsRT1 + ParsRT2 / Fs * std::exp(-Tau); // ok
}
// ------------------------------------------------------------
@@ -52,28 +52,24 @@
#include "GFlashSamplingShowerParameterisation.hh"
#include "GFlashEnergySpot.hh"
GFlashShowerModel::GFlashShowerModel(G4String modelName,
G4Envelope* envelope)
: G4VFastSimulationModel(modelName, envelope),
PBound(0), Parameterisation(0), HMaker(0)
GFlashShowerModel::GFlashShowerModel(G4String modelName, G4Envelope* envelope)
: G4VFastSimulationModel(modelName, envelope), PBound(0), Parameterisation(0), HMaker(0)
{
FlagParamType = 0;
FlagParticleContainment = 1;
FlagParamType = 0;
FlagParticleContainment = 1;
StepInX0 = 0.1;
EnergyStop = 0.0;
Messenger = new GFlashShowerModelMessenger(this);
Messenger = new GFlashShowerModelMessenger(this);
}
GFlashShowerModel::GFlashShowerModel(G4String modelName)
: G4VFastSimulationModel(modelName),
PBound(0), Parameterisation(0), HMaker(0)
: G4VFastSimulationModel(modelName), PBound(0), Parameterisation(0), HMaker(0)
{
FlagParamType =1;
FlagParticleContainment = 1;
StepInX0 = 0.1;
FlagParamType = 1;
FlagParticleContainment = 1;
StepInX0 = 0.1;
EnergyStop = 0.0;
Messenger = new GFlashShowerModelMessenger(this);
Messenger = new GFlashShowerModelMessenger(this);
}
GFlashShowerModel::~GFlashShowerModel()
@@ -81,252 +77,220 @@ GFlashShowerModel::~GFlashShowerModel()
delete Messenger;
}
G4bool
GFlashShowerModel::IsApplicable(const G4ParticleDefinition& particleType)
{
return
&particleType == G4Electron::ElectronDefinition() ||
&particleType == G4Positron::PositronDefinition();
G4bool GFlashShowerModel::IsApplicable(const G4ParticleDefinition& particleType)
{
return &particleType == G4Electron::ElectronDefinition()
|| &particleType == G4Positron::PositronDefinition();
}
/**********************************************************************/
/* Checks whether conditions of fast parameterisation are fullfilled */
/**********************************************************************/
G4bool GFlashShowerModel::ModelTrigger(const G4FastTrack & fastTrack )
G4bool GFlashShowerModel::ModelTrigger(const G4FastTrack& fastTrack)
{
G4bool select = false;
if(FlagParamType != 0)
{
G4double ParticleEnergy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
G4ParticleDefinition &ParticleType =
*(fastTrack.GetPrimaryTrack()->GetDefinition());
if(ParticleEnergy > PBound->GetMinEneToParametrise(ParticleType) &&
ParticleEnergy < PBound->GetMaxEneToParametrise(ParticleType) )
if (FlagParamType != 0) {
G4double ParticleEnergy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
G4ParticleDefinition& ParticleType = *(fastTrack.GetPrimaryTrack()->GetDefinition());
if (ParticleEnergy > PBound->GetMinEneToParametrise(ParticleType)
&& ParticleEnergy < PBound->GetMaxEneToParametrise(ParticleType))
{
// check conditions depending on particle flavour
// performance to be optimized @@@@@@@
Parameterisation->GenerateLongitudinalProfile(ParticleEnergy);
select = CheckParticleDefAndContainment(fastTrack);
if (select) EnergyStop= PBound->GetEneToKill(ParticleType);
select = CheckParticleDefAndContainment(fastTrack);
if (select) EnergyStop = PBound->GetEneToKill(ParticleType);
}
}
return select;
return select;
}
G4bool GFlashShowerModel::CheckParticleDefAndContainment(const G4FastTrack& fastTrack)
{
G4bool filter = false;
G4ParticleDefinition* ParticleType = fastTrack.GetPrimaryTrack()->GetDefinition();
G4bool
GFlashShowerModel::CheckParticleDefAndContainment(const G4FastTrack& fastTrack)
{
G4bool filter=false;
G4ParticleDefinition * ParticleType =
fastTrack.GetPrimaryTrack()->GetDefinition();
if( ParticleType == G4Electron::ElectronDefinition() ||
ParticleType == G4Positron::PositronDefinition() )
if (ParticleType == G4Electron::ElectronDefinition()
|| ParticleType == G4Positron::PositronDefinition())
{
filter=true;
if(FlagParticleContainment == 1)
{
filter=CheckContainment(fastTrack);
filter = true;
if (FlagParticleContainment == 1) {
filter = CheckContainment(fastTrack);
}
}
return filter;
return filter;
}
G4bool GFlashShowerModel::CheckContainment(const G4FastTrack& fastTrack)
{
G4bool filter=false;
G4bool filter = false;
// track informations
G4ThreeVector DirectionShower=fastTrack.GetPrimaryTrackLocalDirection();
G4ThreeVector InitialPositionShower=fastTrack.GetPrimaryTrackLocalPosition();
G4ThreeVector DirectionShower = fastTrack.GetPrimaryTrackLocalDirection();
G4ThreeVector InitialPositionShower = fastTrack.GetPrimaryTrackLocalPosition();
G4ThreeVector OrthoShower, CrossShower;
// Returns orthogonal vector
G4ThreeVector OrthoShower, CrossShower;
// Returns orthogonal vector
OrthoShower = DirectionShower.orthogonal();
// Shower in direction perpendicular to OrthoShower and DirectionShower
CrossShower = DirectionShower.cross(OrthoShower);
G4double R = Parameterisation->GetAveR90();
G4double Z = Parameterisation->GetAveT90();
G4int CosPhi[4] = {1,0,-1,0};
G4int SinPhi[4] = {0,1,0,-1};
G4double R = Parameterisation->GetAveR90();
G4double Z = Parameterisation->GetAveT90();
G4int CosPhi[4] = {1, 0, -1, 0};
G4int SinPhi[4] = {0, 1, 0, -1};
G4ThreeVector Position;
G4int NlateralInside=0;
G4int NlateralInside = 0;
// pointer to solid we're in
G4VSolid *SolidCalo = fastTrack.GetEnvelopeSolid();
for(int i=0; i<4 ;i++)
{
G4VSolid* SolidCalo = fastTrack.GetEnvelopeSolid();
for (int i = 0; i < 4; i++) {
// polar coordinates
Position = InitialPositionShower +
Z*DirectionShower +
R*CosPhi[i]*OrthoShower +
R*SinPhi[i]*CrossShower ;
if(SolidCalo->Inside(Position) != kOutside)
NlateralInside++;
Position = InitialPositionShower + Z * DirectionShower + R * CosPhi[i] * OrthoShower
+ R * SinPhi[i] * CrossShower;
if (SolidCalo->Inside(Position) != kOutside) NlateralInside++;
}
// choose to parameterise or flag when all inetc...
if(NlateralInside==4) filter=true;
if (NlateralInside == 4) filter = true;
// std::cout << " points = " <<NlateralInside << std::endl;
return filter;
}
void
GFlashShowerModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
void GFlashShowerModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
{
// parametrise electrons
if(fastTrack.GetPrimaryTrack()->GetDefinition()
== G4Electron::ElectronDefinition() ||
fastTrack.GetPrimaryTrack()->GetDefinition()
== G4Positron::PositronDefinition() )
ElectronDoIt(fastTrack,fastStep);
if (fastTrack.GetPrimaryTrack()->GetDefinition() == G4Electron::ElectronDefinition()
|| fastTrack.GetPrimaryTrack()->GetDefinition() == G4Positron::PositronDefinition())
ElectronDoIt(fastTrack, fastStep);
}
void
GFlashShowerModel::ElectronDoIt(const G4FastTrack& fastTrack,
G4FastStep& fastStep)
void GFlashShowerModel::ElectronDoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
{
// std::cout<<"--- ElectronDoit --- "<<std::endl;
fastStep.KillPrimaryTrack();
fastStep.ProposePrimaryTrackPathLength(0.0);
fastStep.ProposeTotalEnergyDeposited(fastTrack.GetPrimaryTrack()->
GetKineticEnergy());
fastStep.ProposeTotalEnergyDeposited(fastTrack.GetPrimaryTrack()->GetKineticEnergy());
//-----------------------------
// Get track parameters
//-----------------------------
//E,vect{p} and t,vec(x)
// Get track parameters
//-----------------------------
// E,vect{p} and t,vec(x)
G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
// axis of the shower, in global reference frame:
G4ThreeVector DirectionShower =
fastTrack.GetPrimaryTrack()->GetMomentumDirection();
G4ThreeVector DirectionShower = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
G4ThreeVector OrthoShower, CrossShower;
OrthoShower = DirectionShower.orthogonal();
CrossShower = DirectionShower.cross(OrthoShower);
//--------------------------------
///Generate longitudinal profile
/// Generate longitudinal profile
//--------------------------------
Parameterisation->GenerateLongitudinalProfile(Energy);
// performance iteration @@@@@@@
///Initialisation of long. loop variables
G4VSolid *SolidCalo = fastTrack.GetEnvelopeSolid();
G4ThreeVector pos = fastTrack.GetPrimaryTrackLocalPosition();
G4ThreeVector dir = fastTrack.GetPrimaryTrackLocalDirection();
G4double Bound = SolidCalo->DistanceToOut(pos,dir);
G4double Dz = 0.00;
// performance iteration @@@@@@@
/// Initialisation of long. loop variables
G4VSolid* SolidCalo = fastTrack.GetEnvelopeSolid();
G4ThreeVector pos = fastTrack.GetPrimaryTrackLocalPosition();
G4ThreeVector dir = fastTrack.GetPrimaryTrackLocalDirection();
G4double Bound = SolidCalo->DistanceToOut(pos, dir);
G4double Dz = 0.00;
G4double ZEndStep = 0.00;
G4double EnergyNow = Energy;
G4double EneIntegral = 0.00;
G4double LastEneIntegral = 0.00;
G4double DEne = 0.00;
G4double NspIntegral = 0.00;
G4double LastNspIntegral = 0.00;
G4double DNsp = 0.00;
G4double EnergyNow = Energy;
G4double EneIntegral = 0.00;
G4double LastEneIntegral = 0.00;
G4double DEne = 0.00;
G4double NspIntegral = 0.00;
G4double LastNspIntegral = 0.00;
G4double DNsp = 0.00;
// starting point of the shower:
G4ThreeVector PositionShower = fastTrack.GetPrimaryTrack()->GetPosition();
G4ThreeVector NewPositionShower = PositionShower;
G4double StepLenght = 0.00;
G4ThreeVector PositionShower = fastTrack.GetPrimaryTrack()->GetPosition();
G4ThreeVector NewPositionShower = PositionShower;
G4double StepLenght = 0.00;
//--------------------------
/// Begin Longitudinal Loop
//-------------------------
do
{
//determine step size=min(1Xo,next boundary)
G4double stepLength = StepInX0*Parameterisation->GetX0();
if(Bound < stepLength)
{
Dz = Bound;
do {
// determine step size=min(1Xo,next boundary)
G4double stepLength = StepInX0 * Parameterisation->GetX0();
if (Bound < stepLength) {
Dz = Bound;
Bound = 0.00;
}
else
{
Dz = stepLength;
Bound = Bound-Dz;
else {
Dz = stepLength;
Bound = Bound - Dz;
}
ZEndStep=ZEndStep+Dz;
ZEndStep = ZEndStep + Dz;
// Determine Energy Release in Step
if(EnergyNow > EnergyStop)
{
LastEneIntegral = EneIntegral;
EneIntegral = Parameterisation->IntegrateEneLongitudinal(ZEndStep);
DEne = std::min( EnergyNow,
(EneIntegral-LastEneIntegral)*Energy);
LastNspIntegral = NspIntegral;
NspIntegral = Parameterisation->IntegrateNspLongitudinal(ZEndStep);
DNsp = std::max(1., std::floor( (NspIntegral-LastNspIntegral)
*Parameterisation->GetNspot() ));
if (EnergyNow > EnergyStop) {
LastEneIntegral = EneIntegral;
EneIntegral = Parameterisation->IntegrateEneLongitudinal(ZEndStep);
DEne = std::min(EnergyNow, (EneIntegral - LastEneIntegral) * Energy);
LastNspIntegral = NspIntegral;
NspIntegral = Parameterisation->IntegrateNspLongitudinal(ZEndStep);
DNsp =
std::max(1., std::floor((NspIntegral - LastNspIntegral) * Parameterisation->GetNspot()));
}
// end of the shower
else
{
else {
DEne = EnergyNow;
DNsp = std::max(1., std::floor( (1.- NspIntegral)
*Parameterisation->GetNspot() ));
}
EnergyNow = EnergyNow - DEne;
DNsp = std::max(1., std::floor((1. - NspIntegral) * Parameterisation->GetNspot()));
}
EnergyNow = EnergyNow - DEne;
// Apply sampling fluctuation - only in sampling calorimeters
//
GFlashSamplingShowerParameterisation* sp =
dynamic_cast<GFlashSamplingShowerParameterisation*>(Parameterisation);
if (sp)
{
G4double DEneSampling = sp->ApplySampling(DEne,Energy);
if (sp) {
G4double DEneSampling = sp->ApplySampling(DEne, Energy);
DEne = DEneSampling;
}
//move particle in the middle of the step
StepLenght = StepLenght + Dz/2.00;
NewPositionShower = NewPositionShower +
StepLenght*DirectionShower;
StepLenght = Dz/2.00;
//generate spots & hits:
for (G4int i = 0; i < DNsp; ++i)
{
GFlashEnergySpot Spot;
//Spot energy: the same for all spots
Spot.SetEnergy( DEne / DNsp );
G4double PhiSpot = Parameterisation->GeneratePhi(); // phi of spot
G4double RSpot = Parameterisation // radius of spot
->GenerateRadius(i,Energy,ZEndStep-Dz/2.);
// move particle in the middle of the step
StepLenght = StepLenght + Dz / 2.00;
NewPositionShower = NewPositionShower + StepLenght * DirectionShower;
StepLenght = Dz / 2.00;
// generate spots & hits:
for (G4int i = 0; i < DNsp; ++i) {
GFlashEnergySpot Spot;
// Spot energy: the same for all spots
Spot.SetEnergy(DEne / DNsp);
G4double PhiSpot = Parameterisation->GeneratePhi(); // phi of spot
G4double RSpot = Parameterisation // radius of spot
->GenerateRadius(i, Energy, ZEndStep - Dz / 2.);
// check reference-> may be need to introduce rot matrix @@@
// Position: equally spaced in z
G4ThreeVector SpotPosition = NewPositionShower +
Dz/DNsp*DirectionShower*(i+1/2.-DNsp/2.) +
RSpot*std::cos(PhiSpot)*OrthoShower +
RSpot*std::sin(PhiSpot)*CrossShower;
G4ThreeVector SpotPosition =
NewPositionShower + Dz / DNsp * DirectionShower * (i + 1 / 2. - DNsp / 2.)
+ RSpot * std::cos(PhiSpot) * OrthoShower + RSpot * std::sin(PhiSpot) * CrossShower;
Spot.SetPosition(SpotPosition);
//Generate Hits of this spot
// Generate Hits of this spot
HMaker->make(&Spot, &fastTrack);
}
}
while(EnergyNow > 0.0 && Bound> 0.0);
} while (EnergyNow > 0.0 && Bound > 0.0);
//---------------
/// End Loop
//---------------
//---------------
}
/*
@@ -334,28 +298,28 @@ GFlashShowerModel::ElectronDoIt(const G4FastTrack& fastTrack,
void
GFlashShowerModel::GammaDoIt(const G4FastTrack& fastTrack,
G4FastStep& fastStep)
{
{
if( fastTrack.GetPrimaryTrack()->GetKineticEnergy() > EnergyStop )
return;
//deposita in uno spot unico l'energia
//con andamento exp decrescente.
//deposita in uno spot unico l'energia
//con andamento exp decrescente.
// Kill the particle to be parametrised
fastStep.KillPrimaryTrack();
fastStep.SetPrimaryTrackPathLength(0.0);
fastStep.SetTotalEnergyDeposited(fastTrack.GetPrimaryTrack()
->GetKineticEnergy());
// other settings????
feSpotList.clear();
feSpotList.clear();
//-----------------------------
// Get track parameters
// Get track parameters
//-----------------------------
// E,vect{p} and t,vec(x)
G4double Energy =
G4double Energy =
fastTrack.GetPrimaryTrack()->GetKineticEnergy();
// axis of the shower, in global reference frame:
G4ThreeVector DirectionShower =
@@ -363,23 +327,23 @@ GFlashShowerModel::GammaDoIt(const G4FastTrack& fastTrack,
// starting point of the shower:
G4ThreeVector PositionShower =
fastTrack.GetPrimaryTrack()->GetPosition();
//G4double DEneSampling = Parameterisation->ApplySampling(Energy,Energy);
//if(DEneSampling <= 0.00) DEneSampling=Energy;
//if(DEneSampling <= 0.00) DEneSampling=Energy;
if(Energy > 0.0)
{
G4double dist = Parameterisation->GenerateExponential(Energy);
G4double dist = Parameterisation->GenerateExponential(Energy);
GFlashEnergySpot Spot;
Spot.SetEnergy( Energy );
G4ThreeVector SpotPosition = PositionShower + dist*DirectionShower;
G4ThreeVector SpotPosition = PositionShower + dist*DirectionShower;
Spot.SetPosition(SpotPosition);
// Record the Spot:
feSpotList.push_back(Spot);
//Generate Hits of this spot
//Generate Hits of this spot
HMaker->make(Spot);
}
}
@@ -33,143 +33,137 @@
// Author: Joanna Weng - 9.11.2004
// ------------------------------------------------------------
#include <iomanip>
#include <sstream>
#include "GFlashShowerModelMessenger.hh"
#include "GFlashShowerModel.hh"
#include "GFlashParticleBounds.hh"
#include "globals.hh"
#include "G4SystemOfUnits.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4SystemOfUnits.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIdirectory.hh"
#include "globals.hh"
GFlashShowerModelMessenger::
GFlashShowerModelMessenger(GFlashShowerModel * aModel)
{
#include "GFlashParticleBounds.hh"
#include "GFlashShowerModel.hh"
#include <iomanip>
#include <sstream>
GFlashShowerModelMessenger::GFlashShowerModelMessenger(GFlashShowerModel* aModel)
{
myParaDir = new G4UIdirectory("/GFlash/");
myParaDir->SetGuidance("Parametrisation control.");
myModel= aModel;
FlagCmd = new G4UIcmdWithAnInteger("/GFlash/flag",this);
myModel = aModel;
FlagCmd = new G4UIcmdWithAnInteger("/GFlash/flag", this);
FlagCmd->SetGuidance("Defines if GFlash is activated");
FlagCmd->SetParameterName("flag",false,false);
ContCmd = new G4UIcmdWithAnInteger("/GFlash/containment ",this);
FlagCmd->SetParameterName("flag", false, false);
ContCmd = new G4UIcmdWithAnInteger("/GFlash/containment ", this);
ContCmd->SetGuidance("Defines if Containment is checked");
ContCmd->SetParameterName("flag",false,false);
StepInX0Cmd = new G4UIcmdWithADouble("/GFlash/stepXo",this);
ContCmd->SetParameterName("flag", false, false);
StepInX0Cmd = new G4UIcmdWithADouble("/GFlash/stepXo", this);
StepInX0Cmd->SetGuidance("Defines step lenghts");
StepInX0Cmd->SetParameterName("flag",false,false);
EminCmd = new G4UIcmdWithADoubleAndUnit("/GFlash/Emin",this);
StepInX0Cmd->SetParameterName("flag", false, false);
EminCmd = new G4UIcmdWithADoubleAndUnit("/GFlash/Emin", this);
EminCmd->SetGuidance("Set minimum kinetic energy to trigger parametrisation");
EminCmd->SetParameterName("Emin",false,false);
EminCmd->SetParameterName("Emin", false, false);
EminCmd->SetDefaultUnit("GeV");
EminCmd->SetUnitCategory("Energy");
EminCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
EmaxCmd = new G4UIcmdWithADoubleAndUnit("/GFlash/Emax",this);
EminCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
EmaxCmd = new G4UIcmdWithADoubleAndUnit("/GFlash/Emax", this);
EmaxCmd->SetGuidance("Set maximum kinetic energy to trigger parametrisation");
EmaxCmd->SetParameterName("Emax",false,false);
EmaxCmd->SetParameterName("Emax", false, false);
EmaxCmd->SetDefaultUnit("GeV");
EmaxCmd->SetUnitCategory("Energy");
EmaxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
EkillCmd = new G4UIcmdWithADoubleAndUnit("/GFlash/Ekill",this);
EmaxCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
EkillCmd = new G4UIcmdWithADoubleAndUnit("/GFlash/Ekill", this);
EkillCmd->SetGuidance("Set maximum kinetic energy for electrons to be killed");
EkillCmd->SetParameterName("Ekill",false,false);
EkillCmd->SetParameterName("Ekill", false, false);
EkillCmd->SetDefaultUnit("GeV");
EkillCmd->SetUnitCategory("Energy");
EkillCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
EkillCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
GFlashShowerModelMessenger::~GFlashShowerModelMessenger()
{
delete ContCmd;
delete FlagCmd;
delete StepInX0Cmd;
delete StepInX0Cmd;
delete EminCmd;
delete EmaxCmd;
delete EkillCmd;
}
void GFlashShowerModelMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
if (command == FlagCmd) {
myModel->SetFlagParamType(FlagCmd->GetNewIntValue(newValues));
this->GetCurrentValue(command);
}
if (command == ContCmd) {
myModel->SetFlagParticleContainment(ContCmd->GetNewIntValue(newValues));
this->GetCurrentValue(command);
}
if (command == StepInX0Cmd) {
myModel->SetStepInX0(StepInX0Cmd->GetNewDoubleValue(newValues));
this->GetCurrentValue(command);
}
void GFlashShowerModelMessenger::
SetNewValue(G4UIcommand * command,G4String newValues)
{
if( command == FlagCmd ) {
myModel->SetFlagParamType(FlagCmd->GetNewIntValue(newValues));
this->GetCurrentValue(command);
}
if( command == ContCmd ) {
myModel->SetFlagParticleContainment(ContCmd->GetNewIntValue(newValues));
this->GetCurrentValue(command);
}
if( command == StepInX0Cmd ) {
myModel->SetStepInX0(StepInX0Cmd->GetNewDoubleValue(newValues));
this->GetCurrentValue(command);
}
else if( command == EminCmd ) {
else if (command == EminCmd) {
myModel->PBound->SetMinEneToParametrise(*G4Electron::ElectronDefinition(),
EminCmd->GetNewDoubleValue(newValues));
this->GetCurrentValue(command);
EminCmd->GetNewDoubleValue(newValues));
this->GetCurrentValue(command);
}
else if( command == EmaxCmd ) {
else if (command == EmaxCmd) {
myModel->PBound->SetMaxEneToParametrise(*G4Electron::ElectronDefinition(),
EmaxCmd->GetNewDoubleValue(newValues));
this->GetCurrentValue(command);
EmaxCmd->GetNewDoubleValue(newValues));
this->GetCurrentValue(command);
}
else if( command == EkillCmd ) {
else if (command == EkillCmd) {
myModel->PBound->SetEneToKill(*G4Electron::ElectronDefinition(),
EkillCmd->GetNewDoubleValue(newValues));
this->GetCurrentValue(command);
EkillCmd->GetNewDoubleValue(newValues));
this->GetCurrentValue(command);
}
}
G4String GFlashShowerModelMessenger::GetCurrentValue(G4UIcommand * command)
G4String GFlashShowerModelMessenger::GetCurrentValue(G4UIcommand* command)
{
G4String returnValue(1,'\0');
G4String returnValue(1, '\0');
std::ostringstream os;
if( command == FlagCmd ) {
os << "/GFlash/flag " << myModel->GetFlagParamType() << '\0';
if (command == FlagCmd) {
os << "/GFlash/flag " << myModel->GetFlagParamType() << '\0';
returnValue = G4String(os.str());
}
else if( command == EkillCmd ) {
os << "/GFlash/Ekill "
<< myModel->PBound->GetEneToKill(*G4Electron::ElectronDefinition())/GeV
else if (command == EkillCmd) {
os << "/GFlash/Ekill " << myModel->PBound->GetEneToKill(*G4Electron::ElectronDefinition()) / GeV
<< " GeV" << '\0';
returnValue = G4String(os.str());
}
else if( command == EminCmd ) {
else if (command == EminCmd) {
os << "/GFlash/Emin "
<< myModel->PBound->GetMinEneToParametrise(*G4Electron::ElectronDefinition())/GeV
<< " GeV" << '\0';
returnValue = G4String(os.str());
}
else if( command == EmaxCmd ) {
os << "/GFlash/Emax "
<< myModel->PBound->GetMaxEneToParametrise(*G4Electron::ElectronDefinition())/GeV
<< " GeV" << '\0';
<< myModel->PBound->GetMinEneToParametrise(*G4Electron::ElectronDefinition()) / GeV << " GeV"
<< '\0';
returnValue = G4String(os.str());
}
else if (command == EmaxCmd) {
os << "/GFlash/Emax "
<< myModel->PBound->GetMaxEneToParametrise(*G4Electron::ElectronDefinition()) / GeV << " GeV"
<< '\0';
returnValue = G4String(os.str());
}
return returnValue;
}
@@ -56,30 +56,29 @@ GVFlashShowerParameterisation::~GVFlashShowerParameterisation()
delete fGamma;
}
G4double GVFlashShowerParameterisation::GetEffZ(const G4Material * mat )
G4double GVFlashShowerParameterisation::GetEffZ(const G4Material* mat)
{
// Returns Z or effective Z=sum(pi*Zi) (if compound/mixture)
// of given material
//
G4double z = 0.;
G4int nofElements = (G4int)mat->GetNumberOfElements();
if (nofElements > 1)
{
for (G4int i=0; i<nofElements; ++i) {
if (nofElements > 1) {
for (G4int i = 0; i < nofElements; ++i) {
G4double zOfElement = mat->GetElement(i)->GetZ();
G4double massFraction = mat->GetFractionVector()[i];
// cout << mat->GetElement(i)->GetName()
// <<" Z= "<<zOfElement << " , Fraction= "<<massFraction <<endl;
z += zOfElement*massFraction;
z += zOfElement * massFraction;
}
}
else {
z = mat->GetZ();
}
else {
z = mat->GetZ();
}
return z;
}
G4double GVFlashShowerParameterisation::GetEffA (const G4Material * mat )
G4double GVFlashShowerParameterisation::GetEffA(const G4Material* mat)
{
// Returns A or effective A=sum(pi*Ai) (if compound/mixture)
// of given material
@@ -87,29 +86,29 @@ G4double GVFlashShowerParameterisation::GetEffA (const G4Material * mat )
G4double a = 0.;
G4int nofElements = (G4int)mat->GetNumberOfElements();
if (nofElements > 1) {
for (G4int i=0; i<nofElements; ++i) {
G4double aOfElement = mat->GetElement(i)->GetA()/(g/mole);
G4double massFraction = mat->GetFractionVector()[i];
a += aOfElement*massFraction;
for (G4int i = 0; i < nofElements; ++i) {
G4double aOfElement = mat->GetElement(i)->GetA() / (g / mole);
G4double massFraction = mat->GetFractionVector()[i];
a += aOfElement * massFraction;
}
}
else {
a = mat->GetA()/(g/mole);
else {
a = mat->GetA() / (g / mole);
}
return a;
}
void GVFlashShowerParameterisation::PrintMaterial(const G4Material * mat)
void GVFlashShowerParameterisation::PrintMaterial(const G4Material* mat)
{
G4cout<<"/********************************************/ " << G4endl;
G4cout<<" - GVFlashShowerParameterisation::Material - " << G4endl;
G4cout<<" Material : " << mat->GetName() << G4endl;
G4cout<<" Z = " << Z << G4endl;
G4cout<<" A = " << A << G4endl;
G4cout<<" X0 = " << X0/cm << " cm" << G4endl;
G4cout<<" Rm = " << Rm/cm << " cm" << G4endl;
G4cout<<" Ec = " << Ec/MeV << " MeV"<< G4endl;
G4cout<<"/********************************************/ " << G4endl;
G4cout << "/********************************************/ " << G4endl;
G4cout << " - GVFlashShowerParameterisation::Material - " << G4endl;
G4cout << " Material : " << mat->GetName() << G4endl;
G4cout << " Z = " << Z << G4endl;
G4cout << " A = " << A << G4endl;
G4cout << " X0 = " << X0 / cm << " cm" << G4endl;
G4cout << " Rm = " << Rm / cm << " cm" << G4endl;
G4cout << " Ec = " << Ec / MeV << " MeV" << G4endl;
G4cout << "/********************************************/ " << G4endl;
}
G4double GVFlashShowerParameterisation::GeneratePhi()
@@ -118,7 +117,7 @@ G4double GVFlashShowerParameterisation::GeneratePhi()
return Phi;
}
G4double GVFlashShowerParameterisation::gam(G4double x, G4double a) const
G4double GVFlashShowerParameterisation::gam(G4double x, G4double a) const
{
return fGamma->Gamma(a, x);
return fGamma->Gamma(a, x);
}
+44 -43
View File
@@ -47,7 +47,7 @@ double MyGamma::Gamma(double z)
}
//____________________________________________________________________________
double MyGamma::Gamma(double a,double x)
double MyGamma::Gamma(double a, double x)
{
// Computation of the incomplete gamma function P(a,x)
//
@@ -55,15 +55,17 @@ double MyGamma::Gamma(double a,double x)
// Numerical Recipes 2nd ed. on p. 210-212 (W.H.Press et al.).
//
//--- Nve 14-nov-1998 UU-SAP Utrecht
if (a <= 0 || x <= 0) return 0;
if (x < (a+1)) return GamSer(a,x);
else return GamCf(a,x);
if (x < (a + 1))
return GamSer(a, x);
else
return GamCf(a, x);
}
//____________________________________________________________________________
double MyGamma::GamCf(double a,double x)
double MyGamma::GamCf(double a, double x)
{
// Computation of the incomplete gamma function P(a,x)
// via its continued fraction representation.
@@ -72,38 +74,38 @@ double MyGamma::GamCf(double a,double x)
// Numerical Recipes 2nd ed. on p. 210-212 (W.H.Press et al.).
//
//--- Nve 14-nov-1998 UU-SAP Utrecht
int itmax = 100; // Maximum number of iterations
double eps = 3.e-7; // Relative accuracy
double fpmin = 1.e-30; // Smallest double value allowed here
int itmax = 100; // Maximum number of iterations
double eps = 3.e-7; // Relative accuracy
double fpmin = 1.e-30; // Smallest double value allowed here
if (a <= 0 || x <= 0) return 0;
double gln = LnGamma(a);
double b = x+1-a;
double c = 1/fpmin;
double d = 1/b;
double h = d;
double an,del;
for (int i=1; i<=itmax; i++) {
an = double(-i)*(double(i)-a);
double b = x + 1 - a;
double c = 1 / fpmin;
double d = 1 / b;
double h = d;
double an, del;
for (int i = 1; i <= itmax; i++) {
an = double(-i) * (double(i) - a);
b += 2;
d = an*d+b;
d = an * d + b;
if (Abs(d) < fpmin) d = fpmin;
c = b+an/c;
c = b + an / c;
if (Abs(c) < fpmin) c = fpmin;
d = 1/d;
del = d*c;
h = h*del;
if (Abs(del-1) < eps) break;
//if (i==itmax) cout << "*GamCf(a,x)* a too large or itmax too small" << endl;
d = 1 / d;
del = d * c;
h = h * del;
if (Abs(del - 1) < eps) break;
// if (i==itmax) cout << "*GamCf(a,x)* a too large or itmax too small" << endl;
}
double v = Exp(-x+a*Log(x)-gln)*h;
return (1-v);
double v = Exp(-x + a * Log(x) - gln) * h;
return (1 - v);
}
//____________________________________________________________________________
double MyGamma::GamSer(double a,double x)
double MyGamma::GamSer(double a, double x)
{
// Computation of the incomplete gamma function P(a,x)
// via its series representation.
@@ -112,28 +114,27 @@ double MyGamma::GamSer(double a,double x)
// Numerical Recipes 2nd ed. on p. 210-212 (W.H.Press et al.).
//
//--- Nve 14-nov-1998 UU-SAP Utrecht
int itmax = 100; // Maximum number of iterations
double eps = 3.e-7; // Relative accuracy
int itmax = 100; // Maximum number of iterations
double eps = 3.e-7; // Relative accuracy
if (a <= 0 || x <= 0) return 0;
double gln = LnGamma(a);
double ap = a;
double sum = 1/a;
double ap = a;
double sum = 1 / a;
double del = sum;
for (int n=1; n<=itmax; n++) {
ap += 1;
del = del*x/ap;
for (int n = 1; n <= itmax; n++) {
ap += 1;
del = del * x / ap;
sum += del;
if (MyGamma::Abs(del) < Abs(sum*eps)) break;
//if (n==itmax) cout << "*GamSer(a,x)* a too large or itmax too small" << endl;
if (MyGamma::Abs(del) < Abs(sum * eps)) break;
// if (n==itmax) cout << "*GamSer(a,x)* a too large or itmax too small" << endl;
}
double v = sum*Exp(-x+a*Log(x)-gln);
double v = sum * Exp(-x + a * Log(x) - gln);
return v;
}
double MyGamma::LnGamma(double z)
{
if (z <= 0)