39 if (!inputMcEventCollection.
isValid()) {
40 ATH_MSG_ERROR(
"Could not find input McEventCollection called " << inputMcEventCollection.
name() <<
" in store " << inputMcEventCollection.
store() <<
".");
41 return StatusCode::FAILURE;
46 bool inputProblem(
false);
47 for (
const auto& particle: inputEvent) {
49 if (!particle->production_vertex()) {
50 ATH_MSG_ERROR(
"Stable particle without a production vertex!! " << particle);
55 if (!particle->production_vertex()) {
56 ATH_MSG_ERROR(
"Decyed particle without a production vertex!! " << particle);
59 if (!particle->end_vertex()) {
60 ATH_MSG_ERROR(
"Decyed particle without an end vertex!! " << particle);
67 return StatusCode::FAILURE;
71 std::unique_ptr<HepMC::GenEvent> outputEvent = std::make_unique<HepMC::GenEvent>(inputEvent);
72 if (inputEvent.run_info()) outputEvent->set_run_info(std::make_shared<HepMC3::GenRunInfo>(*(inputEvent.run_info().get())));
74 std::vector<HepMC::GenParticlePtr> p_to_remove;
75 std::vector<HepMC::GenVertexPtr> v_to_remove;
76 for (
auto& particle: outputEvent->particles()) {
78 p_to_remove.push_back(particle);
81 for (
auto& particle: p_to_remove) outputEvent->remove_particle(particle);
82 for (
auto& vertex: outputEvent->vertices()) {
84 v_to_remove.push_back(vertex);
87 for (
auto& vertex: v_to_remove) outputEvent->remove_vertex(vertex);
88 if (p_to_remove.empty() && v_to_remove.empty())
break;
93 bool outputProblem(
false);
94 for (
const auto& particle: *(outputEvent.get())) {
96 if (!particle->production_vertex()) {
97 ATH_MSG_ERROR(
"Stable particle without a production vertex!! " << particle);
100 if (particle->end_vertex()) {
101 ATH_MSG_ERROR(
"Stable particle with an end vertex!! " << particle);
102 outputProblem =
true;
106 if (!particle->production_vertex()) {
107 ATH_MSG_ERROR(
"Decayed particle without a production vertex!! " << particle);
108 outputProblem =
true;
110 if (!particle->end_vertex()) {
111 ATH_MSG_ERROR(
"Decayed particle without an end vertex!! " << particle);
112 outputProblem =
true;
118 return StatusCode::FAILURE;
122 ATH_CHECK(outputMcEventCollection.
record(std::make_unique<McEventCollection>()));
123 outputMcEventCollection->push_back(outputEvent.release());
124 if (!outputMcEventCollection.
isValid()) {
125 ATH_MSG_ERROR(
"Could not record output McEventCollection called " << outputMcEventCollection.
name() <<
" in store " << outputMcEventCollection.
store() <<
".");
126 return StatusCode::FAILURE;
131 return StatusCode::SUCCESS;