Geant4
Geant4 is a toolkit for the simulation of the passage of particles through matter. It is used, e. g. by Mokka. The central installation is available at /afs/desy.de/group/it/ilcsoft/geant4, which is also used by the central Mokka installation. But if you need to change / add something, you have to get your own installation. The latest version and some documentation is available at http://cern.ch/geant4/.
Contents
Installing Geant4
First of all download the latest Geant4 version (currently 4.9.1 patch-02 released 9 May 2008) as Unix tar format, compressed using gzip. You will most probably also need the data packages
- Neutron data files with thermal cross sections
- Data files for low energy electromagnetic processes
- Data files for photon evaporation
- Data files for radioactive decay hadronic processes
- Data files for nuclear shell effects in INCL/ABLA hadronic model
Best is to make a new directory for Geant4, and one for the data files.
$ cd myPathToGeant $ mkdir Geant4 $ cd Geant4 $ mkdir G4Data
Save the geant4.9.1.p02.tar.gz in Geant4 and the data packages in G4Data.
The next step is to unpack all the packages:
$ tar -xzvf geant4.9.1.p02.tar.gz
which will create a directory geant4.9.1.p02. You also need to unpack the data packages.
Before proceeding, make sure you haven’t set any other Geant4 environment in your shell. This can be done by
printenv | grep G4
If you find something, please unset it.
Now you can start the installation. This will take some time and you will have to answere some questions.
$ cd myPathToGeant/Geant4/geant4.9.1.p02 $ ./Configure -build
When it says:
Could not find CLHEP installed on this system!
Please, specify where CLHEP is installed. The central installation is /opt/products/CLHEP/2.0.3.2.
You should be able to pick the default for almost all questions. Anyhow, it doesn’t harm to actually read the question before hitting Enter. One point you may want to change is
G4VIS_BUILD_OPENGLX_DRIVER G4VIS_USE_OPENGLX
The default here is no. Typing “y” will allow you to visualize what is going on.
Once all of the questions have been answered, you will be told:
WARNING: the generated configuration file can be edited if necessary! You can introduce any change to the configuration file ... Press [Enter] to start installation or use a shell escape to edit config.sh:
So hit Enter one last time and do something else for the next hour or so while your computer is busy with the installation. It should start with
Now starting Geant4 libraries build...
and end with
#################################################### # Your Geant4 installation seems to be successful! # To be sure please have a look into the log file: # Geant4/geant4.9.1.p02/.config/bin/Linux-g++/g4make.log ####################################################
Creating the setup script
Before actually running Geant4, you have to set some environment variables. Fortunately, Geant4 is generating the environment script itself. Just type
$ ./Configure
once more (without -build this time). This will create an env.sh and env.csh file in your Geant4/geant4.9.1.p02 directory.
Running Geant4 with Mokka
To introduce your Geant4 installation to Mokka adopt the Mokka environment script
export LD_LIBRARY_PATH=${CLHEP_LIB_DIR}:${LD_LIBRARY_PATH} export G4INSTALL="myPathtoGeant/Geant4/geant4.9.1.p02" export G4WORKDIR=$PWD source ${G4INSTALL}/env.sh
This will automatically set the correct variables for Geant4 if you initialize Mokka.
Modifying Geant4
Adding new Particles
Geant4 knows the particles as defined in geant4.9.1.p02/source/particles. There are subdevided in bosons, hadrons, and leptons. Chose the type of particle you would like to add and add a class in the corresponding subdirectory. For example, I have decided to create a Neutralino, which is a supersymmetric partner of a boson, and therefore a lepton.
$ cd myPathToGeant/Geant4/geant4.9.1.p02/source/particles/leptons/include
Create a file G4Neutralino.hh, which is derived from G4ParticleDefinition.hh:
#ifndef G4Neutralino #define G4Neutralino_h 1 #include "globals.hh" #include "G4ios.hh" #include "G4ParticleDefinition.hh" class G4Neutralino : public G4ParticleDefinition { private: static G4Neutralino *theInstance; G4Neutralino() {} ~G4Neutralino() {} public: static G4Neutralino *Definition(); static G4Neutralino *NeutralinoDefinition(); static G4Neutralino *Neutralino(); }; #endif
Now you have to assign your particles properties in
$ cd myPathToGeant/Geant4/geant4.9.1.p02/source/particles/leptons/src
Where you should add a file G4Neutralino.cc, which should look like
#include "G4Neutralino.hh" #include "G4ParticleTable.hh" #include "G4PhaseSpaceDecayChannel.hh" #include "G4DecayTable.hh" G4Neutralino *G4Neutralino::theInstance = 0; G4Neutralino *G4Neutralino::Definition() { if (theInstance != 0) return theInstance; const G4String name = "neu1"; // search in particle table G4ParticleTable *pTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition *anInstance = pTable->FindParticle(name); if (anInstance == 0) { // create particle // // Arguments for constructor are as follows // name mass width charge // 2*spin parity C-conjugation // 2*Isospin 2*Isospin3 G-parity // type lepton number baryon number PDG encoding // stable lifetime decay table // shortlived subType anti_encoding anInstance = new G4ParticleDefinition( name, 151.01*GeV, 1.601e-12*MeV, 0.0, 1, 0, 0, 0, 0, 0, "lepton", 0, 0, 1000022, false, 0.20285*ns, NULL, false, "neutralino" ); } //create Decay Table G4DecayTable *table = new G4DecayTable(); // create a decay channel G4VDecayChannel *mode; // neu1 -> gravitino + gamma mode = new G4PhaseSpaceDecayChannel("neu1", 1.0, 2, "grav", "gamma"); table->Insert(mode); anInstance->SetDecayTable(table); theInstance = reinterpret_cast<G4Neutralino*>(anInstance); return theInstance; } G4Neutralino *G4Neutralino::NeutralinoDefinition() { return Definition(); } G4Neutralino *G4Neutralino::Neutralino() { return Definition(); }
This corresponds to a spin 1/2 lepton with a mass of 151 GeV and a width of 1.601e-6 eV, that will decay within 0.20285 ns and a branching ratio of 100% into a Gravitino and a photon. One also has to introdice the Gravitino in this example.
Of course you will have to re-compile Geant4 once you changed it.
Modifying the physics list
Before accessing the new particle, you will have to introduce it to the physics list you are using. Usually this will be LCPhys as defined in your Mokka version.
$ cd myPathToMokka/Mokka/Mokka_06-06_p03/source/LCPhys/src
Open the particle class you have changed with your favourite text editor, e. g.
$ emacs LCLeptonPhysics.cc&
and add
... #include "G4Neutralino.hh" ... void LCLeptonPhysics::ConstructParticle() { ... G4Neutralino::NeutralinoDefinition(); } ...
Afterwards re-compile Mokka.