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