32 , m_metaStore(
"MetaDataStore",
n )
48 ATH_MSG_INFO(
"Using " << m_particlesKey.key() <<
" as the input truth container key");
51 ATH_CHECK(m_originAccessorKey.initialize());
52 ATH_CHECK(m_typeAccessorKey.initialize());
53 ATH_CHECK(m_outcomeAccessorKey.initialize());
54 ATH_CHECK(m_classificationAccessorKey.initialize());
57 if (m_collectionName.empty()) {
58 ATH_MSG_FATAL(
"No key provided for the new truth particle collection");
59 return StatusCode::FAILURE;
60 }
else {
ATH_MSG_INFO(
"New truth particle collection key: " << m_collectionName.key() );}
61 ATH_CHECK( m_collectionName.initialize());
64 ATH_CHECK(m_originDecoratorKey.initialize());
65 ATH_CHECK(m_typeDecoratorKey.initialize());
66 ATH_CHECK(m_outcomeDecoratorKey.initialize());
67 ATH_CHECK(m_classificationDecoratorKey.initialize());
72 return StatusCode::SUCCESS;
81 static const bool is_sherpa = [
this]() {
82 bool is_sherpa =
false;
92 if (m_metaStore->retrieve(truthMetaData).isSuccess() && !truthMetaData->
empty()){
94 const std::string gens = truthMetaData->
at(0)->generators();
95 is_sherpa = (gens.find(
"sherpa")==std::string::npos &&
96 gens.find(
"Sherpa")==std::string::npos &&
97 gens.find(
"SHERPA")==std::string::npos) ?
false :
true;
100 ATH_MSG_WARNING(
"Found xAODTruthMetaDataContainer empty! Configuring to be NOT Sherpa.");
102 ATH_MSG_INFO(
"From metadata configured: Sherpa? " << is_sherpa);
105 ATH_MSG_WARNING(
"Could not find metadata container in storegate; assuming NOT Sherpa");
112 if (!truthParticles.
isValid()) {
113 ATH_MSG_ERROR(
"Couldn't retrieve TruthParticle collection with name " << m_particlesKey);
114 return StatusCode::FAILURE;
119 ATH_CHECK(newParticlesWriteHandle.
record(std::make_unique<xAOD::TruthParticleContainer>(),
120 std::make_unique<xAOD::TruthParticleAuxContainer>()));
121 ATH_MSG_DEBUG(
"Recorded new TruthParticleContainer with key: " << (m_collectionName.key()));
135 for (
unsigned int i=0;
i<truthParticles->
size(); ++
i) {
138 if (!theParticle)
continue;
139 if (!theParticle->
isLepton())
continue;
148 bool has_parent_of_same_flavour =
false;
150 for (
size_t p = 0;
p < theParticle->
prodVtx()->nIncomingParticles(); ++
p){
151 if (theParticle->
parent(
p)->
pdg_id() == theParticle->
pdg_id()) has_parent_of_same_flavour =
true;
153 if (has_parent_of_same_flavour)
continue;
156 bool physical =
false, has_V =
false;
182 if (!hasBareDescendent( theParticle ) )
continue;
186 size_t bad_parent = 0;
188 if (!theParticle->
parent(
p)) { bad_parent++;
continue;}
191 if (bad_parent != 0)
continue;
198 newParticlesWriteHandle->
push_back( xTruthParticle );
200 *xTruthParticle=*theParticle;
202 typeDecorator(*xTruthParticle) = typeAccessor(*theParticle);
203 originDecorator(*xTruthParticle) = originAccessor(*theParticle);
204 outcomeDecorator(*xTruthParticle) = outcomeAccessor(*theParticle);
205 classificationDecorator(*xTruthParticle) = classificationAccessor(*theParticle);
208 return StatusCode::SUCCESS;
215 if (!
p)
return false;
219 for (
size_t c=0;
c<
p->nChildren();++
c){
220 if (!
p->child(
c))
continue;
221 if (
p->pdgId()!=
p->child(
c)->pdgId())
continue;
222 if (hasBareDescendent(
p->child(
c) ))
return true;