|
ATLAS Offline Software
|
Go to the documentation of this file.
30 for (
unsigned int i = 0;
43 for (
auto egammaTruth : egammaTruthContainer) {
58 ISvcLocator* pSvcLocator)
102 return StatusCode::SUCCESS;
108 return StatusCode::SUCCESS;
122 std::make_unique<xAOD::TruthParticleContainer>(),
123 std::make_unique<xAOD::TruthParticleAuxContainer>()));
130 if (!truthEvtContainer.
isValid() || truthEvtContainer->
empty()) {
133 <<
" or container empty, returning");
134 return StatusCode::SUCCESS;
137 for (
const auto& truthParticleLink :
138 truthEvtContainer->
front()->truthParticleLinks()) {
139 if (!truthParticleLink.isValid())
145 *egammaTruthContainer,
147 truthParticleLink.getDataPtr());
172 egammaTruthContainer.
ptr()));
181 egammaTruthContainer.
ptr()));
190 egammaTruthContainer.
ptr()));
199 egammaTruthContainer.
ptr()));
202 return StatusCode::SUCCESS;
207 const EventContext& ctx,
211 if ((truth->
pdgId() != 22 && abs(truth->
pdgId()) != 11) ||
220 if (
type.first == MCTruthPartClassifier::IsoElectron ||
237 const EventContext& ctx,
242 auto *truthParticle = egammaTruthContainer.
push_back(std::make_unique<xAOD::TruthParticle>());
243 truthParticle->setPdgId(truth->
pdgId());
245 truthParticle->setStatus(truth->
status());
246 truthParticle->setPx(truth->
px());
247 truthParticle->setPy(truth->
py());
248 truthParticle->setPz(truth->
pz());
249 truthParticle->setE(truth->
e());
250 truthParticle->setM(truth->
m());
251 truthParticle->setProdVtxLink(truth->
prodVtxLink());
261 "truthParticleLink");
270 accTruthLink(*truthParticle) =
TruthLink_t(truth, *oldContainer, ctx);
271 accTruthLink(*truthParticle).toPersistent();
275 accType(*truthParticle) =
static_cast<int>(
info.first);
276 accOrigin(*truthParticle) =
static_cast<int>(
info.second);
284 const std::string&
name)
287 ATH_MSG_FATAL(
"The WriteDecorHandle should not be configured directly.");
288 return StatusCode::FAILURE;
291 keys.emplace_back(
name +
".truthParticleLink");
292 keys.emplace_back(
name +
".truthType");
293 keys.emplace_back(
name +
".truthOrigin");
295 return StatusCode::SUCCESS;
302 const EventContext& ctx)
303 :
el(hkeys.at(0), ctx)
304 ,
type(hkeys.at(1), ctx)
305 , origin(hkeys.at(2), ctx)
311 const EventContext& ctx,
318 info.first = ret.first;
319 info.second = ret.second;
327 egammaTruthAssociationAlg::particleTruthClassifier<xAOD::Electron>(
328 const EventContext& ctx,
331 MCTruthInfo_t
info{};
334 if (ret.first == MCTruthPartClassifier::Unknown &&
337 ATH_MSG_DEBUG(
"Trying cluster-based truth classification for electron");
341 info.first = ret.first;
342 info.second = ret.second;
346 template<
class T,
class L>
349 const EventContext& ctx,
367 truthParticle, truthParticles, ctx);
369 "Decorating object with link to truth, index = " << link.
index());
374 decoHandles.
el(*particle).toPersistent();
376 <<
" truthOrigin = " <<
info.second);
382 if (!egammaTruthContainer) {
384 return StatusCode::FAILURE;
390 getEgammaTruthParticle(truth, *egammaTruthContainer);
394 bool annotateLink =
true;
395 const auto link = linkAccess(*truthEgamma);
396 if (link.isValid()) {
397 auto oldPart = *link;
398 if (oldPart && truthEgamma->
e() > 0 &&
399 std::abs(oldPart->e() / truthEgamma->
e() - 1) <
400 std::abs(
particle->e() / truthEgamma->
e() - 1)) {
403 <<
" already set to a better matched particle: "
405 annotateLink =
false;
411 linkAccess(*truthEgamma) = link;
412 linkAccess(*truthEgamma).toPersistent();
418 return StatusCode::SUCCESS;
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
MCTruthInfo_t particleTruthClassifier(const EventContext &ctx, const T *) const
return the result of MCTruthClassifier::particleTruthClassifier or do a second pass for electrons bas...
ElementLink< xAOD::ElectronContainer > ElectronLink_t
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_egammaTruthParticleContainerKey
Name of the output egamma truth container.
float pz() const
The z component of the particle's momentum.
Helper class to provide type-safe access to aux data.
void getNewTruthParticle(const EventContext &ctx, xAOD::TruthParticleContainer &egammaTruthContainer, const xAOD::TruthParticle *truth, const xAOD::TruthParticleContainer *oldContainer) const
Create a copy a truth particle, add it to the new getNewTruthParticle container and decorate it with ...
ElementLink< xAOD::PhotonContainer > PhotonLink_t
Gaudi::Property< bool > m_matchClusters
Match clusters?
float px() const
The x component of the particle's momentum.
StatusCode match(const EventContext &ctx, const xAOD::TruthParticleContainer &truthParticles, const SG::WriteDecorHandleKeyArray< T > &hkeys, const SG::AuxElement::Accessor< L > &linkAccess, xAOD::TruthParticleContainer *egammaTruthContainer) const
Loop over elements in the reco container, decorate them with truth info and decorate the truth partic...
Gaudi::Property< float > m_minPtFSR
Minimum Pt for FSR to enter egamma truth particle container.
Gaudi::Property< bool > m_matchPhotons
Match photons?
float py() const
The y component of the particle's momentum.
writeDecorHandles(const SG::WriteDecorHandleKeyArray< T > &keys, const EventContext &ctx)
SG::WriteDecorHandleKeyArray< xAOD::ElectronContainer > m_electronDecKeys
The electron container decor handle key array.
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthEventContainerKey
Name of the truth event container.
bool is_same_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same particle.
Gaudi::Property< bool > m_matchElectrons
Match electrons?
SG::WriteDecorHandle< T, int > type
SG::WriteDecorHandleKeyArray< xAOD::ElectronContainer > m_fwdElectronDecKeys
The fwd electron container decor handle key array.
An algorithm that can be simultaneously executed in multiple threads.
Gaudi::Property< std::string > m_fwdElectronDecName
The fwd electron name property used to initialize the WriteDecorHandleKeyArray.
Gaudi::Property< std::string > m_clusterDecName
The egamma cluster name property used to initialize the WriteDecorHandleKeyArray.
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.
virtual StatusCode execute(const EventContext &ctx) const override final
execute on container
virtual StatusCode initialize() override final
initialize method
Handle class for recording to StoreGate.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainerKey
Name of the truth particle container.
virtual double e() const override final
The total energy of the particle.
const ElementLink< TruthVertexContainer > & prodVtxLink() const
The production vertex link of this particle.
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
::StatusCode StatusCode
StatusCode definition for legacy code.
pointer_type ptr()
Dereference the pointer.
Class describing a truth particle in the MC record.
Handle class for adding a decoration to an object.
const T * front() const
Access the first element in the collection as an rvalue.
SG::WriteDecorHandle< T, int > origin
ElementLink< xAOD::CaloClusterContainer > ClusterLink_t
#define CHECK(...)
Evaluate an expression and check for errors.
const TruthParticle_v1 * incomingParticle(size_t index) const
Get one of the incoming particles.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
ToolHandle< IMCTruthClassifier > m_mcTruthClassifier
MCTruthClassifier.
egammaTruthAssociationAlg(const std::string &name, ISvcLocator *pSvcLocator)
constructor
bool isFwdElectron(const xAOD::Egamma *eg)
is the object a Fwd electron
const ElementLink< TruthVertexContainer > & decayVtxLink() const
The decay vertex link of this particle.
helper class to contain write decoration handles
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Gaudi::Property< bool > m_doEgammaTruthContainer
Create egamma truth container?
Gaudi::Property< std::string > m_electronDecName
The electron container name property used to initialize the WriteDecorHandleKeyArray.
StatusCode initializeDecorKeys(SG::WriteDecorHandleKeyArray< T > &keys, const std::string &name)
A function that initializes the decor handles, but also checks the naming convention.
ElementLink implementation for ROOT usage.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
Gaudi::Property< bool > m_matchForwardElectrons
Match fwd electrons?
SG::WriteDecorHandle< T, ElementLink< xAOD::TruthParticleContainer > > el
Gaudi::Property< float > m_minPt
Minimum Pt to enter egamma truth particle container.
const xAOD::TruthParticle * genPart
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any)
SG::WriteDecorHandleKeyArray< xAOD::PhotonContainer > m_photonDecKeys
The photon container decor handle key array.
virtual StatusCode finalize() override final
finalize method
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::WriteDecorHandleKeyArray< xAOD::CaloClusterContainer > m_clusterDecKeys
The egamma cluster decor handle key array.
bool isPromptEgammaParticle(const EventContext &ctx, const xAOD::TruthParticle *truth) const
Return true if the truth particle is a prompt electron or photon.
SG::ReadHandle< T > & readHandle()
int status() const
Status code.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
#define ATH_MSG_WARNING(x)
size_t nIncomingParticles() const
Get the number of incoming particles.
bool isDecayed(const T &p)
Identify if the particle decayed.
index_type index() const
Get the index of the element inside of its container.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
ElementLink< xAOD::TruthParticleContainer > TruthLink_t
Handle class for reading from StoreGate.
Gaudi::Property< std::string > m_photonDecName
The photon container name property used to initialize the WriteDecorHandleKeyArray.
int pdgId() const
PDG ID code.
virtual double m() const override final
The mass of the particle.
bool empty() const noexcept
Returns true if the collection is empty.