ATLAS Offline Software
Loading...
Searching...
No Matches
egammaTruthAssociationAlg Class Reference

Decorate egamma objects with truth information Creates egammaTruthParticles collection with links to reco objects. More...

#include <egammaTruthAssociationAlg.h>

Inheritance diagram for egammaTruthAssociationAlg:
Collaboration diagram for egammaTruthAssociationAlg:

Classes

struct  MCTruthInfo_t
struct  writeDecorHandles
 helper class to contain write decoration handles More...

Public Member Functions

 egammaTruthAssociationAlg (const std::string &name, ISvcLocator *pSvcLocator)
 constructor
virtual ~egammaTruthAssociationAlg ()=default
 destructor
virtual StatusCode initialize () override final
 initialize method
virtual StatusCode finalize () override final
 finalize method
virtual StatusCode execute (const EventContext &ctx) const override final
 execute on container
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
virtual void setFilterPassed (bool state, const EventContext &ctx) const
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

Protected Member Functions

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.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

template<class T>
StatusCode initializeDecorKeys (SG::WriteDecorHandleKeyArray< T > &keys, const std::string &name)
 A function that initializes the decor handles, but also checks the naming convention.
template<class T, class L>
StatusCode match (const EventContext &ctx, const xAOD::TruthParticleContainer &truthParticles, const SG::WriteDecorHandleKeyArray< T > &hkeys, const SG::AuxElement::Accessor< L > &linkAccess, xAOD::TruthParticleContainer *egammaTruthContainer) const
 Loop over elements in the reco container, decorate them with truth info and decorate the truth particles with links to the reco ones (reco<typeName>Link)
template<class T>
MCTruthInfo_t particleTruthClassifier (const EventContext &ctx, const T *) const
 return the result of MCTruthClassifier::particleTruthClassifier or do a second pass for electrons based on the cluster to find true photons
void getNewTruthParticle (const EventContext &ctx, xAOD::TruthParticleContainer &egammaTruthContainer, const xAOD::TruthParticle *truth, const xAOD::TruthParticleContainer *oldContainer) const
 Create a copy a truth particle, add it to the new getNewTruthParticle container and decorate it with a link to the original particle.
bool isPromptEgammaParticle (const EventContext &ctx, const xAOD::TruthParticle *truth) const
 Return true if the truth particle is a prompt electron or photon.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

Gaudi::Property< bool > m_doEgammaTruthContainer
 Create egamma truth container?
Gaudi::Property< bool > m_matchElectrons
 Match electrons?
Gaudi::Property< bool > m_matchPhotons
 Match photons?
Gaudi::Property< bool > m_matchForwardElectrons
 Match fwd electrons?
Gaudi::Property< bool > m_matchClusters
 Match clusters?
SG::WriteDecorHandleKeyArray< xAOD::CaloClusterContainerm_clusterDecKeys
 The egamma cluster decor handle key array.
Gaudi::Property< std::string > m_clusterDecName
 The egamma cluster name property used to initialize the WriteDecorHandleKeyArray.
SG::WriteDecorHandleKeyArray< xAOD::ElectronContainerm_electronDecKeys
 The electron container decor handle key array.
Gaudi::Property< std::string > m_electronDecName
 The electron container name property used to initialize the WriteDecorHandleKeyArray.
SG::WriteDecorHandleKeyArray< xAOD::ElectronContainerm_fwdElectronDecKeys
 The fwd electron container decor handle key array.
Gaudi::Property< std::string > m_fwdElectronDecName
 The fwd electron name property used to initialize the WriteDecorHandleKeyArray.
SG::WriteDecorHandleKeyArray< xAOD::PhotonContainerm_photonDecKeys
 The photon container decor handle key array.
Gaudi::Property< std::string > m_photonDecName
 The photon container name property used to initialize the WriteDecorHandleKeyArray.
SG::ReadHandleKey< xAOD::TruthEventContainerm_truthEventContainerKey
 Name of the truth event container.
SG::ReadHandleKey< xAOD::TruthParticleContainerm_truthParticleContainerKey
 Name of the truth particle container.
SG::WriteHandleKey< xAOD::TruthParticleContainerm_egammaTruthParticleContainerKey
 Name of the output egamma truth container.
Gaudi::Property< float > m_minPt
 Minimum Pt to enter egamma truth particle container.
Gaudi::Property< float > m_minPtFSR
 Minimum Pt for FSR to enter egamma truth particle container.
Gaudi::Property< bool > m_UPCmode
 Allow electron from photon in egamma truth particle container.
ToolHandle< IMCTruthClassifierm_mcTruthClassifier
 MCTruthClassifier.
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
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

Decorate egamma objects with truth information Creates egammaTruthParticles collection with links to reco objects.

Author
B. Lenzi J. Mitrevski C. Anastopoulos

Definition at line 40 of file egammaTruthAssociationAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ egammaTruthAssociationAlg()

egammaTruthAssociationAlg::egammaTruthAssociationAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

constructor

Definition at line 57 of file egammaTruthAssociationAlg.cxx.

59 : AthReentrantAlgorithm(name, pSvcLocator)
60{}

◆ ~egammaTruthAssociationAlg()

virtual egammaTruthAssociationAlg::~egammaTruthAssociationAlg ( )
virtualdefault

destructor

Member Function Documentation

◆ cardinality()

unsigned int AthCommonReentrantAlgorithm< Gaudi::Algorithm >::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.

64{
65 return 0;
66}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

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

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

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

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

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode egammaTruthAssociationAlg::execute ( const EventContext & ctx) const
finaloverridevirtual

execute on container

Definition at line 112 of file egammaTruthAssociationAlg.cxx.

113{
114
115 SG::WriteHandle<xAOD::TruthParticleContainer> egammaTruthContainer;
116
118
119 egammaTruthContainer = SG::WriteHandle<xAOD::TruthParticleContainer>(
121 ATH_CHECK(egammaTruthContainer.record(
122 std::make_unique<xAOD::TruthParticleContainer>(),
123 std::make_unique<xAOD::TruthParticleAuxContainer>()));
124
125 // Add a copy of electrons and photons to the truth egamma container
126 SG::ReadHandle<xAOD::TruthEventContainer> truthEvtContainer(
128
129 // only for serial running. Can remove check later
130 if (!truthEvtContainer.isValid() || truthEvtContainer->empty()) {
131 ATH_MSG_WARNING("Could not retrieve "
133 << " or container empty, returning");
134 return StatusCode::SUCCESS;
135 }
136
137 for (const auto& truthParticleLink :
138 truthEvtContainer->front()->truthParticleLinks()) {
139 if (!truthParticleLink.isValid())
140 continue;
141 const xAOD::TruthParticle* truthParticle = *truthParticleLink;
142 if (!isPromptEgammaParticle(ctx, truthParticle))
143 continue;
145 *egammaTruthContainer,
146 truthParticle,
147 truthParticleLink.getDataPtr());
148 }
149 }
150 // Decorate containers with truth info, including links to truth particles
151 // Decorate the truth particles with links to the reco ones
152
153 // note that in multithreading this must be valid; can't just fail with
154 // success.
155 SG::ReadHandle<xAOD::TruthParticleContainer> truthParticles(
157
158 // accessors
159 static const SG::AuxElement::Accessor<ClusterLink_t> accClusLink(
160 "recoClusterLink");
161 static const SG::AuxElement::Accessor<ElectronLink_t> accElLink(
162 "recoElectronLink");
163 static const SG::AuxElement::Accessor<PhotonLink_t> accPhLink(
164 "recoPhotonLink");
165
166 if (m_matchElectrons) {
167 ATH_MSG_DEBUG("About to match electrons");
168 ATH_CHECK(match(ctx,
169 *truthParticles,
171 accElLink,
172 egammaTruthContainer.ptr()));
173 }
174
175 if (m_matchPhotons) {
176 ATH_MSG_DEBUG("About to match photons");
177 ATH_CHECK(match(ctx,
178 *truthParticles,
180 accPhLink,
181 egammaTruthContainer.ptr()));
182 }
183
184 if (m_matchClusters) {
185 ATH_MSG_DEBUG("About to match clusters");
186 ATH_CHECK(match(ctx,
187 *truthParticles,
189 accClusLink,
190 egammaTruthContainer.ptr()));
191 }
192
194 ATH_MSG_DEBUG("About to match fwd electrons");
195 ATH_CHECK(match(ctx,
196 *truthParticles,
198 accElLink,
199 egammaTruthContainer.ptr()));
200 }
201
202 return StatusCode::SUCCESS;
203}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
Gaudi::Property< bool > m_doEgammaTruthContainer
Create egamma truth container?
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainerKey
Name of the truth particle container.
Gaudi::Property< bool > m_matchElectrons
Match electrons?
SG::WriteDecorHandleKeyArray< xAOD::ElectronContainer > m_fwdElectronDecKeys
The fwd electron container decor handle key array.
SG::WriteDecorHandleKeyArray< xAOD::PhotonContainer > m_photonDecKeys
The photon container decor handle key array.
Gaudi::Property< bool > m_matchClusters
Match clusters?
StatusCode match(const EventContext &ctx, const xAOD::TruthParticleContainer &truthParticles, const SG::WriteDecorHandleKeyArray< T > &hkeys, const SG::AuxElement::Accessor< L > &linkAccess, xAOD::TruthParticleContainer *egammaTruthContainer) const
Loop over elements in the reco container, decorate them with truth info and decorate the truth partic...
Gaudi::Property< bool > m_matchPhotons
Match photons?
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_egammaTruthParticleContainerKey
Name of the output egamma truth container.
SG::WriteDecorHandleKeyArray< xAOD::ElectronContainer > m_electronDecKeys
The electron container decor handle key array.
void getNewTruthParticle(const EventContext &ctx, xAOD::TruthParticleContainer &egammaTruthContainer, const xAOD::TruthParticle *truth, const xAOD::TruthParticleContainer *oldContainer) const
Create a copy a truth particle, add it to the new getNewTruthParticle container and decorate it with ...
bool isPromptEgammaParticle(const EventContext &ctx, const xAOD::TruthParticle *truth) const
Return true if the truth particle is a prompt electron or photon.
Gaudi::Property< bool > m_matchForwardElectrons
Match fwd electrons?
SG::WriteDecorHandleKeyArray< xAOD::CaloClusterContainer > m_clusterDecKeys
The egamma cluster decor handle key array.
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthEventContainerKey
Name of the truth event container.
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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

◆ extraOutputDeps()

const DataObjIDColl & AthCommonReentrantAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.

90{
91 // If we didn't find any symlinks to add, just return the collection
92 // from the base class. Otherwise, return the extended collection.
93 if (!m_extendedExtraObjects.empty()) {
95 }
97}
An algorithm that can be simultaneously executed in multiple threads.

◆ filterPassed()

virtual bool AthCommonReentrantAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Definition at line 96 of file AthCommonReentrantAlgorithm.h.

96 {
97 return execState( ctx ).filterPassed();
98 }
virtual bool filterPassed(const EventContext &ctx) const

◆ finalize()

StatusCode egammaTruthAssociationAlg::finalize ( )
finaloverridevirtual

finalize method

Definition at line 106 of file egammaTruthAssociationAlg.cxx.

107{
108 return StatusCode::SUCCESS;
109}

◆ getNewTruthParticle()

void egammaTruthAssociationAlg::getNewTruthParticle ( const EventContext & ctx,
xAOD::TruthParticleContainer & egammaTruthContainer,
const xAOD::TruthParticle * truth,
const xAOD::TruthParticleContainer * oldContainer ) const
private

Create a copy a truth particle, add it to the new getNewTruthParticle container and decorate it with a link to the original particle.

Definition at line 243 of file egammaTruthAssociationAlg.cxx.

248{
249 auto *truthParticle = egammaTruthContainer.push_back(std::make_unique<xAOD::TruthParticle>());
250 truthParticle->setPdgId(truth->pdgId());
251 truthParticle->setUid(HepMC::uniqueID(truth));
252 truthParticle->setStatus(truth->status());
253 truthParticle->setPx(truth->px());
254 truthParticle->setPy(truth->py());
255 truthParticle->setPz(truth->pz());
256 truthParticle->setE(truth->e());
257 truthParticle->setM(truth->m());
258 truthParticle->setProdVtxLink(truth->prodVtxLink());
259 truthParticle->setDecayVtxLink(truth->decayVtxLink());
260
261 static const SG::AuxElement::Accessor<ClusterLink_t> accClusLink(
262 "recoClusterLink");
263 static const SG::AuxElement::Accessor<ElectronLink_t> accElLink(
264 "recoElectronLink");
265 static const SG::AuxElement::Accessor<PhotonLink_t> accPhLink(
266 "recoPhotonLink");
267 static const SG::AuxElement::Accessor<TruthLink_t> accTruthLink(
268 "truthParticleLink");
269 static const SG::AuxElement::Accessor<int> accType("truthType");
270 static const SG::AuxElement::Accessor<int> accOrigin("truthOrigin");
271
272 if (m_matchClusters) {
273 accClusLink(*truthParticle) = ClusterLink_t();
274 }
275 accElLink(*truthParticle) = ElectronLink_t();
276 accPhLink(*truthParticle) = PhotonLink_t();
277 accTruthLink(*truthParticle) = TruthLink_t(truth, *oldContainer, ctx);
278 accTruthLink(*truthParticle).toPersistent();
279 // MCTruthClassifier info
280 MCTruthPartClassifier::Info mcinfo(ctx);
281 auto info = m_mcTruthClassifier->particleTruthClassifier(truth, &mcinfo);
282 accType(*truthParticle) = static_cast<int>(info.first);
283 accOrigin(*truthParticle) = static_cast<int>(info.second);
284}
ElementLink< xAOD::PhotonContainer > PhotonLink_t
ElementLink< xAOD::ElectronContainer > ElectronLink_t
ElementLink< xAOD::TruthParticleContainer > TruthLink_t
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ToolHandle< IMCTruthClassifier > m_mcTruthClassifier
MCTruthClassifier.
int status() const
Status code.
virtual double m() const override final
The mass of the particle.
int pdgId() const
PDG ID code.
const ElementLink< TruthVertexContainer > & decayVtxLink() const
The decay vertex link of this particle.
float px() const
The x component of the particle's momentum.
virtual double e() const override final
The total energy of the particle.
float py() const
The y component of the particle's momentum.
float pz() const
The z component of the particle's momentum.
const ElementLink< TruthVertexContainer > & prodVtxLink() const
The production vertex link of this particle.
ElementLink< xAOD::CaloClusterContainer > ClusterLink_t
int uniqueID(const T &p)

◆ initialize()

StatusCode egammaTruthAssociationAlg::initialize ( )
finaloverridevirtual

initialize method

Definition at line 63 of file egammaTruthAssociationAlg.cxx.

64{
65
66 ATH_MSG_DEBUG("Initializing " << name() << "...");
67
68 // initialize the data handles
73
74 // Now the standard decoration handles
75 if (m_matchElectrons) {
77 } else {
78 m_electronDecKeys.clear();
79 }
80
81 if (m_matchPhotons) {
83 } else {
84 m_photonDecKeys.clear();
85 }
86
87 if (m_matchClusters) {
89 } else {
90 m_clusterDecKeys.clear();
91 }
92
95 } else {
97 }
98
99 CHECK(m_mcTruthClassifier.retrieve());
100 ATH_MSG_DEBUG("Retrieved tool " << m_mcTruthClassifier);
101 ATH_MSG_DEBUG("Initialization successful");
102 return StatusCode::SUCCESS;
103}
#define CHECK(...)
Evaluate an expression and check for errors.
Gaudi::Property< std::string > m_electronDecName
The electron container name property used to initialize the WriteDecorHandleKeyArray.
StatusCode initializeDecorKeys(SG::WriteDecorHandleKeyArray< T > &keys, const std::string &name)
A function that initializes the decor handles, but also checks the naming convention.
Gaudi::Property< std::string > m_photonDecName
The photon container name property used to initialize the WriteDecorHandleKeyArray.
Gaudi::Property< std::string > m_fwdElectronDecName
The fwd electron name property used to initialize the WriteDecorHandleKeyArray.
Gaudi::Property< std::string > m_clusterDecName
The egamma cluster name property used to initialize the WriteDecorHandleKeyArray.

◆ initializeDecorKeys()

template<class T>
StatusCode egammaTruthAssociationAlg::initializeDecorKeys ( SG::WriteDecorHandleKeyArray< T > & keys,
const std::string & name )
private

A function that initializes the decor handles, but also checks the naming convention.

Definition at line 289 of file egammaTruthAssociationAlg.cxx.

292{
293 if (!keys.empty()) {
294 ATH_MSG_FATAL("The WriteDecorHandle should not be configured directly.");
295 return StatusCode::FAILURE;
296 }
297
298 keys.emplace_back(name + ".truthParticleLink");
299 keys.emplace_back(name + ".truthType");
300 keys.emplace_back(name + ".truthOrigin");
301 ATH_CHECK(keys.initialize());
302 return StatusCode::SUCCESS;
303}
#define ATH_MSG_FATAL(x)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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.

◆ isClonable()

◆ isPromptEgammaParticle()

bool egammaTruthAssociationAlg::isPromptEgammaParticle ( const EventContext & ctx,
const xAOD::TruthParticle * truth ) const
private

Return true if the truth particle is a prompt electron or photon.

Definition at line 206 of file egammaTruthAssociationAlg.cxx.

209{
210
211 if ((truth->pdgId() != 22 && abs(truth->pdgId()) != 11) ||
212 MC::isDecayed(truth) || !MC::isPhysical(truth) ||
213 HepMC::is_simulation_particle(truth) || truth->pt() < m_minPt) {
214 return false;
215 }
216 MCTruthPartClassifier::Info mcinfo(ctx);
217 auto type = m_mcTruthClassifier->particleTruthClassifier(truth, &mcinfo);
218
219 // Isolated electron or photons are kept
222 return true;
223 }
224
225 //In UPC mode (e.g \gamma \gamma -> e e )
226 // keep (non-Geant see above) electrons from photons (Bkg)
227 if (m_UPCmode &&
229 return true;
230 }
231
232 // FSR photon
235 truth->pt() > m_minPtFSR) {
236 return true;
237 }
238
239 return false;
240}
Gaudi::Property< float > m_minPt
Minimum Pt to enter egamma truth particle container.
Gaudi::Property< float > m_minPtFSR
Minimum Pt for FSR to enter egamma truth particle container.
Gaudi::Property< bool > m_UPCmode
Allow electron from photon in egamma truth particle container.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
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.

◆ match()

template<class T, class L>
StatusCode egammaTruthAssociationAlg::match ( const EventContext & ctx,
const xAOD::TruthParticleContainer & truthParticles,
const SG::WriteDecorHandleKeyArray< T > & hkeys,
const SG::AuxElement::Accessor< L > & linkAccess,
xAOD::TruthParticleContainer * egammaTruthContainer ) const
private

Loop over elements in the reco container, decorate them with truth info and decorate the truth particles with links to the reco ones (reco<typeName>Link)

Definition at line 355 of file egammaTruthAssociationAlg.cxx.

361{
362
363 writeDecorHandles<T> decoHandles(hkeys, ctx);
364
365
366 for (auto particle : *decoHandles.readHandle()) {
367
369 particleTruthClassifier(ctx, particle);
370
371 const xAOD::TruthParticle* truthParticle = info.genPart;
372 if (truthParticle) {
373 ElementLink<xAOD::TruthParticleContainer> link(
374 truthParticle, truthParticles, ctx);
376 "Decorating object with link to truth, index = " << link.index());
377 decoHandles.el(*particle) = link;
378 } else {
379 decoHandles.el(*particle) = ElementLink<xAOD::TruthParticleContainer>();
380 }
381 decoHandles.el(*particle).toPersistent();
382 ATH_MSG_DEBUG("truthType = " << info.first
383 << " truthOrigin = " << info.second);
384 decoHandles.type(*particle) = static_cast<int>(info.first);
385 decoHandles.origin(*particle) = static_cast<int>(info.second);
386
387 // Decorate the corresponding truth particle with the link to the reco
389 if (!egammaTruthContainer) {
390 ATH_MSG_ERROR("The egammaTruthContainer needs to be valid");
391 return StatusCode::FAILURE;
392 }
393 const xAOD::TruthParticle* truth =
395 if (truth) {
396 xAOD::TruthParticle* truthEgamma =
397 getEgammaTruthParticle(truth, *egammaTruthContainer);
398 if (truthEgamma) {
399 // we found a truthEgamma object we should annotate if this is the
400 // best link
401 bool annotateLink = true; // by default we annotate
402 const auto& link = linkAccess(*truthEgamma); // what already exists
403 if (link.isValid()) {
404 auto oldPart = *link;
405 if (oldPart && truthEgamma->e() > 0 &&
406 std::abs(oldPart->e() / truthEgamma->e() - 1) <
407 std::abs(particle->e() / truthEgamma->e() - 1)) {
408 ATH_MSG_DEBUG(truthEgamma
409 << ": "
410 << " already set to a better matched particle: "
411 << particle);
412 annotateLink = false;
413 }
414 }
415
416 if (annotateLink) {
417 L link(particle, *decoHandles.readHandle(), ctx);
418 linkAccess(*truthEgamma) = link;
419 linkAccess(*truthEgamma).toPersistent();
420 }
421 }
422 }
423 }
424 }
425 return StatusCode::SUCCESS;
426}
#define ATH_MSG_ERROR(x)
MCTruthInfo_t particleTruthClassifier(const EventContext &ctx, const T *) const
return the result of MCTruthClassifier::particleTruthClassifier or do a second pass for electrons bas...
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any)
helper class to contain write decoration handles

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::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< Gaudi::Algorithm > >::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.

◆ particleTruthClassifier()

template<class T>
egammaTruthAssociationAlg::MCTruthInfo_t egammaTruthAssociationAlg::particleTruthClassifier ( const EventContext & ctx,
const T * particle ) const
private

return the result of MCTruthClassifier::particleTruthClassifier or do a second pass for electrons based on the cluster to find true photons

Definition at line 317 of file egammaTruthAssociationAlg.cxx.

320{
322 MCTruthPartClassifier::Info mcinfo(ctx);
323 auto ret = m_mcTruthClassifier->particleTruthClassifier(particle, &mcinfo);
324 info.genPart = mcinfo.genPart;
325 info.first = ret.first;
326 info.second = ret.second;
327 return info;
328}

◆ 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< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonReentrantAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Definition at line 100 of file AthCommonReentrantAlgorithm.h.

100 {
102 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const

◆ sysExecute()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.

77{
78 return BaseAlg::sysExecute (ctx);
79}

◆ sysInitialize()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in HypoBase, and InputMakerBase.

Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.

107 {
109
110 if (sc.isFailure()) {
111 return sc;
112 }
113
114 ServiceHandle<ICondSvc> cs("CondSvc",name());
115 for (auto h : outputHandles()) {
116 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
117 // do this inside the loop so we don't create the CondSvc until needed
118 if ( cs.retrieve().isFailure() ) {
119 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
120 return StatusCode::SUCCESS;
121 }
122 if (cs->regHandle(this,*h).isFailure()) {
124 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
125 << " with CondSvc");
126 }
127 }
128 }
129 return sc;
130}
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::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 }

Member Data Documentation

◆ m_clusterDecKeys

SG::WriteDecorHandleKeyArray<xAOD::CaloClusterContainer> egammaTruthAssociationAlg::m_clusterDecKeys
private
Initial value:
{
this,
"DoNotSet_ClusterContainerName",
{},
"Do not set; configuration via the string property"
}

The egamma cluster decor handle key array.

Definition at line 151 of file egammaTruthAssociationAlg.h.

151 {
152 this,
153 "DoNotSet_ClusterContainerName",
154 {},
155 "Do not set; configuration via the string property"
156 };

◆ m_clusterDecName

Gaudi::Property<std::string> egammaTruthAssociationAlg::m_clusterDecName
private
Initial value:
{
this,
"ClusterContainerName",
"",
"Name of the egamma cluster container"
}

The egamma cluster name property used to initialize the WriteDecorHandleKeyArray.

Definition at line 160 of file egammaTruthAssociationAlg.h.

160 {
161 this,
162 "ClusterContainerName",
163 "",
164 "Name of the egamma cluster container"
165 };

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doEgammaTruthContainer

Gaudi::Property<bool> egammaTruthAssociationAlg::m_doEgammaTruthContainer
private
Initial value:
{
this,
"CreateEgammaTruthContainer",
true,
"Create egammaTruthContainer?"
}

Create egamma truth container?

Definition at line 119 of file egammaTruthAssociationAlg.h.

119 {
120 this,
121 "CreateEgammaTruthContainer",
122 true,
123 "Create egammaTruthContainer?"
124 };

◆ m_egammaTruthParticleContainerKey

SG::WriteHandleKey<xAOD::TruthParticleContainer> egammaTruthAssociationAlg::m_egammaTruthParticleContainerKey
private
Initial value:
{
this,
"EgammaTruthContainerName",
"",
"Name of the output egamma truth particle container"
}

Name of the output egamma truth container.

Definition at line 236 of file egammaTruthAssociationAlg.h.

236 {
237 this,
238 "EgammaTruthContainerName",
239 "",
240 "Name of the output egamma truth particle container"
241 };

◆ m_electronDecKeys

SG::WriteDecorHandleKeyArray<xAOD::ElectronContainer> egammaTruthAssociationAlg::m_electronDecKeys
private
Initial value:
{
this,
"DoNotSet_ElectronContainerName",
{},
"Do not set; configuration via the string property"
}

The electron container decor handle key array.

Definition at line 168 of file egammaTruthAssociationAlg.h.

168 {
169 this,
170 "DoNotSet_ElectronContainerName",
171 {},
172 "Do not set; configuration via the string property"
173 };

◆ m_electronDecName

Gaudi::Property<std::string> egammaTruthAssociationAlg::m_electronDecName
private
Initial value:
{
this,
"ElectronContainerName",
"",
"Name of the input electron container"
}

The electron container name property used to initialize the WriteDecorHandleKeyArray.

Definition at line 177 of file egammaTruthAssociationAlg.h.

177 {
178 this,
179 "ElectronContainerName",
180 "",
181 "Name of the input electron container"
182 };

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonReentrantAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 114 of file AthCommonReentrantAlgorithm.h.

◆ m_fwdElectronDecKeys

SG::WriteDecorHandleKeyArray<xAOD::ElectronContainer> egammaTruthAssociationAlg::m_fwdElectronDecKeys
private
Initial value:
{
this,
"DoNotSet_FwdElectronContainerName",
{},
"Do not set; configuration via the string property"
}

The fwd electron container decor handle key array.

Definition at line 185 of file egammaTruthAssociationAlg.h.

185 {
186 this,
187 "DoNotSet_FwdElectronContainerName",
188 {},
189 "Do not set; configuration via the string property"
190 };

◆ m_fwdElectronDecName

Gaudi::Property<std::string> egammaTruthAssociationAlg::m_fwdElectronDecName
private
Initial value:
{
this,
"FwdElectronContainerName",
"",
"Name of the input fwd electron container"
}

The fwd electron name property used to initialize the WriteDecorHandleKeyArray.

Definition at line 194 of file egammaTruthAssociationAlg.h.

194 {
195 this,
196 "FwdElectronContainerName",
197 "",
198 "Name of the input fwd electron container"
199 };

◆ m_matchClusters

Gaudi::Property<bool> egammaTruthAssociationAlg::m_matchClusters
private
Initial value:
{ this,
"MatchClusters",
false,
"Match clusters?" }

Match clusters?

Definition at line 145 of file egammaTruthAssociationAlg.h.

145 { this,
146 "MatchClusters",
147 false,
148 "Match clusters?" };

◆ m_matchElectrons

Gaudi::Property<bool> egammaTruthAssociationAlg::m_matchElectrons
private
Initial value:
{ this,
"MatchElectrons",
true,
"Match (central) electrons?" }

Match electrons?

Definition at line 127 of file egammaTruthAssociationAlg.h.

127 { this,
128 "MatchElectrons",
129 true,
130 "Match (central) electrons?" };

◆ m_matchForwardElectrons

Gaudi::Property<bool> egammaTruthAssociationAlg::m_matchForwardElectrons
private
Initial value:
{ this,
"MatchForwardElectrons",
true,
"Match forward electrons?" }

Match fwd electrons?

Definition at line 139 of file egammaTruthAssociationAlg.h.

139 { this,
140 "MatchForwardElectrons",
141 true,
142 "Match forward electrons?" };

◆ m_matchPhotons

Gaudi::Property<bool> egammaTruthAssociationAlg::m_matchPhotons
private
Initial value:
{ this,
"MatchPhotons",
true,
"Match photons?" }

Match photons?

Definition at line 133 of file egammaTruthAssociationAlg.h.

133 { this,
134 "MatchPhotons",
135 true,
136 "Match photons?" };

◆ m_mcTruthClassifier

ToolHandle<IMCTruthClassifier> egammaTruthAssociationAlg::m_mcTruthClassifier
private
Initial value:
{
this,
"MCTruthClassifier",
"EMMCTruthClassifier",
"Handle of MCTruthClassifier"
}

MCTruthClassifier.

Definition at line 269 of file egammaTruthAssociationAlg.h.

269 {
270 this,
271 "MCTruthClassifier",
272 "EMMCTruthClassifier",
273 "Handle of MCTruthClassifier"
274 };

◆ m_minPt

Gaudi::Property<float> egammaTruthAssociationAlg::m_minPt
private
Initial value:
{
this,
"MinPtEgammaTruth",
10,
"Minimum Pt to enter egamma truth particle container"
}

Minimum Pt to enter egamma truth particle container.

Definition at line 244 of file egammaTruthAssociationAlg.h.

244 {
245 this,
246 "MinPtEgammaTruth",
247 10,
248 "Minimum Pt to enter egamma truth particle container"
249 };

◆ m_minPtFSR

Gaudi::Property<float> egammaTruthAssociationAlg::m_minPtFSR
private
Initial value:
{
this,
"MinPtEgammaTruthFSR",
1e3,
"Minimum Pt for FSR to enter egamma truth particle container"
}

Minimum Pt for FSR to enter egamma truth particle container.

Definition at line 252 of file egammaTruthAssociationAlg.h.

252 {
253 this,
254 "MinPtEgammaTruthFSR",
255 1e3,
256 "Minimum Pt for FSR to enter egamma truth particle container"
257 };

◆ m_photonDecKeys

SG::WriteDecorHandleKeyArray<xAOD::PhotonContainer> egammaTruthAssociationAlg::m_photonDecKeys
private
Initial value:
{
this,
"DoNotSet_PhotonContainerName",
{},
"Do not set; configuration via the string property"
}

The photon container decor handle key array.

Definition at line 202 of file egammaTruthAssociationAlg.h.

202 {
203 this,
204 "DoNotSet_PhotonContainerName",
205 {},
206 "Do not set; configuration via the string property"
207 };

◆ m_photonDecName

Gaudi::Property<std::string> egammaTruthAssociationAlg::m_photonDecName
private
Initial value:
{
this,
"PhotonContainerName",
"",
"Name of the input photon container"
}

The photon container name property used to initialize the WriteDecorHandleKeyArray.

Definition at line 211 of file egammaTruthAssociationAlg.h.

211 {
212 this,
213 "PhotonContainerName",
214 "",
215 "Name of the input photon container"
216 };

◆ m_truthEventContainerKey

SG::ReadHandleKey<xAOD::TruthEventContainer> egammaTruthAssociationAlg::m_truthEventContainerKey
private
Initial value:
{
this,
"TruthEventContainerName",
"",
"Name of the truth event container"
}

Name of the truth event container.

Definition at line 219 of file egammaTruthAssociationAlg.h.

219 {
220 this,
221 "TruthEventContainerName",
222 "",
223 "Name of the truth event container"
224 };

◆ m_truthParticleContainerKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> egammaTruthAssociationAlg::m_truthParticleContainerKey
private
Initial value:
{
this,
"TruthParticleContainerName",
"",
"Name of the truth particle container"
}

Name of the truth particle container.

Definition at line 227 of file egammaTruthAssociationAlg.h.

227 {
228 this,
229 "TruthParticleContainerName",
230 "",
231 "Name of the truth particle container"
232 };

◆ m_UPCmode

Gaudi::Property<bool> egammaTruthAssociationAlg::m_UPCmode
private
Initial value:
{
this,
"UPCmode",
false,
"Allow electron from photon in egamma truth particle container"
}

Allow electron from photon in egamma truth particle container.

Definition at line 260 of file egammaTruthAssociationAlg.h.

260 {
261 this,
262 "UPCmode",
263 false,
264 "Allow electron from photon in egamma truth particle container"
265 };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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