 |
ATLAS Offline Software
|
Go to the documentation of this file.
13 #include "AthLinks/ElementLink.h"
26 BuildTruthTaus::BuildTruthTaus(
const std::string&
name )
27 : AsgMetadataTool(
name)
51 ATH_MSG_WARNING(
"Truth electron container is not available, won't perform matching to truth electrons");
54 ATH_MSG_WARNING(
"Truth muon container is not available, won't perform matching to truth muons");
57 ATH_MSG_WARNING(
"Truth jet container is not available, won't perform matching to truth jets");
79 return StatusCode::SUCCESS;
97 const EventContext& ctx = Gaudi::Hive::currentContext();
103 if (!truthElectronsHandle.
isValid()) {
105 return StatusCode::FAILURE;
107 truthTausEvent.m_xTruthElectronContainerConst = truthElectronsHandle.
cptr();
112 if (!truthMuonsHandle.
isValid()) {
114 return StatusCode::FAILURE;
116 truthTausEvent.m_xTruthMuonContainerConst = truthMuonsHandle.
cptr();
121 if (!truthJetsHandle.
isValid()) {
123 return StatusCode::FAILURE;
125 truthTausEvent.m_xTruthJetContainerConst = truthJetsHandle.
cptr();
129 if (!truthTausHandle.
isValid()) {
131 return StatusCode::FAILURE;
133 truthTausEvent.m_xTruthTauContainerConst = truthTausHandle.
cptr();
138 if (!truthParticlesHandle.
isValid()) {
140 return StatusCode::FAILURE;
142 truthTausEvent.m_xTruthParticleContainer = truthParticlesHandle.
cptr();
144 auto truthTausOutput = std::make_unique<xAOD::TruthParticleContainer>();
145 auto truthTausOutputAux = std::make_unique<xAOD::TruthParticleAuxContainer>();
146 truthTausOutput->setStore(truthTausOutputAux.get());
147 truthTausEvent.m_xTruthTauContainer = truthTausOutput.get();
150 ATH_CHECK(writeHandle.record(std::move(truthTausOutput), std::move(truthTausOutputAux)));
155 return StatusCode::SUCCESS;
175 for (
auto xTruthParticle : *truthTausEvent.m_xTruthParticleContainer)
177 if ( xTruthParticle->isTau() )
179 auto xTruthTau = std::make_unique<xAOD::TruthParticle>();
180 xTruthTau->makePrivateStore( *xTruthParticle );
188 truthTausEvent.m_xTruthTauContainer->push_back(std::move(xTruthTau));
192 typeDecorator(*truthTau) = typeReadDecor(*xTruthParticle);
193 originDecorator(*truthTau) = originReadDecor(*xTruthParticle);
194 outcomeDecorator(*truthTau) = outcomeReadDecor(*xTruthParticle);
195 classificationDecorator(*truthTau) = classificationReadDecor(*xTruthParticle);
199 linkDecorator(*truthTau) = lTruthParticleLink;
202 return StatusCode::SUCCESS;
210 return StatusCode::FAILURE;
217 if (xDecayVertex ==
nullptr)
218 return StatusCode::FAILURE;
219 for (
size_t iOutgoingParticle = 0; iOutgoingParticle < xDecayVertex->
nOutgoingParticles(); ++iOutgoingParticle )
222 if (xTruthDaughter ==
nullptr)
224 ATH_MSG_ERROR(
"Truth daughter of tau decay was not found in "<<
m_truthParticleContainer.
key() <<
" container. Please ensure that this container has the full tau decay information or produce the TruthTaus container in AtlasDerivation.");
225 return StatusCode::FAILURE;
229 if ( xTruthDaughter->
isTau() )
232 return StatusCode::FAILURE;
273 TLorentzVector vTruthInvisTLV = xTruthParticle.
p4() - truthInfo.
m_vTruthVisTLV;
278 decPtInvis(xTruthParticle) = vTruthInvisTLV.Pt();
279 decEtaInvis(xTruthParticle) = vTruthInvisTLV.Eta();
280 decPhiInvis(xTruthParticle) = vTruthInvisTLV.Phi();
281 decMInvis(xTruthParticle) = vTruthInvisTLV.M();
311 decDecayModeVector(xTruthParticle) = truthInfo.
m_vDecayMode;
330 decProdVertexX(xTruthParticle) = truthInfo.
m_vProdVertex.X();
331 decProdVertexY(xTruthParticle) = truthInfo.
m_vProdVertex.Y();
332 decProdVertexZ(xTruthParticle) = truthInfo.
m_vProdVertex.Z();
335 return StatusCode::SUCCESS;
345 return StatusCode::SUCCESS;
347 truthInfo.
m_vDecayVertex.SetXYZ(xDecayVertex->
x(),xDecayVertex->
y(),xDecayVertex->
z());
351 truthInfo.
m_vProdVertex.SetXYZ(xProdVertex->
x(),xProdVertex->
y(),xProdVertex->
z());
356 for (
size_t iOutgoingParticle = 0; iOutgoingParticle < xDecayVertex->
nOutgoingParticles(); ++iOutgoingParticle )
359 if (xTruthDaughter ==
nullptr)
361 ATH_MSG_ERROR(
"Truth daughter of tau decay was not found in "<<
m_truthParticleContainer.
key() <<
" container. Please ensure that this container has the full tau decay information or produce the TruthTaus container in AtlasDerivation.");
362 return StatusCode::FAILURE;
365 int iAbsPdgId = xTruthDaughter->
absPdgId();
366 int iPdgId = xTruthDaughter->
pdgId();
371 if ( iAbsPdgId != 111 && iAbsPdgId != 311 && iAbsPdgId != 310 && iAbsPdgId != 130 )
423 return StatusCode::SUCCESS;
431 if (xDecayVertex ==
nullptr)
434 for (
size_t iOutgoingParticle = 0; iOutgoingParticle < xDecayVertex->
nOutgoingParticles(); ++iOutgoingParticle )
437 if (xTruthDaughter ==
nullptr)
439 ATH_MSG_WARNING(
"Truth daughter of tau decay was not found in "<<
m_truthParticleContainer.
key() <<
" container. Please ensure that this container has the full tau decay information or produce the TruthTaus container in AtlasDerivation.");
443 <<
" e "<<xTruthDaughter->
e()
444 <<
" eta "<<xTruthDaughter->
p4().Eta()
445 <<
" phi "<<xTruthDaughter->
p4().Phi()
446 <<
" pdgid "<<xTruthDaughter->
pdgId()
447 <<
" status "<<xTruthDaughter->
status()
size_t nOutgoingParticles() const
Get the number of outgoing particles.
@ depth
pointing depth of the shower as calculated in egammaqgcld
int absPdgId() const
Absolute PDG ID code (often useful)
const_pointer_type cptr()
Dereference the pointer.
#define ATH_MSG_VERBOSE(x)
const std::string & key() const
Return the StoreGate ID for the referenced object.
bool empty() const
Test if the key is blank.
float y() const
Vertex y displacement.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.
bool hasDecayVtx() const
Check for a decay vertex on this particle.
virtual double e() const override final
The total energy of the particle.
Handle class for reading a decoration on an object.
Helper class to provide type-safe access to aux data.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
::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.
bool hasProdVtx() const
Check for a production vertex on this particle.
bool isTau() const
Whether the particle is a tau (or antitau)
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
bool isCharged() const
Whether the particle is electrically charged.
ElementLink implementation for ROOT usage.
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
Class describing a truth vertex in the MC record.
Helper class to provide type-safe access to aux data.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
float x() const
Vertex x displacement.
int status() const
Status code.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
#define ATH_MSG_WARNING(x)
bool isDecayed(const T &p)
Identify if the particle decayed.
float z() const
Vertex longitudinal distance along the beam line form the origin.
bool isNeutrino() const
Whether the particle is a neutrino (or antineutrino)
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
int pdgId() const
PDG ID code.
bool isNeutral() const
Whether the particle is electrically neutral.
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
bool isHadron() const
Whether the particle is a hadron.