|
ATLAS Offline Software
|
Go to the documentation of this file.
24 const std::string&
name, ISvcLocator* loc )
54 return StatusCode::SUCCESS;
65 ATH_MSG_DEBUG(
"Retrieved " << truth_particles->size() <<
" truth_particles..." );
71 if (truth_PVs->
size() != 1) {
73 return StatusCode::FAILURE;
86 std::vector<const xAOD::TruthParticle*> sorted_truth_particles;
87 for (
const auto tp : *truth_particles) { sorted_truth_particles.push_back(
tp); }
91 auto tp_truth_vertices = std::vector<const xAOD::TruthVertex*>();
92 for (
const auto& truth_particle : sorted_truth_particles ) {
96 if ( (!
MC::isStable(truth_particle) or truth_particle->pt() < 500) and !truth_particle->isCharmHadron()) {
100 tp_truth_vertices.push_back(
nullptr);
101 dec_vertex_index(*truth_particle) = -1;
114 dec_origin_label(*truth_particle) = truth_origin_label;
117 dec_source_label(*truth_particle) = truth_source_label;
122 tp_truth_vertices.push_back(truth_vertex);
129 if ( sorted_truth_particles.size() != tp_truth_vertices.size() ) {
130 ATH_MSG_ERROR(
"sorted_truth_particles and tp_truth_vertices have different lengths" );
131 return StatusCode::FAILURE;
135 auto seen_vertices = std::vector<const xAOD::TruthVertex*>();
136 for (
size_t i = 0;
i != tp_truth_vertices.size();
i++) {
137 auto this_vert = tp_truth_vertices.at(
i);
138 auto this_tp = sorted_truth_particles.at(
i);
141 return StatusCode::SUCCESS;
This file contains "getter" functions used for accessing tagger inputs from the EDM.
const xAOD::TruthParticle * get_parent_hadron(const xAOD::TruthParticle *truth_particle, bool user_called=true, int depth=0)
virtual StatusCode execute(const EventContext &) const override
int get_source_type(const int origin)
ToolHandle< InDet::InDetTrackTruthOriginTool > m_truthOriginTool
const std::string & key() const
Return the StoreGate ID for the referenced object.
SG::ReadHandleKey< xAOD::TruthVertexContainer > m_TruthPVsKey
An algorithm that can be simultaneously executed in multiple threads.
::StatusCode StatusCode
StatusCode definition for legacy code.
Handle class for adding a decoration to an object.
const xAOD::TruthVertex * get_truth_vertex(const xAOD::TruthParticle *truth)
Handle class for adding a decoration to an object.
Gaudi::Property< float > m_truthVertexMergeDistance
#define CHECK(...)
Evaluate an expression and check for errors.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
constexpr int UNDEFINED_ID
int get_vertex_index(const xAOD::TruthVertex *vertex, const xAOD::TruthVertex *truth_PV, std::vector< const xAOD::TruthVertex * > &seen_vertices, const float truthVertexMergeDistance)
Class describing a truth vertex in the MC record.
TruthParticleDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_dec_source_label
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_TruthContainerKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_dec_type_label
bool sort_particles(const xAOD::IParticle *particle_A, const xAOD::IParticle *particle_B)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_dec_vertex_index
int getExclusiveOrigin(int origin)
virtual StatusCode initialize() override
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_dec_origin_label
Handle class for reading a decoration on an object.
const T * at(size_type n) const
Access an element, as an rvalue.
int get_truth_type(const xAOD::TruthParticle *truth_particle)
size_type size() const noexcept
Returns the number of elements in the collection.
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_dec_parent_barcode