LDMX Software
LHEParticle.cxx
2
3#include <sstream>
4#include <vector>
5
6#include "Framework/Exception/Exception.h"
7
8namespace simcore {
9namespace lhe {
10
11LHEParticle::LHEParticle(std::string& line) {
12 std::istringstream iss(line);
13 std::vector<std::string> tokens;
14 do {
15 std::string elem;
16 iss >> elem;
17 if (elem.size() != 0) {
18 tokens.push_back(elem);
19 }
20 } while (iss);
21
22 if (tokens.size() != 13) {
23 EXCEPTION_RAISE("TokenNum",
24 "Wrong number of tokens in LHE particle record.");
25 }
26
27 pdg_id_ = atof(tokens[0].c_str());
28 status_ = atoi(tokens[1].c_str());
29 mother_[0] = atoi(tokens[2].c_str());
30 mother_[1] = atoi(tokens[3].c_str());
31 color_[0] = atoi(tokens[4].c_str());
32 color_[1] = atoi(tokens[5].c_str());
33 momentum_[0] = atof(tokens[6].c_str());
34 momentum_[1] = atof(tokens[7].c_str());
35 momentum_[2] = atof(tokens[8].c_str());
36 momentum_[3] = atof(tokens[9].c_str());
37 momentum_[4] = atof(tokens[10].c_str());
38 lifetime_ = atof(tokens[11].c_str());
39 spin_ = atof(tokens[12].c_str());
40
41 mothers_[0] = nullptr;
42 mothers_[1] = nullptr;
43}
44
45int LHEParticle::getPdgId() const { return pdg_id_; }
46
47int LHEParticle::getStatus() const { return status_; }
48
49int LHEParticle::getMother(int i) const { return mother_[i]; }
50
51int LHEParticle::getColor(int i) const { return color_[i]; }
52
53double LHEParticle::getMomentum(int i) const { return momentum_[i]; }
54
55double LHEParticle::getLifetime() const { return lifetime_; }
56
57double LHEParticle::getSpin() const { return spin_; }
58
59void LHEParticle::setMother(int i, LHEParticle* mother) {
60 mothers_[i] = mother;
61}
62
64
65void LHEParticle::print() const {
66 std::cout << "LHEParticle { " << "PDG ID: " << getPdgId()
67 << ", Status: " << getStatus() << ", Mother[0]: " << getMother(0)
68 << ", Mother[1]: " << getMother(1) << ", Color[0]: " << getColor(0)
69 << ", Color[1]: " << getColor(1)
70 << ", Momentum[0]: " << getMomentum(0)
71 << ", Momentum[1]: " << getMomentum(1)
72 << ", Momentum[2]: " << getMomentum(2)
73 << ", Momentum[3]: " << getMomentum(3)
74 << ", Momentum[4]: " << getMomentum(4)
75 << ", Time: " << getLifetime() << ", Spin: " << getSpin() << " }"
76 << std::endl;
77}
78
79} // namespace lhe
80} // namespace simcore
Class defining a single particle record in an LHE event.
Single particle record in an LHE event.
Definition LHEParticle.h:28
double lifetime_
The proper time.
int getColor(int) const
Get the particle color (ICOLUP) by index_.
int spin_
The particle's spin.
int getMother(int) const
Get a mother particle index (MOTHUP) by index_.
double getSpin() const
Get the particle's spin (SPINUP).
LHEParticle(std::string &data)
Class constructor.
void setMother(int i, LHEParticle *particle)
Set a mother particle by index_.
int color_[2]
The particle color.
LHEParticle * mothers_[2]
The mother particles.
void print() const
Print particle information to an output stream.
double momentum_[5]
The momentum components.
double getLifetime() const
Get the proper lifetime (VTIMUP).
LHEParticle * getMotherParticle(int) const
Get a mother particle by index_.
double getMomentum(int) const
Get a momentum component (PUP) by index_.
int getPdgId() const
Get the PDG code (IDUP).
int pdg_id_
The PDG code.
int getStatus() const
Get the status code (ISTUP).
int status_
The status code.
int mother_[2]
The mother particle indices.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...