Instructions for Geant4 simulation
How to …
- Batch jobs
- Running interactively (with/without interactive Geant4 or Athena)
- Running with python scripting only (preliminary) TBD
- Setting parameters
- Working with macros
- Visualize detector and particle trajectories
- See also
1) Batch jobs
How to run in batch mode - tbd
In directory "run" get the jobOptions and then execute the Athena G4 python script
> athena.py AtlasG4Sim/jobOptions.AtlasG4Sim.py
or alternatively
> get_files jobOptions.AtlasG4Sim.py
> athena.py jobOptions.AtlasG4Sim.pyor using the alias to athena.py
> G4Atlas jobOptions.AtlasG4Sim.py
How to watch or kill batch jobs
You can check the status of your job(s) by executing the bjobs
command,
which takes a jobID
as parameter for the "long command".
You can kill your jobs with command bkill
>
> bjobs
> bjobs -l jobID
> bkill jobID
How to terminate cleanly an LSF batch job
To terminate an LSF batch job before it reaches its time limit,
the service LSFTimeKeeper
(package Control) has to be activated by including in your top-level jobOptions
#include "LSFTimeKeeper/LSFTimeKeeperOptions.py"
If you do not run an LSF job, but still want your job to terminate after a certain time, add the following lines, where 3600 is the time in total CPU seconds. Be aware that the average event processing time reported by the LSF and POSIX time-keepers are calculated differently and may not agree with each other.
AthenaEventLoopMgr.TimeKeeper = "SimplePOSIXTimeKeeperSvc";
SimplePOSIXTimeKeeperSvc.AllocTime = 3600;
2) Interactive jobs
How to run interactively
Under control of the python script athena.py
the Geant4 and/or the Athena sessions
can be run interactively.
- Geant4 interactive session, Python non-interactive session
- In the file
jobOptions.AtlasG4Sim.py
set InteractiveG4 to TRUE. When you executeG4Atlas
, you will be prompted withPreInit>
. The program will end when typingexit
.> G4Atlas jobOptions.AtlasG4Sim.py
PreInit>
PreInit> exit - Geant4 interactive session and Python interactive session
- Start G4Atlas with the
-i
option. You will be prompted withathena>
. To start the G4 interactive session, typetheApp.initialize()
. The program will stop with thePreInit>
prompt. By typingexit
the program will return to theathena>
prompt.
By typingtheApp.run()
the default number of events will be processed; by typingtheApp.run(10)
10 events will be processed. After processing, the program returns to python. To terminate typetheApp.exit()
.> G4Atlas -i jobOptions.AtlasG4Sim.py
athena>
athena> theApp.initialize()
PreInit>
PreInit> exit
athena>
athena> theApp.run() or theApp.run(10)
athena> theApp.exit()
- Geant4 non-interactive session and Python interactive session
- In the file
jobOptions.AtlasG4Sim.py
leave the value forInteractiveG4
at its default valueFALSE
. The interactive G4 part will be skipped and the program stops in python with theathena>
prompt. Continue as in the previous case.
3) How to run with python scripting only (preliminary)
TBD
4) Setting parameters
How to run with/without GeoModel
The jobOptions for GeoModel are jobOptions.AtlasGeoG4Sim.py
.
Use them similar to the instructions for jobOptions.AtlasG4Sim.py
in "How to run in batch mode".
Warning: in rel 8.3.0 add the following line in your jobOptions
#include "AtlasGeoModel/InDetGeoModel.txt" (add after this line)
#include "AtlasGeoModel/MuonGeoModel.txt"
How to run with/without magnetic field
The default is to use the magnetic field. To run without magnetic field, comment out the following line in the macro, which sets up the geometry, e.g. Atlas.mac or AtlasGeoModel.mac.
/control/execute AtlasField.mac
How to define the primary vertex region and other restricted regions
Vertex region and vertex spread, as well as the geometrical region for generation can be declared as follows
/Filters/Vertex/toggle ON
/Filters/Vertex/Spread 0.015 0.015 56. mm
/Filters/EtaPhiFilter/toggle ON
/Filters/EtaPhiFilter/EtaInterval -3.2 3.2
In this example the primary vertex will be Gaussian distributed with sigmas in (x,y,z) of the defined values and eta will be restricted to -3.2 lt; eta < 3.2
How to define G4 Regions and set cuts per G4 Region
The two examples show how a Region is defined, a geometrical volume assigned to it and cuts defined for the particles. Example for Muon MDTs:
/Physics/Region/CreateNew DriftWall
/Physics/Region/DriftWall/AddVolume MuonSystem::MDTDriftWall
/Physics/Region/DriftWall/SetParticleCut e- 0.005 mm
Example for LAr
/Physics/Region/DriftWall/SetParticleCut e+ 0.005 mm
/Physics/Region/CreateNew HEC
/Physics/Region/HEC/AddVolume LAr::HEC::LiquidArgon
/Physics/Region/HEC/SetParticleCut e- 0.020 mm
/Physics/Region/HEC/SetParticleCut e+ 0.020 mm
/Physics/Region/HEC/SetParticleCut gamma 0.020 mm
Note: When you assign a Region to a logical volume, it includes all the daughter volumes. The above statements set the cuts for the entire LAr volume that encloses the HEC, as well as all volumes of the HEC itself.
How to change a physics list
The definition of the physics lists used by ATLAS is available on CVS, directory G4PhysicsList (*.hh and *.icc files on LXR). To know more about the physics list, refer to the Geant4 manual, Physics Lists (new pages not yet fully implemented, old pages no longer functional). The old G4 manual is still accessible, see Physics reference manual.
How to perform an action
To perform an action at the beginning of Run/Event/Step use these commands
/Actions/RegisterForAction G4SimTimer BeginOfEvent
/Actions/RegisterForAction G4SimTimer EndOfEvent
/Actions/RegisterForAction G4SimTimer BeginOfRun
/Actions/RegisterForAction G4SimTimer EndOfRun
In this example the G4SimTimer
is requested to act at the Begin/End
of the event and the Begin/End of the run.
5) Working with macros
How to create an html directory for all available commands
Create a new directory and then execute the command to create the HTML directory tree.
Start to navigate the tree from the file _.html
.
If newdir
is not specified, then the tree will be created in the directory,
where the command was executed.
> mkdir newdir
…
Preinit> control/createHTML newdir
How to queue and execute more than one macro
In your jobOptions file replace the line G4Svc.FADSMacro …
, with a line
which specifies the macros as shown below.
The macros are executed in the order in which they are declared.
G4Svc.FADSMacro = "Atlas.mac";
replace with
G4Svc.FADSMacro = "macro1.mac:macro2.mac:etc ";
Run interactively as explained above. Start from the Preinit>
prompt and
print the physics list
Preinit> Physics/PrintLists
Printing the list of pre-defined physics lists:
10
--- Physics list ExN01
--- Physics list ExN02
--- Physics list ExN03
--- Physics list ExN04
--- Physics list Fast_Physics
--- Physics list LHEP_BERT
--- Physics list LHEP_GN
--- Physics list QGSP_BERT
--- Physics list QGSP_GN
Do not forget to set the values of cuts such that they are best suited for your studies. Then set the new physics list.
/Physics/SetGeneralCut 1 mm
/Physics/GetPhysicsList QGSP_GN Physics/ConstructPhysicsList
6) Visualize detector and particle trajectories
How to visualize your detector
Activate in your jobOptions file the interactive G4 and visualization.
G4Svc.InteractiveG4 = true;
G4Svc.Visualize = true;
The command sequence is listed below using the example macro for displaying
the beampipe (red), fastvisual.mac
.
Copy the macro Atlas.mac
to your run directory. Copy also the file fastvisual.mac
or
provide your own macro. Then start the job as shown below. In the athena prompt athena>
type the usual command to initialize, and in the PreInit>
prompt execute the macro
fastvisual.mac
. By default a VRML 1.0 File g4_00.wrl is generated. This takes a while,
the time is proportional to the number of volumes to be drawn. A graphics window will pop up;
you can modify the windows dimensions, the visualization parameters, and -
using the mouse - rotate, zoom, translate, and save your drawing as jpg file.
To continue, close the window by choosing from menu "File" > "Close".
This returns to the PreInit>
prompt. Continue and terminate as described above.
> cd <your_run_directory>
> get_files Atlas.mac
[ download file fastvisual.mac ]
> G4Atlas -i jobOptions.AtlasG4Sim.py
athena> theApp.initialize()
PreInit> /control/execute fastvisual.mac
[ window pops up, when you are finished close it ]
PreInit> exit
athena> theApp.run()
How to make use of the new visualization commands
(Merge with previous section, once it is clarified where login.mac is located)
If you add to the jobOptions the following line, the interactive session will start the command with a list of all logical volumes currently defined, grouped by detector:
G4Svc.FADSMacro = "login.mac:Atlas.mac";
[ starts the session with the command ]
/Geometry/ListAllVolumes
How to make use of special visualization commands
/vis/DrawDetector detName depthOfDescent
/vis/DrawLogicalVolume volName depthOfDescent
The first command draws an entire detector (e.g. TRT), the second command draws a logical volume (LV) tree.
- The argument
depthOfDescent
allows to visualize as many layers as you want below the one you're refering to; its default value is 1. DrawLogicalVolume
scans the LV store and uses the first LV with the name you provided: if more than one LV with the same name exist, only the first one will be displayed.
How to draw a particle trajectory
To draw a particle trajectory, execute commands similar to the following example for the Inner Detector:
/load G4UserActions
/load G4EventGraphics
/Actions/RegisterForAction DrawEventAction BeginOfEvent
/Actions/RegisterForAction DrawEventAction EndOfEvent
/Geometry/Volumes/SetMaxStep IDET::IDET 5 cm
/EventGraphics/TrackDisplayLevel 1
/EventGraphics/TrackColorScheme 3
/EventGraphics/TrackPtCut .3 GeV
/EventGraphics/NeutralTracks Off
See also
- How to run an LSF batch job (examples from DC2 pre-production)
- How to run with pile-up (min bias and cavern bkgd)
- Event Display Event display. See also Geant4 visualisation (old web, up to date?)