00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "G4SmoothTrajectory.hh"
00043 #include "G4SmoothTrajectoryPoint.hh"
00044 #include "G4ParticleTable.hh"
00045 #include "G4AttDefStore.hh"
00046 #include "G4AttDef.hh"
00047 #include "G4AttValue.hh"
00048 #include "G4UIcommand.hh"
00049 #include "G4UnitsTable.hh"
00050
00051
00052 #ifdef G4ATTDEBUG
00053 #include "G4AttCheck.hh"
00054 #endif
00055
00056 G4Allocator<G4SmoothTrajectory> aSmoothTrajectoryAllocator;
00057
00058 G4SmoothTrajectory::G4SmoothTrajectory()
00059 : positionRecord(0), fTrackID(0), fParentID(0),
00060 PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
00061 initialKineticEnergy( 0. ), initialMomentum( G4ThreeVector() )
00062 {;}
00063
00064 G4SmoothTrajectory::G4SmoothTrajectory(const G4Track* aTrack)
00065 {
00066 G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
00067 ParticleName = fpParticleDefinition->GetParticleName();
00068 PDGCharge = fpParticleDefinition->GetPDGCharge();
00069 PDGEncoding = fpParticleDefinition->GetPDGEncoding();
00070 fTrackID = aTrack->GetTrackID();
00071 fParentID = aTrack->GetParentID();
00072 initialKineticEnergy = aTrack->GetKineticEnergy();
00073 initialMomentum = aTrack->GetMomentum();
00074 positionRecord = new TrajectoryPointContainer();
00075
00076 positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition()));
00077
00078
00079
00080 positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), 0));
00081 }
00082
00083 G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory & right):G4VTrajectory()
00084 {
00085 ParticleName = right.ParticleName;
00086 PDGCharge = right.PDGCharge;
00087 PDGEncoding = right.PDGEncoding;
00088 fTrackID = right.fTrackID;
00089 fParentID = right.fParentID;
00090 initialKineticEnergy = right.initialKineticEnergy;
00091 initialMomentum = right.initialMomentum;
00092 positionRecord = new TrajectoryPointContainer();
00093
00094 for(size_t i=0;i<right.positionRecord->size();i++)
00095 {
00096 G4SmoothTrajectoryPoint* rightPoint = (G4SmoothTrajectoryPoint*)((*(right.positionRecord))[i]);
00097 positionRecord->push_back(new G4SmoothTrajectoryPoint(*rightPoint));
00098 }
00099 }
00100
00101 G4SmoothTrajectory::~G4SmoothTrajectory()
00102 {
00103 if (positionRecord) {
00104
00105 size_t i;
00106 for(i=0;i<positionRecord->size();i++){
00107 delete (*positionRecord)[i];
00108 }
00109 positionRecord->clear();
00110 delete positionRecord;
00111 }
00112 }
00113
00114 void G4SmoothTrajectory::ShowTrajectory(std::ostream& os) const
00115 {
00116
00117 G4VTrajectory::ShowTrajectory(os);
00118
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 void G4SmoothTrajectory::DrawTrajectory(G4int i_mode) const
00131 {
00132
00133 G4VTrajectory::DrawTrajectory(i_mode);
00134
00135 }
00136
00137 const std::map<G4String,G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
00138 {
00139 G4bool isNew;
00140 std::map<G4String,G4AttDef>* store
00141 = G4AttDefStore::GetInstance("G4SmoothTrajectory",isNew);
00142 if (isNew) {
00143
00144 G4String ID("ID");
00145 (*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int");
00146
00147 G4String PID("PID");
00148 (*store)[PID] = G4AttDef(PID,"Parent ID","Physics","","G4int");
00149
00150 G4String PN("PN");
00151 (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
00152
00153 G4String Ch("Ch");
00154 (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
00155
00156 G4String PDG("PDG");
00157 (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
00158
00159 G4String IKE("IKE");
00160 (*store)[IKE] =
00161 G4AttDef(IKE, "Initial kinetic energy",
00162 "Physics","G4BestUnit","G4double");
00163
00164 G4String IMom("IMom");
00165 (*store)[IMom] = G4AttDef(IMom, "Initial momentum",
00166 "Physics","G4BestUnit","G4ThreeVector");
00167
00168 G4String IMag("IMag");
00169 (*store)[IMag] = G4AttDef
00170 (IMag, "Initial momentum magnitude",
00171 "Physics","G4BestUnit","G4double");
00172
00173 G4String NTP("NTP");
00174 (*store)[NTP] = G4AttDef(NTP,"No. of points","Physics","","G4int");
00175
00176 }
00177 return store;
00178 }
00179
00180
00181 std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
00182 {
00183 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
00184
00185 values->push_back
00186 (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
00187
00188 values->push_back
00189 (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
00190
00191 values->push_back(G4AttValue("PN",ParticleName,""));
00192
00193 values->push_back
00194 (G4AttValue("Ch",G4UIcommand::ConvertToString(PDGCharge),""));
00195
00196 values->push_back
00197 (G4AttValue("PDG",G4UIcommand::ConvertToString(PDGEncoding),""));
00198
00199 values->push_back
00200 (G4AttValue("IKE",G4BestUnit(initialKineticEnergy,"Energy"),""));
00201
00202 values->push_back
00203 (G4AttValue("IMom",G4BestUnit(initialMomentum,"Energy"),""));
00204
00205 values->push_back
00206 (G4AttValue("IMag",G4BestUnit(initialMomentum.mag(),"Energy"),""));
00207
00208 values->push_back
00209 (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),""));
00210
00211 #ifdef G4ATTDEBUG
00212 G4cout << G4AttCheck(values,GetAttDefs());
00213 #endif
00214
00215 return values;
00216 }
00217
00218 void G4SmoothTrajectory::AppendStep(const G4Step* aStep)
00219 {
00220
00221 positionRecord->push_back(
00222 new G4SmoothTrajectoryPoint(aStep->GetPostStepPoint()->GetPosition(),
00223 aStep->GetPointerToVectorOfAuxiliaryPoints()));
00224 }
00225
00226 G4ParticleDefinition* G4SmoothTrajectory::GetParticleDefinition()
00227 {
00228 return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
00229 }
00230
00231 void G4SmoothTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
00232 {
00233 if(!secondTrajectory) return;
00234
00235 G4SmoothTrajectory* seco = (G4SmoothTrajectory*)secondTrajectory;
00236 G4int ent = seco->GetPointEntries();
00237 for(G4int i=1;i<ent;i++)
00238 {
00239 positionRecord->push_back((*(seco->positionRecord))[i]);
00240
00241 }
00242 delete (*seco->positionRecord)[0];
00243 seco->positionRecord->clear();
00244 }
00245
00246