File indexing completed on 2025-02-23 09:22:25
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
0027
0028
0029
0030
0031 #include "WLSTrajectoryPoint.hh"
0032
0033 #include "G4AttDef.hh"
0034 #include "G4AttDefStore.hh"
0035 #include "G4AttValue.hh"
0036 #include "G4Step.hh"
0037 #include "G4StepStatus.hh"
0038 #include "G4Track.hh"
0039 #include "G4UIcommand.hh"
0040 #include "G4UnitsTable.hh"
0041 #include "G4VProcess.hh"
0042
0043 G4ThreadLocal G4Allocator<WLSTrajectoryPoint>* WLSTrajPointAllocator = nullptr;
0044
0045
0046
0047 WLSTrajectoryPoint::WLSTrajectoryPoint(const G4Step* aStep)
0048 : G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition())
0049 {
0050 auto postStepPoint = aStep->GetPostStepPoint();
0051 fTime = postStepPoint->GetGlobalTime();
0052 fMomentum = postStepPoint->GetMomentum();
0053 fStepStatus = postStepPoint->GetStepStatus();
0054 if (postStepPoint->GetPhysicalVolume()) {
0055 fVolumeName = postStepPoint->GetPhysicalVolume()->GetName();
0056 }
0057 else {
0058 fVolumeName = G4String(" ");
0059 }
0060 }
0061
0062
0063
0064 WLSTrajectoryPoint::WLSTrajectoryPoint(const G4Track* aTrack)
0065 : G4TrajectoryPoint(aTrack->GetPosition())
0066 {
0067 fTime = aTrack->GetGlobalTime();
0068 fMomentum = aTrack->GetMomentum();
0069 fStepStatus = fUndefined;
0070 fVolumeName = aTrack->GetVolume()->GetName();
0071 }
0072
0073
0074
0075 WLSTrajectoryPoint::WLSTrajectoryPoint(const WLSTrajectoryPoint& right) : G4TrajectoryPoint(right)
0076 {
0077 fTime = right.fTime;
0078 fMomentum = right.fMomentum;
0079 fStepStatus = right.fStepStatus;
0080 fVolumeName = right.fVolumeName;
0081 }
0082
0083
0084
0085 const std::map<G4String, G4AttDef>* WLSTrajectoryPoint::GetAttDefs() const
0086 {
0087 G4bool isNew;
0088 std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("TrajectoryPoint", isNew);
0089 if (isNew) {
0090 G4String Pos("Pos");
0091 (*store)[Pos] = G4AttDef(Pos, "Position", "Physics", "G4BestUnit", "G4ThreeVector");
0092
0093 G4String Time("Time");
0094 (*store)[Time] = G4AttDef(Time, "Time", "Physics", "G4BestUnit", "G4double");
0095
0096 G4String Momentum("Momentum");
0097 (*store)[Momentum] = G4AttDef(Momentum, "Momentum", "Physics", "G4BestUnit", "G4ThreeVector");
0098
0099 G4String StepStatus("StepStatus");
0100 (*store)[StepStatus] = G4AttDef(StepStatus, "StepStatus", "Physics", "", "G4StepStatus");
0101
0102 G4String VolumeName("VolumeName");
0103 (*store)[VolumeName] = G4AttDef(VolumeName, "VolumeName", "Physics", "", "G4String");
0104 }
0105 return store;
0106 }
0107
0108
0109
0110 std::vector<G4AttValue>* WLSTrajectoryPoint::CreateAttValues() const
0111 {
0112 auto values = new std::vector<G4AttValue>;
0113
0114 values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), ""));
0115 values->push_back(G4AttValue("Momentum", G4BestUnit(fMomentum, "Momentum"), ""));
0116 values->push_back(G4AttValue("StepStatus", G4UIcommand::ConvertToString(fStepStatus), ""));
0117 values->push_back(G4AttValue("VolumeName", fVolumeName, ""));
0118
0119 return values;
0120 }