Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-12 17:16:06 +01:00
parent 80e2389dd8
commit 84f33a068c
593 changed files with 68589 additions and 1 deletions
+64
View File
@@ -0,0 +1,64 @@
///\file "extended/.README.txt"
///\brief Geant4 Extended Examples README page
/*! \page README_extended Extended Examples
The set of "extended" examples is covering various
use-cases and may require some additional libraries besides of Geant4.
<i> The HTML documentation for extended examples is still work in progres.
Webified README pages are not yet available for all examples. </i>
\section ext_s1 Extended level examples:
- \link Examples_analysis analysis \endlink
- Histogramming through the Geant4 analysis and external tools
- \link Examples_biasing biasing \endlink
- Examples of event biasing, scoring and reverse-MC-
- \link Examples_common common \endlink
- A set of common classes which can be reused in other examples demonstrating just a particular feature
- \link Examples_electromagnetic electromagnetic \endlink
- Specific EM physics simulation with histogramming
- \link Exampleerrorpropagation errorpropagation \endlink
- Use of the error propagation utility (Geant4e)
- \link Examples_eventgenerator eventgenerator \endlink
- Applications demonstrating various ways of primary event generation:
using Geant4 particle gun, Geant4 general particle source,
using interface to HepMC, Pythia
- \link Examples_exoticphysics exoticphysics \endlink
- Exotic simulation applications (classical magnetic monopole, etc...)
- \link Examples_field field \endlink
- Specific simulation setups in magnetic field
- \link Examples_g3tog4 g3tog3 \endlink
- Examples of usage of the g3tog4 converter tool
- \link Examples_geometry geometry \endlink
- Specific geometry examples
- \link Examples_hadronic hadronic \endlink
- Specific hadronic physics simulation with histogramming
- \link Examples_medical medical \endlink
- Specific examples for medical physics applications
- \link Examples_optical optical \endlink
- Examples of generic optical processes simulation setups
- \link Examples_parallel parallel \endlink
- Examples of event-level parallelism in Geant4 using the
TOP-C distribution, and MPI technique
- \link Examples_parameterisations parameterisations \endlink
- Examples for fast shower parameterisations according to specific models
(gflash)
- \link Examples_persistency persistency \endlink
- Persistency of geometry (GDML or ASCII) and simulation output
- \link Examples_physicslists physicslists \endlink
- Examples to demonstrate usage of Geant4 reference physics lists and physics builders
- \link Examples_polarisation polarisation \endlink
- Use of physics processes including polarization
- \link Examples_radioactivedecay radioactivedecay \endlink
- Examples to simulate the decays of radioactive isotopes and
induced radioactivity resulted from nuclear interactions
- \link Examples_runAndEvent runAndEvent \endlink
- Examples to demonstrate how to connect the information between
primary particles and hits and utilize user-information classes
- \link Examples_visualization visualization \endlink
- Specific visualization features and graphical customisations
*/
+23
View File
@@ -0,0 +1,23 @@
///\file "analysis/.README.txt"
///\brief Examples analysis README page
/*! \page Examples_analysis Category "analysis"
Examples in this directory demonstrate how to make histograms and ntuples
\link ExampleAnaEx01 AnaEx01 \endlink
Simple example showing use of g4tools.
\link ExampleAnaEx02 AnaEx02 \endlink
As AnaEx01, but direct interface to ROOT.
\link ExampleB1Con B1Con \endlink
B1Con shows how to use the statistical tool G4ConvergenceTester.
It does not make histograms.
It has the same geometry as B1.
*/
@@ -0,0 +1,145 @@
///\file "analysis/AnaEx01/.README.txt"
///\brief Example AnaEx01 README page
/*! \page ExampleAnaEx01 Example AnaEx01
Examples AnaEx01 and AnaEx02 show the usage of histogram and tuple
manipulations using G4Analysis and ROOT compliant systems on the same
scenario. All analysis manipulations (histo booking, filling, saving histos
in a file, etc...) are located in one class : HistoManager, implementation of
which is different in each example. All the other classes are same in all
three examples.
This example shows the usage of histogram and tuple manipulations using
G4Analysis system.
The example is an adaptation of examples/novice/N03. It describes a simple
sampling calorimeter setup.
\section AnaEx01_s1 Detector description
The calorimeter is a box made of a given number of layers. A layer
consists of an absorber plate and of a detection gap. The layer is
replicated.
Six parameters define the calorimeter :
- the material of the absorber,
- the thickness of an absorber plate,
- the material of the detection gap,
- the thickness of a gap,
- the number of layers,
- the transverse size of the calorimeter (the input face is a square).
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be modified interactively via
the commands defined in the DetectorMessenger class.
<pre>
|<----layer 0---------->|<----layer 1---------->|<----layer 2---------->|
| | | |
==========================================================================
|| | || | || | ||
|| | || | || | ||
beam || absorber | gap || absorber | gap || absorber | gap ||
======> || | || | || | ||
|| | || | || | ||
==========================================================================
</pre>
\section AnaEx01_s2 Physics list
The particle's type and the physic processes which will be available
in this example are set in the FTFP_BERT physics list.
\section AnaEx01_s3 Action Initialization
A newly introduced class, ActionInitialization,
instantiates and registers to Geant4 kernel all user action classes
which are defined thread-local and a run action class
which is defined both thread-local and global.
The thread-local action classes are defined in
ActionInitialization::Build()
and the global run action class is defined in
ActionInitialization::BuildForMaster().
Note that ActionInitialization::Build() is also used to
instatiate user action clasess in sequential mode.
\section AnaEx01_s4 An event : PrimaryGeneratorAction
The primary kinematic consists of a single particle which hits the
calorimeter perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
be changed via the G4 build-in commands of ParticleGun class.
\section AnaEx01_s5 Histograms
AnaEx01 can produce 4 histograms :
- EAbs : total energy deposit in absorber per event
- EGap : total energy deposit in gap per event
- LAbs : total track length of charged particles in absorber per event
- LGap : total track length of charged particles in gap per event
And 2 Ntuples :
- Ntuple1:
- one row per event : EnergyAbs EnergyGap
- Ntuple2:
- one row per event : TrackLAbs TrackLGap
These histos and ntuples are booked in HistoManager and filled from
EventAction.
One can control the name of the histograms file and its format:
- default name : AnaEx01
The format of the histogram file can be : root (default),
xml, csv. Include correct g4nnn.hh in HistoManager.hh
\section AnaEx01_s7 How to build
An additional step is needed when building the example with GNUmake
due to using the extra shared directory:
\verbatim
% cd path_to_AnaEx01/AnaEx01
% gmake setup
% gmake
\endverbatim
This will copy the files from shared in the example include and src;
to remove these files:
\verbatim
% gmake clean_setup
\endverbatim
\section AnaEx01_s8 HOW TO RUN
- Execute AnaEx01 in the 'interactive mode' with visualization
\verbatim
% ./AnaEx01
and type in the commands from run.mac line by line:
Idle> /control/verbose 2
Idle> /tracking/verbose 1
Idle> /run/beamOn 10
Idle> ...
Idle> exit
\endverbatim
or
\verbatim
Idle> /control/execute run.mac
....
Idle> exit
\endverbatim
- Execute AnaEx01 in the 'batch' mode from macro files
(without visualization)
\verbatim
% ./AnaEx01 run.mac
% ./AnaEx01 run.mac > run.out
\endverbatim
The AnaEx01.in macro is used in Geant4 testing.
*/
+140
View File
@@ -0,0 +1,140 @@
--------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
AnaEx01
-------
Examples AnaEx01 and AnaEx02 show the usage of histogram and tuple
manipulations using G4Analysis and ROOT compliant systems on the same
scenario. All analysis manipulations (histo booking, filling, saving histos
in a file, etc...) are located in one class : HistoManager, implementation of
which is different in each example. All the other classes are same in all
three examples.
This example shows the usage of histogram and tuple manipulations using
G4Analysis system.
The example is an adaptation of examples/novice/N03. It describes a simple
sampling calorimeter setup.
1- Detector description
-----------------------
The calorimeter is a box made of a given number of layers. A layer
consists of an absorber plate and of a detection gap. The layer is
replicated.
Six parameters define the calorimeter :
- the material of the absorber,
- the thickness of an absorber plate,
- the material of the detection gap,
- the thickness of a gap,
- the number of layers,
- the transverse size of the calorimeter (the input face is a square).
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be modified interactively via
the commands defined in the DetectorMessenger class.
|<----layer 0---------->|<----layer 1---------->|<----layer 2---------->|
| | | |
==========================================================================
|| | || | || | ||
|| | || | || | ||
beam || absorber | gap || absorber | gap || absorber | gap ||
======> || | || | || | ||
|| | || | || | ||
==========================================================================
2- Physics list
---------------
The particle's type and the physic processes which will be available
in this example are set in the FTFP_BERT physics list.
3- Action Initialization
------------------------
A newly introduced class, ActionInitialization,
instantiates and registers to Geant4 kernel all user action classes
which are defined thread-local and a run action class
which is defined both thread-local and global.
The thread-local action classes are defined in
ActionInitialization::Build()
and the global run action class is defined in
ActionInitialization::BuildForMaster().
Note that ActionInitialization::Build() is also used to
instatiate user action clasess in sequential mode.
4- An event : PrimaryGeneratorAction
------------------------------------
The primary kinematic consists of a single particle which hits the
calorimeter perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
be changed via the G4 build-in commands of ParticleGun class.
5- Histograms
-------------
AnaEx01 can produce 4 histograms :
EAbs : total energy deposit in absorber per event
EGap : total energy deposit in gap per event
LAbs : total track length of charged particles in absorber per event
LGap : total track length of charged particles in gap per event
And 2 Ntuples :
- Ntuple1:
- one row per event : EnergyAbs EnergyGap
- Ntuple2:
- one row per event : TrackLAbs TrackLGap
These histos and ntuples are booked in HistoManager and filled from
EventAction.
One can control the name of the histograms file and its format:
default name : AnaEx01
The format of the histogram file can be : root (default),
xml, csv. Include correct g4nnn.hh in HistoManager.hh
6- How to build
---------------
An additional step is needed when building the example with GNUmake
due to using the extra shared directory:
% cd path_to_AnaEx01/AnaEx01
% gmake setup
% gmake
This will copy the files from shared in the example include and src;
to remove these files:
% gmake clean_setup
7- How to run
--------------
- Execute AnaEx01 in the 'interactive mode' with visualization
% ./AnaEx01
and type in the commands from run.mac line by line:
Idle> /control/verbose 2
Idle> /tracking/verbose 1
Idle> /run/beamOn 10
Idle> ...
Idle> exit
or
Idle> /control/execute run.mac
....
Idle> exit
- Execute AnaEx01 in the 'batch' mode from macro files
(without visualization)
% ./AnaEx01 run.mac
% ./AnaEx01 run.mac > run.out
The AnaEx01.in macro is used in Geant4 testing.
@@ -0,0 +1,149 @@
///\file "analysis/AnaEx02/.README.txt"
///\brief Example AnaEx02 README page
/*! \page ExampleAnaEx02 Example AnaEx02
Examples AnaEx01 and AnaEx02 show the usage of histogram and tuple
manipulations using G4Analysis and ROOT compliant systems on the same
scenario. All analysis manipulations (histo booking, filling, saving histos
in a file, etc...) are located in one class : HistoManager, implementation of
which is different in each example. All the other classes are same in all
three examples.
This example shows the usage of histogram and tuple manipulations using
ROOT system. Please install ROOT before building this example:
http://root.cern.ch
The example is an adaptation of examples/novice/N03. It describes a simple
sampling calorimeter setup.
\section AnaEx02_s1 Detector description
The calorimeter is a box made of a given number of layers. A layer
consists of an absorber plate and of a detection gap. The layer is
replicated.
Six parameters define the calorimeter :
- the material of the absorber,
- the thickness of an absorber plate,
- the material of the detection gap,
- the thickness of a gap,
- the number of layers,
- the transverse size of the calorimeter (the input face is a square).
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be modified interactively via
the commands defined in the DetectorMessenger class.
<pre>
|<----layer 0---------->|<----layer 1---------->|<----layer 2---------->|
| | | |
==========================================================================
|| | || | || | ||
|| | || | || | ||
beam || absorber | gap || absorber | gap || absorber | gap ||
======> || | || | || | ||
|| | || | || | ||
==========================================================================
</pre>
\section AnaEx02_s2 Physics list
The particle's type and the physic processes which will be available
in this example are set in the FTFP_BERT physics list.
\section AnaEx02_s3 Action Initialization
A newly introduced class, ActionInitialization,
instantiates and registers to Geant4 kernel all user action classes
which are defined thread-local and a run action class
which is defined both thread-local and global.
The thread-local action classes are defined in
ActionInitialization::Build()
and the global run action class is defined in
ActionInitialization::BuildForMaster().
Note that ActionInitialization::Build() is also used to
instatiate user action clasess in sequential mode.
\section AnaEx02_s4 An event : PrimaryGeneratorAction
The primary kinematic consists of a single particle which hits the
calorimeter perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
be changed via the G4 build-in commands of ParticleGun class.
\section AnaEx02_s5 Histograms
To produce histograms, ROOT system must be installed
AnaEx02 can produce 4 histograms :
- EAbs : total energy deposit in absorber per event
- EGap : total energy deposit in gap per event
- LAbs : total track length of charged particles in absorber per event
- LGap : total track length of charged particles in gap per event
And 2 Ntuples :
- Ntuple1:
- one row per event : EnergyAbs EnergyGap
- Ntuple2:
- one row per event : TrackLAbs TrackLGap
These histos and ntuples are booked in HistoManager and filled from
EventAction.
One can control the name of the histograms file :
- default name : AnaEx02
Format : root
See HistoManager constructor
\section AnaEx02_s6 How to build
An additional step is needed when building the example with GNUmake
due to using the extra shared directory:
\verbatim
% cd path_to_AnaEx02/AnaEx02
% gmake setup
% gmake
\endverbatim
This will copy the files from shared in the example include and src;
to remove these files:
\verbatim
% gmake clean_setup
\endverbatim
\section AnaEx02_s8 HOW TO RUN
- Execute AnaEx02 in the 'interactive mode' with visualization
\verbatim
% ./AnaEx02
and type in the commands from run.mac line by line:
Idle> /control/verbose 2
Idle> /tracking/verbose 1
Idle> /run/beamOn 10
Idle> ...
Idle> exit
\endverbatim
or
\verbatim
Idle> /control/execute run.mac
....
Idle> exit
\endverbatim
- Execute AnaEx02 in the 'batch' mode from macro files
(without visualization)
\verbatim
% ./AnaEx02 run.mac
% ./AnaEx02 run.mac > run.out
\endverbatim
The AnaEx02.in macro is used in Geant4 testing.
*/
+145
View File
@@ -0,0 +1,145 @@
--------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
AnaEx02
-------
Examples AnaEx01 and AnaEx02 show the usage of histogram and tuple
manipulations using G4Analysis and ROOT compliant systems on the same
scenario. All analysis manipulations (histo booking, filling, saving histos
in a file, etc...) are located in one class : HistoManager, implementation of
which is different in each example. All the other classes are same in all
three examples.
This example shows the usage of histogram and tuple manipulations using
ROOT system. Please install ROOT before building this example:
http://root.cern.ch
The example is an adaptation of examples/novice/N03. It describes a simple
sampling calorimeter setup.
1- Detector description
-----------------------
The calorimeter is a box made of a given number of layers. A layer
consists of an absorber plate and of a detection gap. The layer is
replicated.
Six parameters define the calorimeter :
- the material of the absorber,
- the thickness of an absorber plate,
- the material of the detection gap,
- the thickness of a gap,
- the number of layers,
- the transverse size of the calorimeter (the input face is a square).
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be modified interactively via
the commands defined in the DetectorMessenger class.
|<----layer 0---------->|<----layer 1---------->|<----layer 2---------->|
| | | |
==========================================================================
|| | || | || | ||
|| | || | || | ||
beam || absorber | gap || absorber | gap || absorber | gap ||
======> || | || | || | ||
|| | || | || | ||
==========================================================================
2- Physics list
---------------
The particle's type and the physic processes which will be available
in this example are set in the FTFP_BERT physics list.
3- Action Initialization
------------------------
A newly introduced class, ActionInitialization,
instantiates and registers to Geant4 kernel all user action classes
which are defined thread-local and a run action class
which is defined both thread-local and global.
The thread-local action classes are defined in
ActionInitialization::Build()
and the global run action class is defined in
ActionInitialization::BuildForMaster().
Note that ActionInitialization::Build() is also used to
instatiate user action clasess in sequential mode.
4- An event : PrimaryGeneratorAction
------------------------------------
The primary kinematic consists of a single particle which hits the
calorimeter perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
be changed via the G4 build-in commands of ParticleGun class.
5- Histograms
-------------
To produce histograms, ROOT system must be installed
AnaEx02 can produce 4 histograms :
EAbs : total energy deposit in absorber per event
EGap : total energy deposit in gap per event
LAbs : total track length of charged particles in absorber per event
LGap : total track length of charged particles in gap per event
And 2 Ntuples :
- Ntuple1:
- one row per event : EnergyAbs EnergyGap
- Ntuple2:
- one row per event : TrackLAbs TrackLGap
These histos and ntuples are booked in HistoManager and filled from
EventAction.
One can control the name of the histograms file :
default name : AnaEx02
format : root
See HistoManager constructor
6- How to build
---------------
An additional step is needed when building the example with GNUmake
due to using the extra shared directory:
% cd path_to_AnaEx02/AnaEx02
% gmake setup
% gmake
This will copy the files from shared in the example include and src;
to remove these files:
% gmake clean_setup
7- How to run
--------------
- Execute AnaEx02 in the 'interactive mode' with visualization:
% ./AnaEx02
and type in the commands from run.mac line by line:
Idle> /control/verbose 2
Idle> /tracking/verbose 1
Idle> /run/beamOn 10
Idle> ...
Idle> exit
or
Idle> /control/execute run.mac
....
Idle> exit
- Execute AnaEx02 in the 'batch' mode from macro files
(without visualization)
% ./AnaEx02 run.mac
% ./AnaEx02 run.mac > run.out
The AnaEx02.in macro is used in Geant4 testing.
@@ -0,0 +1,113 @@
///\file "analysis/B1Con/.README.txt"
///\brief Example B1Con README page
/*! \page ExampleB1Con Example B1Con
Example of Convergence Tester
Koi, Tatsumi \n
SLAC National Accelerator Laboratory / PPA \n
tkoi@slac.stanford.eedu \n
This example shows how to use convergece tester in Geant4.
The aim of Convergence Tester
- After a Monte Carlo simulation, we get an answer. However how to estimate quality of the answer.
The answer is usually given in a form of average value.
But sometimes the value is strongly affected by single or a few events in the full calculation.
In such case, we must concern about quality of the value.
What we must remember is
- Large number of history does not valid result of simulation.
- Small Relative Error does not valid result of simulation
Convergence tester provides statistical information
to assist establishing valid confidence intervals for Monte Carlo results for users.
Geometry and Physics are same to exampleB1. Please see \ref ExampleB1.
Note that in this example, the classes with the code added for
the purpose of demonstration of the Convergence Tester start with a prefix
B1Con instead of B1 and also the executable and the test macro names are changed
in exampleB1Con and exampleB1Con.in.
Known problem:
Computing time of T cannot be gotten properly in current MT migration of example of B1Con. Therefore
FOM (=1/(R^2T) where R is relative error and T is computing time) relates numbers are unusable.
\verbatim
***********************************************************************************************************************
Output example
// Part I.A
// Basic statistics values
G4ConvergenceTester Output Result of DOSE_TALLY
EFFICIENCY = 0.601
MEAN = 4.81721e-12
VAR = 2.15334e-23
SD = 4.64041e-12
R = 0.0304622
SHIFT = 2.22459e-13
VOV = 0.000166754
FOM = 1238.68
// Part I.B
// If the largeset scored events happen at next to the last event,
// then how much the event effects the statistics values of the calculation
THE LARGEST SCORE = 1.07301e-11 and it happend at 487th event
Affected Mean = 4.82311e-12 and its ratio to orignal is 1.00123
Affected VAR = 2.15468e-23 and its ratio to orignal is 1.00062
Affected R = 0.0304192 and its ratio to orignal is 0.998587
Affected SHIFT = 2.1804e-13 and its ratio to orignal is 0.980133
Affected FOM = 1238.68 and its ratio to orignal is 1
// Part I.C
// Convergence tests results
MEAN distribution is RANDOM
r follows 1/std::sqrt(N)
r is monotonically decrease
r is less than 0.1. r = 0.0304622
VOV follows 1/std::sqrt(N)
VOV is monotonically decrease
FOM distribution is not RANDOM
SLOPE is not large enough
This result passes 6 / 8 Convergence Test.
// Part II
// Profile of statistics values in the history
G4ConvergenceTester Output History of DOSE_TALLY
i/16 till_ith mean var sd r vov fom shift e r2eff r2int
1 62 4.94618e-12 2.04631e-23 4.52362e-12 0.115225 0.00313634 86.5745 -1.73435e-14 0.619048 0.00976801 0.00329797
2 124 4.69364e-12 2.10698e-23 4.59018e-12 0.0874712 0.001597 150.228 3.11143e-13 0.6 0.00533333 0.00225666
3 187 4.72161e-12 2.14009e-23 4.62612e-12 0.0714575 0.00101852 225.105 3.1009e-13 0.590426 0.00368986 0.00138916
4 249 4.95617e-12 2.13982e-23 4.62582e-12 0.0590299 0.000690138 329.865 9.71971e-14 0.62 0.00245161 0.00101898
5 312 4.8529e-12 2.13482e-23 4.62041e-12 0.0538155 0.000573301 396.887 1.95662e-13 0.607029 0.00206827 0.000818582
6 374 5.14255e-12 2.15736e-23 4.64474e-12 0.046641 0.000432121 528.379 -6.42963e-14 0.637333 0.00151743 0.000652145
7 437 5.03849e-12 2.13484e-23 4.62043e-12 0.0438173 0.000379317 598.673 2.54207e-14 0.636986 0.00130112 0.000614447
8 499 4.96962e-12 2.1429e-23 4.62914e-12 0.0416574 0.000329007 662.364 9.27708e-14 0.63 0.0011746 0.000557264
9 562 4.91513e-12 2.14709e-23 4.63367e-12 0.0397316 0.000285324 728.13 1.33544e-13 0.623446 0.0010728 0.000502991
10 624 4.82995e-12 2.13825e-23 4.62412e-12 0.0382954 0.000272664 783.766 2.19101e-13 0.616 0.000997403 0.000466792
11 687 4.79197e-12 2.13975e-23 4.62574e-12 0.0368022 0.000251788 848.661 2.48547e-13 0.606105 0.000944593 0.000407838
12 749 4.77183e-12 2.15116e-23 4.63807e-12 0.0354912 0.000227501 912.513 2.6728e-13 0.601333 0.000883962 0.000373986
13 812 4.76087e-12 2.14479e-23 4.63119e-12 0.0341162 0.000212259 987.548 2.70437e-13 0.597786 0.000827601 0.000334885
14 874 4.81359e-12 2.13296e-23 4.6184e-12 0.0324353 0.0001976 1092.56 2.14521e-13 0.603429 0.000751082 0.000299767
15 937 4.82018e-12 2.14558e-23 4.63204e-12 0.0313767 0.000181379 1167.52 2.18545e-13 0.601279 0.000706952 0.000276498
16 999 4.81721e-12 2.15334e-23 4.64041e-12 0.0304622 0.000166754 1238.68 2.22459e-13 0.601 0.000663894 0.000263125
**************************************************************************************************************************
\endverbatim
Reference of this Convergence tests: \n
MCNP(TM) -A General Monte Carlo N-Particle Transport Code \n
Version 4B \n
Judith F. Briesmeister, Editor \n
LA-12625-M, Issued: March 1997, UC 705 and UC 700 \n
CHAPTER 2. GEOMETRY, DATA, PHYSICS, AND MATHEMATICS \n
VI. ESTIMATION OF THE MONTE CARLO PRECISION \n
*/
+102
View File
@@ -0,0 +1,102 @@
Example of Convergence Tester
Koi, Tatsumi
SLAC National Accelerator Laboratory / PPA
tkoi@slac.stanford.eedu
This example shows how to use convergece tester in Geant4.
The aim of Convergence Tester
After a Monte Carlo simulation, we get an answer. However how to estimate quality of the answer.
The answer is usually given in a form of average value.
But sometimes the value is strongly affected by single or a few events in the full calculation.
In such case, we must concern about quality of the value.
What we must remember is
Large number of history does not valid result of simulation.
Small Relative Error does not valid result of simulation
Convergence tester provides statistical information
to assist establishing valid confidence intervals for Monte Carlo results for users.
Geometry and Physics are same to exampleB1. Please see README.B1
Note that in this example, the classes with the code added for
the purpose of demonstration of the Convergence Tester start with a prefix
B1Con instead of B1 and also the executable and the test macro names are changed
in exampleB1Con and exampleB1Con.in.
Known problem:
Computing time of T cannot be gotten properly in current MT migration of example of B1Con. Therefore
FOM (=1/(R^2T) where R is relative error and T is computing time) relates numbers are unusable.
***********************************************************************************************************************
Output example
// Part I.A
// Basic statistics values
G4ConvergenceTester Output Result of DOSE_TALLY
EFFICIENCY = 0.601
MEAN = 4.81721e-12
VAR = 2.15334e-23
SD = 4.64041e-12
R = 0.0304622
SHIFT = 2.22459e-13
VOV = 0.000166754
FOM = 1238.68
// Part I.B
// If the largeset scored events happen at next to the last event,
// then how much the event effects the statistics values of the calculation
THE LARGEST SCORE = 1.07301e-11 and it happend at 487th event
Affected Mean = 4.82311e-12 and its ratio to orignal is 1.00123
Affected VAR = 2.15468e-23 and its ratio to orignal is 1.00062
Affected R = 0.0304192 and its ratio to orignal is 0.998587
Affected SHIFT = 2.1804e-13 and its ratio to orignal is 0.980133
Affected FOM = 1238.68 and its ratio to orignal is 1
// Part I.C
// Convergence tests results
MEAN distribution is RANDOM
r follows 1/std::sqrt(N)
r is monotonically decrease
r is less than 0.1. r = 0.0304622
VOV follows 1/std::sqrt(N)
VOV is monotonically decrease
FOM distribution is not RANDOM
SLOPE is not large enough
This result passes 6 / 8 Convergence Test.
// Part II
// Profile of statistics values in the history
G4ConvergenceTester Output History of DOSE_TALLY
i/16 till_ith mean var sd r vov fom shift e r2eff r2int
1 62 4.94618e-12 2.04631e-23 4.52362e-12 0.115225 0.00313634 86.5745 -1.73435e-14 0.619048 0.00976801 0.00329797
2 124 4.69364e-12 2.10698e-23 4.59018e-12 0.0874712 0.001597 150.228 3.11143e-13 0.6 0.00533333 0.00225666
3 187 4.72161e-12 2.14009e-23 4.62612e-12 0.0714575 0.00101852 225.105 3.1009e-13 0.590426 0.00368986 0.00138916
4 249 4.95617e-12 2.13982e-23 4.62582e-12 0.0590299 0.000690138 329.865 9.71971e-14 0.62 0.00245161 0.00101898
5 312 4.8529e-12 2.13482e-23 4.62041e-12 0.0538155 0.000573301 396.887 1.95662e-13 0.607029 0.00206827 0.000818582
6 374 5.14255e-12 2.15736e-23 4.64474e-12 0.046641 0.000432121 528.379 -6.42963e-14 0.637333 0.00151743 0.000652145
7 437 5.03849e-12 2.13484e-23 4.62043e-12 0.0438173 0.000379317 598.673 2.54207e-14 0.636986 0.00130112 0.000614447
8 499 4.96962e-12 2.1429e-23 4.62914e-12 0.0416574 0.000329007 662.364 9.27708e-14 0.63 0.0011746 0.000557264
9 562 4.91513e-12 2.14709e-23 4.63367e-12 0.0397316 0.000285324 728.13 1.33544e-13 0.623446 0.0010728 0.000502991
10 624 4.82995e-12 2.13825e-23 4.62412e-12 0.0382954 0.000272664 783.766 2.19101e-13 0.616 0.000997403 0.000466792
11 687 4.79197e-12 2.13975e-23 4.62574e-12 0.0368022 0.000251788 848.661 2.48547e-13 0.606105 0.000944593 0.000407838
12 749 4.77183e-12 2.15116e-23 4.63807e-12 0.0354912 0.000227501 912.513 2.6728e-13 0.601333 0.000883962 0.000373986
13 812 4.76087e-12 2.14479e-23 4.63119e-12 0.0341162 0.000212259 987.548 2.70437e-13 0.597786 0.000827601 0.000334885
14 874 4.81359e-12 2.13296e-23 4.6184e-12 0.0324353 0.0001976 1092.56 2.14521e-13 0.603429 0.000751082 0.000299767
15 937 4.82018e-12 2.14558e-23 4.63204e-12 0.0313767 0.000181379 1167.52 2.18545e-13 0.601279 0.000706952 0.000276498
16 999 4.81721e-12 2.15334e-23 4.64041e-12 0.0304622 0.000166754 1238.68 2.22459e-13 0.601 0.000663894 0.000263125
**************************************************************************************************************************
Reference of this Convergence tests
MCNP(TM) -A General Monte Carlo N-Particle Transport Code
Version 4B
Judith F. Briesmeister, Editor
LA-12625-M, Issued: March 1997, UC 705 and UC 700
CHAPTER 2. GEOMETRY, DATA, PHYSICS, AND MATHEMATICS
VI. ESTIMATION OF THE MONTE CARLO PRECISION
+167
View File
@@ -0,0 +1,167 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Example B1
-----------
This example demonstrates a very simple application where an energy
deposit is accounted in user actions and their associated objects
and a dose in a selected volume is calculated.
1- GEOMETRY DEFINITION
The geometry is constructed in the B1DetectorConstruction class.
The setup consists of a an envelope of box shape containing two
volumes: a spherical cone and a trapezoid.
In this example we use some common materials materials for medical
applications. The envelope is made of water and the two inner volumes
are made from tissue and bone materials.
The materials are created with the help of the G4NistManager class,
which allows to build a material from the NIST database using their
names. All available materials can be found in the Geant4 User's Guide
for Application Developers, Appendix 10: Geant4 Materials Database.
2- PHYSICS LIST
The particle's type and the physic processes which will be available
in this example are set in the QBBC physics list. This physics list
requires data files for electromagnetic and hadronic processes.
See more on installation of the datasets in Geant4 Installation Guide,
Chapter 3.3: Note On Geant4 Datasets:
http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides
/InstallationGuide/html/ch03s03.html
The following datasets: G4LEDATA, G4LEVELGAMMADATA, G4NEUTRONXSDATA and
G4SAIDXSDATA are mandatory for this example.
In addition the build-in interactive command:
/process/(in)activate processName
allows to activate/inactivate the processes one by one.
3- ACTION INITALIZATION
A newly introduced class, B1ActionInitialization, instantiates and registers
to Geant4 kernel all user action classes.
While in sequential mode the action classes are instatiated just once,
via invoking the method:
B1ActionInitialization::Build()
in multi-threading mode the same method is invoked for each thread worker
and so all user action classes are defined thread-local.
A run action class is instantiated both thread-local
and global that's why its instance has is created also in the method
B1ActionInitialization::BuildForMaster()
which is invoked only in multi-threading mode.
4- PRIMARY GENERATOR
The primary generator is defined in the B1PrimaryGeneratorAction class.
The default kinematics is a 6 MeV gamma, randomly distributed in front
of the envelope across 80% of the transverse (X,Y) envelope size.
This default setting can be changed via the Geant4 built-in commands
of the G4ParticleGun class.
5- DETECTOR RESPONSE
This example demonstrates a simple scoring implemented directly
in the user action classes and B1Run object.
Alternative ways of scoring via Geant4 classes can be found in the
other examples.
The energy deposited is collected step by step for a selected volume
in B1SteppingAction and accumulated event by event in B1EventAction.
At end of event, the value acummulated in B1EventAction is added in B1Run
and summed over the whole run (see B1EventAction::EndOfevent()).
Total dose deposited is computed at B1RunAction::EndOfRunAction(),
and printed together with informations about the primary particle.
In multi-threading mode the energy accumulated in B1Run objects per
workers is merged to the master in B1Run::Merge() and the final
result is printed on the screen.
An example of creating and computing new units (e.g., dose) is also shown
in the class constructor.
The following paragraphs are common to all basic examples
A- VISUALISATION
The visualization manager is set via the G4VisExecutive class
in the main() function in exampleB1.cc.
The initialisation of the drawing is done via a set of /vis/ commands
in the macro vis.mac. This macro is automatically read from
the main function when the example is used in interactive running mode.
By default, vis.mac opens an OpenGL viewer (/vis/open OGL).
The user can change the initial viewer by commenting out this line
and instead uncommenting one of the other /vis/open statements, such as
HepRepFile or DAWNFILE (which produce files that can be viewed with the
HepRApp and DAWN viewers, respectively). Note that one can always
open new viewers at any time from the command line. For example, if
you already have a view in, say, an OpenGL window with a name
"viewer-0", then
/vis/open DAWNFILE
then to get the same view
/vis/viewer/copyView viewer-0
or to get the same view *plus* scene-modifications
/vis/viewer/set/all viewer-0
then to see the result
/vis/viewer/flush
The DAWNFILE, HepRepFile drivers are always available
(since they require no external libraries), but the OGL driver requires
that the Geant4 libraries have been built with the OpenGL option.
From Release 9.6 the vis.mac macro in example B1 has additional commands
that demonstrate additional functionality of the vis system, such as
displaying text, axes, scales, date, logo and shows how to change
viewpoint and style. Consider copying these to other examples or
your application. To see even more commands use help or
ls or browse the available UI commands in the Application
Developers Guide, Section 7.1.
For more information on visualization, including information on how to
install and run DAWN, OpenGL and HepRApp, see the visualization tutorials,
for example,
http://geant4.slac.stanford.edu/Presentations/vis/G4[VIS]Tutorial/G4[VIS]Tutorial.html
(where [VIS] can be replaced by DAWN, OpenGL and HepRApp)
The tracks are automatically drawn at the end of each event, accumulated
for all events and erased at the beginning of the next run.
B- USER INTERFACES
The user command interface is set via the G4UIExecutive class
in the main() function in exampleB1.cc
The selection of the user command interface is then done automatically
according to the Geant4 configuration or it can be done explicitly via
the third argument of the G4UIExecutive constructor (see exampleB4a.cc).
C- HOW TO RUN
- Execute exampleB1 in the 'interactive mode' with visualization:
% ./exampleB1
and type in the commands from run1.mac line by line:
Idle> /control/verbose 2
Idle> /tracking/verbose 1
Idle> /run/beamOn 10
Idle> ...
Idle> exit
or
Idle> /control/execute run1.mac
....
Idle> exit
- Execute exampleB1 in the 'batch' mode from macro files
(without visualization)
% ./exampleB1 run2.mac
% ./exampleB1 exampleB1.in > exampleB1.out
+22
View File
@@ -0,0 +1,22 @@
Geant4 extended examples - analysis
-----------------------------------
Examples in this directory demonstrate how to make histograms and ntuples
AnaEx01
--------
Simple example showing use of g4tools.
AnaEx02
--------
As AnaEx01, but direct interface to ROOT.
B1Con
------
B1Con shows how to use the statistical tool G4ConvergenceTester.
It does not make histograms.
It has the same geometry as B1.
+129
View File
@@ -0,0 +1,129 @@
///\file "biasing/.README.txt"
///\brief Examples biasing README page
/*! \page Examples_biasing Category "biasing"
\section biasing_s1 B01, B02 and B03
B01, B02 and B03 applications demonstrate the usage of different variance
reduction techniques supported in Geant4, or possible from the user
applications.
\subsection biasing_sub_11 General remark to variance reduction
The tools provided for importance sampling (or geometrical splitting and
Russian roulette) and for the weight window technique require the user to
have a good understanding of the physics in the problem. This is because
the user has to decide which particle types have to be biased, define the
cells (physical volumes, replicas) and assign importances or weight
windows to that cells. If this is not done properly it can not be
expected that the results describe a real experiment. The examples given
here only demonstrate how to use the tools technically. They don't intend
to produce physical correct results.
\subsection biasing_sub_12 General remark to scoring
Scoring is carried out using the built-in Multifunctional detectors. For
parallel geometries this requires a special scoring physics process.
See examples/extended/runAndEvent (especailly RE05) for clarification.
\subsection biasing_sub_13 Known problems - should not happen
In the following scenario it can happen that a particle is not
biased and it's weight is therefore not changed even if it crosses
a boundary where biasing should happen.
Importance and weight window sampling create particles on boundaries
between volumes. If the GPIL method of a physical process returns
0 as step length for a particle on a boundary and if the PostStepDoIt of
that process changes the direction of the particle to go back in the
former volume the biasing won't be invoked.
This will produce particles with weights that do not correspondent to the
importance of the current volumes.
\subsection biasing_sub_14 Further information:
Short description of importance sampling and scoring:
http://cern.ch/geant4/working_groups/geometry/biasing/Sampling.html
\subsection biasing_sub_15 Example B01
The example uses importance sampling or the weight window technique
according to an input parameter. It uses scoring in both cases.
Importance values or weight windows are defined according to the mass
geometry. In this example the weight window technique is configured such
that it behaves equivalent to importance sampling: The window is actually
not a window but simply the inverse of the importance value and only
one energy region is used that covers all energies in the problem.
The user may change the weight window configuration by changing the
initialization of the weight window algorithm in example,cc.
Different energy bounds for the weight window technique may be specified
in B01DetectorConstruction.
The executable takes one optional argument: 0 or 1. Without argument or
with argument: 0, the importance sampling is applied with argument: 1,
the weight window technique is applied.
\subsection biasing_sub_16 Example B02
This example uses a parallel geometry to define G4GeometryCell objects
for scoring and importance sampling. The output should be equivalent to B01.
A modular approach is applied to the physicslist and the extension for biasing.
The parallel geometry is included in this extension.
\subsection biasing_sub_17 Example B03
This example uses a parallel geometry to define G4GeometryCell objects
for scoring and importance sampling. The output should be statistically
equivalent to B02 (and B01).
This demonstrates a customised "flat" physics implementation with the addition
of biasing. Complementary approach to the modular physics lists of B01 and B02
\section biasing_s2 Generic biasing examples GB01 - GB06
These examples illustrate the usage of a biasing scheme implemented since
version Geant4 10.0.
The scheme is meant to be extensible, not limited to these six examples.
\link ExampleGB01 Example GB01 \endlink
This example illustrates how to bias process cross-sections in this scheme.
\link ExampleGB02 Example GB02 \endlink
Illustrates a force collision scheme similar to the MCNP one.
\link ExampleGB03 Example GB03 \endlink
Illustrates geometry based biasing.
\link ExampleGB04 Example GB04 \endlink
Illustrates a bremsstrahlung splitting.
\link ExampleGB05 Example GB05 \endlink
Illustrates a "splitting by cross-section" technique: a splitting-based
technique using absorption cross-section to control the neutron population.
\link ExampleGB06 Example GB06 \endlink
Illustrates the usage of parallel geometries with generic biasing.
\link ExampleGB07 Example GB07 \endlink
Illustrates the usage of leading particle biasing with generic biasing.
\section biasing_s3 Reverse MonteCarlo Technique example
\link ExampleReverseMC01 Example ReverseMC01 \endlink
Example illustrating the use of the Reverse Monte Carlo (RMC) mode in a Geant4
application. See details in \link ExampleReverseMC01 Example README page
\endlink.
*/
@@ -0,0 +1,49 @@
///\file "biasing/GB01/.README.txt"
///\brief Example GB01 README page
/*! \page ExampleGB01 Example GB01
\section ExampleGB01_s1 Cross-section biasing
This example illustrates how to bias process cross-sections.
Generally speaking, the scheme consists of a G4VBiasingOperator that takes
decisions on what sort of biasing is to be applied. The operator makes these
decision on requests of the G4BiasingProcessInterface process. This process
wraps an actual physics process and asks to the operator about what sort of
biasing it should apply. This operator selects G4VBiasingOperation objects that
implement the actual biasing content.
In the present case, the G4VBiasingOperation objects are
- G4BOptnChangeCrossSection
instances. This class is defined in processes/biasing/generic.
A first operator is defined to handle the case of one particle:
- GB01BOptrChangeCrossSection .
The change of cross-section is generally speaking a change of process occurence.
G4BOptnChangeCrossSection objets are then selected in the method:
- G4VBiasingOperation* GB01BOptrChangeCrossSection::ProposeOccurenceBiasingOperation(...)
To allow this same cross-section change to be applied to several particle
types, an other operator is defined
- GB01BOptrMultiParticleChangeCrossSection
which holds one GB01BOptrChangeCrossSection per particle type, and which
delegates then everything to it.
The geometry is simple : a single volume to which an instance of
GB01BOptrMultiParticleChangeCrossSection is attached to.
The wrapping of physics processes by G4BiasingProcessInterface processes
is simply handled by the G4GenericBiasingPhysics physics constructor, as shown
in the main program (see exampleGB01.cc).
Then, at whatever level (stepping action, or sensitive detector) the
statistical weight of the track can be obtained as:
\verbatim
w = track->GetWeight() ;
\endverbatim
*/
+50
View File
@@ -0,0 +1,50 @@
Example GB01 : cross-section biasing
------------------------------------
This example illustrates how to bias process cross-sections.
Generally speaking, the scheme consists of a G4VBiasingOperator that takes
decisions on what sort of biasing is to be applied. The operator makes these
decision on requests of the G4BiasingProcessInterface process. This process
wraps an actual physics process and asks to the operator about what sort of
biasing it should apply. This operator selects G4VBiasingOperation objects that
implement the actual biasing content.
In the present case, the G4VBiasingOperation objects are
G4BOptnChangeCrossSection
instances. This class is defined in processes/biasing/generic.
A first operator is defined to handle the case of one particle:
GB01BOptrChangeCrossSection .
The change of cross-section is generally speaking a change of process occurence.
G4BOptnChangeCrossSection objets are then selected in the method:
G4VBiasingOperation* ProposeOccurenceBiasingOperation(...)
of the GB01BOptrChangeCrossSection operator.
To allow this same cross-section change to be applied to several particle
types, an other operator is defined
GB01BOptrMultiParticleChangeCrossSection
which holds one GB01BOptrChangeCrossSection per particle type, and which
delegates then everything to it.
The geometry is simple : a single volume to which an instance of
GB01BOptrMultiParticleChangeCrossSection is attached to.
The wrapping of physics processes by G4BiasingProcessInterface processes
is simply handled by the G4GenericBiasingPhysics physics constructor, as shown
in the main program.
Then, at whatever level (stepping action, or sensitive detector) the
statistical weight of the track can be obtained as:
w = track->GetWeight() ;
@@ -0,0 +1,52 @@
///\file "biasing/GB02/.README.txt"
///\brief Example GB02 README page
/*! \page ExampleGB02 Example GB02
\section ExampleGB02_s1 Force collision biasing
This example illustrates how to make a force collision biasing in a way
that is essentially the same than the MCNP one.
Generally speaking, the scheme consists of a G4VBiasingOperator that takes
decisions on what sort of biasing is to be applied. The operator makes these
decision on requests of the G4BiasingProcessInterface process. This process
wraps an actual physics process and asks to the operator about what sort of
biasing it should apply. This operator selects G4VBiasingOperation objects that
implement the actual biasing content.
In the present case, we make use of the biasing operator
- G4BOptrForceCollision
that implements an "a la MCNP" force collision scheme for one particle type.
This operator is defined in processes/biasing/generic. It is a non-trivial
operator.
It starts by "splitting" the track at the volume entrance. Then this
track is forced to fly through the volume with no interaction. The
G4OptnForceFreeFlight biasing operation is used for that.
The second copy is then forced to interact within the volume, which is
handled by the G4BOptnForceCommonTruncatedExp operation : it is common as it
takes care of several processes by itself, and it applies a truncated
exponential law : ie and exponential law limited to the [0,L] range, L being
the volume width along the track flight.
To allow several particle types to undergo this force interaction scheme,
an other operator is defined
- GB02BOptrMultiParticleForceCollision
which holds one G4BOptrForceCollision per particle type, and which
delegates then everything to it.
The geometry is simple : a single volume to which an instance of
GB02BOptrMultiParticleForceCollision is attached to.
The wrapping of physics processes by G4BiasingProcessInterface processes
is simply handled by the G4GenericBiasingPhysics physics constructor, as shown
in the main program.
Then, at whatever level (stepping action, or sensitive detector) the
statistical weight of the track can be obtained as:
\verbatim
w = track->GetWeight() ;
\endverbatim
*/
+49
View File
@@ -0,0 +1,49 @@
Example GB02 : force collision biasing
--------------------------------------
This example illustrates how to make a force collision biasing in a way
that is essentially the same than the MCNP one.
Generally speaking, the scheme consists of a G4VBiasingOperator that takes
decisions on what sort of biasing is to be applied. The operator makes these
decision on requests of the G4BiasingProcessInterface process. This process
wraps an actual physics process and asks to the operator about what sort of
biasing it should apply. This operator selects G4VBiasingOperation objects that
implement the actual biasing content.
In the present case, we make use of the biasing operator
G4BOptrForceCollision
that implements an "a la MCNP" force collision scheme for one particle type.
This operator is defined in processes/biasing/generic. It is a non-trivial
operator.
It starts by "splitting" the track at the volume entrance. Then this
track is forced to fly through the volume with no interaction. The
G4OptnForceFreeFlight biasing operation is used for that.
The second copy is then forced to interact within the volume, which is
handled by the G4BOptnForceCommonTruncatedExp operation : it is common as it
takes care of several processes by itself, and it applies a truncated
exponential law : ie and exponential law limited to the [0,L] range, L being
the volume width along the track flight.
To allow several particle types to undergo this force interaction scheme,
an other operator is defined
GB02BOptrMultiParticleForceCollision
which holds one G4BOptrForceCollision per particle type, and which
delegates then everything to it.
The geometry is simple : a single volume to which an instance of
GB02BOptrMultiParticleForceCollision is attached to.
The wrapping of physics processes by G4BiasingProcessInterface processes
is simply handled by the G4GenericBiasingPhysics physics constructor, as shown
in the main program.
Then, at whatever level (stepping action, or sensitive detector) the
statistical weight of the track can be obtained as:
w = track->GetWeight() ;
@@ -0,0 +1,54 @@
///\file "biasing/GB03/.README.txt"
///\brief Example GB03 README page
/*! \page ExampleGB03 Example GB03
\section ExampleGB03_s1 Geometry based biasing
This example illustrates a use of generic biasing classes to implement a
technique near to "geometry importance biasing".
The geometry is the same than in EM tests, with the sampling calorimeter
made of a series of layers of absorber and gap.
The biasing applies to neutrons only.
Instead of explicitely assigning "importance" values to the layers, we
split neutrons moving forward and kill the ones moving backward, when they
reach the exit of an absorber volume.
The splitting factor can be controlled by command line, eg:
\verbatim
/GB03/biasing/setSplittingFactor 2
\endverbatim
which also determines the killing probability : 1/(splitting factor).
It can be seen than when defining 10 layers (see exampleGB03.in), a
splitting factor 2 works fine : we don't suffer from under- or over-splitting.
If going to 20 layers, then a splitting with a factor 2 is too large,
and the biasing suffers from over-splitting. (And we can not go lower than
"2", which would mean "1" and hence, no biasing...)
To alleviate the over-splitting, we introduce a probability to apply the
splitting (and killing) (this is one solution, others can be considered), that
can be changed as:
\verbatim
/GB03/biasing/setApplyProbability 0.5
\endverbatim
With above value, we can see that we recover a satisfactory biasing scheme,
with neutrons penetrating the entire setup, without over-splitting.
The classes involved are:
- GB03BOptnSplitOrKillOnBoundary : which is the biasing operation making
the splitting and killing;
- GB03BOptrGeometryBasedBiasing : which is the biasing operator, making
decision to use above operation, and configuring it, passing it the
splitting factor and probability to apply the biasing.
*/
+45
View File
@@ -0,0 +1,45 @@
Example GB03 : geometry based biasing
-------------------------------------
This example illustrates a use of generic biasing classes to implement a
technique near to "geometry importance biasing".
The geometry is the same than in EM tests, with the sampling calorimeter
made of a series of layers of absorber and gap.
The biasing applies to neutrons only.
Instead of explicitely assigning "importance" values to the layers, we
split neutrons moving forward and kill the ones moving backward, when they
reach the exit of an absorber volume.
The splitting factor can be controlled by command line, eg:
/GB03/biasing/setSplittingFactor 2
which also determines the killing probability : 1/(splitting factor).
It can be seen than when defining 10 layers (see exampleGB03.in), a
splitting factor 2 works fine : we don't suffer from under- or over-splitting.
If going to 20 layers, then a splitting with a factor 2 is too large,
and the biasing suffers from over-splitting. (And we can not go lower than
"2", which would mean "1" and hence, no biasing...)
To alleviate the over-splitting, we introduce a probability to apply the
splitting (and killing) (this is one solution, others can be considered), that
can be changed as:
/GB03/biasing/setApplyProbability 0.5
With above value, we can see that we recover a satisfactory biasing scheme,
with neutrons penetrating the entire setup, without over-splitting.
The classes involved are:
- GB03BOptnSplitOrKillOnBoundary : which is the biasing operation making
the splitting and killing;
- GB03BOptrGeometryBasedBiasing : which is the biasing operator, making
decision to use above operation, and configuring it, passing it the
splitting factor and probability to apply the biasing.
@@ -0,0 +1,41 @@
///\file "biasing/GB04/.README.txt"
///\brief Example GB04 README page
/*! \page ExampleGB04 Example GB04
\section ExampleGB04_s1 bremsstrahlung splitting
This example illustrates the use of the generic biasing classes to create
a bremsstrahlung splitting technique.
Note that the EM package also offers a bremsstrahlung splitting, that is
built-in to the package.
- GB04BOptnBremSplitting
The bremsstrahlung splitting is implemented in the GB04BOptnBremSplitting
class (BOptn = Biasing Operation), which acts on the final state creation
of the bremsstrahlung process.
- GB04BOptrBremSplitting
Decisions when to apply the GB04BOptnBremSplitting biasing operation are
taken by the GB04BOptrBremSplitting (BOptr = Biasing Operator) operator. This
one also configures the biasing operation, setting it the splitting factor
and its behavior regarding electrons to be biased : only the primary one, or
all, and only the first bremsstrahlung operation, or all. These are
controled by this specific example commands:
\verbatim
/GB04/biasing/setSplittingFactor [N splitting]
/GB04/biasing/biasPrimaryOnly [true/false]
/GB04/biasing/biasOnlyOnce [true/false]
\endverbatim
The geometry is minimal : a single volume to which an instance of
GB04BOptrBremSplitting is attached to.
The wrapping of physics processes by G4BiasingProcessInterface processes
is simply handled by the G4GenericBiasingPhysics physics constructor, as shown
in the main program.
*/
+36
View File
@@ -0,0 +1,36 @@
Example GB04 : bremsstrahlung splitting
---------------------------------------
This example illustrates the use of the generic biasing classes to create
a bremsstrahlung splitting technique.
Note that the EM package also offers a bremsstrahlung splitting, that is
built-in to the package.
GB04BOptnBremSplitting
The bremsstrahlung splitting is implemented in the GB04BOptnBremSplitting
class (BOptn = Biasing Operation), which acts on the final state creation
of the bremsstrahlung process.
GB04BOptrBremSplitting
Decisions when to apply the GB04BOptnBremSplitting biasing operation are
taken by the GB04BOptrBremSplitting (BOptr = Biasing Operator) operator. This
one also configures the biasing operation, setting it the splitting factor
and its behavior regarding electrons to be biased : only the primary one, or
all, and only the first bremsstrahlung operation, or all. These are
controled by this specific example commands:
/GB04/biasing/setSplittingFactor [N splitting]
/GB04/biasing/biasPrimaryOnly [true/false]
/GB04/biasing/biasOnlyOnce [true/false]
The geometry is minimal : a single volume to which an instance of
GB04BOptrBremSplitting is attached to.
The wrapping of physics processes by G4BiasingProcessInterface processes
is simply handled by the G4GenericBiasingPhysics physics constructor, as shown
in the main program.
@@ -0,0 +1,53 @@
///\file "biasing/GB05/.README.txt"
///\brief Example GB05 README page
/*! \page ExampleGB05 Example GB05
\section ExampleGB05_s1 Splitting by cross-section
This example illustrates a technique that uses physics cross-sections to
determine the splitting [killing] rate in a shielding problem. This technique
is supposed to be an invention, and this example here is not optimized. The
technique is applied here to neutrons.
In the classical treatment of the shielding problem, the shield is divided
in slices at the boundaries of which particles are splitted[killed] if moving
forward[backward]. In the present technique, we collect the cross-section of
"absorbing/destroying" processes : decay, capture, inelastic. We then use the
generic biasing facilities to create an equivalent of a spitting process, that
has a "cross-section" which is the sum of the previous ones. This process is
competing with other processes, as a regular one. The occurence of this process
is hence the same than the "absorbing/destroying" processes together. When this
process wins the competition, it splits the track, with a splitting factor 2 (ie
the original track is kept and a copy of it is created). This splitting is hence
occuring at the same rate than the absorption, resulting in an expected
maintained (unweighted) flux.
The geometry is made of a single block of concrete it. Behind it (in the +z
direction) a thin empty volume is placed to print out the particles which are
exiting the shield.
As in any generic biasing use, a biasing operator (taking decisions on what
biasing to apply) and a biasing operation (applying these decisions) are defined.
These are:
GB05BOptrSplitAndKillByCrossSection for the operator,
GB05BOptnSplitAndKillByCrossSection for the operation.
The operator is created in the detector construction, and receives here the
names of the absorbing/destroying processes to counterbalance for.
At tracking time, it collects the up to date cross-section of these processes
in the ProposeNonPhysicsBiasingOperation(...) method, and passes the sum to the
GB05BOptnSplitAndKillByCrossSection operation.
The operation uses the cross-section (interaction length) to sample the
distance to "interaction" with a classical exponential. If it wins the race
(ie it proposes the smallest of the interaction distances among all processes)
its GenerateBiasingFinalState(...) method is called, and it applies splitting
or killing (Russian roulette) if the track moves forward or backward.
*/
+47
View File
@@ -0,0 +1,47 @@
Example GB05: splitting by cross-section
----------------------------------------
This example illustrates a technique that uses physics cross-sections to
determine the splitting [killing] rate in a shielding problem. This technique
is supposed to be an invention, and this example here is not optimized. The
technique is applied here to neutrons.
In the classical treatment of the shielding problem, the shield is divided
in slices at the boundaries of which particles are splitted[killed] if moving
forward[backward]. In the present technique, we collect the cross-section of
"absorbing/destroying" processes : decay, capture, inelastic. We then use the
generic biasing facilities to create an equivalent of a spitting process, that
has a "cross-section" which is the sum of the previous ones. This process is
competing with other processes, as a regular one. The occurence of this process
is hence the same than the "absorbing/destroying" processes together. When this
process wins the competition, it splits the track, with a splitting factor 2 (ie
the original track is kept and a copy of it is created). This splitting is hence
occuring at the same rate than the absorption, resulting in an expected
maintained (unweighted) flux.
The geometry is made of a single block of concrete it. Behind it (in the +z
direction) a thin empty volume is placed to print out the particles which are
exiting the shield.
As in any generic biasing use, a biasing operator (taking decisions on what
biasing to apply) and a biasing operation (applying these decisions) are defined.
These are:
GB05BOptrSplitAndKillByCrossSection for the operator,
GB05BOptnSplitAndKillByCrossSection for the operation.
The operator is created in the detector construction, and receives here the
names of the absorbing/destroying processes to counterbalance for.
At tracking time, it collects the up to date cross-section of these processes
in the ProposeNonPhysicsBiasingOperation(...) method, and passes the sum to the
GB05BOptnSplitAndKillByCrossSection operation.
The operation uses the cross-section (interaction length) to sample the
distance to "interaction" with a classical exponential. If it wins the race
(ie it proposes the smallest of the interaction distances among all processes)
its GenerateBiasingFinalState(...) method is called, and it applies splitting
or killing (Russian roulette) if the track moves forward or backward.
+108
View File
@@ -0,0 +1,108 @@
///\file "biasing/GB06/.README.txt"
///\brief Example GB06 README page
/*! \page ExampleGB06 Example GB06
\section ExampleGB06_s1 Parallel geometries with generic biasing
This example demonstrates the use of parallel geometries in generic biasing,
on a classical shield problem, using geometry-based importance biasing.
\subsection ExampleGB06_sub_s1 Geometry and activation of navigation in parallel world:
The geometry is made of two parts:
- the mass (standard) geometry, which is made of a single block of
concrete ; this is implemented in GB06DetectorConstuction ;
- a parallel geometry, in which a series of slices is defined, these
slices being created using a replica volume ; this is implemeted in
GB06ParallelGeometryForSlices, which derives from the base class
G4VUserParallelWorld .
The navigation in the parallel geometry is activated for neutrons. This is
done in the main program exampleGB06.cc. The activation is made using the
facilities of the G4GenericBiasingPhysics class, as:
\verbatim
biasingPhysics->AddParallelGeometry("neutron",
"parallelWorldForSlices");
\endverbatim
where the first name is for the particle type to be aware of the parallel word,
the second argument is the name of the parallel world.
When checking the process list of neutrons (/particle/select neutron and
then /particle/process dump ) a new process, `biasingLimiter', is visible. This
process handles the step limitation in the parallel geometry. This process can
handle several parallel geometries, these being passed to the process as
biasingPhysics->AddParallelGeometry("neutron", "parallelWorld1") ,
biasingPhysics->AddParallelGeometry("neutron", "parallelWorld2") , etc.
The geometry-based importance technique utilizes only splitting and killing,
hence techniques which are "non-physics biasing" techniques, in the sense they
don't modify the behavior of physics processes. For this reason, only a process
making the interface between the tracking and the biaising is inserted in the
physics list, the physics processes themselves being untouched, this is made as:
\verbatim
biasingPhysics->NonPhysicsBias("neutron");
\endverbatim
Finally, the volume (ie the slice) importances are defined in a simple
"importance map" that is created in the GB06ParallelGeometryForSlices class, this
map associating a replica number to a volume importance. The map is hold by the
biasing operator.
\subsection ExampleGB06_sub_s2 Biasing classes:
As usual, with the generic biasing scheme, a biasing operator and a biasing
operation are defined, these are, respectively the
- GB06BOptrSplitAndKillByImportance and
- GB06BOptnSplitAndKillByImportance
classes. The operator here only handles one particle type. In the StartRun()
method, it configures the biasing operation GB06BOptnSplitAndKillByImportance
passing it the information related to the parallel geometry, and passing it the
importance map.
The biasing operation GB06BOptnSplitAndKillByImportance applies a classical
importance-based geometry technique, with spliting / killing at the slice
bondaries. Splitting is made if the track goes from a smaller importance to a
volume of larger importance, and killing (Russian roulette) is applied in the
other case.
The particularity of this biasing operation is its handling of the parallel
geometry information. It has to get by itself geometry information that, in the
case of information of the mass geometry, are provided in the G4StepPoint objects
(pre step point, post step point) of the G4Step. Here, in the
DistanceToApplyOperation(...), which is called at the beginning of the step, it
gets a "snapshot" of the geometry state keeping a G4TouchableHistoryHandle. Then
in the GenerateBiasingFinalState, which is called at the end of the step, it gets
the new geometry state, with an other G4TouchableHistoryHandle. For a step that
ends on the boundary, this last touchable history will logically point to the
next volume. In this case, the biasing is applied, and the importances are
obtained from the replica numbers taken from the two touchable histories, and
then from the importance map.
\subsection ExampleGB06_sub_s3 Output
A simple sensitive detector is defined (GB06SD) and is attached to a thin
volume ("meas.logical") placed after the concrete shield. This sensitive
detector simply prints the information (particle type, kinetic energy, etc,
and weight) of particles leaving the shield.
\subsection ExampleGB06_sub_s4 Known problems
In exampleGB06.in the neutron killer process, nKiller, is de-activated
(process that kills neutrons after some time), for two reasons. First, killing
neutrons in a shield problem is not desirable because neutrons may fly for long
time before leaving the shield, and hence must be accounted for. Second, if
nKiller is left active, an exception message about a spurious displacement by
1e-7mm will appear sometimes : this happens when a neutron is killed on a volume
boundary, and the navigation "sees" a (tiny) displacement, that should not exist.
*/
+100
View File
@@ -0,0 +1,100 @@
Example GB06: parallel geometries with generic biasing
------------------------------------------------------
This example demonstrates the use of parallel geometries in generic biasing,
on a classical shield problem, using geometry-based importance biasing.
1) Geometry and activation of navigation in parallel world:
--------------------------------------------------------
The geometry is made of two parts:
- the mass (standard) geometry, which is made of a single block of
concrete ; this is implemented in GB06DetectorConstuction ;
- a parallel geometry, in which a series of slices is defined, these
slices being created using a replica volume ; this is implemeted in
GB06ParallelGeometryForSlices, which derives from the base class
G4VUserParallelWorld .
The navigation in the parallel geometry is activated for neutrons. This is
done in the main program exampleGB06.cc. The activation is made using the
facilities of the G4GenericBiasingPhysics class, as:
biasingPhysics->AddParallelGeometry("neutron",
"parallelWorldForSlices");
where the first name is for the particle type to be aware of the parallel word,
the second argument is the name of the parallel world.
When checking the process list of neutrons (/particle/select neutron and
then /particle/process dump ) a new process, `biasingLimiter', is visible. This
process handles the step limitation in the parallel geometry. This process can
handle several parallel geometries, these being passed to the process as
biasingPhysics->AddParallelGeometry("neutron", "parallelWorld1") ,
biasingPhysics->AddParallelGeometry("neutron", "parallelWorld2") , etc.
The geometry-based importance technique utilizes only splitting and killing,
hence techniques which are "non-physics biasing" techniques, in the sense they
don't modify the behavior of physics processes. For this reason, only a process
making the interface between the tracking and the biaising is inserted in the
physics list, the physics processes themselves being untouched, this is made as:
biasingPhysics->NonPhysicsBias("neutron");
Finally, the volume (ie the slice) importances are defined in a simple
"importance map" that is created in the GB06ParallelGeometryForSlices class, this
map associating a replica number to a volume importance. The map is hold by the
biasing operator.
2) Biasing classes:
----------------
As usual, with the generic biasing scheme, a biasing operator and a biasing
operation are defined, these are, respectively the
GB06BOptrSplitAndKillByImportance and
GB06BOptnSplitAndKillByImportance
classes. The operator here only handles one particle type. In the StartRun()
method, it configures the biasing operation GB06BOptnSplitAndKillByImportance
passing it the information related to the parallel geometry, and passing it the
importance map.
The biasing operation GB06BOptnSplitAndKillByImportance applies a classical
importance-based geometry technique, with spliting / killing at the slice
bondaries. Splitting is made if the track goes from a smaller importance to a
volume of larger importance, and killing (Russian roulette) is applied in the
other case.
The particularity of this biasing operation is its handling of the parallel
geometry information. It has to get by itself geometry information that, in the
case of information of the mass geometry, are provided in the G4StepPoint objects
(pre step point, post step point) of the G4Step. Here, in the
DistanceToApplyOperation(...), which is called at the beginning of the step, it
gets a "snapshot" of the geometry state keeping a G4TouchableHistoryHandle. Then
in the GenerateBiasingFinalState, which is called at the end of the step, it gets
the new geometry state, with an other G4TouchableHistoryHandle. For a step that
ends on the boundary, this last touchable history will logically point to the
next volume. In this case, the biasing is applied, and the importances are
obtained from the replica numbers taken from the two touchable histories, and
then from the importance map.
3) Output:
-------
A simple sensitive detector is defined (GB06SD) and is attached to a thin
volume ("meas.logical") placed after the concrete shield. This sensitive
detector simply prints the information (particle type, kinetic energy, etc,
and weight) leaving the shield.
4) Known problems:
---------------
In exampleGB06.in the neutron killer process, nKiller, is de-activated
(process that kills neutrons after some time), for two reasons. First, killing
neutrons in a shield problem is not desirable because neutrons may fly for some
time before leaving the shield, and hence must be accounted for. Second, if
nKiller is left active, an exception message about a spurious displacement by
1e-7mm will appear sometimes : this happens when a neutron is killed on a volume
boundary, and the navigation "sees" a (tiny) displacement, that should not exist.
@@ -0,0 +1,88 @@
///\file "biasing/GB07/.README.txt"
///\brief Example GB07 README page
/*! \page ExampleGB07 Example GB07
\section ExampleGB07_s1 Leading particle biasing
This example illustrates how to use the leading particle biasing option.
It uses the G4BOptnLeadingParticle biasing operation located in:
source/processes/biasing/generic ,
and defines the following biasing operation to handle it:
GB07OptrLeadingParticle.
As a reminder, the generic biasing scheme consists of a G4VBiasingOperator
that takes decisions on what sort of biasing technique to be applied. The
techniques are called biasing operations, represented by the G4VBiasingOperation
class. The operator is attached to a logical volume in which the biasing must
happen. Decisions are made on requests of the G4BiasingProcessInterface process
that messages the operator when the track is travelling in the volume. To equip
the phyics list with this process, the G4GenericBiasingPhysics physics
constructor is used. In this example, several processes -to which the technique
is applied- are wrapped by this process to control their final state production
for applying the biasing technique.
\section ExampleGB07_s2 Geometry
The geometry is simply :
- a volume in which the biasing occurs and to which an instance of
GB07OptrLeadingParticle is attached,
- a thin volume placed after the above volume, that is used to tally the
particles exiting biasing volume.
- a sensitive detector is attached to the thin volume to simply print the
particles entering here. In particular the statistical weight is printed,
this one is obtained by:
\verbatim
w = track->GetWeight() ;
\endverbatim
\section ExampleGB07_s3 Biasing configuration
The particle types and processes under the leading particle biasing are
visible in the main program exampleGB07.cc, these are:
pi+ and pi-, inelastic process,
proton and anti-proton, inelastic process,
neutron, inelastic and capture processes,
anti-neutron, inelastic process,
gamma, conversion and photonNuclear processes,
electron, electronNuclear process,
positron, annihilation and positronNuceal processes,
pi0, decay process.
For the inelastic and lepto/gamma-nuclear processes, leading particle is applied in a rather
classical way:
- keep the leading particle,
- keep one particle of each species (particles and anti-particles are considered a one
species, and all hadrons with Z>=2 are counted as one species too).
For e+, e-, gamma and pi0 processes (which means in practice main conversion, annihililation
and pi0 decay processes), the leading particle is kept, and the companion track(s) is(are) randomly
kept/killed under a Russian roulette, with a 2/3 killing probabilty. See
GB07BOptrLeadingParticle::StartTracking( ... ) for this killing probability setting.
\section ExampleGB07_s4 Running the program:
The program can be run in batch or interactive mode and has the following options:
- batch mode:
\verbatim
./exampleGB07 [-m macro ] [-b biasing {'on' = default,'off'}]
\endverbatim
or
\verbatim
./exampleGB07 [macro.mac]
\endverbatim
- interactive mode:
\verbatim
./exampleGB07 [-b biasing {'on' = default,'off'}]
\endverbatim
*/
+84
View File
@@ -0,0 +1,84 @@
Example GB07 : leading particle biasing
----------------------------------------
This example illustrates how to use the leading particle biasing option.
It uses the G4BOptnLeadingParticle biasing operation located in:
source/processes/biasing/generic ,
and defines the following biasing operation to handle it:
GB07OptrLeadingParticle.
As a reminder, the generic biasing scheme consists of a G4VBiasingOperator
that takes decisions on what sort of biasing technique to be applied. The
techniques are called biasing operations, represented by the G4VBiasingOperation
class. The operator is attached to a logical volume in which the biasing must
happen. Decisions are made on requests of the G4BiasingProcessInterface process
that messages the operator when the track is travelling in the volume. To equip
the phyics list with this process, the G4GenericBiasingPhysics physics
constructor is used. In this example, several processes -to which the technique
is applied- are wrapped by this process to control their final state production
for applying the biasing technique.
Geometry:
---------
The geometry is simply :
- a volume in which the biasing occurs and to which an instance of
GB07OptrLeadingParticle is attached,
- a thin volume placed after the above volume, that is used to tally the
particles exiting biasing volume.
- a sensitive detector is attached to the thin volume to simply print the
particles entering here. In particular the statistical weight is printed,
this one is obtained by:
w = track->GetWeight() ;
Biasing configuration:
----------------------
The particle types and processes under the leading particle biasing are
visible in the main program exampleGB07.cc, these are:
pi+ and pi-, inelastic process,
proton and anti-proton, inelastic process,
neutron, inelastic and capture processes,
anti-neutron, inelastic process,
gamma, conversion and photonNuclear processes,
electron, electronNuclear process,
positron, annihilation and positronNuceal processes,
pi0, decay process.
For the inelastic and lepto/gamma-nuclear processes, leading particle is applied in a rather
classical way:
- keep the leading particle,
- keep one particle of each species (particles and anti-particles are considered a one
species, and all hadrons with Z>=2 are counted as one species too).
For e+, e-, gamma and pi0 processes (which means in practice main conversion, annihililation
and pi0 decay processes), the leading particle is kept, and the companion track(s) is(are) randomly
kept/killed under a Russian roulette, with a 2/3 killing probabilty. See
GB07BOptrLeadingParticle::StartTracking( ... ) for this killing probability setting.
Running the program:
--------------------
The program can be run in batch or interactive mode and has the following options:
in batch:
./exampleGB07 [-m macro ] [-b biasing {'on' = default,'off'}]
or
./exampleGB07 [macro.mac]
interactive:
./exampleGB07 [-b biasing {'on' = default,'off'}]
+149
View File
@@ -0,0 +1,149 @@
Examples for event biasing: B01, B02 and B03
--------------------------------------------
B01, B02 and B03 applications demonstrate the usage of different variance
reduction techniques supported in Geant4, or possible from the user
applications.
General remark to variance reduction
------------------------------------
The tools provided for importance sampling (or geometrical splitting and
Russian roulette) and for the weight window technique require the user to
have a good understanding of the physics in the problem. This is because
the user has to decide which particle types have to be biased, define the
cells (physical volumes, replicas) and assign importances or weight
windows to that cells. If this is not done properly it can not be
expected that the results describe a real experiment. The examples given
here only demonstrate how to use the tools technically. They don't intend
to produce physical correct results.
General remark to scoring
-------------------------
Scoring is carried out using the built-in Multifunctional detectors. For
parallel geometries this requires a special scoring physics process.
See examples/extended/runAndEvent (especailly RE05) for clarification.
Known problems - should not happen
----------------------------------
In the following scenario it can happen that a particle is not
biased and it's weight is therefore not changed even if it crosses
a boundary where biasing should happen.
Importance and weight window sampling create particles on boundaries
between volumes. If the GPIL method of a physical process returns
0 as step length for a particle on a boundary and if the PostStepDoIt of
that process changes the direction of the particle to go back in the
former volume the biasing won't be invoked.
This will produce particles with weights that do not correspondent to the
importance of the current volumes.
Further information:
--------------------
Short description of importance sampling and scoring:
http://cern.ch/geant4/working_groups/geometry/biasing/Sampling.html
Example B01
===========
The example uses importance sampling or the weight window technique
according to an input parameter. It uses scoring in both cases.
Importance values or weight windows are defined according to the mass
geometry. In this example the weight window technique is configured such
that it behaves equivalent to importance sampling: The window is actually
not a window but simply the inverse of the importance value and only
one energy region is used that covers all energies in the problem.
The user may change the weight window configuration by changing the
initialization of the weight window algorithm in example,cc.
Different energy bounds for the weight window technique may be specified
in B01DetectorConstruction.
The executable takes one optional argument: 0 or 1. Without argument or
with argument: 0, the importance sampling is applied with argument: 1,
the weight window technique is applied.
A modular approach is applied to the physicslist and the extension for biasing.
Example B02
===========
This example uses a parallel geometry to define G4GeometryCell objects
for scoring and importance sampling. The output should be equivalent to B01.
A modular approach is applied to the physicslist and the extension for biasing.
The parallel geometry is included in this extension.
Example B03
===========
This example uses a parallel geometry to define G4GeometryCell objects
for scoring and importance sampling. The output should be statistically
equivalent to B02 (and B01).
This demonstrates a customised "flat" physics implementation with the addition
of biasing. Complementary approach to the modular physics lists of B01 and B02
___________________________________________________________________________
Generic biasing examples GB01 - GB06
------------------------------------
These examples illustrate the usage of a biasing scheme implemented since
version Geant4 10.0.
The scheme is meant to be extensible, not limited to these six examples.
Example GB01:
=============
This example illustrates how to bias process cross-sections in this scheme.
Example GB02:
=============
Illustrates a force collision scheme similar to the MCNP one.
Example GB03:
=============
Illustrates geometry based biasing.
Example GB04:
=============
Illustrates a bremsstrahlung splitting.
Example GB05:
=============
Illustrates a "splitting by cross-section" technique: a splitting-based
technique using absorption cross-section to control the neutron population.
Example GB06:
=============
Illustrates the usage of parallel geometries with generic biasing.
Example GB07:
=============
Illustrates the usage of leading particle biasing with generic biasing.
___________________________________________________________________________
Reverse MonteCarlo Technique example: ReverseMC01
-------------------------------------------------
Example ReverseMC01
===================
Example illustrating the use of the Reverse Monte Carlo (RMC) mode in a Geant4
application. See details in ReverseMC01/README.
@@ -0,0 +1,487 @@
///\file "biasing/ReverseMC01/.README.txt"
///\brief Example ReverseMC01 README page
/*! \page ExampleReverseMC01 Example ReverseMC01
This example illustrates the use of Reverse Monte Carlo in Geant4.
\section ReverseMC01_author Author
This example code and the adjoint classes in the G4 toolkit have been developed by L.Desorgher (SpaceIT GmbH)
under the ESA contract 21435/08/NL/AT. For any (reasonable) question you may contact the author
at the following email address : desorgher@spaceit.ch
\section ReverseMC01_abstract Abstract
This is the README file for the first G4 example illustrating the use of the Reverse Monte Carlo (RMC) mode in a Geant4
application. The Reverse Monte Carlo method is also known as the Adjoint Monte Carlo (AMC) method and
in this document we will alternate both Reverse and Adjoint terms.
\section ReverseMC01_other_doc Other documentation
See also the section 3.7.3 Adjoint/Reverse Monte carlo in the
Geant4 User guide for application developers.
\section ReverseMC01_s1 Definition of Reverse/Adjoint Monte Carlo
When the sensitive part of a detector is small compared to its entire size and to the size of the
external extended primary particle source, a lot of computing time is spent during a normal Monte Carlo run
in the simulation of particle showers that are not contributing to the detector signal.
In such particular case the Reverse Monte Carlo (RMC) method, also known as the
Adjoint Monte Carlo method, can be used.
In this method particles are generated in or on the external surface of the sensitive volume
of the instrument and then are tracked backward in the geometry till they reach the source surface,
or exceed an energy threshold. During the reverse tracking reverse reactions are applied to the particles.
\section ReverseMC01_s2 The Reverse Monte Carlo mode in Geant4 (since G4.9.3 release)
(See also the section 3.7.3 Adjoint/Reverse Monte carlo in the
Geant4 User guide for application developers.)
Different G4Adjoint classes have been implemented into the Geant4
toolkit to run an adjoint/reverse simulation in a Geant4 application.
In this implementation an adjoint run is divided in a succession
of alternative adjoint and forward tracking of adjoint and normal particles.
One Geant4 event treats one of this tracking phase.
\subsection ReverseMC01_sub_s2_1 Reverse tracking phase
Adjoint particles (adjoint_e-, adjoint_gamma,...) are generated one by one on the so called
adjoint source with random position, energy (1/E distribution) and direction. The adjoint
source is the external surface of a user defined volume or of a user defined sphere. The
adjoint source should contain one or several sensitive volumes and should be small
compared to the entire geometry. The user can set the minimum and maximum energy of the
adjoint source. After its generation the adjoint primary particle is tracked backward in
the geometry till a user defined external surface (spherical or boundary of a volume)
or is killed before if it reaches a user defined upper energy limit that represents the
maximum energy of the external source. During the reverse tracking, reverse processes take
place where the adjoint particle being tracked can be either scattered or transformed in
another type of adjoint particle. During the reverse tracking the
G4AdjointSimulationManager replaces the user defined primary, run, stepping, ... actions,
by its own actions.
\subsection ReverseMC01_sub_s2_2 Forward tracking phase:
When an adjoint particle reaches the external surface its weight, type, position,
and direction are registered and a normal primary particle with a type equivalent
to the last generated adjoint primary is generated with the same energy,
position but opposite direction and is tracked in the forward direction
in the sensitive region as in a forward MC simulation.
During this forward tracking phase the event, stacking, stepping, tracking actions defined
by the user for its general forward application are used.
By this clear separation between adjoint and forward tracking phases, the code of the
user developed for a forward simulation should be only slightly
modified to adapt it for an adjoint simulation. Indeed the computation of the signal
is done by the same user actions or analysis classes that the one used in the forward
simulation mode. Before the G4.10.0 release the reverse and forward tracking mode
took place in separated events. Since the G4.10.0 release,
in order to preapre to the migration of the
ReverseMC to the G4 Multiple Threading mode, the reverse and forward tracking
phase of corresponding adjoint and forward primaries have been merged in the same
event.
\subsection ReverseMC01_sub_s2_3 Reverse Processes
During the reverse tracking phase reverse processes act on the adjoint particles.
The Reverse processes that are available at the moment in Geant4 are the:
- Reverse discrete Ionization for e-, proton and ions
- Continuous gain of energy by ionization and bremsstrahlung for e- and by ionization for protons and ions
- Reverse discrete e- bremsstrahlung
- Reverse photoelectric effect
- Reverse Compton scattering
- Approximated multiple scattering (MS) (see section 5.3)
It is important to note that the electromagnetic reverse processes are cut dependent
as their equivalent forward processes. The implementation of the reverse processes is
based on the forward processes
implemented in the G4 standard electromagnetic package.
\subsection ReverseMC01_sub_s2_4 Remark on Nb of adjoint particle types and Nb of G4 events considered in an adjoint simulation
The list of type of adjoint and forward particles that are generated on the adjoint source
and considered in the simulation is a function of the adjoint processes declared in the
physics list. For example if only the e- and gamma electromagnetic processes are considered
, only adjoint e- and adjoint gamma will be considered as primaries. In this case an
adjoint event will be divided in two G4 events. The first event will consist
into the coupled reverse and forward tracking of an adjoint e- and its equivalent
forward e-, while the second events will process the reverse and forward trackings
of corresponsing adjoint and forward primary gamms. In this case a
run of 100 adjoint events will consist into 200 Geant4 events. If the proton ionization is
also considered adjoint and forward protons are also generated as primaries
and 300 Geant4 events are processed for 100 adjoint events.
\subsection ReverseMC01_sub_s2_5 Modifications to bring in a existing G4 application to use the Reverse MC method
(for more details see also the section 3.7.3 Adjoint/Reverse Monte carlo in the
Geant4 User guide for application developers.)
Due the clear separation between the reverse and forward tracking phase only few modifications are needed
to an existing Geant4 application in order to adapt it for the use of the reverse simulation mode.
Except in the physics list where all the reverse processes and their forward equivalent
have to be declared, the principal code modifications are needed only in the analysis phase at the end
of the forward tracking where computed signals have to be multiplied by the weight
of the last reverse tracks and then normalized to different user defined spectra and angular distribution representing
the external source.
The weight of the adjoint tracks is computed by the G4Adjoint classes and the user needs
only to multiply them to the primary differential, directional spectrum of its choice.
The adjoint weight a the end of tracks can be also registered if needed in answer matrices.
More precisely, in order to be able to use the Reverse MC method in his simulation, the user should modify
its code as such:
- Adapt its physics list to use Reverse Processes for adjoint particles. An example of such physics list is provided in an extended
example.
- Create an instance of G4AdjointSimManager somewhere in the main () code.
- Modify the analysis part of the code to normalize the signal computed during the forward phase to the weight of the last adjoint particle
that reaches the external surface. This is done by using the following method of G4AdjointSimManager:
- G4int GetIDOfLastAdjParticleReachingExtSource()
- G4ThreeVector GetPositionAtEndOfLastAdjointTrack(){ return last_pos;}
- G4ThreeVector GetDirectionAtEndOfLastAdjointTrack(){ return last_direction;}
- G4double GetEkinAtEndOfLastAdjointTrack(){ return last_ekin;}
- G4double GetEkinNucAtEndOfLastAdjointTrack(){ return last_ekin_nuc;}
- G4double GetWeightAtEndOfLastAdjointTrack(){return last_weight;}
- G4double GetCosthAtEndOfLastAdjointTrack(){return last_cos_th;}
- G4String GetFwdParticleNameAtEndOfLastAdjointTrack(){return last_fwd_part_name;}
- G4int GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(){return last_fwd_part_PDGEncoding;}
- G4int GetFwdParticleIndexAtEndOfLastAdjointTrack().
In order to have a code working for both forward and adjoint simulation mode, the extra code needed in user actions for the adjoint
simulation mode can be separated to the code needed only for the normal forward simulation by using the following method:
- G4bool GetAdjointSimMode() that return true if an adjoint simulation is running and false if not!
\section ReverseMC01_s3 exampleRMC01
The example RMC01 illustrates how to modify a G4 application in order to use
both forward and reverse MC modes in the same code.
\subsection ReverseMC01_sub_s3_1 Geometry
The following simple geometry is considered:
- sensitive Silicon cylinder at the center of an Aluminum spherical shielding with 10 cm Radius.
- two 0.5mm thick Tantalum plates set horizontally above and below the Sensitive Cylinder
The free parameters of the geometry that can bes set by the user are:
- the thickness of the Aluminum shielding
- the height of the sensitive Si cylinder
- the radius of the sensitive Si cylinder
\subsection ReverseMC01_sub_s3_2 Physics
The physical processes considered are:
- Reverse and forward discrete Ionization for e- and proton
- Continuous gain and loss of energy by ionization and bremsstrahlung for e- and by ionization for protons
- Reverse and forward discrete e- bremsstrahlung
- Reverse and forward photoelectric effect
- Reverse and forward Compton scattering
- Reverse and forward Multiple scattering
These processes are implemented in the class G4AdjointPhysicsList distributed with the example. The G4AdjointPhysicsMessenger allows the user
to switch on/off some processes for testing purpose. By default all processes cited above are considered except the proton ionization that
has to be specifically switch on in the macro file by the user.
\subsection ReverseMC01_sub_s3_3 Analysis and output of the code
The example computes the energy deposited in the sensitive Si cylinder and the current of e-, protons, and gamma
entering this cylinder.
The Hits are registered in the sensitive detector class RMC01SD that is a typical G4 sensitive detector class
used in a forward simulation and is not modified at all
for the adjoint simulation mode.
The analysis of the registered hits during forward events is done by the RMCO1AnalysisManager.
That is the class that illustrates how to adapt an analysis code of a fwd simulation in order to use it also for
an adjoint simulation.
In this class during a forward simulation the method EndOfEventForForwardSimulation is used at the end of an event
while during an adjoint simulation at the end of fwd tracking event the method EndOfEventForAdjointSimulation is called.
By looking at the source of RMCO1AnalysisManager and more particularly to its method EndOfEventForAdjointSimulation the user will
learn how to adapt its G4 analysis code for an adjoint simulation.
The outputs of an adjoint simulation are:
- The total energy deposited and particle current entering the sensitive cylinder normalized
automatically to a user defined primary spectrum(exponential or power law) .These results are stored in the files:
- Adj_Edep_vs_EkinPrim.txt
- Adj_ElectronCurrent.txt
- Adj_GammaCurrent.txt
- Adj_ProtonCurrent.txt
- ConvergenceOfAdjointSimulationResults.txt:
The total normalized edep and its relative error registered every 5000 adjoint events
- The answer matrix of the energy deposited and particles current on the sensitive cylinder in function of primary energy of e-, gamma and
protons. These results are stored in the files Adj********_Answer.txt
The outputs of a forward simulation are:
- The mean energy deposited and particle current entering the sensitive cylinder per event.
These results are stored in the files:
- Fwd_Edep_vs_EkinPrim.txt
- Fwd_ElectronCurrent.txt
- Fwd_GammaCurrent.txt
- Fwd_ProtonCurrent.txt
\subsection ReverseMC01_sub_s3_4 Run macrofiles
The following example run macro files are distributed with the code:
- run_adjoint_simulation_electron.mac and run_adjoint_simulation_proton.mac for adjoint simulations
- run_forward_simulation_electron.mac and run_forward_simulation_proton.mac for forward simulations
\subsection ReverseMC01_sub_s3_5 Comparison of adjoint and forward simulation results
It is the responsibility of the user to select in the macro file the same external spectrum
for both the forward and adjoint simulations and to normalize the per event results of the forward simulation
to the fluence considered in the adjoint simulation.
For the macro files that are provided with the examples it consists into multiplying the forward results by pi*100.
This normalization factor is explained by the following:
- For the forward simulation the results are given per number of events. It corresponds
to a normalization to a fluence of 1 particle emanating from the external source.
- In run_fwd_simulation.mac the source is set on a sphere of 10 cm radius (see /gps commands in
macrofile).Therefore the omnidirectional fluence for the fwd simulation is 1./(pi*R^2) with R=10cm.
- The adjoint results are normalized to a fluence of 1/cm2.
(See command /RMC01/analysis/SetExponentialSpectrumForAdjointSim in macrofile)
- In conclusion to compare the adjoint and forward results, the forward results should
be multiplied by pi*R^2/cm2= pi*100.
\section ReverseMC01_s4 Control of the adjoint simulation and the RMC01 code by G4 macro UI commands
Different G4 macro UI commands are provided to control the RMC01 example and the adjoint simulation.
Some macro commands are provided within the geant4 toolkit and appears in a G4 application when the singleton
class G4AdjointSimManager is called somewhere in the code, the other macro commands are
declared in the code distributed within the example.
\subsection ReverseMC01_sub_s4_1 G4UI commands in the directory /adjoint
The macro command directory /adjoint appears in a user application when the singleton
class G4AdjointSimManager is called somewhere in the code.
It allows to control the adjoint source, the external source and start an adjoint simulation.
The command to start an adjoint run is:
- /adjoint/start_run nb \n
Start an adjoint simulation with a number of events given by nb. It is important to note that the total number of events in the sense of G4
will be nb*2*nb_primary_considered (see 3.4.)
The commands to control the adjoint source are:
- /adjoint/DefineSphericalAdjSource R X Y Z unit_length \n
The adjoint source is set on a sphere with radius R and centered on position (X,Y,Z)
- /adjoint/DefineSphericalAdjSourceCenteredOnAVolume phys_vol_name R unit_length \n
The external source is set on a sphere with radius R and with its center position located at the center of the
the physical volume specified by the name phys_vol_name.
- /adjoint/DefineAdjSourceOnExtSurfaceOfAVolume phys_vol_name \n
The external surface is set as the external boundary of a the physical volume with name phys_vol_name
- /adjoint/SetAdjSourceEmin Emin energy_unit \n
Set the minimum energy of the external source
- /adjoint/SetAdjSourceEmax Emax energy_unit \n
Set the maximum energy of the external source
- /adjoint/ConsiderAsPrimary particle_name \n
The type of particle specified by "particle_name" will be added in the list of primary adjoint particles.
The list of candidates depends on the reverse physics processes considered in the simulation. At the most the
potential candidates are (e-, gamma, proton , ion). For this example only e-, gamma, proton
can be chosen. As the proton ionization is not considered by default, the default list of particles is
[e-,gamma]. To have also the proton as candidate the proton ionization should
be switch on (/adjoint_physics/UseProtonIonisation true).
- /adjoint/NeglectAsPrimary particle_name \n
The type of particle specified by "particle_name" will be removed from the list of primary adjoint particles.
The list of candidates depends on the reverse physics processes considered in the simulation. At the most the
potential candidates are (e-, gamma, proton , ion). For this example only e-, gamma, proton
can be chosen. As the proton ionization is not considered by default, the default list of particles is
[e-,gamma].To have also the proton as candidate the proton ionization should
be switch on (/adjoint_physics/UseProtonIonisation true).
The commands to control the external source are:
- /adjoint/DefineSphericalExtSource R X Y Z unit_length:\n
The external source is set on a sphere with radius R and centered on position (X,Y,Z)
- /adjoint/DefineSphericalExtSourceCenteredOnAVolume phys_vol_name R unit_length\n
The external source is set on a sphere with radius R and with its center position located at the center of the
the physical volume specified by the name phys_vol_name.
- /adjoint/DefineExtSourceOnExtSurfaceOfAVolume phys_vol_name \n
The external surface is set as the external boundary of a the physical volume with name phys_vol_name
- /adjoint/SetExtSourceEmax Emax energy_unit \n
Set the maximum energy of the external source. An adjoint track will be stop when a an adjoint particle get an energy higher than this maximum energy.
\subsection ReverseMC01_sub_s4_2 G4UI commands in the directory /adjoint_physics
These commands allow to control the electromagnetic processes that will be considered in the simulation.
The processes that can be used are:
- Reverse and forward e- continuous and discrete Ionization. Always switch on
- Reverse and forward e- Bremsstrahlung. Switch on by default
- Reverse and forward Compton scattering. Switch on by default
- Reverse and forward photo electric effect. Switch on by default
- Reverse and forward photo electric effect. Switch on by default
- Reverse and forward multiple scattering. Switch on by default
- Reverse and forward proton continuous and discrete Ionization. Switch off by default
- Forward e-e+ pair production. Switch off by default.
The commands that can be used to switch on of these processes are:
- /adjoint_physics/UseProtonIonisation true/false \n
Switch on/off the reverse and forward proton ionization. Off by default.
- /adjoint_physics/UseBremsstrahlung true/false \n
Switch on/off the reverse and forward e- bremsstrahlung. On by default.
- /adjoint_physics/UseCompton true/false \n
Switch on/off the Compton scattering. On by default.
- /adjoint_physics/UseMS true/false \n
Switch on/off the multiple scattering. On by default.
- /adjoint_physics/UseEgainElossFluctuation true/false \n
Switch on/off the fluctuation in the continuous energy loss/gain. On by default. Only for test purpose.
- /adjoint_physics/UsePEEffect true/false \n
Switch on/off the photo electric effect. On by default.
- /adjoint_physics/UseGammaConversion true/false \n
Switch on/off the forward e-e+ pair production from gamma. Off by default. When On all the e+
electromagnetic physics is considered.
The user can also fix the maximum energy Emax and minimum energy Emin of the adjoint physical processes used
in the simulation. The adjoint process will be applied to particles within the energy range [Emin, Emax]
and will produce adjoint secondary only in this energy range. It is recommended to fix Emin to the minimum
energy of the adjoint source and fix Emax to the maximum energy of the external source.
The commands controlling Emin and Emax are:
- /adjoint_physics/SetEminForAdjointModels Emin Energy_unit \n
Set the minimum energy of the adjoint processes/models.
- /adjoint_physics/SetEmaxForAdjointModels Emin Energy_unit \n
Set the maximum energy of the adjoint processes/models.
\subsection ReverseMC01_sub_s4_3 G4UI commands in the directory /RMC01
Commands/RMC01/geometry/ to control the geometry:
- /RMC01/geometry/SetSensitiveVolumeHeight H length_unit \n
Set the height H of the Si sensitive cylinder.
- /RMC01/geometry/SetSensitiveVolumeRadius R length_unit \n
Set the radius R of the Si sensitive cylinder.
- /RMC01/geometry/SetShieldingThickness D length_unit \n
Set the thickness D of the aluminum shielding.
Commands /RMC01/analysis/ to control the primary spectrum used for the normalization of the
adjoint simulation results and fix the expected precision of the computed Edep:
- /RMC01/analysis/SetPowerLawPrimSpectrumForAdjointSim particle_name F F_unit alpha Emin Emax E_unit \n
Set the primary spectrum to which the adjoint simulation results will be normalised to a power law
spectrum E^(-alpha) of particle defined by particle_name, with an omnidirectional fluence F, and
energy range [Emin,Emax]. The fluence unit candidates for F_unit are [1/cm2, 1/m2, cm-2, m-2].
- /RMC01/analysis/SetExponentialSpectrumForAdjointSim particle_name F F_unit E0 Emin Emax E_unit \n
Set the primary spectrum to which the adjoint simulation results will be normalised to an exponential
spectrum exp(-E/E0) of particle defined by particle_name, with an omnidirectional fluence F, and
energy range [Emin,Emax]. The fluence unit candidates for F_unit are [1/cm2, 1/m2, cm-2, m-2].
- /RMC01/analysis/SetExpectedPrecisionOfResults precision \n
Set the expected precision in % for the computed energy deposited in the sensitive volume
for both the forward and adjoint simulation case. When the relative statistical error
of the computed energy deposited reach this precision the run is aborted and the results are registered.
Otherwise the run continue till the nb of events specified by the user are processed. By default the precision is set
to 0. meaning that the run will not be aborted in this case.
\section ReverseMC01_s5 Known issues
\subsection ReverseMC01_sub_s5_1 Rare too high weight in the adjoint simulation
In rare cases an adjoint track may get a much too high weight when reaching the external source.
While this happen not often it may corrupt the simulation results significantly. The reason of this high weight is
the joint use at low e- and gamma energy of both the photoelectric and bremsstrahlung processes.
Unfortunately we still need some investigations to remove this problem at the level of physical processes.
However this problem can be solved at the level of event action in the user code by adding a test on the adjoint
weight. Such test has been implemented in the example RMC01.
In this implementation an event is rejected when the relative error of the computed normalised edep
increase during one event by more than 50% when the precision is already below 10%.
\subsection ReverseMC01_sub_s5_2 Limitation of the reverse bremsstrahlung
The difference between the differential cross sections used in the adjoint and forward bremsstrahlung
models is the source of a higher flux of >100 keV gamma in the reverse simulation compared to the forward simulation.
The adjoint processes/models should make use of the direct differential cross section to sample
the adjoint secondaries and compute the adjoint cross section.
The differential cross section used in G4AdjointeBremstrahlungModel is obtained by the numerical derivation
over the cut energy of the direct cross section provided by G4eBremsstrahlungModel.
This would be a correct procedure if the distribution of secondary in G4eBremsstrahlungModel
would match this differential cross section. Unfortunately it is not the case as independent parameterization are used
in G4eBremsstrahlungModel for both the cross sections and the sample of secondary. (It means that in the forward case
if one would integrate the effective differential cross section considered in the simulation we would not find back
the used cross section).
In the future we plan to correct this problem by using an extra weight correction factor after the occurrence of a reverse
bremsstrahlung. This weight factor should be the ratio between the differential CS used in the adjoint simulation and the
one effectively used in the forward processes. As it is impossible to have access to the forward differential CS
in G4eBremsstrahlungModel we are investigating the feasibility to use the differential CS considered in
G4Penelope models.
\subsection ReverseMC01_sub_s5_3 Limitation of the reverse multiple scattering
For the reverse multiple scattering we are using the same models than for the forward case.
This approximation makes that the discrepancy between the adjoint and forward
simulation cases can get to a level of ~ 10-15% relative differences in the test cases that we have considered.
In the future we plan to improve the adjoint multiple scattering models by forcing the computation of
multiple scattering effect at the end of an adjoint step.
*/
@@ -0,0 +1,542 @@
Example1 for Reverse Monte Carlo
--------------------------------
Author
------
This example code and the adjoint classes in the G4 toolkit have been developed by L.Desorgher (SpaceIT GmbH)
under the ESA contract 21435/08/NL/AT. For any (reasonable) question you may contact the author
at the following email address : desorgher@spaceit.ch
Abstract
--------
This is the README file for the first G4 example illustrating the use of the Reverse Monte Carlo (RMC) mode in a Geant4
application. The Reverse Monte Carlo method is also known as the Adjoint Monte Carlo (AMC) method and
in this document we will alternate both Reverse and Adjoint terms.
Other documentation
-------------------
See also the section 3.7.3 Adjoint/Reverse Monte carlo in the
Geant4 User guide for application developers.
Table of Contents:
-----------------
1.Definition of Reverse/Adjoint Monte Carlo
2.The Reverse Monte Carlo mode in Geant4 (since G4.9.3 release)
2.1. Reverse tracking phase
2.2. Forward tracking phase
2.3. Reverse processes
2.4. Remark on Nb of adjoint particle types and G4 events considered in an adjoint simulation
2.5. Modifications to bring in a existing G4 application to use the Reverse MC method
3.exampleRMC01
3.1. Geometry
3.2. Physics
3.3. Analysis and output of the code
3.4. Run macrofiles
3.5. Comparison of adjoint and forward simulation results. Normalization!
4.Control of the adjoint simulation and the RMC01 code by G4 macro UI commands
4.1. G4UI commands in the directory /adjoint
4.2. G4UI commands in the directory /adjoint_physics
4.3. G4UI commands in the directory /RMC01
5. Known issues
5.1. Rare too high weight in the adjoint simulation
5.2. Limitation of the reverse bremsstrahlung
5.3.Limitation of the reverse multiple scattering
1. Definition of Reverse/Adjoint Monte Carlo
-----------------------------------------
-----------------------------------------
When the sensitive part of a detector is small compared to its entire size and to the size of the
external extended primary particle source, a lot of computing time is spent during a normal Monte Carlo run
in the simulation of particle showers that are not contributing to the detector signal.
In such particular case the Reverse Monte Carlo (RMC) method, also known as the
Adjoint Monte Carlo method, can be used.
In this method particles are generated in or on the external surface of the sensitive volume
of the instrument and then are tracked backward in the geometry till they reach the source surface,
or exceed an energy threshold. During the reverse tracking reverse reactions are applied to the particles.
2. The Reverse Monte Carlo mode in Geant4 (since G4.9.3 release)
----------------------------------------------------------------
----------------------------------------------------------------
(See also the section 3.7.3 Adjoint/Reverse Monte carlo in the
Geant4 User guide for application developers.)
Different G4Adjoint classes have been implemented into the Geant4
toolkit to run an adjoint/reverse simulation in a Geant4 application.
In this implementation an adjoint run is divided in a succession
of alternative adjoint and forward tracking of adjoint and normal particles.
One Geant4 event treats the reverse tracking of an adjoint primary particle
and its secondaries, and the forward tracking of a primary particle euqivalent
to the adjoint primary as well as its secondaries.
2.1. Reverse tracking phase:
-------------------------
Adjoint particles (adjoint_e-, adjoint_gamma,...) are generated one by one on the so called
adjoint source with random position, energy (1/E distribution) and direction. The adjoint
source is the external surface of a user defined volume or of a user defined sphere. The
adjoint source should contain one or several sensitive volumes and should be small
compared to the entire geometry. The user can set the minimum and maximum energy of the
adjoint source. After its generation the adjoint primary particle is tracked backward in
the geometry till a user defined external surface (spherical or boundary of a volume)
or is killed before if it reaches a user defined upper energy limit that represents the
maximum energy of the external source. During the reverse tracking, reverse processes take
place where the adjoint particle being tracked can be either scattered or transformed in
another type of adjoint particle. During the reverse tracking the
G4AdjointSimulationManager replaces the user defined primary, run, stepping, ... actions,
by its own actions.
2.2. Forward tracking phase:
--------------------------
When an adjoint particle reaches the external surface its weight, type, position,
and direction are registered and a normal primary particle with a type equivalent
to the last generated adjoint primary is generated with the same energy,
position but opposite direction and is tracked in the forward direction
in the sensitive region as in a forward MC simulation.
During this forward tracking phase the event, stacking, stepping, tracking actions defined
by the user for its general forward application are used.
By this clear separation between adjoint and forward tracking phases, the code of the
user developed for a forward simulation should be only slightly
modified to adapt it for an adjoint simulation. Indeed the computation of the signal
is done by the same user actions or analysis classes that the one used in the forward
simulation mode. Before the G4.10.0 release the reverse and forward tracking mode
took place in separated events. Since the G4.10.0 release,
in order to prepare to the migration of the
ReverseMC to the G4 Multiple Threading mode, the reverse and forward tracking
phase of corresponding adjoint and forward primaries have been merged in the same
event.
2.3. Reverse Processes:
---------------------
During the reverse tracking phase reverse processes act on the adjoint particles.
The Reverse processes that are available at the moment in Geant4 are the:
- Reverse discrete Ionization for e-, proton and ions
- Continuous gain of energy by ionization and bremsstrahlung for e- and by ionization for protons and ions
- Reverse discrete e- bremsstrahlung
- Reverse photoelectric effect
- Reverse Compton scattering
- Approximated multiple scattering (MS) (see section 5.3)
For the gamma reverse physics an adjoint gamma reverse forced interaction process has been implemented
since GEANT4.10.3. THis process splits a new created gamma in two tracks.
The first tracks is used to force a free flight of the adjoint gamma through the geometry.
The second track is used to force a reverse bremsstrahlung or a reverse compton at some random
position along the free flight track.
It is important to note that the electromagnetic reverse processes are cut dependent
as their equivalent forward processes. The implementation of the reverse processes is
based on the forward processes
implemented in the G4 standard electromagnetic package.
2.4. Remark on Nb of adjoint particle types and Nb of G4 events considered in an adjoint simulation:
---------------------------------------------------------------------------------
The list of type of adjoint and forward particles that are generated on the adjoint source
and considered in the simulation is a function of the adjoint processes declared in the
physics list. For example if only the e- and gamma electromagnetic processes are considered
, only adjoint e- and adjoint gamma will be considered as primaries. In this case an
adjoint event will be divided in two G4 events. The first event will consist
into the coupled reverse and forward tracking of an adjoint e- and its equivalent
forward e-, while the second events will process the reverse and forward trackings
of corresponsing adjoint and forward primary gammas. In this case a
run of 100 adjoint events will consist into 200 Geant4 events. If the proton ionization is
also considered adjoint and forward protons are also generated as primaries
and 300 Geant4 events are processed for 100 adjoint events.
2.5. Modifications to bring in a existing G4 application to use the Reverse MC method
--------------------------------------------------------------------------------
(for more details see also the section 3.7.3 Adjoint/Reverse Monte carlo in the
Geant4 User guide for application developers.)
Due the clear separation between the reverse and forward tracking phase only few modifications are needed
to an existing Geant4 application in order to adapt it for the use of the reverse simulation mode.
Except in the physics list where all the reverse processes and their forward equivalent
have to be declared, the principal code modifications are needed only in the analysis phase at the end
of the forward tracking where computed signals have to be multiplied by the weight
of the reverse tracks that have reached the external surface of the simulatrion
and then normalized to different user defined spectra and angular distribution representing
the external source.
The weight of the adjoint tracks is computed by the G4Adjoint classes and the user needs
only to multiply them to the primary differential, directional spectrum of its choice.
The adjoint weight a the end of tracks can be also registered if needed in answer matrices.
More precisely, in order to be able to use the Reverse MC method in his simulation, the user should modify
its code as such:
- Adapt its physics list to use Reverse Processes for adjoint particles. An example of such physics list is provided in an extended
example.
- Create an instance of G4AdjointSimManager somewhere in the main code.
- Modify the analysis part of the code to normalize the signal computed during the forward phase to the weight
of adjoint particle that reached the external surface during the last tracking phase.
This is done by using the following method of G4AdjointSimManager.
size_t GetNbOfAdointTracksReachingTheExternalSurface()
G4int GetIDOfLastAdjParticleReachingExtSource(size_t i)
G4ThreeVector GetPositionAtEndOfLastAdjointTrack(size_t i)
G4ThreeVector GetDirectionAtEndOfLastAdjointTrack(size_t i)
G4double GetEkinAtEndOfLastAdjointTrack(size_t i)
G4double GetEkinNucAtEndOfLastAdjointTrack(size_t i)
G4double GetWeightAtEndOfLastAdjointTrack(size_t i)
G4double GetCosthAtEndOfLastAdjointTrack(size_t i)
G4String GetFwdParticleNameAtEndOfLastAdjointTrack(size_t i)
G4int GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(size_t i)
G4int GetFwdParticleIndexAtEndOfLastAdjointTrack(size_t i).
Since the version Geant4.10.3 several adjoint tracks can arrive on the external surface during the same events.
It is therefore important to loop over alll these tracks when normalizing the weights at the end of the event.
The method GetNbOfAdointTracksReachingTheExternalSurface() returns the number of adjoint tracks that reached the
external surface. Ine the other methods the input parameter i allows to get the information of the ith track.
In order to have a code working for both forward and adjoint simulation mode, the extra code needed in user actions for the adjoint
simulation mode can be separated to the code needed only for the normal forward simulation by using the following method
G4bool GetAdjointSimMode() that return true if an adjoint simulation is running and false if not!
3. exampleRMC01
---------------
---------------
The example RMC01 illustrates how to modify a G4 application in order to use
both forward and reverse MC modes in the same code.
3.1. Geometry:
--------------
The following simple geometry is considered:
- sensitive Silicon cylinder at the center of an Aluminum spherical shielding with 10 cm Radius.
- two 0.5mm thick Tantalum plates set horizontally above and below the Sensitive Cylinder
The free parameters of the geometry that can bes set by the user are:
- the thickness of the Aluminum shielding
- the height of the sensitive Si cylinder
- the radius of the sensitive Si cylinder
3.2. Physics:
-------------
The physical processes considered are:
- Reverse and forward discrete Ionization for e- and proton
- Continuous gain and loss of energy by ionization and bremsstrahlung for e- and by ionization for protons
- Reverse and forward discrete e- bremsstrahlung
- Reverse and forward photoelectric effect
- Reverse and forward Compton scattering
- Reverse and forward Multiple scattering
These processes are implemented in the class G4AdjointPhysicsList distributed with the example. The G4AdjointPhysicsMessenger allows the user
to switch on/off some processes for testing purpose. By default all processes cited above are considered except the proton ionization that
has to be specifically switch on in the macro file by the user.
3.3. Analysis and output of the code:
----------------------------------
The example computes the energy deposited in the sensitive Si cylinder and the current of e-, protons, and gamma
entering this cylinder.
The Hits are registered in the sensitive detector class RMC01SD that is a typical G4 sensitive detector class
used in a forward simulation and is not modified at all
for the adjoint simulation mode.
The analysis of the registered hits during forward events is done by the RMCO1AnalysisManager.
That is the class that illustrates how to adapt an analysis code of a fwd simulation in order to use it also for
an adjoint simulation.
In this class during a forward simulation the method EndOfEventForForwardSimulation is used at the end of an event
while during an adjoint simulation at the end of fwd tracking event the method EndOfEventForAdjointSimulation is called.
By looking at the source of RMCO1AnalysisManager and more particularly to its method EndOfEventForAdjointSimulation the user will
learn how to adapt its G4 analysis code for an adjoint simulation.
The outputs of an adjoint simulation are:
-The total energy deposited and particle current entering the sensitive cylinder normalized
automatically to a user defined primary spectrum(exponential or power law) .
These results are stored in the files:
-Adj_Edep_vs_EkinPrim.txt
-Adj_ElectronCurrent.txt
-Adj_GammaCurrent.txt
-Adj_ProtonCurrent.txt
-ConvergenceOfAdjointSimulationResults.txt:
The total normalized edep and its relative error registered every 5000 adjoint events
-The answer matrix of the energy deposited and particles current on the sensitive cylinder in function of primary energy of e-, gamma and
protons. These results are stored in the files Adj********_Answer.txt
The outputs of a forward simulation are:
-The mean energy deposited and particle current entering the sensitive cylinder per event.
These results are stored in the files:
-Fwd_Edep_vs_EkinPrim.txt
-Fwd_ElectronCurrent.txt
-Fwd_GammaCurrent.txt
-Fwd_ProtonCurrent.txt
-ConvergenceOfAdjointSimulationResults.txt: The total normalized edep and its relative error registered every 5000 adjoint events
3.4. Run macrofiles:
------------------
The following example run macro files are distributed with the code:
-run_adjoint_simulation_electron.mac and run_adjoint_simulation_proton.mac for adjoint simulations
-run_forward_simulation_electron.mac and run_forward_simulation_proton.mac for forward simulations
3.5. Comparison of adjoint and forward simulation results:
----------------------------------------------------------
It is the responsibility of the user to select in the macro file the same external spectrum
for both the forward and adjoint simulations and to normalize the per event results of the forward simulation
to the fluence considered in the adjoint simulation.
For the macro files that are provided with the examples it consists into multiplying the forward results by pi*100.
This normalization factor is explained by the following:
-For the forward simulation the results are given per number of events. It corresponds
to a normalization to a fluence of 1 particle emanating from the external source.
-In run_fwd_simulation.mac the source is set on a sphere of 10 cm radius (see /gps commands in
macrofile).Therefore the omnidirectional fluence for the fwd simulation is 1./(pi*R^2) with R=10cm.
-The adjoint results are normalized to a fluence of 1/cm2.
(See command /RMC01/analysis/SetExponentialSpectrumForAdjointSim in macrofile)
-In conclusion to compare the adjoint and forward results, the forward results should
be multiplied by pi*R^2/cm2= pi*100.
4. Control of the adjoint simulation and the RMC01 code by G4 macro UI commands:
-------------------------------------------------------------------------
Different G4 macro UI commands are provided to control the RMC01 example and the adjoint simulation.
Some macro commands are provided within the geant4 toolkit and appears in a G4 application when the singleton
class G4AdjointSimManager is called somewhere in the code, the other macro commands are
declared in the code distributed within the example.
4.1. G4UI commands in the directory /adjoint
-----------------------------------------------
The macro commands in the directory /adjoint appears in a user application when the singleton
class G4AdjointSimManager is called somewhere in the code.
It allows to control the adjoint source, the external source and start an adjoint simulation.
The command to start an adjoint run is:
-/adjoint/start_run nb
Start an adjoint simulation with a number of events given by nb. It is important to note that the total number of events in the sense of G4
will be nb*2*nb_primary_considered (see 3.4.)
The commands to control the adjoint source are:
-/adjoint/DefineSphericalAdjSource R X Y Z unit_length
The adjoint source is set on a sphere with radius R and centered on position (X,Y,Z)
-/adjoint/DefineSphericalAdjSourceCenteredOnAVolume phys_vol_name R unit_length
The external source is set on a sphere with radius R and with its center position located at the center of the
the physical volume specified by the name phys_vol_name.
-/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume phys_vol_name
The external surface is set as the external boundary of a the physical volume with name phys_vol_name
-/adjoint/SetAdjSourceEmin Emin energy_unit
Set the minimum energy of the external source
-/adjoint/SetAdjSourceEmax Emax energy_unit
Set the maximum energy of the external source
-/adjoint/ConsiderAsPrimary particle_name
The type of particle specified by "particle_name" will be added in the list of primary adjoint particles.
The list of candidates depends on the reverse physics processes considered in the simulation. At the most the
potential candidates are (e-, gamma, proton , ion). For this example only e-, gamma, proton
can be chosen. As the proton ionization is not considered by default, the default list of particles is
[e-,gamma]. To have also the proton as candidate the proton ionization should
be switch on (/adjoint_physics/UseProtonIonisation true).
-/adjoint/NeglectAsPrimary particle_name
The type of particle specified by "particle_name" will be removed from the list of primary adjoint particles.
The list of candidates depends on the reverse physics processes considered in the simulation. At the most the
potential candidates are (e-, gamma, proton , ion). For this example only e-, gamma, proton
can be chosen. As the proton ionization is not considered by default, the default list of particles is
[e-,gamma].To have also the proton as candidate the proton ionization should
be switch on (/adjoint_physics/UseProtonIonisation true).
The commands to control the external source are:
-/adjoint/DefineSphericalExtSource R X Y Z unit_length:
The external source is set on a sphere with radius R and centered on position (X,Y,Z)
-/adjoint/DefineSphericalExtSourceCenteredOnAVolume phys_vol_name R unit_length
The external source is set on a sphere with radius R and with its center position located at the center of the
the physical volume specified by the name phys_vol_name.
-/adjoint/DefineExtSourceOnExtSurfaceOfAVolume phys_vol_name
The external surface is set as the external boundary of a the physical volume with name phys_vol_name
-/adjoint/SetExtSourceEmax Emax energy_unit
Set the maximum energy of the external source. An adjoint track will be stop when a an adjoint particle get an energy higher than this maximum energy.
4.2. G4UI commands in the directory /adjoint_physics
------------------------------------------------------
These commands allow to control the electromagnetic processes that will be considered in the simulation.
The processes that can be used are:
-Reverse and forward e- continuous and discrete Ionization. Always switch on
-Reverse and forward e- Bremsstrahlung. Switch on by default
-Reverse and forward Compton scattering. Switch on by default
-Reverse and forward photo electric effect. Switch on by default
-Reverse and forward photo electric effect. Switch on by default
-Reverse and forward multiple scattering. Switch on by default
-Reverse and forward proton continuous and discrete Ionization. Switch off by default
-Forward e-e+ pair production. Switch off by default.
If switch all the e+ electromagnetic physics is considered.
The commands that can be used to switch on of these processes are:
/adjoint_physics/UseProtonIonisation true/false
-Switch on/off the reverse and forward proton ionization. Off by default.
/adjoint_physics/UseBremsstrahlung true/false
-Switch on/off the reverse and forward e- bremsstrahlung. On by default.
/adjoint_physics/UseCompton true/false
-Switch on/off the Compton scattering. On by default.
/adjoint_physics/UseMS true/false
-Switch on/off the multiple scattering. On by default.
/adjoint_physics/UseEgainElossFluctuation true/false
-Switch on/off the fluctuation in the continuous energy loss/gain. On by default. Only for test purpose.
/adjoint_physics/UsePEEffect true/false
-Switch on/off the photo electric effect. On by default.
/adjoint_physics/UseGammaConversion true/false
-Switch on/off the forward e-e+ pair production from gamma. Off by default. When On all the e+
electromagnetic physics is considered.
The user can also fix the maximum energy Emax and minimum energy Emin of the adjoint physical processes used
in the simulation. The adjoint process will be applied to particles within the energy range [Emin, Emax]
and will produce adjoint secondary only in this energy range. It is recommended to fix Emin to the minimum
energy of the adjoint source and fix Emax to the maximum energy of the external source.
The commands controlling Emin and Emax are:
/adjoint_physics/SetEminForAdjointModels Emin Energy_unit
-Set the minimum energy of the adjoint processes/models.
/adjoint_physics/SetEmaxForAdjointModels Emin Energy_unit
-Set the maximum energy of the adjoint processes/models.
4.3. G4UI commands in the directory /RMC01
----------------------------------------------
Commands/RMC01/geometry/ to control the geometry:
/RMC01/geometry/SetSensitiveVolumeHeight H length_unit
Set the height H of the Si sensitive cylinder.
/RMC01/geometry/SetSensitiveVolumeRadius R length_unit
Set the radius R of the Si sensitive cylinder.
/RMC01/geometry/SetShieldingThickness D length_unit
Set the thickness D of the aluminum shielding.
Commands /RMC01/analysis/ to control the primary spectrum used for the normalization of the
adjoint simulation results and fix the expected precision of the computed Edep:
/RMC01/analysis/SetPowerLawPrimSpectrumForAdjointSim particle_name F F_unit alpha Emin Emax E_unit
Set the primary spectrum to which the adjoint simulation results will be normalised to a power law
spectrum E^(-alpha) of particle defined by particle_name, with an omnidirectional fluence F, and
energy range [Emin,Emax]. The fluence unit candidates for F_unit are [1/cm2, 1/m2, cm-2, m-2].
/RMC01/analysis/SetExponentialSpectrumForAdjointSim particle_name F F_unit E0 Emin Emax E_unit
Set the primary spectrum to which the adjoint simulation results will be normalised to an exponential
spectrum exp(-E/E0) of particle defined by particle_name, with an omnidirectional fluence F, and
energy range [Emin,Emax]. The fluence unit candidates for F_unit are [1/cm2, 1/m2, cm-2, m-2].
/RMC01/analysis/SetExpectedPrecisionOfResults precision
Set the expected precision in % for the computed energy deposited in the sensitive volume
for both the forward and adjoint simulation case. When the relative statistical error
of the computed energy deposited reach this precision the run is aborted and the results are registered.
Otherwise the run continue till the nb of events specified by the user are processed. By default the precision is set
to 0. meaning that the run will not be aborted in this case.
5. Known issues
--------------------------------
--------------------------------
5.1 Rare too high weight in the adjoint simulation
---------------------------------------------------
In rare cases an adjoint track may get a much too high weight when reaching the external source.
While this happen not often it may corrupt the simulation results significantly. The reason of this high weight is
the joint use at low e- and gamma energy of both the photoelectric and bremsstrahlung processes.
Unfortunately we still need some investigations to remove this problem at the level of physical processes.
However this problem can be solved at the level of event action in the user code by adding a test on the adjoint
weight. Such test has been implemented in the example RMC01.
In this implementation an event is rejected when the relative error of the computed normalised edep
increase during one event by more than 50% when the precision is already below 10%.
5.2 Limitation of the reverse bremsstrahlung
-------------------------------------------
The difference between the differential cross sections used in the adjoint and forward bremsstrahlung
models is the source of a higher flux of >100 keV gamma in the reverse simulation compared to the forward simulation.
The adjoint processes/models should make use of the direct differential cross section to sample
the adjoint secondaries and compute the adjoint cross section.
The differential cross section used in G4AdjointeBremstrahlungModel is obtained by the numerical derivation
over the cut energy of the direct cross section provided by G4eBremsstrahlungModel.
This would be a correct procedure if the distribution of secondary in G4eBremsstrahlungModel
would match this differential cross section. Unfortunately it is not the case as independent parameterization are used
in G4eBremsstrahlungModel for both the cross sections and the sample of secondary. (It means that in the forward case
if one would integrate the effective differential cross section considered in the simulation we would not find back
the used cross section).
In the future we plan to correct this problem by using an extra weight correction factor after the occurrence of a reverse
bremsstrahlung. This weight factor should be the ratio between the differential CS used in the adjoint simulation and the
one effectively used in the forward processes. As it is impossible to have access to the forward differential CS
in G4eBremsstrahlungModel we are investigating the feasibility to use the differential CS considered in
G4Penelope models.
5.3 Limitation of the reverse multiple scattering
-------------------------------------------------
For the reverse multiple scattering we are using the same models than for the forward case.
This approximation makes that the discrepancy between the adjoint and forward
simulation cases can get to a level of ~ 10-15% relative differences in the test cases that we have considered.
In the future we plan to improve the adjoint multiple scattering models by forcing the computation of
multiple scattering effect at the end of an adjoint step.
+24
View File
@@ -0,0 +1,24 @@
///\file "common/.README.txt"
///\brief Common classes README page
/*! \page Examples_common Category "common"
In order to reduce code duplication and to reduce the number of variants of
the code of same kind, we define a set of common classes which
can be reused in "feature" examples demonstrating just a particular feature.
This module may be enhanced in future. Currently it provides
the following sets of classes:
- Detector construction classes
- two simple detector construction classes with a messenger
- Physics list classes
- GeantinoPhysicsList - physics list with geantino and chargedgeantino only
- Primary generator classes
- two simple primary generator classes (with G4ParticleGun and
G4ParticleGeneralSource)
*/
+26
View File
@@ -0,0 +1,26 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Common Classes for Extended Examples
-------------------------------------
In order to reduce code duplication and to reduce the number of variants of
the code of same kind, we define a set of common classes which
can be reused in "feature" examples demonstrating just a particular feature.
This module may be enhanced in future. Currently it provides
the following sets of classes:
- Detector construction classes
- two simple detector construction classes with a messenger
- Physics list classes
- GeantinoPhysicsList - physics list with geantino and chargedgeantino only
- Primary generator classes
- two simple primary generator classes (with G4ParticleGun and
G4ParticleGeneralSource)
@@ -0,0 +1,119 @@
///\file "electromagnetic/.README.txt"
///\brief Examples electromagnetic README page
/*! \page Examples_electromagnetic Category "electromagnetic"
\section electromagnetic_s1 TestEm by theme
\verbatim
--------------------------------------------------------------------------
| Check basic quantities |
|------------------------------------------------------------------------|
| Total cross-sections, mean free paths ... | Em0 Em13 Em14 |
|------------------------------------------------------------------------|
| Stopping power, particle range ... | Em0 Em1 Em5 Em11 Em12 |
|------------------------------------------------------------------------|
| Final state : | |
| energy spectra, angular distributions ... | Em14 |
|------------------------------------------------------------------------|
| Energy loss fluctuations | Em18 |
--------------------------------------------------------------------------
-------------------------------------------------------------------------
| Multiple Coulomb scattering |
|-----------------------------------------------------------------------|
| as an isolated mechanism | Em15 |
|-----------------------------------------------------------------------|
| as a result of particle transport | Em5 |
-------------------------------------------------------------------------
-------------------------------------------------------------------------
| More global verifications |
|-----------------------------------------------------------------------|
| Single layer : | |
| transmission, absoption, reflexion ... | Em5 |
|-----------------------------------------------------------------------|
| Bragg curve, tallies | Em7 |
|-----------------------------------------------------------------------|
| Depth dose distribution | Em11 Em12 |
|-----------------------------------------------------------------------|
| Shower shapes, Moliere radius | Em2 |
|-----------------------------------------------------------------------|
| Sampling calorimeters, energy flow | Em3 |
|-----------------------------------------------------------------------|
| Crystal calorimeters | Em9 |
-------------------------------------------------------------------------
-------------------------------------------------------------------------
| Other specialized programs |
|-----------------------------------------------------------------------|
| High energy muon physics | Em17 |
|-----------------------------------------------------------------------|
| Other rare, high energy processes | Em6 |
|-----------------------------------------------------------------------|
| Synchrotron radiation | Em16 |
|-----------------------------------------------------------------------|
| Transition radiation | Em8 |
|-----------------------------------------------------------------------|
| Photo-absorption-ionization model | Em10 |
-------------------------------------------------------------------------
\endverbatim
- \link ExampleTestEm0 TestEm0 \endlink - how to print cross-sections and stopping power used in input by
the standard EM package
- \link ExampleTestEm1 TestEm1 \endlink - how to count processes, activate/inactivate them and survey
the range of charged particles. How to define a maximum step size
- \link ExampleTestEm2 TestEm2 \endlink - shower development in an homogeneous material :
longitudinal and lateral profiles
- \link ExampleTestEm3 TestEm3 \endlink - shower development in a sampling calorimeter : collect energy
deposited, survey energy flow and print stopping power
- \link ExampleTestEm4 TestEm4 \endlink - 9 MeV point like photon source: plot spectrum of energy
deposited in a single media
- \link ExampleTestEm5 TestEm5 \endlink - how to study transmission, absorption and reflection of particles
through a single, thin or thick, layer.
- \link ExampleTestEm6 TestEm6 \endlink - physics list for rare, high energy, electromagnetic processes :
gamma conversion and e+ annihilation into pair of muons
- \link ExampleTestEm7 TestEm7 \endlink - how to produce a Bragg curve in water phantom.
How to compute dose in tallies
- \link ExampleTestEm8 TestEm8 \endlink - test of photo-absorption-ionisation model in thin absorbers,
and transition radiation
- \link ExampleTestEm9 TestEm9 \endlink - shower development in a crystal calorimeter; cut-per-region
- \link ExampleTestEm10 TestEm10 \endlink - XTR transition radiation model, investigation of ionisation
in thin absorbers
- \link ExampleTestEm11 TestEm11 \endlink - how to plot a depth dose profile in a rectangular box
- \link ExampleTestEm12 TestEm12 \endlink - how to plot a depth dose profile in spherical geometry :
point like source
- \link ExampleTestEm13 TestEm13 \endlink - how to compute cross sections of EM processes from rate of
transmission coefficient
- \link ExampleTestEm14 TestEm14 \endlink - how to compute cross sections of EM processes from direct
evaluation of the mean-free path. How to plot final state
- \link ExampleTestEm15 TestEm15 \endlink - compute and plot final state of Multiple Scattering as an
isolated process
- \link ExampleTestEm16 TestEm16 \endlink - simulation of synchrotron radiation
- \link ExampleTestEm17 TestEm17 \endlink - check the cross sections of high energy muon processes
- \link ExampleTestEm18 TestEm18 \endlink - energy lost by a charged particle in a single layer,
due to ionization and bremsstrahlung
*/
+118
View File
@@ -0,0 +1,118 @@
--------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm by theme
---------------
--------------------------------------------------------------------------
| Check basic quantities |
|------------------------------------------------------------------------|
| Total cross-sections, mean free paths ... | Em0 Em13 Em14 |
|------------------------------------------------------------------------|
| Stopping power, particle range ... | Em0 Em1 Em5 Em11 Em12 |
|------------------------------------------------------------------------|
| Final state : | |
| energy spectra, angular distributions ... | Em14 |
|------------------------------------------------------------------------|
| Energy loss fluctuations | Em18 |
--------------------------------------------------------------------------
-------------------------------------------------------------------------
| Multiple Coulomb scattering |
|-----------------------------------------------------------------------|
| as an isolated mechanism | Em15 |
|-----------------------------------------------------------------------|
| as a result of particle transport | Em5 |
-------------------------------------------------------------------------
-------------------------------------------------------------------------
| More global verifications |
|-----------------------------------------------------------------------|
| Single layer : | |
| transmission, absoption, reflexion ... | Em5 |
|-----------------------------------------------------------------------|
| Bragg curve, tallies | Em7 |
|-----------------------------------------------------------------------|
| Depth dose distribution | Em11 Em12 |
|-----------------------------------------------------------------------|
| Shower shapes, Moliere radius | Em2 |
|-----------------------------------------------------------------------|
| Sampling calorimeters, energy flow | Em3 |
|-----------------------------------------------------------------------|
| Crystal calorimeters | Em9 |
-------------------------------------------------------------------------
-------------------------------------------------------------------------
| Other specialized programs |
|-----------------------------------------------------------------------|
| High energy muon physics | Em17 |
|-----------------------------------------------------------------------|
| Other rare, high energy processes | Em6 |
|-----------------------------------------------------------------------|
| Synchrotron radiation | Em16 |
|-----------------------------------------------------------------------|
| Transition radiation | Em8 |
|-----------------------------------------------------------------------|
| Photo-absorption-ionization model | Em10 |
-------------------------------------------------------------------------
TestEm0 - how to print cross-sections and stopping power used in input by
the standard EM package
TestEm1 - how to count processes, activate/inactivate them and survey
the range of charged particles. How to define a maximum step size
TestEm2 - shower development in an homogeneous material :
longitudinal and lateral profiles
TestEm3 - shower development in a sampling calorimeter : collect energy
deposited, survey energy flow and print stopping power
TestEm4 - 9 MeV point like photon source: plot spectrum of energy
deposited in a single media
TestEm5 - how to study transmission, absorption and reflection of particles
through a single, thin or thick, layer.
TestEm6 - physics list for rare, high energy, electromagnetic processes :
gamma conversion and e+ annihilation into pair of muons
TestEm7 - how to produce a Bragg curve in water phantom.
How to compute dose in tallies
TestEm8 - test of photo-absorption-ionisation model in thin absorbers,
and transition radiation
TestEm9 - shower development in a crystal calorimeter; cut-per-region
TestEm10 - XTR transition radiation model, investigation of ionisation
in thin absorbers
TestEm11 - how to plot a depth dose profile in a rectangular box
TestEm12 - how to plot a depth dose profile in spherical geometry :
point like source
TestEm13 - how to compute cross sections of EM processes from rate of
transmission coefficient
TestEm14 - how to compute cross sections of EM processes from direct
evaluation of the mean-free path. How to plot final state
TestEm15 - compute and plot final state of Multiple Scattering as an
isolated process
TestEm16 - simulation of synchrotron radiation
TestEm17 - check the cross sections of high energy muon processes
TestEm18 - energy lost by a charged particle in a single layer,
due to ionization and bremsstrahlung
@@ -0,0 +1,41 @@
///\file "electromagnetic/TestEm0/.README.txt"
///\brief Example TestEm0 README page
/*! \page ExampleTestEm0 Example TestEm0
This program is not a simulation. It prints the cross sections and stopping
power used by the standard electromagnetic package, via G4EmCalculator
which extracts these data from the PhysicsTables.
The program can be used in batch or interactively.
- execute TestEm0 in 'batch' mode from macro files :
\verbatim
% TestEm0 TestEm0.in
\endverbatim
- Interactively, a typical sequence will be :
\verbatim
% TestEm0
....
Idle> /run/initialize
....
Idle> /testem/det/setMat Silicon
Idle> /run/setCut 100 um
Idle> /gun/particle e-
Idle> /gun/energy 10 MeV
Idle> /run/beamOn
\endverbatim
The last command triggers BuildPhysicsTable() and executes the program.
\section TestEm0_s1 DirectAccess
DirectAccess.cc is a small batch program which shows how to compute the same
basic data directly from the processes (indeed the models).
To run it, change name in the first line on GNUmakefile before to compile.
*/
@@ -0,0 +1,39 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm0
-------
This program is not a simulation. It prints the cross sections and stopping
power used by the standard electromagnetic package, via G4EmCalculator
which extracts these data from the PhysicsTables.
The program can be used in batch or interactively.
- execute TestEm0 in 'batch' mode from macro files :
% TestEm0 TestEm0.in
- Interactively, a typical sequence will be :
% TestEm0
....
Idle> /run/initialize
....
Idle> /testem/det/setMat Silicon
Idle> /run/setCut 100 um
Idle> /gun/particle e-
Idle> /gun/energy 10 MeV
Idle> /run/beamOn
The last command triggers BuildPhysicsTable() and executes the program.
DirectAccess
------------
DirectAccess is a small batch program which shows how to compute the same
basic data directly from the processes (indeed the models).
To run it, change name in the first line on GNUmakefile before to compile.
@@ -0,0 +1,164 @@
///\file "electromagnetic/TestEm1/.README.txt"
///\brief Example TestEm1 README page
/*! \page ExampleTestEm1 Example TestEm1
- How to count processes.
- How to activate/inactivate processes.
- How to survey the tracking, in particular the range of charged particles.
- How to define a maximum step size.
\section TestEm1_s1 GEOMETRY DEFINITION
It is a simple box which represents a 'semi infinite' homogeneous medium.
Two parameters define the geometry :
- the material of the box,
- the full size of the box.
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class, but all of
the above parameters can be changed interactively via the commands defined in
the DetectorMessenger class.
\section TestEm1_s2 PHYSICS LIST
Physics lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
EM physics builders can be local (eg. in this example) or from G4 kernel
physics_lists subdirectory.
Local physics builder:
- "local" standard EM physics with current 'best' options setting.
these options are explicited in PhysListEmStandard
From geant4/source/physics_lists/builders:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardSS" standard EM physics and single scattering model
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
Physics lists and options can be (re)set with UI commands
A few commands have been added to PhysicsList, in order to set the production
threshold for secondaries for gamma and e-/e+.
\section TestEm1_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the left face
of the box. The type of the particle and its energy are set in the
PrimaryGeneratorAction class, and can be changed via the G4 build-in commands
of G4ParticleGun class (see the macros provided with this example).
In addition one can choose randomly the impact point of the incident particle.
The corresponding interactive command is built in PrimaryGeneratorMessenger.
\section TestEm1_s4 VISUALIZATION
The Visualization Manager is set in the main () (see TestEm1.cc).
The initialisation of the drawing is done via the commands /vis/... in the
macro vis.mac. To get visualisation:
\verbatim
> /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
\section TestEm1_s5 PHYSICS SURVEY
The particle's type and the physics processes which will be available in this
example are set in PhysicsList class.
A set of macros defining various run conditions are provided. The processes
are actived/inactivated together with differents cuts, in order to survey the
processes one by one.
The number of produced secondaries are counted, the number of steps, and the
number of process calls responsible of the step.
\section TestEm1_s6 HOW TO START ?
- Execute TestEm1 in 'batch' mode from macro files
\verbatim
% TestEm1 runs.mac
\endverbatim
- Execute TestEm1 in 'interactive mode' with visualization
\verbatim
% TestEm1
....
Idle> type your commands
....
Idle> exit
\endverbatim
Macros provided in this example:
- brems.mac: Bremsstrahlung only
- erange.mac: compute the csda range of primary particle
- geantino.mac: geantino as primary particle
- ionis.mac: Ionisation only
- photoelec.mac: 100 keV photon photoelectric effect
- radioactive.mac: use radioactive ion as primary particle
- range.mac: compute the csda range of the primary particle
with or without fluctuations
- runs.mac: electron 100 MeV; all processes
Macros to be run interactively:
- annihil.mac: To visualise 100 MeV e+ annihilation
- decayinfly.mac: To visualise decay in fly of N16
- gammaconversion.mac: To visualise gamma conversion and e+ annihilation
- photon.mac: To visualiza p300 keV photon beam
- stepMax.mac: to test command /testem/stepMax
- vis.mac: To activate visualization
\section TestEm1_s7 TRACKING : StepMax
In order to control the accuracy of the deposition, the user can limit
'by hand' the maximum step size of charged particles.
As an example, this limitation is implemented as a 'full' process :
see StepMax class and its Messenger. The 'StepMax process' is registered
in the Physics List.
\section TestEm1_s8 HISTOGRAMS
Testem1 produces several histo which are saved as testem1.root by default.
Content of these histo:
- 1 : track length of primary particle
- 2 : number of steps primary particle
- 3 : step size of primary particle
- 4 : total energy deposit
- 5 : energy of charged secondaries at creation
- 6 : energy of neutral secondaries at creation
The histograms are managed by G4AnalysisManager class and its Messenger.
The histos can be individually activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem1)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem1)
*/
@@ -0,0 +1,157 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm1
-------
How to count processes.
How to activate/inactivate processes.
How to survey the tracking, in particular the range of charged particles.
How to define a maximum step size.
1 - GEOMETRY DEFINITION
It is a simple box which represents a 'semi infinite' homogeneous medium.
Two parameters define the geometry :
- the material of the box,
- the full size of the box.
In addition a transverse uniform magnetic field can be applied.
e.g. /globalField/setValue 0 0 5 tesla
The default geometry is constructed in DetectorConstruction class, but all of
the above parameters can be changed interactively via the commands defined in
the DetectorMessenger class.
2 - PHYSICS LIST
Physics lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
EM physics builders can be local (eg. in this example) or from G4 kernel
physics_lists subdirectory.
Local physics builder:
- "local" standard EM physics with current 'best' options setting.
these options are explicited in PhysListEmStandard
From geant4/source/physics_lists/builders:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardSS" standard EM physics and single scattering model
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
Physics lists and options can be (re)set with UI commands
A few commands have been added to PhysicsList, in order to set the production
threshold for secondaries for gamma and e-/e+.
3 - AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the left face
of the box. The type of the particle and its energy are set in the
PrimaryGeneratorAction class, and can be changed via the G4 build-in commands
of G4ParticleGun class (see the macros provided with this example).
In addition one can choose randomly the impact point of the incident particle.
The corresponding interactive command is built in PrimaryGeneratorMessenger.
4 - VISUALIZATION
The Visualization Manager is set in the main () (see TestEm1.cc).
The initialisation of the drawing is done via the commands /vis/... in the
macro vis.mac. To get visualisation:
> /control/execute vis.mac
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
5 - PHYSICS SURVEY
The particle's type and the physics processes which will be available in this
example are set in PhysicsList class.
A set of macros defining various run conditions are provided. The processes
are actived/inactivated together with differents cuts, in order to survey the
processes one by one.
The number of produced secondaries are counted, the number of steps, and the
number of process calls responsible of the step.
6 - HOW TO START ?
- execute TestEm1 in 'batch' mode from macro files
% TestEm1 runs.mac
- execute TestEm1 in 'interactive mode' with visualization
% TestEm1
....
Idle> type your commands
....
Idle> exit
Macros provided in this example:
- brems.mac: Bremsstrahlung only
- erange.mac: compute the csda range of primary particle
- geantino.mac: geantino as primary particle
- ionis.mac: Ionisation only
- photoelec.mac: 100 keV photon photoelectric effect
- radioactive.mac: use radioactive ion as primary particle
- range.mac: compute the csda range of the primary particle
with or without fluctuations
- runs.mac: electron 100 MeV; all processes
Macros to be run interactively:
- annihil.mac: To visualise 100 MeV e+ annihilation
- decayinfly.mac: To visualise decay in fly of N16
- gammaconversion.mac: To visualise gamma conversion and e+ annihilation
- photon.mac: To visualiza p300 keV photon beam
- stepMax.mac: to test command /testem/stepMax
- vis.mac: To activate visualization
7 - TRACKING : StepMax
In order to control the accuracy of the deposition, the user can limit
'by hand' the maximum step size of charged particles.
As an example, this limitation is implemented as a 'full' process :
see StepMax class and its Messenger. The 'StepMax process' is registered
in the Physics List.
8 - HISTOGRAMS
Testem1 produces several histo which are saved as testem1.root by default.
Content of these histo:
1 : track length of primary particle
2 : number of steps primary particle
3 : step size of primary particle
4 : total energy deposit
5 : energy of charged secondaries at creation
6 : energy of neutral secondaries at creation
The histograms are managed by G4AnalysisManager class and its Messenger.
The histos can be individually activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem1)
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem1)
@@ -0,0 +1,103 @@
///\file "electromagnetic/TestEm10/.README.txt"
///\brief Example TestEm10 README page
/*! \page ExampleTestEm10 Example TestEm10
Test for investigation of transition radiation.
Default setup for "TestEm10.in" and "TestEm10.large_N.in" is the simplified
setup for ALICE XTR test beam (~2004), defined in DetectorSimpleALICE class.
\section TestEm10_s0 GEOMETRY DEFINITION
The geometry setup includes "radiator" and "absorber" volumes
of a box shape.
The "radiator" material is defined as a mixture of a gas and foil material
and the "absorber" contains a gas material.
Several geometry setups are defined in the classes
DetectorSetupX,
where SetupX = ALICE06, Bari05, Barr90, Construction, Harris73, Messenger, SimpleALICE, Watase86
The default setup, SimpleALICE, can be changed via UI command:
\verbatim
/XTRdetector/setup setup
where setup = simpleALICE, alice06, bari05, harris73, watase86, barr90
\endverbatim
\section TestEm10_s1 PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
absorber perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
be changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
\section TestEm10_s2 DETECTOR RESPONSE
In this example the total energy deposited in the "absorber" volume
is accounted in SensitevDetector class, and a spectrum of XTR gamma
particles, all secondary gamma particles and all secondary e-
particleas is accounted in StackingAction class.
\section TestEm10_s3 PHYSICS
The particle's type and the physic processes which will be available
in this example are set in PhysicsList class.
The trasition radiation process is defined in the
TransitionRadiationPhysics builder.
The transition radiator models can be changed simply with:
\verbatim
Idle> /emphyslist/setXTRModel modelName
\endverbatim
See macro files "*.mac" for different setups providede with the example.
\section TestEm10_s4 HISTOGRAMS
Testem10 produces several histo which are saved as testem10.root by default.
Content of these histo:
- 1. Energy deposit in absorber
- 2. XTR Gamma spectrum
- 3. Secondary Gamma spectrum
- 4. Secondary e- spectrum
- 5. Energy deposit in absorber with the same histogram parameters
as in the previous version of this example (Geant4 version <=10.2)
The histograms are managed by G4AnalysisManager class and its Messenger.
The histos can be individually activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem1)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/setAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default testem1)
\section TestEm10_s5 HOW TO START ?
- Execute TestEm10 in 'batch' mode from macro files e.g.
\verbatim
% TestEm10 run11.mac
\endverbatim
- Execute TestEm10 in 'interactive' mode with visualization e.g.
\verbatim
% TestEm10
....
Idle> type your commands
....
\endverbatim
*/
@@ -0,0 +1,94 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm10
--------
Test for investigation of transition radiation.
Default setup for "TestEm10.in" and "TestEm10.large_N.in" is the simplified
setup for ALICE XTR test beam (~2004), defined in DetectorSimpleALICE class.
1- GEOMETRY DEFINITION
The geometry setup includes "radiator" and "absorber" volumes
of a box shape.
The "radiator" material is defined as a mixture of a gas and foil material
and the "absorber" contains a gas material.
Several geometry setups are defined in the classes
DetectorSetupX,
where SetupX = ALICE06, Bari05, Barr90, Construction, Harris73, Messenger, SimpleALICE, Watase86
The default setup, SimpleALICE, can be changed via UI command:
/XTRdetector/setup setup
where setup = simpleALICE, alice06, bari05, harris73, watase86, barr90
2- PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
absorber perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
be changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
3- DETECTOR RESPONSE
In this example the total energy deposited in the "absorber" volume
is accounted in SensitevDetector class, and a spectrum of XTR gamma
particles, all secondary gamma particles and all secondary e-
particleas is accounted in StackingAction class.
4- PHYSICS
The particle's type and the physic processes which will be available
in this example are set in PhysicsList class.
The trasition radiation process is defined in the
TransitionRadiationPhysics builder.
The transition radiator models can be changed simply with:
Idle> /emphyslist/setXTRModel modelName
See macro files "*.mac" for different setups providede with the example.
5 - HISTOGRAMS
Testem10 produces several histo which are saved as testem10.root by default.
Content of these histo:
1: Energy deposit in absorber
2: XTR Gamma spectrum
3: Secondary Gamma spectrum
4: Secondary e- spectrum
5: Energy deposit in absorber with the same histogram parameters
as in the previous version of this example (Geant4 version <=10.2)
The histograms are managed by G4AnalysisManager class and its Messenger.
The histos can be individually activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem1)
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem1)
6- HOW TO START ?
- execute TestEm10 in 'batch' mode from macro files e.g.
% TestEm10 run11.mac
- execute TestEm10 in 'interactive' mode with visualization e.g.
% TestEm10
....
Idle> type your commands
....
@@ -0,0 +1,192 @@
///\file "electromagnetic/TestEm11/.README.txt"
///\brief Example TestEm11 README page
/*! \page ExampleTestEm11 Example TestEm11
How to plot a depth dose profile in a rectangular box.
\section TestEm11_s1 GEOMETRY DEFINITION
The geometry consists of a stack of one or several blocks of homogenous
material, called absorbers.
Optionally, each absorber can be divided in thinner layers (replica)
A minimum of 5 parameters define the geometry :
- the number of absorbers (NbOfAbsor)
- the material of each absorber,
- the thickness of each absorber,
- the tranverse dimension of the stack (sizeYZ),
- the number of divisions of each absorber (NbOfDivisions)
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be changed interactively via
the commands defined in the DetectorMessenger class.
\section TestEm11_s2 PHYSICS LIST
Physics Lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
The following options for EM physics using builders from physics_lists
sub-package are available:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emstandardGS" standard EM physics and Goudsmit-Saunderson multiple scatt.
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
A local builder, PhysListEmStandard "local" (similar to opt3) is also
available.
Physics lists and options can be (re)set with UI commands
\section TestEm11_s3 ACTION INITIALIZATION
A newly introduced class, ActionInitialization, instantiates and registers
to Geant4 kernel all user action classes.
While in sequential mode the action classes are instantiated just once,
via invoking the method:
ActionInitialization::Build()
in multi-threading mode the same method is invoked for each thread worker
and so all user action classes are defined thread-local.
A run action class (if present) has to be instantiated both thread-local
and global, which is why its instance has to be created also in the method
ActionInitialization::BuildForMaster()
which is invoked only in multi-threading mode.
\section TestEm11_s4 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the
left face of the box. The type of the particle and its energy are set
in the PrimaryGeneratorAction class, and can be changed via the G4
build-in commands of G4ParticleGun class (see the macros provided with
this example).
In addition one can choose randomly the impact point of the incident
particle. The corresponding interactive command is built in
PrimaryGeneratorMessenger class.
A RUN is a set of events.
\section TestEm11_s5 VISUALIZATION
The Visualization Manager is set in the main () (see TestEm11.cc).
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
\verbatim
> /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged one,
or none. This command is defined in EventActionMessenger class.
\section TestEm11_s6 HOW TO START ?
- Execute TestEm11 in 'batch' mode from macro files
\verbatim
% TestEm11 run01.mac
\endverbatim
- Execute TestEm11 in 'interactive mode' with visualization
\verbatim
% TestEm11
....
Idle> type your commands
....
Idle> exit
\endverbatim
Macros provided in this example:
- alpha.mac: alpha (400 MeV) on water
- ionC12.mac: ion C12 (2.4 GeV) on water
- multiLayers.mac: gamma (6 MeV) on multi layers
- radioactive.mac: radioactive ion on multi layers
- range.mac: compute csda range of primary particle
- run01.mac: e- (500 keV) on silicon. Step max from histo 1
- run02.mac: e- (500 keV) on silicon. Step max from geometry
- sandia.mac: to compare with Sandia data
- water.mac: e- (4 MeV) on water. No constraint on tracking step
Macros to be run interactively:
- vis.mac: To activate visualization
\section TestEm11_s7 TRACKING and STEP MAX
TestEm11 computes the distribution of energy deposited along the trajectory of
the incident particle : the so-called longitudinal energy profile,
or depth dose distribution.
The energy deposited (edep) is randomly distribued along the step (see
SteppingAction).
In order to control the accuracy of the deposition, the maximum step size
of charged particles is computed automatically from the binning of
histograms 1 and 8 (see RunAction).
As an example, this limitation is implemented as a 'full' process :
see StepMax class and its messenger, StepMaxMessenger. The 'StepMax process' is registered
in the Physics List.
StepMax is evaluated at RunAction::BeginOfRunAction(),
and passed to the StepMax process.
A boolean UI command allows to deactivate this mechanism.
Another UI command allows to define directly a stepMax value.
\section TestEm11_s8 HISTOGRAMS
TestEm11 has several predefined 1D histograms :
- 1 : longitudinal energy profile (in MeV/mm and per event)
- 2 : total energy deposited in the absorber
- 3 : total track length of the primary track
- 4 : step size of the primary track
- 5 : projected range of the primary track
- 6 : total track length of charged secondary tracks
- 7 : step size of charged secondary tracks
- 8 : longitudinal energy profile (in MeV.cm2/g), as a function of x/r0
where r0 is the range of the primary particle
- 11 : energy deposited in absorber 1
- 12 : energy deposited in absorber 2
...etc........
The histograms are managed by G4Analysis classes;
The histos can be individually activated with the command :
\verbatim
/analysis/h1/set id nbBins valMin valMax unit
\endverbatim
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem11)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/setAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default testem11)
*/
@@ -0,0 +1,185 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm11
--------
How to plot a depth dose profile in a rectangular box.
1- GEOMETRY DEFINITION
The geometry consists of a stack of one or several blocks of homogenous
material, called absorbers.
Optionally, each absorber can be divided in thinner layers (replica)
A minimum of 5 parameters define the geometry :
- the number of absorbers (NbOfAbsor)
- the material of each absorber,
- the thickness of each absorber,
- the tranverse dimension of the stack (sizeYZ),
- the number of divisions of each absorber (NbOfDivisions)
In addition a transverse uniform magnetic field can be applied.
eg: /globalField/setValue 0 0 5 tesla
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be changed interactively via
the commands defined in the DetectorMessenger class.
2- PHYSICS LIST
Physics Lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
The following options for EM physics using builders from physics_lists
sub-package are available:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emstandardGS" standard EM physics and Goudsmit-Saunderson multiple scatt.
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
- "emstandardMP" standard EM physics where for e- a new model
G4DiscreteScatteringModel is applied; for this model
a data set G4GBFPDATA should be requested from EM group
A local builder, PhysListEmStandard "local" (similar to opt3) is also
available.
Physics lists and options can be (re)set with UI commands
3- ACTION INITIALIZATION
A newly introduced class, ActionInitialization, instantiates and registers
to Geant4 kernel all user action classes.
While in sequential mode the action classes are instantiated just once,
via invoking the method:
ActionInitialization::Build()
in multi-threading mode the same method is invoked for each thread worker
and so all user action classes are defined thread-local.
A run action class (if present) has to be instantiated both thread-local
and global, which is why its instance has to be created also in the method
ActionInitialization::BuildForMaster()
which is invoked only in multi-threading mode.
4- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the
left face of the box. The type of the particle and its energy are set
in the PrimaryGeneratorAction class, and can be changed via the G4
build-in commands of G4ParticleGun class (see the macros provided with
this example).
In addition one can choose randomly the impact point of the incident
particle. The corresponding interactive command is built in
PrimaryGeneratorMessenger class.
A RUN is a set of events.
5- VISUALIZATION
The Visualization Manager is set in the main().
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
> /control/execute vis.mac
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged one,
or none. This command is defined in EventActionMessenger class.
6- HOW TO START ?
- Execute TestEm11 in 'batch' mode from macro files
% TestEm11 run01.mac
- Execute TestEm11 in 'interactive mode' with visualization
% TestEm11
....
Idle> type your commands
....
Idle> exit
Macros provided in this example:
- alpha.mac: alpha (400 MeV) on water
- ionC12.mac: ion C12 (2.4 GeV) on water
- multiLayers.mac: gamma (6 MeV) on multi layers
- radioactive.mac: radioactive ion on multi layers
- range.mac: compute csda range of primary particle
- run01.mac: e- (500 keV) on silicon. Step max from histo 1
- run02.mac: e- (500 keV) on silicon. Step max from geometry
- sandia.mac: to compare with Sandia data
- water.mac: e- (4 MeV) on water. No constraint on tracking step
Macros to be run interactively:
- vis.mac: To activate visualization
7- TRACKING and STEP MAX
TestEm11 computes the distribution of energy deposited along the trajectory of
the incident particle : the so-called longitudinal energy profile,
or depth dose distribution.
The energy deposited (edep) is randomly distribued along the step (see
SteppingAction).
In order to control the accuracy of the deposition, the maximum step size
of charged particles is computed automatically from the binning of
histograms 1 and 8 (see RunAction).
As an example, this limitation is implemented as a 'full' process :
see StepMax class and its Messenger. The 'StepMax process' is registered
in the Physics List.
StepMax is evaluated at RunAction::BeginOfRun(),
and passed to the StepMax process.
A boolean UI command allows to deactivate this mechanism.
Another UI command allows to define directly a stepMax value.
8- HISTOGRAMS
TestEm11 has several predefined 1D histograms :
1 : longitudinal energy profile (in MeV/mm and per event)
2 : total energy deposited in all absorbers
3 : total track length of the primary track
4 : step size of the primary track
5 : projected range of the primary track
6 : total track length of charged secondary tracks
7 : step size of charged secondary tracks
8 : longitudinal energy profile (in MeV.cm2/g), as a function of x/r0
where r0 is the range of the primary particle
11 : energy deposited in absorber 1
12 : energy deposited in absorber 2
...etc........
The histograms are managed by G4Analysis classes.
The histos can be individually activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem11)
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem11)
@@ -0,0 +1,26 @@
------------------
EGSnrc Simulations
------------------
These results were computed with the EGSnrc user code DOSRZnrc.
Yann Perrot (perrot@clermont.in2p3.fr) December 2010
Simulation parameters:
----------------------
Electron Stepping Algorithm : PRESTA-II
Boundary Crossing Algoritm : EXACT with skin parameter=3
Maximum Energy Loss per Step : ESTEPE = 1%
Electron tracking cut : 10keV for E>=1MeV
1keV for E<1MeV
References:
----------
Rogers and Bielajew 1986
Med. Phys. 13, 687-694
Rogers et al 2003
NRC User Codes for EGSnrc
Technical Report PIRS-702(RevB)
National Research Council of Canada
@@ -0,0 +1,174 @@
///\file "electromagnetic/TestEm12/.README.txt"
///\brief Example TestEm12 README page
/*! \page ExampleTestEm12 Example TestEm12
How to plot a depth dose profile in spherical geometry.
\section TestEm12_s1 GEOMETRY DEFINITION
The geometry consists of a single sphere of an homogenous material.
Optionally, the sphere can be divided in thin shells.
3 parameters define the geometry :
- the material of the sphere,
- the radius of the sphere (absorRadius),
- the number of shells (nbOfLayers)
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be changed interactively via
the commands defined in the DetectorMessenger class.
\section TestEm12_s2 PHYSICS LIST
Physics Lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
The following options for EM physics using builders from physics_lists
sub-package are available:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emstandardGS" standard EM physics and Goudsmit-Saunderson multiple scatt.
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
- "dna" process and models for Geant4-DNA
- "dna_opt1" process and models for Geant4-DNA
- "dna_opt2" process and models for Geant4-DNA
- "dna_opt3" process and models for Geant4-DNA
- "dna_opt4" process and models for Geant4-DNA
- "dna_opt5" process and models for Geant4-DNA
- "dna_opt6" process and models for Geant4-DNA
- "dna_opt7" process and models for Geant4-DNA
A local builder, PhysListEmStandard "local" (similar to opt0) is also
available.
Physics lists and options can be (re)set with UI commands
\section TestEm12_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle randomly shot at
the centre of the sphere. The type of the particle and its energy are set
in the PrimaryGeneratorAction class, and can be changed via the G4
built-in commands of G4ParticleGun class (see the macros provided with
this example).
In addition one can deactivate the randomness of the direction of the
incident particle. The corresponding interactive command is built in
PrimaryGeneratorMessenger class.
A RUN is a set of events.
\section TestEm12_s4 VISUALIZATION
The Visualization Manager is set in the main () (see TestEm12.cc).
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
\verbatim
> /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the
box.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged ones,
or none. This command is defined in EventActionMessenger class.
\section TestEm12_s5 HOW TO START ?
- Execute TestEm12 in 'batch' mode from macro files
\verbatim
% TestEm12 run01.mac
\endverbatim
- Execute TestEm12 in 'interactive mode' with visualization
\verbatim
% TestEm12
....
Idle> type your commands
....
Idle> exit
\endverbatim
Macros provided in this example:
- berger.mac: e- (100 keV) on water
- dna.mac: e- (1 keV) on water. DNA physics list
- run01.mac: e- (4 MeV) on water. Step max from histos 1 and 8
- run02.mac: e- (4 MeV) on water. Step max from geometry
Macros to be run interactively:
- vis.mac: To activate visualization
\section TestEm12_s6 TRACKING and STEP MAX
TestDm12 computes the total energy deposited along the trajectory of
the incident particle : the so-called longitudinal energy profile,
or depth dose distribution.
The energy deposited (edep) is randomly distributed along the step (see
SteppingAction).
In order to control the accuracy of the deposition, the maximum step size
of charged particles is computed automatically from the binning of
histograms 1 and 8 (see RunAction).
As an example, this limitation is implemented as a 'full' process :
see StepMax class and its messenger.
The 'StepMax process' is registered in the Physics List.
StepMax is evaluated in RunAction::BeginOfRun() and passed
to the StepMax process.
A boolean UI command allows to deactivate this mechanism.
Another UI command allows to define directly a stepMax value.
\section TestEm12_s7 HISTOGRAMS
Testem12 has several predefined 1D histograms :
- 1 : energy profile dE/dr (in MeV/mm per event)
- 2 : total energy deposited in the absorber
- 3 : total track length of the primary track
- 4 : step size of the primary track
- 5 : projected range of the primary track
- 6 : total track length of charged secondary tracks
- 7 : step size of charged secondary tracks
- 8 : normalized energy profile d(E/E0)/d(r/r0), where r0 is the range of
the primary particle of energy E0
The histograms are managed by G4AnalysisManager class and its messenger.
The histos can be individually activated with the command :
\verbatim
/analysis/h1/set id nbBins valMin valMax unit
\endverbatim
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem12)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/setAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default testem12)
*/
@@ -0,0 +1,163 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm12
--------
How to plot a depth dose profile in spherical geometry.
1- GEOMETRY DEFINITION
The geometry consists of a single sphere of an homogenous material.
Optionally, the sphere can be divided in thin shells.
3 parameters define the geometry :
- the material of the sphere,
- the radius of the sphere (absorRadius),
- the number of shells (nbOfLayers)
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be changed interactively via
the commands defined in the DetectorMessenger class.
2- PHYSICS LIST
Physics Lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
The following options for EM physics using builders from physics_lists
sub-package are available:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emstandardGS" standard EM physics and Goudsmit-Saunderson multiple scatt.
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
- "dna" process and models for Geant4-DNA
- "dna_opt1" process and models for Geant4-DNA
- "dna_opt2" process and models for Geant4-DNA
- "dna_opt3" process and models for Geant4-DNA
- "dna_opt4" process and models for Geant4-DNA
- "dna_opt5" process and models for Geant4-DNA
- "dna_opt6" process and models for Geant4-DNA
- "dna_opt7" process and models for Geant4-DNA
A local builder, PhysListEmStandard "local" (similar to opt0) is also
available.
Physics lists and options can be (re)set with UI commands
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle randomly shot at
the centre of the sphere. The type of the particle and its energy are set
in the PrimaryGeneratorAction class, and can be changed via the G4
built-in commands of ParticleGun class (see the macros provided with
this example).
In addition one can deactivate the randomness of the direction of the
incident particle. The corresponding interactive command is built in
PrimaryGeneratorMessenger class.
A RUN is a set of events.
4- VISUALIZATION
The Visualization Manager is set in the main().
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
> /control/execute vis.mac
The detector has a default view which is a longitudinal view of the
box.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged ones,
or none. This command is defined in EventActionMessenger class.
5- HOW TO START ?
- execute TestEm12 in 'batch' mode from macro files
% TestEm12 run01.mac
- execute TestEm12 in 'interactive mode' with visualization
% TestEm12
....
Idle> type your commands
....
Idle> exit
Macros provided in this example:
- berger.mac: e- (100 keV) on water
- dna.mac: e- (1 keV) on water. DNA physics list
- run01.mac: e- (4 MeV) on water. Step max from histos 1 and 8
- run02.mac: e- (4 MeV) on water. Step max from geometry
Macros to be run interactively:
- vis.mac: To activate visualization
6- TRACKING and STEP MAX
TestDm12 computes the total energy deposited along the trajectory of
the incident particle : the so-called longitudinal energy profile,
or depth dose distribution.
The energy deposited (edep) is randomly distributed along the step (see
SteppingAction).
In order to control the accuracy of the deposition, the maximum step size
of charged particles is computed automatically from the binning of
histograms 1 and 8 (see RunAction).
As an example, this limitation is implemented as a 'full' process :
see StepMax class and its Messenger. The 'StepMax process' is registered
in the Physics List.
StepMax is evaluated in RunAction::BeginOfRun() and passed
to the StepMax process.
A boolean UI command allows to deactivate this mechanism.
Another UI command allows to define directly a stepMax value.
7- HISTOGRAMS
Testem12 has several predefined 1D histograms :
1 : energy profile dE/dr (in MeV/mm per event)
2 : total energy deposited in the absorber
3 : total track length of the primary track
4 : step size of the primary track
5 : projected range of the primary track
6 : total track length of charged secondary tracks
7 : step size of charged secondary tracks
8 : normalized energy profile d(E/E0)/d(r/r0), where r0 is the range of
the primary particle of energy E0
The histograms are managed by G4AnalysisManager class and its Messenger.
The histos can be individually activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem12)
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem12)
@@ -0,0 +1,27 @@
------------------
EGSnrc Simulations
------------------
These results were computed with the EGSnrc user code EDKnrc,
developed by E. Mainegra et al.
Yann Perrot (perrot@clermont.in2p3.fr) December 2010
Simulation parameters:
----------------------
Electron Stepping Algorithm : PRESTA-II
Boundary Crossing Algoritm : EXACT with skin parameter=3
Maximum Energy Loss per Step : ESTEPE = 1%
Electron tracking cut : 10keV for E>=1MeV
1keV for E<1MeV
References:
----------
Mainegra et al 2005
Med. Phys. 32, 685-99
Rogers et al 2003
NRC User Codes for EGSnrc
Technical Report PIRS-702(RevB)
National Research Council of Canada
@@ -0,0 +1,84 @@
///\file "electromagnetic/TestEm13/.README.txt"
///\brief Example TestEm13 README page
/*! \page ExampleTestEm13 Example TestEm13
How to compute cross sections from the transmition coefficient
( see below, \ref TestEm13_s4).
\section TestEm13_s1 GEOMETRY DEFINITION
It is a single box representing a layer of finite thickness of
homogeneous material.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default geometry (1 cm of water) is constructed in
DetectorConstruction, but the above parameters can be changed
interactively via the commands defined in DetectorMessenger.
\section TestEm13_s2 PHYSICS LIST
The physics list contains the standard electromagnetic processes.
In order not to introduce 'artificial' constraints on the step size, the
multiple scattering is not instanciated, and all processes are
registered as discrete : there is no continuous energy loss.
\section TestEm13_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the edge
of the box. The type of the particle and its energy are set in
PrimaryGeneratorAction (1 MeV gamma), and can be changed via the G4
build-in commands of G4ParticleGun class (see the macros provided with
this example).
\section TestEm13_s4 PHYSICS
An event is killed at the first step of the incident paticle.
Either the particle has interacted or is transmitted through the layer.
The cross section, also called absorption coefficient, is computed from
the rate of unaltered transmitted incident particles.
The result is compared with the 'input' data, i.e. with the cross
sections stored in the PhysicsTables and used by Geant4.
A set of macros defining various run conditions are provided.
The processes are actived/inactived in order to survey the processes
individually.
\section TestEm13_s6 VISUALIZATION
The Visualization Manager is set in the main () (see TestEm13.cc).
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
\verbatim
> /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the
box.
The tracks are drawn at the end of event, and erased at the end of run.
\section TestEm13_s7- HOW TO START ?
- Execute TestEm13 in 'batch' mode from macro files :
\verbatim
% TestEm13 compt.mac
\endverbatim
- Execute TestEm13 in 'interactive mode' with visualization :
\verbatim
% TestEm13
Idle> control/execute vis.mac
....
Idle> type your commands
....
Idle> exit
\endverbatim
*/
@@ -0,0 +1,79 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm13
--------
How to compute cross sections from the transmition coefficient
( see below, item Physics).
1- GEOMETRY DEFINITION
It is a single box representing a layer of finite thickness of
homogeneous material.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default geometry (1 cm of water) is constructed in
DetectorConstruction, but the above parameters can be changed
interactively via the commands defined in DetectorMessenger.
2- PHYSICS LIST
The physics list contains the standard electromagnetic processes.
In order not to introduce 'artificial' constraints on the step size, the
multiple scattering is not instanciated, and all processes are
registered as discrete : there is no continuous energy loss.
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the edge
of the box. The type of the particle and its energy are set in
PrimaryGeneratorAction (1 MeV gamma), and can be changed via the G4
build-in commands of ParticleGun class (see the macros provided with
this example).
4- PHYSICS
An event is killed at the first step of the incident paticle.
Either the particle has interacted or is transmitted through the layer.
The cross section, also called absorption coefficient, is computed from
the rate of unaltered transmitted incident particles.
The result is compared with the 'input' data, i.e. with the cross
sections stored in the PhysicsTables and used by Geant4.
A set of macros defining various run conditions are provided.
The processes are actived/inactived in order to survey the processes
individually.
6- VISUALIZATION
The Visualization Manager is set in the main().
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
> /control/execute vis.mac
The detector has a default view which is a longitudinal view of the
box.
The tracks are drawn at the end of event, and erased at the end of run.
7- HOW TO START ?
execute TestEm13 in 'batch' mode from macro files :
% TestEm13 compt.mac
execute TestEm13 in 'interactive mode' with visualization :
% TestEm13
Idle> control/execute vis.mac
....
Idle> type your commands
....
Idle> exit
@@ -0,0 +1,132 @@
///\file "electromagnetic/TestEm14/.README.txt"
///\brief Example TestEm14 README page
/*! \page ExampleTestEm14 Example TestEm14
- How to compute cross sections from the direct evaluation of the mean
free path ( see below, \ref TestEm14_s4).
- How to plot final state of a process.
\section TestEm14_s1 GEOMETRY DEFINITION
It is a single box representing a 'semi infinite' homogeneous medium.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default geometry (100 m of water) is constructed in
DetectorConstruction, but the above parameters can be changed
interactively via the commands defined in DetectorMessenger.
\section TestEm14_s2 PHYSICS LIST
The physics list contains the standard electromagnetic processes.
In order not to introduce 'artificial' constraints on the step size, the
multiple scattering is not instanciated, and all processes are
registered as discrete : there is no continuous energy loss.
\section TestEm14_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the edge
of the box. The type of the particle and its energy are set in
PrimaryGeneratorAction (1 MeV gamma), and can be changed via the G4
build-in commands of G4ParticleGun class (see the macros provided with
this example).
\section TestEm14_s4 PHYSICS
An event is killed at the first interaction of the incident paticle.
The absorption length, also called mean free path, is computed as
the mean value of the track length of the incident particle.
This is why the medium must be 'infinite' : to be sure that interaction
occurs at any events.
The result is compared with the 'input' data, i.e. with the cross
sections stored in the PhysicsTables and used by Geant4.
The energy spectrum and the angular distribution of the scattered
particle (if any) and of the created secondaries are plotted (see
SteppingAction).
A set of macros defining various run conditions are provided.
The processes are actived/inactived in order to survey the processes
individually.
\section TestEm14_s5 HISTOGRAMS
The test contains 6 built-in 1D histograms, which are managed by the
HistoManager class and its messenger, HistoMessenger. The histos can be individually
activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, etc..)
(see the macros xxxx.mac).
- 1 : "scattered primary particle: energy spectrum"
- 2 : "scattered primary particle: costheta distribution"
- 3 : "charged secondaries: energy spectrum"
- 4 : "charged secondaries: costheta distribution"
- 5 : "neutral secondaries: energy spectrum"
- 6 : "neutral secondaries: costheta distribution"
The histograms are managed by the HistoManager class and its messenger,
HistoMessenger
The histos can be individually activated with the command :
\verbatim
/analysis/h1/set id nbBins valMin valMax unit
\endverbatim
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem14)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/setAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default testem14)
\subsection TestEm14_sub_s51 Using hbook format
Need a special treatement : the Cern Library must be installed and the
environment variable CERNLIB correctly set. Then, *before* compiling,
activate G4_USE_HBOOK in GNUmakefile and g4hbook.hh in HistoManager.hh
\section TestEm14_s6- VISUALIZATION
The Visualization Manager is set in the main () (see TestEm14.cc).
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
\verbatim
> /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the
box.
The tracks are drawn at the end of event, and erased at the end of run.
\section TestEm14_s7- HOW TO START ?
- Execute TestEm14 in 'batch' mode from macro files :
\verbatim
% TestEm14 compt.mac
\endverbatim
- Execute TestEm14 in 'interactive mode' with visualization :
\verbatim
% TestEm14
Idle> control/execute vis.mac
....
Idle> type your commands
....
Idle> exit
\endverbatim
*/
@@ -0,0 +1,121 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm14
--------
How to compute cross sections from the direct evaluation of the mean
free path ( see below, item Physics).
How to plot final state of a process.
1- GEOMETRY DEFINITION
It is a single box representing a 'semi infinite' homogeneous medium.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default geometry (100 m of water) is constructed in
DetectorConstruction, but the above parameters can be changed
interactively via the commands defined in DetectorMessenger.
2- PHYSICS LIST
The physics list contains the standard electromagnetic processes.
In order not to introduce 'artificial' constraints on the step size, the
multiple scattering is not instanciated, and all processes are
registered as discrete : there is no continuous energy loss.
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the edge
of the box. The type of the particle and its energy are set in
PrimaryGeneratorAction (1 MeV gamma), and can be changed via the G4
build-in commands of ParticleGun class (see the macros provided with
this example).
4- PHYSICS
An event is killed at the first interaction of the incident paticle.
The absorption length, also called mean free path, is computed as
the mean value of the track length of the incident particle.
This is why the medium must be 'infinite' : to be sure that interaction
occurs at any events.
The result is compared with the 'input' data, i.e. with the cross
sections stored in the PhysicsTables and used by Geant4.
The energy spectrum and the angular distribution of the scattered
particle (if any) and of the created secondaries are plotted (see
SteppingAction).
A set of macros defining various run conditions are provided.
The processes are actived/inactived in order to survey the processes
individually.
5- HISTOGRAMS
The test contains 6 built-in 1D histograms, which are managed by the
HistoManager class and its Messenger. The histos can be individually
activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, etc..)
(see the macros xxxx.mac).
1 "scattered primary particle: energy spectrum"
2 "scattered primary particle: costheta distribution"
3 "charged secondaries: energy spectrum"
4 "charged secondaries: costheta distribution"
5 "neutral secondaries: energy spectrum"
6 "neutral secondaries: costheta distribution"
The histograms are managed by the HistoManager class and its Messenger.
The histos can be individually activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem14)
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem14)
Using hbook format
------------------
Need a special treatement : the Cern Library must be installed and the
environment variable CERNLIB correctly set. Then, *before* compiling,
activate G4_USE_HBOOK in GNUmakefile and g4hbook.hh in HistoManager.hh
6- VISUALIZATION
The Visualization Manager is set in the main().
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
> /control/execute vis.mac
The detector has a default view which is a longitudinal view of the
box.
The tracks are drawn at the end of event, and erased at the end of run.
7- HOW TO START ?
execute TestEm14 in 'batch' mode from macro files :
% TestEm14 compt.mac
execute TestEm14 in 'interactive mode' with visualization :
% TestEm14
Idle> control/execute vis.mac
....
Idle> type your commands
....
Idle> exit
@@ -0,0 +1,124 @@
///\file "electromagnetic/TestEm15/.README.txt"
///\brief Example TestEm15 README page
/*! \page ExampleTestEm15 Example TestEm15
How to compute and plot the final state of Multiple Scattering
considered as an isolated process.
The method is exposed below : see \ref TestEm15_s4.
\section TestEm15_s1 GEOMETRY DEFINITION
It is a single box representing a 'semi infinite' homogeneous medium.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default geometry (100 m of water) is constructed in
DetectorConstruction, but the above parameters can be changed
interactively via the commands defined in DetectorMessenger.
\section TestEm15_s2 PHYSICS LIST
The physics list contains the standard electromagnetic processes.
In order not to introduce 'articicial' constraints on the step size,
there is no limitation from the maximum energy lost per step.
\section TestEm15_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the edge
of the box. The type of the particle and its energy are set in
PrimaryGeneratorAction (1 MeV electron), and can be changed via the G4
build-in commands of G4ParticleGun class (see the macros provided with
this example).
\section TestEm15_s4 PHYSICS
All discrete processes are inactivated (see provided macros),
so that Multiple Scattering is 'forced' to determine the first step of
the primary particle. The step size and the final state are computed
and plotted. Then the event is immediately killed.
The result is compared with the 'input' data, i.e. with the cross
sections stored in the PhysicsTables and used by Geant4.
The stepMax command provides an additionnal control of the step size of
the multiple scattering.
\section TestEm15_s5 HISTOGRAMS
The test contains 9 built-in 1D histograms, which are managed by the
HistoManager class and its Messenger. The histos can be individually
activated with the command :
\verbatim
/analysis/h1/set id nbBins valMin valMax unit
\endverbatim
where unit is the desired unit for the histo (MeV or keV, etc..)
(see the macros xxxx.mac).
- 1 : Multiple Scattering. True step length
- 2 : Multiple Scattering. Geom step length
- 3 : Multiple Scattering. Ratio geomSl/trueSl
- 4 : Multiple Scattering. Lateral displacement: radius
- 5 : Multiple Scattering. Lateral displac: psi_space
- 6 : Multiple Scattering. Angular distrib: theta_plane
- 7 : Multiple Scattering. Phi-position angle
- 8 : Multiple Scattering. Phi-direction angle
- 9 : Multiple Scattering. Correlation: cos(phiPos-phiDir)
The histograms are managed by the HistoManager class and its Messenger.
The histos can be individually activated with the command :
\verbatim
/analysis/h1/set id nbBins valMin valMax unit
\endverbatim
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem15)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/setAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default testem15)
\section TestEm15_s6 VISUALIZATION
The Visualization Manager is set in the main () (see TestEm15.cc).
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
\verbatim
> /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the
box.
The tracks are drawn at the end of event, and erased at the end of run.
\section TestEm15_s7- HOW TO START ?
- Execute TestEm15 in 'batch' mode from macro files :
\verbatim
% TestEm15 compt.mac
\endverbatim
- Execute TestEm15 in 'interactive mode' with visualization :
\verbatim
% TestEm15
Idle> control/execute vis.mac
....
Idle> type your commands
....
Idle> exit
\endverbatim
*/
@@ -0,0 +1,128 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm15
--------
How to compute and plot the final state of Multiple Scattering
or Gamma Conversion considered as an isolated processes.
The method is exposed below : see item Physics.
1- GEOMETRY DEFINITION
It is a single box representing a 'semi infinite' homogeneous medium.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default geometry (100 m of water) is constructed in
DetectorConstruction, but the above parameters can be changed
interactively via the commands defined in DetectorMessenger.
2- PHYSICS LIST
The physics list contains the standard electromagnetic processes.
In order not to introduce 'artificial' constraints on the step size,
there is no limitation from the maximum energy lost per step.
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the edge
of the box. The type of the particle and its energy are set in
PrimaryGeneratorAction (1 MeV electron), and can be changed via the G4
build-in commands of ParticleGun class (see the macros provided with
this example).
4- PHYSICS
All discrete processes are inactivated (see provided macros),
so that Multiple Scattering or Gamma Conversion is 'forced' to
determine the first step of the primary particle.
The step size and the final state are computed and plotted.
Then the event is immediately killed.
The result is compared with the 'input' data, i.e. with the cross
sections stored in the PhysicsTables and used by Geant4.
The stepMax command provides an additional control of the step size of
the multiple scattering.
5- HISTOGRAMS
The test contains 16 built-in 1D histograms, which are managed by
G4AnalysisManager and its Messenger. The histos can be individually
activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, etc..)
(see the macros xxxx.mac).
1 Multiple Scattering. True step length
2 Multiple Scattering. Geom step length
3 Multiple Scattering. Ratio geomSl/trueSl
4 Multiple Scattering. Lateral displacement: radius
5 Multiple Scattering. Lateral displac: psi_space
6 Multiple Scattering. Angular distrib: theta_plane
7 Multiple Scattering. Phi-position angle
8 Multiple Scattering. Phi-direction angle
9 Multiple Scattering. Correlation: cos(phiPos-phiDir)
10 Gamma Conversion. Open Angle * Egamma
11 Gamma Conversion. Log10(P recoil)
12 Gamma Conversion. Phi P recoil angle
13 Gamma Conversion. Phi P plus angle
14 Gamma Conversion. 2 * cos(phiplus + phiminus) Asymmetry
15 Gamma Conversion. E plus / E gamma
16 Gamma Conversion. Phi of Gamma Polarization
The histograms are managed by the HistoManager class and its Messenger.
The histos can be individually activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem15)
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem15)
6- VISUALIZATION
The Visualization Manager is set in the main().
The initialization of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualization:
> /control/execute vis.mac
The detector has a default view which is a longitudinal view of the
box.
The tracks are drawn at the end of event, and erased at the end of run.
7- HOW TO START ?
execute TestEm15 in 'batch' mode from macro files :
% TestEm15 compt.mac
execute TestEm15 in 'interactive mode' with visualization :
% TestEm15
Idle> control/execute vis.mac
....
Idle> type your commands
....
Idle> exit
8 - MACROS
The examples of macros for Multiple Scattering:
electron.mac muon.mac proton.mac
The example of Gamma Conversion macro :
gamma.mac - gamma to e+ e-
gamma2mumu.mac gamma to mu+ mu-
@@ -0,0 +1,48 @@
TestEm15 : gamma.mac
-- tests of the 5D gamma -> e+e- conversion model G4BetheHeitler5DModel
All discrete processes are inactivated (see macro),
so Gamma Conversion is 'forced'.
Histograms :
10 # Open Angle (rad)* E gamma (MeV)
The most probable value of the pair opening angle multiplied by the
photon energy is 1.6 rad*MeV.
Olsen, Phys. Rev. 131 (1963) 406. See also Fig. 7 of arXiv:1802.08253
11 # Log10 ( recoil momentum)
The distribution of the recoil momentum is described by
Jost, Phys. Rev. 80 (1950) 189 (no form factor).
See also Fig. 2 of Astroparticle Physics 88 (2017) 60.
12 # Phi recoil
13 # Phi positron
14 # Asymmetry 2 * cos(phi_+ + phi_-)
For a photon propagating along x, polarized along y, the average value of
2 * cos(phi_+ + phi_-),
provides a measurement of the polarization asymmetry, A.
Eq. (12) of Nucl. Instrum. Meth. A 729 (2013) 765
The azimuthal angle of the event defined as the bisector angle
of the azimuthal angles of the positron and of the electron,
(phi_+ + phi_-)/2,
provides the optimal measurement of the asymmetry
Astroparticle Physics 88 (2017) 30.
For high-energy photons (E >> 20 MeV), the asymptotic expression for A
can be used for comparison.
Boldyshev, Yad. Fiz. 14 (1971) 1027, Sov.J.Nucl.Phys. 14 (1972) 576.
See also eq. (13) of arXiv:1802.08253
Example : A ~ 0.17 at 100 GeV.
15 # E plus / E gamma
x_+ = E plus / E gamma has a more-or-less flat spectrum that extends
almost from 0. to 1.
See Fig. 16 page 261 of "The Quantum Theory of Radiation", W. Heitler,
3rd edition, 1954.
16 # Phi of Gamma Polarization
The phi of polarization vector after transformation into reference system
defined by gamma direction (z) , gamma polarization (x).
@@ -0,0 +1,143 @@
///\file "electromagnetic/TestEm16/.README.txt"
///\brief Example TestEm16 README page
/*! \page ExampleTestEm16 Example TestEm16
Simulate synchrotron radiation
\section TestEm16_s1 GEOMETRY DEFINITION
The geometry consists of a single block of a homogenous material.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default is 500 m of vacuum.
A transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be changed interactively via
the commands defined in the DetectorMessenger class.
\section TestEm16_s2 PHYSICS LIST
The particle list is the one of novice/exampleN03 and
<a href="../../html_TestEm6/html/ExampleTestEm6.html"> TestEm6 </a>
with in addition synchrotron radiation.
To make the synchrotron radiation easily visible, a very low
pressure "vaccuum" and a magnetic field of by default 1 Tesla
in z-direction is used.
\section TestEm16_s3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
block perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
The default is an positron of 10 GeV.
In addition one can choose randomly the impact point of the incident
particle. The corresponding interactive command is built in
PrimaryGeneratorMessenger class.
A RUN is a set of events.
\section TestEm16_s4 VISUALIZATION
The Visualization Manager is set in the main () (see TestEm16.cc).
The initialisation of the drawing is done via the command
\verbatim
> /control/execute vis.mac
> /run/beamOn 1
\endverbatim
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
Optionaly one can choose to draw all particles, only the charged one,
or none. This command is defined in EventActionMessenger class.
\section TestEm16_s5 PHYSICS DEMO
The particle's type and the physic processes which will be available
in this example are set in PhysicsList class.
In addition a build-in interactive command (/process/inactivate proname)
allows to activate/inactivate the processes one by one.
The threshold for producing secondaries can be changed.
eg:
\verbatim
/run/particle/setCut 100 micrometer
/run/initialize
\endverbatim
To visualize the Synchrotron radiation :
\verbatim
/control/execute vis.mac
\endverbatim
\section TestEm16_s6- HOW TO START ?
- Execute Test in 'batch' mode from macro files
\verbatim
% TestEm16 run01.mac
\endverbatim
- Execute Test in 'interactive mode' with visualization
\verbatim
% TestEm16
....
Idle> type your commands
....
Idle> exit
\endverbatim
\section TestEm16_s7 TRACKING : stepMax and setMaxStepLength
In order to control the accuracy of the deposition, the user can limit
'by hand' the maximum step size stepMax of charged particles.
The maximum tracking step length for computing of magnetic field lines
is by default set to 1 km.
Synchrotron radiation in very weak magnetic fields of the order of 1 Gauss
may require longer pathlength.
This can be achieved with using setMaxStepLength like
\verbatim
/testem/tracking/setMaxStepLength 100 km
\endverbatim
\section TestEm16_s8 HISTOGRAMS
TestEm16 produces 3 histograms which illustrate synchrotron radiation.
The photon energy spectrum (photons / energy bin) and the power spectrum
(photon spectrum weighted with the photon energy) and a histogram
of the path length between photon radiation is produced.
The histograms are managed by G4AnalysisManager and its messenger,
HistoMessenger.
The histos can be activated individually with the command :
\verbatim
/analysis/h1/set id nbBins valMin valMax unit
\endverbatim
where 'unit' is the desired unit for the histo (MeV or KeV, cm or mm, etc..)
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem16)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/setAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default testem16)
*/
@@ -0,0 +1,124 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm16
--------
Simulate synchrotron radiation
1- GEOMETRY DEFINITION
The geometry consists of a single block of a homogenous material.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default is 500 m of vacuum.
A transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be changed interactively via
the commands defined in the DetectorMessenger class.
2- PHYSICS LIST
The particle list include EM processes for gamma, e+, e-, mu+, mu-,
and protons, for the rest of particles only transportation.
Synchrotron radiation is added to all charged particles.
To make the synchrotron radiation easily visible, a very low
pressure "vaccuum" and a magnetic field of by default 1 Tesla
in z-direction is used.
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
block perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
changed via the G4 build-in commands of ParticleGun class (see
the macros provided with this example).
The default is an positron of 10 GeV.
In addition one can choose randomly the impact point of the incident
particle. The corresponding interactive command is built in
PrimaryGeneratorMessenger class.
A RUN is a set of events.
4- VISUALIZATION
The Visualization Manager is set in the main().
The initialisation of the drawing is done via the command
> /control/execute vis.mac
> /run/beamOn 1
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
Optionaly one can choose to draw all particles, only the charged one,
or none. This command is defined in EventActionMessenger class.
5- PHYSICS DEMO
The particle's type and the physic processes which will be available
in this example are set in PhysicsList class.
In addition a build-in interactive command (/process/inactivate proname)
allows to activate/inactivate the processes one by one.
The threshold for producing secondaries can be changed.
eg: /run/setCut 100 micrometer
/run/initialize
To visualize the Synchrotron radiation :
/control/execute vis.mac
6- HOW TO START ?
- execute Test in 'batch' mode from macro files
% TestEm16 run01.mac
- execute Test in 'interactive mode' with visualization
% TestEm16
....
Idle> type your commands
....
Idle> exit
7 - TRACKING : stepMax and setMaxStepLength
In order to control the accuracy of the deposition, the user can limit
'by hand' the maximum step size stepMax of charged particles.
The maximum tracking step length for computing of magnetic field lines
is by default set to 1 km.
Synchrotron radiation in very weak magnetic fields of the order of 1 Gauss
may require longer pathlength.
This can be achieved with using setMaxStepLength like
/testem/tracking/setMaxStepLength 100 km
8- HISTOGRAMS
TestEm16 produces 3 histograms which illustrate synchrotron radiation.
The photon energy spectrum (photons / energy bin) and the power spectrum
(photon spectrum weighted with the photon energy) and a histogram
of the path length between photon radiation is produced.
The histograms are managed by G4AnalysisManager and its Messenger.
The histos can be activated individually with the command :
/analysis/h1/set id nbBins valMin valMax unit
where 'unit' is the desired unit for the histo (MeV or KeV, cm or mm, etc..)
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem16)
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem16)
@@ -0,0 +1,118 @@
///\file "electromagnetic/TestEm17/.README.txt"
///\brief Example TestEm17 README page
/*! \page ExampleTestEm17 Example TestEm17
This example is intended to check implementation of the processes
of muon interactions: ionization, direct (e+,e-) production,
bremsstrahlung, mu-nuclear interaction.
It allows to compute differential cross sections (as function of the
energy transfered to secondaries), total cross sections and to compare
with analytic calculations.
\section TestEm17_s1 GEOMETRY DEFINITION
It is a single box of homogeneous medium.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default geometry (1 m of Iron) is constructed in
DetectorConstruction, but the above parameters can be changed
interactively via the commands defined in DetectorMessenger.
\section TestEm17_s2 PHYSICS LIST
The Physics List of the example uses the main local physics constructor
(builder) which called "standard". In this builder a limited set
of physics processes are defined for muons, pions and proton:
ionisation, bremsstrahlung and e+e- pair production. Energy range
for these processes is from 100*eV to 1000*PeV.
Optionally "muNucl" builder, MuNuclearBuilder, may be added activating muon-nuclear
inelastic interaction.
\section TestEm17_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the edge
of the box. The type of the particle and its energy are set in
PrimaryGeneratorAction (mu+ 10 TeV), and can be changed via the G4
build-in commands of ParticleGun class (see the macros provided with
this example).
\section TestEm17_s4 PHYSICS
The incident particle is a muon. During the tracking, secondary
particles are killed.
The number of interactions are plotted as a function of the energy
transfered to the secondaries.
The total number of interactions is recorded, and the total cross section
computed from this.
At RunAction::EndOfRunAction(), the above results are compared with analytic calculations.
The functions which compute the theoretical cross sections have been
provided by the G4 MEPhI group, and grouped in MuCrossSections class.
\section TestEm17_s5 HISTOGRAMS
The test contains 4 built-in 1D histograms, which are managed by the
HistoManager class and its Messenger, HistoMessenger.
- 1 Monte-Carlo relative transferred energy distribution histo
(log10(eps/Emu kin) for knock-on electrons (ionization)
- 2 ... direct (e+,e-) pair production
- 3 ... bremsstrahlung
- 4 ... nuclear interaction
The histos can be activated individually with the command :
\verbatim
/testem/histo/setHisto id nbBins valMin valMax
\endverbatim
min and max values of log10(eps/Emu kin).
At RunAction::EndOfRunAction() the corresponding histos for analytic calculations are
automatically created and filled (histo 11 to 14).
One can control the name and the type of the histograms file with
the command:
\verbatim
/testem/histo/setFileName name (default testem17)
\endverbatim
It is possible to choose the format of the histogram file :
root (default), xml, csv, by using namespace in HistoManager.hh
\section TestEm17_s6- VISUALIZATION
The Visualization Manager is set in the main () (see TestEm17.cc).
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
\verbatim
> /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the
box.
The tracks are drawn at the end of event, and erased at the end of run.
\section TestEm17_s7- HOW TO START ?
- Execute TestEm17 in 'batch' mode from macro files :
\verbatim
% TestEm17 allproc.mac
\endverbatim
- Execute TestEm17 in 'interactive mode' with visualization :
\verbatim
% TestEm17
Idle> control/execute vis.mac
....
Idle> type your commands
....
Idle> exit
\endverbatim
*/
@@ -0,0 +1,112 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm17
--------
This example is intended to check implementation of the processes
of muon interactions: ionization, direct (e+,e-) production,
bremsstrahlung, mu-nuclear interaction.
It allows to compute differential cross sections (as function of the
energy transfered to secondaries), total cross sections and to compare
with analytic calculations.
1- GEOMETRY DEFINITION
It is a single box of homogeneous medium.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default geometry (1 m of Iron) is constructed in
DetectorConstruction, but the above parameters can be changed
interactively via the commands defined in DetectorMessenger.
2- PHYSICS LIST
The Physics List of the example uses the main physics constructor
(builder) called "emstandard_opt0". As an alternative "local"
constructor is provided in which only a limited set
of physics processes are defined for muons, pions and proton:
ionisation, bremsstrahlung and e+e- pair production.
Default energy range for EM processes in this example
is from 100*eV to 1000*PeV.
Optionally "muNucl" builder may be added activating muon-nuclear
inelastic interaction.
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle starting at the edge
of the box. The type of the particle and its energy are set in
PrimaryGeneratorAction (mu+ 10 TeV), and can be changed via the G4
build-in commands of ParticleGun class (see the macros provided with
this example).
4- PHYSICS
The incident particle is a muon. During the tracking, secondary
particles are killed.
The number of interactions are plotted as a function of the energy
transfered to the secondaries.
The total number of interactions is recorded, and the total cross
section computed from this.
At EndOfRun, the above results are compared with analytic calculations.
The functions which compute the theoretical cross sections have been
provided by the G4 MEPhI group, and grouped in MuCrossSections class.
5- HISTOGRAMS
The test contains built-in 1D histograms for muons filled during
Monte Carlo simulation, which are managed by the HistoManager class
and its Messenger:
1 Relative muon transferred energy distribution
(log10(eps/Emu kin) for knock-on electrons (ionization)
2 -"- direct (e+,e-) pair production by muons
3 -"- bremsstrahlung by muons
4 -"- nuclear interaction by muons
5 ionistion for hadrons
6 (e+,e-) pair production by hadrons
7 bremsstrahlung by hadrons
The histos can be activated individually with the command :
/testem/histo/setHisto id nbBins valMin valMax :
min and max values of log10(eps/Emu kin).
At EndOfRun the corresponding histos for analytic calculations are
automatically created and filled (histo 11 to 14).
One can control the name and the type of the histograms file with
the command:
/testem/histo/setFileName name (default testem17)
6- VISUALIZATION
The Visualization Manager is set in the main().
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
> /control/execute vis.mac
The detector has a default view which is a longitudinal view of the
box.
The tracks are drawn at the end of event, and erased at the end of run.
7- HOW TO START ?
execute TestEm17 in 'batch' mode from macro files :
% TestEm17 allproc.mac
execute TestEm17 in 'interactive mode' with visualization :
% TestEm17
Idle> control/execute vis.mac
....
Idle> type your commands
....
Idle> exit
@@ -0,0 +1,135 @@
///\file "electromagnetic/TestEm18/.README.txt"
///\brief Example TestEm18 README page
/*! \page ExampleTestEm18 Example TestEm18
This example allows to study the various contributions of the energy lost
by a charged particle in a single layer of an homogeneous material.
See any textbook of interactions of charged particles with matter, in particular :
1- geant4.web.cern.ch --> UserSupport --> Physics Reference Manual
2- lappweb.in2p3.fr/~maire/tutorials/index.html
\section TestEm18_s1 GEOMETRY DEFINITION
It is a simple cubic box of homogeneous material.
Two parameters define the geometry :
- the material of the box,
- the thickness of the box.
The default geometry (1 cm of water) is constructed in DetectorConstruction,
but the above parameters can be changed interactively via the commands
defined in DetectorMessenger.
\section TestEm18_s2 PHYSICS
The physics list, PhysicsList, contains the 'standard' electromagnetic processes.
However the MultipleScattering is not registered, in order to focuse on
fluctuations of to energy loss alone.
\section TestEm18_s3 BEAM
The primary kinematic is a single particle starting at the edge
of the box. The type of the particle and its energy are set in
PrimaryGeneratorAction (e- 10 MeV), and can be changed via the G4
build-in commands of G4ParticleGun class.
\section TestEm18_s4 RUN
During the tracking of the incident particle, by default, the secondary
particles are immediately killed, after that their energy has been registered
(see SteppingAction and StackingAction).
Therefore, we study here the various components of the total energy lost
by the incident particle, not the energy deposited in a layer of finite
thickness.
With the option /testEm/trackSecondaries one can compute and plot the energy
deposited in the layer. See edep.mac
At EndOfRun, the above results are compared with 'reference' values,
i.e. the input data read from EnergyLoss and Range tables.
See reference 2 : Energy-Range relation, slide 4.
\section TestEm18_s5 HISTOGRAMS
The test contains 13 built-in 1D histograms, which are managed by
G4AnalysisManager and its messenger.
1 step size of primary track
2 energy locally deposited along primary track
3 energy transfered to secondaries by ionisation
4 energy transfered to secondaries by Bremsstrahlung
5 energy transfered to secondaries by (e+,e-) production
6 total energy transfered to secondaries
7 total energy lost by primary track
8 total energy lost by primary track from energy balance
9 energy continuously deposited along secondary tracks
10 total energy deposited
11 energy spectrum of gamma
12 energy spectrum of e-
13 energy spectrum of e+
The histograms are defined in HistoManager.
The histos can be activated individually with the command :
\verbatim
/analysis/h1/set id nbBins valMin valMax unit
\endverbatim
where 'unit' is the desired unit for the histo (MeV or KeV, cm or mm, etc..)
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem18)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
For convenience, few simple Root macros are provided : plotHisto.C pixe.C
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/sweAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default testem18)
\section TestEm18_s6 VISUALIZATION
The Visualization Manager is set in the main () (see TestEm18.cc).
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
\verbatim
> /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
\section TestEm18_s7 HOW TO START ?
- Execute TestEm18 in 'batch' mode from macro files :
\verbatim
% TestEm18 electron.mac
\endverbatim
- Execute TestEm18 in 'interactive mode' with visualization :
\verbatim
% TestEm18
Idle> control/execute vis.mac
....
Idle> type your commands
....
Idle> exit
\endverbatim
Macros provided in this example:
- csda.mac: test independance of user step max
- edep.mac: track secondary particles and plot energy deposited
- electron.mac: e- (10 MeV) on 1 cm of water
- ion.mac: ion C12 (4 GeV) on 1 cm of water
- muon.mac: mu+ (1 TeV) on 1 m of water
- pixe.mac: proton (20 MeV) on 50 um of gold. Plot gamma pixe
- proton.mac: proton (1 GeV) on 10 cm of water
- plotHisto.C, pixe.C: Root macros
Macros to be run interactively:
- vis.mac: To activate visualization
*/
@@ -0,0 +1,123 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm18
--------
This example allows to study the various contributions of the energy lost
by a charged particle in a single layer of an homogeneous material.
See any textbook of interactions of charged particles with matter, in particular :
1- geant4.web.cern.ch --> UserSupport --> Physics Reference Manual
2- lappweb.in2p3.fr/~maire/tutorials/index.html
1- GEOMETRY DEFINITION
It is a simple cubic box of homogeneous material.
Two parameters define the geometry :
- the material of the box,
- the thickness of the box.
The default geometry (1 cm of water) is constructed in DetectorConstruction,
but the above parameters can be changed interactively via the commands
defined in DetectorMessenger.
2- PHYSICS
The physics list contains the 'standard' electromagnetic processes.
However the MultipleScattering is not registered, in order to focuse on
fluctuations of to energy loss alone.
3- BEAM
The primary kinematic is a single particle starting at the edge
of the box. The type of the particle and its energy are set in
PrimaryGeneratorAction (e- 10 MeV), and can be changed via the G4
build-in commands of ParticleGun class.
4- RUN
During the tracking of the incident particle, by default, the secondary
particles are immediately killed, after that their energy has been registered
(see SteppingAction and StackingAction).
Therefore, we study here the various components of the total energy lost
by the incident particle, not the energy deposited in a layer of finite
thickness.
With the option /testEm/trackSecondaries one can compute and plot the energy
deposited in the layer. See edep.mac
At EndOfRun, the above results are compared with 'reference' values,
i.e. the input data read from EnergyLoss and Range tables.
See reference 2 : Energy-Range relation, slide 4.
5- HISTOGRAMS
The test contains 13 built-in 1D histograms, which are managed by
G4AnalysisManager and its Messenger.
1 step size of primary track
2 energy continuously deposited along primary track
3 energy transfered to secondaries by ionisation
4 energy transfered to secondaries by Bremsstrahlung
5 energy transfered to secondaries by (e+,e-) production
6 total energy transfered to secondaries
7 total energy lost by primary track
8 total energy lost by primary track from energy balance
9 energy continuously deposited along secondary tracks
10 total energy deposited
11 energy spectrum of gamma
12 energy spectrum of e-
13 energy spectrum of e+
The histograms are defined in HistoManager.
The histos can be activated individually with the command :
/analysis/h1/set id nbBins valMin valMax unit
where 'unit' is the desired unit for the histo (MeV or KeV, cm or mm, etc..)
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem18)
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
For convenience, few simple Root macros are provided : plotHisto.C pixe.C
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem18)
6- VISUALIZATION
The Visualization Manager is set in the main().
The initialisation of the drawing is done via the commands
/vis/... in the macro vis.mac. To get visualisation:
> /control/execute vis.mac
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
7- HOW TO START ?
execute TestEm18 in 'batch' mode from macro files :
% TestEm18 electron.mac
execute TestEm18 in 'interactive mode' with visualization :
% TestEm18
Idle> control/execute vis.mac
....
Idle> type your commands
....
Idle> exit
Macros provided in this example:
- csda.mac: test independance of user step max
- edep.mac: track secondary particles and plot energy deposited
- electron.mac: e- (10 MeV) on 1 cm of water
- ion.mac: ion C12 (4 GeV) on 1 cm of water
- muon.mac: mu+ (1 TeV) on 1 m of water
- pixe.mac: proton (20 MeV) on 50 um of gold. Plot gamma pixe
- proton.mac: proton (1 GeV) on 10 cm of water
- plotHisto.C, pixe.C: Root macros
Macros to be run interactively:
- vis.mac: To activate visualization
@@ -0,0 +1,171 @@
///\file "electromagnetic/TestEm2/.README.txt"
///\brief Example TestEm2 README page
/*! \page ExampleTestEm2 Example TestEm2
How to do shower profiles in an homogenous medium, with virtual
voxelisation.
\section TestEm2_s1 GEOMETRY DEFINITION
The geometry consists of a cylinder of homogenous material.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be modified interactively via
the commands defined in the DetectorMessenger class.
Material can be choosen: Air Water lAr Al Fe BGO PbWO4 Pb.
eg:
\verbatim
/testem/det/setMat PbWO4
\endverbatim
The cylinder is virtually sliced longitudinally (slice) and radially
(ring). The size of the slices and rings are expressed in radiation
length units and can be changed.
eg:
\verbatim
/testem/det/setLbin 20 1. ---> 20 slices of 1. radl
/testem/det/setRbin 5 0.25 ---> 5 rings of 0.25 radl
/testem/det/update ---> rebuild the geometry
\endverbatim
(MaxBin = 500 in both directions)
An uniform magnetic field along the cylinder axis can be set.
eg:
\verbatim
/testem/det/setField 5 tesla
\endverbatim
\section TestEm2_s2 PHYSICS LISTS
Physics lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
EM physics builders can be local (eg. in this example) or from G4 kernel
physics_lists subdirectory.
Local physics builders:
- "local" standard EM physics with current 'best' options setting.
these options are explicited in PhysListEmStandard
From geant4/source/physics_lists/builders:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
Physics lists and options can be (re)set with UI commands
\section TestEm2_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
cylinder perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
A RUN is a set of events.
\section TestEm2_s4 VISUALIZATION
The Visualization Manager is set in the main() (see TestEm2.cc).
The initialisation of the drawing is done via the commands
/vis/.. in the macro vis.mac. In interactive session:
\verbatim
PreInit or Idle > /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the
cylinder.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged one,
or none. This command is defined in EventActionMessenger class.
\section TestEm2_s5 PHYSICS DEMO
The particle's type and the physics processes which will be available
in this example are set in PhysicsList class.
In addition a build-in interactive command (/process/inactivate procname)
allows to activate/inactivate the processes one by one.
The threshold for producing secondaries can be changed.
eg:
\verbatim
/testem/phys/setCuts 100 microm
/run/initialize
\endverbatim
The shower profiles are histogramed, if histograming is activated.
They can be also printed with the command /testem/run/verbose 1
\section TestEm2_s6 HOW TO START ?
- Execute TestEm2 in 'batch' mode from macro files
\verbatim
% TestEm2 run01.mac
\endverbatim
- Execute TestEm2 in 'interactive mode' with visualization
\verbatim
% TestEm2
....
Idle> type your commands
....
Idle> exit
\endverbatim
Macros provided in this example:
- egs4.mac:
Fe; L = 20 radl; R = 5 radl; electron 30 GeV
(EGS4 simulation: Particle Data Group - Phys.Rev.D 50-3 - August94)
- run01.mac: PbWO4; L = 20 radl; R = 5 radl; electron 5 GeV
- run02.mac: Al; L = 13.5 radl; R = 1.35 radl; electron 1 GeV
(Electron-induced cascade showers: J&H Crannel - Phys. Rev. 184-2 - August69)
- run03.mac: H2O; L = 9.97 radl; R = 0.665 radl; electron 1 GeV
(Electron-induced cascade showers: J&H Crannel - Phys. Rev. 184-2 - August69)
- test.mac: PbWO4; L = 20 radl; R = 5 radl; electron 5 GeV
- vis.mac: to activate visualization
\section TestEm2_s7 HISTOGRAMS
TestEm2 produces several histograms:
Content of these histo:
- 1 : energy deposit per event
- 2 : charged track length per event
- 3 : neutral track length per event
- 4 : longitudinal energy profile
- 5 : rms of longitudinal energy profile
- 6 : cumulated longitudinal energy profile
- 7 : rms of cumulated longitudinal energy profile
- 8 : radial energy profile
- 9 : rms of radial energy profile
- 10 : cumulated radial energy profile
- 11 : rms of cumulated radial energy profile
To define the output file name with histograms, use the UI command :
\verbatim
/analysis/setFileName name
\endverbatim
The format of the histogram file can be : root (default),
xml, csv, by selecting g4nnn.hh in RunAction.hh
*/
@@ -0,0 +1,161 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm2
-------
How to do shower profiles in an homogenous medium, with virtual
voxelisation.
1- GEOMETRY DEFINITION
The geometry consists of a cylinder of homogenous material.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be modified interactively via
the commands defined in the DetectorMessenger class.
Material can be choosen: Air Water lAr Al Fe BGO PbWO4 Pb.
eg: /testem/det/setMat PbWO4
The cylinder is virtually sliced longitudinally (slice) and radially
(ring). The size of the slices and rings are expressed in radiation
length units and can be changed.
eg: /testem/det/setLbin 20 1. ---> 20 slices of 1. radl
/testem/det/setRbin 5 0.25 ---> 5 rings of 0.25 radl
/testem/det/update ---> rebuild the geometry
(MaxBin = 500 in both directions)
An uniform magnetic field along the cylinder axis can be set.
eg: /globalField/setValue 0 0 5 tesla
2- PHYSICS LISTS
Physics lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
EM physics builders can be local (eg. in this example) or from G4 kernel
physics_lists subdirectory.
Local physics builders:
- "local" standard EM physics with current 'best' options setting.
these options are explicited in PhysListEmStandard
From geant4/source/physics_lists/builders:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
Physics lists and options can be (re)set with UI commands
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
cylinder perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
A RUN is a set of events.
4- VISUALIZATION
The Visualization Manager is set in the main() (see TestEm2.cc).
The initialisation of the drawing is done via the commands
/vis/.. in the macro vis.mac. In interactive session:
PreInit or Idle > /control/execute vis.mac
The detector has a default view which is a longitudinal view of the
cylinder.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged one,
or none. This command is defined in EventActionMessenger class.
5- PHYSICS DEMO
The particle's type and the physics processes which will be available
in this example are set in PhysicsList class.
In addition a build-in interactive command (/process/inactivate procname)
allows to activate/inactivate the processes one by one.
The threshold for producing secondaries can be changed.
eg: /testem/phys/setCuts 100 microm
/run/initialize
The shower profiles are histogramed, if histograming is activated.
They can be also printed with the command /testem/run/verbose 1
6- HOW TO START ?
- Execute TestEm2 in 'batch' mode from macro files
% TestEm2 run01.mac
- Execute TestEm2 in 'batch' mode using multi-threading
% TestEm2 run01.mac 4
here 4 is number of threads, it should be user defined,
optimal value depends on hardware
- Execute TestEm2 in 'interactive mode' with visualization
% TestEm2
....
Idle> type your commands
....
Idle> exit
Macros provided in this example:
- egs4.mac:
Fe; L = 20 radl; R = 5 radl; electron 30 GeV
(EGS4 simulation: Particle Data Group - Phys.Rev.D 50-3 - August94)
- run01.mac: PbWO4; L = 20 radl; R = 5 radl; electron 5 GeV
- run02.mac: Al; L = 13.5 radl; R = 1.35 radl; electron 1 GeV
(Electron-induced cascade showers: J&H Crannel - Phys. Rev. 184-2 - August69)
- run03.mac: H2O; L = 9.97 radl; R = 0.665 radl; electron 1 GeV
(Electron-induced cascade showers: J&H Crannel - Phys. Rev. 184-2 - August69)
- test.mac: PbWO4; L = 20 radl; R = 5 radl; electron 5 GeV
- vis.mac: to activate visualization
7- HISTOGRAMS
TestEm2 produces several histograms:
Content of these histo:
1 : energy deposit per event
2 : charged track length per event
3 : neutral track length per event
4 : longitudinal energy profile
5 : rms of longitudinal energy profile
6 : cumulated longitudinal energy profile
7 : rms of cumulated longitudinal energy profile
8 : radial energy profile
9 : rms of radial energy profile
10 : cumulated radial energy profile
11 : rms of cumulated radial energy profile
To define the output file name with histograms, use the UI command :
"/analysis/setFileName name"
The format of the histogram file can be : root (default),
xml, csv, by selecting g4nnn.hh in RunAction.hh
@@ -0,0 +1,209 @@
///\file "electromagnetic/TestEm3/.README.txt"
///\brief Example TestEm3 README page
/*! \page ExampleTestEm3 Example TestEm3
- How to collect energy deposition in a sampling calorimeter.
- How to survey energy flow.
- How to print stopping power.
\section TestEm3_s1 GEOMETRY DEFINITION
The calorimeter is a box made of a given number of layers.
A layer consists of a sequence of various absorbers (maximum MaxAbsor=9).
The layer is replicated.
Parameters defining the calorimeter :
- the number of layers,
- the number of absorbers within a layer,
- the material of the absorbers,
- the thickness of the absorbers,
- the transverse size of the calorimeter (the input face is a square).
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class, but all
of the above parameters can be modified interactively via the commands
defined in the DetectorMessenger class.
<pre>
|<----layer 0---------->|<----layer 1---------->|<----layer 2---------->|
| | | | |
==========================================================================
|| | || | || | ||
|| | || | || | ||
|| abs 1 | abs 2 || abs 1 | abs 2 || abs 1 | abs 2 ||
|| | || | || | ||
|| | || | || | ||
beam || | || | || | ||
======> || | || | || | ||
|| | || | || | ||
|| | || | || | ||
|| | || | || | ||
|| | || | || | ||
|| cell 1 | cell 2 || cell 3 | cell 4 || cell 5 | cell 6 ||
==========================================================================
^ ^ ^ ^ ^ ^ ^
pln1 pln2 pln3 pln4 pln5 pln6 pln7
</pre>
NB. The number of absorbers and the number of layers can be set to 1.
In this case we have a unique homogeneous block of matter, which looks like
a bubble chamber rather than a calorimeter ...
(see the macro emtutor.mac)
\section TestEm3_s2 PHYSICS LISTS
Physics lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
EM physics builders can be local (eg. in this example) or from G4 kernel
physics_lists subdirectory.
Local physics builders:
- "local" standard EM physics with current 'best' options setting.
these options are explicited in PhysListEmStandard
From geant4/source/physics_lists/builders:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
Physics lists and options can be (re)set with UI commands.
\section TestEm3_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the calorimeter
perpendicular to the input face. The type of the particle and its energy are
set in the PrimaryGeneratorAction class, and can be changed via the
G4 build-in commands of G4ParticleGun class (see the macros provided with this
example).
In addition one can choose randomly the impact point of the incident particle.
The corresponding interactive command is built in PrimaryGeneratorMessenger.
A RUN is a set of events.
TestEm3 computes the energy deposited per absorber and the energy flow through
the calorimeter.
\section TestEm3_s4 VISUALIZATION
The Visualization Manager is set in the main() (see TestEm3.cc).
The initialisation of the drawing is done via the commands :
/vis/... in the macro vis.mac. In interactive session:
\verbatim
PreInit or Idle > /control/execute vis.mac
\endverbatim
The default view is a longitudinal view of the calorimeter.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged ones, or
none. This command is defined in EventActionMessenger class.
\section TestEm3_s5 PHYSICS DEMO
The particle's type and the physics processes which will be available
in this example are set in PhysicsList class.
In addition a built-in interactive command (/process/inactivate processName)
allows to activate/inactivate the processes one by one.
Then one can well visualize the processes one by one, especially
in the bubble chamber setup with a transverse magnetic field.
As a homework try to visualize a gamma conversion alone,
or the effect of the multiple scattering.
Notice that one can control the maximum step size, via the
StepMax process and the command /testem/stepMax
\verbatim
/testem/stepMax/absorber
\endverbatim
(see StepMax and PhysicsList classes)
\section TestEm3_s6 HOW TO START ?
- Execute TestEm3 in 'batch' mode from macro files
\verbatim
% TestEm3 run01.mac
\endverbatim
- Execute TestEm3 in 'interactive mode' with visualization
\verbatim
% TestEm3
....
Idle> type your commands. For instance:
Idle> /control/execute run01.mac
....
Idle> exit
\endverbatim
Macros provided in this example:
- atlashec.mac: ATLAS HEC model
- dedx.mac: to control dE/dx calculation: 1 layer; minimum ionizing particle
- emtutor.mac: for tutorial; interactivity + visualisation
- geom.mac: to play with geometry
- ionC12.mac: ion C12, 1 layer
- lhcb.mac: LHCB ECAL model
- linac.mac: Linac/Ecal from Graham Wilson
- lockwood.mac: Al-Au-Al 1 layer (G.L.Lockwood et al. SAND79-0414 (1980))
- run01.mac: Lead-liquidArgon 50 layers; electron 1 GeV
- run02.mac: Tungsten-Silicon 50 layers; electron 1 GeV
- storeTables.mac: show how to store and retrieve physics tables
- tileCal.mac: ATLAS tileCal
- vis.mac: to activate visualization
\section TestEm3_s7 HISTOGRAMS
Testem3 can produce histograms :
- histo 1 : energy deposit in absorber 1
- histo 2 : energy deposit in absorber 2
- etc.
- histo 11 : longitudinal profile of energy deposit in absorber 1 (MeV/event)
- histo 12 : longitudinal profile of energy deposit in absorber 2 (MeV/event)
- etc.
- histo 21 : energy flow (MeV/event)
- histo 22 : lateral energy leak (MeV/event)
NB. Numbering scheme for histograms:
- layer : from 1 to NbOfLayers (included)
- absorbers : from 1 to NbOfAbsor (included)
- planes : from 1 to NbOfLayers*NbOfAbsor + 1 (included)
One can control the binning of the histo with the command:
\verbatim
/analysis/h1/set idAbsor nbin Emin Emax unit
\endverbatim
etc.,
where unit is the desired energy unit for that histo (see TestEm3.in).
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem3)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/setAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default testem3)
*/
@@ -0,0 +1,195 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm3
-------
How to collect energy deposition in a sampling calorimeter.
How to survey energy flow.
how to print stopping power.
1- GEOMETRY DEFINITION
The calorimeter is a box made of a given number of layers.
A layer consists of a sequence of various absorbers (maximum MaxAbsor=9).
The layer is replicated.
Parameters defining the calorimeter :
- the number of layers,
- the number of absorbers within a layer,
- the material of the absorbers,
- the thickness of the absorbers,
- the transverse size of the calorimeter (the input face is a square).
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class, but all
of the above parameters can be modified interactively via the commands
defined in the DetectorMessenger class.
|<----layer 0---------->|<----layer 1---------->|<----layer 2---------->|
| | | | |
==========================================================================
|| | || | || | ||
|| | || | || | ||
|| abs 1 | abs 2 || abs 1 | abs 2 || abs 1 | abs 2 ||
|| | || | || | ||
|| | || | || | ||
beam || | || | || | ||
======> || | || | || | ||
|| | || | || | ||
|| | || | || | ||
|| | || | || | ||
|| | || | || | ||
|| cell 1 | cell 2 || cell 3 | cell 4 || cell 5 | cell 6 ||
==========================================================================
^ ^ ^ ^ ^ ^ ^
pln1 pln2 pln3 pln4 pln5 pln6 pln7
NB. The number of absorbers and the number of layers can be set to 1.
In this case we have a unique homogeneous block of matter, which looks like
a bubble chamber rather than a calorimeter ...
(see the macro emtutor.mac)
2- PHYSICS LISTS
Physics lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
EM physics builders can be local (eg. in this example) or from G4 kernel
physics_lists subdirectory.
Local physics builders:
- "local" standard EM physics with current 'best' options setting.
these options are explicited in PhysListEmStandard
From geant4/source/physics_lists/builders:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
Physics lists and options can be (re)set with UI commands.
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the calorimeter
perpendicular to the input face. The type of the particle and its energy are
set in the PrimaryGeneratorAction class, and can be changed via the
G4 build-in commands of G4ParticleGun class (see the macros provided with this
example).
In addition one can choose randomly the impact point of the incident particle.
The corresponding interactive command is built in PrimaryGeneratorMessenger.
A RUN is a set of events.
TestEm3 computes the energy deposited per absorber and the energy flow through
the calorimeter.
4- VISUALIZATION
The Visualization Manager is set in the main() (see TestEm3.cc).
The initialisation of the drawing is done via the commands :
/vis/... in the macro vis.mac. In interactive session:
PreInit or Idle > /control/execute vis.mac
The default view is a longitudinal view of the calorimeter.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged ones, or
none. This command is defined in EventActionMessenger class.
5- PHYSICS DEMO
The particle's type and the physics processes which will be available
in this example are set in PhysicsList class.
In addition a built-in interactive command (/process/inactivate processName)
allows to activate/inactivate the processes one by one.
Then one can well visualize the processes one by one, especially
in the bubble chamber setup with a transverse magnetic field.
As a homework try to visualize a gamma conversion alone,
or the effect of the multiple scattering.
Notice that one can control the maximum step size, via the
StepMax process and the command /testem/stepMax
(see StepMax and PhysicsList classes)
6- HOW TO START ?
- Execute TestEm3 in 'batch' mode from macro files
% TestEm3 run01.mac
- Execute TestEm3 in 'interactive mode' with visualization
% TestEm3
....
Idle> type your commands. For instance:
Idle> /control/execute run01.mac
....
Idle> exit
Macros provided in this example:
- atlashec.mac: ATLAS HEC model
- dedx.mac: to control dE/dx calculation: 1 layer; minimum ionizing particle
- emtutor.mac: for tutorial; interactivity + visualisation
- geom.mac: to play with geometry
- ionC12.mac: ion C12, 1 layer
- lhcb.mac: LHCB ECAL model
- linac.mac: Linac/Ecal from Graham Wilson
- lockwood.mac: Al-Au-Al 1 layer (G.L.Lockwood et al. SAND79-0414 (1980))
- run01.mac: Lead-liquidArgon 50 layers; electron 1 GeV
- run02.mac: Tungsten-Silicon 50 layers; electron 1 GeV
- storeTables.mac: show how to store and retrieve physics tables
- tileCal.mac: ATLAS tileCal
- vis.mac: to activate visualization
7- HISTOGRAMS
Testem3 can produce histograms :
histo 1 : energy deposit in absorber 1
histo 2 : energy deposit in absorber 2
...etc...........
histo 11 : longitudinal profile of energy deposit in absorber 1 (MeV/event)
histo 12 : longitudinal profile of energy deposit in absorber 2 (MeV/event)
...etc...........
histo 21 : energy flow (MeV/event)
histo 22 : lateral energy leak (MeV/event)
...etc...........
NB. Numbering scheme for histograms:
layer : from 1 to NbOfLayers (included)
absorbers : from 1 to NbOfAbsor (included)
planes : from 1 to NbOfLayers*NbOfAbsor + 1 (included)
One can control the binning of the histo with the command:
/analysis/h1/set idAbsor nbin Emin Emax unit
where unit is the desired energy unit for that histo (see TestEm3.in).
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem3)
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem3)
@@ -0,0 +1,51 @@
testem3/src is the geant3 equivalent of TestEm3
% cd geant3
% gmakeB to make an executable (Batch version)
% gmakeT to make an executable (inTeractive version)
To execute:
% cd geant3
% $G4SYSTEM/testem3.xb (for batch) or testem1.xt (for interactive)
The program will ask:
G3 > gives the filename of the data cards to be read:
run01.dat (runNN.dat is the equivalent of the G4 runNN.mac)
It is possible to set the production cuts BCUTE, DCUTE and PPCUTM
medium by medium, via the data cards:
CUTPR imed1 bcute/m dcute/m ppcutm
CUTPR imed2 bcute/m dcute/m ppcutm
...etc............
testem3 can produce histograms :
histo 1 : energy deposit in absorber 1
histo 2 : energy deposit in absorber 2
...etc...........
histo 11 : longitudinal profile of energy deposit in absorber 1 (MeV/event)
histo 12 : longitudinal profile of energy deposit in absorber 2 (MeV/event)
...etc...........
histo 21 : energy flow (MeV/event)
histo 22 : lateral energy leakage (MeV/event)
One can control the binning of the histograms with the data card:
*HISTO id1 nbBins valMin valMax valUnit
*HISTO id2 nbBins valMin valMax valUnit
... etc ...........
valMin and ValMax are given in the desired unit, whose numerical value must
be specified in valUnit. Remember that Geant3 defaults are: GeV, cm, rad.
The name of de histograms file must be defined with the data card:
FILE fileName (character) This data card is mandatory; it must be the first,
with the format A4,A2,A25
It is possible to set the max allowed step size STEMAX,
via the data card:
STEPMX stepmax (in cm)
(However this value will be taken into account only if auto=0)
@@ -0,0 +1,23 @@
This program compare the Geant3 and Geant4 dE/dx tables.
The Geant4 values are read as ffread data cards, as they are printed out
by TestEm3, according the standard Geant3 binning.
One must complete by hand the data cards KINE and MATE; see the file lead.dat
as an example.
The Geant3 values are computed within this program.
The g4-g3 differences are ploted in the file plmat.paw
% cd geant3/g4mat
% gmakeB to make an executable (Batch version)
% gmakeT to make an executable (inTeractive version)
To execute:
% cd geant3/g4mat
% $G4SYSTEM/g4mat.xb (for batch) or g4mat.xt (for interactive)
The program will ask:
G3 > gives the filename of the data cards to be read:
lead.dat (XXX.dat)
@@ -0,0 +1,94 @@
///\file "electromagnetic/TestEm4/.README.txt"
///\brief Example TestEm4 README page
/*! \page ExampleTestEm4 Example TestEm4
Plot energy deposited by 9 MeV photon beam in an homogeneous medium.
\section TestEm4_s1 GEOMETRY DEFINITION
It is a cylinder of 5 cm radius filled with C6F6.
\section TestEm4_s2 PHYSICS LIST
The particle list contains only gamma, electron,positron.
The physics list contains the 'standard' electromagnetic processes.
\section TestEm4_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic is a single 9 MeV gamma randomly shooted at the
middle of the cylinder.
\section TestEm4_s4 VISUALIZATION
The Visualization Manager is set in the main () (see TestEm4.cc).
The initialisation of the drawing is done via the commands
/vis/.. in the macro vis.mac. This macro is
automatically read from the main in case of interactive running mode.
The detector has a default view which is a transversal view of the
cylinder.
The tracks are drawn at the end of event, and erased at the end of run.
Optionaly one can choose to draw all particles, only the charged one,
or none. This command is defined in EventActionMessenger class.
\section TestEm4_s5 PHYSICS SURVEY
The energy deposited in C6F6 is histogramed.
\section TestEm4_s6 HOW TO START ?
- Execute TestEm4 in 'batch' mode from macro files
\verbatim
% TestEm4 TestEm4.in
\endverbatim
- Execute TestEm4 in 'interactive mode' with visualization
\verbatim
% TestEm4
....
Idle> type your commands
....
Idle> exit
\endverbatim
\section TestEm4_s7 USING HISTOGRAMS
The format of the histogram file can be : root (default),
xml, csv, by selecting g4nnn.hh in RunAction.hh
\section TestEm4_s8- RANDOM NUMBERS HANDLING
CLHEP provides several random number engines. In this example the Ranecu
engine is choosen at beginning of the main (TestEm4.cc).
By default, G4RunManager does not save the rndm seed.
To do so the user must set in BeginOfRunAction:
G4RunManager::GetRunManager()->SetRandomNumberStore(true);
Then the rndm seed is systematically saved at beginning of run
(currentRun.rndm) and beginning of event (currentEvent.rndm)
Therefore, in case of abnormal end, the seed of the last event processed
is available in currentEvent.rndm
Even in case of normal run processing, the user may wish to preserve the
rndm seed of selected events. At any time in the event, put the
following statement:
\verbatim
if (condition) G4RunManager::GetRunManager()->rndmSaveThisEvent();
\endverbatim
currentEvent.rndm will be copied to runXXevntYY.rndm
(see SteppingAction::UserSteppingAction() )
To restart a run from a given rndm seed, use the UI command :
\verbatim
/random/resetEngineFrom fileName
\endverbatim
The macro rndmSeed.mac shows how to save and reset the random number
seed between runs, from UI commands.
*/
@@ -0,0 +1,86 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm4
-------
Plot energy deposited by 9 MeV photon beam in an homogeneous medium.
1- GEOMETRY DEFINITION
It is a cylinder of 5 cm radius filled with C6F6.
2- PHYSICS LIST
The particle list contains only gamma, electron,positron.
The physics list contains the 'standard' electromagnetic processes.
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic is a single 9 MeV gamma randomly shooted at the
middle of the cylinder.
4- VISUALIZATION
The Visualization Manager is set in the main().
The initialisation of the drawing is done via the commands
/vis/.. in the macro vis.mac. This macro is
automatically read from the main in case of interactive running mode.
The detector has a default view which is a transversal view of the
cylinder.
The tracks are drawn at the end of event, and erased at the end of run.
Optionaly one can choose to draw all particles, only the charged one,
or none. This command is defined in EventActionMessenger class.
5- PHYSICS SURVEY
The energy deposited in C6F6 is histogramed.
6- HOW TO START ?
- execute TestEm4 in 'batch' mode from macro files
% TestEm4 TestEm4.in
- execute TestEm4 in 'interactive mode' with visualization
% TestEm4
....
Idle> type your commands
....
Idle> exit
7- USING HISTOGRAMS
The format of the histogram file can be : root (default),
xml, csv, by selecting g4nnn.hh in RunAction.hh
8- RANDOM NUMBERS HANDLING
CLHEP provides several random number engines. In this example the Ranecu
engine is choosen at beginning of the main (TestEm4.cc).
By default, G4RunManager does not save the rndm seed.
To do so the user must set in BeginOfRunAction:
G4RunManager::GetRunManager()->SetRandomNumberStore(true);
Then the rndm seed is systematically saved at beginning of run
(currentRun.rndm) and beginning of event (currentEvent.rndm)
Therefore, in case of abnormal end, the seed of the last event processed
is available in currentEvent.rndm
Even in case of normal run processing, the user may wish to preserve the
rndm seed of selected events. At any time in the event, put the
following statement:
if (condition) G4RunManager::GetRunManager()->rndmSaveThisEvent();
currentEvent.rndm will be copied to runXXevntYY.rndm
(see SteppingAction::UserSteppingAction() )
To restart a run from a given rndm seed, use the UI command :
/random/resetEngineFrom fileName
The macro rndmSeed.mac shows how to save and reset the random number
seed between runs, from UI commands.
@@ -0,0 +1,271 @@
///\file "electromagnetic/TestEm5/.README.txt"
///\brief Example TestEm5 README page
/*! \page ExampleTestEm5 Example TestEm5
How to study the transmission, absorption and reflection of particles through
a single, thin or thick, layer of material.
In particular, the effects of the multiple scattering can be plotted.
\section TestEm5_s1 GEOMETRY DEFINITION
The "absorber" is a box made of a given material.
Three parameters define the absorber :
- the material of the absorber,
- the thickness of an absorber,
- the transverse size of the absorber (the input face is a square).
A volume "World" contains the "absorber".
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class, but all the
parameters can be changed via commands defined in the DetectorMessenger class.
The parameters of the "World" can be changed, too. However, if World material
is not set to vacuum, the plots 10->43 below may be not pertinent.
\section TestEm5_s2 PHYSICS LIST
Physics lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
EM physics builders can be local (eg. in this example) or from G4 kernel
physics_lists subdirectory.
Local physics builders:
- "local" standard EM physics with current 'best' options setting
these options are explicited in PhysListEmStandard
- "standardSSM" standard EM physics with alternative single Coulomb
scattering model instead of multiple scattering.
From geant4/source/physics_lists/builders:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
Physics lists and options can be (re)set with UI commands
Please, notice that options set through G4EmProcessOptions are global, eg
for all particle types. In G4 builders, it is shown how to set options per
particle type.
\section TestEm5_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the absorber
perpendicular to the input face. The type of the particle and its energy are
set in the PrimaryGeneratorAction class, and can be changed via the G4 build-in
commands of G4ParticleGun class (see the macros provided with this example).
In addition one can choose randomly the impact point of the incident particle.
The interactive command is built in PrimaryGeneratorMessenger class.
\section TestEm5_s4 VISUALIZATION
The Visualization Manager is set in the main () (see TestEm5.cc).
The initialisation of the drawing is done via the commands in vis.mac
In interactive session:
\verbatim
PreInit or Idle > /control/execute vis.mac
\endverbatim
The example has a default view which is a longitudinal view of the detector.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged, or none.
This command is defined in EventActionMessenger class.
\section TestEm5_s5 TRACKING
During the tracking, one can keep or not the secondaries : see StackingAction
class and its Messenger (StackingMessenger).
One can also limit 'by hand' the step lenght of the particle. As an example,
this limitation is implemented as a 'full' process : see StepMax class and its
Messenger. The 'StepMax process' is registered in the Physics List.
\section TestEm5_s6 DETECTOR RESPONSE
At the end of a run, from the histogram(s), one can study different
physics quantities such as :
- energy deposit in the absorber,
- energy spectrum of secondaries at creation,
- energy spectrum and angle distribution of particles at exit,
- transmission and backscattering coefficients,
- ...
\section TestEm5_s7 List of the built-in histograms
The test contains more than 60 built-in 1D histograms, which are managed by
G4AnalysisManager class and its Messenger. The histos can be individually activated
with the command :
\verbatim
/analysis/h1/set id nbBins valMin valMax unit
\endverbatim
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
(see the macros xxxx.mac).
- 1 : "energy deposit in absorber"
- 2 : "energy of charged secondaries at creation"
- 3 : "energy of neutral secondaries at creation"
- 4 : "energy of charged at creation (log10(Ekin))"
- 5 : "energy of neutral at creation (log10(Ekin))"
- 6 : "x_vertex of charged secondaries (all)"
- 7 : "x_vertex of charged secondaries (not absorbed)"
- 10 : "(transmit, charged) : kinetic energy at exit of world"
- 11 : "(transmit, charged) : ener fluence: dE(MeV)/dOmega"
- 12 : "(transmit, charged) : space angle dN/dOmega"
- 13 : "(transmit, charged) : projected angle at exit of world"
- 14 : "(transmit, charged) : projected position at exit of world"
- 15 : "(transmit, charged) : radius at exit of world"
- 20 : "(transmit, neutral) : kinetic energy at exit of world"
- 21 : "(transmit, neutral) : ener fluence: dE(MeV)/dOmega"
- 22 : "(transmit, neutral) : space angle dN/dOmega"
- 23 : "(transmit, neutral) : projected angle at exit of world"
- 30 : "(reflect , charged) : kinetic energy at exit of world"
- 31 : "(reflect , charged) : ener fluence: dE(MeV)/dOmega"
- 32 : "(reflect , charged) : space angle dN/dOmega"
- 33 : "(reflect , charged) : projected angle at exit of world"
- 40 : "(reflect , neutral) : kinetic energy at exit of world"
- 41 : "(reflect , neutral) : ener fluence: dE(MeV)/dOmega"
- 42 : "(reflect , neutral) : space angle dN/dOmega"
- 43 : "(reflect , neutral) : projected angle at exit of world"
- 50 : "energy of Auger e- at creation"
- 51 : "energy of fluorescence gamma at creation"
- 52 : "energy of Auger e- at creation (log scale)"
- 53 : "energy of fluorescence gamma at creation (log scale)"
- 54 : "energy of PIXE Auger e- at creation"
- 55 : "energy of PIXE gamma at creation"
- 56 : "energy of PIXE Auger e- at creation (log scale)"
- 57 : "energy of PIXE gamma at creation (log scale)"
- 58 : "energy of G4DNA Auger e- at creation"
- 59 : "energy of G4DNA gamma at creation"
- 60 : "energy of G4DNA Auger e- at creation (log scale)"
- 61 : "energy of G4DNA gamma at creation (log scale)"
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem5)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/setAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default testem5)
\subsection TestEm5_subs1 Using hbook format
Need a special treatement : the Cern Library must be installed and the
environment variable CERNLIB correctly set. Then, *before* compiling,
activate G4_USE_HBOOK in GNUmakefile and g4hbook.hh in HistoManager.hh
\section TestEm5_s8 GEANT4/GEANT3/DATA COMPARISON
A Geant4/Geant3/exp. data comparison is given here for a few cases.
These cases can be classified as follow:
- e-/e+ incident particles versus protons and others.
- 3 energy regimes: low: < 1MeV; medium: 1MeV -> few 10MeV; high: > 100MeV
We indicate here the corresponding macros.
<pre>
| low energy | medium energy | high energy
--------------------------------------------------------
| acosta.mac | |
e-+ | berger.mac | hanson.mac |
| hunger.mac | kulchi.mac |
| tavola.mac | |
--------------------------------------------------------
others| bichsel.mac | vincour.mac | shen1.mac shen2.mac
| | gottsch.mac | tramu.mac
--------------------------------------------------------
</pre>
\section TestEm5_s9 HOW TO START ?
- Execute TestEm5 in 'batch' mode from macro files e.g.
\verbatim
% $(G4INSTALL)/bin/$(G4SYSTEM)/TestEm5 myMacro.mac
\endverbatim
- Execute TestEm5 in 'interactive' mode with visualization e.g.
\verbatim
% $(G4INSTALL)/bin/$(G4SYSTEM)/TestEm5
\endverbatim
Then type your commands, for instance :
\verbatim
Idle> control/execute vis.mac
Idle> run/beamOn 5
....
\endverbatim
Macros provided in this example:
- acosta.mac: Back x-ray emission by 20 keV electrons in Silver.
(E. Acosta et al. Journal of Applied Physics 83(11) 1998 page 6038,
Fig. 4-5-6)
- anthony.mac: LPM and dielectric effect measurement: 25 GeV electrons
through thin foils.
(P.L. Anthony et al. Phys.Rev. D 56 (1997) page 1373.)
- atima.mac: to test PhysListEm19DStandard for ions
- berger.mac: Energy deposit by 1 MeV electrons in silicon counters.
(M.J.Berger et al. NIM 69 (1969) page 181.)
- bichsel.mac: 0.766 MeV protons, transmitted through 1.37 mg/cm2 Al
(H.Bichsel Phys.Rev. 112 (1958) page 182.)
- dedx1.mac: to control dE/dx calculation.
- dedx2.mac: to control dE/dx calculation. High statistic and plot
- dna.mac: to illustrate DNA physics
- fluo.mac: to illustrate atomic deexcitation options
- gammaSpectrum.mac: to plot gamma spectrum with/without atomic deexcitation.
- geom.mac: to play with geometry (can be run interactively with visualization)
- gottsch.mac: 158.6 MeV protons, transmitted through 0.2160 g/cm2 Al
(B.Gottschalk et al. NIM B74 (1993) page 467.)
- hanson.mac: Angle distribution of 15.7 MeV electrons transmitted through
thin gold foils.
(A.O.Hanson et al. Phys.Rev.84 (1951) page 634.)
- hunger.mac: Back scattering of 41 keV electrons.
(H.J. Hunger and L. Kuchler Phys. Stat. Sol.(a) 56, K45 (1979))
- ion.mac: ion C12 in 1m Iron
- kulchi.mac: 2.25 MeV e-, transmitted through 26.60 mg/cm2 Al
(L.Kulchitsky Phys.Rev. 61 (1941) page 254.)
- mumsc.mac: 100 GeV mu+, transmitted through 1 m of iron
- mutev.mac: 1 TeV mu+, transmitted through 1 m of iron
- pixe.mac: to illustrate atomic deexcitation options
- pixe_ANSTO.mac: to illustrate how to activate the ANSTO PIXE data libraries.
for both cross sections and fluorescence radiation yields (for materials with Z < 93).
The cross sections are available for protons with energy < 5 MeV
and alpha particles with energy < 10 MeV/nucleon.
(S. Bakr et al. (2021) NIM B, 507:1119)
(S. Bakr et al (2018), NIMB B, 436: 285-291)
- posi.mac: to test PhysListEm19DStandard for positron
- shen1.mac: Angle distribution of high energy (50-200 GeV/c) protons
transmitted through different targets.
(G. Shen et al. Phys.Rev. D20 (1979) page 1584.)
- shen2.mac: proton 175 GeV/c, transmitted through 8.004 mm Al
(G. Shen et al. Phys.Rev. D20 (1979) page 1584.)
- stepMax.cc: to test the command /testem/stepMax
- tavora.mac: Back scattering of 35 keV electrons in Silver.
(L.M. Tavora et al. J.Phys.D: Appl. Phys. 33 (2000) page 2497,
Fig. 7)
- tramu.mac: 1 TeV mu+, transmitted through 3 m of iron
(Rev. of Particle Physics Eur. Phys. Jour. C (2000) page 172.
Rev. of Particle Physics Letters B 592 (2004) page 251.)
- vincour.mac: Angle distribution of 6.56 MeV protons transmitted through
thin silicon targets.
(J.Vincour,P.Bem NIM 148 (1978) page 396.)
- vis.mac - to activate visualization
*/
@@ -0,0 +1,252 @@
-----------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm5
-------
How to study the transmission, absorption and reflection of particles through
a single, thin or thick, layer of material.
In particular, the effects of the multiple scattering can be plotted.
1- GEOMETRY DEFINITION
The "absorber" is a box made of a given material.
Three parameters define the absorber :
- the material of the absorber,
- the thickness of an absorber,
- the transverse size of the absorber (the input face is a square).
A volume "World" contains the "absorber".
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class, but all the
parameters can be changed via commands defined in the DetectorMessenger class.
The parameters of the "World" can be changed, too. However, if World material
is not set to vacuum, the plots 10->43 below may be not pertinent.
2- PHYSICS LIST
Physics lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
EM physics builders can be local (eg. in this example) or from G4 kernel
physics_lists subdirectory.
Local physics builders:
- "local" standard EM physics with current 'best' options setting
these options are explicited in PhysListEmStandard
- "standardSSM" standard EM physics with alternative single Coulomb
scattering model instead of multiple scattering.
From geant4/source/physics_lists/builders:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
Physics lists and options can be (re)set with UI commands
Please, notice that options set through G4EmProcessOptions are global, eg
for all particle types. In G4 builders, it is shown how to set options per
particle type.
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the absorber
perpendicular to the input face. The type of the particle and its energy are
set in the PrimaryGeneratorAction class, and can be changed via the G4
build-in commands of G4ParticleGun class (see the macros provided with this
example).
In addition one can choose randomly the impact point of the incident particle.
The interactive command is built in PrimaryGeneratorMessenger class.
4- VISUALIZATION
The Visualization Manager is set in the main().
The initialisation of the drawing is done via the commands in vis.mac
In interactive session:
PreInit or Idle > /control/execute vis.mac
The example has a default view which is a longitudinal view of the detector.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged, or none.
This command is defined in EventActionMessenger class.
5- TRACKING
During the tracking, one can keep or not the secondaries : see StackingAction
class and its Messenger (StackingMessenger).
One can also limit 'by hand' the step lenght of the particle. As an example,
this limitation is implemented as a 'full' process : see StepMax class and its
Messenger. The 'StepMax process' is registered in the Physics List.
6- DETECTOR RESPONSE
At the end of a run, from the histogram(s), one can study different
physics quantities such as :
- energy deposit in the absorber,
- energy spectrum of secondaries at creation,
- energy spectrum and angle distribution of particles at exit,
- transmission and backscattering coefficients,
- ...
7- List of the built-in histograms
----------------------------------
The test contains more than 60 built-in 1D histograms, which are managed by
G4AnalysisManager class and its Messenger. The histos can be individually activated
with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
(see the macros xxxx.mac).
1 "energy deposit in absorber"
2 "energy of charged secondaries at creation"
3 "energy of neutral secondaries at creation"
4 "energy of charged at creation (log10(Ekin))"
5 "energy of neutral at creation (log10(Ekin))"
6 "x_vertex of charged secondaries (all)"
7 "x_vertex of charged secondaries (not absorbed)"
10 "(transmit, charged) : kinetic energy at exit of world"
11 "(transmit, charged) : ener fluence: dE(MeV)/dOmega"
12 "(transmit, charged) : space angle dN/dOmega"
13 "(transmit, charged) : projected angle at exit of world"
14 "(transmit, charged) : projected position at exit of world"
15 "(transmit, charged) : radius at exit of world"
20 "(transmit, neutral) : kinetic energy at exit of world"
21 "(transmit, neutral) : ener fluence: dE(MeV)/dOmega"
22 "(transmit, neutral) : space angle dN/dOmega"
23 "(transmit, neutral) : projected angle at exit of world"
30 "(reflect , charged) : kinetic energy at exit of world"
31 "(reflect , charged) : ener fluence: dE(MeV)/dOmega"
32 "(reflect , charged) : space angle dN/dOmega"
33 "(reflect , charged) : projected angle at exit of world"
40 "(reflect , neutral) : kinetic energy at exit of world"
41 "(reflect , neutral) : ener fluence: dE(MeV)/dOmega"
42 "(reflect , neutral) : space angle dN/dOmega"
43 "(reflect , neutral) : projected angle at exit of world"
50 "energy of Auger e- at creation"
51 "energy of fluorescence gamma at creation"
52 "energy of Auger e- at creation (log scale)"
53 "energy of fluorescence gamma at creation (log scale)"
54 "energy of PIXE Auger e- at creation"
55 "energy of PIXE gamma at creation"
56 "energy of PIXE Auger e- at creation (log scale)"
57 "energy of PIXE gamma at creation (log scale)"
58 "energy of G4DNA Auger e- at creation"
59 "energy of G4DNA gamma at creation"
60 "energy of G4DNA Auger e- at creation (log scale)"
61 "energy of G4DNA gamma at creation (log scale)"
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem5)
It is possible to choose the format of the histogram file : root (default),
hbook, xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem5)
8- GEANT4/GEANT3/DATA COMPARISON
A Geant4/Geant3/exp. data comparison is given here for a few cases.
These cases can be classified as follow:
- e-/e+ incident particles versus protons and others.
- 3 energy regimes: low: < 1MeV; medium: 1MeV -> few 10MeV; high: > 100MeV
We indicate here the corresponding macros.
| low energy | medium energy | high energy
--------------------------------------------------------
| acosta.mac | |
e-+ | berger.mac | hanson.mac |
| hunger.mac | kulchi.mac |
| tavola.mac | |
--------------------------------------------------------
others| bichsel.mac | vincour.mac | shen1.mac shen2.mac
| | gottsch.mac | tramu.mac
--------------------------------------------------------
9- HOW TO START ?
- execute TestEm5 in 'batch' mode from macro files e.g.
% $(G4INSTALL)/bin/$(G4SYSTEM)/TestEm5 myMacro.mac
- execute TestEm5 in 'interactive' mode with visualization e.g.
% $(G4INSTALL)/bin/$(G4SYSTEM)/TestEm5
Then type your commands, for instance :
Idle> control/execute vis.mac
Idle> run/beamOn 5
....
Macros provided in this example:
- acosta.mac: Back x-ray emission by 20 keV electrons in Silver.
(E. Acosta et al. Journal of Applied Physics 83(11) 1998 page 6038,
Fig. 4-5-6)
- anthony.mac: LPM and dielectric effect measurement: 25 GeV electrons
through thin foils.
(P.L. Anthony et al. Phys.Rev. D 56 (1997) page 1373.)
- atima.mac: to test PhysListEm19DStandard for ions
- berger.mac: Energy deposit by 1 MeV electrons in silicon counters.
(M.J.Berger et al. NIM 69 (1969) page 181.)
- bichsel.mac: 0.766 MeV protons, transmitted through 1.37 mg/cm2 Al
(H.Bichsel Phys.Rev. 112 (1958) page 182.)
- dedx1.mac: to control dE/dx calculation.
- dedx2.mac: to control dE/dx calculation. High statistic and plot
- dna.mac: to illustrate DNA physics
- fluo.mac: to illustrate atomic deexcitation options
- gammaSpectrum.mac: to plot gamma spectrum with/without atomic deexcitation.
- geom.mac: to play with geometry (can be run interactively with visualization)
- gottsch.mac: 158.6 MeV protons, transmitted through 0.2160 g/cm2 Al
(B.Gottschalk et al. NIM B74 (1993) page 467.)
- hanson.mac: Angle distribution of 15.7 MeV electrons transmitted through
thin gold foils.
(A.O.Hanson et al. Phys.Rev.84 (1951) page 634.)
- hunger.mac: Back scattering of 41 keV electrons.
(H.J. Hunger and L. Kuchler Phys. Stat. Sol.(a) 56, K45 (1979))
- ion.mac: ion C12 in 1m Iron
- kulchi.mac: 2.25 MeV e-, transmitted through 26.60 mg/cm2 Al
(L.Kulchitsky Phys.Rev. 61 (1941) page 254.)
- mumsc.mac: 100 GeV mu+, transmitted through 1 m of iron
- mutev.mac: 1 TeV mu+, transmitted through 1 m of iron
- pixe.mac: to illustrate atomic deexcitation options
- pixe_ANSTO.mac: to illustrate how to activate the ANSTO PIXE data libraries,
for both cross sections and fluorescence radiation yields (for materials with Z < 93).
The cross sections are available for protons with energy < 5 MeV
and alpha particles with energy < 10 MeV/nucleon.
(S. Bakr et al. (2021) NIM B, 507:1119),
(S. Bakr et al (2018), NIMB B, 436: 285-291).
- posi.mac: to test PhysListEm19DStandard for positron
- shen1.mac: Angle distribution of high energy (50-200 GeV/c) protons
transmitted through different targets.
(G. Shen et al. Phys.Rev. D20 (1979) page 1584.)
- shen2.mac: proton 175 GeV/c, transmitted through 8.004 mm Al
(G. Shen et al. Phys.Rev. D20 (1979) page 1584.)
- stepMax.cc: to test the command /testem/stepMax
- tavora.mac: Back scattering of 35 keV electrons in Silver.
(L.M. Tavora et al. J.Phys.D: Appl. Phys. 33 (2000) page 2497,
Fig. 7)
- tramu.mac: 1 TeV mu+, transmitted through 3 m of iron
(Rev. of Particle Physics Eur. Phys. Jour. C (2000) page 172.
Rev. of Particle Physics Letters B 592 (2004) page 251.)
- vincour.mac: Angle distribution of 6.56 MeV protons transmitted through
thin silicon targets.
(J.Vincour,P.Bem NIM 148 (1978) page 396.)
- vis.mac - to activate visualization
@@ -0,0 +1,140 @@
///\file "electromagnetic/TestEm6/.README.txt"
///\brief Example TestEm6 README page
/*! \page ExampleTestEm6 Example TestEm6
This example is intended to test the processes of gamma conversion
to a pair of muons and annihilation of positrons with atomic
electrons to a pair of muons.
\section TestEm6_s1 GEOMETRY DEFINITION
The geometry consists of a single block of a homogenous material.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default is 500 m of iron.
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be changed interactively via
the commands defined in the DetectorMessenger class.
\section TestEm6_s2 PHYSICS LIST
Physics Lists are based on modular design. Several modules are
instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
The electromagnetic physics is chosen from one of the Geant4 EM
physics constructors in the physics_list library.
Cross sections can be enhanced (see below).
\section TestEm6_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
block perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
The default is a Gamma of 100 TeV.
In addition one can choose randomly the impact point of the incident
particle. The corresponding interactive command is built in
PrimaryGeneratorMessenger class.
A RUN is a set of events.
\section TestEm6_s4 VISUALIZATION
The Visualization Manager is set in the main() (see TestEm6.cc).
The initialisation of the drawing is done via the command
\verbatim
> /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged ones,
or none. This command is defined in EventActionMessenger class.
\section TestEm6_s5 PHYSICS DEMO
The particle's type and the physics processes which will be available
in this example are set in PhysicsList class.
In addition a build-in interactive command (/process/inactivate procname)
allows to activate/inactivate the processes one by one.
The threshold for producing secondaries can be changed.
eg:
\verbatim
/run/particle/setCut 100 micrometer
/run/initialize
\endverbatim
To visualize the GammaConversionToMuons :
\verbatim
/control/execute run01.mac
/control/execute vis.mac
/run/beamOn
\endverbatim
To visualize the AnnihiToMuPair :
\verbatim
/control/execute run11.mac
/control/execute vis.mac
/run/beamOn
\endverbatim
\section TestEm6_s6 HOW TO START ?
- Execute Test in 'batch' mode from macro files
\verbatim
% TestEm6 run01.mac
\endverbatim
- Execute Test in 'interactive mode' with visualization
\verbatim
% TestEm6
....
Idle> type your commands
....
Idle> exit
\endverbatim
\section TestEm6_s7 HOW TO INCREASE STATISTICS ON gamma -> mu+mu- ?
The processes of gamma -> mu+mu- and e+e- -> mu+mu-
have a low cross section but can be important
for leakage through thick absorbers and calorimeters.
Straight forward simulation will be quite time consuming.
To make the processes more visible, the cross section can be
artificially increased by some factor (here 1000)
using the commands (only effective after /run/initialize)
\verbatim
/testem/phys/SetGammaToMuPairFac 1000
/testem/phys/SetAnnihiToMuPairFac 1000
\endverbatim
\section TestEm6_s8 HISTOGRAMS
Testem6 produces 6 histograms which illustrate the final state of
the GammaConversionToMuons process. See their definitions in RunAction.cc
By default the histograms are saved as testem6.root
The format of the histogram file can be : root (default), xml, csv,
by selecting g4nnn.hh in RunAction.hh
*/
@@ -0,0 +1,125 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm6
-------
This example is intended to test the processes of gamma conversion
to a pair of muons and annihilation of positrons with atomic
electrons to a pair of muons.
1- GEOMETRY DEFINITION
The geometry consists of a single block of a homogenous material.
Two parameters define the geometry :
- the material of the box,
- the (full) size of the box.
The default is 500 m of iron.
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be changed interactively via
the commands defined in the DetectorMessenger class.
2- PHYSICS LIST
Physics Lists are based on modular design. Several modules are
instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
The electromagnetic physics is chosen from one of the Geant4 EM
physics constructors in the physics_list library.
Cross sections can be enhanced (see below).
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
block perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
The default is a Gamma of 100 TeV.
In addition one can choose randomly the impact point of the incident
particle. The corresponding interactive command is built in
PrimaryGeneratorMessenger class.
A RUN is a set of events.
4- VISUALIZATION
The Visualization Manager is set in the main() (see TestEm6.cc).
The initialisation of the drawing is done via the command
> /control/execute vis.mac
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged ones,
or none. This command is defined in EventActionMessenger class.
5- PHYSICS DEMO
The particle's type and the physics processes which will be available
in this example are set in PhysicsList class.
In addition a build-in interactive command (/process/inactivate procname)
allows to activate/inactivate the processes one by one.
The threshold for producing secondaries can be changed.
eg: /run/particle/setCut 100 micrometer
/run/initialize
To visualize the GammaConversionToMuons :
/control/execute run01.mac
/control/execute vis.mac
/run/beamOn
To visualize the AnnihiToMuPair :
/control/execute run11.mac
/control/execute vis.mac
/run/beamOn
6- HOW TO START ?
- execute Test in 'batch' mode from macro files
% TestEm6 run01.mac
- execute Test in 'interactive mode' with visualization
% TestEm6
....
Idle> type your commands
....
Idle> exit
7- HOW TO INCREASE STATISTICS ON gamma -> mu+mu- ?
The processes of gamma -> mu+mu- and e+e- -> mu+mu-
have a low cross section but can be important
for leakage through thick absorbers and calorimeters.
Straight forward simulation will be quite time consuming.
To make the processes more visible, the cross section can be
artificially increased by some factor (here 1000)
using the commands (only effective after /run/initialize)
/testem/phys/SetGammaToMuPairFac 1000
/testem/phys/SetAnnihiToMuPairFac 1000
8- HISTOGRAMS
Testem6 produces 6 histograms which illustrate the final state of
the GammaConversionToMuons process. See their definitions in RunAction.cc
By default the histograms are saved as testem6.root
The format of the histogram file can be : root (default), xml, csv,
by selecting g4nnn.hh in RunAction.hh
@@ -0,0 +1,177 @@
///\file "electromagnetic/TestEm7/.README.txt"
///\brief Example TestEm7 README page
/*! \page ExampleTestEm7 Example TestEm7
- How to produce a Bragg curve in a water phantom.
- How to compute the dose in 'test volumes' called tallies.
- How to define a maximum step size.
\section TestEm7_s1 GEOMETRY DEFINITION
The geometry consists of a single block of a homogenous material,
placed in a world.
Three parameters define the geometry :
- the material of the box,
- the thickness of the box (sizeX),
- the transverse dimension of the box (sizeYZ).
The default is 20 cm of water.
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be changed interactively via
the commands defined in the DetectorMessenger class.
The size, matter, positions of several test-volumes (tallies) can be
defined via UI commands : /testem/det/tally...
\section TestEm7_s2 PHYSICS LIST
Physics lists can be local (eg. in this example) or from G4 kernel
physics_lists subdirectory.
Local physics lists:
- "local" standard EM physics with current 'best' options setting.
these options are explicited in PhysListEmStandard
- "standardSS" standard EM physics with single Coulomb scattering
instead of multiple scattering;
- "standardNR" standard EM physics with single Coulomb scattering
process G4ScreenedNuclearRecoil instead of the
multiple scattering for ions with energy less than
100 MeV/nucleon; the new process was developed
by M.H. Mendenhall and R.A. Weller from Vanderbuilt
University and published in NIM B 277 (2005) 420.
In later Geant4 releases the process will be a part
of Geant4 source, currently it is released together
with its mathematical tool c2_functions in current
From geant4/source/physics_lists/builders:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emstandardGS" standard EM physics and Goudsmit-Saunderson multiple scatt.
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
Decay and StepMax processes are added to each list.
Optional components can be added:
- "elastic" elastic scattering of hadrons
- "HElastic"
- "QElastic"
- "binary" QBBC configuration of hadron inelastic models
- "binary_ion" Binary ion inelastic models
- "ionIoni" Ion gas models
Physics lists and options can be (re)set with UI commands
Please, notice that options set through G4EmProcessOptions are global, eg
for all particle types. In G4 builders, it is shown how to set options per
particle type.
\section TestEm7_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
block perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
The default is a 160 MeV proton.
In addition one can define randomly the impact point of the incident
particle. The corresponding interactive command is built in
PrimaryGeneratorMessenger class.
A RUN is a set of events.
\section TestEm7_s4 DOSE IN 'TEST-VOLUMES'
The energy deposited in the test-volumes (tallies) defined in
DetectorConstruction are printed at RunAction::EndOfRunAction(), both in MeV and gray.
\section TestEm7_s5 VISUALIZATION
The Visualization Manager is set in the main () (see TestEm7.cc).
The initialisation of the drawing is done via the command
\verbatim
> /control/execute vis.mac
\endverbatim
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged one,
or none. This command is defined in EventActionMessenger class.
\section TestEm7_s6- HOW TO START ?
- Execute Test in 'batch' mode from macro files
\verbatim
% TestEm7 proton.mac
\endverbatim
- Execute Test in 'interactive mode' with visualization
\verbatim
% TestEm7
....
Idle> type your commands
....
Idle> exit
\endverbatim
\section TestEm7_s7- HISTOGRAM OF THE BRAGG PEAK
Testem7 computes the total energy deposited along the trajectory of
the incident particle : the so-called Bragg peak.
In order to control the accuracy of the deposition, the user can limit
the maximum allowed for the step size of charged particles.
(command /testem/stepMax )
The result is a 1D histogram, which is the total energy deposited
along the trajectory of the incident particle.
The bin size is equal to stepMax. The number of bins is determined by
the thickness of the absorber (with a minimum of 100 bins).
The total energy deposited is plotted in MeV/mm per incident particle.
The next histogram allows to have a zoom around the Bragg peak. Its binning
should be defined via UI command:
\verbatim
/analysis/h1/set 2 nbins xmin xmax unit
\endverbatim
The last histogram shows the projectile range. Its bining should be defined
similary by the UI command:
\verbatim
/analysis/h1/set 3 nbins xmin xmax unit
\endverbatim
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default testem7)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/setAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default testem7)
*/
@@ -0,0 +1,156 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm7
-------
How to produce a Bragg curve in a water phantom.
How to compute the dose in 'test volumes' called tallies.
How to define a maximum step size.
1- GEOMETRY DEFINITION
The geometry consists of a single block of a homogenous material,
placed in a world.
Three parameters define the geometry :
- the material of the box,
- the thickness of the box (sizeX),
- the transverse dimension of the box (sizeYZ).
The default is 20 cm of water.
In addition a transverse uniform magnetic field can be applied.
The default geometry is constructed in DetectorConstruction class,
but all of the above parameters can be changed interactively via
the commands defined in the DetectorMessenger class.
The size, matter, positions of several test-volumes (tallies) can be
defined via UI commands : /testem/det/tally...
2- PHYSICS LIST
Physics lists can be local (eg. in this example) or from G4 kernel
physics_lists subdirectory.
Local physics lists:
- "local" standard EM physics with current 'best' options setting.
these options are explicited in PhysListEmStandard
- "standardSS" standard EM physics with single Coulomb scattering
instead of multiple scattering;
- "standardNR" standard EM physics with single Coulomb scattering
process G4ScreenedNuclearRecoil instead of the
multiple scattering for ions with energy less than
100 MeV/nucleon; the new process was developed
by M.H. Mendenhall and R.A. Weller from Vanderbuilt
University and published in NIM B 277 (2005) 420.
The process is released in this example with its
mathematical tool c2_functions
From geant4/source/physics_lists/builders:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emstandardGS" standard EM physics and Goudsmit-Saunderson multiple scatt.
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
Decay and StepMax processes are added to each list.
Optional components can be added:
- "elastic" elastic scattering of hadrons
- "HElastic"
- "QElastic"
- "binary" QBBC configuration of hadron inelastic models
- "binary_ion" Binary ion inelastic models
- "ionIoni" Ion gas models
Physics lists and options can be (re)set with UI commands
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
block perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
The default is a 160 MeV proton.
In addition one can define randomly the impact point of the incident
particle. The corresponding interactive command is built in
PrimaryGeneratorMessenger class.
A RUN is a set of events.
4- DOSE IN 'TEST-VOLUMES'
The energy deposited in the test-volumes (tallies) defined in
DetectorConstruction are printed at EndOfRun, both in MeV and gray.
5- VISUALIZATION
The Visualization Manager is set in the main().
The initialisation of the drawing is done via the command
> /control/execute vis.mac
The detector has a default view which is a longitudinal view of the box.
The tracks are drawn at the end of event, and erased at the end of run.
Optionally one can choose to draw all particles, only the charged one,
or none. This command is defined in EventActionMessenger class.
6- HOW TO START ?
- execute Test in 'batch' mode from macro files
% TestEm7 proton.mac
- execute Test in 'interactive mode' with visualization
% TestEm7
....
Idle> type your commands
....
Idle> exit
7- HISTOGRAM OF THE BRAGG PEAK
Testem7 computes the total energy deposited along the trajectory of
the incident particle : the so-called Bragg peak.
In order to control the accuracy of the deposition, the user can limit
the maximum allowed for the step size of charged particles.
(command /testem/stepMax )
The result is a 1D histogram, which is the total energy deposited
along the trajectory of the incident particle.
The bin size is equal to stepMax. The number of bins is determined by
the thickness of the absorber (with a minimum of 100 bins).
The total energy deposited is plotted in MeV/mm per incident particle.
The next histogram allows to have a zoom around the Bragg peak. Its binning
should be defined via UI command:
/analysis/h1/set 2 nbins xmin xmax unit
The last histogram shows the projectile range. Its bining should be defined
similary by the UI command:
/analysis/h1/set 3 nbins xmin xmax unit
One can control the name of the histograms file with the command:
/analysis/setFileName name (default testem7)
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default testem7)
@@ -0,0 +1,88 @@
///\file "electromagnetic/TestEm8/.README.txt"
///\brief Example TestEm8 README page
/*! \page ExampleTestEm8 Example TestEm8
Example for investigation of ionisation in thin absorbers and gaseous
detectors
\section TestEm8_s1 GEOMETRY DEFINITION
The target is a cylinder made of a given material placed inside
cylindrical container, which is placed inside the world volume.
Following parameters define the geometry:
- the material of the target,
- the thickness of the target,
- the radius of the target,
- the material of the container,
- the thickness of the container,
- the material of the world.
The list of materials used in gaseous detectors are built inside
the DetectorConstruction class, also NIST materials are available.
The default geometry is provided but all parameters can be changed via
UI commands defined in the DetectorMessenger class, for example,
\verbatim
/testem/setGasMat XeCH4C3H8
/testem/setWindowMat G4_MYLAR
/testem/setWorldMat G4_AIR
/testem/setGasThick 10 cm
/testem/setGasRad 20 cm
/testem/setWindowThick 50 um
\endverbatim
\section TestEm8_s2 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
absorber perpendicular to the input face. The type of the particle
and its energy can be set via the G4 build-in commands of G4ParticleGun .
A RUN is a set of events.
\section TestEm8_s3 DETECTOR RESPONSE
The TargetSD class sending information about each step inside the target
to the HistoManager class scoring of energy deposition in the detector.
Additionally at each step of a particle inside the target the number of
ionisation clusters is sampled using G4ElectronIonPair helper class. The
parameter of transformation of energy into ionisation clusters can be
set via UI command:
\verbatim
/testem/setPairEnergy 19 eV
\endverbatim
\section TestEm8_s4 PHYSICS
The particle's type and the physics processes which will be available
in this example are set in PhysicsList class, which uses Geant4
EM physics constructors provided in the physics_list library.
The PhysicsListMessenger classes introduce interactive commands. In particular,
PAI ionisation model can be added using G4EmConfigurator helper class,
which is invoked by the UI command
\verbatim
/testem/phys/addPhysics pai
\endverbatim
\section TestEm8_s5- HOW TO START ?
- Execute TestEm8 in 'batch' mode from macro files e.g.
\verbatim
% $(G4INSTALL)/bin/$(G4SYSTEM)/TestEm8 TestEm8.in N
\endverbatim
here N means number of threads in multi-threaded mode, by
default 2 threads are used
- Execute TestEm8 in 'interactive' mode with visualization e.g.
\verbatim
% $(G4INSTALL)/bin/$(G4SYSTEM)/TestEm8
....
Idle> type your commands
....
\endverbatim
*/
@@ -0,0 +1,87 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm8
-------
Example for investigation of ionisation in thin absorbers and gaseous
detectors
1- GEOMETRY DEFINITION
The target is a cylinder made of a given material placed inside
cylindrical container, which is placed inside the world volume.
Following parameters define the geometry:
- the material of the target,
- the thickness of the target,
- the radius of the target,
- the material of the container,
- the thickness of the container,
- the material of the world.
The list of materials used in gaseous detectors are built inside
the DetectorConstruction class, also NIST materials are available.
The default geometry is provided but all parameters can be changed via
UI commands defined in the DetectorMessenger class, for example,
/testem/setGasMat XeCH4C3H8
/testem/setWindowMat G4_MYLAR
/testem/setWorldMat G4_AIR
/testem/setGasThick 10 cm
/testem/setGasRad 20 cm
/testem/setWindowThick 50 um
2- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
absorber perpendicular to the input face. The type of the particle
and its energy can be set via the G4 build-in commands of G4ParticleGun.
A RUN is a set of events.
3- DETECTOR RESPONSE
The TargetSD class sending information about each step inside the target
to the HistoManager class scoring of energy deposition in the detector.
Additionally at each step of a particle inside the target the number of
ionisation clusters is sampled using G4ElectronIonPair helper class. The
parameter of transformation of energy into ionisation clusters can be
set via UI command:
/testem/setPairEnergy 19 eV
4- PHYSICS
The particle's type and the physics processes which will be available
in this example are set in PhysicsList class, which uses Geant4
EM physics constructors provided in the physics_list library.
The messenger classes introduce interactive commands. In particular,
PAI ionisation model can be added using G4EmConfigurator helper class,
which is invoked by one following UI commands:
/testem/phys/addPhysics pai
/testem/phys/addPhysics pai_photon
/process/em/AddPAIRegion all GasDetector pai
/process/em/AddPAIRegion all GasDetector pai_photon
Cuts for all setup and/or for sensitive volume may changed via commands:
/run/setCut 0.5 mm
/run/setCutForRegion GasDetector 1.8 mm
5- HOW TO START ?
Execute TestEm8 in 'batch' mode from macro files e.g.
% $(G4INSTALL)/bin/$(G4SYSTEM)/TestEm8 TestEm8.in N
here N means number of threads in multi-threaded mode, by
default 2 threads are used
- execute TestEm8 in 'interactive' mode with visualization e.g.
% $(G4INSTALL)/bin/$(G4SYSTEM)/TestEm8
....
Idle> type your commands
....
@@ -0,0 +1,120 @@
///\file "electromagnetic/TestEm9/.README.txt"
///\brief Example TestEm9 README page
/*! \page ExampleTestEm9 Example TestEm9
- Demonstrate electromagnetic physics in crystal calorimeters.
- How to define cut-per-region.
\section TestEm9_s1 GEOMETRY DEFINITION
The geometry consists of the vertex detector (VD), the electromagnetic
calorimeter (EM), and the muon identifier (MU). Detector layout along
the Z axis.
VD consisted of 3 layers of Si with pads structured along the X axis.
Between VD and EM there are 2 active absorbers (scintillators).
EM is the matrix 5x5 of heavy crystals. MU consist of 2 active absorbers
(scintillators) and the iron plate between.
2 regions additional to the World are defined: VertexDetector and
MuonDetector. For testing purposes first absorber of MU is included in
the region of VD.
Material of calorimeter and absorber can be choosen: \n
Air Water lAr Al Fe BGO PbWO4 Pb. \n
Eg:
\verbatim
/testem/det/CalMat PbWO4
/testem/det/AbsMat Al
\endverbatim
The size of the detector can be changed also.\n
Eg:
\verbatim
/testem/det/EcalLength 20 cm
/testem/det/EcalWidth 5 cm
/testem/det/update ---> rebuild the geometry
\endverbatim
\section TestEm9_s2 PHYSICS LISTS
Physics Lists are based on modular design. Several modules are instantiated:
-# Transportation
-# EM physics
-# Decays
-# StepMax - for step limitation
The following options for EM physics using builders from physics_lists
sub-package are available:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emstandardGS" standard EM physics and Goudsmit-Saunderson multiple scatt.
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
A local builder, PhysListEmStandard "local" (similar to opt0) is also
available.
Optional components can be added:
- "elastic" elastic scattering of hadrons
- "binary" QBBC configuration of hadron/ion inelastic models
- "gamma_nuc" gamma- and electro-nuclear processes
- "stopping" stopping processes
\section TestEm9_s3 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
cylinder perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
changed via the G4 build-in commands of G4ParticleGun class.
\section TestEm9_s4 OUTPUT
The batch regime of simulation can be started
\verbatim
$G4WORKDIR/bin/$G4SYSTEM/TestEm9 TestEm9.in
\endverbatim
where TestEm9.in is the example of macro file for batch job.
As a result of simulation the number of secondaries produced
in different regions are averaged. The average energy depositions
in active absorbers and EM as well as RMS of these values are shown.
The number of hits in pads of VD is printed out.
\section TestEm9_s5 VISUALISATION
To use visualisation the environment variable G4_VIS_USE should be
defined. An interactive session starts if no macro file is specified
in the command line:
\verbatim
$G4WORKDIR/bin/$G4SYSTEM/TestEm9
\endverbatim
To start visualisation one can issur
\verbatim
>/control/execute vis.mac
>/run/beamOn 1
\endverbatim
\section TestEm9_s6 ANALYSIS
Number of histograms are built inside the example using internal
analysis sub-package. Histograms are saved in a root file.
Histogram booking and saving is done only if any of histogram
\verbatim
/testem/histo/fileName myname
/testem/histo/setHisto id nbins xmin xmax unit
\endverbatim
*/
@@ -0,0 +1,108 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm9
-------
Demonstrate electromagnetic physics in crystal calorimeters.
How to define cut-per-region.
1- GEOMETRY DEFINITION
The geometry consists of the vertex detector (VD), the electromagnetic
calorimeter (EM), and the muon identifier (MU). Detector layout along
the Z axis.
VD consisted of 3 layers of Si with pads structured along the X axis.
Between VD and EM there are 2 active absorbers (scintillators).
EM is the matrix 5x5 of heavy crystals. MU consist of 2 active absorbers
(scintillators) and the iron plate between.
2 regions additional to the World are defined: VertexDetector and
MuonDetector. For testing purposes first absorber of MU is included in
the region of VD.
Material of calorimeter and absorber can be choosen:
Air Water lAr Al Fe BGO PbWO4 Pb.
eg: /testem/det/CalMat PbWO4
/testem/det/AbsMat Al
The size of the detector can be changed also.
eg: /testem/det/EcalLength 20 cm
/testem/det/EcalWidth 5 cm
/testem/det/update ---> rebuild the geometry
2- PHYSICS LISTS
Physics Lists are based on modular design. Several modules are instantiated:
1. Transportation
2. EM physics
3. Decays
4. StepMax - for step limitation
The following options for EM physics using builders from physics_lists
sub-package are available:
- "emstandard_opt0" recommended standard EM physics for LHC
- "emstandard_opt1" best CPU performance standard physics for LHC
- "emstandard_opt2" similar fast simulation
- "emstandard_opt3" best standard EM options - analog to "local" above
- "emstandard_opt4" best current advanced EM options standard + lowenergy
- "emstandardWVI" standard EM physics and WentzelVI multiple scattering
- "emstandardSS" standard EM physics and single scattering model
- "emstandardGS" standard EM physics and Goudsmit-Saunderson multiple scatt.
- "emlivermore" low-energy EM physics using Livermore data
- "empenelope" low-energy EM physics implementing Penelope models
- "emlowenergy" low-energy EM physics implementing experimental
low-energy models
A local builder, PhysListEmStandard "local" (similar to opt0) is also
available.
Optional components can be added:
- "elastic" elastic scattering of hadrons
- "binary" QBBC configuration of hadron/ion inelastic models
- "gamma_nuc" gamma- and electro-nuclear processes
- "stopping" stopping processes
3- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle which hits the
cylinder perpendicular to the input face. The type of the particle
and its energy are set in the PrimaryGeneratorAction class, and can
changed via the G4 build-in commands of G4ParticleGun class.
4- OUTPUT
The batch regime of simulation can be started
$G4WORKDIR/bin/$G4SYSTEM/TestEm9 TestEm9.in
where TestEm9.in is the example of macro file for batch job.
As a result of simulation the number of secondaries produced
in different regions are averaged. The average energy depositions
in active absorbers and EM as well as RMS of these values are shown.
The number of hits in pads of VD is printed out.
5- VISUALISATION
To use visualisation the environment variable G4_VIS_USE should be
defined. An interactive session starts if no macro file is specified
in the command line:
$G4WORKDIR/bin/$G4SYSTEM/TestEm9
To start visualisation one can issur
>/control/execute vis.mac
>/run/beamOn 1
6- ANALYSIS
Number of histograms are built inside the example using internal
analysis sub-package. Histograms are saved in a root file.
Histogram booking and saving is done only if any of histogram
/testem/histo/fileName myname
/testem/histo/setHisto id nbins xmin xmax unit
@@ -0,0 +1,37 @@
///\file "errorpropagation/.README.txt"
///\brief Exampleerrorpropagation README page
/*! \page Exampleerrorpropagation Category/example "errorpropagation"
This is an example illustrating the use of the error propagation utility.
A G4ErrorFreeTrajState is created to simulate a muon track of 20 GeV along the X axis. Then the track is propagated until the target is reached.
The geometry is a simplified typical HEP detector:
- An air beamline ( BEAM )
- An air central detector ( CDET )
- A copper calorimeter, divided in four ( ECAL )
- An aluminium calorimeter, divided in ten ( HCAL )
- An air muon detector ( MUON )
It is inmersed in a magnetic field along the Z axis with default value -1 kilogauss. This value can be changed with the command "/exerror/setField.
The type of target can be chosen with the enviromental variable G4ERROR_TARGET:
- PLANE_SURFACE : use a G4ErrorPlaneSurfaceTarget perpendicular to X at (2241. mm, 0, 0)
- CYL_SURFACE : use a G4ErrorCylSurfaceTarget parallel to Z of radius 2220 mm
- VOLUME : use a G4ErrorGeomVolumeTarget with volume name "MUON"
- TRKLEN : use a G4ErrorTrackLengthTarget with track length 2230 mm
The user may also choose if the propagation is done forwards (the natural way, loosing energy) or backwards (in opposite direction, gaining energy), with the enviromental variable G4ERROR_MODE:
- FORWARDS : propagate in the forward direction
- BACKWARDS : propagate in the backward direction
There are also two modes of propagation, that can be chosen with the enviromental variable G4ERROR_PROP
- UNTIL_TARGET : propagate until target, all steps in one go
- STEP_BY_STEP propagate until target, returning control to the user at each step
*/
+33
View File
@@ -0,0 +1,33 @@
This is an example illustrating the use of the error propagation utility.
A G4ErrorFreeTrajState is created to simulate a muon track of 20 GeV along the X axis. Then the track is propagated until the target is reached.
The geometry is a simplified typical HEP detector:
An air beamline ( BEAM )
An air central detector ( CDET )
A copper calorimeter, divided in four ( ECAL )
An aluminium calorimeter, divided in ten ( HCAL )
An air muon detector ( MUON )
It is inmersed in a magnetic field along the Z axis with default value -1 kilogauss. This value can be changed with the command "/exerror/setField.
The type of target can be chosen with the enviromental variable G4ERROR_TARGET:
PLANE_SURFACE : use a G4ErrorPlaneSurfaceTarget perpendicular to X at (2241. mm, 0, 0)
CYL_SURFACE : use a G4ErrorCylSurfaceTarget parallel to Z of radius 2220 mm
VOLUME : use a G4ErrorGeomVolumeTarget with volume name "MUON"
TRKLEN : use a G4ErrorTrackLengthTarget with track length 2230 mm
The user may also choose if the propagation is done forwards (the natural way, loosing energy) or backwards (in opposite direction, gaining energy), with the enviromental variable G4ERROR_MODE:
FORWARDS : propagate in the forward direction
BACKWARDS : propagate in the backward direction
There are also two modes of propagation, that can be chosen with the enviromental variable G4ERROR_PROP
UNTIL_TARGET : propagate until target, all steps in one go
STEP_BY_STEP propagate until target, returning control to the user at each step
@@ -0,0 +1,49 @@
///\file "eventgenerator/.README.txt"
///\brief Examples eventgenerator README page
/*! \page Examples_eventgenerator Category "eventgenerator"
Examples in this directory demonstrate various ways of primary event
generation.
\link ExampleparticleGun particleGun \endlink
This example demonstrates 4 ways of the usage of G4ParticleGun shooting
primary particles in different cases.
\link Exampleexgps exgps \endlink
This example demonstrates the usage of G4GeneralParticleSource for generating
primary incident particle according to user defined distributions.
\link ExampleuserPrimaryGenerator userPrimaryGenerator \endlink
This example shows how to create a primary event including several vertices and
several primary particles per vertex.
\link Examples_HepMC HepMC \endlink
This directory contains examples for using HepMC as an interface with
various Monte Carlo event generators, such as PYTHIA.
It also include an example for demonstrating MC truth handling with HepMC.
\link Examples_pythia pythia \endlink
This directory contains the following examples:
a) use of Pythia6 as Monte Carlo event generator, interfaced with Geant4,
and showing how to implement an external decayer based on Pythia6.
The feature is activated by setting environment variable PYTHIA6 to point
to the Pythia6 installation area.
For details, please see \link Exampledecayer6 Example decayer6 \endlink.
b) use of Pythia8 as an external decayer to replace native Geant4 decay
tables for such resonances as tau+/- and B+/-, and to supplement Pythia8-based
decay tables to those resonances where Geant4 native decay features are not
implemented.
The feature is activated by setting environment variable PYTHIA8 to point
to the Pythia8 installation area.
For details, please see \link Examplepy8decayer Example py8decayer \endlink.
*/
@@ -0,0 +1,120 @@
///\file "eventgenerator/HepMC/.README.txt"
///\brief Examples HepMC README page
/*! \page Examples_HepMC Category "eventgenerator/HepMC"
This directory contains examples for using HepMC as an interface with
various Monte Carlo event generators, such as PYTHIA.
It also include an example for demonstrating MC truth handling with HepMC.
\section HepMC_s1 Requirements for external software packages
\subsection HepMC_sub_s11 HepMC
- Tested version : 2.06.09
- http://lcgapp.cern.ch/project/simu/HepMC/
Note: examples were tested only on Linux with gcc.
\subsection HepMC_sub_s12 PYTHIA
- Tested version 6.4.26
- URL: http://www.thep.lu.se/~torbjorn/Pythia.html
\section HepMC_s2 Examples HepMCEx01 and HepMCEx02
\subsection HepMC_sub_s21 class HepMCG4Interface
This class is derived from G4VPrimaryGenerator, and is a base class
for primary generation via HepMC object.
protected members:
- virtual HepMC::GenEvent* GenerateHepMCEvent() \n
Implement this method in his/her own concrete class.
An empty event will be created in default.
- void HepMC2G4(const HepMC::GenEvent* hepmcevt, G4Event* g4event) \n
service method for conversion from HepMC::GenEvent to G4Event
- virtual G4bool CheckVertexInsideWorld(const G4ThreeVector& pos) const \n
We have to take care for the position of primaries because
primary vertices outside the world volume give rise to G4Exception.
If the default implementation is not adequate, an alternative
can be implemented in your own class.
public members:
- virtual void GeneratePrimaryVertex(G4Event* anEvent) \n
The default behavior is that a single HepMC event generated by
GenerateHepMCEvent() will be converted to G4Event through HepMC2G4().
\subsection HepMC_sub_s22 class HepMCG4AsciiReader / HepMCG4AsciiReaderMessenger (derived from HepMCG4Interface)
This derived class is for reading primary information from
an Ascii file generated by HepMC.
\subsection HepMC_sub_s23 class HepMCG4PythiaInterface / HepMCG4AsciiReaderMessenger (derived from HepMCG4Interface)
This derived class is for directly calling PYTHIA functions.
Users can set parameters, initialize, generate, and terminate
by command line operation.
\subsection HepMC_sub_s24 Macros in examples
- hepmc_pygen.in \n
process PYTHIA events(H->4mu) generated at every event.
- hepmc_ascii.in \n
read pregenerated events from HepMC Ascii file (data/example_MyPythia.dat).
\subsection HepMC_sub_s25 Installation
- 1. Download and install HepMC from: \n
http://lcgapp.cern.ch/project/simu/HepMC/ \n
and define the environment variable:
\verbatim
HEPMC_DIR the path to HepMC installation.
\endverbatim
- 2. Download the PYTHIA6 source file from the PYTHIA6 download site:\n
http://www.hepforge.org/downloads/pythia6
- 2A. With CMake: Build pythia6 library
For a convenience a CMake file for building Pythia6 library from
the source is provided in
examples/extended/eventgenerator/CMakeLists.txt.pythia6.
Build the pythia6 library following the instructions in this file
and then define the environment variables:
\verbatim
PYTHIA6 the path where pythia6 library is installed
PYTHIA6_VERSION the pythia version
\endverbatim
- 2B. With GNUmake: Define the environment variables: \n
\verbatim
PYTHIA6 the path to pythia-versionX.f source code
PYTHIA6_VERSION the pythia version
\endverbatim
e.g. If you download pythia-6.4.26.f.gz and unzip it in $HOME,
then you have to set:
export PYTHIA6=$HOME
export PYTHIA6_VERSION="6.4.26"
pythia6 will be then compiled together with example code.
- 3. Compilation:\n
Then the examples are compiled in a standard way, see \ref README_HowToRun.
\subsection HepMC_sub_s26 Examples
See more details in \ref ExampleHepMCEx01 and \ref ExampleHepMCEx02.
\subsection HepMC_sub_s27 Notes
We attached a sample HepMC Ascii data file, "data/example_MyPythia.dat",
which contains 10 PYTHIA events created by "data/example_MyPythia.cxx".
\section HepMC_s3 Example MCTruth
Application \link ExampleMCTruth MCTruth \endlink demonstrating handling of Monte-Carlo truth information through the HepMC package.
*/
@@ -0,0 +1,56 @@
///\file "eventgenerator/HepMC/HepMCEx01/.README.txt"
///\brief Example HepMCEx01 README page
/*! \page ExampleHepMCEx01 Example HepMCEx01
HepMCEx01 is based on Example N04, which has a simplified collider detector
geometry. Only part of the primary generator action is replaced with new one.
This example demonstrates the following features.
\section ExampleHepMCEx01_s1 HepMC interface
ExN04PrimaryGeneratorAction has HepMCG4Interface as the generator.
There are two types of generators provided as samples. One generator reads
primary information from a HepMC Ascii file (data/example_MyPythia.dat).
The other one generates primaries directly invoking PYTHIA routines
in every event.
\section ExampleHepMCEx01_s2 Readout geometry
ExN04DetectorConstruction defines a simplified collider detecor
geometry, tracker made of cylindrical tubes, calorimeter made of
cylindrical tubes, and muon trackers made of planes.
Cylindrical calorimeter is made of tubes of lead and scintirator
without cut in phi nor z direction. Energy deposition in scintirator
is accumulated by ExN04CalorimeterSD sensitive detector, which has
a readout geometry to find the phi-z cell.
\section ExampleHepMCEx01_s3 Full set of "ordinary" physics processes
FTFP_BERT physics list defines almost all of leptons and hadrons which
Geant4 has dedicated classes for. Also almost all physics processes
Geant4 has are defined.
\section ExampleHepMCEx01_s4 Event filtering by the stacking mechanism.
Higgs events in "pythia_event.data" have two lepton pairs produced
by the Higgs decay via Z0. At the first stage of each event, only the
primary muons are tracked without tracking secondaries. then the number
of hits on the muon trackers are examined. At the next stage, only
the primary charged particles are tracked only inside the barrel
tracking area and the isolation of the primary muons are examined.
At the third stage, all particles in the RoI (Region of Interest) along
the isolated muons are tracked. All these examinations are applied in
ExN04StackingAction.
\section ExampleHepMCEx01_s5 Installation
See \ref Examples_HepMC how to build this example.
\section ExampleHepMCEx01_s6 Execution
\verbatim
% HepMCEx01 hepmc_pygen.in
\endverbatim
*/
@@ -0,0 +1,57 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
HepMCEx01
---------
HepMCEx01 is based on ExampleN04, which has a simplified collider detector
geometry. Only part of the primary generator action is replaced with new one.
This example demonstrates the following features.
1. HepMC interface
ExN04PrimaryGeneratorAction has HepMCG4Interface as the generator.
There are two types of generators provided as samples. One generator reads
primary information from a HepMC Ascii file (data/example_MyPythia.dat).
The other one generates primaries directly invoking PYTHIA routines
in every event.
2. Readout geometry
ExN04DetectorConstruction defines a simplified collider detecor
geometry, tracker made of cylindrical tubes, calorimeter made of
cylindrical tubes, and muon trackers made of planes.
Cylindrical calorimeter is made of tubes of lead and scintirator
without cut in phi nor z direction. Energy deposition in scintirator
is accumulated by ExN04CalorimeterSD sensitive detector, which has
a readout geometry to find the phi-z cell.
3. Full set of "ordinary" physics processes
FTFP_BERT physics list defines almost all of leptons and hadrons which
Geant4 has dedicated classes for. Also almost all physics processes
Geant4 has are defined.
4. Event filtering by the stacking mechanism.
Higgs events in "pythia_event.data" have two lepton pairs produced
by the Higgs decay via Z0. At the first stage of each event, only the
primary muons are tracked without tracking secondaries. then the number
of hits on the muon trackers are examined. At the next stage, only
the primary charged particles are tracked only inside the barrel
tracking area and the isolation of the primary muons are examined.
At the third stage, all particles in the RoI (Region of Interest) along
the isolated muons are tracked. All these examinations are applied in
ExN04StackingAction.
5. Installation
See HepMC/README how to build this example.
6. Execution
% HepMCEx01 hepmc_pygen.in
@@ -0,0 +1,47 @@
///\file "eventgenerator/HepMC/HepMCEx02/.README.txt"
///\brief Example HepMCEx02 README page
/*! \page ExampleHepMCEx02 Example HepMCEx02
This example demonstrates how to interface primary particles in Geant4
with various event generators via the HepMC Monte Carlo event interface.
This is another example having the same generator action as HepMCEx01,
but much simpler user control.
\section ExampleHepMCEx02_s1 Primary Generator
H02PrimaryGeneratorAction has HepMCG4Interface as the generator.
There are two types of generators provided as samples. One generator reads
primary information from a HepMC Ascii file (data/example_MyPythia.dat).
The other one generates primaries directly invoking PYTHIA routines
in every event.
\section ExampleHepMCEx02_s2 Geometry
A simplified collider-type geometry, which consists of
- endcap calorimeter (a set of tubes filled with lead),
- barrel calorimeter (tube filled with lead),
- barrel muon detector (8 sets of plates filled with Ar),
- endcap muon detecror, (a set of tubes filled with Ar) and
- uniform magnetic field along the z axis of 3 Tesla at the
central region.
\section ExampleHepMCEx02_s3 Physics List
FTFP_BERT predefined physics list
\section ExampleHepMCEx02_s4 User actions
All particles except muons are killed in the calorimeter section.
\section ExampleHepMCEx02_s5 Installation
See \ref Examples_HepMC how to build this example.
\section ExampleHepMCEx02_s6 Execution
\verbatim
% HepMCEx02 hepmc_pygen.in
\endverbatim
*/
@@ -0,0 +1,48 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
HepMCEx02
---------
This example demonstrates how to interface primary particles in Geant4
with various event generators via the HepMC Monte Carlo event interface.
This is another example having the same generator action as HepMCEx01,
but much simpler user control.
1. Primary Generator
H02PrimaryGeneratorAction has HepMCG4Interface as the generator.
There are two types of generators provided as samples. One generator reads
primary information from a HepMC Ascii file (data/example_MyPythia.dat).
The other one generates primaries directly invoking PYTHIA routines
in every event.
2. Geometry
A simplified collider-type geometry, which consists of
- endcap calorimeter (a set of tubes filled with lead),
- barrel calorimeter (tube filled with lead),
- barrel muon detector (8 sets of plates filled with Ar),
- endcap muon detecror, (a set of tubes filled with Ar) and
- uniform magnetic field along the z axis of 3 Tesla at the
central region.
3. Physics List
FTFP_BERT predefined physics list
4. User actions
All particles except muons are killed in the calorimeter section.
5. Installation
See HepMC/README how to build this example.
6. Execution
% HepMCEx02 hepmc_pygen.in
@@ -0,0 +1,168 @@
///\file "eventgenerator/HepMC/MCTruth/.README.txt"
///\brief Example MCTruth README page
/*! \page ExampleMCTruth Example MCTruth
MCTRUTH using HepMC
This example demonstrates a mechanism for Monte Carlo truth handling
using HepMC as the event record. The user does not interact directly
with the HepMC classes but with the MCTruthManager class which takes
care with storing all the necessary information about particles,
vertices and relations between them. A specialized tracking action is
used to test whether given particle is to be stored or not. The
decision criteria for storing particle are configurable via the
MCTruthConfig class.
\section ExampleMCTruth_s1 HOW TO BUILD THE EXAMPLE ?
- if you do not have it yet, install HepMC event record (tested with version 2.06.08)
- set HEPMC_ROOT_DIR variable to point to the directory where HepMC is installed;
if the HepMC is installed in your system directory (/usr/local) you do not need to set anything
- run the CMake configuration and build mctruthex target in your build directory
- execute the application:
\verbatim
% your_binary_directory/mctruthex
\endverbatim
\section ExampleMCTruth_s2 DESCRIPTION OF THE MCTRUTH HANDLING MECHANISM
The main element of the MC truth handling machinery is the
MCTruthManager class. This class is responsible for all the
interaction with the HepMC event and does not depend on Geant4. It is
a singleton, therefore it is guaranteed to be instanciated only once
and the static 'GetInstance' method allows to access it from anywhere
in the code. It contains methods like MCTruthManager::NewEvent() to start a new event,
MCTruthManager::AddParticle() to add particle to the current event, as well as
MCTruthManager::PrintEvent() for the purpose of the debugging. The core of the
algorithm which deals with building up the MC truth event tree within
the HepMC event is implemented in MCTruthManager::AddParticle() method.
The MCTruthManager::AddParticle() method is called with the following arguments:
four-momentum, production position and 'end' position of the particle,
PDG code of the particle, as well as the particle ID (unique identifier,
as we will see later, corresponding to Geant4 TrackID) and the ID of
the mother. Finally, there is a boolean flag specifying whether the
direct mother of the given particle has been stored, or not.
The first step, which always takes place, is to instanciate a new
HepMC::GenParticle with the barcode corresponding to particle ID, as
well as to instanciate a new HepMC::GenVertex which will represent the
'end' vertex of the particle. The barcode of the 'end vertex' is equal
to minus the barcode of the particle.
We can now distinguish several cases:
- 1) the particle is a primary in the Geant4 language, i.e. its
mother ID is 0
\n\n
This is the simplest case, we just instanciate a new 'primary'
(without any incoming particles) GenVertex, we add to it the
particle and we put it all in the event. Additionally we store the
ID of the particle in a special vector, where all the IDs of
primary particles will be stored, allowing quick access to each of
the main 'branches' of the event. We return from the method.
- 2) the particle is not a primary
\n\n
We use the 'event->barcode_to_particle(motherID)' method to get the
pointer to its mother.
\n\n
We check if the 'end vertex' of the mother corresponds to the
'production vertex' of the particle in question.
\n\n
- 2.1) If the two vertices do match, we attach the new particle to
the 'end vertex' of the mother. We return from the method.
\n\n
- 2.2) If the two vertices do not match, i.e. the new particle is not
a product of the 'end vertex' of the mother particle, we can
have two cases:
\n\n
- 2.2.1) The boolean flag says that the direct mother of the
particle has _not_ been stored. This means that the
particle has been 'adopted' by one of its ancestors, or
in other words, the mother ID of the particle does not
correspond to its direct mother (so clearly the
vertices cannot match). This for instance could happen
if we decided not to store gamma coming from pi0 decay
but did decide to store e+/- coming from the gamma
conversion (so the gamma between pi0 and e+/- was
missing). In such a case we instanciate (or use one of
the existing ones, if vertices match) a 'dummy'
particle (with pdg = -999999) which then acts as the
link between the 'adopted' particle and the
(non-direct) mother. In such a way, the navigability up
in the event is still possible, but in the same time,
we can clearly see that the link is not a direct
one. We return from the method.
\n\n
- 2.2.2) The boolean flag says that direct mother of the
particle _has_ been stored. Taking into account that
the vertices do not match, it can mean only one
thing. The new particle has been produced 'on the
flight', i.e. somewhere 'before' the 'end vertex' of
the mother. This can be the case, for instace, for
delta electrons, bremsstrahlung gammas, etc. In such a
situation, we 'split' the mother particle in two
particles and create a new vertex from which the
secondary will be going out. The complication, however,
arises when we have more than one generated 'on the
flight' particle attached to the same mother. In such a
case, for each secondary we need to locate the right
'segment' of the mother particle (i.e. we need to find
between which two vertices we need to add a new
one). To keep track of those segmentations we introduce
a map where each particle ID we map into the number of
existing segments (in the normal case one). Each new
'segment' gets barcode equal to the barcode of the
original particle + N*10000000, where N is the segment
number. In such a way, one can easily follow the
'segmentation' (if any) of each particle. We return
from the method.
This concludes the description of MCTruthManager. The MCTruthConfig
class is a collection of criteria (minimal energy, PDG, creator
process, etc) that we want to apply when deciding whether to store or
not given particle. These values are used by the
'MCTruthTrackingAction' which we describe below. This class can
certainly be extended with other members.
The actual Geant4-dependent part of the MCTruth handling machinery
consists of a few 'G4 user actions' as well as an implementation of
G4VUserTrackInformation. The later one is, for the moment, used only
to store one boolean flag indicating whether the direct mother of the
given track has been stored or not.
The first user action is MCTruthEventAction which is only reponsible
for calling MCTruthManager::NewEvent() at the beginning
of each event. It can also be used for printing out events for the
purpose of debugging.
The actual 'decision making' concerning which particle to store is
done in MCTruthTrackingAction. At the end of each track the method
trackToBeStored(track) is called to check for various characteristics
of the particle. These, for instance can be energy, particle ID,
creator process, etc.
If the particle satisfies the conditions the
MCTruthManager::AddParticle is called and all the
procedure described above is performed. The important element here is
that the Geant4 TrackID is used as the unique particle ID in
MCTruthManager and eventually as the barcode of the
HepMC::GenParticle.
If the particle does not qualify to be stored, there are two actions
performed. First the 'ParentID' of the _daughters_ is set to the
'ParentID' of the currenly processed particle. In other words, the
'ParentID' of the daughters is set to the ID of the last stored
particle. Second, the 'directParent' flag from MCTruthTrackInformation
of the __daughters__ is set to FALSE. In such a way, one is still able
to navigate up in the event (to get the ancestors of the particle),
but in the same time, the particle is flagged as 'not having direct
parent'.
*/
@@ -0,0 +1,165 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
MCTRUTH using HepMC
-------------------
This example demonstrates a mechanism for Monte Carlo truth handling
using HepMC as the event record. The user does not interact directly
with the HepMC classes but with the MCTruthManager class which takes
care with storing all the necessary information about particles,
vertices and relations between them. A specialized tracking action is
used to test whether given particle is to be stored or not. The
decision criteria for storing particle are configurable via the
MCTruthConfig class.
HOW TO BUILD THE EXAMPLE ?
- if you do not have it yet, install HepMC event record (tested with version 2.06.08)
- set HEPMC_ROOT_DIR variable to point to the directory where HepMC is installed;
if the HepMC is installed in your system directory (/usr/local) you do not need to set anything
- run the CMake configuration and build mctruthex target in your build directory
- execute the application:
% your_binary_directory/mctruthex
DESCRIPTION OF THE MCTRUTH HANDLING MECHANISM
The main element of the MC truth handling machinery is the
MCTruthManager class. This class is responsible for all the
interaction with the HepMC event and does not depend on Geant4. It is
a singleton, therefore it is guaranteed to be instanciated only once
and the static 'GetInstance' method allows to access it from anywhere
in the code. It contains methods like 'NewEvent' to start a new event,
'AddParticle' to add particle to the current event, as well as
'PrintEvent' for the purpose of the debugging. The core of the
algorithm which deals with building up the MC truth event tree within
the HepMC event is implemented in AddParticle method.
The AddParticle method is called with the following arguments:
four-momentum, production position and 'end' position of the particle,
PDG code of the particle, as well as the particle ID (unique identifier,
as we will see later, corresponding to Geant4 TrackID) and the ID of
the mother. Finally, there is a boolean flag specifying whether the
direct mother of the given particle has been stored, or not.
The first step, which always takes place, is to instanciate a new
HepMC::GenParticle with the barcode corresponding to particle ID, as
well as to instanciate a new HepMC::GenVertex which will represent the
'end' vertex of the particle. The barcode of the 'end vertex' is equal
to minus the barcode of the particle.
We can now distinguish several cases:
1) the particle is a primary in the Geant4 language, i.e. its
mother ID is 0
This is the simplest case, we just instanciate a new 'primary'
(without any incoming particles) GenVertex, we add to it the
particle and we put it all in the event. Additionally we store the
ID of the particle in a special vector, where all the IDs of
primary particles will be stored, allowing quick access to each of
the main 'branches' of the event. We return from the method.
2) the particle is not a primary
We use the 'event->barcode_to_particle(motherID)' method to get the
pointer to its mother.
We check if the 'end vertex' of the mother corresponds to the
'production vertex' of the particle in question.
2.1) If the two vertices do match, we attach the new particle to
the 'end vertex' of the mother. We return from the method.
2.2) If the two vertices do not match, i.e. the new particle is not
a product of the 'end vertex' of the mother particle, we can
have two cases:
2.2.1) The boolean flag says that the direct mother of the
particle has _not_ been stored. This means that the
particle has been 'adopted' by one of its ancestors, or
in other words, the mother ID of the particle does not
correspond to its direct mother (so clearly the
vertices cannot match). This for instance could happen
if we decided not to store gamma coming from pi0 decay
but did decide to store e+/- coming from the gamma
conversion (so the gamma between pi0 and e+/- was
missing). In such a case we instanciate (or use one of
the existing ones, if vertices match) a 'dummy'
particle (with pdg = -999999) which then acts as the
link between the 'adopted' particle and the
(non-direct) mother. In such a way, the navigability up
in the event is still possible, but in the same time,
we can clearly see that the link is not a direct
one. We return from the method.
2.2.2) The boolean flag says that direct mother of the
particle _has_ been stored. Taking into account that
the vertices do not match, it can mean only one
thing. The new particle has been produced 'on the
flight', i.e. somewhere 'before' the 'end vertex' of
the mother. This can be the case, for instace, for
delta electrons, bremsstrahlung gammas, etc. In such a
situation, we 'split' the mother particle in two
particles and create a new vertex from which the
secondary will be going out. The complication, however,
arises when we have more than one generated 'on the
flight' particle attached to the same mother. In such a
case, for each secondary we need to locate the right
'segment' of the mother particle (i.e. we need to find
between which two vertices we need to add a new
one). To keep track of those segmentations we introduce
a map where each particle ID we map into the number of
existing segments (in the normal case one). Each new
'segment' gets barcode equal to the barcode of the
original particle + N*10000000, where N is the segment
number. In such a way, one can easily follow the
'segmentation' (if any) of each particle. We return
from the method.
This concludes the description of MCTruthManager. The MCTruthConfig
class is a collection of criteria (minimal energy, PDG, creator
process, etc) that we want to apply when deciding whether to store or
not given particle. These values are used by the
'MCTruthTrackingAction' which we describe below. This class can
certainly be extended with other members.
The actual Geant4-dependent part of the MCTruth handling machinery
consists of a few 'G4 user actions' as well as an implementation of
G4VUserTrackInformation. The later one is, for the moment, used only
to store one boolean flag indicating whether the direct mother of the
given track has been stored or not.
The first user action is MCTruthEventAction which is only reponsible
for calling MCTruthManager::GetInstance()->NewEvent() at the beginning
of each event. It can also be used for printing out events for the
purpose of debugging.
The actual 'decision making' concerning which particle to store is
done in MCTruthTrackingAction. At the end of each track the method
trackToBeStored(track) is called to check for various characteristics
of the particle. These, for instance can be energy, particle ID,
creator process, etc.
If the particle satisfies the conditions the
MCTruthManager::GetInstance()->AddParticle is called and all the
procedure described above is performed. The important element here is
that the Geant4 TrackID is used as the unique particle ID in
MCTruthManager and eventually as the barcode of the
HepMC::GenParticle.
If the particle does not qualify to be stored, there are two actions
performed. First the 'ParentID' of the _daughters_ is set to the
'ParentID' of the currenly processed particle. In other words, the
'ParentID' of the daughters is set to the ID of the last stored
particle. Second, the 'directParent' flag from MCTruthTrackInformation
of the __daughters__ is set to FALSE. In such a way, one is still able
to navigate up in the event (to get the ancestors of the particle),
but in the same time, the particle is flagged as 'not having direct
parent'.
@@ -0,0 +1,118 @@
Examples for HepMC-Geant4 interface
-----------------------------------
This directory contains examples for using HepMC as an interface with
various Monte Carlo event generators, such as PYTHIA.
It also include an example for demonstrating MC truth handling with HepMC.
Requirements for external software packages
-------------------------------------------
HepMC:
Tested version : 2.06.09
http://lcgapp.cern.ch/project/simu/HepMC/
Note: examples were tested only on Linux with gcc.
PYTHIA
Tested version 6.4.26
URL: http://www.thep.lu.se/~torbjorn/Pythia.html
Examples HepMCEx01 and HepMCEx02
================================
class HepMCG4Interface
This class is derived from G4VPrimaryGenerator, and is a base class
for primary generation via HepMC object.
protected members
+ virtual HepMC::GenEvent* GenerateHepMCEvent()
Implement this method in his/her own concrete class.
An empty event will be created in default.
+ void HepMC2G4(const HepMC::GenEvent* hepmcevt, G4Event* g4event)
service method for conversion from HepMC::GenEvent to G4Event
+ virtual G4bool CheckVertexInsideWorld(const G4ThreeVector& pos) const
We have to take care for the position of primaries because
primary vertices outside the world volume give rise to G4Exception.
If the default implementation is not adequate, an alternative
can be implemented in your own class.
public members
+ virtual void GeneratePrimaryVertex(G4Event* anEvent)
The default behavior is that a single HepMC event generated by
GenerateHepMCEvent() will be converted to G4Event through HepMC2G4().
class HepMCG4AsciiReader / HepMCG4AsciiReaderMessenger
(derived from HepMCG4Interface)
This derived class is for reading primary information from
an Ascii file generated by HepMC.
class HepMCG4PythiaInterface / HepMCG4AsciiReaderMessenger
(derived from HepMCG4Interface)
This derived class is for directly calling PYTHIA functions.
Users can set parameters, initialize, generate, and terminate
by command line operation.
Macros in examples
-----------------
hepmc_pygen.in
process PYTHIA events(H->4mu) generated at every event.
hepmc_ascii.in
read pregenerated events from HepMC Ascii file (data/example_MyPythia.dat).
Installation
--------------
1. Download and install HepMC from:
http://lcgapp.cern.ch/project/simu/HepMC/
(Last tested version : 2.06.09)
and define the environment variable:
HEPMC_DIR the path to HepMC installation.
2. Download the PYTHIA6 source file from the PYTHIA6 download site:
http://www.hepforge.org/downloads/pythia6
A) With CMake: Build pythia6 library
For a convenience a CMake file for building Pythia6 library from
the source is provided in
examples/extended/eventgenerator/CMakeLists.txt.pythia6.
Build the pythia6 library following the insytructions in this file
and then define the environment variables:
PYTHIA6 the path where pythia6 library is installed
PYTHIA6_VERSION the pythia version
B) With GNUmake: Define the environment variables
PYTHIA6 the path to pythia-versionX.f source code
PYTHIA6_VERSION the pythia version
e.g. If you download pythia-6.4.26.f.gz and unzip it in $HOME,
then you have to set:
export PYTHIA6=$HOME
export PYTHIA6_VERSION="6.4.26"
Pythia6 will be then compiled together with example code.
3. Compilation:
Then the examples are compiled in a standard way,
see examples/README_HowToRun.
Examples
----------
See more details in HepMCEx01/README and HepMCEx02/README.
Notes
-----
We attached a sample HepMC Ascii data file, "data/example_MyPythia.dat",
which contains 10 PYTHIA events created by "data/example_MyPythia.cxx".
Example MCTruth
===============
Application demonstrating handling of Monte-Carlo truth information through
the HepMC package.
+51
View File
@@ -0,0 +1,51 @@
Geant4 extended examples - event generator
-------------------------------------------
Examples in this directory demonstrate various ways of primary event
generation.
particleGun
------------
This example demonstrate 4 ways of the usage of G4ParticleGun shooting
primary particles in different cases.
exgps
-----
This example demonstrates the usage of G4GeneralParticleSource for generating
primary incident particle according to user defined distributions.
userPrimaryGenerator
--------------------
This example shows how to create a primary event including several vertices and
several primary particles per vertex.
HepMC
------
This directory contains examples for using HepMC as an interface with
various Monte Carlo event generators, such as PYTHIA.
It also include an example for demonstrating MC truth handling with HepMC.
pythia
------
This directory contains the following examples:
a) use of Pythia6 as Monte Carlo event generator, interfaced with Geant4,
and showing how to implement an external decayer based on Pythia6.
The feature is activated by setting environment variable PYTHIA6 to point
to the Pythia6 installation area.
For details, please see pythia/decayer6/README.
b) use of Pythia8 as an external decayer to replace native Geant4 decay
tables for such resonances as tau+/- and B+/-, and to supplement Pythia8-based
decay tables to those resonances where Geant4 native decay features are not
implemented.
The feature is activated by setting environment variable PYTHIA8 to point
to the Pythia8 installation area.
For details, please see pythia/py8decayer/README.
@@ -0,0 +1,101 @@
///\file "eventgenerator/exgps/.README.txt"
///\brief Example exgps README page
/*! \page Exampleexgps Example exgps
exgps is created to demonstrate the usage of G4GeneralParticleSource
for generating primary particle according to user defined distributions.
These range from simple monocromatic point source to complicated mutiple
sources with various biasing schemes.
http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides
/ForApplicationDeveloper/html/ch02s07.html
\section exgps_s1 GEOMETRY
Simple geometry consists of a "Vacuum" world and, in it, two other components:
- An alunimium box : 20 x 20 x 20 cm in size, cerntered at the origin.
- A SiO2 sphere (radius 5 cm) is placed at the centre of the aluminium box.
\section exgps_s2 PHYSICS
Tranportation process only for all particles.
\section exgps_s3 EVENT
The event generator is the G4GeneralParticleSource (GPS). The instantiation of
G4GeneralParticleSource is same as that for G4ParticleGun.
See the exGPSPrimaryGeneratorAction.cc file for details.
\section exgps_s4 VISUALIZATION
Visualisation of the geometry and the tracks is possible with many of the
G4 visualisation packages.
An example of displaying the geometry and tracks using OGL is given in the
macro vis.mac.
\section exgps_s5 HISTOGRAMS
This example implements an histo manager which creates histograms and
ntuples using Geant4 analysis tools.
The output file contains 6 histograms and one ntuple:
histo1D 1: energy spectrum.
histo1D 2: vertex: radial distribution dN/dv.
histo1D 3: angular distribution: cos(theta).
histo1D 4: angular distribution: phi.
histo2D 1: vertex position in the X-Y plane.
histo2D 2: vertex position in the X-Z plane.
histo2D 3: vertex position in the Y-Z plane.
histo2D 4: angular distribution: phi-cos(theta).
histo2D 5: angular distribution: of phi-theta.
In the ntuple the following data are recorded for each incident particle:
Particle ID
Incident Position (x,y,z);
Incident Angle (theta,phi);
Particle weight;
The histograms are managed by G4AnalysisManager class and its Messenger.
The histos can be individually activated with the command :
\verbatim
/analysis/h1/set id nbBins valMin valMax unit
\endverbatim
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
\verbatim
/analysis/setFileName name (default exgps)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
\section exgps_s6 GETTING STARTED
- execute exgps in 'batch' mode from macro files
\verbatim
% exgps exgps.in
\endverbatim
- execute exgps in 'interactive mode' with visualization
\verbatim
% exgps
....
Idle> type your commands
....
Idle> exit
\endverbatim
\section exgps_s7 FURTHER EXAMPLES of MACRO FILES
There are a number of mac files in the ./macros subdirectory, to show the
various features of GPS.
Please see macros/README file for further informations.
*/
@@ -0,0 +1,92 @@
Extended Example for G4GeneralParticleSource (GPS)
--------------------------------------------------
exgps is created to demonstrate the usage of G4GeneralParticleSource
for generating primary particle according to user defined distributions.
These range from simple monocromatic point source to complicated mutiple
sources with various biasing schemes.
http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides
/ForApplicationDeveloper/html/ch02s07.html
1 - GEOMETRY
Simple geometry consists of a "Vacuum" world and, in it, two other components:
- An alunimium box : 20 x 20 x 20 cm in size, cerntered at the origin.
- A SiO2 sphere (radius 5 cm) is placed at the centre of the aluminium box.
2 - PHYSICS
Tranportation process only for all particles.
3 - EVENT
The event generator is the G4GeneralParticleSource (GPS). The instantiation of
G4GeneralParticleSource is same as that for G4ParticleGun.
See the exGPSPrimaryGeneratorAction.cc file for details.
4 - VISUALIZATION
Visualisation of the geometry and the tracks is possible with many of the
G4 visualisation packages.
An example of displaying the geometry and tracks using OGL is given in the
macro vis.mac.
5 - HISTOGRAMS
This example implements an histo manager which creates histograms and
ntuples using Geant4 analysis tools.
The output file contains 6 histograms and one ntuple:
histo1D 1: energy spectrum.
histo1D 2: vertex: radial distribution dN/dv.
histo1D 3: angular distribution: cos(theta).
histo1D 4: angular distribution: phi.
histo2D 1: vertex position in the X-Y plane.
histo2D 2: vertex position in the X-Z plane.
histo2D 3: vertex position in the Y-Z plane.
histo2D 4: angular distribution: phi-cos(theta).
histo2D 5: angular distribution: of phi-theta.
In the ntuple the following data are recorded for each incident particle:
Particle ID
Incident Position (x,y,z);
Incident Angle (theta,phi);
Particle weight;
The histograms are managed by G4AnalysisManager class and its Messenger.
The histos can be individually activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
/analysis/setFileName name (default exgps)
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
6 - GETTING STARTED
- execute exgps in 'batch' mode from macro files
% exgps exgps.in
- execute exgps in 'interactive mode' with visualization
% exgps
....
Idle> type your commands
....
Idle> exit
7 - FURTHER EXAMPLES of MACRO FILES
There are a number of mac files in the ./macros subdirectory, to show the
various features of GPS.
Please see README file there for further informations.
@@ -0,0 +1,167 @@
More info on http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides
/ForApplicationDeveloper/html/ch02s07.html
---------------------------------------------------------------------------
test01.mac
----------
point source, isotropic radiation, monoenergetic
test02.mac
----------
square plane source, cosine-law radiation, linear energy
test03.mac
----------
rectangular plane source, isotropic radiation, power-law energy
test04.mac
----------
circular plane source, cosine-law radiation, exponential energy
test05.mac
----------
elliptical plane source, isotropic radiation, bremsstrahlung energy
test06.mac
----------
spherical surface source, isotropic radiation, black-body energy
test07.mac
----------
cylindrical surface source, cosine-law radiation, Cosmic diffuse energy
test08.mac
----------
elliptical surface source, isotropic radiation, linear energy
test09.mac
----------
parallepiped surface source, isotropic radiation, linear energy
test10.mac
----------
spherical volume source, isotropic radiation, linear energy
test11.mac
----------
cylindrical volume source, isotropic radiation, power-law energy
test12.mac
----------
elliptical volume source, isotropic radiation, power-law energy
test13.mac
----------
parallelepiped volume source, cosine-law radiation, exponential energy
test14.mac
----------
rotated circular plane source, isotropic radiation, exponential energy
test15.mac
----------
rotated surface cylinder source, isotropic radiation, bremsstrahlung energy
test16.mac
----------
rotated parallelepiped volume source, isotropic radiation, bremsstrahlung energy
test17.mac
----------
confined spherical volume source, isotropic radiation, exponential energy
test18.mac
----------
square plane source, cosine-law radiation, user-defined energy histogram
test19.mac
----------
square plane source, cosine-law radiation, arbitrary point-wise energy function
with linear interpolation.
test20.mac
----------
square plane source, cosine-law radiation, arbitrary point-wise energy function
with logarithmic interpolation.
test21.mac
----------
square plane source, cosine-law radiation, arbitrary point-wise energy function
with exponential interpolation.
test22.mac
----------
square plane source, cosine-law radiation, arbitrary point-wise energy function
with spline interpolation.
test23.mac
----------
square plane source with x and y biasing, user-defined theta and phi
distributions, user-defined EPN energy distribution.
test24.mac
----------
spherical volume source with z biasing, isotropic radiation with theta and phi
biasing, arbitrary point-wise energy function with linear interpolation.
test25.mac
----------
spherical volume source, isotropic radiation with theta and phi biasing,
user-defined energy histogram
test26.mac
----------
square plane source, cosine-law radiation with lower and upper theta and phi
limits, linear energy with biasing.
test27.mac
----------
square plane source, user-defined theta, arbitrary point-wise energy function
with linear interpolation.
test28.mac
----------
particle=ion, square plane source, isotropic radiation, monoenergetic energy.
test29.mac
----------
plane source of type annulus, cosine-law radiation, exponential energy
test30.mac
----------
rotated 1d beam source, Gaussian beam energy
test31.mac
----------
two-beam incidence, i.e. multiple sources with relative intensities.
test32.mac
----------
Sphere volume source, with biasing in theta and phi
Isotropic directional distribution with theta and phi biasing
test33.mac
----------
Focused angular distribution.
test34.mac
----------
Two simultaneous sources, both fired at the same time.
test35.mac
----------
automatic biasing of the energy distribution sampling, original in power-law
test36.mac
----------
automatic biasing of the energy distribution sampling, original in arbitrary
data points
test37.mac
----------
automatic biasing of the energy distribution sampling, original in exponetial
form
test38.mac
----------
arbitrary energy distribution, defined using the ascii input file: spectrum.dat
@@ -0,0 +1,158 @@
///\file "eventgenerator/particleGun/.README.txt"
///\brief Example ParticleGun README page
/*! \page ExampleparticleGun Example particleGun
History:
- 10-06-2010 : Makoto Asai - merge into one example
- 13-05-2010 : Michel Maire - create as three examples
This example demonstrates 5 ways of the usage of G4ParticleGun shooting
primary particles in different cases. These are
-# uniform particle direction in a given solid angle
-# Generate several vertices and particles per event
-# Show how to sample a tabulated function (eg. energy spectrum)
-# Divergent beam in an arbitrary direction
-# Shooting primaries in spherical coordinates with rotation matrix.
These usages can be chosen by a UI command
\verbatim
/gunExample/selectGunAction actionID
\endverbatim
where <i>actionID</i> corresponds to above cases.
\section ParticleGun_s1 Geometry construction
It is a simple box which represents an 'infinite' homogeneous medium.
\section ParticleGun_s2 Physics list
PhysicsList.cc defines only geantino and transportation process.
\section ParticleGun_s3 Primary generator
There are 5 concrete primary generator action classes
(PrimaryGeneratorActionN, N=0,1,2,3,4) which can be used as an independent sample
code.
PrimaryGeneratorAction is the class which uses and switches between these
5 concrete action classes. Each concrete generator action shoots geantinoes
in a distribution decribed below.
\subsection ParticleGun_sub_s30 0. Uniform particle direction in a given solid angle
spherical angles (alpha,psi) respective to z axis
Histograms 5,6 show momentum direction in master frame.
\subsection ParticleGun_sub_s31 1. Generate several vertices and particles per event
- particle 1 : a geantino uniformly randomized on a cylinder surface.
- particle 2 and 3 : symetric to particle 1.
In addition, time_zero of each event is randomized.
\subsection ParticleGun_sub_s32 2. Show how to sample a tabulated function (energy spectrum)
Energy is sampled from a tabulated function defined in InitFunction().
The function is assumed positive, linear per segment, continuous.
Two sampling methods are illustrated : RejectAccept() and InverseCumul()
(see Particle Data book, Monte Carlo techniques).
Histogram 1 shows generated energy spectrum.
\subsection ParticleGun_sub_s33 3. Divergent beam in an arbitrary direction with rotation matrix
A geantino uniformly randomized around a given direction (theta, phi).
One wants to limit particle direction uniformly around this direction.
First, one generates momentum direction in the master frame (eg. World).
AlphaMax = opening angle around z axis.
Then one rotates momentum in local frame, using rotateUz() function.
RotateUz() transforms uz to newUz. It is composition of two simple rotations:
theta around oy, then phi around oz (non commutative). \n
See:
http://proj-clhep.web.cern.ch/proj-clhep/manual/UserGuide/VectorDefs/node49.html \n
Histograms 5,6 show momentum direction in local frame.
\subsection ParticleGun_sub_s34 4. Shooting primaries in spherical coordinates with rotation matrix
a geantino uniformly randomized within a spherical shell.
a) Vertex position
One wishes to shoot uniformly within a spherical shell.
One works in spherical coordinates. One uses inverse cumulative method with
analytical formulae. \n
Histograms 2,3,4 demonstrate uniform distribution of vertex position.
b) Momentum direction
One wants to limit particle direction uniformly within (alphaMin, alphaMax).
First, one generates momentum direction in the master frame (eg. World).
Then, one rotates momentum in vertex_position frame, using rotateUz() function.
RotateUz() transforms uz to ur. It is composition of two elementary rotations:
theta around oy, then phi around oz (non commutative). \n
See:
http://proj-clhep.web.cern.ch/proj-clhep/manual/UserGuide/VectorDefs/node49.html \n
Histograms 5,6 show momentum direction in vertex_position frame.
\section ParticleGun_s4 Visualisation
Visualization Manager is set in the main () (see particleGun.cc).
Initialisation of the drawing is done via the commands
/vis/.. in the macro vis.mac. This macro is automatically read from the main
in case of interactive running mode.
\section ParticleGun_s5 How to start ?
- Execute particleGun in 'batch' mode from macro files
\verbatim
% ParticleGun run1.mac
\endverbatim
- Execute particleGun2 in 'interactive mode' with visualization
\verbatim
% particleGun
....
Idle> ---> type your commands. For instance:
Idle> /gunExample/selectGunAction 1
Idle> /run/beamOn 10
....
Idle> exit
\endverbatim
\section ParticleGun_s6 Histograms
particleGun produces several 1D histograms which are saved as
particleGun.root by default.
- 1 : energy spectrum dN/dE = f(E)
- 2 : vertex position: radial distr dN/dv = f(r)
- 3 : vertex position: cos(theta)
- 4 : vertex position: phi
- 5 : particle direction in local frame: cos(alpha)
- 6 : particle direction in local frame: psi
Please note that histogram 1 will be filled only if you use
PrimaryGeneratorAction2, histos 5,6 with PrimaryGeneratorAction0 and 3
and 2 through 6 will be filled with PrimaryGeneratorAction4.
The histograms are managed by the HistoManager class and its Messenger.
The histos can be individually activated with the command :
\verbatim
/analysis/h1/set id nbBins valMin valMax unit
\endverbatim
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
\verbatim
/analysis/h1/setFileName name (default particleGun)
\endverbatim
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
\verbatim
/analysis/h1/setAscii id
\endverbatim
All selected histos will be written on a file name.ascii (default gunExample)
*/
@@ -0,0 +1,152 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
ParticleGun
-----------
History:
10-06-2010 : Makoto Asai - merge into one example
13-05-2010 : Michel Maire - create as three examples
This example demonstrates 5 ways of the usage of G4ParticleGun shooting
primary particles in different cases. These are
0) uniform particle direction in a given solid angle
1) Generate several vertices and particles per event
2) Show how to sample a tabulated function (eg. energy spectrum)
3) Divergent beam in an arbitrary direction
4) Shooting primaries in spherical coordinates with rotation matrix.
These usages can be chosen by a UI command
/gunExample/selectGunAction <actionID>
where <actionID> corresponds to above cases.
1- Geometry construction
---------------------
It is a simple box which represents an 'infinite' homogeneous medium.
2- Physics list
------------
PhysicsList.cc defines only geantino and transportation process.
3- Primary generator
-----------------
There are 5 concrete primary generator action classes
(PrimaryGeneratorActionN, N=0,1,2,3,4) which can be used as an independent sample
code.
PrimaryGeneratorAction is the class which uses and switches between these
5 concrete action classes. Each concrete generator action shoots geantinoes
in a distribution decribed below.
3.0- uniform particle direction in a given solid angle
-------------------------------------------------
spherical angles (alpha,psi) respective to z axis
Histograms 5,6 show momentum direction in master frame.
3.1- Generate several vertices and particles per event
-------------------------------------------------
particle 1 : a geantino uniformly randomized on a cylinder surface.
particle 2 and 3 : symetric to particle 1.
In addition, time_zero of each event is randomized.
3.2- Show how to sample a tabulated function (energy spectrum)
---------------------------------------------------------
Energy is sampled from a tabulated function defined in InitFunction().
The function is assumed positive, linear per segment, continuous.
Two sampling methods are illustrated : RejectAccept() and InverseCumul()
(see Particle Data book, Monte Carlo techniques).
Histogram 1 shows generated energy spectrum.
3.3- Divergent beam in an arbitrary direction with rotation matrix
-------------------------------------------------------------
A geantino uniformly randomized around a given direction (theta, phi).
One wants to limit particle direction uniformly around this direction.
First, one generates momentum direction in the master frame (eg. World).
AlphaMax = opening angle around z axis.
Then one rotates momentum in local frame, using rotateUz() function.
RotateUz() transforms uz to newUz. It is composition of two simple rotations:
theta around oy, then phi around oz (non commutative).
http://proj-clhep.web.cern.ch/proj-clhep/manual/UserGuide/VectorDefs/node49.html
Histograms 5,6 show momentum direction in local frame.
3.4- Shooting primaries in spherical coordinates with rotation matrix
----------------------------------------------------------------
a geantino uniformly randomized within a spherical shell.
a) Vertex position
One wishes to shoot uniformly within a spherical shell.
One works in spherical coordinates. One uses inverse cumulative method with
analytical formulae.
Histograms 2,3,4 demonstrate uniform distribution of vertex position.
b) Momentum direction
One wants to limit particle direction uniformly within (alphaMin, alphaMax).
First, one generates momentum direction in the master frame (eg. World).
Then, one rotates momentum in vertex_position frame, using rotateUz() function.
RotateUz() transforms uz to ur. It is composition of two elementary rotations:
theta around oy, then phi around oz (non commutative).
http://proj-clhep.web.cern.ch/proj-clhep/manual/UserGuide/VectorDefs/node49.html
Histograms 5,6 show momentum direction in vertex_position frame.
4- Visualisation
-------------
Visualization Manager is set in the main().
Initialisation of the drawing is done via the commands
/vis/.. in the macro vis.mac. This macro is automatically read from the main
in case of interactive running mode.
5- How to start ?
--------------
- execute particleGun in 'batch' mode from macro files
% ParticleGun run1.mac
- execute particleGun2 in 'interactive mode' with visualization
% particleGun
....
Idle> ---> type your commands. For instance:
Idle> /gunExample/selectGunAction 1
Idle> /run/beamOn 10
....
Idle> exit
6- Histograms
----------
particleGun produces several 1D histograms which are saved as
particleGun.root by default.
1 : energy spectrum dN/dE = f(E)
2 : vertex position: radial distr dN/dv = f(r)
3 : vertex position: cos(theta)
4 : vertex position: phi
5 : particle direction in local frame: cos(alpha)
6 : particle direction in local frame: psi
Please note that histogram 1 will be filled only if you use
PrimaryGeneratorAction2, histos 5,6 with PrimaryGeneratorAction0 and 3
and 2 through 6 will be filled with PrimaryGeneratorAction4.
The histograms are managed by the HistoManager class and its Messenger.
The histos can be individually activated with the command :
/analysis/h1/set id nbBins valMin valMax unit
where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
One can control the name of the histograms file with the command:
/analysis/h1/setFileName name (default particleGun)
It is possible to choose the format of the histogram file : root (default),
xml, csv, by using namespace in HistoManager.hh
It is also possible to print selected histograms on an ascii file:
/analysis/h1/setAscii id
All selected histos will be written on a file name.ascii (default gunExample)
@@ -0,0 +1,27 @@
///\file "eventgenerator/pythia/.README.txt"
///\brief Examples pythia README page
/*! \page Examples_pythia Category "eventgenerator/pythia"
Examples for Pythia-Geant4 interface.
This directory contains examples for using Pythia as Monte Carlo event
generator, interfaced with Geant4, and showing how to implement an external
decayer.
\section pythia_s1 Requirements for external software packages
\subsection PYTHIA
- Tested versions 6.4.28 (decayer6) and 8.3.0.5 (py8decayer)
- URL: https://pythia.org/
\section pythia_s2 Example decayer6
The \link Exampledecayer6 decayer6 \endlink example demonstrates the use
of Pythia6 as an external decayer.
\section pythia_s3 Example py8decayer
The \link Examplepy8decayer py8decayer \endlink example demonstrates the use
of Pythia8 as an external decayer.
*/
@@ -0,0 +1,16 @@
Examples for Pythia-Geant4 interface
------------------------------------
This directory contains examples for using Pythia as Monte Carlo event
generator, interfaced with Geant4, and showing how to implement an external
decayer.
Requirements for external software packages
-------------------------------------------
PYTHIA
Tested version 6.4.28
URL: http://www.thep.lu.se/~torbjorn/Pythia.html
Example decayer6
This example demonstrates the use of Pythia6 as an external decayer.
@@ -0,0 +1,96 @@
///\file "eventgenerator/pythia/decayer6/.README.txt"
///\brief Example decayer6 page
/*! \page Exampledecayer6 Example decayer6
This is an example of the external decayer implementation
with PYTHIA6.
The complete PYTHIA6 documentation can be found at:
http://home.thep.lu.se/~torbjorn/pythiaaux/recent.html
The PYTHIA6 external decayer was originally developed within
the AliRoot framework, by Andreas Morsch (CERN). \n
The dependence on the ALICE software was taken off
by Christian Holm Christensen. \n
The dependence on the Root framework and the integration in
the Geant4 framework was done by Ivana Hrivnacova (IPN Orsay).
<hr>
The use of the external decayer is demonstrated with using the
classes from common examples repository, see below their complete
list.
The G4Pythia6Decayer class provides the implementation of the
G4VExternalDecayer interface with using PYTHIA6. In order
to be able to use PYTHIA6, which is written in FORTRAN,
a C++ interface class Pythia6 is provided. This class
interfaces only the PYTHIA6 functions relevant to decay.
The G4Pythia6Decayer is instantiated in the
P6DExtDecayerPhysics::ConstructProcess() function where the external
decayer is set to G4Decay process for all particles.
To demonstrate the decay with external decayer,
the B- meson is defined in ExG4PrimaryGeneratorAction01,
as it has no own decay table defined within Geant4.
With PYTHIA6, it is possible to force a selected decay
type. This selection can be chosen interactively via
the implemented Geant4 UI command:
\verbatim
/pythia6Decayer/forceDecayType decayType
\endverbatim
where the available decay types are listed in the EDecayType
enumaration.
The classes Pythia6, G4Pythia6Decayer, G4Pythia6DecayerMessenger
are independent from the example classes and can be reused
in another user application.
Installation:
- 1. Download the PYTHIA6 source file from the PYTHIA6 download site:\n
http://www.hepforge.org/downloads/pythia6
- 2A. With CMake: Build pythia6 library
For a convenience a CMake file for building Pythia6 library from
the source is provided in
examples/extended/eventgenerator/CMakeLists.txt.pythia6.
Build the pythia6 library following the instructions in this file
and then define the environment variables:
\verbatim
PYTHIA6 the path where pythia6 library is installed
PYTHIA6_VERSION the pythia version
\endverbatim
- 2B. With GNUmake: Define the environment variables: \n
\verbatim
PYTHIA6 the path to pythia-versionX.f source code
PYTHIA6_VERSION the pythia version
\endverbatim
e.g. If you download pythia-6.4.26.f.gz and unzip it in $HOME,
then you have to set:
export PYTHIA6=$HOME
export PYTHIA6_VERSION="6.4.26"
pythia6 will be then compiled together with example code.
- 3. Compilation:\n
Then the example is compiled in a standard way, see \ref README_HowToRun. \n
Note that with GNUmake build, an additional step 'gmake setup' is
needed before 'gmake'.
- 4. Execution:
\verbatim
% pythia6_decayer pythia6_decayer.in
\endverbatim
This example uses the following user action classes from the extended examples common
repository available in common subdirectory:
- DetectorConstruction
- GunPrimaryGeneratorAction
*/
@@ -0,0 +1,85 @@
------------------------------------------------------------
Example of the external decayer implementation with PYTHIA6
-----------------------------------------------------------
The complete PYTHIA6 documentation can be found at:
http://home.thep.lu.se/~torbjorn/pythiaaux/recent.html
The PYTHIA6 external decayer was originally developed within
the AliRoot framework, by Andreas Morsch (CERN).
The dependence on the ALICE software was taken off
by Christian Holm Christensen,
The dependence on the Root framework and the integration in
the Geant4 framework was done by Ivana Hrivnacova (IPN Orsay).
------------------------------------------------------------
The use of the external decayer is demonstrated with using the
classes from common examples repository, see below their complete list.
The G4Pythia6Decayer class provides the implementation of the
G4VExternalDecayer interface with using PYTHIA6. In order
to be able to use PYTHIA6, which is written in FORTRAN,
a C++ interface class Pythia6 is provided. This class
interfaces only the PYTHIA6 functions relevant to decay.
The G4Pythia6Decayer is instantiated in the P6DExtDecayerPhysics builder,
in the ConstructProcess() function where the external decayer is set
to G4Decay process for all particles.
To demonstrate the decay with external decayer,
the B- meson is defined in ExG4PrimaryGeneratorAction01,
as it has no own decay table defined within Geant4.
With PYTHIA6, it is possible to force a selected decay
type. This selection can be chosen interactively via
the implemented Geant4 UI command:
/pythia6Decayer/forceDecayType decayType
where the available decay types are listed in the EDecayType
enumaration.
The classes Pythia6, G4Pythia6Decayer, G4Pythia6DecayerMessenger
are independent from the example classes and can be reused
in another user application.
Installation:
1. Download the PYTHIA6 source file from the PYTHIA6 download site:
http://www.hepforge.org/downloads/pythia6
2A.) With CMake: Build pythia6 library
For a convenience a CMake file for building Pythia6 library from
the source is provided in
examples/extended/eventgenerator/CMakeLists.txt.pythia6.
Build the pythia6 library following the instructions in this file
and then define the environment variables:
PYTHIA6 the path where pythia6 library is installed
PYTHIA6_VERSION the pythia version
2B.) With GNUmake: Define the environment variables:
PYTHIA6 the path to pythia-versionX.f source code
PYTHIA6_VERSION the pythia version
e.g. If you download pythia-6.4.26.f.gz and unzip it in $HOME,
then you have to set:
export PYTHIA6=$HOME
export PYTHIA6_VERSION="6.4.26"
Pythia6 will be then compiled together with example code.
3. Compilation:
Then the example is compiled in a standard way, see examples/README_HowToRun.
Note that with GNUmake build, an additional step 'gmake setup' is
needed before 'gmake'.
Execution:
% pythia6_decayer pythia6_decayer.in
This example uses the following user action classes from the extended examples common
repository available in common subdirectory:
DetectorConstruction
GunPrimaryGeneratorAction
@@ -0,0 +1,24 @@
///\file "common/.README.txt"
///\brief Common classes README page
/*! \page Examples_common Category "common"
In order to reduce code duplication and to reduce the number of variants of
the code of same kind, we define a set of common classes which
can be reused in "feature" examples demonstrating just a particular feature.
This module may be enhanced in future. Currently it provides
the following sets of classes:
- Detector construction classes
- two simple detector construction classes with a messenger
- Physics list classes
- GeantinoPhysicsList - physics list with geantino and chargedgeantino only
- Primary generator classes
- two simple primary generator classes (with G4ParticleGun and
G4ParticleGeneralSource)
*/
@@ -0,0 +1,26 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Common Classes for Extended Examples
-------------------------------------
In order to reduce code duplication and to reduce the number of variants of
the code of same kind, we define a set of common classes which
can be reused in "feature" examples demonstrating just a particular feature.
This module may be enhanced in future. Currently it provides
the following sets of classes:
- Detector construction classes
- two simple detector construction classes with a messenger
- Physics list classes
- GeantinoPhysicsList - physics list with geantino and chargedgeantino only
- Primary generator classes
- two simple primary generator classes (with G4ParticleGun and
G4ParticleGeneralSource)
@@ -0,0 +1,128 @@
///\file "eventgenerator/pythia/py8decayer/.README.txt"
///\brief Example py8decayer page
/*! \page Examplepy8decayer Example py8decayer
This example demonstrates how to outfit Pythia8-based decay features
to those resonances in Geant4 where decay tables are not implemented
by default. In addition, it showns how to replace existing
Geant4 decay tables to such resonances as tau+/- or B+/- with
the Pythia8-based ones.
This example is activated by setting up PYTHIA8 environment variable
to point to the area where Pythia8 is installed.
The complete Pythia8 information, including on download, and documentation
is available from the following site:
https://pythia.org
The original version of this example has been implemented by Julia Yarba
(FNAL, USA)
<hr>
For the complete list of the classes that compose this example please
see later in this document.
Location of example:
examples/extended/eventgenerator/pythia/py8decayer
Installation of Pythia8:
NOTE: As of June 2021, pythia8.3.0.5 is the most current version,
this it is used in this example.
In the future, please check updates at Pythia8 site: https://pythia.org
- 1. cd path/to/your/pythia8/area
- 2. Download desired version of Pythia8 and un-tar it, e.g.
\verbatim
wget http://home.thep.lu.se/~torbjorn/pythia8/pythia8305.tgz
tar xzf pythia8305.tgz
\endverbatim
- 3. Build/install Pythia8
\verbatim
cd pythia8305
export CXX=\`which g++\`
./configure --prefix=$PWD --cxx=$CXX
make
\endverbatim
NOTE: By default, Pythia8 (as of 8.3.0.5) builds with C++11 standards.
If one wants to turn to e.g. C++17 standard, one needs to override flags
via --cxx-common argument to configure script.
4. Setup PYTHIA8 environment variable to point to the area where Pythia8
is built/installed:
\verbatim
export PYTHIA8=$PWD
\endverbatim
Building example:
Upon setup of PYTHIA8 environment variable to point to the area where
Pythia8 package is installed, the pythia/py8decayer example will be
compiled together with several other features of the eventgenerator example.
Description of classes:
Py8Decayer class provides implementation of the G4VExternalDecayer interface
with the use of PYTHIA8.
It is reasonably annotated, and demonstrates what features of Pythia8 need
to be activated and/or disactivated in order to make Pythia8 work only in
the decay mode.
It also illustrated how to control several other features of Pythia8, including
some reduction of Pythia8 verbosity (by default, Pythia8 produces quite a large
amount of printouts, thus reducing it could be useful in some cases).
Last but not least, it also shown how to deactivate decays of pi0's by Pythia8
as the idea is to handle pi0's back to Geant4 for decays.
Py8DecayerPhysics class implements a G4VPhysicsConstructor type of component
with the use of Py8Decayer; this component can later be used with a ddsired
physics list (see main program).
Specifically, in the Py8DecayerPhysics::ConstructProcess() the Py8Decayer is
instantiated and is used to
a) replace existing decay tables of such resonances as tau+/- and B+/-
b) supplement decay features to those resonances in Geant4 where the decay
tables are not implemnted by defaukt
In principle, classes Py8Decayer and Py8DecayerPhysics can be directly reused with
another user application.
Alternatively, they can be used as an inspiration to implement similar, or perhaps
even more extensive Pythia8-based functionalities of user's choice.
Class DetConstruction demostrates how to implement minimalistic detector geometry.
Class SingleParticleGun demonstrates how to implement generaton of the primary
particle.
Main program:
pythia8_decayer.cc
Executable:
pythia8_decayer
Execution:
At present, the pythia8_decayer executable does not take any input arguments.
Everything, including the choine of primary particle, is hardcoded in the main.
Although in the future some configurability may be added.
By default it'll run 5 single tau events using Pythia8 to decays them.
It should print some Pythia8 event information, including on decays.
Once again, please bear in mind that the decay of pi0's by Pythia8 is disabled
(see Py8Decayer constructor) since the idea is to hand the pi0's back to Geant4
and make Geant4 decay them.
*/
@@ -0,0 +1,120 @@
------------------------------------------------------------
Example of the external decayer implementation with Pythia8
------------------------------------------------------------
This example demonstrates how to outfit Pythia8-based decay features
to those resonances in Geant4 where decay tables are not implemented
by default. In addition, it showns how to replace existing
Geant4 decay tables to such resonances as tau+/- or B+/- with
the Pythia8-based ones.
This example is activated by setting up PYTHIA8 environment variable
to point to the area where Pythia8 is installed.
The complete Pythia8 information, including on download, and documentation
is available from the following site:
https://pythia.org
The original version of this example has been implemented by Julia Yarba
(FNAL, USA)
For the complete list of the classes that compose this example please
see later in this document.
Location of example:
examples/extended/eventgenerator/pythia/py8decayer
Installation of Pythia8:
NOTE: As of June 2021, pythia8.3.0.5 is the most current version,
this it is used in this example.
In the future, please check updates at Pythi8 site: https://pythia.org
1. cd path/to/your/pythia8/area
2. Download desired version of Pythia8 and un-tar it, e.g.
wget http://home.thep.lu.se/~torbjorn/pythia8/pythia8305.tgz
tar xzf pythia8305.tgz
3. Build/install Pythia8
cd pythia8305
export CXX=\`which g++\`
./configure --prefix=$PWD --cxx=$CXX
make
NOTE: By default, Pythia8 (as of 8.3.0.5) builds with C++11 standards.
If one wants to turn to e.g. C++17 standard, one needs to override flags
via --cxx-common argument to configure script.
4. Setup PYTHIA8 environment variable to point to the area where Pythia8
is built/installed:
export PYTHIA8=$PWD
Building example:
Upon setup of PYTHIA8 environment variable to point to the area where
Pythia8 package is installed, the pythia/py8decayer example will be
compiled together with several other features of the eventgenerator example.
Description of classes:
Py8Decayer class provides implementation of the G4VExternalDecayer interface
with the use of PYTHIA8.
It is reasonably annotated, and demonstrates what features of Pythia8 need
to be activated and/or disactivated in order to make Pythia8 work only in
the decay mode.
It also illustrated how to control several other features of Pythia8, including
some reduction of Pythia8 verbosity (by default, Pythia8 produces quite a large
amount of printouts, thus reducing it could be useful in some cases).
Last but not least, it also shown how to deactivate decays of pi0's by Pythia8
as the idea is to handle pi0's back to Geant4 for decays.
Py8DecayerPhysics class implements a G4VPhysicsConstructor type of component
with the use of Py8Decayer; this component can later be used with a ddsired
physics list (see main program).
Specifically, in the Py8DecayerPhysics::ConstructProcess() the Py8Decayer is
instantiated and is used to
a) replace existing decay tables of such resonances as tau+/- and B+/-
b) supplement decay features to those resonances in Geant4 where the decay
tables are not implemnted by defaukt
In principle, classes Py8Decayer and Py8DecayerPhysics can be directly reused with
another user application.
Alternatively, they can be used as an inspiration to implement similar, or perhaps
even more extensive Pythia8-based functionalities of user's choice.
Class DetConstruction demostrates how to implement minimalistic detector geometry.
Class SingleParticleGun demonstrates how to implement generaton of the primary
particle.
Main program:
pythia8_decayer.cc
Executable:
pythia8_decayer
Execution:
At present, the pythia8_decayer executable does not take any input arguments.
Everything, including the choine of primary particle, is hardcoded in the main.
Although in the future some configurability may be added.
By default it'll run 5 single tau events using Pythia8 to decays them.
It should print some Pythia8 event information, including on decays.
Once again, please bear in mind that the decay of pi0's by Pythia8 is disabled
(see Py8Decayer constructor) since the idea is to hand the pi0's back to Geant4
and make Geant4 decay them.

Some files were not shown because too many files have changed in this diff Show More