Geant4  10.01.p01
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 69003 2013-04-15 09:25:23Z 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();
73  initialMomentum = aTrack->GetMomentum();
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
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;
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  {
105  size_t i;
106  for(i=0;i<positionRecord->size();i++)
107  {
108  delete (*positionRecord)[i];
109  }
110  positionRecord->clear();
111  delete positionRecord;
112  }
113 }
114 
115 void G4SmoothTrajectory::ShowTrajectory(std::ostream& os) const
116 {
117  // Invoke the default implementation in G4VTrajectory...
119  // ... or override with your own code here.
120 }
121 
123 {
124  // Invoke the default implementation in G4VTrajectory...
126  // ... or override with your own code here.
127 }
128 
129 const 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 
173 std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
174 {
175  std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
176 
177  values->push_back
179 
180  values->push_back
182 
183  values->push_back(G4AttValue("PN",ParticleName,""));
184 
185  values->push_back
187 
188  values->push_back
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
202 
203 #ifdef G4ATTDEBUG
204  G4cout << G4AttCheck(values,GetAttDefs());
205 #endif
206 
207  return values;
208 }
209 
211 {
212  positionRecord->push_back(
215 }
216 
218 {
219  return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
220 }
221 
223 {
224  if(!secondTrajectory) return;
225 
226  G4SmoothTrajectory* seco = (G4SmoothTrajectory*)secondTrajectory;
227  G4int ent = seco->GetPointEntries();
228  for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
229  {
230  positionRecord->push_back((*(seco->positionRecord))[i]);
231  }
232  delete (*seco->positionRecord)[0];
233  seco->positionRecord->clear();
234 }
G4ParticleDefinition * GetDefinition() const
G4int GetParentID() const
TrajectoryPointContainer * positionRecord
CLHEP::Hep3Vector G4ThreeVector
std::vector< G4VTrajectoryPoint * > TrajectoryPointContainer
virtual void MergeTrajectory(G4VTrajectory *secondTrajectory)
const G4ThreeVector & GetPosition() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:371
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
#define G4ThreadLocal
Definition: tls.hh:89
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
virtual void DrawTrajectory() const
G4double GetKineticEnergy() const
G4GLOB_DLL std::ostream G4cout
virtual int GetPointEntries() const
virtual void AppendStep(const G4Step *aStep)
G4ThreadLocal G4Allocator< G4SmoothTrajectory > * aSmoothTrajectoryAllocator
const G4ThreeVector & GetPosition() const
bool G4bool
Definition: G4Types.hh:79
Definition: G4Step.hh:76
virtual void DrawTrajectory() const
virtual void ShowTrajectory(std::ostream &os=G4cout) const
G4int GetTrackID() const
G4ThreeVector GetMomentum() const
G4ThreeVector initialMomentum
static G4ParticleTable * GetParticleTable()
virtual std::vector< G4AttValue > * CreateAttValues() const
G4StepPoint * GetPostStepPoint() const
std::vector< G4ThreeVector > * GetPointerToVectorOfAuxiliaryPoints() const
Definition: G4Step.hh:240
G4ParticleDefinition * GetParticleDefinition()
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)
virtual void ShowTrajectory(std::ostream &os=G4cout) const
G4double GetPDGCharge() const