51 ATH_MSG_FATAL(
"No PDG IDs provided, not keeping b- or c-hadrons or BSM particles -- what do you want?");
52 return StatusCode::FAILURE;
63 return StatusCode::SUCCESS;
74 if (!truthParticles.
isValid()) {
76 return StatusCode::FAILURE;
81 ATH_CHECK(newParticlesWriteHandle.
record(std::make_unique<xAOD::TruthParticleContainer>(),
82 std::make_unique<xAOD::TruthParticleAuxContainer>()));
86 ATH_CHECK(newVerticesWriteHandle.
record(std::make_unique<xAOD::TruthVertexContainer>(),
87 std::make_unique<xAOD::TruthVertexAuxContainer>()));
93 std::vector<int> seen_particles;
95 for (
const auto * part : *truthParticles){
101 return StatusCode::SUCCESS;
108 std::vector<int>& seen_particles,
109 const int generations)
const {
111 if (std::find(seen_particles.begin(),seen_particles.end(),
HepMC::uniqueID(&old_part))!=seen_particles.end()){
112 for (
size_t p=0;p<part_cont->
size();++p){
134 xTruthParticle->
setM(old_part.
m());
135 xTruthParticle->
setPx(old_part.
px());
136 xTruthParticle->
setPy(old_part.
py());
137 xTruthParticle->
setPz(old_part.
pz());
138 xTruthParticle->
setE(old_part.
e());
145 int my_index = part_cont->
size()-1;
149 int vert_index =
addTruthVertex( ctx, *old_part.
decayVtx(), part_cont, vert_cont, seen_particles, generations);
152 (*vert_cont)[vert_index]->addIncomingParticleLink( eltp );
160 typeDecorator(*xTruthParticle) = classifierParticleTypeAcc(old_part);
161 originDecorator(*xTruthParticle) = classifierParticleOriginAcc(old_part);
162 outcomeDecorator(*xTruthParticle) = classifierParticleOutcomeAcc(old_part);
163 classificationDecorator(*xTruthParticle) = ClassificationAcc(old_part);
173 std::vector<int>& seen_particles,
174 const int generations)
const {
179 int my_index = vert_cont->
size()-1;
184 xTruthVertex->
setX(old_vert.
x());
185 xTruthVertex->
setY(old_vert.
y());
186 xTruthVertex->
setZ(old_vert.
z());
187 xTruthVertex->
setT(old_vert.
t());
189 if (generations==0)
return my_index;
201 (*part_cont)[part_index]->setProdVtxLink( eltv );
211 if (part.absPdgId()==
id){
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Helper class to provide constant type-safe access to aux data.
ATLAS-specific HepMC functions.
Handle class for reading a decoration on an object.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Handle class for recording to StoreGate.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_daughterIDDecoratorKey
SG::WriteHandleKey< xAOD::TruthVertexContainer > m_outputVerticesKey
virtual StatusCode addBranches(const EventContext &ctx) const override final
Gaudi::Property< bool > m_keepCHadrons
< Option to keep all c-hadrons (better than giving PDG IDs)
Gaudi::Property< std::vector< int > > m_pdgIdsToKeep
< List of PDG IDs to build this collection from
int addTruthVertex(const EventContext &, const xAOD::TruthVertex &old_vert, xAOD::TruthParticleContainer *part_cont, xAOD::TruthVertexContainer *vert_cont, std::vector< int > &seen_particles, const int generations=-1) const
Gaudi::Property< bool > m_rejectHadronChildren
< Option to reject hadron descendants
Gaudi::Property< int > m_generations
^^^^ These should be replaced by SG::Accessor.
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_outputParticlesKey
int addTruthParticle(const EventContext &ctx, const xAOD::TruthParticle &old_part, xAOD::TruthParticleContainer *part_cont, xAOD::TruthVertexContainer *vert_cont, std::vector< int > &seen_particles, const int generations=-1) const
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_outcomeDecoratorKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_outcomeAccessorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_motherIDDecoratorKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_classificationAccessorKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_originAccessorKey
Gaudi::Property< bool > m_keepBHadrons
< Option to keep all b-hadrons (better than giving PDG IDs)
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_particlesKey
virtual StatusCode initialize() override final
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_typeAccessorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_typeDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_originDecoratorKey
FIXME Using WriteDecorHandles for decorations on a Container created in the current algorithm is unne...
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_classificationDecoratorKey
bool id_ok(const xAOD::TruthParticle &part) const
Gaudi::Property< bool > m_keepBSM
< Option to keep all BSM particles (better than giving PDG IDs)
ElementLink implementation for ROOT usage.
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
void setPy(float value)
Set the y component of the particle's momentum.
int status() const
Status code.
void setUid(int value)
Set unique ID.
bool isHadron() const
Whether the particle is a hadron.
void setM(float value)
Also store the mass.
virtual double m() const override final
The mass of the particle.
void setE(float value)
Set the energy of the particle.
int pdgId() const
PDG ID code.
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
Polarization polarization() const
Retrieve a full Polarization with a single call.
void setPz(float value)
Set the z component of the particle's momentum.
float px() const
The x component of the particle's momentum.
bool hasDecayVtx() const
Check for a decay vertex on this particle.
virtual double e() const override final
The total energy of the particle.
bool setPolarizationParameter(float value, PolParam parameter)
Set method for polarization parameter values.
void setDecayVtxLink(const ElementLink< TruthVertexContainer > &link)
Set the decay vertex of the particle.
float py() const
The y component of the particle's momentum.
void setStatus(int value)
Set status code.
void setPdgId(int pid)
Set PDG ID code.
void setPx(float value)
Set the x component of the particle's momentum.
bool polarizationParameter(float &value, PolParam parameter) const
Accessor for polarization parameters.
float pz() const
The z component of the particle's momentum.
@ polarizationPhi
Polarization in ( )
@ polarizationTheta
Polarization in ( )
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
void addOutgoingParticleLink(const TPLink_t &link)
Add one outgoing particle.
float z() const
Vertex longitudinal distance along the beam line form the origin.
void setStatus(int value)
Set the vertex status.
void setZ(float value)
Set the vertex's longitudinal distance from the origin.
float y() const
Vertex y displacement.
void setUid(int value)
Set the vertex unique ID.
float t() const
Vertex time.
size_t nOutgoingParticles() const
Get the number of outgoing particles.
void setT(float value)
Set the vertex time.
float x() const
Vertex x displacement.
void setX(float value)
Set the x displacement of the vertex.
void setY(float value)
Set the y displacement of the vertex.
bool is_same_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same particle.
TruthVertex_v1 TruthVertex
Typedef to implementation.
TruthVertexContainer_v1 TruthVertexContainer
Declare the latest version of the truth vertex container.
TruthParticle_v1 TruthParticle
Typedef to implementation.
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
bool valid() const
Check if the stored values are valid.