24 const std::string& name, ISvcLocator* loc )
50 return StatusCode::SUCCESS;
61 ATH_MSG_DEBUG(
"Retrieved " << truth_particles->size() <<
" truth_particles..." );
64 ATH_MSG_DEBUG(
"Retrieved " << truth_PVs->size() <<
" truth PVs..." );
67 if (truth_PVs->size() != 1) {
69 return StatusCode::FAILURE;
82 std::vector<const xAOD::TruthParticle*> sorted_truth_particles;
83 for (
const auto tp : *truth_particles) { sorted_truth_particles.push_back(tp); }
87 auto tp_truth_vertices = std::vector<const xAOD::TruthVertex*>();
88 for (
const auto& truth_particle : sorted_truth_particles ) {
92 if ( (!
MC::isStable(truth_particle) or truth_particle->pt() < 500) and !truth_particle->isCharmHadron()) {
94 dec_type_label(*truth_particle) = TruthDecoratorHelpers::TruthType::Label::NoTruth;
95 dec_source_label(*truth_particle) = TruthDecoratorHelpers::TruthSource::Label::NoTruth;
96 tp_truth_vertices.push_back(
nullptr);
97 dec_vertex_index(*truth_particle) = -1;
111 dec_origin_label(*truth_particle) = truth_origin_label;
114 dec_source_label(*truth_particle) = truth_source_label;
119 tp_truth_vertices.push_back(truth_vertex);
126 if ( sorted_truth_particles.size() != tp_truth_vertices.size() ) {
127 ATH_MSG_ERROR(
"sorted_truth_particles and tp_truth_vertices have different lengths" );
128 return StatusCode::FAILURE;
132 auto seen_vertices = std::vector<const xAOD::TruthVertex*>();
133 for (
size_t i = 0; i != tp_truth_vertices.size(); i++) {
134 auto this_vert = tp_truth_vertices.at(i);
135 auto this_tp = sorted_truth_particles.at(i);
138 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define CHECK(...)
Evaluate an expression and check for errors.
ATLAS-specific HepMC functions.
Handle class for reading a decoration on an object.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
ToolHandle< InDet::InDetTrackTruthOriginTool > m_truthOriginTool
Gaudi::Property< bool > m_use_barcode
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_dec_origin_label
SG::ReadHandleKey< xAOD::TruthVertexContainer > m_TruthPVsKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_dec_parent_uniqueID
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_dec_type_label
Gaudi::Property< float > m_truthVertexMergeDistance
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_TruthContainerKey
virtual StatusCode execute(const EventContext &) const override
virtual StatusCode initialize() override
SG::ConstAccessor< int > m_uid
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_dec_source_label
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_dec_vertex_index
TruthParticleDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Helper class to provide constant type-safe access to aux data.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
const xAOD::TruthVertex * get_truth_vertex(const xAOD::TruthParticle *truth)
int get_source_type(const int origin)
const xAOD::TruthParticle * get_parent_hadron(const xAOD::TruthParticle *truth_particle, bool user_called=true, int depth=0)
int get_truth_type(const xAOD::TruthParticle *truth_particle)
int get_vertex_index(const xAOD::TruthVertex *vertex, const xAOD::TruthVertex *truth_PV, std::vector< const xAOD::TruthVertex * > &seen_vertices, const float truthVertexMergeDistance)
bool sort_particles(const xAOD::IParticle *particle_A, const xAOD::IParticle *particle_B)
constexpr int UNDEFINED_ID
int getExclusiveOrigin(int origin)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
TruthVertex_v1 TruthVertex
Typedef to implementation.
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.