Import Geant4 11.1.0 source tree
This commit is contained in:
@@ -5,6 +5,10 @@ which **must** added in reverse chronological order (newest at the top). It must
|
||||
be used as a substitute for writing good git commit messages!
|
||||
|
||||
|
||||
## 2022-09-14 Jonas Hahnfeld (exampleRE07-V11-00-01)
|
||||
- Run `clang-format`
|
||||
- Rename static class member `fMasterTrackingManager`
|
||||
|
||||
## 2021-12-10 Ben Morgan (exampleRE07-V11-00-00)
|
||||
- Change to new Markdown History format
|
||||
|
||||
|
||||
@@ -30,32 +30,29 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PhysicsList.hh"
|
||||
|
||||
#include "G4RunManagerFactory.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PhysicsList.hh"
|
||||
|
||||
#include <memory>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if(argc < 2)
|
||||
{
|
||||
if (argc < 2) {
|
||||
G4cerr << "No macro file provided, exiting!" << G4endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Creating run manager
|
||||
std::unique_ptr<G4RunManager> runManager(
|
||||
G4RunManagerFactory::CreateRunManager());
|
||||
std::unique_ptr<G4RunManager> runManager(G4RunManagerFactory::CreateRunManager());
|
||||
|
||||
if(argc == 3)
|
||||
{
|
||||
if (argc == 3) {
|
||||
G4int nThreads = G4UIcommand::ConvertToInt(argv[2]);
|
||||
runManager->SetNumberOfThreads(nThreads);
|
||||
}
|
||||
@@ -71,7 +68,7 @@ int main(int argc, char** argv)
|
||||
// get the pointer to the User Interface manager
|
||||
G4UImanager* UImanager = G4UImanager::GetUIpointer();
|
||||
|
||||
G4String command = "/control/execute ";
|
||||
G4String command = "/control/execute ";
|
||||
G4String fileName = argv[1];
|
||||
UImanager->ApplyCommand(command + fileName);
|
||||
|
||||
|
||||
@@ -81,10 +81,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction
|
||||
|
||||
G4int GetNbOfAbsor() const { return fNbOfAbsor; };
|
||||
G4double GetAbsorThickness(G4int i) const { return fAbsorThickness[i]; };
|
||||
const G4Material* GetAbsorMaterial(G4int i) const
|
||||
{
|
||||
return fAbsorMaterial[i];
|
||||
};
|
||||
const G4Material* GetAbsorMaterial(G4int i) const { return fAbsorMaterial[i]; };
|
||||
|
||||
const G4VPhysicalVolume* GetphysiWorld() const { return fPhysiWorld; };
|
||||
const G4Material* GetWorldMaterial() const { return fWorldMaterial; };
|
||||
|
||||
@@ -91,7 +91,7 @@ class EmStandardPhysicsTrackingManager : public G4VTrackingManager
|
||||
G4RayleighScattering* rayleigh;
|
||||
} fGammaProcs;
|
||||
|
||||
static EmStandardPhysicsTrackingManager* masterTrackingManager;
|
||||
static EmStandardPhysicsTrackingManager* fMasterTrackingManager;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,10 +33,11 @@
|
||||
#ifndef EventAction_h
|
||||
#define EventAction_h 1
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4UserEventAction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class EventAction : public G4UserEventAction
|
||||
|
||||
@@ -33,10 +33,11 @@
|
||||
#ifndef Run_h
|
||||
#define Run_h 1
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include <map>
|
||||
|
||||
class DetectorConstruction;
|
||||
|
||||
@@ -62,41 +62,36 @@ class TrackingManagerHelper
|
||||
// automatically after this method returns. If secondaries should be given
|
||||
// back to the G4EventManager, put them into the container passed as the
|
||||
// last argument.
|
||||
virtual void AlongStepDoIt(G4Track& track, G4Step& step,
|
||||
G4TrackVector& secondaries) = 0;
|
||||
virtual void AlongStepDoIt(G4Track& track, G4Step& step, G4TrackVector& secondaries) = 0;
|
||||
|
||||
// This method is called unless the track has been killed during this step.
|
||||
// If secondaries should be given back to the G4EventManager, put them into
|
||||
// the container passed as the last argument.
|
||||
virtual void PostStepDoIt(G4Track& track, G4Step& step,
|
||||
G4TrackVector& secondaries) = 0;
|
||||
virtual void PostStepDoIt(G4Track& track, G4Step& step, G4TrackVector& secondaries) = 0;
|
||||
|
||||
virtual bool HasAtRestProcesses() { return false; }
|
||||
|
||||
// This method is called when a track is stopped, but still alive. If
|
||||
// secondaries should be given back to the G4EventManager, put them into
|
||||
// the container passed as the last argument.
|
||||
virtual void AtRestDoIt(G4Track& track, G4Step& step,
|
||||
G4TrackVector& secondaries)
|
||||
virtual void AtRestDoIt(G4Track& track, G4Step& step, G4TrackVector& secondaries)
|
||||
{
|
||||
(void) track;
|
||||
(void) step;
|
||||
(void) secondaries;
|
||||
(void)track;
|
||||
(void)step;
|
||||
(void)secondaries;
|
||||
}
|
||||
};
|
||||
|
||||
class Navigation
|
||||
{
|
||||
public:
|
||||
virtual G4double MakeStep(G4Track& track, G4Step& step,
|
||||
G4double physicalStep) = 0;
|
||||
virtual G4double MakeStep(G4Track& track, G4Step& step, G4double physicalStep) = 0;
|
||||
|
||||
virtual void FinishStep(G4Track& track, G4Step& step) = 0;
|
||||
};
|
||||
|
||||
template <typename PhysicsImpl, typename NavigationImpl>
|
||||
static void TrackParticle(G4Track* aTrack, PhysicsImpl& physics,
|
||||
NavigationImpl& navigation);
|
||||
static void TrackParticle(G4Track* aTrack, PhysicsImpl& physics, NavigationImpl& navigation);
|
||||
|
||||
template <typename PhysicsImpl>
|
||||
static void TrackChargedParticle(G4Track* aTrack, PhysicsImpl& physics);
|
||||
|
||||
@@ -35,14 +35,6 @@
|
||||
// Original author: Jonas Hahnfeld, 2021
|
||||
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4TrackVector.hh"
|
||||
#include "G4UserSteppingAction.hh"
|
||||
#include "G4UserTrackingAction.hh"
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
|
||||
#include "G4Field.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4FieldManagerStore.hh"
|
||||
@@ -52,23 +44,30 @@
|
||||
#include "G4PropagatorInField.hh"
|
||||
#include "G4Region.hh"
|
||||
#include "G4SafetyHelper.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4TouchableHandle.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4TrackVector.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4UserSteppingAction.hh"
|
||||
#include "G4UserTrackingAction.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
|
||||
template <typename PhysicsImpl, typename NavigationImpl>
|
||||
void TrackingManagerHelper::TrackParticle(G4Track* aTrack, PhysicsImpl& physics,
|
||||
NavigationImpl& navigation)
|
||||
void TrackingManagerHelper::TrackParticle(
|
||||
G4Track* aTrack, PhysicsImpl& physics, NavigationImpl& navigation)
|
||||
{
|
||||
// Prepare for calling the user action.
|
||||
auto* evtMgr = G4EventManager::GetEventManager();
|
||||
auto* evtMgr = G4EventManager::GetEventManager();
|
||||
auto* userTrackingAction = evtMgr->GetUserTrackingAction();
|
||||
auto* userSteppingAction = evtMgr->GetUserSteppingAction();
|
||||
|
||||
// Locate the track in geometry.
|
||||
{
|
||||
auto* transMgr = G4TransportationManager::GetTransportationManager();
|
||||
auto* transMgr = G4TransportationManager::GetTransportationManager();
|
||||
auto* linearNavigator = transMgr->GetNavigatorForTracking();
|
||||
|
||||
const G4ThreeVector& pos = aTrack->GetPosition();
|
||||
@@ -76,24 +75,20 @@ void TrackingManagerHelper::TrackParticle(G4Track* aTrack, PhysicsImpl& physics,
|
||||
|
||||
// Do not assign directly, doesn't work if the handle is empty.
|
||||
G4TouchableHandle touchableHandle;
|
||||
if(aTrack->GetTouchableHandle())
|
||||
{
|
||||
if (aTrack->GetTouchableHandle()) {
|
||||
touchableHandle = aTrack->GetTouchableHandle();
|
||||
// FIXME: This assumes we only ever have G4TouchableHistorys!
|
||||
auto* touchableHistory = (G4TouchableHistory*) touchableHandle();
|
||||
auto* touchableHistory = (G4TouchableHistory*)touchableHandle();
|
||||
G4VPhysicalVolume* oldTopVolume = touchableHandle->GetVolume();
|
||||
G4VPhysicalVolume* newTopVolume =
|
||||
linearNavigator->ResetHierarchyAndLocate(pos, dir, *touchableHistory);
|
||||
// TODO: WHY?!
|
||||
if(newTopVolume != oldTopVolume ||
|
||||
oldTopVolume->GetRegularStructureId() == 1)
|
||||
{
|
||||
if (newTopVolume != oldTopVolume || oldTopVolume->GetRegularStructureId() == 1) {
|
||||
touchableHandle = linearNavigator->CreateTouchableHistory();
|
||||
aTrack->SetTouchableHandle(touchableHandle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
linearNavigator->LocateGlobalPointAndSetup(pos, &dir, false, false);
|
||||
touchableHandle = linearNavigator->CreateTouchableHistory();
|
||||
aTrack->SetTouchableHandle(touchableHandle);
|
||||
@@ -110,15 +105,13 @@ void TrackingManagerHelper::TrackParticle(G4Track* aTrack, PhysicsImpl& physics,
|
||||
G4TrackVector secondaries;
|
||||
|
||||
// Start of tracking: Inform user and processes.
|
||||
if(userTrackingAction)
|
||||
{
|
||||
if (userTrackingAction) {
|
||||
userTrackingAction->PreUserTrackingAction(aTrack);
|
||||
}
|
||||
|
||||
physics.StartTracking(aTrack);
|
||||
|
||||
while(aTrack->GetTrackStatus() == fAlive)
|
||||
{
|
||||
while (aTrack->GetTrackStatus() == fAlive) {
|
||||
// Beginning of this step: Prepare data structures.
|
||||
aTrack->IncrementCurrentStepNumber();
|
||||
|
||||
@@ -144,15 +137,11 @@ void TrackingManagerHelper::TrackParticle(G4Track* aTrack, PhysicsImpl& physics,
|
||||
physics.AlongStepDoIt(*aTrack, step, secondaries);
|
||||
step.UpdateTrack();
|
||||
|
||||
if(aTrack->GetTrackStatus() == fAlive &&
|
||||
aTrack->GetKineticEnergy() < DBL_MIN)
|
||||
{
|
||||
if(physics.HasAtRestProcesses())
|
||||
{
|
||||
if (aTrack->GetTrackStatus() == fAlive && aTrack->GetKineticEnergy() < DBL_MIN) {
|
||||
if (physics.HasAtRestProcesses()) {
|
||||
aTrack->SetTrackStatus(fStopButAlive);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
}
|
||||
}
|
||||
@@ -160,16 +149,14 @@ void TrackingManagerHelper::TrackParticle(G4Track* aTrack, PhysicsImpl& physics,
|
||||
navigation.FinishStep(*aTrack, step);
|
||||
|
||||
// Check if the track left the world.
|
||||
if(aTrack->GetNextVolume() == nullptr)
|
||||
{
|
||||
if (aTrack->GetNextVolume() == nullptr) {
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
}
|
||||
|
||||
// The check should rather check for == fAlive and avoid calling
|
||||
// PostStepDoIt for fStopButAlive, but the generic stepping loop
|
||||
// does it like this...
|
||||
if(aTrack->GetTrackStatus() != fStopAndKill)
|
||||
{
|
||||
if (aTrack->GetTrackStatus() != fStopAndKill) {
|
||||
physics.PostStepDoIt(*aTrack, step, secondaries);
|
||||
}
|
||||
|
||||
@@ -177,30 +164,24 @@ void TrackingManagerHelper::TrackParticle(G4Track* aTrack, PhysicsImpl& physics,
|
||||
aTrack->AddTrackLength(step.GetStepLength());
|
||||
|
||||
// End of this step: Call sensitive detector and stepping actions.
|
||||
if(step.GetControlFlag() != AvoidHitInvocation)
|
||||
{
|
||||
if (step.GetControlFlag() != AvoidHitInvocation) {
|
||||
auto* sensitive = lvol->GetSensitiveDetector();
|
||||
if(sensitive)
|
||||
{
|
||||
if (sensitive) {
|
||||
sensitive->Hit(&step);
|
||||
}
|
||||
}
|
||||
|
||||
if(userSteppingAction)
|
||||
{
|
||||
if (userSteppingAction) {
|
||||
userSteppingAction->UserSteppingAction(&step);
|
||||
}
|
||||
|
||||
auto* regionalAction = lvol->GetRegion()->GetRegionalSteppingAction();
|
||||
if(regionalAction)
|
||||
{
|
||||
if (regionalAction) {
|
||||
regionalAction->UserSteppingAction(&step);
|
||||
}
|
||||
}
|
||||
|
||||
if(aTrack->GetTrackStatus() == fStopButAlive &&
|
||||
aTrack->GetNextVolume() != nullptr)
|
||||
{
|
||||
if (aTrack->GetTrackStatus() == fStopButAlive && aTrack->GetNextVolume() != nullptr) {
|
||||
// Do one final step.
|
||||
aTrack->IncrementCurrentStepNumber();
|
||||
|
||||
@@ -211,23 +192,19 @@ void TrackingManagerHelper::TrackParticle(G4Track* aTrack, PhysicsImpl& physics,
|
||||
|
||||
// End of this step: Call sensitive detector and stepping actions.
|
||||
auto* lvol = aTrack->GetTouchable()->GetVolume()->GetLogicalVolume();
|
||||
if(step.GetControlFlag() != AvoidHitInvocation)
|
||||
{
|
||||
if (step.GetControlFlag() != AvoidHitInvocation) {
|
||||
auto sensitive = lvol->GetSensitiveDetector();
|
||||
if(sensitive)
|
||||
{
|
||||
if (sensitive) {
|
||||
sensitive->Hit(&step);
|
||||
}
|
||||
}
|
||||
|
||||
if(userSteppingAction)
|
||||
{
|
||||
if (userSteppingAction) {
|
||||
userSteppingAction->UserSteppingAction(&step);
|
||||
}
|
||||
|
||||
auto* regionalAction = lvol->GetRegion()->GetRegionalSteppingAction();
|
||||
if(regionalAction)
|
||||
{
|
||||
if (regionalAction) {
|
||||
regionalAction->UserSteppingAction(&step);
|
||||
}
|
||||
}
|
||||
@@ -235,8 +212,7 @@ void TrackingManagerHelper::TrackParticle(G4Track* aTrack, PhysicsImpl& physics,
|
||||
// End of tracking: Inform processes and user.
|
||||
physics.EndTracking();
|
||||
|
||||
if(userTrackingAction)
|
||||
{
|
||||
if (userTrackingAction) {
|
||||
userTrackingAction->PostUserTrackingAction(aTrack);
|
||||
}
|
||||
|
||||
@@ -246,20 +222,18 @@ void TrackingManagerHelper::TrackParticle(G4Track* aTrack, PhysicsImpl& physics,
|
||||
}
|
||||
|
||||
template <typename PhysicsImpl>
|
||||
void TrackingManagerHelper::TrackChargedParticle(G4Track* aTrack,
|
||||
PhysicsImpl& physics)
|
||||
void TrackingManagerHelper::TrackChargedParticle(G4Track* aTrack, PhysicsImpl& physics)
|
||||
{
|
||||
class ChargedNavigation final : public Navigation
|
||||
{
|
||||
public:
|
||||
ChargedNavigation()
|
||||
{
|
||||
auto* transMgr = G4TransportationManager::GetTransportationManager();
|
||||
auto* transMgr = G4TransportationManager::GetTransportationManager();
|
||||
fLinearNavigator = transMgr->GetNavigatorForTracking();
|
||||
fFieldPropagator = transMgr->GetPropagatorInField();
|
||||
fSafetyHelper = transMgr->GetSafetyHelper();
|
||||
kCarTolerance =
|
||||
0.5 * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
fSafetyHelper = transMgr->GetSafetyHelper();
|
||||
kCarTolerance = 0.5 * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
|
||||
// Reset sstate of field propagator and all chord finders.
|
||||
fFieldPropagator->ClearPropagatorState();
|
||||
@@ -268,20 +242,16 @@ void TrackingManagerHelper::TrackChargedParticle(G4Track* aTrack,
|
||||
fieldMgrStore->ClearAllChordFindersState();
|
||||
}
|
||||
|
||||
G4double MakeStep(G4Track& track, G4Step& step,
|
||||
G4double physicalStep) override
|
||||
G4double MakeStep(G4Track& track, G4Step& step, G4double physicalStep) override
|
||||
{
|
||||
G4ThreeVector pos = track.GetPosition();
|
||||
G4ThreeVector dir = track.GetMomentumDirection();
|
||||
G4ThreeVector pos = track.GetPosition();
|
||||
G4ThreeVector dir = track.GetMomentumDirection();
|
||||
G4StepPoint& postStepPoint = *step.GetPostStepPoint();
|
||||
|
||||
bool fieldExertsForce = false;
|
||||
if(auto* fieldMgr =
|
||||
fFieldPropagator->FindAndSetFieldManager(track.GetVolume()))
|
||||
{
|
||||
if (auto* fieldMgr = fFieldPropagator->FindAndSetFieldManager(track.GetVolume())) {
|
||||
fieldMgr->ConfigureForTrack(&track);
|
||||
if(const G4Field* ptrField = fieldMgr->GetDetectorField())
|
||||
{
|
||||
if (const G4Field* ptrField = fieldMgr->GetDetectorField()) {
|
||||
fieldExertsForce = true;
|
||||
}
|
||||
}
|
||||
@@ -292,21 +262,19 @@ void TrackingManagerHelper::TrackChargedParticle(G4Track* aTrack,
|
||||
// short steps where the field propagator returns immediately without
|
||||
// calling geometry.
|
||||
const G4double shiftSquare = (pos - fSafetyOrigin).mag2();
|
||||
if(shiftSquare < sqr(fSafety))
|
||||
{
|
||||
if (shiftSquare < sqr(fSafety)) {
|
||||
safety = fSafety - std::sqrt(shiftSquare);
|
||||
}
|
||||
|
||||
if(fieldExertsForce)
|
||||
{
|
||||
if (fieldExertsForce) {
|
||||
const G4DynamicParticle* pParticle = track.GetDynamicParticle();
|
||||
const G4double particleCharge = pParticle->GetCharge();
|
||||
const G4double particleMass = pParticle->GetMass();
|
||||
const G4double magneticMoment = pParticle->GetMagneticMoment();
|
||||
const G4ThreeVector particleSpin = pParticle->GetPolarization();
|
||||
const G4double kineticEnergy = pParticle->GetKineticEnergy();
|
||||
const auto pParticleDef = pParticle->GetDefinition();
|
||||
const auto particlePDGSpin = pParticleDef->GetPDGSpin();
|
||||
const G4double particleCharge = pParticle->GetCharge();
|
||||
const G4double particleMass = pParticle->GetMass();
|
||||
const G4double magneticMoment = pParticle->GetMagneticMoment();
|
||||
const G4ThreeVector particleSpin = pParticle->GetPolarization();
|
||||
const G4double kineticEnergy = pParticle->GetKineticEnergy();
|
||||
const auto pParticleDef = pParticle->GetDefinition();
|
||||
const auto particlePDGSpin = pParticleDef->GetPDGSpin();
|
||||
const auto particlePDGMagM = pParticleDef->GetPDGMagneticMoment();
|
||||
|
||||
auto equationOfMotion = fFieldPropagator->GetCurrentEquationOfMotion();
|
||||
@@ -314,32 +282,28 @@ void TrackingManagerHelper::TrackChargedParticle(G4Track* aTrack,
|
||||
G4ChargeState(particleCharge, magneticMoment, particlePDGSpin),
|
||||
pParticle->GetTotalMomentum(), particleMass);
|
||||
|
||||
const G4ThreeVector startPosition = pos;
|
||||
const G4ThreeVector startPosition = pos;
|
||||
const G4ThreeVector startDirection = dir;
|
||||
G4FieldTrack aFieldTrack(startPosition,
|
||||
track.GetGlobalTime(), // Lab.
|
||||
dir, kineticEnergy, particleMass,
|
||||
particleCharge, particleSpin, particlePDGMagM,
|
||||
0.0, // Length along track
|
||||
particlePDGSpin);
|
||||
track.GetGlobalTime(), // Lab.
|
||||
dir, kineticEnergy, particleMass, particleCharge, particleSpin, particlePDGMagM,
|
||||
0.0, // Length along track
|
||||
particlePDGSpin);
|
||||
|
||||
// Do the Transport in the field (non recti-linear)
|
||||
//
|
||||
fGeometryLimitedStep = false;
|
||||
fGeometryLimitedStep = false;
|
||||
const G4double lengthAlongCurve = fFieldPropagator->ComputeStep(
|
||||
aFieldTrack, physicalStep, safety, track.GetVolume(),
|
||||
kineticEnergy < 250.0);
|
||||
if(lengthAlongCurve < physicalStep)
|
||||
{
|
||||
physicalStep = lengthAlongCurve;
|
||||
aFieldTrack, physicalStep, safety, track.GetVolume(), kineticEnergy < 250.0);
|
||||
if (lengthAlongCurve < physicalStep) {
|
||||
physicalStep = lengthAlongCurve;
|
||||
fGeometryLimitedStep = true;
|
||||
}
|
||||
fSafetyHelper->SetCurrentSafety(safety, pos);
|
||||
fSafetyOrigin = pos;
|
||||
fSafety = safety;
|
||||
fSafety = safety;
|
||||
|
||||
if(fFieldPropagator->IsParticleLooping())
|
||||
{
|
||||
if (fFieldPropagator->IsParticleLooping()) {
|
||||
track.SetTrackStatus(fStopAndKill);
|
||||
}
|
||||
|
||||
@@ -351,19 +315,16 @@ void TrackingManagerHelper::TrackChargedParticle(G4Track* aTrack,
|
||||
|
||||
endpointDistance = (startPosition - pos).mag();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
fGeometryLimitedStep = false;
|
||||
G4double linearStepLength =
|
||||
fLinearNavigator->ComputeStep(pos, dir, physicalStep, safety);
|
||||
if(linearStepLength < physicalStep)
|
||||
{
|
||||
physicalStep = linearStepLength;
|
||||
G4double linearStepLength = fLinearNavigator->ComputeStep(pos, dir, physicalStep, safety);
|
||||
if (linearStepLength < physicalStep) {
|
||||
physicalStep = linearStepLength;
|
||||
fGeometryLimitedStep = true;
|
||||
}
|
||||
fSafetyHelper->SetCurrentSafety(safety, pos);
|
||||
fSafetyOrigin = pos;
|
||||
fSafety = safety;
|
||||
fSafety = safety;
|
||||
|
||||
// Update the position.
|
||||
pos += physicalStep * dir;
|
||||
@@ -373,43 +334,37 @@ void TrackingManagerHelper::TrackChargedParticle(G4Track* aTrack,
|
||||
}
|
||||
|
||||
// Update global, local, and proper time.
|
||||
double velocity = track.GetVelocity();
|
||||
double velocity = track.GetVelocity();
|
||||
double deltaTime = 0;
|
||||
if(velocity > 0)
|
||||
{
|
||||
if (velocity > 0) {
|
||||
deltaTime = physicalStep / velocity;
|
||||
}
|
||||
|
||||
postStepPoint.AddGlobalTime(deltaTime);
|
||||
postStepPoint.AddLocalTime(deltaTime);
|
||||
|
||||
double restMass = track.GetDynamicParticle()->GetMass();
|
||||
double restMass = track.GetDynamicParticle()->GetMass();
|
||||
double deltaProperTime = deltaTime * (restMass / track.GetTotalEnergy());
|
||||
postStepPoint.AddProperTime(deltaProperTime);
|
||||
|
||||
// Compute safety, including the call to safetyHelper, but don't set the
|
||||
// safety in the post-step point to mimick the generic stepping loop.
|
||||
if(safety > physicalStep)
|
||||
{
|
||||
if (safety > physicalStep) {
|
||||
safety -= physicalStep;
|
||||
}
|
||||
else if(safety < endpointDistance)
|
||||
{
|
||||
else if (safety < endpointDistance) {
|
||||
safety = fLinearNavigator->ComputeSafety(pos);
|
||||
fSafetyHelper->SetCurrentSafety(safety, pos);
|
||||
fSafetyOrigin = pos;
|
||||
fSafety = safety;
|
||||
fSafety = safety;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
safety = 0;
|
||||
}
|
||||
if(safety < kCarTolerance)
|
||||
{
|
||||
if (safety < kCarTolerance) {
|
||||
fPostStepSafety = kCarTolerance;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
fPostStepSafety = safety;
|
||||
}
|
||||
|
||||
@@ -423,25 +378,21 @@ void TrackingManagerHelper::TrackChargedParticle(G4Track* aTrack,
|
||||
postStepPoint.SetSafety(fPostStepSafety);
|
||||
|
||||
G4TouchableHandle touchableHandle = track.GetTouchableHandle();
|
||||
const G4ThreeVector& pos = track.GetPosition();
|
||||
if(fGeometryLimitedStep)
|
||||
{
|
||||
const G4ThreeVector& pos = track.GetPosition();
|
||||
if (fGeometryLimitedStep) {
|
||||
// Relocate the particle.
|
||||
fLinearNavigator->SetGeometricallyLimitedStep();
|
||||
fLinearNavigator->LocateGlobalPointAndUpdateTouchableHandle(
|
||||
pos, track.GetMomentumDirection(), touchableHandle, true);
|
||||
const G4VPhysicalVolume* newVolume = touchableHandle->GetVolume();
|
||||
if(newVolume == nullptr)
|
||||
{
|
||||
if (newVolume == nullptr) {
|
||||
postStepPoint.SetStepStatus(fWorldBoundary);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
postStepPoint.SetStepStatus(fGeomBoundary);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// Move the Navigator's location.
|
||||
fLinearNavigator->LocateGlobalPointWithinVolume(pos);
|
||||
}
|
||||
@@ -455,7 +406,7 @@ void TrackingManagerHelper::TrackChargedParticle(G4Track* aTrack,
|
||||
G4PropagatorInField* fFieldPropagator;
|
||||
G4SafetyHelper* fSafetyHelper;
|
||||
G4ThreeVector fSafetyOrigin;
|
||||
G4double fSafety = 0;
|
||||
G4double fSafety = 0;
|
||||
G4double fPostStepSafety = 0;
|
||||
G4double kCarTolerance;
|
||||
G4bool fGeometryLimitedStep;
|
||||
@@ -466,81 +417,70 @@ void TrackingManagerHelper::TrackChargedParticle(G4Track* aTrack,
|
||||
}
|
||||
|
||||
template <typename PhysicsImpl>
|
||||
void TrackingManagerHelper::TrackNeutralParticle(G4Track* aTrack,
|
||||
PhysicsImpl& physics)
|
||||
void TrackingManagerHelper::TrackNeutralParticle(G4Track* aTrack, PhysicsImpl& physics)
|
||||
{
|
||||
class NeutralNavigation final : public Navigation
|
||||
{
|
||||
public:
|
||||
NeutralNavigation()
|
||||
{
|
||||
auto* transMgr = G4TransportationManager::GetTransportationManager();
|
||||
auto* transMgr = G4TransportationManager::GetTransportationManager();
|
||||
fLinearNavigator = transMgr->GetNavigatorForTracking();
|
||||
fSafetyHelper = transMgr->GetSafetyHelper();
|
||||
kCarTolerance =
|
||||
0.5 * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
fSafetyHelper = transMgr->GetSafetyHelper();
|
||||
kCarTolerance = 0.5 * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
}
|
||||
|
||||
G4double MakeStep(G4Track& track, G4Step& step,
|
||||
G4double physicalStep) override
|
||||
G4double MakeStep(G4Track& track, G4Step& step, G4double physicalStep) override
|
||||
{
|
||||
G4ThreeVector pos = track.GetPosition();
|
||||
G4ThreeVector dir = track.GetMomentumDirection();
|
||||
G4ThreeVector pos = track.GetPosition();
|
||||
G4ThreeVector dir = track.GetMomentumDirection();
|
||||
G4StepPoint& postStepPoint = *step.GetPostStepPoint();
|
||||
|
||||
G4double safety = 0.0;
|
||||
G4double safety = 0.0;
|
||||
const G4double shiftSquare = (pos - fSafetyOrigin).mag2();
|
||||
if(shiftSquare < sqr(fSafety))
|
||||
{
|
||||
if (shiftSquare < sqr(fSafety)) {
|
||||
safety = fSafety - std::sqrt(shiftSquare);
|
||||
}
|
||||
|
||||
fGeometryLimitedStep = false;
|
||||
G4double linearStepLength =
|
||||
fLinearNavigator->ComputeStep(pos, dir, physicalStep, safety);
|
||||
if(linearStepLength < physicalStep)
|
||||
{
|
||||
physicalStep = linearStepLength;
|
||||
G4double linearStepLength = fLinearNavigator->ComputeStep(pos, dir, physicalStep, safety);
|
||||
if (linearStepLength < physicalStep) {
|
||||
physicalStep = linearStepLength;
|
||||
fGeometryLimitedStep = true;
|
||||
}
|
||||
fSafetyHelper->SetCurrentSafety(safety, pos);
|
||||
fSafetyOrigin = pos;
|
||||
fSafety = safety;
|
||||
fSafety = safety;
|
||||
|
||||
// Update the position.
|
||||
pos += physicalStep * dir;
|
||||
postStepPoint.SetPosition(pos);
|
||||
|
||||
// Update global, local, and proper time.
|
||||
double velocity = track.GetVelocity();
|
||||
double velocity = track.GetVelocity();
|
||||
double deltaTime = 0;
|
||||
if(velocity > 0)
|
||||
{
|
||||
if (velocity > 0) {
|
||||
deltaTime = physicalStep / velocity;
|
||||
}
|
||||
postStepPoint.AddGlobalTime(deltaTime);
|
||||
postStepPoint.AddLocalTime(deltaTime);
|
||||
|
||||
double restMass = track.GetDynamicParticle()->GetMass();
|
||||
double restMass = track.GetDynamicParticle()->GetMass();
|
||||
double deltaProperTime = deltaTime * (restMass / track.GetTotalEnergy());
|
||||
postStepPoint.AddProperTime(deltaProperTime);
|
||||
|
||||
// Compute safety, but don't set the safety in the post-step point to
|
||||
// mimick the generic stepping loop.
|
||||
if(safety > physicalStep)
|
||||
{
|
||||
if (safety > physicalStep) {
|
||||
safety -= physicalStep;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
safety = 0;
|
||||
}
|
||||
if(safety < kCarTolerance)
|
||||
{
|
||||
if (safety < kCarTolerance) {
|
||||
fPostStepSafety = kCarTolerance;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
fPostStepSafety = safety;
|
||||
}
|
||||
|
||||
@@ -554,25 +494,21 @@ void TrackingManagerHelper::TrackNeutralParticle(G4Track* aTrack,
|
||||
postStepPoint.SetSafety(fPostStepSafety);
|
||||
|
||||
G4TouchableHandle touchableHandle = track.GetTouchableHandle();
|
||||
const G4ThreeVector& pos = track.GetPosition();
|
||||
if(fGeometryLimitedStep)
|
||||
{
|
||||
const G4ThreeVector& pos = track.GetPosition();
|
||||
if (fGeometryLimitedStep) {
|
||||
// Relocate the particle.
|
||||
fLinearNavigator->SetGeometricallyLimitedStep();
|
||||
fLinearNavigator->LocateGlobalPointAndUpdateTouchableHandle(
|
||||
pos, track.GetMomentumDirection(), touchableHandle, true);
|
||||
const G4VPhysicalVolume* newVolume = touchableHandle->GetVolume();
|
||||
if(newVolume == nullptr)
|
||||
{
|
||||
if (newVolume == nullptr) {
|
||||
postStepPoint.SetStepStatus(fWorldBoundary);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
postStepPoint.SetStepStatus(fGeomBoundary);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// Move the Navigator's location.
|
||||
fLinearNavigator->LocateGlobalPointWithinVolume(pos);
|
||||
}
|
||||
@@ -585,7 +521,7 @@ void TrackingManagerHelper::TrackNeutralParticle(G4Track* aTrack,
|
||||
G4Navigator* fLinearNavigator;
|
||||
G4SafetyHelper* fSafetyHelper;
|
||||
G4ThreeVector fSafetyOrigin;
|
||||
G4double fSafety = 0;
|
||||
G4double fSafety = 0;
|
||||
G4double fPostStepSafety = 0;
|
||||
G4double kCarTolerance;
|
||||
G4bool fGeometryLimitedStep;
|
||||
|
||||
@@ -11,7 +11,7 @@ Environment variable "G4FORCE_RUN_MANAGER_TYPE" enabled with value == Serial. Fo
|
||||
|
||||
|
||||
**************************************************************
|
||||
Geant4 version Name: geant4-11-01-beta-01 (30-June-2022)
|
||||
Geant4 version Name: geant4-11-01-ref-00 (9-December-2022)
|
||||
Copyright : Geant4 Collaboration
|
||||
References : NIM A 506 (2003), 250-303
|
||||
: IEEE-TNS 53 (2006), 270-278
|
||||
@@ -64,15 +64,15 @@ Command is ignored.
|
||||
------------------------------------------------------------
|
||||
material Edep RMS sqrt(E0(GeV))*rmsE/Emean total tracklen
|
||||
|
||||
G4_Pb: 775.55 MeV : 16.21 MeV 2.09 +- 0.0661 % 54.8 cm +- 1.26 cm
|
||||
G4_lAr: 214.33 MeV : 15.46 MeV 7.212 +- 0.2281 % 1.05 m +- 7.92 cm
|
||||
G4_Pb: 775.16 MeV : 16.8 MeV 2.167 +- 0.06853 % 54.8 cm +- 1.27 cm
|
||||
G4_lAr: 214.33 MeV : 15.48 MeV 7.224 +- 0.2284 % 1.05 m +- 7.92 cm
|
||||
|
||||
------------------------------------------------------------
|
||||
Beam particle e- E = 1 GeV
|
||||
Mean number of gamma 509
|
||||
Mean number of e- 868
|
||||
Mean number of gamma 508
|
||||
Mean number of e- 870
|
||||
Mean number of e+ 53.5
|
||||
Mean number of charged steps 3667.62
|
||||
Mean number of neutral steps 3692.19
|
||||
Mean number of charged steps 3666.14
|
||||
Mean number of neutral steps 3691.55
|
||||
------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ Environment variable "G4FORCE_RUN_MANAGER_TYPE" enabled with value == Serial. Fo
|
||||
|
||||
|
||||
**************************************************************
|
||||
Geant4 version Name: geant4-11-01-beta-01 (30-June-2022)
|
||||
Geant4 version Name: geant4-11-01-ref-00 (9-December-2022)
|
||||
Copyright : Geant4 Collaboration
|
||||
References : NIM A 506 (2003), 250-303
|
||||
: IEEE-TNS 53 (2006), 270-278
|
||||
@@ -64,15 +64,15 @@ Command is ignored.
|
||||
------------------------------------------------------------
|
||||
material Edep RMS sqrt(E0(GeV))*rmsE/Emean total tracklen
|
||||
|
||||
G4_Pb: 774.24 MeV : 18.18 MeV 2.348 +- 0.07425 % 54.7 cm +- 1.4 cm
|
||||
G4_lAr: 214.49 MeV : 15.96 MeV 7.441 +- 0.2353 % 1.06 m +- 8.16 cm
|
||||
G4_Pb: 774.7 MeV : 20.7 MeV 2.672 +- 0.08451 % 54.7 cm +- 1.58 cm
|
||||
G4_lAr: 213.2 MeV : 15.58 MeV 7.309 +- 0.2311 % 1.05 m +- 7.92 cm
|
||||
|
||||
------------------------------------------------------------
|
||||
Beam particle e- E = 1 GeV
|
||||
Mean number of gamma 509
|
||||
Mean number of e- 868
|
||||
Mean number of e+ 53.7
|
||||
Mean number of charged steps 3665.78
|
||||
Mean number of neutral steps 3688.02
|
||||
Mean number of e- 871
|
||||
Mean number of e+ 53.6
|
||||
Mean number of charged steps 3655.39
|
||||
Mean number of neutral steps 3689.52
|
||||
------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ Environment variable "G4FORCE_RUN_MANAGER_TYPE" enabled with value == Serial. Fo
|
||||
|
||||
|
||||
**************************************************************
|
||||
Geant4 version Name: geant4-11-01-beta-01 (30-June-2022)
|
||||
Geant4 version Name: geant4-11-01-ref-00 (9-December-2022)
|
||||
Copyright : Geant4 Collaboration
|
||||
References : NIM A 506 (2003), 250-303
|
||||
: IEEE-TNS 53 (2006), 270-278
|
||||
@@ -64,15 +64,15 @@ Command is ignored.
|
||||
------------------------------------------------------------
|
||||
material Edep RMS sqrt(E0(GeV))*rmsE/Emean total tracklen
|
||||
|
||||
G4_Pb: 775.99 MeV : 16.74 MeV 2.158 +- 0.06824 % 54.8 cm +- 1.3 cm
|
||||
G4_lAr: 213.94 MeV : 15.58 MeV 7.284 +- 0.2304 % 1.05 m +- 7.93 cm
|
||||
G4_Pb: 775.71 MeV : 16.23 MeV 2.092 +- 0.06615 % 54.8 cm +- 1.28 cm
|
||||
G4_lAr: 214.08 MeV : 15.48 MeV 7.229 +- 0.2286 % 1.05 m +- 7.91 cm
|
||||
|
||||
------------------------------------------------------------
|
||||
Beam particle e- E = 1 GeV
|
||||
Mean number of gamma 510
|
||||
Mean number of e- 874
|
||||
Mean number of gamma 509
|
||||
Mean number of e- 871
|
||||
Mean number of e+ 53.7
|
||||
Mean number of charged steps 3671.37
|
||||
Mean number of neutral steps 3699.68
|
||||
Mean number of charged steps 3677.35
|
||||
Mean number of neutral steps 3694.33
|
||||
------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user