Import Geant4 11.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2024-06-28 13:08:51 +02:00
parent f7b23877ed
commit e58e650b32
5232 changed files with 239416 additions and 244360 deletions
@@ -26,7 +26,7 @@
/// \file ActionInitialization.hh
/// \brief Definition of the ActionInitialization class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -38,7 +38,8 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class ActionInitialization : public G4VUserActionInitialization {
class ActionInitialization : public G4VUserActionInitialization
{
public:
ActionInitialization();
~ActionInitialization() override = default;
@@ -26,7 +26,7 @@
/// \file DetectorConstruction.hh
/// \brief Definition of the DetectorConstruction class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -35,7 +35,7 @@
#define DetectorConstruction_H 1
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
#include "globals.hh"
class G4LogicalVolume;
class G4VPhysicalVolume;
@@ -44,41 +44,46 @@ class DetectorMessenger;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class DetectorConstruction : public G4VUserDetectorConstruction {
class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
DetectorConstruction();
~DetectorConstruction();
G4VPhysicalVolume* Construct();
void SetMaterial( const G4String name );
void SetMaterial(const G4String name);
inline G4Material* GetMaterial() const;
inline void SetRadius( const G4double value );
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;
G4LogicalVolume* fExperimentalHall_log;
G4VPhysicalVolume* fExperimentalHall_phys;
G4LogicalVolume* fLogicSphere;
G4LogicalVolume* fLogicSphere;
G4VPhysicalVolume* fPhysiSphere;
G4LogicalVolume* fLogicScoringShell;
G4LogicalVolume* fLogicScoringShell;
G4VPhysicalVolume* fPhysiScoringShell;
DetectorMessenger* fDetectorMessenger;
G4double fRadius;
const G4double fScoringThickness = 10.0; //***LOOKHERE*** thickness of the scoring shell
};
inline G4Material* DetectorConstruction::GetMaterial() const {
inline G4Material* DetectorConstruction::GetMaterial() const
{
return fMaterial;
}
inline void DetectorConstruction::SetRadius( const G4double value ) {
inline void DetectorConstruction::SetRadius(const G4double value)
{
fRadius = value;
}
inline G4double DetectorConstruction::GetRadius() const {
inline G4double DetectorConstruction::GetRadius() const
{
return fRadius;
}
@@ -26,7 +26,7 @@
/// \file DetectorMessenger.hh
/// \brief Definition of the DetectorMessenger class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -34,8 +34,8 @@
#ifndef DetectorMessenger_h
#define DetectorMessenger_h 1
#include "globals.hh"
#include "G4UImessenger.hh"
#include "globals.hh"
class DetectorConstruction;
class G4UIdirectory;
@@ -45,17 +45,19 @@ class G4UIcmdWithoutParameter;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class DetectorMessenger: public G4UImessenger {
class DetectorMessenger : public G4UImessenger
{
public:
DetectorMessenger( DetectorConstruction* );
DetectorMessenger(DetectorConstruction*);
~DetectorMessenger();
void SetNewValue( G4UIcommand*, G4String ) override;
void SetNewValue(G4UIcommand*, G4String) override;
private:
DetectorConstruction* fDetector;
G4UIdirectory* fDetectorDir;
G4UIcmdWithAString* fMaterial;
DetectorConstruction* fDetector;
G4UIdirectory* fDetectorDir;
G4UIcmdWithAString* fMaterial;
G4UIcmdWithADoubleAndUnit* fRadius;
G4UIcmdWithoutParameter* fUpdateCommand;
G4UIcmdWithoutParameter* fUpdateCommand;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file PrimaryGeneratorAction.hh
/// \brief Definition of the PrimaryGeneratorAction class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -41,12 +41,14 @@ class G4Event;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
PrimaryGeneratorAction();
~PrimaryGeneratorAction();
void GeneratePrimaries( G4Event* anEvent ) override;
void GeneratePrimaries(G4Event* anEvent) override;
void SetGunPosition() const;
private:
G4ParticleGun* fParticleGun;
};
@@ -26,7 +26,7 @@
/// \file Run.hh
/// \brief Definition of the Run class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -34,87 +34,102 @@
#ifndef Run_h
#define Run_h 1
#include "G4Run.hh"
#include "G4ThreeVector.hh"
#include "SteppingAction.hh"
#include "TrackingAction.hh"
#include "G4Run.hh"
#include "G4ThreeVector.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
// and TrackingAction::PreUserTrackingAction. )
// 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.
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
// and TrackingAction::PreUserTrackingAction. )
// 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() override = default;
void RecordEvent( const G4Event* anEvent ) override;
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.
void Merge( const G4Run* aRun ) override;
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; }
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 SetSteppingArray( const std::array< G4double,
SteppingAction::fkNumberCombinations >& inputArray );
std::array< G4double, SteppingAction::fkNumberCombinations > GetSteppingArray() const
{ return fSteppingArray; }
void
SetSteppingArray(const std::array<G4double, SteppingAction::fkNumberCombinations>& inputArray);
std::array<G4double, SteppingAction::fkNumberCombinations> GetSteppingArray() const
{
return fSteppingArray;
}
// Accessor methods useful to transfer information collected by the stepping-action
// into this Run class
void SetTrackingArray1( const std::array< G4long,
TrackingAction::fkNumberCombinations >& inputArray );
std::array< G4long, TrackingAction::fkNumberCombinations > GetTrackingArray1() const
{ return fTrackingArray1; }
void SetTrackingArray2( const std::array< G4double,
TrackingAction::fkNumberCombinations >& inputArray );
std::array< G4double, TrackingAction::fkNumberCombinations > GetTrackingArray2() const
{ return fTrackingArray2; }
void
SetTrackingArray1(const std::array<G4long, TrackingAction::fkNumberCombinations>& inputArray);
std::array<G4long, TrackingAction::fkNumberCombinations> GetTrackingArray1() const
{
return fTrackingArray1;
}
void
SetTrackingArray2(const std::array<G4double, TrackingAction::fkNumberCombinations>& inputArray);
std::array<G4double, TrackingAction::fkNumberCombinations> GetTrackingArray2() const
{
return fTrackingArray2;
}
// Accessor methods useful to transfer information collected by the tracking-action
// into this Run class
private:
private:
G4int fNumEvents;
G4int fPrimaryParticleId;
G4double fPrimaryParticleEnergy;
G4ThreeVector fPrimaryParticleDirection;
G4String fTargetMaterialName;
G4double fCubicVolumeScoringShell;
std::array< G4double, SteppingAction::fkNumberCombinations > fSteppingArray;
std::array< G4long, TrackingAction::fkNumberCombinations > fTrackingArray1;
std::array< G4double, TrackingAction::fkNumberCombinations > fTrackingArray2;
std::array<G4double, SteppingAction::fkNumberCombinations> fSteppingArray;
std::array<G4long, TrackingAction::fkNumberCombinations> fTrackingArray1;
std::array<G4double, TrackingAction::fkNumberCombinations> fTrackingArray2;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file RunAction.hh
/// \brief Definition of the RunAction class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -42,17 +42,18 @@ class TrackingAction;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class RunAction: public G4UserRunAction {
class RunAction : public G4UserRunAction
{
public:
RunAction( SteppingAction* steppingAction = nullptr,
TrackingAction* trackingAction = nullptr );
RunAction(SteppingAction* steppingAction = nullptr, TrackingAction* trackingAction = nullptr);
~RunAction() override = default;
void BeginOfRunAction( const G4Run* aRun ) override;
void EndOfRunAction( const G4Run* aRun ) override;
void BeginOfRunAction(const G4Run* aRun) override;
void EndOfRunAction(const G4Run* aRun) override;
G4Run* GenerateRun() override;
private:
SteppingAction* fSteppingAction;
TrackingAction* fTrackingAction;
TrackingAction* fTrackingAction;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file SteppingAction.hh
/// \brief Definition of the SteppingAction class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -34,21 +34,23 @@
#ifndef SteppingAction_H
#define SteppingAction_H 1
#include "globals.hh"
#include "G4UserSteppingAction.hh"
#include "G4ThreeVector.hh"
#include "G4UserSteppingAction.hh"
#include "globals.hh"
#include <array>
class Run;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class SteppingAction : public G4UserSteppingAction {
public:
class SteppingAction : public G4UserSteppingAction
{
public:
SteppingAction();
~SteppingAction() override = default;
void UserSteppingAction( const G4Step* ) override;
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
@@ -62,7 +64,7 @@ class SteppingAction : public G4UserSteppingAction {
// This is necessary because different runs can have different primary particle
// types, kinetic energies, and detector configurations.
void SetRunPointer( Run* inputValue = nullptr ) { fRunPtr = inputValue; }
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
@@ -71,21 +73,21 @@ class SteppingAction : public G4UserSteppingAction {
G4double GetCubicVolumeScoringShell() const { return fCubicVolumeScoringShell; }
// The cubic-volume of the scoring shell is needed to get the fluence from the
// sum of step lengths inside that scoring shell.
static const G4int fkNumberKinematicRegions = 3; // all, below 20 MeV, above 20 MeV
static const G4int fkNumberScoringPositions = 2; // forward, backward (hemisphere with
// respect to the primary particle direction)
static const G4int fkNumberParticleTypes = 11; // all, e, gamma, mu, nu, pi, n, p, ions,
// respect to the primary particle direction)
static const G4int fkNumberParticleTypes = 11; // all, e, gamma, mu, nu, pi, n, p, ions,
// other-mesons, other-baryons
static const G4int fkNumberCombinations =
fkNumberKinematicRegions*fkNumberScoringPositions*fkNumberParticleTypes;
static const std::array< G4String, fkNumberKinematicRegions > fkArrayKinematicRegionNames;
static const std::array< G4String, fkNumberScoringPositions > fkArrayScoringPositionNames;
static const std::array< G4String, fkNumberParticleTypes > fkArrayParticleTypeNames;
static G4int GetIndex( const G4int iKinematicRegion, const G4int iScoringPosition,
const G4int iParticleType );
private:
fkNumberKinematicRegions * fkNumberScoringPositions * fkNumberParticleTypes;
static const std::array<G4String, fkNumberKinematicRegions> fkArrayKinematicRegionNames;
static const std::array<G4String, fkNumberScoringPositions> fkArrayScoringPositionNames;
static const std::array<G4String, fkNumberParticleTypes> fkArrayParticleTypeNames;
static G4int GetIndex(const G4int iKinematicRegion, const G4int iScoringPosition,
const G4int iParticleType);
private:
Run* fRunPtr; // Pointer to the Run object
G4int fPrimaryParticleId;
G4double fPrimaryParticleEnergy;
@@ -95,8 +97,8 @@ class SteppingAction : public G4UserSteppingAction {
G4bool fIsFirstStepInTarget;
G4bool fIsFirstStepInScoringShell;
G4double fCubicVolumeScoringShell;
std::array< G4double, fkNumberCombinations > fArraySumStepLengths;
std::array<G4double, fkNumberCombinations> fArraySumStepLengths;
// Array to collect the sum of step lengths in the scoring shell for the whole run,
// according to the various cases (kinematical region, scoring position and particle type).
// Note that the fluence in a scoring volume is defined as sum of step lengths
@@ -26,63 +26,65 @@
/// \file TrackingAction.hh
/// \brief Definition of the TrackingAction class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef TrackingAction_h
#ifndef TrackingAction_h
#define TrackingAction_h 1
#include "globals.hh"
#include "G4UserTrackingAction.hh"
#include "globals.hh"
#include <array>
class Run;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class TrackingAction : public G4UserTrackingAction {
// We are using this class to monitor the average multiplicity, the average
// kinetic energy, and the average total energy flow (i.e. sum of the
// kinetic energies) of different particle types as they are produced
// inside the target sphere.
// The aim is then to try to correlate some changes in these (more primitive)
// quantities with the observed changes in the (more indirect and complex)
// particle fluences.
class TrackingAction : public G4UserTrackingAction
{
// We are using this class to monitor the average multiplicity, the average
// kinetic energy, and the average total energy flow (i.e. sum of the
// kinetic energies) of different particle types as they are produced
// inside the target sphere.
// The aim is then to try to correlate some changes in these (more primitive)
// quantities with the observed changes in the (more indirect and complex)
// particle fluences.
public:
TrackingAction();
~TrackingAction() override = default;
void PreUserTrackingAction( const G4Track* ) override;
void PostUserTrackingAction( const G4Track* ) override;
void PreUserTrackingAction(const G4Track*) override;
void PostUserTrackingAction(const G4Track*) override;
void Initialize();
// This method is called by RunAction::BeginOfRunAction for the
// initialization of the tracking-action at the beginning of each Run.
void SetRunPointer( Run* inputValue = nullptr ) { fRunPtr = inputValue; }
void SetRunPointer(Run* inputValue = nullptr) { fRunPtr = inputValue; }
// This method is called by RunAction::BeginOfRunAction for providing to the
// tracking-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 tracking-action
// to the run object.
static const G4int fkNumberScoringVolumes = 1; // only the target sphere
static const G4int fkNumberScoringVolumes = 1; // only the target sphere
static const G4int fkNumberKinematicRegions = 3; // all, below 20 MeV, above 20 MeV
static const G4int fkNumberParticleTypes = 11; // all, e, gamma, mu, nu, pi, n, p, ions,
static const G4int fkNumberParticleTypes = 11; // all, e, gamma, mu, nu, pi, n, p, ions,
// other-mesons, other-baryons
static const G4int fkNumberCombinations =
fkNumberScoringVolumes*fkNumberKinematicRegions*fkNumberParticleTypes;
static const std::array< G4String, fkNumberScoringVolumes > fkArrayScoringVolumeNames;
static const std::array< G4String, fkNumberKinematicRegions > fkArrayKinematicRegionNames;
static const std::array< G4String, fkNumberParticleTypes > fkArrayParticleTypeNames;
static G4int GetIndex( const G4int iScoringVolume, const G4int iKinematicRegion,
const G4int iParticleType );
fkNumberScoringVolumes * fkNumberKinematicRegions * fkNumberParticleTypes;
static const std::array<G4String, fkNumberScoringVolumes> fkArrayScoringVolumeNames;
static const std::array<G4String, fkNumberKinematicRegions> fkArrayKinematicRegionNames;
static const std::array<G4String, fkNumberParticleTypes> fkArrayParticleTypeNames;
static G4int GetIndex(const G4int iScoringVolume, const G4int iKinematicRegion,
const G4int iParticleType);
private:
Run* fRunPtr; // Pointer to the Run object
std::array< G4long, fkNumberCombinations > fArrayMultiplicities;
std::array< G4double, fkNumberCombinations > fArraySumKineticEnergies;
std::array<G4long, fkNumberCombinations> fArrayMultiplicities;
std::array<G4double, fkNumberCombinations> fArraySumKineticEnergies;
// Keep record of the number of particles and their kinetic energy at production,
// according to the particle type and their kinetic energy range (below/above 20 MeV).
};