LDMX Software
LHEParticle.cxx
2
3#include "Framework/Exception/Exception.h"
4
5// STL
6#include <stdlib.h>
7
8#include <iostream>
9#include <sstream>
10#include <vector>
11
12// Geant4
13#include "globals.hh"
14
15namespace simcore::lhe {
16
17LHEParticle::LHEParticle(std::string& line) {
18 std::istringstream iss(line);
19 std::vector<std::string> tokens;
20 do {
21 std::string elem;
22 iss >> elem;
23 if (elem.size() != 0) {
24 tokens.push_back(elem);
25 }
26 } while (iss);
27
28 if (tokens.size() != 13) {
29 EXCEPTION_RAISE("TokenNum",
30 "Wrong number of tokens in LHE particle record.");
31 }
32
33 idup_ = atof(tokens[0].c_str());
34 istup_ = atoi(tokens[1].c_str());
35 mothup_[0] = atoi(tokens[2].c_str());
36 mothup_[1] = atoi(tokens[3].c_str());
37 icolup_[0] = atoi(tokens[4].c_str());
38 icolup_[1] = atoi(tokens[5].c_str());
39 pup_[0] = atof(tokens[6].c_str());
40 pup_[1] = atof(tokens[7].c_str());
41 pup_[2] = atof(tokens[8].c_str());
42 pup_[3] = atof(tokens[9].c_str());
43 pup_[4] = atof(tokens[10].c_str());
44 vtimup_ = atof(tokens[11].c_str());
45 spinup_ = atof(tokens[12].c_str());
46
47 mothers_[0] = nullptr;
48 mothers_[1] = nullptr;
49}
50
51int LHEParticle::getIDUP() const { return idup_; }
52
53int LHEParticle::getISTUP() const { return istup_; }
54
55int LHEParticle::getMOTHUP(int i) const { return mothup_[i]; }
56
57int LHEParticle::getICOLUP(int i) const { return icolup_[i]; }
58
59double LHEParticle::getPUP(int i) const { return pup_[i]; }
60
61double LHEParticle::getVTIMUP() const { return vtimup_; }
62
63double LHEParticle::getSPINUP() const { return spinup_; }
64
65void LHEParticle::setMother(int i, LHEParticle* mother) {
66 mothers_[i] = mother;
67}
68
69LHEParticle* LHEParticle::getMother(int i) const { return mothers_[i]; }
70
71void LHEParticle::print(std::ostream& stream) const {
72 stream << "LHEParticle { "
73 << "IDUP: " << getIDUP() << ", ISTUP: " << getISTUP()
74 << ", MOTHUP[0]: " << getMOTHUP(0) << ", MOTHUP[1]: " << getMOTHUP(1)
75 << ", ICOLUP[0]: " << getICOLUP(0) << ", ICOLUP[1]: " << getICOLUP(1)
76 << ", PUP[0]: " << getPUP(0) << ", PUP[1]: " << getPUP(1)
77 << ", PUP[2]: " << getPUP(2) << ", PUP[3]: " << getPUP(3)
78 << ", PUP[4]: " << getPUP(4) << ", VTIMUP: " << getVTIMUP()
79 << ", SPINUP: " << getSPINUP() << " }" << std::endl;
80}
81
82std::ostream& operator<<(std::ostream& stream, const LHEParticle& particle) {
83 particle.print(stream);
84 return stream;
85}
86
87} // namespace simcore::lhe
Class defining a single particle record in an LHE event.
Single particle record in an LHE event.
Definition LHEParticle.h:20
int getMOTHUP(int) const
Get a mother particle index (MOTHUP) by index.
double getPUP(int) const
Get a momentum component (PUP) by index.
int idup_
The PDG code.
LHEParticle(std::string &data)
Class constructor.
void setMother(int i, LHEParticle *particle)
Set a mother particle by index.
LHEParticle * mothers_[2]
The mother particles.
int istup_
The status code.
double getSPINUP() const
Get the particle's spin (SPINUP).
int spinup_
The particle's spin.
double getVTIMUP() const
Get the proper lifetime (VTIMUP).
int icolup_[2]
The particle color.
int mothup_[2]
The mother particle indices.
void print(std::ostream &stream) const
Print particle information to an output stream.
int getISTUP() const
Get the status code (ISTUP).
LHEParticle * getMother(int) const
Get a mother particle by index.
double pup_[5]
The momentum components.
int getIDUP() const
Get the PDG code (IDUP).
int getICOLUP(int) const
Get the particle color (ICOLUP) by index.
double vtimup_
The proper time.