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
SG::WriteDecorHandleKey< JCm_target_mass_key
SG::WriteDecorHandleKey< JCm_target_pt_key
SG::WriteDecorHandleKey< JCm_target_energy_key
SG::WriteDecorHandleKey< JCm_target_eta_key
SG::WriteDecorHandleKey< JCm_target_phi_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 35 of file TruthParentDecoratorAlg.h.

Member Typedef Documentation

◆ Barcodex

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

Definition at line 38 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 49 of file TruthParentDecoratorAlg.h.

◆ IPMap

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

Definition at line 39 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 228 of file TruthParentDecoratorAlg.cxx.

228 :
229 AthReentrantAlgorithm(name, loc)
230{
231 // these aren't user configurable
232 declare(m_target_pdgid_key);
233 declare(m_target_dr_truth_key);
234 declare(m_target_link_key);
235 declare(m_target_index_key);
236 declare(m_target_n_matched_key);
238 declare(m_match_pdgid_key);
239 declare(m_match_children_key);
240 declare(m_match_link_key);
241 declare(m_target_mass_key);
242 declare(m_target_pt_key);
243 declare(m_target_energy_key);
244 declare(m_target_eta_key);
245 declare(m_target_phi_key);
246}
SG::WriteDecorHandleKey< JC > m_target_phi_key
SG::WriteDecorHandleKey< JC > m_target_index_key
SG::WriteDecorHandleKey< JC > m_target_eta_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_target_energy_key
SG::WriteDecorHandleKey< JC > m_match_link_key
SG::WriteDecorHandleKey< JC > m_target_pt_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
SG::WriteDecorHandleKey< JC > m_target_mass_key

Member Function Documentation

◆ addTruthContainer()

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

Definition at line 492 of file TruthParentDecoratorAlg.cxx.

492 {
493
494 std::set<int> targid(m_cascade_pdgids.begin(), m_cascade_pdgids.end());
495 // we allow decays through any of the parent pdgids
496 targid.insert(m_parent_pdgids.begin(), m_parent_pdgids.end());
497
498 // this determines if a cascade vertex should be saved or not
499 auto cascadeWants = [
500 &targid,
501 &b=m_add_b,
502 &c=m_add_c,
505 ] (const xAOD::TruthParticle* p) {
506 if (int n_parents = p->nParents(); n_parents == 1) {
507 if (vsl && isSoftLepton(p)) return false;
508 if (vsc && isSoftCharm(p)) return false;
509 }
510 if (targid.contains(p->pdgId())) return true;
511 if (b && p->hasBottom()) return true;
512 if (c && p->hasCharm()) return true;
513 return false;
514 };
515
516 // insert a particle into the record, return the child set
517 // ATLASRECTS-8290: this should be replaced with ->uid()
518 auto insert = [this, &barcodex, &ipmap](const auto* p) -> auto& {
519 ipmap[m_uid(*p)].insert(p);
520 return barcodex[m_uid(*p)];
521 };
522
523 for (const xAOD::TruthParticle* p: container) {
524 if (cascadeWants(p)) {
525 auto& child_set = insert(p);
526 for (unsigned int child_n = 0; child_n < p->nChildren(); child_n++) {
527 const xAOD::TruthParticle* c = p->child(child_n);
528
529 // Unfortunately the truth record is often broken in various
530 // ways. There are a few configurable ways to deal with
531 // this. We keep track of the total number and how often we
532 // use these workarounds to make sure things don't go too
533 // crazy.
535 const auto& ok_missing = m_allow_missing_children_pdgids.value();
536 if (!c) {
537 if(ok_missing.contains(p->pdgId())) {
539 } else {
540 auto problem = std::format(
541 "null truth child [barcode={},pdg_id={},child={}of{}]",
542 // ATLASRECTS-8290: m_uid should be replaced with ->uid()
543 m_uid(*p), p->pdgId(), child_n, p->nChildren());
544 const auto& warn_missing = m_warn_missing_children_pdgids.value();
545 if (warn_missing.contains(p->pdgId())) {
547 ATH_MSG_WARNING(problem);
548 } else {
549 throw std::runtime_error(problem);
550 }
551 }
552 } else if (cascadeWants(c)) {
553 insert(c);
554 // ATLASRECTS-8290: m_uid should be replaced with ->uid()
555 child_set.insert(m_uid(*c));
556 }
557 };
558 }
559 }
560}
#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
ConcurrentBitset & insert(bit_t bit, bit_t new_nbits=0)
Set a bit to 1.
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.

62{
63 return 0;
64}

◆ 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 300 of file TruthParentDecoratorAlg.cxx.

301{
302 ATH_MSG_DEBUG("Executing");
303
305 // part 1: read in the particles
307 SG::ReadHandle<JC> targets(m_target_container_key, cxt);
308
309 using uc_t = unsigned char;
310 SG::WriteDecorHandle<JC,int> pdgid(m_target_pdgid_key, cxt);
311 SG::WriteDecorHandle<JC,float> deltaR(m_target_dr_truth_key, cxt);
312 SG::WriteDecorHandle<JC,JL> link(m_target_link_key, cxt);
313 SG::WriteDecorHandle<JC,char> index(m_target_index_key, cxt);
314 SG::WriteDecorHandle<JC,uc_t> nMatched(m_target_n_matched_key, cxt);
315 SG::WriteDecorHandle<JC,parent_mask_t> mask(m_target_match_mask_key, cxt);
316 SG::WriteDecorHandle<JC,int> matchPdgId(m_match_pdgid_key, cxt);
317 SG::WriteDecorHandle<JC,int> matchChildCount(m_match_children_key, cxt);
318 SG::WriteDecorHandle<JC,JL> matchLink(m_match_link_key, cxt);
319 SG::WriteDecorHandle<JC,float> dec_mass(m_target_mass_key, cxt);
320 SG::WriteDecorHandle<JC,float> dec_pt(m_target_pt_key, cxt);
321 SG::WriteDecorHandle<JC,float> dec_energy(m_target_energy_key, cxt);
322 SG::WriteDecorHandle<JC,float> dec_eta(m_target_eta_key, cxt);
323 SG::WriteDecorHandle<JC,float> dec_phi(m_target_phi_key, cxt);
324
325 if (targets->empty()) return StatusCode::SUCCESS;
326
327 // read in and sort the parent collection
328 SG::ReadHandle<TPC> phandle(m_parents_key, cxt);
329 std::set<int> parentids(m_parent_pdgids.begin(), m_parent_pdgids.end());
330 std::vector<const xAOD::TruthParticle*> psort;
331 for (const xAOD::TruthParticle* p: *phandle) {
332 if (!parentids.contains(p->pdgId())) continue;
333 if (!isOriginal(p)) continue;
334 psort.push_back(p);
335 }
336 // for lack of a better idea, store truth parents sorted by mass
337 std::sort(psort.begin(), psort.end(),[](const auto* p1, const auto* p2) {return p1->m() > p2->m();});
338 // check to make sure we don't overflow the match mask
339 constexpr size_t max_idx = std::numeric_limits<parent_mask_t>::digits;
340 if (psort.size() > max_idx) {
342 "Found too many parent particles to store in parent match mask "
343 "truncating the parent collection [max: " << max_idx << ", "
344 "n: " << psort.size() << "]");
345 psort.resize(max_idx);
346 }
347
348
349 std::vector<SG::ReadHandle<TPC>> cascades_raw;
350 for (const auto& key: m_cascades_key) {
351 cascades_raw.emplace_back(key, cxt);
352 }
353 logInputs(msgStream(), targets, phandle, cascades_raw);
354
356 // part 2: build the barcodex
358 Barcodex barcodex;
359 IPMap ipmap;
360 addTruthContainer(barcodex, ipmap, *phandle);
361 for (auto& cascade: cascades_raw) {
362 addTruthContainer(barcodex, ipmap, *cascade);
363 }
364 logIPMap(msg(), ipmap);
365
366 ATH_MSG_DEBUG("merged cascade contains " << barcodex.size() << " particles");
367
369 // Part 3: build map from targets to parents
371 std::unordered_map<const J*, std::vector<MatchedParent>> labeled_targets;
372 unsigned int n_parents = 0;
373 for (const auto* p: psort) {
374 unsigned int parent_index = n_parents++;
375 // ATLASRECTS-8290: this should be replaced with ->uid()
376 ATH_MSG_VERBOSE("pdgid: " << p->pdgId() << ", barcode: " << m_uid(*p));
377 for (auto& [cbar, histbars]: findAllDescendants(m_uid(*p), barcodex)) {
378 IPMap::mapped_type& barkids = ipmap.at(cbar);
379 const xAOD::TruthParticle* child = selectChild(barkids);
380 std::vector<std::pair<float, const J*>> drs;
381 float drsMinDR=9999;
382 const J* drsMinMatch = 0;
383 for (const auto* j: *targets) {
384 if(j->p4().DeltaR(child->p4()) < drsMinDR) {
385 drsMinDR=j->p4().DeltaR(child->p4());
386 drsMinMatch=j;
387 }
388 }
389 if(drsMinMatch){
390 MatchedParent match;
391 match.parent = p;
392 match.child = child;
393 match.deltaR = drsMinDR;
394 match.parent_index = parent_index;
395 match.cascade_pids.insert(child->pdgId());
396 for (auto& histbar: histbars) {
397 match.cascade_pids.insert(selectChild(ipmap.at(histbar))->pdgId());
398 }
399 if (match.deltaR < m_match_delta_r) {
400 labeled_targets[drsMinMatch].push_back(std::move(match));
401 }
402 }
403 }
404 }
405
407 // Part 4: decorate!
409
410 for (const J* j: *targets) {
411 if (labeled_targets.contains(j)) {
412 const std::vector<MatchedParent>& matches = labeled_targets.at(j);
413 auto min_dr = [](auto& p1, auto& p2) {
414 return p1.deltaR < p2.deltaR;
415 };
416 const MatchedParent& nearest = *std::min_element(
417 matches.begin(), matches.end(), min_dr);
418 const xAOD::TruthParticle* p = nearest.parent;
419 pdgid(*j) = p->pdgId();
420 deltaR(*j) = nearest.deltaR;
421 auto* container = dynamic_cast<const TPC*>(p->container());
422 link(*j) = JL(*container, p->index());
423 index(*j) = nearest.parent_index;
424 nMatched(*j) = matches.size();
425 mask(*j) = matchMask(matches);
426 const xAOD::TruthParticle* child = nearest.child;
427 matchPdgId(*j) = child->pdgId();
428 matchChildCount(*j) = child->nChildren();
429 auto* matchedContainer = dynamic_cast<const TPC*>(child->container());
430 matchLink(*j) = JL(*matchedContainer, child->index());
431 dec_mass(*j) = p->m();
432 dec_pt(*j) = p->pt();
433 dec_energy(*j) = p->e();
434 dec_eta(*j) = p->eta();
435 dec_phi(*j) = p->phi();
436 for (const auto& cascadeCount: m_cascade_count_decorators) {
437 cascadeCount.decorate(*j, matches);
438 }
439 } else {
440 pdgid(*j) = 0;
441 deltaR(*j) = NAN;
442 link(*j) = JL();
443 index(*j) = -1;
444 nMatched(*j) = -1;
445 mask(*j) = 0x0;
446 matchPdgId(*j) = 0;
447 matchChildCount(*j) = 0;
448 matchLink(*j) = JL();
449 dec_mass(*j) = NAN;
450 dec_pt(*j) = NAN;
451 dec_energy(*j) = NAN;
452 dec_eta(*j) = NAN;
453 dec_phi(*j) = NAN;
454 for (const auto& cascadeCount: m_cascade_count_decorators) {
455 cascadeCount.decorateDefault(*j);
456 }
457 }
458 }
459
461 // Part 5: lock decorations
463
464 for (const auto& dec: m_cascade_count_decorators) {
465 dec.lock(targets.get());
466 }
467
468 return StatusCode::SUCCESS;
469}
Scalar deltaR(const MatrixBase< Derived > &vec) const
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
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:359
str index
Definition DeMoScan.py:362
pointer & link(pointer p) const
Return a reference to the link for an element.
const SG::AuxVectorData * container() const
Return the container holding this element.
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
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.

88{
89 // If we didn't find any symlinks to add, just return the collection
90 // from the base class. Otherwise, return the extended collection.
91 if (!m_extendedExtraObjects.empty()) {
93 }
95}
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 471 of file TruthParentDecoratorAlg.cxx.

471 {
472 if (!m_allow_missing_children_pdgids.empty()) {
473 float missing_fraction = double(m_missing_n_ignored) / m_total_children;
474 auto msg = std::format("ignored {} missing children out of {} ({:.2}%)",m_missing_n_ignored.load(),m_total_children.load(),missing_fraction * 100);
475 if (missing_fraction > m_missing_children_fraction_warning_threshold) {
477 } else {
479 }
480 }
481 if (!m_warn_missing_children_pdgids.empty()) {
482 auto msg = std::format("warned of {} missing children out of {}", m_missing_n_warned.load(), m_total_children.load());
483 if (m_missing_n_warned > 0) {
485 } else {
487 }
488 }
489 return StatusCode::SUCCESS;
490}
#define ATH_MSG_INFO(x)
Gaudi::Property< float > m_missing_children_fraction_warning_threshold

◆ initialize()

StatusCode TruthParentDecoratorAlg::initialize ( )
overridevirtual

Definition at line 248 of file TruthParentDecoratorAlg.cxx.

248 {
249 // initialize inputs
250 ATH_CHECK(m_parents_key.initialize());
251 ATH_CHECK(m_target_container_key.initialize());
252 ATH_CHECK(m_cascades_key.initialize());
253 // weird hack because Gaudi can't handle an infinite default
254 if (m_match_delta_r.value() <= 0) m_match_delta_r.value() = INFINITY;
255 // initialize outputs
256 std::string jc = m_target_container_key.key();
257 std::string pfx = jc + "." + m_prefix.value();
258 m_target_pdgid_key = pfx + "PdgId";
259 m_target_dr_truth_key = pfx + "DRTruthParticle";
260 m_target_link_key = pfx + "Link";
261 m_target_index_key = pfx + "Index";
262 m_target_n_matched_key = pfx + "NMatchedChildren";
263 m_target_match_mask_key = pfx + "ParentsMask";
264 m_match_pdgid_key = pfx + "MatchingParticlePdgId";
265 m_match_children_key = pfx + "MatchingParticleNChildren";
266 m_match_link_key = pfx + "MatchingParticleLink";
267 m_target_mass_key = pfx + "Mass";
268 m_target_pt_key = pfx + "PT";
269 m_target_energy_key = pfx + "Energy";
270 m_target_eta_key = pfx + "Eta";
271 m_target_phi_key = pfx + "Phi";
272 ATH_CHECK(m_target_pdgid_key.initialize());
273 ATH_CHECK(m_target_dr_truth_key.initialize());
274 ATH_CHECK(m_target_link_key.initialize());
275 ATH_CHECK(m_target_index_key.initialize());
276 ATH_CHECK(m_target_n_matched_key.initialize());
278 ATH_CHECK(m_match_pdgid_key.initialize());
279 ATH_CHECK(m_match_children_key.initialize());
280 ATH_CHECK(m_match_link_key.initialize());
281 ATH_CHECK(m_target_mass_key.initialize());
282 ATH_CHECK(m_target_pt_key.initialize());
283 ATH_CHECK(m_target_energy_key.initialize());
284 ATH_CHECK(m_target_eta_key.initialize());
285 ATH_CHECK(m_target_phi_key.initialize());
286
287 for (auto& [key, pids]: m_counts_matching_cascade) {
288 m_cascade_count_writer_keys.emplace_back(jc + "." + key);
289 m_cascade_count_decorators.emplace_back(key, pids);
290 }
291 for (auto& key: m_cascade_count_writer_keys) declare(key);
293
294 // ATLASRECTS-8290: this should be removed eventually
295 if (m_use_barcode) m_uid = SG::ConstAccessor<int>("barcode");
296
297 return StatusCode::SUCCESS;
298}
#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.

75{
76 return BaseAlg::sysExecute (ctx);
77}

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

105 {
107
108 if (sc.isFailure()) {
109 return sc;
110 }
111
112 ServiceHandle<ICondSvc> cs("CondSvc",name());
113 for (auto h : outputHandles()) {
114 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
115 // do this inside the loop so we don't create the CondSvc until needed
116 if ( cs.retrieve().isFailure() ) {
117 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
118 return StatusCode::SUCCESS;
119 }
120 if (cs->regHandle(this,*h).isFailure()) {
122 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
123 << " with CondSvc");
124 }
125 }
126 }
127 return sc;
128}
#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 63 of file TruthParentDecoratorAlg.h.

63 {
64 this, "addBsToCascade", false, "add all bhadrons to cascade"
65 };

◆ m_add_c

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

Definition at line 66 of file TruthParentDecoratorAlg.h.

66 {
67 this, "addCsToCascade", false, "add all chadrons to cascade"
68 };

◆ 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 110 of file TruthParentDecoratorAlg.h.

110 {
111 this, "allowMissingChildrenPdgIds", {},
112 "Allow particles matching these PDG IDs to have missing children"
113 };

◆ m_cascade_count_decorators

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

Definition at line 108 of file TruthParentDecoratorAlg.h.

◆ m_cascade_count_writer_keys

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

Definition at line 107 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 60 of file TruthParentDecoratorAlg.h.

60 {
61 this, "cascadePdgIds", {}, "PDGIDs of particles in the decay chain"
62 };

◆ m_cascades_key

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

Definition at line 84 of file TruthParentDecoratorAlg.h.

84 {
85 this, "cascades", {}, "truth hadron container"
86 };

◆ 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 102 of file TruthParentDecoratorAlg.h.

102 {
103 this, "countChildrenInCascadeWithPdgIds", {},
104 "Create one counter for each entry, named by key. Counts children "
105 "with at least one overlapping value in the cascade."
106 };

◆ 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 94 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 77 of file TruthParentDecoratorAlg.h.

77 {
78 this, "matchDeltaR", -1,
79 "width of delta R cone for matching (zero or less -> infinite)"
80 };

◆ m_match_link_key

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

Definition at line 95 of file TruthParentDecoratorAlg.h.

◆ m_match_pdgid_key

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

Definition at line 93 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 114 of file TruthParentDecoratorAlg.h.

114 {
115 this, "missingChildrenFractionWarningThreshold", 0.01,
116 "Turn the missing children info into a warning above this"
117 };

◆ m_missing_n_ignored

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

Definition at line 122 of file TruthParentDecoratorAlg.h.

◆ m_missing_n_warned

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

Definition at line 123 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 57 of file TruthParentDecoratorAlg.h.

57 {
58 this, "parentPdgIds", {}, "PDGIDs of allowed parent particles"
59 };

◆ m_parents_key

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

Definition at line 81 of file TruthParentDecoratorAlg.h.

81 {
82 this, "parents", "", "truth parent container"
83 };

◆ m_prefix

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

Definition at line 54 of file TruthParentDecoratorAlg.h.

54 {
55 this, "decoratorPrefix", "parentBoson", "prefix for decorations"
56 };

◆ m_target_container_key

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

Definition at line 51 of file TruthParentDecoratorAlg.h.

51 {
52 this, "targetContainer", "", "target container to decorate"
53 };

◆ m_target_dr_truth_key

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

Definition at line 88 of file TruthParentDecoratorAlg.h.

◆ m_target_energy_key

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

Definition at line 98 of file TruthParentDecoratorAlg.h.

◆ m_target_eta_key

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

Definition at line 99 of file TruthParentDecoratorAlg.h.

◆ m_target_index_key

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

Definition at line 90 of file TruthParentDecoratorAlg.h.

◆ m_target_link_key

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

Definition at line 89 of file TruthParentDecoratorAlg.h.

◆ m_target_mass_key

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

Definition at line 96 of file TruthParentDecoratorAlg.h.

◆ m_target_match_mask_key

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

Definition at line 92 of file TruthParentDecoratorAlg.h.

◆ m_target_n_matched_key

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

Definition at line 91 of file TruthParentDecoratorAlg.h.

◆ m_target_pdgid_key

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

Definition at line 87 of file TruthParentDecoratorAlg.h.

◆ m_target_phi_key

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

Definition at line 100 of file TruthParentDecoratorAlg.h.

◆ m_target_pt_key

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

Definition at line 97 of file TruthParentDecoratorAlg.h.

◆ m_total_children

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

Definition at line 124 of file TruthParentDecoratorAlg.h.

◆ m_uid

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

Definition at line 130 of file TruthParentDecoratorAlg.h.

130{"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 127 of file TruthParentDecoratorAlg.h.

127 {
128 this, "useBarcode", false, "use barcode rather than UID"
129 };

◆ 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 73 of file TruthParentDecoratorAlg.h.

73 {
74 this, "vetoSoftCharmCascade", false,
75 "veto soft charm decays from cascade"
76 };

◆ 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 69 of file TruthParentDecoratorAlg.h.

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

◆ 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 118 of file TruthParentDecoratorAlg.h.

118 {
119 this, "warnMissingChildrenPdgIds", {},
120 "Warn if particles matching these PDF IDs have missing children"
121 };

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