ATLAS Offline Software
Loading...
Searching...
No Matches
ThinGeantTruthAlg Class Referencefinal

#include <ThinGeantTruthAlg.h>

Inheritance diagram for ThinGeantTruthAlg:
Collaboration diagram for ThinGeantTruthAlg:

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode execute (const EventContext &ctx) const override final
void ancestors (const xAOD::TruthParticle *, std::vector< bool > &, std::unordered_set< int > &) const
 Inline method.
void descendants (const xAOD::TruthParticle *, std::vector< bool > &, std::unordered_set< int > &) const
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
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
 Get filter decision:
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 Set filter decision:
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< StoreGateSvc > StoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StringProperty m_streamName
Gaudi::Property< float > m_etaMaxEgTruth
Gaudi::Property< bool > m_keepMuons { this, "keepMuons", true }
Gaudi::Property< bool > m_keepEGamma { this, "keepEGamma", true }
Gaudi::Property< std::string > m_truthLinkDecor {this, "TruthLinkDecor", "truthParticleLink"}
 Truth particle link decorations.
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_readDecorKeys {this, "DecorKeys", {}}
 Schedule the algorithm's dependency on the truth particle link.
Gaudi::Property< std::vector< int > > m_longlived
SG::ThinningHandleKey< xAOD::TruthParticleContainer > m_truthParticlesKey
SG::ThinningHandleKey< xAOD::TruthVertexContainer > m_truthVerticesKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronsKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_fwdElectronsKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_lrtElectronsKey
SG::ReadHandleKey< xAOD::PhotonContainer > m_photonsKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonsKey { this, "MuonsKey", "Muons", "Name of the input muon container" }
SG::ReadHandleKey< xAOD::MuonContainer > m_lrtMuonsKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_egammaTruthKey
std::atomic< unsigned long > m_nEventsProcessed {}
 Counters.
std::atomic< unsigned long > m_nParticlesProcessed {}
std::atomic< unsigned long > m_nVerticesProcessed {}
std::atomic< unsigned long > m_nParticlesThinned {}
std::atomic< unsigned long > m_nVerticesThinned {}
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

Definition at line 30 of file ThinGeantTruthAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 376 of file AthCommonDataStore.h.

Member Function Documentation

◆ ancestors()

void ThinGeantTruthAlg::ancestors ( const xAOD::TruthParticle * pHead,
std::vector< bool > & particleMask,
std::unordered_set< int > & encounteredUniqueIDs ) const

Inline method.

Definition at line 365 of file ThinGeantTruthAlg.cxx.

368{
369
370 // Check that this uniqueID hasn't been seen before (e.g. we are in a loop)
371 std::unordered_set<int>::const_iterator found =
372 encounteredUniqueIDs.find(HepMC::uniqueID(pHead));
373 if (found != encounteredUniqueIDs.end())
374 return;
375 encounteredUniqueIDs.insert(HepMC::uniqueID(pHead));
376
377 // Save particle position in the mask
378 int headIndex = pHead->index();
379 particleMask[headIndex] = true;
380
381 // Get the production vertex
382 const xAOD::TruthVertex* prodVtx(nullptr);
383 if (pHead->hasProdVtx()) {
384 prodVtx = pHead->prodVtx();
385 } else {
386 return;
387 }
388
389 // Get children particles and self-call
390 int nParents = prodVtx->nIncomingParticles();
391 for (int i = 0; i < nParents; ++i)
392 ancestors(prodVtx->incomingParticle(i), particleMask, encounteredUniqueIDs);
393}
void ancestors(const xAOD::TruthParticle *, std::vector< bool > &, std::unordered_set< int > &) const
Inline method.
bool hasProdVtx() const
Check for a production vertex on this particle.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
int uniqueID(const T &p)
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15

◆ 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>

◆ descendants()

void ThinGeantTruthAlg::descendants ( const xAOD::TruthParticle * pHead,
std::vector< bool > & particleMask,
std::unordered_set< int > & encounteredUniqueIDs ) const

Definition at line 400 of file ThinGeantTruthAlg.cxx.

404{
405 // Check that this unique ID hasn't been seen before (e.g. we are in a loop)
406 std::unordered_set<int>::const_iterator found =
407 encounteredUniqueIDs.find(HepMC::uniqueID(pHead));
408 if (found != encounteredUniqueIDs.end())
409 return;
410 encounteredUniqueIDs.insert(HepMC::uniqueID(pHead));
411
412 // Save the particle position in the mask
413 int headIndex = pHead->index();
414 particleMask[headIndex] = true;
415
416 // Get the decay vertex
417 const xAOD::TruthVertex* decayVtx(nullptr);
418 if (pHead->hasDecayVtx()) {
419 decayVtx = pHead->decayVtx();
420 } else {
421 return;
422 }
423
424 // Get children particles and self-call
425 int nChildren = decayVtx->nOutgoingParticles();
426 for (int i = 0; i < nChildren; ++i) {
428 decayVtx->outgoingParticle(i), particleMask, encounteredUniqueIDs);
429 }
430
431 }
void descendants(const xAOD::TruthParticle *, std::vector< bool > &, std::unordered_set< int > &) const
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
bool hasDecayVtx() const
Check for a decay vertex on this particle.

◆ 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 ThinGeantTruthAlg::execute ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 91 of file ThinGeantTruthAlg.cxx.

92{
93 // Increase the event counter
95
96 // Retrieve truth and vertex containers
97 SG::ThinningHandle truthParticles{m_truthParticlesKey, ctx};
98 SG::ThinningHandle truthVertices{m_truthVerticesKey, ctx};
99 if (!truthParticles.isValid()) {
100 ATH_MSG_FATAL("No TruthParticleContainer with key " << m_truthParticlesKey.key() << " found.");
101 return StatusCode::FAILURE;
102 }
103 if (!truthVertices.isValid()) {
104 ATH_MSG_FATAL("No TruthVertexContainer with key " << m_truthVerticesKey.key() << " found.");
105 return StatusCode::FAILURE;
106 }
107
108 // Loop over photons, electrons and muons and get the associated truth
109 // particles Retain the associated index number
110 std::vector<int> recoParticleTruthIndices;
111 std::vector<int> egammaTruthIndices{};
112
113 // Muons
114 if (m_keepMuons) {
115 const xAOD::MuonContainer* muons{nullptr};
116 ATH_CHECK(SG::get(muons, m_muonsKey, ctx));
117 for (const xAOD::Muon* muon : *muons) {
119 if (truthMuon) {
121 if (truthMuon) {
122 recoParticleTruthIndices.push_back(truthMuon->index());
123 }
124 }
125 }
126
127 // LRT muons
128 const xAOD::MuonContainer* lrtMuons{nullptr};
129 ATH_CHECK(SG::get(lrtMuons, m_lrtMuonsKey, ctx));
130 if (lrtMuons) {
131 for (const xAOD::Muon* muon : *lrtMuons) {
133 if (truthMuon) {
135 if (truthMuon) {
136 recoParticleTruthIndices.push_back(truthMuon->index());
137 }
138 }
139 }
140 }
141 }
142
143 // Electrons and photons
144 if (m_keepEGamma) {
145
146 // Electrons
147 const xAOD::ElectronContainer* electrons{nullptr};
148 ATH_CHECK(SG::get(electrons, m_electronsKey, ctx));
149
150 for (const xAOD::Electron* electron : *electrons) {
151 const xAOD::TruthParticle* truthElectron =
153 if (truthElectron) {
154 recoParticleTruthIndices.push_back(truthElectron->index());
155 }
156 }
157
158 // Forward Electrons
159 const xAOD::ElectronContainer* fwdElectrons{nullptr};
160 ATH_CHECK(SG::get(fwdElectrons, m_fwdElectronsKey, ctx));
161 if (fwdElectrons) {
162
163 for (const xAOD::Electron* electron : *fwdElectrons) {
164 const xAOD::TruthParticle* truthElectron =
166 if (truthElectron) {
167 recoParticleTruthIndices.push_back(truthElectron->index());
168 }
169 }
170 }
171
172 // LRT electrons
173 const xAOD::ElectronContainer* lrtElectrons{nullptr};
174 ATH_CHECK(SG::get(lrtElectrons, m_lrtElectronsKey, ctx));
175 if (lrtElectrons) {
176 for (const xAOD::Electron* electron : *lrtElectrons) {
177 const xAOD::TruthParticle* truthElectron =
179 if (truthElectron) {
180 recoParticleTruthIndices.push_back(truthElectron->index());
181 }
182 }
183 }
184
185 // Photons
186 const xAOD::PhotonContainer* photons{nullptr};
187 ATH_CHECK(SG::get(photons, m_photonsKey, ctx));
188 for (const xAOD::Photon* photon : *photons) {
189 const xAOD::TruthParticle* truthPhoton =
191 if (truthPhoton) {
192 recoParticleTruthIndices.push_back(truthPhoton->index());
193 }
194 }
195
196 // egamma Truth Particles
197 const xAOD::TruthParticleContainer* egammaTruthParticles{nullptr};
198 ATH_CHECK(SG::get(egammaTruthParticles, m_egammaTruthKey, ctx));
199
200 for (const xAOD::TruthParticle* egTruthParticle : *egammaTruthParticles) {
201 //coverity[UNNECESSARY_STRING_COPY:FALSE]
202 static const SG::ConstAccessor<int> accType("truthType");
203
204 if (!accType.isAvailable(*egTruthParticle) ||
205 accType(*egTruthParticle) != MCTruthPartClassifier::IsoElectron ||
206 std::abs(egTruthParticle->eta()) > m_etaMaxEgTruth) {
207 continue;
208 }
209 // Only isolated true electrons
210 using TruthLink_t = ElementLink<xAOD::TruthParticleContainer>;
211 static const SG::ConstAccessor<TruthLink_t> linkToTruth(
212 "truthParticleLink");
213 if (!linkToTruth.isAvailable(*egTruthParticle)) {
214 continue;
215 }
216
217 const TruthLink_t& truthegamma = linkToTruth(*egTruthParticle);
218 if (!truthegamma.isValid()) {
219 continue;
220 }
221 egammaTruthIndices.push_back((*truthegamma)->index());
222 }
223 }
224
225 // Set up masks
226 std::vector<bool> particleMask, vertexMask;
227 int nTruthParticles = truthParticles->size();
228 int nTruthVertices = truthVertices->size();
229 m_nParticlesProcessed.fetch_add(nTruthParticles, std::memory_order_relaxed);
230 m_nVerticesProcessed.fetch_add(nTruthVertices, std::memory_order_relaxed);
231 particleMask.assign(nTruthParticles, false);
232 vertexMask.assign(nTruthVertices, false);
233
234 // Vector of pairs keeping track of how many incoming/outgoing particles each
235 // vertex has
236 std::vector<std::pair<int, int>> vertexLinksCounts;
237 for (const auto *vertex : *truthVertices) {
238 std::pair<int, int> tmpPair;
239 tmpPair.first = vertex->nIncomingParticles();
240 tmpPair.second = vertex->nOutgoingParticles();
241 vertexLinksCounts.push_back(tmpPair);
242 }
243
244 // Loop over truth particles and update mask
245 std::unordered_set<int> encounteredUniqueIDs; // for loop protection
246 for (int i = 0; i < nTruthParticles; ++i) {
247 encounteredUniqueIDs.clear();
248 const xAOD::TruthParticle* particle = (*truthParticles)[i];
249 // Retain status 1 BSM particles and descendants
250 if (MC::isBSM(particle) && MC::isStable(particle)) {
251 descendants(particle, particleMask, encounteredUniqueIDs);
252 encounteredUniqueIDs.clear();
253 }
254
255 // Retain stable Tau particles produced by Geant4 and their descendants
256 if (MC::isTau(particle) && MC::isStable(particle)) {
257 descendants(particle, particleMask, encounteredUniqueIDs);
258 encounteredUniqueIDs.clear();
259 }
260
261 // Retain children of longer-lived generator particles
262 if (MC::isStable(particle)) {
263 int pdgId = abs(particle->pdgId());
264 if (std::find(m_longlived.begin(), m_longlived.end(), pdgId) !=
265 m_longlived.end()) {
266 const xAOD::TruthVertex* decayVtx(nullptr);
267 if (particle->hasDecayVtx()) {
268 decayVtx = particle->decayVtx();
269 }
270 int nChildren = 0;
271 if (decayVtx)
272 nChildren = decayVtx->nOutgoingParticles();
273 for (int i = 0; i < nChildren; ++i) {
274 particleMask[decayVtx->outgoingParticle(i)->index()] = true;
275 }
276 }
277 }
278
279 // Retain particles and their descendants/ancestors associated with the
280 // reconstructed objects
281 if (std::find(recoParticleTruthIndices.begin(),
282 recoParticleTruthIndices.end(),
283 i) != recoParticleTruthIndices.end()) {
284 if (HepMC::is_simulation_particle(particle)) { // only need to do this for Geant particles since
285 // non-Geant are kept anyway
286 ancestors(particle, particleMask, encounteredUniqueIDs);
287 encounteredUniqueIDs.clear();
288 descendants(particle, particleMask, encounteredUniqueIDs);
289 encounteredUniqueIDs.clear();
290 }
291 }
292
293 // Retain particles and their descendants associated with the egamma Truth
294 // Particles
295 if (std::find(egammaTruthIndices.begin(), egammaTruthIndices.end(), i) !=
296 egammaTruthIndices.end()) {
297 descendants(particle, particleMask, encounteredUniqueIDs);
298 encounteredUniqueIDs.clear();
299 }
300
301 if (!HepMC::is_simulation_particle(particle)) {
302 particleMask[i] = true;
303 }
304 else {
305 // deal with the products of interactions of quasi-stable
306 // particles
307 if (particle->hasProdVtx()) {
308 const xAOD::TruthVertex* prodVtx = particle->prodVtx();
309 const int nParents = prodVtx->nIncomingParticles();
310 for (int parent = 0; parent < nParents; ++parent) {
311 if (MC::isDecayed(prodVtx->incomingParticle(parent))) {
312 // "simulation particle" with a parent with status==2 was
313 // produced via the interaction of a quasi-stable particle
314 // with the detector material. Such particles should be kept.
315 particleMask[i] = true;
316 break;
317 }
318 }
319 }
320 }
321 }
322
323 // Loop over the mask and update vertex association counters
324 for (int i = 0; i < nTruthParticles; ++i) {
325 if (!particleMask[i]) {
327 const xAOD::TruthParticle* particle = (*truthParticles)[i];
328 if (particle->hasProdVtx()) {
329 const auto *prodVertex = particle->prodVtx();
330 --vertexLinksCounts[prodVertex->index()].second;
331 }
332 if (particle->hasDecayVtx()) {
333 const auto *decayVertex = particle->decayVtx();
334 --vertexLinksCounts[decayVertex->index()].first;
335 }
336 }
337 }
338
339 // Loop over truth vertices and update mask
340 // Those for which all incoming and outgoing particles are to be thinned, will
341 // be thinned as well
342 unsigned int nVerticesThinned = 0;
343 for (int i = 0; i < nTruthVertices; ++i) {
344 if (vertexLinksCounts[i].first != 0 || vertexLinksCounts[i].second != 0) {
345 vertexMask[i] = true;
346 } else {
347 ++nVerticesThinned;
348 }
349 }
350 m_nVerticesThinned.fetch_add(nVerticesThinned, std::memory_order_relaxed);
351 // Apply masks to thinning
352 truthParticles.keep(particleMask);
353 truthVertices.keep(vertexMask);
354
355 return StatusCode::SUCCESS;
356}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x,...)
ElementLink< xAOD::TruthParticleContainer > TruthLink_t
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
SG::ReadHandleKey< xAOD::MuonContainer > m_muonsKey
std::atomic< unsigned long > m_nParticlesThinned
SG::ReadHandleKey< xAOD::MuonContainer > m_lrtMuonsKey
std::atomic< unsigned long > m_nVerticesProcessed
std::atomic< unsigned long > m_nVerticesThinned
SG::ReadHandleKey< xAOD::PhotonContainer > m_photonsKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_egammaTruthKey
SG::ThinningHandleKey< xAOD::TruthVertexContainer > m_truthVerticesKey
Gaudi::Property< std::vector< int > > m_longlived
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronsKey
std::atomic< unsigned long > m_nEventsProcessed
Counters.
SG::ReadHandleKey< xAOD::ElectronContainer > m_lrtElectronsKey
Gaudi::Property< bool > m_keepMuons
Gaudi::Property< bool > m_keepEGamma
std::atomic< unsigned long > m_nParticlesProcessed
SG::ThinningHandleKey< xAOD::TruthParticleContainer > m_truthParticlesKey
Gaudi::Property< float > m_etaMaxEgTruth
SG::ReadHandleKey< xAOD::ElectronContainer > m_fwdElectronsKey
const TruthParticle_v1 * incomingParticle(size_t index) const
Get one of the incoming particles.
size_t nIncomingParticles() const
Get the number of incoming particles.
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 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 isTau(const T &p)
bool isBSM(const T &p)
APID: graviton and all Higgs extensions are BSM.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:570
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
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).
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:
Photon_v1 Photon
Definition of the current "egamma version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
Electron_v1 Electron
Definition of the current "egamma version".

◆ 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 & AthCommonAlgorithm< 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 89 of file AthCommonAlgorithm.cxx.

54{
55 // If we didn't find any symlinks to add, just return the collection
56 // from the base class. Otherwise, return the extended collection.
57 if (!m_extendedExtraObjects.empty()) {
59 }
61}
Common base class for algorithms.

◆ filterPassed()

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

Get filter decision:

Definition at line 93 of file AthCommonAlgorithm.h.

93 {
94 return execState( ctx ).filterPassed();
95 }
virtual bool filterPassed(const EventContext &ctx) const
Get filter decision:

◆ finalize()

StatusCode ThinGeantTruthAlg::finalize ( )
overridevirtual

Definition at line 79 of file ThinGeantTruthAlg.cxx.

80{
81 ATH_MSG_INFO("Processed " << m_nEventsProcessed << " events containing "
82 << m_nParticlesProcessed << " truth particles and "
83 << m_nVerticesProcessed << " truth vertices ");
85 << " Geant truth particles and " << m_nVerticesThinned
86 << " corresponding truth vertices ");
87 return StatusCode::SUCCESS;
88}
#define ATH_MSG_INFO(x,...)

◆ initialize()

StatusCode ThinGeantTruthAlg::initialize ( )
overridevirtual

Definition at line 39 of file ThinGeantTruthAlg.cxx.

40{
41 if (m_streamName.empty()) {
42 ATH_MSG_ERROR("StreamName property was not initialized.");
43 return StatusCode::FAILURE;
44 }
45
52 ATH_CHECK(m_muonsKey.initialize(m_keepMuons));
53 ATH_CHECK(m_lrtMuonsKey.initialize(m_keepMuons && !m_lrtMuonsKey.empty()));
55 if (m_keepEGamma) {
58 if (!m_fwdElectronsKey.empty()){
60 }
61 if (!m_lrtElectronsKey.empty()){
63 }
64 }
65 if (!m_muonsKey.empty()){
67 }
68 if (!m_lrtMuonsKey.empty()){
70 }
71
72 ATH_CHECK(m_readDecorKeys.initialize());
73
74
75 return StatusCode::SUCCESS;
76}
#define ATH_MSG_ERROR(x,...)
Gaudi::Property< std::string > m_truthLinkDecor
Truth particle link decorations.
StringProperty m_streamName
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_readDecorKeys
Schedule the algorithm's dependency on the truth particle link.

◆ 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()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::isClonable ( ) const
inlineoverridevirtualinherited

Specify if the algorithm is clonable.

Only relevant for non-reentrant algorithms. Actual number of clones needs to be set via the "Cardinality" property.

Reimplemented in AFP_DigiTop, AlgB, AlgT, BCM_Digitization, CscDigitBuilder, CscDigitToCscRDO, G4AtlasAlg, G4RunAlg, HGTD_Digitization, HiveAlgBase, InDet::GNNSeedingTrackMaker, InDet::SCT_Clusterization, InDet::SiSPGNNTrackMaker, InDet::SiSPSeededTrackFinder, InDet::SiTrackerSpacePointFinder, ISF::SimKernelMT, ITk::StripDigitization, ITkPixelCablingAlg, ITkStripCablingAlg, LArHitEMapMaker, LArTTL1Maker, LUCID_DigiTop, LVL1::L1TopoSimulation, MergeCalibHits, MergeGenericMuonSimHitColl, MergeHijingPars, MergeMcEventCollection, MergeTrackRecordCollection, MergeTruthJets, MergeTruthParticles, MuonDigitizer, PileUpMTAlg, PixelDigitization, RoIBResultToxAOD, SCT_ByteStreamErrorsTestAlg, SCT_CablingCondAlgFromCoraCool, SCT_CablingCondAlgFromText, SCT_ConditionsParameterTestAlg, SCT_ConditionsSummaryTestAlg, SCT_ConfigurationConditionsTestAlg, SCT_Digitization, SCT_FlaggedConditionTestAlg, SCT_LinkMaskingTestAlg, SCT_MajorityConditionsTestAlg, SCT_ModuleVetoTestAlg, SCT_MonitorConditionsTestAlg, SCT_PrepDataToxAOD, SCT_RawDataToxAOD, SCT_ReadCalibChipDataTestAlg, SCT_ReadCalibDataTestAlg, SCT_RODVetoTestAlg, SCT_SensorsTestAlg, SCT_SiliconConditionsTestAlg, SCT_StripVetoTestAlg, SCT_TdaqEnabledTestAlg, SCT_TestCablingAlg, SCTEventFlagWriter, SCTRawDataProvider, SCTSiLorentzAngleTestAlg, SCTSiPropertiesTestAlg, SGInputLoader, Simulation::BeamEffectsAlg, TileHitVecToCnt, TileMuonFitter, TilePulseForTileMuonReceiver, TileRawChannelMaker, TRTDigitization, and ZDC_DigiTop.

Definition at line 68 of file AthCommonAlgorithm.h.

68 {
69 return true;
70 }

◆ 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.

◆ 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 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
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 352 of file AthCommonDataStore.h.

352 {
354 }

◆ setFilterPassed()

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

Set filter decision:

Definition at line 99 of file AthCommonAlgorithm.h.

99 {
101 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Set filter decision:

◆ sysExecute()

StatusCode AthCommonAlgorithm< 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.

Reimplemented in AthAnalysisAlgorithm.

Definition at line 80 of file AthCommonAlgorithm.cxx.

41{
42 return BaseAlg::sysExecute (ctx);
43}

◆ sysInitialize()

StatusCode AthCommonAlgorithm< 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 AthAnalysisAlgorithm, AthHistogramAlgorithm, HypoBase, InputMakerBase, and PyAthena::Alg.

Definition at line 60 of file AthCommonAlgorithm.cxx.

71 {
73
74 if (sc.isFailure()) {
75 return sc;
76 }
77
78 ServiceHandle<ICondSvc> cs("CondSvc",name());
79 for (auto h : outputHandles()) {
80 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
81 // do this inside the loop so we don't create the CondSvc until needed
82 if ( cs.retrieve().isFailure() ) {
83 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
85 }
86 if (cs->regHandle(this,*h).isFailure()) {
88 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
89 << " with CondSvc");
90 }
91 }
92 }
93 return sc;
94}
#define ATH_MSG_WARNING(x,...)
virtual StatusCode sysInitialize() override
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 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }

Member Data Documentation

◆ m_detStore

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

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_egammaTruthKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> ThinGeantTruthAlg::m_egammaTruthKey
private
Initial value:
{
this,
"EGammaTruthKey",
"egammaTruthParticles",
"Name of the input egammaTruth container"
}

Definition at line 125 of file ThinGeantTruthAlg.h.

125 {
126 this,
127 "EGammaTruthKey",
128 "egammaTruthParticles",
129 "Name of the input egammaTruth container"
130 };

◆ m_electronsKey

SG::ReadHandleKey<xAOD::ElectronContainer> ThinGeantTruthAlg::m_electronsKey
private
Initial value:
{
this,
"ElectronsKey",
"Electrons",
"Name of the input electron container"
}

Definition at line 87 of file ThinGeantTruthAlg.h.

87 {
88 this,
89 "ElectronsKey",
90 "Electrons",
91 "Name of the input electron container"
92 };

◆ m_etaMaxEgTruth

Gaudi::Property<float> ThinGeantTruthAlg::m_etaMaxEgTruth
private
Initial value:
{ this,
"EtaMaxEGammaTruth",
2.525,
"Max eta value for e-gamma truth particles" }

Definition at line 52 of file ThinGeantTruthAlg.h.

52 { this,
53 "EtaMaxEGammaTruth",
54 2.525,
55 "Max eta value for e-gamma truth particles" };

◆ m_evtStore

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

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

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

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

Empty if no symlinks were found.

Definition at line 108 of file AthCommonAlgorithm.h.

◆ m_fwdElectronsKey

SG::ReadHandleKey<xAOD::ElectronContainer> ThinGeantTruthAlg::m_fwdElectronsKey
private
Initial value:
{
this,
"FwdElectronsKey",
"",
"Name of the input forward electron container"
}

Definition at line 94 of file ThinGeantTruthAlg.h.

94 {
95 this,
96 "FwdElectronsKey",
97 "",
98 "Name of the input forward electron container"
99 };

◆ m_keepEGamma

Gaudi::Property<bool> ThinGeantTruthAlg::m_keepEGamma { this, "keepEGamma", true }
private

Definition at line 58 of file ThinGeantTruthAlg.h.

58{ this, "keepEGamma", true };

◆ m_keepMuons

Gaudi::Property<bool> ThinGeantTruthAlg::m_keepMuons { this, "keepMuons", true }
private

Definition at line 57 of file ThinGeantTruthAlg.h.

57{ this, "keepMuons", true };

◆ m_longlived

Gaudi::Property<std::vector<int> > ThinGeantTruthAlg::m_longlived
private
Initial value:
{
this,
"LongLivedParticleList",
{ 310, 3122, 3222, 3112, 3322, 3312 },
"List of long lifetime particles which are likely to be decayed by "
"Geant but whose children must be kept"
}

Definition at line 65 of file ThinGeantTruthAlg.h.

65 {
66 this,
67 "LongLivedParticleList",
68 { 310, 3122, 3222, 3112, 3322, 3312 },
69 "List of long lifetime particles which are likely to be decayed by "
70 "Geant but whose children must be kept"
71 };

◆ m_lrtElectronsKey

SG::ReadHandleKey<xAOD::ElectronContainer> ThinGeantTruthAlg::m_lrtElectronsKey
private
Initial value:
{
this,
"LRTElectronsKey",
"",
"Name of the input LRT electron container"
}

Definition at line 101 of file ThinGeantTruthAlg.h.

101 {
102 this,
103 "LRTElectronsKey",
104 "",
105 "Name of the input LRT electron container"
106 };

◆ m_lrtMuonsKey

SG::ReadHandleKey<xAOD::MuonContainer> ThinGeantTruthAlg::m_lrtMuonsKey
private
Initial value:
{
this,
"LRTMuonsKey",
"",
"Name of the input LRT muon container"
}

Definition at line 118 of file ThinGeantTruthAlg.h.

118 {
119 this,
120 "LRTMuonsKey",
121 "",
122 "Name of the input LRT muon container"
123 };

◆ m_muonsKey

SG::ReadHandleKey<xAOD::MuonContainer> ThinGeantTruthAlg::m_muonsKey { this, "MuonsKey", "Muons", "Name of the input muon container" }
private

Definition at line 116 of file ThinGeantTruthAlg.h.

116{ this, "MuonsKey", "Muons", "Name of the input muon container" };

◆ m_nEventsProcessed

std::atomic<unsigned long> ThinGeantTruthAlg::m_nEventsProcessed {}
mutableprivate

Counters.

Definition at line 133 of file ThinGeantTruthAlg.h.

133{};

◆ m_nParticlesProcessed

std::atomic<unsigned long> ThinGeantTruthAlg::m_nParticlesProcessed {}
mutableprivate

Definition at line 134 of file ThinGeantTruthAlg.h.

134{};

◆ m_nParticlesThinned

std::atomic<unsigned long> ThinGeantTruthAlg::m_nParticlesThinned {}
mutableprivate

Definition at line 136 of file ThinGeantTruthAlg.h.

136{};

◆ m_nVerticesProcessed

std::atomic<unsigned long> ThinGeantTruthAlg::m_nVerticesProcessed {}
mutableprivate

Definition at line 135 of file ThinGeantTruthAlg.h.

135{};

◆ m_nVerticesThinned

std::atomic<unsigned long> ThinGeantTruthAlg::m_nVerticesThinned {}
mutableprivate

Definition at line 137 of file ThinGeantTruthAlg.h.

137{};

◆ m_photonsKey

SG::ReadHandleKey<xAOD::PhotonContainer> ThinGeantTruthAlg::m_photonsKey
private
Initial value:
{
this,
"PhotonsKey",
"Photons",
"Name of the input photon container"
}

Definition at line 108 of file ThinGeantTruthAlg.h.

108 {
109 this,
110 "PhotonsKey",
111 "Photons",
112 "Name of the input photon container"
113 };

◆ m_readDecorKeys

SG::ReadDecorHandleKeyArray<xAOD::IParticleContainer> ThinGeantTruthAlg::m_readDecorKeys {this, "DecorKeys", {}}
private

Schedule the algorithm's dependency on the truth particle link.

Definition at line 63 of file ThinGeantTruthAlg.h.

63{this, "DecorKeys", {}};

◆ m_streamName

StringProperty ThinGeantTruthAlg::m_streamName
private
Initial value:
{ this,
"StreamName",
"",
"Stream for which thinning is to be done." }

Definition at line 47 of file ThinGeantTruthAlg.h.

47 { this,
48 "StreamName",
49 "",
50 "Stream for which thinning is to be done." };

◆ m_truthLinkDecor

Gaudi::Property<std::string> ThinGeantTruthAlg::m_truthLinkDecor {this, "TruthLinkDecor", "truthParticleLink"}
private

Truth particle link decorations.

Definition at line 61 of file ThinGeantTruthAlg.h.

61{this, "TruthLinkDecor", "truthParticleLink"};

◆ m_truthParticlesKey

SG::ThinningHandleKey<xAOD::TruthParticleContainer> ThinGeantTruthAlg::m_truthParticlesKey
private
Initial value:
{
this,
"TruthParticlesKey",
"TruthParticles",
"Name of the input Truth Particle container"
}

Definition at line 73 of file ThinGeantTruthAlg.h.

73 {
74 this,
75 "TruthParticlesKey",
76 "TruthParticles",
77 "Name of the input Truth Particle container"
78 };

◆ m_truthVerticesKey

SG::ThinningHandleKey<xAOD::TruthVertexContainer> ThinGeantTruthAlg::m_truthVerticesKey
private
Initial value:
{
this,
"TruthVerticesKey",
"TruthVertices",
"Name of the input Truth Vertices container"
}

Definition at line 80 of file ThinGeantTruthAlg.h.

80 {
81 this,
82 "TruthVerticesKey",
83 "TruthVertices",
84 "Name of the input Truth Vertices container"
85 };

◆ m_varHandleArraysDeclared

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

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 386 of file AthCommonDataStore.h.


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