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
@@ -0,0 +1,39 @@
///\file "parameterisations/.README.txt"
///\brief Examples parameterisations README page
/*! \page Examples_parameterisations Category "parameterisations"
Examples in this directory demonstrate use of parameterisation libraries.
Currently, two examples are provided:
\link ExamplePar01 Par01 \endlink
This example demonstrates the use of parameterisation facilities.
It was moved in extended examples from novice/N05 with removal of
novice examples.
\link ExamplePar02 Par02 \endlink
This example shows how to do "track and energy smearing" in Geant4,
in order to have a very fast simulation based on assumed detector
resolutions.
\link ExamplePar03 Par03 \endlink
This example demonstrates how to create multiple energy deposits
from the fast simulation model and store it alongside deposits created
in full/detailed simulation.
\link ExamplePar04 Par04 \endlink
This example demonstrates how to use machine-learning aided fast simulation
of electromagnetic showers. It runs inference using an external library:
either ONNX Runtime, or LWTNN.
\link Examples_gflash gflash \endlink
Set of examples demonstrating the use of the GFLASH parameterisation library.
*/
@@ -0,0 +1,76 @@
///\file "parameterisations/Par01/.README.txt"
///\brief Example Par01 README page
/*! \page ExamplePar01 Example Par01
Example Par01 provides examples of the use of parameterisation facilities.
It was moved in extended examples from novice/N05 with removal of
novice examples.
Geometry, sensitive detector, hits, processes are defined respectively in:
- Par01DetectorConstruction
- Par01CalorimeterSD
- Par01CalorimeterHit
The particularities are:
- The parameterisation models:
- Par01EMShowerModel which provides a crude
parameterisation for e+/e-/gamma. This model
is bound to the EM calorimeter. \n\n
- Par01PionShowerModel: an even more crude
parameterisation for pi+/pi-. This model
is bound to a ghost volume. \n\n
Those two models produces "hits": ie the energy
of the incident particle is distributed into
the volume of the envelope throught energy spots
(class Par01EnergySpot), those energy spots being
recorded in the sensitive detector at this point
if any. \n\n
They are rather similar from a technical point of vue.
They both make use of a private G4Navigator to set
their energy spots into the sensitive volumes.
However, we don't take care of putting every spot into
a sensitive (which is recommended in a "serious"
parameterisation !). \n\n
Those two models trigger their parameterisation
on the first step the particle does in the envelope,
but it would be perfectly possible to wait that the
particle is far enough from the boundary of the envelope
for example. \n\n
- Par01PiModel: just there to show how a parameterisation
can create secondaries, but not used. \n\n
- Par01PhysicsList::AddParameterisation(). A method which
sets the G4FastSimulationManagerProcess in the process
manager of all the particles. This process provides
the INTERFACE between the tracking and the parameterisation
models. \n\n
- In Par01DetectorConstruction::Construct(): the parameterisation
models are built and bound to envelopes: \n\n
- Par01EMShowerModel is bound to the electromagnetic
calorimeter \n\n
- Par01PionShowerModel is bound to a ghost volume
which encompasses the electromagnetic and
hadronic calorimters \n\n
- The Physics list used is FTFP_BERT which is augmented using the
G4FastSimulationPhysics physics constructor to insert the
G4FastSimulationManagerProcess that is making the interface
between the fast simulation and the tracking.
The configuration is shown in examlePar01.cc.
*/
@@ -0,0 +1,72 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Example Par01
-------------
Example Par01 provides examples of the use of parameterisation facilities.
It was moved in extended examples from novice/N05 with removal of
novice examples.
Geometry, sensitive detector, hits, processes are defined respectively in:
Par01DetectorConstruction
Par01CalorimeterSD
Par01CalorimeterHit
The particularities are:
o The parameterisation models:
o Par01EMShowerModel which provides a crude
parameterisation for e+/e-/gamma. This model
is bound to the EM calorimeter.
o Par01PionShowerModel: an even more crude
parameterisation for pi+/pi-. This model
is bound to a ghost volume.
Those two models produces "hits": ie the energy
of the incident particle is distributed into
the volume of the envelope throught energy spots
(class Par01EnergySpot), those energy spots being
recorded in the sensitive detector at this point
if any.
They are rather similar from a technical point of vue.
They both make use of a private G4Navigator to set
their energy spots into the sensitive volumes.
However, we don't take care of putting every spot into
a sensitive (which is recommended in a "serious"
parameterisation !).
Those two models trigger their parameterisation
on the first step the particle does in the envelope,
but it would be perfectly possible to wait that the
particle is far enough from the boundary of the envelope
for example.
o Par01PiModel: just there to show how a parameterisation
can create secondaries, but not used.
o Par01DetectorConstruction::Construct: in this method, the parameterisation
models are built and bound to envelopes:
o Par01EMShowerModel is bound to the electromagnetic
calorimeter
o Par01PionShowerModel is bound to a ghost volume
which encompasses the electromagnetic and
hadronic calorimters
o The Physics list used is FTFP_BERT which is augmented using the
G4FastSimulationPhysics physics constructor to insert the
G4FastSimulationManagerProcess that is making the interface
between the fast simulation and the tracking.
The configuration is shown in examlePar01.cc.
@@ -0,0 +1,250 @@
///\file "parameterisations/Par02/.README.txt"
///\brief Example Par02 README page
/*! \page ExamplePar02 Example Par02
This example is a simplified version of a Geant4-based fast simulation
program written by Anna Zaborowska for Future Circular Collider (FCC)
studies.
This example shows how to do "track and energy smearing" in Geant4,
in order to have a very fast simulation based on assumed detector
resolutions.
The geometry which is considered is a simplified collider detector set-up,
inspired by ALEPH/ATLAS/CMS detectors. Although it is much simpler than
a realistic detector, it is anyhow fairly complex and therefore build up
from a GDML file, Par02FullDetector.gdml .
In this example:
- Particles with transverse momentum less than 1 MeV or pseudorapidity
larger (in module) than 5.5 are neglected (i.e. the corresponding
Geant4 track is killed as soon as it is created).
- Any primary charged particle is smeared in the tracker as follows:
its momentum is smeared according to a gaussian, with mean equal to 1.0
and sigma taken from the momentum resolution of the CMS tracker
(with ALEPH or ATLAS tracker as a possible alternative), and then placed
at the end of the tracker, at the position that it would reach if
normally transported (i.e. without smearing).
- Any primary electron, or positron, or gamma is smeared in the
electromagnetic calorimeter as follows: it is killed at the entrance
of the electromagnetic calorimeter, with a deposited energy equal to
the gaussian smearing (with mean equal to 1.0 and sigma taken from the
energy resolution of the CMS electromagnetic calorimeter - with ALEPH or
ATLAS electromagnetic calorimeter as a possible alternative) of its
kinetic energy (at the entrance of the electromagnetic calorimeter).
- Any primary hadron is smeared in the hadronic calorimeter as follows:
it is killed at the entrance of the hadronic calorimeter, with a
deposited energy equal to the gaussian smearing (with mean equal to 1.0
and sigma taken from the energy resolution of the CMS hadronic
calorimeter - with ALEPH or ATLAS hadronic calorimeter as a possible
alternative) of its kinetic energy (at the entrance of the hadronic
calorimeter).
- The only competing physical processes with respect to the above physics
parametrisations are the decays.
Note: no electromagnetic processes;
no momentum smearing in the tracker for secondary particles;
secondary electrons, positrons, gammas in the electromagnetic
calorimeter are killed (at the entrance) but without any
energy deposition;
secondary hadrons in the hadronic calorimeter are killed (at the
entrance) but without any energy deposition.
Below some details.
\section Par02_s1 Detector description
The geometry is read in from a GDML file, Par02FullDetector.gdml .
The geometry is a simplified collider detector set-up used for the
first FCC studies, inspired by ALEPH/ATLAS/CMS detectors.
It is made of 4 main parts:
- Tracker
- Electromagnetic calorimeter
- Hadronic calorimeter
- Muon subdetector
In this example, fast simulation parametrisation models exist for the
first three subdetectors, but not for the Muon subdetector.
The three parametrisation models:
- Par02FastSimModelTracker : in the tracker
- Par02FastSimModelEMCal : in the electromagnetic calorimeter
- Par02FastSimModelHCal : in the hadronic calorimeter
are build and bound to the respective subdetector (i.e. Geant4 regions)
in the method: Par02DetectorConstruction::Construct() .
Three configurations are possible for those parametrisation models:
CMS-like, ALEPH-like, ATLAS-like.
By default, the CMS configuration is used.
\section Par02_s2 Primary generation
In this example we use a very simple primary generation action,
Par02PrimaryGeneratorAction, that uses the G4ParticleGun.
One single particle type, with a well defined energy, and in one fixed
direction is used for each run: the corresponding values can be set via
macro commands. See examplePar02.in as an example.
For the FCC studies, Pythia8 events in HepMC format were used for the
generation of the primary particles.
\section Par02_s3 Physics List
A special, ad-hoc physics list is used in this example, in order to have
an ultra-fast parametrised simulation: for all particles, the only two
physics processes that are assigned are the decay process and the fast
simulation process.
The following three fast simulation models are defined:
- Par02FastSimModelTracker :
- bound to the tracker
(see the method Par02DetectorConstruction::Construct )
- applicable to all charged particles
(see the method Par02FastSimModelTracker::IsApplicable )
- triggered in all cases (i.e. no kinematic constraints)
(see the method Par02FastSimModelTracker::ModelTrigger )
- does the following: place the particle at the tracking detector exit
(at the place the particle would reach without smearing), and, only
if the particle is a primary, it smears the momentum of the particle
according to a gaussian, with mean equal to 1.0 and sigma taken from
the momentum resolution of the CMS tracker (with ALEPH or ATLAS tracker
as a possible alternative)
(see the method Par02FastSimModelTracker::DoIt )
- Par02FastSimModelEMCal :
- bound to the electromagnetic calorimeter
(see the method Par02DetectorConstruction::Construct )
- applicable to electrons, positrons, gammas
(see the method Par02FastSimModelEMCal::IsApplicable )
- triggered in all cases (i.e. no kinematic constraints)
(see the method Par02FastSimModelEMCal::ModelTrigger )
- does the following: kill the particle at the entrance of the
electromagnetic calorimeter, and, only if the particle is a primary,
it deposits in the electromagnetic calorimeter an energy obtained
by a gaussian smearing (with mean equal to 1.0 and sigma taken from the
energy resolution of the CMS electromagnetic calorimeter - with ALEPH
or ATLAS electromagnetic calorimeter as a possible alternative) of the
particle kinetic energy (at the entrance of the electromagnetic
calorimeter)
(see the method Par02FastSimModelEMCal::DoIt )
- Par02FastSimModelHCal :
- bound to the hadronic calorimeter
(see the method Par02DetectorConstruction::Construct )
- applicable to all hadrons (i.e. particles made of quarks)
(see the method Par02FastSimModelHCal::IsApplicable )
- triggered in all cases (i.e. no kinematic constraints)
(see the method Par02FastSimModelHCal::ModelTrigger )
- does the following: kill the particle at the entrance of the
hadronic calorimeter, and, only if the particle is a primary,
it deposits in the hadronic calorimeter an energy obtained by a
gaussian smearing (with mean equal to 1.0 and sigma taken from the
energy resolution of the CMS hadronic calorimeter - with ALEPH
or ATLAS hadronic calorimeter as a possible alternative) of the
particle kinetic energy (at the entrance of the hadronic
calorimeter)
(see the method Par02FastSimModelHCal::DoIt )
\section Par02_s4 User actions, user information and user utility classes
- Par02RunAction : run action used for initialization and termination
of the run.
- Par02EventAction : event action used for initialization and termination
of the event.
- Par02TrackingAction : tracking action used for killing particles with
transverse momentum less than 1 MeV or
pseudorapidity larger (in module) than 5.5
(see method Par02TrackingAction::PreUserTrackingAction )
and to store the information about the track at
the end of the simulation of such a track
(see method Par02TrackingAction::PostUserTrackingAction ).
- Par02ActionInitialization : initialization of the primary generator class
and all user-defined actions (i.e. the three
classes above).
- Par02PrimaryParticleInformation : utility class to store information
associated with a primary particle.
- Par02EventInformation : utility class to store information associated
with a Geant4 event.
- Par02DetectorParametrisation : a simple class used to provide the detector
resolution and efficiency, according to the
type of detector: tracker, electromagnetic
calorimeter, hadronic calorimeter.
There are 3 choices: CMS-like (default),
ALEPH-like and ATLAS-like.
The efficiency is currently set to 1.0 in
all cases and not used.
- Par02Smearer : a simple class that does the gaussian smearing, either
of the momentum (in the tracker detector) or in energy
(in the electromagnetic or hadronic calorimeter).
\section Par02_s5 Output
The execution of the program (examplePar02) produces in output, at the end
of a run, a Root file, by default named DefaultOutput.root, which contains
3 histograms and one ntuple.
The macro file examplePar02.in specifies one run made of 1000 events
each consisting of one 50 GeV electron.
By editing the file, one could select alternatively a run made of 1000
events each consisting of one 100 GeV muon, or a run made of 1000 events
each consisting of one 20 GeV pion- .
See the class Par02Output for the definition of the 3 histograms and the
ntuples. Here is a quick summary:
- histogram of the ratio of the momentum smeared and the original momentum
in the tracker (for primary charged particles);
- histogram of the ratio of the smeared energy deposited and the original
energy at the entrance in the electromagnetic calorimeter (for primary
electrons, positrons and gammas);
- histogram of the ratio of the smeared energy deposited and the original
energy at the entrance in the hadronic calorimeter (for primary hadrons);
- ntuple containing the "Monte-Carlo true" information regarding the
primary, and the resolution, efficiency, smeared momentum (tracker),
smeared energy (calorimeter) and impact position (calorimeter) of each
subdetector (tracker, electromagnetic calorimeter, hadronic calorimeter)
where the primary is parametrised (tracker and electromagnetic calorimeter
in the case of primary electrons, positrons and gammas; tracker and
hadronic calorimeter in the case of primary hadrons; tracker only for
all other primary charged particles, e.g. muons).
Note:
- you do not need to have the Root package available to run this example,
but you need it if you want to look at the histograms and the ntuple
contained in the Root output file;
- because the class Par02Output is a singleton, this example must be run
in sequential mode, not in multi-threaded mode;
- sensitive detectors and hits are not used in this example.
\section Par02_s6 How to build and run the example
- You need to have built the Geant4 persistency/gdml module by having set
the -DGEANT4_USE_GDML=ON flag during the CMAKE configuration step,
as well as the -DXERCESC_ROOT_DIR=path_to_xercesc flag pointing to
the path where the XercesC XML parser package is installed in your system.
- Compile and link to generate the executable (in your CMAKE build directory):
\verbatim
% make
\endverbatim
- Execute the application:
\verbatim
% examplePar02 examplePar02.in
\endverbatim
which produces one Root file: DefaultOutput.root .
*/
@@ -0,0 +1,254 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Example Par02
-------------
This example is a simplified version of a Geant4-based fast simulation
program written by Anna Zaborowska for Future Circular Collider (FCC)
studies.
This example shows how to do "track and energy smearing" in Geant4,
in order to have a very fast simulation based on assumed detector
resolutions.
The geometry which is considered is a simplified collider detector set-up,
inspired by ALEPH/ATLAS/CMS detectors. Although it is much simpler than
a realistic detector, it is anyhow fairly complex and therefore build up
from a GDML file, Par02FullDetector.gdml .
In this example:
- Particles with transverse momentum less than 1 MeV or pseudorapidity
larger (in module) than 5.5 are neglected (i.e. the corresponding
Geant4 track is killed as soon as it is created).
- Any primary charged particle is smeared in the tracker as follows:
its momentum is smeared according to a gaussian, with mean equal to 1.0
and sigma taken from the momentum resolution of the CMS tracker
(with ALEPH or ATLAS tracker as a possible alternative), and then placed
at the end of the tracker, at the position that it would reach if
normally transported (i.e. without smearing).
- Any primary electron, or positron, or gamma is smeared in the
electromagnetic calorimeter as follows: it is killed at the entrance
of the electromagnetic calorimeter, with a deposited energy equal to
the gaussian smearing (with mean equal to 1.0 and sigma taken from the
energy resolution of the CMS electromagnetic calorimeter - with ALEPH or
ATLAS electromagnetic calorimeter as a possible alternative) of its
kinetic energy (at the entrance of the electromagnetic calorimeter).
- Any primary hadron is smeared in the hadronic calorimeter as follows:
it is killed at the entrance of the hadronic calorimeter, with a
deposited energy equal to the gaussian smearing (with mean equal to 1.0
and sigma taken from the energy resolution of the CMS hadronic
calorimeter - with ALEPH or ATLAS hadronic calorimeter as a possible
alternative) of its kinetic energy (at the entrance of the hadronic
calorimeter).
- The only competing physical processes with respect to the above physics
parametrisations are the decays.
Note: no electromagnetic processes;
no momentum smearing in the tracker for secondary particles;
secondary electrons, positrons, gammas in the electromagnetic
calorimeter are killed (at the entrance) but without any
energy deposition;
secondary hadrons in the hadronic calorimeter are killed (at the
entrance) but without any energy deposition.
Below some details.
1. Detector description
-----------------------
The geometry is read in from a GDML file, Par02FullDetector.gdml .
The geometry is a simplified collider detector set-up used for the
first FCC studies, inspired by ALEPH/ATLAS/CMS detectors.
It is made of 4 main parts:
- Tracker
- Electromagnetic calorimeter
- Hadronic calorimeter
- Muon subdetector
In this example, fast simulation parametrisation models exist for the
first three subdetectors, but not for the Muon subdetector.
The three parametrisation models:
- Par02FastSimModelTracker : in the tracker
- Par02FastSimModelEMCal : in the electromagnetic calorimeter
- Par02FastSimModelHCal : in the hadronic calorimeter
are build and bound to the respective subdetector (i.e. Geant4 regions)
in the method: Par02DetectorConstruction::Construct() .
Three configurations are possible for those parametrisation models:
CMS-like, ALEPH-like, ATLAS-like.
By default, the CMS configuration is used.
2. Primary generation
---------------------
In this example we use a very simple primary generation action,
Par02PrimaryGeneratorAction, that uses the G4ParticleGun.
One single particle type, with a well defined energy, and in one fixed
direction is used for each run: the corresponding values can be set via
macro commands. See examplePar02.in as an example.
For the FCC studies, Pythia8 events in HepMC format were used for the
generation of the primary particles.
3. Physics List
---------------
A special, ad-hoc physics list is used in this example, in order to have
an ultra-fast parametrised simulation: for all particles, the only two
physics processes that are assigned are the decay process and the fast
simulation process.
The following three fast simulation models are defined:
- Par02FastSimModelTracker :
- bound to the tracker
(see the method Par02DetectorConstruction::Construct )
- applicable to all charged particles
(see the method Par02FastSimModelTracker::IsApplicable )
- triggered in all cases (i.e. no kinematic constraints)
(see the method Par02FastSimModelTracker::ModelTrigger )
- does the following: place the particle at the tracking detector exit
(at the place the particle would reach without smearing), and, only
if the particle is a primary, it smears the momentum of the particle
according to a gaussian, with mean equal to 1.0 and sigma taken from
the momentum resolution of the CMS tracker (with ALEPH or ATLAS tracker
as a possible alternative)
(see the method Par02FastSimModelTracker::DoIt )
- Par02FastSimModelEMCal :
- bound to the electromagnetic calorimeter
(see the method Par02DetectorConstruction::Construct )
- applicable to electrons, positrons, gammas
(see the method Par02FastSimModelEMCal::IsApplicable )
- triggered in all cases (i.e. no kinematic constraints)
(see the method Par02FastSimModelEMCal::ModelTrigger )
- does the following: kill the particle at the entrance of the
electromagnetic calorimeter, and, only if the particle is a primary,
it deposits in the electromagnetic calorimeter an energy obtained
by a gaussian smearing (with mean equal to 1.0 and sigma taken from the
energy resolution of the CMS electromagnetic calorimeter - with ALEPH
or ATLAS electromagnetic calorimeter as a possible alternative) of the
particle kinetic energy (at the entrance of the electromagnetic
calorimeter)
(see the method Par02FastSimModelEMCal::DoIt )
- Par02FastSimModelHCal :
- bound to the hadronic calorimeter
(see the method Par02DetectorConstruction::Construct )
- applicable to all hadrons (i.e. particles made of quarks)
(see the method Par02FastSimModelHCal::IsApplicable )
- triggered in all cases (i.e. no kinematic constraints)
(see the method Par02FastSimModelHCal::ModelTrigger )
- does the following: kill the particle at the entrance of the
hadronic calorimeter, and, only if the particle is a primary,
it deposits in the hadronic calorimeter an energy obtained by a
gaussian smearing (with mean equal to 1.0 and sigma taken from the
energy resolution of the CMS hadronic calorimeter - with ALEPH
or ATLAS hadronic calorimeter as a possible alternative) of the
particle kinetic energy (at the entrance of the hadronic
calorimeter)
(see the method Par02FastSimModelHCal::DoIt )
4. User actions, user information and user utility classes
----------------------------------------------------------
- Par02RunAction : run action used for initialization and termination
of the run.
- Par02EventAction : event action used for initialization and termination
of the event.
- Par02TrackingAction : tracking action used for killing particles with
transverse momentum less than 1 MeV or
pseudorapidity larger (in module) than 5.5
(see method Par02TrackingAction::PreUserTrackingAction )
and to store the information about the track at
the end of the simulation of such a track
(see method Par02TrackingAction::PostUserTrackingAction ).
- Par02ActionInitialization : initialization of the primary generator class
and all user-defined actions (i.e. the three
classes above).
- Par02PrimaryParticleInformation : utility class to store information
associated with a primary particle.
- Par02EventInformation : utility class to store information associated
with a Geant4 event.
- Par02DetectorParametrisation : a simple class used to provide the detector
resolution and efficiency, according to the
type of detector: tracker, electromagnetic
calorimeter, hadronic calorimeter.
There are 3 choices: CMS-like (default),
ALEPH-like and ATLAS-like.
The efficiency is currently set to 1.0 in
all cases and not used.
- Par02Smearer : a simple class that does the gaussian smearing, either
of the momentum (in the tracker detector) or in energy
(in the electromagnetic or hadronic calorimeter).
5. Output
---------
The execution of the program (examplePar02) produces in output, at the end
of a run, a Root file, by default named DefaultOutput.root, which contains
3 histograms and one ntuple.
The macro file examplePar02.in specifies one run made of 1000 events
each consisting of one 50 GeV electron.
By editing the file, one could select alternatively a run made of 1000
events each consisting of one 100 GeV muon, or a run made of 1000 events
each consisting of one 20 GeV pion- .
See the class Par02Output for the definition of the 3 histograms and the
ntuples. Here is a quick summary:
- histogram of the ratio of the momentum smeared and the original momentum
in the tracker (for primary charged particles);
- histogram of the ratio of the smeared energy deposited and the original
energy at the entrance in the electromagnetic calorimeter (for primary
electrons, positrons and gammas);
- histogram of the ratio of the smeared energy deposited and the original
energy at the entrance in the hadronic calorimeter (for primary hadrons);
- ntuple containing the "Monte-Carlo true" information regarding the
primary, and the resolution, efficiency, smeared momentum (tracker),
smeared energy (calorimeter) and impact position (calorimeter) of each
subdetector (tracker, electromagnetic calorimeter, hadronic calorimeter)
where the primary is parametrised (tracker and electromagnetic calorimeter
in the case of primary electrons, positrons and gammas; tracker and
hadronic calorimeter in the case of primary hadrons; tracker only for
all other primary charged particles, e.g. muons).
Note:
- you do not need to have the Root package available to run this example,
but you need it if you want to look at the histograms and the ntuple
contained in the Root output file;
- sensitive detectors and hits are not used in this example.
6. How to build and run the example
-----------------------------------
- You need to have built the Geant4 persistency/gdml module by having set
the -DGEANT4_USE_GDML=ON flag during the CMAKE configuration step,
as well as the -DXERCESC_ROOT_DIR=<path_to_xercesc> flag pointing to
the path where the XercesC XML parser package is installed in your system.
- Compile and link to generate the executable (in your CMAKE build directory):
% make
- Execute the application:
% examplePar02 examplePar02.in
which produces one Root file: DefaultOutput.root .
@@ -0,0 +1,134 @@
///\file "parameterisations/Par03/.README.txt"
///\brief Example Par03 README page
/*! \page ExamplePar03 Example Par03
This example demonstrates how to use G4FastSimHitMaker helper class
to create multiple energy deposits from the fast simulation model.
It requires sensitive detector class to inherit from both base classes:
- G4VSensitiveDetector: for processing of detailed/non-fast simulation hits
- G4VFastSimSensitiveDetector: for processing of fast sim (G4FastSim) hits
Hits are placed in the same hit collection, so they can be used to
compare between the full and the fast simulation.
The geometry used in the example is a homogeneous cylinder of lead, with
3D readout geometry (cylindrical). Analysis of energy deposits is done
in the event action.
\section Par03_s1 Detector description
The detector is a homogeneous cylinder of lead. It is segmented along
z, R and phi to create a readout geometry in the cylindrical coordinates.
Fast simulation is attached to the region of the detector.
\section Par03_s2 Sensitive detector
Sensitive detector inherits from both base classes:
- G4VSensitiveDetector: for processing of detailed/non-fast simulation hits
- G4VFastSimSensitiveDetector: for processing of fast sim (G4FastSim) hits.
Hits are placed in the same hit collection, with a different flag to distinguish
between those originated in the full simulation, and those from the fast
simulation.
During visualisation, hits are represented as volumes of different colour:
green for full simulation and red for fast simulation.
\section Par03_s3 Primary generation
Particle gun is used as a primary generator. The direction of particles is along
the axis of symmetry of the detector (cylinder). It is positioned 10 cm in front
of the entrance to the detector. 10 GeV electron is used by default. Those values
can be changed using /gun/ UI commands.
\section Par03_s4 Physics List
FTFP_BERT modular physics list is used. On top of it, fast simulation physics
is registered for selected particles (electrons, positrons, and photons).
\section Par03_s5 User actions
- Par03RunAction : run action used for initialization and termination
of the run. Histograms for analysis of shower development
in the detector are created.
- Par03EventAction : event action used for initialization and termination
of the event. Analysis of shower development is performed
on event-by-event basis.
\section Par03_s6 Output
The execution of the program (examplePar03) produces an output with histograms.
The macro file examplePar03.in specifies three runs. Each run is made of 100
events, for single 10 GeV electron beams. The first run is executed with fast
simulation model activated with defualt parameters. The second run executes fast
simulation with modified parameters. For the third run the fast simulation model
is disactivated.
Three output files are produced: two with shower development from the fast
simulation (with different parameters), and from the full simulation.
\section Par03_s7 How to build and run the example
- Compile and link to generate the executable (in your CMAKE build directory):
\verbatim
% cmake <PAR03_SOURCE>
% make
\endverbatim
- Execute the application (in batch mode):
\verbatim
% ./examplePar03 -m examplePar03.in
\endverbatim
which produces three root files: Par03_fastsim_100events.root,
Par03_fastsimModified_100events.root, and Par03_fullsim_100events.root.
- Execute the application (in interactive mode):
\verbatim
% ./examplePar03
\endverbatim
which allows to visualize hits.
\section Par03_s8 UI commands
UI commands useful in this example:
- activation/disactivation of the fast simulation model:
\verbatim
/param/ActivateModel model
/param/InActivateModel model
\endverbatim
- particle gun commands
\verbatim
/gun/particle e+
/gun/energy 50 GeV
/gun/direction 0 0.2 1
/gun/position 0 0 0
\endverbatim
UI commands defined in this example:
- detector settings
\verbatim
/Par03/detector/print
/Par03/detector/setDetectorRadius 10 cm
/Par03/detector/setDetectorLength 30 cm
/Par03/detector/setDetectorMaterial G4_Pb
/Par03/detector/setNbOfLayers 100
/Par03/detector/setNbOfPhiCells 20
/Par03/detector/setNbOfRhoCells 100
\endverbatim
- fast simulation settings
\verbatim
/Par03/fastSim/print
/Par03/fastSim/transverseProfile/sigma 20 mm
/Par03/fastSim/longitudinalProfile/beta 0.6
/Par03/fastSim/longitudinalProfile/alpha 2.
/Par03/fastSim/longitudinalProfile/maxDepth 20
/Par03/fastSim/numberOfHits 500
\endverbatim
*/
@@ -0,0 +1,130 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Example Par03
-------------
This example demonstrates how to use G4FastSimHitMaker helper class
to create multiple energy deposits from the fast simulation model.
It requires sensitive detector class to inherit from both base classes:
- G4VSensitiveDetector: for processing of detailed/non-fast simulation hits
- G4VFastSimSensitiveDetector: for processing of fast sim (G4FastSim) hits
Hits are placed in the same hit collection, so they can be used to
compare between the full and the fast simulation.
The geometry used in the example is a homogeneous cylinder of lead, with
3D readout geometry (cylindrical). Analysis of energy deposits is done
in the event action.
1. Detector description
-----------------------
The detector is a homogeneous cylinder of lead. It is segmented along
z, R and phi to create a readout geometry in the cylindrical coordinates.
Fast simulation is attached to the region of the detector.
2. Sensitive detector
-----------------------
Sensitive detector inherits from both base classes:
- G4VSensitiveDetector: for processing of detailed/non-fast simulation hits
- G4VFastSimSensitiveDetector: for processing of fast sim (G4FastSim) hits.
Hits are placed in the same hit collection, with a different flag to distinguish
between those originated in the full simulation, and those from the fast
simulation.
During visualisation, hits are represented as volumes of different colour:
green for full simulation and red for fast simulation.
3. Primary generation
---------------------
Particle gun is used as a primary generator. The direction of particles is along
the axis of symmetry of the detector (cylinder). It is positioned 10 cm in front
of the entrance to the detector. 10 GeV electron is used by default. Those values
can be changed using /gun/ UI commands.
4. Physics List
---------------
FTFP_BERT modular physics list is used. On top of it, fast simulation physics
is registered for selected particles (electrons, positrons, and photons).
5. User actions
----------------------------------------------------------
- Par03RunAction : run action used for initialization and termination
of the run. Histograms for analysis of shower development
in the detector are created.
- Par03EventAction : event action used for initialization and termination
of the event. Analysis of shower development is performed
on event-by-event basis.
6. Output
---------
The execution of the program (examplePar03) produces an output with histograms.
The macro file examplePar03.in specifies three runs. Each run is made of 100
events, for single 10 GeV electron beams. The first run is executed with fast
simulation model activated with defualt parameters. The second run executes fast
simulation with modified parameters. For the third run the fast simulation model
is disactivated.
Three output files are produced: two with shower development from the fast
simulation (with different parameters), and from the full simulation.
7. How to build and run the example
-----------------------------------
- Compile and link to generate the executable (in your CMAKE build directory):
% cmake <PAR03_SOURCE>
% make
- Execute the application (in batch mode):
% ./examplePar03 -m examplePar03.in
which produces three root files: Par03_fastsim_100events.root,
Par03_fastsimModified_100events.root, and Par03_fullsim_100events.root.
- Execute the application (in interactive mode):
% ./examplePar03
which allows to visualize hits.
8. UI commands
--------------
UI commands useful in this example:
- activation/disactivation of the fast simulation model:
/param/ActivateModel model
/param/InActivateModel model
- particle gun commands
/gun/particle e+
/gun/energy 50 GeV
/gun/direction 0 0.2 1
/gun/position 0 0 0
UI commands defined in this example:
- detector settings
/Par03/detector/print
/Par03/detector/setDetectorRadius 10 cm
/Par03/detector/setDetectorLength 30 cm
/Par03/detector/setDetectorMaterial G4_Pb
/Par03/detector/setNbOfLayers 100
/Par03/detector/setNbOfPhiCells 20
/Par03/detector/setNbOfRhoCells 100
- fast simulation settings
/Par03/fastSim/print
/Par03/fastSim/transverseProfile/sigma 20 mm
/Par03/fastSim/longitudinalProfile/beta 0.6
/Par03/fastSim/longitudinalProfile/alpha 2.
/Par03/fastSim/longitudinalProfile/maxDepth 20
/Par03/fastSim/numberOfHits 500
@@ -0,0 +1,191 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Example Par04
-------------
This example demonstrates how to use the Machine Learning (ML) inference
to create energy deposits as a fast simulation model using
<a href="https://github.com/microsoft/onnxruntime">ONNX runtime</a>
and <a href="https://github.com/lwtnn/lwtnn">LWTNN</a> libraries.
The model used in this example was trained externally (in Python) on data
from this examples' full simulation and can be applied to perform fast simulation
The geometry used in the example is a cylindrical setup of layers: tungsten
absorber and silicon as the active material. 3D readout geometry (cylindrical)
is defined dynamically, based on the particle direction at the entrance to the
calorimeter. This is set using a fast simulation model that is triggered at
detector entrance. Analysis of energy deposits is done in the event action,
ntuple with hits is stored.
## 1. Detector description
The detector consists of cylindrical layers of passive and active material,
tungsten and silicon, respectively.
Fast simulation is attached to the region of the detector.
Input macro can specify which layer is considered an active layer (sensitive
detector is attached to it). For fast simulation both layers should be marked
as sensitive. It is connected to the wway the deposits are created: position is
centre of the layer, which may often fall within the absorber (which is thicker
than the active material). In a realistic detector setup, the positions used in
fast simulation would be calculated properly, to deposit energy within the active
material.
## 2. Sensitive detector
Sensitive detector inherits from both base classes:
- G4VSensitiveDetector: for processing of detailed/non-fast simulation hits
- G4VFastSimSensitiveDetector: for processing of fast sim (G4FastSim) hits.
Hits are placed in the same hit collection, with a different flag to distinguish
between those originated in the full simulation, and those from the fast
simulation.
During visualisation, hits are represented as volumes of different colour:
green for full simulation and red for fast simulation.
## 3. Primary generation
Particle gun is used as a primary generator. 10 GeV electron is used by default.
By default particles are generated along y axis. Those values
can be changed using /gun/ UI commands.
## 4. Physics List
FTFP_BERT modular physics list is used. On top of it, fast simulation physics
is registered for selected particles (electrons, positrons).
## 5. User actions
- Par04RunAction : run action used for initialization and termination
of the run. Histograms for analysis of shower development
in the detector are created.
- Par04EventAction : event action used for initialization and termination
of the event. Analysis of shower development is performed
on event-by-event basis.
## 6. ML Inference
- Par04MLFastSimModel : model used for parametrisation of źelectrons, positrons,
and gammas. Energy is deposited and
distributed according to inferred values from the ML model.
This class triggers the inference setup, asks for values,
and deposits energies at given positions.
- Par04InferenceSetup : this class is used to initialize the inference parameters
(user application specific) such as the inference library,
the path and name of the inference model and the size of
the input inference vector(latent dimension and and condition size).
This class constructs this vector and triggers the interface
corresponding to the specified input inference library.
After the inference, the post processing step consists of
scaling back inferred values to the original range.
- Par04InferenceInterface : is a base class that allows to read in the ML model, configure
and execute inference.
- Par04OnnxInference and Par04LWTNNInference : inference library specific classes that inherit
from the base class Par04InferenceInterface.
## 7. Output
The execution of the program (examplePar04) produces an output with histograms.
Ntuples are also stored. They are not merged if the application is run on multiple threads.
The macro file examplePar04.in is used to run full simulation. It will simulate 100
events, for single 10 GeV electron beams.
If CMake is able to find inference libraries (lwtnn and/or ONNX Runtime), a configuration
macro will be available for that library (examplePar04_lwtnn.in and/or examplePar04_onnx.in).
It will use a trained model to run inference and create showers in the detector by directly
depositing energy.
## 8. How to build and run the example
- LWTNN and ONNX Runtime are available on LCG. In order to use them, one can setup the envirnment:
% source /cvmfs/sft.cern.ch/lcg/views/LCG_100/x86_64-centos7-gcc10-opt/setup.sh
- Compile and link to generate the executable (in your CMAKE build directory):
% cmake <Par04_SOURCE>
% make
- Execute the application (in batch mode):
% ./examplePar04 -m examplePar04.in
which produces two root file for full simulation.
- Execute the application (in interactive mode):
% ./examplePar04
which allows to visualize hits.
- If ONNX Runtime is available:
% ./examplePar04 -m examplePar04_onnx.in
- If LWTNN is available:
% ./examplePar04 -m examplePar04_lwtnn.in
By default, CMake will attempt to build fast simulation with ONNX Runtime and LWTNN. However, if none
of those libraries is found, it will proceed with full simulation only. The search can be switched
off manually switching CMake flag INFERENCE_LIB to OFF (-DINFERENCE_LIB=OFF)
## 9. Macros
vis.mac - Allows to run visualization. It will be automatically run in interactive mode, if no
argument is passed to the executable (examplePar04)
examplePar04.in - Runs full simulation. It will run 100 events with single electrons, 10 GeV and
along y axis.
examplePar04_onnx.in - Available only if ONNX Runtime is found by CMake. Runs fast simulation with
a NN stored in onnx file.
examplePar04_lwtnn.in - Available only if LWTNN is found by CMake. Runs fast simulation with
a NN stored in json file.
## 10. UI commands
UI commands useful in this example:
- activation/disactivation of the fast simulation model:
/param/ActivateModel inferenceModel
/param/InActivateModel inferenceModel
- particle gun commands
/gun/particle e-
/gun/energy 10 GeV
/gun/direction 0 1 0
/gun/position 0 0 0
UI commands defined in this example:
- detector settings
/Par04/detector/setDetectorInnerRadius 80 cm
/Par04/detector/setDetectorLength 2 m
/Par04/detector/setNbOfLayers 90
/Par04/detector/setAbsorber 0 G4_W 1.4 mm false
/Par04/detector/setAbsorber 1 G4_Si 0.3 mm true
- readout mesh
/Par04/mesh/setSizeOfRhoCells 2.325 mm
/Par04/mesh/setSizeOfZCells 3.4 mm
/Par04/mesh/setNbOfRhoCells 18
/Par04/mesh/setNbOfPhiCells 50
/Par04/mesh/setNbOfZCells 45
- inference setup
/Par04/inference/setSizeLatentVector 10
/Par04/inference/setSizeConditionVector 4
/Par04/inference/setModelPathName MLModels/Generator.onnx
/Par04/inference/setProfileFlag 0
/Par04/inference/setOptimizationFlag 0
/Par04/inference/setInferenceLibrary ONNX
/Par04/inference/setSizeOfRhoCells 2.325 mm
/Par04/inference/setSizeOfZCells 3.4 mm
/Par04/inference/setNbOfRhoCells 18
/Par04/inference/setNbOfPhiCells 50
/Par04/inference/setNbOfZCells 45
@@ -0,0 +1,200 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Example Par04
-------------
This example demonstrates how to use the Machine Learning (ML) inference
to create energy deposits as a fast simulation model using ONNX runtime [1]
and LWTNN [2] libraries.
The model used in this example was trained externally (in Python) on data
from this examples' full simulation and can be applied to perform fast simulation
The geometry used in the example is a cylindrical setup of layers: tungsten
absorber and silicon as the active material. 3D readout geometry (cylindrical)
is defined dynamically, based on the particle direction at the entrance to the
calorimeter. This is set using a fast simulation model that is triggered at
detector entrance. Analysis of energy deposits is done in the event action,
ntuple with hits is stored.
[1]: https://github.com/microsoft/onnxruntime
[2]: https://github.com/lwtnn/lwtnn
1. Detector description
-----------------------
The detector consists of cylindrical layers of passive and active material,
tungsten and silicon, respectively.
Fast simulation is attached to the region of the detector.
Input macro can specify which layer is considered an active layer (sensitive
detector is attached to it). For fast simulation both layers should be marked
as sensitive. It is connected to the wway the deposits are created: position is
centre of the layer, which may often fall within the absorber (which is thicker
than the active material). In a realistic detector setup, the positions used in
fast simulation would be calculated properly, to deposit energy within the active
material.
2. Sensitive detector
-----------------------
Sensitive detector inherits from both base classes:
- G4VSensitiveDetector: for processing of detailed/non-fast simulation hits
- G4VFastSimSensitiveDetector: for processing of fast sim (G4FastSim) hits.
Hits are placed in the same hit collection, with a different flag to distinguish
between those originated in the full simulation, and those from the fast
simulation.
During visualisation, hits are represented as volumes of different colour:
green for full simulation and red for fast simulation.
3. Primary generation
---------------------
Particle gun is used as a primary generator. 10 GeV electron is used by default.
By default particles are generated along y axis. Those values
can be changed using /gun/ UI commands.
4. Physics List
---------------
FTFP_BERT modular physics list is used. On top of it, fast simulation physics
is registered for selected particles (electrons, positrons).
5. User actions
----------------------------------------------------------
- Par04RunAction : run action used for initialization and termination
of the run. Histograms for analysis of shower development
in the detector are created.
- Par04EventAction : event action used for initialization and termination
of the event. Analysis of shower development is performed
on event-by-event basis.
6. ML Inference
----------------------------------------------------------
- Par04MLFastSimModel : model used for parametrisation of źelectrons, positrons,
and gammas. Energy is deposited and
distributed according to inferred values from the ML model.
This class triggers the inference setup, asks for values,
and deposits energies at given positions.
- Par04InferenceSetup : this class is used to initialize the inference parameters
(user application specific) such as the inference library,
the path and name of the inference model and the size of
the input inference vector(latent dimension and and condition size).
This class constructs this vector and triggers the interface
corresponding to the specified input inference library.
After the inference, the post processing step consists of
scaling back inferred values to the original range.
- Par04InferenceInterface : is a base class that allows to read in the ML model, configure
and execute inference.
- Par04OnnxInference and Par04LWTNNInference : inference library specific classes that inherit
from the base class Par04InferenceInterface.
7. Output
---------
The execution of the program (examplePar04) produces an output with histograms.
Ntuples are also stored. They are not merged if the application is run on multiple threads.
The macro file examplePar04.in is used to run full simulation. It will simulate 100
events, for single 10 GeV electron beams.
If CMake is able to find inference libraries (lwtnn and/or ONNX Runtime), a configuration
macro will be available for that library (examplePar04_lwtnn.in and/or examplePar04_onnx.in).
It will use a trained model to run inference and create showers in the detector by directly
depositing energy.
8. How to build and run the example
-----------------------------------
- LWTNN and ONNX Runtime are available on LCG. In order to use them, one can setup the envirnment:
% source /cvmfs/sft.cern.ch/lcg/views/LCG_100/x86_64-centos7-gcc10-opt/setup.sh
- Compile and link to generate the executable (in your CMAKE build directory):
% cmake <Par04_SOURCE>
% make
- Execute the application (in batch mode):
% ./examplePar04 -m examplePar04.in
which produces two root file for full simulation.
- Execute the application (in interactive mode):
% ./examplePar04
which allows to visualize hits.
- If ONNX Runtime is available:
% ./examplePar04 -m examplePar04_onnx.in
- If LWTNN is available:
% ./examplePar04 -m examplePar04_lwtnn.in
By default, CMake will attempt to build fast simulation with ONNX Runtime and LWTNN. However, if none
of those libraries is found, it will proceed with full simulation only. The search can be switched
off manually switching CMake flag INFERENCE_LIB to OFF (-DINFERENCE_LIB=OFF)
9. Macros
---------
vis.mac - Allows to run visualization. It will be automatically run in interactive mode, if no
argument is passed to the executable (examplePar04)
examplePar04.in - Runs full simulation. It will run 100 events with single electrons, 10 GeV and
along y axis.
examplePar04_onnx.in - Available only if ONNX Runtime is found by CMake. Runs fast simulation with
a NN stored in onnx file.
examplePar04_lwtnn.in - Available only if LWTNN is found by CMake. Runs fast simulation with
a NN stored in json file.
10. UI commands
--------------
UI commands useful in this example:
- activation/disactivation of the fast simulation model:
/param/ActivateModel inferenceModel
/param/InActivateModel inferenceModel
- particle gun commands
/gun/particle e-
/gun/energy 10 GeV
/gun/direction 0 1 0
/gun/position 0 0 0
UI commands defined in this example:
- detector settings
/Par04/detector/setDetectorInnerRadius 80 cm
/Par04/detector/setDetectorLength 2 m
/Par04/detector/setNbOfLayers 90
/Par04/detector/setAbsorber 0 G4_W 1.4 mm false
/Par04/detector/setAbsorber 1 G4_Si 0.3 mm true
- readout mesh
/Par04/mesh/setSizeOfRhoCells 2.325 mm
/Par04/mesh/setSizeOfZCells 3.4 mm
/Par04/mesh/setNbOfRhoCells 18
/Par04/mesh/setNbOfPhiCells 50
/Par04/mesh/setNbOfZCells 45
- inference setup
/Par04/inference/setSizeLatentVector 10
/Par04/inference/setSizeConditionVector 4
/Par04/inference/setModelPathName MLModels/Generator.onnx
/Par04/inference/setProfileFlag 0
/Par04/inference/setOptimizationFlag 0
/Par04/inference/setInferenceLibrary ONNX
/Par04/inference/setSizeOfRhoCells 2.325 mm
/Par04/inference/setSizeOfZCells 3.4 mm
/Par04/inference/setNbOfRhoCells 18
/Par04/inference/setNbOfPhiCells 50
/Par04/inference/setNbOfZCells 45
@@ -0,0 +1,39 @@
Geant4 extended examples - parameterisations
----------------------------------------------
Examples in this directory demonstrate use of parameterisation libraries.
Currently, two examples are provided:
Par01
-------
This example demonstrates the use of parameterisation facilities.
It was moved in extended examples from novice/N05 with removal of
novice examples.
Par02
-------
This example shows how to do "track and energy smearing" in Geant4,
in order to have a very fast simulation based on assumed detector
resolutions.
Par03
-------
This example demonstrates how to create multiple energy deposits
from the fast simulation model and store it alongside deposits created
in full/detailed simulation.
Par04
-------
This example demonstrates how to use machine-learning aided fast simulation
of electromagnetic showers. It runs inference using an external library:
either ONNX Runtime, or LWTNN.
gflash
-------
Set of examples demonstrating the use of the GFLASH parameterisation library.
@@ -0,0 +1,165 @@
///\file "parameterisations/gflash/.README.txt"
///\brief Examples gflash README page
/*! \page Examples_gflash Category "parameterisations/gflash"
These examples demonstrate the use of the GFLASH parameterisation library.
They use the GFLASH equations (hep-ex/0001020, Grindhammer & Peters)
to parametrise electromagnetic showers in matter.
In these examples the calorimeter is a simple cube,
which consists of 10 x 10 crystals of PbWO4 (CMS like).
Briefly, whenever a e-/e+ enters the calorimeter, it is parametrised if it
has a minimum energy and the shower is expected to be contained
in the calorimeter (so called " parameterisation envelope").
If this is fullfilled the particle is killed, as well as all secondaries,
and the energy is deposited according to the GFLASH equations.
The examples show how to interface GFLASH to your application.
The simulation time is measured, so the user can see immediately
the speed up by using GFLASH.
Geometry and parametrisation is defined in different ways in the set of three equivalent
(in terms of produced showers) examples: gflash1, gflash2 and gflash3, to demonstrate
how to use the parametrisation, sensitive detectors and parallel geometry.
The classes which are the same in all three examples have the names with ExGflash prefix while
the names of classes specific to each example have the prexix ExGflash[1,2,3].
The <a href="../html_gflasha/html/Examplegflasha.html"> gflasha </a>
example - allow histogramming of show profiles and fine tuning
of gflash parametrization for homogeneous medium.
Note: Instead of particle gun the gps class is used here for particle generation.
\section Examples_gflash_s1 Briefly
Table below presents in which world/geometry (mass or parallel) each of the elements is defined.
| Example | gflash1 | gflash2 | gflash3 |
|------------------------------|----------|--------------|--------------|
| Block of material | mass geo | mass geo | mass geo |
| Crystals (readout geometry) | mass geo | mass geo | parallel geo |
| Sensitive detector | mass geo | mass geo | parallel geo |
| Envelope for parametrisation | mass geo | parallel geo | mass geo |
\subsection Examples_gflash_s1_sub1 Example gflash1:
Uses only the mass geometry, with each crystal defined as a volume,
with parametrisation attached to the envelope in the mass geometry.
Geometry and sensitive detector are defined in:
- ExGflash1DetectorConstruction
- ExGflash1SensitiveDetector
\subsection Examples_gflash_s1_sub2 Example gflash2:
Uses mass geometry to create volumes and to create a sensitive detector
for storing hits, but parametrisation is attached to the envelope
in the parallel geometry (see also examples/extended/parametrisations/Par01).
Geometry and sensitive detector are defined in:
- ExGflash2DetectorConstruction
- ExGflash2ParallelWorld
- ExGflash2SensitiveDetector
\subsection Examples_gflash_s1_sub3 Example gflash3:
Uses mass geometry to create the main volume (homogeneous material) and use it
as an envelope for the parametrisation, but the readout geometry (crystals)
are defined in the parallel geometry, together with the sensitive detector
to store the hits.
Geometry and sensitive detector are defined in:
- ExGflash3DetectorConstruction
- ExGflash3ParallelWorld
- ExGflash3SensitiveDetector
\section Examples_gflash_s2 Details of implementation:
\subsection Examples_gflash_s2_sub1 Example gflash1:
To use GFLASH the user has to implement the following:
- ExGflash1DetectorConstruction::ConstructSDandField() : \n
Here GFLASH has to be initialized and assigend to the envelope,
where it should be active (here our calorimeter = caloLog )
\code{.cpp}
// **********************************************
// * Initializing shower modell
// ***********************************************
G4cout << "Creating shower parameterization models" << G4endl;
fFastShowerModel = new GFlashShowerModel("fFastShowerModel", fRegion);
fParameterisation = new GFlashHomoShowerParameterisation(pbWO4);
fFastShowerModel->SetParameterisation(*fParameterisation);
fParticleBounds = new GFlashParticleBounds();
fFastShowerModel->SetParticleBounds(*fParticleBounds);
fHitMaker = new GFlashHitMaker();
fFastShowerModel->SetHitMaker(*fHitMaker);
G4cout<<"end shower parameterization."<<G4endl;
// **********************************************
\endcode
- ExGflash1SensitiveDetector: \n
It is mandatory to use G4VGFlashSensitiveDetector as (additional)
base class for the sensitive detector.
Here it is necessary to implement a seperate
interface, where the GFlash spots are processed.
(ProcessHits(G4GFlashSpot*aSpot ,G4TouchableHistory* ROhist))
The separate interface is used, because the GFLASH spots contains
(naturally) less information than the full simulation.
\subsection Examples_gflash_s2_sub2 Example gflash2:
- ExGflash2.cc:
Parallel world needs to be registered;
Fast simulation is activated for parallel world (where envelope is);
- ExGflash2DetectorConstruction:
Only main geometry and SD are created;
- ExGflash2ParallelWorld:
Construction of identical volume for the main box as in the mass geometry,
but with dummy material (it is not used anyway);
Creation of G4Region associated to G4LogicalVolume;
Initialization of GFlash, attaching it to the envelope (G4Region);
- ExGflash2SensitiveDetector:
Uses pointer to ExGflash2ParallelWorld to get the crystals for the readout;
\subsection Examples_gflash_s2_sub3 Example gflash3:
- ExGflash3.cc:
Parallel world needs to be registered;
Physics of the parallel world needs to be registered so sensitive detector can
collect hits;
Fast simulation is activated for mass world (where envelope is);
- ExGflash3DetectorConstruction:
Only main volume (box) with material is created;
Creation of G4Region associated to G4LogicalVolume of that box;
Initialization of GFlash, attaching it to the envelope (G4Region);
- ExGflash3ParallelWorld:
Construction of identical volume for the main box as in the mass geometry,
but with dummy material (it is not used anyway);
Construction of individual crystals for the readout geometry;
Creation of the sensitive detector;
- ExGflash3SensitiveDetector:
Uses pointer to ExGflash3DetectorConstruction to get the crystals for the readout;
\section Examples_gflash_s3 Macros
- vis.mac - macro for use in interactive mode (default, if no arguments are specified)
- test.mac - macro for tests: 50 GeV electrons are shot in the direction of the detector
(along z axis), 10 times. As they enter the parametrisation envelope,
the GFlash parametrisation is invoked and energy is deposited.
The results are printed out:
- energy in the most central crystal
- energy in 3x3 crystals
- energy in 5x5 crystals
- number of created deposits
- simulation time per event
*/
@@ -0,0 +1,175 @@
$README, v 1.0 26.11.2004 Joanna Weng $
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
GFLASH Examples
--------------
These examples demonstrate the use of the GFLASH parameterisation library.
They use the GFLASH equations (hep-ex/0001020, Grindhammer & Peters)
to parametrise electromagnetic showers in matter.
In these examples the calorimeter is a simple cube,
which consists of 10 x 10 crystals of PbWO4 (CMS like).
Briefly, whenever a e-/e+ enters the calorimeter, it is parametrised if it
has a minimum energy and the shower is expected to be contained
in the calorimeter (so called " parameterisation envelope").
If this is fullfilled the particle is killed, as well as all secondaries,
and the energy is deposited according to the GFLASH equations.
The examples show how to interface GFLASH to your application.
The simulation time is measured, so the user can see immediately
the speed up by using GFLASH.
Geometry and parametrisation is defined in different ways in the set of three equivalent
(in terms of produced showers) examples: gflash1, gflash2 and gflash3, to demonstrate
how to use the parametrisation, sensitive detectors and parallel geometry.
The classes which are the same in all three examples have the names with ExGflash prefix while
the names of classes specific to each example have the prexix ExGflash[1,2,3].
The gflasha example - allow histogramming of show profiles and fine tuning
of gflash parametrization for homogeneous medium. This examples has a standalone documentation.
Note: Instead of particle gun the gps class is used here for particle generation.
Briefly
-------
Table below presents in which world/geometry (mass or parallel) each of the elements is defined.
+------------------------------+----------+--------------+--------------+
| Example | gflash1 | gflash2 | gflash3 |
+------------------------------+----------+--------------+--------------+
| Block of material | mass geo | mass geo | mass geo |
+------------------------------+----------+--------------+--------------+
| Crystals (readout geometry) | mass geo | mass geo | parallel geo |
+------------------------------+----------+--------------+--------------+
| Sensitive detector | mass geo | mass geo | parallel geo |
+------------------------------+----------+--------------+--------------+
| Envelope for parametrisation | mass geo | parallel geo | mass geo |
+------------------------------+----------+--------------+--------------+
Example gflash1:
Uses only the mass geometry, with each crystal defined as a volume,
with parametrisation attached to the envelope in the mass geometry.
Geometry and sensitive detector are defined in:
ExGflash1DetectorConstruction
ExGflash1SensitiveDetector
Example gflash2:
Uses mass geometry to create volumes and to create a sensitive detector
for storing hits, but parametrisation is attached to the envelope
in the parallel geometry (see also examples/extended/parametrisations/Par01).
Geometry and sensitive detector are defined in:
ExGflash2DetectorConstruction
ExGflash2ParallelWorld
ExGflash2SensitiveDetector
Example gflash3:
Uses mass geometry to create the main volume (homogeneous material) and use it
as an envelope for the parametrisation, but the readout geometry (crystals)
are defined in the parallel geometry, together with the sensitive detector
to store the hits.
Geometry and sensitive detector are defined in:
ExGflash3DetectorConstruction
ExGflash3ParallelWorld
ExGflash3SensitiveDetector
Details of implementation:
-------
Example gflash1:
To use GFLASH the user has to implement the following:
- ExGflash1DetectorConstruction::ConstructSD() :
Here GFLASH has to be initialized and assigend to the envelope,
where it should be active (here our calorimeter = fCalo_log )
// **********************************************
// * Initializing shower modell
// ***********************************************
G4cout << "Creating shower parameterization models" << G4endl;
fFastShowerModel = new GFlashShowerModel("fFastShowerModel", fRegion);
fParameterisation = new GFlashHomoShowerParameterisation(pbWO4);
fFastShowerModel->SetParameterisation(*fParameterisation);
fParticleBounds = new GFlashParticleBounds();
fFastShowerModel->SetParticleBounds(*fParticleBounds);
fHitMaker = new GFlashHitMaker();
fFastShowerModel->SetHitMaker(*fHitMaker);
G4cout<<"end shower parameterization."<<G4endl;
- ExGflash1SensitiveDetector:
It is mandatory to use G4VGFlashSensitiveDetector as (additional)
base class for the sensitive detector.
Here it is necessary to implement a seperate
interface, where the GFlash spots are processed.
(ProcessHits(G4GFlashSpot*aSpot ,G4TouchableHistory* ROhist))
The separate interface is used, because the GFLASH spots contains
(naturally) less information than the full simulation.
Example gflash2:
- ExGflash2.cc:
Parallel world needs to be registered;
Fast simulation is activated for parallel world (where envelope is);
- ExGflash2DetectorConstruction:
Only main geometry and SD are created;
- ExGflash2ParallelWorld:
Construction of identical volume for the main box as in the mass geometry,
but with dummy material (it is not used anyway);
Creation of G4Region associated to G4LogicalVolume;
Initialization of GFlash, attaching it to the envelope (G4Region);
- ExGflash2SensitiveDetector:
Uses pointer to ExGflash2ParallelWorld to get the crystals for the readout;
Example gflash3:
- ExGflash3.cc:
Parallel world needs to be registered;
Physics of the parallel world needs to be registered so sensitive detector can
collect hits;
Fast simulation is activated for mass world (where envelope is);
- ExGflash3DetectorConstruction:
Only main volume (box) with material is created;
Creation of G4Region associated to G4LogicalVolume of that box;
Initialization of GFlash, attaching it to the envelope (G4Region);
- ExGflash3ParallelWorld:
Construction of identical volume for the main box as in the mass geometry,
but with dummy material (it is not used anyway);
Construction of individual crystals for the readout geometry;
Creation of the sensitive detector;
- ExGflash3SensitiveDetector:
Uses pointer to ExGflash3DetectorConstruction to get the crystals for the readout;
Macros
-------
vis.mac - macro for use in interactive mode (default, if no arguments are specified)
test.mac - macro for tests: 50 GeV electrons are shot in the direction of the detector
(along z axis), 10 times. As they enter the parametrisation envelope,
the GFlash parametrisation is invoked and energy is deposited.
The results are printed out:
- energy in the most central crystal
- energy in 3x3 crystals
- energy in 5x5 crystals
- number of created deposits
- simulation time per event
@@ -0,0 +1,119 @@
///\file "parameterisations/gflash/gflasha/.README.txt"
///\brief Example gflasha README page
/*! \page Examplegflasha Example gflasha
This example demonstrates usage 'gflash' shower parameterisation
in homogeneous calorimeter. Compare with glash1,2,3 in this
example histograms was added. This makes it possible to use this
example for fine tuning of GFLASH parameters.
This example allows to compare the shower profiles from fast simulation
with full simulation by histograming of longitudinal (slice)
and radial profiles with different "binning".
Then GFlash fast simulation can be "tuned" via modification
of the model parameters file:
include/ExGflashHomoShowerTuning.hh
in this example.
\section gflasha_s1 Geometry Definition
In this example the calorimeter is a simple cube,
which consists of 10 x 10 crystals of PbWO4 (CMS like).
Geometry, sensitive detector and hits are defined respectively in:
- ExGflashDetectorConstruction
- ExGflashSensitiveDetector
- ExGflashHit
Materials can be choosen from Nist Materials: G4_Air G4_WATER ...
eg:
\verbatim
/exgflash/det/setMat G4_PbWO4
\endverbatim
see also: csi1.mac
\section gflasha_s2 Hit Scoring
The virtual cylinder sliced longitudinally (slice) and radially (ring) was used.
The size of the slices and rings are expressed in radiation
length units and can be changed.
eg:
\verbatim
/exgflash/det/setLbin 20 1. ---> 20 slices of 1. radl
/exgflash/det/setRbin 5 0.25 ---> 5 rings of 0.25 radl
(MaxBin = 500 in both directions)
\endverbatim
In ExGflashEventAction class the arrays corresponded slices and rings was
created and filled with hists information. This arrays was use to fill
histograms later.
\section gflasha_s3 Visualization
The Visualization Manager is set in the main().
The initialization of the drawing is done via the commands /vis/...
in the macro vis.mac. To get visualization:
\verbatim
/control/execute vis.mac
\endverbatim
\section gflasha_s4 How to start ?
- Execute ExGflasha in 'batch' mode from macro files
\verbatim
% ExGflasha test.mac
\endverbatim
- Execute ExGflasha in 'interactive mode' with visualization
\verbatim
% ExGflasha
....
Idle> type your commands
....
Idle> exit
\endverbatim
The GFLASH activated via:
\verbatim
/GFlash/flag 1
\endverbatim
\section gflasha_s5 Histograms
ExGflasha produces several histograms:
The histograms defined in ExGflashHistoManager class
Content of these histo:
- h0 : energy deposit per event
- h1 : the number of hits per event
- h2 : the energy per hit ( in MeV )
- p0 : longitudinal energy profile
- p1 : radial energy profile
- p2 : cumulated longitudinal energy profile
- p3 : cumulated radial energy profile
To define the output file name with histograms, use the UI command :
\verbatim
/analysys/setFileName name
\endverbatim
\section gflasha_s6 Macros
The macros to run in batch mode:
- test.mac - default macro for example testing
- run01.mac - show how redefine the histograms
- csi1.mac - macro which produce profiles in CsI Material
- test0.mac - profile caparison, long run without GFLASH
- test1.mac - profile comprising, long run with GFLASH on
*/
@@ -0,0 +1,110 @@
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
GFLASHa Example
---------------
The Example demonstrating usage 'gflash' shower parameterisation
in homogeneous calorimeter.Compare with glash1,2,3 in this
example histograms was added. This makes it possible to use this
example for fine tuning of GFLASH parameters.
This example allow compare the shower profiles from fast simulation
with full simulation by histograming of longitudinal (slice)
and radial profiles with different "binning".
Then GFlash fast simulation can be "tuned" via modification
of the model parameters file:
include/ExGflashHomoShowerTuning.hh
in this example.
GEOMETRY DEFINITION
-------------------
In this example the calorimeter is a simple cube,
which consists of 10 x 10 crystals of PbWO4 (CMS like).
Geometry, sensitive detector and hits are defined respectively in:
ExGflashDetectorConstruction
ExGflashSensitiveDetector
ExGflashHit
Materials can be choosen from Nist Materials: G4_Air G4_WATER ...
eg: /exgflash/det/setMat G4_PbWO4 see also: csi1.mac
HIT SCORING
-----------
The virtual cylinder sliced longitudinally (slice) and radially (ring) was used.
The size of the slices and rings are expressed in radiation
length units and can be changed.
eg: /exgflash/det/setLbin 20 1. ---> 20 slices of 1. radl
/exgflash/det/setRbin 5 0.25 ---> 5 rings of 0.25 radl
(MaxBin = 500 in both directions)
In ExGflashEventAction class the arrays corresponded slices and rings was
created and filled with hists information. This arrays was use to fill
histograms later.
VISUALIZATION
-------------
The Visualization Manager is set in the main().
The initialization of the drawing is done via the commands /vis/...
in the macro vis.mac. To get visualization:
/control/execute vis.mac
HOW TO START ?
--------------
- Execute ExGflasha in 'batch' mode from macro files
% ExGflasha test.mac
- Execute ExGflasha in 'interactive mode' with visualization
% ExGflasha
....
Idle> type your commands
....
Idle> exit
The GFLASH activated via:
/GFlash/flag 1
HISTOGRAMS
----------
ExGflasha produces several histograms:
The histograms defined in ExGflashHistoManager class
Content of these histo:
h0 : energy deposit per event
h1 : the number of hits per event
h2 : the energy per hit ( in MeV )
p0 : longitudinal energy profile
p1 : radial energy profile
p2 : cumulated longitudinal energy profile
p3 : cumulated radial energy profile
To define the output file name with histograms, use the UI command :
"/analysys/setFileName name"
MACROS
------
The macros to run in batch mode:
test.mac - default macro for example testing
run01.mac - show how redefine the histograms
csi1.mac - macro which produce profiles in CsI Material
test0.mac - profile comparison, long run without GFLASH
test1.mac - profile comparison, long run with GFLASH on