ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODCore
xAODCore
tools
AuxVariable.h
Go to the documentation of this file.
1
// Dear emacs, this is -*- c++ -*-
2
//
3
// Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4
//
5
#ifndef XAODCORE_TOOLS_AUXVARIABLE_H
6
#define XAODCORE_TOOLS_AUXVARIABLE_H
7
8
// EDM include(s).
9
#include "
AthContainers/AuxTypeRegistry.h
"
10
#include "
AthContainers/ConstAccessor.h
"
11
#include "
CxxUtils/pputils.h
"
12
23
#define AUX_VARIABLE( VAR, ... ) \
24
do { \
25
static const auxid_t auxid = \
26
getAuxID( #VAR, VAR CXXUTILS_PP_FIRST( __VA_ARGS__ ) ); \
27
regAuxVar( auxid, #VAR, VAR ); \
28
} while( false )
29
30
31
55
namespace
xAOD
{
namespace
detail
{
56
57
58
template
<
class
VARTYPE,
class
AUXBASE>
59
VARTYPE
initAuxVar2
( AUXBASE* auxcont,
60
std::true_type)
61
{
62
return
VARTYPE (auxcont->memResource());
63
}
64
65
66
template
<
class
VARTYPE,
class
AUXBASE>
67
VARTYPE
initAuxVar2
( AUXBASE*
/*auxcont*/
,
68
std::false_type)
69
{
70
return
VARTYPE();
71
}
72
73
74
template
<
class
VARTYPE,
class
AUXBASE>
75
VARTYPE
initAuxVar1
( AUXBASE* auxcont)
76
{
77
return
initAuxVar2<VARTYPE>
( auxcont, std::is_constructible<VARTYPE, std::pmr::memory_resource*>() );
78
}
79
80
81
template
<const
char
* NAME,
class
AUXBASE,
class
VARTYPE>
82
VARTYPE
initAuxVar
( AUXBASE* auxcont,
83
VARTYPE& var,
84
SG::AuxVarFlags
flags =
SG::AuxVarFlags::None
)
85
{
86
static
const
SG::auxid_t
auxid = auxcont->getAuxID( NAME, var, flags );
87
auxcont->regAuxVar (auxid, NAME, var);
88
return
initAuxVar1<VARTYPE>
( auxcont );
89
}
90
91
92
// Version to handle initializing a linked variable.
93
// ELT is the type of the variable being linked to, LINKS is the type of the
94
// member defined in the container for it. LINKED is the member type
95
// for the linked variable, and AUXBASE is the container base class.
96
template
<
class
ELT, const
char
* NAME,
class
AUXBASE,
class
LINKS,
class
LINKED>
97
LINKED
initLinkedVar
( AUXBASE* auxcont,
98
LINKS& links,
99
LINKED& linked )
100
{
101
// Use the @c ConstAccessor specialization to get the variable
102
// declared properly.
103
static
const
SG::ConstAccessor<ELT>
acc
( NAME );
104
auxcont->regAuxVar(
acc
.linkedAuxid(),
SG::AuxTypeRegistry::linkedName
(NAME), linked );
105
auxcont->regAuxVar(
acc
.auxid(), NAME, links );
106
return
xAOD::detail::initAuxVar1<LINKED>
( auxcont );
107
}
108
109
110
}}
// namespace xAOD::detail
111
112
113
#define AUXVAR_DECL( TYPE, NAME, ... ) \
114
static constexpr const char NAME ## __name[] = #NAME; \
115
AuxVariable_t< TYPE AUXVAR_DECL_ALLOC_( TYPE, __VA_ARGS__ ) > NAME \
116
{ xAOD::detail::initAuxVar< NAME ## __name >( this, NAME CXXUTILS_PP_SECOND( __VA_ARGS__ ) ) }
117
#define AUXVAR_DECL_ALLOC_( TYPE, ... ) \
118
__VA_OPT__( CXXUTILS_PP_FIRST( __VA_ARGS__ )< TYPE > )
119
120
121
#define AUXVAR_PACKEDCONTAINER_DECL( TYPE, NAME ) \
122
static constexpr const char NAME ## __name[] = #NAME; \
123
SG::PackedContainer< TYPE > NAME { xAOD::detail::initAuxVar< NAME ## __name >( this, NAME ) }
124
125
126
#endif
// XAODCORE_TOOLS_AUXVARIABLE_H
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
SG::AuxTypeRegistry::linkedName
static std::string linkedName(const std::string &name)
Given a variable name, return the name of the corresponding linked variable.
Definition
AuxTypeRegistry.cxx:1303
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
SG::AuxVarFlags
AuxVarFlags
Additional flags to qualify an auxiliary variable.
Definition
AuxTypes.h:58
SG::None
@ None
No special flags set.
Definition
AuxTypes.h:60
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition
AuxTypes.h:27
detail
Definition
extract_histogram_tag.cxx:14
xAOD::detail::initLinkedVar
LINKED initLinkedVar(AUXBASE *auxcont, LINKS &links, LINKED &linked)
Definition
AuxVariable.h:97
xAOD::detail::initAuxVar2
VARTYPE initAuxVar2(AUXBASE *auxcont, std::true_type)
Definition
AuxVariable.h:59
xAOD::detail::initAuxVar
VARTYPE initAuxVar(AUXBASE *auxcont, VARTYPE &var, SG::AuxVarFlags flags=SG::AuxVarFlags::None)
Definition
AuxVariable.h:82
xAOD::detail::initAuxVar1
VARTYPE initAuxVar1(AUXBASE *auxcont)
Definition
AuxVariable.h:75
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition
ICaloAffectedTool.h:24
xAOD::acc
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
pputils.h
Preprocessor utilities.
Generated on
for ATLAS Offline Software by
1.17.0