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-2020 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/OwnershipPolicy.h
"
22
#include "
AthContainers/exceptions.h
"
23
#include "
AthContainers/tools/CurrentEventStore.h
"
24
#include "
AthContainersInterfaces/AuxStore_traits.h
"
25
#include "AthLinks/ElementLink.h"
26
#include <vector>
27
28
29
namespace
SG
{
30
31
32
#ifdef XAOD_STANDALONE
33
using
AthContainers::IProxyDict;
34
#endif
// XAOD_STANDALONE
35
36
42
template
<
class
DV>
43
void
dataVectorViewAsELV
(
const
std::true_type&,
44
const
DV& v,
45
std::vector<
ElementLink<DV>
>& ret,
46
IProxyDict
* store)
47
{
48
const
DV* last_d =
nullptr
;
49
const
SG::AuxVectorData
* last_b =
nullptr
;
50
for
(
const
typename
DV::base_value_type* elt : v) {
51
const
SG::AuxVectorData
* cont_b = elt->container();
52
if
(cont_b != last_b) {
53
last_b = cont_b;
54
last_d =
dynamic_cast<
const
DV*
>
(cont_b);
55
}
56
if
(!last_d)
57
throw
SG::ExcDVToELV
(
"Element not in a container"
);
58
ret.emplace_back (*last_d, elt->index(), store);
59
}
60
}
61
62
63
70
template
<
class
DV>
71
void
dataVectorViewAsELV
(
const
std::false_type&,
72
const
DV&,
73
std::vector<
ElementLink<DV>
>&,
74
IProxyDict
*)
75
{
76
throw
SG::ExcDVToELV
(
"Element in view container does not derive from AuxElement."
);
77
}
78
79
80
90
template
<
class
DV>
91
std::vector<ElementLink<DV> >
92
dataVectorAsELV
(
const
DV& v,
IProxyDict
* store = 0)
93
{
94
std::vector<ElementLink<DV> > ret;
95
size_t
sz
= v.size();
96
ret.reserve (
sz
);
97
98
if
(!store) store = SG::CurrentEventStore::store();
99
100
if
(v.ownPolicy() ==
SG::OWN_ELEMENTS
) {
101
// Could hoist the sgkey lookup.
102
// But this will probably not be a common case, so don't do that
103
// unless it's needed.
104
for
(
size_t
i = 0; i <
sz
; i++)
105
ret.emplace_back (v, i, store);
106
}
107
else
{
108
dataVectorViewAsELV
(
typename
AuxStore_traits<DV>::flag
(), v, ret, store);
109
}
110
111
return
ret;
112
}
113
114
115
}
// namespace SG
116
117
118
#endif
// not ATHCONTAINERS_DATAVECTORASELV_H
CurrentEventStore.h
Wrapper for CurrentEventStore, to do the correct thing for both Athena and standalone builds.
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
IProxyDict
A proxy dictionary.
Definition
AthenaKernel/AthenaKernel/IProxyDict.h:47
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, IProxyDict *store)
Helper for dataVectorViewAsELV.
Definition
dataVectorAsELV.h:43
SG::dataVectorAsELV
std::vector< ElementLink< DV > > dataVectorAsELV(const DV &v, IProxyDict *store=0)
Helper to make a vector<EL> from a DataVector.
Definition
dataVectorAsELV.h:92
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