Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4SmoothTrajectory.cc
Go to the documentation of this file.
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 67009 2013-01-29 16:00:21Z gcosmo $
28 //
29 //
30 // ---------------------------------------------------------------
31 //
32 // G4SmoothTrajectory.cc
33 //
34 // Contact:
35 // Questions and comments to this code should be sent to
36 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
37 // Makoto Asai (e-mail: asai@kekvax.kek.jp)
38 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
39 //
40 // ---------------------------------------------------------------
41 
42 #include "G4SmoothTrajectory.hh"
44 #include "G4ParticleTable.hh"
45 #include "G4AttDefStore.hh"
46 #include "G4AttDef.hh"
47 #include "G4AttValue.hh"
48 #include "G4UIcommand.hh"
49 #include "G4UnitsTable.hh"
50 
51 //#define G4ATTDEBUG
52 #ifdef G4ATTDEBUG
53 #include "G4AttCheck.hh"
54 #endif
55 
57 
59 : positionRecord(0), fTrackID(0), fParentID(0),
60  PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
61  initialKineticEnergy( 0. ), initialMomentum( G4ThreeVector() )
62 {;}
63 
65 {
66  G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
67  ParticleName = fpParticleDefinition->GetParticleName();
68  PDGCharge = fpParticleDefinition->GetPDGCharge();
69  PDGEncoding = fpParticleDefinition->GetPDGEncoding();
70  fTrackID = aTrack->GetTrackID();
71  fParentID = aTrack->GetParentID();
72  initialKineticEnergy = aTrack->GetKineticEnergy();
73  initialMomentum = aTrack->GetMomentum();
74  positionRecord = new TrajectoryPointContainer();
75  // Following is for the first trajectory point
76  positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition()));
77 
78  // The first point has no auxiliary points, so set the auxiliary
79  // points vector to NULL (jacek 31/10/2002)
80  positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), 0));
81 }
82 
84 {
85  ParticleName = right.ParticleName;
86  PDGCharge = right.PDGCharge;
87  PDGEncoding = right.PDGEncoding;
88  fTrackID = right.fTrackID;
89  fParentID = right.fParentID;
90  initialKineticEnergy = right.initialKineticEnergy;
91  initialMomentum = right.initialMomentum;
92  positionRecord = new TrajectoryPointContainer();
93 
94  for(size_t i=0;i<right.positionRecord->size();i++)
95  {
96  G4SmoothTrajectoryPoint* rightPoint = (G4SmoothTrajectoryPoint*)((*(right.positionRecord))[i]);
97  positionRecord->push_back(new G4SmoothTrajectoryPoint(*rightPoint));
98  }
99 }
100 
102 {
103  if (positionRecord) {
104  // positionRecord->clearAndDestroy();
105  size_t i;
106  for(i=0;i<positionRecord->size();i++){
107  delete (*positionRecord)[i];
108  }
109  positionRecord->clear();
110  delete positionRecord;
111  }
112 }
113 
114 void G4SmoothTrajectory::ShowTrajectory(std::ostream& os) const
115 {
116  // Invoke the default implementation in G4VTrajectory...
118  // ... or override with your own code here.
119 }
120 
121 /***
122 void G4SmoothTrajectory::DrawTrajectory() const
123 {
124  // Invoke the default implementation in G4VTrajectory...
125  G4VTrajectory::DrawTrajectory();
126  // ... or override with your own code here.
127 }
128 ***/
129 
131 {
132  // Invoke the default implementation in G4VTrajectory...
134  // ... or override with your own code here.
135 }
136 
137 const std::map<G4String,G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
138 {
139  G4bool isNew;
140  std::map<G4String,G4AttDef>* store
141  = G4AttDefStore::GetInstance("G4SmoothTrajectory",isNew);
142  if (isNew) {
143 
144  G4String ID("ID");
145  (*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int");
146 
147  G4String PID("PID");
148  (*store)[PID] = G4AttDef(PID,"Parent ID","Physics","","G4int");
149 
150  G4String PN("PN");
151  (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
152 
153  G4String Ch("Ch");
154  (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
155 
156  G4String PDG("PDG");
157  (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
158 
159  G4String IKE("IKE");
160  (*store)[IKE] =
161  G4AttDef(IKE, "Initial kinetic energy",
162  "Physics","G4BestUnit","G4double");
163 
164  G4String IMom("IMom");
165  (*store)[IMom] = G4AttDef(IMom, "Initial momentum",
166  "Physics","G4BestUnit","G4ThreeVector");
167 
168  G4String IMag("IMag");
169  (*store)[IMag] = G4AttDef
170  (IMag, "Initial momentum magnitude",
171  "Physics","G4BestUnit","G4double");
172 
173  G4String NTP("NTP");
174  (*store)[NTP] = G4AttDef(NTP,"No. of points","Physics","","G4int");
175 
176  }
177  return store;
178 }
179 
180 
181 std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
182 {
183  std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
184 
185  values->push_back
186  (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
187 
188  values->push_back
189  (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
190 
191  values->push_back(G4AttValue("PN",ParticleName,""));
192 
193  values->push_back
194  (G4AttValue("Ch",G4UIcommand::ConvertToString(PDGCharge),""));
195 
196  values->push_back
197  (G4AttValue("PDG",G4UIcommand::ConvertToString(PDGEncoding),""));
198 
199  values->push_back
200  (G4AttValue("IKE",G4BestUnit(initialKineticEnergy,"Energy"),""));
201 
202  values->push_back
203  (G4AttValue("IMom",G4BestUnit(initialMomentum,"Energy"),""));
204 
205  values->push_back
206  (G4AttValue("IMag",G4BestUnit(initialMomentum.mag(),"Energy"),""));
207 
208  values->push_back
210 
211 #ifdef G4ATTDEBUG
212  G4cout << G4AttCheck(values,GetAttDefs());
213 #endif
214 
215  return values;
216 }
217 
219 {
220  // (jacek 30/10/2002)
221  positionRecord->push_back(
224 }
225 
227 {
228  return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
229 }
230 
232 {
233  if(!secondTrajectory) return;
234 
235  G4SmoothTrajectory* seco = (G4SmoothTrajectory*)secondTrajectory;
236  G4int ent = seco->GetPointEntries();
237  for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
238  {
239  positionRecord->push_back((*(seco->positionRecord))[i]);
240  // positionRecord->push_back(seco->positionRecord->removeAt(1));
241  }
242  delete (*seco->positionRecord)[0];
243  seco->positionRecord->clear();
244 }
245 
246