Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TruthParentDecoratorAlg.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef TRUTH_PARENT_DECORATOR_ALG
5 #define TRUTH_PARENT_DECORATOR_ALG
6 
8 
9 // no need for forward declaration here, no one reads this header
13 
14 struct MatchedParent;
15 
17 {
18 public:
19  CascadeCountDecorator(const std::string& name,
20  const std::vector<int>& pids);
21  void decorate(const SG::AuxElement& target,
22  const std::vector<MatchedParent>& parents) const;
23  void decorateDefault(const SG::AuxElement& target) const;
24  void lock(const xAOD::IParticleContainer* target) const;
25 private:
26  std::vector<int> m_pids;
29 };
30 
32 {
33 public:
34  using Barcodex = std::map<int, std::set<int>>;
35  using IPMap = std::map<int, std::set<const xAOD::TruthParticle*>>;
37  using J = xAOD::IParticle;
40  TruthParentDecoratorAlg(const std::string& name, ISvcLocator* loc);
41  virtual StatusCode initialize () override;
42  virtual StatusCode execute (const EventContext&) const override;
43  virtual StatusCode finalize () override;
44 private:
45  using cascade_counter_property_t = std::map<std::string,std::vector<int>>;
46  void addTruthContainer(Barcodex&, IPMap&, const TPC&) const;
48  this, "targetContainer", "", "target container to decorate"
49  };
50  Gaudi::Property<std::string> m_prefix{
51  this, "decoratorPrefix", "parentBoson", "prefix for decorations"
52  };
53  Gaudi::Property<std::vector<int>> m_parent_pdgids{
54  this, "parentPdgIds", {}, "PDGIDs of allowed parent particles"
55  };
56  Gaudi::Property<std::vector<int>> m_cascade_pdgids{
57  this, "cascadePdgIds", {}, "PDGIDs of particles in the decay chain"
58  };
59  Gaudi::Property<bool> m_add_b{
60  this, "addBsToCascade", false, "add all bhadrons to cascade"
61  };
62  Gaudi::Property<bool> m_add_c{
63  this, "addCsToCascade", false, "add all chadrons to cascade"
64  };
65  Gaudi::Property<bool> m_veto_soft_lepton{
66  this, "vetoSoftLeptonCascade", false,
67  "veto soft lepton decays from cascade"
68  };
69  Gaudi::Property<bool> m_veto_soft_charm{
70  this, "vetoSoftCharmCascade", false,
71  "veto soft charm decays from cascade"
72  };
73  Gaudi::Property<float> m_match_delta_r{
74  this, "matchDeltaR", -1,
75  "width of delta R cone for matching (zero or less -> infinite)"
76  };
78  this, "parents", "", "truth parent container"
79  };
81  this, "cascades", {}, "truth hadron container"
82  };
92 
93  Gaudi::Property<cascade_counter_property_t> m_counts_matching_cascade {
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  };
99  std::vector<CascadeCountDecorator> m_cascade_count_decorators;
100 
101  Gaudi::Property<std::unordered_set<int>> m_allow_missing_children_pdgids {
102  this, "allowMissingChildrenPdgIds", {},
103  "Allow particles matching these PDG IDs to have missing children"
104  };
106  this, "missingChildrenFractionWarningThreshold", 0.01,
107  "Turn the missing children info into a warning above this"
108  };
109  Gaudi::Property<std::unordered_set<int>> m_warn_missing_children_pdgids {
110  this, "warnMissingChildrenPdgIds", {},
111  "Warn if particles matching these PDF IDs have missing children"
112  };
113  mutable std::atomic<unsigned long long> m_missing_n_ignored;
114  mutable std::atomic<unsigned long long> m_missing_n_warned;
115  mutable std::atomic<unsigned long long> m_total_children;
116 };
117 
118 #endif
TruthParentDecoratorAlg
Definition: TruthParentDecoratorAlg.h:32
TruthParentDecoratorAlg::m_parent_pdgids
Gaudi::Property< std::vector< int > > m_parent_pdgids
Definition: TruthParentDecoratorAlg.h:53
SG::WriteDecorHandleKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Definition: StoreGate/StoreGate/WriteDecorHandleKey.h:89
TruthParentDecoratorAlg::m_cascades_key
SG::ReadHandleKeyArray< TPC > m_cascades_key
Definition: TruthParentDecoratorAlg.h:80
TruthParentDecoratorAlg::initialize
virtual StatusCode initialize() override
Definition: TruthParentDecoratorAlg.cxx:232
TruthParentDecoratorAlg::cascade_counter_property_t
std::map< std::string, std::vector< int > > cascade_counter_property_t
Definition: TruthParentDecoratorAlg.h:45
TruthParentDecoratorAlg::m_veto_soft_lepton
Gaudi::Property< bool > m_veto_soft_lepton
Definition: TruthParentDecoratorAlg.h:65
TruthParentDecoratorAlg::addTruthContainer
void addTruthContainer(Barcodex &, IPMap &, const TPC &) const
Definition: TruthParentDecoratorAlg.cxx:447
CascadeCountDecorator::m_auxid
SG::auxid_t m_auxid
Definition: TruthParentDecoratorAlg.h:28
CascadeCountDecorator::CascadeCountDecorator
CascadeCountDecorator(const std::string &name, const std::vector< int > &pids)
Definition: TruthParentDecoratorAlg.cxx:184
TruthParentDecoratorAlg::m_match_link_key
SG::WriteDecorHandleKey< JC > m_match_link_key
Definition: TruthParentDecoratorAlg.h:91
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:483
python.DecayParser.parents
parents
print ("==> buf:",buf)
Definition: DecayParser.py:31
TruthParentDecoratorAlg::finalize
virtual StatusCode finalize() override
Definition: TruthParentDecoratorAlg.cxx:426
TruthParticleContainer.h
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition: xAOD/xAODBase/xAODBase/IParticleContainer.h:32
TruthParentDecoratorAlg::m_target_container_key
SG::ReadHandleKey< JC > m_target_container_key
Definition: TruthParentDecoratorAlg.h:47
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:38
TruthParentDecoratorAlg::m_add_b
Gaudi::Property< bool > m_add_b
Definition: TruthParentDecoratorAlg.h:59
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
TruthParentDecoratorAlg::m_cascade_count_decorators
std::vector< CascadeCountDecorator > m_cascade_count_decorators
Definition: TruthParentDecoratorAlg.h:99
TruthParentDecoratorAlg::TruthParentDecoratorAlg
TruthParentDecoratorAlg(const std::string &name, ISvcLocator *loc)
Definition: TruthParentDecoratorAlg.cxx:217
TruthParentDecoratorAlg::m_parents_key
SG::ReadHandleKey< TPC > m_parents_key
Definition: TruthParentDecoratorAlg.h:77
TruthParentDecoratorAlg::m_target_pdgid_key
SG::WriteDecorHandleKey< JC > m_target_pdgid_key
Definition: TruthParentDecoratorAlg.h:83
CascadeCountDecorator::m_pids
std::vector< int > m_pids
Definition: TruthParentDecoratorAlg.h:26
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
TruthParentDecoratorAlg::m_match_delta_r
Gaudi::Property< float > m_match_delta_r
Definition: TruthParentDecoratorAlg.h:73
CascadeCountDecorator::m_dec
SG::AuxElement::Decorator< unsigned char > m_dec
Definition: TruthParentDecoratorAlg.h:27
TruthParentDecoratorAlg::IPMap
std::map< int, std::set< const xAOD::TruthParticle * > > IPMap
Definition: TruthParentDecoratorAlg.h:35
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
TruthParentDecoratorAlg::m_add_c
Gaudi::Property< bool > m_add_c
Definition: TruthParentDecoratorAlg.h:62
TruthParentDecoratorAlg::m_cascade_pdgids
Gaudi::Property< std::vector< int > > m_cascade_pdgids
Definition: TruthParentDecoratorAlg.h:56
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
TruthParentDecoratorAlg::m_total_children
std::atomic< unsigned long long > m_total_children
Definition: TruthParentDecoratorAlg.h:115
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TruthParentDecoratorAlg::Barcodex
std::map< int, std::set< int > > Barcodex
Definition: TruthParentDecoratorAlg.h:34
IParticleContainer.h
TruthParentDecoratorAlg::m_counts_matching_cascade
Gaudi::Property< cascade_counter_property_t > m_counts_matching_cascade
Definition: TruthParentDecoratorAlg.h:93
CascadeCountDecorator
Definition: TruthParentDecoratorAlg.h:17
TruthParentDecoratorAlg::m_match_children_key
SG::WriteDecorHandleKey< JC > m_match_children_key
Definition: TruthParentDecoratorAlg.h:90
TruthParentDecoratorAlg::m_target_n_matched_key
SG::WriteDecorHandleKey< JC > m_target_n_matched_key
Definition: TruthParentDecoratorAlg.h:87
TruthParentDecoratorAlg::m_warn_missing_children_pdgids
Gaudi::Property< std::unordered_set< int > > m_warn_missing_children_pdgids
Definition: TruthParentDecoratorAlg.h:109
TruthParentDecoratorAlg::m_missing_n_ignored
std::atomic< unsigned long long > m_missing_n_ignored
Definition: TruthParentDecoratorAlg.h:113
TruthParentDecoratorAlg::m_cascade_count_writer_keys
SG::WriteDecorHandleKeyArray< JC > m_cascade_count_writer_keys
Definition: TruthParentDecoratorAlg.h:98
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
TruthParentDecoratorAlg::m_prefix
Gaudi::Property< std::string > m_prefix
Definition: TruthParentDecoratorAlg.h:50
CascadeCountDecorator::decorate
void decorate(const SG::AuxElement &target, const std::vector< MatchedParent > &parents) const
Definition: TruthParentDecoratorAlg.cxx:191
AthReentrantAlgorithm.h
TruthParentDecoratorAlg::m_missing_children_fraction_warning_threshold
Gaudi::Property< float > m_missing_children_fraction_warning_threshold
Definition: TruthParentDecoratorAlg.h:105
TruthParentDecoratorAlg::m_target_index_key
SG::WriteDecorHandleKey< JC > m_target_index_key
Definition: TruthParentDecoratorAlg.h:86
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TruthParentDecoratorAlg::execute
virtual StatusCode execute(const EventContext &) const override
Definition: TruthParentDecoratorAlg.cxx:271
xAOD::TruthParticleContainer
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
Definition: Event/xAOD/xAODTruth/xAODTruth/TruthParticleContainer.h:17
MatchedParent
Definition: TruthParentDecoratorAlg.cxx:14
TruthParentDecoratorAlg::m_target_dr_truth_key
SG::WriteDecorHandleKey< JC > m_target_dr_truth_key
Definition: TruthParentDecoratorAlg.h:84
TruthParentDecoratorAlg::m_veto_soft_charm
Gaudi::Property< bool > m_veto_soft_charm
Definition: TruthParentDecoratorAlg.h:69
CascadeCountDecorator::decorateDefault
void decorateDefault(const SG::AuxElement &target) const
Definition: TruthParentDecoratorAlg.cxx:201
copySelective.target
string target
Definition: copySelective.py:37
WriteDecorHandleKeyArray.h
TruthParentDecoratorAlg::m_target_match_mask_key
SG::WriteDecorHandleKey< JC > m_target_match_mask_key
Definition: TruthParentDecoratorAlg.h:88
TruthParentDecoratorAlg::m_allow_missing_children_pdgids
Gaudi::Property< std::unordered_set< int > > m_allow_missing_children_pdgids
Definition: TruthParentDecoratorAlg.h:101
CascadeCountDecorator::lock
void lock(const xAOD::IParticleContainer *target) const
Definition: TruthParentDecoratorAlg.cxx:205
TruthParentDecoratorAlg::m_target_link_key
SG::WriteDecorHandleKey< JC > m_target_link_key
Definition: TruthParentDecoratorAlg.h:85
TruthParentDecoratorAlg::m_match_pdgid_key
SG::WriteDecorHandleKey< JC > m_match_pdgid_key
Definition: TruthParentDecoratorAlg.h:89
TruthParentDecoratorAlg::m_missing_n_warned
std::atomic< unsigned long long > m_missing_n_warned
Definition: TruthParentDecoratorAlg.h:114