 |
ATLAS Offline Software
|
#include <TruthParentDecoratorAlg.h>
|
| | 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. More...
|
| |
| virtual bool | isClonable () const override |
| | Specify if the algorithm is clonable. More...
|
| |
| virtual unsigned int | cardinality () const override |
| | Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant. More...
|
| |
| virtual StatusCode | sysExecute (const EventContext &ctx) override |
| | Execute an algorithm. More...
|
| |
| virtual const DataObjIDColl & | extraOutputDeps () const override |
| | Return the list of extra output dependencies. More...
|
| |
| 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. More...
|
| |
| const ServiceHandle< StoreGateSvc > & | evtStore () const |
| | The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
|
| |
| const ServiceHandle< StoreGateSvc > & | detStore () const |
| | The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
|
| |
| virtual StatusCode | sysStart () override |
| | Handle START transition. More...
|
| |
| virtual std::vector< Gaudi::DataHandle * > | inputHandles () const override |
| | Return this algorithm's input handles. More...
|
| |
| virtual std::vector< Gaudi::DataHandle * > | outputHandles () const override |
| | Return this algorithm's output handles. More...
|
| |
| Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Property< T, V, H > &t) |
| |
| Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &) |
| | Declare a new Gaudi property. More...
|
| |
| Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &) |
| | Declare a new Gaudi property. More...
|
| |
| Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &) |
| |
| Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &) |
| | Declare a new Gaudi property. More...
|
| |
| Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc="none") |
| | Declare a new Gaudi property. More...
|
| |
| void | updateVHKA (Gaudi::Details::PropertyBase &) |
| |
| MsgStream & | msg () const |
| |
| MsgStream & | msg (const MSG::Level lvl) const |
| |
| bool | msgLvl (const MSG::Level lvl) const |
| |
|
| 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> More...
|
| |
| Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyArrayType &) |
| | specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
|
| |
| Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleType &) |
| | specialization for handling Gaudi::Property<SG::VarHandleBase> More...
|
| |
| Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T, V, H > &t, const SG::NotHandleType &) |
| | specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
|
| |
Definition at line 31 of file TruthParentDecoratorAlg.h.
◆ Barcodex
◆ cascade_counter_property_t
◆ IPMap
◆ JC
◆ JL
◆ StoreGateSvc_t
◆ TPC
◆ TruthParentDecoratorAlg()
| TruthParentDecoratorAlg::TruthParentDecoratorAlg |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
loc |
|
) |
| |
◆ addTruthContainer()
| void TruthParentDecoratorAlg::addTruthContainer |
( |
Barcodex & |
barcodex, |
|
|
IPMap & |
ipmap, |
|
|
const TPC & |
container |
|
) |
| const |
|
private |
Definition at line 452 of file TruthParentDecoratorAlg.cxx.
459 auto cascadeWants = [
466 if (
int n_parents =
p->nParents(); n_parents == 1) {
467 if (vsl && isSoftLepton(
p))
return false;
468 if (vsc && isSoftCharm(
p))
return false;
470 if (targid.contains(
p->pdgId()))
return true;
471 if (
b &&
p->hasBottom())
return true;
472 if (
c &&
p->hasCharm())
return true;
478 auto insert = [
this, &barcodex, &ipmap](
const auto*
p) ->
auto& {
480 return barcodex[
m_uid(*
p)];
484 if (cascadeWants(
p)) {
485 auto& child_set = insert(
p);
486 for (
unsigned int child_n = 0; child_n <
p->nChildren(); child_n++) {
497 if(ok_missing.contains(
p->pdgId())) {
501 "null truth child [barcode={},pdg_id={},child={}of{}]",
503 m_uid(*
p),
p->pdgId(), child_n,
p->nChildren());
505 if (warn_missing.contains(
p->pdgId())) {
509 throw std::runtime_error(problem);
512 }
else if (cascadeWants(
c)) {
515 child_set.insert(
m_uid(*
c));
◆ cardinality()
Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
Override this to return 0 for reentrant algorithms.
Override this to return 0 for reentrant algorithms.
Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.
◆ declareGaudiProperty() [1/4]
specialization for handling Gaudi::Property<SG::VarHandleKeyArray>
Definition at line 170 of file AthCommonDataStore.h.
175 hndl.documentation());
◆ declareGaudiProperty() [2/4]
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
161 hndl.documentation());
◆ declareGaudiProperty() [3/4]
specialization for handling Gaudi::Property<SG::VarHandleBase>
Definition at line 184 of file AthCommonDataStore.h.
189 hndl.documentation());
◆ declareGaudiProperty() [4/4]
◆ declareProperty() [1/6]
Declare a new Gaudi property.
- Parameters
-
| name | Name of the property. |
| hndl | Object holding the property value. |
| doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 245 of file AthCommonDataStore.h.
250 this->declare(hndl.
vhKey());
251 hndl.
vhKey().setOwner(
this);
◆ declareProperty() [2/6]
Declare a new Gaudi property.
- Parameters
-
| name | Name of the property. |
| hndl | Object holding the property value. |
| doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 221 of file AthCommonDataStore.h.
◆ declareProperty() [3/6]
◆ declareProperty() [4/6]
Declare a new Gaudi property.
- Parameters
-
| name | Name of the property. |
| property | Object holding the property value. |
| doc | Documentation string for the property. |
This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.
Definition at line 333 of file AthCommonDataStore.h.
◆ declareProperty() [5/6]
Declare a new Gaudi property.
- Parameters
-
| name | Name of the property. |
| property | Object holding the property value. |
| doc | Documentation string for the property. |
This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.
Definition at line 352 of file AthCommonDataStore.h.
◆ declareProperty() [6/6]
◆ detStore()
◆ evtStore() [1/2]
◆ evtStore() [2/2]
◆ execute()
| StatusCode TruthParentDecoratorAlg::execute |
( |
const EventContext & |
cxt | ) |
const |
|
overridevirtual |
Definition at line 275 of file TruthParentDecoratorAlg.cxx.
284 using uc_t =
unsigned char;
295 if (targets->empty())
return StatusCode::SUCCESS;
300 std::vector<const xAOD::TruthParticle*> psort;
302 if (!parentids.contains(
p->pdgId()))
continue;
303 if (!isOriginal(
p))
continue;
307 std::sort(psort.begin(), psort.end(),[](
const auto*
p1,
const auto*
p2) {return p1->m() > p2->m();});
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);
319 std::vector<SG::ReadHandle<TPC>> cascades_raw;
321 cascades_raw.emplace_back(
key, cxt);
323 logInputs(msgStream(), targets, phandle, cascades_raw);
331 for (
auto& cascade: cascades_raw) {
334 logIPMap(
msg(), ipmap);
336 ATH_MSG_DEBUG(
"merged cascade contains " << barcodex.size() <<
" particles");
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++;
347 for (
auto& [cbar, histbars]: findAllDescendants(
m_uid(*
p), barcodex)) {
348 IPMap::mapped_type& barkids = ipmap.at(cbar);
350 std::vector<std::pair<float, const J*>> drs;
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());
363 match.deltaR = drsMinDR;
364 match.parent_index = parent_index;
366 for (
auto& histbar: histbars) {
367 match.cascade_pids.insert(selectChild(ipmap.at(histbar))->pdgId());
370 labeled_targets[drsMinMatch].push_back(
match);
380 for (
const J* j: *targets) {
381 if (labeled_targets.contains(j)) {
382 const std::vector<MatchedParent>& matches = labeled_targets.at(j);
384 return p1.deltaR <
p2.deltaR;
387 matches.begin(), matches.end(),
min_dr);
389 pdgid(*j) =
p->pdgId();
391 auto* container =
dynamic_cast<const TPC*
>(
p->container());
392 link(*j) =
JL(*container,
p->index());
394 nMatched(*j) = matches.size();
395 mask(*j) = matchMask(matches);
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());
402 cascadeCount.decorate(*j, matches);
412 matchChildCount(*j) = 0;
413 matchLink(*j) =
JL();
415 cascadeCount.decorateDefault(*j);
425 dec.lock(targets.get());
428 return StatusCode::SUCCESS;
◆ extraDeps_update_handler()
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()
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.
◆ filterPassed()
◆ finalize()
| StatusCode TruthParentDecoratorAlg::finalize |
( |
| ) |
|
|
overridevirtual |
◆ initialize()
| StatusCode TruthParentDecoratorAlg::initialize |
( |
| ) |
|
|
overridevirtual |
◆ inputHandles()
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() [1/2]
◆ msg() [2/2]
◆ msgLvl()
◆ outputHandles()
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()
◆ renounceArray()
◆ setFilterPassed()
◆ sysExecute()
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.
◆ sysInitialize()
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 InputMakerBase, and HypoBase.
Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.
110 if (
sc.isFailure()) {
118 if ( cs.retrieve().isFailure() ) {
120 return StatusCode::SUCCESS;
122 if (cs->regHandle(
this,*
h).isFailure()) {
123 sc = StatusCode::FAILURE;
124 ATH_MSG_ERROR(
"unable to register WriteCondHandle " <<
h->fullKey()
◆ sysStart()
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
◆ updateVHKA()
◆ 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.
◆ 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.
◆ 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.
◆ m_cascade_count_decorators
◆ m_cascade_count_writer_keys
◆ 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.
◆ m_cascades_key
◆ m_counts_matching_cascade
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.
◆ m_detStore
◆ m_evtStore
◆ m_extendedExtraObjects
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
◆ 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.
◆ m_match_link_key
◆ m_match_pdgid_key
◆ 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.
◆ m_missing_n_ignored
| std::atomic<unsigned long long> TruthParentDecoratorAlg::m_missing_n_ignored |
|
mutableprivate |
◆ m_missing_n_warned
| std::atomic<unsigned long long> TruthParentDecoratorAlg::m_missing_n_warned |
|
mutableprivate |
◆ 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.
◆ m_parents_key
◆ 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.
◆ m_target_container_key
◆ m_target_dr_truth_key
◆ m_target_index_key
◆ m_target_link_key
◆ m_target_match_mask_key
◆ m_target_n_matched_key
◆ m_target_pdgid_key
◆ m_total_children
| std::atomic<unsigned long long> TruthParentDecoratorAlg::m_total_children |
|
mutableprivate |
◆ m_uid
◆ m_use_barcode
| Gaudi::Property<bool> TruthParentDecoratorAlg::m_use_barcode |
|
private |
◆ m_varHandleArraysDeclared
◆ 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.
◆ 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.
◆ m_vhka
◆ 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.
The documentation for this class was generated from the following files:
Gaudi::Property< std::vector< int > > m_parent_pdgids
SG::ReadHandleKeyArray< TPC > m_cascades_key
const xAOD::TruthParticle * child
Gaudi::Property< bool > m_veto_soft_lepton
void addTruthContainer(Barcodex &, IPMap &, const TPC &) const
SG::WriteDecorHandleKey< JC > m_match_link_key
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)
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
SG::ReadHandleKey< JC > m_target_container_key
Gaudi::Property< bool > m_add_b
#define ATH_MSG_VERBOSE(x)
xAOD::TruthParticleContainer TPC
std::vector< CascadeCountDecorator > m_cascade_count_decorators
SG::ReadHandleKey< TPC > m_parents_key
SG::WriteDecorHandleKey< JC > m_target_pdgid_key
virtual void setOwner(IDataHandleHolder *o)=0
An algorithm that can be simultaneously executed in multiple threads.
Gaudi::Property< float > m_match_delta_r
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
virtual const DataObjIDColl & extraOutputDeps() const override
Return the list of extra output dependencies.
std::map< int, std::set< const xAOD::TruthParticle * > > IPMap
Gaudi::Property< bool > m_add_c
Gaudi::Property< std::vector< int > > m_cascade_pdgids
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
std::atomic< unsigned long long > m_total_children
::StatusCode StatusCode
StatusCode definition for legacy code.
std::map< int, std::set< int > > Barcodex
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Class describing a truth particle in the MC record.
Handle class for adding a decoration to an object.
Gaudi::Property< cascade_counter_property_t > m_counts_matching_cascade
virtual StatusCode sysExecute(const EventContext &ctx) override
Execute an algorithm.
SG::WriteDecorHandleKey< JC > m_match_children_key
SG::WriteDecorHandleKey< JC > m_target_n_matched_key
SG::ConstAccessor< int > m_uid
Gaudi::Property< std::unordered_set< int > > m_warn_missing_children_pdgids
std::atomic< unsigned long long > m_missing_n_ignored
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
SG::WriteDecorHandleKeyArray< JC > m_cascade_count_writer_keys
unsigned int parent_index
size_t index() const
Return the index of this element within its container.
Gaudi::Property< std::string > m_prefix
virtual void renounce()=0
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Gaudi::Property< float > m_missing_children_fraction_warning_threshold
SG::WriteDecorHandleKey< JC > m_target_index_key
size_t nChildren() const
Number of children of this particle.
virtual FourMom_t p4() const =0
The full 4-momentum of the particle.
Gaudi::Property< bool > m_use_barcode
SG::WriteDecorHandleKey< JC > m_target_dr_truth_key
Gaudi::Property< bool > m_veto_soft_charm
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
#define ATH_MSG_WARNING(x)
SG::WriteDecorHandleKey< JC > m_target_match_mask_key
Gaudi::Property< std::unordered_set< int > > m_allow_missing_children_pdgids
SG::WriteDecorHandleKey< JC > m_target_link_key
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
virtual StatusCode sysInitialize() override
Override sysInitialize.
SG::WriteDecorHandleKey< JC > m_match_pdgid_key
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
const SG::AuxVectorData * container() const
Return the container holding this element.
int pdgId() const
PDG ID code.
DataObjIDColl m_extendedExtraObjects
Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
const xAOD::TruthParticle * parent
std::atomic< unsigned long long > m_missing_n_warned
bool match(std::string s1, std::string s2)
match the individual directories of two strings