Import Geant4 11.1.0.beta source tree
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
|
||||
///\file "ParticleFluence/.README.txt"
|
||||
///\brief ParticleFluence set-ups
|
||||
|
||||
/*! \page Set-ups-ParticleFluence Category "ParticleFluence"
|
||||
|
||||
Examples in this directory demonstrate specific set-ups in
|
||||
which to evaluate particle fluence.
|
||||
|
||||
\link ExampleSphere Sphere \endlink
|
||||
This set-up consists of a full solid target sphere - whose radius and
|
||||
material can be set via UI commands.
|
||||
The primary particle is shot from the center of the target sphere
|
||||
(along the z-axis direction by default).
|
||||
As scoring volume, we use a thin spherical shell outside the target sphere.
|
||||
The particle fluences are evaluated in the forward and backward hemispheres
|
||||
(with respect to the primary particle direction).
|
||||
|
||||
\link ExampleConcentricSpheres ConcentricSpheres \endlink
|
||||
Similar to the Sphere one, but with two larger solid target spherical shells
|
||||
outside the first one, separated by some space filled up by G4_Galactic.
|
||||
The dimensions of these three targets - which are meant as a simplified
|
||||
proxy for, respectively, a Tracker (inner sphere), EM (electromagnetic)
|
||||
calorimeter (middle spherical shell), and HAD (hadronic) calorimeter
|
||||
(external spherical shell) - and their materials can be set via UI commands.
|
||||
As scoring volumes, we use three thin spherical shells immediately outside
|
||||
the inner target sphere and the two target spherical shells.
|
||||
The particle fluences are evaluated in the forward and backward hemispheres
|
||||
(with respect to the primary particle direction).
|
||||
|
||||
\link ExampleLayer Layer \endlink
|
||||
This set-up consists of a cylinder, with axis along the z-direction, whose
|
||||
radius, length (i.e. thickness) and material can be set via UI commands.
|
||||
The primary particle is shot by default along the z-axis, from behind
|
||||
the target.
|
||||
As scoring volumes, we use three thin cylindrical layers, filled up by
|
||||
G4_Galactic, and placed downstream, upstream, and aside of the target
|
||||
cylinder.
|
||||
|
||||
\link ExampleLayer Calo \endlink
|
||||
Similar to the Layer one, the target consists of a simplified cylindrical
|
||||
hadronic calorimeter, whose properties - size, number of layers, sampling
|
||||
fraction, active and absorber materials - can be set via UI commands.
|
||||
Similarly to the Layer case, the the particle fluences are evaluated in the
|
||||
downstream, upstream and aside positions.
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.16...3.21)
|
||||
|
||||
add_subdirectory(Sphere)
|
||||
add_subdirectory(ConcentricSpheres)
|
||||
add_subdirectory(Layer)
|
||||
add_subdirectory(Calo)
|
||||
@@ -0,0 +1,64 @@
|
||||
///\file "hadronic/ParticleFluence/Calo/.README.txt"
|
||||
///\brief Example ParticleFluence/Calo README page
|
||||
|
||||
/*! \page ExampeParticleFluenceCalo Example Calo
|
||||
|
||||
In this example, the particle fluence is evaluated for simplified,
|
||||
cylindrical hadronic calorimeters with axis along the z-direction,
|
||||
and a beam particle shot before the calorimeter along its axis.
|
||||
|
||||
The particle fluence is computed in three places: "upstream", "downstream"
|
||||
and "side", defined as the positions immediately after, before and aside,
|
||||
respectively, of the calorimeter with respect to the direction of the
|
||||
primary particle.
|
||||
|
||||
The particle fluence is estimated by summing the track length in a
|
||||
"scoring volume" - i.e. a thin cylinder (for "upstream" and "downstream"
|
||||
cases) or a thin hemisphere shell (for the "side" case) filled up with
|
||||
G4_Galactic (very low density gas) material, immediately outside the
|
||||
calorimeter - and then dividing for the cubic volume of such scoring volume.
|
||||
|
||||
The particle fluence is evaluated for the following 11 particle types:
|
||||
- all
|
||||
- electron + positron
|
||||
- gamma
|
||||
- muon- + muon+
|
||||
- neutrino (any flavour and including anti-neutrino)
|
||||
- charged pions
|
||||
- neutron + anti_neutron
|
||||
- proton + anti_proton
|
||||
- ion (and anti-ions)
|
||||
- otherMeson (e.g. kaons, etc.)
|
||||
- otherBaryon (e.g. hyperons, etc.)
|
||||
|
||||
The particle fluence is evaluated for the following 3 kinematical ranges:
|
||||
- any kinetic energy
|
||||
- kinetic energy < 20 MeV
|
||||
- kinetic energy > 20 MeV
|
||||
|
||||
Look for the string "***LOOKHERE***" for those parameters/options that
|
||||
are either hardwired in the code (i.e. not available via UI command),
|
||||
or default values of UI commands.
|
||||
|
||||
This example uses the physics list factory, therefore you can specify
|
||||
the reference physics list you want to use via the PHYSLIST
|
||||
environmental variable (by default, if you don't set it, the FTFP_BERT
|
||||
physics list is used).
|
||||
|
||||
To build this example:
|
||||
|
||||
mkdir Build; cd Build
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DGeant4_DIR=/path-to-geant4-libraries ../.
|
||||
make
|
||||
|
||||
To run it:
|
||||
|
||||
./Calo atlasHec.g4
|
||||
|
||||
which shoots 50 GeV pion- on a simplified ATLAS HEC hadronic calorimeter,
|
||||
in one run of 100 events, and print out some information on the particle
|
||||
fluence at the end of the run.
|
||||
Other macros exist for other types of simplified hadronic calorimeters.
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,61 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# Setup the project
|
||||
cmake_minimum_required(VERSION 3.16...3.21)
|
||||
project(Calo)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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 executable, and link it to the Geant4 libraries
|
||||
#
|
||||
add_executable(Calo Calo.cc ${sources} ${headers})
|
||||
target_link_libraries(Calo ${Geant4_LIBRARIES} )
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Copy all scripts to the build directory, so that we can run the executable
|
||||
# directly there.
|
||||
#
|
||||
set(SCRIPTS
|
||||
atlasEcal.g4
|
||||
atlasFcal.g4
|
||||
atlasHec.g4
|
||||
atlasTileCal.g4
|
||||
cmsEcal.g4
|
||||
lhcbEcal.g4
|
||||
)
|
||||
|
||||
foreach(_script ${SCRIPTS})
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/${_script}
|
||||
${PROJECT_BINARY_DIR}/${_script}
|
||||
COPYONLY
|
||||
)
|
||||
endforeach()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
|
||||
#
|
||||
install(TARGETS Calo DESTINATION bin)
|
||||
+72
@@ -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 Layer.cc
|
||||
/// \brief Main program of the hadronic/ParticleFluence/Layer example
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4Threading.hh"
|
||||
#include "G4RunManagerFactory.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4PhysListFactory.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
int main(int argc,char** argv) {
|
||||
|
||||
auto* runManager = G4RunManagerFactory::CreateRunManager();
|
||||
|
||||
DetectorConstruction* pDetectorInstance = new DetectorConstruction;
|
||||
runManager->SetUserInitialization( pDetectorInstance );
|
||||
|
||||
// Physics list factory: use the PHYSLIST environmental variable.
|
||||
G4PhysListFactory factory;
|
||||
G4VModularPhysicsList* thePL = factory.ReferencePhysList();
|
||||
|
||||
runManager->SetUserInitialization( thePL );
|
||||
runManager->SetUserInitialization( new ActionInitialization( pDetectorInstance ) );
|
||||
|
||||
runManager->Initialize();
|
||||
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if ( argc==1 ) { // Define UI session for interactive mode.
|
||||
} else { // Batch mode
|
||||
G4String command = "/control/execute ";
|
||||
G4String fileName = argv[1];
|
||||
UI->ApplyCommand(command+fileName);
|
||||
}
|
||||
|
||||
// job termination
|
||||
delete runManager;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,11 @@
|
||||
name := Calo
|
||||
G4TARGET := $(name)
|
||||
G4EXLIB := true
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
.PHONY: all
|
||||
|
||||
all: lib bin
|
||||
|
||||
include $(G4INSTALL)/config/binmake.gmk
|
||||
@@ -0,0 +1,10 @@
|
||||
# Example ParticleFluence 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!
|
||||
|
||||
|
||||
## 2021-06-10 Alberto Ribon (exhadrParticleFluenceCalo-V11-00-00)
|
||||
- Created the Calo variant of the ParticleFluence example.
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
In this example, the particle fluence is evaluated for simplified,
|
||||
cylindrical hadronic calorimeters with axis along the z-direction,
|
||||
and a beam particle shot before the calorimeter along its axis.
|
||||
|
||||
The particle fluence is computed in three places: "upstream", "downstream"
|
||||
and "side", defined as the positions immediately after, before and aside,
|
||||
respectively, of the calorimeter with respect to the direction of the
|
||||
primary particle.
|
||||
|
||||
The particle fluence is estimated by summing the track length in a
|
||||
"scoring volume" - i.e. a thin cylinder (for "upstream" and "downstream"
|
||||
cases) or a thin hemisphere shell (for the "side" case) filled up with
|
||||
G4_Galactic (very low density gas) material, immediately outside the
|
||||
calorimeter - and then dividing for the cubic volume of such scoring volume.
|
||||
|
||||
The particle fluence is evaluated for the following 11 particle types:
|
||||
- all
|
||||
- electron + positron
|
||||
- gamma
|
||||
- muon- + muon+
|
||||
- neutrino (any flavour and including anti-neutrino)
|
||||
- charged pions
|
||||
- neutron + anti_neutron
|
||||
- proton + anti_proton
|
||||
- ion (and anti-ions)
|
||||
- otherMeson (e.g. kaons, etc.)
|
||||
- otherBaryon (e.g. hyperons, etc.)
|
||||
|
||||
The particle fluence is evaluated for the following 3 kinematical ranges:
|
||||
- any kinetic energy
|
||||
- kinetic energy < 20 MeV
|
||||
- kinetic energy > 20 MeV
|
||||
|
||||
Look for the string "***LOOKHERE***" for those parameters/options that
|
||||
are either hardwired in the code (i.e. not available via UI command),
|
||||
or default values of UI commands.
|
||||
|
||||
This example uses the physics list factory, therefore you can specify
|
||||
the reference physics list you want to use via the PHYSLIST
|
||||
environmental variable (by default, if you don't set it, the FTFP_BERT
|
||||
physics list is used).
|
||||
|
||||
To build this example:
|
||||
|
||||
mkdir Build; cd Build
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DGeant4_DIR=/path-to-geant4-libraries ../.
|
||||
make
|
||||
|
||||
To run it:
|
||||
|
||||
./Calo atlasHec.g4
|
||||
|
||||
which shoots 50 GeV pion- on a simplified ATLAS HEC hadronic calorimeter,
|
||||
in one run of 100 events, and print out some information on the particle
|
||||
fluence at the end of the run.
|
||||
Other macros exist for other types of simplified hadronic calorimeters.
|
||||
@@ -0,0 +1,17 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/mydet/absorberMaterial Lead
|
||||
/mydet/activeMaterial LiquidArgon
|
||||
/mydet/isCalHomogeneous 0
|
||||
/mydet/isUnitInLambda 1
|
||||
/mydet/absorberTotalLength 10
|
||||
/mydet/calorimeterRadius 5
|
||||
/mydet/activeLayerNumber 720
|
||||
/mydet/activeLayerSize 4.2
|
||||
/mydet/isRadiusUnitInLambda 1
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,17 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/mydet/absorberMaterial Tungsten
|
||||
/mydet/activeMaterial LiquidArgon
|
||||
/mydet/isCalHomogeneous 0
|
||||
/mydet/isUnitInLambda 1
|
||||
/mydet/absorberTotalLength 10
|
||||
/mydet/calorimeterRadius 5
|
||||
/mydet/activeLayerNumber 210
|
||||
/mydet/activeLayerSize 0.5
|
||||
/mydet/isRadiusUnitInLambda 1
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,17 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/mydet/absorberMaterial Copper
|
||||
/mydet/activeMaterial LiquidArgon
|
||||
/mydet/isCalHomogeneous 0
|
||||
/mydet/isUnitInLambda 1
|
||||
/mydet/absorberTotalLength 10
|
||||
/mydet/calorimeterRadius 5
|
||||
/mydet/activeLayerNumber 60
|
||||
/mydet/activeLayerSize 8.5
|
||||
/mydet/isRadiusUnitInLambda 1
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,17 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/mydet/absorberMaterial Iron
|
||||
/mydet/activeMaterial Scintillator
|
||||
/mydet/isCalHomogeneous 0
|
||||
/mydet/isUnitInLambda 1
|
||||
/mydet/absorberTotalLength 10.0
|
||||
/mydet/calorimeterRadius 5.0
|
||||
/mydet/activeLayerNumber 100
|
||||
/mydet/activeLayerSize 4.0
|
||||
/mydet/isRadiusUnitInLambda 1
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,16 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/mydet/absorberMaterial PbWO4
|
||||
/mydet/isCalHomogeneous 1
|
||||
/mydet/isUnitInLambda 1
|
||||
/mydet/absorberTotalLength 10
|
||||
/mydet/calorimeterRadius 5
|
||||
/mydet/activeLayerNumber 1
|
||||
/mydet/activeLayerSize 1e-06
|
||||
/mydet/isRadiusUnitInLambda 1
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 ActionInitialization.hh
|
||||
/// \brief Definition of the ActionInitialization class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ActionInitialization_h
|
||||
#define ActionInitialization_h 1
|
||||
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
|
||||
class DetectorConstruction;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ActionInitialization : public G4VUserActionInitialization {
|
||||
public:
|
||||
ActionInitialization( const DetectorConstruction* inputDetectorConstruction = nullptr );
|
||||
virtual ~ActionInitialization();
|
||||
virtual void BuildForMaster() const override;
|
||||
virtual void Build() const override;
|
||||
private:
|
||||
const DetectorConstruction* fPtrDetectorConstruction = nullptr;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorConstruction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef DetectorConstruction_H
|
||||
#define DetectorConstruction_H 1
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4LogicalVolume;
|
||||
class G4VPhysicalVolume;
|
||||
class G4FieldManager;
|
||||
class G4UniformMagField;
|
||||
class G4Material;
|
||||
class DetectorMessenger;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class DetectorConstruction : public G4VUserDetectorConstruction {
|
||||
public:
|
||||
DetectorConstruction();
|
||||
~DetectorConstruction();
|
||||
|
||||
G4VPhysicalVolume* Construct();
|
||||
void ConstructSDandField();
|
||||
|
||||
void SetMagField( const G4double fieldValue );
|
||||
void SetAbsorberMaterial( const G4String name );
|
||||
void SetActiveMaterial( const G4String name );
|
||||
// Use by the messenger.
|
||||
|
||||
inline G4Material* GetAbsorberMaterial() const;
|
||||
inline G4Material* GetActiveMaterial() const;
|
||||
|
||||
inline void SetIsCalHomogeneous( const G4bool choice );
|
||||
inline void SetIsUnitInLambda( const G4bool choice );
|
||||
inline void SetAbsorberTotalLength( const G4double value );
|
||||
inline void SetCalorimeterRadius( const G4double value );
|
||||
inline void SetActiveLayerNumber( const G4int value );
|
||||
inline void SetActiveLayerSize( const G4double value );
|
||||
// To define the calorimeter geometry.
|
||||
|
||||
inline void SetIsRadiusUnitInLambda( const G4bool choice );
|
||||
|
||||
void UpdateGeometry();
|
||||
|
||||
inline G4double GetCaloLength() const;
|
||||
|
||||
private:
|
||||
|
||||
void DefineMaterials();
|
||||
// Define all the materials.
|
||||
|
||||
G4VPhysicalVolume* ConstructCalorimeter();
|
||||
// To be invoked each time the geometry needs to be updated.
|
||||
|
||||
G4bool areParametersOK();
|
||||
// Return true if all the parameters are sensible, false otherwise.
|
||||
|
||||
void PrintParameters();
|
||||
// Print the various parameters which define the calorimeter.
|
||||
|
||||
G4Material* fVacuum;
|
||||
G4Material* fIron;
|
||||
G4Material* fCopper;
|
||||
G4Material* fTungsten;
|
||||
G4Material* fLead;
|
||||
G4Material* fUranium;
|
||||
G4Material* fPbWO4;
|
||||
G4Material* fPolystyrene;
|
||||
G4Material* fLiquidArgon;
|
||||
G4Material* fSilicon;
|
||||
G4Material* fQuartz;
|
||||
G4Material* fBrass;
|
||||
G4Material* fAluminium;
|
||||
G4Material* fGraphite;
|
||||
G4Material* fAbsorberMaterial;
|
||||
G4Material* fActiveMaterial;
|
||||
|
||||
G4LogicalVolume* fExperimentalHall_log;
|
||||
G4VPhysicalVolume* fExperimentalHall_phys;
|
||||
// World envelope.
|
||||
|
||||
G4LogicalVolume* fLogicCalo;
|
||||
G4VPhysicalVolume* fPhysiCalo;
|
||||
// "Calorimeter".
|
||||
|
||||
G4LogicalVolume* fLogicModule;
|
||||
G4VPhysicalVolume* fPhysiModule;
|
||||
// Module of the "calorimeter".
|
||||
|
||||
G4LogicalVolume* fLogicAbsorber;
|
||||
G4VPhysicalVolume* fPhysiAbsorber;
|
||||
// Absorber layer of the "calorimeter".
|
||||
|
||||
G4LogicalVolume* fLogicActive;
|
||||
G4VPhysicalVolume* fPhysiActive;
|
||||
// Active layer of the "calorimeter".
|
||||
|
||||
G4FieldManager* fFieldMgr;
|
||||
// Pointer to the field manager.
|
||||
|
||||
G4UniformMagField* fUniformMagField;
|
||||
// Pointer to the uniform magnetic field.
|
||||
|
||||
DetectorMessenger* fDetectorMessenger;
|
||||
// Pointer to the Messenger.
|
||||
|
||||
G4bool fIsCalHomogeneous;
|
||||
// If false then Sampling calorimeter;
|
||||
// If true then Homogeneous calorimeter.
|
||||
|
||||
G4bool fIsUnitInLambda;
|
||||
// If false then normal unit of length to express the absorber total length.
|
||||
// If true then lambda (interaction length) to express the absorber total length.
|
||||
|
||||
G4double fAbsorberTotalLength;
|
||||
// This is the total length of the absorber material, expressed
|
||||
// in unit of length (e.g. m, cm, mm) if theIsUnitInLambda is false,
|
||||
// otherwise in number of lambdas (interaction lengths).
|
||||
// Notice that in the case of a sampling calorimeter (i.e.
|
||||
// theIsCalHomogeneous is false), the active layers are not counted;
|
||||
// in the case of an homogenous calorimeter, this length account
|
||||
// for the overall dimension of the calorimeter.
|
||||
|
||||
G4double fCalorimeterRadius;
|
||||
// This is the radius of the calorimeter which is a cylinder, expressed
|
||||
// in unit of length (e.g. m, cm, mm) if theIsUnitInLambda is false,
|
||||
// otherwise in number of lambdas (interaction lengths) of the absorber.
|
||||
|
||||
G4int fActiveLayerNumber;
|
||||
G4double fActiveLayerSize;
|
||||
// Number of active layers and length of each of them (in normal unit
|
||||
// of length, e.g. mm): in the case of sampling calorimeter
|
||||
// (i.e. theIsCalHomogeneous is false) the medium is theActiveMaterial;
|
||||
// in the case of an homogeneous calorimeter, the "active layers" are
|
||||
// only a fictitious way to sample the longitudinal energy deposits,
|
||||
// but they are actually made of the same absorber material, and their
|
||||
// thickness is taken into account in theAbsorberTotalLength.
|
||||
|
||||
G4bool fIsRadiusUnitInLambda;
|
||||
// If false then normal unit of length to express the radius bin size.
|
||||
// If true then lambda (interaction length of the absorber) to express
|
||||
// the radius bin size.
|
||||
|
||||
G4double fCaloLength; // total length of the calorimeter along its (z) axis
|
||||
|
||||
// Scoring part
|
||||
G4LogicalVolume* fLogicScoringUpDown;
|
||||
G4VPhysicalVolume* fPhysiScoringUpstream;
|
||||
G4VPhysicalVolume* fPhysiScoringDownstream;
|
||||
G4LogicalVolume* fLogicScoringSide;
|
||||
G4VPhysicalVolume* fPhysiScoringSide;
|
||||
const G4double fScoringThickness = 10.0;
|
||||
};
|
||||
|
||||
inline G4Material* DetectorConstruction::GetAbsorberMaterial() const {
|
||||
return fAbsorberMaterial;
|
||||
}
|
||||
|
||||
inline G4Material* DetectorConstruction::GetActiveMaterial() const {
|
||||
return fActiveMaterial;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetIsCalHomogeneous( const G4bool choice ) {
|
||||
fIsCalHomogeneous = choice;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetIsUnitInLambda( const G4bool choice ) {
|
||||
fIsUnitInLambda = choice;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetAbsorberTotalLength( const G4double value ) {
|
||||
fAbsorberTotalLength = value;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetCalorimeterRadius( const G4double value ) {
|
||||
fCalorimeterRadius = value;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetActiveLayerNumber( const G4int value ) {
|
||||
fActiveLayerNumber = value;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetActiveLayerSize( const G4double value ) {
|
||||
fActiveLayerSize = value;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetIsRadiusUnitInLambda( const G4bool choice ) {
|
||||
fIsRadiusUnitInLambda = choice;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetCaloLength() const {
|
||||
return fCaloLength;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorMessenger.hh
|
||||
/// \brief Definition of the DetectorMessenger class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef DetectorMessenger_h
|
||||
#define DetectorMessenger_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class DetectorConstruction;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithADoubleAndUnit;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithADouble;
|
||||
|
||||
class G4UIcmdWithABool;
|
||||
class G4UIcmdWithAnInteger;
|
||||
class G4UIcmdWithoutParameter;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class DetectorMessenger: public G4UImessenger {
|
||||
public:
|
||||
DetectorMessenger( DetectorConstruction* );
|
||||
~DetectorMessenger();
|
||||
void SetNewValue( G4UIcommand*, G4String ) override;
|
||||
|
||||
private:
|
||||
DetectorConstruction* fDetector;
|
||||
G4UIdirectory* fDetectorDir;
|
||||
G4UIcmdWithADoubleAndUnit* fFieldCommand;
|
||||
G4UIcmdWithAString* fAbsorberMaterial;
|
||||
G4UIcmdWithAString* fActiveMaterial;
|
||||
G4UIcmdWithABool* fIsCalHomogeneous;
|
||||
G4UIcmdWithABool* fIsUnitInLambda;
|
||||
G4UIcmdWithADouble* fAbsorberTotalLength;
|
||||
G4UIcmdWithADouble* fCalorimeterRadius;
|
||||
G4UIcmdWithAnInteger* fActiveLayerNumber;
|
||||
G4UIcmdWithADouble* fActiveLayerSize;
|
||||
G4UIcmdWithABool* fIsRadiusUnitInLambda;
|
||||
G4UIcmdWithoutParameter* fUpdateCommand;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 PrimaryGeneratorAction.hh
|
||||
/// \brief Definition of the PrimaryGeneratorAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef PrimaryGeneratorAction_h
|
||||
#define PrimaryGeneratorAction_h 1
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class G4ParticleGun;
|
||||
class G4Event;
|
||||
class DetectorConstruction;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
|
||||
public:
|
||||
PrimaryGeneratorAction( const DetectorConstruction* );
|
||||
~PrimaryGeneratorAction();
|
||||
void GeneratePrimaries( G4Event* anEvent ) override;
|
||||
void SetGunPosition() const;
|
||||
private:
|
||||
G4ParticleGun* fParticleGun;
|
||||
const DetectorConstruction* fPointerDetectorConstruction = nullptr;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 Run.hh
|
||||
/// \brief Definition of the Run class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef Run_h
|
||||
#define Run_h 1
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include <array>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class Run : public G4Run {
|
||||
// This class accumulates relevant quantities related to particle fluence collected during
|
||||
// the run.
|
||||
// ( Note: these information are provided via calls of accessor methods of this Run class
|
||||
// made by SteppingAction::UserSteppingAction. )
|
||||
// At the end of a run, the printInfo method is called by the run-action to print out
|
||||
// some summary information about these quantities.
|
||||
// In multithreaded (MT) mode, an object of this class is filled up for each working thread,
|
||||
// and then merged (automatically by the Geant4 kernel) into another object (of this class)
|
||||
// owned by the master class; the printInfo method is then called only for the latter run
|
||||
// object.
|
||||
// Note that, for simplicity and brevity, we avoid histograms and print-out instead some
|
||||
// statistics (compute by ourself) at the end of the run.
|
||||
public:
|
||||
Run();
|
||||
~Run();
|
||||
|
||||
virtual void RecordEvent( const G4Event* anEvent ) override;
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) at the end
|
||||
// of each event. In the case of multithreaded mode, it is called only for the working thread
|
||||
// that handled that event.
|
||||
|
||||
virtual void Merge( const G4Run* aRun ) override;
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) only in the
|
||||
// case of multithreaded mode and only for working threads.
|
||||
|
||||
void printInfo() const;
|
||||
// This method is called by RunAction::EndOfRunAction : in the case of multithreaded mode,
|
||||
// only the master thread calls it.
|
||||
|
||||
void setPrimaryParticleId( const G4int inputValue ) { fPrimaryParticleId = inputValue; }
|
||||
void setPrimaryParticleEnergy( const G4double inputValue )
|
||||
{ fPrimaryParticleEnergy = inputValue; }
|
||||
void setPrimaryParticleDirection( const G4ThreeVector &inputValue )
|
||||
{ fPrimaryParticleDirection = inputValue; }
|
||||
void setAbsorberMaterialName( const G4String &inputValue )
|
||||
{ fAbsorberMaterialName = inputValue; }
|
||||
void setActiveMaterialName( const G4String &inputValue ) { fActiveMaterialName = inputValue; }
|
||||
void setCubicVolumeScoringUpDown( const G4double inputValue )
|
||||
{ fCubicVolumeScoringUpDown = inputValue; }
|
||||
void setCubicVolumeScoringSide( const G4double inputValue )
|
||||
{ fCubicVolumeScoringSide = inputValue; }
|
||||
G4int getPrimaryParticleId() const { return fPrimaryParticleId; }
|
||||
G4double getPrimaryParticleEnergy() const { return fPrimaryParticleEnergy; }
|
||||
G4ThreeVector getPrimaryParticleDirection() const { return fPrimaryParticleDirection; }
|
||||
G4String getAbsorberMaterialName() const { return fAbsorberMaterialName; }
|
||||
G4String getActiveMaterialName() const { return fActiveMaterialName; }
|
||||
G4double getCubicVolumeScoringUpDown() const { return fCubicVolumeScoringUpDown; }
|
||||
G4double getCubicVolumeScoringSide() const { return fCubicVolumeScoringSide; }
|
||||
void setArray( const std::array< G4double, SteppingAction::numberCombinations >& inputArray );
|
||||
std::array< G4double, SteppingAction::numberCombinations > getArray() const { return fArray; }
|
||||
// Accessor methods useful to transfer information collected by the stepping-action
|
||||
// into this Run class
|
||||
|
||||
private:
|
||||
G4int fNumEvents;
|
||||
G4int fPrimaryParticleId;
|
||||
G4double fPrimaryParticleEnergy;
|
||||
G4ThreeVector fPrimaryParticleDirection;
|
||||
G4String fAbsorberMaterialName;
|
||||
G4String fActiveMaterialName;
|
||||
G4double fCubicVolumeScoringUpDown;
|
||||
G4double fCubicVolumeScoringSide;
|
||||
std::array< G4double, SteppingAction::numberCombinations > fArray;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 RunAction.hh
|
||||
/// \brief Definition of the RunAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef RunAction_h
|
||||
#define RunAction_h
|
||||
|
||||
#include "G4UserRunAction.hh"
|
||||
|
||||
class G4Run;
|
||||
class SteppingAction;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class RunAction: public G4UserRunAction {
|
||||
public:
|
||||
RunAction( SteppingAction* steppingAction = nullptr );
|
||||
virtual ~RunAction();
|
||||
virtual void BeginOfRunAction( const G4Run* aRun ) override;
|
||||
virtual void EndOfRunAction( const G4Run* aRun ) override;
|
||||
virtual G4Run* GenerateRun() override;
|
||||
private:
|
||||
SteppingAction* fSteppingAction;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 SteppingAction.hh
|
||||
/// \brief Definition of the SteppingAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef SteppingAction_H
|
||||
#define SteppingAction_H 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UserSteppingAction.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include <array>
|
||||
|
||||
class Run;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class SteppingAction : public G4UserSteppingAction {
|
||||
public:
|
||||
SteppingAction();
|
||||
virtual ~SteppingAction();
|
||||
|
||||
virtual void UserSteppingAction( const G4Step* ) override;
|
||||
// This is the main method where the step lengths of particles inside
|
||||
// the scoring volumes are collected, and then the corresponding fluences
|
||||
// are filled up in the Run object where they are stored (and then
|
||||
// printed out at the end of the Run).
|
||||
// (For simplicity and brevity, we avoid histograms and compute instead
|
||||
// some statistics ourself, which will be print-out at the end of the run.)
|
||||
|
||||
void initialize();
|
||||
// This method is called by RunAction::BeginOfRunAction for the
|
||||
// initialization of the stepping-action at the beginning of each Run.
|
||||
// This is necessary because different runs can have different primary particle
|
||||
// types, kinetic energies, and detector configurations.
|
||||
|
||||
void setRunPointer( Run* inputValue = nullptr ) { fRunPtr = inputValue; }
|
||||
// This method is called by RunAction::BeginOfRunAction for providing to the
|
||||
// stepping-action the pointer to the run object at the beginning of each Run.
|
||||
// This pointer is then used to pass the information collected by the stepping-action
|
||||
// to the run object.
|
||||
|
||||
G4double getCubicVolumeScoringUpDown() const { return fCubicVolumeScoringUpDown; }
|
||||
G4double getCubicVolumeScoringSide() const { return fCubicVolumeScoringSide; }
|
||||
// The cubic-volumes of the scoring volumes are needed to get the fluence from
|
||||
// the sum of step lengths in those scoring volumes.
|
||||
// Notice that two of the three scoring volumes - upstream and downstream -
|
||||
// have the same cubic-volume, that we call "fCubicVolumeScoringUpDown".
|
||||
|
||||
static const G4int numberScoringVolumes = 3; // downstream, side, upstream
|
||||
static const G4int numberKinematicRegions = 3; // all, below 20 MeV, above 20 MeV
|
||||
static const G4int numberParticleTypes = 11; // all, e, gamma, mu, nu, pi, n, p, ions,
|
||||
// other-mesons, other-baryons
|
||||
static const G4int numberCombinations =
|
||||
numberScoringVolumes*numberKinematicRegions*numberParticleTypes;
|
||||
static const std::array< G4String, numberScoringVolumes > arrayScoringVolumeNames;
|
||||
static const std::array< G4String, numberKinematicRegions > arrayKinematicRegionNames;
|
||||
static const std::array< G4String, numberParticleTypes > arrayParticleTypeNames;
|
||||
static G4int getIndex( const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType );
|
||||
|
||||
private:
|
||||
Run* fRunPtr; // Pointer to the Run object
|
||||
G4int fPrimaryParticleId;
|
||||
G4double fPrimaryParticleEnergy;
|
||||
G4ThreeVector fPrimaryParticleDirection;
|
||||
G4String fAbsorberMaterialName;
|
||||
G4String fActiveMaterialName;
|
||||
G4bool fIsFirstStepOfTheEvent;
|
||||
G4bool fIsFirstStepInAbsorberLayer;
|
||||
G4bool fIsFirstStepInActiveLayer;
|
||||
G4bool fIsFirstStepInScoringUpDown;
|
||||
G4bool fIsFirstStepInScoringSide;
|
||||
G4double fCubicVolumeScoringUpDown;
|
||||
G4double fCubicVolumeScoringSide;
|
||||
|
||||
std::array< G4double, numberCombinations > fArraySumStepLengths;
|
||||
// Array to collect the sum of step lengths in the scoring volumes for the whole run,
|
||||
// according to the various cases (kinematical region and particle type).
|
||||
// Note that the fluence in a scoring volume is defined as sum of step lengths
|
||||
// in that scoring volume divided by the cubic-volume of that scoring volume.
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/mydet/absorberMaterial Lead
|
||||
/mydet/activeMaterial Scintillator
|
||||
/mydet/isCalHomogeneous 0
|
||||
/mydet/isUnitInLambda 1
|
||||
/mydet/absorberTotalLength 10.0
|
||||
/mydet/calorimeterRadius 5.0
|
||||
/mydet/activeLayerNumber 854
|
||||
/mydet/activeLayerSize 4.0
|
||||
/mydet/isRadiusUnitInLambda 1
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
@@ -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 ActionInitialization.cc
|
||||
/// \brief Implementation of the ActionInitialization class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::
|
||||
ActionInitialization( const DetectorConstruction* inputDetectorConstruction ) :
|
||||
G4VUserActionInitialization(), fPtrDetectorConstruction( inputDetectorConstruction ) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::~ActionInitialization() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const {
|
||||
// This is NOT called in SEQ-mode, while in the MT-mode is called only for the Master thread.
|
||||
SetUserAction( new RunAction );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::Build() const {
|
||||
// This is called in the SEQ-mode and in the MT-mode only for Worker threads.
|
||||
SetUserAction( new PrimaryGeneratorAction( fPtrDetectorConstruction ) );
|
||||
SteppingAction* steppingAction = new SteppingAction;
|
||||
SetUserAction( steppingAction );
|
||||
SetUserAction( new RunAction( steppingAction ) );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+680
@@ -0,0 +1,680 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorConstruction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4Cons.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4RotationMatrix.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4UniformMagField.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "DetectorMessenger.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction() :
|
||||
fVacuum( nullptr ), fIron( nullptr ), fCopper( nullptr ), fTungsten( nullptr ),
|
||||
fLead( nullptr ), fUranium( nullptr ), fPbWO4( nullptr ), fPolystyrene( nullptr ),
|
||||
fLiquidArgon( nullptr ), fSilicon( nullptr ), fQuartz( nullptr ), fBrass( nullptr ),
|
||||
fAluminium( nullptr ), fGraphite( nullptr ),
|
||||
fAbsorberMaterial( nullptr ), fActiveMaterial( nullptr ),
|
||||
fExperimentalHall_log( nullptr ), fExperimentalHall_phys( nullptr ),
|
||||
fLogicCalo( nullptr ), fPhysiCalo( nullptr ),
|
||||
fLogicModule( nullptr ), fPhysiModule( nullptr ),
|
||||
fLogicAbsorber( nullptr ), fPhysiAbsorber( nullptr ),
|
||||
fLogicActive( nullptr ), fPhysiActive( nullptr ),
|
||||
fFieldMgr( nullptr ), fUniformMagField( nullptr ),
|
||||
fDetectorMessenger( nullptr ),
|
||||
// Default values. ***LOOKHERE***
|
||||
fIsCalHomogeneous( false ), // Sampling calorimeter.
|
||||
fIsUnitInLambda( false ), // Unit of length for the absorber total length.
|
||||
fAbsorberTotalLength( 2.0*CLHEP::m ),
|
||||
fCalorimeterRadius( 1.0*CLHEP::m ),
|
||||
fActiveLayerNumber( 50 ),
|
||||
fActiveLayerSize( 4.0*CLHEP::mm ),
|
||||
fIsRadiusUnitInLambda( false ), // Unit of length for the radius bin size.
|
||||
// Extra
|
||||
fCaloLength( 2.0*CLHEP::m ),
|
||||
// Scoring part
|
||||
fLogicScoringUpDown( nullptr ),
|
||||
fPhysiScoringUpstream( nullptr ),
|
||||
fPhysiScoringDownstream( nullptr ),
|
||||
fLogicScoringSide( nullptr ),
|
||||
fPhysiScoringSide( nullptr )
|
||||
{
|
||||
fFieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
DefineMaterials();
|
||||
fAbsorberMaterial = fIron;
|
||||
fActiveMaterial = fPolystyrene;
|
||||
fDetectorMessenger = new DetectorMessenger( this );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::~DetectorConstruction() {
|
||||
delete fDetectorMessenger;
|
||||
delete fUniformMagField;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct() {
|
||||
return ConstructCalorimeter();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::ConstructSDandField() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::DefineMaterials() {
|
||||
G4double a; // atomic mass
|
||||
G4double z; // atomic number
|
||||
G4double density, pressure, temperature, fractionmass;
|
||||
G4String name, symbol;
|
||||
G4int nel, natoms;
|
||||
|
||||
//--- elements
|
||||
|
||||
a = 1.01*g/mole;
|
||||
G4Element* elH = new G4Element( name="Hydrogen", symbol="H2", z=1., a );
|
||||
|
||||
a = 2.01*g/mole;
|
||||
//G4Element* elD = new G4Element( name="Deuterium", symbol="D", z=1., a );
|
||||
|
||||
a = 4.*g/mole;
|
||||
//G4Element* elHe = new G4Element( name="Helium", symbol="He", z=2., a );
|
||||
|
||||
a = 6.94*g/mole;
|
||||
//G4Element* elLi = new G4Element( name="Lithium", symbol="Li", z=3., a );
|
||||
|
||||
a = 9.01*g/mole;
|
||||
//G4Element* elBe = new G4Element( name="Berillium", symbol="Be", z=4., a );
|
||||
|
||||
a = 12.01*g/mole;
|
||||
G4Element* elC = new G4Element( name="Carbon", symbol="C", z=6., a );
|
||||
|
||||
a = 14.01*g/mole;
|
||||
G4Element* elN = new G4Element( name="Nitrogen", symbol="N2", z=7., a );
|
||||
|
||||
a = 16.*g/mole;
|
||||
G4Element* elO = new G4Element( name="Oxygen", symbol="O2", z=8., a );
|
||||
|
||||
a = 20.18*g/mole;
|
||||
//G4Element* elNe = new G4Element( name="Neon", symbol="Ne", z=10., a );
|
||||
|
||||
a = 22.99*g/mole;
|
||||
//G4Element* elNa = new G4Element( name="Sodium", symbol="Na", z=11., a );
|
||||
|
||||
a = 26.98*g/mole;
|
||||
//G4Element* elAl = new G4Element( name="Aluminium", symbol="Al", z=13., a );
|
||||
|
||||
a = 28.085*g/mole;
|
||||
G4Element* elSi = new G4Element( name="Silicon", symbol="Si", z=14., a );
|
||||
|
||||
a = 40.08*g/mole;
|
||||
//G4Element* elCa = new G4Element( name="Calcium", symbol="Ca", z=20., a );
|
||||
|
||||
a = 55.850*g/mole;
|
||||
//G4Element* elFe = new G4Element( name="Iron", symbol="Fe", z=26., a );
|
||||
|
||||
a = 63.54*g/mole;
|
||||
G4Element* elCu = new G4Element( name="Copper", symbol="Cu", z=29., a );
|
||||
|
||||
a = 65.41*g/mole;
|
||||
G4Element* elZn = new G4Element( name="Zinc", symbol="Zn", z=30., a );
|
||||
|
||||
a = 183.85*g/mole;
|
||||
G4Element* elW = new G4Element( name="Tungstenm", symbol="W", z=74., a );
|
||||
|
||||
a = 207.19*g/mole;
|
||||
G4Element* elPb = new G4Element( name="Lead", symbol="Pb", z=82., a );
|
||||
|
||||
a = 238.03*g/mole;
|
||||
//G4Element* elU = new G4Element(name="Uranium", symbol="U", z=92., a);
|
||||
|
||||
//--- simple materials
|
||||
|
||||
// Iron has a X0 = 1.7585 cm and lambda_I = 16.760 cm.
|
||||
density = 7.87*g/cm3;
|
||||
a = 55.85*g/mole;
|
||||
fIron = new G4Material( name="Iron", z=26., a, density );
|
||||
|
||||
// Copper has a X0 = 1.4353 cm and lambda_I = 15.056 cm.
|
||||
density = 8.96*g/cm3;
|
||||
a = 63.54*g/mole;
|
||||
fCopper = new G4Material( name="Copper", z=29., a, density );
|
||||
|
||||
// Tungsten has a X0 = 0.35 cm and lambda_I = 9.5855 cm.
|
||||
density = 19.3*g/cm3;
|
||||
a = 183.85*g/mole;
|
||||
fTungsten = new G4Material( name="Tungsten", z=74., a, density );
|
||||
|
||||
// Lead has a X0 = 0.56120 cm and lambda_I = 17.092 cm.
|
||||
density = 11.35*g/cm3;
|
||||
a = 207.19*g/mole;
|
||||
fLead = new G4Material( name="Lead", z=82., a, density );
|
||||
|
||||
// Uranium has a X0 = 0.31662 cm and lambda_I = 10.501 cm.
|
||||
density = 18.95*g/cm3;
|
||||
a = 238.03*g/mole;
|
||||
fUranium = new G4Material( name="Uranium", z=92., a, density );
|
||||
|
||||
// Liquid Argon has a X0 = 10.971 cm and lambda_I = 65.769 cm.
|
||||
density = 1.4*g/cm3;
|
||||
a = 39.95*g/mole;
|
||||
fLiquidArgon = new G4Material( name="LiquidArgon", z=18., a, density );
|
||||
|
||||
density = 0.002*g/cm3;
|
||||
a = 39.95*g/mole;
|
||||
//G4Material* ArgonGas = new G4Material( name="ArgonGas", z=18., a, density );
|
||||
|
||||
// Silicon has a X0 = 9.3688 cm and lambda_I = 46.5436 cm
|
||||
density = 2.33*g/cm3;
|
||||
a = 28.085*g/mole;
|
||||
fSilicon = new G4Material( name="Silicon", z=14., a, density );
|
||||
|
||||
// Aluminium has a X0 = 8.8959 cm and lambda_I = 39.7184 cm
|
||||
density = 2.7*g/cm3;
|
||||
a = 26.98*g/mole;
|
||||
fAluminium = new G4Material( name="Aluminium", z=13., a, density );
|
||||
|
||||
// Graphite has a X0 = 19.3213 cm and lambda_I = 38.8235 cm
|
||||
density = 2.210*g/cm3;
|
||||
a = 12.0107*g/mole;
|
||||
fGraphite = new G4Material( name="Graphite", z=6., a, density );
|
||||
|
||||
density = 8.96*g/cm3;
|
||||
a = 58.69*g/mole;
|
||||
//G4Material* Nickel = new G4Material( name="Nickel", z=28., a, density );
|
||||
|
||||
//--- mixtures
|
||||
|
||||
density = 1.290*mg/cm3;
|
||||
G4Material* Air = new G4Material( name="Air", density, nel=2 );
|
||||
Air->AddElement(elN, 0.7);
|
||||
Air->AddElement(elO, 0.3);
|
||||
|
||||
density = 1.e-5*g/cm3;
|
||||
pressure = 2.e-2*bar;
|
||||
temperature = STP_Temperature; // From PhysicalConstants.h .
|
||||
fVacuum = new G4Material( name="Vacuum", density, nel=1,
|
||||
kStateGas, temperature, pressure );
|
||||
fVacuum->AddMaterial( Air, fractionmass=1. );
|
||||
|
||||
// Plastic scintillator tiles (used both in CMS hadron calorimeter
|
||||
// and ATLAS hadron barrel calorimeter):
|
||||
// X0 = 42.4 cm and lambda_I = 79.360 cm.
|
||||
density = 1.032*g/cm3;
|
||||
fPolystyrene = new G4Material( name="Polystyrene", density, nel=2 );
|
||||
fPolystyrene->AddElement( elC, natoms=19 );
|
||||
fPolystyrene->AddElement( elH, natoms=21 );
|
||||
|
||||
// PbWO4 CMS crystals. It has a X0 = 0.89 cm and lambda_I = 22.4 cm.
|
||||
density = 8.28*g/cm3;
|
||||
fPbWO4 = new G4Material( name="PbWO4", density, nel=3 );
|
||||
fPbWO4->AddElement( elPb, natoms=1 );
|
||||
fPbWO4->AddElement( elW, natoms=1 );
|
||||
fPbWO4->AddElement( elO, natoms=4 );
|
||||
|
||||
fQuartz = new G4Material( name="Quartz", density=2.200*g/cm3, nel=2 );
|
||||
fQuartz->AddElement( elSi, 1 );
|
||||
fQuartz->AddElement( elO , 2 );
|
||||
|
||||
fBrass = new G4Material( name="Brass", density=8.6*g/cm3, nel=2 );
|
||||
fBrass->AddElement( elCu, 0.7 );
|
||||
fBrass->AddElement( elZn, 0.3 );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter() {
|
||||
if ( ! areParametersOK() ) {
|
||||
G4cout << " DetectorConstruction::ConstructCalorimeter() : ***ERROR*** "
|
||||
<< G4endl << "\t PARAMETERS NOT WELL-DEFINED! GEOMETRY UNCHANGED."
|
||||
<< G4endl;
|
||||
return fExperimentalHall_phys;
|
||||
}
|
||||
|
||||
// Clean old geometry, if any.
|
||||
G4GeometryManager::GetInstance()->OpenGeometry();
|
||||
G4PhysicalVolumeStore::GetInstance()->Clean();
|
||||
G4LogicalVolumeStore::GetInstance()->Clean();
|
||||
G4SolidStore::GetInstance()->Clean();
|
||||
|
||||
G4double lambda = 0.0; // G4double X0 = 0.0;
|
||||
if ( fIsUnitInLambda ) {
|
||||
if ( fAbsorberMaterial == fIron ) {
|
||||
lambda = 16.760*cm; // X0 = 1.7585*cm;
|
||||
} else if ( fAbsorberMaterial == fCopper ) {
|
||||
lambda = 15.056*cm; // X0 = 1.4353*cm;
|
||||
} else if ( fAbsorberMaterial == fBrass ) {
|
||||
lambda = 15.056*cm; // Lack of PDG data: I am assuming the same as Copper. // X0=1.4353*cm
|
||||
} else if ( fAbsorberMaterial == fTungsten ) {
|
||||
lambda = 9.5855*cm; // X0 = 0.35*cm;
|
||||
} else if ( fAbsorberMaterial == fLead ) {
|
||||
lambda = 17.092*cm; // X0 = 0.56120*cm;
|
||||
} else if ( fAbsorberMaterial == fPbWO4 ) {
|
||||
lambda = 22.4*cm; // X0 = 0.89*cm;
|
||||
} else if ( fAbsorberMaterial == fUranium ) {
|
||||
lambda = 10.501*cm; // X0 = 0.31662*cm;
|
||||
} else if ( fAbsorberMaterial == fGraphite ) {
|
||||
lambda = 38.82*cm; // X0 = 19.32*cm;
|
||||
} else {
|
||||
std::cout << "ERROR: absorber material not recognized" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------- volumes --------------------------
|
||||
|
||||
G4double absorberTotalLength = fAbsorberTotalLength;
|
||||
G4double calorimeterRadius = fCalorimeterRadius;
|
||||
if ( fIsUnitInLambda ) {
|
||||
absorberTotalLength *= lambda;
|
||||
calorimeterRadius *= lambda;
|
||||
}
|
||||
|
||||
// --- experimental hall (world volume) ***LOOKHERE***
|
||||
// beam line along the Z-axis
|
||||
G4double expHall_x = 10.0*m; // half dimension along x
|
||||
G4double expHall_y = 10.0*m; // half dimension along y
|
||||
G4double expHall_z = 10.0*m; // half dimension along z
|
||||
|
||||
G4Box* experimentalHall_box = new G4Box( "expHall_box", expHall_x, expHall_y, expHall_z );
|
||||
fExperimentalHall_log = new G4LogicalVolume( experimentalHall_box, // solid
|
||||
fVacuum, // material
|
||||
"expHall_log", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fExperimentalHall_phys = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"expHall", // name
|
||||
fExperimentalHall_log, // logical volume
|
||||
0, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// --- Detector
|
||||
// The idea is to use Replica placement.
|
||||
// To do that, we have to define two extra volumes: the "calorimeter" volume
|
||||
// and the "module". The former, which has the world as its mother volume,
|
||||
// is the mother of the module volume. The calorimeter volume is completely
|
||||
// filled by a number (theActiveLayerNumber) of replicas of the module volume.
|
||||
// A module volume, in its turn, is the mother volume of the absorber layer +
|
||||
// active layer.
|
||||
|
||||
// --- absorber layer : logical
|
||||
G4double zAbsorber = absorberTotalLength / static_cast< double >( fActiveLayerNumber );
|
||||
// In the case of homogenous calorimeter the "active" part must be
|
||||
// subtracted because it is made of the same material
|
||||
// (the material of the "active" part is set to be the same as
|
||||
// the aborber).
|
||||
if ( fIsCalHomogeneous ) {
|
||||
fActiveMaterial = fAbsorberMaterial;
|
||||
zAbsorber -= fActiveLayerSize;
|
||||
}
|
||||
zAbsorber /= 2.0; // half dimension along z
|
||||
G4Tubs* solidAbsorber = new G4Tubs( "solidAbsorber", // name
|
||||
0.0, // inner radius
|
||||
calorimeterRadius, // outer radius
|
||||
zAbsorber, // half cylinder length in z
|
||||
0.0, // starting phi angle in rad
|
||||
2.0*pi ); // final phi angle in rad
|
||||
fLogicAbsorber = new G4LogicalVolume( solidAbsorber, // solid
|
||||
fAbsorberMaterial, // material
|
||||
"logicAbsorber", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
|
||||
// --- active layer : logical
|
||||
G4double zActive = fActiveLayerSize / 2.0; // half dimension along z
|
||||
G4Tubs* solidActive = new G4Tubs( "solidActive", // name
|
||||
0.0, // inner radius
|
||||
calorimeterRadius, // outer radius
|
||||
zActive, // half cylinder length in z
|
||||
0.0, // starting phi angle in rad
|
||||
2.0*pi ); // final phi angle in rad
|
||||
fLogicActive = new G4LogicalVolume( solidActive, // solid
|
||||
fActiveMaterial, // material
|
||||
"logicActive", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
|
||||
// --- module : logical
|
||||
G4double zModule = zAbsorber + zActive; // half dimension along z
|
||||
G4Tubs* solidModule = new G4Tubs( "solidModule", // name
|
||||
0.0, // inner radius
|
||||
calorimeterRadius, // outer radius
|
||||
zModule, // half cylinder length in z
|
||||
0.0, // starting phi angle in rad
|
||||
2.0*pi ); // final phi angle in rad
|
||||
fLogicModule = new G4LogicalVolume( solidModule, // solid
|
||||
fLead, // material, it does NOT matter
|
||||
"logicModule", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
|
||||
// --- calorimeter : logical
|
||||
G4int numberOfModules = fActiveLayerNumber;
|
||||
G4double zCalo = numberOfModules*zModule; // half dimension along z
|
||||
fCaloLength = 2.0*zCalo;
|
||||
G4Tubs* solidCalo = new G4Tubs( "solidCalo", // name
|
||||
0.0, // inner radius
|
||||
calorimeterRadius, // outer radius
|
||||
zCalo, // half cylinder length in z
|
||||
0.0, // starting phi angle in rad
|
||||
2.0*pi ); // final phi angle in rad
|
||||
fLogicCalo = new G4LogicalVolume( solidCalo, // solid
|
||||
fLead, // material, it does NOT matter
|
||||
"logicCalo", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
|
||||
// --- absorber layer : physical
|
||||
G4double zpos = - zActive;
|
||||
fPhysiAbsorber = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(0,0,zpos), // translation
|
||||
fLogicAbsorber, // logical volume
|
||||
"physiAbsorber", // name
|
||||
fLogicModule, // mother logical volume
|
||||
false, // boolean operation
|
||||
1000 ); // copy number
|
||||
|
||||
// --- active layer : physical
|
||||
zpos += zAbsorber + zActive;
|
||||
fPhysiActive = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(0,0,zpos), // translation
|
||||
fLogicActive, // logical volume
|
||||
"physiActive", // name
|
||||
fLogicModule, // mother logical volume
|
||||
false, // boolean operation
|
||||
2000 ); // copy number
|
||||
|
||||
// --- module : physical (using replica)
|
||||
fPhysiModule = new G4PVReplica( "Calo", // name
|
||||
fLogicModule, // logical volume
|
||||
fLogicCalo, // mother logical volume
|
||||
kZAxis, // axis of replication
|
||||
numberOfModules, // number of replica
|
||||
2*(zAbsorber+zActive) ); // (full) width of replica
|
||||
|
||||
// --- calorimeter : physical
|
||||
fPhysiCalo = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiCalo", // its name
|
||||
fLogicCalo, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
100 ); // copy number
|
||||
|
||||
// Three scoring volumes: one thin layer downstream of the calorimeter ("down")
|
||||
// one thin layer surrounding (lateral) of the calorimeter ("side")
|
||||
// one thin layer upstream of the calorimeter ("up")
|
||||
G4Tubs* solidScoringUpDown = new G4Tubs( "solidScoringUpDown", // name
|
||||
0.0, // inner radius
|
||||
calorimeterRadius, // outer radius
|
||||
0.5*fScoringThickness, // half cylinder length in z
|
||||
0.0, // starting phi angle in rad
|
||||
2.0*pi ); // final phi angle in rad
|
||||
fLogicScoringUpDown = new G4LogicalVolume( solidScoringUpDown, // solid
|
||||
fVacuum, // material
|
||||
"logicScoringUpDown", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
G4double zScoringUpDown = 0.5*(fCaloLength + fScoringThickness);
|
||||
fPhysiScoringUpstream = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector( 0.0, 0.0, -zScoringUpDown ),
|
||||
// translation
|
||||
"physiScoringUpstream", // name
|
||||
fLogicScoringUpDown, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
fPhysiScoringDownstream = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector( 0.0, 0.0, zScoringUpDown ),
|
||||
// translation
|
||||
"physiScoringDownstream", // name
|
||||
fLogicScoringUpDown, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
G4Tubs* solidScoringSide = new G4Tubs( "solidScoringSide", // name
|
||||
calorimeterRadius, // inner radius
|
||||
calorimeterRadius + fScoringThickness, // outer radius
|
||||
0.5*fCaloLength, // half cylinder length in z
|
||||
0.0, // starting phi angle in rad
|
||||
2.0*pi ); // final phi angle in rad
|
||||
fLogicScoringSide = new G4LogicalVolume( solidScoringSide, // solid
|
||||
fVacuum, // material
|
||||
"logicScoringSide", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiScoringSide = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector( 0.0, 0.0, 0.0 ), // translation
|
||||
"physiScoringSide", // name
|
||||
fLogicScoringSide, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
return fExperimentalHall_phys;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool DetectorConstruction::areParametersOK() {
|
||||
bool isOk = true;
|
||||
if ( ! fAbsorberMaterial ) {
|
||||
isOk = false;
|
||||
G4cout << " DetectorConstruction::areParametersOK() : UNDEFINED absorber material" << G4endl;
|
||||
}
|
||||
if ( ! fActiveMaterial ) {
|
||||
isOk = false;
|
||||
G4cout << " DetectorConstruction::areParametersOK() : UNDEFINED active material" << G4endl;
|
||||
}
|
||||
if ( fAbsorberTotalLength <= 0.0 ) {
|
||||
isOk = false;
|
||||
G4cout << " DetectorConstruction::areParametersOK() : fAbsorberTotalLength = "
|
||||
<< fAbsorberTotalLength << G4endl;
|
||||
}
|
||||
if ( fCalorimeterRadius <= 0.0 ) {
|
||||
isOk = false;
|
||||
G4cout << " DetectorConstruction::areParametersOK() : fCalorimeterRadius = "
|
||||
<< fCalorimeterRadius << G4endl;
|
||||
}
|
||||
if ( fActiveLayerNumber <= 0 ) {
|
||||
isOk = false;
|
||||
G4cout << " DetectorConstruction::areParametersOK() : fActiveLayerNumber = "
|
||||
<< fActiveLayerNumber << G4endl;
|
||||
}
|
||||
if ( fActiveLayerSize <= 0.0 ) {
|
||||
isOk = false;
|
||||
G4cout << " DetectorConstruction::areParametersOK() : fActiveLayerSize = "
|
||||
<< fActiveLayerSize << G4endl;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMagField( const G4double fieldValue ) {
|
||||
if ( fUniformMagField ) {
|
||||
delete fUniformMagField;
|
||||
}
|
||||
if ( std::abs( fieldValue ) > 0.0 ) {
|
||||
// Apply a global uniform magnetic field along the Y axis.
|
||||
// Notice that only if the magnetic field is not zero, the Geant4
|
||||
// transportion in field gets activated.
|
||||
fUniformMagField = new G4UniformMagField( G4ThreeVector( 0.0, fieldValue, 0.0 ) );
|
||||
fFieldMgr->SetDetectorField( fUniformMagField );
|
||||
fFieldMgr->CreateChordFinder( fUniformMagField );
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetAbsorberMaterial( const G4String name ) {
|
||||
if ( name == "Fe" || name == "Iron" || name == "iron" ) {
|
||||
fAbsorberMaterial = fIron;
|
||||
} else if ( name == "Cu" || name == "Copper" || name == "copper" ) {
|
||||
fAbsorberMaterial = fCopper;
|
||||
} else if ( name == "Brass" || name == "brass" ) {
|
||||
fAbsorberMaterial = fBrass;
|
||||
} else if ( name == "Pb" || name == "Lead" || name == "lead" ) {
|
||||
fAbsorberMaterial = fLead;
|
||||
} else if ( name == "PbWO4" ) {
|
||||
fAbsorberMaterial = fPbWO4;
|
||||
} else if ( name == "W" || name == "Tungsten" || name == "tungsten" ) {
|
||||
fAbsorberMaterial = fTungsten;
|
||||
} else if ( name == "U" || name == "Uranium" || name == "uranium" ) {
|
||||
fAbsorberMaterial = fUranium;
|
||||
} else if ( name == "C" || name == "Graphite" || name == "graphite" ) {
|
||||
fAbsorberMaterial = fGraphite;
|
||||
} else {
|
||||
G4cout << G4endl << G4endl
|
||||
<< "WARNING: the name of the material has not been recognized!" << G4endl
|
||||
<< " ===> the default * Iron * will be used." << G4endl << G4endl;
|
||||
fAbsorberMaterial = fIron;
|
||||
}
|
||||
fLogicAbsorber->SetMaterial( fAbsorberMaterial );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetActiveMaterial( const G4String name ) {
|
||||
if ( name == "Scintillator" || name == "scintillator" ) {
|
||||
fActiveMaterial = fPolystyrene;
|
||||
} else if ( name == "LAr" || name == "LiquidArgon" || name == "liquidArgon" ) {
|
||||
fActiveMaterial = fLiquidArgon;
|
||||
} else if ( name == "PbWO4" ) {
|
||||
fActiveMaterial = fPbWO4;
|
||||
} else if ( name == "Si" || name == "Silicon" || name == "silicon" ) {
|
||||
fActiveMaterial = fSilicon;
|
||||
} else if ( name == "Quartz" || name == "quartz" ) {
|
||||
fActiveMaterial = fQuartz;
|
||||
} else if ( name == "C" || name == "Graphite" || name == "graphite" ) {
|
||||
fActiveMaterial = fGraphite;
|
||||
} else {
|
||||
G4cout << G4endl << G4endl
|
||||
<< "WARNING: the name of the material has not been recognized!" << G4endl
|
||||
<< " ===> the default * Scintillator * will be used." << G4endl << G4endl;
|
||||
fActiveMaterial = fPolystyrene;
|
||||
}
|
||||
fLogicActive->SetMaterial( fActiveMaterial );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::UpdateGeometry() {
|
||||
//G4RunManager::GetRunManager()->DefineWorldVolume( ConstructCalorimeter() );
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
PrintParameters();
|
||||
// Update also the position of the gun
|
||||
const PrimaryGeneratorAction* pPrimaryAction =
|
||||
dynamic_cast< const PrimaryGeneratorAction* >(
|
||||
G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction() );
|
||||
if ( pPrimaryAction ) pPrimaryAction->SetGunPosition();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::PrintParameters() {
|
||||
G4cout << G4endl << G4endl << " ------ DetectorConstruction::PrintParameters() ------ "
|
||||
<< G4endl
|
||||
<< " Absorber Material = ";
|
||||
if ( fAbsorberMaterial ) {
|
||||
G4cout << fAbsorberMaterial->GetName();
|
||||
} else {
|
||||
G4cout << " UNDEFINED ";
|
||||
}
|
||||
G4cout << G4endl << " Active Material = ";
|
||||
if ( fActiveMaterial ) {
|
||||
G4cout << fActiveMaterial->GetName();
|
||||
} else {
|
||||
G4cout << " UNDEFINED ";
|
||||
}
|
||||
G4cout << G4endl << " Is the Calorimeter Homogeneous ? " << fIsCalHomogeneous;
|
||||
G4cout << G4endl << " Is the Unit in Lambda ? " << fIsUnitInLambda;
|
||||
G4cout << G4endl << " Absorber Total Length = ";
|
||||
if ( fIsUnitInLambda ) {
|
||||
G4cout << fAbsorberTotalLength << " lambdas";
|
||||
} else {
|
||||
G4cout << fAbsorberTotalLength / m << " m";
|
||||
}
|
||||
G4cout << G4endl << " Calorimeter Radius = ";
|
||||
if ( fIsUnitInLambda ) {
|
||||
G4cout << fCalorimeterRadius << " lambdas";
|
||||
} else {
|
||||
G4cout << fCalorimeterRadius / m << " m";
|
||||
}
|
||||
G4cout << G4endl << " Active Layer Number = " << fActiveLayerNumber;
|
||||
G4cout << G4endl << " Active Layer Size = " << fActiveLayerSize/mm << " mm";
|
||||
G4cout << G4endl << " Is the Radius Unit in Lambda ? " << fIsRadiusUnitInLambda;
|
||||
G4cout << G4endl << " Radius Bin Size = ";
|
||||
G4cout << G4endl << " Magnetic field [T] = ";
|
||||
if ( fUniformMagField ) {
|
||||
G4cout << fUniformMagField->GetConstantFieldValue() / tesla;
|
||||
} else {
|
||||
G4cout << "(0,0,0)";
|
||||
}
|
||||
|
||||
G4cout << G4endl << " -------------------------------------------------------- " << G4endl
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,187 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorMessenger.cc
|
||||
/// \brief Implementation of the DetectorMessenger class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorMessenger.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::DetectorMessenger( DetectorConstruction* myDet ) : fDetector( myDet ) {
|
||||
fDetectorDir = new G4UIdirectory( "/mydet/" );
|
||||
fDetectorDir->SetGuidance( "Detector control." );
|
||||
|
||||
fFieldCommand = new G4UIcmdWithADoubleAndUnit( "/mydet/setField", this );
|
||||
fFieldCommand->SetGuidance( "Define uniform magnetic field along Y." );
|
||||
fFieldCommand->SetGuidance( " -> in unit of [Tesla]" );
|
||||
fFieldCommand->SetParameterName( "By", false );
|
||||
fFieldCommand->SetDefaultValue( 0.0 );
|
||||
fFieldCommand->SetUnitCategory( "Magnetic flux density" );
|
||||
fFieldCommand->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fAbsorberMaterial = new G4UIcmdWithAString( "/mydet/absorberMaterial", this );
|
||||
fAbsorberMaterial->SetGuidance( "Choice of the absorber material:" );
|
||||
fAbsorberMaterial->SetGuidance( " iron / copper / tungsten / lead / PbWO4 / uranium " );
|
||||
fAbsorberMaterial->SetParameterName( "choiceAbsorberMaterial", true );
|
||||
fAbsorberMaterial->SetDefaultValue( "iron" );
|
||||
fAbsorberMaterial->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fActiveMaterial = new G4UIcmdWithAString( "/mydet/activeMaterial", this );
|
||||
fActiveMaterial->SetGuidance( "Choice of the active material:" );
|
||||
fActiveMaterial->SetGuidance( " scintillator / liquidArgon / PbWO4 / silicon / quartz " );
|
||||
fActiveMaterial->SetParameterName( "choiceActiveMaterial", true );
|
||||
fActiveMaterial->SetDefaultValue( "scintillator" );
|
||||
fActiveMaterial->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fIsCalHomogeneous = new G4UIcmdWithABool( "/mydet/isCalHomogeneous", this );
|
||||
fIsCalHomogeneous->SetParameterName( "choiceIsCalHomogeneous", true );
|
||||
fIsCalHomogeneous->SetGuidance( "Is the calorimeter homogeneous?" );
|
||||
fIsCalHomogeneous->SetGuidance( " -> yes|y|true|t|1 : Homogeneous calorimeter" );
|
||||
fIsCalHomogeneous->SetGuidance( " -> no|n|false|f|0 : Sampling calorimeter" );
|
||||
fIsCalHomogeneous->SetDefaultValue( false ); // default: sampling calorimeter
|
||||
fIsCalHomogeneous->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fIsUnitInLambda = new G4UIcmdWithABool( "/mydet/isUnitInLambda", this );
|
||||
fIsUnitInLambda->SetParameterName( "choiceIsUnitInLambda", true );
|
||||
fIsUnitInLambda->SetGuidance( "Is unit for absorber length in lambda?" );
|
||||
fIsUnitInLambda->SetGuidance( " -> yes|y|true|t|1 : unit in lambda" );
|
||||
fIsUnitInLambda->SetGuidance( " -> no|n|false|f|0 : unit in [mm]" );
|
||||
fIsUnitInLambda->SetDefaultValue( false ); // default: unit in [mm].
|
||||
fIsUnitInLambda->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fAbsorberTotalLength = new G4UIcmdWithADouble( "/mydet/absorberTotalLength", this );
|
||||
fAbsorberTotalLength->SetParameterName( "choiceAbsorberTotalLength", true );
|
||||
fAbsorberTotalLength->SetGuidance( "Absorber total length" );
|
||||
fAbsorberTotalLength->SetGuidance( " -> in unit of lambda or [mm]" );
|
||||
fAbsorberTotalLength->SetGuidance( " -> depending on value of choiceIsUnitInLambda" );
|
||||
fAbsorberTotalLength->SetDefaultValue( 2000.0 ); // default: 2 meters.
|
||||
fAbsorberTotalLength->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fCalorimeterRadius = new G4UIcmdWithADouble( "/mydet/calorimeterRadius", this );
|
||||
fCalorimeterRadius->SetParameterName( "choiceCalorimeterRadius", true );
|
||||
fCalorimeterRadius->SetGuidance( "Calorimeter Radius" );
|
||||
fCalorimeterRadius->SetGuidance( " -> in unit of lambda or [mm]" );
|
||||
fCalorimeterRadius->SetGuidance( " -> depending on value of choiceIsUnitInLambda" );
|
||||
fCalorimeterRadius->SetDefaultValue( 1000.0 ); // default: 1 meter.
|
||||
fCalorimeterRadius->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fActiveLayerNumber = new G4UIcmdWithAnInteger( "/mydet/activeLayerNumber", this );
|
||||
fActiveLayerNumber->SetParameterName( "choiceActiveLayerNumber", true );
|
||||
fActiveLayerNumber->SetGuidance( "Number of active layers" );
|
||||
fActiveLayerNumber->SetDefaultValue( 50 );
|
||||
fActiveLayerNumber->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fActiveLayerSize = new G4UIcmdWithADouble( "/mydet/activeLayerSize", this );
|
||||
fActiveLayerSize->SetParameterName( "choiceActiveLayerSize", true );
|
||||
fActiveLayerSize->SetGuidance( "Size (thickness) of the active layer, in [mm]" );
|
||||
fActiveLayerSize->SetDefaultValue( 4.0 ); // default: 4 millimeters.
|
||||
fActiveLayerSize->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fIsRadiusUnitInLambda = new G4UIcmdWithABool( "/mydet/isRadiusUnitInLambda", this );
|
||||
fIsRadiusUnitInLambda->SetParameterName( "choiceIsRadiusUnitInLambda", true );
|
||||
fIsRadiusUnitInLambda->SetGuidance( "Is unit of radius in lambda?" );
|
||||
fIsRadiusUnitInLambda->SetGuidance( " -> yes|y|true|t|1 : unit in lambda" );
|
||||
fIsRadiusUnitInLambda->SetGuidance( " -> no|n|false|f|0 : unit in [mm]" );
|
||||
fIsRadiusUnitInLambda->SetDefaultValue( false ); // default: unit in [mm].
|
||||
fIsRadiusUnitInLambda->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fUpdateCommand = new G4UIcmdWithoutParameter( "/mydet/update", this);
|
||||
fUpdateCommand->SetGuidance( "Update calorimeter geometry." );
|
||||
fUpdateCommand->SetGuidance( "This command MUST be applied before \"beamOn\" " );
|
||||
fUpdateCommand->SetGuidance( "if you changed geometrical value(s)." );
|
||||
fUpdateCommand->AvailableForStates( G4State_Idle );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::~DetectorMessenger() {
|
||||
delete fFieldCommand;
|
||||
delete fDetectorDir;
|
||||
delete fAbsorberMaterial;
|
||||
delete fActiveMaterial;
|
||||
delete fIsCalHomogeneous;
|
||||
delete fIsUnitInLambda;
|
||||
delete fAbsorberTotalLength;
|
||||
delete fCalorimeterRadius;
|
||||
delete fActiveLayerNumber;
|
||||
delete fActiveLayerSize;
|
||||
delete fIsRadiusUnitInLambda;
|
||||
delete fUpdateCommand;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorMessenger::SetNewValue( G4UIcommand* command, G4String newValue ) {
|
||||
if ( command == fFieldCommand ) {
|
||||
fDetector->SetMagField( fFieldCommand->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fAbsorberMaterial ) {
|
||||
fDetector->SetAbsorberMaterial( newValue );
|
||||
}
|
||||
if ( command == fActiveMaterial ) {
|
||||
fDetector->SetActiveMaterial( newValue );
|
||||
}
|
||||
if ( command == fIsCalHomogeneous ) {
|
||||
fDetector->SetIsCalHomogeneous( fIsCalHomogeneous->GetNewBoolValue( newValue ) );
|
||||
}
|
||||
if ( command == fIsUnitInLambda ) {
|
||||
fDetector->SetIsUnitInLambda( fIsUnitInLambda->GetNewBoolValue( newValue ) );
|
||||
}
|
||||
if ( command == fAbsorberTotalLength ) {
|
||||
fDetector->SetAbsorberTotalLength( fAbsorberTotalLength->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fCalorimeterRadius ) {
|
||||
fDetector->SetCalorimeterRadius( fCalorimeterRadius->GetNewDoubleValue(newValue) );
|
||||
}
|
||||
if ( command == fActiveLayerNumber ) {
|
||||
fDetector->SetActiveLayerNumber( fActiveLayerNumber->GetNewIntValue( newValue ) );
|
||||
}
|
||||
if ( command == fActiveLayerSize ) {
|
||||
fDetector->SetActiveLayerSize( fActiveLayerSize->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fIsRadiusUnitInLambda ) {
|
||||
fDetector->SetIsRadiusUnitInLambda( fIsRadiusUnitInLambda->GetNewBoolValue( newValue ) );
|
||||
}
|
||||
if ( command == fUpdateCommand ) {
|
||||
fDetector->UpdateGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction( const DetectorConstruction* pDetector ) :
|
||||
fPointerDetectorConstruction( pDetector )
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun( n_particle );
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
//***LOOKHERE*** Default particle and energy
|
||||
fParticleGun->SetParticleDefinition( particleTable->FindParticle( "geantino" ) );
|
||||
fParticleGun->SetParticleEnergy( 10.0*GeV );
|
||||
SetGunPosition();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction() {
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::SetGunPosition() const {
|
||||
// Shoot the particle in the middle between the world and the calorimeter
|
||||
G4double caloLength =
|
||||
( fPointerDetectorConstruction ? fPointerDetectorConstruction->GetCaloLength() : 0.0 );
|
||||
G4double gunPosition = -0.55*caloLength; //***LOOKHERE*** default gun position along the z-axis
|
||||
G4cout << G4endl << "PrimaryGenerationAction::SetGunPosition() : gun position along z = "
|
||||
<< gunPosition << " mm " << G4endl << G4endl;
|
||||
fParticleGun->SetParticlePosition( G4ThreeVector( 0.0, 0.0, gunPosition ) );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::GeneratePrimaries( G4Event* anEvent ) {
|
||||
G4ThreeVector v( 0.0, 0.0, 1.0 ); //***LOOKHERE*** default shoot along the z-axis
|
||||
fParticleGun->SetParticleMomentumDirection( v );
|
||||
fParticleGun->GeneratePrimaryVertex( anEvent );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,138 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 Run.cc
|
||||
/// \brief Implementation of the Run class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "Run.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::Run() : G4Run(), fNumEvents( 0 ),
|
||||
fPrimaryParticleId( 0 ), fPrimaryParticleEnergy( 0.0 ),
|
||||
fPrimaryParticleDirection( G4ThreeVector( 0.0, 0.0, 0.0 ) ),
|
||||
fAbsorberMaterialName( "" ), fActiveMaterialName( "" ),
|
||||
fCubicVolumeScoringUpDown( 1.0 ), fCubicVolumeScoringSide( 1.0 )
|
||||
{
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) fArray[i] = 0.0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::~Run() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::RecordEvent( const G4Event* anEvent ) {
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) at the end
|
||||
// of each event : in MT-mode, it is called only for the working thread that handled the event.
|
||||
G4int nEvt = anEvent->GetEventID();
|
||||
if ( nEvt % 10 == 0 ) G4cout << " Event#=" << nEvt << G4endl;
|
||||
G4Run::RecordEvent( anEvent );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Merge( const G4Run* aRun ) {
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) only in the case
|
||||
// of multithreaded mode and only for working threads.
|
||||
const Run* localRun = static_cast< const Run* >( aRun );
|
||||
fPrimaryParticleId = localRun->getPrimaryParticleId();
|
||||
fPrimaryParticleEnergy = localRun->getPrimaryParticleEnergy();
|
||||
fPrimaryParticleDirection = localRun->getPrimaryParticleDirection();
|
||||
fAbsorberMaterialName = localRun->getAbsorberMaterialName();
|
||||
fActiveMaterialName = localRun->getActiveMaterialName();
|
||||
fCubicVolumeScoringUpDown = localRun->getCubicVolumeScoringUpDown();
|
||||
fCubicVolumeScoringSide = localRun->getCubicVolumeScoringSide();
|
||||
fNumEvents += localRun->GetNumberOfEvent();
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) {
|
||||
fArray[i] += localRun->getArray()[i];
|
||||
}
|
||||
G4Run::Merge( aRun );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::printInfo() const {
|
||||
// This method is called by RunAction::EndOfRunAction. In MT-mode, only the master thread
|
||||
// calls it.
|
||||
const G4double floatingNumberOfEvents =
|
||||
std::max( 1.0, fNumEvents > 0 ? fNumEvents*1.0 : GetNumberOfEvent()*1.0 );
|
||||
// The fluence in the scoring volume is defined as sum of step lengths in that volume
|
||||
// divided by the volume of that scoring volume.
|
||||
const G4double conversionFactor = CLHEP::cm * CLHEP::cm; // From mm^-2 to cm^-2
|
||||
const G4double factorUpDown =
|
||||
conversionFactor / ( fCubicVolumeScoringUpDown*floatingNumberOfEvents );
|
||||
const G4double factorSide =
|
||||
conversionFactor / ( fCubicVolumeScoringSide*floatingNumberOfEvents );
|
||||
G4cout << std::setprecision(6) << G4endl << G4endl
|
||||
<< " =============== Run::printInfo() =============== \t RunID = " << GetRunID()
|
||||
<< G4endl
|
||||
<< " Primary particle PDG code = " << fPrimaryParticleId << G4endl
|
||||
<< " Primary particle kinetic energy = " << fPrimaryParticleEnergy / CLHEP::GeV
|
||||
<< " GeV" << G4endl
|
||||
<< " Primary particle direction = " << fPrimaryParticleDirection << G4endl
|
||||
<< " Absorber material = " << fAbsorberMaterialName << G4endl
|
||||
<< " Active material = " << fActiveMaterialName << G4endl
|
||||
<< " Cubic-volume scoring up-down = " << fCubicVolumeScoringUpDown << " mm^3" << G4endl
|
||||
<< " Cubic-volume scoring side = " << fCubicVolumeScoringSide << " mm^3" << G4endl
|
||||
<< " Number of events = " << floatingNumberOfEvents << G4endl
|
||||
<< " Conversion factor: fluence from mm^-2 to cm^-2 = " << conversionFactor << G4endl
|
||||
<< " Particle fluence in unit of cm^-2 :" << G4endl;
|
||||
for ( G4int i = 0; i < SteppingAction::numberScoringVolumes; ++i ) {
|
||||
G4double factor = ( i == 1 ? factorSide : factorUpDown );
|
||||
for ( G4int j = 0; j < SteppingAction::numberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < SteppingAction::numberParticleTypes; ++k ) {
|
||||
G4int index = SteppingAction::getIndex( i, j, k );
|
||||
//G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
G4cout << " case=" << std::setw(3) << index
|
||||
<< " " << std::setw(12) << SteppingAction::arrayScoringVolumeNames[i]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayKinematicRegionNames[j]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayParticleTypeNames[k]
|
||||
<< " " << factor*fArray[index] << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
G4cout << " ============================================================= " << G4endl << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::setArray( const std::array< G4double,
|
||||
SteppingAction::numberCombinations >& inputArray ) {
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) {
|
||||
fArray[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -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 RunAction.cc
|
||||
/// \brief Implementation of the RunAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "Run.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction( SteppingAction* steppingAction ) :
|
||||
G4UserRunAction(), fSteppingAction( steppingAction ) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::~RunAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4Run* RunAction::GenerateRun() {
|
||||
return new Run;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction( const G4Run* aRun ) {
|
||||
G4cout << "### Run " << aRun->GetRunID() << " starts." << G4endl;
|
||||
if ( fSteppingAction ) {
|
||||
fSteppingAction->initialize();
|
||||
Run* run = const_cast< Run* >( static_cast< const Run* >( aRun ) );
|
||||
if ( run != nullptr ) fSteppingAction->setRunPointer( run );
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction( const G4Run* aRun ) {
|
||||
const Run* run = static_cast< const Run* >( aRun );
|
||||
if ( run == nullptr || run->GetNumberOfEvent() == 0 ) return;
|
||||
if ( IsMaster() ) run->printInfo();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,239 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 SteppingAction.cc
|
||||
/// \brief Implementation of the SteppingAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "SteppingAction.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4LossTableManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
const std::array< G4String, SteppingAction::numberScoringVolumes >
|
||||
SteppingAction::arrayScoringVolumeNames = { "downstream", "side", "upstream" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberKinematicRegions >
|
||||
SteppingAction::arrayKinematicRegionNames = { "", "below 20 MeV", "above 20 MeV" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberParticleTypes >
|
||||
SteppingAction::arrayParticleTypeNames = { "all", "electron", "gamma", "muon", "neutrino",
|
||||
"pion", "neutron", "proton", "ion", "otherMeson",
|
||||
"otherBaryon" };
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4int SteppingAction::getIndex( const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType ) {
|
||||
G4int index = -1;
|
||||
if ( iScoringVolume >= 0 && iScoringVolume < numberScoringVolumes &&
|
||||
iKinematicRegion >= 0 && iKinematicRegion < numberKinematicRegions &&
|
||||
iParticleType >= 0 && iParticleType < numberParticleTypes ) {
|
||||
index = iScoringVolume * numberKinematicRegions * numberParticleTypes +
|
||||
iKinematicRegion * numberParticleTypes +
|
||||
iParticleType;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction() :G4UserSteppingAction() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::~SteppingAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::initialize() {
|
||||
// Initialization needed at the beginning of each Run
|
||||
fPrimaryParticleId = 0;
|
||||
fPrimaryParticleEnergy = 0.0;
|
||||
fPrimaryParticleDirection = G4ThreeVector( 0.0, 0.0, 1.0 );
|
||||
fAbsorberMaterialName = "";
|
||||
fActiveMaterialName = "";
|
||||
fIsFirstStepOfTheEvent = true;
|
||||
fIsFirstStepInAbsorberLayer = true;
|
||||
fIsFirstStepInActiveLayer = true;
|
||||
fIsFirstStepInScoringUpDown = true;
|
||||
fIsFirstStepInScoringSide = true;
|
||||
fCubicVolumeScoringUpDown = 1.0;
|
||||
fCubicVolumeScoringSide = 1.0;
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) {
|
||||
fArraySumStepLengths[i] = 0.0;
|
||||
}
|
||||
/*
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) fArraySumStepLengths[i] = 999.9;
|
||||
G4cout << " numberCombinations=" << numberCombinations << G4endl;
|
||||
for ( G4int i = 0; i < numberScoringVolumes; ++i ) {
|
||||
for ( G4int j = 0; j < numberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < numberParticleTypes; ++k ) {
|
||||
G4int index = getIndex( i, j, k );
|
||||
G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
if ( fArraySumStepLengths[ index ] < 1.0 ) G4cout << " <=== REPEATED!";
|
||||
else fArraySumStepLengths[ index ] = 0.0;
|
||||
G4cout << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) {
|
||||
if ( fArraySumStepLengths[i] > 999.0 ) G4cout << " i=" << i << " NOT COVERED !" << G4endl;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
// Get information on the primary particle
|
||||
if ( fIsFirstStepOfTheEvent ) {
|
||||
if ( theStep->GetTrack()->GetParentID() == 0 ) {
|
||||
fPrimaryParticleId = theStep->GetTrack()->GetDefinition()->GetPDGEncoding();
|
||||
fPrimaryParticleEnergy = theStep->GetPreStepPoint()->GetKineticEnergy();
|
||||
fPrimaryParticleDirection = theStep->GetPreStepPoint()->GetMomentumDirection();
|
||||
if ( fRunPtr ) {
|
||||
fRunPtr->setPrimaryParticleId( fPrimaryParticleId );
|
||||
fRunPtr->setPrimaryParticleEnergy( fPrimaryParticleEnergy );
|
||||
fRunPtr->setPrimaryParticleDirection( fPrimaryParticleDirection );
|
||||
}
|
||||
fIsFirstStepOfTheEvent = false;
|
||||
}
|
||||
}
|
||||
// Get information on the materials of the calorimeter
|
||||
if ( fIsFirstStepInAbsorberLayer &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiAbsorber" ) {
|
||||
fAbsorberMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->setAbsorberMaterialName( fAbsorberMaterialName );
|
||||
fIsFirstStepInAbsorberLayer = false;
|
||||
}
|
||||
if ( fIsFirstStepInActiveLayer &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiActive" ) {
|
||||
fActiveMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->setActiveMaterialName( fActiveMaterialName );
|
||||
fIsFirstStepInActiveLayer = false;
|
||||
}
|
||||
// Get information on step lengths in the scoring volumes
|
||||
G4int iScoringVolume = -1;
|
||||
if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringDownstream" ) {
|
||||
iScoringVolume = 0;
|
||||
if ( fIsFirstStepInScoringUpDown ) {
|
||||
fCubicVolumeScoringUpDown =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringUpDown( fCubicVolumeScoringUpDown );
|
||||
fIsFirstStepInScoringUpDown = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringSide" ) {
|
||||
iScoringVolume = 1;
|
||||
if ( fIsFirstStepInScoringSide ) {
|
||||
fCubicVolumeScoringSide =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringSide( fCubicVolumeScoringSide );
|
||||
fIsFirstStepInScoringSide = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ==
|
||||
"physiScoringUpstream" ) {
|
||||
iScoringVolume = 2;
|
||||
if ( fIsFirstStepInScoringUpDown ) {
|
||||
fCubicVolumeScoringUpDown =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringUpDown( fCubicVolumeScoringUpDown );
|
||||
fIsFirstStepInScoringUpDown = false;
|
||||
}
|
||||
}
|
||||
if ( iScoringVolume >= 0 ) {
|
||||
// In the case of the upstream scoring volume, consider only particles whose direction
|
||||
// is opposite with respect to the primary particle (this is needed, in particular,
|
||||
// for avoiding to account the incoming, primary beam particle in the "upstream" fluence).
|
||||
if ( iScoringVolume == 2 &&
|
||||
fPrimaryParticleDirection.dot(
|
||||
theStep->GetPreStepPoint()->GetMomentumDirection() ) > 0.0 ) return;
|
||||
G4double stepLength = theStep->GetTrack()->GetStepLength() * theStep->GetTrack()->GetWeight();
|
||||
G4int absPdg = theStep->GetTrack()->GetDefinition() == nullptr ? 0 :
|
||||
std::abs( theStep->GetTrack()->GetDefinition()->GetPDGEncoding() );
|
||||
/*
|
||||
G4cout << std::setprecision(6)
|
||||
<< theStep->GetTrack()->GetDefinition()->GetParticleName() << " absPdg=" << absPdg
|
||||
<< " Ekin[MeV]=" << theStep->GetPreStepPoint()->GetKineticEnergy()
|
||||
<< " (rho,z)[mm]=(" << theStep->GetTrack()->GetPosition().perp()
|
||||
<< "," << theStep->GetTrack()->GetPosition().z() << ")"
|
||||
<< " " << theStep->GetTrack()->GetVolume()->GetName()
|
||||
<< " " << theStep->GetTrack()->GetMaterial()->GetName()
|
||||
<< " L[mm]=" << stepLength << " "
|
||||
<< ( fPrimaryParticleDirection.dot(
|
||||
theStep->GetPreStepPoint()->GetMomentumDirection() ) > 0.0
|
||||
? "forward" : "backward" )
|
||||
<< G4endl;
|
||||
*/
|
||||
// Three kinematical regions: [0] : any value ; [1] : below 20 MeV ; [2] : above 20 MeV
|
||||
G4int iKinematicRegion = theStep->GetPreStepPoint()->GetKineticEnergy() < 20.0 ? 1 : 2;
|
||||
G4int iParticleType = -1;
|
||||
if ( absPdg == 11 ) iParticleType = 1; // electron (and positron)
|
||||
else if ( absPdg == 22 ) iParticleType = 2; // gamma
|
||||
else if ( absPdg == 13 ) iParticleType = 3; // muons (mu- and mu+)
|
||||
else if ( absPdg == 12 || absPdg == 14 || absPdg == 16 ) iParticleType = 4; // neutrinos
|
||||
// (and anti-neutrinos), all flavors
|
||||
else if ( absPdg == 111 || absPdg == 211 ) iParticleType = 5; // (charged) pions
|
||||
else if ( absPdg == 2112 ) iParticleType = 6; // neutron (and anti-neutron)
|
||||
else if ( absPdg == 2212 ) iParticleType = 7; // proton (and anti-proton)
|
||||
else if ( G4IonTable::IsIon( theStep->GetTrack()->GetDefinition() ) || // ions (and anti-ions)
|
||||
G4IonTable::IsAntiIon( theStep->GetTrack()->GetDefinition() ) ) iParticleType = 8;
|
||||
else if ( absPdg < 1000 ) iParticleType = 9; // other mesons (e.g. kaons) (Note: this works
|
||||
// in most cases, but not always!)
|
||||
else if ( absPdg > 1000 ) iParticleType = 10; // other baryons (e.g. hyperons, anti-hyperons,
|
||||
// etc.)
|
||||
// Consider the specific case : scoring volume, kinematic region and particle type
|
||||
G4int index = getIndex( iScoringVolume, iKinematicRegion, iParticleType );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "all" particle case, with the same scoring volume and kinematic region
|
||||
index = getIndex( iScoringVolume, iKinematicRegion, 0 );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region case, with the same scoring volume and particle type
|
||||
index = getIndex( iScoringVolume, 0, iParticleType );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region and "all" particle, with the same scoring volume
|
||||
index = getIndex( iScoringVolume, 0, 0 );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
if ( fRunPtr ) fRunPtr->setArray( fArraySumStepLengths );
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,72 @@
|
||||
///\file "hadronic/ParticleFluence/ConcentricSpheres/.README.txt"
|
||||
///\brief Example ParticleFluence/ConcentricSpheres README page
|
||||
|
||||
/*! \page ExampeParticleFluenceConcentricSpheres Example ConcentricSpheres
|
||||
|
||||
In this example, the particle fluence is evaluated for a set-up made
|
||||
of one target solid sphere, at the center of which a particle is shot
|
||||
(by default along the z-axis), followed by two outer, target solid sphere
|
||||
shells, with space in between filled up with G4_Galactic material - i.e.
|
||||
very low density gas.
|
||||
The three targets mimic a very simplified collider detector, with the
|
||||
first (inner) target as a proxy for a Tracker, the second (middle) target
|
||||
as a proxy for an electromagnetic (homogeneous) calorimeter, and the
|
||||
third and last (outer) target as a proxy for a hadronic (homogeneous)
|
||||
calorimeter.
|
||||
|
||||
The particle fluence is computed in six places: immediately outside
|
||||
each of the three targets (inner, middle and outer targets), and for
|
||||
each of them, in the "forward" and "backward" hemispheres (i.e. immediately
|
||||
after and before, respectively, of the target with respect to the direction
|
||||
of the primary particle).
|
||||
|
||||
The particle fluence is estimated by summing the track length in a
|
||||
"scoring volume" - i.e. a thin hemisphere shell filled up with G4_Galactic
|
||||
(very low density gas) material, immediately outside one of the targets -
|
||||
and then dividing for the cubic volume of such scoring volume.
|
||||
|
||||
The particle fluence is evaluated for the following 11 particle types:
|
||||
- all
|
||||
- electron + positron
|
||||
- gamma
|
||||
- muon- + muon+
|
||||
- neutrino (any flavour and including anti-neutrino)
|
||||
- charged pions
|
||||
- neutron + anti_neutron
|
||||
- proton + anti_proton
|
||||
- ion (and anti-ions)
|
||||
- otherMeson (e.g. kaons, etc.)
|
||||
- otherBaryon (e.g. hyperons, etc.)
|
||||
|
||||
The particle fluence is evaluated for the following 3 kinematical ranges:
|
||||
- any kinetic energy
|
||||
- kinetic energy < 20 MeV
|
||||
- kinetic energy > 20 MeV
|
||||
|
||||
Look for the string "***LOOKHERE***" for those parameters/options that
|
||||
are either hardwired in the code (i.e. not available via UI command),
|
||||
or default values of UI commands.
|
||||
|
||||
This example uses the physics list factory, therefore you can specify
|
||||
the reference physics list you want to use via the PHYSLIST
|
||||
environmental variable (by default, if you don't set it, the FTFP_BERT
|
||||
physics list is used).
|
||||
|
||||
To build this example:
|
||||
|
||||
mkdir Build; cd Build
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DGeant4_DIR=/path-to-geant4-libraries ../.
|
||||
make
|
||||
|
||||
To run it:
|
||||
|
||||
./ConcentricSpheres all_together.g4
|
||||
|
||||
which shoots 50 GeV pion- on three different configurations
|
||||
(Scintillator-PbWO4-Copper, LiquidArgon-Lead-Iron, Silicon-Tungsten-Tungsten),
|
||||
with 100 events in each run, and print out some information on the
|
||||
particle fluence at the end of each run.
|
||||
Other macros exist for each of these specific configurations.
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,59 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# Setup the project
|
||||
cmake_minimum_required(VERSION 3.16...3.21)
|
||||
project(ConcentricSpheres)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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 executable, and link it to the Geant4 libraries
|
||||
#
|
||||
add_executable(ConcentricSpheres ConcentricSpheres.cc ${sources} ${headers})
|
||||
target_link_libraries(ConcentricSpheres ${Geant4_LIBRARIES} )
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Copy all scripts to the build directory, so that we can run the executable
|
||||
# directly there.
|
||||
#
|
||||
set(SCRIPTS
|
||||
all_together.g4
|
||||
lar_pb_fe.g4
|
||||
sci_pbwo4_cu.g4
|
||||
si_w_w.g4
|
||||
)
|
||||
|
||||
foreach(_script ${SCRIPTS})
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/${_script}
|
||||
${PROJECT_BINARY_DIR}/${_script}
|
||||
COPYONLY
|
||||
)
|
||||
endforeach()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
|
||||
#
|
||||
install(TARGETS ConcentricSpheres DESTINATION bin)
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 ConcentricSpheres.cc
|
||||
/// \brief Main program of the hadronic/ParticleFluence/ConcentricSpheres example
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4Threading.hh"
|
||||
#include "G4RunManagerFactory.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4PhysListFactory.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
int main(int argc,char** argv) {
|
||||
|
||||
auto* runManager = G4RunManagerFactory::CreateRunManager();
|
||||
|
||||
DetectorConstruction* pDetectorInstance = new DetectorConstruction;
|
||||
runManager->SetUserInitialization( pDetectorInstance );
|
||||
|
||||
// Physics list factory: use the PHYSLIST environmental variable.
|
||||
G4PhysListFactory factory;
|
||||
G4VModularPhysicsList* thePL = factory.ReferencePhysList();
|
||||
|
||||
runManager->SetUserInitialization( thePL );
|
||||
runManager->SetUserInitialization( new ActionInitialization );
|
||||
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if ( argc==1 ) { // Define UI session for interactive mode.
|
||||
} else { // Batch mode
|
||||
G4String command = "/control/execute ";
|
||||
G4String fileName = argv[1];
|
||||
UI->ApplyCommand(command+fileName);
|
||||
}
|
||||
|
||||
// job termination
|
||||
delete runManager;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,11 @@
|
||||
name := ConcentricSpheres
|
||||
G4TARGET := $(name)
|
||||
G4EXLIB := true
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
.PHONY: all
|
||||
|
||||
all: lib bin
|
||||
|
||||
include $(G4INSTALL)/config/binmake.gmk
|
||||
@@ -0,0 +1,10 @@
|
||||
# Example ParticleFluence 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!
|
||||
|
||||
|
||||
## 2021-06-10 Alberto Ribon (exhadrParticleFluenceConcentricSpheres-V11-00-00)
|
||||
- Created the ConcentricSpheres variant of the ParticleFluence example.
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
In this example, the particle fluence is evaluated for a set-up made
|
||||
of one target solid sphere, at the center of which a particle is shot
|
||||
(by default along the z-axis), followed by two outer, target solid sphere
|
||||
shells, with space in between filled up with G4_Galactic material - i.e.
|
||||
very low density gas.
|
||||
The three targets mimic a very simplified collider detector, with the
|
||||
first (inner) target as a proxy for a Tracker, the second (middle) target
|
||||
as a proxy for an electromagnetic (homogeneous) calorimeter, and the
|
||||
third and last (outer) target as a proxy for a hadronic (homogeneous)
|
||||
calorimeter.
|
||||
|
||||
The particle fluence is computed in six places: immediately outside
|
||||
each of the three targets (inner, middle and outer targets), and for
|
||||
each of them, in the "forward" and "backward" hemispheres (i.e. immediately
|
||||
after and before, respectively, of the target with respect to the direction
|
||||
of the primary particle).
|
||||
|
||||
The particle fluence is estimated by summing the track length in a
|
||||
"scoring volume" - i.e. a thin hemisphere shell filled up with G4_Galactic
|
||||
(very low density gas) material, immediately outside one of the targets -
|
||||
and then dividing for the cubic volume of such scoring volume.
|
||||
|
||||
The particle fluence is evaluated for the following 11 particle types:
|
||||
- all
|
||||
- electron + positron
|
||||
- gamma
|
||||
- muon- + muon+
|
||||
- neutrino (any flavour and including anti-neutrino)
|
||||
- charged pions
|
||||
- neutron + anti_neutron
|
||||
- proton + anti_proton
|
||||
- ion (and anti-ions)
|
||||
- otherMeson (e.g. kaons, etc.)
|
||||
- otherBaryon (e.g. hyperons, etc.)
|
||||
|
||||
The particle fluence is evaluated for the following 3 kinematical ranges:
|
||||
- any kinetic energy
|
||||
- kinetic energy < 20 MeV
|
||||
- kinetic energy > 20 MeV
|
||||
|
||||
Look for the string "***LOOKHERE***" for those parameters/options that
|
||||
are either hardwired in the code (i.e. not available via UI command),
|
||||
or default values of UI commands.
|
||||
|
||||
This example uses the physics list factory, therefore you can specify
|
||||
the reference physics list you want to use via the PHYSLIST
|
||||
environmental variable (by default, if you don't set it, the FTFP_BERT
|
||||
physics list is used).
|
||||
|
||||
To build this example:
|
||||
|
||||
mkdir Build; cd Build
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DGeant4_DIR=/path-to-geant4-libraries ../.
|
||||
make
|
||||
|
||||
To run it:
|
||||
|
||||
./ConcentricSpheres all_together.g4
|
||||
|
||||
which shoots 50 GeV pion- on three different configurations
|
||||
(Scintillator-PbWO4-Copper, LiquidArgon-Lead-Iron, Silicon-Tungsten-Tungsten),
|
||||
with 100 events in each run, and print out some information on the
|
||||
particle fluence at the end of each run.
|
||||
Other macros exist for each of these specific configurations.
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
#
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
#
|
||||
#---
|
||||
#
|
||||
/mydet/material_tracker G4_POLYSTYRENE
|
||||
/mydet/inner_radius_tracker 5.0 cm
|
||||
/mydet/outer_radius_tracker 25.0 cm
|
||||
#
|
||||
/mydet/material_emCalo G4_PbWO4
|
||||
/mydet/inner_radius_emCalo 30.0 cm
|
||||
/mydet/outer_radius_emCalo 60.0 cm
|
||||
#
|
||||
/mydet/material_hadCalo G4_Cu
|
||||
/mydet/inner_radius_hadCalo 70.0 cm
|
||||
/mydet/outer_radius_hadCalo 170.0 cm
|
||||
#
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
#---
|
||||
#
|
||||
/mydet/material_tracker G4_lAr
|
||||
/mydet/inner_radius_tracker 5.0 cm
|
||||
/mydet/outer_radius_tracker 25.0 cm
|
||||
#
|
||||
/mydet/material_emCalo G4_Pb
|
||||
/mydet/inner_radius_emCalo 30.0 cm
|
||||
/mydet/outer_radius_emCalo 60.0 cm
|
||||
#
|
||||
/mydet/material_hadCalo G4_Fe
|
||||
/mydet/inner_radius_hadCalo 70.0 cm
|
||||
/mydet/outer_radius_hadCalo 170.0 cm
|
||||
#
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
#---
|
||||
#
|
||||
/mydet/material_tracker G4_Si
|
||||
/mydet/inner_radius_tracker 5.0 cm
|
||||
/mydet/outer_radius_tracker 25.0 cm
|
||||
#
|
||||
/mydet/material_emCalo G4_W
|
||||
/mydet/inner_radius_emCalo 30.0 cm
|
||||
/mydet/outer_radius_emCalo 60.0 cm
|
||||
#
|
||||
/mydet/material_hadCalo G4_W
|
||||
/mydet/inner_radius_hadCalo 70.0 cm
|
||||
/mydet/outer_radius_hadCalo 170.0 cm
|
||||
#
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 ActionInitialization.hh
|
||||
/// \brief Definition of the ActionInitialization class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ActionInitialization_h
|
||||
#define ActionInitialization_h 1
|
||||
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ActionInitialization : public G4VUserActionInitialization {
|
||||
public:
|
||||
ActionInitialization();
|
||||
virtual ~ActionInitialization();
|
||||
virtual void BuildForMaster() const override;
|
||||
virtual void Build() const override;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
Executable
+174
@@ -0,0 +1,174 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorConstruction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef DetectorConstruction_H
|
||||
#define DetectorConstruction_H 1
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4LogicalVolume;
|
||||
class G4VPhysicalVolume;
|
||||
class G4Material;
|
||||
class DetectorMessenger;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class DetectorConstruction : public G4VUserDetectorConstruction {
|
||||
public:
|
||||
DetectorConstruction();
|
||||
~DetectorConstruction();
|
||||
|
||||
G4VPhysicalVolume* Construct();
|
||||
|
||||
void SetMaterialTracker( const G4String name );
|
||||
inline G4Material* GetMaterialTracker() const;
|
||||
void SetMaterialEmCalo( const G4String name );
|
||||
inline G4Material* GetMaterialEmCalo() const;
|
||||
void SetMaterialHadCalo( const G4String name );
|
||||
inline G4Material* GetMaterialHadCalo() const;
|
||||
|
||||
inline void SetInnerRadiusTracker( const G4double value );
|
||||
inline G4double GetInnerRadiusTracker() const;
|
||||
inline void SetOuterRadiusTracker( const G4double value );
|
||||
inline G4double GetOuterRadiusTracker() const;
|
||||
inline void SetInnerRadiusEmCalo( const G4double value );
|
||||
inline G4double GetInnerRadiusEmCalo() const;
|
||||
inline void SetOuterRadiusEmCalo( const G4double value );
|
||||
inline G4double GetOuterRadiusEmCalo() const;
|
||||
inline void SetInnerRadiusHadCalo( const G4double value );
|
||||
inline G4double GetInnerRadiusHadCalo() const;
|
||||
inline void SetOuterRadiusHadCalo( const G4double value );
|
||||
inline G4double GetOuterRadiusHadCalo() const;
|
||||
inline G4double GetScoringThickness() const;
|
||||
|
||||
void UpdateGeometry();
|
||||
|
||||
private:
|
||||
G4VPhysicalVolume* ConstructDetector(); // To be invoked each time the geometry needs
|
||||
// to be updated.
|
||||
void PrintParameters();
|
||||
G4Material* fMaterialTracker;
|
||||
G4Material* fMaterialEmCalo;
|
||||
G4Material* fMaterialHadCalo;
|
||||
G4LogicalVolume* fExperimentalHall_log;
|
||||
G4VPhysicalVolume* fExperimentalHall_phys;
|
||||
G4LogicalVolume* fLogicTrackerShell;
|
||||
G4VPhysicalVolume* fPhysiTrackerShell;
|
||||
G4LogicalVolume* fLogicEmCaloShell;
|
||||
G4VPhysicalVolume* fPhysiEmCaloShell;
|
||||
G4LogicalVolume* fLogicHadCaloShell;
|
||||
G4VPhysicalVolume* fPhysiHadCaloShell;
|
||||
G4LogicalVolume* fLogicScoringTrackerShell;
|
||||
G4VPhysicalVolume* fPhysiScoringTrackerShell;
|
||||
G4LogicalVolume* fLogicScoringEmCaloShell;
|
||||
G4VPhysicalVolume* fPhysiScoringEmCaloShell;
|
||||
G4LogicalVolume* fLogicScoringHadCaloShell;
|
||||
G4VPhysicalVolume* fPhysiScoringHadCaloShell;
|
||||
DetectorMessenger* fDetectorMessenger;
|
||||
G4double fInnerRadiusTracker;
|
||||
G4double fOuterRadiusTracker;
|
||||
G4double fInnerRadiusEmCalo;
|
||||
G4double fOuterRadiusEmCalo;
|
||||
G4double fInnerRadiusHadCalo;
|
||||
G4double fOuterRadiusHadCalo;
|
||||
const G4double fScoringThickness = 10.0; //***LOOKHERE*** thickness of the scoring shell
|
||||
};
|
||||
|
||||
inline G4Material* DetectorConstruction::GetMaterialTracker() const {
|
||||
return fMaterialTracker;
|
||||
}
|
||||
|
||||
inline G4Material* DetectorConstruction::GetMaterialEmCalo() const {
|
||||
return fMaterialEmCalo;
|
||||
}
|
||||
|
||||
inline G4Material* DetectorConstruction::GetMaterialHadCalo() const {
|
||||
return fMaterialHadCalo;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetInnerRadiusTracker() const {
|
||||
return fInnerRadiusTracker;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetInnerRadiusTracker( const G4double value ) {
|
||||
fInnerRadiusTracker = value;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetOuterRadiusTracker() const {
|
||||
return fOuterRadiusTracker;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetOuterRadiusTracker( const G4double value ) {
|
||||
fOuterRadiusTracker = value;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetInnerRadiusEmCalo() const {
|
||||
return fInnerRadiusEmCalo;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetInnerRadiusEmCalo( const G4double value ) {
|
||||
fInnerRadiusEmCalo = value;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetOuterRadiusEmCalo() const {
|
||||
return fOuterRadiusEmCalo;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetOuterRadiusEmCalo( const G4double value ) {
|
||||
fOuterRadiusEmCalo = value;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetInnerRadiusHadCalo() const {
|
||||
return fInnerRadiusHadCalo;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetInnerRadiusHadCalo( const G4double value ) {
|
||||
fInnerRadiusHadCalo = value;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetOuterRadiusHadCalo() const {
|
||||
return fOuterRadiusHadCalo;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetOuterRadiusHadCalo( const G4double value ) {
|
||||
fOuterRadiusHadCalo = value;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetScoringThickness() const {
|
||||
return fScoringThickness;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorMessenger.hh
|
||||
/// \brief Definition of the DetectorMessenger class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef DetectorMessenger_h
|
||||
#define DetectorMessenger_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class DetectorConstruction;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithADoubleAndUnit;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithoutParameter;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class DetectorMessenger: public G4UImessenger {
|
||||
public:
|
||||
DetectorMessenger( DetectorConstruction* );
|
||||
~DetectorMessenger();
|
||||
void SetNewValue( G4UIcommand*, G4String ) override;
|
||||
private:
|
||||
DetectorConstruction* fDetector;
|
||||
G4UIdirectory* fDetectorDir;
|
||||
G4UIcmdWithAString* fMaterialTracker;
|
||||
G4UIcmdWithAString* fMaterialEmCalo;
|
||||
G4UIcmdWithAString* fMaterialHadCalo;
|
||||
G4UIcmdWithADoubleAndUnit* fInnerRadiusTracker;
|
||||
G4UIcmdWithADoubleAndUnit* fOuterRadiusTracker;
|
||||
G4UIcmdWithADoubleAndUnit* fInnerRadiusEmCalo;
|
||||
G4UIcmdWithADoubleAndUnit* fOuterRadiusEmCalo;
|
||||
G4UIcmdWithADoubleAndUnit* fInnerRadiusHadCalo;
|
||||
G4UIcmdWithADoubleAndUnit* fOuterRadiusHadCalo;
|
||||
G4UIcmdWithoutParameter* fUpdateCommand;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 PrimaryGeneratorAction.hh
|
||||
/// \brief Definition of the PrimaryGeneratorAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef PrimaryGeneratorAction_h
|
||||
#define PrimaryGeneratorAction_h 1
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class G4ParticleGun;
|
||||
class G4Event;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
|
||||
public:
|
||||
PrimaryGeneratorAction();
|
||||
~PrimaryGeneratorAction();
|
||||
void GeneratePrimaries( G4Event* anEvent ) override;
|
||||
void SetGunPosition() const;
|
||||
private:
|
||||
G4ParticleGun* fParticleGun;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 Run.hh
|
||||
/// \brief Definition of the Run class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef Run_h
|
||||
#define Run_h 1
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include <array>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class Run : public G4Run {
|
||||
// This class accumulates relevant quantities related to particle fluence collected during
|
||||
// the run.
|
||||
// ( Note: these information are provided via calls of accessor methods of this Run class
|
||||
// made by SteppingAction::UserSteppingAction. )
|
||||
// At the end of a run, the printInfo method is called by the run-action to print out
|
||||
// some summary information about these quantities.
|
||||
// In multithreaded (MT) mode, an object of this class is filled up for each working thread,
|
||||
// and then merged (automatically by the Geant4 kernel) into another object (of this class)
|
||||
// owned by the master class; the printInfo method is then called only for the latter run
|
||||
// object.
|
||||
// Note that, for simplicity and brevity, we avoid histograms and print-out instead some
|
||||
// statistics (compute by ourself) at the end of the run.
|
||||
public:
|
||||
Run();
|
||||
~Run();
|
||||
|
||||
virtual void RecordEvent( const G4Event* anEvent ) override;
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) at the end
|
||||
// of each event. In the case of multithreaded mode, it is called only for the working thread
|
||||
// that handled that event.
|
||||
|
||||
virtual void Merge( const G4Run* aRun ) override;
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) only in the
|
||||
// case of multithreaded mode and only for working threads.
|
||||
|
||||
void printInfo() const;
|
||||
// This method is called by RunAction::EndOfRunAction : in the case of multithreaded mode,
|
||||
// only the master thread calls it.
|
||||
|
||||
void setPrimaryParticleId( const G4int inputValue ) { fPrimaryParticleId = inputValue; }
|
||||
void setPrimaryParticleEnergy( const G4double inputValue )
|
||||
{ fPrimaryParticleEnergy = inputValue; }
|
||||
void setPrimaryParticleDirection( const G4ThreeVector &inputValue )
|
||||
{ fPrimaryParticleDirection = inputValue; }
|
||||
void setTrackerMaterialName( const G4String &inputValue )
|
||||
{ fTrackerMaterialName = inputValue; }
|
||||
void setEmCaloMaterialName( const G4String &inputValue )
|
||||
{ fEmCaloMaterialName = inputValue; }
|
||||
void setHadCaloMaterialName( const G4String &inputValue )
|
||||
{ fHadCaloMaterialName = inputValue; }
|
||||
void setCubicVolumeScoringTrackerShell( const G4double inputValue )
|
||||
{ fCubicVolumeScoringTrackerShell = inputValue; }
|
||||
void setCubicVolumeScoringEmCaloShell( const G4double inputValue )
|
||||
{ fCubicVolumeScoringEmCaloShell = inputValue; }
|
||||
void setCubicVolumeScoringHadCaloShell( const G4double inputValue )
|
||||
{ fCubicVolumeScoringHadCaloShell = inputValue; }
|
||||
G4int getPrimaryParticleId() const { return fPrimaryParticleId; }
|
||||
G4double getPrimaryParticleEnergy() const { return fPrimaryParticleEnergy; }
|
||||
G4ThreeVector getPrimaryParticleDirection() const { return fPrimaryParticleDirection; }
|
||||
G4String getTrackerMaterialName() const { return fTrackerMaterialName; }
|
||||
G4String getEmCaloMaterialName() const { return fEmCaloMaterialName; }
|
||||
G4String getHadCaloMaterialName() const { return fHadCaloMaterialName; }
|
||||
G4double getCubicVolumeScoringTrackerShell() const { return fCubicVolumeScoringTrackerShell; }
|
||||
G4double getCubicVolumeScoringEmCaloShell() const { return fCubicVolumeScoringEmCaloShell; }
|
||||
G4double getCubicVolumeScoringHadCaloShell() const { return fCubicVolumeScoringHadCaloShell; }
|
||||
void setArray( const std::array< G4double, SteppingAction::numberCombinations >& inputArray );
|
||||
std::array< G4double, SteppingAction::numberCombinations > getArray() const { return fArray; }
|
||||
// Accessor methods useful to transfer information collected by the stepping-action
|
||||
// into this Run class
|
||||
|
||||
private:
|
||||
G4int fNumEvents;
|
||||
G4int fPrimaryParticleId;
|
||||
G4double fPrimaryParticleEnergy;
|
||||
G4ThreeVector fPrimaryParticleDirection;
|
||||
G4String fTrackerMaterialName;
|
||||
G4String fEmCaloMaterialName;
|
||||
G4String fHadCaloMaterialName;
|
||||
G4double fCubicVolumeScoringTrackerShell;
|
||||
G4double fCubicVolumeScoringEmCaloShell;
|
||||
G4double fCubicVolumeScoringHadCaloShell;
|
||||
std::array< G4double, SteppingAction::numberCombinations > fArray;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 RunAction.hh
|
||||
/// \brief Definition of the RunAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef RunAction_h
|
||||
#define RunAction_h
|
||||
|
||||
#include "G4UserRunAction.hh"
|
||||
|
||||
class G4Run;
|
||||
class SteppingAction;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class RunAction: public G4UserRunAction {
|
||||
public:
|
||||
RunAction( SteppingAction* steppingAction = nullptr );
|
||||
virtual ~RunAction();
|
||||
virtual void BeginOfRunAction( const G4Run* aRun ) override;
|
||||
virtual void EndOfRunAction( const G4Run* aRun ) override;
|
||||
virtual G4Run* GenerateRun() override;
|
||||
private:
|
||||
SteppingAction* fSteppingAction;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 SteppingAction.hh
|
||||
/// \brief Definition of the SteppingAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef SteppingAction_H
|
||||
#define SteppingAction_H 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UserSteppingAction.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include <array>
|
||||
|
||||
class Run;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class SteppingAction : public G4UserSteppingAction {
|
||||
public:
|
||||
SteppingAction();
|
||||
virtual ~SteppingAction();
|
||||
|
||||
virtual void UserSteppingAction( const G4Step* ) override;
|
||||
// This is the main method where the step lengths of particles inside
|
||||
// the scoring shell are collected, and then the corresponding fluences
|
||||
// are filled up in the Run object where they are stored (and then
|
||||
// printed out at the end of the Run).
|
||||
// (For simplicity and brevity, we avoid histograms and compute instead
|
||||
// some statistics ourself, which will be print-out at the end of the run.)
|
||||
|
||||
void initialize();
|
||||
// This method is called by RunAction::BeginOfRunAction for the
|
||||
// initialization of the stepping-action at the beginning of each Run.
|
||||
// This is necessary because different runs can have different primary particle
|
||||
// types, kinetic energies, and detector configurations.
|
||||
|
||||
void setRunPointer( Run* inputValue = nullptr ) { fRunPtr = inputValue; }
|
||||
// This method is called by RunAction::BeginOfRunAction for providing to the
|
||||
// stepping-action the pointer to the run object at the beginning of each Run.
|
||||
// This pointer is then used to pass the information collected by the stepping-action
|
||||
// to the run object.
|
||||
|
||||
G4double getCubicVolumeScoringTrackerShell() const { return fCubicVolumeScoringTrackerShell; }
|
||||
G4double getCubicVolumeScoringEmCaloShell() const { return fCubicVolumeScoringEmCaloShell; }
|
||||
G4double getCubicVolumeScoringHadCaloShell() const { return fCubicVolumeScoringHadCaloShell; }
|
||||
// Needed to get the fluence from the sum of step lengths
|
||||
|
||||
static const G4int numberScoringShells = 3; // tracker, emCalo, hadCalo
|
||||
static const G4int numberKinematicRegions = 3; // all, below 20 MeV, above 20 MeV
|
||||
static const G4int numberScoringPositions = 2; // forward, backward (hemisphere, with respect
|
||||
// to the primary particle direction)
|
||||
static const G4int numberParticleTypes = 11; // all, e, gamma, mu, nu, pi, n, p, ions,
|
||||
// other-mesons, other-baryons
|
||||
static const G4int numberCombinations =
|
||||
numberScoringShells*numberKinematicRegions*numberScoringPositions*numberParticleTypes;
|
||||
static const std::array< G4String, numberScoringShells > arrayScoringShellNames;
|
||||
static const std::array< G4String, numberKinematicRegions > arrayKinematicRegionNames;
|
||||
static const std::array< G4String, numberScoringPositions > arrayScoringPositionNames;
|
||||
static const std::array< G4String, numberParticleTypes > arrayParticleTypeNames;
|
||||
static G4int getIndex( const G4int iScoringShell, const G4int iKinematicRegion,
|
||||
const G4int iScoringPosition, const G4int iParticleType );
|
||||
|
||||
private:
|
||||
Run* fRunPtr; // Pointer to the Run object
|
||||
G4int fPrimaryParticleId;
|
||||
G4double fPrimaryParticleEnergy;
|
||||
G4ThreeVector fPrimaryParticleDirection;
|
||||
G4String fTrackerMaterialName;
|
||||
G4String fEmCaloMaterialName;
|
||||
G4String fHadCaloMaterialName;
|
||||
G4bool fIsFirstStepOfTheEvent;
|
||||
G4bool fIsFirstStepInTracker;
|
||||
G4bool fIsFirstStepInScoringTrackerShell;
|
||||
G4double fCubicVolumeScoringTrackerShell;
|
||||
G4bool fIsFirstStepInEmCalo;
|
||||
G4bool fIsFirstStepInScoringEmCaloShell;
|
||||
G4double fCubicVolumeScoringEmCaloShell;
|
||||
G4bool fIsFirstStepInHadCalo;
|
||||
G4bool fIsFirstStepInScoringHadCaloShell;
|
||||
G4double fCubicVolumeScoringHadCaloShell;
|
||||
|
||||
std::array< G4double, numberCombinations > fArraySumStepLengths;
|
||||
// Array to collect the sum of step lengths in the scoring shells for the whole run,
|
||||
// according to the various cases (scoring shell, kinematical region, scoring position
|
||||
// and particle type).
|
||||
// Note that the fluence in a scoring volume is defined as sum of step lengths
|
||||
// in that scoring volume divided by the cubic-volume of that scoring volume.
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
#
|
||||
/mydet/material_tracker G4_lAr
|
||||
/mydet/inner_radius_tracker 5.0 cm
|
||||
/mydet/outer_radius_tracker 25.0 cm
|
||||
#
|
||||
/mydet/material_emCalo G4_Pb
|
||||
/mydet/inner_radius_emCalo 30.0 cm
|
||||
/mydet/outer_radius_emCalo 60.0 cm
|
||||
#
|
||||
/mydet/material_hadCalo G4_Fe
|
||||
/mydet/inner_radius_hadCalo 70.0 cm
|
||||
/mydet/outer_radius_hadCalo 170.0 cm
|
||||
#
|
||||
/run/initialize
|
||||
#
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
#
|
||||
/run/beamOn 100
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
#
|
||||
/mydet/material_tracker G4_POLYSTYRENE
|
||||
/mydet/inner_radius_tracker 5.0 cm
|
||||
/mydet/outer_radius_tracker 25.0 cm
|
||||
#
|
||||
/mydet/material_emCalo G4_PbWO4
|
||||
/mydet/inner_radius_emCalo 30.0 cm
|
||||
/mydet/outer_radius_emCalo 60.0 cm
|
||||
#
|
||||
/mydet/material_hadCalo G4_Cu
|
||||
/mydet/inner_radius_hadCalo 70.0 cm
|
||||
/mydet/outer_radius_hadCalo 170.0 cm
|
||||
#
|
||||
/run/initialize
|
||||
#
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
#
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,23 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
#
|
||||
/mydet/material_tracker G4_Si
|
||||
/mydet/inner_radius_tracker 5.0 cm
|
||||
/mydet/outer_radius_tracker 25.0 cm
|
||||
#
|
||||
/mydet/material_emCalo G4_W
|
||||
/mydet/inner_radius_emCalo 30.0 cm
|
||||
/mydet/outer_radius_emCalo 60.0 cm
|
||||
#
|
||||
/mydet/material_hadCalo G4_W
|
||||
/mydet/inner_radius_hadCalo 70.0 cm
|
||||
/mydet/outer_radius_hadCalo 170.0 cm
|
||||
#
|
||||
/run/initialize
|
||||
#
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
#
|
||||
/run/beamOn 100
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 ActionInitialization.cc
|
||||
/// \brief Implementation of the ActionInitialization class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::ActionInitialization() : G4VUserActionInitialization() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::~ActionInitialization() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const {
|
||||
// This is NOT called in SEQ-mode, while in the MT-mode is called only for the Master thread.
|
||||
SetUserAction( new RunAction );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::Build() const {
|
||||
// This is called in the SEQ-mode and in the MT-mode only for Worker threads.
|
||||
SetUserAction( new PrimaryGeneratorAction );
|
||||
SteppingAction* steppingAction = new SteppingAction;
|
||||
SetUserAction( steppingAction );
|
||||
SetUserAction( new RunAction( steppingAction ) );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+409
@@ -0,0 +1,409 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorConstruction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "DetectorMessenger.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction() :
|
||||
fMaterialTracker( nullptr ), fMaterialEmCalo( nullptr ), fMaterialHadCalo( nullptr ),
|
||||
fExperimentalHall_log( nullptr ), fExperimentalHall_phys( nullptr ),
|
||||
fLogicTrackerShell( nullptr), fPhysiTrackerShell( nullptr ),
|
||||
fLogicEmCaloShell( nullptr), fPhysiEmCaloShell( nullptr),
|
||||
fLogicHadCaloShell( nullptr), fPhysiHadCaloShell( nullptr),
|
||||
fLogicScoringTrackerShell( nullptr), fPhysiScoringTrackerShell( nullptr ),
|
||||
fLogicScoringEmCaloShell( nullptr), fPhysiScoringEmCaloShell( nullptr),
|
||||
fLogicScoringHadCaloShell( nullptr), fPhysiScoringHadCaloShell( nullptr),
|
||||
fDetectorMessenger( nullptr ),
|
||||
fInnerRadiusTracker( 10.0*cm ), fOuterRadiusTracker( 20.0*cm ), //***LOOKHERE*** Default radii
|
||||
fInnerRadiusEmCalo( 30.0*cm ), fOuterRadiusEmCalo( 60.0*cm ),
|
||||
fInnerRadiusHadCalo( 70.0*cm ), fOuterRadiusHadCalo( 170.0*cm )
|
||||
{
|
||||
//G4cout << " BEGIN DetectorConstruction::DetectorConstruction()" << G4endl;
|
||||
fMaterialTracker = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Si" ); //***LOOKHERE***
|
||||
// Default material
|
||||
fMaterialEmCalo = G4NistManager::Instance()->FindOrBuildMaterial( "G4_PbWO4" );
|
||||
fMaterialHadCalo = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Fe" );
|
||||
fDetectorMessenger = new DetectorMessenger( this );
|
||||
//G4cout << " END DetectorConstruction::DetectorConstruction()" << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::~DetectorConstruction() {
|
||||
delete fDetectorMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct() {
|
||||
//G4cout << " BEGIN DetectorConstruction::Construct()" << G4endl;
|
||||
return ConstructDetector();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::ConstructDetector() {
|
||||
//G4cout << " BEGIN DetectorConstruction::ConstructDetector()" << G4endl;
|
||||
|
||||
// Clean old geometry, if any.
|
||||
G4GeometryManager::GetInstance()->OpenGeometry();
|
||||
|
||||
G4PhysicalVolumeStore::GetInstance()->Clean();
|
||||
G4LogicalVolumeStore::GetInstance()->Clean();
|
||||
G4SolidStore::GetInstance()->Clean();
|
||||
|
||||
// Check that the radii are resonable
|
||||
G4bool isOK = true;
|
||||
if ( fInnerRadiusTracker < 0.0 ||
|
||||
fOuterRadiusTracker < fInnerRadiusTracker ||
|
||||
fInnerRadiusEmCalo < fOuterRadiusTracker + fScoringThickness ||
|
||||
fOuterRadiusEmCalo < fInnerRadiusEmCalo ||
|
||||
fInnerRadiusHadCalo < fOuterRadiusEmCalo + fScoringThickness ||
|
||||
fOuterRadiusHadCalo < fInnerRadiusHadCalo ) {
|
||||
isOK = false;
|
||||
}
|
||||
if ( ! isOK ) {
|
||||
G4cerr << G4endl << "ERROR: the radii are inconsistent !" << G4endl
|
||||
<< " InnerRadiusTracker = " << fInnerRadiusTracker << " mm" << G4endl
|
||||
<< " OuterRadiusTracker = " << fOuterRadiusTracker << " mm" << G4endl
|
||||
<< " InnerRadiusEmCalo = " << fInnerRadiusEmCalo << " mm" << G4endl
|
||||
<< " OuterRadiusEmCalo = " << fOuterRadiusEmCalo << " mm" << G4endl
|
||||
<< " InnerRadiusHadCalo = " << fInnerRadiusHadCalo << " mm" << G4endl
|
||||
<< " OuterRadiusHadCalo = " << fOuterRadiusHadCalo << " mm" << G4endl
|
||||
<< " ScoringThickness = " << fScoringThickness << " mm" << G4endl
|
||||
<< G4endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The detector consists of 3 concentric full spherical shells (G4Sphere),
|
||||
// positioned at the center, (0.0, 0.0, 0.0).
|
||||
// The world volume (experimental hall) is a box 10% bigger than the outmost
|
||||
// spherical shell.
|
||||
// and it is filled of "G4_Galactic" material.
|
||||
|
||||
G4double expHall_x = 1.1*fOuterRadiusHadCalo; // half dimension along x
|
||||
G4double expHall_y = 1.1*fOuterRadiusHadCalo; // half dimension along y
|
||||
G4double expHall_z = 1.1*fOuterRadiusHadCalo; // half dimension along z
|
||||
|
||||
G4Material* vacuum = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Galactic" );
|
||||
|
||||
G4Box* experimentalHall_box = new G4Box( "expHall_box", expHall_x, expHall_y, expHall_z );
|
||||
|
||||
fExperimentalHall_log = new G4LogicalVolume( experimentalHall_box, // solid
|
||||
vacuum, // material
|
||||
"expHall_log", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
|
||||
fExperimentalHall_phys = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"expHall", // name
|
||||
fExperimentalHall_log, // logical volume
|
||||
0, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// 1st (innermost) spherical shell: Tracker
|
||||
G4Sphere* solidTrackerShell = new G4Sphere( "solidTrackerShell", // name
|
||||
fInnerRadiusTracker, // Inner radius
|
||||
fOuterRadiusTracker, // Outer radius
|
||||
0.0, // Starting Phi angle of the
|
||||
// segment in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the
|
||||
// segment in radians
|
||||
0.0, // Starting Theta angle of
|
||||
// the segment in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the
|
||||
// segment in radians
|
||||
fLogicTrackerShell = new G4LogicalVolume( solidTrackerShell, // solid
|
||||
fMaterialTracker, // material
|
||||
"logicTrackerShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiTrackerShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiTrackerShell", // name
|
||||
fLogicTrackerShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// Scoring tracker shell (a thin vacuum layer, immediately outside the Tracker shell)
|
||||
G4Sphere* solidScoringTrackerShell =
|
||||
new G4Sphere( "solidScoringTrackerShell", // name
|
||||
fOuterRadiusTracker, // Inner radius
|
||||
fOuterRadiusTracker + fScoringThickness, // Outer radius
|
||||
0.0, // Starting Phi angle of the segment
|
||||
// in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the segment
|
||||
// in radians
|
||||
0.0, // Starting Theta angle of the segment
|
||||
// in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the segment
|
||||
// in radians
|
||||
fLogicScoringTrackerShell = new G4LogicalVolume( solidScoringTrackerShell, // solid
|
||||
vacuum, // material
|
||||
"logicScoringTrackerShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive
|
||||
// detector
|
||||
0 ); // user limits
|
||||
fPhysiScoringTrackerShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiScoringTrackerShell", // name
|
||||
fLogicScoringTrackerShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical
|
||||
// volume
|
||||
false, // boolean
|
||||
// operation
|
||||
0 ); // copy number
|
||||
|
||||
// 2nd (middle) spherical shell: EM Calo
|
||||
G4Sphere* solidEmCaloShell = new G4Sphere( "solidEmCaloShell", // name
|
||||
fInnerRadiusEmCalo, // Inner radius
|
||||
fOuterRadiusEmCalo, // Outer radius
|
||||
0.0, // Starting Phi angle of the
|
||||
// segment in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the
|
||||
// segment in radians
|
||||
0.0, // Starting Theta angle of the
|
||||
// segment in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the
|
||||
// segment in radians
|
||||
fLogicEmCaloShell = new G4LogicalVolume( solidEmCaloShell, // solid
|
||||
fMaterialEmCalo, // material
|
||||
"logicEmCaloShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiEmCaloShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiEmCaloShell", // name
|
||||
fLogicEmCaloShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// Scoring EmCalo shell (a thin vacuum layer, immediately outside the EmCalo shell)
|
||||
G4Sphere* solidScoringEmCaloShell =
|
||||
new G4Sphere( "solidScoringEmCaloShell", // name
|
||||
fOuterRadiusEmCalo, // Inner radius
|
||||
fOuterRadiusEmCalo + fScoringThickness, // Outer radius
|
||||
0.0, // Starting Phi angle of the segment
|
||||
// in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the segment
|
||||
// in radians
|
||||
0.0, // Starting Theta angle of the
|
||||
// segment in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the segment
|
||||
// in radians
|
||||
fLogicScoringEmCaloShell = new G4LogicalVolume( solidScoringEmCaloShell, // solid
|
||||
vacuum, // material
|
||||
"logicScoringEmCaloShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive
|
||||
// detector
|
||||
0 ); // user limits
|
||||
fPhysiScoringEmCaloShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiScoringEmCaloShell", // name
|
||||
fLogicScoringEmCaloShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical
|
||||
// volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// 3rd (outmost) spherical shell: HAD Calo
|
||||
G4Sphere* solidHadCaloShell = new G4Sphere( "solidHadCaloShell", // name
|
||||
fInnerRadiusHadCalo, // Inner radius
|
||||
fOuterRadiusHadCalo, // Outer radius
|
||||
0.0, // Starting Phi angle of the
|
||||
// segment in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the
|
||||
// segment in radians
|
||||
0.0, // Starting Theta angle of
|
||||
// the segment in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the
|
||||
// segment in radians
|
||||
fLogicHadCaloShell = new G4LogicalVolume( solidHadCaloShell, // solid
|
||||
fMaterialHadCalo, // material
|
||||
"logicHadCaloShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiHadCaloShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiHadCaloShell", // name
|
||||
fLogicHadCaloShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// Scoring HadCalo shell (a thin vacuum layer, immediately outside the HadCalo shell)
|
||||
G4Sphere* solidScoringHadCaloShell =
|
||||
new G4Sphere( "solidScoringHadCaloShell", // name
|
||||
fOuterRadiusHadCalo, // Inner radius
|
||||
fOuterRadiusHadCalo + fScoringThickness, // Outer radius
|
||||
0.0, // Starting Phi angle of the
|
||||
// segment in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the segment
|
||||
// in radians
|
||||
0.0, // Starting Theta angle of the
|
||||
// segment in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the segment
|
||||
// in radians
|
||||
fLogicScoringHadCaloShell = new G4LogicalVolume( solidScoringHadCaloShell, // solid
|
||||
vacuum, // material
|
||||
"logicScoringHadCaloShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive
|
||||
// detector
|
||||
0 ); // user limits
|
||||
fPhysiScoringHadCaloShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiScoringHadCaloShell", // name
|
||||
fLogicScoringHadCaloShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical
|
||||
// volume
|
||||
false, // boolean
|
||||
// operation
|
||||
0 ); // copy number
|
||||
|
||||
G4cout << "DetectorConstruction::ConstructSphere() : " << G4endl
|
||||
<< "\t World (box) size: " << G4endl
|
||||
<< "\t \t x : -/+ " << expHall_x << " mm ;"
|
||||
<< "\t y : -/+ " << expHall_y << " mm ;"
|
||||
<< "\t z : -/+ " << expHall_z << " mm ;" << G4endl
|
||||
<< G4endl;
|
||||
PrintParameters();
|
||||
//G4cout << " END DetectorConstruction::ConstructDetector()
|
||||
|
||||
return fExperimentalHall_phys;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMaterialTracker( const G4String name ) {
|
||||
fMaterialTracker = G4NistManager::Instance()->FindOrBuildMaterial( name );
|
||||
if ( ! fMaterialTracker ) {
|
||||
G4cout << G4endl << G4endl
|
||||
<< "WARNING: the name of the material has not been recognized!" << G4endl
|
||||
<< " ===> the default * G4_Si * will be used."
|
||||
<< G4endl << G4endl;
|
||||
fMaterialTracker = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Si" );
|
||||
}
|
||||
if ( fLogicTrackerShell ) fLogicTrackerShell->SetMaterial( fMaterialTracker );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMaterialEmCalo( const G4String name ) {
|
||||
fMaterialEmCalo = G4NistManager::Instance()->FindOrBuildMaterial( name );
|
||||
if ( ! fMaterialEmCalo ) {
|
||||
G4cout << G4endl << G4endl
|
||||
<< "WARNING: the name of the material has not been recognized!" << G4endl
|
||||
<< " ===> the default * G4_Pb * will be used."
|
||||
<< G4endl << G4endl;
|
||||
fMaterialEmCalo = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Pb" );
|
||||
}
|
||||
if ( fLogicEmCaloShell ) fLogicEmCaloShell->SetMaterial( fMaterialEmCalo );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMaterialHadCalo( const G4String name ) {
|
||||
fMaterialHadCalo = G4NistManager::Instance()->FindOrBuildMaterial( name );
|
||||
if ( fMaterialHadCalo == nullptr ) {
|
||||
G4cout << G4endl << G4endl
|
||||
<< "WARNING: the name of the material has not been recognized!" << G4endl
|
||||
<< " ===> the default * G4_Fe * will be used."
|
||||
<< G4endl << G4endl;
|
||||
fMaterialHadCalo = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Fe" );
|
||||
}
|
||||
if ( fLogicHadCaloShell ) fLogicHadCaloShell->SetMaterial( fMaterialHadCalo );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::UpdateGeometry() {
|
||||
//G4cout << " BEGIN DetectorConstruction::UpdateGeometry" << G4endl;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
PrintParameters();
|
||||
// Update also the position of the gun
|
||||
const PrimaryGeneratorAction* pPrimaryAction =
|
||||
dynamic_cast< const PrimaryGeneratorAction* >
|
||||
( G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction() );
|
||||
if ( pPrimaryAction ) pPrimaryAction->SetGunPosition();
|
||||
//G4cout << " END DetectorConstruction::UpdateGeometry" << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::PrintParameters() {
|
||||
G4cout << G4endl
|
||||
<< " ------ DetectorConstruction::PrintParameters() ------ " << G4endl
|
||||
<< " MaterialTracker = " << fMaterialTracker->GetName() << G4endl
|
||||
<< " MaterialEmCalo = " << fMaterialEmCalo->GetName() << G4endl
|
||||
<< " MaterialHadCalo = " << fMaterialHadCalo->GetName() << G4endl
|
||||
<< " InnerRadiusTracker = " << fInnerRadiusTracker << " mm" << G4endl
|
||||
<< " OuterRadiusTracker = " << fOuterRadiusTracker << " mm" << G4endl
|
||||
<< " InnerRadiusEmCalo = " << fInnerRadiusEmCalo << " mm" << G4endl
|
||||
<< " OuterRadiusEmCalo = " << fOuterRadiusEmCalo << " mm" << G4endl
|
||||
<< " InnerRadiusHadCalo = " << fInnerRadiusHadCalo << " mm" << G4endl
|
||||
<< " OuterRadiusHadCalo = " << fOuterRadiusHadCalo << " mm" << G4endl
|
||||
<< " ScoringThickness = " << fScoringThickness << " mm" << G4endl
|
||||
<< " -------------------------------------------------------- " << G4endl
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorMessenger.cc
|
||||
/// \brief Implementation of the DetectorMessenger class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorMessenger.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::DetectorMessenger( DetectorConstruction* myDet ) : fDetector( myDet ) {
|
||||
fDetectorDir = new G4UIdirectory( "/mydet/" );
|
||||
fDetectorDir->SetGuidance( "Detector control." );
|
||||
|
||||
fMaterialTracker = new G4UIcmdWithAString( "/mydet/material_tracker", this );
|
||||
fMaterialTracker->SetGuidance( "Choice of the material for the Tracker:" );
|
||||
fMaterialTracker->SetGuidance( " a Geant4 NIST material, e.g. G4_Si " );
|
||||
fMaterialTracker->SetParameterName( "choiceMaterial", true );
|
||||
fMaterialTracker->SetDefaultValue( "G4_Si" );
|
||||
fMaterialTracker->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fMaterialEmCalo = new G4UIcmdWithAString( "/mydet/material_emCalo", this );
|
||||
fMaterialEmCalo->SetGuidance( "Choice of the material for the EM calo:" );
|
||||
fMaterialEmCalo->SetGuidance( " a Geant4 NIST material, e.g. G4_Pb " );
|
||||
fMaterialEmCalo->SetParameterName( "choiceMaterial", true );
|
||||
fMaterialEmCalo->SetDefaultValue( "G4_Pb" );
|
||||
fMaterialEmCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fMaterialHadCalo = new G4UIcmdWithAString( "/mydet/material_hadCalo", this );
|
||||
fMaterialHadCalo->SetGuidance( "Choice of the material for the HAD calo:" );
|
||||
fMaterialHadCalo->SetGuidance( " a Geant4 NIST material, e.g. G4_Fe " );
|
||||
fMaterialHadCalo->SetParameterName( "choiceMaterial", true );
|
||||
fMaterialHadCalo->SetDefaultValue( "G4_Fe" );
|
||||
fMaterialHadCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fInnerRadiusTracker = new G4UIcmdWithADoubleAndUnit( "/mydet/inner_radius_tracker", this );
|
||||
fInnerRadiusTracker->SetParameterName( "choiceInnerRadiusTracker", true );
|
||||
fInnerRadiusTracker->SetGuidance( "Inner radius of the Tracker" );
|
||||
fInnerRadiusTracker->SetDefaultValue( 100.0 ); // default: 10 cm.
|
||||
fInnerRadiusTracker->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fOuterRadiusTracker = new G4UIcmdWithADoubleAndUnit( "/mydet/outer_radius_tracker", this );
|
||||
fOuterRadiusTracker->SetParameterName( "choiceOuterRadiusTracker", true );
|
||||
fOuterRadiusTracker->SetGuidance( "Outer radius of the Tracker" );
|
||||
fOuterRadiusTracker->SetDefaultValue( 200.0 ); // default: 20 cm.
|
||||
fOuterRadiusTracker->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fInnerRadiusEmCalo = new G4UIcmdWithADoubleAndUnit( "/mydet/inner_radius_emCalo", this );
|
||||
fInnerRadiusEmCalo->SetParameterName( "choiceInnerRadiusEmCalo", true );
|
||||
fInnerRadiusEmCalo->SetGuidance( "Inner radius of the EM Calo" );
|
||||
fInnerRadiusEmCalo->SetDefaultValue( 300.0 ); // default: 30 cm.
|
||||
fInnerRadiusEmCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fOuterRadiusEmCalo = new G4UIcmdWithADoubleAndUnit( "/mydet/outer_radius_emCalo", this );
|
||||
fOuterRadiusEmCalo->SetParameterName( "choiceOuterRadiusEmCalo", true );
|
||||
fOuterRadiusEmCalo->SetGuidance( "Outer radius of the EM Calo" );
|
||||
fOuterRadiusEmCalo->SetDefaultValue( 600.0 ); // default: 60 cm.
|
||||
fOuterRadiusEmCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fInnerRadiusHadCalo = new G4UIcmdWithADoubleAndUnit( "/mydet/inner_radius_hadCalo", this );
|
||||
fInnerRadiusHadCalo->SetParameterName( "choiceInnerRadiusHadCalo", true );
|
||||
fInnerRadiusHadCalo->SetGuidance( "Inner radius of the HAD Calo" );
|
||||
fInnerRadiusHadCalo->SetDefaultValue( 700.0 ); // default: 70 cm.
|
||||
fInnerRadiusHadCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fOuterRadiusHadCalo = new G4UIcmdWithADoubleAndUnit( "/mydet/outer_radius_hadCalo", this );
|
||||
fOuterRadiusHadCalo->SetParameterName( "choiceOuterRadiusHadCalo", true );
|
||||
fOuterRadiusHadCalo->SetGuidance( "Outer radius of the HAD Calo" );
|
||||
fOuterRadiusHadCalo->SetDefaultValue( 1700.0 ); // default: 170 cm.
|
||||
fOuterRadiusHadCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fUpdateCommand = new G4UIcmdWithoutParameter( "/mydet/update", this);
|
||||
fUpdateCommand->SetGuidance( "Update geometry." );
|
||||
fUpdateCommand->SetGuidance( "This command MUST be applied before \"beamOn\" " );
|
||||
fUpdateCommand->SetGuidance( "if you changed geometrical value(s)." );
|
||||
fUpdateCommand->AvailableForStates( G4State_Idle );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::~DetectorMessenger() {
|
||||
delete fDetectorDir;
|
||||
delete fMaterialTracker;
|
||||
delete fMaterialEmCalo;
|
||||
delete fMaterialHadCalo;
|
||||
delete fInnerRadiusTracker;
|
||||
delete fOuterRadiusTracker;
|
||||
delete fInnerRadiusEmCalo;
|
||||
delete fOuterRadiusEmCalo;
|
||||
delete fInnerRadiusHadCalo;
|
||||
delete fOuterRadiusHadCalo;
|
||||
delete fUpdateCommand;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorMessenger::SetNewValue( G4UIcommand* command, G4String newValue ) {
|
||||
if ( command == fMaterialTracker ) {
|
||||
fDetector->SetMaterialTracker( newValue );
|
||||
}
|
||||
if ( command == fMaterialEmCalo ) {
|
||||
fDetector->SetMaterialEmCalo( newValue );
|
||||
}
|
||||
if ( command == fMaterialHadCalo ) {
|
||||
fDetector->SetMaterialHadCalo( newValue );
|
||||
}
|
||||
if ( command == fInnerRadiusTracker ) {
|
||||
fDetector->SetInnerRadiusTracker( fInnerRadiusTracker->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fOuterRadiusTracker ) {
|
||||
fDetector->SetOuterRadiusTracker( fOuterRadiusTracker->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fInnerRadiusEmCalo ) {
|
||||
fDetector->SetInnerRadiusEmCalo( fInnerRadiusEmCalo->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fOuterRadiusEmCalo ) {
|
||||
fDetector->SetOuterRadiusEmCalo( fOuterRadiusEmCalo->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fInnerRadiusHadCalo ) {
|
||||
fDetector->SetInnerRadiusHadCalo( fInnerRadiusHadCalo->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fOuterRadiusHadCalo ) {
|
||||
fDetector->SetOuterRadiusHadCalo( fOuterRadiusHadCalo->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fUpdateCommand ) {
|
||||
fDetector->UpdateGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction() : G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun( nullptr ) {
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun( n_particle );
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
//***LOOKHERE*** Default particle and energy
|
||||
fParticleGun->SetParticleDefinition( particleTable->FindParticle( "geantino" ) );
|
||||
fParticleGun->SetParticleEnergy( 10.0*GeV );
|
||||
SetGunPosition();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction() {
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::SetGunPosition() const {
|
||||
// Shoot the particle from the center of the sphere
|
||||
fParticleGun->SetParticlePosition( G4ThreeVector( 0.0, 0.0, 0.0 ) );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::GeneratePrimaries( G4Event* anEvent ) {
|
||||
G4ThreeVector v( 0.0, 0.0, 1.0 ); //***LOOKHERE*** default shoot along the z-axis
|
||||
fParticleGun->SetParticleMomentumDirection( v );
|
||||
fParticleGun->GeneratePrimaryVertex( anEvent );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,154 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 Run.cc
|
||||
/// \brief Implementation of the Run class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "Run.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::Run() : G4Run(), fNumEvents( 0 ),
|
||||
fPrimaryParticleId( 0 ), fPrimaryParticleEnergy( 0.0 ),
|
||||
fPrimaryParticleDirection( G4ThreeVector( 0.0, 0.0, 0.0 ) ),
|
||||
fTrackerMaterialName( "" ), fEmCaloMaterialName( "" ), fHadCaloMaterialName( "" ),
|
||||
fCubicVolumeScoringTrackerShell( 1.0 ), fCubicVolumeScoringEmCaloShell( 1.0 ),
|
||||
fCubicVolumeScoringHadCaloShell( 1.0 )
|
||||
{
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) fArray[i] = 0.0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::~Run() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::RecordEvent( const G4Event* anEvent ) {
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) at the end
|
||||
// of each event : in MT-mode, it is called only for the working thread that handled the event.
|
||||
G4int nEvt = anEvent->GetEventID();
|
||||
if ( nEvt % 10 == 0 ) G4cout << " Event#=" << nEvt << G4endl;
|
||||
G4Run::RecordEvent( anEvent );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Merge( const G4Run* aRun ) {
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) only in the case
|
||||
// of multithreaded mode and only for working threads.
|
||||
const Run* localRun = static_cast< const Run* >( aRun );
|
||||
fPrimaryParticleId = localRun->getPrimaryParticleId();
|
||||
fPrimaryParticleEnergy = localRun->getPrimaryParticleEnergy();
|
||||
fPrimaryParticleDirection = localRun->getPrimaryParticleDirection();
|
||||
fTrackerMaterialName = localRun->getTrackerMaterialName();
|
||||
fEmCaloMaterialName = localRun->getEmCaloMaterialName();
|
||||
fHadCaloMaterialName = localRun->getHadCaloMaterialName();
|
||||
fCubicVolumeScoringTrackerShell = localRun->getCubicVolumeScoringTrackerShell();
|
||||
fCubicVolumeScoringEmCaloShell = localRun->getCubicVolumeScoringEmCaloShell();
|
||||
fCubicVolumeScoringHadCaloShell = localRun->getCubicVolumeScoringHadCaloShell();
|
||||
fNumEvents += localRun->GetNumberOfEvent();
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) {
|
||||
fArray[i] += localRun->getArray()[i];
|
||||
}
|
||||
G4Run::Merge( aRun );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::printInfo() const {
|
||||
// This method is called by RunAction::EndOfRunAction.
|
||||
// In MT-mode, only the master thread calls it.
|
||||
const G4double floatingNumberOfEvents =
|
||||
std::max( 1.0, fNumEvents > 0 ? fNumEvents*1.0 : GetNumberOfEvent()*1.0 );
|
||||
// The fluence in a scoring shell is defined as sum of step lengths in that shell
|
||||
// divided by the cubic-volume of the scoring shell.
|
||||
const G4double conversionFactor = CLHEP::cm * CLHEP::cm; // From mm^-2 to cm^-2
|
||||
const G4double factorTracker =
|
||||
conversionFactor / ( 0.5*fCubicVolumeScoringTrackerShell*floatingNumberOfEvents );
|
||||
const G4double factorEmCalo =
|
||||
conversionFactor / ( 0.5*fCubicVolumeScoringEmCaloShell*floatingNumberOfEvents );
|
||||
const G4double factorHadCalo =
|
||||
conversionFactor / ( 0.5*fCubicVolumeScoringHadCaloShell*floatingNumberOfEvents );
|
||||
G4cout << std::setprecision(6) << G4endl << G4endl
|
||||
<< " =============== Run::printInfo() =============== \t RunID = " << GetRunID()
|
||||
<< G4endl
|
||||
<< " Primary particle PDG code = " << fPrimaryParticleId << G4endl
|
||||
<< " Primary particle kinetic energy = " << fPrimaryParticleEnergy / CLHEP::GeV
|
||||
<< " GeV" << G4endl
|
||||
<< " Primary particle direction = " << fPrimaryParticleDirection << G4endl
|
||||
<< " Tracker material = " << fTrackerMaterialName << G4endl
|
||||
<< " EmCalo material = " << fEmCaloMaterialName << G4endl
|
||||
<< " HadCalo material = " << fHadCaloMaterialName << G4endl
|
||||
<< " Cubic-volume scoring tracker shell = " << fCubicVolumeScoringTrackerShell
|
||||
<< " mm^3" << G4endl
|
||||
<< " Cubic-volume scoring emCalo shell = " << fCubicVolumeScoringEmCaloShell
|
||||
<< " mm^3" << G4endl
|
||||
<< " Cubic-volume scoring hadCalo shell = " << fCubicVolumeScoringHadCaloShell
|
||||
<< " mm^3" << G4endl
|
||||
<< " Number of events = " << floatingNumberOfEvents << G4endl
|
||||
<< " Conversion factor: fluence from mm^-2 to cm^-2 = " << conversionFactor << G4endl
|
||||
<< " Particle fluence in unit of cm^-2 :" << G4endl;
|
||||
for ( G4int i = 0; i < SteppingAction::numberScoringShells; ++i ) {
|
||||
G4double factor = factorTracker;
|
||||
if ( i == 1 ) factor = factorEmCalo;
|
||||
else if ( i == 2 ) factor = factorHadCalo;
|
||||
for ( G4int j = 0; j < SteppingAction::numberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < SteppingAction::numberScoringPositions; ++k ) {
|
||||
for ( G4int ll = 0; ll < SteppingAction::numberParticleTypes; ++ll ) {
|
||||
G4int index = SteppingAction::getIndex( i, j, k, ll );
|
||||
//G4cout << "(i, j, k, ll)=(" << i << ", " << j << ", " << k << ", "
|
||||
// << ll << ") ->" << index;
|
||||
G4cout << " case=" << std::setw(3) << index
|
||||
<< " " << std::setw(12) << SteppingAction::arrayScoringShellNames[i]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayKinematicRegionNames[j]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayScoringPositionNames[k]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayParticleTypeNames[ll]
|
||||
<< " " << factor*fArray[index] << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
G4cout << " ============================================================= " << G4endl << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::setArray( const std::array< G4double,
|
||||
SteppingAction::numberCombinations >& inputArray ) {
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) {
|
||||
fArray[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+75
@@ -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 RunAction.cc
|
||||
/// \brief Implementation of the RunAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "Run.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction( SteppingAction* steppingAction ) :
|
||||
G4UserRunAction(), fSteppingAction( steppingAction ) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::~RunAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4Run* RunAction::GenerateRun() {
|
||||
return new Run;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction( const G4Run* aRun ) {
|
||||
G4cout << "### Run " << aRun->GetRunID() << " starts." << G4endl;
|
||||
if ( fSteppingAction ) {
|
||||
fSteppingAction->initialize();
|
||||
Run* run = const_cast< Run* >( static_cast< const Run* >( aRun ) );
|
||||
if ( run != nullptr ) fSteppingAction->setRunPointer( run );
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction( const G4Run* aRun ) {
|
||||
const Run* run = static_cast< const Run* >( aRun );
|
||||
if ( run == nullptr || run->GetNumberOfEvent() == 0 ) return;
|
||||
if ( IsMaster() ) run->printInfo();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 SteppingAction.cc
|
||||
/// \brief Implementation of the SteppingAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "SteppingAction.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4LossTableManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
const std::array< G4String, SteppingAction::numberScoringShells >
|
||||
SteppingAction::arrayScoringShellNames = { "tracker", "emCalo", "hadCalo" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberKinematicRegions >
|
||||
SteppingAction::arrayKinematicRegionNames = { "", "below 20 MeV", "above 20 MeV" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberScoringPositions >
|
||||
SteppingAction::arrayScoringPositionNames = { "forward", "backward" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberParticleTypes >
|
||||
SteppingAction::arrayParticleTypeNames = { "all", "electron", "gamma", "muon", "neutrino",
|
||||
"pion", "neutron", "proton", "ion", "otherMeson",
|
||||
"otherBaryon" };
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4int SteppingAction::getIndex( const G4int iScoringShell, const G4int iKinematicRegion,
|
||||
const G4int iScoringPosition, const G4int iParticleType ) {
|
||||
G4int index = -1;
|
||||
if ( iScoringShell >= 0 && iScoringShell < numberScoringShells &&
|
||||
iKinematicRegion >= 0 && iKinematicRegion < numberKinematicRegions &&
|
||||
iScoringPosition >= 0 && iScoringPosition < numberScoringPositions &&
|
||||
iParticleType >= 0 && iParticleType < numberParticleTypes ) {
|
||||
index = iScoringShell * numberKinematicRegions * numberScoringPositions * numberParticleTypes +
|
||||
iKinematicRegion * numberScoringPositions * numberParticleTypes +
|
||||
iScoringPosition * numberParticleTypes +
|
||||
iParticleType;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction() :G4UserSteppingAction() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::~SteppingAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::initialize() {
|
||||
// Initialization needed at the beginning of each Run
|
||||
fPrimaryParticleId = 0;
|
||||
fPrimaryParticleEnergy = 0.0;
|
||||
fPrimaryParticleDirection = G4ThreeVector( 0.0, 0.0, 1.0 );
|
||||
fTrackerMaterialName = fEmCaloMaterialName = fHadCaloMaterialName = "";
|
||||
fIsFirstStepOfTheEvent = true;
|
||||
fIsFirstStepInTracker = fIsFirstStepInEmCalo = fIsFirstStepInHadCalo = true;
|
||||
fIsFirstStepInScoringTrackerShell = fIsFirstStepInScoringEmCaloShell =
|
||||
fIsFirstStepInScoringHadCaloShell = true;
|
||||
fCubicVolumeScoringTrackerShell = fCubicVolumeScoringEmCaloShell =
|
||||
fCubicVolumeScoringHadCaloShell = 1.0;
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) {
|
||||
fArraySumStepLengths[i] = 0.0;
|
||||
}
|
||||
/*
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) fArraySumStepLengths[i] = 999.9;
|
||||
G4cout << " numberCombinations=" << numberCombinations << G4endl;
|
||||
for ( G4int i = 0; i < numberScoringShells; ++i ) {
|
||||
for ( G4int j = 0; j < numberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < numberScoringPositions; ++k ) {
|
||||
for ( G4int ll = 0; ll < numberParticleTypes; ++ll ) {
|
||||
G4int index = getIndex( i, j, k, ll );
|
||||
G4cout << "(i, j, k, ll)=(" << i << ", " << j << ", " << k << ", "
|
||||
<< ll << ") ->" << index;
|
||||
if ( fArraySumStepLengths[ index ] < 1.0 ) G4cout << " <=== REPEATED!";
|
||||
else fArraySumStepLengths[ index ] = 0.0;
|
||||
G4cout << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) {
|
||||
if ( fArraySumStepLengths[i] > 999.0 ) G4cout << " i=" << i << " NOT COVERED !" << G4endl;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
// Get information on the primary particle
|
||||
if ( fIsFirstStepOfTheEvent ) {
|
||||
if ( theStep->GetTrack()->GetParentID() == 0 ) {
|
||||
fPrimaryParticleId = theStep->GetTrack()->GetDefinition()->GetPDGEncoding();
|
||||
fPrimaryParticleEnergy = theStep->GetPreStepPoint()->GetKineticEnergy();
|
||||
fPrimaryParticleDirection = theStep->GetPreStepPoint()->GetMomentumDirection();
|
||||
if ( fRunPtr ) {
|
||||
fRunPtr->setPrimaryParticleId( fPrimaryParticleId );
|
||||
fRunPtr->setPrimaryParticleEnergy( fPrimaryParticleEnergy );
|
||||
fRunPtr->setPrimaryParticleDirection( fPrimaryParticleDirection );
|
||||
}
|
||||
fIsFirstStepOfTheEvent = false;
|
||||
}
|
||||
}
|
||||
// Get information on the materials
|
||||
if ( fIsFirstStepInTracker &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiTrackerShell" ) {
|
||||
fTrackerMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->setTrackerMaterialName( fTrackerMaterialName );
|
||||
fIsFirstStepInTracker = false;
|
||||
}
|
||||
if ( fIsFirstStepInEmCalo &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiEmCaloShell" ) {
|
||||
fEmCaloMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->setEmCaloMaterialName( fEmCaloMaterialName );
|
||||
fIsFirstStepInEmCalo = false;
|
||||
}
|
||||
if ( fIsFirstStepInHadCalo &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiHadCaloShell" ) {
|
||||
fHadCaloMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->setHadCaloMaterialName( fHadCaloMaterialName );
|
||||
fIsFirstStepInHadCalo = false;
|
||||
}
|
||||
// Get information on step lengths in the scoring shells
|
||||
G4int iScoringShell = -1;
|
||||
if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ==
|
||||
"physiScoringTrackerShell" ) {
|
||||
iScoringShell = 0;
|
||||
if ( fIsFirstStepInScoringTrackerShell ) {
|
||||
fCubicVolumeScoringTrackerShell =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringTrackerShell( fCubicVolumeScoringTrackerShell );
|
||||
fIsFirstStepInScoringTrackerShell = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ==
|
||||
"physiScoringEmCaloShell" ) {
|
||||
iScoringShell = 1;
|
||||
if ( fIsFirstStepInScoringEmCaloShell ) {
|
||||
fCubicVolumeScoringEmCaloShell =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringEmCaloShell( fCubicVolumeScoringEmCaloShell );
|
||||
fIsFirstStepInScoringEmCaloShell = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ==
|
||||
"physiScoringHadCaloShell" ) {
|
||||
iScoringShell = 2;
|
||||
if ( fIsFirstStepInScoringHadCaloShell ) {
|
||||
fCubicVolumeScoringHadCaloShell =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringHadCaloShell( fCubicVolumeScoringHadCaloShell );
|
||||
fIsFirstStepInScoringHadCaloShell = false;
|
||||
}
|
||||
}
|
||||
if ( iScoringShell >= 0 ) {
|
||||
G4double stepLength = theStep->GetTrack()->GetStepLength() * theStep->GetTrack()->GetWeight();
|
||||
G4int absPdg = theStep->GetTrack()->GetDefinition() == nullptr ? 0 :
|
||||
std::abs( theStep->GetTrack()->GetDefinition()->GetPDGEncoding() );
|
||||
/*
|
||||
G4cout << theStep->GetTrack()->GetDefinition()->GetParticleName() << " absPdg=" << absPdg
|
||||
<< " Ekin[MeV]=" << theStep->GetPreStepPoint()->GetKineticEnergy()
|
||||
<< " r[mm]=" << theStep->GetTrack()->GetPosition().mag()
|
||||
<< " z[mm]=" << theStep->GetTrack()->GetPosition().z()
|
||||
<< " " << theStep->GetTrack()->GetVolume()->GetName()
|
||||
<< " " << theStep->GetTrack()->GetMaterial()->GetName()
|
||||
<< " L[mm]=" << stepLength << " "
|
||||
<< ( fPrimaryParticleDirection.dot( theStep->GetTrack()->GetPosition().unit() ) > 0.0
|
||||
? "forward" : "backward" ) << G4endl;
|
||||
*/
|
||||
// Three kinematical regions: [0] : any value ; [1] : below 20 MeV ; [2] : above 20 MeV
|
||||
G4int iKinematicRegion = theStep->GetPreStepPoint()->GetKineticEnergy() < 20.0 ? 1 : 2;
|
||||
// Two scoring positions: [0] : forward hemisphere ; [1] : backward hemisphere
|
||||
// (with respect to the primary particle initial direction)
|
||||
G4int iScoringPosition =
|
||||
fPrimaryParticleDirection.dot( theStep->GetTrack()->GetPosition().unit() ) > 0.0 ? 0 : 1;
|
||||
G4int iParticleType = -1;
|
||||
if ( absPdg == 11 ) iParticleType = 1; // electron (and positron)
|
||||
else if ( absPdg == 22 ) iParticleType = 2; // gamma
|
||||
else if ( absPdg == 13 ) iParticleType = 3; // muons (mu- and mu+)
|
||||
else if ( absPdg == 12 || absPdg == 14 || absPdg == 16 ) iParticleType = 4; // neutrinos
|
||||
// (and anti-neutrinos), all flavors
|
||||
else if ( absPdg == 111 || absPdg == 211 ) iParticleType = 5; // (charged) pions
|
||||
else if ( absPdg == 2112 ) iParticleType = 6; // neutron (and anti-neutron)
|
||||
else if ( absPdg == 2212 ) iParticleType = 7; // proton (and anti-proton)
|
||||
else if ( G4IonTable::IsIon( theStep->GetTrack()->GetDefinition() ) || // ions (and anti-ions)
|
||||
G4IonTable::IsAntiIon( theStep->GetTrack()->GetDefinition() ) ) iParticleType = 8;
|
||||
else if ( absPdg < 1000 ) iParticleType = 9; // other mesons (e.g. kaons) (Note: this works
|
||||
// in most cases, but not always!)
|
||||
else if ( absPdg > 1000 ) iParticleType = 10; // other baryons (e.g. hyperons, anti-hyperons,
|
||||
// etc.)
|
||||
// Consider the specific case : scoring shell, kinematic region, scoring position, and
|
||||
// particle type
|
||||
G4int index = getIndex( iScoringShell, iKinematicRegion, iScoringPosition, iParticleType );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "all" particle case, with the same scoring shell, kinematic region and
|
||||
// scoring position
|
||||
index = getIndex( iScoringShell, iKinematicRegion, iScoringPosition, 0 );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region case, with the same scoring shell, scoring position
|
||||
// and particle type
|
||||
index = getIndex( iScoringShell, 0, iScoringPosition, iParticleType );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region and "all" particle, with the same scoring shell and
|
||||
// scoring position
|
||||
index = getIndex( iScoringShell, 0, iScoringPosition, 0 );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
if ( fRunPtr ) fRunPtr->setArray( fArraySumStepLengths );
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,10 @@
|
||||
# Example ParticleFluence 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!
|
||||
|
||||
|
||||
## 2021-06-10 Alberto Ribon (exhadrParticleFluence-V11-00-00)
|
||||
- Created this example.
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
///\file "hadronic/ParticleFluence/Layer/.README.txt"
|
||||
///\brief Example ParticleFluence/Layer README page
|
||||
|
||||
/*! \page ExampeParticleFluenceLayer Example Layer
|
||||
|
||||
In this example, the particle fluence is evaluated for a simple set-up,
|
||||
consisting of one target solid cylinder, with axis along the z-direction,
|
||||
and a beam particle shot before the target along the axis of the target.
|
||||
|
||||
The particle fluence is computed in three places: "upstream", "downstream"
|
||||
and "side", defined as the positions immediately after, before and aside,
|
||||
respectively, of the target with respect to the direction of the primary
|
||||
particle.
|
||||
|
||||
The particle fluence is estimated by summing the track length in a
|
||||
"scoring volume" - i.e. a thin cylinder (for "upstream" and "downstream"
|
||||
cases) or a thin hemisphere shell (for the "side" case) filled up with
|
||||
G4_Galactic (very low density gas) material, immediately outside the
|
||||
target - and then dividing for the cubic volume of such scoring volume.
|
||||
|
||||
The particle fluence is evaluated for the following 11 particle types:
|
||||
- all
|
||||
- electron + positron
|
||||
- gamma
|
||||
- muon- + muon+
|
||||
- neutrino (any flavour and including anti-neutrino)
|
||||
- charged pions
|
||||
- neutron + anti_neutron
|
||||
- proton + anti_proton
|
||||
- ion (and anti-ions)
|
||||
- otherMeson (e.g. kaons, etc.)
|
||||
- otherBaryon (e.g. hyperons, etc.)
|
||||
|
||||
The particle fluence is evaluated for the following 3 kinematical ranges:
|
||||
- any kinetic energy
|
||||
- kinetic energy < 20 MeV
|
||||
- kinetic energy > 20 MeV
|
||||
|
||||
Look for the string "***LOOKHERE***" for those parameters/options that
|
||||
are either hardwired in the code (i.e. not available via UI command),
|
||||
or default values of UI commands.
|
||||
|
||||
This example uses the physics list factory, therefore you can specify
|
||||
the reference physics list you want to use via the PHYSLIST
|
||||
environmental variable (by default, if you don't set it, the FTFP_BERT
|
||||
physics list is used).
|
||||
|
||||
To build this example:
|
||||
|
||||
mkdir Build; cd Build
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DGeant4_DIR=/path-to-geant4-libraries ../.
|
||||
make
|
||||
|
||||
To run it:
|
||||
|
||||
./Layer all_together.g4
|
||||
|
||||
which shoots 50 GeV pion- on different target materials, 100 events
|
||||
in each run, and print out some information on the particle fluence
|
||||
at the end of each run.
|
||||
Other macros exist for specific materials.
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,65 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# Setup the project
|
||||
cmake_minimum_required(VERSION 3.16...3.21)
|
||||
project(Layer)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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 executable, and link it to the Geant4 libraries
|
||||
#
|
||||
add_executable(Layer Layer.cc ${sources} ${headers})
|
||||
target_link_libraries(Layer ${Geant4_LIBRARIES} )
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Copy all scripts to the build directory, so that we can run the executable
|
||||
# directly there.
|
||||
#
|
||||
set(SCRIPTS
|
||||
all_together.g4
|
||||
cu.g4
|
||||
fe.g4
|
||||
graphite.g4
|
||||
lar.g4
|
||||
pb.g4
|
||||
pbwo4.g4
|
||||
polystyrene.g4
|
||||
si.g4
|
||||
w.g4
|
||||
)
|
||||
|
||||
foreach(_script ${SCRIPTS})
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/${_script}
|
||||
${PROJECT_BINARY_DIR}/${_script}
|
||||
COPYONLY
|
||||
)
|
||||
endforeach()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
|
||||
#
|
||||
install(TARGETS Layer DESTINATION bin)
|
||||
@@ -0,0 +1,11 @@
|
||||
name := Layer
|
||||
G4TARGET := $(name)
|
||||
G4EXLIB := true
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
.PHONY: all
|
||||
|
||||
all: lib bin
|
||||
|
||||
include $(G4INSTALL)/config/binmake.gmk
|
||||
@@ -0,0 +1,10 @@
|
||||
# Example ParticleFluence 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!
|
||||
|
||||
|
||||
## 2021-06-10 Alberto Ribon (exhadrParticleFluenceLayer-V11-00-00)
|
||||
- Created the Layer variant of the ParticleFluence example.
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 Layer.cc
|
||||
/// \brief Main program of the hadronic/ParticleFluence/Layer example
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4Threading.hh"
|
||||
#include "G4RunManagerFactory.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4PhysListFactory.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
int main(int argc,char** argv) {
|
||||
|
||||
auto* runManager = G4RunManagerFactory::CreateRunManager();
|
||||
|
||||
DetectorConstruction* pDetectorInstance = new DetectorConstruction;
|
||||
runManager->SetUserInitialization( pDetectorInstance );
|
||||
|
||||
// Physics list factory: use the PHYSLIST environmental variable.
|
||||
G4PhysListFactory factory;
|
||||
G4VModularPhysicsList* thePL = factory.ReferencePhysList();
|
||||
|
||||
runManager->SetUserInitialization( thePL );
|
||||
runManager->SetUserInitialization( new ActionInitialization( pDetectorInstance ) );
|
||||
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if ( argc==1 ) { // Define UI session for interactive mode.
|
||||
} else { // Batch mode
|
||||
G4String command = "/control/execute ";
|
||||
G4String fileName = argv[1];
|
||||
UI->ApplyCommand(command+fileName);
|
||||
}
|
||||
|
||||
// job termination
|
||||
delete runManager;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,57 @@
|
||||
In this example, the particle fluence is evaluated for a simple set-up,
|
||||
consisting of one target solid cylinder, with axis along the z-direction,
|
||||
and a beam particle shot before the target along the axis of the target.
|
||||
|
||||
The particle fluence is computed in three places: "upstream", "downstream"
|
||||
and "side", defined as the positions immediately after, before and aside,
|
||||
respectively, of the target with respect to the direction of the primary
|
||||
particle.
|
||||
|
||||
The particle fluence is estimated by summing the track length in a
|
||||
"scoring volume" - i.e. a thin cylinder (for "upstream" and "downstream"
|
||||
cases) or a thin hemisphere shell (for the "side" case) filled up with
|
||||
G4_Galactic (very low density gas) material, immediately outside the
|
||||
target - and then dividing for the cubic volume of such scoring volume.
|
||||
|
||||
The particle fluence is evaluated for the following 11 particle types:
|
||||
- all
|
||||
- electron + positron
|
||||
- gamma
|
||||
- muon- + muon+
|
||||
- neutrino (any flavour and including anti-neutrino)
|
||||
- charged pions
|
||||
- neutron + anti_neutron
|
||||
- proton + anti_proton
|
||||
- ion (and anti-ions)
|
||||
- otherMeson (e.g. kaons, etc.)
|
||||
- otherBaryon (e.g. hyperons, etc.)
|
||||
|
||||
The particle fluence is evaluated for the following 3 kinematical ranges:
|
||||
- any kinetic energy
|
||||
- kinetic energy < 20 MeV
|
||||
- kinetic energy > 20 MeV
|
||||
|
||||
Look for the string "***LOOKHERE***" for those parameters/options that
|
||||
are either hardwired in the code (i.e. not available via UI command),
|
||||
or default values of UI commands.
|
||||
|
||||
This example uses the physics list factory, therefore you can specify
|
||||
the reference physics list you want to use via the PHYSLIST
|
||||
environmental variable (by default, if you don't set it, the FTFP_BERT
|
||||
physics list is used).
|
||||
|
||||
To build this example:
|
||||
|
||||
mkdir Build; cd Build
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DGeant4_DIR=/path-to-geant4-libraries ../.
|
||||
make
|
||||
|
||||
To run it:
|
||||
|
||||
./Layer all_together.g4
|
||||
|
||||
which shoots 50 GeV pion- on different target materials, 100 events
|
||||
in each run, and print out some information on the particle fluence
|
||||
at the end of each run.
|
||||
Other macros exist for specific materials.
|
||||
@@ -0,0 +1,62 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
#
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
#
|
||||
/mydet/material G4_POLYSTYRENE
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_GRAPHITE
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_Si
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_lAr
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_Fe
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_Cu
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_W
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_Pb
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_PbWO4
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_Cu
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_Fe
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,11 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_GRAPHITE
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 ActionInitialization.hh
|
||||
/// \brief Definition of the ActionInitialization class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ActionInitialization_h
|
||||
#define ActionInitialization_h 1
|
||||
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
|
||||
class DetectorConstruction;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ActionInitialization : public G4VUserActionInitialization {
|
||||
public:
|
||||
ActionInitialization( const DetectorConstruction* inputDetectorConstruction = nullptr );
|
||||
virtual ~ActionInitialization();
|
||||
virtual void BuildForMaster() const override;
|
||||
virtual void Build() const override;
|
||||
private:
|
||||
const DetectorConstruction* fPtrDetectorConstruction = nullptr;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorConstruction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef DetectorConstruction_H
|
||||
#define DetectorConstruction_H 1
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4LogicalVolume;
|
||||
class G4VPhysicalVolume;
|
||||
class G4Material;
|
||||
class DetectorMessenger;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class DetectorConstruction : public G4VUserDetectorConstruction {
|
||||
public:
|
||||
DetectorConstruction();
|
||||
~DetectorConstruction();
|
||||
|
||||
G4VPhysicalVolume* Construct();
|
||||
|
||||
void SetMaterial( const G4String name );
|
||||
inline G4Material* GetMaterial() const;
|
||||
inline void SetThickness( const G4double value );
|
||||
inline G4double GetThickness() const;
|
||||
inline void SetDiameter( const G4double value );
|
||||
inline G4double GetDiameter() const;
|
||||
void UpdateGeometry();
|
||||
private:
|
||||
G4VPhysicalVolume* ConstructLayer(); // To be invoked each time the geometry needs to be
|
||||
// updated.
|
||||
void PrintParameters();
|
||||
G4Material* fMaterial;
|
||||
G4LogicalVolume* fExperimentalHall_log;
|
||||
G4VPhysicalVolume* fExperimentalHall_phys;
|
||||
G4LogicalVolume* fLogicLayer;
|
||||
G4VPhysicalVolume* fPhysiLayer;
|
||||
G4LogicalVolume* fLogicScoringUpDown;
|
||||
G4VPhysicalVolume* fPhysiScoringUpstream;
|
||||
G4VPhysicalVolume* fPhysiScoringDownstream;
|
||||
G4LogicalVolume* fLogicScoringSide;
|
||||
G4VPhysicalVolume* fPhysiScoringSide;
|
||||
DetectorMessenger* fDetectorMessenger;
|
||||
G4double fThickness;
|
||||
G4double fDiameter;
|
||||
const G4double fScoringThickness = 10.0; //***LOOKHERE*** thickness of the scoring shell
|
||||
};
|
||||
|
||||
inline G4Material* DetectorConstruction::GetMaterial() const {
|
||||
return fMaterial;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetThickness( const G4double value ) {
|
||||
fThickness = value;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetThickness() const {
|
||||
return fThickness;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetDiameter( const G4double value ) {
|
||||
fDiameter = value;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetDiameter() const {
|
||||
return fDiameter;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorMessenger.hh
|
||||
/// \brief Definition of the DetectorMessenger class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef DetectorMessenger_h
|
||||
#define DetectorMessenger_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class DetectorConstruction;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithADoubleAndUnit;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithoutParameter;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class DetectorMessenger: public G4UImessenger {
|
||||
public:
|
||||
DetectorMessenger( DetectorConstruction* );
|
||||
~DetectorMessenger();
|
||||
void SetNewValue( G4UIcommand*, G4String ) override;
|
||||
private:
|
||||
DetectorConstruction* fDetector;
|
||||
G4UIdirectory* fDetectorDir;
|
||||
G4UIcmdWithAString* fMaterial;
|
||||
G4UIcmdWithADoubleAndUnit* fThickness;
|
||||
G4UIcmdWithADoubleAndUnit* fDiameter;
|
||||
G4UIcmdWithoutParameter* fUpdateCommand;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 PrimaryGeneratorAction.hh
|
||||
/// \brief Definition of the PrimaryGeneratorAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef PrimaryGeneratorAction_h
|
||||
#define PrimaryGeneratorAction_h 1
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class G4ParticleGun;
|
||||
class G4Event;
|
||||
class DetectorConstruction;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
|
||||
public:
|
||||
PrimaryGeneratorAction( const DetectorConstruction* );
|
||||
~PrimaryGeneratorAction();
|
||||
void GeneratePrimaries( G4Event* anEvent ) override;
|
||||
void SetGunPosition() const;
|
||||
private:
|
||||
G4ParticleGun* fParticleGun;
|
||||
const DetectorConstruction* fPointerDetectorConstruction = nullptr;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 Run.hh
|
||||
/// \brief Definition of the Run class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef Run_h
|
||||
#define Run_h 1
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include <array>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class Run : public G4Run {
|
||||
// This class accumulates relevant quantities related to particle fluence collected during
|
||||
// the run.
|
||||
// ( Note: these information are provided via calls of accessor methods of this Run class
|
||||
// made by SteppingAction::UserSteppingAction. )
|
||||
// At the end of a run, the printInfo method is called by the run-action to print out
|
||||
// some summary information about these quantities.
|
||||
// In multithreaded (MT) mode, an object of this class is filled up for each working thread,
|
||||
// and then merged (automatically by the Geant4 kernel) into another object (of this class)
|
||||
// owned by the master class; the printInfo method is then called only for the latter run
|
||||
// object.
|
||||
// Note that, for simplicity and brevity, we avoid histograms and print-out instead some
|
||||
// statistics (compute by ourself) at the end of the run.
|
||||
public:
|
||||
Run();
|
||||
~Run();
|
||||
|
||||
virtual void RecordEvent( const G4Event* anEvent ) override;
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) at the end
|
||||
// of each event. In the case of multithreaded mode, it is called only for the working thread
|
||||
// that handled that event.
|
||||
|
||||
virtual void Merge( const G4Run* aRun ) override;
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) only in the
|
||||
// case of multithreaded mode and only for working threads.
|
||||
|
||||
void printInfo() const;
|
||||
// This method is called by RunAction::EndOfRunAction : in the case of multithreaded mode,
|
||||
// only the master thread calls it.
|
||||
|
||||
void setPrimaryParticleId( const G4int inputValue ) { fPrimaryParticleId = inputValue; }
|
||||
void setPrimaryParticleEnergy( const G4double inputValue )
|
||||
{ fPrimaryParticleEnergy = inputValue; }
|
||||
void setPrimaryParticleDirection( const G4ThreeVector &inputValue )
|
||||
{ fPrimaryParticleDirection = inputValue; }
|
||||
void setTargetMaterialName( const G4String &inputValue ) { fTargetMaterialName = inputValue; }
|
||||
void setCubicVolumeScoringUpDown( const G4double inputValue )
|
||||
{ fCubicVolumeScoringUpDown = inputValue; }
|
||||
void setCubicVolumeScoringSide( const G4double inputValue )
|
||||
{ fCubicVolumeScoringSide = inputValue; }
|
||||
G4int getPrimaryParticleId() const { return fPrimaryParticleId; }
|
||||
G4double getPrimaryParticleEnergy() const { return fPrimaryParticleEnergy; }
|
||||
G4ThreeVector getPrimaryParticleDirection() const { return fPrimaryParticleDirection; }
|
||||
G4String getTargetMaterialName() const { return fTargetMaterialName; }
|
||||
G4double getCubicVolumeScoringUpDown() const { return fCubicVolumeScoringUpDown; }
|
||||
G4double getCubicVolumeScoringSide() const { return fCubicVolumeScoringSide; }
|
||||
void setArray( const std::array< G4double, SteppingAction::numberCombinations >& inputArray );
|
||||
std::array< G4double, SteppingAction::numberCombinations > getArray() const { return fArray; }
|
||||
// Accessor methods useful to transfer information collected by the stepping-action
|
||||
// into this Run class
|
||||
|
||||
private:
|
||||
G4int fNumEvents;
|
||||
G4int fPrimaryParticleId;
|
||||
G4double fPrimaryParticleEnergy;
|
||||
G4ThreeVector fPrimaryParticleDirection;
|
||||
G4String fTargetMaterialName;
|
||||
G4double fCubicVolumeScoringUpDown;
|
||||
G4double fCubicVolumeScoringSide;
|
||||
std::array< G4double, SteppingAction::numberCombinations > fArray;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 RunAction.hh
|
||||
/// \brief Definition of the RunAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef RunAction_h
|
||||
#define RunAction_h
|
||||
|
||||
#include "G4UserRunAction.hh"
|
||||
|
||||
class G4Run;
|
||||
class SteppingAction;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class RunAction: public G4UserRunAction {
|
||||
public:
|
||||
RunAction( SteppingAction* steppingAction = nullptr );
|
||||
virtual ~RunAction();
|
||||
virtual void BeginOfRunAction( const G4Run* aRun ) override;
|
||||
virtual void EndOfRunAction( const G4Run* aRun ) override;
|
||||
virtual G4Run* GenerateRun() override;
|
||||
private:
|
||||
SteppingAction* fSteppingAction;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 SteppingAction.hh
|
||||
/// \brief Definition of the SteppingAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef SteppingAction_H
|
||||
#define SteppingAction_H 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UserSteppingAction.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include <array>
|
||||
|
||||
class Run;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class SteppingAction : public G4UserSteppingAction {
|
||||
public:
|
||||
SteppingAction();
|
||||
virtual ~SteppingAction();
|
||||
|
||||
virtual void UserSteppingAction( const G4Step* ) override;
|
||||
// This is the main method where the step lengths of particles inside
|
||||
// the scoring volumes are collected, and then the corresponding fluences
|
||||
// are filled up in the Run object where they are stored (and then
|
||||
// printed out at the end of the Run).
|
||||
// (For simplicity and brevity, we avoid histograms and compute instead
|
||||
// some statistics ourself, which will be print-out at the end of the run.)
|
||||
|
||||
void initialize();
|
||||
// This method is called by RunAction::BeginOfRunAction for the
|
||||
// initialization of the stepping-action at the beginning of each Run.
|
||||
// This is necessary because different runs can have different primary particle
|
||||
// types, kinetic energies, and detector configurations.
|
||||
|
||||
void setRunPointer( Run* inputValue = nullptr ) { fRunPtr = inputValue; }
|
||||
// This method is called by RunAction::BeginOfRunAction for providing to the
|
||||
// stepping-action the pointer to the run object at the beginning of each Run.
|
||||
// This pointer is then used to pass the information collected by the stepping-action
|
||||
// to the run object.
|
||||
|
||||
G4double getCubicVolumeScoringUpDown() const { return fCubicVolumeScoringUpDown; }
|
||||
G4double getCubicVolumeScoringSide() const { return fCubicVolumeScoringSide; }
|
||||
// The cubic-volumes of the scoring volumes are needed to get the fluence from
|
||||
// the sum of step lengths in those scoring volumes.
|
||||
// Notice that two of the three scoring volumes - upstream and downstream -
|
||||
// have the same cubic-volume, that we call "fCubicVolumeScoringUpDown".
|
||||
|
||||
static const G4int numberScoringVolumes = 3; // downstream, side, upstream
|
||||
static const G4int numberKinematicRegions = 3; // all, below 20 MeV, above 20 MeV
|
||||
static const G4int numberParticleTypes = 11; // all, e, gamma, mu, nu, pi, n, p, ions,
|
||||
// other-mesons, other-baryons
|
||||
static const G4int numberCombinations =
|
||||
numberScoringVolumes*numberKinematicRegions*numberParticleTypes;
|
||||
static const std::array< G4String, numberScoringVolumes > arrayScoringVolumeNames;
|
||||
static const std::array< G4String, numberKinematicRegions > arrayKinematicRegionNames;
|
||||
static const std::array< G4String, numberParticleTypes > arrayParticleTypeNames;
|
||||
static G4int getIndex( const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType );
|
||||
|
||||
private:
|
||||
Run* fRunPtr; // Pointer to the Run object
|
||||
G4int fPrimaryParticleId;
|
||||
G4double fPrimaryParticleEnergy;
|
||||
G4ThreeVector fPrimaryParticleDirection;
|
||||
G4String fTargetMaterialName;
|
||||
G4bool fIsFirstStepOfTheEvent;
|
||||
G4bool fIsFirstStepInTarget;
|
||||
G4bool fIsFirstStepInScoringUpDown;
|
||||
G4bool fIsFirstStepInScoringSide;
|
||||
G4double fCubicVolumeScoringUpDown;
|
||||
G4double fCubicVolumeScoringSide;
|
||||
|
||||
std::array< G4double, numberCombinations > fArraySumStepLengths;
|
||||
// Array to collect the sum of step lengths in the scoring volumes for the whole run,
|
||||
// according to the various cases (kinematical region and particle type).
|
||||
// Note that the fluence in a scoring volume is defined as sum of step lengths
|
||||
// in that scoring volume divided by the cubic-volume of that scoring volume.
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_lAr
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_Pb
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,11 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_PbWO4
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,11 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_POLYSTYRENE
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_Si
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
@@ -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 ActionInitialization.cc
|
||||
/// \brief Implementation of the ActionInitialization class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::ActionInitialization( const DetectorConstruction*
|
||||
inputDetectorConstruction ) :
|
||||
G4VUserActionInitialization(), fPtrDetectorConstruction( inputDetectorConstruction ) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::~ActionInitialization() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const {
|
||||
// This is NOT called in SEQ-mode, while in the MT-mode is called only for the Master thread.
|
||||
SetUserAction( new RunAction );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::Build() const {
|
||||
// This is called in the SEQ-mode and in the MT-mode only for Worker threads.
|
||||
SetUserAction( new PrimaryGeneratorAction( fPtrDetectorConstruction ) );
|
||||
SteppingAction* steppingAction = new SteppingAction;
|
||||
SetUserAction( steppingAction );
|
||||
SetUserAction( new RunAction( steppingAction ) );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorConstruction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "DetectorMessenger.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction() :
|
||||
fMaterial( nullptr ), fExperimentalHall_log( nullptr ), fExperimentalHall_phys( nullptr ),
|
||||
fLogicLayer( nullptr ), fPhysiLayer( nullptr ),
|
||||
fLogicScoringUpDown( nullptr ), fPhysiScoringUpstream( nullptr ),
|
||||
fPhysiScoringDownstream( nullptr ),
|
||||
fLogicScoringSide( nullptr ), fPhysiScoringSide( nullptr ),
|
||||
fDetectorMessenger( nullptr ),
|
||||
fThickness( 2.0*CLHEP::m ), fDiameter( 2.0*CLHEP::m ) //***LOOKHERE*** Default values
|
||||
{
|
||||
fMaterial = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Fe" ); //***LOOKHERE***
|
||||
// Default material
|
||||
fDetectorMessenger = new DetectorMessenger( this );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::~DetectorConstruction() {
|
||||
delete fDetectorMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct() {
|
||||
return ConstructLayer();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::ConstructLayer() {
|
||||
// Clean old geometry, if any.
|
||||
G4GeometryManager::GetInstance()->OpenGeometry();
|
||||
G4PhysicalVolumeStore::GetInstance()->Clean();
|
||||
G4LogicalVolumeStore::GetInstance()->Clean();
|
||||
G4SolidStore::GetInstance()->Clean();
|
||||
|
||||
// The target layer is a cylinder, with axis along the z-direction,
|
||||
// and positioned at the center, (0.0, 0.0, 0.0).
|
||||
// The world volume (experimental hall) is a box 20% bigger than the target layer,
|
||||
// and it is filled of "G4_Galactic" material.
|
||||
|
||||
G4double expHall_x = 0.6*fDiameter; // half dimension along x : 20% bigger than the radius
|
||||
// of the target layer
|
||||
G4double expHall_y = 0.6*fDiameter; // half dimension along y : 20% bigger than the radius
|
||||
// of the target layer
|
||||
G4double expHall_z = 0.6*fThickness; // half dimension along z : 20% bigger than the half
|
||||
// thickness of the target layer
|
||||
|
||||
G4Material* vacuum = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Galactic" );
|
||||
|
||||
// Experimental hall
|
||||
G4Box* experimentalHall_box = new G4Box( "expHall_box", expHall_x, expHall_y, expHall_z );
|
||||
fExperimentalHall_log = new G4LogicalVolume( experimentalHall_box, // solid
|
||||
vacuum, // material
|
||||
"expHall_log", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fExperimentalHall_phys = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"expHall", // name
|
||||
fExperimentalHall_log, // logical volume
|
||||
0, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// Target
|
||||
G4Tubs* solidLayer = new G4Tubs( "solidLayer", // name
|
||||
0.0, // inner radius
|
||||
0.5*fDiameter, // outer radius
|
||||
0.5*fThickness, // half cylinder length in z
|
||||
0.0, // starting phi angle in rad
|
||||
2.0*pi ); // final phi angle in rad
|
||||
fLogicLayer = new G4LogicalVolume( solidLayer, // solid
|
||||
fMaterial, // material
|
||||
"logicLayer", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiLayer = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiLayer", // name
|
||||
fLogicLayer, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// Three scoring volumes: one thin layer downstream of the target ("down")
|
||||
// one thin layer surrounding (lateral) of the target ("side")
|
||||
// one thin layer upstream of the target ("up")
|
||||
G4Tubs* solidScoringUpDown = new G4Tubs( "solidScoringUpDown", // name
|
||||
0.0, // inner radius
|
||||
0.5*fDiameter, // outer radius
|
||||
0.5*fScoringThickness, // half cylinder length in z
|
||||
0.0, // starting phi angle in rad
|
||||
2.0*pi ); // final phi angle in rad
|
||||
fLogicScoringUpDown = new G4LogicalVolume( solidScoringUpDown, // solid
|
||||
vacuum, // material
|
||||
"logicScoringUpDown", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
G4double zScoringUpDown = 0.5*(fThickness + fScoringThickness);
|
||||
fPhysiScoringUpstream = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector( 0.0, 0.0, -zScoringUpDown ),
|
||||
// translation
|
||||
"physiScoringUpstream", // name
|
||||
fLogicScoringUpDown, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
fPhysiScoringDownstream = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector( 0.0, 0.0, zScoringUpDown ),
|
||||
// translation
|
||||
"physiScoringDownstream", // name
|
||||
fLogicScoringUpDown, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
G4Tubs* solidScoringSide = new G4Tubs( "solidScoringSide", // name
|
||||
0.5*fDiameter, // inner radius
|
||||
0.5*fDiameter + fScoringThickness, // outer radius
|
||||
0.5*fThickness, // half cylinder length in z
|
||||
0.0, // starting phi angle in rad
|
||||
2.0*pi ); // final phi angle in rad
|
||||
fLogicScoringSide = new G4LogicalVolume( solidScoringSide, // solid
|
||||
vacuum, // material
|
||||
"logicScoringSide", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiScoringSide = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector( 0.0, 0.0, 0.0 ), // translation
|
||||
"physiScoringSide", // name
|
||||
fLogicScoringSide, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
G4cout << G4endl
|
||||
<< "DetectorConstruction::ConstructLayer() : " << G4endl
|
||||
<< "\t World (box) size: " << G4endl
|
||||
<< "\t \t x : -/+ " << expHall_x << " mm ;"
|
||||
<< "\t y : -/+ " << expHall_y << " mm ;"
|
||||
<< "\t z : -/+ " << expHall_z << " mm ;" << G4endl
|
||||
<< "\t Target layer (cylinder) size: " << G4endl
|
||||
<< "\t \t x : -/+ " << 0.5*fDiameter << " mm ;"
|
||||
<< "\t y : -/+ " << 0.5*fDiameter << " mm ;"
|
||||
<< "\t z : -/+ " << 0.5*fThickness << " mm ;" << G4endl
|
||||
<< G4endl << G4endl;
|
||||
|
||||
return fExperimentalHall_phys;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMaterial( const G4String name ) {
|
||||
fMaterial = G4NistManager::Instance()->FindOrBuildMaterial( name );
|
||||
if ( ! fMaterial ) {
|
||||
G4cout << G4endl << G4endl
|
||||
<< "WARNING: the name of the material has not been recognized!" << G4endl
|
||||
<< " ===> the default * G4_Fe * will be used."
|
||||
<< G4endl << G4endl;
|
||||
fMaterial = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Fe" );
|
||||
}
|
||||
if ( fLogicLayer ) fLogicLayer->SetMaterial( fMaterial );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::UpdateGeometry() {
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
PrintParameters();
|
||||
// Update also the position of the gun
|
||||
const PrimaryGeneratorAction* pPrimaryAction = dynamic_cast< const PrimaryGeneratorAction* >(
|
||||
G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction() );
|
||||
if ( pPrimaryAction ) pPrimaryAction->SetGunPosition();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::PrintParameters() {
|
||||
G4cout << G4endl << G4endl
|
||||
<< " ------ DetectorConstruction::PrintParameters() ------ " << G4endl
|
||||
<< " Material = " << fMaterial->GetName() << G4endl
|
||||
<< " Thickness = " << fThickness << " mm" << G4endl
|
||||
<< " Diameter = " << fDiameter << " mm" << G4endl
|
||||
<< " ScoringThickness = " << fScoringThickness << " mm" << G4endl
|
||||
<< " ------------------------------------------------------ "
|
||||
<< G4endl << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,101 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorMessenger.cc
|
||||
/// \brief Implementation of the DetectorMessenger class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorMessenger.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::DetectorMessenger( DetectorConstruction* myDet ) : fDetector( myDet ) {
|
||||
fDetectorDir = new G4UIdirectory( "/mydet/" );
|
||||
fDetectorDir->SetGuidance( "Detector control." );
|
||||
|
||||
fMaterial = new G4UIcmdWithAString( "/mydet/material", this );
|
||||
fMaterial->SetGuidance( "Choice of the material:" );
|
||||
fMaterial->SetGuidance( " a Geant4 NIST material, e.g. G4_Fe " );
|
||||
fMaterial->SetParameterName( "choiceMaterial", true );
|
||||
fMaterial->SetDefaultValue( "G4_Fe" );
|
||||
fMaterial->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fThickness = new G4UIcmdWithADoubleAndUnit( "/mydet/thickness", this );
|
||||
fThickness->SetParameterName( "choiceThickness", true );
|
||||
fThickness->SetGuidance( "Target thickness" );
|
||||
fThickness->SetDefaultValue( 1000.0 ); // default: 1 meter.
|
||||
fThickness->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fDiameter = new G4UIcmdWithADoubleAndUnit( "/mydet/diameter", this );
|
||||
fDiameter->SetParameterName( "choiceDiameter", true );
|
||||
fDiameter->SetGuidance( "Target diameter" );
|
||||
fDiameter->SetDefaultValue( 1000.0 ); // default: 1 meter.
|
||||
fDiameter->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fUpdateCommand = new G4UIcmdWithoutParameter( "/mydet/update", this);
|
||||
fUpdateCommand->SetGuidance( "Update calorimeter geometry." );
|
||||
fUpdateCommand->SetGuidance( "This command MUST be applied before \"beamOn\" " );
|
||||
fUpdateCommand->SetGuidance( "if you changed geometrical value(s)." );
|
||||
fUpdateCommand->AvailableForStates( G4State_Idle );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::~DetectorMessenger() {
|
||||
delete fDetectorDir;
|
||||
delete fMaterial;
|
||||
delete fThickness;
|
||||
delete fDiameter;
|
||||
delete fUpdateCommand;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorMessenger::SetNewValue( G4UIcommand* command, G4String newValue ) {
|
||||
if ( command == fMaterial ) {
|
||||
fDetector->SetMaterial( newValue );
|
||||
}
|
||||
if ( command == fThickness ) {
|
||||
fDetector->SetThickness( fThickness->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fDiameter ) {
|
||||
fDetector->SetDiameter( fDiameter->GetNewDoubleValue(newValue) );
|
||||
}
|
||||
if ( command == fUpdateCommand ) {
|
||||
fDetector->UpdateGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::
|
||||
PrimaryGeneratorAction( const DetectorConstruction* pDetector ) :
|
||||
fPointerDetectorConstruction( pDetector )
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun( n_particle );
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
//***LOOKHERE*** Default particle and energy
|
||||
fParticleGun->SetParticleDefinition( particleTable->FindParticle( "geantino" ) );
|
||||
fParticleGun->SetParticleEnergy( 10.0*GeV );
|
||||
SetGunPosition();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction() {
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::SetGunPosition() const {
|
||||
// Shoot the particle in the middle between the world and the target layer
|
||||
G4double targetThickness =
|
||||
( fPointerDetectorConstruction ? fPointerDetectorConstruction->GetThickness() : 0.0 );
|
||||
G4double gunPosition = -0.55*targetThickness; //***LOOKHERE*** default gun position
|
||||
// along the z-axis
|
||||
G4cout << G4endl << "PrimaryGenerationAction::SetGunPosition() : gun position along z = "
|
||||
<< gunPosition << " mm " << G4endl << G4endl;
|
||||
fParticleGun->SetParticlePosition( G4ThreeVector( 0.0, 0.0, gunPosition ) );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::GeneratePrimaries( G4Event* anEvent ) {
|
||||
G4ThreeVector v( 0.0, 0.0, 1.0 ); //***LOOKHERE*** default shoot along the z-axis
|
||||
fParticleGun->SetParticleMomentumDirection( v );
|
||||
fParticleGun->GeneratePrimaryVertex( anEvent );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 Run.cc
|
||||
/// \brief Implementation of the Run class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "Run.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::Run() : G4Run(), fNumEvents( 0 ),
|
||||
fPrimaryParticleId( 0 ), fPrimaryParticleEnergy( 0.0 ),
|
||||
fPrimaryParticleDirection( G4ThreeVector( 0.0, 0.0, 0.0 ) ),
|
||||
fTargetMaterialName( "" ),
|
||||
fCubicVolumeScoringUpDown( 1.0 ), fCubicVolumeScoringSide( 1.0 )
|
||||
{
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) fArray[i] = 0.0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::~Run() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::RecordEvent( const G4Event* anEvent ) {
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) at the end
|
||||
// of each event : in MT-mode, it is called only for the working thread that handled the event.
|
||||
G4int nEvt = anEvent->GetEventID();
|
||||
if ( nEvt % 10 == 0 ) G4cout << " Event#=" << nEvt << G4endl;
|
||||
G4Run::RecordEvent( anEvent );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Merge( const G4Run* aRun ) {
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) only in the case
|
||||
// of multithreaded mode and only for working threads.
|
||||
const Run* localRun = static_cast< const Run* >( aRun );
|
||||
fPrimaryParticleId = localRun->getPrimaryParticleId();
|
||||
fPrimaryParticleEnergy = localRun->getPrimaryParticleEnergy();
|
||||
fPrimaryParticleDirection = localRun->getPrimaryParticleDirection();
|
||||
fTargetMaterialName = localRun->getTargetMaterialName();
|
||||
fCubicVolumeScoringUpDown = localRun->getCubicVolumeScoringUpDown();
|
||||
fCubicVolumeScoringSide = localRun->getCubicVolumeScoringSide();
|
||||
fNumEvents += localRun->GetNumberOfEvent();
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) {
|
||||
fArray[i] += localRun->getArray()[i];
|
||||
}
|
||||
G4Run::Merge( aRun );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::printInfo() const {
|
||||
// This method is called by RunAction::EndOfRunAction. In MT-mode, only the master thread
|
||||
// calls it.
|
||||
const G4double floatingNumberOfEvents =
|
||||
std::max( 1.0, fNumEvents > 0 ? fNumEvents*1.0 : GetNumberOfEvent()*1.0 );
|
||||
// The fluence in the scoring volume is defined as sum of step lengths in that volume
|
||||
// divided by the volume of that scoring volume.
|
||||
const G4double conversionFactor = CLHEP::cm * CLHEP::cm; // From mm^-2 to cm^-2
|
||||
const G4double factorUpDown =
|
||||
conversionFactor / ( fCubicVolumeScoringUpDown*floatingNumberOfEvents );
|
||||
const G4double factorSide =
|
||||
conversionFactor / ( fCubicVolumeScoringSide*floatingNumberOfEvents );
|
||||
G4cout << std::setprecision(6) << G4endl << G4endl
|
||||
<< " =============== Run::printInfo() =============== \t RunID = " << GetRunID()
|
||||
<< G4endl
|
||||
<< " Primary particle PDG code = " << fPrimaryParticleId << G4endl
|
||||
<< " Primary particle kinetic energy = " << fPrimaryParticleEnergy / CLHEP::GeV
|
||||
<< " GeV" << G4endl
|
||||
<< " Primary particle direction = " << fPrimaryParticleDirection << G4endl
|
||||
<< " Target material = " << fTargetMaterialName << G4endl
|
||||
<< " Cubic-volume scoring up-down = " << fCubicVolumeScoringUpDown << " mm^3" << G4endl
|
||||
<< " Cubic-volume scoring side = " << fCubicVolumeScoringSide << " mm^3" << G4endl
|
||||
<< " Number of events = " << floatingNumberOfEvents << G4endl
|
||||
<< " Conversion factor: fluence from mm^-2 to cm^-2 = " << conversionFactor << G4endl
|
||||
<< " Particle fluence in unit of cm^-2 :" << G4endl;
|
||||
for ( G4int i = 0; i < SteppingAction::numberScoringVolumes; ++i ) {
|
||||
G4double factor = ( i == 1 ? factorSide : factorUpDown );
|
||||
for ( G4int j = 0; j < SteppingAction::numberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < SteppingAction::numberParticleTypes; ++k ) {
|
||||
G4int index = SteppingAction::getIndex( i, j, k );
|
||||
//G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
G4cout << " case=" << std::setw(3) << index
|
||||
<< " " << std::setw(12) << SteppingAction::arrayScoringVolumeNames[i]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayKinematicRegionNames[j]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayParticleTypeNames[k]
|
||||
<< " " << factor*fArray[index] << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
G4cout << " ============================================================= " << G4endl << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::setArray( const std::array< G4double,
|
||||
SteppingAction::numberCombinations >& inputArray ) {
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) {
|
||||
fArray[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -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 RunAction.cc
|
||||
/// \brief Implementation of the RunAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "Run.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction( SteppingAction* steppingAction ) :
|
||||
G4UserRunAction(), fSteppingAction( steppingAction ) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::~RunAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4Run* RunAction::GenerateRun() {
|
||||
return new Run;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction( const G4Run* aRun ) {
|
||||
G4cout << "### Run " << aRun->GetRunID() << " starts." << G4endl;
|
||||
if ( fSteppingAction ) {
|
||||
fSteppingAction->initialize();
|
||||
Run* run = const_cast< Run* >( static_cast< const Run* >( aRun ) );
|
||||
if ( run != nullptr ) fSteppingAction->setRunPointer( run );
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction( const G4Run* aRun ) {
|
||||
const Run* run = static_cast< const Run* >( aRun );
|
||||
if ( run == nullptr || run->GetNumberOfEvent() == 0 ) return;
|
||||
if ( IsMaster() ) run->printInfo();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,232 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 SteppingAction.cc
|
||||
/// \brief Implementation of the SteppingAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "SteppingAction.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4LossTableManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
const std::array< G4String, SteppingAction::numberScoringVolumes >
|
||||
SteppingAction::arrayScoringVolumeNames = { "downstream", "side", "upstream" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberKinematicRegions >
|
||||
SteppingAction::arrayKinematicRegionNames = { "", "below 20 MeV", "above 20 MeV" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberParticleTypes >
|
||||
SteppingAction::arrayParticleTypeNames = { "all", "electron", "gamma", "muon", "neutrino",
|
||||
"pion", "neutron", "proton", "ion", "otherMeson",
|
||||
"otherBaryon" };
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4int SteppingAction::getIndex( const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType ) {
|
||||
G4int index = -1;
|
||||
if ( iScoringVolume >= 0 && iScoringVolume < numberScoringVolumes &&
|
||||
iKinematicRegion >= 0 && iKinematicRegion < numberKinematicRegions &&
|
||||
iParticleType >= 0 && iParticleType < numberParticleTypes ) {
|
||||
index = iScoringVolume * numberKinematicRegions * numberParticleTypes +
|
||||
iKinematicRegion * numberParticleTypes +
|
||||
iParticleType;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction() :G4UserSteppingAction() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::~SteppingAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::initialize() {
|
||||
// Initialization needed at the beginning of each Run
|
||||
fPrimaryParticleId = 0;
|
||||
fPrimaryParticleEnergy = 0.0;
|
||||
fPrimaryParticleDirection = G4ThreeVector( 0.0, 0.0, 1.0 );
|
||||
fTargetMaterialName = "";
|
||||
fIsFirstStepOfTheEvent = true;
|
||||
fIsFirstStepInTarget = true;
|
||||
fIsFirstStepInScoringUpDown = true;
|
||||
fIsFirstStepInScoringSide = true;
|
||||
fCubicVolumeScoringUpDown = 1.0;
|
||||
fCubicVolumeScoringSide = 1.0;
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) {
|
||||
fArraySumStepLengths[i] = 0.0;
|
||||
}
|
||||
/*
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) fArraySumStepLengths[i] = 999.9;
|
||||
G4cout << " numberCombinations=" << numberCombinations << G4endl;
|
||||
for ( G4int i = 0; i < numberScoringVolumes; ++i ) {
|
||||
for ( G4int j = 0; j < numberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < numberParticleTypes; ++k ) {
|
||||
G4int index = getIndex( i, j, k );
|
||||
G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
if ( fArraySumStepLengths[ index ] < 1.0 ) G4cout << " <=== REPEATED!";
|
||||
else fArraySumStepLengths[ index ] = 0.0;
|
||||
G4cout << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) {
|
||||
if ( fArraySumStepLengths[i] > 999.0 ) G4cout << " i=" << i << " NOT COVERED !" << G4endl;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
// Get information on the primary particle
|
||||
if ( fIsFirstStepOfTheEvent ) {
|
||||
if ( theStep->GetTrack()->GetParentID() == 0 ) {
|
||||
fPrimaryParticleId = theStep->GetTrack()->GetDefinition()->GetPDGEncoding();
|
||||
fPrimaryParticleEnergy = theStep->GetPreStepPoint()->GetKineticEnergy();
|
||||
fPrimaryParticleDirection = theStep->GetPreStepPoint()->GetMomentumDirection();
|
||||
if ( fRunPtr ) {
|
||||
fRunPtr->setPrimaryParticleId( fPrimaryParticleId );
|
||||
fRunPtr->setPrimaryParticleEnergy( fPrimaryParticleEnergy );
|
||||
fRunPtr->setPrimaryParticleDirection( fPrimaryParticleDirection );
|
||||
}
|
||||
fIsFirstStepOfTheEvent = false;
|
||||
}
|
||||
}
|
||||
// Get information on the target material
|
||||
if ( fIsFirstStepInTarget &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiLayer" ) {
|
||||
fTargetMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->setTargetMaterialName( fTargetMaterialName );
|
||||
fIsFirstStepInTarget = false;
|
||||
}
|
||||
// Get information on step lengths in the scoring volumes
|
||||
G4int iScoringVolume = -1;
|
||||
if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringDownstream" ) {
|
||||
iScoringVolume = 0;
|
||||
if ( fIsFirstStepInScoringUpDown ) {
|
||||
fCubicVolumeScoringUpDown =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringUpDown( fCubicVolumeScoringUpDown );
|
||||
fIsFirstStepInScoringUpDown = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringSide" ) {
|
||||
iScoringVolume = 1;
|
||||
if ( fIsFirstStepInScoringSide ) {
|
||||
fCubicVolumeScoringSide =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringSide( fCubicVolumeScoringSide );
|
||||
fIsFirstStepInScoringSide = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ==
|
||||
"physiScoringUpstream" ) {
|
||||
iScoringVolume = 2;
|
||||
if ( fIsFirstStepInScoringUpDown ) {
|
||||
fCubicVolumeScoringUpDown =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringUpDown( fCubicVolumeScoringUpDown );
|
||||
fIsFirstStepInScoringUpDown = false;
|
||||
}
|
||||
}
|
||||
if ( iScoringVolume >= 0 ) {
|
||||
// In the case of the upstream scoring volume, consider only particles whose direction
|
||||
// is opposite with respect to the primary particle (this is needed, in particular,
|
||||
// for avoiding to account the incoming, primary beam particle in the "upstream" fluence).
|
||||
if ( iScoringVolume == 2 && fPrimaryParticleDirection.dot(
|
||||
theStep->GetPreStepPoint()->GetMomentumDirection() ) > 0.0 ) {
|
||||
return;
|
||||
}
|
||||
G4double stepLength = theStep->GetTrack()->GetStepLength() * theStep->GetTrack()->GetWeight();
|
||||
G4int absPdg = theStep->GetTrack()->GetDefinition() == nullptr ? 0 :
|
||||
std::abs( theStep->GetTrack()->GetDefinition()->GetPDGEncoding() );
|
||||
/*
|
||||
G4cout << std::setprecision(6)
|
||||
<< theStep->GetTrack()->GetDefinition()->GetParticleName() << " absPdg=" << absPdg
|
||||
<< " Ekin[MeV]=" << theStep->GetPreStepPoint()->GetKineticEnergy()
|
||||
<< " (rho,z)[mm]=(" << theStep->GetTrack()->GetPosition().perp()
|
||||
<< "," << theStep->GetTrack()->GetPosition().z() << ")"
|
||||
<< " " << theStep->GetTrack()->GetVolume()->GetName()
|
||||
<< " " << theStep->GetTrack()->GetMaterial()->GetName()
|
||||
<< " L[mm]=" << stepLength << " "
|
||||
<< ( fPrimaryParticleDirection.dot(
|
||||
theStep->GetPreStepPoint()->GetMomentumDirection() ) > 0.0
|
||||
? "forward" : "backward" )
|
||||
<< G4endl;
|
||||
*/
|
||||
// Three kinematical regions: [0] : any value ; [1] : below 20 MeV ; [2] : above 20 MeV
|
||||
G4int iKinematicRegion = theStep->GetPreStepPoint()->GetKineticEnergy() < 20.0 ? 1 : 2;
|
||||
G4int iParticleType = -1;
|
||||
if ( absPdg == 11 ) iParticleType = 1; // electron (and positron)
|
||||
else if ( absPdg == 22 ) iParticleType = 2; // gamma
|
||||
else if ( absPdg == 13 ) iParticleType = 3; // muons (mu- and mu+)
|
||||
else if ( absPdg == 12 || absPdg == 14 || absPdg == 16 ) iParticleType = 4; // neutrinos
|
||||
//(and anti-neutrinos), all flavors
|
||||
else if ( absPdg == 111 || absPdg == 211 ) iParticleType = 5; // (charged) pions
|
||||
else if ( absPdg == 2112 ) iParticleType = 6; // neutron (and anti-neutron)
|
||||
else if ( absPdg == 2212 ) iParticleType = 7; // proton (and anti-proton)
|
||||
else if ( G4IonTable::IsIon( theStep->GetTrack()->GetDefinition() ) || // ions (and anti-ions)
|
||||
G4IonTable::IsAntiIon( theStep->GetTrack()->GetDefinition() ) ) iParticleType = 8;
|
||||
else if ( absPdg < 1000 ) iParticleType = 9; // other mesons (e.g. kaons) (Note: this works
|
||||
// in most cases, but not always!)
|
||||
else if ( absPdg > 1000 ) iParticleType = 10; // other baryons (e.g. hyperons, anti-hyperons,
|
||||
// etc.)
|
||||
// Consider the specific case : scoring volume, kinematic region and particle type
|
||||
G4int index = getIndex( iScoringVolume, iKinematicRegion, iParticleType );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "all" particle case, with the same scoring volume and kinematic region
|
||||
index = getIndex( iScoringVolume, iKinematicRegion, 0 );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region case, with the same scoring volume and particle type
|
||||
index = getIndex( iScoringVolume, 0, iParticleType );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region and "all" particle, with the same scoring volume
|
||||
index = getIndex( iScoringVolume, 0, 0 );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
if ( fRunPtr ) fRunPtr->setArray( fArraySumStepLengths );
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_W
|
||||
/mydet/thickness 100.0 cm
|
||||
/mydet/diameter 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
ParticleFluence set-ups
|
||||
-----------------------
|
||||
|
||||
Sphere
|
||||
------
|
||||
This set-up consists of a full solid target sphere - whose radius and
|
||||
material can be set via UI commands.
|
||||
The primary particle is shot from the center of the target sphere
|
||||
(along the z-axis direction by default).
|
||||
As scoring volume, we use a thin spherical shell outside the target sphere.
|
||||
The particle fluences are evaluated in the forward and backward hemispheres
|
||||
(with respect to the primary particle direction).
|
||||
|
||||
ConcentricSpheres
|
||||
-----------------
|
||||
Similar to the Sphere one, but with two larger solid target spherical shells
|
||||
outside the first one, separated by some space filled up by G4_Galactic.
|
||||
The dimensions of these three targets - which are meant as a simplified
|
||||
proxy for, respectively, a Tracker (inner sphere), EM (electromagnetic)
|
||||
calorimeter (middle spherical shell), and HAD (hadronic) calorimeter
|
||||
(external spherical shell) - and their materials can be set via UI commands.
|
||||
As scoring volumes, we use three thin spherical shells immediately outside
|
||||
the inner target sphere and the two target spherical shells.
|
||||
The particle fluences are evaluated in the forward and backward hemispheres
|
||||
(with respect to the primary particle direction).
|
||||
|
||||
Layer
|
||||
-----
|
||||
This set-up consists of a cylinder, with axis along the z-direction, whose
|
||||
radius, length (i.e. thickness) and material can be set via UI commands.
|
||||
The primary particle is shot by default along the z-axis, from behind
|
||||
the target.
|
||||
As scoring volumes, we use three thin cylindrical layers, filled up by
|
||||
G4_Galactic, and placed downstream, upstream, and aside of the target
|
||||
cylinder.
|
||||
|
||||
Calo
|
||||
----
|
||||
Similar to the Layer one, the target consists of a simplified cylindrical
|
||||
hadronic calorimeter, whose properties - size, number of layers, sampling
|
||||
fraction, active and absorber materials - can be set via UI commands.
|
||||
Similarly to the Layer case, the the particle fluences are evaluated in the
|
||||
downstream, upstream and aside positions.
|
||||
@@ -0,0 +1,62 @@
|
||||
///\file "hadronic/ParticleFluence/Sphere/.README.txt"
|
||||
///\brief Example ParticleFluence/Sphere README page
|
||||
|
||||
/*! \page ExampeParticleFluenceSphere Example Sphere
|
||||
|
||||
In this example, the particle fluence is evaluated for a very simple
|
||||
set-up, consisting of one target solid sphere, at the center of which
|
||||
a particle is shot (by default along the z-axis).
|
||||
|
||||
The particle fluence is computed in two places: "forward" and "backward",
|
||||
defined as the positions immediately after and before, respectively, of
|
||||
the target with respect to the direction of the primary particle.
|
||||
|
||||
The particle fluence is estimated by summing the track length in a
|
||||
"scoring volume" - i.e. a thin hemisphere shell filled up with G4_Galactic
|
||||
(very low density gas) material, immediately outside the target sphere -
|
||||
and then dividing for the cubic volume of such scoring volume.
|
||||
|
||||
The particle fluence is evaluated for the following 11 particle types:
|
||||
- all
|
||||
- electron + positron
|
||||
- gamma
|
||||
- muon- + muon+
|
||||
- neutrino (any flavour and including anti-neutrino)
|
||||
- charged pions
|
||||
- neutron + anti_neutron
|
||||
- proton + anti_proton
|
||||
- ion (and anti-ions)
|
||||
- otherMeson (e.g. kaons, etc.)
|
||||
- otherBaryon (e.g. hyperons, etc.)
|
||||
|
||||
The particle fluence is evaluated for the following 3 kinematical ranges:
|
||||
- any kinetic energy
|
||||
- kinetic energy < 20 MeV
|
||||
- kinetic energy > 20 MeV
|
||||
|
||||
Look for the string "***LOOKHERE***" for those parameters/options that
|
||||
are either hardwired in the code (i.e. not available via UI command),
|
||||
or default values of UI commands.
|
||||
|
||||
This example uses the physics list factory, therefore you can specify
|
||||
the reference physics list you want to use via the PHYSLIST
|
||||
environmental variable (by default, if you don't set it, the FTFP_BERT
|
||||
physics list is used).
|
||||
|
||||
To build this example:
|
||||
|
||||
mkdir Build; cd Build
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DGeant4_DIR=/path-to-geant4-libraries ../.
|
||||
make
|
||||
|
||||
To run it:
|
||||
|
||||
./Sphere all_together.g4
|
||||
|
||||
which shoots 50 GeV pion- on different target materials, 100 events
|
||||
in each run, and print out some information on the particle fluence
|
||||
at the end of each run.
|
||||
Other macros exist for specific materials.
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,65 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# Setup the project
|
||||
cmake_minimum_required(VERSION 3.16...3.21)
|
||||
project(Sphere)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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 executable, and link it to the Geant4 libraries
|
||||
#
|
||||
add_executable(Sphere Sphere.cc ${sources} ${headers})
|
||||
target_link_libraries(Sphere ${Geant4_LIBRARIES} )
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Copy all scripts to the build directory, so that we can run the executable
|
||||
# directly there.
|
||||
#
|
||||
set(Sphere_SCRIPTS
|
||||
all_together.g4
|
||||
polystyrene.g4
|
||||
graphite.g4
|
||||
si.g4
|
||||
lar.g4
|
||||
fe.g4
|
||||
cu.g4
|
||||
w.g4
|
||||
pb.g4
|
||||
pbwo4.g4
|
||||
)
|
||||
|
||||
foreach(_script ${Sphere_SCRIPTS})
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/${_script}
|
||||
${PROJECT_BINARY_DIR}/${_script}
|
||||
COPYONLY
|
||||
)
|
||||
endforeach()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
|
||||
#
|
||||
install(TARGETS Sphere DESTINATION bin)
|
||||
@@ -0,0 +1,11 @@
|
||||
name := Sphere
|
||||
G4TARGET := $(name)
|
||||
G4EXLIB := true
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
.PHONY: all
|
||||
|
||||
all: lib bin
|
||||
|
||||
include $(G4INSTALL)/config/binmake.gmk
|
||||
@@ -0,0 +1,10 @@
|
||||
# Example ParticleFluence 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!
|
||||
|
||||
|
||||
## 2021-06-10 Alberto Ribon (exhadrParticleFluenceSphere-V11-00-00)
|
||||
- Created the Sphere variant of the ParticleFluence example.
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
In this example, the particle fluence is evaluated for a very simple
|
||||
set-up, consisting of one target solid sphere, at the center of which
|
||||
a particle is shot (by default along the z-axis).
|
||||
|
||||
The particle fluence is computed in two places: "forward" and "backward",
|
||||
defined as the positions immediately after and before, respectively, of
|
||||
the target with respect to the direction of the primary particle.
|
||||
|
||||
The particle fluence is estimated by summing the track length in a
|
||||
"scoring volume" - i.e. a thin hemisphere shell filled up with G4_Galactic
|
||||
(very low density gas) material, immediately outside the target sphere -
|
||||
and then dividing for the cubic volume of such scoring volume.
|
||||
|
||||
The particle fluence is evaluated for the following 11 particle types:
|
||||
- all
|
||||
- electron + positron
|
||||
- gamma
|
||||
- muon- + muon+
|
||||
- neutrino (any flavour and including anti-neutrino)
|
||||
- charged pions
|
||||
- neutron + anti_neutron
|
||||
- proton + anti_proton
|
||||
- ion (and anti-ions)
|
||||
- otherMeson (e.g. kaons, etc.)
|
||||
- otherBaryon (e.g. hyperons, etc.)
|
||||
|
||||
The particle fluence is evaluated for the following 3 kinematical ranges:
|
||||
- any kinetic energy
|
||||
- kinetic energy < 20 MeV
|
||||
- kinetic energy > 20 MeV
|
||||
|
||||
Look for the string "***LOOKHERE***" for those parameters/options that
|
||||
are either hardwired in the code (i.e. not available via UI command),
|
||||
or default values of UI commands.
|
||||
|
||||
This example uses the physics list factory, therefore you can specify
|
||||
the reference physics list you want to use via the PHYSLIST
|
||||
environmental variable (by default, if you don't set it, the FTFP_BERT
|
||||
physics list is used).
|
||||
|
||||
To build this example:
|
||||
|
||||
mkdir Build; cd Build
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DGeant4_DIR=/path-to-geant4-libraries ../.
|
||||
make
|
||||
|
||||
To run it:
|
||||
|
||||
./Sphere all_together.g4
|
||||
|
||||
which shoots 50 GeV pion- on different target materials, 100 events
|
||||
in each run, and print out some information on the particle fluence
|
||||
at the end of each run.
|
||||
Other macros exist for specific materials.
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 Sphere.cc
|
||||
/// \brief Main program of the hadronic/ParticleFluence/Sphere example
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4Threading.hh"
|
||||
#include "G4RunManagerFactory.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4PhysListFactory.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
int main(int argc,char** argv) {
|
||||
|
||||
auto* runManager = G4RunManagerFactory::CreateRunManager();
|
||||
|
||||
DetectorConstruction* pDetectorInstance = new DetectorConstruction;
|
||||
runManager->SetUserInitialization( pDetectorInstance );
|
||||
|
||||
// Physics list factory: use the PHYSLIST environmental variable.
|
||||
G4PhysListFactory factory;
|
||||
G4VModularPhysicsList* thePL = factory.ReferencePhysList();
|
||||
|
||||
runManager->SetUserInitialization( thePL );
|
||||
runManager->SetUserInitialization( new ActionInitialization );
|
||||
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if ( argc==1 ) { // Define UI session for interactive mode.
|
||||
} else { // Batch mode
|
||||
G4String command = "/control/execute ";
|
||||
G4String fileName = argv[1];
|
||||
UI->ApplyCommand(command+fileName);
|
||||
}
|
||||
|
||||
// job termination
|
||||
delete runManager;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,53 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
#
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
#
|
||||
/mydet/material G4_POLYSTYRENE
|
||||
/mydet/radius 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_GRAPHITE
|
||||
/mydet/radius 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_Si
|
||||
/mydet/radius 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_lAr
|
||||
/mydet/radius 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_Fe
|
||||
/mydet/radius 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_Cu
|
||||
/mydet/radius 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_W
|
||||
/mydet/radius 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_Pb
|
||||
/mydet/radius 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
#
|
||||
/mydet/material G4_PbWO4
|
||||
/mydet/radius 100.0 cm
|
||||
/mydet/update
|
||||
/run/beamOn 100
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_Cu
|
||||
/mydet/radius 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_Fe
|
||||
/mydet/radius 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,10 @@
|
||||
/random/setSavingFlag 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
/tracking/verbose 0
|
||||
/mydet/material G4_GRAPHITE
|
||||
/mydet/radius 100.0 cm
|
||||
/run/initialize
|
||||
/gun/particle pi-
|
||||
/gun/energy 50 GeV
|
||||
/run/beamOn 100
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 ActionInitialization.hh
|
||||
/// \brief Definition of the ActionInitialization class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ActionInitialization_h
|
||||
#define ActionInitialization_h 1
|
||||
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ActionInitialization : public G4VUserActionInitialization {
|
||||
public:
|
||||
ActionInitialization();
|
||||
virtual ~ActionInitialization();
|
||||
virtual void BuildForMaster() const override;
|
||||
virtual void Build() const override;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 DetectorConstruction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef DetectorConstruction_H
|
||||
#define DetectorConstruction_H 1
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4LogicalVolume;
|
||||
class G4VPhysicalVolume;
|
||||
class G4Material;
|
||||
class DetectorMessenger;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class DetectorConstruction : public G4VUserDetectorConstruction {
|
||||
public:
|
||||
DetectorConstruction();
|
||||
~DetectorConstruction();
|
||||
G4VPhysicalVolume* Construct();
|
||||
void SetMaterial( const G4String name );
|
||||
inline G4Material* GetMaterial() const;
|
||||
inline void SetRadius( const G4double value );
|
||||
inline G4double GetRadius() const;
|
||||
void UpdateGeometry();
|
||||
private:
|
||||
G4VPhysicalVolume* ConstructSphere(); // To be invoked each time the geometry needs
|
||||
// to be updated
|
||||
void PrintParameters();
|
||||
G4Material* fMaterial;
|
||||
G4LogicalVolume* fExperimentalHall_log;
|
||||
G4VPhysicalVolume* fExperimentalHall_phys;
|
||||
G4LogicalVolume* fLogicSphere;
|
||||
G4VPhysicalVolume* fPhysiSphere;
|
||||
G4LogicalVolume* fLogicScoringShell;
|
||||
G4VPhysicalVolume* fPhysiScoringShell;
|
||||
DetectorMessenger* fDetectorMessenger;
|
||||
G4double fRadius;
|
||||
const G4double fScoringThickness = 10.0; //***LOOKHERE*** thickness of the scoring shell
|
||||
};
|
||||
|
||||
inline G4Material* DetectorConstruction::GetMaterial() const {
|
||||
return fMaterial;
|
||||
}
|
||||
|
||||
inline void DetectorConstruction::SetRadius( const G4double value ) {
|
||||
fRadius = value;
|
||||
}
|
||||
|
||||
inline G4double DetectorConstruction::GetRadius() const {
|
||||
return fRadius;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+63
@@ -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 DetectorMessenger.hh
|
||||
/// \brief Definition of the DetectorMessenger class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef DetectorMessenger_h
|
||||
#define DetectorMessenger_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class DetectorConstruction;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithADoubleAndUnit;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithoutParameter;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class DetectorMessenger: public G4UImessenger {
|
||||
public:
|
||||
DetectorMessenger( DetectorConstruction* );
|
||||
~DetectorMessenger();
|
||||
void SetNewValue( G4UIcommand*, G4String ) override;
|
||||
private:
|
||||
DetectorConstruction* fDetector;
|
||||
G4UIdirectory* fDetectorDir;
|
||||
G4UIcmdWithAString* fMaterial;
|
||||
G4UIcmdWithADoubleAndUnit* fRadius;
|
||||
G4UIcmdWithoutParameter* fUpdateCommand;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 PrimaryGeneratorAction.hh
|
||||
/// \brief Definition of the PrimaryGeneratorAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef PrimaryGeneratorAction_h
|
||||
#define PrimaryGeneratorAction_h 1
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class G4ParticleGun;
|
||||
class G4Event;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
|
||||
public:
|
||||
PrimaryGeneratorAction();
|
||||
~PrimaryGeneratorAction();
|
||||
void GeneratePrimaries( G4Event* anEvent ) override;
|
||||
void SetGunPosition() const;
|
||||
private:
|
||||
G4ParticleGun* fParticleGun;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 Run.hh
|
||||
/// \brief Definition of the Run class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef Run_h
|
||||
#define Run_h 1
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include <array>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class Run : public G4Run {
|
||||
// This class accumulates relevant quantities related to particle fluence collected during
|
||||
// the run.
|
||||
// ( Note: these information are provided via calls of accessor methods of this Run class
|
||||
// made by SteppingAction::UserSteppingAction. )
|
||||
// At the end of a run, the printInfo method is called by the run-action to print out
|
||||
// some summary information about these quantities.
|
||||
// In multithreaded (MT) mode, an object of this class is filled up for each working thread,
|
||||
// and then merged (automatically by the Geant4 kernel) into another object (of this class)
|
||||
// owned by the master class; the printInfo method is then called only for the latter run
|
||||
// object.
|
||||
// Note that, for simplicity and brevity, we avoid histograms and print-out instead some
|
||||
// statistics (compute by ourself) at the end of the run.
|
||||
public:
|
||||
Run();
|
||||
~Run();
|
||||
|
||||
virtual void RecordEvent( const G4Event* anEvent ) override;
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) at the end
|
||||
// of each event. In the case of multithreaded mode, it is called only for the working thread
|
||||
// that handled that event.
|
||||
|
||||
virtual void Merge( const G4Run* aRun ) override;
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) only in the
|
||||
// case of multithreaded mode and only for working threads.
|
||||
|
||||
void printInfo() const;
|
||||
// This method is called by RunAction::EndOfRunAction : in the case of multithreaded mode,
|
||||
// only the master thread calls it.
|
||||
|
||||
void setPrimaryParticleId( const G4int inputValue ) { fPrimaryParticleId = inputValue; }
|
||||
void setPrimaryParticleEnergy( const G4double inputValue )
|
||||
{ fPrimaryParticleEnergy = inputValue; }
|
||||
void setPrimaryParticleDirection( const G4ThreeVector &inputValue )
|
||||
{ fPrimaryParticleDirection = inputValue; }
|
||||
void setTargetMaterialName( const G4String &inputValue ) { fTargetMaterialName = inputValue; }
|
||||
void setCubicVolumeScoringShell( const G4double inputValue )
|
||||
{ fCubicVolumeScoringShell = inputValue; }
|
||||
G4int getPrimaryParticleId() const { return fPrimaryParticleId; }
|
||||
G4double getPrimaryParticleEnergy() const { return fPrimaryParticleEnergy; }
|
||||
G4ThreeVector getPrimaryParticleDirection() const { return fPrimaryParticleDirection; }
|
||||
G4String getTargetMaterialName() const { return fTargetMaterialName; }
|
||||
G4double getCubicVolumeScoringShell() const { return fCubicVolumeScoringShell; }
|
||||
void setArray( const std::array< G4double, SteppingAction::numberCombinations >& inputArray );
|
||||
std::array< G4double, SteppingAction::numberCombinations > getArray() const { return fArray; }
|
||||
// Accessor methods useful to transfer information collected by the stepping-action
|
||||
// into this Run class
|
||||
|
||||
private:
|
||||
G4int fNumEvents;
|
||||
G4int fPrimaryParticleId;
|
||||
G4double fPrimaryParticleEnergy;
|
||||
G4ThreeVector fPrimaryParticleDirection;
|
||||
G4String fTargetMaterialName;
|
||||
G4double fCubicVolumeScoringShell;
|
||||
std::array< G4double, SteppingAction::numberCombinations > fArray;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 RunAction.hh
|
||||
/// \brief Definition of the RunAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef RunAction_h
|
||||
#define RunAction_h
|
||||
|
||||
#include "G4UserRunAction.hh"
|
||||
|
||||
class G4Run;
|
||||
class SteppingAction;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class RunAction: public G4UserRunAction {
|
||||
public:
|
||||
RunAction( SteppingAction* steppingAction = nullptr );
|
||||
virtual ~RunAction();
|
||||
virtual void BeginOfRunAction( const G4Run* aRun ) override;
|
||||
virtual void EndOfRunAction( const G4Run* aRun ) override;
|
||||
virtual G4Run* GenerateRun() override;
|
||||
private:
|
||||
SteppingAction* fSteppingAction;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user