LDMX Software
SimParticle.h
1#ifndef SIMCORE_EVENT_SIMPARTICLE_H
2#define SIMCORE_EVENT_SIMPARTICLE_H
3
4/*~~~~~~~~~~*/
5/* ROOT */
6/*~~~~~~~~~~*/
7#include "TObject.h"
8
9/*~~~~~~~~~~~~~~~~*/
10/* C++ StdLib */
11/*~~~~~~~~~~~~~~~~*/
12#include <functional>
13#include <map>
14#include <string>
15#include <vector>
16
17namespace ldmx {
18
25 public:
30 unknown = 0,
31 annihil = 1,
32 compt = 2,
33 conv = 3,
34 electronNuclear = 4,
35 eBrem = 5,
36 eIoni = 6,
37 msc = 7,
38 phot = 8,
39 photonNuclear = 9,
40 GammaToMuPair = 10,
41 eDarkBrem = 11,
42 Decay = 12,
43 Primary = 13,
44 muonNuclear = 14,
45 neutronInelastic = 15,
46 neutronCapture = 16,
47 kaonInelastic = 17,
48 pionInelastic = 18,
49 protonInelastic = 19,
50 // Only add additional processes to the end of this list!
51 };
52
54 typedef std::map<std::string, ProcessType> ProcessTypeMap;
55
57 SimParticle() = default;
58
60 virtual ~SimParticle() = default;
61
63 void clear();
64
66 friend std::ostream& operator<<(std::ostream& o, const SimParticle& d);
67
73 double getEnergy() const { return energy_; }
74
80 double getKineticEnergy() const { return energy_ - mass_; }
86 int getPdgID() const { return pdg_id_; }
87
95 int getGenStatus() const { return gen_status_; }
96
102 double getTime() const { return time_; }
103
114 std::vector<double> getVertex() const { return {vtx_x_, vtx_y_, vtx_z_}; }
115
123 std::string getVertexVolume() const { return vertex_volume_; }
124
132 std::string getInteractionMaterial() const { return interaction_material_; }
133
140 std::vector<double> getEndPoint() const { return {end_x_, end_y_, end_z_}; }
141
149 std::vector<double> getMomentum() const { return {px_, py_, pz_}; }
150
156 double getMass() const { return mass_; }
157
163 double getCharge() const { return charge_; }
164
171 std::vector<int> getDaughters() const { return daughters_; }
172
178 std::vector<int> getParents() const { return parents_; }
179
185 void setEnergy(const double& energy) { energy_ = energy; }
186
192 void setPdgID(const int& pdg_id) { pdg_id_ = pdg_id; }
193
199 void setGenStatus(const int& gen_status) { gen_status_ = gen_status; }
200
206 void setTime(const double& time) { time_ = time; }
207
215 void setVertex(const double& vtx_x, const double& vtx_y,
216 const double& vtx_z) {
217 vtx_x_ = vtx_x;
218 vtx_y_ = vtx_y;
219 vtx_z_ = vtx_z;
220 }
221
228 void setVertexVolume(const std::string& vertexVolume) {
229 vertex_volume_ = vertexVolume;
230 }
231
238 void setInteractionMaterial(const std::string& interaction_material) {
239 interaction_material_ = interaction_material;
240 }
241
249 void setEndPoint(const double& end_x, const double& end_y,
250 const double& end_z) {
251 end_x_ = end_x;
252 end_y_ = end_y;
253 end_z_ = end_z;
254 }
255
263 void setMomentum(const double& px, const double& py, const double& pz) {
264 px_ = px;
265 py_ = py;
266 pz_ = pz;
267 }
268
274 void setMass(const double& mass) { mass_ = mass; }
275
281 void setCharge(const double& charge) { charge_ = charge; }
282
291 void addDaughter(const int& daughter_track_id) {
292 daughters_.push_back(daughter_track_id);
293 }
294
300 void addParent(const int& parent_track_id) {
301 parents_.push_back(parent_track_id);
302 }
303
312 void encodeTracks(
313 std::function<int(int, unsigned int, unsigned int)> encodeFunc,
314 const unsigned int encoding_version, const unsigned int event_index = 0);
315
321 int getProcessType() const { return process_type_; }
322
328 void setProcessType(const int& process_type) { process_type_ = process_type; }
329
337 void setEndPointMomentum(const double& end_px, const double& end_py,
338 const double& end_pz) {
339 end_px_ = end_px;
340 end_py_ = end_py;
341 end_pz_ = end_pz;
342 }
343
349 std::vector<double> getEndPointMomentum() const {
350 return {end_px_, end_py_, end_pz_};
351 }
352
358 static ProcessType findProcessType(std::string processName);
359
360 private:
362
363 private:
365 double energy_{0};
366
368 int pdg_id_{0};
369
371 int gen_status_{-1};
372
374 double time_{0};
375
377 double vtx_x_{0};
378
380 double vtx_y_{0};
381
383 double vtx_z_{0};
384
386 double end_x_{0};
387
389 double end_y_{0};
390
392 double end_z_{0};
393
395 double px_{0};
396
398 double py_{0};
399
401 double pz_{0};
402
404 double end_px_{0};
405
407 double end_py_{0};
408
410 double end_pz_{0};
411
413 double mass_{0};
414
416 double charge_{0};
417
419 std::vector<int> daughters_;
420
422 std::vector<int> parents_;
423
426
428 std::string vertex_volume_{""};
429
431 std::string interaction_material_{""};
432
435
436 ClassDef(SimParticle, 8);
437
438}; // SimParticle
439} // namespace ldmx
440
441#endif // SIMCORE_EVENT_SIMPARTICLE_H
Class representing a simulated particle.
Definition SimParticle.h:24
double getCharge() const
Get the charge of this particle.
double end_py_
The y component of the end_point momentum.
double pz_
The z component of the momentum.
double getMass() const
Get the mass of this particle [GeV].
ProcessType
Enum for interesting process types.
Definition SimParticle.h:29
std::string getVertexVolume() const
Get the volume name in which this particle was created in.
void setPdgID(const int &pdg_id)
Set the PDG ID of this particle.
double getTime() const
Get the global time of this particle's creation [ns].
double getEnergy() const
Get the energy of this particle [MeV].
Definition SimParticle.h:73
void setEndPointMomentum(const double &end_px, const double &end_py, const double &end_pz)
Set the momentum at this particle's end point.
double py_
The y component of the momentum.
void addParent(const int &parent_track_id)
Add a reference to a parent particle by its track ID.
void setProcessType(const int &process_type)
Set the creator process type of this particle.
virtual ~SimParticle()=default
Destructor.
double vtx_x_
The x component of the vertex.
std::vector< int > getParents() const
Get a vector containing the track IDs of the parent particles.
std::vector< double > getVertex() const
Get a vector containing the vertex of this particle in mm.
static ProcessType findProcessType(std::string processName)
Get the process type enum from a G4VProcess name.
std::string getInteractionMaterial() const
Get the material name in which this particle was created in.
std::vector< int > daughters_
The list of daughter particle track IDs.
int process_type_
Encoding of Geant4 process type.
void setMomentum(const double &px, const double &py, const double &pz)
Set the momentum of this particle [MeV].
double end_x_
The x component of the end point.
std::vector< double > getEndPointMomentum() const
Get the momentum at this particle's end point.
double energy_
The energy of this particle.
std::vector< int > getDaughters() const
Get a vector containing the track IDs of all daughter particles.
SimParticle()=default
Constructor.
void setCharge(const double &charge)
Set the charge of this particle.
int getPdgID() const
Get the PDG ID of this particle.
Definition SimParticle.h:86
double end_pz_
The z component of the end_point momentum.
void setEnergy(const double &energy)
Set the energy of this particle [MeV].
int getGenStatus() const
Get the generator status of this particle.
Definition SimParticle.h:95
void setGenStatus(const int &gen_status)
Set the generator status of this particle.
std::vector< double > getEndPoint() const
Get the end_point of this particle where it was destroyed or left the world volume [mm].
double vtx_y_
The y component of the vertex.
double charge_
The particle's charge.
double end_y_
The y component of the end point.
double px_
The x component of the momentum.
std::map< std::string, ProcessType > ProcessTypeMap
Typedef for process map.
Definition SimParticle.h:54
std::vector< double > getMomentum() const
Get a vector containing the momentum of this particle [MeV].
double end_z_
The z component of the end point.
std::string interaction_material_
Volume the track was created in.
void setMass(const double &mass)
Set the mass of this particle [GeV].
void setVertex(const double &vtx_x, const double &vtx_y, const double &vtx_z)
Set the vertex of this particle [mm].
double mass_
The particle's mass.
std::vector< int > parents_
The list of parent particles track IDs.
void setEndPoint(const double &end_x, const double &end_y, const double &end_z)
Set the end point position of this particle [mm].
void setVertexVolume(const std::string &vertexVolume)
Set the name of the volume that this particle was created in.
double end_px_
The x component of the end_point momentum.
int getProcessType() const
Get the creator process type of this particle.
void setTime(const double &time)
Set the global time of this particle's creation [ns].
double getKineticEnergy() const
Get the kinetic energy of this particle [MeV].
Definition SimParticle.h:80
double vtx_z_
The z component of the vertex.
static ProcessTypeMap createProcessTypeMap()
int pdg_id_
The PDG ID of this particle.
int gen_status_
The generator status.
friend std::ostream & operator<<(std::ostream &o, const SimParticle &d)
Print a string representation of this object.
void addDaughter(const int &daughter_track_id)
Add a reference to a daughter particle by its track ID.
static ProcessTypeMap process_map
Map containing the process types.
void clear()
Reset an instance of this class by clearing all of its data.
double time_
The global creation time.
void encodeTracks(std::function< int(int, unsigned int, unsigned int)> encodeFunc, const unsigned int encoding_version, const unsigned int event_index=0)
Encodes all Track IDs in the SimParticle object according to the schema provided in the 'encodeFunc' ...
std::string vertex_volume_
Volume the track was created in.
void setInteractionMaterial(const std::string &interaction_material)
Set the name of the material that this particle was created in.