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
@@ -28,6 +28,7 @@
/// \brief Implementation of the ActionInitialization class
#include "ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "EventAction.hh"
#include "PrimaryGeneratorAction.hh"
@@ -38,8 +39,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::ActionInitialization(DetectorConstruction* det)
: G4VUserActionInitialization()
, fDetector(det)
: G4VUserActionInitialization(), fDetector(det)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -48,10 +48,7 @@ ActionInitialization::~ActionInitialization() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::BuildForMaster() const
{
SetUserAction(new RunAction(fDetector));
}
void ActionInitialization::BuildForMaster() const { SetUserAction(new RunAction(fDetector)); }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -31,7 +31,6 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
@@ -39,39 +38,39 @@
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4PhysicalConstants.hh"
#include "G4ProductionCutsTable.hh"
#include "G4Region.hh"
#include "G4PhysicalConstants.hh"
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "DetectorMessenger.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction()
: fWorldMaterial(nullptr)
, fLogicWorld(nullptr)
, fPhysiWorld(nullptr)
, fLogicLayerFront(nullptr)
, fLogicLayerBack(nullptr)
: fWorldMaterial(nullptr),
fLogicWorld(nullptr),
fPhysiWorld(nullptr),
fLogicLayerFront(nullptr),
fLogicLayerBack(nullptr)
{
for(G4int i = 0; i < kMaxAbsor; ++i)
{
fAbsorMaterial[i] = nullptr;
fAbsorThickness[i] = 0.0;
for (G4int i = 0; i < kMaxAbsor; ++i) {
fAbsorMaterial[i] = nullptr;
fAbsorThickness[i] = 0.0;
fLogicAbsorFront[i] = nullptr;
fLogicAbsorBack[i] = nullptr;
fLogicAbsorBack[i] = nullptr;
}
// default parameter values of the calorimeter
fNbOfAbsor = 2;
fNbOfAbsor = 2;
fAbsorThickness[1] = 2.3 * mm;
fAbsorThickness[2] = 5.7 * mm;
fNbOfLayers = 50;
fCalorSizeYZ = 40. * cm;
fNbOfLayers = 50;
fCalorSizeYZ = 40. * cm;
ComputeCalorParameters();
// materials
@@ -89,21 +88,19 @@ void DetectorConstruction::ComputeCalorParameters()
{
// Compute derived parameters of the calorimeter
fLayerThickness = 0.;
for(G4int iAbs = 1; iAbs <= fNbOfAbsor; iAbs++)
{
for (G4int iAbs = 1; iAbs <= fNbOfAbsor; iAbs++) {
fLayerThickness += fAbsorThickness[iAbs];
}
fCalorThickness = fNbOfLayers * fLayerThickness;
fWorldSizeX = 1.2 * fCalorThickness;
fWorldSizeYZ = 1.2 * fCalorSizeYZ;
fWorldSizeX = 1.2 * fCalorThickness;
fWorldSizeYZ = 1.2 * fCalorSizeYZ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::Construct()
{
if(fPhysiWorld)
{
if (fPhysiWorld) {
return fPhysiWorld;
}
// complete the Calor parameters definition
@@ -113,62 +110,55 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
// World
//
auto* solidWorld = new G4Box("World", // its name
fWorldSizeX / 2, fWorldSizeYZ / 2,
fWorldSizeYZ / 2); // its size
fWorldSizeX / 2, fWorldSizeYZ / 2,
fWorldSizeYZ / 2); // its size
fLogicWorld = new G4LogicalVolume(solidWorld, // its solid
fWorldMaterial, // its material
"World"); // its name
fLogicWorld = new G4LogicalVolume(solidWorld, // its solid
fWorldMaterial, // its material
"World"); // its name
fPhysiWorld = new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
fLogicWorld, // its fLogical volume
"World", // its name
0, // its mother volume
false, // no boolean operation
0); // copy number
fPhysiWorld = new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
fLogicWorld, // its fLogical volume
"World", // its name
0, // its mother volume
false, // no boolean operation
0); // copy number
//
// Calorimeter
//
auto* solidCalor = new G4Box("Calorimeter", fCalorThickness / 2,
fCalorSizeYZ / 2, fCalorSizeYZ / 2);
auto* solidCalor =
new G4Box("Calorimeter", fCalorThickness / 2, fCalorSizeYZ / 2, fCalorSizeYZ / 2);
auto* logicCalor =
new G4LogicalVolume(solidCalor, fWorldMaterial, "Calorimeter");
auto* logicCalor = new G4LogicalVolume(solidCalor, fWorldMaterial, "Calorimeter");
new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
logicCalor, // its fLogical volume
"Calorimeter", // its name
fLogicWorld, // its mother volume
false, // no boolean operation
0); // copy number
new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
logicCalor, // its fLogical volume
"Calorimeter", // its name
fLogicWorld, // its mother volume
false, // no boolean operation
0); // copy number
//
// Layers
//
auto* solidLayer =
new G4Box("Layer", fLayerThickness / 2, fCalorSizeYZ / 2, fCalorSizeYZ / 2);
auto* solidLayer = new G4Box("Layer", fLayerThickness / 2, fCalorSizeYZ / 2, fCalorSizeYZ / 2);
fLogicLayerFront =
new G4LogicalVolume(solidLayer, fWorldMaterial, "Layer-front");
fLogicLayerBack =
new G4LogicalVolume(solidLayer, fWorldMaterial, "Layer-back");
fLogicLayerFront = new G4LogicalVolume(solidLayer, fWorldMaterial, "Layer-front");
fLogicLayerBack = new G4LogicalVolume(solidLayer, fWorldMaterial, "Layer-back");
G4double xfront = -0.5 * fCalorThickness;
for(G4int l = 0; l < fNbOfLayers; ++l)
{
for (G4int l = 0; l < fNbOfLayers; ++l) {
G4double xcenter = xfront + 0.5 * fLayerThickness;
xfront += fLayerThickness;
G4LogicalVolume* logicLayer = fLogicLayerFront;
if(xcenter > 0)
{
if (xcenter > 0) {
logicLayer = fLogicLayerBack;
}
new G4PVPlacement(0, G4ThreeVector(xcenter, 0, 0), logicLayer, "Layer",
logicCalor, false, l);
new G4PVPlacement(0, G4ThreeVector(xcenter, 0, 0), logicLayer, "Layer", logicCalor, false, l);
}
//
@@ -176,12 +166,12 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
//
auto* regionFront = new G4Region("Front");
regionFront->SetProductionCuts(G4ProductionCutsTable::GetProductionCutsTable()
->GetDefaultProductionCuts());
regionFront->SetProductionCuts(
G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
regionFront->AddRootLogicalVolume(fLogicLayerFront);
auto* regionBack = new G4Region("Back");
regionBack->SetProductionCuts(G4ProductionCutsTable::GetProductionCutsTable()
->GetDefaultProductionCuts());
regionBack->SetProductionCuts(
G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
regionBack->AddRootLogicalVolume(fLogicLayerBack);
//
@@ -189,28 +179,25 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
//
xfront = -0.5 * fLayerThickness;
for(G4int k = 1; k <= fNbOfAbsor; ++k)
{
auto* solidAbsor =
new G4Box("Absorber", // its name
fAbsorThickness[k] / 2, fCalorSizeYZ / 2, fCalorSizeYZ / 2);
for (G4int k = 1; k <= fNbOfAbsor; ++k) {
auto* solidAbsor = new G4Box("Absorber", // its name
fAbsorThickness[k] / 2, fCalorSizeYZ / 2, fCalorSizeYZ / 2);
fLogicAbsorFront[k] =
new G4LogicalVolume(solidAbsor, // its solid
fAbsorMaterial[k], // its material
fAbsorMaterial[k]->GetName());
fLogicAbsorBack[k] = new G4LogicalVolume(solidAbsor, // its solid
fAbsorMaterial[k], // its material
fAbsorMaterial[k]->GetName());
fLogicAbsorFront[k] = new G4LogicalVolume(solidAbsor, // its solid
fAbsorMaterial[k], // its material
fAbsorMaterial[k]->GetName());
fLogicAbsorBack[k] = new G4LogicalVolume(solidAbsor, // its solid
fAbsorMaterial[k], // its material
fAbsorMaterial[k]->GetName());
G4double xcenter = xfront + 0.5 * fAbsorThickness[k];
xfront += fAbsorThickness[k];
new G4PVPlacement(0, G4ThreeVector(xcenter, 0., 0.), fLogicAbsorFront[k],
fAbsorMaterial[k]->GetName(), fLogicLayerFront, false,
k); // copy number
fAbsorMaterial[k]->GetName(), fLogicLayerFront, false,
k); // copy number
new G4PVPlacement(0, G4ThreeVector(xcenter, 0., 0.), fLogicAbsorBack[k],
fAbsorMaterial[k]->GetName(), fLogicLayerBack, false,
k); // copy number
fAbsorMaterial[k]->GetName(), fLogicLayerBack, false,
k); // copy number
}
PrintCalorParameters();
@@ -226,16 +213,14 @@ void DetectorConstruction::PrintCalorParameters()
{
G4cout << "\n-------------------------------------------------------------"
<< "\n ---> The calorimeter is " << fNbOfLayers << " layers of:";
for(G4int i = 1; i <= fNbOfAbsor; ++i)
{
G4cout << "\n \t" << std::setw(12) << fAbsorMaterial[i]->GetName() << ": "
<< std::setw(6) << G4BestUnit(fAbsorThickness[i], "Length");
for (G4int i = 1; i <= fNbOfAbsor; ++i) {
G4cout << "\n \t" << std::setw(12) << fAbsorMaterial[i]->GetName() << ": " << std::setw(6)
<< G4BestUnit(fAbsorThickness[i], "Length");
}
G4cout << "\n-------------------------------------------------------------\n";
G4cout << "\n" << fWorldMaterial << G4endl;
for(G4int j = 1; j <= fNbOfAbsor; ++j)
{
for (G4int j = 1; j <= fNbOfAbsor; ++j) {
G4cout << "\n" << fAbsorMaterial[j] << G4endl;
}
G4cout << "\n-------------------------------------------------------------\n";
@@ -246,13 +231,10 @@ void DetectorConstruction::PrintCalorParameters()
void DetectorConstruction::SetWorldMaterial(const G4String& material)
{
// search the material by its name
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(material);
if(pttoMaterial)
{
G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(material);
if (pttoMaterial) {
fWorldMaterial = pttoMaterial;
if(fLogicWorld)
{
if (fLogicWorld) {
fLogicWorld->SetMaterial(fWorldMaterial);
fLogicLayerFront->SetMaterial(fWorldMaterial);
fLogicLayerBack->SetMaterial(fWorldMaterial);
@@ -267,8 +249,7 @@ void DetectorConstruction::SetNbOfLayers(G4int ival)
{
// set the number of Layers
//
if(ival < 2)
{
if (ival < 2) {
G4cout << "\n --->warning from SetfNbOfLayers: " << ival
<< " must be at least 2. Command refused" << G4endl;
return;
@@ -282,11 +263,9 @@ void DetectorConstruction::SetNbOfAbsor(G4int ival)
{
// set the number of Absorbers
//
if(ival < 1 || ival > (kMaxAbsor - 1))
{
G4cout << "\n ---> warning from SetfNbOfAbsor: " << ival
<< " must be at least 1 and and most " << kMaxAbsor - 1
<< ". Command refused" << G4endl;
if (ival < 1 || ival > (kMaxAbsor - 1)) {
G4cout << "\n ---> warning from SetfNbOfAbsor: " << ival << " must be at least 1 and and most "
<< kMaxAbsor - 1 << ". Command refused" << G4endl;
return;
}
fNbOfAbsor = ival;
@@ -294,25 +273,20 @@ void DetectorConstruction::SetNbOfAbsor(G4int ival)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetAbsorMaterial(G4int ival,
const G4String& material)
void DetectorConstruction::SetAbsorMaterial(G4int ival, const G4String& material)
{
// search the material by its name
//
if(ival > fNbOfAbsor || ival <= 0)
{
if (ival > fNbOfAbsor || ival <= 0) {
G4cout << "\n --->warning from SetAbsorMaterial: absor number " << ival
<< " out of range. Command refused" << G4endl;
return;
}
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(material);
if(pttoMaterial)
{
G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(material);
if (pttoMaterial) {
fAbsorMaterial[ival] = pttoMaterial;
if(fLogicAbsorFront[ival])
{
if (fLogicAbsorFront[ival]) {
fLogicAbsorFront[ival]->SetMaterial(pttoMaterial);
fLogicAbsorBack[ival]->SetMaterial(pttoMaterial);
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
@@ -326,14 +300,12 @@ void DetectorConstruction::SetAbsorThickness(G4int ival, G4double val)
{
// change Absorber thickness
//
if(ival > fNbOfAbsor || ival <= 0)
{
if (ival > fNbOfAbsor || ival <= 0) {
G4cout << "\n --->warning from SetAbsorThickness: absor number " << ival
<< " out of range. Command refused" << G4endl;
return;
}
if(val <= DBL_MIN)
{
if (val <= DBL_MIN) {
G4cout << "\n --->warning from SetAbsorThickness: thickness " << val
<< " out of range. Command refused" << G4endl;
return;
@@ -347,8 +319,7 @@ void DetectorConstruction::SetCalorSizeYZ(G4double val)
{
// change the transverse size
//
if(val <= DBL_MIN)
{
if (val <= DBL_MIN) {
G4cout << "\n --->warning from SetfCalorSizeYZ: thickness " << val
<< " out of range. Command refused" << G4endl;
return;
@@ -363,12 +334,11 @@ void DetectorConstruction::SetCalorSizeYZ(G4double val)
void DetectorConstruction::ConstructSDandField()
{
if(fFieldMessenger.Get() == nullptr)
{
if (fFieldMessenger.Get() == nullptr) {
// Create global magnetic field messenger.
// Uniform magnetic field is then created automatically if
// the field value is not zero.
G4ThreeVector fieldValue = G4ThreeVector();
G4ThreeVector fieldValue = G4ThreeVector();
G4GlobalMagFieldMessenger* msg = new G4GlobalMagFieldMessenger(fieldValue);
// msg->SetVerboseLevel(1);
G4AutoDelete::Register(msg);
@@ -32,9 +32,6 @@
#include "DetectorMessenger.hh"
#include <sstream>
#include "DetectorConstruction.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithoutParameter.hh"
@@ -42,11 +39,13 @@
#include "G4UIdirectory.hh"
#include "G4UIparameter.hh"
#include "DetectorConstruction.hh"
#include <sstream>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction* Det)
: G4UImessenger()
, fDetector(Det)
DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : G4UImessenger(), fDetector(Det)
{
fDetDir.reset(new G4UIdirectory("/det/"));
fDetDir->SetGuidance("detector construction commands");
@@ -111,20 +110,16 @@ DetectorMessenger::~DetectorMessenger() = default;
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if(command == fSizeYZCmd.get())
{
if (command == fSizeYZCmd.get()) {
fDetector->SetCalorSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));
}
else if(command == fNbLayersCmd.get())
{
else if (command == fNbLayersCmd.get()) {
fDetector->SetNbOfLayers(fNbLayersCmd->GetNewIntValue(newValue));
}
else if(command == fNbAbsorCmd.get())
{
else if (command == fNbAbsorCmd.get()) {
fDetector->SetNbOfAbsor(fNbAbsorCmd->GetNewIntValue(newValue));
}
else if(command == fAbsorCmd.get())
{
else if (command == fAbsorCmd.get()) {
G4int num;
G4double tick;
G4String unt, mat;
@@ -29,9 +29,21 @@
// Original author: Jonas Hahnfeld, 2021
#include "EmStandardPhysicsTrackingManager.hh"
#include "TrackingManagerHelper.hh"
#include "G4ComptonScattering.hh"
#include "G4CoulombScattering.hh"
#include "G4Electron.hh"
#include "G4EmParameters.hh"
#include "G4Gamma.hh"
#include "G4GammaConversion.hh"
#include "G4KleinNishinaModel.hh"
#include "G4LivermorePhotoElectricModel.hh"
#include "G4LivermorePolarizedRayleighModel.hh"
#include "G4PhotoElectricAngularGeneratorPolarized.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4Positron.hh"
#include "G4RayleighScattering.hh"
#include "G4SystemOfUnits.hh"
#include "G4UrbanMscModel.hh"
#include "G4WentzelVIModel.hh"
#include "G4eBremsstrahlung.hh"
@@ -40,46 +52,32 @@
#include "G4eMultipleScattering.hh"
#include "G4eplusAnnihilation.hh"
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4KleinNishinaModel.hh"
#include "G4LivermorePhotoElectricModel.hh"
#include "G4LivermorePolarizedRayleighModel.hh"
#include "G4PhotoElectricAngularGeneratorPolarized.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4RayleighScattering.hh"
#include "TrackingManagerHelper.hh"
#include "G4EmParameters.hh"
#include "G4SystemOfUnits.hh"
#include "G4Electron.hh"
#include "G4Gamma.hh"
#include "G4Positron.hh"
EmStandardPhysicsTrackingManager*
EmStandardPhysicsTrackingManager::masterTrackingManager = nullptr;
EmStandardPhysicsTrackingManager* EmStandardPhysicsTrackingManager::fMasterTrackingManager =
nullptr;
EmStandardPhysicsTrackingManager::EmStandardPhysicsTrackingManager()
{
G4EmParameters* param = G4EmParameters::Instance();
G4EmParameters* param = G4EmParameters::Instance();
G4double highEnergyLimit = param->MscEnergyLimit();
G4bool polar = param->EnablePolarisation();
G4bool polar = param->EnablePolarisation();
// e-
{
G4eMultipleScattering* msc = new G4eMultipleScattering;
G4UrbanMscModel* msc1 = new G4UrbanMscModel;
G4WentzelVIModel* msc2 = new G4WentzelVIModel;
G4UrbanMscModel* msc1 = new G4UrbanMscModel;
G4WentzelVIModel* msc2 = new G4WentzelVIModel;
msc1->SetHighEnergyLimit(highEnergyLimit);
msc2->SetLowEnergyLimit(highEnergyLimit);
msc->SetEmModel(msc1);
msc->SetEmModel(msc2);
fElectronProcs.msc = msc;
fElectronProcs.ioni = new G4eIonisation;
fElectronProcs.ioni = new G4eIonisation;
fElectronProcs.brems = new G4eBremsstrahlung;
G4CoulombScattering* ss = new G4CoulombScattering;
G4CoulombScattering* ss = new G4CoulombScattering;
G4eCoulombScatteringModel* ssm = new G4eCoulombScatteringModel;
ssm->SetLowEnergyLimit(highEnergyLimit);
ssm->SetActivationLowEnergyLimit(highEnergyLimit);
@@ -91,19 +89,19 @@ EmStandardPhysicsTrackingManager::EmStandardPhysicsTrackingManager()
// e+
{
G4eMultipleScattering* msc = new G4eMultipleScattering;
G4UrbanMscModel* msc1 = new G4UrbanMscModel;
G4WentzelVIModel* msc2 = new G4WentzelVIModel;
G4UrbanMscModel* msc1 = new G4UrbanMscModel;
G4WentzelVIModel* msc2 = new G4WentzelVIModel;
msc1->SetHighEnergyLimit(highEnergyLimit);
msc2->SetLowEnergyLimit(highEnergyLimit);
msc->SetEmModel(msc1);
msc->SetEmModel(msc2);
fPositronProcs.msc = msc;
fPositronProcs.ioni = new G4eIonisation;
fPositronProcs.brems = new G4eBremsstrahlung;
fPositronProcs.ioni = new G4eIonisation;
fPositronProcs.brems = new G4eBremsstrahlung;
fPositronProcs.annihilation = new G4eplusAnnihilation;
G4CoulombScattering* ss = new G4CoulombScattering;
G4CoulombScattering* ss = new G4CoulombScattering;
G4eCoulombScatteringModel* ssm = new G4eCoulombScatteringModel;
ssm->SetLowEnergyLimit(highEnergyLimit);
ssm->SetActivationLowEnergyLimit(highEnergyLimit);
@@ -114,18 +112,15 @@ EmStandardPhysicsTrackingManager::EmStandardPhysicsTrackingManager()
{
G4PhotoElectricEffect* pe = new G4PhotoElectricEffect;
G4VEmModel* peModel = new G4LivermorePhotoElectricModel;
if(polar)
{
peModel->SetAngularDistribution(
new G4PhotoElectricAngularGeneratorPolarized);
G4VEmModel* peModel = new G4LivermorePhotoElectricModel;
if (polar) {
peModel->SetAngularDistribution(new G4PhotoElectricAngularGeneratorPolarized);
}
pe->SetEmModel(peModel);
fGammaProcs.pe = pe;
G4ComptonScattering* cs = new G4ComptonScattering;
if(polar)
{
if (polar) {
cs->SetEmModel(new G4KleinNishinaModel);
}
fGammaProcs.compton = cs;
@@ -133,77 +128,58 @@ EmStandardPhysicsTrackingManager::EmStandardPhysicsTrackingManager()
fGammaProcs.conversion = new G4GammaConversion;
G4RayleighScattering* rl = new G4RayleighScattering;
if(polar)
{
if (polar) {
rl->SetEmModel(new G4LivermorePolarizedRayleighModel);
}
fGammaProcs.rayleigh = rl;
}
if(masterTrackingManager == nullptr)
{
masterTrackingManager = this;
if (fMasterTrackingManager == nullptr) {
fMasterTrackingManager = this;
}
else
{
fElectronProcs.msc->SetMasterProcess(
masterTrackingManager->fElectronProcs.msc);
fElectronProcs.ss->SetMasterProcess(
masterTrackingManager->fElectronProcs.ss);
fElectronProcs.ioni->SetMasterProcess(
masterTrackingManager->fElectronProcs.ioni);
fElectronProcs.brems->SetMasterProcess(
masterTrackingManager->fElectronProcs.brems);
else {
fElectronProcs.msc->SetMasterProcess(fMasterTrackingManager->fElectronProcs.msc);
fElectronProcs.ss->SetMasterProcess(fMasterTrackingManager->fElectronProcs.ss);
fElectronProcs.ioni->SetMasterProcess(fMasterTrackingManager->fElectronProcs.ioni);
fElectronProcs.brems->SetMasterProcess(fMasterTrackingManager->fElectronProcs.brems);
fPositronProcs.msc->SetMasterProcess(
masterTrackingManager->fPositronProcs.msc);
fPositronProcs.ss->SetMasterProcess(
masterTrackingManager->fPositronProcs.ss);
fPositronProcs.ioni->SetMasterProcess(
masterTrackingManager->fPositronProcs.ioni);
fPositronProcs.brems->SetMasterProcess(
masterTrackingManager->fPositronProcs.brems);
fPositronProcs.msc->SetMasterProcess(fMasterTrackingManager->fPositronProcs.msc);
fPositronProcs.ss->SetMasterProcess(fMasterTrackingManager->fPositronProcs.ss);
fPositronProcs.ioni->SetMasterProcess(fMasterTrackingManager->fPositronProcs.ioni);
fPositronProcs.brems->SetMasterProcess(fMasterTrackingManager->fPositronProcs.brems);
fPositronProcs.annihilation->SetMasterProcess(
masterTrackingManager->fPositronProcs.annihilation);
fMasterTrackingManager->fPositronProcs.annihilation);
fGammaProcs.pe->SetMasterProcess(masterTrackingManager->fGammaProcs.pe);
fGammaProcs.compton->SetMasterProcess(
masterTrackingManager->fGammaProcs.compton);
fGammaProcs.conversion->SetMasterProcess(
masterTrackingManager->fGammaProcs.conversion);
fGammaProcs.rayleigh->SetMasterProcess(
masterTrackingManager->fGammaProcs.rayleigh);
fGammaProcs.pe->SetMasterProcess(fMasterTrackingManager->fGammaProcs.pe);
fGammaProcs.compton->SetMasterProcess(fMasterTrackingManager->fGammaProcs.compton);
fGammaProcs.conversion->SetMasterProcess(fMasterTrackingManager->fGammaProcs.conversion);
fGammaProcs.rayleigh->SetMasterProcess(fMasterTrackingManager->fGammaProcs.rayleigh);
}
}
EmStandardPhysicsTrackingManager::~EmStandardPhysicsTrackingManager()
{
if(masterTrackingManager == this)
{
masterTrackingManager = nullptr;
if (fMasterTrackingManager == this) {
fMasterTrackingManager = nullptr;
}
}
void EmStandardPhysicsTrackingManager::BuildPhysicsTable(
const G4ParticleDefinition& part)
void EmStandardPhysicsTrackingManager::BuildPhysicsTable(const G4ParticleDefinition& part)
{
if(&part == G4Electron::Definition())
{
if (&part == G4Electron::Definition()) {
fElectronProcs.msc->BuildPhysicsTable(part);
fElectronProcs.ioni->BuildPhysicsTable(part);
fElectronProcs.brems->BuildPhysicsTable(part);
fElectronProcs.ss->BuildPhysicsTable(part);
}
else if(&part == G4Positron::Definition())
{
else if (&part == G4Positron::Definition()) {
fPositronProcs.msc->BuildPhysicsTable(part);
fPositronProcs.ioni->BuildPhysicsTable(part);
fPositronProcs.brems->BuildPhysicsTable(part);
fPositronProcs.annihilation->BuildPhysicsTable(part);
fPositronProcs.ss->BuildPhysicsTable(part);
}
else if(&part == G4Gamma::Definition())
{
else if (&part == G4Gamma::Definition()) {
fGammaProcs.pe->BuildPhysicsTable(part);
fGammaProcs.compton->BuildPhysicsTable(part);
fGammaProcs.conversion->BuildPhysicsTable(part);
@@ -211,26 +187,22 @@ void EmStandardPhysicsTrackingManager::BuildPhysicsTable(
}
}
void EmStandardPhysicsTrackingManager::PreparePhysicsTable(
const G4ParticleDefinition& part)
void EmStandardPhysicsTrackingManager::PreparePhysicsTable(const G4ParticleDefinition& part)
{
if(&part == G4Electron::Definition())
{
if (&part == G4Electron::Definition()) {
fElectronProcs.msc->PreparePhysicsTable(part);
fElectronProcs.ioni->PreparePhysicsTable(part);
fElectronProcs.brems->PreparePhysicsTable(part);
fElectronProcs.ss->PreparePhysicsTable(part);
}
else if(&part == G4Positron::Definition())
{
else if (&part == G4Positron::Definition()) {
fPositronProcs.msc->PreparePhysicsTable(part);
fPositronProcs.ioni->PreparePhysicsTable(part);
fPositronProcs.brems->PreparePhysicsTable(part);
fPositronProcs.annihilation->PreparePhysicsTable(part);
fPositronProcs.ss->PreparePhysicsTable(part);
}
else if(&part == G4Gamma::Definition())
{
else if (&part == G4Gamma::Definition()) {
fGammaProcs.pe->PreparePhysicsTable(part);
fGammaProcs.compton->PreparePhysicsTable(part);
fGammaProcs.conversion->PreparePhysicsTable(part);
@@ -243,9 +215,7 @@ void EmStandardPhysicsTrackingManager::TrackElectron(G4Track* aTrack)
class ElectronPhysics final : public TrackingManagerHelper::Physics
{
public:
ElectronPhysics(EmStandardPhysicsTrackingManager& mgr)
: fMgr(mgr)
{}
ElectronPhysics(EmStandardPhysicsTrackingManager& mgr) : fMgr(mgr) {}
void StartTracking(G4Track* aTrack) override
{
@@ -276,49 +246,40 @@ void EmStandardPhysicsTrackingManager::TrackElectron(G4Track* aTrack)
G4GPILSelection selection;
fProposedStep = DBL_MAX;
fSelected = -1;
fSelected = -1;
physIntLength =
electronProcs.ss->PostStepGPIL(track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
physIntLength = electronProcs.ss->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 0;
fSelected = 0;
}
physIntLength = electronProcs.brems->PostStepGPIL(
track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
physIntLength = electronProcs.brems->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 1;
fSelected = 1;
}
physIntLength = electronProcs.ioni->PostStepGPIL(
track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
physIntLength = electronProcs.ioni->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 2;
fSelected = 2;
}
physIntLength = electronProcs.ioni->AlongStepGPIL(
track, fPreviousStepLength, fProposedStep, proposedSafety, &selection);
if(physIntLength < fProposedStep)
{
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = -1;
fSelected = -1;
}
physIntLength = electronProcs.msc->AlongStepGPIL(
track, fPreviousStepLength, fProposedStep, proposedSafety, &selection);
if(physIntLength < fProposedStep)
{
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
// Check if MSC actually wants to win, in most cases it only limits the
// step size.
if(selection == CandidateForSelection)
{
if (selection == CandidateForSelection) {
fSelected = -1;
}
}
@@ -328,12 +289,10 @@ void EmStandardPhysicsTrackingManager::TrackElectron(G4Track* aTrack)
void AlongStepDoIt(G4Track& track, G4Step& step, G4TrackVector&) override
{
if(step.GetStepLength() == fProposedStep)
{
if (step.GetStepLength() == fProposedStep) {
step.GetPostStepPoint()->SetStepStatus(fAlongStepDoItProc);
}
else
{
else {
// Remember that the step was limited by geometry.
fSelected = -1;
}
@@ -353,31 +312,28 @@ void EmStandardPhysicsTrackingManager::TrackElectron(G4Track* aTrack)
fPreviousStepLength = step.GetStepLength();
}
void PostStepDoIt(G4Track& track, G4Step& step,
G4TrackVector& secondaries) override
void PostStepDoIt(G4Track& track, G4Step& step, G4TrackVector& secondaries) override
{
if(fSelected < 0)
{
if (fSelected < 0) {
return;
}
step.GetPostStepPoint()->SetStepStatus(fPostStepDoItProc);
auto& electronProcs = fMgr.fElectronProcs;
G4VProcess* process = nullptr;
auto& electronProcs = fMgr.fElectronProcs;
G4VProcess* process = nullptr;
G4VParticleChange* particleChange = nullptr;
switch(fSelected)
{
switch (fSelected) {
case 0:
process = electronProcs.ss;
process = electronProcs.ss;
particleChange = electronProcs.ss->PostStepDoIt(track, step);
break;
case 1:
process = electronProcs.brems;
process = electronProcs.brems;
particleChange = electronProcs.brems->PostStepDoIt(track, step);
break;
case 2:
process = electronProcs.ioni;
process = electronProcs.ioni;
particleChange = electronProcs.ioni->PostStepDoIt(track, step);
break;
}
@@ -386,8 +342,7 @@ void EmStandardPhysicsTrackingManager::TrackElectron(G4Track* aTrack)
step.UpdateTrack();
int numSecondaries = particleChange->GetNumberOfSecondaries();
for(int i = 0; i < numSecondaries; i++)
{
for (int i = 0; i < numSecondaries; i++) {
G4Track* secondary = particleChange->GetSecondary(i);
secondary->SetParentID(track.GetTrackID());
secondary->SetCreatorProcess(process);
@@ -414,9 +369,7 @@ void EmStandardPhysicsTrackingManager::TrackPositron(G4Track* aTrack)
class PositronPhysics final : public TrackingManagerHelper::Physics
{
public:
PositronPhysics(EmStandardPhysicsTrackingManager& mgr)
: fMgr(mgr)
{}
PositronPhysics(EmStandardPhysicsTrackingManager& mgr) : fMgr(mgr) {}
void StartTracking(G4Track* aTrack) override
{
@@ -449,57 +402,47 @@ void EmStandardPhysicsTrackingManager::TrackPositron(G4Track* aTrack)
G4GPILSelection selection;
fProposedStep = DBL_MAX;
fSelected = -1;
fSelected = -1;
physIntLength = positronProcs.ss->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 0;
}
physIntLength =
positronProcs.ss->PostStepGPIL(track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
positronProcs.annihilation->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 0;
fSelected = 1;
}
physIntLength = positronProcs.annihilation->PostStepGPIL(
track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
physIntLength = positronProcs.brems->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 1;
fSelected = 2;
}
physIntLength = positronProcs.brems->PostStepGPIL(
track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
physIntLength = positronProcs.ioni->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 2;
}
physIntLength = positronProcs.ioni->PostStepGPIL(
track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
fProposedStep = physIntLength;
fSelected = 3;
fSelected = 3;
}
physIntLength = positronProcs.ioni->AlongStepGPIL(
track, fPreviousStepLength, fProposedStep, proposedSafety, &selection);
if(physIntLength < fProposedStep)
{
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = -1;
fSelected = -1;
}
physIntLength = positronProcs.msc->AlongStepGPIL(
track, fPreviousStepLength, fProposedStep, proposedSafety, &selection);
if(physIntLength < fProposedStep)
{
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
// Check if MSC actually wants to win, in most cases it only limits the
// step size.
if(selection == CandidateForSelection)
{
if (selection == CandidateForSelection) {
fSelected = -1;
}
}
@@ -509,12 +452,10 @@ void EmStandardPhysicsTrackingManager::TrackPositron(G4Track* aTrack)
void AlongStepDoIt(G4Track& track, G4Step& step, G4TrackVector&) override
{
if(step.GetStepLength() == fProposedStep)
{
if (step.GetStepLength() == fProposedStep) {
step.GetPostStepPoint()->SetStepStatus(fAlongStepDoItProc);
}
else
{
else {
// Remember that the step was limited by geometry.
fSelected = -1;
}
@@ -534,11 +475,9 @@ void EmStandardPhysicsTrackingManager::TrackPositron(G4Track* aTrack)
fPreviousStepLength = step.GetStepLength();
}
void PostStepDoIt(G4Track& track, G4Step& step,
G4TrackVector& secondaries) override
void PostStepDoIt(G4Track& track, G4Step& step, G4TrackVector& secondaries) override
{
if(fSelected < 0)
{
if (fSelected < 0) {
return;
}
step.GetPostStepPoint()->SetStepStatus(fPostStepDoItProc);
@@ -547,23 +486,21 @@ void EmStandardPhysicsTrackingManager::TrackPositron(G4Track* aTrack)
G4VProcess* process;
G4VParticleChange* particleChange = nullptr;
switch(fSelected)
{
switch (fSelected) {
case 0:
process = positronProcs.ss;
process = positronProcs.ss;
particleChange = positronProcs.ss->PostStepDoIt(track, step);
break;
case 1:
process = positronProcs.annihilation;
particleChange =
positronProcs.annihilation->PostStepDoIt(track, step);
particleChange = positronProcs.annihilation->PostStepDoIt(track, step);
break;
case 2:
process = positronProcs.brems;
process = positronProcs.brems;
particleChange = positronProcs.brems->PostStepDoIt(track, step);
break;
case 3:
process = positronProcs.ioni;
process = positronProcs.ioni;
particleChange = positronProcs.ioni->PostStepDoIt(track, step);
break;
}
@@ -572,8 +509,7 @@ void EmStandardPhysicsTrackingManager::TrackPositron(G4Track* aTrack)
step.UpdateTrack();
int numSecondaries = particleChange->GetNumberOfSecondaries();
for(int i = 0; i < numSecondaries; i++)
{
for (int i = 0; i < numSecondaries; i++) {
G4Track* secondary = particleChange->GetSecondary(i);
secondary->SetParentID(track.GetTrackID());
secondary->SetCreatorProcess(process);
@@ -586,19 +522,16 @@ void EmStandardPhysicsTrackingManager::TrackPositron(G4Track* aTrack)
G4bool HasAtRestProcesses() override { return true; }
void AtRestDoIt(G4Track& track, G4Step& step,
G4TrackVector& secondaries) override
void AtRestDoIt(G4Track& track, G4Step& step, G4TrackVector& secondaries) override
{
auto& positronProcs = fMgr.fPositronProcs;
// Annihilate the positron at rest.
G4VParticleChange* particleChange =
positronProcs.annihilation->AtRestDoIt(track, step);
G4VParticleChange* particleChange = positronProcs.annihilation->AtRestDoIt(track, step);
particleChange->UpdateStepForAtRest(&step);
step.UpdateTrack();
int numSecondaries = particleChange->GetNumberOfSecondaries();
for(int i = 0; i < numSecondaries; i++)
{
for (int i = 0; i < numSecondaries; i++) {
G4Track* secondary = particleChange->GetSecondary(i);
secondary->SetParentID(track.GetTrackID());
secondary->SetCreatorProcess(positronProcs.annihilation);
@@ -625,9 +558,7 @@ void EmStandardPhysicsTrackingManager::TrackGamma(G4Track* aTrack)
class GammaPhysics final : public TrackingManagerHelper::Physics
{
public:
GammaPhysics(EmStandardPhysicsTrackingManager& mgr)
: fMgr(mgr)
{}
GammaPhysics(EmStandardPhysicsTrackingManager& mgr) : fMgr(mgr) {}
void StartTracking(G4Track* aTrack) override
{
@@ -657,38 +588,30 @@ void EmStandardPhysicsTrackingManager::TrackGamma(G4Track* aTrack)
G4ForceCondition condition;
fProposedStep = DBL_MAX;
fSelected = -1;
fSelected = -1;
physIntLength = gammaProcs.rayleigh->PostStepGPIL(
track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
physIntLength = gammaProcs.rayleigh->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 0;
fSelected = 0;
}
physIntLength = gammaProcs.conversion->PostStepGPIL(
track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
physIntLength = gammaProcs.conversion->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 1;
fSelected = 1;
}
physIntLength = gammaProcs.compton->PostStepGPIL(
track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
physIntLength = gammaProcs.compton->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 2;
fSelected = 2;
}
physIntLength =
gammaProcs.pe->PostStepGPIL(track, fPreviousStepLength, &condition);
if(physIntLength < fProposedStep)
{
physIntLength = gammaProcs.pe->PostStepGPIL(track, fPreviousStepLength, &condition);
if (physIntLength < fProposedStep) {
fProposedStep = physIntLength;
fSelected = 3;
fSelected = 3;
}
return fProposedStep;
@@ -696,47 +619,42 @@ void EmStandardPhysicsTrackingManager::TrackGamma(G4Track* aTrack)
void AlongStepDoIt(G4Track&, G4Step& step, G4TrackVector&) override
{
if(step.GetStepLength() == fProposedStep)
{
if (step.GetStepLength() == fProposedStep) {
step.GetPostStepPoint()->SetStepStatus(fAlongStepDoItProc);
}
else
{
else {
// Remember that the step was limited by geometry.
fSelected = -1;
}
fPreviousStepLength = step.GetStepLength();
}
void PostStepDoIt(G4Track& track, G4Step& step,
G4TrackVector& secondaries) override
void PostStepDoIt(G4Track& track, G4Step& step, G4TrackVector& secondaries) override
{
if(fSelected < 0)
{
if (fSelected < 0) {
return;
}
step.GetPostStepPoint()->SetStepStatus(fPostStepDoItProc);
auto& gammaProcs = fMgr.fGammaProcs;
G4VProcess* process = nullptr;
auto& gammaProcs = fMgr.fGammaProcs;
G4VProcess* process = nullptr;
G4VParticleChange* particleChange = nullptr;
switch(fSelected)
{
switch (fSelected) {
case 0:
process = gammaProcs.rayleigh;
process = gammaProcs.rayleigh;
particleChange = gammaProcs.rayleigh->PostStepDoIt(track, step);
break;
case 1:
process = gammaProcs.conversion;
process = gammaProcs.conversion;
particleChange = gammaProcs.conversion->PostStepDoIt(track, step);
break;
case 2:
process = gammaProcs.compton;
process = gammaProcs.compton;
particleChange = gammaProcs.compton->PostStepDoIt(track, step);
break;
case 3:
process = gammaProcs.pe;
process = gammaProcs.pe;
particleChange = gammaProcs.pe->PostStepDoIt(track, step);
break;
}
@@ -745,8 +663,7 @@ void EmStandardPhysicsTrackingManager::TrackGamma(G4Track* aTrack)
step.UpdateTrack();
int numSecondaries = particleChange->GetNumberOfSecondaries();
for(int i = 0; i < numSecondaries; i++)
{
for (int i = 0; i < numSecondaries; i++) {
G4Track* secondary = particleChange->GetSecondary(i);
secondary->SetParentID(track.GetTrackID());
secondary->SetCreatorProcess(process);
@@ -772,16 +689,13 @@ void EmStandardPhysicsTrackingManager::HandOverOneTrack(G4Track* aTrack)
{
const G4ParticleDefinition* part = aTrack->GetParticleDefinition();
if(part == G4Electron::Definition())
{
if (part == G4Electron::Definition()) {
TrackElectron(aTrack);
}
else if(part == G4Positron::Definition())
{
else if (part == G4Positron::Definition()) {
TrackPositron(aTrack);
}
else if(part == G4Gamma::Definition())
{
else if (part == G4Gamma::Definition()) {
TrackGamma(aTrack);
}
@@ -32,24 +32,20 @@
#include "EventAction.hh"
#include "Run.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "Run.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::EventAction(DetectorConstruction* det)
: G4UserEventAction()
, fDetector(det)
{}
EventAction::EventAction(DetectorConstruction* det) : G4UserEventAction(), fDetector(det) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::BeginOfEventAction(const G4Event*)
{
for(G4int k = 0; k < kMaxAbsor; k++)
{
for (G4int k = 0; k < kMaxAbsor; k++) {
fEnergyDeposit[k] = fTrackLengthCh[k] = 0.0;
}
}
@@ -58,11 +54,9 @@ void EventAction::BeginOfEventAction(const G4Event*)
void EventAction::EndOfEventAction(const G4Event*)
{
Run* run =
static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
for(G4int k = 1; k <= fDetector->GetNbOfAbsor(); k++)
{
for (G4int k = 1; k <= fDetector->GetNbOfAbsor(); k++) {
run->FillPerEvent(k, fEnergyDeposit[k], fTrackLengthCh[k]);
}
}
@@ -31,20 +31,19 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysicsList.hh"
#include "PhysicsListMessenger.hh"
#include "PhysicsListEmSpecialized.hh"
#include "PhysicsListEmStandardTracking.hh"
#include "G4EmStandardPhysics.hh"
#include "G4BaryonConstructor.hh"
#include "G4BosonConstructor.hh"
#include "G4EmStandardPhysics.hh"
#include "G4IonConstructor.hh"
#include "G4LeptonConstructor.hh"
#include "G4MesonConstructor.hh"
#include "G4ShortLivedConstructor.hh"
#include "PhysicsListEmSpecialized.hh"
#include "PhysicsListEmStandardTracking.hh"
#include "PhysicsListMessenger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::PhysicsList()
@@ -80,25 +79,20 @@ void PhysicsList::ConstructProcess()
void PhysicsList::SetMode(const G4String& name)
{
if(verboseLevel > -1)
{
if (verboseLevel > -1) {
G4cout << "PhysicsList::SetMode: <" << name << ">" << G4endl;
}
if(name == "processes")
{
if (name == "processes") {
fEmPhysicsList.reset(new G4EmStandardPhysics(GetVerboseLevel()));
}
else if(name == "tracking")
{
else if (name == "tracking") {
fEmPhysicsList.reset(new PhysicsListEmStandardTracking(GetVerboseLevel()));
}
else if(name == "specialized")
{
else if (name == "specialized") {
fEmPhysicsList.reset(new PhysicsListEmSpecialized(GetVerboseLevel()));
}
else
{
else {
G4cout << "PhysicsList::SetMode: <" << name << ">"
<< " is not defined" << G4endl;
}
@@ -29,17 +29,16 @@
#include "PhysicsListEmSpecialized.hh"
#include "SpecializedTrackingManager.hh"
#include "G4Electron.hh"
#include "G4Gamma.hh"
#include "G4ParticleDefinition.hh"
#include "G4Positron.hh"
#include "SpecializedTrackingManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListEmSpecialized::PhysicsListEmSpecialized(G4int ver,
const G4String& name)
PhysicsListEmSpecialized::PhysicsListEmSpecialized(G4int ver, const G4String& name)
: G4EmStandardPhysics(ver, name)
{}
@@ -29,14 +29,14 @@
#include "PhysicsListEmStandardTracking.hh"
#include "EmStandardPhysicsTrackingManager.hh"
#include "G4Electron.hh"
#include "G4EmBuilder.hh"
#include "G4Gamma.hh"
#include "G4ParticleDefinition.hh"
#include "G4Positron.hh"
#include "EmStandardPhysicsTrackingManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListEmStandardTracking::PhysicsListEmStandardTracking(G4int ver)
@@ -34,13 +34,13 @@
#include "G4UIcmdWithAString.hh"
#include "G4UIdirectory.hh"
#include "PhysicsList.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
: G4UImessenger()
, fPhysicsList(pPhys)
: G4UImessenger(), fPhysicsList(pPhys)
{
fModeCmd.reset(new G4UIcmdWithAString("/setMode", this));
fModeCmd->SetGuidance("Add physics mode.");
@@ -57,8 +57,7 @@ PhysicsListMessenger::~PhysicsListMessenger() = default;
void PhysicsListMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if(command == fModeCmd.get())
{
if (command == fModeCmd.get()) {
fPhysicsList->SetMode(newValue);
}
}
@@ -32,16 +32,15 @@
#include "PrimaryGeneratorAction.hh"
#include "DetectorConstruction.hh"
#include "G4Electron.hh"
#include "G4ParticleGun.hh"
#include "G4SystemOfUnits.hh"
#include "DetectorConstruction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det)
: fDetector(det)
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det) : fDetector(det)
{
G4int numberOfParticles = 1;
fParticleGun.reset(new G4ParticleGun(numberOfParticles));
+42 -57
View File
@@ -31,38 +31,37 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "Run.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "G4Electron.hh"
#include "G4Gamma.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4Positron.hh"
#include "G4Track.hh"
#include "G4SystemOfUnits.hh"
#include "G4Track.hh"
#include "G4UnitsTable.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Run::Run(DetectorConstruction* det)
: G4Run()
, fDetector(det)
, fParticle(nullptr)
, fEkin(0.)
, fChargedStep(0)
, fNeutralStep(0)
, fN_gamma(0)
, fN_elec(0)
, fN_pos(0)
: G4Run(),
fDetector(det),
fParticle(nullptr),
fEkin(0.),
fChargedStep(0),
fNeutralStep(0),
fN_gamma(0),
fN_elec(0),
fN_pos(0)
{
// initialize cumulative quantities
//
for(G4int k = 0; k < kMaxAbsor; k++)
{
for (G4int k = 0; k < kMaxAbsor; k++) {
fSumEAbs[k] = fSum2EAbs[k] = fSumLAbs[k] = fSum2LAbs[k] = 0.;
fEnergyDeposit[k].clear();
}
@@ -77,7 +76,7 @@ Run::~Run() {}
void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy)
{
fParticle = particle;
fEkin = energy;
fEkin = energy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -106,16 +105,13 @@ void Run::AddNeutralStep() { fNeutralStep += 1.0; }
void Run::AddSecondaryTrack(const G4Track* track)
{
const G4ParticleDefinition* d = track->GetDefinition();
if(d == G4Gamma::Gamma())
{
if (d == G4Gamma::Gamma()) {
++fN_gamma;
}
else if(d == G4Electron::Electron())
{
else if (d == G4Electron::Electron()) {
++fN_elec;
}
else if(d == G4Positron::Positron())
{
else if (d == G4Positron::Positron()) {
++fN_pos;
}
}
@@ -128,12 +124,11 @@ void Run::Merge(const G4Run* run)
// pass information about primary particle
fParticle = localRun->fParticle;
fEkin = localRun->fEkin;
fEkin = localRun->fEkin;
// accumulate sums
//
for(G4int k = 0; k < kMaxAbsor; k++)
{
for (G4int k = 0; k < kMaxAbsor; k++) {
fSumEAbs[k] += localRun->fSumEAbs[k];
fSum2EAbs[k] += localRun->fSum2EAbs[k];
fSumLAbs[k] += localRun->fSumLAbs[k];
@@ -154,10 +149,9 @@ void Run::Merge(const G4Run* run)
void Run::EndOfRun()
{
G4int nEvt = numberOfEvent;
G4int nEvt = numberOfEvent;
G4double norm = G4double(nEvt);
if(norm > 0)
norm = 1. / norm;
if (norm > 0) norm = 1. / norm;
G4double qnorm = std::sqrt(norm);
fChargedStep *= norm;
@@ -166,61 +160,52 @@ void Run::EndOfRun()
// compute and print statistic
//
G4double beamEnergy = fEkin;
G4double sqbeam = std::sqrt(beamEnergy / GeV);
G4double sqbeam = std::sqrt(beamEnergy / GeV);
G4double MeanEAbs, MeanEAbs2, rmsEAbs, resolution, rmsres;
G4double MeanLAbs, MeanLAbs2, rmsLAbs;
std::ios::fmtflags mode = G4cout.flags();
G4int prec = G4cout.precision(2);
G4int prec = G4cout.precision(2);
G4cout << "\n------------------------------------------------------------\n";
G4cout << std::setw(14) << "material" << std::setw(17) << "Edep RMS"
<< std::setw(33) << "sqrt(E0(GeV))*rmsE/Emean" << std::setw(23)
<< "total tracklen \n \n";
G4cout << std::setw(14) << "material" << std::setw(17) << "Edep RMS" << std::setw(33)
<< "sqrt(E0(GeV))*rmsE/Emean" << std::setw(23) << "total tracklen \n \n";
for(G4int k = 1; k <= fDetector->GetNbOfAbsor(); k++)
{
MeanEAbs = fSumEAbs[k] * norm;
for (G4int k = 1; k <= fDetector->GetNbOfAbsor(); k++) {
MeanEAbs = fSumEAbs[k] * norm;
MeanEAbs2 = fSum2EAbs[k] * norm;
rmsEAbs = std::sqrt(std::abs(MeanEAbs2 - MeanEAbs * MeanEAbs));
rmsEAbs = std::sqrt(std::abs(MeanEAbs2 - MeanEAbs * MeanEAbs));
resolution = 100. * sqbeam * rmsEAbs / MeanEAbs;
rmsres = resolution * qnorm;
rmsres = resolution * qnorm;
// Save mean and RMS
fSumEAbs[k] = MeanEAbs;
fSumEAbs[k] = MeanEAbs;
fSum2EAbs[k] = rmsEAbs;
MeanLAbs = fSumLAbs[k] * norm;
MeanLAbs = fSumLAbs[k] * norm;
MeanLAbs2 = fSum2LAbs[k] * norm;
rmsLAbs = std::sqrt(std::abs(MeanLAbs2 - MeanLAbs * MeanLAbs));
rmsLAbs = std::sqrt(std::abs(MeanLAbs2 - MeanLAbs * MeanLAbs));
// print
//
G4cout << std::setw(14) << fDetector->GetAbsorMaterial(k)->GetName() << ": "
<< std::setprecision(5) << std::setw(6)
<< G4BestUnit(MeanEAbs, "Energy") << " : " << std::setprecision(4)
<< std::setw(5) << G4BestUnit(rmsEAbs, "Energy") << std::setw(10)
<< resolution << " +- " << std::setw(5) << rmsres << " %"
<< std::setprecision(3) << std::setw(10)
<< G4BestUnit(MeanLAbs, "Length") << " +- " << std::setw(4)
<< std::setprecision(5) << std::setw(6) << G4BestUnit(MeanEAbs, "Energy") << " : "
<< std::setprecision(4) << std::setw(5) << G4BestUnit(rmsEAbs, "Energy") << std::setw(10)
<< resolution << " +- " << std::setw(5) << rmsres << " %" << std::setprecision(3)
<< std::setw(10) << G4BestUnit(MeanLAbs, "Length") << " +- " << std::setw(4)
<< G4BestUnit(rmsLAbs, "Length") << G4endl;
}
G4cout << "\n------------------------------------------------------------\n";
G4cout << " Beam particle " << fParticle->GetParticleName()
<< " E = " << G4BestUnit(beamEnergy, "Energy") << G4endl;
G4cout << " Mean number of gamma " << (G4double) fN_gamma * norm
<< G4endl;
G4cout << " Mean number of e- " << (G4double) fN_elec * norm
<< G4endl;
G4cout << " Mean number of e+ " << (G4double) fN_pos * norm
<< G4endl;
G4cout << std::setprecision(6) << " Mean number of charged steps "
<< fChargedStep << G4endl;
G4cout << " Mean number of gamma " << (G4double)fN_gamma * norm << G4endl;
G4cout << " Mean number of e- " << (G4double)fN_elec * norm << G4endl;
G4cout << " Mean number of e+ " << (G4double)fN_pos * norm << G4endl;
G4cout << std::setprecision(6) << " Mean number of charged steps " << fChargedStep << G4endl;
G4cout << " Mean number of neutral steps " << fNeutralStep << G4endl;
G4cout << "------------------------------------------------------------\n"
<< G4endl;
G4cout << "------------------------------------------------------------\n" << G4endl;
G4cout.setf(mode, std::ios::floatfield);
G4cout.precision(prec);
@@ -32,20 +32,18 @@
#include "RunAction.hh"
#include "DetectorConstruction.hh"
#include "G4RunManager.hh"
#include "G4Timer.hh"
#include "PrimaryGeneratorAction.hh"
#include "Randomize.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "Run.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* prim)
: G4UserRunAction()
, fDetector(det)
, fPrimary(prim)
, fRun(nullptr)
: G4UserRunAction(), fDetector(det), fPrimary(prim), fRun(nullptr)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -61,16 +59,13 @@ G4Run* RunAction::GenerateRun()
void RunAction::BeginOfRunAction(const G4Run*)
{
// keep run condition
if(fPrimary)
{
G4ParticleDefinition* particle =
fPrimary->GetParticleGun()->GetParticleDefinition();
if (fPrimary) {
G4ParticleDefinition* particle = fPrimary->GetParticleGun()->GetParticleDefinition();
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
fRun->SetPrimary(particle, energy);
}
if(isMaster)
{
if (isMaster) {
fTimer.Start();
}
}
@@ -80,15 +75,11 @@ void RunAction::BeginOfRunAction(const G4Run*)
void RunAction::EndOfRunAction(const G4Run*)
{
// compute and print statistic
if(isMaster)
{
if (isMaster) {
fTimer.Stop();
if(!((G4RunManager::GetRunManager()->GetRunManagerType() ==
G4RunManager::sequentialRM)))
{
if (! ((G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::sequentialRM))) {
G4cout << "\n"
<< "Total number of events: " << fRun->GetNumberOfEvent()
<< G4endl;
<< "Total number of events: " << fRun->GetNumberOfEvent() << G4endl;
G4cout << "Master thread time: " << fTimer << G4endl;
}
fRun->EndOfRun();
@@ -33,9 +33,8 @@
#include "G4ProcessManager.hh"
#include "G4RegionStore.hh"
#include "G4StackManager.hh"
#include "G4TrackingManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4TrackingManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -47,26 +46,21 @@ SpecializedTrackingManager::~SpecializedTrackingManager() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SpecializedTrackingManager::BuildPhysicsTable(
const G4ParticleDefinition& part)
void SpecializedTrackingManager::BuildPhysicsTable(const G4ParticleDefinition& part)
{
if(fBackRegion == nullptr)
{
if (fBackRegion == nullptr) {
fBackRegion = G4RegionStore::GetInstance()->GetRegion("Back", false);
}
G4ProcessManager* pManager = part.GetProcessManager();
G4ProcessManager* pManager = part.GetProcessManager();
G4ProcessManager* pManagerShadow = part.GetMasterProcessManager();
G4ProcessVector* pVector = pManager->GetProcessList();
for(std::size_t j = 0; j < pVector->size(); ++j)
{
if(pManagerShadow == pManager)
{
for (std::size_t j = 0; j < pVector->size(); ++j) {
if (pManagerShadow == pManager) {
(*pVector)[j]->BuildPhysicsTable(part);
}
else
{
else {
(*pVector)[j]->BuildWorkerPhysicsTable(part);
}
}
@@ -74,21 +68,17 @@ void SpecializedTrackingManager::BuildPhysicsTable(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SpecializedTrackingManager::PreparePhysicsTable(
const G4ParticleDefinition& part)
void SpecializedTrackingManager::PreparePhysicsTable(const G4ParticleDefinition& part)
{
G4ProcessManager* pManager = part.GetProcessManager();
G4ProcessManager* pManager = part.GetProcessManager();
G4ProcessManager* pManagerShadow = part.GetMasterProcessManager();
G4ProcessVector* pVector = pManager->GetProcessList();
for(std::size_t j = 0; j < pVector->size(); ++j)
{
if(pManagerShadow == pManager)
{
for (std::size_t j = 0; j < pVector->size(); ++j) {
if (pManagerShadow == pManager) {
(*pVector)[j]->PreparePhysicsTable(part);
}
else
{
else {
(*pVector)[j]->PrepareWorkerPhysicsTable(part);
}
}
@@ -98,20 +88,18 @@ void SpecializedTrackingManager::PreparePhysicsTable(
void SpecializedTrackingManager::HandOverOneTrack(G4Track* aTrack)
{
if(aTrack->GetKineticEnergy() < 100 * MeV)
{
if (aTrack->GetKineticEnergy() < 100 * MeV) {
// If the particle energy is lower than 100 MeV, track it immediately by
// passing to the generic G4TrackingManager. This avoids storing lower
// energy particles in the buffer and feeding it through the specialized
// tracking.
G4EventManager* eventManager = G4EventManager::GetEventManager();
G4EventManager* eventManager = G4EventManager::GetEventManager();
G4TrackingManager* trackManager = eventManager->GetTrackingManager();
trackManager->ProcessOneTrack(aTrack);
if(aTrack->GetTrackStatus() != fStopAndKill)
{
G4Exception("SpecializedTrackingManager::HandOverOneTrack", "NotStopped",
FatalException, "track was not stopped");
if (aTrack->GetTrackStatus() != fStopAndKill) {
G4Exception("SpecializedTrackingManager::HandOverOneTrack", "NotStopped", FatalException,
"track was not stopped");
}
G4TrackVector* secondaries = trackManager->GimmeSecondaries();
@@ -127,26 +115,22 @@ void SpecializedTrackingManager::HandOverOneTrack(G4Track* aTrack)
void SpecializedTrackingManager::FlushEvent()
{
G4EventManager* eventManager = G4EventManager::GetEventManager();
G4TrackingManager* trackManager = eventManager->GetTrackingManager();
G4EventManager* eventManager = G4EventManager::GetEventManager();
G4TrackingManager* trackManager = eventManager->GetTrackingManager();
G4SteppingManager* steppingManager = trackManager->GetSteppingManager();
G4TrackVector* secondaries = trackManager->GimmeSecondaries();
G4TrackVector* secondaries = trackManager->GimmeSecondaries();
for(G4Track* aTrack : fBufferedTracks)
{
for (G4Track* aTrack : fBufferedTracks) {
// Clear secondary particle vector
for(std::size_t itr = 0; itr < secondaries->size(); ++itr)
{
delete(*secondaries)[itr];
for (std::size_t itr = 0; itr < secondaries->size(); ++itr) {
delete (*secondaries)[itr];
}
secondaries->clear();
steppingManager->SetInitialStep(aTrack);
G4UserTrackingAction* userTrackingAction =
trackManager->GetUserTrackingAction();
if(userTrackingAction != nullptr)
{
G4UserTrackingAction* userTrackingAction = trackManager->GetUserTrackingAction();
if (userTrackingAction != nullptr) {
userTrackingAction->PreUserTrackingAction(aTrack);
}
@@ -160,24 +144,19 @@ void SpecializedTrackingManager::FlushEvent()
aTrack->GetDefinition()->GetProcessManager()->StartTracking(aTrack);
// Track the particle Step-by-Step while it is alive
while((aTrack->GetTrackStatus() == fAlive) ||
(aTrack->GetTrackStatus() == fStopButAlive))
{
while ((aTrack->GetTrackStatus() == fAlive) || (aTrack->GetTrackStatus() == fStopButAlive)) {
G4Region* region = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
if(region == fBackRegion)
{
if (region == fBackRegion) {
StepInBackRegion(aTrack);
}
else
{
else {
StepOutside(aTrack);
}
}
aTrack->GetDefinition()->GetProcessManager()->EndTracking();
if(userTrackingAction != nullptr)
{
if (userTrackingAction != nullptr) {
userTrackingAction->PostUserTrackingAction(aTrack);
}
@@ -192,33 +171,28 @@ void SpecializedTrackingManager::FlushEvent()
void SpecializedTrackingManager::StepInBackRegion(G4Track* aTrack)
{
G4EventManager* eventManager = G4EventManager::GetEventManager();
G4TrackingManager* trackManager = eventManager->GetTrackingManager();
G4EventManager* eventManager = G4EventManager::GetEventManager();
G4TrackingManager* trackManager = eventManager->GetTrackingManager();
G4SteppingManager* steppingManager = trackManager->GetSteppingManager();
// Track the particle Step-by-Step while it is alive and inside the "Back"
// region of the detector. Implement a low-energy cut-off for particles
// below 100 MeV. More specialized handling would also be possible, such
// as only killing particles in non-sensitive materials / volumes.
while((aTrack->GetTrackStatus() == fAlive) ||
(aTrack->GetTrackStatus() == fStopButAlive))
{
while ((aTrack->GetTrackStatus() == fAlive) || (aTrack->GetTrackStatus() == fStopButAlive)) {
aTrack->IncrementCurrentStepNumber();
steppingManager->Stepping();
if(aTrack->GetTrackStatus() != fStopAndKill)
{
if (aTrack->GetTrackStatus() != fStopAndKill) {
// Switch the touchable to update the volume, which is checked in the
// condition below and at the call site.
aTrack->SetTouchableHandle(aTrack->GetNextTouchableHandle());
G4Region* region = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
if(region != fBackRegion)
{
if (region != fBackRegion) {
return;
}
if(aTrack->GetKineticEnergy() < 100 * MeV)
{
if (aTrack->GetKineticEnergy() < 100 * MeV) {
// Kill the particle.
aTrack->SetTrackStatus(fStopAndKill);
}
@@ -230,26 +204,22 @@ void SpecializedTrackingManager::StepInBackRegion(G4Track* aTrack)
void SpecializedTrackingManager::StepOutside(G4Track* aTrack)
{
G4EventManager* eventManager = G4EventManager::GetEventManager();
G4TrackingManager* trackManager = eventManager->GetTrackingManager();
G4EventManager* eventManager = G4EventManager::GetEventManager();
G4TrackingManager* trackManager = eventManager->GetTrackingManager();
G4SteppingManager* steppingManager = trackManager->GetSteppingManager();
// Track the particle Step-by-Step while it is alive and still outside of
// the "Back" region.
while((aTrack->GetTrackStatus() == fAlive) ||
(aTrack->GetTrackStatus() == fStopButAlive))
{
while ((aTrack->GetTrackStatus() == fAlive) || (aTrack->GetTrackStatus() == fStopButAlive)) {
aTrack->IncrementCurrentStepNumber();
steppingManager->Stepping();
if(aTrack->GetTrackStatus() != fStopAndKill)
{
if (aTrack->GetTrackStatus() != fStopAndKill) {
// Switch the touchable to update the volume, which is checked in the
// condition below and at the call site.
aTrack->SetTouchableHandle(aTrack->GetNextTouchableHandle());
G4Region* region = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
if(region == fBackRegion)
{
if (region == fBackRegion) {
return;
}
}
@@ -32,20 +32,18 @@
#include "SteppingAction.hh"
#include "DetectorConstruction.hh"
#include "EventAction.hh"
#include "Run.hh"
#include "G4PhysicalConstants.hh"
#include "G4Positron.hh"
#include "G4RunManager.hh"
#include "DetectorConstruction.hh"
#include "EventAction.hh"
#include "Run.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction(DetectorConstruction* det, EventAction* evt)
: G4UserSteppingAction()
, fDetector(det)
, fEventAct(evt)
: G4UserSteppingAction(), fDetector(det), fEventAct(evt)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -61,8 +59,7 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep)
// if sum of absorbers do not fill exactly a layer: check material, not
// volume.
const G4Material* mat = volume->GetLogicalVolume()->GetMaterial();
if(mat == fDetector->GetWorldMaterial())
return;
if (mat == fDetector->GetWorldMaterial()) return;
const G4ParticleDefinition* particle = aStep->GetTrack()->GetDefinition();
@@ -72,22 +69,18 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep)
// G4int layerNum = prePoint->GetTouchableHandle()->GetCopyNumber(1);
// get Run
Run* run =
static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
// collect energy deposit taking into account track weight
G4double edep =
aStep->GetTotalEnergyDeposit() * aStep->GetTrack()->GetWeight();
G4double edep = aStep->GetTotalEnergyDeposit() * aStep->GetTrack()->GetWeight();
// collect step length of charged particles
G4double stepl = 0.;
if(particle->GetPDGCharge() != 0.)
{
if (particle->GetPDGCharge() != 0.) {
stepl = aStep->GetStepLength();
run->AddChargedStep();
}
else
{
else {
run->AddNeutralStep();
}
@@ -33,28 +33,24 @@
#include "TrackingAction.hh"
#include "Run.hh"
#include "G4PhysicalConstants.hh"
#include "G4Positron.hh"
#include "G4RunManager.hh"
#include "Run.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackingAction::TrackingAction()
: G4UserTrackingAction()
{}
TrackingAction::TrackingAction() : G4UserTrackingAction() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void TrackingAction::PreUserTrackingAction(const G4Track* track)
{
// get Run
Run* run =
static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
if(track->GetTrackID() != 1)
{
if (track->GetTrackID() != 1) {
run->AddSecondaryTrack(track);
}
}