Skip to content

Commit

Permalink
Get particle spin/helicity from attribute 'spin', if any (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
gganis authored Aug 18, 2022
1 parent a270867 commit 75a7a53
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions k4Gen/src/components/HepMCToEDMConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "GaudiKernel/PhysicalConstants.h"
#include "edm4hep/MCParticleCollection.h"
#include "HepPDT/ParticleID.hh"
#include "HepMC3/Attribute.h"

DECLARE_COMPONENT(HepMCToEDMConverter)

Expand All @@ -17,6 +18,13 @@ edm4hep::MutableMCParticle HepMCToEDMConverter::convert(std::shared_ptr<const He
auto p = hepmcParticle->momentum();
edm_particle.setMomentum( {float(p.px()), float(p.py()), float(p.pz())} );

// add spin (particle helicity) information if available
std::shared_ptr<HepMC3::VectorFloatAttribute> spin = hepmcParticle->attribute<HepMC3::VectorFloatAttribute>("spin");
if (spin) {
edm4hep::Vector3f hel(spin->value()[0], spin->value()[1], spin->value()[2]);
edm_particle.setSpin(hel);
}

// convert vertex info
auto prodVtx = hepmcParticle->production_vertex();

Expand Down

0 comments on commit 75a7a53

Please sign in to comment.