ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
Global
GlobalSimulation
GlobalSimulation
Object.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef GLOBALSIM_OBJECT_H
6
#define GLOBALSIM_OBJECT_H
7
8
#include "
AthContainers/AuxElement.h
"
9
#include "
xAODCore/tools/PrintHelpers.h
"
10
11
#include "
BitSpec.h
"
// for NoBase
12
13
namespace
GlobalSim
{
14
15
// Object template class exists so that can have "whole object" methods like bits(), which need to know about
16
// the "Spec" as a whole. If tried to put these into the ObjectAcc subclass, that subclass doesn't know about
17
// the Spec it lives in, so in the DECLARE_FIELDS macro we would also have to pass the SpecName
18
// in order to define (in the macro) the bits() method that uses SpecName::packFields etc
19
20
template
<
typename
Spec>
class
Object
;
// forward declare primary template
21
22
// Terminal case: nothing more to compose. Also conveniently can create and own an AuxElement in one place
23
template
<>
24
class
Object
<
NoBase
> {
25
public
:
26
explicit
Object
(
const
SG::AuxElement
& obj) :
m_ref
(obj) {}
27
28
Object
() :
m_owned
(
std
::make_shared<
SG
::AuxElement>()),
m_ref
(*
m_owned
) {
29
m_owned
->makePrivateStore();
30
}
31
protected
:
32
const
SG::AuxElement
&
auxRef
()
const
{
return
m_ref
; }
33
private
:
34
std::shared_ptr<SG::AuxElement>
m_owned
;
// null when wrapping external object;
35
const
SG::AuxElement
&
m_ref
;
36
};
37
38
template
<
typename
Spec>
39
class
Object
:
public
Object
<typename Spec::BaseSpec>,
public
Spec::ObjectAcc {
40
public
:
41
using
BaseObject
=
Object<typename Spec::BaseSpec>
;
42
43
static
constexpr
Spec
spec
{};
// allows access to the BitSpec with obj.spec. syntax
44
45
46
explicit
Object
(
const
SG::AuxElement
&obj) :
BaseObject
(obj), Spec::ObjectAcc(obj) {
47
48
}
49
50
// convenience constructor that will create and use a private AuxElement
51
explicit
Object
() :
BaseObject
(), Spec::ObjectAcc(
BaseObject
::auxRef()) { }
52
53
// ------------------------------------------------------------------------
54
// Complete packed representation.
55
// ------------------------------------------------------------------------
56
57
Spec::bitset_type
bits
()
const
{
58
return
Spec::packFields(Spec::allFields(), Spec::ObjectAcc::m_obj);
59
}
60
61
void
operator=
(
const
Spec::bitset_type &
bits
) {
62
std::apply([&](
const
auto
*... field) {
63
(field->decodeAndAssignFrom(
bits
,
const_cast<
SG::AuxElement
&
>
(Spec::ObjectAcc::m_obj)), ...);
64
},
65
Spec::allFields());
66
}
67
68
public
:
69
const
SG::AuxElement
*
objectPtr
()
const
{
70
return
&this->Spec::ObjectAcc::m_obj;
71
}
72
73
void
dump
()
const
{
74
xAOD::dump
(*
objectPtr
());
75
}
76
77
78
};
79
80
}
81
82
#endif
AuxElement.h
Base class for elements of a container that can have aux data.
BitSpec.h
PrintHelpers.h
GlobalSim::Object< NoBase >::auxRef
const SG::AuxElement & auxRef() const
Definition
Object.h:32
GlobalSim::Object< NoBase >::m_ref
const SG::AuxElement & m_ref
Definition
Object.h:35
GlobalSim::Object< NoBase >::Object
Object()
Definition
Object.h:28
GlobalSim::Object< NoBase >::Object
Object(const SG::AuxElement &obj)
Definition
Object.h:26
GlobalSim::Object< NoBase >::m_owned
std::shared_ptr< SG::AuxElement > m_owned
Definition
Object.h:34
GlobalSim::Object
Definition
Object.h:39
GlobalSim::Object::Object
Object()
Definition
Object.h:51
GlobalSim::Object::objectPtr
const SG::AuxElement * objectPtr() const
Definition
Object.h:69
GlobalSim::Object::dump
void dump() const
Definition
Object.h:73
GlobalSim::Object::BaseObject
Object< typename Spec::BaseSpec > BaseObject
Definition
Object.h:41
GlobalSim::Object< typename Spec::BaseSpec >::spec
static constexpr Spec spec
Definition
Object.h:43
GlobalSim::Object::Object
Object(const SG::AuxElement &obj)
Definition
Object.h:46
GlobalSim::Object::operator=
void operator=(const Spec::bitset_type &bits)
Definition
Object.h:61
GlobalSim::Object::bits
Spec::bitset_type bits() const
Definition
Object.h:57
GlobalSim
AlgTool to read in LArStripNeighborhoods, and run the BDT Algorithm.
Definition
BitSpec.h:24
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::AuxElement
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
std
STL namespace.
xAOD::dump
void dump(const SG::AuxElement &obj)
Helper function for dumping xAOD objects on the screen in PyROOT.
Definition
PrintHelpers.cxx:182
GlobalSim::NoBase
Definition
BitSpec.h:616
Generated on
for ATLAS Offline Software by
1.17.0