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

#include <TruthParentDecoratorAlg.h>

Inheritance diagram for TruthParentDecoratorAlg:
Collaboration diagram for TruthParentDecoratorAlg:

Public Types

using Barcodex = std::map<int, std::set<int>>
using IPMap = std::map<int, std::set<const xAOD::TruthParticle*>>
using JC = xAOD::IParticleContainer
using J = xAOD::IParticle
using TPC = xAOD::TruthParticleContainer
using JL = ElementLink<JC>

Public Member Functions

 TruthParentDecoratorAlg (const std::string &name, ISvcLocator *loc)
virtual StatusCode initialize () override
virtual StatusCode execute (const EventContext &) const override
virtual StatusCode finalize () override
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

using cascade_counter_property_t = std::map<std::string,std::vector<int>>
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

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

Private Attributes

SG::ReadHandleKey< JCm_target_container_key
Gaudi::Property< std::string > m_prefix
Gaudi::Property< std::vector< int > > m_parent_pdgids
Gaudi::Property< std::vector< int > > m_cascade_pdgids
Gaudi::Property< bool > m_add_b
Gaudi::Property< bool > m_add_c
Gaudi::Property< bool > m_veto_soft_lepton
Gaudi::Property< bool > m_veto_soft_charm
Gaudi::Property< float > m_match_delta_r
SG::ReadHandleKey< TPCm_parents_key
SG::ReadHandleKeyArray< TPCm_cascades_key
SG::WriteDecorHandleKey< JCm_target_pdgid_key
SG::WriteDecorHandleKey< JCm_target_dr_truth_key
SG::WriteDecorHandleKey< JCm_target_link_key
SG::WriteDecorHandleKey< JCm_target_index_key
SG::WriteDecorHandleKey< JCm_target_n_matched_key
SG::WriteDecorHandleKey< JCm_target_match_mask_key
SG::WriteDecorHandleKey< JCm_match_pdgid_key
SG::WriteDecorHandleKey< JCm_match_children_key
SG::WriteDecorHandleKey< JCm_match_link_key
Gaudi::Property< cascade_counter_property_tm_counts_matching_cascade
SG::WriteDecorHandleKeyArray< JCm_cascade_count_writer_keys
std::vector< CascadeCountDecoratorm_cascade_count_decorators
Gaudi::Property< std::unordered_set< int > > m_allow_missing_children_pdgids
Gaudi::Property< float > m_missing_children_fraction_warning_threshold
Gaudi::Property< std::unordered_set< int > > m_warn_missing_children_pdgids
std::atomic< unsigned long long > m_missing_n_ignored
std::atomic< unsigned long long > m_missing_n_warned
std::atomic< unsigned long long > m_total_children
Gaudi::Property< bool > m_use_barcode
SG::ConstAccessor< int > m_uid {"uid"}
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 31 of file TruthParentDecoratorAlg.h.

Member Typedef Documentation

◆ Barcodex

using TruthParentDecoratorAlg::Barcodex = std::map<int, std::set<int>>

Definition at line 34 of file TruthParentDecoratorAlg.h.

◆ cascade_counter_property_t

using TruthParentDecoratorAlg::cascade_counter_property_t = std::map<std::string,std::vector<int>>
private

Definition at line 45 of file TruthParentDecoratorAlg.h.

◆ IPMap

using TruthParentDecoratorAlg::IPMap = std::map<int, std::set<const xAOD::TruthParticle*>>

Definition at line 35 of file TruthParentDecoratorAlg.h.

◆ J

◆ JC

◆ JL

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

◆ TPC

Constructor & Destructor Documentation

◆ TruthParentDecoratorAlg()

TruthParentDecoratorAlg::TruthParentDecoratorAlg ( const std::string & name,
ISvcLocator * loc )

Definition at line 218 of file TruthParentDecoratorAlg.cxx.

218 :
219 AthReentrantAlgorithm(name, loc)
220{
221 // these aren't user configurable
222 declare(m_target_pdgid_key);
223 declare(m_target_dr_truth_key);
224 declare(m_target_link_key);
225 declare(m_target_index_key);
226 declare(m_target_n_matched_key);
228 declare(m_match_pdgid_key);
229 declare(m_match_children_key);
230 declare(m_match_link_key);
231}
SG::WriteDecorHandleKey< JC > m_target_index_key
SG::WriteDecorHandleKey< JC > m_target_n_matched_key
SG::WriteDecorHandleKey< JC > m_match_children_key
SG::WriteDecorHandleKey< JC > m_target_pdgid_key
SG::WriteDecorHandleKey< JC > m_match_link_key
SG::WriteDecorHandleKey< JC > m_target_match_mask_key
SG::WriteDecorHandleKey< JC > m_target_link_key
SG::WriteDecorHandleKey< JC > m_target_dr_truth_key
SG::WriteDecorHandleKey< JC > m_match_pdgid_key

Member Function Documentation

◆ addTruthContainer()

void TruthParentDecoratorAlg::addTruthContainer ( Barcodex & barcodex,
IPMap & ipmap,
const TPC & container ) const
private

Definition at line 452 of file TruthParentDecoratorAlg.cxx.

452 {
453
454 std::set<int> targid(m_cascade_pdgids.begin(), m_cascade_pdgids.end());
455 // we allow decays through any of the parent pdgids
456 targid.insert(m_parent_pdgids.begin(), m_parent_pdgids.end());
457
458 // this determines if a cascade vertex should be saved or not
459 auto cascadeWants = [
460 &targid,
461 b=m_add_b,
462 c=m_add_c,
465 ] (const xAOD::TruthParticle* p) {
466 if (int n_parents = p->nParents(); n_parents == 1) {
467 if (vsl && isSoftLepton(p)) return false;
468 if (vsc && isSoftCharm(p)) return false;
469 }
470 if (targid.contains(p->pdgId())) return true;
471 if (b && p->hasBottom()) return true;
472 if (c && p->hasCharm()) return true;
473 return false;
474 };
475
476 // insert a particle into the record, return the child set
477 // ATLASRECTS-8290: this should be replaced with ->uid()
478 auto insert = [this, &barcodex, &ipmap](const auto* p) -> auto& {
479 ipmap[m_uid(*p)].insert(p);
480 return barcodex[m_uid(*p)];
481 };
482
483 for (const xAOD::TruthParticle* p: container) {
484 if (cascadeWants(p)) {
485 auto& child_set = insert(p);
486 for (unsigned int child_n = 0; child_n < p->nChildren(); child_n++) {
487 const xAOD::TruthParticle* c = p->child(child_n);
488
489 // Unfortunately the truth record is often broken in various
490 // ways. There are a few configurable ways to deal with
491 // this. We keep track of the total number and how often we
492 // use these workarounds to make sure things don't go too
493 // crazy.
495 const auto& ok_missing = m_allow_missing_children_pdgids.value();
496 if (!c) {
497 if(ok_missing.contains(p->pdgId())) {
499 } else {
500 auto problem = std::format(
501 "null truth child [barcode={},pdg_id={},child={}of{}]",
502 // ATLASRECTS-8290: m_uid should be replaced with ->uid()
503 m_uid(*p), p->pdgId(), child_n, p->nChildren());
504 const auto& warn_missing = m_warn_missing_children_pdgids.value();
505 if (warn_missing.contains(p->pdgId())) {
507 ATH_MSG_WARNING(problem);
508 } else {
509 throw std::runtime_error(problem);
510 }
511 }
512 } else if (cascadeWants(c)) {
513 insert(c);
514 // ATLASRECTS-8290: m_uid should be replaced with ->uid()
515 child_set.insert(m_uid(*c));
516 }
517 };
518 }
519 }
520}
#define ATH_MSG_WARNING(x)
Gaudi::Property< std::unordered_set< int > > m_allow_missing_children_pdgids
Gaudi::Property< bool > m_add_c
Gaudi::Property< bool > m_veto_soft_lepton
Gaudi::Property< bool > m_add_b
std::atomic< unsigned long long > m_total_children
Gaudi::Property< std::vector< int > > m_cascade_pdgids
Gaudi::Property< bool > m_veto_soft_charm
Gaudi::Property< std::vector< int > > m_parent_pdgids
SG::ConstAccessor< int > m_uid
std::atomic< unsigned long long > m_missing_n_warned
Gaudi::Property< std::unordered_set< int > > m_warn_missing_children_pdgids
std::atomic< unsigned long long > m_missing_n_ignored
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ 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 TruthParentDecoratorAlg::execute ( const EventContext & cxt) const
overridevirtual

Definition at line 275 of file TruthParentDecoratorAlg.cxx.

276{
277 ATH_MSG_DEBUG("Executing");
278
280 // part 1: read in the particles
282 SG::ReadHandle<JC> targets(m_target_container_key, cxt);
283
284 using uc_t = unsigned char;
285 SG::WriteDecorHandle<JC,int> pdgid(m_target_pdgid_key, cxt);
286 SG::WriteDecorHandle<JC,float> deltaR(m_target_dr_truth_key, cxt);
287 SG::WriteDecorHandle<JC,JL> link(m_target_link_key, cxt);
288 SG::WriteDecorHandle<JC,char> index(m_target_index_key, cxt);
289 SG::WriteDecorHandle<JC,uc_t> nMatched(m_target_n_matched_key, cxt);
290 SG::WriteDecorHandle<JC,parent_mask_t> mask(m_target_match_mask_key, cxt);
291 SG::WriteDecorHandle<JC,int> matchPdgId(m_match_pdgid_key, cxt);
292 SG::WriteDecorHandle<JC,int> matchChildCount(m_match_children_key, cxt);
293 SG::WriteDecorHandle<JC,JL> matchLink(m_match_link_key, cxt);
294
295 if (targets->empty()) return StatusCode::SUCCESS;
296
297 // read in and sort the parent collection
298 SG::ReadHandle<TPC> phandle(m_parents_key, cxt);
299 std::set<int> parentids(m_parent_pdgids.begin(), m_parent_pdgids.end());
300 std::vector<const xAOD::TruthParticle*> psort;
301 for (const xAOD::TruthParticle* p: *phandle) {
302 if (!parentids.contains(p->pdgId())) continue;
303 if (!isOriginal(p)) continue;
304 psort.push_back(p);
305 }
306 // for lack of a better idea, store truth parents sorted by mass
307 std::sort(psort.begin(), psort.end(),[](const auto* p1, const auto* p2) {return p1->m() > p2->m();});
308 // check to make sure we don't overflow the match mask
309 constexpr size_t max_idx = std::numeric_limits<parent_mask_t>::digits;
310 if (psort.size() > max_idx) {
312 "Found too many parent particles to store in parent match mask "
313 "truncating the parent collection [max: " << max_idx << ", "
314 "n: " << psort.size() << "]");
315 psort.resize(max_idx);
316 }
317
318
319 std::vector<SG::ReadHandle<TPC>> cascades_raw;
320 for (const auto& key: m_cascades_key) {
321 cascades_raw.emplace_back(key, cxt);
322 }
323 logInputs(msgStream(), targets, phandle, cascades_raw);
324
326 // part 2: build the barcodex
328 Barcodex barcodex;
329 IPMap ipmap;
330 addTruthContainer(barcodex, ipmap, *phandle);
331 for (auto& cascade: cascades_raw) {
332 addTruthContainer(barcodex, ipmap, *cascade);
333 }
334 logIPMap(msg(), ipmap);
335
336 ATH_MSG_DEBUG("merged cascade contains " << barcodex.size() << " particles");
337
339 // Part 3: build map from targets to parents
341 std::unordered_map<const J*, std::vector<MatchedParent>> labeled_targets;
342 unsigned int n_parents = 0;
343 for (const auto* p: psort) {
344 unsigned int parent_index = n_parents++;
345 // ATLASRECTS-8290: this should be replaced with ->uid()
346 ATH_MSG_VERBOSE("pdgid: " << p->pdgId() << ", barcode: " << m_uid(*p));
347 for (auto& [cbar, histbars]: findAllDescendants(m_uid(*p), barcodex)) {
348 IPMap::mapped_type& barkids = ipmap.at(cbar);
349 const xAOD::TruthParticle* child = selectChild(barkids);
350 std::vector<std::pair<float, const J*>> drs;
351 float drsMinDR=9999;
352 const J* drsMinMatch = 0;
353 for (const auto* j: *targets) {
354 if(j->p4().DeltaR(child->p4()) < drsMinDR) {
355 drsMinDR=j->p4().DeltaR(child->p4());
356 drsMinMatch=j;
357 }
358 }
359 if(drsMinMatch){
360 MatchedParent match;
361 match.parent = p;
362 match.child = child;
363 match.deltaR = drsMinDR;
364 match.parent_index = parent_index;
365 match.cascade_pids.insert(child->pdgId());
366 for (auto& histbar: histbars) {
367 match.cascade_pids.insert(selectChild(ipmap.at(histbar))->pdgId());
368 }
369 if (match.deltaR < m_match_delta_r) {
370 labeled_targets[drsMinMatch].push_back(std::move(match));
371 }
372 }
373 }
374 }
375
377 // Part 4: decorate!
379
380 for (const J* j: *targets) {
381 if (labeled_targets.contains(j)) {
382 const std::vector<MatchedParent>& matches = labeled_targets.at(j);
383 auto min_dr = [](auto& p1, auto& p2) {
384 return p1.deltaR < p2.deltaR;
385 };
386 const MatchedParent& nearest = *std::min_element(
387 matches.begin(), matches.end(), min_dr);
388 const xAOD::TruthParticle* p = nearest.parent;
389 pdgid(*j) = p->pdgId();
390 deltaR(*j) = nearest.deltaR;
391 auto* container = dynamic_cast<const TPC*>(p->container());
392 link(*j) = JL(*container, p->index());
393 index(*j) = nearest.parent_index;
394 nMatched(*j) = matches.size();
395 mask(*j) = matchMask(matches);
396 const xAOD::TruthParticle* child = nearest.child;
397 matchPdgId(*j) = child->pdgId();
398 matchChildCount(*j) = child->nChildren();
399 auto* matchedContainer = dynamic_cast<const TPC*>(child->container());
400 matchLink(*j) = JL(*matchedContainer, child->index());
401 for (const auto& cascadeCount: m_cascade_count_decorators) {
402 cascadeCount.decorate(*j, matches);
403 }
404 } else {
405 pdgid(*j) = 0;
406 deltaR(*j) = NAN;
407 link(*j) = JL();
408 index(*j) = -1;
409 nMatched(*j) = -1;
410 mask(*j) = 0x0;
411 matchPdgId(*j) = 0;
412 matchChildCount(*j) = 0;
413 matchLink(*j) = JL();
414 for (const auto& cascadeCount: m_cascade_count_decorators) {
415 cascadeCount.decorateDefault(*j);
416 }
417 }
418 }
419
421 // Part 5: lock decorations
423
424 for (const auto& dec: m_cascade_count_decorators) {
425 dec.lock(targets.get());
426 }
427
428 return StatusCode::SUCCESS;
429}
Scalar deltaR(const MatrixBase< Derived > &vec) const
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
const SG::AuxVectorData * container() const
Return the container holding this element.
size_t index() const
Return the index of this element within its container.
void addTruthContainer(Barcodex &, IPMap &, const TPC &) const
std::vector< CascadeCountDecorator > m_cascade_count_decorators
std::map< int, std::set< const xAOD::TruthParticle * > > IPMap
SG::ReadHandleKeyArray< TPC > m_cascades_key
std::map< int, std::set< int > > Barcodex
SG::ReadHandleKey< JC > m_target_container_key
SG::ReadHandleKey< TPC > m_parents_key
Gaudi::Property< float > m_match_delta_r
xAOD::TruthParticleContainer TPC
int pdgId() const
PDG ID code.
size_t nChildren() const
Number of children of this particle.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:357
str index
Definition DeMoScan.py:362
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
const xAOD::TruthParticle * parent
const xAOD::TruthParticle * child

◆ 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 TruthParentDecoratorAlg::finalize ( )
overridevirtual

Definition at line 431 of file TruthParentDecoratorAlg.cxx.

431 {
432 if (!m_allow_missing_children_pdgids.empty()) {
433 float missing_fraction = double(m_missing_n_ignored) / m_total_children;
434 auto msg = std::format("ignored {} missing children out of {} ({:.2}%)",m_missing_n_ignored.load(),m_total_children.load(),missing_fraction * 100);
435 if (missing_fraction > m_missing_children_fraction_warning_threshold) {
437 } else {
439 }
440 }
441 if (!m_warn_missing_children_pdgids.empty()) {
442 auto msg = std::format("warned of {} missing children out of {}", m_missing_n_warned.load(), m_total_children.load());
443 if (m_missing_n_warned > 0) {
445 } else {
447 }
448 }
449 return StatusCode::SUCCESS;
450}
#define ATH_MSG_INFO(x)
Gaudi::Property< float > m_missing_children_fraction_warning_threshold

◆ initialize()

StatusCode TruthParentDecoratorAlg::initialize ( )
overridevirtual

Definition at line 233 of file TruthParentDecoratorAlg.cxx.

233 {
234 // initialize inputs
235 ATH_CHECK(m_parents_key.initialize());
236 ATH_CHECK(m_target_container_key.initialize());
237 ATH_CHECK(m_cascades_key.initialize());
238 // weird hack because Gaudi can't handle an infinite default
239 if (m_match_delta_r.value() <= 0) m_match_delta_r.value() = INFINITY;
240 // initialize outputs
241 std::string jc = m_target_container_key.key();
242 std::string pfx = jc + "." + m_prefix.value();
243 m_target_pdgid_key = pfx + "PdgId";
244 m_target_dr_truth_key = pfx + "DRTruthParticle";
245 m_target_link_key = pfx + "Link";
246 m_target_index_key = pfx + "Index";
247 m_target_n_matched_key = pfx + "NMatchedChildren";
248 m_target_match_mask_key = pfx + "ParentsMask";
249 m_match_pdgid_key = pfx + "MatchingParticlePdgId";
250 m_match_children_key = pfx + "MatchingParticleNChildren";
251 m_match_link_key = pfx + "MatchingParticleLink";
252 ATH_CHECK(m_target_pdgid_key.initialize());
253 ATH_CHECK(m_target_dr_truth_key.initialize());
254 ATH_CHECK(m_target_link_key.initialize());
255 ATH_CHECK(m_target_index_key.initialize());
256 ATH_CHECK(m_target_n_matched_key.initialize());
258 ATH_CHECK(m_match_pdgid_key.initialize());
259 ATH_CHECK(m_match_children_key.initialize());
260 ATH_CHECK(m_match_link_key.initialize());
261
262 for (auto& [key, pids]: m_counts_matching_cascade) {
263 m_cascade_count_writer_keys.emplace_back(jc + "." + key);
264 m_cascade_count_decorators.emplace_back(key, pids);
265 }
266 for (auto& key: m_cascade_count_writer_keys) declare(key);
268
269 // ATLASRECTS-8290: this should be removed eventually
270 if (m_use_barcode) m_uid = SG::ConstAccessor<int>("barcode");
271
272 return StatusCode::SUCCESS;
273}
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::WriteDecorHandleKeyArray< JC > m_cascade_count_writer_keys
Gaudi::Property< bool > m_use_barcode
Gaudi::Property< cascade_counter_property_t > m_counts_matching_cascade
Gaudi::Property< std::string > m_prefix

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

◆ 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 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}
#define ATH_MSG_ERROR(x)
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_add_b

Gaudi::Property<bool> TruthParentDecoratorAlg::m_add_b
private
Initial value:
{
this, "addBsToCascade", false, "add all bhadrons to cascade"
}

Definition at line 59 of file TruthParentDecoratorAlg.h.

59 {
60 this, "addBsToCascade", false, "add all bhadrons to cascade"
61 };

◆ m_add_c

Gaudi::Property<bool> TruthParentDecoratorAlg::m_add_c
private
Initial value:
{
this, "addCsToCascade", false, "add all chadrons to cascade"
}

Definition at line 62 of file TruthParentDecoratorAlg.h.

62 {
63 this, "addCsToCascade", false, "add all chadrons to cascade"
64 };

◆ m_allow_missing_children_pdgids

Gaudi::Property<std::unordered_set<int> > TruthParentDecoratorAlg::m_allow_missing_children_pdgids
private
Initial value:
{
this, "allowMissingChildrenPdgIds", {},
"Allow particles matching these PDG IDs to have missing children"
}

Definition at line 101 of file TruthParentDecoratorAlg.h.

101 {
102 this, "allowMissingChildrenPdgIds", {},
103 "Allow particles matching these PDG IDs to have missing children"
104 };

◆ m_cascade_count_decorators

std::vector<CascadeCountDecorator> TruthParentDecoratorAlg::m_cascade_count_decorators
private

Definition at line 99 of file TruthParentDecoratorAlg.h.

◆ m_cascade_count_writer_keys

SG::WriteDecorHandleKeyArray<JC> TruthParentDecoratorAlg::m_cascade_count_writer_keys
private

Definition at line 98 of file TruthParentDecoratorAlg.h.

◆ m_cascade_pdgids

Gaudi::Property<std::vector<int> > TruthParentDecoratorAlg::m_cascade_pdgids
private
Initial value:
{
this, "cascadePdgIds", {}, "PDGIDs of particles in the decay chain"
}

Definition at line 56 of file TruthParentDecoratorAlg.h.

56 {
57 this, "cascadePdgIds", {}, "PDGIDs of particles in the decay chain"
58 };

◆ m_cascades_key

SG::ReadHandleKeyArray<TPC> TruthParentDecoratorAlg::m_cascades_key
private
Initial value:
{
this, "cascades", {}, "truth hadron container"
}

Definition at line 80 of file TruthParentDecoratorAlg.h.

80 {
81 this, "cascades", {}, "truth hadron container"
82 };

◆ m_counts_matching_cascade

Gaudi::Property<cascade_counter_property_t> TruthParentDecoratorAlg::m_counts_matching_cascade
private
Initial value:
{
this, "countChildrenInCascadeWithPdgIds", {},
"Create one counter for each entry, named by key. Counts children "
"with at least one overlapping value in the cascade."
}

Definition at line 93 of file TruthParentDecoratorAlg.h.

93 {
94 this, "countChildrenInCascadeWithPdgIds", {},
95 "Create one counter for each entry, named by key. Counts children "
96 "with at least one overlapping value in the cascade."
97 };

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

SG::WriteDecorHandleKey<JC> TruthParentDecoratorAlg::m_match_children_key
private

Definition at line 90 of file TruthParentDecoratorAlg.h.

◆ m_match_delta_r

Gaudi::Property<float> TruthParentDecoratorAlg::m_match_delta_r
private
Initial value:
{
this, "matchDeltaR", -1,
"width of delta R cone for matching (zero or less -> infinite)"
}

Definition at line 73 of file TruthParentDecoratorAlg.h.

73 {
74 this, "matchDeltaR", -1,
75 "width of delta R cone for matching (zero or less -> infinite)"
76 };

◆ m_match_link_key

SG::WriteDecorHandleKey<JC> TruthParentDecoratorAlg::m_match_link_key
private

Definition at line 91 of file TruthParentDecoratorAlg.h.

◆ m_match_pdgid_key

SG::WriteDecorHandleKey<JC> TruthParentDecoratorAlg::m_match_pdgid_key
private

Definition at line 89 of file TruthParentDecoratorAlg.h.

◆ m_missing_children_fraction_warning_threshold

Gaudi::Property<float> TruthParentDecoratorAlg::m_missing_children_fraction_warning_threshold
private
Initial value:
{
this, "missingChildrenFractionWarningThreshold", 0.01,
"Turn the missing children info into a warning above this"
}

Definition at line 105 of file TruthParentDecoratorAlg.h.

105 {
106 this, "missingChildrenFractionWarningThreshold", 0.01,
107 "Turn the missing children info into a warning above this"
108 };

◆ m_missing_n_ignored

std::atomic<unsigned long long> TruthParentDecoratorAlg::m_missing_n_ignored
mutableprivate

Definition at line 113 of file TruthParentDecoratorAlg.h.

◆ m_missing_n_warned

std::atomic<unsigned long long> TruthParentDecoratorAlg::m_missing_n_warned
mutableprivate

Definition at line 114 of file TruthParentDecoratorAlg.h.

◆ m_parent_pdgids

Gaudi::Property<std::vector<int> > TruthParentDecoratorAlg::m_parent_pdgids
private
Initial value:
{
this, "parentPdgIds", {}, "PDGIDs of allowed parent particles"
}

Definition at line 53 of file TruthParentDecoratorAlg.h.

53 {
54 this, "parentPdgIds", {}, "PDGIDs of allowed parent particles"
55 };

◆ m_parents_key

SG::ReadHandleKey<TPC> TruthParentDecoratorAlg::m_parents_key
private
Initial value:
{
this, "parents", "", "truth parent container"
}

Definition at line 77 of file TruthParentDecoratorAlg.h.

77 {
78 this, "parents", "", "truth parent container"
79 };

◆ m_prefix

Gaudi::Property<std::string> TruthParentDecoratorAlg::m_prefix
private
Initial value:
{
this, "decoratorPrefix", "parentBoson", "prefix for decorations"
}

Definition at line 50 of file TruthParentDecoratorAlg.h.

50 {
51 this, "decoratorPrefix", "parentBoson", "prefix for decorations"
52 };

◆ m_target_container_key

SG::ReadHandleKey<JC> TruthParentDecoratorAlg::m_target_container_key
private
Initial value:
{
this, "targetContainer", "", "target container to decorate"
}

Definition at line 47 of file TruthParentDecoratorAlg.h.

47 {
48 this, "targetContainer", "", "target container to decorate"
49 };

◆ m_target_dr_truth_key

SG::WriteDecorHandleKey<JC> TruthParentDecoratorAlg::m_target_dr_truth_key
private

Definition at line 84 of file TruthParentDecoratorAlg.h.

◆ m_target_index_key

SG::WriteDecorHandleKey<JC> TruthParentDecoratorAlg::m_target_index_key
private

Definition at line 86 of file TruthParentDecoratorAlg.h.

◆ m_target_link_key

SG::WriteDecorHandleKey<JC> TruthParentDecoratorAlg::m_target_link_key
private

Definition at line 85 of file TruthParentDecoratorAlg.h.

◆ m_target_match_mask_key

SG::WriteDecorHandleKey<JC> TruthParentDecoratorAlg::m_target_match_mask_key
private

Definition at line 88 of file TruthParentDecoratorAlg.h.

◆ m_target_n_matched_key

SG::WriteDecorHandleKey<JC> TruthParentDecoratorAlg::m_target_n_matched_key
private

Definition at line 87 of file TruthParentDecoratorAlg.h.

◆ m_target_pdgid_key

SG::WriteDecorHandleKey<JC> TruthParentDecoratorAlg::m_target_pdgid_key
private

Definition at line 83 of file TruthParentDecoratorAlg.h.

◆ m_total_children

std::atomic<unsigned long long> TruthParentDecoratorAlg::m_total_children
mutableprivate

Definition at line 115 of file TruthParentDecoratorAlg.h.

◆ m_uid

SG::ConstAccessor<int> TruthParentDecoratorAlg::m_uid {"uid"}
private

Definition at line 121 of file TruthParentDecoratorAlg.h.

121{"uid"};

◆ m_use_barcode

Gaudi::Property<bool> TruthParentDecoratorAlg::m_use_barcode
private
Initial value:
{
this, "useBarcode", false, "use barcode rather than UID"
}

Definition at line 118 of file TruthParentDecoratorAlg.h.

118 {
119 this, "useBarcode", false, "use barcode rather than UID"
120 };

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_veto_soft_charm

Gaudi::Property<bool> TruthParentDecoratorAlg::m_veto_soft_charm
private
Initial value:
{
this, "vetoSoftCharmCascade", false,
"veto soft charm decays from cascade"
}

Definition at line 69 of file TruthParentDecoratorAlg.h.

69 {
70 this, "vetoSoftCharmCascade", false,
71 "veto soft charm decays from cascade"
72 };

◆ m_veto_soft_lepton

Gaudi::Property<bool> TruthParentDecoratorAlg::m_veto_soft_lepton
private
Initial value:
{
this, "vetoSoftLeptonCascade", false,
"veto soft lepton decays from cascade"
}

Definition at line 65 of file TruthParentDecoratorAlg.h.

65 {
66 this, "vetoSoftLeptonCascade", false,
67 "veto soft lepton decays from cascade"
68 };

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_warn_missing_children_pdgids

Gaudi::Property<std::unordered_set<int> > TruthParentDecoratorAlg::m_warn_missing_children_pdgids
private
Initial value:
{
this, "warnMissingChildrenPdgIds", {},
"Warn if particles matching these PDF IDs have missing children"
}

Definition at line 109 of file TruthParentDecoratorAlg.h.

109 {
110 this, "warnMissingChildrenPdgIds", {},
111 "Warn if particles matching these PDF IDs have missing children"
112 };

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