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