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 #include "gerdaio/MaGeTrajectory.hh"
00042 #include "gerdaio/MaGeTrajectoryPoint.hh"
00043
00044 #include "G4ParticleTable.hh"
00045 #include "G4AttDefStore.hh"
00046 #include "G4AttDef.hh"
00047 #include "G4AttValue.hh"
00048 #include "G4UnitsTable.hh"
00049 #include "G4TouchableHistory.hh"
00050 #include "G4ios.hh"
00051 #include <strstream>
00052 #include "G4VProcess.hh"
00053 #include "G4VPhysicalVolume.hh"
00054
00055 G4Allocator<MaGeTrajectory> MaGeTrajectoryAllocator;
00056
00057 MaGeTrajectory::MaGeTrajectory()
00058 : positionRecord(0), fTrackID(0), fParentID(0),
00059 PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
00060 initialMomentum( G4ThreeVector() )
00061 {;}
00062
00063 MaGeTrajectory::MaGeTrajectory(const G4Track* aTrack)
00064 {
00065 G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
00066 ParticleName = fpParticleDefinition->GetParticleName();
00067 PDGCharge = fpParticleDefinition->GetPDGCharge();
00068 PDGEncoding = fpParticleDefinition->GetPDGEncoding();
00069 fTrackID = aTrack->GetTrackID();
00070 fParentID = aTrack->GetParentID();
00071 initialMomentum = aTrack->GetMomentum();
00072 positionRecord = new MaGeTrajectoryPointContainer();
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 positionRecord->push_back(new MaGeTrajectoryPoint(aTrack->GetPosition()));
00088
00089 }
00090
00091 MaGeTrajectory::MaGeTrajectory(MaGeTrajectory & right):G4VTrajectory()
00092 {
00093 ParticleName = right.ParticleName;
00094 PDGCharge = right.PDGCharge;
00095 PDGEncoding = right.PDGEncoding;
00096 fTrackID = right.fTrackID;
00097 fParentID = right.fParentID;
00098 initialMomentum = right.initialMomentum;
00099 positionRecord = new MaGeTrajectoryPointContainer();
00100
00101 for(size_t i=0;i<right.positionRecord->size();i++)
00102 {
00103 MaGeTrajectoryPoint* rightPoint = (MaGeTrajectoryPoint*)((*(right.positionRecord))[i]);
00104 positionRecord->push_back(new MaGeTrajectoryPoint(*rightPoint));
00105 }
00106 }
00107
00108 MaGeTrajectory::~MaGeTrajectory()
00109 {
00110
00111 size_t i;
00112 for(i=0;i<positionRecord->size();i++){
00113 delete (*positionRecord)[i];
00114 }
00115 positionRecord->clear();
00116
00117 delete positionRecord;
00118 }
00119
00120 void MaGeTrajectory::ShowTrajectory(std::ostream& os) const
00121 {
00122
00123 G4VTrajectory::ShowTrajectory(os);
00124
00125 }
00126
00127 void MaGeTrajectory::DrawTrajectory(G4int i_mode) const
00128 {
00129
00130 G4VTrajectory::DrawTrajectory(i_mode);
00131
00132 }
00133
00134 const std::map<G4String,G4AttDef>* MaGeTrajectory::GetAttDefs() const
00135 {
00136 G4bool isNew;
00137 std::map<G4String,G4AttDef>* store
00138 = G4AttDefStore::GetInstance("MaGeTrajectory",isNew);
00139 if (isNew) {
00140
00141 G4String ID("ID");
00142 (*store)[ID] = G4AttDef(ID,"Track ID","Bookkeeping","","G4int");
00143
00144 G4String PID("PID");
00145 (*store)[PID] = G4AttDef(PID,"Parent ID","Bookkeeping","","G4int");
00146
00147 G4String PN("PN");
00148 (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
00149
00150 G4String Ch("Ch");
00151 (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","","G4double");
00152
00153 G4String PDG("PDG");
00154 (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
00155
00156 G4String IMom("IMom");
00157 (*store)[IMom] = G4AttDef(IMom, "Momentum of track at start of trajectory",
00158 "Physics","","G4ThreeVector");
00159
00160 G4String NTP("NTP");
00161 (*store)[NTP] = G4AttDef(NTP,"No. of points","Physics","","G4int");
00162
00163 }
00164 return store;
00165 }
00166
00167 std::vector<G4AttValue>* MaGeTrajectory::CreateAttValues() const
00168 {
00169 char c[100];
00170 std::ostrstream s(c,100);
00171
00172 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
00173
00174 s.seekp(std::ios::beg);
00175 s << fTrackID << std::ends;
00176 values->push_back(G4AttValue("ID",c,""));
00177
00178 s.seekp(std::ios::beg);
00179 s << fParentID << std::ends;
00180 values->push_back(G4AttValue("PID",c,""));
00181
00182 values->push_back(G4AttValue("PN",ParticleName,""));
00183
00184 s.seekp(std::ios::beg);
00185 s << PDGCharge << std::ends;
00186 values->push_back(G4AttValue("Ch",c,""));
00187
00188 s.seekp(std::ios::beg);
00189 s << PDGEncoding << std::ends;
00190 values->push_back(G4AttValue("PDG",c,""));
00191
00192 s.seekp(std::ios::beg);
00193 s << G4BestUnit(initialMomentum,"Energy") << std::ends;
00194 values->push_back(G4AttValue("IMom",c,""));
00195
00196 s.seekp(std::ios::beg);
00197 s << GetPointEntries() << std::ends;
00198 values->push_back(G4AttValue("NTP",c,""));
00199
00200 return values;
00201 }
00202
00203 void MaGeTrajectory::AppendStep(const G4Step* aStep)
00204 {
00205
00206
00207
00208
00209 MaGeTrajectoryPoint* oneTrajectoryPoint = new MaGeTrajectoryPoint();
00210 oneTrajectoryPoint->SetPosition(aStep->GetPostStepPoint()->GetPosition());
00211 oneTrajectoryPoint->SetEnergyLost(aStep->GetTotalEnergyDeposit());
00212 oneTrajectoryPoint->SetStepLength(aStep->GetStepLength());
00213
00214 oneTrajectoryPoint->SetTrackLength(aStep->GetTrack()->GetTrackLength());
00215
00216 G4TouchableHistory* theTouchable
00217 = (G4TouchableHistory*)(aStep->GetPostStepPoint()->GetTouchable());
00218 if (theTouchable->GetVolume()!=0){
00219 oneTrajectoryPoint->SetVolumeName( theTouchable->GetVolume()->GetName() );
00220 }
00221 else {
00222 oneTrajectoryPoint->SetVolumeName("outofworld");
00223 }
00224 oneTrajectoryPoint->SetProcessName( aStep->GetPostStepPoint()
00225 ->GetProcessDefinedStep()->GetProcessName() );
00226
00227 positionRecord->push_back(oneTrajectoryPoint);
00228 }
00229
00230 G4ParticleDefinition* MaGeTrajectory::GetParticleDefinition()
00231 {
00232 return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
00233 }
00234
00235 void MaGeTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
00236 {
00237 if(!secondTrajectory) return;
00238
00239 MaGeTrajectory* seco = (MaGeTrajectory*)secondTrajectory;
00240 G4int ent = seco->GetPointEntries();
00241 for(G4int i=1;i<ent;i++)
00242 {
00243 positionRecord->push_back((*(seco->positionRecord))[i]);
00244
00245 }
00246 delete (*seco->positionRecord)[0];
00247 seco->positionRecord->clear();
00248 }
00249
00250