 |
ATLAS Offline Software
|
Go to the documentation of this file.
31 , m_metaStore(
"MetaDataStore",
n )
47 ATH_MSG_INFO(
"Using " << m_particlesKey.key() <<
" as the input truth container key");
50 if (m_collectionName.empty()) {
51 ATH_MSG_FATAL(
"No key provided for the new truth particle collection");
52 return StatusCode::FAILURE;
53 }
else {
ATH_MSG_INFO(
"New truth particle collection key: " << m_collectionName.key() );}
54 ATH_CHECK( m_collectionName.initialize());
57 m_originDecoratorKey = m_collectionName.key() +
".classifierParticleOrigin";
58 ATH_CHECK(m_originDecoratorKey.initialize());
59 m_typeDecoratorKey = m_collectionName.key() +
".classifierParticleType";
60 ATH_CHECK(m_typeDecoratorKey.initialize());
61 m_outcomeDecoratorKey = m_collectionName.key() +
".classifierParticleOutCome";
62 ATH_CHECK(m_outcomeDecoratorKey.initialize());
63 m_classificationDecoratorKey = m_collectionName.key() +
".Classification";
64 ATH_CHECK(m_classificationDecoratorKey.initialize());
69 return StatusCode::SUCCESS;
76 const EventContext& ctx = Gaudi::Hive::currentContext();
79 static const bool is_sherpa = [
this]() {
80 bool is_sherpa =
false;
90 if (m_metaStore->retrieve(truthMetaData).isSuccess() && !truthMetaData->
empty()){
92 const std::string gens = truthMetaData->
at(0)->generators();
93 is_sherpa = (gens.find(
"sherpa")==std::string::npos &&
94 gens.find(
"Sherpa")==std::string::npos &&
95 gens.find(
"SHERPA")==std::string::npos) ?
false :
true;
98 ATH_MSG_WARNING(
"Found xAODTruthMetaDataContainer empty! Configuring to be NOT Sherpa.");
100 ATH_MSG_INFO(
"From metadata configured: Sherpa? " << is_sherpa);
103 ATH_MSG_WARNING(
"Could not find metadata container in storegate; assuming NOT Sherpa");
110 if (!truthParticles.
isValid()) {
111 ATH_MSG_ERROR(
"Couldn't retrieve TruthParticle collection with name " << m_particlesKey);
112 return StatusCode::FAILURE;
117 ATH_CHECK(newParticlesWriteHandle.
record(std::make_unique<xAOD::TruthParticleContainer>(),
118 std::make_unique<xAOD::TruthParticleAuxContainer>()));
119 ATH_MSG_DEBUG(
"Recorded new TruthParticleContainer with key: " << (m_collectionName.key()));
133 for (
unsigned int i=0;
i<truthParticles->
size(); ++
i) {
136 if (!theParticle)
continue;
137 if (!theParticle->
isLepton())
continue;
146 bool has_parent_of_same_flavour =
false;
148 for (
size_t p = 0;
p < theParticle->
prodVtx()->nIncomingParticles(); ++
p){
149 if (theParticle->
parent(
p)->
pdg_id() == theParticle->
pdg_id()) has_parent_of_same_flavour =
true;
151 if (has_parent_of_same_flavour)
continue;
154 bool physical =
false, has_V =
false;
180 if (!hasBareDescendent( theParticle ) )
continue;
184 size_t bad_parent = 0;
186 if (!theParticle->
parent(
p)) { bad_parent++;
continue;}
189 if (bad_parent != 0)
continue;
196 newParticlesWriteHandle->
push_back( xTruthParticle );
198 *xTruthParticle=*theParticle;
200 typeDecorator(*xTruthParticle) = classifierParticleTypeAcc.
withDefault(*theParticle, 0);
201 originDecorator(*xTruthParticle) = classifierParticleOriginAcc.
withDefault(*theParticle, 0);
202 outcomeDecorator(*xTruthParticle) = classifierParticleOutComeAcc.
withDefault(*theParticle, 0);
203 classificationDecorator(*xTruthParticle) = ClassificationAcc.
withDefault(*theParticle, 0);
206 return StatusCode::SUCCESS;
213 if (!
p)
return false;
217 for (
size_t c=0;
c<
p->nChildren();++
c){
218 if (!
p->child(
c))
continue;
219 if (
p->pdgId()!=
p->child(
c)->pdgId())
continue;
220 if (hasBareDescendent(
p->child(
c) ))
return true;
size_t nOutgoingParticles() const
Get the number of outgoing particles.
TruthBornLeptonCollectionMaker(const std::string &t, const std::string &n, const IInterface *p)
virtual StatusCode addBranches() const
bool isW() const
Check if this particle is a W boson.
#define ATH_MSG_VERBOSE(x)
int pdg_id() const
PDG ID code.
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?
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.
bool hasBareDescendent(const xAOD::TruthParticle *p) const
Helper function for finding bare descendents of born leptons.
const TruthParticle_v1 * parent(size_t i) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
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.