Import Geant4 10.5.0 source tree

This commit is contained in:
Gabriele Cosmo
2018-12-07 15:15:39 +01:00
parent 6aa23be517
commit db49709b53
11370 changed files with 187480 additions and 160142 deletions
+200 -50
View File
@@ -1,75 +1,221 @@
//$Id$
///\file "field/field01/.README.txt"
///\brief Example field01 README page
/*! \page Examplefield01 Example field01
Example enabling investigation of tracking in a magnetic field.
Example that enables investigation of the accuracy and performance of the
tracking in a magnetic field.
The key capabilities of this example are creting a uniform magnetic
field interactively using the field messenger.
The key Geant4 capabilities demonstrated in this example are:
\item creating a uniform magnetic field interactively using the field
messenger,
\item choosing the type of Runge Kutta stepper used for integration of the
motion of charged particles in the magnetic field,
\item controlling the thresholds that determine which looping particles are
killed by G4Transporation.
The capabilities are demonstrated in the field.in file:
Some of these capabilities are available via interactive commands,
implemented in F01FieldMessenger.
The magnetic field is defined in the F01FieldSetup class which object
is created in the ConstructSDandField() function in the F01DetectorConstruction
class. The interactive commands are implemented in F01FieldMessenger.
The magnetic field is defined in F01FieldSetup, which is created in
the ConstructSDandField() method in the F01DetectorConstruction class.
\subsection Choosing the type of stepper
The basic capabilities of choosing the stepper type are demonstrated in the
field.in macro file:
\verbatim
/field/setStepperType 4
/field/setMinStep 0.1 mm
/field/update
\endverbatim
/field/setStepperType 145 ## Choose a stepper type ( Tsitouras )
There are several potential choices of the stepper type. Here are some suggestions:
/field/setStepperType 101 ## Choose an FSAL stepper ( FEqRK1 )
/field/setMinStep 0.1 mm ## Smaller steps always succeed
/field/update ## Initialise using parameters above
\endverbatim
In addition it is possible to choose to use a new type of stepper, known
as 'First Same as Last' or FSAL, which in each step obtains the field value
at the step endpoint and evaluates the 'right hand size' of the equation
for the next integration step. This reduces the number of calls to the field
evaluation, which can be one the most computationally expensive methods,
while providing similar accuracy.
There are several potential choices of the stepper type. Here are some suggestions:
\verbatim
===========================================================================
Number Name of Stepper Comments
===========================================================================
Recommended - new in Geant4 10.3-beta:
15 - Dormand Prince 745 : well-known and very efficient embedded method
Highly recommended in literature, including
Hairer & Wanner, & even Numerical Recipes
Used in several established RK code (e.g. DOPRI5)
===========================================================================
Good choices for reasonably smooth fields:
===========================================================================
Number Name of Stepper Comments
===========================================================================
Recommended - default since Geant4 10.4:
15 - 'DoPri5' or
Dormand Prince 745 : Uses a pair 4th & 5th order formulae (like other 4/5
well-known and very efficient embedded method
methods); their difference is the error estimate.
Highly recommended in literature, including
Hairer & Wanner, & Numerical Recipes
Used in several established RK code (e.g. DOPRI5)
===========================================================================
Good choices for reasonably smooth fields:
8 - Cash Karp RKF 45 : Old 'embedded' RK method - fairly robust,
Uses a pair 4th & 5th order formulae;
the difference is the error estimate.
Faster than old 'simple' that use two half
steps to estimate error.
Available since Geant4 1.0
45 - BogackiShampine45 : more efficient embedded 4/5 pair
Used in many applications, including
RKSUITE suite.
45 - BogackiShampine45 : More efficient embedded 4/5 pair
Used in many applications, including
RKSUITE suite.
New in Geant4 10.3-beta:
145 - Tsitouras45 : potentially the most efficient embedded 4/5
pair - found in expanded search of parameter
space.
===========================================================================
Default - good choice for unknown fields:
4 - ClassicalRK4 : original Runge-Kutta method, very robust but slower )
( obtains error estimate by doing 2 half steps )
56 - Dormand Prince RK56 : higher order embedded method from authors of DoPri5.
Uses a pair 5th & 6th order formulae.
===========================================================================
Good choices for non-smooth fields (with kinks, abrupt changes):
3 - SimpleHeum : low order, with error obtained from half-steps
23 - BogackiShampine23 : lower order embedded method (new in 10.3-beta)
===========================================================================
78 - Dormand Prince RK78 : higher order embedded method from authors of DoPri5.
Uses a pair 7th & 8th order formulae.
9 - NystromRK4 : a specialised Nystrom method for magnetic fields.
Reuses the field value at the mid-point of the step,
and also provides an analytical estimation of the
integration error based on numerical evaluation of
fourth order variation in the equation for
magnetic field.
===========================================================================
The new 'First Same as Last' (FSAL) steppers can be chosen in addition:
1 - RKFEq1 : FSAL stepper with improved equilibrium properties.
When kinks or other anomalies are encountered,
and at the start of integration when the best
step size is not known, this type of stepper
converges faster and more smoothly to good
step sizes.
===========================================================================
The old default and old first alternative -
4 - ClassicalRK4 : original Runge-Kutta method, very robust but slower )
( obtains error estimate by doing 2 half steps )
Good baseline for comparison - long experience of use.
May be good alternative for less smooth fields.
8 - Cash Karp RKF 45 : The oldest 'embedded' RK method in Geant4 -
also fairly robust.
Faster than ClassicalRK4 for smoother fields,
as it does not need two half steps to estimate error.
Available since Geant4 1.0
===========================================================================
Other potential choices for non-smooth fields (with kinks, abrupt changes):
3 - SimpleHeum : low order, with error obtained from half-steps
23 - BogackiShampine23 : lower order embedded method (new in 10.3-beta)
===========================================================================
\endverbatim
\subsection Controlling the killing of looping particles
Occasionally tracks 'looping' in a strong magnetic field, making little
progress even over hundreds of integration steps. This is due to a
combination of a strong magnetic field and a thin material (gas or vacuum)
in which the size of a physics step is substantially larger than the radius
of curvature of the track.
Since the amount of CPU time which can be consumed by one or few such tracks
is very large, it is important to limit the number of integration steps
spent on these tracks. The module for propagation in field in Geant4
flags tracks which take more than a certain number (default 1,000) integration
steps without reaching the requested end of the step size, which was
determined by the physics and geometry.
The Geant4 G4Transportation and G4CoupledTransportation processes are tasked
to select which of the looping tracks are killed and which survive. To
balance the potential significant cost of integrating looping particles,
three thresholds exist
The 'Warning' Energy: a track with energy below this value that is found to
loop is killed silently (no warning.)
Above the 'Warning Energy', if a track is selected for killing a warning is
generated.
The 'Important' Energy: the threshold energy above which a track will survive
for multiple steps if found looping.
number of 'tracking' steps. They will be only be killed only if they still
loop after than
The number of 'trials': the number of steps that 'important' tracks survive.
Note that currently only stable particles are killed. ( Refinements to enable
toggling whether unstable particles can be killed are in development. )
This example demonstrate choosing different values for these parametes
in the main() method of field01.cc using one of two techniques.
The first method is new in Geant4 release 10.5, and uses the G4PhysicsListHelper
which has methods to choose a pre-selected set of parameter values. The choices
are between a set each of low and high thresholds. Either one can be enabled
by calling correspondingly
- G4PhysicsListHelper::GetPhysicsListHelper()->UseLowLooperThresholds();
or
- G4PhysicsListHelper::GetPhysicsListHelper()->UseHighLooperThresholds();
These methods must be called before the physics is constructed - i.e. typically
before RunManager's Initialise() method is called.
This works only if either
- a modular physics lists is used, or if
- the G4ModularPhysicsList and its AddTransporation method are used
to create and register a common transportation process for all particles
(one for each thread).
ii) Fine grained control (available in Geant4 versions since 7.0)
Fine grained control of the Transportation's parameters for looping particles
is also possible.
This is demonstrated in the F01RunAction's ChangeLooperParameters method,
which is called by the BeginOfRunAction. There the appropriate
Transportation object for the electron is obtained, and its parameters
(if valid) are used to overwrite the thresholds in the G4Transportation class.
For example, to ensure that only looping particles with energy 10 keV are
killed silently we change the value of the 'Warning' Energy:
\verbatim
runAction->SetWarningEnergy( 10.0 * CLHEP::keV );
\endverbatim
[ This is passed along to the registered G4Transportation or
G4CoupledTransportation object by the F01RunAction's ChangeLooperParameters.]
As a result the killing of any (stable) looping track with energy over 10 keV
will generate a warning.
A second configurable energy threshold enables tracks above it to survive a
chosen number of 'tracking' steps. They will be only be killed only if they
still loop after than number of tracking steps. F01RunAction's methods are
used to configure these parameters:
\verbatim
runAction->SetImportantEnergy( 0.1 * CLHEP::MeV );
runAction->SetNumberOfTrials( 30 );
\endverbatim
which the run action passes to the G4Transportation or
G4CoupledTransportation object registered for the electron.
Note that for all pre-configured and modular physics lists share a single
Transportation process for all types of particles. So the parameters for
killing loopers will be shared by all particle types in this case.
\section field01_s1 Background Information
\subsection field01_s1_sub1 GEOMETRY DEFINITION
The "absorber" is a solid made of a given material.
The "Absorber" is a solid made of a given material.
Three parameters define the absorber :
- the material of the absorber,
- the thickness of an absorber,
- the transverse size of the absorber (the input face is a square).
The volume "World" contains the "absorber".
The volume "World" contains the "Absorber".
In this test the parameters of the "World" can be changed , too.
In addition a transverse uniform magnetic field can be applied.
@@ -80,13 +226,17 @@
\subsection field01_s1_sub2 AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle (proton, Ekin = 1 GeV)
The primary kinematic consists of a single particle (electron, Ekin = 0.5 GeV)
which hits the
absorber perpendicular to the input face. The type of the particle
and its energy are set in the F01PrimaryGeneratorAction class, and can
be changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
It is also possible to change the position of the primary particle vertex
or activate its randomization via the commands defined in the
F01PrimaryGeneratorMessenger class.
A RUN is a set of events.
\subsection field01_s1_sub3 DETECTOR RESPONSE
@@ -114,14 +264,14 @@
- Execute field01 in 'batch' mode from macro file e.g.
\verbatim
% field01 field01.in
% ./field01 field01.in
\endverbatim
- Execute field01 in 'interactive' mode with visualization e.g.
\verbatim
% field01
% ./field01
....
Idle> /control/execute vis.mac
Idle> /run/beamOn 1
....
\endverbatim
@@ -40,7 +40,7 @@ target_link_libraries(field01 ${Geant4_LIBRARIES} )
# relies on these scripts being in the current working directory.
#
set(field01_SCRIPTS
field01.in field01.out vis.mac gui.mac
field01.in field01.out init_vis.mac vis.mac gui.mac
)
foreach(_script ${field01_SCRIPTS})
@@ -1,4 +1,3 @@
# $Id: GNUmakefile 68021 2013-03-13 13:36:07Z gcosmo $
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
+37 -1
View File
@@ -1,4 +1,3 @@
$Id: History 110139 2018-05-16 07:33:34Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -14,6 +13,43 @@ track of all tags.
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
Dec 4, 2018 J.Apostolakis - fieldex01-V10-04-06
- Corrections to use arguments of methods in F01RunAction.
Fixes compilation warnings.
- Added information to README, .README.txt about new choice of
FSAL drivers and choices to control killing of particles looping
in low density medium with strong field.
Dec 3, 2018 J.Apostolakis - fieldex01-V10-04-05
- field01.cc: Added code to demonstrate use of G4PhysicsListHelper's
UseLowLooperThresholds / UseHighLooperThresholds method
- Added F01RunAction class to demonstrate fine grained control
of G4(Coupled)Transportation's parameters for (killing) looping
tracks. ( Tracks which take too many iterations to finish
integration - typically due to electrons in vacuum, but also
can affect other charged particles. )
- field01.cc, F01FieldSetup and F01DetectorConstruction:
enable use of FSAL stepper and driver. ( To use it uncomment line
in field01.cc )
Nov 12, 2018 J.Apostolakis - fieldex01-V10-04-04
- Improved README, .README.txt and field01.in updating information
on steppers. Noted that DoPri5 (Dormand Prince 7 4/5) is now
the default stepper, and proposed G4NystromRK4 as a fast alternative.
July 27, 2018 I.Hrivnacova - fieldex01-V10-04-02,03
- Added command:
/field/setField Bx By Bz unit
- Macro review and code clean-up:
- Removed EventAction, RunAction, RunActionMessenger
used only for storing random numbers, already available in kernel
- Separated other than visualization settings from vis.mac in a
new init_vis.mac
- Added test for commands defined in the example at the end
of field01.in macro
- Improved visualization of geometry
- Added "beamOn 10" button in gui.mac
- Updated README files
May 15, 2018 J.Allison - fieldex01-V10-04-01
- Remove G4UI_USE and G4VIS_USE.
+183 -34
View File
@@ -1,4 +1,3 @@
$Id: README 100688 2016-10-31 11:21:51Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -8,70 +7,216 @@ $Id: README 100688 2016-10-31 11:21:51Z gcosmo $
field01
-------
Example enabling investigation of tracking in a magnetic field.
Example that enables investigation of the accuracy and performance of the
tracking in a magnetic field.
The key capabilities of this example are creating a uniform magnetic
field interactively using the field messenger.
The key Geant4 capabilities demonstrated in this example are:
- creating a uniform magnetic field interactively using the field
messenger,
- choosing the type of Runge Kutta stepper used for integration of the
motion of charged particles in the magnetic field,
- controlling the thresholds that determine which looping particles are
killed by G4Transporation.
The capabilities are demonstrated in the field.in file:
Some of these capabilities are available via interactive commands,
implemented in F01FieldMessenger.
/field/setStepperType 4
A. The magnetic field is defined in F01FieldSetup, which is created in
the ConstructSDandField() method in the F01DetectorConstruction
class.
/field/setMinStep 0.1 mm
B. Choosing the type of stepper -
/field/update
The basic capabilities of choosing the stepper type are demonstrated in the
field.in macro file:
There are several potential choices of the stepper type. Here are some suggestions:
/field/setStepperType 145 ## Choose a stepper type ( Tsitouras )
/field/setStepperType 101 ## Choose an FSAL stepper ( FEqRK1 )
/field/setMinStep 0.1 mm ## Smaller steps always succeed
/field/update ## Initialise using parameters above
In addition it is possible to choose to use a new type of stepper, known
as 'First Same as Last' or FSAL, which in each step obtains the field value
at the step endpoint and evaluates the 'right hand size' of the equation
for the next integration step. This reduces the number of calls to the field
evaluation, which can be one the most computationally expensive methods,
while providing similar accuracy.
There are several potential choices of the stepper type. Here are some
suggestions:
===========================================================================
Number Name of Stepper Comments
===========================================================================
Recommended - new in Geant4 10.3-beta:
Recommended - default since Geant4 10.4:
15 - Dormand Prince 745 : well-known and very efficient embedded method
15 - 'DoPri5' or
Dormand Prince 745 : Uses a pair 4th & 5th order formulae (like other 4/5
well-known and very efficient embedded method
methods); their difference is the error estimate.
Highly recommended in literature, including
Hairer & Wanner, & even Numerical Recipes
Hairer & Wanner, & Numerical Recipes
Used in several established RK code (e.g. DOPRI5)
===========================================================================
Good choices for reasonably smooth fields:
8 - Cash Karp RKF 45 : Old 'embedded' RK method - fairly robust,
Uses a pair 4th & 5th order formulae;
the difference is the error estimate.
Faster than old 'simple' that use two half
steps to estimate error.
Available since Geant4 1.0
45 - BogackiShampine45 : More efficient embedded 4/5 pair
45 - BogackiShampine45 : more efficient embedded 4/5 pair
Used in many applications, including
RKSUITE suite.
New in Geant4 10.3-beta:
145 - Tsitouras45 : potentially the most efficient embedded 4/5
pair - found in expanded search of parameter
space.
56 - Dormand Prince RK56 : higher order embedded method from authors of DoPri5.
Uses a pair 5th & 6th order formulae.
78 - Dormand Prince RK78 : higher order embedded method from authors of DoPri5.
Uses a pair 7th & 8th order formulae.
9 - NystromRK4 : a specialised Nystrom method for magnetic fields.
Reuses the field value at the mid-point of the step,
and also provides an analytical estimation of the
integration error based on numerical evaluation of
fourth order variation in the equation for
magnetic field.
===========================================================================
The new 'First Same as Last' (FSAL) steppers can be chosen in addition:
1 - RKFEq1 : FSAL stepper with improved equilibrium properties.
When kinks or other anomalies are encountered,
and at the start of integration when the best
step size is not known, this type of stepper
converges faster and more smoothly to good
step sizes.
===========================================================================
Default - good choice for unknown fields:
The old default and old first alternative -
4 - ClassicalRK4 : original Runge-Kutta method, very robust but slower )
( obtains error estimate by doing 2 half steps )
Good baseline for comparison - long experience of use.
May be good alternative for less smooth fields.
8 - Cash Karp RKF 45 : The oldest 'embedded' RK method in Geant4 -
also fairly robust.
Faster than ClassicalRK4 for smoother fields,
as it does not need two half steps to estimate error.
Available since Geant4 1.0
===========================================================================
Good choices for non-smooth fields (with kinks, abrupt changes):
Other potential choices for non-smooth fields (with kinks, abrupt changes):
3 - SimpleHeum : low order, with error obtained from half-steps
23 - BogackiShampine23 : lower order embedded method (new in 10.3-beta)
===========================================================================
C. Controlling the killing of looping particles
Occasionally tracks 'looping' in a strong magnetic field, making little
progress even over hundreds of integration steps. This is due to a
combination of a strong magnetic field and a thin material (gas or vacuum)
in which the size of a physics step is substantially larger than the radius
of curvature of the track.
Since the amount of CPU time which can be consumed by one or few such tracks
is very large, it is important to limit the number of integration steps
spent on these tracks. The module for propagation in field in Geant4
flags tracks which take more than a certain number (default 1,000) integration
steps without reaching the requested end of the step size, which was
determined by the physics and geometry.
The Geant4 G4Transportation and G4CoupledTransportation processes are tasked
to select which of the looping tracks are killed and which survive. To
balance the potential significant cost of integrating looping particles,
three thresholds exist
The 'Warning' Energy: a track with energy below this value that is found to
loop is killed silently (no warning.)
Above the 'Warning Energy', if a track is selected for killing a warning is
generated.
The 'Important' Energy: the threshold energy above which a track will survive
for multiple steps if found looping.
number of 'tracking' steps. They will be only be killed only if they still
loop after than
The number of 'trials': the number of steps that 'important' tracks survive.
Note that currently only stable particles are killed. ( Refinements to enable
toggling whether unstable particles can be killed are in development. )
This example demonstrate choosing different values for these parametes
in the main() method of field01.cc using one of two techniques.
The first method is new in Geant4 release 10.5, and uses the G4PhysicsListHelper
which has methods to choose a pre-selected set of parameter values. The choices
are between a set each of low and high thresholds. Either one can be enabled
by calling correspondingly
- G4PhysicsListHelper::GetPhysicsListHelper()->UseLowLooperThresholds();
or
- G4PhysicsListHelper::GetPhysicsListHelper()->UseHighLooperThresholds();
These methods must be called before the physics is constructed - i.e. typically
before RunManager's Initialise() method is called.
This works only if either
- a modular physics lists is used, or if
- the G4ModularPhysicsList and its AddTransporation method are used
to create and register a common transportation process for all particles
(one for each thread).
ii) Fine grained control (available in Geant4 versions since 7.0)
Fine grained control of the Transportation's parameters for looping particles
is also possible.
This is demonstrated in the F01RunAction's ChangeLooperParameters method,
which is called by the BeginOfRunAction. There the appropriate
Transportation object for the electron is obtained, and its parameters
(if valid) are used to overwrite the thresholds in the G4Transportation class.
For example, to ensure that only looping particles with energy 10 keV are
killed silently we change the value of the 'Warning' Energy:
runAction->SetWarningEnergy( 10.0 * CLHEP::keV );
[ This is passed along to the registered G4Transportation or
G4CoupledTransportation object by the F01RunAction's ChangeLooperParameters.]
As a result the killing of any (stable) looping track with energy over 10 keV
will generate a warning.
A second configurable energy threshold enables tracks above it to survive a
chosen number of 'tracking' steps. They will be only be killed only if they
still loop after than number of tracking steps. F01RunAction's methods are
used to configure these parameters:
runAction->SetImportantEnergy( 0.1 * CLHEP::MeV );
runAction->SetNumberOfTrials( 30 );
which the run action passes to the G4Transportation or
G4CoupledTransportation object registered for the electron.
Note that for all pre-configured and modular physics lists share a single
Transportation process for all types of particles. So the parameters for
killing loopers will be shared by all particle types in this case.
Background Information
1- GEOMETRY DEFINITION
The "absorber" is a solid made of a given material.
The "Absorber" is a solid made of a given material.
Three parameters define the absorber :
- the material of the absorber,
- the thickness of an absorber,
- the transverse size of the absorber (the input face is a square).
The volume "World" contains the "absorber".
The volume "World" contains the "Absorber".
In this test the parameters of the "World" can be changed , too.
In addition a transverse uniform magnetic field can be applied.
@@ -82,18 +227,22 @@ Background Information
2- AN EVENT : THE PRIMARY GENERATOR
The primary kinematic consists of a single particle (proton, Ekin = 1 GeV)
The primary kinematic consists of a single particle (electron, Ekin = 0.5 GeV)
which hits the
absorber perpendicular to the input face. The type of the particle
and its energy are set in the F01PrimaryGeneratorAction class, and can
be changed via the G4 build-in commands of G4ParticleGun class (see
the macros provided with this example).
It is also possible to change the position of the primary particle vertex
or activate its randomization via the commands defined in the
F01PrimaryGeneratorMessenger class.
A RUN is a set of events.
3- DETECTOR RESPONSE
The spatial distribution of charged particles transported in magnetic
The spatial distribution of charged particles transported in magnetic
field is envistigated.
A HIT is a record, event per event , of all the
informations needed to simulate and analyse the detector response.
@@ -114,13 +263,13 @@ Background Information
5- HOW TO START ?
- execute field01 in 'batch' mode from macro file e.g.
% field01 field01.in
- Execute field01 in 'batch' mode from macro file e.g.
% ./field01 field01.in
- execute field01 in 'interactive' mode with visualization e.g.
% field01
- Execute field01 in 'interactive' mode with visualization e.g.
% ./field01
....
Idle> /control/execute vis.mac
Idle> /run/beamOn 1
....
+53 -8
View File
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: field01.cc 110139 2018-05-16 07:33:34Z gcosmo $
//
/// \file field/field01/field01.cc
/// \brief Main program of the field/field01 example
@@ -37,6 +36,10 @@
#include "G4Types.hh"
#ifdef G4MULTITHREADED
// #define USE_MULTITHREADED
#endif
#ifdef USE_MULTITHREADED
#include "G4MTRunManager.hh"
#else
#include "F01SteppingVerbose.hh"
@@ -46,7 +49,15 @@
#include "F01DetectorConstruction.hh"
#include "F01ActionInitialization.hh"
#include "F01RunAction.hh"
#include "G4UImanager.hh"
#include "G4EmParameters.hh"
#include "G4HadronicProcessStore.hh"
#include "G4PhysicsListHelper.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"
#include "Randomize.hh"
@@ -54,6 +65,11 @@
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
// For Printing statistic from Transporation process(es)
#include "G4Electron.hh"
#include "G4Transportation.hh"
#include "G4CoupledTransportation.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc,char** argv)
@@ -70,7 +86,7 @@ int main(int argc,char** argv)
// Construct the default run manager
//
#ifdef G4MULTITHREADED
#ifdef USE_MULTITHREADED
G4MTRunManager * runManager = new G4MTRunManager;
#else
G4VSteppingVerbose::SetInstance(new F01SteppingVerbose);
@@ -81,14 +97,44 @@ int main(int argc,char** argv)
//
// Detector construction
F01DetectorConstruction* detector = new F01DetectorConstruction();
// detector->SetUseFSALstepper(); // Uncomment to use FSAL steppers
runManager->SetUserInitialization(detector);
// Configure the use of low thresholds for looping particles
// ( appropriate for typical applications using low-energy physics. )
auto plHelper = G4PhysicsListHelper::GetPhysicsListHelper();
plHelper->UseLowLooperThresholds();
// Request a set of pre-selected values of the parameters for looping
// particles
// Physics list
G4VModularPhysicsList* physicsList = new FTFP_BERT;
physicsList->RegisterPhysics(new G4StepLimiterPhysics());
runManager->SetUserInitialization(physicsList);
// User action initialization
runManager->SetUserInitialization(new F01ActionInitialization(detector));
// Fine grained control of thresholds for looping particles
auto runAction= new F01RunAction();
runAction->SetWarningEnergy( 10.0 * CLHEP::keV );
// Looping particles with E < 10 keV will be killed after 1 step
// with warning.
// Looping particles with E > 10 keV will generate a warning.
runAction->SetImportantEnergy( 0.1 * CLHEP::MeV );
runAction->SetNumberOfTrials( 30 );
// Looping particles with E > 0.1 MeV will survive for up to
// 30 'tracking' steps, and only be killed if they still loop.
// Note: this mechanism overwrites the thresholds established by
// the call to UseLowLooperThresholds() above.
runManager->SetUserAction(runAction);
// Suppress large verbosity from EM & hadronic processes
G4EmParameters::Instance()->SetVerbose(-1);
G4HadronicProcessStore::Instance()->SetVerbose(0);
// Initialize G4 kernel
//
runManager->Initialize();
@@ -96,7 +142,7 @@ int main(int argc,char** argv)
// Initialize visualization
//
G4VisManager* visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
// G4VisExecutive can take a verbosity argument - see /vis/verbose
// G4VisManager* visManager = new G4VisExecutive("Quiet");
visManager->Initialize();
@@ -112,17 +158,16 @@ int main(int argc,char** argv)
}
else
{ // interactive mode : define UI session
UImanager->ApplyCommand("/control/execute init_vis.mac");
if (ui->IsGUI())
UImanager->ApplyCommand("/control/execute gui.mac");
UImanager->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not
// be deleted in the main() program !
// Statistics of tracks killed by G4Transportation are currently
// printed in the RunAction's EndOfEvent action.
// ( Eventually a summary could be provided here instead or as well. )
delete visManager;
delete runManager;
+38 -14
View File
@@ -1,5 +1,5 @@
#
# Macro file for the initialization phase of field01
# Macro file for the test of field01 example
#
# It creates the default geometry (simple absorber cylinder )
#
@@ -9,17 +9,26 @@
# ****** Start of initialisation of classes for field propagation
# Change the type of stepper used to integrate the ODE of motion
#
#/field/setStepperType 45
# Recommended and default since Geant4 10.4 (Dec 2017) - Dormand Prince (7) 4/5
/field/setStepperType 745
# High efficiency 5th order embedded stepper - Tsitouras
# /field/setStepperType 145
# Higher order Dormand Prince stepper - 6th order (for smoothest fields & long steps)
# /field/setStepperType 56
#
# Recommended - new in Geant4 10.3-beta:
# 15 - Dormand Prince 745 : well-known and very efficient embedded method
# Highly recommended in literature, e.g. Hairer,
# Numerical Recipes
# Used in several RK programs (e.g. DOPRI5 code)
#
# Different types of steppers can be chosen for integration in B-field:
#
# 745 - Dormand Prince 745 : established, efficient embedded method
# recommended in literature, e.g. Hairer, Numerical Recipes
# Used in several RK programs (e.g. DOPRI5 code)
#
# 45 - Bogacki Shampine 4/5 : more efficient 4/5 embedded stepper
# 13 - Nystrom RK4 : stepper with few field calls & analytic estimate of error
#
# Good choices for reasonably smooth fields - available since Geant4 1.0
# 8 - Cash Karp RKF 45 : 'embedded' RK method - 4th/5th faster, robust
# ( uses difference of 4th & 5th order for error estimate )
# ( uses difference of 4th & 5th order for error estimate )
#
# Default - good choice for unknown fields
# 4 - ClassicalRK4 : original Runge-Kutta method, very robust but slower )
@@ -67,14 +76,29 @@
# Change the value of the B-field
#
/field/update
/field/setFieldZ 1.0 kG
#
#
/field/setField 0.1 0 0 tesla
/run/beamOn 1
#
/gun/energy 500.0 MeV
/tracking/verbose 1
/run/beamOn 1
/tracking/verbose 0
/run/printProgress 10
/run/beamOn 100
#
# Test commands defined in this example
/control/verbose 2
#
/calor/setAbsMat Xe20CO2 # default Air
/calor/setWorldMat Kr20CO2 # default Air
/calor/setAbsThick 0.8 mm # default 1 mm
/calor/setAbsRad 1900 mm # default 20000.*mm
/calor/setAbsZpos 20990 mm # default 21990.0*mm
/calor/setWorldZ 45000 mm # default 44000.*mm
/calor/setWorldR 23000 mm # default 22000.*mm
/field/setFieldZ 1.0 kG # default field 3*tesla in X-direction
#
/gun/random on # default "off"
/gun/xvertex 100 mm # default 0
/gun/yvertex 100 mm # default 0
/gun/zvertex 100 mm # default 0
#
/run/beamOn 1
File diff suppressed because it is too large Load Diff
+1
View File
@@ -10,6 +10,7 @@
# Run menu :
/gui/addMenu run Run
/gui/addButton run "beamOn 1" "/run/beamOn 1"
/gui/addButton run "beamOn 10" "/run/beamOn 10"
#/gui/addButton run run1 "/control/execute run1.mac"
#/gui/addButton run run2 "/control/execute run2.mac"
#
@@ -27,7 +27,6 @@
/// \brief Definition of the F01CalorHit class
//
//
// $Id: F01CalorHit.hh 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,6 @@
/// \brief Definition of the F01CalorimeterSD class
//
//
// $Id: F01CalorimeterSD.hh 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,6 @@
/// \brief Definition of the F01DetectorConstruction class
//
//
// $Id: F01DetectorConstruction.hh 90341 2015-05-26 08:38:36Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -95,6 +94,9 @@ class F01DetectorConstruction : public G4VUserDetectorConstruction
const G4VPhysicalVolume* GetAbsorber() {return fPhysiAbsorber;}
G4LogicalVolume* GetLogicalAbsorber() {return fLogicAbsorber;}
void SetUseFSALstepper( G4bool val ) { fUseFSALstepper = val; }
G4bool AreUsingFSALstepper() { return fUseFSALstepper; }
private:
F01DetectorMessenger* fDetectorMessenger; // pointer -> Messenger
@@ -120,6 +122,8 @@ class F01DetectorConstruction : public G4VUserDetectorConstruction
G4double fWorldSizeR;
G4double fWorldSizeZ;
G4bool fUseFSALstepper= false;
private:
void DefineMaterials();
@@ -27,7 +27,6 @@
/// \brief Definition of the F01DetectorMessenger class
//
//
// $Id: F01DetectorMessenger.hh 77115 2013-11-21 15:06:37Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -1,60 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file field/field01/include/F01EventAction.hh
/// \brief Definition of the F01EventAction class
//
//
// $Id: F01EventAction.hh 92496 2015-09-02 07:22:25Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef F01EventAction_h
#define F01EventAction_h 1
#include "globals.hh"
#include "G4UserEventAction.hh"
class F01RunAction;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class F01EventAction : public G4UserEventAction
{
public:
F01EventAction(F01RunAction* F01RA);
virtual ~F01EventAction();
public:
virtual void BeginOfEventAction(const G4Event*);
virtual void EndOfEventAction(const G4Event*);
private:
F01RunAction* fRunAction;
};
#endif
@@ -27,7 +27,6 @@
/// \brief Definition of the F01FieldMessenger class
//
//
// $Id: F01FieldMessenger.hh 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -42,6 +41,7 @@ class F01FieldSetup;
class G4UIdirectory;
class G4UIcmdWithAnInteger;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWith3VectorAndUnit;
class G4UIcmdWithoutParameter;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -61,7 +61,8 @@ class F01FieldMessenger: public G4UImessenger
G4UIdirectory* fFieldDir;
G4UIcmdWithAnInteger* fStepperCmd;
G4UIcmdWithADoubleAndUnit* fMagFieldCmd;
G4UIcmdWithADoubleAndUnit* fMagFieldZCmd;
G4UIcmdWith3VectorAndUnit* fMagFieldCmd;
G4UIcmdWithADoubleAndUnit* fMinStepCmd;
G4UIcmdWithoutParameter* fUpdateCmd;
};
@@ -27,17 +27,15 @@
/// \brief Definition of the F01FieldSetup class
//
//
// $Id: F01FieldSetup.hh 90341 2015-05-26 08:38:36Z gcosmo $
//
//
// A class for control of the Magnetic Field of the detector.
// The field is assumed to be uniform.
//
// Should this be a:
// i) messenger
// ii) user class that creates the field ?
// iii) simply a derived class of Uniform field ? <== I have chosen this now.
// iv) a field manager that creates/updates field (Prefered?)
// i) a messenger class
// ii) user class that creates the field ( Current choice )
// iii) a field manager that creates/updates field
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -52,13 +50,19 @@ class G4FieldManager;
class G4ChordFinder;
class G4Mag_UsualEqRhs;
class G4MagIntegratorStepper;
class G4VIntegrationDriver;
class F01FieldMessenger;
class F01FieldSetup
{
public:
F01FieldSetup(G4ThreeVector); // The value of the field
F01FieldSetup(G4ThreeVector, // The value of the field
G4int stepperNum = -1000, // -ive = fsal, +ive = old.
// default (-1000) uses next flag
G4bool useFSALstepper= false );
F01FieldSetup(); // A zero field
F01FieldSetup( F01FieldSetup & ) = delete;
virtual ~F01FieldSetup();
@@ -70,29 +74,42 @@ public:
void SetMinStep(G4double s) { fMinStep = s; }
void InitialiseAll(); // Set parameters and call method below
// Original method -
void CreateStepperAndChordFinder();
// New method - create FSAL stepper and driver
void CreateFSALStepperAndChordFinder();
void SetFieldValue(G4ThreeVector fieldVector);
void SetFieldValue(G4double fieldValue);
void SetFieldZValue(G4double fieldValue);
G4ThreeVector GetConstantFieldValue();
void SetUseFSALstepper(G4bool val= true) { fUseFSALstepper = val; }
G4bool GetUseFSALstepper() { return fUseFSALstepper; }
protected:
// Implementation methods
G4VIntegrationDriver* CreateFSALStepperAndDriver();
// Find the global Field Manager
G4FieldManager* GetGlobalFieldManager();
protected:
// Find the global Field Manager
G4FieldManager* fFieldManager = nullptr;
G4ChordFinder* fChordFinder = nullptr;
G4Mag_UsualEqRhs* fEquation = nullptr;
G4MagneticField* fMagneticField = nullptr;
G4FieldManager* GetGlobalFieldManager();
G4MagIntegratorStepper* fStepper = nullptr;
G4bool fUseFSALstepper = false;
G4VIntegrationDriver* fDriver = nullptr; // If non-null, its new type (FSAL)
G4int fStepperType = -1;
G4FieldManager* fFieldManager;
G4ChordFinder* fChordFinder;
G4Mag_UsualEqRhs* fEquation;
G4MagneticField* fMagneticField;
G4MagIntegratorStepper* fStepper;
G4int fStepperType;
G4double fMinStep;
F01FieldMessenger* fFieldMessenger;
G4double fMinStep = -1.0;
F01FieldMessenger* fFieldMessenger = nullptr;
};
@@ -27,7 +27,6 @@
/// \brief Definition of the F01PrimaryGeneratorAction class
//
//
// $Id: F01PrimaryGeneratorAction.hh 77881 2013-11-29 08:37:53Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,6 @@
/// \brief Definition of the F01PrimaryGeneratorMessenger class
//
//
// $Id: F01PrimaryGeneratorMessenger.hh 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,43 +23,51 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file field/field01/include/F01RunAction.hh
/// \brief Definition of the F01RunAction class
//
//
// $Id: F01RunAction.hh 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef F01RunAction_h
#define F01RunAction_h 1
#define F01RunAction_h
#include "G4UserRunAction.hh"
class F01RunMessenger;
class G4ParticleDefinition;
class G4Transportation;
class G4CoupledTransportation;
class G4Run;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class F01RunAction: public G4UserRunAction {
class F01RunAction : public G4UserRunAction
{
public:
F01RunAction();
virtual ~F01RunAction();
public:
public:
virtual void BeginOfRunAction(const G4Run*);
virtual void EndOfRunAction(const G4Run*);
F01RunAction();
virtual ~F01RunAction();
virtual void BeginOfRunAction( const G4Run* aRun );
virtual void EndOfRunAction( const G4Run* aRun );
void SetRndmFreq(G4int val) {fSaveRndm = val;}
G4int GetRndmFreq() const {return fSaveRndm;}
// Helper method to change the Transportation's 'looper' parameters
void ChangeLooperParameters(const G4ParticleDefinition* particleDef );
private:
// Helper method to find the Transportation process for a particle type
std::pair<G4Transportation*, G4CoupledTransportation*>
findTransportation( const G4ParticleDefinition * particleDef,
bool reportError= true );
F01RunMessenger* fMessenger;
G4int fSaveRndm;
public:
void SetNumberOfTrials( G4int val ) { theNumberOfTrials = val; }
void SetWarningEnergy( double val ) { theWarningEnergy = val; }
void SetImportantEnergy( double val ) { theImportantEnergy = val; }
G4int GetNumberOfTrials() { return theNumberOfTrials; }
G4double GetWarningEnergy() { return theWarningEnergy; }
G4double GetImportantEnergy() { return theImportantEnergy; }
private:
// Values for initialising 'loopers' parameters of Transport process
G4int theNumberOfTrials = 0; // Default will not overwrite
G4double theWarningEnergy = -1.0; // Default values - non operational
G4double theImportantEnergy = -1.0; // Default - will not overwrite
int theVerboseLevel = 0;
};
#endif
@@ -1,68 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file field/field01/include/F01RunMessenger.hh
/// \brief Definition of the F01RunMessenger class
//
//
// $Id: F01RunMessenger.hh 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef F01RunMessenger_h
#define F01RunMessenger_h 1
#include "G4UImessenger.hh"
class F01RunAction;
class G4UIdirectory;
class G4UIcmdWithAnInteger;
class G4UIcmdWithAString;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class F01RunMessenger: public G4UImessenger
{
public:
F01RunMessenger(F01RunAction* );
virtual ~F01RunMessenger();
virtual void SetNewValue(G4UIcommand* ,G4String );
private:
F01RunAction* fRunAction;
G4UIdirectory* fRndmDir;
G4UIcmdWithAnInteger* fRndmSaveCmd;
G4UIcmdWithAString* fRndmReadCmd;
};
#endif
@@ -27,7 +27,6 @@
/// \brief Definition of the F01SteppingVerbose class
//
//
// $Id: F01SteppingVerbose.hh 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//---------------------------------------------------------------
@@ -0,0 +1,26 @@
# Macro file for the initialization of example field01
# in interactive session
#
# It creates the default geometry (simple absorber cylinder )
#
/control/verbose 2
/run/verbose 1
#
# Field parameters (default values)
#/field/setStepperType 4
#/field/setMinStep 0.1 mm
#/field/setField 0 10000 0 megavolt/m
#/field/update
#
/run/initialize
#
#
/gun/particle e-
#/gun/particle proton
#/gun/particle chargedgeantino
#
/gun/energy 2 GeV
/tracking/verbose 1
# Visualization setting
/control/execute vis.mac
@@ -29,8 +29,6 @@
#include "F01ActionInitialization.hh"
#include "F01PrimaryGeneratorAction.hh"
#include "F01RunAction.hh"
#include "F01EventAction.hh"
#include "F01SteppingVerbose.hh"
#include "F01DetectorConstruction.hh"
@@ -52,7 +50,6 @@ F01ActionInitialization::~F01ActionInitialization()
void F01ActionInitialization::BuildForMaster() const
{
SetUserAction(new F01RunAction());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -60,11 +57,6 @@ void F01ActionInitialization::BuildForMaster() const
void F01ActionInitialization::Build() const
{
SetUserAction(new F01PrimaryGeneratorAction(fDetConstruction));
F01RunAction* runAction = new F01RunAction();
SetUserAction(runAction);
F01EventAction* eventAction = new F01EventAction(runAction);
SetUserAction(eventAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,6 @@
/// \brief Implementation of the F01CalorHit class
//
//
// $Id: F01CalorHit.cc 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,6 @@
/// \brief Implementation of the F01CalorimeterSD class
//
//
// $Id: F01CalorimeterSD.cc 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,6 @@
/// \brief Implementation of the F01DetectorConstruction class
//
//
// $Id: F01DetectorConstruction.cc 101664 2016-11-21 09:10:32Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -395,7 +394,8 @@ void F01DetectorConstruction::ConstructSDandField()
// Construct the field creator - this will register the field it creates
if (!fEmFieldSetup.Get()) {
F01FieldSetup* fieldSetup
= new F01FieldSetup(G4ThreeVector( 3.3*tesla, 0.0, 0.0 ) );
= new F01FieldSetup(G4ThreeVector( 3.3*tesla, 0.0, 0.0 ),
fUseFSALstepper );
G4AutoDelete::Register(fieldSetup); // Kernel will delete the F01FieldSetup
fEmFieldSetup.Put(fieldSetup);
}
@@ -27,7 +27,6 @@
/// \brief Implementation of the F01DetectorMessenger class
//
//
// $Id: F01DetectorMessenger.cc 77115 2013-11-21 15:06:37Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -1,79 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file field/field01/src/F01EventAction.cc
/// \brief Implementation of the F01EventAction class
//
//
// $Id: F01EventAction.cc 92496 2015-09-02 07:22:25Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "F01EventAction.hh"
#include "F01RunAction.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
F01EventAction::F01EventAction(F01RunAction* action)
: G4UserEventAction(),
fRunAction(action)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
F01EventAction::~F01EventAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void F01EventAction::BeginOfEventAction(const G4Event*)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void F01EventAction::EndOfEventAction(const G4Event* evt)
{
// save rndm status
if (fRunAction->GetRndmFreq() == 2)
{
G4Random::saveEngineStatus("endOfEvent.rndm");
G4int evtNb = evt->GetEventID();
G4int printProgress = G4RunManager::GetRunManager()->GetPrintProgress();
if (evtNb%printProgress == 0)
{
G4cout << "\n---> End of Event: " << evtNb << G4endl;
G4Random::showEngineStatus();
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,6 @@
/// \brief Implementation of the F01FieldMessenger class
//
//
// $Id: F01FieldMessenger.cc 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -38,6 +37,7 @@
#include "F01FieldSetup.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -47,6 +47,7 @@ F01FieldMessenger::F01FieldMessenger(F01FieldSetup* fieldSetup)
fEMfieldSetup(fieldSetup),
fFieldDir(0),
fStepperCmd(0),
fMagFieldZCmd(0),
fMagFieldCmd(0),
fMinStepCmd(0),
fUpdateCmd(0)
@@ -66,10 +67,16 @@ F01FieldMessenger::F01FieldMessenger(F01FieldSetup* fieldSetup)
fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
fUpdateCmd->AvailableForStates(G4State_Idle);
fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/field/setFieldZ",this);
fMagFieldZCmd = new G4UIcmdWithADoubleAndUnit("/field/setFieldZ",this);
fMagFieldZCmd->SetGuidance("Define magnetic field.");
fMagFieldZCmd->SetGuidance("Magnetic field will be in Z direction.");
fMagFieldZCmd->SetParameterName("Bz",false,false);
fMagFieldZCmd->SetDefaultUnit("tesla");
fMagFieldZCmd->AvailableForStates(G4State_Idle);
fMagFieldCmd = new G4UIcmdWith3VectorAndUnit("/field/setField",this);
fMagFieldCmd->SetGuidance("Define magnetic field.");
fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
fMagFieldCmd->SetParameterName("Bz",false,false);
fMagFieldCmd->SetParameterName("Bx", "By", "Bz" ,false,false);
fMagFieldCmd->SetDefaultUnit("tesla");
fMagFieldCmd->AvailableForStates(G4State_Idle);
@@ -86,6 +93,7 @@ F01FieldMessenger::F01FieldMessenger(F01FieldSetup* fieldSetup)
F01FieldMessenger::~F01FieldMessenger()
{
delete fStepperCmd;
delete fMagFieldZCmd;
delete fMagFieldCmd;
delete fMinStepCmd;
delete fFieldDir;
@@ -100,8 +108,10 @@ void F01FieldMessenger::SetNewValue( G4UIcommand* command, G4String newValue)
fEMfieldSetup->SetStepperType(fStepperCmd->GetNewIntValue(newValue));
if( command == fUpdateCmd )
fEMfieldSetup->CreateStepperAndChordFinder();
if( command == fMagFieldZCmd )
fEMfieldSetup->SetFieldZValue(fMagFieldZCmd->GetNewDoubleValue(newValue));
if( command == fMagFieldCmd )
fEMfieldSetup->SetFieldValue(fMagFieldCmd->GetNewDoubleValue(newValue));
fEMfieldSetup->SetFieldValue(fMagFieldCmd->GetNew3VectorValue(newValue));
if( command == fMinStepCmd )
fEMfieldSetup->SetMinStep(fMinStepCmd->GetNewDoubleValue(newValue));
}
@@ -27,7 +27,6 @@
/// \brief Implementation of the F01FieldSetup class
//
//
// $Id: F01FieldSetup.cc 104350 2017-05-26 07:20:25Z gcosmo $
//
// User Field setup class implementation.
//
@@ -65,40 +64,62 @@
#include "G4BogackiShampine23.hh"
#include "G4BogackiShampine45.hh"
#include "G4DormandPrince745.hh"
#include "G4DormandPrinceRK56.hh"
#include "G4DormandPrinceRK78.hh"
#include "G4TsitourasRK45.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
enum EStepperNumber { kDormandPrince45 = 17, kBogackiShampine45= 45, kClassicalRK4 = 4,
kNystromRK4 = 13 /*soon 40*/,
kDormandPrince56 = 56, kBogackiShampine23= 23, kCashKarp = 8,
kDormandPrince78 = 78, kTsitouras45 = 145
} ;
// Constructors:
F01FieldSetup::F01FieldSetup(G4ThreeVector fieldVector)
: fFieldManager(0),
fChordFinder(0),
fEquation(0),
fMagneticField(new G4UniformMagField(fieldVector)),
fStepper(0),
F01FieldSetup::F01FieldSetup(G4ThreeVector fieldVector,
G4int stepperNum,
G4bool useFSALstepper )
: fMagneticField(new G4UniformMagField(fieldVector)),
fUseFSALstepper(useFSALstepper),
fStepperType(0),
fMinStep(0.),
fFieldMessenger(0)
fMinStep(0.)
{
G4cout << " F01FieldSetup: magnetic field set to Uniform( "
<< fieldVector << " ) " << G4endl;
if( stepperNum == -1000 )
{
fUseFSALstepper = useFSALstepper;
if( !useFSALstepper )
fStepperType= 17; // Use Dormand Prince (7) 4/5 as default stepper
else
fStepperType = 101;
}
else
{
fUseFSALstepper = ( stepperNum > 0 );
if( stepperNum > 0 )
fStepperType = stepperNum;
else
fStepperType = - stepperNum;
}
InitialiseAll();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
F01FieldSetup::F01FieldSetup()
: fFieldManager(0),
fChordFinder(0),
fEquation(0),
fMagneticField(new G4UniformMagField(G4ThreeVector())),
fStepper(0),
fStepperType(0),
fMinStep(0.),
fFieldMessenger(0)
: fMagneticField(new G4UniformMagField(G4ThreeVector())),
fUseFSALstepper(false),
fStepperType(17), // Use Dormand Prince (7) 4/5 as default stepper
fMinStep(0.)
{
G4cout << " F01FieldSetup: magnetic field set to Uniform( 0.0, 0, 0 ) "
<< G4endl;
@@ -115,11 +136,20 @@ void F01FieldSetup::InitialiseAll()
fMinStep = 1.0*mm; // minimal step of 1 mm is default
fStepperType = 4; // ClassicalRK4 is default stepper
fFieldManager = G4TransportationManager::GetTransportationManager()
->GetFieldManager();
CreateStepperAndChordFinder();
if( fUseFSALstepper ) {
CreateFSALStepperAndChordFinder();
}
else
{
CreateStepperAndChordFinder();
}
G4cout << " 4. Updating Field Manager." << G4endl;
fFieldManager->SetChordFinder( fChordFinder );
fFieldManager->SetDetectorField(fMagneticField );
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -164,6 +194,14 @@ void F01FieldSetup::SetStepper()
switch ( fStepperType )
{
// The new default in G4 and here ( since G4 10.4 Dec 2017 )
case 17:
case 457:
case 745:
fStepper = new G4DormandPrince745( fEquation );
G4cout<<"G4DormandPrince745 Stepper is chosen"<<G4endl;
break;
case 0:
fStepper = new G4ExplicitEuler( fEquation );
G4cout<<"G4ExplicitEuler is chosen."<<G4endl;
@@ -217,6 +255,7 @@ void F01FieldSetup::SetStepper()
G4cout<<"G4ConstRK4 Stepper is chosen"<<G4endl;
break;
case 13:
case 40:
fStepper = new G4NystromRK4( fEquation );
G4cout<<" G4NystromRK4 Stepper is chosen"<<G4endl;
break;
@@ -225,58 +264,142 @@ void F01FieldSetup::SetStepper()
fStepper = new G4BogackiShampine23( fEquation );
G4cout<<"G4BogackiShampine23 Stepper is chosen"<<G4endl;
break;
// Other optimised 4/5th order embedded drivers
case 15:
case 45:
fStepper = new G4BogackiShampine45( fEquation );
G4cout<<"G4BogackiShampine45 Stepper is chosen"<<G4endl;
break;
case 457:
case 745:
fStepper = new G4DormandPrince745( fEquation );
G4cout<<"G4DormandPrince745 Stepper is chosen"<<G4endl;
// case 145:
case kTsitouras45:
fStepper = new G4TsitourasRK45( fEquation );
G4cout<<"G4TsitourasRK45 Stepper is chosen"<<G4endl;
break;
// Higher order embedded drivers - for very smooth fields
case 56:
fStepper = new G4DormandPrinceRK56( fEquation );
G4cout<<"G4DormandPrinceRK56 Stepper is chosen"<<G4endl;
break;
case 78:
fStepper = new G4DormandPrinceRK78( fEquation );
G4cout<<"G4DormandPrinceRK78 Stepper is chosen"<<G4endl;
break;
default:
fStepper = new G4ClassicalRK4( fEquation );
G4cout<<"G4ClassicalRK4 Stepper (default) is chosen"<<G4endl;
// fStepper = new G4DormandPrince745( fEquation );
// G4cout<<"G4DormandPrince745 (default) Stepper is chosen"<<G4endl;
// fStepper = new G4ClassicalRK4( fEquation );
// G4cout<<"G4ClassicalRK4 Stepper (default) is chosen"<<G4endl;
fStepper = new G4DormandPrince745( fEquation );
G4cout<<"G4DormandPrince745 (default) Stepper is chosen"<<G4endl;
break;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void F01FieldSetup::SetFieldValue(G4double fieldStrength)
#include "G4VIntegrationDriver.hh"
#include "G4FSALIntegrationDriver.hh"
#include "G4RK547FEq1.hh"
#include "G4RK547FEq2.hh"
#include "G4RK547FEq3.hh"
G4VIntegrationDriver*
F01FieldSetup::CreateFSALStepperAndDriver()
{
// using FsalStepperType = G4RK547FEq1;
const char *methodName= "F01FieldSetup::CreateFSALStepperAndDriver()";
if (fStepper) delete fStepper;
fStepper = nullptr;
G4cout << " F01FieldSetup::CreateFSALStepperAndDriver() called. " << G4endl;
G4cout << " 1. Creating Stepper." << G4endl;
// auto fsalStepper = new FsalStepperType( fEquation );
G4RK547FEq1* stepper1 = nullptr;
G4RK547FEq2* stepper2 = nullptr;
G4RK547FEq3* stepper3 = nullptr;
G4cout << " 2. Creating FSAL Driver." << G4endl;
G4VIntegrationDriver* fsalDriver = nullptr;
switch ( fStepperType )
{
case 1:
case 101:
stepper1 = new G4RK547FEq1( fEquation );
fsalDriver = new G4FSALIntegrationDriver<G4RK547FEq1>( fMinStep, stepper1 );
G4cout << " Stepper type '1' is G4RK547FEq1 stepper (in FSAL mode) with FSAL driver. "
<< G4endl;
fStepper = stepper1;
stepper1 = nullptr;
break;
case 2:
case 102:
stepper2= new G4RK547FEq2( fEquation );
fsalDriver = new G4FSALIntegrationDriver<G4RK547FEq2>( fMinStep, stepper2 );
G4cout << " Stepper type '2' is G4RK547FEq2 stepper (in FSAL mode) with FSAL driver. "
<< G4endl;
fStepper = stepper2;
stepper2 = nullptr;
break;
case 3:
case 103:
stepper3 = new G4RK547FEq3( fEquation );
fsalDriver = new G4FSALIntegrationDriver<G4RK547FEq3>( fMinStep, stepper3 );
G4cout << " Stepper type '3' is G4RK547FEq3 stepper (in FSAL mode) with FSAL driver. "
<< G4endl;
fStepper = stepper3;
stepper3 = nullptr;
break;
default:
G4cout << " Warning from " << methodName << " : stepperType (= "
<< fStepperType << " ) is unknown. " << G4endl
<< " Using value '1' instead - i.e. G4RK547FEq1 stepper. "
<< G4endl;
stepper1 = new G4RK547FEq1( fEquation );
fsalDriver = new G4FSALIntegrationDriver<G4RK547FEq1>( fMinStep, stepper1 );
fStepper = stepper1;
stepper1 = nullptr;
break;
}
delete stepper1; stepper1 = nullptr;
delete stepper2; stepper2 = nullptr;
delete stepper3; stepper3 = nullptr;
if( fsalDriver )
fStepper = fsalDriver->GetStepper();
return fsalDriver;
}
void F01FieldSetup::CreateFSALStepperAndChordFinder()
{
// using FsalStepperType = G4DormandPrince745; // eventually ?
delete fChordFinder;
fChordFinder= nullptr;
G4cout << " F01FieldSetup::CreateFSALStepperAndChordFinder() called. " << G4endl;
auto FSALdriver= CreateFSALStepperAndDriver();
fDriver = FSALdriver;
G4cout<<"The minimal step is equal to "<<fMinStep/mm<<" mm"<<G4endl;
G4cout << " 3. Creating ChordFinder." << G4endl;
fChordFinder = new G4ChordFinder( FSALdriver ); // ( fMagneticField, fMinStep, fStepper );
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void F01FieldSetup::SetFieldZValue(G4double fieldStrength)
{
// Set the value of the Global Field to fieldValue along Z
#ifdef G4VERBOSE
G4cout << "Setting Field strength to "
<< fieldStrength / gauss << " Gauss."; // << G4endl;
#endif
G4ThreeVector fieldSetVec(0.0, 0.0, fieldStrength);
this->SetFieldValue( fieldSetVec );
#ifdef G4VERBOSE
G4double fieldValue[6], position[4];
position[0] = position[1] = position[2] = position[3] = 0.0;
if ( fieldStrength != 0.0 ) {
fMagneticField->GetFieldValue( position, fieldValue);
G4ThreeVector fieldVec(fieldValue[0], fieldValue[1], fieldValue[2]);
// G4cout << " fMagneticField is now " << fMagneticField
G4cout << " Magnetic field vector is "
<< fieldVec / gauss << " G " << G4endl;
} else {
if ( fMagneticField == 0 )
G4cout << " Magnetic field pointer is null." << G4endl;
else
G4Exception("F01FieldSetup::SetFieldValue(double)",
"IncorrectForZeroField",
FatalException,
"fMagneticField ptr should be set to 0 for no field.");
}
#endif
SetFieldValue(G4ThreeVector(0, 0, fieldStrength));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -287,12 +410,20 @@ void F01FieldSetup::SetFieldValue(G4ThreeVector fieldVector)
if (fMagneticField) delete fMagneticField;
#ifdef G4VERBOSE
G4cout << "Setting Field strength to "
<< fieldVector / gauss << " Gauss." << G4endl;
#endif
if (fieldVector != G4ThreeVector(0.,0.,0.))
{
fMagneticField = new G4UniformMagField(fieldVector);
}
else
{
#ifdef G4VERBOSE
G4cout << " Magnetic field pointer is null." << G4endl;
#endif
// If the new field's value is Zero, signal it as below
// so that it is not used for propagation.
fMagneticField = 0;
@@ -27,7 +27,6 @@
/// \brief Implementation of the F01PrimaryGeneratorAction class
//
//
// $Id: F01PrimaryGeneratorAction.cc 77881 2013-11-29 08:37:53Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,6 @@
/// \brief Implementation of the F01PrimaryGeneratorMessenger class
//
//
// $Id: F01PrimaryGeneratorMessenger.cc 77881 2013-11-29 08:37:53Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,65 +23,111 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file field/field01/src/F01RunAction.cc
/// \brief Implementation of the F01RunAction class
//
//
// $Id: F01RunAction.cc 110139 2018-05-16 07:33:34Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "F01RunAction.hh"
#include "F01RunMessenger.hh"
#include "globals.hh"
#include "G4SystemOfUnits.hh"
#include "G4Run.hh"
#include "G4UImanager.hh"
#include "G4VVisManager.hh"
#include "Randomize.hh"
#include "G4ParticleDefinition.hh"
#include "G4Electron.hh"
#include "G4ProcessManager.hh"
#include "G4Transportation.hh"
#include "G4CoupledTransportation.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
F01RunAction::F01RunAction()
: G4UserRunAction(),
fMessenger(0),
fSaveRndm(0)
{
fMessenger = new F01RunMessenger(this);
F01RunAction::F01RunAction() {
theWarningEnergy = 1.0 * CLHEP::kiloelectronvolt; // Arbitrary
theImportantEnergy = 10.0 * CLHEP::kiloelectronvolt; // Arbitrary
theNumberOfTrials = 15; // Arbitrary
// Applications should determine these thresholds according to
// - physics requirements, and
// - the computing cost of continuing integration for looping tracks
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
F01RunAction::~F01RunAction() {}
F01RunAction::~F01RunAction()
{
delete fMessenger;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
void F01RunAction::BeginOfRunAction( const G4Run* aRun ) {
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
G4cout << " Calling F01RunAction::ChangeLooperParameters() " << G4endl;
ChangeLooperParameters( G4Electron::Definition() );
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
void F01RunAction::BeginOfRunAction(const G4Run*)
void F01RunAction::
ChangeLooperParameters(const G4ParticleDefinition* particleDef )
{
// save Rndm status
if (fSaveRndm > 0)
{
G4Random::showEngineStatus();
G4Random::saveEngineStatus("beginOfRun.rndm");
if( particleDef == nullptr )
particleDef = G4Electron::Definition();
auto transportPair= findTransportation( particleDef );
auto transport = transportPair.first;
auto coupledTransport = transportPair.second;
if( transport != nullptr )
{
// Change the values of the looping particle parameters of Transportation
if( theWarningEnergy >= 0.0 )
transport->SetThresholdWarningEnergy( theWarningEnergy );
if( theImportantEnergy >= 0.0 )
transport->SetThresholdImportantEnergy( theImportantEnergy );
if( theNumberOfTrials > 0 )
transport->SetThresholdTrials( theNumberOfTrials );
}
else if( coupledTransport != nullptr )
{
// Change the values for Coupled Transport
if( theWarningEnergy >= 0.0 )
coupledTransport->SetThresholdWarningEnergy( theWarningEnergy );
if( theImportantEnergy >= 0.0 )
coupledTransport->SetThresholdImportantEnergy( theImportantEnergy );
if( theNumberOfTrials > 0 )
coupledTransport->SetThresholdTrials( theNumberOfTrials );
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
void F01RunAction::EndOfRunAction(const G4Run*)
{
// save Rndm status
void F01RunAction::EndOfRunAction( const G4Run* ) {
if( theVerboseLevel > 1 )
G4cout << G4endl << G4endl
<< " ########### Track Statistics for Transportation process(es) "
<< " ########### " << G4endl
<< " ############################################## "
<< " ####################### " << G4endl << G4endl;
if (fSaveRndm == 1)
{
G4Random::showEngineStatus();
G4Random::saveEngineStatus("endOfRun.rndm");
}
auto transportPair= findTransportation( G4Electron::Definition() );
auto transport = transportPair.first;
auto coupledTransport = transportPair.second;
if( transport) { transport->PrintStatistics(G4cout); }
else if( coupledTransport) { coupledTransport->PrintStatistics(G4cout); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::pair<G4Transportation*, G4CoupledTransportation*>
F01RunAction::findTransportation( const G4ParticleDefinition* particleDef,
bool reportError )
{
const auto *partPM= particleDef->GetProcessManager();
G4VProcess* partTransport = partPM->GetProcess("Transportation");
auto transport= dynamic_cast<G4Transportation*>(partTransport);
partTransport = partPM->GetProcess("CoupledTransportation");
auto coupledTransport=
dynamic_cast<G4CoupledTransportation*>(partTransport);
if( reportError && !transport && !coupledTransport )
{
G4cerr << "Unable to find Transportation process for particle type "
<< particleDef->GetParticleName()
<< " ( PDG code = " << particleDef->GetPDGEncoding() << " ) "
<< G4endl;
}
return
std::make_pair( transport, coupledTransport );
// <G4Transportation*, G4CoupledTransportation*>
}
@@ -1,96 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file field/field01/src/F01RunMessenger.cc
/// \brief Implementation of the F01RunMessenger class
//
//
// $Id: F01RunMessenger.cc 76248 2013-11-08 11:19:52Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "F01RunMessenger.hh"
#include "F01RunAction.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithAString.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
F01RunMessenger::F01RunMessenger(F01RunAction* action)
: G4UImessenger(),
fRunAction(action),
fRndmDir(0),
fRndmSaveCmd(0),
fRndmReadCmd(0)
{
fRndmDir = new G4UIdirectory("/rndm/");
fRndmDir->SetGuidance("Rndm status control.");
fRndmSaveCmd = new G4UIcmdWithAnInteger("/rndm/save",this);
fRndmSaveCmd->
SetGuidance("set frequency to save rndm status on external files.");
fRndmSaveCmd->SetGuidance("freq = 0 not saved");
fRndmSaveCmd->SetGuidance("freq > 0 saved on: beginOfRun.rndm");
fRndmSaveCmd->SetGuidance("freq = 1 saved on: endOfRun.rndm");
fRndmSaveCmd->SetGuidance("freq = 2 saved on: endOfEvent.rndm");
fRndmSaveCmd->SetParameterName("frequency",false);
fRndmSaveCmd->SetRange("frequency>=0 && frequency<=2");
fRndmSaveCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fRndmReadCmd = new G4UIcmdWithAString("/rndm/read",this);
fRndmReadCmd->SetGuidance("get rndm status from an external file.");
fRndmReadCmd->SetParameterName("fileName",true);
fRndmReadCmd->SetDefaultValue ("beginOfRun.rndm");
fRndmReadCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
F01RunMessenger::~F01RunMessenger()
{
delete fRndmSaveCmd;
delete fRndmReadCmd;
delete fRndmDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void F01RunMessenger::SetNewValue(G4UIcommand* command,G4String newValues)
{
if (command == fRndmSaveCmd)
fRunAction->SetRndmFreq(fRndmSaveCmd->GetNewIntValue(newValues));
if (command == fRndmReadCmd)
{G4cout << "\n---> rndm status restored from file: " << newValues << G4endl;
G4Random::restoreEngineStatus(newValues);
G4Random::showEngineStatus();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,6 @@
/// \brief Implementation of the F01SteppingVerbose class
//
//
// $Id: F01SteppingVerbose.cc 77483 2013-11-25 10:10:57Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+24 -34
View File
@@ -1,31 +1,6 @@
# Macro file for the initialization phase of field01
# Macro file for the visualization setting in the initialization phase
# of the field01 example.
#
# It creates the default geometry (simple absorber cylinder )
#
/tracking/verbose 1
/run/verbose 1
#
/field/setStepperType 4
#
/field/setMinStep 0.1 mm
#
/field/setFieldZ 1.0 kG
#
/field/update
#
/run/initialize
#
# /run/particle/dumpCutValues
#
/gun/particle e-
#
# /gun/particle proton
# /gun/particle chargedgeantino
#
#
/gun/energy 5.0 MeV
/tracking/verbose 1
# Use this open statement to create an OpenGL view:
/vis/open OGL 600x600-0+0
#
@@ -49,12 +24,6 @@
# Draw geometry:
/vis/drawVolume
#
# Specify view angle:
/vis/viewer/set/viewpointThetaPhi 40. 10.
#
# Specify zoom value:
#/vis/viewer/zoom 2.
#
# Specify style (surface or wireframe):
#/vis/viewer/set/style wireframe
#
@@ -72,6 +41,9 @@
# Draw hits at end of event:
#/vis/scene/add/hits
#
# Draw magnetic field
#/vis/scene/add/magneticField 2
#
# To draw only gammas:
#/vis/filtering/trajectories/create/particleFilter
#/vis/filtering/trajectories/particleFilter-0/add gamma
@@ -86,7 +58,25 @@
#/vis/modeling/trajectories/drawByParticleID-0/set e- blue
#
# To superimpose all of the events from a given run:
#/vis/scene/endOfEventAction accumulate
/vis/scene/endOfEventAction accumulate
#
# field01 specific setting
#
# To get nice view
#/vis/geometry/set/visibility World 0 false
/vis/geometry/set/colour World 0 1 1 1 .3 # gray
/vis/geometry/set/colour Absorber 0 0 0 1 .1 # blue
/vis/viewer/set/style surface
/vis/viewer/set/hiddenMarker true
#
# Specify view angle:
/vis/viewer/set/viewpointThetaPhi 40. 10.
#
# Specify zoom value:
#/vis/viewer/zoom 2.
#
# Draw magnetic field
#/vis/scene/add/magneticField 1
#
# Re-establish auto refreshing and verbosity:
/vis/viewer/set/autoRefresh true