LDMX Software
SimParticle.h
1#ifndef SIMCORE_EVENT_SIMPARTICLE_H
2#define SIMCORE_EVENT_SIMPARTICLE_H
3
4/*~~~~~~~~~~*/
5/* ROOT */
6/*~~~~~~~~~~*/
7
8/*~~~~~~~~~~~~~~~~*/
9/* C++ StdLib */
10/*~~~~~~~~~~~~~~~~*/
11#include <Rtypes.h>
12
13#include <functional>
14#include <map>
15#include <string>
16#include <vector>
17
18namespace ldmx {
19
26 public:
31 unknown = 0,
32 annihil = 1,
33 compt = 2,
34 conv = 3,
35 electronNuclear = 4,
36 eBrem = 5,
37 eIoni = 6,
38 msc = 7,
39 phot = 8,
40 photonNuclear = 9,
41 GammaToMuPair = 10,
42 eDarkBrem = 11,
43 Decay = 12,
44 Primary = 13,
45 muonNuclear = 14,
46 neutronInelastic = 15,
47 neutronCapture = 16,
48 kaonInelastic = 17,
49 pionInelastic = 18,
50 protonInelastic = 19,
51 // Only add additional processes to the end of this list!
52 };
53
55 typedef std::map<std::string, ProcessType> ProcessTypeMap;
56
58 SimParticle() = default;
59
61 virtual ~SimParticle() = default;
62
64 void clear();
65
67 friend std::ostream& operator<<(std::ostream& o, const SimParticle& d);
68
74 double getEnergy() const { return energy_; }
75
81 double getKineticEnergy() const { return energy_ - mass_; }
87 int getPdgID() const { return pdg_id_; }
88
96 int getGenStatus() const { return gen_status_; }
97
103 double getTime() const { return time_; }
104
115 std::vector<double> getVertex() const { return {vtx_x_, vtx_y_, vtx_z_}; }
116
124 std::string getVertexVolume() const { return vertex_volume_; }
125
133 std::string getInteractionMaterial() const { return interaction_material_; }
134
141 std::vector<double> getEndPoint() const { return {end_x_, end_y_, end_z_}; }
142
150 std::vector<double> getMomentum() const { return {px_, py_, pz_}; }
151
157 double getMass() const { return mass_; }
158
164 double getCharge() const { return charge_; }
165
172 std::vector<int> getDaughters() const { return daughters_; }
173
179 std::vector<int> getParents() const { return parents_; }
180
186 void setEnergy(const double& energy) { energy_ = energy; }
187
193 void setPdgID(const int& pdg_id) { pdg_id_ = pdg_id; }
194
200 void setGenStatus(const int& gen_status) { gen_status_ = gen_status; }
201
207 void setTime(const double& time) { time_ = time; }
208
216 void setVertex(const double& vtx_x, const double& vtx_y,
217 const double& vtx_z) {
218 vtx_x_ = vtx_x;
219 vtx_y_ = vtx_y;
220 vtx_z_ = vtx_z;
221 }
222
229 void setVertexVolume(const std::string& vertexVolume) {
230 vertex_volume_ = vertexVolume;
231 }
232
239 void setInteractionMaterial(const std::string& interaction_material) {
240 interaction_material_ = interaction_material;
241 }
242
250 void setEndPoint(const double& end_x, const double& end_y,
251 const double& end_z) {
252 end_x_ = end_x;
253 end_y_ = end_y;
254 end_z_ = end_z;
255 }
256
264 void setMomentum(const double& px, const double& py, const double& pz) {
265 px_ = px;
266 py_ = py;
267 pz_ = pz;
268 }
269
275 void setMass(const double& mass) { mass_ = mass; }
276
282 void setCharge(const double& charge) { charge_ = charge; }
283
292 void addDaughter(const int& daughter_track_id) {
293 daughters_.push_back(daughter_track_id);
294 }
295
301 void addParent(const int& parent_track_id) {
302 parents_.push_back(parent_track_id);
303 }
304
313 void encodeTracks(
314 std::function<int(int, unsigned int, unsigned int)> encodeFunc,
315 const unsigned int encoding_version, const unsigned int event_index = 0);
316
322 int getProcessType() const { return process_type_; }
323
329 void setProcessType(const int& process_type) { process_type_ = process_type; }
330
338 void setEndPointMomentum(const double& end_px, const double& end_py,
339 const double& end_pz) {
340 end_px_ = end_px;
341 end_py_ = end_py;
342 end_pz_ = end_pz;
343 }
344
350 std::vector<double> getEndPointMomentum() const {
351 return {end_px_, end_py_, end_pz_};
352 }
353
359 static ProcessType findProcessType(std::string processName);
360
361 private:
363
364 private:
366 double energy_{0};
367
369 int pdg_id_{0};
370
372 int gen_status_{-1};
373
375 double time_{0};
376
378 double vtx_x_{0};
379
381 double vtx_y_{0};
382
384 double vtx_z_{0};
385
387 double end_x_{0};
388
390 double end_y_{0};
391
393 double end_z_{0};
394
396 double px_{0};
397
399 double py_{0};
400
402 double pz_{0};
403
405 double end_px_{0};
406
408 double end_py_{0};
409
411 double end_pz_{0};
412
414 double mass_{0};
415
417 double charge_{0};
418
420 std::vector<int> daughters_;
421
423 std::vector<int> parents_;
424
427
429 std::string vertex_volume_{""};
430
432 std::string interaction_material_{""};
433
436
437 ClassDef(SimParticle, 8);
438
439}; // SimParticle
440} // namespace ldmx
441
442#endif // SIMCORE_EVENT_SIMPARTICLE_H
Class representing a simulated particle.
Definition SimParticle.h:25
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:30
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:74
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:87
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:96
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:55
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:81
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.