File indexing completed on 2025-02-23 09:22:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include "Par04DefineMeshModel.hh"
0027
0028 #include "Par04EventInformation.hh" // for Par04EventInformation
0029
0030 #include "G4Event.hh" // for G4Event
0031 #include "G4EventManager.hh" // for G4EventManager
0032
0033 #include <G4FastTrack.hh> // for G4FastTrack
0034 #include <G4Track.hh> // for G4Track
0035 #include <G4VFastSimulationModel.hh> // for G4VFastSimulationModel
0036 #include <G4VUserEventInformation.hh> // for G4VUserEventInformation
0037 class G4FastStep;
0038 class G4ParticleDefinition;
0039 class G4Region;
0040
0041
0042
0043 Par04DefineMeshModel::Par04DefineMeshModel(G4String aModelName, G4Region* aEnvelope)
0044 : G4VFastSimulationModel(aModelName, aEnvelope)
0045 {}
0046
0047
0048
0049 Par04DefineMeshModel::Par04DefineMeshModel(G4String aModelName) : G4VFastSimulationModel(aModelName)
0050 {}
0051
0052
0053
0054 Par04DefineMeshModel::~Par04DefineMeshModel() = default;
0055
0056
0057
0058 G4bool Par04DefineMeshModel::IsApplicable(const G4ParticleDefinition&)
0059 {
0060 return true;
0061 }
0062
0063
0064
0065 G4bool Par04DefineMeshModel::ModelTrigger(const G4FastTrack&)
0066 {
0067 auto info = dynamic_cast<Par04EventInformation*>(
0068 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
0069
0070 if (info != nullptr)
0071 return !info->GetFlag();
0072 else
0073 return true;
0074 }
0075
0076
0077
0078 void Par04DefineMeshModel::DoIt(const G4FastTrack& aFastTrack, G4FastStep&)
0079 {
0080 auto info = dynamic_cast<Par04EventInformation*>(
0081 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
0082 if (info == nullptr) {
0083 info = new Par04EventInformation();
0084 G4EventManager::GetEventManager()->GetNonconstCurrentEvent()->SetUserInformation(info);
0085 }
0086 info->SetPosition(aFastTrack.GetPrimaryTrack()->GetPosition());
0087 info->SetDirection(aFastTrack.GetPrimaryTrack()->GetMomentumDirection());
0088 info->SetFlag(true);
0089 }