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
+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.