ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthContainers
AthContainers
dataVectorAsELV.h
Go to the documentation of this file.
1
// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
3
/*
4
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// $Id$
14
15
16
#ifndef ATHCONTAINERS_DATAVECTORASELV_H
17
#define ATHCONTAINERS_DATAVECTORASELV_H
18
19
20
#include "
AthContainers/AuxVectorData.h
"
21
#include "
AthContainers/CurrentContext.h
"
22
#include "
AthContainers/OwnershipPolicy.h
"
23
#include "
AthContainers/exceptions.h
"
24
#include "
AthContainersInterfaces/AuxStore_traits.h
"
25
#include "AthLinks/ElementLink.h"
26
#include <vector>
27
28
29
namespace
SG
{
30
31
37
template
<
class
DV>
38
void
dataVectorViewAsELV
(
const
std::true_type&,
39
const
DV& v,
40
std::vector<
ElementLink<DV>
>& ret,
41
const
EventContext& ctx)
42
{
43
const
DV* last_d =
nullptr
;
44
const
SG::AuxVectorData
* last_b =
nullptr
;
45
for
(
const
typename
DV::base_value_type* elt : v) {
46
const
SG::AuxVectorData
* cont_b = elt->container();
47
if
(cont_b != last_b) {
48
last_b = cont_b;
49
last_d =
dynamic_cast<
const
DV*
>
(cont_b);
50
}
51
if
(!last_d)
52
throw
SG::ExcDVToELV
(
"Element not in a container"
);
53
ret.emplace_back (*last_d, elt->index(), ctx);
54
}
55
}
56
57
58
65
template
<
class
DV>
66
void
dataVectorViewAsELV
(
const
std::false_type&,
67
const
DV&,
68
std::vector<
ElementLink<DV>
>&,
69
const
EventContext&)
70
{
71
throw
SG::ExcDVToELV
(
"Element in view container does not derive from AuxElement."
);
72
}
73
74
75
85
template
<
class
DV>
86
std::vector<ElementLink<DV> >
87
dataVectorAsELV
(
const
DV& v,
const
EventContext& ctx = Gaudi::Hive::currentContext())
88
{
89
std::vector<ElementLink<DV> > ret;
90
size_t
sz
= v.size();
91
ret.reserve (
sz
);
92
93
if
(v.ownPolicy() ==
SG::OWN_ELEMENTS
) {
94
// Could hoist the sgkey lookup.
95
// But this will probably not be a common case, so don't do that
96
// unless it's needed.
97
for
(
size_t
i = 0; i <
sz
; i++)
98
ret.emplace_back (v, i, ctx);
99
}
100
else
{
101
dataVectorViewAsELV
(
typename
AuxStore_traits<DV>::flag
(), v, ret, ctx);
102
}
103
104
return
ret;
105
}
106
107
108
}
// namespace SG
109
110
111
#endif
// not ATHCONTAINERS_DATAVECTORASELV_H
CurrentContext.h
AuxStore_traits.h
Associate AuxStore classes with EDM container classes.
AuxVectorData.h
Manage lookup of vectors of auxiliary data.
exceptions.h
Exceptions that can be thrown from AthContainers.
sz
static Double_t sz
Definition
LArPhysWaveHECTool.cxx:37
OwnershipPolicy.h
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition
AuxVectorData.h:164
SG::ExcDVToELV
Exception — Can't convert DataVector to vector of ElementLinks.
Definition
Control/AthContainers/AthContainers/exceptions.h:268
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::dataVectorViewAsELV
void dataVectorViewAsELV(const std::true_type &, const DV &v, std::vector< ElementLink< DV > > &ret, const EventContext &ctx)
Helper for dataVectorViewAsELV.
Definition
dataVectorAsELV.h:38
SG::dataVectorAsELV
std::vector< ElementLink< DV > > dataVectorAsELV(const DV &v, const EventContext &ctx=Gaudi::Hive::currentContext())
Helper to make a vector<EL> from a DataVector.
Definition
dataVectorAsELV.h:87
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition
OwnershipPolicy.h:17
SG::AuxStore_traits
Associate AuxStore classes with EDM container classes (default implementation).
Definition
AuxStore_traits.h:138
Generated on
for ATLAS Offline Software by
1.17.0