34 declareInterface<DerivationFramework::IAugmentationTool>(
this);
48 ATH_MSG_INFO(
"Using " << m_particlesKey.key() <<
" as the input truth container key");
51 if (m_collectionName.empty()) {
52 ATH_MSG_FATAL(
"No base name provided for the new truth particle/vertex containers");
53 return StatusCode::FAILURE;
54 }
else {
ATH_MSG_INFO(
"Base name for new truth particle/vertex containers: " << m_collectionName );}
55 m_outputParticlesKey = m_collectionName +
"Particles";
56 ATH_CHECK(m_outputParticlesKey.initialize());
57 ATH_MSG_INFO(
"New truth particles container key: " << m_outputParticlesKey.key() );
58 m_outputVerticesKey = m_collectionName +
"Vertices";
59 ATH_CHECK(m_outputVerticesKey.initialize());
60 ATH_MSG_INFO(
"New truth vertices container key: " << m_outputVerticesKey.key() );
62 if (m_pdgIdsToKeep.empty() && !m_keepBHadrons && !m_keepCHadrons && !m_keepBSM) {
63 ATH_MSG_FATAL(
"No PDG IDs provided, not keeping b- or c-hadrons or BSM particles -- what do you want?");
64 return StatusCode::FAILURE;
68 m_originDecoratorKey = m_outputParticlesKey.key()+
".classifierParticleOrigin";
69 ATH_CHECK(m_originDecoratorKey.initialize());
70 m_typeDecoratorKey = m_outputParticlesKey.key()+
".classifierParticleType";
71 ATH_CHECK(m_typeDecoratorKey.initialize());
72 m_outcomeDecoratorKey = m_outputParticlesKey.key()+
".classifierParticleOutCome";
73 ATH_CHECK(m_outcomeDecoratorKey.initialize());
74 m_classificationDecoratorKey = m_outputParticlesKey.key()+
".Classification";
75 ATH_CHECK(m_classificationDecoratorKey.initialize());
76 m_motherIDDecoratorKey = m_outputParticlesKey.key()+
".motherID";
77 ATH_CHECK(m_motherIDDecoratorKey.initialize());
78 m_daughterIDDecoratorKey = m_outputParticlesKey.key()+
".daughterID";
79 ATH_CHECK(m_daughterIDDecoratorKey.initialize());
81 return StatusCode::SUCCESS;
89 const EventContext& ctx = Gaudi::Hive::currentContext();
93 if (!truthParticles.
isValid()) {
94 ATH_MSG_ERROR(
"Couldn't retrieve TruthParticle collection with name " << m_particlesKey);
95 return StatusCode::FAILURE;
100 ATH_CHECK(newParticlesWriteHandle.
record(std::make_unique<xAOD::TruthParticleContainer>(),
101 std::make_unique<xAOD::TruthParticleAuxContainer>()));
102 ATH_MSG_DEBUG(
"Recorded new TruthParticleContainer with key: " << (m_outputParticlesKey.key()));
105 ATH_CHECK(newVerticesWriteHandle.
record(std::make_unique<xAOD::TruthVertexContainer>(),
106 std::make_unique<xAOD::TruthVertexAuxContainer>()));
107 ATH_MSG_DEBUG(
"Recorded new TruthVertexContainer with key: " << (m_outputVerticesKey.key()));
112 std::vector<int> seen_particles;
114 for (
const auto *
part : *truthParticles){
117 addTruthParticle( ctx, *
part, newParticlesWriteHandle.
ptr(), newVerticesWriteHandle.
ptr(), seen_particles , m_generations );
120 return StatusCode::SUCCESS;
127 std::vector<int>& seen_particles,
131 for (
size_t p=0;
p<part_cont->
size();++
p){
153 xTruthParticle->
setM(old_part.
m());
154 xTruthParticle->
setPx(old_part.
px());
155 xTruthParticle->
setPy(old_part.
py());
156 xTruthParticle->
setPz(old_part.
pz());
157 xTruthParticle->
setE(old_part.
e());
164 int my_index = part_cont->
size()-1;
168 int vert_index = addTruthVertex( ctx, *old_part.
decayVtx(), part_cont, vert_cont, seen_particles,
generations);
171 (*vert_cont)[vert_index]->addIncomingParticleLink( eltp );
179 typeDecorator(*xTruthParticle) = classifierParticleTypeAcc.
withDefault (old_part, 0);
180 originDecorator(*xTruthParticle) = classifierParticleOriginAcc.
withDefault (old_part, 0);
181 outcomeDecorator(*xTruthParticle) = classifierParticleOutComeAcc.
withDefault (old_part, 0);
182 classificationDecorator(*xTruthParticle) = ClassificationAcc.
withDefault (old_part, 0);
192 std::vector<int>& seen_particles,
198 int my_index = vert_cont->
size()-1;
203 xTruthVertex->
setX(old_vert.
x());
204 xTruthVertex->
setY(old_vert.
y());
205 xTruthVertex->
setZ(old_vert.
z());
206 xTruthVertex->
setT(old_vert.
t());
216 int part_index = addTruthParticle( ctx, *old_vert.
outgoingParticle(
n), part_cont, vert_cont, seen_particles,
220 (*part_cont)[part_index]->setProdVtxLink( eltv );
229 for (
int id : m_pdgIdsToKeep){
230 if (
part.absPdgId()==
id){
235 return (m_keepBHadrons &&
part.isBottomHadron()) ||
237 (m_keepCHadrons &&
part.isCharmHadron()) ||
239 (m_keepBSM &&
part.isBSM());