20 const IInterface*
p ) :
23 declareInterface<DerivationFramework::IAugmentationTool>(
this);
35 ATH_CHECK( m_truthEventKey.initialize() );
39 for (
auto key : m_inputKeys) {
40 m_parentLinksDecorKeys.emplace_back(
key.key()+
".parentLinks");
41 m_childLinksDecorKeys.emplace_back(
key.key()+
".childLinks");
44 ATH_CHECK( m_parentLinksDecorKeys.initialize() );
45 ATH_CHECK( m_childLinksDecorKeys.initialize() );
47 return StatusCode::SUCCESS;
55 const EventContext& ctx = Gaudi::Hive::currentContext();
60 ATH_MSG_ERROR(
"Couldn't retrieve TruthEvent collection with name " << m_truthEventKey);
61 return StatusCode::FAILURE;
65 std::vector<SG::ReadHandle<xAOD::TruthParticleContainer> > inputParticles;
66 inputParticles.reserve(m_inputKeys.size());
72 std::map<int,ElementLink<xAOD::TruthParticleContainer> > linkMap;
73 for (
auto& coll : inputParticles){
74 for (
size_t p=0;
p<coll.ptr()->
size();++
p){
75 if (!coll.ptr()->at(
p))
continue;
76 if (linkMap.find(
HepMC::uniqueID(coll.ptr()->at(
p))) != linkMap.end())
continue;
88 std::map< int , std::vector<ElementLink<xAOD::TruthParticleContainer> > > parentMap;
89 std::map< int , std::vector<ElementLink<xAOD::TruthParticleContainer> > > childMap;
92 std::vector<int> seen_particles(20);
95 for (
size_t p=0;
p<
event->nTruthParticles();++
p){
96 if (!
event->truthParticle(
p))
continue;
99 std::vector<ElementLink<xAOD::TruthParticleContainer> >
parents;
100 std::vector<ElementLink<xAOD::TruthParticleContainer> >
children;
102 seen_particles.clear();
103 find_parents(
event->truthParticle(
p) ,
parents , linkMap , seen_particles );
104 seen_particles.clear();
105 find_children(
event->truthParticle(
p) ,
children , linkMap , seen_particles );
112 auto parent_decorator = m_parentLinksDecorKeys.makeHandles (ctx);
113 auto child_decorator = m_childLinksDecorKeys.makeHandles (ctx);
114 unsigned int pCntr{0};
115 for (
auto coll : inputParticles){
116 if (parent_decorator.at(pCntr).isAvailable()) {
120 for (
size_t p=0;
p<coll.ptr()->
size();++
p){
121 if (!coll.ptr()->at(
p))
continue;
122 parent_decorator.at(pCntr)(*coll.ptr()->at(
p)) = parentMap[
HepMC::uniqueID(coll->at(
p)) ];
123 child_decorator.at(pCntr)(*coll.ptr()->at(
p)) = childMap[
HepMC::uniqueID(coll->at(
p)) ];
128 return StatusCode::SUCCESS;
134 std::vector<int>& seen_particles )
const {
156 std::vector<int>& seen_particles )
const {
163 for (
size_t child=0;child<
part->nChildren();++child){
164 if (!
part->child(child))
continue;
170 find_children(
part->child(child) ,
children , linkMap , seen_particles );