56 if (!inputCollection.
isValid()) {
57 ATH_MSG_ERROR(
"Could not get input truth collection " << inputCollection.
name() <<
" from store " << inputCollection.
store());
58 return StatusCode::FAILURE;
60 ATH_MSG_DEBUG(
"Found input truth collection " << inputCollection.
name() <<
" in store " << inputCollection.
store());
63 ATH_CHECK(outputCollection.record(std::make_unique<McEventCollection>()));
64 if (!outputCollection.isValid()) {
65 ATH_MSG_ERROR(
"Could not record output truth collection " << outputCollection.name() <<
" to store " << outputCollection.store());
66 return StatusCode::FAILURE;
68 ATH_MSG_DEBUG(
"Recorded output truth collection " << outputCollection.name() <<
" in store " << outputCollection.store());
73 genPart->set_status(1);
78 genVertex->add_particle_out(genPart);
80 const HepMC::GenEvent* genEvt = *(inputCollection->begin());
84 for (
const auto &oldbp : genEvt->beams()) {
89 evt->add_beam_particle(bp);
93 if (genEvt->cross_section()) {
94 auto cs = std::make_shared<HepMC3::GenCrossSection>(*genEvt->cross_section().get());
95 evt->set_cross_section(std::move(cs));
99 if (hScatVx !=
nullptr) {
100 HepMC::FourVector pmvxpos=hScatVx->position();
101 genVertex->set_position(pmvxpos);
104 if (hScatVx->particles_in().size()==2) {
105 double sum = hScatVx->particles_in().at(0)->momentum().e()+hScatVx->particles_in().at(1)->momentum().e();
106 genPart->set_momentum(HepMC::FourVector(sum,0,0,sum));
110 evt->set_beam_particles(genEvt->beam_particles());
111 if (genEvt->cross_section()) {
112 evt->set_cross_section(*genEvt->cross_section());
116 if (hScatVx !=
nullptr) {
117 HepMC::FourVector pmvxpos=hScatVx->position();
118 genVertex->set_position(pmvxpos);
120 HepMC::GenVertex::particles_in_const_iterator itrp =hScatVx->particles_in_const_begin();
121 if (hScatVx->particles_in_size()==2) {
122 HepMC::FourVector mom1=(*itrp)->momentum();
123 HepMC::FourVector mom2=(*(++itrp))->momentum();
124 double sum = mom1.e()+mom2.e();
125 genPart->set_momentum(HepMC::FourVector(sum,0,0,sum));
134 if (!inputCollectionH.
isValid()) {
135 ATH_MSG_ERROR(
"Could not get input hits collection " << inputCollectionH.
name() <<
" from store " << inputCollectionH.
store());
136 return StatusCode::FAILURE;
138 ATH_MSG_DEBUG(
"Found input hits collection " << inputCollectionH.
name() <<
" in store " << inputCollectionH.
store());
142 int pdgID = hit.GetParticleEncoding();
150 const HepMC::FourVector &position = vx->position();
152 newVertex->add_particle_out(newParticle);
153 evt->add_vertex(std::move(newVertex));
161 evt->add_vertex(std::move(genVertex));
168 outputCollection->push_back(evt);
170 return StatusCode::SUCCESS;
a link optimized in size for a GenParticle in a McEventCollection
HepMC::ConstGenParticlePtr cptr() const
Dereference.
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)