Import Geant4 11.3.0.beta source tree
This commit is contained in:
@@ -31,40 +31,42 @@
|
||||
//....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"
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "G4PhysListFactory.hh"
|
||||
#include "G4RunManagerFactory.hh"
|
||||
#include "G4Threading.hh"
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
int main(int argc,char** argv) {
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
auto* runManager = G4RunManagerFactory::CreateRunManager();
|
||||
|
||||
|
||||
DetectorConstruction* pDetectorInstance = new DetectorConstruction;
|
||||
runManager->SetUserInitialization( pDetectorInstance );
|
||||
runManager->SetUserInitialization(pDetectorInstance);
|
||||
|
||||
// Physics list factory: use the PHYSLIST environmental variable.
|
||||
G4PhysListFactory factory;
|
||||
G4VModularPhysicsList* thePL = factory.ReferencePhysList();
|
||||
G4VModularPhysicsList* thePL = factory.ReferencePhysList();
|
||||
|
||||
runManager->SetUserInitialization( thePL );
|
||||
runManager->SetUserInitialization( new ActionInitialization );
|
||||
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);
|
||||
}
|
||||
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;
|
||||
// job termination
|
||||
delete runManager;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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).
|
||||
};
|
||||
|
||||
@@ -32,11 +32,12 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "Run.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "TrackingAction.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -44,21 +45,23 @@ ActionInitialization::ActionInitialization() : G4VUserActionInitialization() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const {
|
||||
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 );
|
||||
SetUserAction(new RunAction);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::Build() const {
|
||||
void ActionInitialization::Build() const
|
||||
{
|
||||
// This is called in the SEQ-mode and in the MT-mode only for Worker threads.
|
||||
SetUserAction( new PrimaryGeneratorAction );
|
||||
SetUserAction(new PrimaryGeneratorAction);
|
||||
SteppingAction* steppingAction = new SteppingAction;
|
||||
SetUserAction( steppingAction );
|
||||
SetUserAction(steppingAction);
|
||||
TrackingAction* trackingAction = new TrackingAction;
|
||||
SetUserAction( trackingAction );
|
||||
SetUserAction( new RunAction( steppingAction, trackingAction ) );
|
||||
SetUserAction(trackingAction);
|
||||
SetUserAction(new RunAction(steppingAction, trackingAction));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -32,59 +32,67 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "DetectorMessenger.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4Box.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Orb.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"
|
||||
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction() :
|
||||
fMaterial( nullptr ),
|
||||
fExperimentalHall_log( nullptr ), fExperimentalHall_phys( nullptr ),
|
||||
fLogicSphere( nullptr ), fPhysiSphere( nullptr ),
|
||||
fLogicScoringShell( nullptr ), fPhysiScoringShell( nullptr ),
|
||||
fDetectorMessenger( nullptr ),
|
||||
fRadius( 1.0*CLHEP::m ) //***LOOKHERE*** Default values
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
: fMaterial(nullptr),
|
||||
fExperimentalHall_log(nullptr),
|
||||
fExperimentalHall_phys(nullptr),
|
||||
fLogicSphere(nullptr),
|
||||
fPhysiSphere(nullptr),
|
||||
fLogicScoringShell(nullptr),
|
||||
fPhysiScoringShell(nullptr),
|
||||
fDetectorMessenger(nullptr),
|
||||
fRadius(1.0 * CLHEP::m) //***LOOKHERE*** Default values
|
||||
{
|
||||
//G4cout << " BEGIN DetectorConstruction::DetectorConstruction()" << G4endl;
|
||||
fMaterial = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Fe" ); //***LOOKHERE***
|
||||
// Default material
|
||||
fDetectorMessenger = new DetectorMessenger( this );
|
||||
//G4cout << " END DetectorConstruction::DetectorConstruction()" << G4endl;
|
||||
// G4cout << " BEGIN DetectorConstruction::DetectorConstruction()" << G4endl;
|
||||
fMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Fe"); //***LOOKHERE***
|
||||
// Default material
|
||||
fDetectorMessenger = new DetectorMessenger(this);
|
||||
// G4cout << " END DetectorConstruction::DetectorConstruction()" << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::~DetectorConstruction() {
|
||||
DetectorConstruction::~DetectorConstruction()
|
||||
{
|
||||
delete fDetectorMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct() {
|
||||
//G4cout << " BEGIN DetectorConstruction::Construct()" << G4endl;
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
{
|
||||
// G4cout << " BEGIN DetectorConstruction::Construct()" << G4endl;
|
||||
return ConstructSphere();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::ConstructSphere() {
|
||||
//G4cout << " BEGIN DetectorConstruction::ConstructSphere()" << G4endl;
|
||||
G4VPhysicalVolume* DetectorConstruction::ConstructSphere()
|
||||
{
|
||||
// G4cout << " BEGIN DetectorConstruction::ConstructSphere()" << G4endl;
|
||||
|
||||
// Clean old geometry, if any.
|
||||
G4GeometryManager::GetInstance()->OpenGeometry();
|
||||
@@ -97,123 +105,119 @@ G4VPhysicalVolume* DetectorConstruction::ConstructSphere() {
|
||||
// The world volume (experimental hall) is a box 10% bigger than the sphere
|
||||
// and it is filled of "G4_Galactic" material.
|
||||
|
||||
G4double expHall_x = 1.1*fRadius; // half dimension along x
|
||||
G4double expHall_y = 1.1*fRadius; // half dimension along y
|
||||
G4double expHall_z = 1.1*fRadius; // half dimension along z
|
||||
G4double expHall_x = 1.1 * fRadius; // half dimension along x
|
||||
G4double expHall_y = 1.1 * fRadius; // half dimension along y
|
||||
G4double expHall_z = 1.1 * fRadius; // half dimension along z
|
||||
|
||||
G4Material* vacuum = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Galactic" );
|
||||
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
|
||||
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 sphere
|
||||
G4Orb* solidSphere = new G4Orb( "solidSphere", // name
|
||||
fRadius ); // outer radius
|
||||
fLogicSphere = new G4LogicalVolume( solidSphere, // solid
|
||||
fMaterial, // material
|
||||
"logicSphere", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiSphere = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiSphere", // name
|
||||
fLogicSphere, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
G4Orb* solidSphere = new G4Orb("solidSphere", // name
|
||||
fRadius); // outer radius
|
||||
fLogicSphere = new G4LogicalVolume(solidSphere, // solid
|
||||
fMaterial, // material
|
||||
"logicSphere", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0); // user limits
|
||||
fPhysiSphere = new G4PVPlacement(0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiSphere", // name
|
||||
fLogicSphere, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0); // copy number
|
||||
|
||||
// Scoring shell (a thin vacuum layer, immediately outside the target sphere)
|
||||
G4Sphere* solidScoringShell = new G4Sphere( "solidScoringShell", // name
|
||||
fRadius, // Inner radius (the radius
|
||||
// of the target sphere)
|
||||
fRadius + 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
|
||||
fLogicScoringShell = new G4LogicalVolume( solidScoringShell, // solid
|
||||
vacuum, // material
|
||||
"logicScoringShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiScoringShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiScoringShell", // name
|
||||
fLogicScoringShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
G4Sphere* solidScoringShell = new G4Sphere("solidScoringShell", // name
|
||||
fRadius, // Inner radius (the radius
|
||||
// of the target sphere)
|
||||
fRadius + 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
|
||||
fLogicScoringShell = new G4LogicalVolume(solidScoringShell, // solid
|
||||
vacuum, // material
|
||||
"logicScoringShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0); // user limits
|
||||
fPhysiScoringShell = new G4PVPlacement(0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiScoringShell", // name
|
||||
fLogicScoringShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0); // copy number
|
||||
|
||||
G4cout << G4endl
|
||||
<< "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 << G4endl;
|
||||
G4cout << G4endl << "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 << G4endl;
|
||||
|
||||
//G4cout << " END DetectorConstruction::ConstructSphere()
|
||||
// G4cout << " END DetectorConstruction::ConstructSphere()
|
||||
|
||||
return fExperimentalHall_phys;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMaterial( const G4String name ) {
|
||||
fMaterial = G4NistManager::Instance()->FindOrBuildMaterial( name );
|
||||
if ( fMaterial == nullptr ) {
|
||||
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" );
|
||||
void DetectorConstruction::SetMaterial(const G4String name)
|
||||
{
|
||||
fMaterial = G4NistManager::Instance()->FindOrBuildMaterial(name);
|
||||
if (fMaterial == nullptr) {
|
||||
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 ( fLogicSphere ) fLogicSphere->SetMaterial( fMaterial );
|
||||
//G4cout << " Absorber Material = " << logicSphere->GetMaterial()->GetName() << G4endl;
|
||||
if (fLogicSphere) fLogicSphere->SetMaterial(fMaterial);
|
||||
// G4cout << " Absorber Material = " << logicSphere->GetMaterial()->GetName() << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::UpdateGeometry() {
|
||||
//G4cout << " BEGIN DetectorConstruction::UpdateGeometry" << G4endl;
|
||||
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;
|
||||
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 << G4endl
|
||||
<< " ------ DetectorConstruction::PrintParameters() ------ " << G4endl
|
||||
void DetectorConstruction::PrintParameters()
|
||||
{
|
||||
G4cout << G4endl << G4endl << " ------ DetectorConstruction::PrintParameters() ------ " << G4endl
|
||||
<< " Material = " << fMaterial->GetName() << G4endl
|
||||
<< " Radius = " << fRadius << " mm" << G4endl
|
||||
<< " ScoringThickness = " << fScoringThickness << " mm" << G4endl
|
||||
<< " -------------------------------------------------------- "
|
||||
<< G4endl << G4endl;
|
||||
<< " -------------------------------------------------------- " << G4endl << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -32,42 +32,46 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorMessenger.hh"
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::DetectorMessenger( DetectorConstruction* myDet ) : fDetector( myDet ) {
|
||||
fDetectorDir = new G4UIdirectory( "/mydet/" );
|
||||
fDetectorDir->SetGuidance( "Detector control." );
|
||||
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 );
|
||||
|
||||
fRadius = new G4UIcmdWithADoubleAndUnit( "/mydet/radius", this );
|
||||
fRadius->SetParameterName( "choiceRadius", true );
|
||||
fRadius->SetGuidance( "Target sphere radius" );
|
||||
fRadius->SetDefaultValue( 1000.0 ); // default: 1 meter.
|
||||
fRadius->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
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);
|
||||
|
||||
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 );
|
||||
fRadius = new G4UIcmdWithADoubleAndUnit("/mydet/radius", this);
|
||||
fRadius->SetParameterName("choiceRadius", true);
|
||||
fRadius->SetGuidance("Target sphere radius");
|
||||
fRadius->SetDefaultValue(1000.0); // default: 1 meter.
|
||||
fRadius->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() {
|
||||
DetectorMessenger::~DetectorMessenger()
|
||||
{
|
||||
delete fDetectorDir;
|
||||
delete fMaterial;
|
||||
delete fRadius;
|
||||
@@ -76,14 +80,15 @@ DetectorMessenger::~DetectorMessenger() {
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorMessenger::SetNewValue( G4UIcommand* command, G4String newValue ) {
|
||||
if ( command == fMaterial ) {
|
||||
fDetector->SetMaterial( newValue );
|
||||
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if (command == fMaterial) {
|
||||
fDetector->SetMaterial(newValue);
|
||||
}
|
||||
if ( command == fRadius ) {
|
||||
fDetector->SetRadius( fRadius->GetNewDoubleValue( newValue ) );
|
||||
if (command == fRadius) {
|
||||
fDetector->SetRadius(fRadius->GetNewDoubleValue(newValue));
|
||||
}
|
||||
if ( command == fUpdateCommand ) {
|
||||
if (command == fUpdateCommand) {
|
||||
fDetector->UpdateGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,45 +32,50 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction() : G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun( nullptr ) {
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction()
|
||||
: G4VUserPrimaryGeneratorAction(), fParticleGun(nullptr)
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun( n_particle );
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
//***LOOKHERE*** Default particle and energy
|
||||
fParticleGun->SetParticleDefinition( particleTable->FindParticle( "geantino" ) );
|
||||
fParticleGun->SetParticleEnergy( 10.0*GeV );
|
||||
//***LOOKHERE*** Default particle and energy
|
||||
fParticleGun->SetParticleDefinition(particleTable->FindParticle("geantino"));
|
||||
fParticleGun->SetParticleEnergy(10.0 * GeV);
|
||||
SetGunPosition();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction() {
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
{
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::SetGunPosition() const {
|
||||
void PrimaryGeneratorAction::SetGunPosition() const
|
||||
{
|
||||
// Shoot the particle from the center of the sphere
|
||||
fParticleGun->SetParticlePosition( G4ThreeVector( 0.0, 0.0, 0.0 ) );
|
||||
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 );
|
||||
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......
|
||||
|
||||
@@ -32,88 +32,94 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "Run.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::Run() : G4Run(), fNumEvents( 0 ),
|
||||
fPrimaryParticleId( 0 ), fPrimaryParticleEnergy( 0.0 ),
|
||||
fPrimaryParticleDirection( G4ThreeVector( 0.0, 0.0, 0.0 ) ),
|
||||
fTargetMaterialName( "" ), fCubicVolumeScoringShell( 1.0 )
|
||||
Run::Run()
|
||||
: G4Run(),
|
||||
fNumEvents(0),
|
||||
fPrimaryParticleId(0),
|
||||
fPrimaryParticleEnergy(0.0),
|
||||
fPrimaryParticleDirection(G4ThreeVector(0.0, 0.0, 0.0)),
|
||||
fTargetMaterialName(""),
|
||||
fCubicVolumeScoringShell(1.0)
|
||||
{
|
||||
fSteppingArray.fill( 0.0 );
|
||||
fTrackingArray1.fill( 0 );
|
||||
fTrackingArray2.fill( 0.0 );
|
||||
fSteppingArray.fill(0.0);
|
||||
fTrackingArray1.fill(0);
|
||||
fTrackingArray2.fill(0.0);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::RecordEvent( const G4Event* anEvent ) {
|
||||
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 );
|
||||
if (nEvt % 10 == 0) G4cout << " Event#=" << nEvt << G4endl;
|
||||
G4Run::RecordEvent(anEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Merge( const G4Run* aRun ) {
|
||||
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 );
|
||||
const Run* localRun = static_cast<const Run*>(aRun);
|
||||
fPrimaryParticleId = localRun->GetPrimaryParticleId();
|
||||
fPrimaryParticleEnergy = localRun->GetPrimaryParticleEnergy();
|
||||
fPrimaryParticleDirection = localRun->GetPrimaryParticleDirection();
|
||||
fTargetMaterialName = localRun->GetTargetMaterialName();
|
||||
fCubicVolumeScoringShell = localRun->GetCubicVolumeScoringShell();
|
||||
fNumEvents += localRun->GetNumberOfEvent();
|
||||
for ( G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i ) {
|
||||
for (G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i) {
|
||||
fSteppingArray[i] += localRun->GetSteppingArray()[i];
|
||||
}
|
||||
for ( G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i ) {
|
||||
for (G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i) {
|
||||
fTrackingArray1[i] += localRun->GetTrackingArray1()[i];
|
||||
fTrackingArray2[i] += localRun->GetTrackingArray2()[i];
|
||||
}
|
||||
G4Run::Merge( aRun );
|
||||
G4Run::Merge(aRun);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::PrintInfo() const {
|
||||
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 );
|
||||
std::max(1.0, fNumEvents > 0 ? fNumEvents * 1.0 : GetNumberOfEvent() * 1.0);
|
||||
// The fluence in the scoring shell is defined as sum of step lengths in that shell
|
||||
// divided by the cubic-volume of that scoring shell.
|
||||
const G4double conversionFactor = CLHEP::cm * CLHEP::cm; // From mm^-2 to cm^-2
|
||||
const G4double factor =
|
||||
conversionFactor / ( 0.5*fCubicVolumeScoringShell*floatingNumberOfEvents );
|
||||
conversionFactor / (0.5 * fCubicVolumeScoringShell * 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
|
||||
<< 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 shell = " << fCubicVolumeScoringShell << " 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::fkNumberKinematicRegions; ++i ) {
|
||||
for ( G4int j = 0; j < SteppingAction::fkNumberScoringPositions; ++j ) {
|
||||
for ( G4int k = 0; k < SteppingAction::fkNumberParticleTypes; ++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::fkArrayKinematicRegionNames[i]
|
||||
<< " " << std::setw(12) << SteppingAction::fkArrayScoringPositionNames[j]
|
||||
<< " " << std::setw(12) << SteppingAction::fkArrayParticleTypeNames[k]
|
||||
<< " " << std::setw( 8) << factor*fSteppingArray[index] << G4endl;
|
||||
for (G4int i = 0; i < SteppingAction::fkNumberKinematicRegions; ++i) {
|
||||
for (G4int j = 0; j < SteppingAction::fkNumberScoringPositions; ++j) {
|
||||
for (G4int k = 0; k < SteppingAction::fkNumberParticleTypes; ++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::fkArrayKinematicRegionNames[i] << " " << std::setw(12)
|
||||
<< SteppingAction::fkArrayScoringPositionNames[j] << " " << std::setw(12)
|
||||
<< SteppingAction::fkArrayParticleTypeNames[k] << " " << std::setw(8)
|
||||
<< factor * fSteppingArray[index] << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,21 +127,19 @@ void Run::PrintInfo() const {
|
||||
<< " Extra information: particle production \t \t <N> <E_kin> <Sum_Ekin> [MeV]"
|
||||
<< G4endl;
|
||||
const G4double normalization = 1.0 / floatingNumberOfEvents;
|
||||
for ( G4int i = 0; i < TrackingAction::fkNumberScoringVolumes; ++i ) {
|
||||
for ( G4int j = 0; j < TrackingAction::fkNumberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < TrackingAction::fkNumberParticleTypes; ++k ) {
|
||||
G4int index = TrackingAction::GetIndex( i, j, k );
|
||||
//G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
G4cout << " case=" << std::setw(3) << index
|
||||
<< " " << std::setw(12) << TrackingAction::fkArrayScoringVolumeNames[i]
|
||||
<< " " << std::setw(12) << TrackingAction::fkArrayKinematicRegionNames[j]
|
||||
<< " " << std::setw(12) << TrackingAction::fkArrayParticleTypeNames[k]
|
||||
<< " " << std::setw( 8) << normalization * fTrackingArray1[index]
|
||||
<< " " << std::setw( 8) << ( fTrackingArray1[index] > 0 ?
|
||||
fTrackingArray2[index] / fTrackingArray1[index] :
|
||||
0.0 )
|
||||
<< " " << std::setw( 8) << normalization * fTrackingArray2[index]
|
||||
<< G4endl;
|
||||
for (G4int i = 0; i < TrackingAction::fkNumberScoringVolumes; ++i) {
|
||||
for (G4int j = 0; j < TrackingAction::fkNumberKinematicRegions; ++j) {
|
||||
for (G4int k = 0; k < TrackingAction::fkNumberParticleTypes; ++k) {
|
||||
G4int index = TrackingAction::GetIndex(i, j, k);
|
||||
// G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
G4cout << " case=" << std::setw(3) << index << " " << std::setw(12)
|
||||
<< TrackingAction::fkArrayScoringVolumeNames[i] << " " << std::setw(12)
|
||||
<< TrackingAction::fkArrayKinematicRegionNames[j] << " " << std::setw(12)
|
||||
<< TrackingAction::fkArrayParticleTypeNames[k] << " " << std::setw(8)
|
||||
<< normalization * fTrackingArray1[index] << " " << std::setw(8)
|
||||
<< (fTrackingArray1[index] > 0 ? fTrackingArray2[index] / fTrackingArray1[index]
|
||||
: 0.0)
|
||||
<< " " << std::setw(8) << normalization * fTrackingArray2[index] << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,27 +148,30 @@ void Run::PrintInfo() const {
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::SetSteppingArray( const std::array< G4double,
|
||||
SteppingAction::fkNumberCombinations >& inputArray ) {
|
||||
for ( G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i ) {
|
||||
void Run::SetSteppingArray(
|
||||
const std::array<G4double, SteppingAction::fkNumberCombinations>& inputArray)
|
||||
{
|
||||
for (G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i) {
|
||||
fSteppingArray[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::SetTrackingArray1( const std::array< G4long,
|
||||
TrackingAction::fkNumberCombinations >& inputArray ) {
|
||||
for ( G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i ) {
|
||||
void Run::SetTrackingArray1(
|
||||
const std::array<G4long, TrackingAction::fkNumberCombinations>& inputArray)
|
||||
{
|
||||
for (G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i) {
|
||||
fTrackingArray1[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::SetTrackingArray2( const std::array< G4double,
|
||||
TrackingAction::fkNumberCombinations >& inputArray ) {
|
||||
for ( G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i ) {
|
||||
void Run::SetTrackingArray2(
|
||||
const std::array<G4double, TrackingAction::fkNumberCombinations>& inputArray)
|
||||
{
|
||||
for (G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i) {
|
||||
fTrackingArray2[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,46 +32,52 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4Run.hh"
|
||||
|
||||
#include "Run.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "TrackingAction.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction( SteppingAction* steppingAction, TrackingAction* trackingAction ) :
|
||||
G4UserRunAction(), fSteppingAction( steppingAction ), fTrackingAction( trackingAction ) {}
|
||||
RunAction::RunAction(SteppingAction* steppingAction, TrackingAction* trackingAction)
|
||||
: G4UserRunAction(), fSteppingAction(steppingAction), fTrackingAction(trackingAction)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4Run* RunAction::GenerateRun() {
|
||||
G4Run* RunAction::GenerateRun()
|
||||
{
|
||||
return new Run;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction( const G4Run* aRun ) {
|
||||
void RunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
G4cout << "### Run " << aRun->GetRunID() << " starts." << G4endl;
|
||||
Run* run = const_cast< Run* >( static_cast< const Run* >( aRun ) );
|
||||
if ( run == nullptr ) return;
|
||||
if ( fSteppingAction != nullptr ) {
|
||||
Run* run = const_cast<Run*>(static_cast<const Run*>(aRun));
|
||||
if (run == nullptr) return;
|
||||
if (fSteppingAction != nullptr) {
|
||||
fSteppingAction->Initialize();
|
||||
fSteppingAction->SetRunPointer( run );
|
||||
fSteppingAction->SetRunPointer(run);
|
||||
}
|
||||
if ( fTrackingAction != nullptr ) {
|
||||
if (fTrackingAction != nullptr) {
|
||||
fTrackingAction->Initialize();
|
||||
fTrackingAction->SetRunPointer( run );
|
||||
fTrackingAction->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();
|
||||
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......
|
||||
|
||||
@@ -32,44 +32,47 @@
|
||||
//....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::fkNumberKinematicRegions >
|
||||
SteppingAction::fkArrayKinematicRegionNames = { "", "below 20 MeV", "above 20 MeV" };
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4LossTableManager.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
|
||||
const std::array< G4String, SteppingAction::fkNumberScoringPositions >
|
||||
SteppingAction::fkArrayScoringPositionNames = { "forward", "backward" };
|
||||
const std::array<G4String, SteppingAction::fkNumberKinematicRegions>
|
||||
SteppingAction::fkArrayKinematicRegionNames = {"", "below 20 MeV", "above 20 MeV"};
|
||||
|
||||
const std::array< G4String, SteppingAction::fkNumberParticleTypes >
|
||||
SteppingAction::fkArrayParticleTypeNames = { "all", "electron", "gamma", "muon", "neutrino",
|
||||
"pion", "neutron", "proton", "ion", "otherMeson",
|
||||
"otherBaryon" };
|
||||
const std::array<G4String, SteppingAction::fkNumberScoringPositions>
|
||||
SteppingAction::fkArrayScoringPositionNames = {"forward", "backward"};
|
||||
|
||||
const std::array<G4String, SteppingAction::fkNumberParticleTypes>
|
||||
SteppingAction::fkArrayParticleTypeNames = {"all", "electron", "gamma", "muon",
|
||||
"neutrino", "pion", "neutron", "proton",
|
||||
"ion", "otherMeson", "otherBaryon"};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4int SteppingAction::GetIndex( const G4int iKinematicRegion, const G4int iScoringPosition,
|
||||
const G4int iParticleType ) {
|
||||
G4int SteppingAction::GetIndex(const G4int iKinematicRegion, const G4int iScoringPosition,
|
||||
const G4int iParticleType)
|
||||
{
|
||||
G4int index = -1;
|
||||
if ( iKinematicRegion >= 0 && iKinematicRegion < fkNumberKinematicRegions &&
|
||||
iScoringPosition >= 0 && iScoringPosition < fkNumberScoringPositions &&
|
||||
iParticleType >= 0 && iParticleType < fkNumberParticleTypes ) {
|
||||
index = iKinematicRegion * fkNumberScoringPositions * fkNumberParticleTypes +
|
||||
iScoringPosition * fkNumberParticleTypes +
|
||||
iParticleType;
|
||||
if (iKinematicRegion >= 0 && iKinematicRegion < fkNumberKinematicRegions && iScoringPosition >= 0
|
||||
&& iScoringPosition < fkNumberScoringPositions && iParticleType >= 0
|
||||
&& iParticleType < fkNumberParticleTypes)
|
||||
{
|
||||
index = iKinematicRegion * fkNumberScoringPositions * fkNumberParticleTypes
|
||||
+ iScoringPosition * fkNumberParticleTypes + iParticleType;
|
||||
}
|
||||
if ( index < 0 || index >= fkNumberCombinations ) {
|
||||
if (index < 0 || index >= fkNumberCombinations) {
|
||||
G4cerr << "SteppingAction::GetIndex : WRONG index=" << index << " set it to 0 !" << G4endl;
|
||||
index = 0;
|
||||
}
|
||||
@@ -78,23 +81,25 @@ G4int SteppingAction::GetIndex( const G4int iKinematicRegion, const G4int iScori
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction() :G4UserSteppingAction() {
|
||||
SteppingAction::SteppingAction() : G4UserSteppingAction()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::Initialize() {
|
||||
// Initialization needed at the beginning of each Run
|
||||
void SteppingAction::Initialize()
|
||||
{
|
||||
// Initialization needed at the beginning of each Run
|
||||
fPrimaryParticleId = 0;
|
||||
fPrimaryParticleEnergy = 0.0;
|
||||
fPrimaryParticleDirection = G4ThreeVector( 0.0, 0.0, 1.0 );
|
||||
fPrimaryParticleDirection = G4ThreeVector(0.0, 0.0, 1.0);
|
||||
fTargetMaterialName = "";
|
||||
fIsFirstStepOfTheEvent = true;
|
||||
fIsFirstStepInTarget = true;
|
||||
fIsFirstStepInScoringShell = true;
|
||||
fIsFirstStepInScoringShell = true;
|
||||
fCubicVolumeScoringShell = 1.0;
|
||||
for ( G4int i = 0; i < fkNumberCombinations; ++i ) {
|
||||
for (G4int i = 0; i < fkNumberCombinations; ++i) {
|
||||
fArraySumStepLengths[i] = 0.0;
|
||||
}
|
||||
/*
|
||||
@@ -119,47 +124,50 @@ void SteppingAction::Initialize() {
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
void SteppingAction::UserSteppingAction(const G4Step* theStep)
|
||||
{
|
||||
// Get information on the primary particle
|
||||
if ( fIsFirstStepOfTheEvent ) {
|
||||
if ( theStep->GetTrack()->GetParentID() == 0 ) {
|
||||
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 );
|
||||
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() == "physiSphere" ) {
|
||||
if (fIsFirstStepInTarget
|
||||
&& theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiSphere")
|
||||
{
|
||||
fTargetMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->SetTargetMaterialName( fTargetMaterialName );
|
||||
if (fRunPtr) fRunPtr->SetTargetMaterialName(fTargetMaterialName);
|
||||
fIsFirstStepInTarget = false;
|
||||
}
|
||||
// Get information on step lengths in the scoring shell
|
||||
if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringShell" ) {
|
||||
if ( fIsFirstStepInScoringShell ) {
|
||||
if (theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringShell") {
|
||||
if (fIsFirstStepInScoringShell) {
|
||||
fCubicVolumeScoringShell =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->SetCubicVolumeScoringShell( fCubicVolumeScoringShell );
|
||||
if (fRunPtr) fRunPtr->SetCubicVolumeScoringShell(fCubicVolumeScoringShell);
|
||||
fIsFirstStepInScoringShell = false;
|
||||
}
|
||||
G4double stepLength = theStep->GetTrack()->GetStepLength() * theStep->GetTrack()->GetWeight();
|
||||
G4int absPdg = theStep->GetTrack()->GetDefinition() == nullptr ? 0 :
|
||||
std::abs( theStep->GetTrack()->GetDefinition()->GetPDGEncoding() );
|
||||
/*
|
||||
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 << " "
|
||||
<< " L[mm]=" << stepLength << " "
|
||||
<< ( fPrimaryParticleDirection.dot( theStep->GetTrack()->GetPosition().unit() ) > 0.0
|
||||
? "forward" : "backward" ) << G4endl;
|
||||
*/
|
||||
@@ -168,35 +176,45 @@ void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
// 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;
|
||||
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.)
|
||||
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 : kinematic region, scoring position, and particle type
|
||||
G4int index = GetIndex( iKinematicRegion, iScoringPosition, iParticleType );
|
||||
G4int index = GetIndex(iKinematicRegion, iScoringPosition, iParticleType);
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "all" particle case, with the same kinematic region and scoring position
|
||||
index = GetIndex( iKinematicRegion, iScoringPosition, 0 );
|
||||
index = GetIndex(iKinematicRegion, iScoringPosition, 0);
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region case, with the same scoring position and particle type
|
||||
index = GetIndex( 0, iScoringPosition, iParticleType );
|
||||
index = GetIndex(0, iScoringPosition, iParticleType);
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region and "all" particle, with the same scoring position
|
||||
index = GetIndex( 0, iScoringPosition, 0 );
|
||||
index = GetIndex(0, iScoringPosition, 0);
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
if ( fRunPtr ) fRunPtr->SetSteppingArray( fArraySumStepLengths );
|
||||
if (fRunPtr) fRunPtr->SetSteppingArray(fArraySumStepLengths);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,112 +32,127 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "TrackingAction.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "Run.hh"
|
||||
|
||||
const std::array< G4String, TrackingAction::fkNumberScoringVolumes >
|
||||
TrackingAction::fkArrayScoringVolumeNames = { "sphere" };
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Track.hh"
|
||||
|
||||
const std::array< G4String, TrackingAction::fkNumberKinematicRegions >
|
||||
TrackingAction::fkArrayKinematicRegionNames = { "", "below 20 MeV", "above 20 MeV" };
|
||||
const std::array<G4String, TrackingAction::fkNumberScoringVolumes>
|
||||
TrackingAction::fkArrayScoringVolumeNames = {"sphere"};
|
||||
|
||||
const std::array< G4String, TrackingAction::fkNumberParticleTypes >
|
||||
TrackingAction::fkArrayParticleTypeNames = { "all", "electron", "gamma", "muon", "neutrino",
|
||||
"pion", "neutron", "proton", "ion", "otherMeson",
|
||||
"otherBaryon" };
|
||||
const std::array<G4String, TrackingAction::fkNumberKinematicRegions>
|
||||
TrackingAction::fkArrayKinematicRegionNames = {"", "below 20 MeV", "above 20 MeV"};
|
||||
|
||||
const std::array<G4String, TrackingAction::fkNumberParticleTypes>
|
||||
TrackingAction::fkArrayParticleTypeNames = {"all", "electron", "gamma", "muon",
|
||||
"neutrino", "pion", "neutron", "proton",
|
||||
"ion", "otherMeson", "otherBaryon"};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4int TrackingAction::GetIndex( const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType ) {
|
||||
G4int TrackingAction::GetIndex(const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType)
|
||||
{
|
||||
G4int index = -1;
|
||||
if ( iScoringVolume >= 0 && iScoringVolume < fkNumberScoringVolumes &&
|
||||
iKinematicRegion >= 0 && iKinematicRegion < fkNumberKinematicRegions &&
|
||||
iParticleType >= 0 && iParticleType < fkNumberParticleTypes ) {
|
||||
index = iScoringVolume * fkNumberKinematicRegions * fkNumberParticleTypes +
|
||||
iKinematicRegion * fkNumberParticleTypes +
|
||||
iParticleType;
|
||||
if (iScoringVolume >= 0 && iScoringVolume < fkNumberScoringVolumes && iKinematicRegion >= 0
|
||||
&& iKinematicRegion < fkNumberKinematicRegions && iParticleType >= 0
|
||||
&& iParticleType < fkNumberParticleTypes)
|
||||
{
|
||||
index = iScoringVolume * fkNumberKinematicRegions * fkNumberParticleTypes
|
||||
+ iKinematicRegion * fkNumberParticleTypes + iParticleType;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
TrackingAction::TrackingAction() : G4UserTrackingAction() {
|
||||
TrackingAction::TrackingAction() : G4UserTrackingAction()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void TrackingAction::Initialize() {
|
||||
// Initialization needed at the beginning of each Run
|
||||
fArrayMultiplicities.fill( 0 );
|
||||
fArraySumKineticEnergies.fill( 0.0 );
|
||||
void TrackingAction::Initialize()
|
||||
{
|
||||
// Initialization needed at the beginning of each Run
|
||||
fArrayMultiplicities.fill(0);
|
||||
fArraySumKineticEnergies.fill(0.0);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void TrackingAction::PreUserTrackingAction( const G4Track* aTrack ) {
|
||||
// This method is called not only once when a particle is created,
|
||||
void TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
|
||||
{
|
||||
// This method is called not only once when a particle is created,
|
||||
// but also each time it is resumed, in the case the track gets suspended,
|
||||
// as it happens in the case of neutrons with _HP Physics Lists.
|
||||
// To be sure that we collect information about a track one and only once,
|
||||
// we require that the current step be the first one.
|
||||
if ( aTrack == nullptr ||
|
||||
aTrack->GetCurrentStepNumber() != 0 ||
|
||||
aTrack->GetDefinition() == nullptr ||
|
||||
aTrack->GetLogicalVolumeAtVertex() == nullptr ||
|
||||
aTrack->GetLogicalVolumeAtVertex()->GetName() != "logicSphere" ) return;
|
||||
if (aTrack == nullptr || aTrack->GetCurrentStepNumber() != 0 || aTrack->GetDefinition() == nullptr
|
||||
|| aTrack->GetLogicalVolumeAtVertex() == nullptr
|
||||
|| aTrack->GetLogicalVolumeAtVertex()->GetName() != "logicSphere")
|
||||
return;
|
||||
G4int iScoringVolume = 0;
|
||||
// Three kinematical regions: [0] : any value ; [1] : below 20 MeV ; [2] : above 20 MeV
|
||||
G4int iKinematicRegion = aTrack->GetKineticEnergy() < 20.0 ? 1 : 2;
|
||||
G4int absPdg = std::abs( aTrack->GetDefinition()->GetPDGEncoding() );
|
||||
G4int absPdg = std::abs(aTrack->GetDefinition()->GetPDGEncoding());
|
||||
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( aTrack->GetDefinition() ) ||
|
||||
G4IonTable::IsAntiIon( aTrack->GetDefinition() ) ) iParticleType = 8;
|
||||
// ions (and anti-ions)
|
||||
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.)
|
||||
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(aTrack->GetDefinition())
|
||||
|| G4IonTable::IsAntiIon(aTrack->GetDefinition()))
|
||||
iParticleType = 8;
|
||||
// ions (and anti-ions)
|
||||
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 );
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
// Consider the "all" particle case, with the same scoring volume and kinematic region
|
||||
index = GetIndex( iScoringVolume, iKinematicRegion, 0 );
|
||||
G4int index = GetIndex(iScoringVolume, iKinematicRegion, iParticleType);
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
// Consider the "any" kinematic region case, with the same scoring volume and particle type
|
||||
index = GetIndex( iScoringVolume, 0, iParticleType );
|
||||
// Consider the "all" particle case, with the same scoring volume and kinematic region
|
||||
index = GetIndex(iScoringVolume, iKinematicRegion, 0);
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
// Consider the "any" kinematic region case, with the same scoring volume and particle type
|
||||
index = GetIndex(iScoringVolume, 0, iParticleType);
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
// Consider the "any" kinematic region and "all" particle, with the same scoring volume
|
||||
index = GetIndex( iScoringVolume, 0, 0 );
|
||||
index = GetIndex(iScoringVolume, 0, 0);
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
if ( fRunPtr ) {
|
||||
fRunPtr->SetTrackingArray1( fArrayMultiplicities );
|
||||
fRunPtr->SetTrackingArray2( fArraySumKineticEnergies );
|
||||
if (fRunPtr) {
|
||||
fRunPtr->SetTrackingArray1(fArrayMultiplicities);
|
||||
fRunPtr->SetTrackingArray2(fArraySumKineticEnergies);
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void TrackingAction::PostUserTrackingAction( const G4Track* /* aTrack */ ) {}
|
||||
void TrackingAction::PostUserTrackingAction(const G4Track* /* aTrack */) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Reference in New Issue
Block a user