ATLAS Offline Software
Loading...
Searching...
No Matches
TauAnalysisTools::TauTruthMatchingTool Class Reference

#include <TauTruthMatchingTool.h>

Inheritance diagram for TauAnalysisTools::TauTruthMatchingTool:
Collaboration diagram for TauAnalysisTools::TauTruthMatchingTool:

Public Types

Definition of the StoreGate-like object's definition
typedef ServiceHandle< StoreGateSvcMetaStore_t
 Type of the metadata store object in Athena.
typedef const ServiceHandle< StoreGateSvc > & MetaStorePtr_t
 Type of the metadata store pointer in standalone mode.

Public Member Functions

virtual TLorentzVector getTruthTauP4Vis (const xAOD::TauJet &xTau) override final
virtual TLorentzVector getTruthTauP4Vis (const xAOD::TruthParticle &xTruthTau) const override final
virtual TLorentzVector getTruthTauP4Invis (const xAOD::TauJet &xTau) override final
virtual TLorentzVector getTruthTauP4Invis (const xAOD::TruthParticle &xTruthTau) const override final
bool matchTruthLeptonicTauDecay (const xAOD::IParticle *p, const xAOD::TruthParticleContainer *truth_taus)
virtual TauAnalysisTools::TruthMatchedParticleType getTruthParticleType (const xAOD::TauJet &xTau) override final
virtual int getNTauDecayParticles (const xAOD::TauJet &xTau, int iPdgId, bool bCompareAbsoluteValues=false) override final
virtual int getNTauDecayParticles (const xAOD::TruthParticle &xTruthTau, int iPdgId, bool bCompareAbsoluteValues=false) const override final
virtual xAOD::TauJetParameters::DecayMode getDecayMode (const xAOD::TauJet &xTau) override final
virtual xAOD::TauJetParameters::DecayMode getDecayMode (const xAOD::TruthParticle &xTruthTau) const override final
virtual StatusCode lockDecorations (const xAOD::TauJetContainer &taus) const override final
 Decorations produced by an algorithm need to be locked; otherwise, they will be ignored by deep copies.
virtual void print () const
 Print the state of the tool.
virtual StatusCode sysInitialize ()
 Function initialising the tool in the correct way in Athena.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Functions providing access to the input/output metadata
MetaStorePtr_t inputMetaStore () const
 Accessor for the input metadata store.
MetaStorePtr_t outputMetaStore () const
 Accessor for the output metadata store.
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

StatusCode retrieveTruthTausImpl (TruthTausEvent &truthTausEvent, const EventContext &ctx) const
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.
Callback functions helping in metadata reading/writing
void setUseIncidents (const bool flag)
virtual void handle (const Incident &inc)
 Function receiving incidents from IncidentSvc/TEvent.
virtual StatusCode beginInputFile ()
 Function called when a new input file is opened.
virtual StatusCode endInputFile ()
 Function called when the currently open input file got completely processed.
virtual StatusCode beginEvent ()
 Function called when a new events is loaded.
virtual StatusCode metaDataStop ()
 Function called when the tool should write out its metadata.

Protected Attributes

TruthTausEvent m_truthTausEvent
bool m_bTruthTauAvailable {}

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

virtual ASG_TOOL_CLASS2(TauTruthMatchingTool, TauAnalysisTools::IBuildTruthTaus, TauAnalysisTools::ITauTruthMatchingTool) public ~TauTruthMatchingTool ()=default
 Create a proper constructor for Athena.
virtual StatusCode initialize () override final
virtual std::unique_ptr< ITruthTausEventgetEvent () const override final
virtual const xAOD::TruthParticlegetTruth (const xAOD::TauJet &xTau) override final
virtual const xAOD::TruthParticlegetTruth (const xAOD::TauJet &xTau, ITruthTausEvent &truthTausEVent) const override final
virtual std::vector< const xAOD::TruthParticle * > getTruth (const std::vector< const xAOD::TauJet * > &vTaus) override final
StatusCode findTruthTau (const xAOD::TauJet &xTau, TruthTausEvent &truthTausEvent) const
StatusCode checkTruthMatch (const xAOD::TauJet &xTau, const xAOD::TruthParticleContainer &xTauContainer, const TruthTausEvent &truthTausEvent) const
virtual void setTruthMatchingMode () override
virtual StatusCode retrieveTruthTaus () override
virtual StatusCode retrieveTruthTaus (ITruthTausEvent &truthTausEvent, const EventContext &ctx) const override
StatusCode buildTruthTausFromTruthParticles (TruthTausEvent &truthTausEvent, const EventContext &ctx) const
StatusCode examineTruthTau (const xAOD::TruthParticle &xTruthParticle) const
StatusCode examineTruthTauDecay (const xAOD::TruthParticle &xTruthParticle, TauTruthInfo &truthInfo) const
void printDecay (const xAOD::TruthParticle &xTruthParticle, int depth=0) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

Gaudi::Property< double > m_dMaxDeltaR {this, "MaxDeltaR", 0.2}
CxxUtils::CachedValue< bool > m_bIsTruthMatchedAvailable
CxxUtils::CachedValue< bool > m_bIsTruthParticleLinkAvailable
SG::ConstAccessor< double > m_accPtVis
SG::ConstAccessor< double > m_accEtaVis
SG::ConstAccessor< double > m_accPhiVis
SG::ConstAccessor< double > m_accMVis
Gaudi::Property< bool > m_bForceCheckTruthMatch { this, "ForceCheckTruthMatch", false}
Gaudi::Property< bool > m_bWriteInvisibleFourMomentum { this, "WriteInvisibleFourMomentum", false}
Gaudi::Property< bool > m_bWriteVisibleChargedFourMomentum { this, "WriteVisibleChargedFourMomentum", false}
Gaudi::Property< bool > m_bWriteVisibleChargedFourMomentumComponent { this, "WriteVisibleChargedFourMomentumComponent", false}
Gaudi::Property< bool > m_bWriteVisibleNeutralFourMomentum { this, "WriteVisibleNeutralFourMomentum", false}
Gaudi::Property< bool > m_bWriteVisibleNeutralFourMomentumComponent { this, "WriteVisibleNeutralFourMomentumComponent", false}
Gaudi::Property< bool > m_bWriteDecayModeVector { this, "WriteDecayModeVector", true}
Gaudi::Property< bool > m_bWriteVertices { this, "WriteVertices", true}
SG::ReadHandleKey< xAOD::TruthParticleContainerm_truthTauInputContainer { this, "TruthTauContainerName", "TruthTaus", "Truth tau input container name (truth matching mode)" }
SG::ReadHandleKey< xAOD::TruthParticleContainerm_truthParticleContainer { this, "TruthParticleContainerName", "TruthParticles", "Truth particles input container name" }
SG::ReadHandleKey< xAOD::TruthParticleContainerm_truthElectronContainer { this, "TruthElectronContainerName", "TruthElectrons", "Truth electrons input container name" }
SG::ReadHandleKey< xAOD::TruthParticleContainerm_truthMuonContainer { this, "TruthMuonContainerName", "TruthMuons", "Truth muons input container name" }
SG::ReadHandleKey< xAOD::JetContainerm_truthJetContainer { this, "TruthJetContainerName", "AntiKt4TruthDressedWZJets", "Truth jets input container name" }
SG::WriteHandleKey< xAOD::TruthParticleContainerm_truthTauOutputContainer { this, "NewTruthTauContainerName", "TruthTaus", "Truth tau output container name" }
SG::ReadDecorHandleKey< xAOD::TruthParticleContainerm_originReadDecorKey {this, "inputClassifierParticleOrigin", "TruthParticles.classifierParticleOrigin", "Particle origin"}
SG::ReadDecorHandleKey< xAOD::TruthParticleContainerm_typeReadDecorKey {this, "inputClassifierParticleType", "TruthParticles.classifierParticleType", "Particle type"}
SG::ReadDecorHandleKey< xAOD::TruthParticleContainerm_outcomeReadDecorKey {this, "inputClassifierParticleOutCome", "TruthParticles.classifierParticleOutCome", "Particle outcome"}
SG::ReadDecorHandleKey< xAOD::TruthParticleContainerm_classificationReadDecorKey {this, "inputClassification", "TruthParticles.Classification", "Classification code"}
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_linkDecoratorKey {this, "originalTruthParticle", "TruthTaus.originalTruthParticle", "Name of the decoration linking to the original truth particle"}
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_originDecoratorKey {this, "classifierParticleOrigin", "TruthTaus.classifierParticleOrigin", "Name of the decoration which records the particle origin"}
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_typeDecoratorKey {this, "classifierParticleType", "TruthTaus.classifierParticleType", "Name of the decoration which records the particle type"}
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_outcomeDecoratorKey {this, "classifierParticleOutCome", "TruthTaus.classifierParticleOutCome", "Name of the decoration which records the particle outcome"}
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_classificationDecoratorKey {this, "Classification", "TruthTaus.Classification", "Name of the decoration which records the particle classification"}
bool m_truthMatchingMode = false
MetaStore_t m_inputMetaStore
 Object accessing the input metadata store.
MetaStore_t m_outputMetaStore
 Object accessing the output metadata store.
bool m_beginInputFileCalled
 Flag helping to discover when the tool misses the opening of the first input file.
bool m_useIncidents
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 23 of file TauTruthMatchingTool.h.

Member Typedef Documentation

◆ MetaStore_t

Type of the metadata store object in Athena.

Definition at line 66 of file AsgMetadataTool.h.

◆ MetaStorePtr_t

Type of the metadata store pointer in standalone mode.

Definition at line 68 of file AsgMetadataTool.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Function Documentation

◆ beginEvent()

StatusCode asg::AsgMetadataTool::beginEvent ( )
protectedvirtualinherited

◆ beginInputFile()

StatusCode asg::AsgMetadataTool::beginInputFile ( )
protectedvirtualinherited

Function called when a new input file is opened.

Dummy implementation that can be overridden by the derived tool.

Reimplemented in AsgElectronEfficiencyCorrectionTool, BookkeeperDumperTool, BookkeeperTool, PMGTools::PMGTruthWeightTool, TauAnalysisTools::TauEfficiencyCorrectionsTool, TauAnalysisTools::TauSmearingTool, Trig::TrigDecisionTool, Trig::xAODBunchCrossingTool, TrigConf::xAODConfigTool, xAODMaker::TriggerMenuMetaDataTool, and xAODMaker::TruthMetaDataTool.

Definition at line 185 of file AsgMetadataTool.cxx.

185 {
186
187 // Return gracefully:
188 return StatusCode::SUCCESS;
189 }

◆ buildTruthTausFromTruthParticles()

StatusCode BuildTruthTaus::buildTruthTausFromTruthParticles ( TruthTausEvent & truthTausEvent,
const EventContext & ctx ) const
privateinherited

Definition at line 161 of file BuildTruthTaus.cxx.

162{
163 SG::ReadDecorHandle<xAOD::TruthParticleContainer, unsigned int > originReadDecor(m_originReadDecorKey, ctx);
164 SG::ReadDecorHandle<xAOD::TruthParticleContainer, unsigned int > typeReadDecor(m_typeReadDecorKey, ctx);
165 SG::ReadDecorHandle<xAOD::TruthParticleContainer, unsigned int > outcomeReadDecor(m_outcomeReadDecorKey, ctx);
166 SG::ReadDecorHandle<xAOD::TruthParticleContainer, unsigned int > classificationReadDecor(m_classificationReadDecorKey, ctx);
167
168 SG::WriteDecorHandle<xAOD::TruthParticleContainer, ElementLink<xAOD::TruthParticleContainer> > linkDecorator(m_linkDecoratorKey, ctx);
169 SG::WriteDecorHandle<xAOD::TruthParticleContainer, unsigned int > originDecorator(m_originDecoratorKey, ctx);
170 SG::WriteDecorHandle<xAOD::TruthParticleContainer, unsigned int > typeDecorator(m_typeDecoratorKey, ctx);
171 SG::WriteDecorHandle<xAOD::TruthParticleContainer, unsigned int > outcomeDecorator(m_outcomeDecoratorKey, ctx);
172 SG::WriteDecorHandle<xAOD::TruthParticleContainer, unsigned int > classificationDecorator(m_classificationDecoratorKey, ctx);
173
174 for (auto xTruthParticle : *truthTausEvent.m_xTruthParticleContainer)
175 {
176 if ( xTruthParticle->isTau() )
177 {
178 auto xTruthTau = std::make_unique<xAOD::TruthParticle>();
179 xTruthTau->makePrivateStore( *xTruthParticle );
180
181 if ( examineTruthTau(*xTruthTau).isFailure() )
182 {
183 continue;
184 }
185
186 // adding decorations onto the truth tau requires that it is in the final Aux store
187 truthTausEvent.m_xTruthTauContainer->push_back(std::move(xTruthTau));
188 xAOD::TruthParticle* truthTau = truthTausEvent.m_xTruthTauContainer->back();
189
190 // propagate MCTruthClassifier decorations
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;
195
196 // create link to the original TruthParticle
197 ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink(xTruthParticle, *truthTausEvent.m_xTruthParticleContainer);
198 linkDecorator(*truthTau) = lTruthParticleLink;
199 }
200 }
201 return StatusCode::SUCCESS;
202}
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_outcomeReadDecorKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_originReadDecorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_originDecoratorKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_classificationReadDecorKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_typeReadDecorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_linkDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_typeDecoratorKey
StatusCode examineTruthTau(const xAOD::TruthParticle &xTruthParticle) const
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_classificationDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_outcomeDecoratorKey
XAOD_AUXDATA_DEPRECATED bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if a user property is available for reading or not.
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ checkTruthMatch()

StatusCode TauTruthMatchingTool::checkTruthMatch ( const xAOD::TauJet & xTau,
const xAOD::TruthParticleContainer & xTauContainer,
const TruthTausEvent & truthTausEvent ) const
private

Definition at line 346 of file TauTruthMatchingTool.cxx.

347{
348 const xAOD::TruthParticle* xTruthMatch = nullptr;
349 const xAOD::Jet* xTruthJetMatch = nullptr;
350 TruthMatchedParticleType eTruthMatchedParticleType = Unknown;
351 static const SG::Decorator<char> decIsTruthMatched("IsTruthMatched");
352 static const SG::Decorator< ElementLink< xAOD::JetContainer > > decTruthJetLink("truthJetLink");
353
354 for (auto xTruthTauIt : xTruthTauContainer)
355 {
356 TLorentzVector vTruthVisTLV;
357 vTruthVisTLV.SetPtEtaPhiM(m_accPtVis(*xTruthTauIt),
358 m_accEtaVis(*xTruthTauIt),
359 m_accPhiVis(*xTruthTauIt),
360 m_accMVis(*xTruthTauIt));
361 if (xTau.p4().DeltaR(vTruthVisTLV) <= m_dMaxDeltaR)
362 {
363 static const SG::ConstAccessor<char> accIsHadronicTau("IsHadronicTau");
364 if (static_cast<bool>(accIsHadronicTau(*xTruthTauIt)))
365 eTruthMatchedParticleType = TruthHadronicTau;
366 else
367 eTruthMatchedParticleType = TruthLeptonicTau;
368
369 xTruthMatch = xTruthTauIt;
370 break;
371 }
372 }
373
374 double dPtMax = 0.;
375 if (!xTruthMatch and truthTausEvent.m_xTruthMuonContainerConst)
376 {
377 dPtMax = 0.;
378 for (auto xTruthMuonIt : *truthTausEvent.m_xTruthMuonContainerConst)
379 {
380 if (xTau.p4().DeltaR(xTruthMuonIt->p4()) <= m_dMaxDeltaR)
381 {
382 if (xTruthMuonIt->pt()<dPtMax)
383 continue;
384 eTruthMatchedParticleType = TruthMuon;
385 xTruthMatch = xTruthMuonIt;
386 dPtMax = xTruthMuonIt->pt();
387 }
388 }
389 }
390
391 if (!xTruthMatch and truthTausEvent.m_xTruthElectronContainerConst)
392 {
393 dPtMax = 0.;
394 for (auto xTruthElectronIt : *truthTausEvent.m_xTruthElectronContainerConst)
395 {
396 if (xTau.p4().DeltaR(xTruthElectronIt->p4()) <= m_dMaxDeltaR)
397 {
398 if (xTruthElectronIt->pt()<dPtMax)
399 continue;
400 eTruthMatchedParticleType = TruthElectron;
401 xTruthMatch = xTruthElectronIt;
402 dPtMax = xTruthElectronIt->pt();
403 }
404 }
405 }
406
407 if (truthTausEvent.m_xTruthJetContainerConst)
408 {
409 dPtMax = 0.;
410 for (auto xTruthJetIt : *truthTausEvent.m_xTruthJetContainerConst)
411 {
412 if (xTau.p4().DeltaR(xTruthJetIt->p4()) <= m_dMaxDeltaR)
413 {
414 if (xTruthJetIt->pt()<dPtMax)
415 continue;
416 xTruthJetMatch = xTruthJetIt;
417 dPtMax = xTruthJetIt->pt();
418 }
419 }
420 }
421
422 if (xTruthMatch)
423 decIsTruthMatched(xTau) = (char)true;
424 else
425 decIsTruthMatched(xTau) = (char)false;
426
427 if (xTruthJetMatch)
428 {
429 ElementLink < xAOD::JetContainer > lTruthParticleLink(xTruthJetMatch, *truthTausEvent.m_xTruthJetContainerConst);
430 decTruthJetLink(xTau) = lTruthParticleLink;
431 }
432 else
433 {
434 ElementLink < xAOD::JetContainer > lTruthParticleLink;
435 decTruthJetLink(xTau) = lTruthParticleLink;
436 }
437
438 // create link to the original TruthParticle
439 static const SG::Decorator< ElementLink< xAOD::TruthParticleContainer > > decTruthParticleLink("truthParticleLink");
440
441 if (xTruthMatch)
442 {
443 if (eTruthMatchedParticleType == TruthHadronicTau or eTruthMatchedParticleType == TruthLeptonicTau)
444 {
445 ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink(xTruthMatch, xTruthTauContainer);
446 decTruthParticleLink(xTau) = lTruthParticleLink;
447 }
448 else if (eTruthMatchedParticleType == TruthMuon)
449 {
450 ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink(xTruthMatch, *truthTausEvent.m_xTruthMuonContainerConst);
451 decTruthParticleLink(xTau) = lTruthParticleLink;
452 }
453 else if (eTruthMatchedParticleType == TruthElectron)
454 {
455 ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink(xTruthMatch, *truthTausEvent.m_xTruthElectronContainerConst);
456 decTruthParticleLink(xTau) = lTruthParticleLink;
457 }
458 }
459 else
460 {
461 ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink;
462 decTruthParticleLink(xTau) = lTruthParticleLink;
463 }
464
465 return StatusCode::SUCCESS;
466}
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition TauJet_v3.cxx:96
virtual double pt() const override final
The transverse momentum ( ) of the particle.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
Jet_v1 Jet
Definition of the current "jet version".

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ endInputFile()

StatusCode asg::AsgMetadataTool::endInputFile ( )
protectedvirtualinherited

Function called when the currently open input file got completely processed.

Dummy implementation that can be overridden by the derived tool.

Reimplemented in BookkeeperDumperTool, BookkeeperTool, xAODMaker::TriggerMenuMetaDataTool, and xAODMaker::TruthMetaDataTool.

Definition at line 193 of file AsgMetadataTool.cxx.

193 {
194
195 // Return gracefully:
196 return StatusCode::SUCCESS;
197 }

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ examineTruthTau()

StatusCode BuildTruthTaus::examineTruthTau ( const xAOD::TruthParticle & xTruthParticle) const
privateinherited

Definition at line 205 of file BuildTruthTaus.cxx.

206{
207 // skip this tau if it has no decay vertex, should not happen
208 if ( !xTruthParticle.hasDecayVtx() )
209 return StatusCode::FAILURE;
210
211 ATH_MSG_VERBOSE("looking for charged daughters of a truth tau");
212
213 TauTruthInfo truthInfo;
214
215 const xAOD::TruthVertex* xDecayVertex = xTruthParticle.decayVtx();
216 if (xDecayVertex == nullptr)
217 return StatusCode::FAILURE;
218 for ( size_t iOutgoingParticle = 0; iOutgoingParticle < xDecayVertex->nOutgoingParticles(); ++iOutgoingParticle )
219 {
220 const xAOD::TruthParticle* xTruthDaughter = xDecayVertex->outgoingParticle(iOutgoingParticle);
221 if (xTruthDaughter == nullptr)
222 {
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;
225 }
226
227 // if tau decays into tau this is not a proper tau decay
228 if ( xTruthDaughter->isTau() )
229 {
230 ATH_MSG_VERBOSE("Tau decays into a tau itself -> skip this decay");
231 return StatusCode::FAILURE;
232 }
233 }
234
235 examineTruthTauDecay(xTruthParticle, truthInfo).ignore();
236
237 if (truthInfo.m_bIsHadronicTau)
238 ATH_MSG_VERBOSE(truthInfo.m_iNChargedDaughters << " prong hadronic truth tau was found with uniqueID "<<HepMC::uniqueID(xTruthParticle));
239 else
240 ATH_MSG_VERBOSE(truthInfo.m_iNChargedDaughters << " prong leptonic truth tau was found with uniqueID "<<HepMC::uniqueID(xTruthParticle));
241 if ( truthInfo.m_iNChargedDaughters%2 == 0 )
242 {
243 ATH_MSG_WARNING("found tau with even multiplicity: " << truthInfo.m_iNChargedDaughters);
244 printDecay(xTruthParticle);
245 }
246
247 static const SG::Decorator<double> decPtVis("pt_vis");
248 static const SG::Decorator<double> decEtaVis("eta_vis");
249 static const SG::Decorator<double> decPhiVis("phi_vis");
250 static const SG::Decorator<double> decMVis("m_vis");
251
252 static const SG::Decorator<size_t> decNumCharged("numCharged");
253 static const SG::Decorator<size_t> decNumChargedPion("numChargedPion");
254 static const SG::Decorator<size_t> decNumNeutral("numNeutral");
255 static const SG::Decorator<size_t> decNumNeutralPion("numNeutralPion");
256
257 decPtVis(xTruthParticle) = truthInfo.m_vTruthVisTLV.Pt();
258 decEtaVis(xTruthParticle) = truthInfo.m_vTruthVisTLV.Eta();
259 decPhiVis(xTruthParticle) = truthInfo.m_vTruthVisTLV.Phi();
260 decMVis(xTruthParticle) = truthInfo.m_vTruthVisTLV.M();
261
262 decNumCharged(xTruthParticle) = truthInfo.m_iNChargedDaughters;
263 decNumChargedPion(xTruthParticle) = truthInfo.m_iNChargedPions;
264 decNumNeutral(xTruthParticle) = truthInfo.m_iNNeutralPions+truthInfo.m_iNNeutralOthers;
265 decNumNeutralPion(xTruthParticle) = truthInfo.m_iNNeutralPions;
266
267 static const SG::Decorator<char> decIsHadronicTau("IsHadronicTau");
268 decIsHadronicTau(xTruthParticle) = (char)truthInfo.m_bIsHadronicTau;
269
271 {
272 TLorentzVector vTruthInvisTLV = xTruthParticle.p4() - truthInfo.m_vTruthVisTLV;
273 static const SG::Decorator<double> decPtInvis("pt_invis");
274 static const SG::Decorator<double> decEtaInvis("eta_invis");
275 static const SG::Decorator<double> decPhiInvis("phi_invis");
276 static const SG::Decorator<double> decMInvis("m_invis");
277 decPtInvis(xTruthParticle) = vTruthInvisTLV.Pt();
278 decEtaInvis(xTruthParticle) = vTruthInvisTLV.Eta();
279 decPhiInvis(xTruthParticle) = vTruthInvisTLV.Phi();
280 decMInvis(xTruthParticle) = vTruthInvisTLV.M();
281 }
282
284 {
285 static const SG::Decorator<double> decPtVisCharged("pt_vis_charged");
286 static const SG::Decorator<double> decEtaVisCharged("eta_vis_charged");
287 static const SG::Decorator<double> decPhiVisCharged("phi_vis_charged");
288 static const SG::Decorator<double> decMVisCharged("m_vis_charged");
289 decPtVisCharged(xTruthParticle) = truthInfo.m_vTruthVisTLVCharged.Pt();
290 decEtaVisCharged(xTruthParticle) = truthInfo.m_vTruthVisTLVCharged.Eta();
291 decPhiVisCharged(xTruthParticle) = truthInfo.m_vTruthVisTLVCharged.Phi();
292 decMVisCharged(xTruthParticle) = truthInfo.m_vTruthVisTLVCharged.M();
293 }
294
296 {
297 static const SG::Decorator<std::vector<double>> decCharged_pt("pt_charged"); std::vector<double> vec_ptcharged;
298 static const SG::Decorator<std::vector<double>> decCharged_eta("eta_charged"); std::vector<double> vec_etacharged;
299 static const SG::Decorator<std::vector<double>> decCharged_phi("phi_charged"); std::vector<double> vec_phicharged;
300 static const SG::Decorator<std::vector<double>> decCharged_m("m_charged"); std::vector<double> vec_mcharged;
301 for(size_t iProducts=0; iProducts < truthInfo.m_TLVCharged.size(); ++iProducts){
302 TLorentzVector iTLV_c = truthInfo.m_TLVCharged.at(iProducts);
303 vec_ptcharged.push_back(iTLV_c.Pt());
304 vec_etacharged.push_back(iTLV_c.Eta());
305 vec_phicharged.push_back(iTLV_c.Phi());
306 vec_mcharged.push_back(iTLV_c.M());
307 }
308 decCharged_pt(xTruthParticle) = std::move(vec_ptcharged);
309 decCharged_eta(xTruthParticle) = std::move(vec_etacharged);
310 decCharged_phi(xTruthParticle) = std::move(vec_phicharged);
311 decCharged_m(xTruthParticle) = std::move(vec_mcharged);
312 }
313
315 {
316 static const SG::Decorator<double> decPtVisNeutral("pt_vis_neutral");
317 static const SG::Decorator<double> decEtaVisNeutral("eta_vis_neutral");
318 static const SG::Decorator<double> decPhiVisNeutral("phi_vis_neutral");
319 static const SG::Decorator<double> decMVisNeutral("m_vis_neutral");
320 decPtVisNeutral(xTruthParticle) = truthInfo.m_vTruthVisTLVNeutral.Pt();
321 decEtaVisNeutral(xTruthParticle) = truthInfo.m_vTruthVisTLVNeutral.Eta();
322 decPhiVisNeutral(xTruthParticle) = truthInfo.m_vTruthVisTLVNeutral.Phi();
323 decMVisNeutral(xTruthParticle) = truthInfo.m_vTruthVisTLVNeutral.M();
324 }
325
327 {
328 static const SG::Decorator<std::vector<double>> decNeutral_pt("pt_neutral"); std::vector<double> vec_ptneutral;
329 static const SG::Decorator<std::vector<double>> decNeutral_eta("eta_neutral"); std::vector<double> vec_etaneutral;
330 static const SG::Decorator<std::vector<double>> decNeutral_phi("phi_neutral"); std::vector<double> vec_phineutral;
331 static const SG::Decorator<std::vector<double>> decNeutral_m("m_neutral"); std::vector<double> vec_mneutral;
332 for(size_t iProducts=0; iProducts < truthInfo.m_TLVNeutral.size(); ++iProducts){
333 TLorentzVector iTLV_n = truthInfo.m_TLVNeutral.at(iProducts);
334 vec_ptneutral.push_back(iTLV_n.Pt());
335 vec_etaneutral.push_back(iTLV_n.Eta());
336 vec_phineutral.push_back(iTLV_n.Phi());
337 vec_mneutral.push_back(iTLV_n.M());
338 }
339 decNeutral_pt(xTruthParticle) = std::move(vec_ptneutral);
340 decNeutral_eta(xTruthParticle) = std::move(vec_etaneutral);
341 decNeutral_phi(xTruthParticle) = std::move(vec_phineutral);
342 decNeutral_m(xTruthParticle) = std::move(vec_mneutral);
343 }
344
346 {
347 static const SG::Decorator<std::vector<int> > decDecayModeVector("DecayModeVector");
348 decDecayModeVector(xTruthParticle) = truthInfo.m_vDecayMode;
349 }
350
351 if ( m_bWriteVertices )
352 {
353 // tau decay vertex
354 static const SG::Decorator<float> decDecayVertexX("decay_vertex_x");
355 static const SG::Decorator<float> decDecayVertexY("decay_vertex_y");
356 static const SG::Decorator<float> decDecayVertexZ("decay_vertex_z");
357
358 decDecayVertexX(xTruthParticle) = truthInfo.m_vDecayVertex.X();
359 decDecayVertexY(xTruthParticle) = truthInfo.m_vDecayVertex.Y();
360 decDecayVertexZ(xTruthParticle) = truthInfo.m_vDecayVertex.Z();
361
362 // tau production vertex
363 static const SG::Decorator<float> decProdVertexX("prod_vertex_x");
364 static const SG::Decorator<float> decProdVertexY("prod_vertex_y");
365 static const SG::Decorator<float> decProdVertexZ("prod_vertex_z");
366
367 decProdVertexX(xTruthParticle) = truthInfo.m_vProdVertex.X();
368 decProdVertexY(xTruthParticle) = truthInfo.m_vProdVertex.Y();
369 decProdVertexZ(xTruthParticle) = truthInfo.m_vProdVertex.Z();
370 }
371
372 return StatusCode::SUCCESS;
373}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Gaudi::Property< bool > m_bWriteDecayModeVector
void printDecay(const xAOD::TruthParticle &xTruthParticle, int depth=0) const
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainer
Gaudi::Property< bool > m_bWriteVisibleChargedFourMomentumComponent
Gaudi::Property< bool > m_bWriteVisibleChargedFourMomentum
Gaudi::Property< bool > m_bWriteVertices
Gaudi::Property< bool > m_bWriteInvisibleFourMomentum
Gaudi::Property< bool > m_bWriteVisibleNeutralFourMomentum
StatusCode examineTruthTauDecay(const xAOD::TruthParticle &xTruthParticle, TauTruthInfo &truthInfo) const
Gaudi::Property< bool > m_bWriteVisibleNeutralFourMomentumComponent
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
bool hasDecayVtx() const
Check for a decay vertex on this particle.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
bool isTau() const
Whether the particle is a tau (or antitau).
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
size_t nOutgoingParticles() const
Get the number of outgoing particles.
int uniqueID(const T &p)
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15

◆ examineTruthTauDecay()

StatusCode BuildTruthTaus::examineTruthTauDecay ( const xAOD::TruthParticle & xTruthParticle,
TauTruthInfo & truthInfo ) const
privateinherited

Definition at line 376 of file BuildTruthTaus.cxx.

378{
379 // get vertex and check if it exists
380 const xAOD::TruthVertex* xDecayVertex = xTruthParticle.decayVtx();
381 if (!xDecayVertex)
382 return StatusCode::SUCCESS;
383
384 truthInfo.m_vDecayVertex.SetXYZ(xDecayVertex->x(),xDecayVertex->y(),xDecayVertex->z());
385
386 if (xTruthParticle.hasProdVtx() ) {
387 const xAOD::TruthVertex* xProdVertex = xTruthParticle.prodVtx();
388 truthInfo.m_vProdVertex.SetXYZ(xProdVertex->x(),xProdVertex->y(),xProdVertex->z());
389 } else {
390 truthInfo.m_vProdVertex.SetXYZ(-1234,-1234,-1234);
391 }
392
393 for ( size_t iOutgoingParticle = 0; iOutgoingParticle < xDecayVertex->nOutgoingParticles(); ++iOutgoingParticle )
394 {
395 const xAOD::TruthParticle* xTruthDaughter = xDecayVertex->outgoingParticle(iOutgoingParticle);
396 if (xTruthDaughter == nullptr)
397 {
398 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.");
399 return StatusCode::FAILURE;
400 }
401
402 int iAbsPdgId = xTruthDaughter->absPdgId();
403 int iPdgId = xTruthDaughter->pdgId();
404
405 // look at decay of unstable particles
406 if (MC::isDecayed(xTruthDaughter) || !MC::isPhysical(xTruthDaughter))
407 {
408 if ( iAbsPdgId != 111 && iAbsPdgId != 311 && iAbsPdgId != 310 && iAbsPdgId != 130 )
409 {
410 examineTruthTauDecay(*xTruthDaughter, truthInfo).ignore();
411 continue;
412 }
413 }
414
415 // only process stable particles
416 if (!MC::isStable(xTruthDaughter) && !MC::isDecayed(xTruthDaughter))
417 continue;
418
419 // add pdgID to vector for decay mode classification
420 truthInfo.m_vDecayMode.push_back(iPdgId);
421
422 // if tau decays leptonically, indicated by an electron/muon neutrino then
423 // it is not a hadronic decay
424 if ( xTruthDaughter->isHadron() )
425 truthInfo.m_bIsHadronicTau = true;
426
427 // ignore neutrinos for further progress
428 if ( xTruthDaughter->isNeutrino() )
429 {
430 ATH_MSG_VERBOSE("found neutrino decay particle with PdgId "<<iPdgId);
431 continue;
432 }
433
434 // add momentum of non-neutrino particle to visible momentum
435 truthInfo.m_vTruthVisTLV += xTruthDaughter->p4();
437 if ( xTruthDaughter->isCharged() )
438 truthInfo.m_vTruthVisTLVCharged += xTruthDaughter->p4();
440 if ( xTruthDaughter->isCharged() )
441 truthInfo.m_TLVCharged.push_back(xTruthDaughter->p4());
443 if ( xTruthDaughter->isNeutral() )
444 truthInfo.m_vTruthVisTLVNeutral += xTruthDaughter->p4();
446 if ( xTruthDaughter->isNeutral() )
447 truthInfo.m_TLVNeutral.push_back(xTruthDaughter->p4());
448
449 // only count charged decay particles
450 if ( xTruthDaughter->isCharged() )
451 {
452 ATH_MSG_VERBOSE("found charged decay particle with PdgId "<<iPdgId);
453 truthInfo.m_iNChargedDaughters++;
454 // count charged pions
455 if (iAbsPdgId==211) truthInfo.m_iNChargedPions++;
456 else truthInfo.m_iNChargedOthers++;
457 }
458 else
459 {
460 ATH_MSG_VERBOSE("found neutral decay particle with PdgId "<<iPdgId);
461 // count neutral pions
462 if (iAbsPdgId==111) truthInfo.m_iNNeutralPions++;
463 else truthInfo.m_iNNeutralOthers++;
464 }
465 }
466 return StatusCode::SUCCESS;
467}
bool isNeutrino() const
Whether the particle is a neutrino (or antineutrino).
bool isHadron() const
Whether the particle is a hadron.
int pdgId() const
PDG ID code.
bool isCharged() const
Whether the particle is electrically charged.
int absPdgId() const
Absolute PDG ID code (often useful).
bool hasProdVtx() const
Check for a production vertex on this particle.
bool isNeutral() const
Whether the particle is electrically neutral.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
float z() const
Vertex longitudinal distance along the beam line form the origin.
float y() const
Vertex y displacement.
float x() const
Vertex x displacement.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
bool isDecayed(const T &p)
Identify if the particle decayed.
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ findTruthTau()

StatusCode TauTruthMatchingTool::findTruthTau ( const xAOD::TauJet & xTau,
TruthTausEvent & truthTausEvent ) const
private

Definition at line 316 of file TauTruthMatchingTool.cxx.

318{
319 // check if decorations were already added to the first passed tau
320 if (!m_bIsTruthMatchedAvailable.isValid()) {
321 static const SG::ConstAccessor<char> accIsTruthMatched("IsTruthMatched");
322 m_bIsTruthMatchedAvailable.set (accIsTruthMatched.isAvailable(xTau));
323 }
324 // check if decorations were already added to the first passed tau
325 if (!m_bIsTruthParticleLinkAvailable.isValid()) {
327 accTruthParticleLink("truthParticleLink");
328 m_bIsTruthParticleLinkAvailable.set (accTruthParticleLink.isAvailable(xTau));
329 }
330
332 if (!m_bForceCheckTruthMatch) return StatusCode::SUCCESS;
333 }
334
335 // only search for truth taus once
336
337 // need to be reviewed
338
340 return checkTruthMatch(xTau, *truthTausEvent.m_xTruthTauContainerConst, truthTausEvent);
341 else
342 return checkTruthMatch(xTau, *truthTausEvent.m_xTruthTauContainer, truthTausEvent);
343}
Gaudi::Property< bool > m_bForceCheckTruthMatch
CxxUtils::CachedValue< bool > m_bIsTruthParticleLinkAvailable
CxxUtils::CachedValue< bool > m_bIsTruthMatchedAvailable
StatusCode checkTruthMatch(const xAOD::TauJet &xTau, const xAOD::TruthParticleContainer &xTauContainer, const TruthTausEvent &truthTausEvent) const
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:570

◆ getDecayMode() [1/2]

xAOD::TauJetParameters::DecayMode TauTruthMatchingTool::getDecayMode ( const xAOD::TauJet & xTau)
finaloverridevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 261 of file TauTruthMatchingTool.cxx.

262{
263 const xAOD::TruthParticle* xTruthTau = getTruth(xTau);
264 if (xTruthTau == nullptr)
265 {
266 ATH_MSG_DEBUG("no truth particle was found, return Mode_Error");
268 }
269 static const SG::ConstAccessor<size_t> accNumCharged("numCharged");
270 if (!accNumCharged.isAvailable(*xTruthTau))
271 {
272 ATH_MSG_INFO("found truth particle is not a truth tau, return Mode_Error");
274 }
275 return getDecayMode(*xTruthTau);
276}
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
virtual xAOD::TauJetParameters::DecayMode getDecayMode(const xAOD::TauJet &xTau) override final
virtual const xAOD::TruthParticle * getTruth(const xAOD::TauJet &xTau) override final

◆ getDecayMode() [2/2]

xAOD::TauJetParameters::DecayMode TauTruthMatchingTool::getDecayMode ( const xAOD::TruthParticle & xTruthTau) const
finaloverridevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 279 of file TauTruthMatchingTool.cxx.

280{
281 static const SG::ConstAccessor<size_t> accNumCharged("numCharged");
282 if (!accNumCharged.isAvailable(xTruthTau))
283 {
284 ATH_MSG_WARNING("passed truth particle is not a truth tau, return Mode_Error");
286 }
287
288 int iCharged = getNTauDecayParticles(xTruthTau,MC::PIPLUS, true) + getNTauDecayParticles(xTruthTau,MC::KPLUS, true);
289 int iNeutral = getNTauDecayParticles(xTruthTau,MC::PI0, true);
290 if (iCharged == 1)
291 {
292 if (iNeutral == 0) return xAOD::TauJetParameters::DecayMode::Mode_1p0n;
293 if (iNeutral == 1) return xAOD::TauJetParameters::DecayMode::Mode_1p1n;
294 if (iNeutral >= 2) return xAOD::TauJetParameters::DecayMode::Mode_1pXn;
295 }
296 else if (iCharged == 3)
297 {
298 if (iNeutral == 0) return xAOD::TauJetParameters::DecayMode::Mode_3p0n;
299 if (iNeutral >= 1) return xAOD::TauJetParameters::DecayMode::Mode_3pXn;
300 }
301
302 if (iCharged == 2 or iCharged == 4 or iCharged == 5)
304 if (iCharged == 0 or iCharged >=6)
306
307 // if you got here, something should have gone wrong
309}
virtual int getNTauDecayParticles(const xAOD::TauJet &xTau, int iPdgId, bool bCompareAbsoluteValues=false) override final
static const int PI0
static const int KPLUS
static const int PIPLUS

◆ getEvent()

std::unique_ptr< TauTruthMatchingTool::ITruthTausEvent > TauTruthMatchingTool::getEvent ( ) const
finaloverrideprivatevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 38 of file TauTruthMatchingTool.cxx.

39{
40 const EventContext& ctx = Gaudi::Hive::currentContext();
41 auto truthTausEvent = std::make_unique<TruthTausEvent>();
42 if (retrieveTruthTaus(*truthTausEvent, ctx).isFailure()) {
43 truthTausEvent.reset();
44 }
45 return truthTausEvent;
46}
virtual StatusCode retrieveTruthTaus() override

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::TEvent, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::TEvent, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getNTauDecayParticles() [1/2]

int TauTruthMatchingTool::getNTauDecayParticles ( const xAOD::TauJet & xTau,
int iPdgId,
bool bCompareAbsoluteValues = false )
finaloverridevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 220 of file TauTruthMatchingTool.cxx.

221{
222 const xAOD::TruthParticle* xTruthTau = getTruth(xTau);
223 if (xTruthTau == nullptr)
224 {
225 ATH_MSG_DEBUG("no truth particle was found, return 0");
226 return 0;
227 }
228 static const SG::ConstAccessor<std::vector<int> > accDecayModeVector("DecayModeVector");
229 if (!accDecayModeVector.isAvailable(*xTruthTau))
230 {
231 ATH_MSG_INFO("found truth particle is not a truth tau, return 0");
232 return 0;
233 }
234 return getNTauDecayParticles(*xTruthTau,iPdgId, bCompareAbsoluteValues);
235}

◆ getNTauDecayParticles() [2/2]

int TauTruthMatchingTool::getNTauDecayParticles ( const xAOD::TruthParticle & xTruthTau,
int iPdgId,
bool bCompareAbsoluteValues = false ) const
finaloverridevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 238 of file TauTruthMatchingTool.cxx.

239{
240 int iNum = 0;
241 static const SG::ConstAccessor<std::vector<int> > accDecayModeVector("DecayModeVector");
242 if (!accDecayModeVector.isAvailable(xTruthTau))
243 {
244 ATH_MSG_WARNING("passed truth particle is not a truth tau, return 0");
245 return 0;
246 }
247
248 for(auto iPdgId2 : accDecayModeVector(xTruthTau))
249 if (!bCompareAbsoluteValues)
250 {
251 if (iPdgId2 == iPdgId) iNum++;
252 }
253 else
254 {
255 if (std::abs(iPdgId2) == std::abs(iPdgId)) iNum++;
256 }
257 return iNum;
258}

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ getTruth() [1/3]

std::vector< const xAOD::TruthParticle * > TauTruthMatchingTool::getTruth ( const std::vector< const xAOD::TauJet * > & vTaus)
finaloverrideprivatevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 98 of file TauTruthMatchingTool.cxx.

99{
100 std::vector<const xAOD::TruthParticle*> vTruths;
101 for (auto xTau : vTaus)
102 vTruths.push_back(getTruth(*xTau));
103 return vTruths;
104}

◆ getTruth() [2/3]

const xAOD::TruthParticle * TauTruthMatchingTool::getTruth ( const xAOD::TauJet & xTau)
finaloverrideprivatevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 49 of file TauTruthMatchingTool.cxx.

50{
51 return getTruth (xTau, m_truthTausEvent);
52}

◆ getTruth() [3/3]

const xAOD::TruthParticle * TauTruthMatchingTool::getTruth ( const xAOD::TauJet & xTau,
ITruthTausEvent & truthTausEVent ) const
finaloverrideprivatevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 55 of file TauTruthMatchingTool.cxx.

57{
58 TruthTausEvent& truthTausEvent = dynamic_cast<TruthTausEvent&> (itruthTausEvent);
59 const EventContext& ctx = Gaudi::Hive::currentContext();
60 if (retrieveTruthTaus(truthTausEvent, ctx).isFailure())
61 return nullptr;
62
63 if (findTruthTau(xTau, truthTausEvent).isFailure())
64 ATH_MSG_WARNING("There was a failure in finding the matched truth tau");
65
66 static const SG::ConstAccessor<char> accIsTruthMatched("IsTruthMatched");
67 static const SG::ConstAccessor< ElementLink< xAOD::TruthParticleContainer > > accTruthParticleLink("truthParticleLink");
68
69 // derivations may drop IsTruthMatched, redecorate using truthParticleLink (this assumes links to truth leptons are preserved, i.e. TruthTaus, TruthElectron, TruthMuon)
71 ATH_MSG_DEBUG("TauJetContainer has truthParticleLink available while IsTruthMatched not available. Re-evaluate IsTruthMatched");
72 static const SG::Decorator<char> decIsTruthMatched("IsTruthMatched");
73 if (accTruthParticleLink(xTau)) {
74 decIsTruthMatched(xTau) = (char)true;
75 } else {
76 decIsTruthMatched(xTau) = (char)false;
77 }
78 }
79
80 // if matched to a truth particle return its pointer, else return a null pointer
81 if (static_cast<bool>(accIsTruthMatched(xTau)))
82 {
83 if (accTruthParticleLink(xTau).isValid())
84 {
85 return *accTruthParticleLink(xTau);
86 }
87 else
88 {
89 ATH_MSG_WARNING("ElementLink to TruthParticle is not valid.");
90 return nullptr;
91 }
92 }
93
94 return nullptr;
95}
StatusCode findTruthTau(const xAOD::TauJet &xTau, TruthTausEvent &truthTausEvent) const

◆ getTruthParticleType()

TauAnalysisTools::TruthMatchedParticleType TauTruthMatchingTool::getTruthParticleType ( const xAOD::TauJet & xTau)
finaloverridevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 174 of file TauTruthMatchingTool.cxx.

175{
177}
TruthMatchedParticleType getTruthParticleType(const xAOD::TauJet &xTau)
return TauJet match type

◆ getTruthTauP4Invis() [1/2]

TLorentzVector TauTruthMatchingTool::getTruthTauP4Invis ( const xAOD::TauJet & xTau)
finaloverridevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 140 of file TauTruthMatchingTool.cxx.

141{
142 const xAOD::TruthParticle* xTruthTau = getTruth(xTau);
143 TLorentzVector vTLV;
144 if (xTruthTau == nullptr)
145 {
146 ATH_MSG_INFO("no truth particle was found, returning TLorentzVector with all values equal to 0");
147 } else {
148 vTLV = getTruthTauP4Invis(*xTruthTau);
149 }
150 return vTLV;
151}
virtual TLorentzVector getTruthTauP4Invis(const xAOD::TauJet &xTau) override final

◆ getTruthTauP4Invis() [2/2]

TLorentzVector TauTruthMatchingTool::getTruthTauP4Invis ( const xAOD::TruthParticle & xTruthTau) const
finaloverridevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 154 of file TauTruthMatchingTool.cxx.

155{
156 TLorentzVector vTLV;
157
158 static const SG::ConstAccessor<double> accPtInvis("pt_invis");
159 static const SG::ConstAccessor<double> accEtaInvis("eta_invis");
160 static const SG::ConstAccessor<double> accPhiInvis("phi_invis");
161 static const SG::ConstAccessor<double> accMInvis("m_invis");
162
163 if (!accPtInvis.isAvailable(xTruthTau))
164 return vTLV;
165 vTLV.SetPtEtaPhiM(
166 accPtInvis(xTruthTau),
167 accEtaInvis(xTruthTau),
168 accPhiInvis(xTruthTau),
169 accMInvis(xTruthTau));
170 return vTLV;
171}

◆ getTruthTauP4Vis() [1/2]

TLorentzVector TauTruthMatchingTool::getTruthTauP4Vis ( const xAOD::TauJet & xTau)
finaloverridevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 111 of file TauTruthMatchingTool.cxx.

112{
113 const xAOD::TruthParticle* xTruthTau = getTruth(xTau);
114 TLorentzVector vTLV;
115 if (xTruthTau == nullptr)
116 {
117 ATH_MSG_INFO("no truth particle was found, returning TLorentzVector with all values equal to 0");
118 } else {
119 vTLV = getTruthTauP4Vis(*xTruthTau);
120 }
121 return vTLV;
122}
virtual TLorentzVector getTruthTauP4Vis(const xAOD::TauJet &xTau) override final

◆ getTruthTauP4Vis() [2/2]

TLorentzVector TauTruthMatchingTool::getTruthTauP4Vis ( const xAOD::TruthParticle & xTruthTau) const
finaloverridevirtual

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 125 of file TauTruthMatchingTool.cxx.

126{
127 TLorentzVector vTLV;
128 static const SG::ConstAccessor<double> acc ("pt_vis");
129 if (!acc.isAvailable(xTruthTau))
130 return vTLV;
131 vTLV.SetPtEtaPhiM(
132 m_accPtVis(xTruthTau),
133 m_accEtaVis(xTruthTau),
134 m_accPhiVis(xTruthTau),
135 m_accMVis(xTruthTau));
136 return vTLV;
137}

◆ handle()

void asg::AsgMetadataTool::handle ( const Incident & inc)
protectedvirtualinherited

Function receiving incidents from IncidentSvc/TEvent.

Reimplemented in Trig::TrigDecisionTool.

Definition at line 135 of file AsgMetadataTool.cxx.

135 {
136
137 // Tell the user what's happening:
138 ATH_MSG_VERBOSE( "Callback received with incident: " << inc.type() );
139
140 // Call the appropriate member function:
141 if( inc.type() == IncidentType::BeginInputFile ) {
143 if( beginInputFile().isFailure() ) {
144 ATH_MSG_FATAL( "Failed to call beginInputFile()" );
145 throw std::runtime_error( "Couldn't call beginInputFile()" );
146 }
147 } else if( inc.type() == IncidentType::EndInputFile ) {
148 if( endInputFile().isFailure() ) {
149 ATH_MSG_FATAL( "Failed to call endInputFile()" );
150 throw std::runtime_error( "Couldn't call endInputFile()" );
151 }
152 } else if( inc.type() == IncidentType::BeginEvent ) {
153 // If the tool didn't catch the begin input file incident for the
154 // first input file of the job, then call the appropriate function
155 // now.
156 if( ! m_beginInputFileCalled ) {
158 if( beginInputFile().isFailure() ) {
159 ATH_MSG_FATAL( "Failed to call beginInputFile()" );
160 throw std::runtime_error( "Couldn't call beginInputFile()" );
161 }
162 }
163 if( beginEvent().isFailure() ) {
164 ATH_MSG_FATAL( "Failed to call beginEvent()" );
165 throw std::runtime_error( "Couldn't call beginEvent()" );
166 }
167
168 #ifdef XAOD_STANDALONE
169 } else if( inc.type() == IncidentType::MetaDataStop ) {
170 if( metaDataStop().isFailure() ) {
171 ATH_MSG_FATAL( "Failed to call metaDataStop()" );
172 throw std::runtime_error( "Couldn't call metaDataStop()" );
173 }
174
175 #endif // XAOD_STANDALONE
176 } else {
177 ATH_MSG_WARNING( "Unknown incident type received in AsgMetaDataTool: " << inc.type() );
178 }
179
180 return;
181 }
#define ATH_MSG_FATAL(x)
virtual StatusCode beginInputFile()
Function called when a new input file is opened.
virtual StatusCode beginEvent()
Function called when a new events is loaded.
bool m_beginInputFileCalled
Flag helping to discover when the tool misses the opening of the first input file.
virtual StatusCode endInputFile()
Function called when the currently open input file got completely processed.
virtual StatusCode metaDataStop()
Function called when the tool should write out its metadata.

◆ initialize()

StatusCode TauTruthMatchingTool::initialize ( void )
finaloverrideprivatevirtual

Reimplemented from TauAnalysisTools::BuildTruthTaus.

Definition at line 22 of file TauTruthMatchingTool.cxx.

23{
24 ATH_MSG_INFO( "Initializing TauTruthMatchingTool" );
25
26 // configure BuildTruthTaus in truth matching mode, not truth tau building mode
27 TauTruthMatchingTool::BuildTruthTaus::setTruthMatchingMode();
28
29 if (TauTruthMatchingTool::BuildTruthTaus::initialize().isFailure())
30 {
31 ATH_MSG_FATAL("Failed initializing BuildTruthTaus");
32 return StatusCode::FAILURE;
33 }
34 return StatusCode::SUCCESS;
35}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ inputMetaStore()

AsgMetadataTool::MetaStorePtr_t asg::AsgMetadataTool::inputMetaStore ( ) const
inherited

Accessor for the input metadata store.

Definition at line 93 of file AsgMetadataTool.cxx.

93 {
94
95#ifdef XAOD_STANDALONE
96 return &m_inputMetaStore;
97#else // XAOD_STANDALONE
98 return m_inputMetaStore;
99#endif // XAOD_STANDALONE
100 }
MetaStore_t m_inputMetaStore
Object accessing the input metadata store.

◆ lockDecorations()

StatusCode TauTruthMatchingTool::lockDecorations ( const xAOD::TauJetContainer & taus) const
finaloverridevirtual

Decorations produced by an algorithm need to be locked; otherwise, they will be ignored by deep copies.

The interfaces of this tool take a single object at a time, so we can't do the locking there. Instead, call this method after all taus in a container have been processed.

Implements TauAnalysisTools::ITauTruthMatchingTool.

Definition at line 477 of file TauTruthMatchingTool.cxx.

478{
480 static const SG::Decorator<char> decIsTruthMatched("IsTruthMatched");
481 static const SG::Decorator< ElementLink< xAOD::JetContainer > > decTruthJetLink("truthJetLink");
482 static const SG::Decorator< ElementLink< xAOD::TruthParticleContainer > > decTruthParticleLink("truthParticleLink");
483 taus_nc.lockDecoration (decIsTruthMatched.auxid());
484 taus_nc.lockDecoration (decTruthJetLink.auxid());
485 taus_nc.lockDecoration (decTruthParticleLink.auxid());
486 return StatusCode::SUCCESS;
487}
static Double_t taus
#define ATLAS_THREAD_SAFE
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".

◆ matchTruthLeptonicTauDecay()

bool TauTruthMatchingTool::matchTruthLeptonicTauDecay ( const xAOD::IParticle * p,
const xAOD::TruthParticleContainer * truth_taus )

Definition at line 180 of file TauTruthMatchingTool.cxx.

181{
182 // input check
183 if (p->type() != xAOD::Type::Muon && p->type() != xAOD::Type::Electron)
184 return false;
185
186 // loop over truth_tau container
187 for (auto truth_tau : *truth_taus) {
188 if (!truth_tau->isTau()) {
189 continue;
190 }
191 static const SG::ConstAccessor<char> accIsHadronicTau ("IsHadronicTau");
192 if( accIsHadronicTau(*truth_tau)){
193 continue;
194 }
195
196 static const SG::ConstAccessor<std::vector<int> > accDecayModeVector("DecayModeVector");
197 if (accDecayModeVector.isAvailable(*truth_tau))
198 {
199 std::vector<int> vDecayMode = accDecayModeVector(*truth_tau);
200 for (auto decayMode : vDecayMode) {
201 if (p->type() == xAOD::Type::Electron) {
202 if (fabs(decayMode) != 11)
203 continue;
204 } else if (p->type() == xAOD::Type::Muon) {
205 if (fabs(decayMode) != 13)
206 continue;
207 }
208 TLorentzVector vis = getTruthTauP4Vis(*truth_tau);
209 if (vis.DeltaR(p->p4()) < 0.2) {
210 return true;
211 }
212 }
213 }
214 }
215 // matching not found
216 return false;
217}
@ Muon
The object is a muon.
Definition ObjectType.h:48
@ Electron
The object is an electron.
Definition ObjectType.h:46

◆ metaDataStop()

StatusCode asg::AsgMetadataTool::metaDataStop ( )
protectedvirtualinherited

Function called when the tool should write out its metadata.

Dummy implementation that can be overridden by the derived tool.

Reimplemented in BookkeeperDumperTool, BookkeeperTool, xAODMaker::TriggerMenuMetaDataTool, and xAODMaker::TruthMetaDataTool.

Definition at line 209 of file AsgMetadataTool.cxx.

209 {
210
211 // Return gracefully:
212 return StatusCode::SUCCESS;
213 }

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ outputMetaStore()

AsgMetadataTool::MetaStorePtr_t asg::AsgMetadataTool::outputMetaStore ( ) const
inherited

Accessor for the output metadata store.

Definition at line 102 of file AsgMetadataTool.cxx.

102 {
103
104#ifdef XAOD_STANDALONE
105 return &m_outputMetaStore;
106#else // XAOD_STANDALONE
107 return m_outputMetaStore;
108#endif // XAOD_STANDALONE
109 }
MetaStore_t m_outputMetaStore
Object accessing the output metadata store.

◆ print()

◆ printDecay()

void BuildTruthTaus::printDecay ( const xAOD::TruthParticle & xTruthParticle,
int depth = 0 ) const
privateinherited

Definition at line 469 of file BuildTruthTaus.cxx.

470{
471 // loop over all decay particles, print their kinematic and other properties
472
473 const xAOD::TruthVertex* xDecayVertex = xTruthParticle.decayVtx();
474 if (xDecayVertex == nullptr)
475 return;
476
477 for ( size_t iOutgoingParticle = 0; iOutgoingParticle < xDecayVertex->nOutgoingParticles(); ++iOutgoingParticle )
478 {
479 const xAOD::TruthParticle* xTruthDaughter = xDecayVertex->outgoingParticle(iOutgoingParticle);
480 if (xTruthDaughter == nullptr)
481 {
482 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.");
483 return;
484 }
485 ATH_MSG_WARNING("depth "<<depth
486 <<" e "<<xTruthDaughter->e()
487 <<" eta "<<xTruthDaughter->p4().Eta()
488 <<" phi "<<xTruthDaughter->p4().Phi()
489 <<" pdgid "<<xTruthDaughter->pdgId()
490 <<" status "<<xTruthDaughter->status()
491 <<" uniqueID "<<HepMC::uniqueID(xTruthDaughter));
492 printDecay(*xTruthDaughter, depth+1);
493 }
494}
int status() const
Status code.
virtual double e() const override final
The total energy of the particle.
std::string depth
tag string for intendation
Definition fastadd.cxx:46

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ retrieveTruthTaus() [1/2]

StatusCode BuildTruthTaus::retrieveTruthTaus ( )
overrideprivatevirtualinherited

Implements TauAnalysisTools::IBuildTruthTaus.

Definition at line 83 of file BuildTruthTaus.cxx.

84{
85 const EventContext& ctx = Gaudi::Hive::currentContext();
87}
StatusCode retrieveTruthTausImpl(TruthTausEvent &truthTausEvent, const EventContext &ctx) const

◆ retrieveTruthTaus() [2/2]

StatusCode BuildTruthTaus::retrieveTruthTaus ( ITruthTausEvent & truthTausEvent,
const EventContext & ctx ) const
overrideprivatevirtualinherited

Implements TauAnalysisTools::IBuildTruthTaus.

Definition at line 90 of file BuildTruthTaus.cxx.

91{
92 return retrieveTruthTausImpl (dynamic_cast<TruthTausEvent&> (truthTausEvent), ctx);
93}

◆ retrieveTruthTausImpl()

StatusCode BuildTruthTaus::retrieveTruthTausImpl ( TruthTausEvent & truthTausEvent,
const EventContext & ctx ) const
protectedinherited

Definition at line 96 of file BuildTruthTaus.cxx.

97{
98 // truth matching mode
100 if (!m_truthElectronContainer.empty()) {
101 SG::ReadHandle<xAOD::TruthParticleContainer> truthElectronsHandle(m_truthElectronContainer, ctx);
102 if (!truthElectronsHandle.isValid()) {
103 ATH_MSG_ERROR ("Could not retrieve " << truthElectronsHandle.key());
104 return StatusCode::FAILURE;
105 }
106 truthTausEvent.m_xTruthElectronContainerConst = truthElectronsHandle.cptr();
107 }
108
109 if (!m_truthMuonContainer.empty()) {
110 SG::ReadHandle<xAOD::TruthParticleContainer> truthMuonsHandle(m_truthMuonContainer, ctx);
111 if (!truthMuonsHandle.isValid()) {
112 ATH_MSG_ERROR ("Could not retrieve " << truthMuonsHandle.key());
113 return StatusCode::FAILURE;
114 }
115 truthTausEvent.m_xTruthMuonContainerConst = truthMuonsHandle.cptr();
116 }
117
118 if (!m_truthJetContainer.empty()) {
119 SG::ReadHandle<xAOD::JetContainer> truthJetsHandle(m_truthJetContainer, ctx);
120 if (!truthJetsHandle.isValid()) {
121 ATH_MSG_ERROR ("Could not retrieve " << truthJetsHandle.key());
122 return StatusCode::FAILURE;
123 }
124 truthTausEvent.m_xTruthJetContainerConst = truthJetsHandle.cptr();
125 }
126
127 SG::ReadHandle<xAOD::TruthParticleContainer> truthTausHandle(m_truthTauInputContainer, ctx);
128 if (!truthTausHandle.isValid()) {
129 ATH_MSG_ERROR ("Could not retrieve " << truthTausHandle.key());
130 return StatusCode::FAILURE;
131 }
132 truthTausEvent.m_xTruthTauContainerConst = truthTausHandle.cptr();
133 }
134 // truth tau building mode
135 else {
136 SG::ReadHandle<xAOD::TruthParticleContainer> truthParticlesHandle(m_truthParticleContainer, ctx);
137 if (!truthParticlesHandle.isValid()) {
138 ATH_MSG_ERROR ("Could not retrieve " << truthParticlesHandle.key());
139 return StatusCode::FAILURE;
140 }
141 truthTausEvent.m_xTruthParticleContainer = truthParticlesHandle.cptr();
142
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();
147
148 auto writeHandle = SG::makeHandle(m_truthTauOutputContainer, ctx);
149 ATH_CHECK(writeHandle.record(std::move(truthTausOutput), std::move(truthTausOutputAux)));
150
151 ATH_CHECK( buildTruthTausFromTruthParticles(truthTausEvent, ctx) );
152 }
153
154 return StatusCode::SUCCESS;
155}
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthElectronContainer
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthMuonContainer
SG::ReadHandleKey< xAOD::JetContainer > m_truthJetContainer
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_truthTauOutputContainer
StatusCode buildTruthTausFromTruthParticles(TruthTausEvent &truthTausEvent, const EventContext &ctx) const
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthTauInputContainer
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())

◆ setTruthMatchingMode()

virtual void TauAnalysisTools::BuildTruthTaus::setTruthMatchingMode ( )
inlineoverrideprivatevirtualinherited

Implements TauAnalysisTools::IBuildTruthTaus.

Definition at line 65 of file BuildTruthTaus.h.

65 {
67 };

◆ setUseIncidents()

void asg::AsgMetadataTool::setUseIncidents ( const bool flag)
inlineprotectedinherited

Definition at line 132 of file AsgMetadataTool.h.

133 {
135 }
bool flag
Definition master.py:29

◆ sysInitialize()

StatusCode asg::AsgMetadataTool::sysInitialize ( )
virtualinherited

Function initialising the tool in the correct way in Athena.

This function is used to set up the callbacks from IncidentSvc in Athena at the right time during initialisation, without the user having to do anything special in his/her code.

Reimplemented from AthCommonDataStore< AthCommonMsg< AlgTool > >.

Definition at line 115 of file AsgMetadataTool.cxx.

115 {
116
117#ifndef XAOD_STANDALONE
118 if (m_useIncidents) {
119 // Connect to the IncidentSvc:
120 ServiceHandle< IIncidentSvc > incSvc( "IncidentSvc", name() );
121 ATH_CHECK( incSvc.retrieve() );
122
123 // Set up the right callbacks: don't rethrow exceptions, any failure and we should end
124 incSvc->addListener( this, IncidentType::BeginEvent, 0, false );
125 }
126 // Let the base class do its thing:
127 ATH_CHECK( AlgTool::sysInitialize() );
128
129#endif // not XAOD_STANDALONE
130
131 // Return gracefully:
132 return StatusCode::SUCCESS;
133 }

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ ~TauTruthMatchingTool()

virtual ASG_TOOL_CLASS2(TauTruthMatchingTool, TauAnalysisTools::IBuildTruthTaus, TauAnalysisTools::ITauTruthMatchingTool) public TauAnalysisTools::TauTruthMatchingTool::~TauTruthMatchingTool ( )
privatevirtualdefault

Create a proper constructor for Athena.

Member Data Documentation

◆ m_accEtaVis

SG::ConstAccessor<double> TauAnalysisTools::TauTruthMatchingTool::m_accEtaVis
private

Definition at line 96 of file TauTruthMatchingTool.h.

◆ m_accMVis

SG::ConstAccessor<double> TauAnalysisTools::TauTruthMatchingTool::m_accMVis
private

Definition at line 98 of file TauTruthMatchingTool.h.

◆ m_accPhiVis

SG::ConstAccessor<double> TauAnalysisTools::TauTruthMatchingTool::m_accPhiVis
private

Definition at line 97 of file TauTruthMatchingTool.h.

◆ m_accPtVis

SG::ConstAccessor<double> TauAnalysisTools::TauTruthMatchingTool::m_accPtVis
private

Definition at line 95 of file TauTruthMatchingTool.h.

◆ m_beginInputFileCalled

bool asg::AsgMetadataTool::m_beginInputFileCalled
privateinherited

Flag helping to discover when the tool misses the opening of the first input file.

Definition at line 126 of file AsgMetadataTool.h.

◆ m_bForceCheckTruthMatch

Gaudi::Property<bool> TauAnalysisTools::BuildTruthTaus::m_bForceCheckTruthMatch { this, "ForceCheckTruthMatch", false}
privateinherited

Definition at line 72 of file BuildTruthTaus.h.

72{ this, "ForceCheckTruthMatch", false};

◆ m_bIsTruthMatchedAvailable

CxxUtils::CachedValue<bool> TauAnalysisTools::TauTruthMatchingTool::m_bIsTruthMatchedAvailable
private

Definition at line 90 of file TauTruthMatchingTool.h.

◆ m_bIsTruthParticleLinkAvailable

CxxUtils::CachedValue<bool> TauAnalysisTools::TauTruthMatchingTool::m_bIsTruthParticleLinkAvailable
private

Definition at line 91 of file TauTruthMatchingTool.h.

◆ m_bTruthTauAvailable

bool TauAnalysisTools::BuildTruthTaus::m_bTruthTauAvailable {}
protectedinherited

Definition at line 116 of file BuildTruthTaus.h.

116{};

◆ m_bWriteDecayModeVector

Gaudi::Property<bool> TauAnalysisTools::BuildTruthTaus::m_bWriteDecayModeVector { this, "WriteDecayModeVector", true}
privateinherited

Definition at line 126 of file BuildTruthTaus.h.

126{ this, "WriteDecayModeVector", true};

◆ m_bWriteInvisibleFourMomentum

Gaudi::Property<bool> TauAnalysisTools::BuildTruthTaus::m_bWriteInvisibleFourMomentum { this, "WriteInvisibleFourMomentum", false}
privateinherited

Definition at line 121 of file BuildTruthTaus.h.

121{ this, "WriteInvisibleFourMomentum", false};

◆ m_bWriteVertices

Gaudi::Property<bool> TauAnalysisTools::BuildTruthTaus::m_bWriteVertices { this, "WriteVertices", true}
privateinherited

Definition at line 127 of file BuildTruthTaus.h.

127{ this, "WriteVertices", true};

◆ m_bWriteVisibleChargedFourMomentum

Gaudi::Property<bool> TauAnalysisTools::BuildTruthTaus::m_bWriteVisibleChargedFourMomentum { this, "WriteVisibleChargedFourMomentum", false}
privateinherited

Definition at line 122 of file BuildTruthTaus.h.

122{ this, "WriteVisibleChargedFourMomentum", false};

◆ m_bWriteVisibleChargedFourMomentumComponent

Gaudi::Property<bool> TauAnalysisTools::BuildTruthTaus::m_bWriteVisibleChargedFourMomentumComponent { this, "WriteVisibleChargedFourMomentumComponent", false}
privateinherited

Definition at line 123 of file BuildTruthTaus.h.

123{ this, "WriteVisibleChargedFourMomentumComponent", false};

◆ m_bWriteVisibleNeutralFourMomentum

Gaudi::Property<bool> TauAnalysisTools::BuildTruthTaus::m_bWriteVisibleNeutralFourMomentum { this, "WriteVisibleNeutralFourMomentum", false}
privateinherited

Definition at line 124 of file BuildTruthTaus.h.

124{ this, "WriteVisibleNeutralFourMomentum", false};

◆ m_bWriteVisibleNeutralFourMomentumComponent

Gaudi::Property<bool> TauAnalysisTools::BuildTruthTaus::m_bWriteVisibleNeutralFourMomentumComponent { this, "WriteVisibleNeutralFourMomentumComponent", false}
privateinherited

Definition at line 125 of file BuildTruthTaus.h.

125{ this, "WriteVisibleNeutralFourMomentumComponent", false};

◆ m_classificationDecoratorKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_classificationDecoratorKey {this, "Classification", "TruthTaus.Classification", "Name of the decoration which records the particle classification"}
privateinherited

Definition at line 148 of file BuildTruthTaus.h.

148{this, "Classification", "TruthTaus.Classification", "Name of the decoration which records the particle classification"};

◆ m_classificationReadDecorKey

SG::ReadDecorHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_classificationReadDecorKey {this, "inputClassification", "TruthParticles.Classification", "Classification code"}
privateinherited

Definition at line 142 of file BuildTruthTaus.h.

142{this, "inputClassification", "TruthParticles.Classification", "Classification code"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_dMaxDeltaR

Gaudi::Property<double> TauAnalysisTools::TauTruthMatchingTool::m_dMaxDeltaR {this, "MaxDeltaR", 0.2}
private

Definition at line 88 of file TauTruthMatchingTool.h.

88{this, "MaxDeltaR", 0.2};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_inputMetaStore

MetaStore_t asg::AsgMetadataTool::m_inputMetaStore
privateinherited

Object accessing the input metadata store.

Definition at line 119 of file AsgMetadataTool.h.

◆ m_linkDecoratorKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_linkDecoratorKey {this, "originalTruthParticle", "TruthTaus.originalTruthParticle", "Name of the decoration linking to the original truth particle"}
privateinherited

Definition at line 144 of file BuildTruthTaus.h.

144{this, "originalTruthParticle", "TruthTaus.originalTruthParticle", "Name of the decoration linking to the original truth particle"};

◆ m_originDecoratorKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_originDecoratorKey {this, "classifierParticleOrigin", "TruthTaus.classifierParticleOrigin", "Name of the decoration which records the particle origin"}
privateinherited

Definition at line 145 of file BuildTruthTaus.h.

145{this, "classifierParticleOrigin", "TruthTaus.classifierParticleOrigin", "Name of the decoration which records the particle origin"};

◆ m_originReadDecorKey

SG::ReadDecorHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_originReadDecorKey {this, "inputClassifierParticleOrigin", "TruthParticles.classifierParticleOrigin", "Particle origin"}
privateinherited

Definition at line 139 of file BuildTruthTaus.h.

139{this, "inputClassifierParticleOrigin", "TruthParticles.classifierParticleOrigin", "Particle origin"};

◆ m_outcomeDecoratorKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_outcomeDecoratorKey {this, "classifierParticleOutCome", "TruthTaus.classifierParticleOutCome", "Name of the decoration which records the particle outcome"}
privateinherited

Definition at line 147 of file BuildTruthTaus.h.

147{this, "classifierParticleOutCome", "TruthTaus.classifierParticleOutCome", "Name of the decoration which records the particle outcome"};

◆ m_outcomeReadDecorKey

SG::ReadDecorHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_outcomeReadDecorKey {this, "inputClassifierParticleOutCome", "TruthParticles.classifierParticleOutCome", "Particle outcome"}
privateinherited

Definition at line 141 of file BuildTruthTaus.h.

141{this, "inputClassifierParticleOutCome", "TruthParticles.classifierParticleOutCome", "Particle outcome"};

◆ m_outputMetaStore

MetaStore_t asg::AsgMetadataTool::m_outputMetaStore
privateinherited

Object accessing the output metadata store.

Definition at line 121 of file AsgMetadataTool.h.

◆ m_truthElectronContainer

SG::ReadHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_truthElectronContainer { this, "TruthElectronContainerName", "TruthElectrons", "Truth electrons input container name" }
privateinherited

Definition at line 132 of file BuildTruthTaus.h.

132{ this, "TruthElectronContainerName", "TruthElectrons", "Truth electrons input container name" };

◆ m_truthJetContainer

SG::ReadHandleKey<xAOD::JetContainer> TauAnalysisTools::BuildTruthTaus::m_truthJetContainer { this, "TruthJetContainerName", "AntiKt4TruthDressedWZJets", "Truth jets input container name" }
privateinherited

Definition at line 134 of file BuildTruthTaus.h.

134{ this, "TruthJetContainerName", "AntiKt4TruthDressedWZJets", "Truth jets input container name" };

◆ m_truthMatchingMode

bool TauAnalysisTools::BuildTruthTaus::m_truthMatchingMode = false
privateinherited

Definition at line 150 of file BuildTruthTaus.h.

◆ m_truthMuonContainer

SG::ReadHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_truthMuonContainer { this, "TruthMuonContainerName", "TruthMuons", "Truth muons input container name" }
privateinherited

Definition at line 133 of file BuildTruthTaus.h.

133{ this, "TruthMuonContainerName", "TruthMuons", "Truth muons input container name" };

◆ m_truthParticleContainer

SG::ReadHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_truthParticleContainer { this, "TruthParticleContainerName", "TruthParticles", "Truth particles input container name" }
privateinherited

Definition at line 131 of file BuildTruthTaus.h.

131{ this, "TruthParticleContainerName", "TruthParticles", "Truth particles input container name" };

◆ m_truthTauInputContainer

SG::ReadHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_truthTauInputContainer { this, "TruthTauContainerName", "TruthTaus", "Truth tau input container name (truth matching mode)" }
privateinherited

Definition at line 130 of file BuildTruthTaus.h.

130{ this, "TruthTauContainerName", "TruthTaus", "Truth tau input container name (truth matching mode)" };

◆ m_truthTauOutputContainer

SG::WriteHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_truthTauOutputContainer { this, "NewTruthTauContainerName", "TruthTaus", "Truth tau output container name" }
privateinherited

Definition at line 136 of file BuildTruthTaus.h.

136{ this, "NewTruthTauContainerName", "TruthTaus", "Truth tau output container name" };

◆ m_truthTausEvent

TruthTausEvent TauAnalysisTools::BuildTruthTaus::m_truthTausEvent
protectedinherited

Definition at line 113 of file BuildTruthTaus.h.

◆ m_typeDecoratorKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_typeDecoratorKey {this, "classifierParticleType", "TruthTaus.classifierParticleType", "Name of the decoration which records the particle type"}
privateinherited

Definition at line 146 of file BuildTruthTaus.h.

146{this, "classifierParticleType", "TruthTaus.classifierParticleType", "Name of the decoration which records the particle type"};

◆ m_typeReadDecorKey

SG::ReadDecorHandleKey<xAOD::TruthParticleContainer> TauAnalysisTools::BuildTruthTaus::m_typeReadDecorKey {this, "inputClassifierParticleType", "TruthParticles.classifierParticleType", "Particle type"}
privateinherited

Definition at line 140 of file BuildTruthTaus.h.

140{this, "inputClassifierParticleType", "TruthParticles.classifierParticleType", "Particle type"};

◆ m_useIncidents

bool asg::AsgMetadataTool::m_useIncidents
privateinherited

Definition at line 128 of file AsgMetadataTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: