File indexing completed on 2026-03-29 07:51:19
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 "F04TrajectoryPoint.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
0042 #ifdef G4ATTDEBUG
0043 # include "G4AttCheck.hh"
0044 #endif
0045
0046 G4ThreadLocal G4Allocator<F04TrajectoryPoint>* F04TrajPointAllocator = nullptr;
0047
0048
0049
0050 F04TrajectoryPoint::F04TrajectoryPoint() {}
0051
0052
0053
0054 F04TrajectoryPoint::F04TrajectoryPoint(const G4Step* aStep)
0055 : G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition())
0056 {
0057 fTime = aStep->GetPostStepPoint()->GetGlobalTime();
0058 fMomentum = aStep->GetPostStepPoint()->GetMomentum();
0059 fStepStatus = aStep->GetPostStepPoint()->GetStepStatus();
0060 if (aStep->GetPostStepPoint()->GetPhysicalVolume()) {
0061 fVolumeName = aStep->GetPostStepPoint()->GetPhysicalVolume()->GetName();
0062 }
0063 else {
0064 fVolumeName = G4String(" ");
0065 }
0066 }
0067
0068
0069
0070 F04TrajectoryPoint::F04TrajectoryPoint(const G4Track* aTrack)
0071 : G4TrajectoryPoint(aTrack->GetPosition())
0072 {
0073 fTime = aTrack->GetGlobalTime();
0074 fMomentum = aTrack->GetMomentum();
0075 fStepStatus = fUndefined;
0076 fVolumeName = aTrack->GetVolume()->GetName();
0077 }
0078
0079
0080
0081 F04TrajectoryPoint::F04TrajectoryPoint(const F04TrajectoryPoint& right) : G4TrajectoryPoint(right)
0082 {
0083 fTime = right.fTime;
0084 fMomentum = right.fMomentum;
0085 fStepStatus = right.fStepStatus;
0086 fVolumeName = right.fVolumeName;
0087 }
0088
0089
0090
0091 const std::map<G4String, G4AttDef>* F04TrajectoryPoint::GetAttDefs() const
0092 {
0093 G4bool isNew;
0094 std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("TrajectoryPoint", isNew);
0095 if (isNew) {
0096 G4String Pos("Pos");
0097 (*store)[Pos] = G4AttDef(Pos, "Position", "Physics", "G4BestUnit", "G4ThreeVector");
0098
0099 G4String Time("Time");
0100 (*store)[Time] = G4AttDef(Time, "Time", "Physics", "G4BestUnit", "G4double");
0101
0102 G4String Momentum("Momentum");
0103 (*store)[Momentum] = G4AttDef(Momentum, "Momentum", "Physics", "G4BestUnit", "G4ThreeVector");
0104
0105 G4String StepStatus("StepStatus");
0106 (*store)[StepStatus] = G4AttDef(StepStatus, "StepStatus", "Physics", "", "G4StepStatus");
0107
0108 G4String VolumeName("VolumeName");
0109 (*store)[VolumeName] = G4AttDef(VolumeName, "VolumeName", "Physics", "", "G4String");
0110 }
0111 return store;
0112 }
0113
0114
0115
0116 std::vector<G4AttValue>* F04TrajectoryPoint::CreateAttValues() const
0117 {
0118 auto values = new std::vector<G4AttValue>;
0119
0120 values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), ""));
0121
0122 values->push_back(G4AttValue("Momentum", G4BestUnit(fMomentum, "Momentum"), ""));
0123
0124 values->push_back(G4AttValue("StepStatus", G4UIcommand::ConvertToString(fStepStatus), ""));
0125
0126 values->push_back(G4AttValue("VolumeName", fVolumeName, ""));
0127
0128 #ifdef G4ATTDEBUG
0129 G4cout << G4AttCheck(values, GetAttDefs());
0130 #endif
0131
0132 return values;
0133 }