| main() | |
G4RunManager* runManager = new G4RunManager;
| Construct the default run manager |
Project_DetectorConstruction* detector new Project_DetectorConstruction runManager->SetUserInitialization(detector); runManager->SetUserInitialization(new Project_List);
| Set mandatory initialization classes |
runManager->SetUserAction(new Project_PrimaryGeneratorAction);
| Set mandatory user action class |
G4VisManager* visManager = new G4VisExecutive; visManager->Initialize();
| Initialize visualization manager
|
runManager->SetUserAction(new Project_PrimaryGeneratorAction(detector)); runManager->SetUserAction(new Project_RunAction); runManager->SetUserAction(new Project_EventAction); runManager->SetUserAction(new Project_SteppingAction);
| Set user action classes |
runManager->Initialize();
| Initialize G4 kernel
|
G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand("/run/verbose 1"); UI->ApplyCommand("/event/verbose 1"); UI->ApplyCommand("/tracking/verbose 1");
| Get the pointer to the UI manager and set verbosities |
G4UIsession * session = new G4UIterminal; UI->ApplyCommand("/control/execute prerun.g4mac"); session->sessionStart(); delete session;
| Define (G)UI terminal for interactive mode |
G4String command = "/control/execute "; G4String fileName = argv[1]; UI->ApplyCommand(command+fileName);
| Batch mode |
int numberOfEvent = 3; runManager->BeamOn(numberOfEvent);
| Start a run |
delete runManager; delete visManager; return 0;
| Job termination
|
| Project_DetectorConstruction.cc | |
| World Volume |
G4Box* world_box = new G4Box( | G4string | world_box_name, | | G4int | length_x,
| | G4int | length_y,
| | G4int | length_z); |
| Physical World volume |
G4LogicalVolume* world_log = new G4LogicalVolume( | G4box | world_box, | | G4material | material, | | G4string | name_world_log); |
| Logical World volumn |
| General volume definition |
G4double dimensions = ?.?*m; | millimeter | mm | | meter | m | | g | gramm | | nanosecond | ns | | Mega electron Volt | MeV | | positron charge | eplus | | degree Kelvin | kelvin | | amount of substance | mole | | luminous intensity | candela | | radian | radian | | steradian | steradian |
| Definition of dimensions and units |
G4VPhysicalVolume* physical_volume = new G4VolumeFunction( | G4string | volume_name, | | array of G4double | dimensions); |
| Physical volume (consult detail G4 volume function list) |
G4LogicalVolume* logical_volume = new G4LogicalVolume( | G4VPhysicalVolume | physical_volume, | | G4material | material, | | G4string | name_logical_volume); |
| Logical World volumn |
tree_vector = G4ThreeVector( | G4int | position_x, | | G4int | position_y, | | G4int | position_z); |
| Position |
G4VPhysicalVolume* physical_position = new G4PVPlacement( | G4RotationMatrix* | pRot, | | const G4ThreeVector& | tlate, | | G4LogicalVolume* | pCurrentLogical, | | const G4String& | pName, | | G4LogicalVolume* | pMotherLogical, | | G4bool | pMany, | | G4int | pCopyNo, | | G4bool | pSurfChk=false); |
| | Rotation with respect to its mother volume | | Translation with respect to its mother volume | | The associated Logical Volume | | String identifier for this placement | | The associated mother volume | | For future use. Can be set to false | | Integer which identifies this placement | | If true activates check for overlaps with existing volumes |
|
G4PVReplica( | const G4String& | pName, | | G4LogicalVolume* | pCurrentLogical, | G4LogicalVolume* or G4VPhysicalVolume* | pMotherLogical, | | const EAxis | pAxis, | | const G4int | nReplicas, | | const G4double | width, | | const G4double | offset=0); |
| | String identifier for the replicated volume | | The associated Logical Volume | | The associated mother volume | | The axis along with the replication is applied | | The number of replicated volumes | | The width of a single replica along the axis of replication | | Possible offset associated to mother offset along the axis of replication |
|
G4PVParameterised( | const G4String& | pName, | | G4LogicalVolume* | pCurrentLogical, | G4LogicalVolume*pMotherLogical, or G4VPhysicalVolume* | | const EAxis | pAxis, | | const G4int | nReplicas, | | G4VPVParameterisation* | pParam, | | G4bool | pSurfChk=false); |
| |
G4RotationMatrix* rotation = new G4RotationMatrix;
| Rotates X and Z axes only |
rotation->rotateY(
| Rotates in an angle |
G4ThreeVector trans( | G4double | trans_x, | | G4double | trans_y, | | G4double | trans_z); |
| |
G4Transform3D transform( | G4RotationMatrix* | rotation, | | G4ThreeVector | trans); |
| Build a transformation from a rotation and a translation
|
G4UnionSolid* union = new G4UnionSolid( | G4string | name_union_volumen, | | G4Volume | volume_1, | | G4Volume | volume_2, | | [G4RotationMatrix* | yRot], | | [G4ThreeVector | zTrans]); |
| Volume build by union of two volume. |
G4IntersectionSolid* intersection = new G4IntersectionSolid( | G4string | name_intersection_volumen, | | G4Volume | volume_1, | | G4Volume | volume_2, | | [G4Transform3D | transform]); |
| Volume build by intersection of two volume. |
G4SubtractionSolid* subtraction = new G4SubtractionSolid( | G4string | name_substraction_volumen, | | G4Volume | volume_1, | | G4Volume | volume_2); |
| Volume build by substraction of two volume. |
| Material specification |
G4Material* material = new G4Material( | G4string | name_material | | G4int | atomic_number | | G4double | mass_per_mole | | G4double | density); |
| Definition of simple material |
G4Element* element = new G4Element( | G4string | name | | G4string | symbol | | G4int | atomic_number | | G4double | mass_per_mole); |
| Definition of elements. |
G4Material* material = new G4Material( | G4string | name | | G4double | density | | G4int | ncomponents); |
| Definition of materials. |
material->AddElement( | G4Element | element | | G4int | natoms |
material->AddElement(element_1,natoms); material->AddElement(element_2,natoms);
| Associate elements to a material. |
G4NistManager* manager = G4NistManager::Instance(); G4Material* material = manager->FindOrBuildMaterial(
| Material from the Geant4 Material Database. |
G4cout << material; G4Material material
| Print a given material. |
G4cout << *(G4Material::GetMaterialTable());
| Print the list of materials. |
| Specify Particles | |
| ConstructParticle(); - Construction of particles |
FindParticle( G4string name);
| Find the particle by name. |
FindParticle(
| Find the particle by PDG encoding. |
G4ParticleDefinition* GetIon( | G4int | atomicNumber | | G4int | atomicMass | | G4double | excitationEnergy |
| Get heavy ions (including hyper-nuclei) |
G4Geantino::GeantinoDefinition();
| Contruct a "Geantino". |
G4Proton::ProtonDefinition();
| Construct a Proton. |
G4LeptonConstructor pConstructor; pConstructor.ConstructParticle();
| Construct all Leptons. |
| SetCuts(); - Setting a range cut value for all particles |
SetCutsWithDefault();
| Set default cut values. |
G4double defaultCutValue = value;
| Default cut values. |
SetCutValue( | G4double | cutForGamma, | | G4string | particle_name); |
| Set cut value for a specific particle. |
| ConstructProcess(); - Construct processes and register them to particles |
AddTransportation();
| Add transportation process |
G4ParticleDefinition* particle = G4Gamma::GammaDefinition(); G4ProcessManager* pmanager = particle->GetProcessManager();
| Get the process manager for gamma |
G4PhotoElectricEffect * pPhotoElectricEffect = new G4PhotoElectricEffect();
| Construct Photo Electric Effect processes for gamma |
G4ComptonScattering * pComptonScattering = new G4ComptonScattering();
| Construct Compton Scattering processes for gamma |
G4GammaConversion* pGammaConversion = new G4GammaConversion();
| Construct Conversion processes for gamma |
pmanager->AddDiscreteProcess( | pPhotoElectricEffect | G4PhotoElectricEffect); |
| Register gamma Photo Electric Effect process |
pmanager->AddDiscreteProcess( | pComptonScattering | G4ComptonScattering); |
| Register gamma Compton Scattering process |
pmanager->AddDiscreteProcess( | pGammaConversion | G4GammaConversion); |
| Register gamma Conversion process |
| Generate Primary Events |
particleGun = new G4ParticleGun(
| Create particle for impacting the target |
particleGun->SetParticleDefinition( | G4ParticleDefinition* | particle_definition); |
| Define the particle type |
particleGun->SetParticleMomentum( | G4ParticleMomentum | particle_momentum); |
| Define the particle momentum |
particleGun->SetParticleMomentumDirection(
| Define the particle momentum direction |
particleGun->SetParticleEnergy(
| Define the particle energy |
particleGun->SetParticleTime(
| Define the time |
particleGun->SetParticlePosition(
| Define the particle position |
particleGun->SetParticlePolarization( | G4ThreeVector | polarization)); |
| Define the particle polarization |
particleGun->SetNumberOfParticles(
| Define the number of particles |
particleGun->generatePrimaryVertex(
| Generate a primary vertex event |
delete particleGun;
| Delete the gun |