Structure of the main program
Description 
The simplest main program has the structure:```int main(int argc, char** argv){ G4RunManager* runManager = new G4RunManager; MyGeometry* geom = new MyGeometry(); runManager->SetUserInitialization(geom); MyPhysicsList* physics = new MyPhysicsList(); runManager->SetUserInitialization(physics); MyPrimaryGeneratorAction* generator = new MyPrimaryGeneratorAction(); runManager->SetUserAction(generator); runManager->Initialize(); runManager->BeamOn(1); delete runManager; return 0;}```where:> control is initialized> geometry is created> the particles are created> the particle generator is created> a particle is fired> the program is closed
ID:(9412, 0)
Creation of geometry
Description 
The minimum to create the geometry is a volume, which can be done through```Class MyGeometry : public G4VUserDetectorConstruction{ G4VPhysicalVolume* Construct();}```what is inherited from G4VUserDetectorConstruction.The volume will include all the remaining volumes of the model and is called the 'world'.
ID:(9411, 0)
Creation of particles
Description 
The easiest way to create the particles is to use the default list that Gean4 brings, which is done through```G4VUserPhysicsList* physics = new FTFP_BERT();runManager->SetUserInitialization(physics);```what is inherited from G4VUserPhysicsList.The other alternative is the customized creation by the user that must include the particle constructor (ConstructParticle ()), processes (ConstructProcess ()) and cuts (SetCuts ()) by:```class MyPhysics : public G4VUserPhysicsList{ void ConstructParticle(); void ConstructProcess(); void SetCuts();}```
ID:(9413, 0)
Shot of particles
Description 
To generate the particles a generator is created with```class myGenerator : public G4VUserPrimaryGeneratorAction{ void GeneratePrimaries(G4Event*);}```which is inherited from G4VUserPrimaryGeneratorAction and must implement GeneratePrimaries(G4Event*).The particles can be generated by G4ParticleGun on which you can define key parameters such as:```G4ParticleGun* myGun = new G4ParticleGun(int n_particle = 1);myGun->SetMomentumDirection(G4ThreeVector(1,0,0));myGun->SetKineticEnergy(50.*MeV);myGun->GeneratePrimaryVertex(G4Event* anEvent);```
ID:(9414, 0)
