17 bool found_event_element =
false;
18 while (getline(
ifs_, line)) {
20 std::find_if_not(line.rbegin(), line.rend(), [](
unsigned char c) {
21 return std::isspace(c);
23 line.erase(back, line.end());
24 if (line ==
"<event>") {
25 found_event_element =
true;
30 if (!found_event_element) {
31 ldmx_log(warn) <<
"No next <event> element was found by the LHE reader.";
38 auto next_event = std::make_unique<LHEEvent>(line);
40 while (getline(
ifs_, line)) {
42 std::find_if_not(line.rbegin(), line.rend(), [](
unsigned char c) {
43 return std::isspace(c);
45 line.erase(back, line.end());
46 if (line ==
"</event>" || line ==
"<mgrwt>") {
51 if (line.find(
"#") == std::string::npos) {
53 auto particle = std::make_unique<LHEParticle>(line);
54 next_event->addParticle(std::move(particle));
56 if (line.find(
"#vertex") != std::string::npos) {
57 next_event->setVertex(line);
62 const std::vector<std::unique_ptr<LHEParticle>>& particles =
63 next_event->getParticles();
64 for (
const auto& particle : particles) {
65 if (particle->getMother(0) != 0) {
66 int mother1 = particle->getMother(0);
67 int mother2 = particle->getMother(1);
69 particle->setMother(0, particles[mother1 - 1].get());
72 particle->setMother(1, particles[mother2 - 1].get());