ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaDependencyHelpers.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8#ifndef SYSTEMATICS_HANDLES__ATHENA_DEPENDENCY_HELPERS_H
9#define SYSTEMATICS_HANDLES__ATHENA_DEPENDENCY_HELPERS_H
10
11//
12// includes
13//
14
16#include <type_traits>
17
18#ifndef XAOD_STANDALONE
24#endif
25
26//
27// method implementations
28//
29
30namespace CP
31{
32 namespace detail
33 {
34#ifndef XAOD_STANDALONE
35 template<typename ContainerType,unsigned mode,typename AlgorithmType>
36 requires (mode <= 2 && !std::is_const_v<ContainerType>)
37 StatusCode
38 addDependency (AlgorithmType& owner, const std::string& name,const std::string& decoName,bool decoWrite)
39 {
40 // I'm creating a `****HandleKey` for the given name and then take
41 // the proper dependency information from that, as that reuses as
42 // much as possible from the official AthenaMT dependency
43 // machinery.
44 std::conditional_t<mode == 0,SG::ReadHandleKey<ContainerType>,
45 std::conditional_t<mode == 1,SG::WriteHandleKey<ContainerType>,
47 if (!key.initialize().isSuccess())
48 return StatusCode::FAILURE;
49
50 if (decoName.empty())
51 {
52 owner.addDependency (key.fullKey(), key.mode());
53 return StatusCode::SUCCESS;
54 }
55
56 // This `if` exempts the MissingETContainer, which doesn't seem to
57 // like decoration handles. once this is fixed, this `if` should
58 // be removed, as well as the link dependency to xAODMissingET in
59 // the CMakeLists.txt of this package.
60 if constexpr (std::same_as<ContainerType, xAOD::MissingETContainer>)
61 {
62 owner.msg() << MSG::WARNING << "Can not add decoration dependency " << name << "." << decoName << " as MissingET doesn't support decoration dependencies. This is only problematic if you are running in AthenaMT and rely on this dependency to exist." << endmsg;
63 return StatusCode::SUCCESS;
64 } else
65 {
66 if (decoWrite)
67 {
68 SG::WriteDecorHandleKey<ContainerType> decoKey {key, decoName};
69 if (!decoKey.initialize().isSuccess())
70 return StatusCode::FAILURE;
71 owner.addDependency (decoKey.fullKey(), decoKey.mode());
72 } else
73 {
74 SG::ReadDecorHandleKey<ContainerType> decoKey {key, decoName};
75 if (!decoKey.initialize().isSuccess())
76 return StatusCode::FAILURE;
77 owner.addDependency (decoKey.fullKey(), decoKey.mode());
78 }
79 return StatusCode::SUCCESS;
80 }
81 }
82#endif
83 } // namespace detail
84}
85
86#endif
#define endmsg
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
Property holding a SG store/key/clid from which an UpdateHandle is made.
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Property holding a SG store/key/clid from which an UpdateHandle is made.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
StatusCode addDependency(AlgorithmType &owner, const std::string &name, const std::string &decoName, bool decoWrite)
Select isolated Photons, Electrons and Muons.