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