ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
HitManagement
HitManagement
AtlasHitsVector.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
//
6
// Templated class for the Hit collections in athena
7
// There is a bunch of ifdef __CINT__ to make this class
8
// intelligible to AthenaRoot and work out a persistency mechanism
9
//
10
11
12
#ifndef AtlasHitsVector_H
13
#define AtlasHitsVector_H
14
//
15
//
16
// vector class
17
#include <vector>
18
#include "
HitManagement/AthenaHitsVector.h
"
19
#include "
AthContainers/tools/DVLInfo.h
"
20
21
//
22
// Gaudi includes, not provided to rootcint
23
#ifndef __CINT__
24
#include "GaudiKernel/ISvcLocator.h"
25
#include "
AthenaKernel/getMessageSvc.h
"
26
#include "GaudiKernel/MsgStream.h"
27
#include "GaudiKernel/IMessageSvc.h"
28
#endif
29
30
//
31
template
<
typename
T>
32
class
AtlasHitsVector
:
public
HitsVectorBase
{
33
public
:
34
//
35
// additional typedef
36
typedef
T
base_value_type
;
37
typedef
std::vector<T>
CONT
;
38
typedef
typename
CONT::value_type
value_type
;
39
typedef
typename
CONT::pointer
pointer
;
40
typedef
typename
CONT::const_pointer
const_pointer
;
41
typedef
typename
CONT::iterator
iterator
;
42
typedef
typename
CONT::const_iterator
const_iterator
;
43
typedef
typename
CONT::reference
reference
;
44
typedef
typename
CONT::const_reference
const_reference
;
45
typedef
typename
CONT::size_type
size_type
;
46
typedef
typename
CONT::difference_type
difference_type
;
47
//
48
// default constructor for rootcint
49
#ifdef __CINT__
50
AtlasHitsVector
( ) {}
51
//
52
// methods not provided to rootcint
53
#else
54
AtlasHitsVector
(
const
std::string& collectionName=
"DefaultCollectionName"
,
const
unsigned
int
mySize=100)
55
{
56
IMessageSvc* msgSvc(
Athena::getMessageSvc
());
57
MsgStream log(msgSvc,
"AtlasHitsVector"
);
58
log << MSG::DEBUG <<
" initialized AtlasHitVector "
<< collectionName <<
endmsg
;
59
60
m_name
= collectionName;
61
m_hitvector
.reserve(mySize);
62
}
63
64
~AtlasHitsVector
()
override
=
default
;
65
66
void
Clear
()
67
{
68
m_hitvector
.clear();
69
std::vector<T>().swap(
m_hitvector
);
70
}
71
72
void
Insert
(
const
T&
h
)
73
{
74
m_hitvector
.push_back(
h
);
75
}
76
void
Insert
(T&&
h
)
77
{
78
m_hitvector
.push_back( std::move(
h
) );
79
}
80
template
<
class
...
Args
>
void
Emplace
(
Args
&&... args)
81
{
82
m_hitvector
.emplace_back( std::forward<Args>(args)... );
83
}
84
int
Size
()
const
85
{
86
return
size
();
87
}
88
#endif
// __CINT__
89
90
explicit
AtlasHitsVector
(
const
AtlasHitsVector<T>
& rhs)
91
:
m_hitvector
(rhs.
m_hitvector
) {}
92
93
AtlasHitsVector
(
AtlasHitsVector<T>
&& rhs)
noexcept
=
default
;
94
95
// Conversion
96
explicit
AtlasHitsVector
(
const
AthenaHitsVector<T>
& rhs) {
97
m_hitvector
.reserve(rhs.
Size
());
98
typename
AthenaHitsVector<T>::const_iterator
i(rhs.
begin
()), e(rhs.
end
());
99
while
(i != e) {
m_hitvector
.push_back( T( (**i) ) ); ++i;}
100
}
101
102
AtlasHitsVector<T>
&
operator=
(
const
AtlasHitsVector<T>
& rhs) {
103
if
(
this
!= &rhs) {
104
m_hitvector
=rhs.
m_hitvector
;
105
}
106
return
*
this
;
107
}
108
109
AtlasHitsVector<T>
&
operator=
(
AtlasHitsVector<T>
&& rhs)
noexcept
=
default
;
110
112
// Assignment from the AthenaHitsVector form
113
AtlasHitsVector<T>
&
operator=
(
const
AthenaHitsVector<T>
& rhs) {
114
this->
Clear
();
115
m_hitvector
.reserve(rhs.
Size
());
116
typename
AthenaHitsVector<T>::const_iterator
i(rhs.
begin
()), e(rhs.
end
());
117
while
(i != e) {
m_hitvector
.push_back( T( (**i) ) ); ++i;}
118
return
*
this
;
119
}
120
121
const
std::string&
Name
()
const
{
return
m_name
;}
122
123
void
setName
(
const
std::string& name) {
m_name
= name;}
124
//
125
// vector methods.
126
const
std::vector<T>&
getVector
()
const
{
return
m_hitvector
;}
127
128
bool
empty
()
const
{
return
m_hitvector
.empty(); }
129
130
const_iterator
begin
()
const
131
{
return
m_hitvector
.begin(); }
132
133
const_iterator
end
()
const
134
{
return
m_hitvector
.end(); }
135
136
iterator
begin
()
137
{
return
m_hitvector
.begin(); }
138
139
iterator
end
()
140
{
return
m_hitvector
.end(); }
141
142
size_type
size
()
const
{
return
m_hitvector
.size(); }
143
144
void
push_back
(
const
T& t ) {
m_hitvector
.push_back(t);}
145
146
T
At
(
unsigned
int
pos)
const
{
147
return
m_hitvector
.at(pos);
148
}
149
150
const
T
operator[]
(
size_type
n)
const
{
return
m_hitvector
[n];}
151
152
void
clear
() {
153
m_hitvector
.clear();
154
std::vector<T>().swap(
m_hitvector
);
155
}
156
157
void
reserve
(
size_type
n) {
m_hitvector
.reserve (n); }
158
159
void
resize
(
size_type
n) {
m_hitvector
.resize (n); }
160
161
162
protected
:
163
std::string
m_name
;
164
std::vector<T>
m_hitvector
;
165
166
167
public
:
168
// Used to ensure that the DVLInfo gets registered
169
// when the dictionary for this class is loaded.
170
static
const
std::type_info*
initHelper
()
171
{
return
DataModel_detail::DVLInfo<AtlasHitsVector<T>
>
::initHelper
(); }
172
static
const
std::type_info*
const
s_info
;
173
};
174
183
template
<
class
T>
184
void
dvl_makecontainer
(
size_t
nreserve,
AtlasHitsVector<T>
*& cont)
185
{
186
cont =
new
AtlasHitsVector<T>
(
""
, nreserve);
187
}
188
189
190
// Ensure that the DVLInfo gets registered
191
// when the dictionary for this class is loaded.
192
template
<
class
T>
193
const
std::type_info*
const
AtlasHitsVector<T>::s_info
=
AtlasHitsVector<T>::initHelper
();
194
195
196
#endif
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
AthenaHitsVector.h
dvl_makecontainer
void dvl_makecontainer(size_t nreserve, AtlasHitsVector< T > *&cont)
Construct a new container.
Definition
AtlasHitsVector.h:184
DVLInfo.h
Holder to implement conversion copies for DataVector/DataList.
h
Header file for AthHistogramAlgorithm.
AthenaHitsVector
Definition
AthenaHitsVector.h:87
AthenaHitsVector::end
const_iterator end() const
Definition
AthenaHitsVector.h:191
AthenaHitsVector::begin
const_iterator begin() const
Definition
AthenaHitsVector.h:187
AthenaHitsVector::const_iterator
boost::transform_iterator< make_const, typename CONT::const_iterator > const_iterator
Definition
AthenaHitsVector.h:105
AthenaHitsVector::Size
int Size() const
Definition
AthenaHitsVector.h:144
AtlasHitsVector
Definition
AtlasHitsVector.h:32
AtlasHitsVector< AFP_SiDigi >::pointer
CONT::pointer pointer
Definition
AtlasHitsVector.h:39
AtlasHitsVector< AFP_SiDigi >::m_hitvector
std::vector< AFP_SiDigi > m_hitvector
Definition
AtlasHitsVector.h:164
AtlasHitsVector::AtlasHitsVector
AtlasHitsVector(const AthenaHitsVector< T > &rhs)
Definition
AtlasHitsVector.h:96
AtlasHitsVector< AFP_SiDigi >::const_pointer
CONT::const_pointer const_pointer
Definition
AtlasHitsVector.h:40
AtlasHitsVector< AFP_SiDigi >::CONT
std::vector< AFP_SiDigi > CONT
Definition
AtlasHitsVector.h:37
AtlasHitsVector::begin
iterator begin()
Definition
AtlasHitsVector.h:136
AtlasHitsVector::operator[]
const T operator[](size_type n) const
Definition
AtlasHitsVector.h:150
AtlasHitsVector< AFP_SiDigi >::m_name
std::string m_name
Definition
AtlasHitsVector.h:163
AtlasHitsVector::empty
bool empty() const
Definition
AtlasHitsVector.h:128
AtlasHitsVector::Size
int Size() const
Definition
AtlasHitsVector.h:84
AtlasHitsVector::Insert
void Insert(const T &h)
Definition
AtlasHitsVector.h:72
AtlasHitsVector::AtlasHitsVector
AtlasHitsVector(const std::string &collectionName="DefaultCollectionName", const unsigned int mySize=100)
Definition
AtlasHitsVector.h:54
AtlasHitsVector::AtlasHitsVector
AtlasHitsVector(AtlasHitsVector< T > &&rhs) noexcept=default
AtlasHitsVector< AFP_SiDigi >::value_type
CONT::value_type value_type
Definition
AtlasHitsVector.h:38
AtlasHitsVector::end
iterator end()
Definition
AtlasHitsVector.h:139
AtlasHitsVector::Clear
void Clear()
Definition
AtlasHitsVector.h:66
AtlasHitsVector< AFP_SiDigi >::const_iterator
CONT::const_iterator const_iterator
Definition
AtlasHitsVector.h:42
AtlasHitsVector::push_back
void push_back(const T &t)
Definition
AtlasHitsVector.h:144
AtlasHitsVector< AFP_SiDigi >::difference_type
CONT::difference_type difference_type
Definition
AtlasHitsVector.h:46
AtlasHitsVector::operator=
AtlasHitsVector< T > & operator=(const AthenaHitsVector< T > &rhs)
assignment deletes old elements and deep copies the new ones
Definition
AtlasHitsVector.h:113
AtlasHitsVector< AFP_SiDigi >::size_type
CONT::size_type size_type
Definition
AtlasHitsVector.h:45
AtlasHitsVector< AFP_SiDigi >::const_reference
CONT::const_reference const_reference
Definition
AtlasHitsVector.h:44
AtlasHitsVector::~AtlasHitsVector
~AtlasHitsVector() override=default
AtlasHitsVector::Insert
void Insert(T &&h)
Definition
AtlasHitsVector.h:76
AtlasHitsVector::setName
void setName(const std::string &name)
Definition
AtlasHitsVector.h:123
AtlasHitsVector::begin
const_iterator begin() const
Definition
AtlasHitsVector.h:130
AtlasHitsVector::operator=
AtlasHitsVector< T > & operator=(AtlasHitsVector< T > &&rhs) noexcept=default
AtlasHitsVector::AtlasHitsVector
AtlasHitsVector(const AtlasHitsVector< T > &rhs)
Definition
AtlasHitsVector.h:90
AtlasHitsVector< AFP_SiDigi >::reference
CONT::reference reference
Definition
AtlasHitsVector.h:43
AtlasHitsVector::resize
void resize(size_type n)
Definition
AtlasHitsVector.h:159
AtlasHitsVector< AFP_SiDigi >::s_info
static const std::type_info *const s_info
Definition
AtlasHitsVector.h:172
AtlasHitsVector::Emplace
void Emplace(Args &&... args)
Definition
AtlasHitsVector.h:80
AtlasHitsVector< AFP_SiDigi >::iterator
CONT::iterator iterator
Definition
AtlasHitsVector.h:41
AtlasHitsVector::reserve
void reserve(size_type n)
Definition
AtlasHitsVector.h:157
AtlasHitsVector::size
size_type size() const
Definition
AtlasHitsVector.h:142
AtlasHitsVector::clear
void clear()
Definition
AtlasHitsVector.h:152
AtlasHitsVector< AFP_SiDigi >::base_value_type
AFP_SiDigi base_value_type
Definition
AtlasHitsVector.h:36
AtlasHitsVector::end
const_iterator end() const
Definition
AtlasHitsVector.h:133
AtlasHitsVector::Name
const std::string & Name() const
Definition
AtlasHitsVector.h:121
AtlasHitsVector::operator=
AtlasHitsVector< T > & operator=(const AtlasHitsVector< T > &rhs)
Definition
AtlasHitsVector.h:102
AtlasHitsVector::getVector
const std::vector< T > & getVector() const
Definition
AtlasHitsVector.h:126
AtlasHitsVector::At
T At(unsigned int pos) const
Definition
AtlasHitsVector.h:146
AtlasHitsVector::initHelper
static const std::type_info * initHelper()
Definition
AtlasHitsVector.h:170
DataModel_detail::DVLInfo
Definition
DVLInfo.h:237
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition
getMessageSvc.cxx:20
Args
Definition
test_lwtnn_fastgraph.cxx:12
HitsVectorBase
Definition
AthenaHitsVector.h:33
Generated on
for ATLAS Offline Software by
1.17.0