1. 5. Técnicas de Simulación
3. Geant4
Dr. Willy H. Gerber
Instituto de Fisica
Universidad Austral
Valdivia, Chile
Objetivos: Comprender como se estructuran programas
que simulan procesos basados en Geant4.
1
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
2. Estructura de archivos
Demo
Include
ExDetectorConstruction.hh
ExPhysicsList.hh
ExPrimaryGeneratorAction.hh
src
ExDetectorConstruction.cc
ExPhysicsList.cc
ExPrimaryGeneratorAction.cc
MainDemo.cc
2
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
3. Programas Geant4
Includes
necesarios
int main(int argc,char** argv)
{
Setear
runManager
Definir
Output
Ejecutar
Proceso
delete visManager;
delete runManager;
return 0;
}
3
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
10. ExDetectorConstruction
Lógica de la rutina con solo 2 elementos
Crear caja (volumen World)
Crear cilindro
Crear volumen lógico para caja
Crear volumen lógico para cilindro
Posicionar cilindro
Posicionar caja
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
12. ExDetectorConstruction - demo
Crear volumen lógico para caja – clase G4LogicalVolume
G4LogicalVolume* experimentalHall_log =
new G4LogicalVolume(experimentalHall_box,Ar,quot;expHall_logquot;);
Crear volumen lógico para cilindro – clase G4LogicalVolume
G4LogicalVolume* tracker_log =
new G4LogicalVolume(tracker_tube,Al,quot;tracker_logquot;);
Posicionar cilindroc
G4double trackerPos_x = -1.0*meter;
G4double trackerPos_y = 0.0*meter;
G4double trackerPos_z = 0.0*meter;
G4VPhysicalVolume* tracker_phys = new G4PVPlacement(0, // no rotation
G4ThreeVector(trackerPos_x,trackerPos_y,trackerPos_z), // translation position
tracker_log, // its logical volume
quot;trackerquot;, // its name experimentalHall_log, // its mother (logical)
volume false, // no boolean
operations 0); // its copy number
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
13. ExDetectorConstruction - demo
Posicionar caja – clase G4LogicalVolume
G4VPhysicalVolume* experimentalHall_phys = new G4PVPlacement(0, // no rotation
G4ThreeVector(0.,0.,0.), // translation position
experimentalHall_log, // its logical volume
quot;expHallquot;, // its name
0, // its mother volume
false, // no boolean
operations 0); // its copy number
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
14. ExDetectorConstruction - demo
Material (directo)
G4double density = 1.390*g/cm3;
G4double a = 39.95*g/mole;
G4Material* lAr = new G4Material(name=quot;liquidArgonquot;, z=18., a, density);
G4LogicalVolume* myLbox = new G4LogicalVolume(aBox,lAr,quot;Lboxquot;,0,0,0);
Elementos
a = 1.01*g/mole;
G4Element* elH = new G4Element(name=quot;Hydrogenquot;,symbol=quot;Hquot; , z= 1., a);
a = 16.00*g/mole;
G4Element* elO = new G4Element(name=quot;Oxygenquot; ,symbol=quot;Oquot; , z= 8., a);
density = 1.000*g/cm3;
Material (compuesto desde elementos, por numero de elementos)
G4Material* H2O = new G4Material(name=quot;Waterquot;,density,ncomponents=2);
H2O->AddElement(elH, natoms=2);
H2O->AddElement(elO, natoms=1);
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
15. ExDetectorConstruction - demo
Elementos
a = 14.01*g/mole;
G4Element* elN = new G4Element(name=quot;Nitrogenquot;,symbol=quot;Nquot; , z= 7., a);
a = 16.00*g/mole;
G4Element* elO = new G4Element(name=quot;Oxygenquot; ,symbol=quot;Oquot; , z= 8., a);
Material (compuesto desde elementos, por fracción de átomos)
density = 1.290*mg/cm3;
G4Material* Air = new G4Material(name=quot;Air quot;,density,ncomponents=2);
Air->AddElement(elN, fractionmass=70*perCent);
Air->AddElement(elO, fractionmass=30*perCent);
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
16. ExDetectorConstruction.hh – primer parte
class G4LogicalVolume;
class G4VPhysicalVolume;
#include quot;G4VUserDetectorConstruction.hhquot;
class ExDetectorConstruction : public
G4VUserDetectorConstruction
{
public:
ExDetectorConstruction();
~ExDetectorConstruction();
G4VPhysicalVolume* Construct();
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
25. Definición de partículas
G4String GetParticleName() particle name
G4double GetPDGMass() mass
G4double GetPDGWidth() decay width
G4double GetPDGCharge() electric charge
G4double GetPDGSpin() spin
G4double GetPDGMagneticMoment() magnetic moment (a)
G4int GetPDGiParity() parity (b)
G4int GetPDGiConjugation() charge conjugation (b)
G4double GetPDGIsospin() iso-spin
G4double GetPDGIsospin3() 3rd-component of iso-spin
G4int GetPDGiGParity() G-parity (0:not defined)
G4String GetParticleType() particle type
G4String GetParticleSubType() particle sub-type
G4int GetLeptonNumber() lepton number
G4int GetBaryonNumber() baryon number
G4int GetPDGEncoding() particle encoding number by PDG
G4int GetAntiPDGEncoding() encoding for anti-particle of this particle
a: 0: not defined or no mag. Moment
b: 0:not defined
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
26. Definición de partículas
G4bool GetPDGStable() stable flag
G4double GetPDGLifeTime() life time
G4DecayTable *GetDecayTable() decay table
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
27. Variables dinámicas
G4double theDynamicalMass dynamical mass
G4ThreeVector theMomentumDirection normalized momentum vector
G4ParticleDefinition *theParticleDefinition definition of particle
G4double theDynamicalSpin dynamical spin (1)
G4ThreeVector thePolarization polarization vector
G4double theMagneticMoment dynamical magnetic moment (2)
G4double theKineticEnergy kinetic energy
G4double theProperTime proper time
G4double theDynamicalCharge dynamical electric charge (3)
G4ElectronOccupancy *theElectronOccupancy electron orbits for ions
1. i.e. total angular momentum as a ion/atom
2. i.e. total magnetic moment as a ion/atom
3. i.e. total electric charge as a ion/atom
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
28. ExPhysicsList - demo
ExPhysicsList.hh
protected:
// Construct particle and physics
void ConstructParticle();
void ConstructProcess();
void SetCuts();
// these methods Construct particles
void ConstructBosons();
void ConstructLeptons();
void ConstructMesons();
void ConstructBaryons();
protected:
// these methods Construct physics processes and register them
void ConstructGeneral();
void ConstructEM();
void AddStepMax();
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
39. ExPhysicsList.cc – primera parte
#include quot;ExPhysicsList.hhquot;
#include quot;G4ParticleTypes.hhquot;
ExPhysicsList::ExPhysicsList()
{;}
ExPhysicsList::~ExPhysicsList()
{;}
void ExPhysicsList::ConstructParticle()
{
// In this method, static member functions should be called
// for all particles which you want to use.
// This ensures that objects of these particle types will be
// created in the program.
G4Geantino::GeantinoDefinition();
}
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
40. ExPhysicsList.cc – segunda parte
void ExPhysicsList::ConstructProcess()
{
// Define transportation process
AddTransportation();
}
void ExPhysicsList::SetCuts()
{
// uppress error messages even in case e/gamma/proton do not exist
G4int temp = GetVerboseLevel();
SetVerboseLevel(0);
// quot; G4VUserPhysicsList::SetCutsWithDefaultquot; method sets
// the default cut value for all particle types
SetCutsWithDefault();
// Retrieve verbose level
SetVerboseLevel(temp);
}
www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09