Import Geant4 10.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2017-12-08 12:52:30 +01:00
parent 98e455a940
commit fc6af9e721
2166 changed files with 276760 additions and 100873 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VPartonStringModel.cc 102023 2016-12-16 14:39:26Z gcosmo $
// $Id: G4VPartonStringModel.cc 107318 2017-11-08 16:27:32Z gcosmo $
//
//// ------------------------------------------------------------
// GEANT 4 class implementation file
@@ -50,8 +50,8 @@ G4VPartonStringModel::G4VPartonStringModel(const G4String& modelName)
theThis(0)
{
// Make shure Shotrylived particles are constructed.
G4ShortLivedConstructor ShortLived;
ShortLived.ConstructParticle();
G4ShortLivedConstructor ShortLived;
ShortLived.ConstructParticle();
}
G4VPartonStringModel::~G4VPartonStringModel()
@@ -62,16 +62,12 @@ G4KineticTrackVector * G4VPartonStringModel::Scatter(const G4Nucleus &theNucleus
const G4DynamicParticle &aPrimary)
{
G4ExcitedStringVector * strings = NULL;
G4DynamicParticle thePrimary=aPrimary;
G4LorentzVector SumStringMom(0.,0.,0.,0.);
G4KineticTrackVector * theResult = 0;
G4Nucleon * theNuclNucleon(0);
G4LorentzVector SumStringMom(0.,0.,0.,0.); // Uzhi 21 Sept. 2016
G4KineticTrackVector * theResult = 0; // Uzhi 21 Sept. 2016
G4Nucleon * theNuclNucleon(0); // Uzhi 11 Oct. 2016
#ifdef debug_PartonStringModel
#ifdef debug_PartonStringModel
G4cout<<G4endl;
G4cout<<"-----------------------Parton-String model is runnung ------------"<<G4endl;
G4cout<<"Projectile Name Mass "<<thePrimary.GetDefinition()->GetParticleName()<<" "
@@ -84,16 +80,14 @@ G4KineticTrackVector * G4VPartonStringModel::Scatter(const G4Nucleus &theNucleus
G4cout<<"Initial baryon number "<<Bsum<<G4endl;
G4cout<<"Initial charge "<<Qsum<<G4endl;
G4cout<<"-------------- Parton-String model: Generation of strings -------"<<G4endl<<G4endl;
Bsum -= theNucleus.GetA_asInt(); Qsum -= theNucleus.GetZ_asInt();
if(theThis->GetProjectileNucleus()) {
Bsum -= thePrimary.GetDefinition()->GetBaryonNumber();
Qsum -= thePrimary.GetDefinition()->GetPDGCharge();
}
G4int QsumSec(0), BsumSec(0); // Uzhi 21 Sept. 2016
G4LorentzVector SumPsecondr(0.,0.,0.,0.); // Uzhi 21 Sept. 2016
#endif
G4int QsumSec(0), BsumSec(0);
G4LorentzVector SumPsecondr(0.,0.,0.,0.);
#endif
G4LorentzRotation toZ;
G4LorentzVector Ptmp=thePrimary.Get4Momentum();
@@ -102,256 +96,251 @@ G4KineticTrackVector * G4VPartonStringModel::Scatter(const G4Nucleus &theNucleus
thePrimary.Set4Momentum(toZ*Ptmp);
G4LorentzRotation toLab(toZ.inverse());
G4bool Success=true; // Uzhi 21 Sept. 2016
G4int attempts = 0, maxAttempts=1000; // Uzhi 12 Oct. 2016
do // Uzhi 21 Sept. 2016
G4bool Success=true;
G4int attempts = 0, maxAttempts=1000;
do
{
if (attempts++ > maxAttempts )
{
theThis->Init(theNucleus,thePrimary); // To put a nucleus into ground state
// But marks of hitted nucleons are left. They must be erased.
G4V3DNucleus * ResNucleus=theThis->GetWoundedNucleus();
theNuclNucleon = ResNucleus->StartLoop() ? ResNucleus->GetNextNucleon() : NULL;
while( theNuclNucleon )
{
if(theNuclNucleon->AreYouHit()) theNuclNucleon->Hit(nullptr);
theNuclNucleon = ResNucleus->GetNextNucleon();
}
G4V3DNucleus * ProjResNucleus=theThis->GetProjectileNucleus();
if(ProjResNucleus != 0)
{
theNuclNucleon = ProjResNucleus->StartLoop() ? ProjResNucleus->GetNextNucleon() : NULL;
while( theNuclNucleon )
{
if(theNuclNucleon->AreYouHit()) theNuclNucleon->Hit(nullptr);
theNuclNucleon = ProjResNucleus->GetNextNucleon();
}
}
G4ExceptionDescription ed;
ed << "Projectile Name Mass " <<thePrimary.GetDefinition()->GetParticleName()
<< " " << thePrimary.GetMass()<< G4endl;
ed << "           Momentum  " << thePrimary.Get4Momentum() <<G4endl;
ed << "Target nucleus   A Z " << theNucleus.GetA_asInt() << " "
<< theNucleus.GetZ_asInt() <<G4endl;
ed << "Initial states of projectile and target nucleus will be returned!"<<G4endl;
G4Exception( "G4VPartonStringModel::Scatter(): fails to generate or fragment strings ",
"HAD_PARTON_STRING_001", JustWarning, ed );
G4ThreeVector Position(0.,0.,2*ResNucleus->GetOuterRadius());
G4KineticTrack* Hadron = new G4KineticTrack(aPrimary.GetParticleDefinition(),
0., Position,
aPrimary.Get4Momentum());
if(theResult == 0) theResult = new G4KineticTrackVector();
theResult->push_back(Hadron);
return theResult;
}
Success=true;
theThis->Init(theNucleus,thePrimary);
strings = GetStrings();
if(strings == 0) {Success=false; continue;} // Uzhi 28 Sept. 2016
G4double stringEnergy(0);
SumStringMom=G4LorentzVector(0.,0.,0.,0.); // Uzhi 21 Sept. 2016
#ifdef debug_PartonStringModel
G4cout<<"------------ Parton-String model: Number of produced strings ---- "<<strings->size()<<G4endl;
#endif
for ( unsigned int astring=0; astring < strings->size(); astring++)
{
// rotate string to lab frame, models have it aligned to z
if((*strings)[astring]->IsExcited())
if (attempts++ > maxAttempts )
{
stringEnergy += (*strings)[astring]->GetLeftParton()->Get4Momentum().t();
stringEnergy += (*strings)[astring]->GetRightParton()->Get4Momentum().t();
(*strings)[astring]->LorentzRotate(toLab);
SumStringMom+=(*strings)[astring]->Get4Momentum();
#ifdef debug_PartonStringModel
G4cout<<"String No "<<astring+1<<" "<<(*strings)[astring]->Get4Momentum()<<" "
<<(*strings)[astring]->Get4Momentum().mag()
<<" Partons "<<(*strings)[astring]->GetLeftParton()->GetDefinition()->GetPDGEncoding()
<<" "<<(*strings)[astring]->GetRightParton()->GetDefinition()->GetPDGEncoding()<<G4endl;
#endif
theThis->Init(theNucleus,thePrimary); // To put a nucleus into ground state
// But marks of hitted nucleons are left. They must be erased.
G4V3DNucleus * ResNucleus=theThis->GetWoundedNucleus();
theNuclNucleon = ResNucleus->StartLoop() ? ResNucleus->GetNextNucleon() : NULL;
while( theNuclNucleon )
{
if(theNuclNucleon->AreYouHit()) theNuclNucleon->Hit(nullptr);
theNuclNucleon = ResNucleus->GetNextNucleon();
}
G4V3DNucleus * ProjResNucleus=theThis->GetProjectileNucleus();
if(ProjResNucleus != 0)
{
theNuclNucleon = ProjResNucleus->StartLoop() ? ProjResNucleus->GetNextNucleon() : NULL;
while( theNuclNucleon )
{
if(theNuclNucleon->AreYouHit()) theNuclNucleon->Hit(nullptr);
theNuclNucleon = ProjResNucleus->GetNextNucleon();
}
}
G4ExceptionDescription ed;
ed << "Projectile Name Mass " <<thePrimary.GetDefinition()->GetParticleName()
<< " " << thePrimary.GetMass()<< G4endl;
ed << "           Momentum  " << thePrimary.Get4Momentum() <<G4endl;
ed << "Target nucleus   A Z " << theNucleus.GetA_asInt() << " "
<< theNucleus.GetZ_asInt() <<G4endl;
ed << "Initial states of projectile and target nucleus will be returned!"<<G4endl;
G4Exception( "G4VPartonStringModel::Scatter(): fails to generate or fragment strings ",
"HAD_PARTON_STRING_001", JustWarning, ed );
G4ThreeVector Position(0.,0.,2*ResNucleus->GetOuterRadius());
G4KineticTrack* Hadron = new G4KineticTrack(aPrimary.GetParticleDefinition(), 0.,
Position, aPrimary.Get4Momentum());
if(theResult == 0) theResult = new G4KineticTrackVector();
theResult->push_back(Hadron);
return theResult;
}
else
Success=true;
theThis->Init(theNucleus,thePrimary);
strings = GetStrings();
if(strings == 0) {Success=false; continue;}
G4double stringEnergy(0);
SumStringMom=G4LorentzVector(0.,0.,0.,0.);
#ifdef debug_PartonStringModel
G4cout<<"------------ Parton-String model: Number of produced strings ---- "<<strings->size()<<G4endl;
#endif
for ( unsigned int astring=0; astring < strings->size(); astring++)
{
stringEnergy += (*strings)[astring]->GetKineticTrack()->Get4Momentum().t();
(*strings)[astring]->LorentzRotate(toLab);
SumStringMom+=(*strings)[astring]->GetKineticTrack()->Get4Momentum();
#ifdef debug_PartonStringModel
G4cout<<"A track No "<<astring+1<<" "
<<(*strings)[astring]->GetKineticTrack()->Get4Momentum()<<" "
<<(*strings)[astring]->GetKineticTrack()->Get4Momentum().mag()<<" "
<<(*strings)[astring]->GetKineticTrack()->GetDefinition()->GetParticleName()<<G4endl;
#endif
// rotate string to lab frame, models have it aligned to z
if((*strings)[astring]->IsExcited())
{
stringEnergy += (*strings)[astring]->GetLeftParton()->Get4Momentum().t();
stringEnergy += (*strings)[astring]->GetRightParton()->Get4Momentum().t();
(*strings)[astring]->LorentzRotate(toLab);
SumStringMom+=(*strings)[astring]->Get4Momentum();
#ifdef debug_PartonStringModel
G4cout<<"String No "<<astring+1<<" "<<(*strings)[astring]->Get4Momentum()<<" "
<<(*strings)[astring]->Get4Momentum().mag()
<<" Partons "<<(*strings)[astring]->GetLeftParton()->GetDefinition()->GetPDGEncoding()
<<" "<<(*strings)[astring]->GetRightParton()->GetDefinition()->GetPDGEncoding()<<G4endl;
#endif
}
else
{
stringEnergy += (*strings)[astring]->GetKineticTrack()->Get4Momentum().t();
(*strings)[astring]->LorentzRotate(toLab);
SumStringMom+=(*strings)[astring]->GetKineticTrack()->Get4Momentum();
#ifdef debug_PartonStringModel
G4cout<<"A track No "<<astring+1<<" "
<<(*strings)[astring]->GetKineticTrack()->Get4Momentum()<<" "
<<(*strings)[astring]->GetKineticTrack()->Get4Momentum().mag()<<" "
<<(*strings)[astring]->GetKineticTrack()->GetDefinition()->GetParticleName()<<G4endl;
#endif
}
}
}
#ifdef debug_PartonStringModel
G4cout<<G4endl<<"SumString4Mom "<<SumStringMom<<G4endl;
#ifdef debug_PartonStringModel
G4cout<<G4endl<<"SumString4Mom "<<SumStringMom<<G4endl;
G4LorentzVector TargetResidual4Momentum(0.,0.,0.,0.);
G4LorentzVector ProjectileResidual4Momentum(0.,0.,0.,0.);
G4int hitsT(0), charged_hitsT(0);
G4int hitsP(0), charged_hitsP(0);
G4double ExcitationEt(0.), ExcitationEp(0.);
#endif
G4LorentzVector TargetResidual4Momentum(0.,0.,0.,0.);
G4LorentzVector ProjectileResidual4Momentum(0.,0.,0.,0.);
G4int hitsT(0), charged_hitsT(0);
G4int hitsP(0), charged_hitsP(0);
G4double ExcitationEt(0.), ExcitationEp(0.);
#endif
G4V3DNucleus * ProjResNucleus=theThis->GetProjectileNucleus();
G4V3DNucleus * ProjResNucleus=theThis->GetProjectileNucleus();
if(ProjResNucleus != 0)
{
theNuclNucleon = ProjResNucleus->StartLoop() ? ProjResNucleus->GetNextNucleon() : NULL;
while( theNuclNucleon )
{
if(theNuclNucleon->AreYouHit())
{
G4LorentzVector tmp=toLab*theNuclNucleon->Get4Momentum();
#ifdef debug_PartonStringModel
ProjectileResidual4Momentum += tmp;
hitsP++;
if ( theNuclNucleon->GetDefinition() == G4Proton::Proton() ) ++charged_hitsP;
ExcitationEp +=theNuclNucleon->GetBindingEnergy();
#endif
theNuclNucleon->SetMomentum(tmp);
}
theNuclNucleon = ProjResNucleus->GetNextNucleon();
}
#ifdef debug_PartonStringModel
G4cout<<"Projectile residual A, Z and E* "
<<thePrimary.GetDefinition()->GetBaryonNumber() - hitsP<<" "
<<thePrimary.GetDefinition()->GetPDGCharge() - charged_hitsP<<" "
<<ExcitationEp<<G4endl;
G4cout<<"Projectile residual 4 momentum "<<ProjectileResidual4Momentum<<G4endl;
#endif
}
if(ProjResNucleus != 0)
{
theNuclNucleon = ProjResNucleus->StartLoop() ? ProjResNucleus->GetNextNucleon() : NULL;
G4V3DNucleus * ResNucleus=theThis->GetWoundedNucleus();
// loop over wounded nucleus
theNuclNucleon = ResNucleus->StartLoop() ? ResNucleus->GetNextNucleon() : NULL;
while( theNuclNucleon )
{
if(theNuclNucleon->AreYouHit())
{
G4LorentzVector tmp=toLab*theNuclNucleon->Get4Momentum();
#ifdef debug_PartonStringModel
ProjectileResidual4Momentum += tmp;
hitsP++;
if ( theNuclNucleon->GetDefinition() == G4Proton::Proton() ) ++charged_hitsP;
ExcitationEp +=theNuclNucleon->GetBindingEnergy();
#endif
theNuclNucleon->SetMomentum(tmp);
}
theNuclNucleon = ProjResNucleus->GetNextNucleon();
if(theNuclNucleon->AreYouHit())
{
G4LorentzVector tmp=toLab*theNuclNucleon->Get4Momentum();
#ifdef debug_PartonStringModel
TargetResidual4Momentum += tmp;
hitsT++;
if ( theNuclNucleon->GetDefinition() == G4Proton::Proton() ) ++charged_hitsT;
ExcitationEt +=theNuclNucleon->GetBindingEnergy();
#endif
theNuclNucleon->SetMomentum(tmp);
}
theNuclNucleon = ResNucleus->GetNextNucleon();
}
#ifdef debug_PartonStringModel
G4cout<<"Projectile residual A, Z and E* "
<<thePrimary.GetDefinition()->GetBaryonNumber() - hitsP<<" "
<<thePrimary.GetDefinition()->GetPDGCharge() - charged_hitsP<<" "
<<ExcitationEp<<G4endl;
G4cout<<"Projectile residual 4 momentum "<<ProjectileResidual4Momentum<<G4endl;
#endif
}
G4V3DNucleus * ResNucleus=theThis->GetWoundedNucleus();
#ifdef debug_PartonStringModel
G4cout<<"Target residual A, Z and E* "
<<theNucleus.GetA_asInt() - hitsT<<" "
<<theNucleus.GetZ_asInt() - charged_hitsT<<" "
<<ExcitationEt<<G4endl;
G4cout<<"Target residual 4 momentum "<<TargetResidual4Momentum<<G4endl;
Bsum+=( hitsT + hitsP);
Qsum+=(charged_hitsT + charged_hitsP);
G4cout<<"Hitted # of nucleons of projectile and target "<<hitsP<<" "<<hitsT<<G4endl;
G4cout<<"Hitted # of protons of projectile and target "
<<charged_hitsP<<" "<<charged_hitsT<<G4endl<<G4endl;
G4cout<<"Bsum Qsum "<<Bsum<<" "<<Qsum<<G4endl<<G4endl;
#endif
// loop over wounded nucleus
theNuclNucleon = ResNucleus->StartLoop() ? ResNucleus->GetNextNucleon() : NULL;
while( theNuclNucleon )
{
if(theNuclNucleon->AreYouHit())
{
G4LorentzVector tmp=toLab*theNuclNucleon->Get4Momentum();
//=========================================================================================
// Fragment strings
#ifdef debug_PartonStringModel
G4cout<<"---------------- Attempt to fragment strings ------------- "<<attempts<<G4endl;
#endif
G4double InvMass=SumStringMom.mag();
G4double SumMass(0.);
#ifdef debug_PartonStringModel
QsumSec=0; BsumSec=0;
SumPsecondr=G4LorentzVector(0.,0.,0.,0.);
#endif
if(theResult != 0)
{
std::for_each(theResult->begin(), theResult->end(), DeleteKineticTrack());
delete theResult;
}
theResult = stringFragmentationModel->FragmentStrings(strings);
#ifdef debug_PartonStringModel
G4cout<<"String fragmentation success (OK - #0, Not OK - 0) : "<<theResult<<G4endl;
#endif
if(theResult == 0) {Success=false; continue;}
#ifdef debug_PartonStringModel
G4cout<<"Parton-String model: Number of produced particles "<<theResult->size()<<G4endl;
SumPsecondr = G4LorentzVector(0.,0.,0.,0.);
QsumSec = 0; BsumSec = 0;
#endif
SumMass=0.;
for ( unsigned int i=0; i < theResult->size(); i++)
{
SumMass+=(*theResult)[i]->Get4Momentum().mag();
#ifdef debug_PartonStringModel
TargetResidual4Momentum += tmp;
hitsT++;
if ( theNuclNucleon->GetDefinition() == G4Proton::Proton() ) ++charged_hitsT;
ExcitationEt +=theNuclNucleon->GetBindingEnergy();
G4cout<<i<<" : "<<(*theResult)[i]->GetDefinition()->GetParticleName()<<" "
<<(*theResult)[i]->Get4Momentum()<<" "
<<(*theResult)[i]->Get4Momentum().mag()<<" "
<<(*theResult)[i]->GetDefinition()->GetPDGMass()<<G4endl;
SumPsecondr+=(*theResult)[i]->Get4Momentum();
BsumSec += (*theResult)[i]->GetDefinition()->GetBaryonNumber();
QsumSec += (*theResult)[i]->GetDefinition()->GetPDGCharge();
#endif
theNuclNucleon->SetMomentum(tmp);
}
theNuclNucleon = ResNucleus->GetNextNucleon();
}
#ifdef debug_PartonStringModel
G4cout<<"Target residual A, Z and E* "
<<theNucleus.GetA_asInt() - hitsT<<" "
<<theNucleus.GetZ_asInt() - charged_hitsT<<" "
<<ExcitationEt<<G4endl;
G4cout<<"Target residual 4 momentum "<<TargetResidual4Momentum<<G4endl;
}
Bsum+=( hitsT + hitsP);
Qsum+=(charged_hitsT + charged_hitsP);
#ifdef debug_PartonStringModel
G4cout<<G4endl<<"-----------------------Parton-String model: balances -------------"<<G4endl;
if(Qsum != QsumSec) {
G4cout<<"Charge is not conserved!!! ----"<<G4endl;
G4cout<<" Qsum != QsumSec "<<Qsum<<" "<<QsumSec<<G4endl;
}
if(Bsum != BsumSec) {
G4cout<<"Baryon number is not conserved!!!"<<G4endl;
G4cout<<" Bsum != BsumSec "<<Bsum<<" "<<BsumSec<<G4endl;
}
#endif
G4cout<<"Hitted # of nucleons of projectile and target "<<hitsP<<" "<<hitsT<<G4endl;
G4cout<<"Hitted # of protons of projectile and target "
<<charged_hitsP<<" "<<charged_hitsT<<G4endl<<G4endl;
G4cout<<"Bsum Qsum "<<Bsum<<" "<<Qsum<<G4endl<<G4endl;
#endif
if((SumMass > InvMass)||(SumMass == 0.)) {Success=false;}
std::for_each(strings->begin(), strings->end(), DeleteString() );
delete strings;
//=========================================================================================
// Fragment strings
#ifdef debug_PartonStringModel
G4cout<<"---------------- Attempt to fragment strings ------------- "<<attempts<<G4endl;
#endif
} while(!Success);
G4double InvMass=SumStringMom.mag();
G4double SumMass(0.);
#ifdef debug_PartonStringModel
QsumSec=0; BsumSec=0; // Uzhi 21 Sept. 2016
SumPsecondr=G4LorentzVector(0.,0.,0.,0.); // Uzhi 21 Sept. 2016
#endif
if(theResult != 0)
{
std::for_each(theResult->begin(), theResult->end(), DeleteKineticTrack());
delete theResult;
}
theResult = stringFragmentationModel->FragmentStrings(strings);
#ifdef debug_PartonStringModel
G4cout<<"String fragmentation success (OK - #0, Not OK - 0) : "<<theResult<<G4endl;
#endif
if(theResult == 0) {Success=false; continue;} // Uzhi 21 Sept. 2016
#ifdef debug_PartonStringModel
G4cout<<"Parton-String model: Number of produced particles "<<theResult->size()<<G4endl;
SumPsecondr = G4LorentzVector(0.,0.,0.,0.);
QsumSec = 0; BsumSec = 0;
#endif
SumMass=0.;
for ( unsigned int i=0; i < theResult->size(); i++)
{
SumMass+=(*theResult)[i]->Get4Momentum().mag();
#ifdef debug_PartonStringModel
G4cout<<i<<" : "<<(*theResult)[i]->GetDefinition()->GetParticleName()<<" "
<<(*theResult)[i]->Get4Momentum()<<" "
<<(*theResult)[i]->Get4Momentum().mag()<<" "
<<(*theResult)[i]->GetDefinition()->GetPDGMass()<<G4endl;
SumPsecondr+=(*theResult)[i]->Get4Momentum();
BsumSec += (*theResult)[i]->GetDefinition()->GetBaryonNumber();
QsumSec += (*theResult)[i]->GetDefinition()->GetPDGCharge();
#endif
}
#ifdef debug_PartonStringModel
G4cout<<G4endl<<"-----------------------Parton-String model: balances -------------"<<G4endl;
if(Qsum != QsumSec) {
G4cout<<"Charge is not conserved!!! ----"<<G4endl;
G4cout<<" Qsum != QsumSec "<<Qsum<<" "<<QsumSec<<G4endl;
}
if(Bsum != BsumSec) {
G4cout<<"Baryon number is not conserved!!!"<<G4endl;
G4cout<<" Bsum != BsumSec "<<Bsum<<" "<<BsumSec<<G4endl;
}
#endif
if((SumMass > InvMass)||(SumMass == 0.)) {Success=false;} // Uzhi 21 Sept. 2016
std::for_each(strings->begin(), strings->end(), DeleteString() );
delete strings;
} while(!Success); // End of do // Uzhi 21 Sept. 2016
#ifdef debug_PartonStringModel
#ifdef debug_PartonStringModel
G4cout <<"Baryon number balance "<<Bsum-BsumSec<<G4endl;
G4cout <<"Charge balance "<<Qsum-QsumSec<<G4endl;
G4cout <<"4 momentum balance "<<SumStringMom-SumPsecondr<<G4endl;
G4cout<<"---------------------End of Parton-String model work -------------"<<G4endl<<G4endl;
#endif
#endif
return theResult;
}
void G4VPartonStringModel::ModelDescription(std::ostream& outFile) const
{
outFile << GetModelName() << " has no description yet.\n";
outFile << GetModelName() << " has no description yet.\n";
}
G4V3DNucleus * G4VPartonStringModel::GetProjectileNucleus() const
{ return 0;}
{ return 0; }