|
ATLAS Offline Software
|
Go to the documentation of this file.
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;
154 sherpLepParentUniqueID = cparentUniqueID;
159 if (sherpLepParentUniqueID > 0 && sherpLepParentUniqueID == puniqueID)
continue;
160 }
else if (is_sherpa == 0) {
162 bool physical=
false,has_V=
false;
187 if (!theParticle->
parent())
continue;
189 if (!hasBareDescendent( theParticle ) )
continue;
195 newParticlesWriteHandle->
push_back( xTruthParticle );
197 *xTruthParticle=*theParticle;
199 typeDecorator(*xTruthParticle) = classifierParticleTypeAcc.
withDefault(*theParticle, 0);
200 originDecorator(*xTruthParticle) = classifierParticleOriginAcc.
withDefault(*theParticle, 0);
201 outcomeDecorator(*xTruthParticle) = classifierParticleOutComeAcc.
withDefault(*theParticle, 0);
202 classificationDecorator(*xTruthParticle) = ClassificationAcc.
withDefault(*theParticle, 0);
205 return StatusCode::SUCCESS;
212 if (!
p)
return false;
216 for (
size_t c=0;
c<
p->nChildren();++
c){
217 if (!
p->child(
c))
continue;
218 if (
p->pdgId()!=
p->child(
c)->pdgId())
continue;
219 if (hasBareDescendent(
p->child(
c) ))
return true;
size_t nOutgoingParticles() const
Get the number of outgoing particles.
const TruthParticle_v1 * parent(size_t i=0) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
TruthBornLeptonCollectionMaker(const std::string &t, const std::string &n, const IInterface *p)
virtual StatusCode addBranches() const
Pass the thinning service
bool isW() const
Check if this particle is a W boson.
#define ATH_MSG_VERBOSE(x)
bool isZ() const
Check if this particle is a Z boson.
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.
Handle class for recording to StoreGate.
bool isLepton() const
Whether the particle is a lepton.
::StatusCode StatusCode
StatusCode definition for legacy code.
Class describing a truth particle in the MC record.
Handle class for adding a decoration to an object.
Handle class for adding a decoration to an object.
TruthParticle_v1 TruthParticle
Typedef to implementation.
bool hasProdVtx() const
Check for a production vertex on this particle.
const TruthParticle_v1 * incomingParticle(size_t index) const
Get one of the incoming particles.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
constexpr int UNDEFINED_ID
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
Class describing a truth vertex in the MC record.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
bool isHiggs() const
Check if this particle is a Higgs boson.
#define ATH_MSG_WARNING(x)
size_t nIncomingParticles() const
Get the number of incoming particles.
const TruthParticle_v1 * child(size_t i=0) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
bool hasBareDescendent(const xAOD::TruthParticle *p) const
Helper function for finding bare descendents of born leptons.
bool isConditionB(const T &p)
ServiceHandle< StoreGateSvc > m_metaStore
Handle on the metadata store for init.
const T * at(size_type n) const
Access an element, as an rvalue.
Helper class to provide constant type-safe access to aux data.
Handle class for reading from StoreGate.
~TruthBornLeptonCollectionMaker()
size_type size() const noexcept
Returns the number of elements in the collection.
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
bool empty() const noexcept
Returns true if the collection is empty.
const_reference_type withDefault(const ELT &e, const T &deflt) const
Fetch the variable for one element, as a const reference, with a default.