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