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

219 :
220 AthReentrantAlgorithm(name, loc)
221{
222 // these aren't user configurable
223 declare(m_target_pdgid_key);
224 declare(m_target_dr_truth_key);
225 declare(m_target_link_key);
226 declare(m_target_index_key);
227 declare(m_target_n_matched_key);
229 declare(m_match_pdgid_key);
230 declare(m_match_children_key);
231 declare(m_match_link_key);
232}
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 453 of file TruthParentDecoratorAlg.cxx.

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

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

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

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

◆ initialize()

StatusCode TruthParentDecoratorAlg::initialize ( )
overridevirtual

Definition at line 234 of file TruthParentDecoratorAlg.cxx.

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

105 {
106 this, "allowMissingChildrenPdgIds", {},
107 "Allow particles matching these PDG IDs to have missing children"
108 };

◆ m_cascade_count_decorators

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

Definition at line 103 of file TruthParentDecoratorAlg.h.

◆ m_cascade_count_writer_keys

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

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

97 {
98 this, "countChildrenInCascadeWithPdgIds", {},
99 "Create one counter for each entry, named by key. Counts children "
100 "with at least one overlapping value in the cascade."
101 };

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

109 {
110 this, "missingChildrenFractionWarningThreshold", 0.01,
111 "Turn the missing children info into a warning above this"
112 };

◆ m_missing_n_ignored

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

Definition at line 117 of file TruthParentDecoratorAlg.h.

◆ m_missing_n_warned

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

Definition at line 118 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_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_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_total_children

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

Definition at line 119 of file TruthParentDecoratorAlg.h.

◆ m_uid

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

Definition at line 125 of file TruthParentDecoratorAlg.h.

125{"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 122 of file TruthParentDecoratorAlg.h.

122 {
123 this, "useBarcode", false, "use barcode rather than UID"
124 };

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

113 {
114 this, "warnMissingChildrenPdgIds", {},
115 "Warn if particles matching these PDF IDs have missing children"
116 };

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