Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
+14 -1
View File
@@ -1,4 +1,4 @@
$Id: History 97799 2016-06-13 12:13:11Z gcosmo $
$Id: History 100680 2016-10-31 10:52:13Z gcosmo $
-------------------------------------------------------------------
==========================================================
@@ -14,6 +14,19 @@ code and to keep track of all tags.
---------------------------------------------------------------
* Please list in reverse chronological order (last date on top)
---------------------------------------------------------------
25 October 2016 V. Uzhinsky (hadr-mod-util-V10-02-08)
- New method - void SetDefinition(G4ParticleDefinition * aDefinition);
was added to G4Parton class. It is needed for an implementation of
quark exchange processes in QGSM.
16 August 2016 Alberto Ribon (hadr-mod-util-V10-02-07)
- G4KineticTrack : improved the decay part, by checking whether the
sampled decay channel is kinematically below threshold; if this is so,
then the sampling is repeated (but not more than a max number of times).
12 August 2016 Alberto Ribon (hadr-mod-util-V10-02-06)
- G4GeneralPhaseSpaceDecay : added "throw" to hadronic exception
(fix suggested by the PVS-Studio static code analyzer)
10 June 2016 Vladimir Ivanchenko (hadr-mod-util-V10-02-05)
- G4Fragment - real fix of the Coverity warning
@@ -123,7 +123,7 @@ inline
// calculate momentum of daughter particles in two-body decay
if (e-p1-p2 < 0 )
{
G4HadronicException(__FILE__, __LINE__, "G4GeneralPhaseSpaceDecay::Pmx energy in cms > mass1+mass2");
throw G4HadronicException(__FILE__, __LINE__, "G4GeneralPhaseSpaceDecay::Pmx energy in cms > mass1+mass2");
}
G4double ppp = (e+p1+p2)*(e+p1-p2)*(e-p1+p2)*(e-p1-p2)/(4.0*e*e);
if (ppp>0) return std::sqrt(ppp);
@@ -70,8 +70,9 @@ class G4Parton
int operator!=(const G4Parton &right) const;
G4int GetPDGcode() const;
G4ParticleDefinition * GetDefinition();
void SetDefinition(G4ParticleDefinition * aDefinition); // Uzhi
void DefineMomentumInZ(G4double aLightConeMomentum, G4bool aDirection);
void DefineMomentumInZ(G4double aLightConeMomentum,G4double aLightConeE, G4bool aDirection);
@@ -97,9 +98,11 @@ class G4Parton
private:
G4double GetMass();
private:
public:
G4int PDGencoding;
G4ParticleDefinition * theDefinition;
private:
G4LorentzVector theMomentum;
G4ThreeVector thePosition;
@@ -160,5 +163,11 @@ G4ParticleDefinition * G4Parton::GetDefinition()
return theDefinition;
}
inline void G4Parton::SetDefinition(G4ParticleDefinition * aDefinition) // Uzhi
{
theDefinition = aDefinition;
PDGencoding = theDefinition->GetPDGEncoding();
}
#endif
@@ -50,6 +50,7 @@ void G4DecayKineticTracks::Decay(G4KineticTrackVector *tracks) const {
// Select decay of current track, put daughters at end of vector
daughters = track->GetDefinition()->IsShortLived() ? track->Decay() : 0;
if (daughters) {
tracks->insert(tracks->end(), daughters->begin(), daughters->end());
delete track; // Remove parent track
@@ -516,131 +516,160 @@ G4KineticTrackVector* G4KineticTrack::Decay()
G4double theTotalActualWidth = this->EvaluateTotalActualWidth();
if (theTotalActualWidth !=0)
{
G4int index;
G4double theSumActualWidth = 0.0;
G4double* theCumActualWidth = new G4double[nChannels];
for (index = nChannels - 1; index >= 0; index--)
{
theSumActualWidth += theActualWidth[index];
theCumActualWidth[index] = theSumActualWidth;
// cout << "DECAY Cum. Width " << index << " " << theCumActualWidth[index] << G4endl;
}
// cout << "DECAY Total Width " << theSumActualWidth << G4endl;
// cout << "DECAY Total Width " << theTotalActualWidth << G4endl;
G4double r = theTotalActualWidth * G4UniformRand();
G4VDecayChannel* theDecayChannel(0);
G4int chosench=-1;
for (index = nChannels - 1; index >= 0; index--)
{
if (r < theCumActualWidth[index])
{
theDecayChannel = theDecayTable->GetDecayChannel(index);
// cout << "DECAY SELECTED CHANNEL" << index << G4endl;
chosench=index;
break;
}
}
delete [] theCumActualWidth;
if(!theDecayChannel)
{
G4cerr << "Error condition encountered in G4KineticTrack::Decay()"<<G4endl;
G4cerr << " decay channel has 0x0 channel associated."<<G4endl;
G4cerr << " particle was "<<thisDefinition->GetParticleName()<<G4endl;
G4cerr << " channel index "<< chosench << "of "<<nChannels<<"channels"<<G4endl;
return 0;
}
G4String theParentName = theDecayChannel->GetParentName();
G4double theParentMass = this->GetActualMass();
G4double theBR = theActualWidth[index];
// cout << "**BR*** DECAYNEW " << theBR << G4endl;
G4int theNumberOfDaughters = theDecayChannel->GetNumberOfDaughters();
G4String theDaughtersName1 = "";
G4String theDaughtersName2 = "";
G4String theDaughtersName3 = "";
G4String theDaughtersName4 = "";
//AR-16Aug2016 : Repeat the sampling of the decay channel until is
// kinematically above threshold or a max number of attempts is reached
G4bool isChannelBelowThreshold = true;
const G4int maxNumberOfLoops = 10000;
G4int loopCounter = 0;
G4int chosench;
G4String theParentName;
G4double theParentMass;
G4double theBR;
G4int theNumberOfDaughters;
G4String theDaughtersName1;
G4String theDaughtersName2;
G4String theDaughtersName3;
G4String theDaughtersName4;
G4double masses[4]={0.,0.,0.,0.};
G4int shortlivedDaughters[4];
G4int numberOfShortliveds(0);
G4double SumLongLivedMass(0);
for (G4int aD=0; aD < theNumberOfDaughters ; aD++)
{
const G4ParticleDefinition* aDaughter = theDecayChannel->GetDaughter(aD);
masses[aD] = aDaughter->GetPDGMass();
if ( aDaughter->IsShortLived() )
{
shortlivedDaughters[numberOfShortliveds]=aD;
numberOfShortliveds++;
} else {
SumLongLivedMass += aDaughter->GetPDGMass();
}
do {
G4int index;
G4double theSumActualWidth = 0.0;
G4double* theCumActualWidth = new G4double[nChannels];
for (index = nChannels - 1; index >= 0; index--)
{
theSumActualWidth += theActualWidth[index];
theCumActualWidth[index] = theSumActualWidth;
// cout << "DECAY Cum. Width " << index << " " << theCumActualWidth[index] << G4endl;
}
// cout << "DECAY Total Width " << theSumActualWidth << G4endl;
// cout << "DECAY Total Width " << theTotalActualWidth << G4endl;
G4double r = theTotalActualWidth * G4UniformRand();
G4VDecayChannel* theDecayChannel(0);
chosench=-1;
for (index = nChannels - 1; index >= 0; index--)
{
if (r < theCumActualWidth[index])
{
theDecayChannel = theDecayTable->GetDecayChannel(index);
// cout << "DECAY SELECTED CHANNEL" << index << G4endl;
chosench=index;
break;
}
}
delete [] theCumActualWidth;
if(!theDecayChannel)
{
G4cerr << "Error condition encountered in G4KineticTrack::Decay()"<<G4endl;
G4cerr << " decay channel has 0x0 channel associated."<<G4endl;
G4cerr << " particle was "<<thisDefinition->GetParticleName()<<G4endl;
G4cerr << " channel index "<< chosench << "of "<<nChannels<<"channels"<<G4endl;
return 0;
}
theParentName = theDecayChannel->GetParentName();
theParentMass = this->GetActualMass();
theBR = theActualWidth[index];
// cout << "**BR*** DECAYNEW " << theBR << G4endl;
theNumberOfDaughters = theDecayChannel->GetNumberOfDaughters();
theDaughtersName1 = "";
theDaughtersName2 = "";
theDaughtersName3 = "";
theDaughtersName4 = "";
for (G4int i=0; i < 4; i++) masses[i]=0.;
G4int shortlivedDaughters[4];
G4int numberOfShortliveds(0);
G4double SumLongLivedMass(0);
for (G4int aD=0; aD < theNumberOfDaughters ; aD++)
{
const G4ParticleDefinition* aDaughter = theDecayChannel->GetDaughter(aD);
masses[aD] = aDaughter->GetPDGMass();
if ( aDaughter->IsShortLived() )
{
shortlivedDaughters[numberOfShortliveds]=aD;
numberOfShortliveds++;
} else {
SumLongLivedMass += aDaughter->GetPDGMass();
}
}
switch (theNumberOfDaughters)
{
case 0:
break;
case 1:
theDaughtersName1 = theDecayChannel->GetDaughterName(0);
theDaughtersName2 = "";
theDaughtersName3 = "";
theDaughtersName4 = "";
break;
case 2:
theDaughtersName1 = theDecayChannel->GetDaughterName(0);
theDaughtersName2 = theDecayChannel->GetDaughterName(1);
theDaughtersName3 = "";
theDaughtersName4 = "";
if ( numberOfShortliveds == 1)
{ G4SampleResonance aSampler;
G4double massmax=theParentMass - SumLongLivedMass;
const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[0]);
masses[shortlivedDaughters[0]]= aSampler.SampleMass(aDaughter,massmax);
} else if ( numberOfShortliveds == 2) {
// choose masses one after the other, start with randomly choosen
G4int zero= (G4UniformRand() > 0.5) ? 0 : 1;
G4int one = 1-zero;
G4SampleResonance aSampler;
G4double massmax=theParentMass - aSampler.GetMinimumMass(theDecayChannel->GetDaughter(shortlivedDaughters[one]));
const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[zero]);
masses[shortlivedDaughters[zero]]=aSampler.SampleMass(aDaughter,massmax);
massmax=theParentMass - masses[shortlivedDaughters[zero]];
aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[one]);
masses[shortlivedDaughters[one]]=aSampler.SampleMass(aDaughter,massmax);
}
break;
case 3:
theDaughtersName1 = theDecayChannel->GetDaughterName(0);
theDaughtersName2 = theDecayChannel->GetDaughterName(1);
theDaughtersName3 = theDecayChannel->GetDaughterName(2);
theDaughtersName4 = "";
if ( numberOfShortliveds == 1)
{ G4SampleResonance aSampler;
G4double massmax=theParentMass - SumLongLivedMass;
const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[0]);
masses[shortlivedDaughters[0]]= aSampler.SampleMass(aDaughter,massmax);
}
break;
default:
theDaughtersName1 = theDecayChannel->GetDaughterName(0);
theDaughtersName2 = theDecayChannel->GetDaughterName(1);
theDaughtersName3 = theDecayChannel->GetDaughterName(2);
theDaughtersName4 = theDecayChannel->GetDaughterName(3);
if ( numberOfShortliveds == 1)
{ G4SampleResonance aSampler;
G4double massmax=theParentMass - SumLongLivedMass;
const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[0]);
masses[shortlivedDaughters[0]]= aSampler.SampleMass(aDaughter,massmax);
}
if ( theNumberOfDaughters > 4 ) {
G4ExceptionDescription ed;
ed << "More than 4 decay daughters: kept only the first 4" << G4endl;
G4Exception( "G4KineticTrack::Decay()", "KINTRK5", JustWarning, ed );
}
break;
}
}
switch (theNumberOfDaughters)
{
case 0:
break;
case 1:
theDaughtersName1 = theDecayChannel->GetDaughterName(0);
theDaughtersName2 = "";
theDaughtersName3 = "";
theDaughtersName4 = "";
break;
case 2:
theDaughtersName1 = theDecayChannel->GetDaughterName(0);
theDaughtersName2 = theDecayChannel->GetDaughterName(1);
theDaughtersName3 = "";
theDaughtersName4 = "";
if ( numberOfShortliveds == 1)
{ G4SampleResonance aSampler;
G4double massmax=theParentMass - SumLongLivedMass;
const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[0]);
masses[shortlivedDaughters[0]]= aSampler.SampleMass(aDaughter,massmax);
} else if ( numberOfShortliveds == 2) {
// choose masses one after the other, start with randomly choosen
G4int zero= (G4UniformRand() > 0.5) ? 0 : 1;
G4int one = 1-zero;
G4SampleResonance aSampler;
G4double massmax=theParentMass - aSampler.GetMinimumMass(theDecayChannel->GetDaughter(shortlivedDaughters[one]));
const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[zero]);
masses[shortlivedDaughters[zero]]=aSampler.SampleMass(aDaughter,massmax);
massmax=theParentMass - masses[shortlivedDaughters[zero]];
aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[one]);
masses[shortlivedDaughters[one]]=aSampler.SampleMass(aDaughter,massmax);
}
break;
case 3:
theDaughtersName1 = theDecayChannel->GetDaughterName(0);
theDaughtersName2 = theDecayChannel->GetDaughterName(1);
theDaughtersName3 = theDecayChannel->GetDaughterName(2);
theDaughtersName4 = "";
if ( numberOfShortliveds == 1)
{ G4SampleResonance aSampler;
G4double massmax=theParentMass - SumLongLivedMass;
const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[0]);
masses[shortlivedDaughters[0]]= aSampler.SampleMass(aDaughter,massmax);
}
break;
default:
theDaughtersName1 = theDecayChannel->GetDaughterName(0);
theDaughtersName2 = theDecayChannel->GetDaughterName(1);
theDaughtersName3 = theDecayChannel->GetDaughterName(2);
theDaughtersName4 = theDecayChannel->GetDaughterName(3);
if ( numberOfShortliveds == 1)
{ G4SampleResonance aSampler;
G4double massmax=theParentMass - SumLongLivedMass;
const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[0]);
masses[shortlivedDaughters[0]]= aSampler.SampleMass(aDaughter,massmax);
}
if ( theNumberOfDaughters > 4 ) {
G4ExceptionDescription ed;
ed << "More than 4 decay daughters: kept only the first 4" << G4endl;
G4Exception( "G4KineticTrack::Decay()", "KINTRK5", JustWarning, ed );
}
break;
}
//AR-16Aug2016 : Check whether the sum of the masses of the daughters is smaller than the parent mass.
// If this is still not the case, but the max number of attempts has been reached,
// then the subsequent call thePhaseSpaceDecayChannel.DecayIt() will throw an exception.
G4double sumDaughterMasses = 0.0;
for (G4int i=0; i < 4; i++) sumDaughterMasses += masses[i];
if ( theParentMass - sumDaughterMasses > 0.0 ) isChannelBelowThreshold = false;
} while ( isChannelBelowThreshold && ++loopCounter < maxNumberOfLoops ); /* Loop checking, 16.08.2016, A.Ribon */
//
// Get the decay products List