31 , m_metaStore(
"MetaDataStore",
n )
33 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 key provided for the new truth particle collection");
53 return StatusCode::FAILURE;
54 }
else {
ATH_MSG_INFO(
"New truth particle collection key: " << m_collectionName.key() );}
55 ATH_CHECK( m_collectionName.initialize());
58 m_originDecoratorKey = m_collectionName.key() +
".classifierParticleOrigin";
59 ATH_CHECK(m_originDecoratorKey.initialize());
60 m_typeDecoratorKey = m_collectionName.key() +
".classifierParticleType";
61 ATH_CHECK(m_typeDecoratorKey.initialize());
62 m_outcomeDecoratorKey = m_collectionName.key() +
".classifierParticleOutCome";
63 ATH_CHECK(m_outcomeDecoratorKey.initialize());
64 m_classificationDecoratorKey = m_collectionName.key() +
".Classification";
65 ATH_CHECK(m_classificationDecoratorKey.initialize());
70 return StatusCode::SUCCESS;
77 const EventContext& ctx = Gaudi::Hive::currentContext();
80 static const bool is_sherpa = [
this]() {
81 bool is_sherpa =
false;
91 if (m_metaStore->retrieve(truthMetaData).isSuccess() && !truthMetaData->
empty()){
93 const std::string gens = truthMetaData->
at(0)->generators();
94 is_sherpa = (gens.find(
"sherpa")==std::string::npos &&
95 gens.find(
"Sherpa")==std::string::npos &&
96 gens.find(
"SHERPA")==std::string::npos) ?
false :
true;
99 ATH_MSG_WARNING(
"Found xAODTruthMetaDataContainer empty! Configuring to be NOT Sherpa.");
101 ATH_MSG_INFO(
"From metadata configured: Sherpa? " << is_sherpa);
104 ATH_MSG_WARNING(
"Could not find metadata container in storegate; assuming NOT Sherpa");
111 if (!truthParticles.
isValid()) {
112 ATH_MSG_ERROR(
"Couldn't retrieve TruthParticle collection with name " << m_particlesKey);
113 return StatusCode::FAILURE;
118 ATH_CHECK(newParticlesWriteHandle.
record(std::make_unique<xAOD::TruthParticleContainer>(),
119 std::make_unique<xAOD::TruthParticleAuxContainer>()));
120 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;
143 if (theParticle->
status() != 11)
continue;
155 sherpLepParentUniqueID = cparentUniqueID;
160 if (sherpLepParentUniqueID > 0 && sherpLepParentUniqueID == puniqueID)
continue;
161 }
else if (is_sherpa == 0) {
163 bool has_status_n3=
false, has_status_3=
false, has_V=
false;
187 if ( !(has_status_3 && has_status_n3 && has_V && !
MC::isPhysical(theParticle)) &&
188 theParticle->
status()!=23){
190 if (!theParticle->
parent())
continue;
192 if (!hasBareDescendent( theParticle ) )
continue;
198 newParticlesWriteHandle->
push_back( xTruthParticle );
200 *xTruthParticle=*theParticle;
202 typeDecorator(*xTruthParticle) = classifierParticleTypeAcc.
withDefault(*theParticle, 0);
203 originDecorator(*xTruthParticle) = classifierParticleOriginAcc.
withDefault(*theParticle, 0);
204 outcomeDecorator(*xTruthParticle) = classifierParticleOutComeAcc.
withDefault(*theParticle, 0);
205 classificationDecorator(*xTruthParticle) = ClassificationAcc.
withDefault(*theParticle, 0);
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;