Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
*.d
+60
View File
@@ -0,0 +1,60 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4EvManMessenger.cc,v 2.2 1998/07/12 03:42:25 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// --------------------------------------------------------------------
#include "G4EvManMessenger.hh"
#include "G4EventManager.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAnInteger.hh"
G4EvManMessenger::G4EvManMessenger(G4EventManager * fEvMan)
:fEvManager(fEvMan)
{
eventDirectory = new G4UIdirectory("/event/");
eventDirectory->SetGuidance("EventManager control commands.");
abortCmd = new G4UIcmdWithoutParameter("/event/abort",this);
abortCmd->SetGuidance("Abort current event.");
abortCmd->AvailableForStates(EventProc);
verboseCmd = new G4UIcmdWithAnInteger("/event/verbose",this);
verboseCmd->SetGuidance("Set Verbose level of event management category.");
verboseCmd->SetGuidance(" 0 : Silent");
verboseCmd->SetGuidance(" 1 : Stacking information");
verboseCmd->SetGuidance(" 2 : More...");
verboseCmd->SetParameterName("level",false);
verboseCmd->SetRange("level>=0");
}
G4EvManMessenger::~G4EvManMessenger()
{
delete abortCmd;
delete verboseCmd;
delete eventDirectory;
}
void G4EvManMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
{
if( command == verboseCmd )
{ fEvManager->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues)); }
if( command == abortCmd )
{ fEvManager->AbortCurrentEvent(); }
}
G4String G4EvManMessenger::GetCurrentValue(G4UIcommand * command)
{
G4String cv;
if( command == verboseCmd )
{ cv = verboseCmd->ConvertToString(fEvManager->GetVerboseLevel()); }
return cv;
}
+95
View File
@@ -0,0 +1,95 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Event.cc,v 2.3 1998/09/21 02:02:09 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
// G4Event
#include "G4Event.hh"
#include "G4VVisManager.hh"
//#include "G4HCofThisEvent.hh"
//#include "G4DCofThisEvent.hh"
#include "G4VHitsCollection.hh"
#include "G4VDigiCollection.hh"
#include "G4ios.hh"
G4Allocator<G4Event> anEventAllocator;
G4Event::G4Event()
:eventID(0),
thePrimaryVertex(NULL),numberOfPrimaryVertex(0),
DC(NULL),HC(NULL),trajectoryContainer(NULL)
{;}
G4Event::G4Event(G4int evID)
:eventID(evID),
thePrimaryVertex(NULL),numberOfPrimaryVertex(0),
DC(NULL),HC(NULL),trajectoryContainer(NULL)
{;}
G4Event::~G4Event()
{
if(thePrimaryVertex) delete thePrimaryVertex;
if(HC) delete HC;
if(DC) delete DC;
if(trajectoryContainer)
{
trajectoryContainer->clearAndDestroy();
delete trajectoryContainer;
}
}
int G4Event::operator==(const G4Event &right) const
{
return ( eventID == right.eventID );
}
int G4Event::operator!=(const G4Event &right) const
{
return ( eventID != right.eventID );
}
void G4Event::Print() const
{
G4cout << "G4Event " << eventID << endl;
}
void G4Event::Draw() const
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(!pVVisManager) return;
if(trajectoryContainer)
{
G4int n_traj = trajectoryContainer->entries();
for(int i=0;i<n_traj;i++)
{ (*trajectoryContainer)[i]->DrawTrajectory(); }
}
if(HC)
{
G4int n_HC = HC->GetCapacity();
for(int j=0;j<n_HC;j++)
{
G4VHitsCollection * VHC = HC->GetHC(j);
if(VHC) VHC->DrawAllHits();
}
}
if(DC)
{
G4int n_DC = DC->GetCapacity();
for(int j=0;j<n_DC;j++)
{
G4VDigiCollection * VDC = DC->GetDC(j);
if(VDC) VDC->DrawAllDigi();
}
}
}
+219
View File
@@ -0,0 +1,219 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4EventManager.cc,v 2.2 1998/07/13 16:50:12 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//
#include "G4EventManager.hh"
#include "G4ios.hh"
#include "G4EvManMessenger.hh"
#include "G4Event.hh"
#include "G4UserEventAction.hh"
#include "G4UserStackingAction.hh"
#include "G4SDManager.hh"
G4EventManager::G4EventManager()
:verboseLevel(0),trajectoryContainer(NULL),userEventAction(NULL),
tracking(false),currentEvent(NULL)
{
trackManager = new G4TrackingManager;
transformer = new G4PrimaryTransformer;
trackContainer = new G4StackManager;
theMessenger = new G4EvManMessenger(this);
sdManager = G4SDManager::GetSDMpointerIfExist();
}
// private -> never called
G4EventManager::G4EventManager(const G4EventManager &right) { }
G4EventManager& G4EventManager::operator=(const G4EventManager& right)
{
return *this;
}
G4EventManager::~G4EventManager()
{
delete trackContainer;
delete transformer;
delete trackManager;
delete theMessenger;
if (userEventAction) delete userEventAction;
}
/*
const G4EventManager & G4EventManager::operator=(const G4EventManager &right)
{ }
int G4EventManager::operator==(const G4EventManager &right) const { }
int G4EventManager::operator!=(const G4EventManager &right) const { }
*/
void G4EventManager::ProcessOneEvent(G4Event* anEvent)
{
currentEvent = anEvent;
G4Track * track;
G4TrackStatus istop;
#ifdef G4VERBOSE
if ( verboseLevel > 0 )
{
G4cout << "=====================================" << endl;
G4cout << " G4EventManager::ProcessOneEvent() " << endl;
G4cout << "=====================================" << endl;
}
#endif
trackIDCounter = trackContainer->PrepareNewEvent();
#ifdef G4_STORE_TRAJECTORY
trajectoryContainer = NULL;
#endif
sdManager = G4SDManager::GetSDMpointerIfExist();
if(sdManager)
{ currentEvent->SetHCofThisEvent(sdManager->PrepareNewEvent()); }
if(userEventAction) userEventAction->BeginOfEventAction();
#ifdef G4VERBOSE
if ( verboseLevel > 1 )
{
G4cout << currentEvent->GetNumberOfPrimaryVertex()
<< " vertices passed from G4Event." << endl;
}
#endif
StackTracks( transformer->GimmePrimaries( currentEvent ) );
#ifdef G4VERBOSE
if ( verboseLevel > 0 )
{
G4cout << trackContainer->GetNTotalTrack() << " primaries "
<< "are passed from G4EventTransformer." << endl;
G4cout << "!!!!!!! Now start processing an event !!!!!!!" << endl;
}
#endif
while( ( track = trackContainer->PopNextTrack() ) != NULL )
{
#ifdef G4VERBOSE
if ( verboseLevel > 1 )
{
G4cout << "Track " << track << " (trackID " << track->GetTrackID()
<< ", parentID " << track->GetParentID()
<< ") is passed to G4TrackingManager." << endl;
}
#endif
tracking = true;
trackManager->ProcessOneTrack( track );
istop = track->GetTrackStatus();
tracking = false;
#ifdef G4VERBOSE
if ( verboseLevel > 0 )
{
G4cout << "Track (trackID " << track->GetTrackID()
<< ", parentID " << track->GetParentID()
<< ") is processed with stopping code " << istop << endl;
}
#endif
#ifdef G4_STORE_TRAJECTORY
G4Trajectory * aTrajectory = trackManager->GimmeTrajectory();
if(aTrajectory)
{
if(!trajectoryContainer)
{ trajectoryContainer = new G4TrajectoryContainer; }
trajectoryContainer->insert(aTrajectory);
}
#endif
G4TrackVector * secondaries = trackManager->GimmeSecondaries();
switch (istop)
{
case fStopButAlive:
case fSuspend:
case fPostponeToNextEvent:
trackContainer->PushOneTrack( track );
StackTracks( secondaries );
break;
case fStopAndKill:
StackTracks( secondaries );
delete track;
break;
case fAlive:
G4cout << "Illeagal TrackStatus returned from G4TrackingManager!"
<< endl;
case fKillTrackAndSecondaries:
if( secondaries ) secondaries->clearAndDestroy();
delete track;
break;
}
}
#ifdef G4VERBOSE
if ( verboseLevel > 0 )
{
G4cout << "NULL returned from G4StackManager." << endl;
G4cout << "Terminate current event processing." << endl;
}
#endif
if(sdManager)
{ sdManager->TerminateCurrentEvent(currentEvent->GetHCofThisEvent()); }
#ifdef G4_STORE_TRAJECTORY
currentEvent->SetTrajectoryContainer(trajectoryContainer);
#endif
if(userEventAction) userEventAction->EndOfEventAction();
currentEvent = NULL;
}
void G4EventManager::StackTracks(G4TrackVector *trackVector)
{
G4Track * newTrack;
if( trackVector )
{
size_t n_passedTrack = trackVector->entries();
if( n_passedTrack == 0 ) return;
for( size_t i = 0; i < n_passedTrack; i++ )
{
newTrack = (*trackVector)[ i ];
trackIDCounter++;
newTrack->SetTrackID( trackIDCounter );
trackContainer->PushOneTrack( newTrack );
#ifdef G4VERBOSE
if ( verboseLevel > 1 )
{
G4cout << "A new track " << newTrack
<< " (trackID " << newTrack->GetTrackID()
<< ", parentID " << newTrack->GetParentID()
<< ") is passed to G4StackManager." << endl;
}
#endif
}
trackVector->clear();
}
}
void G4EventManager::SetUserAction(G4UserEventAction* userAction)
{
if (userEventAction) delete userEventAction;
userEventAction = userAction;
userEventAction->SetEventManager(this);
}
+128
View File
@@ -0,0 +1,128 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4HEPEvtInterface.cc,v 2.3 1998/07/18 10:34:11 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// --------------------------------------------------------------------
#ifdef WIN32
# include <Strstrea.h>
#else
# include <strstream.h>
#endif
#include "G4ios.hh"
#include "G4HEPEvtInterface.hh"
#include "G4PrimaryVertex.hh"
#include "G4PrimaryParticle.hh"
#include "G4HEPEvtParticle.hh"
#include "G4Event.hh"
G4HEPEvtInterface::G4HEPEvtInterface(char* evfile)
{
inputFile.open(evfile);
fileName = evfile;
}
G4HEPEvtInterface::G4HEPEvtInterface(G4String evfile)
{
const char* fn = evfile.data();
inputFile.open((char*)fn);
fileName = evfile;
}
G4HEPEvtInterface::~G4HEPEvtInterface()
{;}
void G4HEPEvtInterface::GeneratePrimaryVertex(G4Event* evt)
{
int NHEP; // number of entries
inputFile >> NHEP;
if( inputFile.eof() )
{
G4Exception("End-Of-File : HEPEvt input file");
return;
}
for( int IHEP=0; IHEP<NHEP; IHEP++ )
{
G4int ISTHEP; // status code
G4int IDHEP; // PDG code
G4int JDAHEP1; // first daughter
G4int JDAHEP2; // last daughter
G4double PHEP1; // px in GeV
G4double PHEP2; // py in GeV
G4double PHEP3; // pz in GeV
G4double PHEP5; // mass in GeV
inputFile >> ISTHEP >> IDHEP >> JDAHEP1 >> JDAHEP2
>> PHEP1 >> PHEP2 >> PHEP3 >> PHEP5;
// create G4PrimaryParticle object
G4PrimaryParticle* particle
= new G4PrimaryParticle( IDHEP, PHEP1*GeV, PHEP2*GeV, PHEP3*GeV );
particle->SetMass( PHEP5*GeV );
// create G4HEPEvtParticle object
G4HEPEvtParticle* hepParticle
= new G4HEPEvtParticle( particle, ISTHEP, JDAHEP1, JDAHEP2 );
// Store
HPlist.insert( hepParticle );
}
// check if there is at least one particle
if( HPlist.entries() == 0 ) return;
// make connection between daughter particles decayed from
// the same mother
for( int i=0; i<HPlist.entries(); i++ )
{
if( HPlist(i)->GetJDAHEP1() > 0 ) // it has daughters
{
int jda1 = HPlist(i)->GetJDAHEP1()-1; // FORTRAN index starts from 1
int jda2 = HPlist(i)->GetJDAHEP2()-1; // but C++ starts from 0.
G4PrimaryParticle* mother = HPlist(i)->GetTheParticle();
for( int j=jda1; j<=jda2; j++ )
{
G4PrimaryParticle* daughter = HPlist(j)->GetTheParticle();
if(HPlist(j)->GetISTHEP()>0)
{
mother->SetDaughter( daughter );
HPlist(j)->Done();
}
}
}
}
// create G4PrimaryVertex object
G4double x0 = 0.; // vertex point X
G4double y0 = 0.; // vertex point Y
G4double z0 = 0.; // vertex point Z
G4double t0 = 0.; // vertex time
G4PrimaryVertex* vertex = new G4PrimaryVertex(x0,y0,z0,t0);
// put initial particles to the vertex
for( int ii=0; ii<HPlist.entries(); ii++ )
{
if( HPlist(ii)->GetISTHEP() > 0 ) // ISTHEP of daughters had been
// set to negative
{
G4PrimaryParticle* initialParticle = HPlist(ii)->GetTheParticle();
vertex->SetPrimary( initialParticle );
}
}
// clear G4HEPEvtParticles
HPlist.clearAndDestroy();
// Put the vertex to G4Event object
evt->AddPrimaryVertex( vertex );
}
+39
View File
@@ -0,0 +1,39 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4HEPEvtParticle.cc,v 2.0 1998/07/02 16:53:56 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#include "G4HEPEvtParticle.hh"
G4Allocator<G4HEPEvtParticle> aHEPEvtParticleAllocator;
G4HEPEvtParticle::G4HEPEvtParticle()
{;}
G4HEPEvtParticle::G4HEPEvtParticle(G4PrimaryParticle* pp,
G4int isthep, G4int jdahep1, G4int jdahep2)
:theParticle(pp),ISTHEP(isthep),JDAHEP1(jdahep1),JDAHEP2(jdahep2)
{;}
G4HEPEvtParticle::~G4HEPEvtParticle()
{;}
const G4HEPEvtParticle &
G4HEPEvtParticle::operator=(const G4HEPEvtParticle &right)
{ return *this; }
int G4HEPEvtParticle::operator==(const G4HEPEvtParticle &right) const
{ return false; }
int G4HEPEvtParticle::operator!=(const G4HEPEvtParticle &right) const
{ return true; }
+113
View File
@@ -0,0 +1,113 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4ParticleGun.cc,v 2.2 1998/07/13 16:50:14 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// G4ParticleGun
#include "G4ParticleGun.hh"
#include "G4PrimaryParticle.hh"
#include "G4ParticleGunMessenger.hh"
#include "G4Event.hh"
#include "G4ios.hh"
G4ParticleGun::G4ParticleGun()
{
SetInitialValues();
}
G4ParticleGun::G4ParticleGun(G4int numberofparticles)
{
SetInitialValues();
NumberOfParticlesToBeGenerated = numberofparticles;
}
G4ParticleGun::G4ParticleGun
(G4ParticleDefinition * particleDef, G4int numberofparticles)
{
SetInitialValues();
NumberOfParticlesToBeGenerated = numberofparticles;
particle_definition = particleDef;
}
void G4ParticleGun::SetInitialValues()
{
NumberOfParticlesToBeGenerated = 1;
particle_definition = NULL;
G4ThreeVector zero;
particle_momentum_direction = (G4ParticleMomentum)zero;
particle_energy = 0.0;
particle_position = zero;
particle_time = 0.0;
particle_polarization = zero;
theMessenger = new G4ParticleGunMessenger(this);
}
G4ParticleGun::~G4ParticleGun()
{
delete theMessenger;
}
void G4ParticleGun::SetParticleMomentum(G4ParticleMomentum aMomentum)
{
if(particle_definition==NULL)
{
G4cout <<"Particle Definition not defined yet for G4ParticleGun"<< endl;
G4cout <<"Zero Mass is assumed"<<endl;
particle_momentum_direction = aMomentum.unit();
particle_energy = aMomentum.mag();
}
else
{
G4double mass = particle_definition->GetPDGMass();
G4double p = aMomentum.mag();
particle_momentum_direction = aMomentum.unit();
if ((particle_energy>0.0)&&(abs(particle_energy+mass-sqrt(p*p+mass*mass))>keV))
{
G4cout << "G4ParticleGun::" << particle_definition->GetParticleName() << endl;
G4cout << " KineticEnergy and Momentum could be inconsistent" << endl;
G4cout << " (Momentum:" << p/GeV << " GeV/c";
G4cout << " Mass:" << mass/GeV << " GeV/c/c)" << endl;
G4cout << " KineticEnergy is overwritten!! ";
G4cout << particle_energy/GeV << "->";
G4cout << (sqrt(p*p+mass*mass)-mass)/GeV << "GeV" << endl;
}
particle_energy = sqrt(p*p+mass*mass)-mass;
}
}
void G4ParticleGun::GeneratePrimaryVertex(G4Event* evt)
{
if(particle_definition==NULL) return;
// create a new vertex
G4PrimaryVertex* vertex =
new G4PrimaryVertex(particle_position,particle_time);
// create new primaries and set them to the vertex
G4double mass = particle_definition->GetPDGMass();
G4double energy = particle_energy + mass;
G4double pmom = sqrt(energy*energy-mass*mass);
G4double px = pmom*particle_momentum_direction.x();
G4double py = pmom*particle_momentum_direction.y();
G4double pz = pmom*particle_momentum_direction.z();
for( int i=0; i<NumberOfParticlesToBeGenerated; i++ )
{
G4PrimaryParticle* particle =
new G4PrimaryParticle(particle_definition,px,py,pz);
particle->SetMass( mass );
particle->SetPolarization(particle_polarization.x(),
particle_polarization.y(),
particle_polarization.z());
vertex->SetPrimary( particle );
}
evt->AddPrimaryVertex( vertex );
}
+155
View File
@@ -0,0 +1,155 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4ParticleGunMessenger.cc,v 2.4 1998/10/01 16:58:31 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4ParticleGunMessenger.hh"
#include "G4ParticleGun.hh"
#include "G4Geantino.hh"
#include "G4ThreeVector.hh"
#include "G4ParticleTable.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWith3Vector.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4ios.hh"
G4ParticleGunMessenger::G4ParticleGunMessenger(G4ParticleGun * fPtclGun)
:fParticleGun(fPtclGun)
{
particleTable = G4ParticleTable::GetParticleTable();
gunDirectory = new G4UIdirectory("/gun/");
gunDirectory->SetGuidance("Particle Gun control commands.");
listCmd = new G4UIcmdWithoutParameter("/gun/List",this);
listCmd->SetGuidance("List available particles.");
listCmd->SetGuidance(" Invoke G4ParticleTable.");
particleCmd = new G4UIcmdWithAString("/gun/particle",this);
particleCmd->SetGuidance("Set particle to be generated.");
particleCmd->SetGuidance(" (geantino is default)");
particleCmd->SetParameterName("particleName",true);
particleCmd->SetDefaultValue("geantino");
G4String candidateList;
G4int nPtcl = particleTable->entries();
for(G4int i=0;i<nPtcl;i++)
{
candidateList += particleTable->GetParticleName(i);
candidateList += " ";
}
particleCmd->SetCandidates(candidateList);
directionCmd = new G4UIcmdWith3Vector("/gun/direction",this);
directionCmd->SetGuidance("Set momentum direction.");
directionCmd->SetGuidance("Direction needs not to be a unit vector.");
directionCmd->SetParameterName("Px","Py","Pz",true,true);
directionCmd->SetRange("Px != 0 || Py != 0 || Pz != 0");
energyCmd = new G4UIcmdWithADoubleAndUnit("/gun/energy",this);
energyCmd->SetGuidance("Set kinetic energy.");
energyCmd->SetParameterName("Energy",true,true);
energyCmd->SetDefaultUnit("GeV");
//energyCmd->SetUnitCategory("Energy");
//energyCmd->SetUnitCandidates("eV keV MeV GeV TeV");
positionCmd = new G4UIcmdWith3VectorAndUnit("/gun/position",this);
positionCmd->SetGuidance("Set starting position of the particle.");
positionCmd->SetParameterName("X","Y","Z",true,true);
positionCmd->SetDefaultUnit("cm");
//positionCmd->SetUnitCategory("Length");
//positionCmd->SetUnitCandidates("microm mm cm m km");
timeCmd = new G4UIcmdWithADoubleAndUnit("/gun/time",this);
timeCmd->SetGuidance("Set initial time of the particle.");
timeCmd->SetParameterName("t0",true,true);
timeCmd->SetDefaultUnit("ns");
//timeCmd->SetUnitCategory("Time");
//timeCmd->SetUnitCandidates("ns ms s");
polCmd = new G4UIcmdWith3Vector("/gun/polarization",this);
polCmd->SetGuidance("Set polarization.");
polCmd->SetParameterName("Px","Py","Pz",true,true);
polCmd->SetRange("Px>=-1.&&Px<=1.&&Py>=-1.&&Py<=1.&&Pz>=-1.&&Pz<=1.");
numberCmd = new G4UIcmdWithAnInteger("/gun/number",this);
numberCmd->SetGuidance("Set number of particles to be generated.");
numberCmd->SetParameterName("N",true,true);
numberCmd->SetRange("N>0");
// set initial value to G4ParticleGun
fParticleGun->SetParticleDefinition( G4Geantino::Geantino() );
fParticleGun->SetParticleMomentumDirection( G4ThreeVector(1.0,0.0,0.0) );
fParticleGun->SetParticleEnergy( 1.0*GeV );
fParticleGun->SetParticlePosition(G4ThreeVector(0.0*cm, 0.0*cm, 0.0*cm));
fParticleGun->SetParticleTime( 0.0*ns );
}
G4ParticleGunMessenger::~G4ParticleGunMessenger()
{
delete listCmd;
delete particleCmd;
delete directionCmd;
delete energyCmd;
delete positionCmd;
delete timeCmd;
delete polCmd;
delete numberCmd;
delete gunDirectory;
}
void G4ParticleGunMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
{
if( command==listCmd )
{ particleTable->DumpTable(); }
else if( command==particleCmd )
{
G4ParticleDefinition* pd = particleTable->FindParticle(newValues);
if(pd != NULL)
{ fParticleGun->SetParticleDefinition( pd ); }
}
else if( command==directionCmd )
{ fParticleGun->SetParticleMomentumDirection(directionCmd->GetNew3VectorValue(newValues)); }
else if( command==energyCmd )
{ fParticleGun->SetParticleEnergy(energyCmd->GetNewDoubleValue(newValues)); }
else if( command==positionCmd )
{ fParticleGun->SetParticlePosition(positionCmd->GetNew3VectorValue(newValues)); }
else if( command==timeCmd )
{ fParticleGun->SetParticleTime(timeCmd->GetNewDoubleValue(newValues)); }
else if( command==polCmd )
{ fParticleGun->SetParticlePolarization(polCmd->GetNew3VectorValue(newValues)); }
else if( command==numberCmd )
{ fParticleGun->SetNumberOfParticles(numberCmd->GetNewIntValue(newValues)); }
}
G4String G4ParticleGunMessenger::GetCurrentValue(G4UIcommand * command)
{
G4String cv;
if( command==directionCmd )
{ cv = directionCmd->ConvertToString(fParticleGun->GetParticleMomentumDirection()); }
else if( command==particleCmd )
{ cv = fParticleGun->GetParticleDefinition()->GetParticleName(); }
else if( command==energyCmd )
{ cv = energyCmd->ConvertToString(fParticleGun->GetParticleEnergy(),"GeV"); }
else if( command==positionCmd )
{ cv = positionCmd->ConvertToString(fParticleGun->GetParticlePosition(),"cm"); }
else if( command==timeCmd )
{ cv = timeCmd->ConvertToString(fParticleGun->GetParticleTime(),"ns"); }
else if( command==polCmd )
{ cv = polCmd->ConvertToString(fParticleGun->GetParticlePolarization()); }
else if( command==numberCmd )
{ cv = numberCmd->ConvertToString(fParticleGun->GetNumberOfParticles()); }
return cv;
}
+99
View File
@@ -0,0 +1,99 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PrimaryParticle.cc,v 2.3 1998/10/10 10:51:24 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4PrimaryParticle.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4ios.hh"
G4Allocator<G4PrimaryParticle> aPrimaryParticleAllocator;
G4PrimaryParticle::G4PrimaryParticle()
:PDGcode(0),G4code(NULL),Px(0.),Py(0.),Pz(0.),
nextParticle(NULL),daughterParticle(NULL),trackID(-1),
mass(0.),polX(0.),polY(0.),polZ(0.)
{;}
G4PrimaryParticle::G4PrimaryParticle(G4int Pcode)
:PDGcode(Pcode),Px(0.),Py(0.),Pz(0.),
nextParticle(NULL),daughterParticle(NULL),trackID(-1),
mass(0.),polX(0.),polY(0.),polZ(0.)
{ G4code = G4ParticleTable::GetParticleTable()->FindParticle(Pcode); }
G4PrimaryParticle::G4PrimaryParticle(G4int Pcode,
G4double px,G4double py,G4double pz)
:PDGcode(Pcode),Px(px),Py(py),Pz(pz),
nextParticle(NULL),daughterParticle(NULL),trackID(-1),
mass(0.),polX(0.),polY(0.),polZ(0.)
{ G4code = G4ParticleTable::GetParticleTable()->FindParticle(Pcode); }
G4PrimaryParticle::G4PrimaryParticle(G4ParticleDefinition* Gcode)
:G4code(Gcode),Px(0.),Py(0.),Pz(0.),
nextParticle(NULL),daughterParticle(NULL),trackID(-1),
mass(0.),polX(0.),polY(0.),polZ(0.)
{ PDGcode = Gcode->GetPDGEncoding(); }
G4PrimaryParticle::G4PrimaryParticle(G4ParticleDefinition* Gcode,
G4double px,G4double py,G4double pz)
:G4code(Gcode),Px(px),Py(py),Pz(pz),
nextParticle(NULL),daughterParticle(NULL),trackID(-1),
mass(0.),polX(0.),polY(0.),polZ(0.)
{ PDGcode = Gcode->GetPDGEncoding(); }
G4PrimaryParticle::~G4PrimaryParticle()
{
if(nextParticle != NULL)
{ delete nextParticle; }
if(daughterParticle != NULL)
{ delete daughterParticle; }
}
void G4PrimaryParticle::SetPDGcode(G4int Pcode)
{
PDGcode = Pcode;
G4code = G4ParticleTable::GetParticleTable()->FindParticle(Pcode);
}
void G4PrimaryParticle::SetG4code(G4ParticleDefinition* Gcode)
{
G4code = Gcode;
PDGcode = Gcode->GetPDGEncoding();
}
const G4PrimaryParticle &
G4PrimaryParticle::operator=(const G4PrimaryParticle &right)
{ return *this; }
int G4PrimaryParticle::operator==(const G4PrimaryParticle &right) const
{ return false; }
int G4PrimaryParticle::operator!=(const G4PrimaryParticle &right) const
{ return true; }
void G4PrimaryParticle::Print() const
{
G4cout << "==== PDGcode " << PDGcode << " Particle name ";
if(G4code != NULL)
{ G4cout << G4code->GetParticleName() << endl; }
else
{ G4cout << "is not defined in G4." << endl; }
G4cout << " Momentum ( " << Px << ", " << Py << ", " << Pz << " )" << endl;
G4cout << " Polarization ( " << polX << ", " << polY << ", "
<< polZ << " )" << endl;
if(daughterParticle != NULL)
{
G4cout << ">>>> Daughters" << endl;
daughterParticle->Print();
}
if(nextParticle != NULL)
{ nextParticle->Print(); }
else
{ G4cout << "<<<< End of link" << endl; }
}
+164
View File
@@ -0,0 +1,164 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PrimaryTransformer.cc,v 2.2 1998/10/10 10:51:25 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4PrimaryTransformer.hh"
#include "G4Event.hh"
#include "G4PrimaryVertex.hh"
#include "G4ParticleDefinition.hh"
#include "G4DynamicParticle.hh"
#include "G4Track.hh"
#include "G4ThreeVector.hh"
#include "G4DecayProducts.hh"
#include "G4ios.hh"
G4PrimaryTransformer::G4PrimaryTransformer()
:verboseLevel(0)
{
particleTable = G4ParticleTable::GetParticleTable();
}
G4PrimaryTransformer::~G4PrimaryTransformer()
{;}
G4TrackVector* G4PrimaryTransformer::GimmePrimaries(G4Event* anEvent)
{
TV.clearAndDestroy();
G4int n_vertex = anEvent->GetNumberOfPrimaryVertex();
if(n_vertex==0) return NULL;
for( int i=0; i<n_vertex; i++ )
{ GenerateTracks( anEvent->GetPrimaryVertex(i) ); }
return &TV;
}
void G4PrimaryTransformer::GenerateTracks(G4PrimaryVertex* primaryVertex)
{
G4double X0 = primaryVertex->GetX0();
G4double Y0 = primaryVertex->GetY0();
G4double Z0 = primaryVertex->GetZ0();
G4double T0 = primaryVertex->GetT0();
#ifdef G4VERBOSE
if(verboseLevel>1)
{
G4cout << "G4PrimaryTransformer::PrimaryVertex ("
<< X0 / mm << "(mm),"
<< Y0 / mm << "(mm),"
<< Z0 / mm << "(mm),"
<< T0 / nanosecond << "(nsec))" << endl;
}
#endif
G4PrimaryParticle* primaryParticle = primaryVertex->GetPrimary();
while( primaryParticle != NULL )
{
GenerateSingleTrack( primaryParticle, X0, Y0, Z0, T0 );
primaryParticle = primaryParticle->GetNext();
}
}
void G4PrimaryTransformer::GenerateSingleTrack
(G4PrimaryParticle* primaryParticle,
G4double x0,G4double y0,G4double z0,G4double t0)
{
G4ParticleDefinition* partDef = GetDefinition(primaryParticle);
if((!partDef)||partDef->IsShortLived())
// The particle is not defined in GEANT4, check daughters
{
#ifdef G4VERBOSE
if(verboseLevel>2)
{
G4cout << "Primary particle (PDGcode " << primaryParticle->GetPDGcode()
<< ") --- Ignored" << endl;
}
#endif
G4PrimaryParticle* daughter = primaryParticle->GetDaughter();
while(daughter)
{
GenerateSingleTrack(daughter,x0,y0,z0,t0);
daughter = daughter->GetNext();
}
}
// The particle is defined in GEANT4
else
{
// Create G4DynamicParticle object
#ifdef G4VERBOSE
if(verboseLevel>1)
{
G4cout << "Primary particle (" << partDef->GetParticleName()
<< ") --- Transfered with momentum " << primaryParticle->GetMomentum()
<< endl;
}
#endif
G4DynamicParticle* DP =
new G4DynamicParticle(partDef,primaryParticle->GetMomentum());
DP->SetPolarization(primaryParticle->GetPolX(),
primaryParticle->GetPolY(),
primaryParticle->GetPolZ());
// Set decay products to the DynamicParticle
SetDecayProducts( primaryParticle, DP );
// Create G4Track object
G4Track* track = new G4Track(DP,t0,G4ThreeVector(x0,y0,z0));
// Set parentID to 0 as a primary particle
track->SetParentID(0);
// Store it to G4TrackVector
TV.insert( track );
}
}
void G4PrimaryTransformer::SetDecayProducts
(G4PrimaryParticle* mother, G4DynamicParticle* motherDP)
{
G4PrimaryParticle* daughter = mother->GetDaughter();
if(!daughter) return;
G4DecayProducts* decayProducts = motherDP->GetPreAssignedDecayProducts();
if(!decayProducts)
{
decayProducts = new G4DecayProducts(*motherDP);
motherDP->SetPreAssignedDecayProducts(decayProducts);
}
while(daughter)
{
G4ParticleDefinition* partDef = GetDefinition(daughter);
if(!partDef)
{
#ifdef G4VERBOSE
if(verboseLevel>2)
{
G4cout << " >> Decay product (PDGcode " << daughter->GetPDGcode()
<< ") --- Ignored" << endl;
}
#endif
SetDecayProducts(daughter,motherDP);
}
else
{
#ifdef G4VERBOSE
if(verboseLevel>1)
{
G4cout << " >> Decay product (" << partDef->GetParticleName()
<< ") --- Attached with momentum " << daughter->GetMomentum()
<< endl;
}
#endif
G4DynamicParticle*DP
= new G4DynamicParticle(partDef,daughter->GetMomentum());
decayProducts->PushProducts(DP);
SetDecayProducts(daughter,DP);
}
daughter = daughter->GetNext();
}
}
+66
View File
@@ -0,0 +1,66 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PrimaryVertex.cc,v 2.4 1998/11/11 11:19:42 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4PrimaryVertex.hh"
#include "G4ios.hh"
G4Allocator<G4PrimaryVertex> aPrimaryVertexAllocator;
G4PrimaryVertex::G4PrimaryVertex()
:X0(0.),Y0(0.),Z0(0.),T0(0.),numberOfParticle(0),nextVertex(NULL),
theParticle(NULL),theTail(NULL)
{;}
G4PrimaryVertex::G4PrimaryVertex(
G4double x0,G4double y0,G4double z0,G4double t0)
:X0(x0),Y0(y0),Z0(z0),T0(t0),numberOfParticle(0),nextVertex(NULL),
theParticle(NULL),theTail(NULL)
{;}
G4PrimaryVertex::G4PrimaryVertex(G4ThreeVector xyz0,G4double t0)
:T0(t0),numberOfParticle(0),nextVertex(NULL),
theParticle(NULL),theTail(NULL)
{
X0=xyz0.x();
Y0=xyz0.y();
Z0=xyz0.z();
}
G4PrimaryVertex::~G4PrimaryVertex()
{
if(theParticle != NULL)
{ delete theParticle; }
if(nextVertex != NULL)
{ delete nextVertex; }
}
const G4PrimaryVertex &
G4PrimaryVertex::operator=(const G4PrimaryVertex &right)
{ return *this; }
int G4PrimaryVertex::operator==(const G4PrimaryVertex &right) const
{ return false; }
int G4PrimaryVertex::operator!=(const G4PrimaryVertex &right) const
{ return true; }
void G4PrimaryVertex::Print() const
{
G4cout << "Vertex ( "
<< X0 << ", " << Y0 << ", " << Z0 << ", " << T0 << " )" << endl;
G4cout << "#### Primary particles" << endl;
G4PrimaryParticle* aPrim = theParticle;
if(aPrim != NULL)
{
aPrim->Print();
aPrim = aPrim->GetNext();
}
}
+224
View File
@@ -0,0 +1,224 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4StackManager.cc,v 2.2 1998/07/13 16:50:19 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 09/Dec/96 M.Asai
//
#include "G4StackManager.hh"
#include "G4StackingMessenger.hh"
#include "evmandefs.hh"
#include "G4ios.hh"
G4StackManager::G4StackManager()
:verboseLevel(0),userStackingAction(NULL)
{
theMessenger = new G4StackingMessenger(this);
urgentStack = new G4TrackStack;
waitingStack = new G4TrackStack;
postponeStack = new G4TrackStack;
}
G4StackManager::~G4StackManager()
{
if(userStackingAction) delete userStackingAction;
delete urgentStack;
delete waitingStack;
delete postponeStack;
delete theMessenger;
}
const G4StackManager & G4StackManager::operator=
(const G4StackManager &) { return *this; }
int G4StackManager::operator==(const G4StackManager &)
const{ return false; }
int G4StackManager::operator!=(const G4StackManager &)
const{ return true; }
G4int G4StackManager::PushOneTrack(G4Track *newTrack)
{
G4ClassificationOfNewTrack classification;
if(userStackingAction)
{ classification = userStackingAction->ClassifyNewTrack( newTrack ); }
else
{ classification = DefaultClassification( newTrack ); }
if(classification==fKill) // delete newTrack without stacking
{
#ifdef G4VERBOSE
if( verboseLevel > 0 )
{
G4cout << " ---> G4Track " << newTrack << " (trackID "
<< newTrack->GetTrackID() << ", parentID "
<< newTrack->GetParentID() << ") is not to be stored." << endl;
}
#endif
delete newTrack;
}
else
{
G4StackedTrack * newStackedTrack = new G4StackedTrack( newTrack );
switch (classification)
{
case fUrgent:
urgentStack->PushToStack( newStackedTrack );
break;
case fWaiting:
waitingStack->PushToStack( newStackedTrack );
break;
case fPostpone:
postponeStack->PushToStack( newStackedTrack );
break;
case fKill:
break;
}
}
return GetNUrgentTrack();
}
G4Track * G4StackManager::PopNextTrack()
{
#ifdef G4VERBOSE
if( verboseLevel > 0 )
{
G4cout << "### pop requested out of "
<< GetNUrgentTrack() << " stacked tracks." << endl;
}
#endif
while( GetNUrgentTrack() == 0 )
{
#ifdef G4VERBOSE
if( verboseLevel > 0 ) G4cout << "### " << GetNWaitingTrack()
<< " waiting tracks are re-classified to" << endl;
#endif
waitingStack->TransferTo(urgentStack);
if(userStackingAction) userStackingAction->NewStage();
#ifdef G4VERBOSE
if( verboseLevel > 0 ) G4cout << " " << GetNUrgentTrack()
<< " urgent tracks and " << GetNWaitingTrack()
<< " waiting tracks." << endl;
#endif
if( ( GetNUrgentTrack()==0 ) && ( GetNWaitingTrack()==0 ) ) return NULL;
}
G4StackedTrack * selectedStackedTrack = urgentStack->PopFromStack();
G4Track * selectedTrack = selectedStackedTrack->GetTrack();
#ifdef G4VERBOSE
if( verboseLevel > 1 )
{
G4cout << "Selected G4StackedTrack : " << selectedStackedTrack
<< " with G4Track " << selectedStackedTrack->GetTrack()
<< " (trackID " << selectedStackedTrack->GetTrack()->GetTrackID()
<< ", parentID " << selectedStackedTrack->GetTrack()->GetParentID()
<< ")" << endl;
}
#endif
delete selectedStackedTrack;
return selectedTrack;
}
void G4StackManager::ReClassify()
{
G4StackedTrack * aStackedTrack;
G4TrackStack tmpStack;
if( !userStackingAction ) return;
if( GetNUrgentTrack() == 0 ) return;
urgentStack->TransferTo(&tmpStack);
while( (aStackedTrack=tmpStack.PopFromStack()) != NULL )
{
G4ClassificationOfNewTrack classification =
userStackingAction->ClassifyNewTrack( aStackedTrack->GetTrack() );
switch (classification)
{
case fKill:
delete aStackedTrack->GetTrack();
delete aStackedTrack;
break;
case fUrgent:
urgentStack->PushToStack( aStackedTrack );
break;
case fWaiting:
waitingStack->PushToStack( aStackedTrack );
break;
case fPostpone:
postponeStack->PushToStack( aStackedTrack );
break;
}
}
}
G4int G4StackManager::PrepareNewEvent()
{
if(userStackingAction) userStackingAction->PrepareNewEvent();
G4int n_passedFromPrevious = 0;
if( GetNPostponedTrack() > 0 )
{
#ifdef G4VERBOSE
if( verboseLevel > 0 )
{
G4cout << GetNPostponedTrack()
<< " postponed tracked are now shifted to the stack." << endl;
}
#endif
G4StackedTrack * aStackedTrack;
G4TrackStack tmpStack;
postponeStack->TransferTo(&tmpStack);
while( (aStackedTrack=tmpStack.PopFromStack()) != NULL )
{
G4Track* aTrack = aStackedTrack->GetTrack();
aTrack->SetParentID(-1);
G4ClassificationOfNewTrack classification;
if(userStackingAction)
{ classification = userStackingAction->ClassifyNewTrack( aTrack ); }
else
{ classification = DefaultClassification( aTrack ); }
if(classification==fKill)
{
delete aTrack;
delete aStackedTrack;
}
else
{
aTrack->SetTrackID(++n_passedFromPrevious);
switch (classification)
{
case fUrgent:
urgentStack->PushToStack( aStackedTrack );
break;
case fWaiting:
waitingStack->PushToStack( aStackedTrack );
break;
case fPostpone:
postponeStack->PushToStack( aStackedTrack );
break;
case fKill:
break;
}
}
}
}
return n_passedFromPrevious;
}
+37
View File
@@ -0,0 +1,37 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4StackedTrack.cc,v 2.0 1998/07/02 16:54:06 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 02/Feb/96 M.Asai
//
#include "G4StackedTrack.hh"
G4Allocator<G4StackedTrack> aStackedTrackAllocator;
G4StackedTrack::G4StackedTrack()
{ }
G4StackedTrack::G4StackedTrack(G4Track * newTrack)
:track(newTrack),priorityWeight(0.),
previousStackedTrack(NULL),nextStackedTrack(NULL)
{ }
G4StackedTrack::~G4StackedTrack()
{ }
const G4StackedTrack & G4StackedTrack::operator=(const G4StackedTrack &right)
{ return *this; }
int G4StackedTrack::operator==(const G4StackedTrack &right) const
{ return false; }
int G4StackedTrack::operator!=(const G4StackedTrack &right) const
{ return true; }
+80
View File
@@ -0,0 +1,80 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4StackingMessenger.cc,v 2.3 1998/07/13 16:50:21 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// --------------------------------------------------------------------
#include "G4StackingMessenger.hh"
#include "G4StackManager.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4ios.hh"
G4StackingMessenger::G4StackingMessenger(G4StackManager * fCont)
:fContainer(fCont)
{
stackDir = new G4UIdirectory("/event/stack/");
stackDir->SetGuidance("Stack control commands.");
statusCmd = new G4UIcmdWithoutParameter("/event/stack/status",this);
statusCmd->SetGuidance("List current status of the stack.");
clearCmd = new G4UIcmdWithAnInteger("/event/stack/clear",this);
clearCmd->SetGuidance("Clear stacked tracks.");
clearCmd->SetGuidance(" 2 : clear all tracks in all stacks");
clearCmd->SetGuidance(" 1 : clear tracks in the urgent and waiting stacks");
clearCmd->SetGuidance(" 0 : clear tracks in the waiting stack (default)");
clearCmd->SetGuidance("-1 : clear tracks in the urgent stack");
clearCmd->SetGuidance("-2 : clear tracks in the postponed stack");
clearCmd->SetParameterName("level",true);
clearCmd->SetDefaultValue(0);
clearCmd->SetRange("level>=-2&&level<=2");
clearCmd->AvailableForStates(GeomClosed,EventProc);
}
G4StackingMessenger::~G4StackingMessenger()
{
delete statusCmd;
delete clearCmd;
delete stackDir;
}
void G4StackingMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
{
if( command==statusCmd )
{
G4cout << "========================== Current status of the stack =====" << endl;
G4cout << " Number of tracks in the stack" << endl;
G4cout << " Urgent stack : " << fContainer->GetNUrgentTrack() << endl;
G4cout << " Waiting stack : " << fContainer->GetNWaitingTrack() << endl;
G4cout << " Postponed stack : " << fContainer->GetNPostponedTrack() << endl;
}
if( command==clearCmd )
{
G4int vc = clearCmd->GetNewIntValue(newValues);
switch (vc)
{
case 2:
fContainer->ClearPostponeStack();
case 1:
fContainer->ClearUrgentStack();
case 0:
fContainer->ClearWaitingStack();
break;
case -1:
fContainer->ClearUrgentStack();
break;
case -2:
fContainer->ClearPostponeStack();
break;
}
}
}
+135
View File
@@ -0,0 +1,135 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4TrackStack.cc,v 2.1 1998/07/12 02:54:07 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 09/Dec/96 M.Asai
//
#include "G4TrackStack.hh"
G4TrackStack::G4TrackStack()
:n_stackedTrack(0),firstStackedTrack(NULL),lastStackedTrack(NULL)
{;}
G4TrackStack::~G4TrackStack()
{;}
const G4TrackStack & G4TrackStack::operator=(const G4TrackStack &right)
{
n_stackedTrack = right.n_stackedTrack;
firstStackedTrack = right.firstStackedTrack;
lastStackedTrack = right.lastStackedTrack;
return *this;
}
int G4TrackStack::operator==(const G4TrackStack &right) const
{ return (firstStackedTrack==right.firstStackedTrack); }
int G4TrackStack::operator!=(const G4TrackStack &right) const
{ return (firstStackedTrack!=right.firstStackedTrack); }
void G4TrackStack::TransferTo(G4TrackStack * aStack)
{
if(n_stackedTrack==0) return;
if(aStack->n_stackedTrack == 0)
{
*aStack = *this;
}
else
{
aStack->lastStackedTrack->SetNext( firstStackedTrack );
firstStackedTrack->SetPrevious( aStack->lastStackedTrack );
aStack->lastStackedTrack = lastStackedTrack;
aStack->n_stackedTrack += n_stackedTrack;
}
n_stackedTrack = 0;
firstStackedTrack = NULL;
lastStackedTrack = NULL;
}
G4StackedTrack * G4TrackStack::PopFromStack()
{
if( n_stackedTrack == 0 ) return NULL;
G4StackedTrack * aStackedTrack = lastStackedTrack;
GrabFromStack( aStackedTrack );
return aStackedTrack;
}
void G4TrackStack::PushToStack( G4StackedTrack * aStackedTrack )
{
if( n_stackedTrack == 0 )
{
aStackedTrack->SetPrevious( NULL );
firstStackedTrack = aStackedTrack;
}
else
{
lastStackedTrack->SetNext( aStackedTrack );
aStackedTrack->SetPrevious( lastStackedTrack );
}
lastStackedTrack = aStackedTrack;
n_stackedTrack++;
}
void G4TrackStack::GrabFromStack( G4StackedTrack * aStackedTrack )
{
if( n_stackedTrack == 1 )
{
firstStackedTrack = NULL;
lastStackedTrack = NULL;
}
else
{
if( aStackedTrack == firstStackedTrack )
{
firstStackedTrack = aStackedTrack->GetNext();
firstStackedTrack->SetPrevious( NULL );
}
else
{
if( aStackedTrack == lastStackedTrack )
{
lastStackedTrack = aStackedTrack->GetPrevious();
lastStackedTrack->SetNext( NULL );
}
else
{
aStackedTrack->GetPrevious()
->SetNext( aStackedTrack->GetNext() );
aStackedTrack->GetNext()
->SetPrevious( aStackedTrack->GetPrevious() );
}
}
}
n_stackedTrack--;
}
void G4TrackStack::clear()
{
G4StackedTrack * aStackedTrack = firstStackedTrack;
G4StackedTrack * nextStackedTrack;
if ( n_stackedTrack == 0 ) return;
// delete tracks in the stack
while( aStackedTrack != NULL )
{
nextStackedTrack = aStackedTrack->GetNext();
delete aStackedTrack->GetTrack();
delete aStackedTrack;
aStackedTrack = nextStackedTrack;
}
n_stackedTrack = 0;
firstStackedTrack = NULL;
lastStackedTrack = NULL;
}
+19
View File
@@ -0,0 +1,19 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4UserEventAction.cc,v 2.1 1998/07/12 02:54:08 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4UserEventAction.hh"
void G4UserEventAction::BeginOfEventAction()
{;}
void G4UserEventAction::EndOfEventAction()
{;}
+37
View File
@@ -0,0 +1,37 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4UserStackingAction.cc,v 2.2 1998/07/13 16:50:22 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 09/Dec/96 M.Asai
//
#include "G4UserStackingAction.hh"
#include "G4Track.hh"
#include "G4ios.hh"
G4UserStackingAction::G4UserStackingAction()
{;}
G4UserStackingAction::~G4UserStackingAction()
{;}
G4ClassificationOfNewTrack G4UserStackingAction::ClassifyNewTrack
(G4Track * const aTrack)
{
return fUrgent;
}
void G4UserStackingAction::NewStage()
{;}
void G4UserStackingAction::PrepareNewEvent()
{;}
+21
View File
@@ -0,0 +1,21 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VPrimaryGenerator.cc,v 2.0 1998/07/02 16:54:13 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// G4VPrimaryGenerator
#include "G4VPrimaryGenerator.hh"
G4VPrimaryGenerator::G4VPrimaryGenerator()
{;}
G4VPrimaryGenerator::~G4VPrimaryGenerator()
{;}