ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
TRT_ConditionsData
src
FloatArrayStore.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TRT_ConditionsData/FloatArrayStore.h
"
6
#include "GaudiKernel/MsgStream.h"
7
#include "
AthenaKernel/getMessageSvc.h
"
8
#include <iostream>
9
10
void
FloatArrayStore::cleanUp
(){
11
std::multimap<int,Identifier> indexmap;
12
13
map_citr
itr=
m_bufmap
.begin();
14
for
(;itr!=
m_bufmap
.end();++itr)
15
indexmap.insert(std::pair<int,Identifier>(std::abs(itr->second),itr->first));
16
std::vector< std::vector<float> > tmp(
m_buf
);
17
dbg
();
18
this->
clear
();
19
int
i(-tmp.size());
20
for
(;i<(int)tmp.size();i++){
21
bool
first(
true
);
22
Identifier
shared_id;
23
std::multimap<int,Identifier>::iterator pos;
24
for
( pos=indexmap.lower_bound(i); pos!=indexmap.upper_bound(i); ++pos){
25
if
(first){
26
first=
false
;
27
shared_id=pos->second;
28
this->
push_back
(shared_id,tmp[std::abs(i)]);
29
}
else
30
this->
share
(pos->second,shared_id);
31
}
32
}
33
}
34
35
void
FloatArrayStore::dbg
()
const
{
36
std::cout <<
"dbg:"
<<
m_bufmap
.size() <<
" "
<<
m_buf
.size() << std::endl;
37
}
38
39
40
std::ostream&
operator<<
(std::ostream& os,
const
FloatArrayStore
& store){
41
os << store.tag() << std::endl ;
42
// it is a bit of a heck, but the FloatArrayStore doesn't allow for more.
43
// first make an inverse map
44
std::map<int, std::vector<Identifier> > indextoidentmap ;
45
for
(
auto
it : store)
46
indextoidentmap[it.second].push_back(it.first) ;
47
// store the number of lines
48
os << indextoidentmap.size() << std::endl ;
49
// now store all elements, as follows
50
// each line is: #idents ident1 ident2 ...indentN vectorsize element1 element2 ... elementN
51
for
( std::map<
int
, std::vector<Identifier> >
::const_iterator
it = indextoidentmap.begin() ;
52
it != indextoidentmap.end(); ++it) {
53
os << it->second.size() <<
" "
;
54
for
(
auto
vit : it->second)
55
os << vit <<
" "
;
56
const
std::vector<float>& data = store[it->second.front()] ;
57
os << data.size() <<
" "
;
58
for
(
float
vit : data)
59
os << vit <<
" "
;
60
os << std::endl ;
61
}
62
return
os ;
63
}
64
65
std::istream&
operator>>
(std::istream& is,
FloatArrayStore
& store){
66
store.clear() ;
67
std::string tag ;
68
is >> tag ;
69
store =
FloatArrayStore
(tag) ;
70
std::vector<int> identifiers(0) ;
71
std::vector<float> data(0) ;
72
constexpr
int
maxLines=2000000;
//max 2 million lines
73
constexpr
int
maxSize=2000000;
//max size 2 million
74
int
nlines ;
75
is >> nlines ;
76
if
((nlines>=0) and (nlines<maxLines)) {
77
for
(
int
iline = 0; iline <nlines; ++iline) {
78
int
size
;
79
is >>
size
;
80
if
((
size
>=0) and (
size
<maxSize)){
81
identifiers.resize(
size
) ;
82
for
(
int
i=0; i<size; ++i) is >> (identifiers[i]) ;
83
}
84
else
{
85
MsgStream log(
Athena::getMessageSvc
(),
"FloatArrayStore"
);
86
log << MSG::ERROR <<
"size of identifier is incorrect"
<<
endmsg
;
87
return
is;
88
}
89
is >>
size
;
90
if
((
size
>=0) and (
size
<maxSize)){
91
data.resize(
size
) ;
92
for
(
int
i=0; i<size; ++i) is >> (data[i]) ;
93
}
94
else
{
95
MsgStream log(
Athena::getMessageSvc
(),
"FloatArrayStore"
);
96
log << MSG::ERROR <<
"size of data is incorrect"
<<
endmsg
;
97
return
is;
98
}
99
Identifier
reference
(identifiers.front()) ;
100
store.push_back(
reference
, data ) ;
101
std::vector<int>::const_iterator it = identifiers.begin() ;
102
for
( ++it; it!= identifiers.end(); ++it) store.share(
Identifier
(*it),
reference
) ;
103
}
104
}
105
return
is ;
106
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
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.h
size
size_t size() const
Number of registered mappings.
const_iterator
FloatArrayStore
class FloatArrayStore Access and manipulate an indexed storage of float vectors
Definition
FloatArrayStore.h:34
FloatArrayStore::cleanUp
void cleanUp()
remove data with no index pointing to it
Definition
FloatArrayStore.cxx:10
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::clear
void clear()
remove all
Definition
FloatArrayStore.h:113
FloatArrayStore::m_bufmap
BufferMap m_bufmap
The std::map.
Definition
FloatArrayStore.h:89
FloatArrayStore::push_back
void push_back(const Identifier &ident, const std::vector< float > &value)
makes new indices
Definition
FloatArrayStore.h:116
FloatArrayStore::dbg
void dbg() const
print method
Definition
FloatArrayStore.cxx:35
FloatArrayStore::m_buf
Buffer m_buf
The std::vector<float> stored in each second element.
Definition
FloatArrayStore.h:90
reference
Definition
hcg.cxx:440
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition
getMessageSvc.cxx:20
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0