ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
TRT_ConditionsData
TRT_ConditionsData
FloatArrayStore.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
#ifndef TRTCONDITIONSDATA_FLOATARRAYSTORE_H
6
#define TRTCONDITIONSDATA_FLOATARRAYSTORE_H
7
/********************************************************************
8
9
NAME: FloatArrayStore
10
PACKAGE: TRT_ConditionsData
11
12
AUTHORS: Jorgen Beck Hansen, Peter Hansen
13
CREATED: 1/8/05
14
15
PURPOSE: Access and manipulate an indexed storage
16
17
********************************************************************/
18
19
// INCLUDE HEADER FILES:
20
21
#include <vector>
22
#include <map>
23
#include <string>
24
#include <functional>
//for std::less
25
#include <iosfwd>
// fwd declaration for io classes
26
#include <cmath>
//std::abs
27
#include "Identifier/Identifier.h"
28
#include "
AthenaKernel/CLASS_DEF.h
"
29
34
class
FloatArrayStore
{
35
public
:
36
37
typedef
std::less<Identifier>
lessp
;
38
typedef
std::map<Identifier,int,lessp>
BufferMap
;
39
typedef
BufferMap::const_iterator
map_citr
;
40
typedef
std::vector< std::vector<float> >
Buffer
;
41
43
FloatArrayStore
();
44
FloatArrayStore
(
const
std::string&
tag
);
46
virtual
~FloatArrayStore
();
48
FloatArrayStore
&
operator=
(
FloatArrayStore
&& other);
49
51
const
std::string&
tag
()
const
;
53
int
numberOfIDs
()
const
;
55
const
std::vector<float>&
operator[]
(
const
Identifier
& ident)
const
;
57
bool
sharedID
(
const
Identifier
& ident)
const
;
59
bool
existID
(
const
Identifier
& ident)
const
;
61
void
dbg
()
const
;
63
map_citr
cbegin
()
const
;
64
map_citr
cend
()
const
;
65
67
std::vector<float>&
operator[]
(
const
Identifier
& ident);
69
void
share
(
const
Identifier
& ident,
const
Identifier
& referenceIdent);
71
void
push_back
(
const
Identifier
& ident,
const
std::vector<float>& value);
72
void
push_back
(
const
std::vector<Identifier>& identvec,
const
std::vector<float>& value);
74
void
removeID
(
const
Identifier
& ident);
76
void
clear
();
78
void
cleanUp
();
80
map_citr
begin
()
const
;
81
map_citr
end
()
const
;
83
const
Buffer
&
buffer
()
const
{
return
m_buf
; }
84
85
86
private
:
87
88
std::string
m_tag
;
89
BufferMap
m_bufmap
;
90
Buffer
m_buf
;
91
92
};
93
94
CLASS_DEF
(
FloatArrayStore
,170308771,1)
95
96
// inline methods
97
inline
FloatArrayStore
::
FloatArrayStore
() :
m_tag
(
"Undefined"
) { }
98
99
inline
FloatArrayStore::FloatArrayStore
(
const
std::string&
tag
) :
m_tag
(
tag
) { }
100
101
inline
FloatArrayStore
&
FloatArrayStore::operator=
(
FloatArrayStore
&& other){
102
if
(
this
!=&other){
103
m_tag
=std::move(other.m_tag);
104
m_bufmap
= other.m_bufmap;
//can't std::move a map, the keys are const
105
m_buf
=std::move(other.m_buf);
106
}
107
return
*
this
;
108
}
109
110
111
inline
FloatArrayStore::~FloatArrayStore
() {}
112
113
inline
void
FloatArrayStore::clear
() {
m_bufmap
.clear();
m_buf
.clear(); }
114
115
inline
void
FloatArrayStore::push_back
116
(
const
Identifier
& ident,
const
std::vector<float>& value){
117
m_buf
.push_back(value);
118
m_bufmap
[ident]=
m_buf
.size()-1;
119
}
120
121
inline
void
FloatArrayStore::push_back
(
const
std::vector<Identifier>& identvec,
const
std::vector<float>& value){
122
m_buf
.push_back(value);
123
size_t
index
=
m_buf
.size()-1;
124
for
(std::vector<Identifier>::const_iterator it = identvec.begin() ; it != identvec.end(); ++it)
125
m_bufmap
[*it] =
index
;
126
}
127
128
inline
int
FloatArrayStore::numberOfIDs
()
const
129
{
return
m_bufmap
.size(); }
130
131
inline
void
FloatArrayStore::removeID
(
const
Identifier
& ident)
132
{
m_bufmap
.erase(ident); }
133
134
inline
bool
FloatArrayStore::existID
(
const
Identifier
& ident)
const
135
{
return
m_bufmap
.find(ident)!=
m_bufmap
.end(); }
136
137
inline
bool
FloatArrayStore::sharedID
(
const
Identifier
& ident)
const
{
return
existID
(ident)?
m_bufmap
.find(ident)->second <0 :
false
; }
138
139
inline
const
std::vector<float>& FloatArrayStore::operator[]
140
(
const
Identifier
& ident)
const
141
{
return
m_buf
[std::abs(
m_bufmap
.find(ident)->second)]; }
142
143
inline
std::vector<float>&
FloatArrayStore::operator[]
(
const
Identifier
& ident)
144
{
return
m_buf
[std::abs(
m_bufmap
[ident])]; }
145
146
inline
void
FloatArrayStore::share
147
(
const
Identifier
& ident,
const
Identifier
& referenceIdent) {
148
if
(
existID
(referenceIdent)){
149
m_bufmap
[ident] = -std::abs(
m_bufmap
[referenceIdent]);
150
m_bufmap
[referenceIdent] = -std::abs(
m_bufmap
[referenceIdent]);
151
}
152
}
153
154
inline
const
std::string&
FloatArrayStore::tag
()
const
{
return
m_tag
;}
155
156
inline
FloatArrayStore::map_citr
157
FloatArrayStore::begin
()
const
{
return
m_bufmap
.begin(); }
158
159
inline
FloatArrayStore::map_citr
160
FloatArrayStore::end
()
const
{
return
m_bufmap
.end(); }
161
162
inline
FloatArrayStore::map_citr
163
FloatArrayStore::cbegin
()
const
{
return
m_bufmap
.begin(); }
164
165
inline
FloatArrayStore::map_citr
FloatArrayStore::cend
()
const
{
return
m_bufmap
.end(); }
166
167
std::ostream&
operator<<
(std::ostream& os,
const
FloatArrayStore
& store) ;
168
std::istream&
operator>>
(std::istream& is,
FloatArrayStore
& store) ;
169
170
#endif
CLASS_DEF.h
macros to associate a CLID to a type
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition
Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:67
operator<<
std::ostream & operator<<(std::ostream &os, const FloatArrayStore &store)
Definition
FloatArrayStore.cxx:40
operator>>
std::istream & operator>>(std::istream &is, FloatArrayStore &store)
Definition
FloatArrayStore.cxx:65
FloatArrayStore
class FloatArrayStore Access and manipulate an indexed storage of float vectors
Definition
FloatArrayStore.h:34
FloatArrayStore::sharedID
bool sharedID(const Identifier &ident) const
returns flag for index sharing data
Definition
FloatArrayStore.h:137
FloatArrayStore::buffer
const Buffer & buffer() const
return stored vector
Definition
FloatArrayStore.h:83
FloatArrayStore::cbegin
map_citr cbegin() const
begin/end const iterators
Definition
FloatArrayStore.h:163
FloatArrayStore::numberOfIDs
int numberOfIDs() const
Size accessor.
Definition
FloatArrayStore.h:128
FloatArrayStore::cleanUp
void cleanUp()
remove data with no index pointing to it
Definition
FloatArrayStore.cxx:10
FloatArrayStore::operator=
FloatArrayStore & operator=(FloatArrayStore &&other)
move assignment
Definition
FloatArrayStore.h:101
FloatArrayStore::Buffer
std::vector< std::vector< float > > Buffer
Definition
FloatArrayStore.h:40
FloatArrayStore::operator[]
const std::vector< float > & operator[](const Identifier &ident) const
Overload [] const access.
Definition
FloatArrayStore.h:140
FloatArrayStore::share
void share(const Identifier &ident, const Identifier &referenceIdent)
makes index ident share data with referenceIdent
Definition
FloatArrayStore.h:147
FloatArrayStore::map_citr
BufferMap::const_iterator map_citr
Definition
FloatArrayStore.h:39
FloatArrayStore::m_tag
std::string m_tag
The tag std::string.
Definition
FloatArrayStore.h:88
FloatArrayStore::clear
void clear()
remove all
Definition
FloatArrayStore.h:113
FloatArrayStore::m_bufmap
BufferMap m_bufmap
The std::map.
Definition
FloatArrayStore.h:89
FloatArrayStore::begin
map_citr begin() const
begin/end iterators
Definition
FloatArrayStore.h:157
FloatArrayStore::BufferMap
std::map< Identifier, int, lessp > BufferMap
Definition
FloatArrayStore.h:38
FloatArrayStore::FloatArrayStore
FloatArrayStore()
constructors, optionally with a tag
Definition
FloatArrayStore.h:97
FloatArrayStore::existID
bool existID(const Identifier &ident) const
returns flag for index existing in the std::map
Definition
FloatArrayStore.h:134
FloatArrayStore::push_back
void push_back(const Identifier &ident, const std::vector< float > &value)
makes new indices
Definition
FloatArrayStore.h:116
FloatArrayStore::end
map_citr end() const
Definition
FloatArrayStore.h:160
FloatArrayStore::removeID
void removeID(const Identifier &ident)
remove new index
Definition
FloatArrayStore.h:131
FloatArrayStore::~FloatArrayStore
virtual ~FloatArrayStore()
destructor
Definition
FloatArrayStore.h:111
FloatArrayStore::cend
map_citr cend() const
Definition
FloatArrayStore.h:165
FloatArrayStore::dbg
void dbg() const
print method
Definition
FloatArrayStore.cxx:35
FloatArrayStore::lessp
std::less< Identifier > lessp
Definition
FloatArrayStore.h:37
FloatArrayStore::tag
const std::string & tag() const
Tag accessor.
Definition
FloatArrayStore.h:154
FloatArrayStore::m_buf
Buffer m_buf
The std::vector<float> stored in each second element.
Definition
FloatArrayStore.h:90
Identifier
Definition
IdentifierFieldParser.cxx:14
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0