Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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// G4SmoothTrajectory class implementation
27//
28// Contact:
29// Questions and comments to this code should be sent to
30// Katsuya Amako (e-mail: [email protected])
31// Makoto Asai (e-mail: [email protected])
32// Takashi Sasaki (e-mail: [email protected])
33// --------------------------------------------------------------------
34
35#include "G4SmoothTrajectory.hh"
36
37#include "G4AttDef.hh"
38#include "G4AttDefStore.hh"
39#include "G4AttValue.hh"
40#include "G4ParticleTable.hh"
42#include "G4UIcommand.hh"
43#include "G4UnitsTable.hh"
44
45// #define G4ATTDEBUG
46#ifdef G4ATTDEBUG
47# include "G4AttCheck.hh"
48#endif
49
55
57{
58 G4ParticleDefinition* fpParticleDefinition = aTrack->GetDefinition();
59 ParticleName = fpParticleDefinition->GetParticleName();
60 PDGCharge = fpParticleDefinition->GetPDGCharge();
61 PDGEncoding = fpParticleDefinition->GetPDGEncoding();
62 fTrackID = aTrack->GetTrackID();
63 fParentID = aTrack->GetParentID();
64 initialKineticEnergy = aTrack->GetKineticEnergy();
65 initialMomentum = aTrack->GetMomentum();
66 positionRecord = new G4TrajectoryPointContainer();
67
68 // Following is for the first trajectory point
69 //
70 positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition()));
71
72 // The first point has no auxiliary points, so set the auxiliary
73 // points vector to NULL
74 //
75 positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), nullptr));
76}
77
79{
80 ParticleName = right.ParticleName;
81 PDGCharge = right.PDGCharge;
82 PDGEncoding = right.PDGEncoding;
83 fTrackID = right.fTrackID;
84 fParentID = right.fParentID;
85 initialKineticEnergy = right.initialKineticEnergy;
86 initialMomentum = right.initialMomentum;
87 positionRecord = new G4TrajectoryPointContainer();
88
89 for (auto& i : *right.positionRecord) {
90 auto rightPoint = (G4SmoothTrajectoryPoint*)i;
91 positionRecord->push_back(new G4SmoothTrajectoryPoint(*rightPoint));
92 }
93}
94
96{
97 if (positionRecord != nullptr) {
98 for (auto& i : *positionRecord) {
99 delete i;
100 }
101 positionRecord->clear();
102 delete positionRecord;
103 }
104}
105
106void G4SmoothTrajectory::ShowTrajectory(std::ostream& os) const
107{
108 // Invoke the default implementation in G4VTrajectory...
109 //
111
112 // ... or override with your own code here.
113}
114
116{
117 // Invoke the default implementation in G4VTrajectory...
118 //
120
121 // ... or override with your own code here.
122}
123
124const std::map<G4String, G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
125{
126 G4bool isNew;
127 std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4SmoothTrajectory", isNew);
128 if (isNew) {
129 G4String ID("ID");
130 (*store)[ID] = G4AttDef(ID, "Track ID", "Physics", "", "G4int");
131
132 G4String PID("PID");
133 (*store)[PID] = G4AttDef(PID, "Parent ID", "Physics", "", "G4int");
134
135 G4String PN("PN");
136 (*store)[PN] = G4AttDef(PN, "Particle Name", "Physics", "", "G4String");
137
138 G4String Ch("Ch");
139 (*store)[Ch] = G4AttDef(Ch, "Charge", "Physics", "e+", "G4double");
140
141 G4String PDG("PDG");
142 (*store)[PDG] = G4AttDef(PDG, "PDG Encoding", "Physics", "", "G4int");
143
144 G4String IKE("IKE");
145 (*store)[IKE] = G4AttDef(IKE, "Initial kinetic energy", "Physics", "G4BestUnit", "G4double");
146
147 G4String IMom("IMom");
148 (*store)[IMom] = G4AttDef(IMom, "Initial momentum", "Physics", "G4BestUnit", "G4ThreeVector");
149
150 G4String IMag("IMag");
151 (*store)[IMag] =
152 G4AttDef(IMag, "Initial momentum magnitude", "Physics", "G4BestUnit", "G4double");
153
154 G4String NTP("NTP");
155 (*store)[NTP] = G4AttDef(NTP, "No. of points", "Physics", "", "G4int");
156 }
157 return store;
158}
159
160std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
161{
162 auto values = new std::vector<G4AttValue>;
163
164 values->push_back(G4AttValue("ID", G4UIcommand::ConvertToString(fTrackID), ""));
165
166 values->push_back(G4AttValue("PID", G4UIcommand::ConvertToString(fParentID), ""));
167
168 values->push_back(G4AttValue("PN", ParticleName, ""));
169
170 values->push_back(G4AttValue("Ch", G4UIcommand::ConvertToString(PDGCharge), ""));
171
172 values->push_back(G4AttValue("PDG", G4UIcommand::ConvertToString(PDGEncoding), ""));
173
174 values->push_back(G4AttValue("IKE", G4BestUnit(initialKineticEnergy, "Energy"), ""));
175
176 values->push_back(G4AttValue("IMom", G4BestUnit(initialMomentum, "Energy"), ""));
177
178 values->push_back(G4AttValue("IMag", G4BestUnit(initialMomentum.mag(), "Energy"), ""));
179
180 values->push_back(G4AttValue("NTP", G4UIcommand::ConvertToString(GetPointEntries()), ""));
181
182#ifdef G4ATTDEBUG
183 G4cout << G4AttCheck(values, GetAttDefs());
184#endif
185
186 return values;
187}
188
190{
191 positionRecord->push_back(new G4SmoothTrajectoryPoint(
193}
194
199
201{
202 if (secondTrajectory == nullptr) return;
203
204 auto seco = (G4SmoothTrajectory*)secondTrajectory;
205 G4int ent = seco->GetPointEntries();
206
207 // initial point of the second trajectory should not be merged
208 //
209 for (G4int i = 1; i < ent; ++i) {
210 positionRecord->push_back((*(seco->positionRecord))[i]);
211 }
212 delete (*seco->positionRecord)[0];
213 seco->positionRecord->clear();
214}
G4Allocator< G4SmoothTrajectory > *& aSmoothTrajectoryAllocator()
#define G4BestUnit(a, b)
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
double mag() const
const G4String & GetParticleName() const
static G4ParticleTable * GetParticleTable()
void MergeTrajectory(G4VTrajectory *secondTrajectory) override
G4SmoothTrajectory()=default
void AppendStep(const G4Step *aStep) override
G4int GetPointEntries() const override
std::vector< G4AttValue > * CreateAttValues() const override
void DrawTrajectory() const override
G4ParticleDefinition * GetParticleDefinition()
void ShowTrajectory(std::ostream &os=G4cout) const override
const std::map< G4String, G4AttDef > * GetAttDefs() const override
const G4ThreeVector & GetPosition() const
std::vector< G4ThreeVector > * GetPointerToVectorOfAuxiliaryPoints() const
G4StepPoint * GetPostStepPoint() const
G4int GetTrackID() const
const G4ThreeVector & GetPosition() const
G4ThreeVector GetMomentum() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
G4int GetParentID() const
static G4String ConvertToString(G4bool boolVal)
virtual G4int GetPointEntries() const =0
virtual void ShowTrajectory(std::ostream &os=G4cout) const
virtual void DrawTrajectory() const
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)
#define G4ThreadLocalStatic
Definition tls.hh:76