Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
+42 -9
View File
@@ -5,7 +5,7 @@
/*! \page ExampleRE03 Example RE03
Contact : M.Asai (SLAC), A.Kimura (AIT), T.Aso (TNCMT)
Contact : M.Asai (SLAC/JLab), A.Kimura (AIT), T.Aso (TNCMT)
\section RE03_s1 Introduction
@@ -31,16 +31,49 @@ in Geant4.
\section RE03_s2 Macro files
"run1.mac" through "run4.mac" macro files should be used
independently. Each macro file create its own scoring parallel
world(s). "vis.mac", "drawSlices.mac" and "drawCylinderSlices.mac"
are used internally. Each macro should work for both interactively
and batch, but interactive mode is advised for better visualization.
\subsection RE03_s21 "run.mac"
IMPORTANT: DO NOT use more than one of these macro files in one
execution of this example.
"run.mac" is the main macro file of this example for both
batch and interactive modes.
\section RE03_s3 RE03UserScoreWriter
In interactive mode, trajectories are not visualized by default
for the sake of execution speed. To visualize them, comment out
lines of /vis/disable and /vis/enable in "run.mac".
In addition, in sub-event parallel mode, only the trajectories
created in the master thread are visualized by default.
Un-comment the line of /run/trajectoriesToBeMerged in "vis.mac"
to visualize all trajectories.
"draw.mac" is used by "run1.mac" to visualize a score.
\subsection RE03_s22 Other macro files
"run2.mac" through "run4.mac" macro files should be used
independently. They demonstrate additional functionalities of
command-based scoring. Each macro file create its own scoring
parallel world(s).
- "run2.mac" : defining three box meshes of different sizes
and granurarities touching to each other
- "run3.mac" : defining two box meshes of different sizes and
granurarities overlaying one over the other to demonstrate
changing granurarity of a box mesh
- "run4.mac" " defining a cylindrical mesh
IMPORTANT: DO NOT use more than one of these macro files in
one execution of this example.
"drawSlice.mac" and "drawCylinderSlice.mac" are used internally
from "run*.mac" to draw a single slice of the corresponding mesh.
\section RE03_s3 RE03ActionInitialization
This UserActionInitialization class works for all Geant4 run
modes, i.e. sequential mode, event-level paralle mode and
sub-event-level parallel mode.
\section RE03_s4 RE03UserScoreWriter
G4ScoringManager has a default score writer which dumps every
entry of one quantity of a mesh for all quantities of the mesh
@@ -40,7 +40,7 @@ target_link_libraries(RE03 ${Geant4_LIBRARIES} )
# relies on these scripts being in the current working directory.
#
set(RE03_SCRIPTS
drawCylinderSlice.mac drawSlice.mac batchrun1.mac run1.mac run2.mac run3.mac run4.mac vis.mac
drawCylinderSlice.mac drawSlice.mac draw.mac run.mac run2.mac run3.mac run4.mac vis.mac
)
foreach(_script ${RE03_SCRIPTS})
+9 -2
View File
@@ -1,9 +1,16 @@
# Example RE03 History
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top). It must **not**
be used as a substitute for writing good git commit messages!
which **must** added in reverse chronological order (newest at the top).
It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-11-11 Gabriele Cosmo (exampleRE03-V11-02-01)
- Fixed CMake script for missing input macros.
## 2024-11-07 Makoto Asai (exampleRE03-V11-02-00)
- Adding sub-event parallel mode
## 2021-12-10 Ben Morgan (exampleRE03-V11-00-00)
- Change to new Markdown History format
+63 -61
View File
@@ -29,89 +29,91 @@
//
//
#include "FTFP_BERT.hh"
#include "RE03ActionInitialization.hh"
#include "RE03DetectorConstruction.hh"
#include "G4Types.hh"
#include "G4RunManagerFactory.hh"
#include "G4ScoringManager.hh"
#include "G4Types.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4ScoringManager.hh"
#include "RE03DetectorConstruction.hh"
#include "FTFP_BERT.hh"
#include "RE03ActionInitialization.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
//====================================================================
// Un-comment this line for user defined score writer
// #include "RE03UserScoreWriter.hh"
//====================================================================
int main(int argc, char** argv)
int main(int argc,char** argv)
{
// Instantiate G4UIExecutive if there are no arguments (interactive mode)
G4UIExecutive* ui = nullptr;
if (argc == 1) {
ui = new G4UIExecutive(argc, argv);
}
// Instantiate G4UIExecutive if there are no arguments (interactive mode)
G4UIExecutive* ui = nullptr;
if ( argc == 1 ) {
ui = new G4UIExecutive(argc, argv);
}
// Construct the run manager
//
auto* runManager = G4RunManagerFactory::CreateRunManager();
runManager->SetNumberOfThreads(4);
// Construct the run manager
//
auto* runManager = G4RunManagerFactory::CreateRunManager();
runManager->SetNumberOfThreads(4);
// Activate UI-command base scorer
G4ScoringManager* scManager = G4ScoringManager::GetScoringManager();
scManager->SetVerboseLevel(1);
// Activate UI-command base scorer
G4ScoringManager * scManager = G4ScoringManager::GetScoringManager();
scManager->SetVerboseLevel(1);
//====================================================================
// Un-comment this line for user defined score writer
// scManager->SetScoreWriter(new RE03UserScoreWriter());
//====================================================================
//====================================================================
// Un-comment this line for user defined score writer
// scManager->SetScoreWriter(new RE03UserScoreWriter());
//====================================================================
// Set mandatory initialization classes
//
G4VUserDetectorConstruction* detector = new RE03DetectorConstruction;
runManager->SetUserInitialization(detector);
//
G4VUserPhysicsList* physics = new FTFP_BERT;
runManager->SetUserInitialization(physics);
// Set mandatory initialization classes
//
G4VUserDetectorConstruction* detector = new RE03DetectorConstruction;
runManager->SetUserInitialization(detector);
//
G4VUserPhysicsList* physics = new FTFP_BERT;
runManager->SetUserInitialization(physics);
// Set user action classes through Worker Initialization
//
RE03ActionInitialization* actions = new RE03ActionInitialization;
runManager->SetUserInitialization(actions);
// Visualization manager
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
// Set user action classes through Worker Initialization
//
RE03ActionInitialization* actions = new RE03ActionInitialization;
runManager->SetUserInitialization(actions);
// Initialize G4 kernel
//
runManager->Initialize();
// Get the pointer to the User Interface manager
//
G4UImanager* UImanager = G4UImanager::GetUIpointer();
// Visualization manager
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
// Initialize G4 kernel
//
runManager->Initialize();
// Get the pointer to the User Interface manager
//
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if (ui) // Define UI session for interactive mode
{
UImanager->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
}
else // Batch mode
{
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command + fileName);
}
if (ui) // Define UI session for interactive mode
{
UImanager->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
}
else // Batch mode
{
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command+fileName);
}
// 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 !
delete visManager;
delete runManager;
delete visManager;
delete runManager;
return 0;
return 0;
}
+42 -9
View File
@@ -2,7 +2,7 @@
RE03 - An extended example for run and event
--------------------------------------------
Contact : M.Asai (SLAC), A.Kimura (AIT), T.Aso (TNCMT)
Contact : M.Asai (SLAC/JLab), A.Kimura (AIT), T.Aso (TNCMT)
1. Introduction
@@ -28,16 +28,49 @@ in Geant4.
2. Macro files
"run1.mac" through "run4.mac" macro files should be used
independently. Each macro file create its own scoring parallel
world(s). "vis.mac", "drawSlices.mac" and "drawCylinderSlices.mac"
are used internally. Each macro should work for both interactively
and batch, but interactive mode is advised for better visualization.
2.1 "run.mac"
IMPORTANT: DO NOT use more than one of these macro files in one
execution of this example.
"run.mac" is the main macro file of this example for both
batch and interactive modes.
In interactive mode, trajectories are not visualized by default
for the sake of execution speed. To visualize them, comment out
lines of /vis/disable and /vis/enable in "run.mac".
3. RE03UserScoreWriter
In addition, in sub-event parallel mode, only the trajectories
created in the master thread are visualized by default.
Un-comment the line of /run/trajectoriesToBeMerged in "vis.mac"
to visualize all trajectories.
"draw.mac" is used by "run.mac" to visualize a score.
2.2 Other macro files
"run2.mac" through "run4.mac" macro files should be used
independently. They demonstrate additional functionalities of
command-based scoring. Each macro file create its own scoring
parallel world(s).
- "run2.mac" : defining three box meshes of different sizes
and granurarities touching to each other
- "run3.mac" : defining two box meshes of different sizes and
granurarities overlaying one over the other to demonstrate
changing granurarity of a box mesh
- "run4.mac" " defining a cylindrical mesh
IMPORTANT: DO NOT use more than one of these macro files in
one execution of this example.
"drawSlice.mac" and "drawCylinderSlice.mac" are used internally
from "run*.mac" to draw a single slice of the corresponding mesh.
3. RE03ActionInitialization
This UserActionInitialization class works for all Geant4 run
modes, i.e. sequential mode, event-level paralle mode and
sub-event-level parallel mode.
4. RE03UserScoreWriter
G4ScoringManager has a default score writer which dumps every
entry of one quantity of a mesh for all quantities of the mesh
@@ -0,0 +1,18 @@
########################################
#
# drawing projections
#
######/score/drawProjection boxMesh_1 eDep
######/score/drawProjection boxMesh_1 nOfStepGamma
######/score/drawProjection boxMesh_1 nOfStepEMinus
######/score/drawProjection boxMesh_1 nOfStepEPlus
#
########################################
#
# drawing slices
#
/score/colorMap/setMinMax ! 0. 400.
/control/loop drawSlice.mac iColumn 0 29 7
#
########################################
#
@@ -38,10 +38,11 @@ class RE03ActionInitialization : public G4VUserActionInitialization
{
public:
RE03ActionInitialization();
virtual ~RE03ActionInitialization();
~RE03ActionInitialization() override;
public:
virtual void Build() const;
void BuildForMaster() const override;
void Build() const override;
};
#endif
@@ -1,9 +1,19 @@
########################################
#########################################################
# macro file for RE03 example
# - for both batch and interactive modes
#
# in interactive mode
# - to visualize trajectories, remove /vis/disable and
# /vis/enable commands below.
# - in sub-event parallel mode, to visualize trajectories
# generated in worker threads, un-comment the specified
# line in the vis.mac macro file.
#
#########################################################
#
# define scoring mesh
#
/score/create/boxMesh boxMesh_1
#
/score/mesh/boxSize 100. 100. 100. cm
/score/mesh/nBin 30 30 30
#
@@ -21,18 +31,24 @@
#
########################################
#
/control/doifInteractive /vis/disable
/control/verbose 2
/run/verbose 1
/gun/particle e-
/run/verbose 2
/gun/particle mu-
/run/beamOn 2000
/control/doifInteractive /vis/enable
#
########################################
#
# Dump scorers to a file
#
/score/dumpQuantityToFile boxMesh_1 eDep eDep.txt
/score/dumpQuantityToFile boxMesh_1 nOfStepGamma nOfStepGamma.txt
/score/dumpQuantityToFile boxMesh_1 nOfStepEMinus nOfStepEMinus.txt
/score/dumpQuantityToFile boxMesh_1 nOfStepEPlus nOfStepEPlus.txt
#
#
########################################
#
# drawing projection
#
/control/ifInteractive draw.mac
#
#
+86 -15
View File
@@ -11,7 +11,7 @@ Environment variable "G4FORCE_RUN_MANAGER_TYPE" enabled with value == Serial. Fo
**************************************************************
Geant4 version Name: geant4-11-02-ref-06 (28-June-2024)
Geant4 version Name: geant4-11-03-ref-00 (6-December-2024)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
@@ -33,7 +33,6 @@ Registered graphics systems are:
RayTracer (RayTracer)
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)
TOOLSSG_OFFSCREEN (TSG_OFFSCREEN)
TOOLSSG_OFFSCREEN (TSG_OFFSCREEN, TSG_FILE)
OpenGLImmediateQt (OGLIQt, OGLI)
OpenGLStoredQt (OGLSQt, OGL, OGLS)
@@ -118,8 +117,8 @@ G4ScoringBox : boxMesh_1 --- Shape: Box mesh
1 nOfStepGamma with gammaFilter
2 nOfStepEMinus with eMinusFilter
3 nOfStepEPlus with ePlusFilter
/run/verbose 1
/gun/particle e-
/run/verbose 2
/gun/particle mu-
/run/beamOn 2000
/run/geometryModified
=======================================================================
@@ -143,10 +142,13 @@ Bremsstrahlung energy threshold above which
primary e+- is added to the list of secondary 100 TeV
Bremsstrahlung energy threshold above which primary
muon/hadron is added to the list of secondary 100 TeV
Positron annihilation at rest model SimplePositronium
Enable 3 gamma annihilation on fly 0
Lowest triplet kinetic energy 1 MeV
Enable sampling of gamma linear polarisation 0
5D gamma conversion model type 0
5D gamma conversion model on isolated ion 0
Use Ricardo-Gerardo pair production model 0
Livermore data directory epics_2017
=======================================================================
====== Ionisation Parameters ========
@@ -317,7 +319,7 @@ ionIoni: for GenericIon XStype:3 SubType=2
Lambda tables from threshold to 100 TeV, 7 bins/decade, spline: 1
StepFunction=(0.2, 0.1 mm), integ: 3, fluct: 1, linLossLim= 0.02
===== EM models for the G4Region DefaultRegionForTheWorld ======
BraggIon : Emin= 0 eV Emax= 2 MeV
Bragg : Emin= 0 eV Emax= 2 MeV
BetheBloch : Emin= 2 MeV Emax= 100 TeV
msc: for alpha SubType= 10
@@ -799,7 +801,7 @@ CoulombScat: for pi- XStype:1 SubType=1 BuildTable=1
=======================================================================
====== Geant4 Native Pre-compound Model Parameters ========
=======================================================================
Type of pre-compound inverse x-section 3
Type of pre-compound inverse x-section 1
Pre-compound model active 1
Pre-compound excitation low energy 100 keV
Pre-compound excitation high energy 30 MeV
@@ -824,11 +826,24 @@ Use discrete excitation energy of the residual 0
Time limit for long lived isomeres 1 ns
Isomer production flag 1
Internal e- conversion flag 1
Store e- internal conversion data 0
Store e- internal conversion data 1
Correlated gamma emission flag 0
Max 2J for sampling of angular correlations 10
=======================================================================
Region <DefaultRegionForTheWorld> -- -- appears in <World> world volume
This region is in the mass world.
Root logical volume(s) : World
Pointers : G4VUserRegionInformation[0], G4UserLimits[0], G4FastSimulationManager[0], G4UserSteppingAction[0]
Materials : G4_AIR G4_WATER
Production cuts : gamma 700 um e- 700 um e+ 700 um proton 700 um
Region <DefaultRegionForParallelWorld> -- -- is not associated to any world.
Root logical volume(s) : boxMesh_1
Pointers : G4VUserRegionInformation[0], G4UserLimits[0], G4FastSimulationManager[0], G4UserSteppingAction[0]
Materials :
Production cuts : gamma 700 um e- 700 um e+ 700 um proton 700 um
========= Table of registered couples ============================
Index : 0 used in the geometry : Yes
@@ -847,27 +862,83 @@ Index : 1 used in the geometry : Yes
==================================================================
G4VisManager: Using G4TrajectoryDrawByCharge as fallback trajectory model.
See commands in /vis/modeling/trajectories/ for other options.
Start closing geometry.
--------------------------------------------------------------------------------
G4GeometryManager::ReportVoxelStats -- Voxel Statistics
Total memory consumed for geometry optimisation: 5 kByte
Total CPU time elapsed for geometry optimisation: 0 seconds
Voxelisation: top CPU users:
Percent Total CPU System CPU Memory Volume
------- ---------- ---------- -------- ----------
0.00 0.00 0.00 2k boxMesh_1_0
0.00 0.00 0.00 2k boxMesh_1_1
0.00 0.00 0.00 2k boxMesh_1_2
Voxelisation: top memory users:
Percent Memory Heads Nodes Pointers Total CPU Volume
------- -------- ------ ------ -------- ---------- ----------
33.33 1k 1 30 30 0.00 boxMesh_1_0
33.33 1k 1 30 30 0.00 boxMesh_1_1
33.33 1k 1 30 30 0.00 boxMesh_1_2
--------------------------------------------------------------------------------
### Run 0 starts.
Run terminated.
Run Summary
Number of events processed : 2000
User=44.460000s Real=46.031008s Sys=0.020000s
User=5.480000s Real=5.759561s Sys=0.010000s
/control/doifInteractive /vis/enable
#
########################################
#
# Dump scorers to a file
#
/score/dumpQuantityToFile boxMesh_1 eDep eDep.txt
/score/dumpQuantityToFile boxMesh_1 nOfStepGamma nOfStepGamma.txt
/score/dumpQuantityToFile boxMesh_1 nOfStepEMinus nOfStepEMinus.txt
/score/dumpQuantityToFile boxMesh_1 nOfStepEPlus nOfStepEPlus.txt
#
#
########################################
#
# drawing projection
#
/control/ifInteractive draw.mac
#
#
Graphics systems deleted.
Visualization Manager deleting...
G4 kernel has come to Quit state.
Deleting G4Run (id:0)
UserDetectorConstruction deleted 0xa4aaf0
UserPhysicsList deleted 0xa46e40
UserActionInitialization deleted 0xc05bd0
UserWorkerInitialization deleted 0
UserWorkerThreadInitialization deleted 0
UserRunAction deleted.
UserPrimaryGenerator deleted.
RunManager is deleting RunManagerKernel.
G4SDManager deleted.
EventManager deleted.
Units table cleared.
TransportationManager deleted.
Total navigation history collections cleaned: 49
G4RNGHelper object is deleted.
================== Deleting memory pools ===================
Number of memory pools allocated: 12 of which, static: 0
Dynamic pools deleted: 12 / Total memory freed: 0.17 MB
Pool ID '20G4NavigationLevelRep', size : 0.0779 MB
Pool ID '24G4ReferenceCountedHandleIvE', size : 0.000961 MB
Pool ID '17G4DynamicParticle', size : 0.0211 MB
Pool ID '7G4Event', size : 0.000961 MB
Pool ID '15G4PrimaryVertex', size : 0.000961 MB
Pool ID '17G4PrimaryParticle', size : 0.000961 MB
Pool ID '15G4HCofThisEvent', size : 0.000961 MB
Pool ID '7G4Track', size : 0.0413 MB
Pool ID '18G4TouchableHistory', size : 0.00577 MB
Pool ID '15G4CountedObjectIvE', size : 0.000961 MB
Number of memory pools allocated: 10 of which, static: 0
Dynamic pools deleted: 10 / Total memory freed: 0.15 MB
============================================================
G4Allocator objects are deleted.
UImanager deleted.
StateManager deleted.
RunManagerKernel is deleted. Good bye :)
RunManager is deleted.
@@ -1,62 +0,0 @@
########################################
#
# define scoring mesh
#
/score/create/boxMesh boxMesh_1
#
/score/mesh/boxSize 100. 100. 100. cm
/score/mesh/nBin 30 30 30
#
/score/quantity/energyDeposit eDep
/score/quantity/nOfStep nOfStepGamma
/score/filter/particle gammaFilter gamma
/score/quantity/nOfStep nOfStepEMinus
/score/filter/particle eMinusFilter e-
/score/quantity/nOfStep nOfStepEPlus
/score/filter/particle ePlusFilter e+
#
/score/close
#
/score/list
#
########################################
#
/vis/disable
/control/verbose 2
/run/verbose 1
#######/event/verbose 1
#######/tracking/verbose 1
#######/vis/verbose confirmations
/gun/particle e-
/run/beamOn 2000
/vis/enable
#
########################################
#
# drawing projections
#
/score/drawProjection boxMesh_1 eDep
/score/drawProjection boxMesh_1 nOfStepGamma
/score/drawProjection boxMesh_1 nOfStepEMinus
/score/drawProjection boxMesh_1 nOfStepEPlus
#
########################################
#
# drawing slices
#
# new scene and viewer
/vis/open
# This opens the default viewer - see examples/basic/B1/vis.mac for a
# more comprehensive overview of options. Also the documentation.
/vis/drawVolume world
/vis/viewer/copyViewFrom viewer-0
/score/colorMap/setMinMax ! 0. 800.
/control/loop drawSlice.mac iColumn 0 29 7
#
########################################
#
# Dump scorers to a file
#
/score/dumpQuantityToFile boxMesh_1 nOfStepGamma nOfStepGamma.txt
#
#
@@ -30,7 +30,9 @@
//
#include "RE03ActionInitialization.hh"
#include "G4RunManager.hh"
#include "G4ParticleTypes.hh"
#include "G4ClassificationOfNewTrack.hh"
#include "RE03PrimaryGeneratorAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -45,8 +47,35 @@ RE03ActionInitialization::~RE03ActionInitialization()
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RE03ActionInitialization::BuildForMaster() const
{
auto* runManager = G4RunManager::GetRunManager();
// check if in sub-event parallel mode
if(runManager->GetRunManagerType()==G4RunManager::subEventMasterRM)
{
// defining size of sub-event
runManager->RegisterSubEventType(0,100);
// sending electron, positron and gamma to worker thread
runManager->SetDefaultClassification(G4Electron::Definition(),fSubEvent_0);
runManager->SetDefaultClassification(G4Positron::Definition(),fSubEvent_0);
runManager->SetDefaultClassification(G4Gamma::Definition(),fSubEvent_0);
// primary generator action is defined to the master thread
SetUserAction(new RE03PrimaryGeneratorAction);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RE03ActionInitialization::Build() const
{
SetUserAction(new RE03PrimaryGeneratorAction);
auto* runManager = G4RunManager::GetRunManager();
// check if NOT in the sub-event parallel mode
if(runManager->GetRunManagerType()!=G4RunManager::subEventWorkerRM)
{
// primary generator action is defined to the worker thread
SetUserAction(new RE03PrimaryGeneratorAction);
}
}
+7 -5
View File
@@ -7,15 +7,17 @@
/vis/drawVolume worlds
#
/vis/viewer/set/viewpointThetaPhi 105 165 deg
# Set specific color for identification
###/vis/geometry/set/colour Calor-AP_LayerLog ! yellow
###/vis/geometry/set/colour Calor-BP_LayerLog ! yellow
###/vis/geometry/set/colour Calor-CP_LayerLog ! yellow
/vis/viewer/zoom 2.0
##############/vis/viewer/flush
#
# for drawing the tracks
/vis/scene/endOfEventAction accumulate
/vis/scene/add/trajectories
#
# Un-comment the following line to draw trajectories created in
# worker threads for the case of sub-event parallel mode.
# Please be cautious of the memory consumption! Do not use this
# with too many events.
####/control/strdoif {RunMode} == subEventParallel /run/trajectoriesToBeMerged
#
# If too many tracks, /vis/disable before running many events