 |
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;
85 const EventContext& ctx = Gaudi::Hive::currentContext();
102 if (!truthElectronsHandle.
isValid()) {
104 return StatusCode::FAILURE;
106 truthTausEvent.m_xTruthElectronContainerConst = truthElectronsHandle.
cptr();
111 if (!truthMuonsHandle.
isValid()) {
113 return StatusCode::FAILURE;
115 truthTausEvent.m_xTruthMuonContainerConst = truthMuonsHandle.
cptr();
120 if (!truthJetsHandle.
isValid()) {
122 return StatusCode::FAILURE;
124 truthTausEvent.m_xTruthJetContainerConst = truthJetsHandle.
cptr();
128 if (!truthTausHandle.
isValid()) {
130 return StatusCode::FAILURE;
132 truthTausEvent.m_xTruthTauContainerConst = truthTausHandle.
cptr();
137 if (!truthParticlesHandle.
isValid()) {
139 return StatusCode::FAILURE;
141 truthTausEvent.m_xTruthParticleContainer = truthParticlesHandle.
cptr();
143 auto truthTausOutput = std::make_unique<xAOD::TruthParticleContainer>();
144 auto truthTausOutputAux = std::make_unique<xAOD::TruthParticleAuxContainer>();
145 truthTausOutput->setStore(truthTausOutputAux.get());
146 truthTausEvent.m_xTruthTauContainer = truthTausOutput.get();
149 ATH_CHECK(writeHandle.record(std::move(truthTausOutput), std::move(truthTausOutputAux)));
154 return StatusCode::SUCCESS;
174 for (
auto xTruthParticle : *truthTausEvent.m_xTruthParticleContainer)
176 if ( xTruthParticle->isTau() )
178 auto xTruthTau = std::make_unique<xAOD::TruthParticle>();
179 xTruthTau->makePrivateStore( *xTruthParticle );
187 truthTausEvent.m_xTruthTauContainer->push_back(std::move(xTruthTau));
191 typeDecorator(*truthTau) = typeReadDecor.
isAvailable() ? typeReadDecor(*xTruthParticle) : -1234;
192 originDecorator(*truthTau) = originReadDecor.
isAvailable() ? originReadDecor(*xTruthParticle) : -1234;
193 outcomeDecorator(*truthTau) = outcomeReadDecor.
isAvailable() ? outcomeReadDecor(*xTruthParticle) : -1234;
194 classificationDecorator(*truthTau) = classificationReadDecor.
isAvailable() ? classificationReadDecor(*xTruthParticle) : -1234;
198 linkDecorator(*truthTau) = lTruthParticleLink;
201 return StatusCode::SUCCESS;
209 return StatusCode::FAILURE;
216 if (xDecayVertex ==
nullptr)
217 return StatusCode::FAILURE;
218 for (
size_t iOutgoingParticle = 0; iOutgoingParticle < xDecayVertex->
nOutgoingParticles(); ++iOutgoingParticle )
221 if (xTruthDaughter ==
nullptr)
223 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.");
224 return StatusCode::FAILURE;
228 if ( xTruthDaughter->
isTau() )
231 return StatusCode::FAILURE;
272 TLorentzVector vTruthInvisTLV = xTruthParticle.
p4() - truthInfo.
m_vTruthVisTLV;
277 decPtInvis(xTruthParticle) = vTruthInvisTLV.Pt();
278 decEtaInvis(xTruthParticle) = vTruthInvisTLV.Eta();
279 decPhiInvis(xTruthParticle) = vTruthInvisTLV.Phi();
280 decMInvis(xTruthParticle) = vTruthInvisTLV.M();
310 decDecayModeVector(xTruthParticle) = truthInfo.
m_vDecayMode;
329 decProdVertexX(xTruthParticle) = truthInfo.
m_vProdVertex.X();
330 decProdVertexY(xTruthParticle) = truthInfo.
m_vProdVertex.Y();
331 decProdVertexZ(xTruthParticle) = truthInfo.
m_vProdVertex.Z();
334 return StatusCode::SUCCESS;
344 return StatusCode::SUCCESS;
346 truthInfo.
m_vDecayVertex.SetXYZ(xDecayVertex->
x(),xDecayVertex->
y(),xDecayVertex->
z());
350 truthInfo.
m_vProdVertex.SetXYZ(xProdVertex->
x(),xProdVertex->
y(),xProdVertex->
z());
355 for (
size_t iOutgoingParticle = 0; iOutgoingParticle < xDecayVertex->
nOutgoingParticles(); ++iOutgoingParticle )
358 if (xTruthDaughter ==
nullptr)
360 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.");
361 return StatusCode::FAILURE;
364 int iAbsPdgId = xTruthDaughter->
absPdgId();
365 int iPdgId = xTruthDaughter->
pdgId();
370 if ( iAbsPdgId != 111 && iAbsPdgId != 311 && iAbsPdgId != 310 && iAbsPdgId != 130 )
422 return StatusCode::SUCCESS;
430 if (xDecayVertex ==
nullptr)
433 for (
size_t iOutgoingParticle = 0; iOutgoingParticle < xDecayVertex->
nOutgoingParticles(); ++iOutgoingParticle )
436 if (xTruthDaughter ==
nullptr)
438 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.");
442 <<
" e "<<xTruthDaughter->
e()
443 <<
" eta "<<xTruthDaughter->
p4().Eta()
444 <<
" phi "<<xTruthDaughter->
p4().Phi()
445 <<
" pdgid "<<xTruthDaughter->
pdgId()
446 <<
" 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 isAvailable()
Test to see if this variable exists in the store, for the referenced object.
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.