UFRO Master Fisica Medica 5 3 Geant4

710 views
572 views

Published on

UFRO Lectrue, Fall 2009

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
710
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

UFRO Master Fisica Medica 5 3 Geant4

  1. 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. 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. 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
  4. 4. Estructuras a incluir #include quot;G4RunManager.hhquot; #include quot;G4UImanager.hhquot; #include quot;G4UIterminal.hhquot; #include quot;G4VisExecutive.hhquot; #include quot;ExDetectorConstruction.hhquot; #include quot;ExPhysicsList.hhquot; #include quot;ExPrimaryGeneratorAction.hh“ #include “ExRunAction.hhquot; #include “ExEventAction.hhquot; #include “ExSteppingAction.hhquot; #include “G4templates.hhquot; 4 www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  5. 5. Inicialización runManager - Clases Construction del runManager G4RunManager* runManager = new G4RunManager; Clases obligatorias de inicialización runManager->SetUserInitialization(new ExDetectorConstruction); runManager->SetUserInitialization(new ExPhysicsList); Clases obligatorias respecto de acciones runManager->SetUserAction(new ExPrimaryGeneratorAction); runManager->SetUserAction(new ExRunAction); runManager->SetUserAction(new ExEventAction); runManager->SetUserAction(new ExSteppingAction); 5 www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  6. 6. Inicializacion runManager Inicializacion del Display G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand(quot;/run/verbose 1quot;); UI->ApplyCommand(quot;/event/verbose 1quot;); UI->ApplyCommand(quot;/tracking/verbose 1quot;); Inicializacion … G4VisManager* visManager = new G4VisExecutive; visManager->Initialize(); Inicializacion el sistema runManager->Initialize(); 6 www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  7. 7. Ejecutar Ejecución int numberOfEvent = 3; runManager->BeamOn(numberOfEvent); if(argc==1) // Define (G)UI terminal for interactive mode { G4UIsession * session = new G4UIterminal; UI->ApplyCommand(quot;/control/execute prerun.g4macquot;); session->sessionStart(); delete session; } else // Batch mode { G4String command = quot;/control/execute quot;; G4String fileName = argv[1]; UI->ApplyCommand(command+fileName); } 7 www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  8. 8. Includes y Subrutinas Includes y Subrutinas www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  9. 9. ExDetectorConstruction - demo ExDetectorConstruction www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  10. 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
  11. 11. ExDetectorConstruction - demo Crear caja – clase G4Box (volumen World) G4double expHall_x = 3.0*m; G4double expHall_y = 1.0*m; G4double expHall_z = 1.0*m; G4Box* experimentalHall_box = new G4Box(quot;expHall_boxquot;,expHall_x,expHall_y,expHall_z); Crear cilindro – clase G4Tubs G4double innerRadiusOfTheTube = 0.*cm; G4double outerRadiusOfTheTube = 60.*cm; G4double hightOfTheTube = 25.*cm; G4double startAngleOfTheTube = 0.*deg; G4double spanningAngleOfTheTube = 360.*deg; G4Tubs* tracker_tube = new G4Tubs(quot;tracker_tubequot;, innerRadiusOfTheTube, outerRadiusOfTheTube, hightOfTheTube, startAngleOfTheTube, spanningAngleOfTheTube); www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  12. 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. 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. 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. 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. 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
  17. 17. ExDetectorConstruction.hh – segunda parte private: // Logical volumes // G4LogicalVolume* experimentalHall_log; G4LogicalVolume* tracker_log; G4LogicalVolume* calorimeterBlock_log; G4LogicalVolume* calorimeterLayer_log; // Physical volumes // G4VPhysicalVolume* experimentalHall_phys; G4VPhysicalVolume* calorimeterLayer_phys; G4VPhysicalVolume* calorimeterBlock_phys; G4VPhysicalVolume* tracker_phys; }; www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  18. 18. ExDetectorConstruction.cc – primera parte #include quot;ExDetectorConstruction.hhquot; #include quot;G4Material.hhquot; #include quot;G4Box.hhquot; #include quot;G4Tubs.hhquot; #include quot;G4LogicalVolume.hhquot; #include quot;G4ThreeVector.hhquot; #include quot;G4PVPlacement.hhquot; #include quot;globals.hhquot; ExDetectorConstruction::ExDetectorConstruction() : experimentalHall_log(0), tracker_log(0), calorimeterBlock_log(0), calorimeterLayer_log(0), experimentalHall_phys(0), calorimeterLayer_phys(0), calorimeterBlock_phys(0), tracker_phys(0) {;} ExDetectorConstruction::~ExDetectorConstruction() { } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  19. 19. ExDetectorConstruction.cc – segunda parte G4VPhysicalVolume* ExN01DetectorConstruction::Construct() { //------------------------------------------------------ materials G4double a; // atomic mass G4double z; // atomic number G4double density; G4Material* Ar = new G4Material(quot;ArgonGasquot;, z= 18., a= 39.95*g/mole, density= 1.782*mg/cm3); G4Material* Al = new G4Material(quot;Aluminumquot;, z= 13., a= 26.98*g/mole, density= 2.7*g/cm3); G4Material* Pb = new G4Material(quot;Leadquot;, z= 82., a= 207.19*g/mole, density= 11.35*g/cm3); www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  20. 20. ExDetectorConstruction.cc – tercera parte //------------------------------------------------------ volumes //------------------------------ experimental hall (world volume) //------------------------------ beam line along x axis G4double expHall_x = 3.0*m; G4double expHall_y = 1.0*m; G4double expHall_z = 1.0*m; G4Box* experimentalHall_box = new G4Box(quot;expHall_boxquot;,expHall_x,expHall_y,expHall_z); experimentalHall_log = new G4LogicalVolume(experimentalHall_box, Ar,quot;expHall_logquot;,0,0,0); experimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(), experimentalHall_log,quot;expHallquot;,0,false,0); www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  21. 21. ExDetectorConstruction.cc – cuarta parte //------------------------------ a tracker tube G4double innerRadiusOfTheTube = 0.*cm; G4double outerRadiusOfTheTube = 60.*cm; G4double hightOfTheTube = 50.*cm; G4double startAngleOfTheTube = 0.*deg; G4double spanningAngleOfTheTube = 360.*deg; G4Tubs* tracker_tube = new G4Tubs(quot;tracker_tubequot;,innerRadiusOfTheTube, outerRadiusOfTheTube,hightOfTheTube, startAngleOfTheTube,spanningAngleOfTheTube); tracker_log = new G4LogicalVolume(tracker_tube,Al,quot;tracker_logquot;,0,0,0); G4double trackerPos_x = -1.0*m; G4double trackerPos_y = 0.*m; G4double trackerPos_z = 0.*m; tracker_phys = new G4PVPlacement(0, G4ThreeVector(trackerPos_x,trackerPos_y,trackerPos_z), tracker_log,quot;trackerquot;,experimentalHall_log,false,0); www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  22. 22. ExDetectorConstruction.cc – quinta parte //------------------------------ a calorimeter block G4double block_x = 1.0*m; G4double block_y = 50.0*cm; G4double block_z = 50.0*cm; G4Box* calorimeterBlock_box = new G4Box(quot;calBlock_boxquot;,block_x, block_y,block_z); calorimeterBlock_log = new G4LogicalVolume(calorimeterBlock_box, Pb,quot;caloBlock_logquot;,0,0,0); G4double blockPos_x = 1.0*m; G4double blockPos_y = 0.0*m; G4double blockPos_z = 0.0*m; calorimeterBlock_phys = new G4PVPlacement(0, G4ThreeVector(blockPos_x,blockPos_y,blockPos_z), calorimeterBlock_log,quot;caloBlockquot;, experimentalHall_log,false,0); www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  23. 23. ExDetectorConstruction.cc – sesta parte //------------------------------ calorimeter layers (20 elements) G4double calo_x = 1.*cm; G4double calo_y = 40.*cm; G4double calo_z = 40.*cm; G4Box* calorimeterLayer_box = new G4Box(quot;caloLayer_box“, calo_x,calo_y,calo_z); calorimeterLayer_log = new G4LogicalVolume(calorimeterLayer_box, Al,quot;caloLayer_logquot;,0,0,0); for(G4int i=0;i<19;i++) // loop for 19 layers { G4double caloPos_x = (i-9)*10.*cm; G4double caloPos_y = 0.0*m; G4double caloPos_z = 0.0*m; calorimeterLayer_phys = new G4PVPlacement(0, G4ThreeVector(caloPos_x,caloPos_y,caloPos_z), calorimeterLayer_log,quot;caloLayerquot;,calorimeterBlock_log,false,i); } //------------------------------------------------------------------ return experimentalHall_phys; } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  24. 24. ExPhysicsList ExPhysicsList www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  25. 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. 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. 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. 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
  29. 29. ExPhysicsList - demo ExPhysicsList.cc #include quot;ExPhysicsList.hhquot; #include quot;G4ProcessManager.hhquot; #include quot;G4ParticleTypes.hhquot; void ExPhysicsList::ConstructParticle() { G4Proton::ProtonDefinition(); ConstructBosons(); ConstructLeptons(); ConstructMesons(); ConstructBaryons(); G4Geantino::GeantinoDefinition(); } void ExPhysicsList::ConstructBosons() { G4Geantino::GeantinoDefinition(); // pseudo-particles G4ChargedGeantino::ChargedGeantinoDefinition(); G4Gamma::GammaDefinition(); // gamma } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  30. 30. ExPhysicsList - demo void ExPhysicsList::ConstructLeptons() { G4Electron::ElectronDefinition(); // e- G4Positron::PositronDefinition(); // e+ Construir todos de una vez: G4MuonPlus::MuonPlusDefinition(); // mu+ G4LeptonConstructor pConstructor; G4MuonMinus::MuonMinusDefinition(); // mu- pConstructor.ConstructParticle(); G4NeutrinoE::NeutrinoEDefinition(); // nu_e G4AntiNeutrinoE::AntiNeutrinoEDefinition(); // nu_e G4NeutrinoMu::NeutrinoMuDefinition(); // nu_mu G4AntiNeutrinoMu::AntiNeutrinoMuDefinition(); // nu_mu } void ExPhysicsList::ConstructBaryons() { G4Proton::ProtonDefinition(); G4AntiProton::AntiProtonDefinition(); G4Neutron::NeutronDefinition(); G4AntiNeutron::AntiNeutronDefinition(); } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  31. 31. ExPhysicsList - demo void ExPhysicsList::ConstructMesons() { G4PionPlus::PionPlusDefinition(); G4PionMinus::PionMinusDefinition(); G4PionZero::PionZeroDefinition(); G4Eta::EtaDefinition(); G4EtaPrime::EtaPrimeDefinition(); G4KaonPlus::KaonPlusDefinition(); G4KaonMinus::KaonMinusDefinition(); G4KaonZero::KaonZeroDefinition(); G4AntiKaonZero::AntiKaonZeroDefinition(); G4KaonZeroLong::KaonZeroLongDefinition(); G4KaonZeroShort::KaonZeroShortDefinition(); } void ExPhysicsList::ConstructProcess() { AddTransportation(); ConstructEM(); ConstructGeneral(); AddStepMax(); } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  32. 32. ExPhysicsList - demo #include quot;G4ComptonScattering.hhquot; #include quot;G4GammaConversion.hhquot; #include quot;G4PhotoElectricEffect.hhquot; #include quot;G4eMultipleScattering.hhquot; #include quot;G4hMultipleScattering.hhquot; #include quot;G4eIonisation.hhquot; #include quot;G4eBremsstrahlung.hhquot; #include quot;G4eplusAnnihilation.hhquot; #include quot;G4MuIonisation.hhquot; #include quot;G4MuBremsstrahlung.hhquot; #include quot;G4MuPairProduction.hhquot; #include quot;G4hIonisation.hhquot; #include quot;G4hBremsstrahlung.hhquot; #include quot;G4hPairProduction.hhquot; #include quot;G4ionIonisation.hhquot; www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  33. 33. ExPhysicsList - demo void ExN02PhysicsList::ConstructEM() { theParticleIterator->reset(); while( (*theParticleIterator)() ){ G4ParticleDefinition* particle = theParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); G4String particleName = particle->GetParticleName(); if (particleName == quot;gammaquot;) { // gamma pmanager->AddDiscreteProcess(new G4PhotoElectricEffect); pmanager->AddDiscreteProcess(new G4ComptonScattering); pmanager->AddDiscreteProcess(new G4GammaConversion); } else if (particleName == quot;e-quot;) { //electron pmanager->AddProcess(new G4eMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4eIonisation, -1, 2, 2); pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3); } else if (particleName == quot;e+quot;) { //positron pmanager->AddProcess(new G4eMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4eIonisation, -1, 2, 2); pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3); pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 4); www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  34. 34. ExPhysicsList - demo } else if( particleName == quot;mu+quot; || particleName == quot;mu-quot; ) { //muon pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4MuIonisation, -1, 2, 2); pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3, 3); pmanager->AddProcess(new G4MuPairProduction, -1, 4, 4); } else if( particleName == quot;protonquot; || particleName == quot;pi-quot; || particleName == quot;pi+quot; ) { //proton pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4hIonisation, -1, 2, 2); pmanager->AddProcess(new G4hBremsstrahlung, -1, 3, 3); pmanager->AddProcess(new G4hPairProduction, -1, 4, 4); } else if( particleName == quot;alphaquot; || particleName == quot;He3quot; || particleName == quot;GenericIonquot; ) {//Ions pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4ionIonisation, -1, 2, 2); } else if ((!particle->IsShortLived()) && (particle->GetPDGCharge() != 0.0) && (particle->GetParticleName() != quot;chargedgeantinoquot;)) { //all others charged particles except geantino pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4hIonisation, -1, 2, 2); } } } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  35. 35. ExPhysicsList - demo #include quot;G4Decay.hhquot; void ExN02PhysicsList::ConstructGeneral() { // Add Decay Process G4Decay* theDecayProcess = new G4Decay(); theParticleIterator->reset(); while( (*theParticleIterator)() ){ G4ParticleDefinition* particle = theParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); if (theDecayProcess->IsApplicable(*particle)) { pmanager ->AddProcess(theDecayProcess); // set ordering for PostStepDoIt and AtRestDoIt pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep); pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest); } } } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  36. 36. ExPhysicsList - demo #include quot;G4StepLimiter.hhquot; #include quot;G4UserSpecialCuts.hhquot; void ExPhysicsList::AddStepMax() { // Step limitation seen as a process G4StepLimiter* stepLimiter = new G4StepLimiter(); ////G4UserSpecialCuts* userCuts = new G4UserSpecialCuts(); theParticleIterator->reset(); while ((*theParticleIterator)()) { G4ParticleDefinition* particle = theParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); if (particle->GetPDGCharge() != 0.0) { pmanager ->AddDiscreteProcess(stepLimiter); ////pmanager ->AddDiscreteProcess(userCuts); } } } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  37. 37. ExPhysicsList - demo ExPhysicsList::ExPhysicsList(): G4VUserPhysicsList() { // default cut value (1.0mm) defaultCutValue = 1.0*mm; } void ExPhysicsList::SetCuts() { // the default cut value for all particle types SetCutsWithDefault(); // specific cut values SetCutValue(cutForGamma, quot;gammaquot;); SetCutValue(cutForElectron, quot;e-quot;); SetCutValue(cutForElectron, quot;e+quot;); if (verboseLevel>0) DumpCutValuesTable(); } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  38. 38. ExPhysicsList.hh #include quot;G4VUserPhysicsList.hhquot; #include quot;globals.hhquot; class ExPhysicsList: public G4VUserPhysicsList { public: ExPhysicsList(); ~ExPhysicsList(); protected: // Construct particle and physics process void ConstructParticle(); void ConstructProcess(); void SetCuts(); }; www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  39. 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. 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
  41. 41. ExPrimaryGeneratorAction ExPrimaryGeneratorAction www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  42. 42. ExPrimaryGeneratorAction - demo Definición de partícula disparadas G4int n_particle = 1; particleGun = new G4ParticleGun(n_particle); particleGun->SetParticleDefinition(G4Geantino::GeantinoDefinition()); particleGun->SetParticleEnergy(1.0*GeV); particleGun->SetParticlePosition(G4ThreeVector(-2.0*m,0.0*m,0.0*m)); Seteos posibles void SetParticleDefinition(G4ParticleDefinition*) void SetParticleMomentum(G4ParticleMomentum) void SetParticleMomentumDirection(G4ThreeVector) void SetParticleEnergy(G4double) void SetParticleTime(G4double) void SetParticlePosition(G4ThreeVector) void SetParticlePolarization(G4ThreeVector) void SetNumberOfParticles(G4int) www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  43. 43. ExPrimaryGeneratorAction.hh #include quot;G4VUserPrimaryGeneratorAction.hhquot; class G4ParticleGun; class G4Event; class ExPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction { public: ExPrimaryGeneratorAction(); ~ExPrimaryGeneratorAction(); public: void GeneratePrimaries(G4Event* anEvent); private: G4ParticleGun* particleGun; }; www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  44. 44. ExPrimaryGeneratorAction.cc – primera parte #include quot;ExPrimaryGeneratorAction.hhquot; #include quot;G4Event.hhquot; #include quot;G4ParticleGun.hhquot; #include quot;G4ParticleTable.hhquot; #include quot;G4ParticleDefinition.hhquot; #include quot;globals.hhquot; ExPrimaryGeneratorAction::ExPrimaryGeneratorAction() { G4int n_particle = 1; particleGun = new G4ParticleGun(n_particle); G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* particle = particleTable->FindParticle(quot;protonquot;); G4String particleName; // find in particle table particleGun->SetParticleDefinition(particleTable->FindParticle(particleName=quot;geantinoquot;)); // use defined particle particleGun->SetParticleDefinition(particle); particleGun->SetParticleEnergy(1.0*GeV); particleGun->SetParticlePosition(G4ThreeVector(-2.0*m, 0.0, 0.0)); } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  45. 45. ExPrimaryGeneratorAction.cc – segunda parte ExPrimaryGeneratorAction::~ExN01PrimaryGeneratorAction() { delete particleGun; } void ExPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) { G4int i = anEvent->get_eventID() % 3; switch(i) { case 0: particleGun->SetParticleMomentumDirection(G4ThreeVector(1.0,0.0,0.0)); break; case 1: particleGun->SetParticleMomentumDirection(G4ThreeVector(1.0,0.1,0.0)); break; case 2: particleGun->SetParticleMomentumDirection(G4ThreeVector(1.0,0.0,0.1)); break; } particleGun->generatePrimaryVertex(anEvent); } www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09

×