Import Geant4 11.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2022-12-09 14:43:28 +01:00
parent c07cea1fe0
commit 9f34590941
3810 changed files with 200490 additions and 182326 deletions
@@ -41,9 +41,9 @@
class ActionInitialization : public G4VUserActionInitialization {
public:
ActionInitialization();
virtual ~ActionInitialization();
virtual void BuildForMaster() const override;
virtual void Build() const override;
~ActionInitialization() override = default;
void BuildForMaster() const override;
void Build() const override;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -37,6 +37,7 @@
#include "G4Run.hh"
#include "G4ThreeVector.hh"
#include "SteppingAction.hh"
#include "TrackingAction.hh"
#include <array>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -45,49 +46,64 @@ 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
// 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
// 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();
~Run() override = default;
virtual 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.
virtual 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;
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 )
void SetPrimaryParticleId( const G4int inputValue ) { fPrimaryParticleId = inputValue; }
void SetPrimaryParticleEnergy( const G4double inputValue )
{ fPrimaryParticleEnergy = inputValue; }
void setPrimaryParticleDirection( const G4ThreeVector &inputValue )
void SetPrimaryParticleDirection( const G4ThreeVector &inputValue )
{ fPrimaryParticleDirection = inputValue; }
void setTargetMaterialName( const G4String &inputValue ) { fTargetMaterialName = inputValue; }
void setCubicVolumeScoringShell( const G4double 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; }
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; }
// Accessor methods useful to transfer information collected by the stepping-action
// into this Run class
// into this Run class
void SetTrackingArray1( const std::array< G4int,
TrackingAction::fkNumberCombinations >& inputArray );
std::array< G4int, 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:
G4int fNumEvents;
@@ -96,7 +112,9 @@ class Run : public G4Run {
G4ThreeVector fPrimaryParticleDirection;
G4String fTargetMaterialName;
G4double fCubicVolumeScoringShell;
std::array< G4double, SteppingAction::numberCombinations > fArray;
std::array< G4double, SteppingAction::fkNumberCombinations > fSteppingArray;
std::array< G4int, TrackingAction::fkNumberCombinations > fTrackingArray1;
std::array< G4double, TrackingAction::fkNumberCombinations > fTrackingArray2;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+8 -5
View File
@@ -38,18 +38,21 @@
class G4Run;
class SteppingAction;
class TrackingAction;
//....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;
RunAction( SteppingAction* steppingAction = nullptr,
TrackingAction* trackingAction = nullptr );
~RunAction() override = default;
void BeginOfRunAction( const G4Run* aRun ) override;
void EndOfRunAction( const G4Run* aRun ) override;
G4Run* GenerateRun() override;
private:
SteppingAction* fSteppingAction;
TrackingAction* fTrackingAction;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+15 -15
View File
@@ -46,9 +46,9 @@ class Run;
class SteppingAction : public G4UserSteppingAction {
public:
SteppingAction();
virtual ~SteppingAction();
~SteppingAction() override = default;
virtual 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
@@ -56,33 +56,33 @@ class SteppingAction : public G4UserSteppingAction {
// (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();
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; }
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 getCubicVolumeScoringShell() const { return fCubicVolumeScoringShell; }
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 numberKinematicRegions = 3; // all, below 20 MeV, above 20 MeV
static const G4int numberScoringPositions = 2; // forward, backward (hemisphere with
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 numberParticleTypes = 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 numberCombinations =
numberKinematicRegions*numberScoringPositions*numberParticleTypes;
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 iKinematicRegion, const G4int iScoringPosition,
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:
@@ -96,7 +96,7 @@ class SteppingAction : public G4UserSteppingAction {
G4bool fIsFirstStepInScoringShell;
G4double fCubicVolumeScoringShell;
std::array< G4double, numberCombinations > 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
@@ -0,0 +1,92 @@
//
// ********************************************************************
// * 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 TrackingAction.hh
/// \brief Definition of the TrackingAction class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef TrackingAction_h
#define TrackingAction_h 1
#include "globals.hh"
#include "G4UserTrackingAction.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.
public:
TrackingAction();
~TrackingAction() override = default;
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; }
// 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 fkNumberKinematicRegions = 3; // all, below 20 MeV, above 20 MeV
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 );
private:
Run* fRunPtr; // Pointer to the Run object
std::array< G4int, 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).
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif