source: trunk/source/tracking/src/G4SmoothTrajectory.cc@ 1271

Last change on this file since 1271 was 1228, checked in by garnier, 16 years ago

update geant4.9.3 tag

File size: 7.9 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id: G4SmoothTrajectory.cc,v 1.19 2009/11/12 09:09:56 allison Exp $
28// GEANT4 tag $Name: geant4-09-03 $
29//
30//
31// ---------------------------------------------------------------
32//
33// G4SmoothTrajectory.cc
34//
35// Contact:
36// Questions and comments to this code should be sent to
37// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
38// Makoto Asai (e-mail: asai@kekvax.kek.jp)
39// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
40//
41// ---------------------------------------------------------------
42
43#include "G4SmoothTrajectory.hh"
44#include "G4SmoothTrajectoryPoint.hh"
45#include "G4ParticleTable.hh"
46#include "G4AttDefStore.hh"
47#include "G4AttDef.hh"
48#include "G4AttValue.hh"
49#include "G4UIcommand.hh"
50#include "G4UnitsTable.hh"
51
52//#define G4ATTDEBUG
53#ifdef G4ATTDEBUG
54#include "G4AttCheck.hh"
55#endif
56
57G4Allocator<G4SmoothTrajectory> aSmoothTrajectoryAllocator;
58
59G4SmoothTrajectory::G4SmoothTrajectory()
60: positionRecord(0), fTrackID(0), fParentID(0),
61 PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
62 initialKineticEnergy( 0. ), initialMomentum( G4ThreeVector() )
63{;}
64
65G4SmoothTrajectory::G4SmoothTrajectory(const G4Track* aTrack)
66{
67 G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
68 ParticleName = fpParticleDefinition->GetParticleName();
69 PDGCharge = fpParticleDefinition->GetPDGCharge();
70 PDGEncoding = fpParticleDefinition->GetPDGEncoding();
71 fTrackID = aTrack->GetTrackID();
72 fParentID = aTrack->GetParentID();
73 initialKineticEnergy = aTrack->GetKineticEnergy();
74 initialMomentum = aTrack->GetMomentum();
75 positionRecord = new TrajectoryPointContainer();
76 // Following is for the first trajectory point
77 positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition()));
78
79 // The first point has no auxiliary points, so set the auxiliary
80 // points vector to NULL (jacek 31/10/2002)
81 positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), NULL));
82}
83
84G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory & right):G4VTrajectory()
85{
86 ParticleName = right.ParticleName;
87 PDGCharge = right.PDGCharge;
88 PDGEncoding = right.PDGEncoding;
89 fTrackID = right.fTrackID;
90 fParentID = right.fParentID;
91 initialKineticEnergy = right.initialKineticEnergy;
92 initialMomentum = right.initialMomentum;
93 positionRecord = new TrajectoryPointContainer();
94
95 for(size_t i=0;i<right.positionRecord->size();i++)
96 {
97 G4SmoothTrajectoryPoint* rightPoint = (G4SmoothTrajectoryPoint*)((*(right.positionRecord))[i]);
98 positionRecord->push_back(new G4SmoothTrajectoryPoint(*rightPoint));
99 }
100}
101
102G4SmoothTrajectory::~G4SmoothTrajectory()
103{
104 if (positionRecord) {
105 // positionRecord->clearAndDestroy();
106 size_t i;
107 for(i=0;i<positionRecord->size();i++){
108 delete (*positionRecord)[i];
109 }
110 positionRecord->clear();
111 delete positionRecord;
112 }
113}
114
115void G4SmoothTrajectory::ShowTrajectory(std::ostream& os) const
116{
117 // Invoke the default implementation in G4VTrajectory...
118 G4VTrajectory::ShowTrajectory(os);
119 // ... or override with your own code here.
120}
121
122void G4SmoothTrajectory::DrawTrajectory(G4int i_mode) const
123{
124 // Invoke the default implementation in G4VTrajectory...
125 G4VTrajectory::DrawTrajectory(i_mode);
126 // ... or override with your own code here.
127}
128
129const std::map<G4String,G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
130{
131 G4bool isNew;
132 std::map<G4String,G4AttDef>* store
133 = G4AttDefStore::GetInstance("G4SmoothTrajectory",isNew);
134 if (isNew) {
135
136 G4String ID("ID");
137 (*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int");
138
139 G4String PID("PID");
140 (*store)[PID] = G4AttDef(PID,"Parent ID","Physics","","G4int");
141
142 G4String PN("PN");
143 (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
144
145 G4String Ch("Ch");
146 (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
147
148 G4String PDG("PDG");
149 (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
150
151 G4String IKE("IKE");
152 (*store)[IKE] =
153 G4AttDef(IKE, "Initial kinetic energy",
154 "Physics","G4BestUnit","G4double");
155
156 G4String IMom("IMom");
157 (*store)[IMom] = G4AttDef(IMom, "Initial momentum",
158 "Physics","G4BestUnit","G4ThreeVector");
159
160 G4String IMag("IMag");
161 (*store)[IMag] = G4AttDef
162 (IMag, "Initial momentum magnitude",
163 "Physics","G4BestUnit","G4double");
164
165 G4String NTP("NTP");
166 (*store)[NTP] = G4AttDef(NTP,"No. of points","Physics","","G4int");
167
168 }
169 return store;
170}
171
172
173std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
174{
175 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
176
177 values->push_back
178 (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
179
180 values->push_back
181 (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
182
183 values->push_back(G4AttValue("PN",ParticleName,""));
184
185 values->push_back
186 (G4AttValue("Ch",G4UIcommand::ConvertToString(PDGCharge),""));
187
188 values->push_back
189 (G4AttValue("PDG",G4UIcommand::ConvertToString(PDGEncoding),""));
190
191 values->push_back
192 (G4AttValue("IKE",G4BestUnit(initialKineticEnergy,"Energy"),""));
193
194 values->push_back
195 (G4AttValue("IMom",G4BestUnit(initialMomentum,"Energy"),""));
196
197 values->push_back
198 (G4AttValue("IMag",G4BestUnit(initialMomentum.mag(),"Energy"),""));
199
200 values->push_back
201 (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),""));
202
203#ifdef G4ATTDEBUG
204 G4cout << G4AttCheck(values,GetAttDefs());
205#endif
206
207 return values;
208}
209
210void G4SmoothTrajectory::AppendStep(const G4Step* aStep)
211{
212 // (jacek 30/10/2002)
213 positionRecord->push_back(
214 new G4SmoothTrajectoryPoint(aStep->GetPostStepPoint()->GetPosition(),
215 aStep->GetPointerToVectorOfAuxiliaryPoints()));
216}
217
218G4ParticleDefinition* G4SmoothTrajectory::GetParticleDefinition()
219{
220 return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
221}
222
223void G4SmoothTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
224{
225 if(!secondTrajectory) return;
226
227 G4SmoothTrajectory* seco = (G4SmoothTrajectory*)secondTrajectory;
228 G4int ent = seco->GetPointEntries();
229 for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
230 {
231 positionRecord->push_back((*(seco->positionRecord))[i]);
232 // positionRecord->push_back(seco->positionRecord->removeAt(1));
233 }
234 delete (*seco->positionRecord)[0];
235 seco->positionRecord->clear();
236}
237
238
Note: See TracBrowser for help on using the repository browser.