ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Columnar
ColumnarCore
ColumnarCore
ObjectId.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
8
#ifndef COLUMNAR_CORE_OBJECT_ID_H
9
#define COLUMNAR_CORE_OBJECT_ID_H
10
11
#include <
ColumnarCore/ContainerId.h
>
12
#include <
CxxUtils/checker_macros.h
>
13
#include <iostream>
14
#include <stdexcept>
15
16
namespace
columnar
17
{
19
template
<ContainerIdConcept CI,
typename
CM>
class
ObjectId
;
20
21
22
23
24
25
template
<ContainerIdConcept CI>
class
ObjectId
<
CI
,
ColumnarModeXAOD
> final
26
{
29
public
:
30
31
using
xAODObject
=
typename
CI::xAODObjectIdType;
32
33
ObjectId
(
xAODObject
& val_object) noexcept
34
:
m_object
(&val_object)
35
{}
36
37
ObjectId
(
const
ObjectId<CI,ColumnarModeXAOD>
& that)
noexcept
=
default
;
38
39
template
<ContainerIdConcept CI2>
requires
(CI2::isMutable && std::is_same_v<typename CI2::constId,CI>)
40
ObjectId
(
const
ObjectId<CI2,ColumnarModeXAOD>
& that) noexcept
41
:
m_object
(&that.getXAODObjectNoexcept())
42
{}
43
44
ObjectId
&
operator =
(
const
ObjectId<CI,ColumnarModeXAOD>
& that)
noexcept
=
default
;
45
46
[[nodiscard]]
xAODObject
&
getXAODObject
()
const
noexcept {
47
// This object should ever be held within the context of a
48
// single thread (and generally on the stack), so the associated
49
// check is meaningless.
50
auto
*result
ATLAS_THREAD_SAFE
=
m_object
;
51
return
*result;}
52
53
// a version of `getXAODObject` that only exists when it is `noexcept`
54
[[nodiscard]]
xAODObject
&
getXAODObjectNoexcept
()
const
noexcept {
55
// This object should ever be held within the context of a
56
// single thread (and generally on the stack), so the associated
57
// check is meaningless.
58
auto
*result
ATLAS_THREAD_SAFE
=
m_object
;
59
return
*result;}
60
61
template
<
typename
Acc,
typename
...
Args
>
62
requires
std::invocable<Acc,ObjectId<CI,ColumnarModeXAOD>,
Args
...>
63
[[nodiscard]]
decltype
(
auto
)
operator
() (Acc& acc,
Args
&&... args)
const
{
64
return
acc (*
this
, std::forward<Args> (args)...);}
65
66
67
70
private
:
71
72
xAODObject
*
m_object
=
nullptr
;
73
};
74
75
template
<ContainerIdConcept CI>
76
std::ostream&
operator<<
(std::ostream&
str
,
const
ObjectId<CI,ColumnarModeXAOD>
& obj)
77
{
78
return
str
<< &obj.getXAODObjectNoexcept() <<
"/"
<< obj.getXAODObjectNoexcept().index();
79
}
80
81
template
<ContainerIdConcept CI>
82
bool
operator==
(
const
ObjectId<CI,ColumnarModeXAOD>
& lhs,
const
ObjectId<CI,ColumnarModeXAOD>
& rhs)
83
{
84
return
&lhs.getXAODObjectNoexcept() == &rhs.getXAODObjectNoexcept();
85
}
86
87
template
<ContainerIdConcept CI>
88
bool
operator!=
(
const
ObjectId<CI,ColumnarModeXAOD>
& lhs,
const
ObjectId<CI,ColumnarModeXAOD>
& rhs)
89
{
90
return
&lhs.getXAODObjectNoexcept() != &rhs.getXAODObjectNoexcept();
91
}
92
93
94
95
96
template
<ContainerIdConcept CI, ColumnarArrayMode CM>
97
class
ObjectId
<
CI
,CM> final
98
{
101
public
:
102
103
using
xAODObject
=
typename
CI::xAODObjectIdType;
104
105
// Whatever you do: Do not remove this function. Yes, it will always
106
// throw. It is meant to throw in this template specialization, and
107
// only do something useful in the xAOD mode specialization. If you
108
// remove it you break the columnar mode.
109
ObjectId
(
xAODObject
&
/*val_object*/
)
110
{
111
throw
std::logic_error (
"can't call xAOD function in columnar mode"
);
112
}
113
114
ObjectId
(
const
ObjectId<CI,CM>
& that)
noexcept
=
default
;
115
116
template
<ContainerIdConcept CI2>
requires
(CI2::isMutable && std::is_same_v<typename CI2::constId,CI>)
117
ObjectId
(
const
ObjectId<CI2,CM>
& that) noexcept
118
:
m_dataArea
(that.getDataArea()),
m_index
(that.getIndex())
119
{}
120
121
ObjectId
&
operator =
(
const
ObjectId<CI,CM>
& that)
noexcept
=
default
;
122
123
// Whatever you do: Do not remove this function. Yes, it will always
124
// throw. It is meant to throw in this template specialization, and
125
// only do something useful in the xAOD mode specialization. If you
126
// remove it you break the columnar mode.
127
[[nodiscard]]
xAODObject
&
getXAODObject
()
const
{
128
throw
std::logic_error (
"can't call xAOD function in columnar mode"
);}
129
130
template
<
typename
Acc,
typename
...
Args
>
131
requires
std::invocable<Acc,ObjectId<CI,CM>,
Args
...>
132
[[nodiscard]]
decltype
(
auto
)
operator
() (Acc& acc,
Args
&&... args)
const
{
133
return
acc (*
this
, std::forward<Args> (args)...);}
134
135
136
139
public
:
140
141
explicit
ObjectId
(
void
**val_dataArea, std::size_t val_index) noexcept
142
:
m_dataArea
(val_dataArea),
m_index
(val_index)
143
{}
144
145
[[nodiscard]] std::size_t
getIndex
()
const
noexcept {
146
return
m_index
;}
147
148
[[nodiscard]]
void
**
getDataArea
()
const
noexcept {
149
return
m_dataArea
;}
150
151
152
155
private
:
156
157
void
**
m_dataArea
=
nullptr
;
158
std::size_t
m_index
= 0u;
159
};
160
161
template
<ContainerIdConcept CI, ColumnarArrayMode CM>
162
std::ostream&
operator<<
(std::ostream&
str
,
const
ObjectId<CI,CM>
& obj)
163
{
164
return
str
<< CI::idName <<
"/"
<< obj.getIndex();
165
}
166
167
template
<ContainerIdConcept CI, ColumnarArrayMode CM>
168
bool
operator==
(
const
ObjectId<CI,CM>
& lhs,
const
ObjectId<CI,CM>
& rhs)
169
{
170
return
lhs.getIndex() == rhs.getIndex();
171
}
172
173
template
<ContainerIdConcept CI, ColumnarArrayMode CM>
174
bool
operator!=
(
const
ObjectId<CI,CM>
& lhs,
const
ObjectId<CI,CM>
& rhs)
175
{
176
return
lhs.getIndex() != rhs.getIndex();
177
}
178
}
179
180
#endif
operator=
ElementLink & operator=(const ElementLink &)=default
ContainerId.h
checker_macros.h
Define macros for attributes used to control the static checker.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
columnar::ObjectId< CI, CM >::getDataArea
void ** getDataArea() const noexcept
Definition
ObjectId.h:148
columnar::ObjectId< CI, CM >::m_dataArea
void ** m_dataArea
Definition
ObjectId.h:157
columnar::ObjectId< CI, CM >::ObjectId
ObjectId(const ObjectId< CI, CM > &that) noexcept=default
columnar::ObjectId< CI, CM >::ObjectId
ObjectId(void **val_dataArea, std::size_t val_index) noexcept
Definition
ObjectId.h:141
columnar::ObjectId< CI, CM >::m_index
std::size_t m_index
Definition
ObjectId.h:158
columnar::ObjectId< CI, CM >::getXAODObject
xAODObject & getXAODObject() const
Definition
ObjectId.h:127
columnar::ObjectId< CI, CM >::getIndex
std::size_t getIndex() const noexcept
Definition
ObjectId.h:145
columnar::ObjectId< CI, CM >::ObjectId
ObjectId(xAODObject &)
Definition
ObjectId.h:109
columnar::ObjectId< CI, CM >::xAODObject
typename CI::xAODObjectIdType xAODObject
Definition
ObjectId.h:103
columnar::ObjectId< CI, ColumnarModeXAOD >::ObjectId
ObjectId(xAODObject &val_object) noexcept
Definition
ObjectId.h:33
columnar::ObjectId< CI, ColumnarModeXAOD >::ObjectId
ObjectId(const ObjectId< CI, ColumnarModeXAOD > &that) noexcept=default
columnar::ObjectId< CI, ColumnarModeXAOD >::xAODObject
typename CI::xAODObjectIdType xAODObject
Definition
ObjectId.h:31
columnar::ObjectId< CI, ColumnarModeXAOD >::m_object
xAODObject * m_object
Definition
ObjectId.h:72
columnar::ObjectId< CI, ColumnarModeXAOD >::getXAODObjectNoexcept
xAODObject & getXAODObjectNoexcept() const noexcept
Definition
ObjectId.h:54
columnar::ObjectId< CI, ColumnarModeXAOD >::getXAODObject
xAODObject & getXAODObject() const noexcept
Definition
ObjectId.h:46
columnar::ObjectId
a class representing a single object (electron, muons, etc.)
Definition
ContainerId.h:205
const
columnar
Definition
ClusterDef.h:16
columnar::operator==
bool operator==(const ObjectId< CI, ColumnarModeXAOD > &lhs, const ObjectId< CI, ColumnarModeXAOD > &rhs)
Definition
ObjectId.h:82
columnar::operator!=
bool operator!=(const ObjectId< CI, ColumnarModeXAOD > &lhs, const ObjectId< CI, ColumnarModeXAOD > &rhs)
Definition
ObjectId.h:88
columnar::operator<<
std::ostream & operator<<(std::ostream &str, const ObjectId< CI, ColumnarModeXAOD > &obj)
Definition
ObjectId.h:76
str
Definition
BTagTrackIpAccessor.cxx:11
Args
Definition
test_lwtnn_fastgraph.cxx:12
columnar::ColumnarModeXAOD
Definition
ColumnarCore/ColumnarCore/ColumnarDef.h:18
CI
std::map< std::string, HypoJetVector >::const_iterator CI
Definition
xAODJetCollector.h:18
Generated on
for ATLAS Offline Software by
1.17.0