Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
@@ -0,0 +1,84 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 3.16...3.27)
project(${common_prefix}common)
#----------------------------------------------------------------------------
# Find Geant4 package, activating all available UI and Vis drivers by default
# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Option to build examples in addition to test
#
option(COMMON_EXAMPLES "Activate building example executables" ON)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
#----------------------------------------------------------------------------
# Locate sources and headers for this project
#
include_directories(${PROJECT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR})
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
#----------------------------------------------------------------------------
# Add the library
#
add_library(${common_prefix}common ${sources} ${headers})
target_link_libraries(${common_prefix}common ${Geant4_LIBRARIES} )
#----------------------------------------------------------------------------
# Add the test executable, and link it to the Geant4 libraries and common library
#
add_executable(${common_prefix}testCommon testCommon.cc )
target_link_libraries(${common_prefix}testCommon ${common_prefix}common ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# Optionally, add the example executables, and link it to the Geant4 libraries and common library
#
if(COMMON_EXAMPLES)
add_executable(exCommon exCommon.cc )
target_link_libraries(exCommon ${common_prefix}common ${Geant4_LIBRARIES})
add_executable(exCommonNoVis exCommonNoVis.cc )
target_link_libraries(exCommonNoVis ${common_prefix}common ${Geant4_LIBRARIES})
endif(COMMON_EXAMPLES)
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build detectorConstruction. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(detectorConstruction_SCRIPTS
init.mac init_vis.mac run.mac vis.mac
)
foreach(_script ${detectorConstruction_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
# and the library to 'lib' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS ${common_prefix}testCommon DESTINATION bin)
if (COMMON_EXAMPLES)
install(TARGETS exCommon DESTINATION bin)
install(TARGETS exCommonNoVis DESTINATION bin)
endif(COMMON_EXAMPLES)
install(TARGETS ${common_prefix}common DESTINATION lib)
+120
View File
@@ -0,0 +1,120 @@
# Example common 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!
## 2025-07-28 I. Hrivnacova (common-V11-03-00)
- Moved the example as 'exCommon' in the new 'common' directory and renamed the executables
from exampleCommon* in exCommon
## 2023-11-15 I. Hrivnacova (excommon-V11-01-02)
- Updated vis.mac macros:
- Changed "/vis/open XYZ [600x600-0+0]" to "/vis/open" to allow run-time choices
and simplified comments.
## 2023-11-14 I. Hrivnacova (excommon-V11-01-01)
- Fixes for Doxygen:
Move class description comments after namespace
## 2023-11-09 I. Hrivnacova (excommon-V11-01-00)
- Coding guidelines - document macros in README files
## 2022-11-09 I. Hrivnacova (excommon-V11-00-02)
- Fixed file descriptions in the top directory
## 2022-11-07 I. Hrivnacova (excommon-V11-00-01)
New coding guidelines, added tests:
- Added exampleCommon.cc and exampleCommonNoVis.cc
- Added namespace Common
- Override keywords
- Data members initialization in .hh
- Updated README files
- Removed trailing whitespaces
## 2021-12-10 Ben Morgan (excommon-V11-00-00)
- Change to new Markdown History format
---
# History entries prior to 11.0
24/05/21 B. Morgan (excommon-V10-07-00)
- Bump required CMake version range to 3.12...3.20, matching core Geant4
03/11/20 B. Morgan (excommon-V10-06-00)
- Support same CMake version range as core Geant4
29/09/17 I. Hrivnacova (excommon-V10-03-00,01)
- Removed generic class names prefix (ExG4) and introduced a meaningful one
when appropriate
- Removed event and run action classes which are now obsolete
- Replaced explicit messengers with use of G4GenericMessenger
- C++11 (nullptr, auto)
20/07/16 I. Hrivnacova (excommon-V10-02-01)
- Coding guidelines (redundant empty lines)
04/07/16 I. Hrivnacova (excommon-V10-02-00)
- Fix for Doxygen documentation
09/06/15 I. Hrivnacova (excommon-V10-01-00)
- Added a client-specific prefix to common library and test
to avoid name clashes when building all extended examples at once
06/11/14 I. Hrivnacova (excommon-V10-00-06)
- Fixed CMakeLists.txt for removal of analysis directory
05/11/14 I. Hrivnacova (excommon-V10-00-05)
- Restoring back GNUmakefile (lost with previous update)
05/11/14 I. Hrivnacova (excommon-V10-00-04)
- Moved analysis subdirectory in extended/analysis/AnaEx01/hbook,
as it is not used anywhere else
05/11/14 I. Hrivnacova (excommon-V10-00-03)
- Removed sub-directories with user classes and scripts (now obsolete)
04/11/14 I. Hrivnacova (excommon-V10-00-02)
- Added GNUmakefile in top directory
04/11/14 I. Hrivnacova (excommon-V10-00-01)
- Modifications to facilitate use of common directory via svn:externals:
merging user classes in the top directoy (include and src),
added testCommon.cc for all classes altogether and
added building common library
28/05/14 I. Hrivnacova (excommon-V10-00-00)
- Removed fPrintModulo from ExG4EventAction01
and fSetPrintModuloCmd from ExG4EventAction01Messenger,
now obsolete.
- Fixed long lines, separators in userActions classes
28/02/13 I. Hrivnacova (excommon-V09-06-00)
- When building materials with NistManager
do not set fromIsotopes argument (which was set to false),
as since 9.6 all materials have to be built from isotopes.
Thanks to V. Ivantchenko for pointing at this.
26/09/2012 I. Hrivnacova (excommon-V09-05-02)
- Added/updated CMakeLists.txt files:
adding copying macros, install target, comment lines
and HBOOK external package in analysis
- Added explicit includes of G4SystemOfUnits.hh and G4PhysicalConstants.hh
- Replaced tabulators with space characters
- Updated script for generating CMakeLists.txt files
19/07/2012 I. Hrivnacova (excommon-V09-05-01)
- Fix in the scripts (copying files from shared with an extension)
05/06/2012 I. Hrivnacova (excommon-V09-05-00)
- Updated scripts for copying shared files; the shared files are now
defined in the SharedFilesList.txt file
23/11/2011 I. Hrivnacova (excommon-V09-04-01)
- Addded physicsList directory with a physics list with genatino
and charged geantino
15/11/2011 I. Hrivnacova (excommon-V09-04-00)
- First version of the common classes for the extended examples.
@@ -0,0 +1,26 @@
\page ExampleexCommon Example exCommon
This example includes a set of classes independent on each other which
can be reused in "feature" examples demonstrating just a particular feature
or users applications.
It provides the following sets of classes:
- Detector construction classes
- two simple detector construction classes with a messenger
- Physics list classes
- GeantinoPhysicsList - physics list with geantino and chargedgeantino only
- Primary generator classes
- two simple primary generator classes (with G4ParticleGun and
G4ParticleGeneralSource)
These classes can be tested with the following programs:
- testCommon.cc - only instantiates all classes
- exampleCommonNoVis.cc - Geant4 application without visualization, that can be run
both interactively or in batch (with the init.mac or run.mac macro)
- exampleCommonNoVis.cc - Geant4 application with visualization, that can be run
both interactively or in batch (with the init_vis.mac or run.mac macro)
Building examples programs can be disabled with the CMake option: -DEXAMPLES_COMMON=OFF.
@@ -0,0 +1,167 @@
############################################
!!! WARNING - FPE detection is activated !!!
############################################
################################
!!! G4Backtrace is activated !!!
################################
**************************************************************
Geant4 version Name: geant4-11-03-ref-06 (30-June-2025)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
: NIM A 835 (2016), 186-225
WWW : http://geant4.org/
**************************************************************
Visualization Manager instantiating with verbosity "warnings (3)"...
Visualization Manager initialising...
Registering graphics systems...
You have successfully registered the following graphics systems.
Registered graphics systems are:
ASCIITree (ATree)
DAWNFILE (DAWNFILE)
G4HepRepFile (HepRepFile)
RayTracer (RT)
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)
TOOLSSG_OFFSCREEN (TSG_OFFSCREEN, TSG_FILE)
OpenGLImmediateQt (OGLIQt, OGLI)
OpenGLStoredQt (OGLSQt, OGLS)
OpenGLImmediateXm (OGLIXm, OGLIQt_FALLBACK)
OpenGLStoredXm (OGLSXm, OGLSQt_FALLBACK)
OpenGLImmediateX (OGLIX, OGLIQt_FALLBACK, OGLIXm_FALLBACK)
OpenGLStoredX (OGLSX, OGLSQt_FALLBACK, OGLSXm_FALLBACK)
RayTracerX (RTX)
RayTracerQt (RTQt)
Qt3D (Qt3D)
TOOLSSG_X11_GLES (TSG_X11_GLES, TSGX11, TSG_XT_GLES_FALLBACK)
TOOLSSG_X11_ZB (TSG_X11_ZB, TSGX11ZB)
TOOLSSG_XT_GLES (TSG_XT_GLES, TSGXt, TSG_QT_GLES_FALLBACK)
TOOLSSG_XT_ZB (TSG_XT_ZB, TSGXtZB)
TOOLSSG_QT_GLES (TSG_QT_GLES, TSGQt, TSG, OGL)
TOOLSSG_QT_ZB (TSG_QT_ZB, TSGQtZB)
You may choose a graphics system (driver) with a parameter of
the command "/vis/open" or "/vis/sceneHandler/create",
or you may omit the driver parameter and choose at run time:
- by argument in the construction of G4VisExecutive
- by environment variable "G4VIS_DEFAULT_DRIVER"
- by entry in "~/.g4session"
- by build flags.
- Note: This feature is not allowed in batch mode.
For further information see "examples/basic/B1/exampleB1.cc"
and "vis.mac".
Registering model factories...
You have successfully registered the following model factories.
Registered model factories:
generic
drawByAttribute
drawByCharge
drawByOriginVolume
drawByParticleID
drawByEncounteredVolume
Registered models:
None
Registered filter factories:
attributeFilter
chargeFilter
originVolumeFilter
particleFilter
encounteredVolumeFilter
Registered filters:
None
You have successfully registered the following user vis actions.
Run Duration User Vis Actions: none
End of Event User Vis Actions: none
End of Run User Vis Actions: none
Some /vis commands (optionally) take a string to specify colour.
"/vis/list" to see available colours.
/run/verbose 2
#
/run/beamOn 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
Production cuts : gamma 1 mm e- 1 mm e+ 1 mm proton 1 mm
Region <DefaultRegionForParallelWorld> -- -- is not associated to any world.
Root logical volume(s) :
Pointers : G4VUserRegionInformation[0], G4UserLimits[0], G4FastSimulationManager[0], G4UserSteppingAction[0]
Materials :
Production cuts : gamma 1 mm e- 1 mm e+ 1 mm proton 1 mm
========= Table of registered couples ============================
Index : 0 used in the geometry : Yes
Material : G4_AIR
Range cuts : gamma 1 mm e- 1 mm e+ 1 mm proton 1 mm
Energy thresholds : gamma -1 MeV e- -1 MeV e+ -1 MeV proton -1 MeV
Region(s) which use this couple :
DefaultRegionForTheWorld
==================================================================
Start closing geometry.
--------------------------------------------------------------------------------
G4GeometryManager::ReportVoxelStats -- Voxel Statistics
Total memory consumed for geometry optimisation: 0 kByte
Total CPU time elapsed for geometry optimisation: 0 seconds
--------------------------------------------------------------------------------
### Run 0 starts.
Run terminated.
Run Summary
Number of events processed : 10
User=0.000000s Real=0.000177s Sys=0.000000s
Graphics systems deleted.
Visualization Manager deleting...
G4 kernel has come to Quit state.
Deleting G4Run (id:0)
UserDetectorConstruction deleted 0x1e38090
UserPhysicsList deleted 0x2098e70
UserActionInitialization deleted 0
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: 6
G4RNGHelper object is deleted.
================== Deleting memory pools ===================
Pool ID '20G4NavigationLevelRep', size : 0.00769 MB
Pool ID '24G4ReferenceCountedHandleIvE', size : 0.000961 MB
Pool ID '7G4Event', size : 0.000961 MB
Pool ID '15G4PrimaryVertex', size : 0.000961 MB
Pool ID '17G4PrimaryParticle', size : 0.000961 MB
Pool ID '17G4DynamicParticle', size : 0.000961 MB
Pool ID '7G4Track', size : 0.000961 MB
Pool ID '18G4TouchableHistory', size : 0.000961 MB
Pool ID '15G4CountedObjectIvE', size : 0.000961 MB
Number of memory pools allocated: 9 of which, static: 0
Dynamic pools deleted: 9 / Total memory freed: 0.015 MB
============================================================
G4Allocator objects are deleted.
UImanager deleted.
StateManager deleted.
RunManagerKernel is deleted. Good bye :)
RunManager is deleted.
@@ -0,0 +1,90 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file exCommon.cc
/// \brief Main program of the common/exCommon example
#include "DetectorConstruction.hh"
#include "GeantinoPhysicsList.hh"
#include "GpsPrimaryGeneratorAction.hh"
#include "G4RunManager.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
using namespace Common;
int main(int argc, char** argv)
{
// Detect interactive mode (if no arguments) and define UI session
//
G4UIExecutive* ui = nullptr;
if (argc == 1) {
ui = new G4UIExecutive(argc, argv);
}
// Construct the default run manager
G4RunManager* runManager = new G4RunManager;
// Set mandatory initialization classes
runManager->SetUserInitialization(new DetectorConstruction);
runManager->SetUserInitialization(new GeantinoPhysicsList);
// Set mandatory user action class
runManager->SetUserAction(new GpsPrimaryGeneratorAction);
// Initialize visualization
//
G4VisManager* visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
// G4VisManager* visManager = new G4VisExecutive("Quiet");
visManager->Initialize();
// Get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();
// Process macro or start UI session
//
if (!ui) {
// batch mode
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command + fileName);
}
else {
// interactive mode
UImanager->ApplyCommand("/control/execute init_vis.mac");
ui->SessionStart();
delete ui;
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not be deleted
// in the main() program !
delete visManager;
delete runManager;
}
@@ -0,0 +1,81 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file exCommonNoVis.cc
/// \brief Main program of the common/exCommon example
#include "DetectorConstruction.hh"
#include "GeantinoPhysicsList.hh"
#include "GpsPrimaryGeneratorAction.hh"
#include "G4RunManager.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
using namespace Common;
int main(int argc, char** argv)
{
// Detect interactive mode (if no arguments) and define UI session
//
G4UIExecutive* ui = nullptr;
if (argc == 1) {
ui = new G4UIExecutive(argc, argv);
}
// Construct the default run manager
G4RunManager* runManager = new G4RunManager;
// Set mandatory initialization classes
runManager->SetUserInitialization(new DetectorConstruction);
runManager->SetUserInitialization(new GeantinoPhysicsList);
// Set mandatory user action class
runManager->SetUserAction(new GpsPrimaryGeneratorAction);
// Get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();
// Process macro or start UI session
//
if (!ui) {
// batch mode
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command + fileName);
}
else {
// interactive mode
UImanager->ApplyCommand("/control/execute init.mac");
ui->SessionStart();
delete ui;
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not be deleted
// in the main() program !
delete runManager;
}
@@ -0,0 +1,82 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file DetectorConstruction.hh
/// \brief Definition of the Common::DetectorConstruction class
#ifndef DetectorConstruction_h
#define DetectorConstruction_h 1
#include "CLHEP/Units/SystemOfUnits.h"
#include "G4ThreeVector.hh"
#include "G4VUserDetectorConstruction.hh"
class G4LogicalVolume;
class G4Material;
class G4GenericMessenger;
namespace Common
{
/// Simple detector construction with a box volume placed in a world
class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
DetectorConstruction(const G4String& boxMaterialName = "G4_AIR",
G4double boxHx = 40 * CLHEP::cm, G4double boxHy = 40 * CLHEP::cm,
G4double boxHz = 40 * CLHEP::cm,
const G4String& worldMaterialName = "G4_AIR",
G4double worldSizeFactor = 1.25);
~DetectorConstruction() override;
public:
// methods from base class
G4VPhysicalVolume* Construct() override;
// set methods
void SetBoxMaterial(const G4String& materialName);
void SetWorldMaterial(const G4String& materialName);
void SetBoxDimensions(G4ThreeVector dimensions);
void SetWorldSizeFactor(G4double factor);
private:
void DefineCommands();
G4GenericMessenger* fMessenger = nullptr;
G4String fBoxMaterialName;
G4String fWorldMaterialName;
G4ThreeVector fBoxDimensions;
G4double fWorldSizeFactor = 0.;
G4LogicalVolume* fBoxVolume = nullptr;
G4LogicalVolume* fWorldVolume = nullptr;
};
} // namespace Common
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -0,0 +1,74 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file DetectorConstruction0.hh
/// \brief Definition of the Common::DetectorConstruction0 class
#ifndef DetectorConstruction0_h
#define DetectorConstruction0_h 1
#include "CLHEP/Units/SystemOfUnits.h"
#include "G4ThreeVector.hh"
#include "G4VUserDetectorConstruction.hh"
class G4LogicalVolume;
class G4Material;
class G4GenericMessenger;
namespace Common
{
/// Simple detector construction with only a world volume
class DetectorConstruction0 : public G4VUserDetectorConstruction
{
public:
DetectorConstruction0(const G4String& materialName = "G4_AIR", G4double hx = 50 * CLHEP::cm,
G4double hy = 50 * CLHEP::cm, G4double hz = 50 * CLHEP::cm);
~DetectorConstruction0() override;
public:
// methods from base class
G4VPhysicalVolume* Construct() override;
// set methods
void SetMaterial(const G4String& materialName);
void SetDimensions(G4ThreeVector dimensions);
private:
void DefineCommands();
G4GenericMessenger* fMessenger = nullptr;
G4String fMaterialName;
G4ThreeVector fDimensions;
G4LogicalVolume* fWorldVolume = nullptr;
};
} // namespace Common
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -0,0 +1,53 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file GeantinoPhysicsList.hh
/// \brief Definition of the Common::GeantinoPhysicsList class
#ifndef GeantinoPhysicsList_h
#define GeantinoPhysicsList_h 1
#include "G4VUserPhysicsList.hh"
namespace Common
{
/// Physics list with geantino and charged geantino only
class GeantinoPhysicsList : public G4VUserPhysicsList
{
public:
GeantinoPhysicsList();
~GeantinoPhysicsList() override;
protected:
// Construct particle and physics process
void ConstructParticle() override;
void ConstructProcess() override;
};
} // namespace Common
#endif
@@ -0,0 +1,61 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file GpsPrimaryGeneratorAction.hh
/// \brief Definition of the Common::GpsPrimaryGeneratorAction class
#ifndef GpsPrimaryGeneratorAction_h
#define GpsPrimaryGeneratorAction_h 1
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
class G4GeneralParticleSource;
class G4Event;
namespace Common
{
/// The primary generator class with general particle source
///
/// \author I. Hrivnacova; IPN Orsay
class GpsPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
GpsPrimaryGeneratorAction();
~GpsPrimaryGeneratorAction() override;
// methods
void GeneratePrimaries(G4Event*) override;
private:
// data members
G4GeneralParticleSource* fGeneralParticleSource = nullptr;
};
} // namespace Common
#endif
@@ -0,0 +1,67 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file GunPrimaryGeneratorAction.hh
/// \brief Definition of the Common::GunPrimaryGeneratorAction class
#ifndef GunPrimaryGeneratorAction_h
#define GunPrimaryGeneratorAction_h 1
#include "CLHEP/Units/SystemOfUnits.h"
#include "G4ThreeVector.hh"
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
class G4ParticleGun;
class G4Event;
namespace Common
{
/// The primary generator class with particle gun
///
/// \author I. Hrivnacova; IPN Orsay
class GunPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
GunPrimaryGeneratorAction(const G4String& particleName = "geantino",
G4double energy = 1. * CLHEP::MeV,
G4ThreeVector position = G4ThreeVector(0, 0, 0),
G4ThreeVector momentumDirection = G4ThreeVector(0, 0, 1));
~GunPrimaryGeneratorAction() override;
// methods
void GeneratePrimaries(G4Event*) override;
private:
// data members
G4ParticleGun* fParticleGun = nullptr;
};
} // namespace Common
#endif
@@ -0,0 +1,13 @@
# Macro file for the initialization of example B1
# in interactive session
#
# Set some default verbose
/control/verbose 2
/control/saveHistory
/run/verbose 2
#
# Change the default number of threads (in multi-threaded mode)
#/run/numberOfThreads 4
#
# Initialize kernel
/run/initialize
@@ -0,0 +1,16 @@
# Macro file for the initialization of example B1
# in interactive session
#
# Set some default verbose
/control/verbose 2
/control/saveHistory
/run/verbose 2
#
# Change the default number of threads (in multi-threaded mode)
#/run/numberOfThreads 4
#
# Initialize kernel
/run/initialize
#
# Visualization setting
/control/execute vis.mac
+12
View File
@@ -0,0 +1,12 @@
# Macro file for example common
#
# To be run preferably in batch
# % ./exampleCommon[NoVis] run.mac
#
#/run/numberOfThreads 4
/run/initialize
#
/control/verbose 2
/run/verbose 2
#
/run/beamOn 10
@@ -0,0 +1,209 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file DetectorConstruction.cc
/// \brief Implementation of the Common::DetectorConstruction class
#include "DetectorConstruction.hh"
#include "G4Box.hh"
#include "G4GenericMessenger.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
namespace Common
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction(const G4String& boxMaterialName, G4double boxHx,
G4double boxHy, G4double boxHz,
const G4String& worldMaterialName,
G4double worldSizeFactor)
: fBoxMaterialName(boxMaterialName),
fWorldMaterialName(worldMaterialName),
fBoxDimensions(boxHx * 2, boxHy * 2, boxHz * 2),
fWorldSizeFactor(worldSizeFactor)
{
DefineCommands();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::Construct()
{
// Define materials via NIST manager
//
auto nistManager = G4NistManager::Instance();
auto worldMaterial = nistManager->FindOrBuildMaterial(fWorldMaterialName);
auto boxMaterial = nistManager->FindOrBuildMaterial(fBoxMaterialName);
// Geometry parameters
//
G4ThreeVector worldDimensions = fBoxDimensions * fWorldSizeFactor;
// World
//
auto sWorld = new G4Box("World", // name
worldDimensions.x(), // dimensions (half-lentghs)
worldDimensions.y(), worldDimensions.z());
fWorldVolume = new G4LogicalVolume(sWorld, // shape
worldMaterial, // material
"World"); // name
auto pWorld = new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
fWorldVolume, // logical volume
"World", // name
0, // mother volume
false, // no boolean operation
0); // copy number
// Box
//
auto sBox = new G4Box("Box", // its name
fBoxDimensions.x(), // dimensions (half-lengths)
fBoxDimensions.y(), fBoxDimensions.z());
fBoxVolume = new G4LogicalVolume(sBox, // its shape
boxMaterial, // its material
"Box"); // its name
new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
fBoxVolume, // its logical volume
"Box", // its name
fWorldVolume, // its mother volume
false, // no boolean operation
0); // copy number
// always return the root volume
//
return pWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetBoxMaterial(const G4String& materialName)
{
auto nistManager = G4NistManager::Instance();
auto newMaterial = nistManager->FindOrBuildMaterial(materialName);
if (!newMaterial) {
G4cerr << "Material " << materialName << " not found." << G4endl;
G4cerr << "The box material was not changed." << G4endl;
return;
}
if (fBoxVolume) fBoxVolume->SetMaterial(newMaterial);
G4cout << "Material of box changed to " << materialName << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetWorldMaterial(const G4String& materialName)
{
auto nistManager = G4NistManager::Instance();
auto newMaterial = nistManager->FindOrBuildMaterial(materialName);
if (!newMaterial) {
G4cerr << "Material " << materialName << " not found." << G4endl;
G4cerr << "The box material was not changed." << G4endl;
return;
}
if (fWorldVolume) fWorldVolume->SetMaterial(newMaterial);
G4cout << "Material of box changed to " << materialName << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetBoxDimensions(G4ThreeVector dimensions)
{
/// Set box dimension (in half lengths).
/// This setting has effect only if called in PreInit> phase
fBoxDimensions = dimensions;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetWorldSizeFactor(G4double factor)
{
/// Set the multiplication factor from box dimensions to world dimensions.
/// This setting has effect only if called in PreInit> phase
fWorldSizeFactor = factor;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::DefineCommands()
{
// Define /B5/detector command directory using generic messenger class
fMessenger = new G4GenericMessenger(this, "/detector/", "Detector control");
// setBoxMaterial command
auto& setBoxMaterialCmd = fMessenger->DeclareMethod(
"setBoxMaterial", &DetectorConstruction::SetBoxMaterial, "Set box material name.");
setBoxMaterialCmd.SetParameterName("boxMaterialName", false);
setBoxMaterialCmd.SetDefaultValue("G4_AIR");
// setWorldMaterial command
auto& setWorldMaterialCmd = fMessenger->DeclareMethod(
"setWorldMaterial", &DetectorConstruction::SetWorldMaterial, "Set world material name.");
setWorldMaterialCmd.SetParameterName("worldMaterialName", false);
setWorldMaterialCmd.SetDefaultValue("G4_AIR");
// setBoxDimensions command
auto& setBoxDimensionsCmd = fMessenger->DeclareMethodWithUnit(
"setBoxDimensions", "mm", &DetectorConstruction::SetBoxDimensions,
"Set box dimensions (in half lentgh).");
setBoxDimensionsCmd.SetParameterName("boxDimensions", false);
setBoxDimensionsCmd.SetStates(G4State_PreInit);
// setWorldSizeFactor command
auto& setWorldSizeFactorCmd = fMessenger->DeclareMethod(
"setWorldSizeFactor", &DetectorConstruction::SetWorldSizeFactor,
"Set the multiplication factor from box dimensions to world dimensions.");
setWorldSizeFactorCmd.SetParameterName("worldSizeFactor", false);
setWorldSizeFactorCmd.SetRange("WorldSizeFactor >= 1");
setWorldSizeFactorCmd.SetStates(G4State_PreInit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
} // namespace Common
@@ -0,0 +1,141 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file DetectorConstruction0.cc
/// \brief Implementation of the Common::DetectorConstruction0 class
#include "DetectorConstruction0.hh"
#include "G4Box.hh"
#include "G4GenericMessenger.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
namespace Common
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction0::DetectorConstruction0(const G4String& materialName, G4double hx, G4double hy,
G4double hz)
: fMaterialName(materialName), fDimensions(hx, hy, hz)
{
DefineCommands();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction0::~DetectorConstruction0()
{
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction0::Construct()
{
// Define materials via NIST manager
//
auto nistManager = G4NistManager::Instance();
auto material = nistManager->FindOrBuildMaterial(fMaterialName);
// World
//
auto sWorld = new G4Box("World", // name
fDimensions.x(), // dimensions (half-lentghs)
fDimensions.y(), fDimensions.z());
fWorldVolume = new G4LogicalVolume(sWorld, // shape
material, // material
"World"); // name
auto pWorld = new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
fWorldVolume, // logical volume
"World", // name
0, // mother volume
false, // no boolean operation
0); // copy number
// always return the root volume
//
return pWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction0::SetMaterial(const G4String& materialName)
{
auto nistManager = G4NistManager::Instance();
auto newMaterial = nistManager->FindOrBuildMaterial(materialName);
if (!newMaterial) {
G4cerr << "Material " << materialName << " not found." << G4endl;
G4cerr << "The box material was not changed." << G4endl;
return;
}
if (fWorldVolume) fWorldVolume->SetMaterial(newMaterial);
G4cout << "Material of box changed to " << materialName << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction0::SetDimensions(G4ThreeVector dimensions)
{
/// Set world dimension (in half lengths).
/// This setting has effect only if called in PreInit> phase
fDimensions = dimensions;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction0::DefineCommands()
{
// Define /B5/detector command directory using generic messenger class
fMessenger = new G4GenericMessenger(this, "/detector/", "Detector control");
// setMaterial command
auto& setMaterialCmd = fMessenger->DeclareMethod(
"setMaterial", &DetectorConstruction0::SetMaterial, "Set world material name.");
setMaterialCmd.SetParameterName("materialName", false);
setMaterialCmd.SetDefaultValue("G4_AIR");
setMaterialCmd.SetStates(G4State_PreInit);
// setDimensions command
auto& setDimensionsCmd =
fMessenger->DeclareMethodWithUnit("setDimensions", "mm", &DetectorConstruction0::SetDimensions,
"Set world dimensions (in half lentgh).");
setDimensionsCmd.SetParameterName("dimensions", false);
setDimensionsCmd.SetStates(G4State_PreInit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
} // namespace Common
@@ -0,0 +1,69 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file GeantinoPhysicsList.cc
/// \brief Implementation of the Common::GeantinoPhysicsList class
#include "GeantinoPhysicsList.hh"
#include "G4ChargedGeantino.hh"
#include "G4Geantino.hh"
namespace Common
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GeantinoPhysicsList::GeantinoPhysicsList() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GeantinoPhysicsList::~GeantinoPhysicsList() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GeantinoPhysicsList::ConstructParticle()
{
// In this method, static member functions should be called
// for all particles which you want to use.
// This ensures that objects of these particle types will be
// created in the program.
G4Geantino::GeantinoDefinition();
G4ChargedGeantino::ChargedGeantinoDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GeantinoPhysicsList::ConstructProcess()
{
// Define transportation process
AddTransportation();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
} // namespace Common
@@ -0,0 +1,63 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file GpsPrimaryGeneratorAction.cc
/// \brief Implementation of the Common::GpsPrimaryGeneratorAction class
#include "GpsPrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4GeneralParticleSource.hh"
#include "G4SystemOfUnits.hh"
namespace Common
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GpsPrimaryGeneratorAction::GpsPrimaryGeneratorAction()
{
fGeneralParticleSource = new G4GeneralParticleSource();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GpsPrimaryGeneratorAction::~GpsPrimaryGeneratorAction()
{
delete fGeneralParticleSource;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GpsPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
// this function is called at the begining of event
fGeneralParticleSource->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
} // namespace Common
@@ -0,0 +1,75 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file GunPrimaryGeneratorAction.cc
/// \brief Implementation of the Common::GunPrimaryGeneratorAction class
#include "GunPrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
namespace Common
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GunPrimaryGeneratorAction::GunPrimaryGeneratorAction(const G4String& particleName, G4double energy,
G4ThreeVector position,
G4ThreeVector momentumDirection)
{
G4int nofParticles = 1;
fParticleGun = new G4ParticleGun(nofParticles);
// default particle kinematic
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4ParticleDefinition* particle = particleTable->FindParticle(particleName);
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleEnergy(energy);
fParticleGun->SetParticlePosition(position);
fParticleGun->SetParticleMomentumDirection(momentumDirection);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GunPrimaryGeneratorAction::~GunPrimaryGeneratorAction()
{
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GunPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
// this function is called at the begining of event
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
} // namespace Common
@@ -0,0 +1,72 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file testCommon.cc
/// \brief Main program of the common/exCommon example
#include "DetectorConstruction.hh"
#include "DetectorConstruction0.hh"
#include "FTFP_BERT.hh"
#include "GeantinoPhysicsList.hh"
#include "GpsPrimaryGeneratorAction.hh"
#include "GunPrimaryGeneratorAction.hh"
#include "G4RunManager.hh"
using namespace Common;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Test program which only instantiates classes defined in
// examples/common
int main()
{
// First construct necessary classes
//
auto runManager = new G4RunManager;
auto physicsList = new FTFP_BERT;
runManager->SetUserInitialization(physicsList);
// Instantiate all detector construction classes
auto detectorConstruction = new DetectorConstruction;
auto detectorConstruction0 = new DetectorConstruction0;
// Instantiate all physics list classes
auto geantinoPhysicsList = new GeantinoPhysicsList();
// Instantiate all primary generator actions classes
auto gpsPrimaryGeneratorAction = new GpsPrimaryGeneratorAction();
auto gunPrimaryGeneratorAction = new GunPrimaryGeneratorAction();
// delete all
delete detectorConstruction;
delete detectorConstruction0;
delete geantinoPhysicsList;
delete gpsPrimaryGeneratorAction;
delete gunPrimaryGeneratorAction;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+106
View File
@@ -0,0 +1,106 @@
# Macro file for the visualization setting in the initialization phase
# of the B1 example when running in interactive mode
#
# Open a viewer
/vis/open
# This opens the default viewer - see examples/basic/B1/vis.mac for a
# more comprehensive overview of options. Also the documentation.
#
# Use this open statement to create an offscreen file with TSG:
#/vis/open TSG_OFFSCREEN 1200x1200
# See the tsg_offscreen.mac file for more commands to change
# the file format, file name, picture size, etc.
#
# Disable auto refresh and quieten vis messages whilst scene and
# trajectories are established:
/vis/viewer/set/autoRefresh false
/vis/verbose errors
#
# Draw geometry:
/vis/drawVolume
#
# Specify view angle:
/vis/viewer/set/viewpointVector -1 0 0
/vis/viewer/set/lightsVector -1 0 0
#
# Specify style (surface, wireframe, auxiliary edges,...)
/vis/viewer/set/style wireframe
/vis/viewer/set/auxiliaryEdge true
/vis/viewer/set/lineSegmentsPerCircle 100
#
# Draw smooth trajectories at end of event, showing trajectory points
# as markers 2 pixels wide:
/vis/scene/add/trajectories smooth
/vis/modeling/trajectories/create/drawByCharge
/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true
/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2
# (if too many tracks cause core dump => /tracking/storeTrajectory 0)
#
# Draw hits at end of event:
#/vis/scene/add/hits
#
# To draw only gammas:
#/vis/filtering/trajectories/create/particleFilter
#/vis/filtering/trajectories/particleFilter-0/add gamma
#
# To invert the above, drawing all particles except gammas,
# keep the above two lines but also add:
#/vis/filtering/trajectories/particleFilter-0/invert true
#
# Many other options are available with /vis/modeling and /vis/filtering.
# For example, to select colour by particle ID:
#/vis/modeling/trajectories/create/drawByParticleID
#/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true
# To select or override default colours (note: e+ is blue by default):
#/vis/modeling/trajectories/list
#/vis/modeling/trajectories/drawByParticleID-0/set e+ yellow
#
# To superimpose all of the events from a given run:
/vis/scene/endOfEventAction accumulate
#
# Decorations
# Name
/vis/set/textColour green
/vis/set/textLayout right
/vis/scene/add/text2D 0.9 -.9 24 ! ! exampleB1
# or, if your system does not support right-adjustment
#/vis/scene/add/text2D 0 -.9 24 ! ! exampleB1
/vis/set/textLayout # Revert to normal (left adjusted) layout
/vis/set/textColour # Revert to default text colour (blue)
#
# Axes, scale, etc.
/vis/scene/add/scale # Simple scale line
/vis/scene/add/axes # Simple axes: x=red, y=green, z=blue.
/vis/scene/add/eventID # Drawn at end of event
/vis/scene/add/date # Date stamp
/vis/scene/add/logo2D # Simple logo
/vis/scene/add/logo # 3D logo
#
# Frame
/vis/set/colour red
/vis/set/lineWidth 2
/vis/scene/add/frame # Simple frame around the view
/vis/set/colour # Revert to default colour (white)
/vis/set/lineWidth # Revert to default line width (1.)
#
# Attach text to one edge of Shape1, with a small, fixed offset
/vis/scene/add/text 0 6 -4 cm 18 4 4 Shape1
# Attach text to one corner of Shape2, with a small, fixed offset
/vis/scene/add/text 6 7 10 cm 18 4 4 Shape2
#
# To get nice view
# Make the "World" box invisible
/vis/geometry/set/visibility World 0 false
# "Envelope" is transparent blue to represent water
#/vis/geometry/set/colour Envelope 0 0 0 1 .3
/vis/viewer/set/style surface
/vis/viewer/set/hiddenMarker true
/vis/viewer/set/viewpointThetaPhi 120 150
#
# Re-establish auto refreshing and verbosity:
/vis/viewer/set/autoRefresh true
/vis/verbose warnings
#
# For file-based drivers, use this to create an empty detector view:
#/vis/viewer/flush