33 return StatusCode::SUCCESS;
42 auto outputContainer = std::make_unique<xAOD::TruthParticleContainer>();
43 auto outputAuxContainer = std::make_unique<xAOD::AuxContainerBase>();
44 outputContainer->setStore(outputAuxContainer.get());
51 if(!uid.isAvailable()){
53 uid(*input) = barcodeAcc(*input);
58 bool warningPrinted =
false;
62 outputContainer->push_back(output);
67 const int barcode = barcodeAcc(*output);
72 output->setUid(barcode);
73 }
else if (warningPrinted ==
false) {
76 "xAOD::TruthParticle barcode is not available. This algorithm should "
77 "not be run with the current input.");
78 warningPrinted =
true;
88 <<
"\" is not available on "
92 return StatusCode::FAILURE;
94 auto& links = linkAcc(*output);
96 for (
auto& link : links) {
97 link.resetWithKeyAndIndex(
110 <<
"\" is not available on "
114 return StatusCode::FAILURE;
116 auto& links = linkAcc(*output);
118 for (
auto& link : links) {
119 link.resetWithKeyAndIndex(
129 .record(std::move(outputContainer), std::move(outputAuxContainer)));
134 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
Helper class to provide type-safe access to aux data.
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Handle class for adding a decoration to an object.
Gaudi::Property< std::vector< std::string > > m_particleLinks
Names of the truth particle links to fix.
Gaudi::Property< std::string > m_linkPrefixToRemove
Prefix to remove from the link names.
virtual StatusCode initialize() override
Function initialising the algorithm.
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_outputContainerKey
The keys for the output xAOD truth containers.
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_uidKey
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Gaudi::Property< std::vector< std::string > > m_vertexLinks
Names of the truth vertex links to fix.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_inputContainerKey
The keys of the input xAOD truth containers.
int new_particle_status_from_old(const int oldStatus, const int barcode)
Get particle status in the new scheme from the barcode and status in the old scheme.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
std::string removePrefix(std::string_view str, std::string_view prefix)
Remove a prefix from a string, if it exists.
TruthParticle_v1 TruthParticle
Typedef to implementation.