La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

Objetivos: Comprender como se estructuran programas que simulan procesos basados en Geant4. 1 5. Técnicas de Simulación 3. Geant4 www.gphysics.net – UFRO-Master-Fisica-Medica-5-3-Geant4-05.09.

Presentaciones similares


Presentación del tema: "Objetivos: Comprender como se estructuran programas que simulan procesos basados en Geant4. 1 5. Técnicas de Simulación 3. Geant4 www.gphysics.net – UFRO-Master-Fisica-Medica-5-3-Geant4-05.09."— Transcripción de la presentación:

1 Objetivos: Comprender como se estructuran programas que simulan procesos basados en Geant Técnicas de Simulación 3. Geant4 – UFRO-Master-Fisica-Medica-5-3-Geant Dr. Willy H. Gerber Instituto de Fisica Universidad Austral Valdivia, Chile

2 Estructura de archivos 2 – UFRO-Master-Fisica-Medica-5-3-Geant Demo Include src MainDemo.cc ExPrimaryGeneratorAction.hh ExDetectorConstruction.hh ExPhysicsList.hh ExPrimaryGeneratorAction.cc ExDetectorConstruction.cc ExPhysicsList.cc

3 Programas Geant4 3 – UFRO-Master-Fisica-Medica-5-3-Geant Includes necesarios Setear runManager int main(int argc,char** argv) { Definir Output delete visManager; delete runManager; return 0; } Ejecutar Proceso

4 Estructuras a incluir 4 #include "G4RunManager.hh" #include "G4UImanager.hh" #include "G4UIterminal.hh" #include "G4VisExecutive.hh" #include "ExDetectorConstruction.hh" #include "ExPhysicsList.hh" #include "ExPrimaryGeneratorAction.hh #include ExRunAction.hh" #include ExEventAction.hh" #include ExSteppingAction.hh" #include G4templates.hh" – UFRO-Master-Fisica-Medica-5-3-Geant

5 Inicialización runManager - Clases 5 G4RunManager* runManager = new G4RunManager; – UFRO-Master-Fisica-Medica-5-3-Geant Construction del runManager 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);

6 Inicializacion runManager 6 – UFRO-Master-Fisica-Medica-5-3-Geant Inicializacion el sistema runManager->Initialize(); G4VisManager* visManager = new G4VisExecutive; visManager->Initialize(); G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand("/run/verbose 1"); UI->ApplyCommand("/event/verbose 1"); UI->ApplyCommand("/tracking/verbose 1"); Inicializacion … Inicializacion del Display

7 Ejecutar 7 int numberOfEvent = 3; runManager->BeamOn(numberOfEvent); – UFRO-Master-Fisica-Medica-5-3-Geant Ejecución if(argc==1) // Define (G)UI terminal for interactive mode { G4UIsession * session = new G4UIterminal; UI->ApplyCommand("/control/execute prerun.g4mac"); session->sessionStart(); delete session; } else // Batch mode { G4String command = "/control/execute "; G4String fileName = argv[1]; UI->ApplyCommand(command+fileName); }

8 Includes y Subrutinas – UFRO-Master-Fisica-Medica-5-3-Geant

9 ExDetectorConstruction ExDetectorConstruction - demo – UFRO-Master-Fisica-Medica-5-3-Geant

10 ExDetectorConstruction – UFRO-Master-Fisica-Medica-5-3-Geant Crear caja (volumen World) Crear cilindro Crear volumen lógico para caja Crear volumen lógico para cilindro Posicionar cilindro Posicionar caja Lógica de la rutina con solo 2 elementos

11 ExDetectorConstruction - demo – UFRO-Master-Fisica-Medica-5-3-Geant G4double expHall_x = 3.0*m; G4double expHall_y = 1.0*m; G4double expHall_z = 1.0*m; G4Box* experimentalHall_box = new G4Box("expHall_box",expHall_x,expHall_y,expHall_z); 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("tracker_tube", innerRadiusOfTheTube, outerRadiusOfTheTube, hightOfTheTube, startAngleOfTheTube, spanningAngleOfTheTube); Crear caja – clase G4Box (volumen World) Crear cilindro – clase G4Tubs

12 ExDetectorConstruction - demo – UFRO-Master-Fisica-Medica-5-3-Geant G4LogicalVolume* experimentalHall_log = new G4LogicalVolume(experimentalHall_box,Ar,"expHall_log"); G4LogicalVolume* tracker_log = new G4LogicalVolume(tracker_tube,Al,"tracker_log"); 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 "tracker", // its name experimentalHall_log, // its mother (logical) volume false, // no boolean operations 0); // its copy number Crear volumen lógico para caja – clase G4LogicalVolume Crear volumen lógico para cilindro – clase G4LogicalVolume Posicionar cilindroc

13 ExDetectorConstruction - demo – UFRO-Master-Fisica-Medica-5-3-Geant G4VPhysicalVolume* experimentalHall_phys = new G4PVPlacement(0, // no rotation G4ThreeVector(0.,0.,0.), // translation position experimentalHall_log, // its logical volume "expHall", // its name 0, // its mother volume false, // no boolean operations 0); // its copy number Posicionar caja – clase G4LogicalVolume

14 ExDetectorConstruction - demo – UFRO-Master-Fisica-Medica-5-3-Geant Elementos G4double density = 1.390*g/cm3; G4double a = 39.95*g/mole; G4Material* lAr = new G4Material(name="liquidArgon", z=18., a, density); G4LogicalVolume* myLbox = new G4LogicalVolume(aBox,lAr,"Lbox",0,0,0); Material (directo) a = 1.01*g/mole; G4Element* elH = new G4Element(name="Hydrogen",symbol="H", z= 1., a); a = 16.00*g/mole; G4Element* elO = new G4Element(name="Oxygen",symbol="O", z= 8., a); density = 1.000*g/cm3; G4Material* H2O = new G4Material(name="Water",density,ncomponents=2); H2O->AddElement(elH, natoms=2); H2O->AddElement(elO, natoms=1); Material (compuesto desde elementos, por numero de elementos)

15 ExDetectorConstruction - demo – UFRO-Master-Fisica-Medica-5-3-Geant Elementos a = 14.01*g/mole; G4Element* elN = new G4Element(name="Nitrogen",symbol="N", z= 7., a); a = 16.00*g/mole; G4Element* elO = new G4Element(name="Oxygen",symbol="O", z= 8., a); density = 1.290*mg/cm3; G4Material* Air = new G4Material(name="Air ",density,ncomponents=2); Air->AddElement(elN, fractionmass=70*perCent); Air->AddElement(elO, fractionmass=30*perCent); Material (compuesto desde elementos, por fracción de átomos)

16 class G4LogicalVolume; class G4VPhysicalVolume; #include "G4VUserDetectorConstruction.hh" class ExDetectorConstruction : public G4VUserDetectorConstruction { public: ExDetectorConstruction(); ~ExDetectorConstruction(); G4VPhysicalVolume* Construct(); ExDetectorConstruction.hh – primer parte – UFRO-Master-Fisica-Medica-5-3-Geant

17 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; }; ExDetectorConstruction.hh – segunda parte – UFRO-Master-Fisica-Medica-5-3-Geant

18 #include "ExDetectorConstruction.hh" #include "G4Material.hh" #include "G4Box.hh" #include "G4Tubs.hh" #include "G4LogicalVolume.hh" #include "G4ThreeVector.hh" #include "G4PVPlacement.hh" #include "globals.hh" 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() { } ExDetectorConstruction.cc – primera parte – UFRO-Master-Fisica-Medica-5-3-Geant

19 G4VPhysicalVolume* ExN01DetectorConstruction::Construct() { // materials G4double a; // atomic mass G4double z; // atomic number G4double density; G4Material* Ar = new G4Material("ArgonGas", z= 18., a= 39.95*g/mole, density= 1.782*mg/cm3); G4Material* Al = new G4Material("Aluminum", z= 13., a= 26.98*g/mole, density= 2.7*g/cm3); G4Material* Pb = new G4Material("Lead", z= 82., a= *g/mole, density= 11.35*g/cm3); ExDetectorConstruction.cc – segunda parte – UFRO-Master-Fisica-Medica-5-3-Geant

20 // 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("expHall_box",expHall_x,expHall_y,expHall_z); experimentalHall_log = new G4LogicalVolume(experimentalHall_box, Ar,"expHall_log",0,0,0); experimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(), experimentalHall_log,"expHall",0,false,0); ExDetectorConstruction.cc – tercera parte – UFRO-Master-Fisica-Medica-5-3-Geant

21 // 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("tracker_tube",innerRadiusOfTheTube, outerRadiusOfTheTube,hightOfTheTube, startAngleOfTheTube,spanningAngleOfTheTube); tracker_log = new G4LogicalVolume(tracker_tube,Al,"tracker_log",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,"tracker",experimentalHall_log,false,0); ExDetectorConstruction.cc – cuarta parte – UFRO-Master-Fisica-Medica-5-3-Geant

22 // 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("calBlock_box",block_x, block_y,block_z); calorimeterBlock_log = new G4LogicalVolume(calorimeterBlock_box, Pb,"caloBlock_log",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,"caloBlock", experimentalHall_log,false,0); ExDetectorConstruction.cc – quinta parte – UFRO-Master-Fisica-Medica-5-3-Geant

23 // calorimeter layers (20 elements) G4double calo_x = 1.*cm; G4double calo_y = 40.*cm; G4double calo_z = 40.*cm; G4Box* calorimeterLayer_box = new G4Box("caloLayer_box, calo_x,calo_y,calo_z); calorimeterLayer_log = new G4LogicalVolume(calorimeterLayer_box, Al,"caloLayer_log",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,"caloLayer",calorimeterBlock_log,false,i); } // return experimentalHall_phys; } ExDetectorConstruction.cc – sesta parte – UFRO-Master-Fisica-Medica-5-3-Geant

24 ExPhysicsList – UFRO-Master-Fisica-Medica-5-3-Geant

25 Definición de partículas – UFRO-Master-Fisica-Medica-5-3-Geant G4String G4double G4int G4double G4int G4String G4int GetParticleName() GetPDGMass() GetPDGWidth() GetPDGCharge() GetPDGSpin() GetPDGMagneticMoment() GetPDGiParity() GetPDGiConjugation() GetPDGIsospin() GetPDGIsospin3() GetPDGiGParity() GetParticleType() GetParticleSubType() GetLeptonNumber() GetBaryonNumber() GetPDGEncoding() GetAntiPDGEncoding() particle name mass decay width electric charge spin magnetic moment (a) parity (b) charge conjugation (b) iso-spin 3 rd -component of iso-spin G-parity (0:not defined) particle type particle sub-type lepton number baryon number particle encoding number by PDG encoding for anti-particle of this particle a: 0: not defined or no mag. Moment b: 0:not defined

26 Definición de partículas – UFRO-Master-Fisica-Medica-5-3-Geant G4bool G4double G4DecayTable stable flag life time decay table GetPDGStable() GetPDGLifeTime() *GetDecayTable()

27 Variables dinámicas – UFRO-Master-Fisica-Medica-5-3-Geant G4double G4ThreeVector G4ParticleDefinition G4double G4ThreeVector G4double G4ElectronOccupancy theDynamicalMass theMomentumDirection *theParticleDefinition theDynamicalSpin thePolarization theMagneticMoment theKineticEnergy theProperTime theDynamicalCharge *theElectronOccupancy dynamical mass normalized momentum vector definition of particle dynamical spin (1) polarization vector dynamical magnetic moment (2) kinetic energy proper time dynamical electric charge (3) 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

28 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(); ExPhysicsList - demo – UFRO-Master-Fisica-Medica-5-3-Geant ExPhysicsList.hh

29 void ExPhysicsList::ConstructParticle() { G4Proton::ProtonDefinition(); ConstructBosons(); ConstructLeptons(); ConstructMesons(); ConstructBaryons(); G4Geantino::GeantinoDefinition(); } void ExPhysicsList::ConstructBosons() { G4Geantino::GeantinoDefinition(); // pseudo-particles G4ChargedGeantino::ChargedGeantinoDefinition(); G4Gamma::GammaDefinition(); // gamma } #include "ExPhysicsList.hh" #include "G4ProcessManager.hh" #include "G4ParticleTypes.hh" ExPhysicsList - demo – UFRO-Master-Fisica-Medica-5-3-Geant ExPhysicsList.cc

30 void ExPhysicsList::ConstructLeptons() { G4Electron::ElectronDefinition(); // e- G4Positron::PositronDefinition(); // e+ G4MuonPlus::MuonPlusDefinition(); // mu+ G4MuonMinus::MuonMinusDefinition(); // mu- 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(); } ExPhysicsList - demo – UFRO-Master-Fisica-Medica-5-3-Geant G4LeptonConstructor pConstructor; pConstructor.ConstructParticle(); Construir todos de una vez:

31 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(); } ExPhysicsList - demo – UFRO-Master-Fisica-Medica-5-3-Geant

32 #include "G4ComptonScattering.hh" #include "G4GammaConversion.hh" #include "G4PhotoElectricEffect.hh" #include "G4eMultipleScattering.hh" #include "G4hMultipleScattering.hh" #include "G4eIonisation.hh" #include "G4eBremsstrahlung.hh" #include "G4eplusAnnihilation.hh" #include "G4MuIonisation.hh" #include "G4MuBremsstrahlung.hh" #include "G4MuPairProduction.hh" #include "G4hIonisation.hh" #include "G4hBremsstrahlung.hh" #include "G4hPairProduction.hh" #include "G4ionIonisation.hh" ExPhysicsList - demo – UFRO-Master-Fisica-Medica-5-3-Geant

33 void ExN02PhysicsList::ConstructEM() { theParticleIterator->reset(); while( (*theParticleIterator)() ){ G4ParticleDefinition* particle = theParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); G4String particleName = particle->GetParticleName(); if (particleName == "gamma") { // gamma pmanager->AddDiscreteProcess(new G4PhotoElectricEffect); pmanager->AddDiscreteProcess(new G4ComptonScattering); pmanager->AddDiscreteProcess(new G4GammaConversion); } else if (particleName == "e-") { //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 == "e+") { //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); ExPhysicsList - demo – UFRO-Master-Fisica-Medica-5-3-Geant

34 } else if( particleName == "mu+" || particleName == "mu-" ) { //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 == "proton" || particleName == "pi-" || particleName == "pi+" ) { //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 == "alpha" || particleName == "He3" || particleName == "GenericIon" ) {//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() != "chargedgeantino")) { //all others charged particles except geantino pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4hIonisation, -1, 2, 2); } ExPhysicsList - demo – UFRO-Master-Fisica-Medica-5-3-Geant

35 #include "G4Decay.hh" 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); } ExPhysicsList - demo – UFRO-Master-Fisica-Medica-5-3-Geant

36 #include "G4StepLimiter.hh" #include "G4UserSpecialCuts.hh" 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); } ExPhysicsList - demo – UFRO-Master-Fisica-Medica-5-3-Geant

37 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, "gamma"); SetCutValue(cutForElectron, "e-"); SetCutValue(cutForElectron, "e+"); if (verboseLevel>0) DumpCutValuesTable(); } ExPhysicsList - demo – UFRO-Master-Fisica-Medica-5-3-Geant

38 #include "G4VUserPhysicsList.hh" #include "globals.hh" class ExPhysicsList: public G4VUserPhysicsList { public: ExPhysicsList(); ~ExPhysicsList(); protected: // Construct particle and physics process void ConstructParticle(); void ConstructProcess(); void SetCuts(); }; ExPhysicsList.hh – UFRO-Master-Fisica-Medica-5-3-Geant

39 #include "ExPhysicsList.hh" #include "G4ParticleTypes.hh" 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(); } ExPhysicsList.cc – primera parte – UFRO-Master-Fisica-Medica-5-3-Geant

40 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); // " G4VUserPhysicsList::SetCutsWithDefault" method sets // the default cut value for all particle types SetCutsWithDefault(); // Retrieve verbose level SetVerboseLevel(temp); } ExPhysicsList.cc – segunda parte – UFRO-Master-Fisica-Medica-5-3-Geant

41 ExPrimaryGeneratorAction – UFRO-Master-Fisica-Medica-5-3-Geant

42 void SetParticleDefinition(G4ParticleDefinition*) void SetParticleMomentum(G4ParticleMomentum) void SetParticleMomentumDirection(G4ThreeVector) void SetParticleEnergy(G4double) void SetParticleTime(G4double) void SetParticlePosition(G4ThreeVector) void SetParticlePolarization(G4ThreeVector) void SetNumberOfParticles(G4int) ExPrimaryGeneratorAction - demo – UFRO-Master-Fisica-Medica-5-3-Geant 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)); Definición de partícula disparadas Seteos posibles

43 #include "G4VUserPrimaryGeneratorAction.hh" class G4ParticleGun; class G4Event; class ExPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction { public: ExPrimaryGeneratorAction(); ~ExPrimaryGeneratorAction(); public: void GeneratePrimaries(G4Event* anEvent); private: G4ParticleGun* particleGun; }; ExPrimaryGeneratorAction.hh – UFRO-Master-Fisica-Medica-5-3-Geant

44 #include "ExPrimaryGeneratorAction.hh" #include "G4Event.hh" #include "G4ParticleGun.hh" #include "G4ParticleTable.hh" #include "G4ParticleDefinition.hh" #include "globals.hh" ExPrimaryGeneratorAction::ExPrimaryGeneratorAction() { G4int n_particle = 1; particleGun = new G4ParticleGun(n_particle); G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* particle = particleTable->FindParticle("proton"); G4String particleName; // find in particle table particleGun->SetParticleDefinition(particleTable->FindParticle(particleName="geantino")); // use defined particle particleGun->SetParticleDefinition(particle); particleGun->SetParticleEnergy(1.0*GeV); particleGun->SetParticlePosition(G4ThreeVector(-2.0*m, 0.0, 0.0)); } ExPrimaryGeneratorAction.cc – primera parte – UFRO-Master-Fisica-Medica-5-3-Geant

45 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); } ExPrimaryGeneratorAction.cc – segunda parte – UFRO-Master-Fisica-Medica-5-3-Geant


Descargar ppt "Objetivos: Comprender como se estructuran programas que simulan procesos basados en Geant4. 1 5. Técnicas de Simulación 3. Geant4 www.gphysics.net – UFRO-Master-Fisica-Medica-5-3-Geant4-05.09."

Presentaciones similares


Anuncios Google