Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -24,9 +24,10 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4FTFParticipants.cc 74627 2013-10-17 07:04:38Z gcosmo $
// GEANT4 tag $Name: $
//
// ------------------------------------------------------------
// GEANT 4 class implementation file
//
@@ -47,233 +48,302 @@
#include "G4ios.hh"
#include "Randomize.hh"
#include "G4SystemOfUnits.hh"
#include "G4FTFParameters.hh" // Uzhi 29.03.08
#include "G4FTFParameters.hh"
#include "G4DiffractiveSplitableHadron.hh"
#include "G4VSplitableHadron.hh"
G4FTFParticipants::G4FTFParticipants() :
theProjectileNucleus(0),
currentInteraction(-1)
{
}
G4FTFParticipants::G4FTFParticipants(const G4FTFParticipants &): G4VParticipants()
, theProjectileNucleus(0), currentInteraction(-1) //A.R. 14-Aug-2012 Coverity fix.
//============================================================================
//#define debugFTFparticipant
//============================================================================
G4FTFParticipants::G4FTFParticipants() : currentInteraction( -1 ) {}
//============================================================================
G4FTFParticipants::G4FTFParticipants( const G4FTFParticipants& ) :
G4VParticipants(), currentInteraction( -1 )
{
G4Exception("G4FTFParticipants::G4FTFParticipants()","HAD_FTF_001",
FatalException," Must not use copy ctor()");
G4Exception( "G4FTFParticipants::G4FTFParticipants()", "HAD_FTF_001",
FatalException, " Must not use copy ctor()" );
}
G4FTFParticipants::~G4FTFParticipants()
{
if ( theProjectileNucleus != NULL ) delete theProjectileNucleus;
}
//============================================================================
//-------------------------------------------------------------------------
G4FTFParticipants::~G4FTFParticipants() {}
void G4FTFParticipants::SetProjectileNucleus(G4V3DNucleus * aNucleus)
{
if (theProjectileNucleus) delete theProjectileNucleus;
theProjectileNucleus = aNucleus;
}
G4V3DNucleus * G4FTFParticipants::GetProjectileNucleus()
{
return theProjectileNucleus;
}
//============================================================================
void G4FTFParticipants::InitProjectileNucleus(G4int theA, G4int theZ)
{
if ( theProjectileNucleus == NULL ) theProjectileNucleus = new G4Fancy3DNucleus();
theProjectileNucleus->Init(theA, theZ);
theProjectileNucleus->SortNucleonsDecZ();
}
//-------------------------------------------------------------------------
void G4FTFParticipants::GetList(const G4ReactionProduct &thePrimary,
G4FTFParameters *theParameters)
{
//G4cout<<"Participants::GetList"<<G4endl;
//G4cout<<"thePrimary "<<thePrimary.GetMomentum()<<G4endl;
StartLoop(); // reset Loop over Interactions
void G4FTFParticipants::GetList( const G4ReactionProduct& thePrimary,
G4FTFParameters* theParameters ) {
for(unsigned int i=0; i<theInteractions.size(); i++) delete theInteractions[i];
theInteractions.clear();
#ifdef debugFTFparticipant
G4cout << "Participants::GetList" << G4endl
<< "thePrimary " << thePrimary.GetMomentum() << G4endl << G4endl;
#endif
G4double deltaxy=2 * fermi; // Extra nuclear radius
//G4cout<<"theProjectileNucleus "<<theProjectileNucleus<<G4endl;
if(theProjectileNucleus == 0)
{ // Hadron-nucleus or anti-baryon-nucleus interactions
//G4cout<<"Hadron-nucleus or anti-baryon-nucleus interactions"<<G4endl;
G4double betta_z = thePrimary.GetMomentum().z() / thePrimary.GetTotalEnergy();
if ( betta_z < 1.0e-10 ) betta_z = 1.0e-10;
G4double impactX(0.), impactY(0.);
StartLoop(); // reset Loop over Interactions
G4VSplitableHadron * primarySplitable=new G4DiffractiveSplitableHadron(thePrimary);
//G4cout<<"Prim in Part "<<primarySplitable->Get4Momentum()<<G4endl;
G4double xyradius;
xyradius =theNucleus->GetOuterRadius() + deltaxy; // Impact parameter sampling
// G4bool nucleusNeedsShift = true; // Uzhi 20 July 2009
do
{
std::pair<G4double, G4double> theImpactParameter;
theImpactParameter = theNucleus->ChooseImpactXandY(xyradius);
impactX = theImpactParameter.first;
impactY = theImpactParameter.second;
for ( unsigned int i = 0; i < theInteractions.size(); i++ ) delete theInteractions[i];
theInteractions.clear();
G4ThreeVector thePosition(impactX, impactY, -DBL_MAX);
primarySplitable->SetPosition(thePosition);
G4double deltaxy = 2.0 * fermi; // Extra nuclear radius
theNucleus->StartLoop();
G4Nucleon * nucleon;
if ( theProjectileNucleus == 0 ) { // Hadron-nucleus or anti-baryon-nucleus interactions
G4int TrN(0);
while ( (nucleon=theNucleus->GetNextNucleon()) )
{
G4double impact2= sqr(impactX - nucleon->GetPosition().x()) +
sqr(impactY - nucleon->GetPosition().y());
G4double impactX( 0.0 ), impactY( 0.0 );
if ( theParameters->GetProbabilityOfInteraction(impact2/fermi/fermi)
> G4UniformRand() )
{
primarySplitable->SetStatus(1); // It takes part in the interaction
G4VSplitableHadron * targetSplitable=0;
if ( ! nucleon->AreYouHit() )
{
targetSplitable= new G4DiffractiveSplitableHadron(*nucleon);
nucleon->Hit(targetSplitable);
nucleon->SetBindingEnergy(3.*nucleon->GetBindingEnergy());
//G4cout<<" Part nucl "<<TrN<<" "<<nucleon->Get4Momentum()<<G4endl;
//G4cout<<" Part nucl "<<G4endl;
targetSplitable->SetStatus(1); // It takes part in the interaction
}
G4InteractionContent * aInteraction =
new G4InteractionContent(primarySplitable);
aInteraction->SetTarget(targetSplitable);
aInteraction->SetTargetNucleon(nucleon); // Uzhi 16.07.09
aInteraction->SetStatus(1); // Uzhi Feb26
theInteractions.push_back(aInteraction);
}
TrN++;
}
} while ( theInteractions.size() == 0 );
//if ( theInteractions.size() == 0 ) delete primarySplitable; //A.R. 14-Aug-2012 Coverity fix
// G4cout << "Number of Hit nucleons " << theInteractions.size()
// << "\t" << impactX/fermi << "\t"<<impactY/fermi
// << "\t" << std::sqrt(sqr(impactX)+sqr(impactY))/fermi <<G4endl;
return;
} // end of if(theProjectileNucleus == 0)
//-------------------------------------------------------------------
// Projectile and target are nuclei
//-------------------------------------------------------------------
//VU G4VSplitableHadron * primarySplitable=new G4DiffractiveSplitableHadron(thePrimary);
//G4cout<<"Prim in Part "<<primarySplitable->Get4Momentum()<<G4endl;
//G4cout<<"Projectile and target are nuclei"<<G4endl;
//G4cout<<thePrimary.GetMomentum()<<G4endl;
//G4cout<<"Part Pr Tr "<<theProjectileNucleus<<" "<<theNucleus<<G4endl;
G4VSplitableHadron* primarySplitable = new G4DiffractiveSplitableHadron( thePrimary );
#ifdef debugFTFparticipant
G4cout << "Hadron-nucleus or anti-baryon-nucleus interactions" << G4endl;
#endif
G4double xyradius;
xyradius =theProjectileNucleus->GetOuterRadius() + // Impact parameter sampling
theNucleus->GetOuterRadius() + deltaxy;
xyradius = theNucleus->GetOuterRadius() + deltaxy; // Range of impact parameter sampling
do { // while ( theInteractions.size() == 0 )
G4double impactX(0.), impactY(0.);
std::pair< G4double, G4double > theImpactParameter;
theImpactParameter = theNucleus->ChooseImpactXandY( xyradius );
impactX = theImpactParameter.first;
impactY = theImpactParameter.second;
do
{
//G4cout<<"New interaction list"<<G4endl;
std::pair<G4double, G4double> theImpactParameter;
theImpactParameter = theNucleus->ChooseImpactXandY(xyradius);
impactX = theImpactParameter.first;
impactY = theImpactParameter.second;
//G4cout<<"B "<<std::sqrt(sqr(impactX)+sqr(impactY))/fermi<<G4endl;
#ifdef debugFTFparticipant
G4cout << "New interaction list," << " b= "
<< std::sqrt( sqr(impactX ) + sqr( impactY ) )/fermi << G4endl;
#endif
G4ThreeVector thePosition(impactX, impactY, -DBL_MAX);
//VU primarySplitable->SetPosition(thePosition);
G4ThreeVector thePosition( impactX, impactY, 0.0 );
primarySplitable->SetPosition( thePosition );
theProjectileNucleus->StartLoop();
G4Nucleon * ProjectileNucleon;
G4int PrNuclN(0);
theNucleus->StartLoop();
G4Nucleon* nucleon;
while ( (ProjectileNucleon=theProjectileNucleus->GetNextNucleon()) )
{
G4VSplitableHadron * ProjectileSplitable=0;
//G4cout<<G4endl<<"Prj N mom "<<ProjectileNucleon->Get4Momentum()<<"-------------"<<G4endl;
theNucleus->StartLoop();
G4Nucleon * TargetNucleon;
#ifdef debugFTFparticipant
G4int TrN( 0 );
#endif
G4int TrNuclN(0);
while ( (TargetNucleon=theNucleus->GetNextNucleon()) )
{
//G4cout<<"Trg N mom "<<TargetNucleon->Get4Momentum()<<G4endl;
G4double impact2=
sqr(impactX+ProjectileNucleon->GetPosition().x()-TargetNucleon->GetPosition().x())+
sqr(impactY+ProjectileNucleon->GetPosition().y()-TargetNucleon->GetPosition().y());
while ( ( nucleon = theNucleus->GetNextNucleon() ) ) {
G4VSplitableHadron * TargetSplitable=0;
G4double impact2 = sqr( impactX - nucleon->GetPosition().x() ) +
sqr( impactY - nucleon->GetPosition().y() );
if ( theParameters->GetProbabilityOfInteraction(impact2/fermi/fermi)
> G4UniformRand() )
{ // An Interaction has happend!
//G4cout<<"An Interaction has happend"<<G4endl;
//G4cout<<"PrN TrN "<<PrNuclN<<" "<<TrNuclN<<" "<<ProjectileNucleon->GetPosition().z()/fermi<<" "<<TargetNucleon->GetPosition().z()/fermi<<" "<<ProjectileNucleon->GetPosition().z()/fermi + TargetNucleon->GetPosition().z()/fermi <<G4endl;
if ( theParameters->GetProbabilityOfInteraction( impact2/fermi/fermi ) >
G4UniformRand() ) {
primarySplitable->SetStatus( 1 ); // It takes part in the interaction
G4VSplitableHadron* targetSplitable = 0;
if ( ! nucleon->AreYouHit() ) {
targetSplitable = new G4DiffractiveSplitableHadron( *nucleon );
nucleon->Hit( targetSplitable );
targetSplitable->SetStatus( 1 ); // It takes part in the interaction
if ( ! ProjectileNucleon->AreYouHit() )
{ // Projectile nucleon was not involved until now.
ProjectileSplitable= new G4DiffractiveSplitableHadron(*ProjectileNucleon);
ProjectileNucleon->Hit(ProjectileSplitable);
ProjectileNucleon->SetBindingEnergy(3.*ProjectileNucleon->GetBindingEnergy());
ProjectileSplitable->SetStatus(1); // It takes part in the interaction
}
else
{ // Projectile nucleon was involved before.
ProjectileSplitable=ProjectileNucleon->GetSplitableHadron();
} // End of if ( ! Projectileucleon->AreYouHit() )
#ifdef debugFTFparticipant
G4cout << "Participated nucleons #, " << TrN << " " << "Splitable Pr* Tr* "
<< primarySplitable << " " << targetSplitable << G4endl;
#endif
if ( ! TargetNucleon->AreYouHit() )
{ // Target nucleon was not involved until now
TargetSplitable= new G4DiffractiveSplitableHadron(*TargetNucleon);
TargetNucleon->Hit(TargetSplitable);
TargetNucleon->SetBindingEnergy(3.*ProjectileNucleon->GetBindingEnergy());
TargetSplitable->SetStatus(1); // It takes part in the interaction
}
else
{ // Target nucleon was involved before.
TargetSplitable=TargetNucleon->GetSplitableHadron();
} // End of if ( ! TargetNeucleon->AreYouHit() )
}
G4InteractionContent* aInteraction = new G4InteractionContent( primarySplitable );
G4Nucleon* PrNucleon = 0;
aInteraction->SetProjectileNucleon( PrNucleon );
aInteraction->SetTarget( targetSplitable );
aInteraction->SetTargetNucleon( nucleon );
aInteraction->SetStatus( 1 );
aInteraction->SetInteractionTime( ( primarySplitable->GetPosition().z() +
nucleon->GetPosition().z() ) / betta_z );
theInteractions.push_back( aInteraction );
}
G4InteractionContent * anInteraction =
new G4InteractionContent(ProjectileSplitable);
anInteraction->SetTarget(TargetSplitable);
anInteraction->SetTargetNucleon(TargetNucleon);
anInteraction->SetStatus(1); // Uzhi Feb26
// anInteraction->SetInteractionTime(ProjectileNucleon->GetPosition().z()+
// TargetNucleon->GetPosition().z());
//G4cout<<"Z's pr tr "<<ProjectileNucleon->GetPosition().z()/fermi<<" "<<TargetNucleon->GetPosition().z()/fermi<<" "<<ProjectileNucleon->GetPosition().z()/fermi + TargetNucleon->GetPosition().z()/fermi <<G4endl;
theInteractions.push_back(anInteraction);
//G4cout<<"Ppr tr "<<ProjectileSplitable<<" "<<TargetSplitable<<G4endl;
} // End of An Interaction has happend!
TrNuclN++;
} // End of while ( (TargetNucleon=theNucleus->GetNextNucleon()) )
PrNuclN++;
} // End of while ( (ProjectileNucleon=theProjectileNucleus->GetNextNucleon()) )
} while ( theInteractions.size() == 0 ); // end of while ( theInteractions.size() == 0 )
#ifdef debugFTFparticipant
TrN++;
#endif
//std::sort(theInteractions.begin(),theInteractions.end()); // ????
}
// G4cout << "Number of primary collisions " << theInteractions.size()
// << "\t" << impactX/fermi << "\t"<<impactY/fermi
// << "\t" << std::sqrt(sqr(impactX)+sqr(impactY))/fermi <<G4endl;
//G4int Uzhi; G4cin >> Uzhi;
} while ( theInteractions.size() == 0 );
#ifdef debugFTFparticipant
G4cout << "Number of Hit nucleons " << theInteractions.size() << "\t Bx " << impactX/fermi
<< "\t By " << impactY/fermi << "\t B "
<< std::sqrt( sqr( impactX ) + sqr( impactY ) )/fermi << G4endl << G4endl;
#endif
//SortInteractionsIncT(); // Not need because nucleons are sorted in increasing z-coordinates.
ShiftInteractionTime(); // To put correct times and z-coordinates
return;
}
//--------------------------------------------------------------
// Implementation (private) methods
} // end of if ( theProjectileNucleus == 0 )
// Projectile and target are nuclei
#ifdef debugFTFparticipant
G4cout << "Projectile and target are nuclei" << G4endl;
#endif
G4double xyradius;
xyradius = theProjectileNucleus->GetOuterRadius() + // Range of impact parameter sampling
theNucleus->GetOuterRadius() + deltaxy;
G4double impactX( 0.0 ), impactY( 0.0 );
do { // while ( theInteractions.size() == 0 )
std::pair< G4double, G4double > theImpactParameter;
theImpactParameter = theNucleus->ChooseImpactXandY( xyradius );
impactX = theImpactParameter.first;
impactY = theImpactParameter.second;
#ifdef debugFTFparticipant
G4cout << "New interaction list, " << "b "
<< std::sqrt( sqr( impactX ) + sqr( impactY ) )/fermi << G4endl;
#endif
G4ThreeVector theBeamPosition( impactX, impactY, 0.0 );
theProjectileNucleus->StartLoop();
G4Nucleon* ProjectileNucleon;
#ifdef debugFTFparticipant
G4int PrNuclN( 0 );
#endif
while ( ( ProjectileNucleon = theProjectileNucleus->GetNextNucleon() ) ) {
G4VSplitableHadron* ProjectileSplitable = 0;
theNucleus->StartLoop();
G4Nucleon* TargetNucleon = 0;
#ifdef debugFTFparticipant
G4int TrNuclN( 0 );
#endif
while ( ( TargetNucleon = theNucleus->GetNextNucleon() ) ) {
G4double impact2 = sqr( impactX + ProjectileNucleon->GetPosition().x() -
TargetNucleon->GetPosition().x() ) +
sqr( impactY + ProjectileNucleon->GetPosition().y() -
TargetNucleon->GetPosition().y() );
G4VSplitableHadron* TargetSplitable = 0;
if ( theParameters->GetProbabilityOfInteraction( impact2/fermi/fermi ) >
G4UniformRand() ) { // An interaction has happend!
#ifdef debugFTFparticipant
G4cout << G4endl << "An Interaction has happend" << G4endl << "Proj N mom " << PrNuclN
<< " " << ProjectileNucleon->Get4Momentum() << "-------------" << G4endl
<< "Targ N mom " << TrNuclN << " " << TargetNucleon->Get4Momentum() << G4endl
<< "PrN TrN Z coords " << ProjectileNucleon->GetPosition().z()/fermi
<< " " << TargetNucleon->GetPosition().z()/fermi
<< " " << ProjectileNucleon->GetPosition().z()/fermi +
TargetNucleon->GetPosition().z()/fermi << G4endl;
#endif
if ( ! ProjectileNucleon->AreYouHit() ) {
// Projectile nucleon was not involved until now.
ProjectileSplitable = new G4DiffractiveSplitableHadron( *ProjectileNucleon );
ProjectileNucleon->Hit( ProjectileSplitable );
ProjectileSplitable->SetStatus( 1 ); // It takes part in the interaction
} else { // Projectile nucleon was involved before.
ProjectileSplitable = ProjectileNucleon->GetSplitableHadron();
}
if ( ! TargetNucleon->AreYouHit() ) { // Target nucleon was not involved until now
TargetSplitable = new G4DiffractiveSplitableHadron( *TargetNucleon );
TargetNucleon->Hit( TargetSplitable );
TargetSplitable->SetStatus( 1 ); // It takes part in the interaction
} else { // Target nucleon was involved before.
TargetSplitable = TargetNucleon->GetSplitableHadron();
}
G4InteractionContent* anInteraction = new G4InteractionContent( ProjectileSplitable );
anInteraction->SetTarget( TargetSplitable );
anInteraction->SetProjectileNucleon( ProjectileNucleon );
anInteraction->SetTargetNucleon( TargetNucleon );
anInteraction->SetInteractionTime( ( ProjectileNucleon->GetPosition().z() +
TargetNucleon->GetPosition().z() ) / betta_z );
anInteraction->SetStatus( 1 );
#ifdef debugFTFparticipant
G4cout << "Part anInteraction->GetInteractionTime() "
<< anInteraction->GetInteractionTime()/fermi << G4endl
<< "Splitable Pr* Tr* " << ProjectileSplitable << " "
<< TargetSplitable << G4endl;
#endif
theInteractions.push_back( anInteraction );
} // End of an Interaction has happend!
#ifdef debugFTFparticipant
TrNuclN++;
#endif
} // End of while ( ( TargetNucleon = theNucleus->GetNextNucleon() ) )
#ifdef debugFTFparticipant
PrNuclN++;
#endif
} // End of while ( ( ProjectileNucleon = theProjectileNucleus->GetNextNucleon() ) )
if ( theInteractions.size() != 0 ) theProjectileNucleus->DoTranslation( theBeamPosition );
} while ( theInteractions.size() == 0 );
SortInteractionsIncT();
ShiftInteractionTime();
#ifdef debugFTFparticipant
G4cout << G4endl << "Number of primary collisions " << theInteractions.size()
<< "\t Bx " << impactX/fermi << "\t By " << impactY/fermi
<< "\t B " << std::sqrt( sqr( impactX ) + sqr( impactY ) )/fermi << G4endl
<< "FTF participant End. #######################" << G4endl << G4endl;
#endif
return;
}
//============================================================================
bool G4FTFPartHelperForSortInT( const G4InteractionContent* Int1,
const G4InteractionContent* Int2 ) {
return Int1->GetInteractionTime() < Int2->GetInteractionTime();
}
//============================================================================
void G4FTFParticipants::SortInteractionsIncT() { // on increased T
if ( theInteractions.size() < 2 ) return; // Avoid unnecesary work
std::sort( theInteractions.begin(), theInteractions.end(), G4FTFPartHelperForSortInT );
}
//============================================================================
void G4FTFParticipants::ShiftInteractionTime() {
G4double InitialTime = theInteractions[0]->GetInteractionTime();
for ( unsigned int i = 1; i < theInteractions.size(); i++ ) {
G4double InterTime = theInteractions[i]->GetInteractionTime() - InitialTime;
theInteractions[i]->SetInteractionTime( InterTime );
G4InteractionContent* aCollision = theInteractions[i];
G4VSplitableHadron* projectile = aCollision->GetProjectile();
G4VSplitableHadron* target = aCollision->GetTarget();
G4ThreeVector prPosition = projectile->GetPosition();
prPosition.setZ( target->GetPosition().z() );
projectile->SetPosition( prPosition );
projectile->SetTimeOfCreation( InterTime );
target->SetTimeOfCreation( InterTime );
}
return;
}