This repository was archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimParticle.h
More file actions
390 lines (325 loc) · 9.23 KB
/
Copy pathSimParticle.h
File metadata and controls
390 lines (325 loc) · 9.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
#ifndef SIMCORE_EVENT_SIMPARTICLE_H
#define SIMCORE_EVENT_SIMPARTICLE_H
/*~~~~~~~~~~*/
/* ROOT */
/*~~~~~~~~~~*/
#include "TObject.h"
/*~~~~~~~~~~~~~~~~*/
/* C++ StdLib */
/*~~~~~~~~~~~~~~~~*/
#include <map>
#include <string>
#include <vector>
namespace ldmx {
/**
* Class representing a simulated particle.
*
* The particles are created from the tracks produced by simulation.
*/
class SimParticle {
public:
/**
* Enum for interesting process types.
*/
enum ProcessType {
unknown = 0,
annihil,
compt,
conv,
electronNuclear,
eBrem,
eIoni,
msc,
phot,
photonNuclear,
GammaToMuPair,
eDarkBrem,
// Only add additional processes to the end of this list!
};
/// Typedef for process map.
typedef std::map<std::string, ProcessType> ProcessTypeMap;
/// Constructor
SimParticle();
/// Destructor
~SimParticle();
/// Reset an instance of this class by clearing all of its data.
void Clear();
/// Print a string representation of this object.
void Print() const;
/**
* Get the energy of this particle [MeV].
*
* @return The energy of this particle.
*/
double getEnergy() const { return energy_; }
/**
* Get the PDG ID of this particle.
*
* @return The PDG ID of this particle.
*/
int getPdgID() const { return pdgID_; }
/**
* Get the generator status of this particle. A non-zero status
* indicates that this particle originates from an external
* generator (e.g. LHE).
*
* @return The generator status.
*/
int getGenStatus() const { return genStatus_; }
/**
* Get the global time of this particle's creation [ns].
*
* @return The global time of this particle's creation.
*/
double getTime() const { return time_; }
/**
* Get a vector containing the vertex of this particle in mm.
*
* In this case, the vertex refers to the position where the
* particle is first created in the simulation. For a particle
* with generator status equal to 1, this will equal the position
* from which this particle is fired from.
*
* @return The vertex of this particle.
*/
std::vector<double> getVertex() const { return {x_, y_, z_}; }
/**
* Get the volume name in which this particle was created in.
*
* The volumes names are set in the GDML detector description.
*
* @return The volume name in which this particle was created in.
*/
std::string getVertexVolume() const { return vertexVolume_; }
/**
* Get the endpoint of this particle where it was destroyed
* or left the world volume [mm].
*
* @return The endpoint of this particle
*/
std::vector<double> getEndPoint() const { return {endX_, endY_, endZ_}; }
/**
* Get a vector containing the momentum of this particle [MeV].
*
* The momentum of this particle is set at the time of its creation.
*
* @return The momentum of this particle.
*/
std::vector<double> getMomentum() const { return {px_, py_, pz_}; }
/**
* Get the mass of this particle [GeV].
*
* @return The mass of this particle in GeV.
*/
double getMass() const { return mass_; }
/**
* Get the charge of this particle.
*
* @return The charge of this particle.
*/
double getCharge() const { return charge_; }
/**
* Get a vector containing the track IDs of all daughter particles.
*
* @return A vector containing the track IDs of all daughter
* particles.
*/
std::vector<int> getDaughters() const { return daughters_; }
/**
* Get a vector containing the track IDs of the parent particles.
*
* @return A vector containing the track IDs the parent particles.
*/
std::vector<int> getParents() const { return parents_; }
/**
* Set the energy of this particle [MeV].
*
* @param[in] energy the energy of this particle.
*/
void setEnergy(const double& energy) { energy_ = energy; }
/**
* Set the PDG ID of this particle.
*
* @param[in] pdgID the PDG ID of the hit.
*/
void setPdgID(const int& pdgID) { pdgID_ = pdgID; }
/**
* Set the generator status of this particle.
*
* @param[in] genStatus the generator status of the hit.
*/
void setGenStatus(const int& genStatus) { genStatus_ = genStatus; }
/**
* Set the global time of this particle's creation [ns].
*
* @param[in] time The global time of this particle's creation.
*/
void setTime(const double& time) { time_ = time; }
/**
* Set the vertex of this particle [mm].
*
* @param[in] x The vertex x position.
* @param[in] y The vertex y position.
* @param[in] z The vertex z position.
*/
void setVertex(const double& x, const double& y, const double& z) {
x_ = x;
y_ = y;
z_ = z;
}
/**
* Set the name of the volume that this particle was created in.
*
* @param[in] vertexVolume volume name that this particle was
* created in.
*/
void setVertexVolume(const std::string& vertexVolume) {
vertexVolume_ = vertexVolume;
}
/**
* Set the end point position of this particle [mm].
*
* @param[in] endX The x position of the end point.
* @param[in] endY The y position of the end point.
* @param[in] endZ The z position of the end point.
*/
void setEndPoint(const double& endX, const double& endY, const double& endZ) {
endX_ = endX;
endY_ = endY;
endZ_ = endZ;
}
/**
* Set the momentum of this particle [MeV].
*
* @param[in] px The x momentum component.
* @param[in] py The y momentum component.
* @param[in] pz The z momentum component.
*/
void setMomentum(const double& px, const double& py, const double& pz) {
px_ = px;
py_ = py;
pz_ = pz;
}
/**
* Set the mass of this particle [GeV].
*
* @param[in] mass The mass of this particle.
*/
void setMass(const double& mass) { mass_ = mass; }
/**
* Set the charge of this particle.
*
* @param[in] charge The charge of this particle.
*/
void setCharge(const double& charge) { charge_ = charge; }
/**
* Add a reference to a daughter particle by its track ID.
*
* This adds the track ID of the daughter particle to the vector of
* daughter particle IDs.
*
* @param[in] daughterTrackID The daughter particle track ID.
*/
void addDaughter(const int& daughterTrackID) {
daughters_.push_back(daughterTrackID);
}
/**
* Add a reference to a parent particle by its track ID.
*
* @param[in] parentTrackID The track ID of the parent particle.
*/
void addParent(const int& parentTrackID) {
parents_.push_back(parentTrackID);
}
/**
* Get the creator process type of this particle.
*
* @return The creator process type of this particle.
*/
int getProcessType() const { return processType_; }
/**
* Set the creator process type of this particle.
*
* @param[in] processType the creator process type of this particle.
*/
void setProcessType(const int& processType) { processType_ = processType; }
/**
* Set the momentum at this particle's end point.
*
* @param[in] endpx The x component of the momentum.
* @param[in] endpy The y component of the momentum.
* @param[in] endpz The z component of the momentum.
*/
void setEndPointMomentum(const double& endpx, const double& endpy,
const double& endpz) {
endpx_ = endpx;
endpy_ = endpy;
endpz_ = endpz;
}
/**
* Get the momentum at this particle's end point.
*
* @return The momentum at this particle's end point as a vector.
*/
std::vector<double> getEndPointMomentum() const {
return {endpx_, endpy_, endpz_};
}
/**
* Get the process type enum from a G4VProcess name.
*
* @return The process type from the string.
*/
static ProcessType findProcessType(std::string processName);
private:
static ProcessTypeMap createProcessTypeMap();
private:
/// The energy of this particle.
double energy_{0};
/// The PDG ID of this particle.
int pdgID_{0};
/// The generator status.
int genStatus_{-1};
/// The global creation time.
double time_{0};
/// The x component of the vertex.
double x_{0};
/// The y component of the vertex.
double y_{0};
/// The z component of the vertex.
double z_{0};
/// The x component of the end point.
double endX_{0};
/// The y component of the end point.
double endY_{0};
/// The z component of the end point.
double endZ_{0};
/// The x component of the momentum.
double px_{0};
/// The y component of the momentum.
double py_{0};
/// The z component of the momentum.
double pz_{0};
/// The x component of the endpoint momentum.
double endpx_{0};
/// The y component of the endpoint momentum.
double endpy_{0};
/// The z component of the endpoint momentum.
double endpz_{0};
/// The particle's mass.
double mass_{0};
/// The particle's charge.
double charge_{0};
/// The list of daughter particle track IDs.
std::vector<int> daughters_;
/// The list of parent particles track IDs.
std::vector<int> parents_;
/// Encoding of Geant4 process type.
int processType_{-1};
/// Volume the track was created in.
std::string vertexVolume_{""};
/// Map containing the process types.
static ProcessTypeMap PROCESS_MAP;
ClassDef(SimParticle, 7);
}; // SimParticle
} // namespace ldmx
#endif // SIMCORE_EVENT_SIMPARTICLE_H