Home Geant4 Structure
Geant4 Structure PDF Print E-mail
Written by Willy Gerber   
Friday, 19 June 2009 12:28
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(
  G4stringworld_box_name,
  G4intlength_x,
  G4intlength_y,
  G4intlength_z);


Physical World volume
G4LogicalVolume* world_log = new G4LogicalVolume(
  G4boxworld_box,
  G4materialmaterial,
  G4stringname_world_log);


Logical World volumn
General volume definition

G4double dimensions = ?.?*m;
millimetermm
meterm
ggramm
nanosecondns
Mega electron VoltMeV
positron chargeeplus
degree Kelvinkelvin
amount of substancemole
luminous intensitycandela
radianradian
steradiansteradian


Definition of dimensions and units
G4VPhysicalVolume* physical_volume = new G4VolumeFunction(
  G4stringvolume_name,
  array of G4doubledimensions);


Physical volume (consult detail G4 volume function list)
G4LogicalVolume* logical_volume = new G4LogicalVolume(
  G4VPhysicalVolumephysical_volume,
  G4materialmaterial,
  G4stringname_logical_volume);


Logical World volumn
tree_vector = G4ThreeVector(
  G4intposition_x,
  G4intposition_y,
  G4intposition_z);


Position
G4VPhysicalVolume* physical_position = new G4PVPlacement(
  G4RotationMatrix*pRot,
  const G4ThreeVector&tlate,
  G4LogicalVolume*pCurrentLogical,
  const G4String&pName,
  G4LogicalVolume*pMotherLogical,
  G4boolpMany,
  G4intpCopyNo,
  G4boolpSurfChk=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 EAxispAxis,
  const G4intnReplicas,
  const G4doublewidth,
  const G4doubleoffset=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 EAxispAxis,
  const G4intnReplicas,
  G4VPVParameterisation*pParam,
  G4boolpSurfChk=false);


 
G4RotationMatrix* rotation = new G4RotationMatrix;

Rotates X and Z axes only
rotation->rotateY(
  G4doubleangle);


Rotates in an angle
G4ThreeVector trans(
  G4doubletrans_x,
  G4doubletrans_y,
  G4doubletrans_z);


 
G4Transform3D transform(
  G4RotationMatrix*rotation,
  G4ThreeVectortrans);


Build a transformation from a rotation and a translation
G4UnionSolid* union = new G4UnionSolid(
  G4stringname_union_volumen,
  G4Volumevolume_1,
  G4Volumevolume_2,
  [G4RotationMatrix*yRot],
  [G4ThreeVectorzTrans]);


Volume build by union of two volume.
G4IntersectionSolid* intersection = new G4IntersectionSolid(
  G4stringname_intersection_volumen,
  G4Volumevolume_1,
  G4Volumevolume_2,
  [G4Transform3Dtransform]);


Volume build by intersection of two volume.
G4SubtractionSolid* subtraction = new G4SubtractionSolid(
  G4stringname_substraction_volumen,
  G4Volumevolume_1,
  G4Volumevolume_2);


Volume build by substraction of two volume.
Material specification

G4Material* material = new G4Material(
  G4stringname_material
  G4intatomic_number
  G4doublemass_per_mole
  G4doubledensity);



Definition of simple material
G4Element* element = new G4Element(
  G4stringname
  G4stringsymbol
  G4intatomic_number
  G4doublemass_per_mole);


Definition of elements.
G4Material* material = new G4Material(
  G4stringname
  G4doubledensity
  G4intncomponents);


Definition of materials.
material->AddElement(
  G4Elementelement
  G4intnatoms

material->AddElement(element_1,natoms);
material->AddElement(element_2,natoms);

Associate elements to a material.
G4NistManager* manager = G4NistManager::Instance();
G4Material* material = manager->FindOrBuildMaterial(
  G4stringmaterial_name);


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(
  G4intPDGencoding);


Find the particle by PDG encoding.
G4ParticleDefinition* GetIon(
  G4intatomicNumber
  G4intatomicMass
  G4doubleexcitationEnergy


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(
  G4doublecutForGamma,
  G4stringparticle_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(
  pPhotoElectricEffectG4PhotoElectricEffect);


Register gamma Photo Electric Effect process
pmanager->AddDiscreteProcess(
  pComptonScatteringG4ComptonScattering);


Register gamma Compton Scattering process
pmanager->AddDiscreteProcess(
  pGammaConversionG4GammaConversion);


Register gamma Conversion process
Generate Primary Events
particleGun = new G4ParticleGun(
  G4intnumber_particle);


Create particle for impacting the target
particleGun->SetParticleDefinition(
  G4ParticleDefinition*particle_definition);


Define the particle type
particleGun->SetParticleMomentum(
  G4ParticleMomentumparticle_momentum);


Define the particle momentum
particleGun->SetParticleMomentumDirection(
  G4ThreeVectormementum);


Define the particle momentum direction
particleGun->SetParticleEnergy(
  G4doubleenergy);


Define the particle energy
particleGun->SetParticleTime(
  G4doubletime);


Define the time
particleGun->SetParticlePosition(
  G4ThreeVectorvector);


Define the particle position
particleGun->SetParticlePolarization(
  G4ThreeVectorpolarization));


Define the particle polarization
particleGun->SetNumberOfParticles(
  G4intnumber_particles));


Define the number of particles
particleGun->generatePrimaryVertex(
  G4Event*anEvent);


Generate a primary vertex event
delete particleGun;

Delete the gun
 
Copyright © 2010 gPhysics. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.