19 bool found_event_element =
false;
20 while (getline(
ifs_, line)) {
22 std::find_if_not(line.rbegin(), line.rend(), [](
unsigned char c) {
23 return std::isspace(c);
25 line.erase(back, line.end());
26 if (line ==
"<event>") {
27 found_event_element =
true;
32 if (!found_event_element) {
33 ldmx_log(warn) <<
"No next <event> element was found by the LHE reader.";
40 auto next_event = std::make_unique<LHEEvent>(line);
42 while (getline(
ifs_, line)) {
44 std::find_if_not(line.rbegin(), line.rend(), [](
unsigned char c) {
45 return std::isspace(c);
47 line.erase(back, line.end());
48 if (line ==
"</event>" || line ==
"<mgrwt>") {
53 if (line.find(
"#") == std::string::npos) {
55 auto particle = std::make_unique<LHEParticle>(line);
56 next_event->addParticle(std::move(particle));
58 if (line.find(
"#vertex") != std::string::npos) {
59 next_event->setVertex(line);
64 const std::vector<std::unique_ptr<LHEParticle>>& particles =
65 next_event->getParticles();
66 for (
const auto& particle : particles) {
67 if (particle->getMother(0) != 0) {
68 int mother1 = particle->getMother(0);
69 int mother2 = particle->getMother(1);
71 particle->setMother(0, particles[mother1 - 1].get());
74 particle->setMother(1, particles[mother2 - 1].get());