SlideShare a Scribd company logo
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
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
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
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
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
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
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
Includes y Subrutinas




                                  Includes y Subrutinas




                 www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
ExDetectorConstruction - demo




                                 ExDetectorConstruction




                www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
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
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
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
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
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
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
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
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
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
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
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
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
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
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
ExPhysicsList




                                   ExPhysicsList




                www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
ExPrimaryGeneratorAction




                        ExPrimaryGeneratorAction




                www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
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
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
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
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

More Related Content

Similar to UFRO Master Fisica Medica 5 3 Geant4

Going On with the Check of Geant4
Going On with the Check of Geant4Going On with the Check of Geant4
Going On with the Check of Geant4
Andrey Karpov
 
Testing of javacript
Testing of javacriptTesting of javacript
Testing of javacriptLei Kang
 
API Performance Testing
API Performance TestingAPI Performance Testing
API Performance Testing
rsg00usa
 
Introducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerIntroducing Playwright's New Test Runner
Introducing Playwright's New Test Runner
Applitools
 
10reasons
10reasons10reasons
10reasonsLi Huan
 
Androidaop 170105090257
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257
newegg
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
Thierry Wasylczenko
 
Ineffective and Effective Ways To Find Out Latency Bottlenecks With Ftrace
Ineffective and Effective Ways To Find Out Latency Bottlenecks With FtraceIneffective and Effective Ways To Find Out Latency Bottlenecks With Ftrace
Ineffective and Effective Ways To Find Out Latency Bottlenecks With Ftrace
Yoshitake Kobayashi
 
Dalvik Source Code Reading
Dalvik Source Code ReadingDalvik Source Code Reading
Dalvik Source Code Reading
kishima7
 
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at RuntimeOSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
NETWAYS
 
Production Time Profiling and Diagnostics on the JVM
Production Time Profiling and Diagnostics on the JVMProduction Time Profiling and Diagnostics on the JVM
Production Time Profiling and Diagnostics on the JVM
Marcus Hirt
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extreme
yinonavraham
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
Gareth Rushgrove
 
Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Inside the JVM - Performance & Garbage Collector Tuning in JAVA Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Rafael Monteiro e Pereira
 
Maze
MazeMaze
Maze
yito24
 
PHPUnit testing to Zend_Test
PHPUnit testing to Zend_TestPHPUnit testing to Zend_Test
PHPUnit testing to Zend_Test
Michelangelo van Dam
 
[232]TensorRT를 활용한 딥러닝 Inference 최적화
[232]TensorRT를 활용한 딥러닝 Inference 최적화[232]TensorRT를 활용한 딥러닝 Inference 최적화
[232]TensorRT를 활용한 딥러닝 Inference 최적화
NAVER D2
 
[232] TensorRT를 활용한 딥러닝 Inference 최적화
[232] TensorRT를 활용한 딥러닝 Inference 최적화[232] TensorRT를 활용한 딥러닝 Inference 최적화
[232] TensorRT를 활용한 딥러닝 Inference 최적화
NAVER D2
 
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
solit
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
Suman Sourav
 

Similar to UFRO Master Fisica Medica 5 3 Geant4 (20)

Going On with the Check of Geant4
Going On with the Check of Geant4Going On with the Check of Geant4
Going On with the Check of Geant4
 
Testing of javacript
Testing of javacriptTesting of javacript
Testing of javacript
 
API Performance Testing
API Performance TestingAPI Performance Testing
API Performance Testing
 
Introducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerIntroducing Playwright's New Test Runner
Introducing Playwright's New Test Runner
 
10reasons
10reasons10reasons
10reasons
 
Androidaop 170105090257
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
Ineffective and Effective Ways To Find Out Latency Bottlenecks With Ftrace
Ineffective and Effective Ways To Find Out Latency Bottlenecks With FtraceIneffective and Effective Ways To Find Out Latency Bottlenecks With Ftrace
Ineffective and Effective Ways To Find Out Latency Bottlenecks With Ftrace
 
Dalvik Source Code Reading
Dalvik Source Code ReadingDalvik Source Code Reading
Dalvik Source Code Reading
 
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at RuntimeOSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
 
Production Time Profiling and Diagnostics on the JVM
Production Time Profiling and Diagnostics on the JVMProduction Time Profiling and Diagnostics on the JVM
Production Time Profiling and Diagnostics on the JVM
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extreme
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
 
Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Inside the JVM - Performance & Garbage Collector Tuning in JAVA Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Inside the JVM - Performance & Garbage Collector Tuning in JAVA
 
Maze
MazeMaze
Maze
 
PHPUnit testing to Zend_Test
PHPUnit testing to Zend_TestPHPUnit testing to Zend_Test
PHPUnit testing to Zend_Test
 
[232]TensorRT를 활용한 딥러닝 Inference 최적화
[232]TensorRT를 활용한 딥러닝 Inference 최적화[232]TensorRT를 활용한 딥러닝 Inference 최적화
[232]TensorRT를 활용한 딥러닝 Inference 최적화
 
[232] TensorRT를 활용한 딥러닝 Inference 최적화
[232] TensorRT를 활용한 딥러닝 Inference 최적화[232] TensorRT를 활용한 딥러닝 Inference 최적화
[232] TensorRT를 활용한 딥러닝 Inference 최적화
 
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 

More from Willy H. Gerber

UACH Fisica en la Terapia Ocupacional 2.1 Accion del Musculo Teoria
UACH Fisica en la Terapia Ocupacional 2.1 Accion del Musculo TeoriaUACH Fisica en la Terapia Ocupacional 2.1 Accion del Musculo Teoria
UACH Fisica en la Terapia Ocupacional 2.1 Accion del Musculo Teoria
Willy H. Gerber
 
UACH Fisica En La Terapia Ocupacional 1 3 Rotacion Teoria
UACH Fisica En La Terapia Ocupacional 1 3 Rotacion TeoriaUACH Fisica En La Terapia Ocupacional 1 3 Rotacion Teoria
UACH Fisica En La Terapia Ocupacional 1 3 Rotacion Teoria
Willy H. Gerber
 
UACH Fisica En La Terapia Ocupacional 1 1 Modelando Teoria
UACH Fisica En La Terapia Ocupacional 1 1 Modelando TeoriaUACH Fisica En La Terapia Ocupacional 1 1 Modelando Teoria
UACH Fisica En La Terapia Ocupacional 1 1 Modelando Teoria
Willy H. Gerber
 
UACH Física en la Odontologia 3 3 Resonancia Magnética Nuclear
UACH Física en la Odontologia 3 3 Resonancia Magnética NuclearUACH Física en la Odontologia 3 3 Resonancia Magnética Nuclear
UACH Física en la Odontologia 3 3 Resonancia Magnética Nuclear
Willy H. Gerber
 
UACH Física en la Odontologia 2 6 Propiedades De Ceramicas Y Composits
UACH Física en la Odontologia 2 6 Propiedades De Ceramicas Y CompositsUACH Física en la Odontologia 2 6 Propiedades De Ceramicas Y Composits
UACH Física en la Odontologia 2 6 Propiedades De Ceramicas Y Composits
Willy H. Gerber
 
UACH Física en la Odontologia 3 2 Ultrasonido
UACH Física en la Odontologia 3 2 UltrasonidoUACH Física en la Odontologia 3 2 Ultrasonido
UACH Física en la Odontologia 3 2 Ultrasonido
Willy H. Gerber
 
UFRO Master Fisica Medica 5 2 Programando C
UFRO Master Fisica Medica 5 2 Programando CUFRO Master Fisica Medica 5 2 Programando C
UFRO Master Fisica Medica 5 2 Programando C
Willy H. Gerber
 
UFRO Master Fisica Medica 5 1 Conceptos
UFRO Master Fisica Medica 5 1 ConceptosUFRO Master Fisica Medica 5 1 Conceptos
UFRO Master Fisica Medica 5 1 Conceptos
Willy H. Gerber
 
UFRO Fisica En La Medicina 2009
UFRO Fisica En La Medicina 2009UFRO Fisica En La Medicina 2009
UFRO Fisica En La Medicina 2009
Willy H. Gerber
 
UACH Bachillerato Lab 13 Efecto Magnus
UACH Bachillerato Lab 13 Efecto MagnusUACH Bachillerato Lab 13 Efecto Magnus
UACH Bachillerato Lab 13 Efecto Magnus
Willy H. Gerber
 
UACH Bachillerato Lab 12 Termodinamica
UACH Bachillerato Lab 12 TermodinamicaUACH Bachillerato Lab 12 Termodinamica
UACH Bachillerato Lab 12 Termodinamica
Willy H. Gerber
 
UFRO Master Fisica Medica 4 2 Modelos
UFRO Master Fisica Medica 4 2 ModelosUFRO Master Fisica Medica 4 2 Modelos
UFRO Master Fisica Medica 4 2 Modelos
Willy H. Gerber
 
UACH Bachillerato Lab 11 Hidrodinamica
UACH Bachillerato Lab 11 HidrodinamicaUACH Bachillerato Lab 11 Hidrodinamica
UACH Bachillerato Lab 11 Hidrodinamica
Willy H. Gerber
 
Fisica Aplicada
Fisica AplicadaFisica Aplicada
Fisica Aplicada
Willy H. Gerber
 
UACH Bachillerato Lab 10; Hidrostatica
UACH Bachillerato Lab 10; HidrostaticaUACH Bachillerato Lab 10; Hidrostatica
UACH Bachillerato Lab 10; Hidrostatica
Willy H. Gerber
 
UACH Bachillerato, Lab 8: Rotación y Conservación de Energia
UACH Bachillerato, Lab 8: Rotación y Conservación de EnergiaUACH Bachillerato, Lab 8: Rotación y Conservación de Energia
UACH Bachillerato, Lab 8: Rotación y Conservación de Energia
Willy H. Gerber
 
UACH Bachillerato Lab 8: Fuerza en el Choque
UACH Bachillerato Lab 8: Fuerza en el ChoqueUACH Bachillerato Lab 8: Fuerza en el Choque
UACH Bachillerato Lab 8: Fuerza en el Choque
Willy H. Gerber
 
UACH Bachillerato Lab 7: Choque de un Cuerpo
UACH Bachillerato Lab 7: Choque de un CuerpoUACH Bachillerato Lab 7: Choque de un Cuerpo
UACH Bachillerato Lab 7: Choque de un Cuerpo
Willy H. Gerber
 
UACH Bachillerato Lab 6
UACH Bachillerato Lab 6UACH Bachillerato Lab 6
UACH Bachillerato Lab 6
Willy H. Gerber
 
UACH Fisica De Las Ciencias Forestales 2 2 Nadar Y Volar
UACH Fisica De Las Ciencias Forestales 2 2 Nadar Y VolarUACH Fisica De Las Ciencias Forestales 2 2 Nadar Y Volar
UACH Fisica De Las Ciencias Forestales 2 2 Nadar Y Volar
Willy H. Gerber
 

More from Willy H. Gerber (20)

UACH Fisica en la Terapia Ocupacional 2.1 Accion del Musculo Teoria
UACH Fisica en la Terapia Ocupacional 2.1 Accion del Musculo TeoriaUACH Fisica en la Terapia Ocupacional 2.1 Accion del Musculo Teoria
UACH Fisica en la Terapia Ocupacional 2.1 Accion del Musculo Teoria
 
UACH Fisica En La Terapia Ocupacional 1 3 Rotacion Teoria
UACH Fisica En La Terapia Ocupacional 1 3 Rotacion TeoriaUACH Fisica En La Terapia Ocupacional 1 3 Rotacion Teoria
UACH Fisica En La Terapia Ocupacional 1 3 Rotacion Teoria
 
UACH Fisica En La Terapia Ocupacional 1 1 Modelando Teoria
UACH Fisica En La Terapia Ocupacional 1 1 Modelando TeoriaUACH Fisica En La Terapia Ocupacional 1 1 Modelando Teoria
UACH Fisica En La Terapia Ocupacional 1 1 Modelando Teoria
 
UACH Física en la Odontologia 3 3 Resonancia Magnética Nuclear
UACH Física en la Odontologia 3 3 Resonancia Magnética NuclearUACH Física en la Odontologia 3 3 Resonancia Magnética Nuclear
UACH Física en la Odontologia 3 3 Resonancia Magnética Nuclear
 
UACH Física en la Odontologia 2 6 Propiedades De Ceramicas Y Composits
UACH Física en la Odontologia 2 6 Propiedades De Ceramicas Y CompositsUACH Física en la Odontologia 2 6 Propiedades De Ceramicas Y Composits
UACH Física en la Odontologia 2 6 Propiedades De Ceramicas Y Composits
 
UACH Física en la Odontologia 3 2 Ultrasonido
UACH Física en la Odontologia 3 2 UltrasonidoUACH Física en la Odontologia 3 2 Ultrasonido
UACH Física en la Odontologia 3 2 Ultrasonido
 
UFRO Master Fisica Medica 5 2 Programando C
UFRO Master Fisica Medica 5 2 Programando CUFRO Master Fisica Medica 5 2 Programando C
UFRO Master Fisica Medica 5 2 Programando C
 
UFRO Master Fisica Medica 5 1 Conceptos
UFRO Master Fisica Medica 5 1 ConceptosUFRO Master Fisica Medica 5 1 Conceptos
UFRO Master Fisica Medica 5 1 Conceptos
 
UFRO Fisica En La Medicina 2009
UFRO Fisica En La Medicina 2009UFRO Fisica En La Medicina 2009
UFRO Fisica En La Medicina 2009
 
UACH Bachillerato Lab 13 Efecto Magnus
UACH Bachillerato Lab 13 Efecto MagnusUACH Bachillerato Lab 13 Efecto Magnus
UACH Bachillerato Lab 13 Efecto Magnus
 
UACH Bachillerato Lab 12 Termodinamica
UACH Bachillerato Lab 12 TermodinamicaUACH Bachillerato Lab 12 Termodinamica
UACH Bachillerato Lab 12 Termodinamica
 
UFRO Master Fisica Medica 4 2 Modelos
UFRO Master Fisica Medica 4 2 ModelosUFRO Master Fisica Medica 4 2 Modelos
UFRO Master Fisica Medica 4 2 Modelos
 
UACH Bachillerato Lab 11 Hidrodinamica
UACH Bachillerato Lab 11 HidrodinamicaUACH Bachillerato Lab 11 Hidrodinamica
UACH Bachillerato Lab 11 Hidrodinamica
 
Fisica Aplicada
Fisica AplicadaFisica Aplicada
Fisica Aplicada
 
UACH Bachillerato Lab 10; Hidrostatica
UACH Bachillerato Lab 10; HidrostaticaUACH Bachillerato Lab 10; Hidrostatica
UACH Bachillerato Lab 10; Hidrostatica
 
UACH Bachillerato, Lab 8: Rotación y Conservación de Energia
UACH Bachillerato, Lab 8: Rotación y Conservación de EnergiaUACH Bachillerato, Lab 8: Rotación y Conservación de Energia
UACH Bachillerato, Lab 8: Rotación y Conservación de Energia
 
UACH Bachillerato Lab 8: Fuerza en el Choque
UACH Bachillerato Lab 8: Fuerza en el ChoqueUACH Bachillerato Lab 8: Fuerza en el Choque
UACH Bachillerato Lab 8: Fuerza en el Choque
 
UACH Bachillerato Lab 7: Choque de un Cuerpo
UACH Bachillerato Lab 7: Choque de un CuerpoUACH Bachillerato Lab 7: Choque de un Cuerpo
UACH Bachillerato Lab 7: Choque de un Cuerpo
 
UACH Bachillerato Lab 6
UACH Bachillerato Lab 6UACH Bachillerato Lab 6
UACH Bachillerato Lab 6
 
UACH Fisica De Las Ciencias Forestales 2 2 Nadar Y Volar
UACH Fisica De Las Ciencias Forestales 2 2 Nadar Y VolarUACH Fisica De Las Ciencias Forestales 2 2 Nadar Y Volar
UACH Fisica De Las Ciencias Forestales 2 2 Nadar Y Volar
 

Recently uploaded

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 

Recently uploaded (20)

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 

UFRO Master Fisica Medica 5 3 Geant4

  • 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
  • 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. 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. 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. 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. Includes y Subrutinas Includes y Subrutinas www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  • 9. ExDetectorConstruction - demo ExDetectorConstruction 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
  • 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. 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
  • 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. 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. 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. 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. 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. 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. 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. ExPhysicsList ExPhysicsList 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
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  • 41. ExPrimaryGeneratorAction ExPrimaryGeneratorAction www.gphysics.net – UFRO-2008-Master-Fisica-Medica-5-3-Geant4-05.09
  • 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. 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. 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. 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