LDMX Software
LHEEvent.cxx
2
3#include <sstream>
4
5#include "Framework/Exception/Exception.h"
6
7namespace simcore {
8namespace lhe {
9
10LHEEvent::LHEEvent(std::string& line) {
11 std::istringstream iss(line);
12 std::vector<std::string> tokens;
13 do {
14 std::string elem;
15 iss >> elem;
16 if (elem.size() != 0) {
17 tokens.push_back(elem);
18 }
19 } while (iss);
20
21 if (tokens.size() != 6) {
22 EXCEPTION_RAISE("TokenNum",
23 "Wrong number of tokens in LHE event information record.");
24 }
25
26 num_particles_ = atoi(tokens[0].c_str());
27 // The physics process ID
28 process_id_ = atoi(tokens[1].c_str());
29 // The event weight
30 event_weight_ = atof(tokens[2].c_str());
31 // Scale Q of parton distributions
32 scale_q_ = atof(tokens[3].c_str());
33 // QED coupling value
34 coupling_qed_ = atof(tokens[4].c_str());
35 // QCD coupling value
36 coupling_qcd_ = atof(tokens[5].c_str());
37
38 vtx_[0] = 0;
39 vtx_[1] = 0;
40 vtx_[2] = 0;
41}
42
44
45int LHEEvent::getProcessID() const { return process_id_; }
46
47double LHEEvent::getEventWeight() const { return event_weight_; }
48
49double LHEEvent::getScaleQ() const { return scale_q_; }
50
51double LHEEvent::getCouplingQed() const { return coupling_qed_; }
52
53double LHEEvent::getCouplingQcd() const { return coupling_qcd_; }
54
55const double* LHEEvent::getVertex() const { return vtx_; }
56
57double LHEEvent::getVertexTime() const { return vtxt_; }
58
59void LHEEvent::addParticle(std::unique_ptr<LHEParticle> particle) {
60 particles_.push_back(std::move(particle));
61}
62
63const std::vector<std::unique_ptr<LHEParticle>>& LHEEvent::getParticles()
64 const {
65 return particles_;
66}
67
68void LHEEvent::setVertex(double x_, double y_, double z_) {
69 vtx_[0] = x_;
70 vtx_[1] = y_;
71 vtx_[2] = z_;
72}
73
78void LHEEvent::setVertex(const std::string& line) {
79 std::istringstream iss(line);
80 std::vector<std::string> tokens;
81 do {
82 std::string elem;
83 iss >> elem;
84 if (elem.size() != 0) {
85 tokens.push_back(elem);
86 }
87 } while (iss);
88
89 if (tokens.size() != 4 && tokens.size() != 5) {
90 EXCEPTION_RAISE("TokenNum",
91 "Wrong number of tokens or format in LHE event vertex "
92 "information record.");
93 }
94 vtx_[0] = atof(tokens[1].c_str());
95 vtx_[1] = atof(tokens[2].c_str());
96 vtx_[2] = atof(tokens[3].c_str());
97 if (tokens.size() > 4) {
98 vtxt_ = atof(tokens[4].c_str());
99 }
100}
101
102} // namespace lhe
103} // namespace simcore
Class defining an LHE event with a list of particles and information from the header block.
double getEventWeight() const
Get the event weight (XWGTUP).
Definition LHEEvent.cxx:47
LHEEvent(std::string &data)
Class constructor.
Definition LHEEvent.cxx:10
double vtx_[3]
Vertex location.
Definition LHEEvent.h:150
int getProcessID() const
Get the ID of the physics process (IDRUP).
Definition LHEEvent.cxx:45
void addParticle(std::unique_ptr< LHEParticle > particle)
Add a particle to the event.
Definition LHEEvent.cxx:59
double getCouplingQed() const
Get the value of the QED coupling (AQEDUP).
Definition LHEEvent.cxx:51
int num_particles_
Number of particles.
Definition LHEEvent.h:120
double getVertexTime() const
Get the vertex time.
Definition LHEEvent.cxx:57
void setVertex(double x_, double y_, double z_)
Set the vertex location (careful to match units as expected!)
Definition LHEEvent.cxx:68
double getCouplingQcd() const
Get the value of the QCD coupling (AQCDUP).
Definition LHEEvent.cxx:53
double event_weight_
The event weight.
Definition LHEEvent.h:130
double getScaleQ() const
Get the scale Q of parton distributions (SCALUP).
Definition LHEEvent.cxx:49
double coupling_qcd_
QCD coupling value.
Definition LHEEvent.h:145
int getNumParticles() const
Get the number of particles (NUP) in the event.
Definition LHEEvent.cxx:43
const double * getVertex() const
Get the vertex location (careful to match units as expected!)
Definition LHEEvent.cxx:55
std::vector< std::unique_ptr< LHEParticle > > particles_
The list of particles.
Definition LHEEvent.h:160
const std::vector< std::unique_ptr< LHEParticle > > & getParticles() const
Get the list of particles in the event.
Definition LHEEvent.cxx:63
double scale_q_
Scale Q of parton distributions.
Definition LHEEvent.h:135
double vtxt_
Vertex time.
Definition LHEEvent.h:155
int process_id_
The physics process ID.
Definition LHEEvent.h:125
double coupling_qed_
QED coupling value.
Definition LHEEvent.h:140
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...