128 std::unique_ptr<HepMC::GenEvent> outputEvent = std::make_unique<HepMC::GenEvent>(inputEvent);
131 if (inputEvent.run_info()) {
132 outputEvent->set_run_info(std::make_shared<HepMC3::GenRunInfo>(*(inputEvent.run_info().get())));
134 if (inputEvent.heavy_ion()) {
135 outputEvent->set_heavy_ion(std::make_shared<HepMC::GenHeavyIon>(*(inputEvent.heavy_ion())));
140 for (
auto&
particle: outputEvent->particles()) {
144 const int shadowId =
particle->id();
146 particle->add_attribute(
"ShadowParticleId",
147 std::make_shared<HepMC3::IntAttribute>(shadowId));
157 std::vector<HepMC::GenParticlePtr> p_to_remove;
158 std::vector<HepMC::GenVertexPtr> v_to_remove;
159 for (
auto&
particle: outputEvent->particles()) {
166 for (
auto&
vertex: outputEvent->vertices()) {
169 v_to_remove.push_back(
vertex);
172 for (
auto&
vertex: v_to_remove) outputEvent->remove_vertex(
vertex);
173 if (p_to_remove.empty() && v_to_remove.empty())
break;
177 std::unique_ptr<HepMC::GenEvent> outputEvent = std::make_unique<HepMC::GenEvent>(inputEvent.signal_process_id(),
178 inputEvent.event_number());
180 outputEvent->set_mpi ( inputEvent.mpi() );
181 outputEvent->set_event_scale ( inputEvent.event_scale() );
182 outputEvent->set_alphaQCD ( inputEvent.alphaQCD() );
183 outputEvent->set_alphaQED ( inputEvent.alphaQED() );
184 if ( inputEvent.cross_section() ) {
185 outputEvent->set_cross_section ( *inputEvent.cross_section());
187 if (inputEvent.heavy_ion()) {
188 outputEvent->set_heavy_ion(*(inputEvent.heavy_ion()));
190 if (inputEvent.pdf_info()) {
191 outputEvent->set_pdf_info(*(inputEvent.pdf_info()));
193 outputEvent->define_units( inputEvent.momentum_unit(), inputEvent.length_unit() );
200 std::map<const HepMC::GenVertex*,HepMC::GenVertex*> inputEvtVtxToOutputEvtVtx;
201 HepMC::GenEvent::vertex_const_iterator currentVertexIter(inputEvent.vertices_begin());
202 const HepMC::GenEvent::vertex_const_iterator endOfCurrentListOfVertices(inputEvent.vertices_end());
204 for (; currentVertexIter != endOfCurrentListOfVertices; ++currentVertexIter) {
205 const HepMC::GenVertex *pCurrentVertex(*currentVertexIter);
209 std::unique_ptr<HepMC::GenVertex> copyOfGenVertex =std::make_unique<HepMC::GenVertex>(pCurrentVertex->position(), pCurrentVertex->id(), pCurrentVertex->weights() );
210 copyOfGenVertex->suggest_barcode(
HepMC::barcode(pCurrentVertex) );
211 inputEvtVtxToOutputEvtVtx[pCurrentVertex] = copyOfGenVertex.get();
212 outputEvent->add_vertex( copyOfGenVertex.release() );
216 if ( inputEvent.signal_process_vertex() ) {
217 outputEvent->set_signal_process_vertex( inputEvtVtxToOutputEvtVtx[inputEvent.signal_process_vertex()] );
220 outputEvent->set_signal_process_vertex(
nullptr );
227 for ( HepMC::GenEvent::particle_const_iterator particleIter = inputEvent.particles_begin();
228 particleIter != inputEvent.particles_end(); ++particleIter ) {
233 std::unique_ptr<HepMC::GenParticle> copyOfGenParticle = std::make_unique<HepMC::GenParticle>(*currentParticle);
234 const bool isBeamParticle1(currentParticle == inputEvent.beam_particles().first);
235 const bool isBeamParticle2(currentParticle == inputEvent.beam_particles().second);
239 const bool shouldAddProdVertex(currentParticle->production_vertex() && inputEvtVtxToOutputEvtVtx[ currentParticle->production_vertex() ]);
240 const bool shouldAddEndVertex(currentParticle->end_vertex() && inputEvtVtxToOutputEvtVtx[ currentParticle->end_vertex() ]);
241 if ( isBeamParticle1 || isBeamParticle2 || shouldAddProdVertex || shouldAddEndVertex ) {
243 if ( isBeamParticle1 ) {
244 beam1 = particleCopy;
246 if ( isBeamParticle2 ) {
247 beam2 = particleCopy;
249 if ( shouldAddProdVertex || shouldAddEndVertex ) {
250 if ( shouldAddEndVertex ) {
251 inputEvtVtxToOutputEvtVtx[ currentParticle->end_vertex() ]->
252 add_particle_in(particleCopy);
254 if ( shouldAddProdVertex ) {
255 inputEvtVtxToOutputEvtVtx[ currentParticle->production_vertex() ]->
256 add_particle_out(particleCopy);
260 ATH_MSG_WARNING (
"Found GenParticle with no production or end vertex! \n" << *currentParticle);
264 outputEvent->set_beam_particles(
beam1,
beam2 );
267 outputEvent->set_random_states( inputEvent.random_states() );
268 outputEvent->weights() = inputEvent.weights();