135 std::unique_ptr<HepMC::GenEvent> outputEvent = std::make_unique<HepMC::GenEvent>(inputEvent);
138 if (inputEvent.run_info()) {
139 outputEvent->set_run_info(std::make_shared<HepMC3::GenRunInfo>(*(inputEvent.run_info().get())));
141 if (inputEvent.heavy_ion()) {
142 outputEvent->set_heavy_ion(std::make_shared<HepMC::GenHeavyIon>(*(inputEvent.heavy_ion())));
147 for (
auto&
particle: outputEvent->particles()) {
151 const int shadowId =
particle->id();
153 particle->add_attribute(
"ShadowParticleId",
154 std::make_shared<HepMC3::IntAttribute>(shadowId));
164 std::vector<HepMC::GenParticlePtr> p_to_remove;
165 std::vector<HepMC::GenVertexPtr> v_to_remove;
166 for (
auto&
particle: outputEvent->particles()) {
173 for (
auto&
vertex: outputEvent->vertices()) {
176 v_to_remove.push_back(
vertex);
179 for (
auto&
vertex: v_to_remove) outputEvent->remove_vertex(
vertex);
180 if (p_to_remove.empty() && v_to_remove.empty())
break;
184 std::unique_ptr<HepMC::GenEvent> outputEvent = std::make_unique<HepMC::GenEvent>(inputEvent.signal_process_id(),
185 inputEvent.event_number());
187 outputEvent->set_mpi ( inputEvent.mpi() );
188 outputEvent->set_event_scale ( inputEvent.event_scale() );
189 outputEvent->set_alphaQCD ( inputEvent.alphaQCD() );
190 outputEvent->set_alphaQED ( inputEvent.alphaQED() );
191 if ( inputEvent.cross_section() ) {
192 outputEvent->set_cross_section ( *inputEvent.cross_section());
194 if (inputEvent.heavy_ion()) {
195 outputEvent->set_heavy_ion(*(inputEvent.heavy_ion()));
197 if (inputEvent.pdf_info()) {
198 outputEvent->set_pdf_info(*(inputEvent.pdf_info()));
200 outputEvent->define_units( inputEvent.momentum_unit(), inputEvent.length_unit() );
207 std::map<const HepMC::GenVertex*,HepMC::GenVertex*> inputEvtVtxToOutputEvtVtx;
208 HepMC::GenEvent::vertex_const_iterator currentVertexIter(inputEvent.vertices_begin());
209 const HepMC::GenEvent::vertex_const_iterator endOfCurrentListOfVertices(inputEvent.vertices_end());
211 for (; currentVertexIter != endOfCurrentListOfVertices; ++currentVertexIter) {
212 const HepMC::GenVertex *pCurrentVertex(*currentVertexIter);
216 std::unique_ptr<HepMC::GenVertex> copyOfGenVertex =std::make_unique<HepMC::GenVertex>(pCurrentVertex->position(), pCurrentVertex->id(), pCurrentVertex->weights() );
217 copyOfGenVertex->suggest_barcode(
HepMC::barcode(pCurrentVertex) );
218 inputEvtVtxToOutputEvtVtx[pCurrentVertex] = copyOfGenVertex.get();
219 outputEvent->add_vertex( copyOfGenVertex.release() );
223 if ( inputEvent.signal_process_vertex() ) {
224 outputEvent->set_signal_process_vertex( inputEvtVtxToOutputEvtVtx[inputEvent.signal_process_vertex()] );
227 outputEvent->set_signal_process_vertex(
nullptr );
234 for ( HepMC::GenEvent::particle_const_iterator particleIter = inputEvent.particles_begin();
235 particleIter != inputEvent.particles_end(); ++particleIter ) {
240 std::unique_ptr<HepMC::GenParticle> copyOfGenParticle = std::make_unique<HepMC::GenParticle>(*currentParticle);
241 const bool isBeamParticle1(currentParticle == inputEvent.beam_particles().first);
242 const bool isBeamParticle2(currentParticle == inputEvent.beam_particles().second);
246 const bool shouldAddProdVertex(currentParticle->production_vertex() && inputEvtVtxToOutputEvtVtx[ currentParticle->production_vertex() ]);
247 const bool shouldAddEndVertex(currentParticle->end_vertex() && inputEvtVtxToOutputEvtVtx[ currentParticle->end_vertex() ]);
248 if ( isBeamParticle1 || isBeamParticle2 || shouldAddProdVertex || shouldAddEndVertex ) {
250 if ( isBeamParticle1 ) {
251 beam1 = particleCopy;
253 if ( isBeamParticle2 ) {
254 beam2 = particleCopy;
256 if ( shouldAddProdVertex || shouldAddEndVertex ) {
257 if ( shouldAddEndVertex ) {
258 inputEvtVtxToOutputEvtVtx[ currentParticle->end_vertex() ]->
259 add_particle_in(particleCopy);
261 if ( shouldAddProdVertex ) {
262 inputEvtVtxToOutputEvtVtx[ currentParticle->production_vertex() ]->
263 add_particle_out(particleCopy);
267 ATH_MSG_WARNING (
"Found GenParticle with no production or end vertex! \n" << *currentParticle);
271 outputEvent->set_beam_particles(
beam1,
beam2 );
274 outputEvent->set_random_states( inputEvent.random_states() );
275 outputEvent->weights() = inputEvent.weights();