File indexing completed on 2025-02-23 09:21: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
0030
0031 #include "F04Trajectory.hh"
0032
0033 #include "F04TrajectoryPoint.hh"
0034
0035 #include "G4AttDef.hh"
0036 #include "G4AttDefStore.hh"
0037 #include "G4AttValue.hh"
0038 #include "G4ParticleTable.hh"
0039 #include "G4UIcommand.hh"
0040 #include "G4UnitsTable.hh"
0041
0042
0043 #ifdef G4ATTDEBUG
0044 # include "G4AttCheck.hh"
0045 #endif
0046
0047 G4ThreadLocal G4Allocator<F04Trajectory>* F04TrajectoryAllocator = nullptr;
0048
0049
0050
0051 F04Trajectory::F04Trajectory() {}
0052
0053
0054
0055 F04Trajectory::F04Trajectory(const G4Track* aTrack)
0056 {
0057 G4ParticleDefinition* particleDefinition = aTrack->GetDefinition();
0058 fParticleName = particleDefinition->GetParticleName();
0059 fPDGCharge = particleDefinition->GetPDGCharge();
0060 fPDGEncoding = particleDefinition->GetPDGEncoding();
0061 fTrackID = aTrack->GetTrackID();
0062 fParentID = aTrack->GetParentID();
0063 fInitialMomentum = aTrack->GetMomentum();
0064 fpPointsContainer = new TrajectoryPointContainer();
0065
0066 fpPointsContainer->push_back(new F04TrajectoryPoint(aTrack));
0067 }
0068
0069
0070
0071 F04Trajectory::F04Trajectory(F04Trajectory& right) : G4VTrajectory()
0072 {
0073 fParticleName = right.fParticleName;
0074 fPDGCharge = right.fPDGCharge;
0075 fPDGEncoding = right.fPDGEncoding;
0076 fTrackID = right.fTrackID;
0077 fParentID = right.fParentID;
0078 fInitialMomentum = right.fInitialMomentum;
0079 fpPointsContainer = new TrajectoryPointContainer();
0080
0081 for (size_t i = 0; i < right.fpPointsContainer->size(); ++i) {
0082 auto rightPoint = (F04TrajectoryPoint*)((*(right.fpPointsContainer))[i]);
0083 fpPointsContainer->push_back(new F04TrajectoryPoint(*rightPoint));
0084 }
0085 }
0086
0087
0088
0089 F04Trajectory::~F04Trajectory()
0090 {
0091 for (size_t i = 0; i < fpPointsContainer->size(); ++i) {
0092 delete (*fpPointsContainer)[i];
0093 }
0094 fpPointsContainer->clear();
0095
0096 delete fpPointsContainer;
0097 }
0098
0099
0100
0101 void F04Trajectory::ShowTrajectory(std::ostream& os) const
0102 {
0103
0104 G4VTrajectory::ShowTrajectory(os);
0105
0106 }
0107
0108
0109
0110 void F04Trajectory::AppendStep(const G4Step* aStep)
0111 {
0112 fpPointsContainer->push_back(new F04TrajectoryPoint(aStep));
0113 }
0114
0115
0116
0117 G4ParticleDefinition* F04Trajectory::GetParticleDefinition()
0118 {
0119 return (G4ParticleTable::GetParticleTable()->FindParticle(fParticleName));
0120 }
0121
0122
0123
0124 void F04Trajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
0125 {
0126 if (!secondTrajectory) return;
0127
0128 auto second = (F04Trajectory*)secondTrajectory;
0129 G4int ent = second->GetPointEntries();
0130
0131 for (G4int i = 1; i < ent; ++i) {
0132 fpPointsContainer->push_back((*(second->fpPointsContainer))[i]);
0133 }
0134 delete (*second->fpPointsContainer)[0];
0135 second->fpPointsContainer->clear();
0136 }
0137
0138
0139
0140 const std::map<G4String, G4AttDef>* F04Trajectory::GetAttDefs() const
0141 {
0142 G4bool isNew;
0143 std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("Trajectory", isNew);
0144
0145 if (isNew) {
0146 G4String ID("ID");
0147 (*store)[ID] = G4AttDef(ID, "Track ID", "Bookkeeping", "", "G4int");
0148
0149 G4String PID("PID");
0150 (*store)[PID] = G4AttDef(PID, "Parent ID", "Bookkeeping", "", "G4int");
0151
0152 G4String PN("PN");
0153 (*store)[PN] = G4AttDef(PN, "Particle Name", "Physics", "", "G4String");
0154
0155 G4String Ch("Ch");
0156 (*store)[Ch] = G4AttDef(Ch, "Charge", "Physics", "e+", "G4double");
0157
0158 G4String PDG("PDG");
0159 (*store)[PDG] = G4AttDef(PDG, "PDG Encoding", "Physics", "", "G4int");
0160
0161 G4String IMom("IMom");
0162 (*store)[IMom] = G4AttDef(IMom, "Momentum of track at start of trajectory", "Physics",
0163 "G4BestUnit", "G4ThreeVector");
0164
0165 G4String IMag("IMag");
0166 (*store)[IMag] = G4AttDef(IMag, "Magnitude of momentum of track at start of trajectory",
0167 "Physics", "G4BestUnit", "G4double");
0168
0169 G4String NTP("NTP");
0170 (*store)[NTP] = G4AttDef(NTP, "No. of points", "Bookkeeping", "", "G4int");
0171 }
0172 return store;
0173 }
0174
0175
0176
0177 std::vector<G4AttValue>* F04Trajectory::CreateAttValues() const
0178 {
0179 auto values = new std::vector<G4AttValue>;
0180
0181 values->push_back(G4AttValue("ID", G4UIcommand::ConvertToString(fTrackID), ""));
0182
0183 values->push_back(G4AttValue("PID", G4UIcommand::ConvertToString(fParentID), ""));
0184
0185 values->push_back(G4AttValue("PN", fParticleName, ""));
0186
0187 values->push_back(G4AttValue("Ch", G4UIcommand::ConvertToString(fPDGCharge), ""));
0188
0189 values->push_back(G4AttValue("PDG", G4UIcommand::ConvertToString(fPDGEncoding), ""));
0190
0191 values->push_back(G4AttValue("IMom", G4BestUnit(fInitialMomentum, "Energy"), ""));
0192
0193 values->push_back(G4AttValue("IMag", G4BestUnit(fInitialMomentum.mag(), "Energy"), ""));
0194
0195 values->push_back(G4AttValue("NTP", G4UIcommand::ConvertToString(GetPointEntries()), ""));
0196
0197 #ifdef G4ATTDEBUG
0198 G4cout << G4AttCheck(values, GetAttDefs());
0199 #endif
0200 return values;
0201 }