LDMX Software
HepMC3GenEvent.cxx
1//
2// Created by Wesley Ketchum on 4/26/24.
3//
4
5#include "SimCore/Event/HepMC3GenEvent.h"
6
7#include <sstream>
8#include <string>
9
10#include "HepMC3/Print.h"
11#include "HepMC3/WriterAscii.h"
12
13namespace ldmx {
14
15void HepMC3GenEvent::clear() {
16 this->particles.clear();
17 this->vertices.clear();
18 this->links1.clear();
19 this->links2.clear();
20 this->attribute_id.clear();
21 this->attribute_name.clear();
22 this->attribute_string.clear();
23}
24
25void HepMC3GenEvent::print() const {
26 HepMC3::GenEvent ev;
27 ev.read_data(*this);
28 HepMC3::Print::line(ev, true); // print attributes
29}
30
31HepMC3::GenEvent HepMC3GenEvent::getHepMCGenEvent() const {
32 HepMC3::GenEvent ev;
33 ev.read_data(*this);
34 return ev;
35}
36
37std::string HepMC3GenEvent::getAsString() const {
38 HepMC3::GenEvent ev;
39 ev.read_data(*this);
40
41 std::stringstream ss;
42 HepMC3::WriterAscii writer(ss);
43
44 writer.write_event(ev);
45 return ss.str();
46}
47} // namespace ldmx