ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCabling
src
LArHVIdMappingReader.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration.
3
*/
10
11
12
#include "
LArCabling/LArHVIdMappingReader.h
"
13
#include "
LArIdentifier/LArElectrodeID.h
"
14
#include "
LArIdentifier/LArHVLineID.h
"
15
#include "
PathResolver/PathResolver.h
"
16
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
17
#include <sstream>
18
#include <fstream>
19
20
21
LArHVIdMappingReader::LArHVIdMappingReader
()
22
:
AthMessaging
(
"LArHVIdMappingReader"
)
23
{
24
}
25
26
27
StatusCode
LArHVIdMappingReader::read
(
const
AthenaAttributeList
* attrList,
28
const
LArHVLineID
& hvlineHelper,
29
const
LArElectrodeID
& electrodeHelper,
30
hvlineMap_t
& hvlineMap,
31
electrodeMap_t
& electrodeMap)
const
32
{
33
hvlineMap.clear();
34
electrodeMap.clear();
35
36
std::string content;
37
if
(attrList) {
38
content =
fromAttrList
(*attrList);
39
}
40
else
{
41
content =
fromFile
();
42
}
43
44
if
(content.empty()) {
45
return
StatusCode::FAILURE;
46
}
47
48
return
fillHV
(content,
49
hvlineHelper,
50
electrodeHelper,
51
hvlineMap,
52
electrodeMap);
53
}
54
55
56
std::string
57
LArHVIdMappingReader::fromAttrList
(
const
AthenaAttributeList
& attrList)
const
58
{
59
std::ostringstream attrStr1;
60
coral::AttributeList::const_iterator itr = attrList.begin();
61
itr->toOutputStream(attrStr1);
62
std::string::size_type pos = attrStr1.str().find(
':'
);
63
if
(pos == std::string::npos)
64
pos = 0;
65
else
66
pos++;
67
std::string Line = attrStr1.str().substr(pos);
68
ATH_MSG_DEBUG
(
" Line "
<< Line );
69
return
Line;
70
}
71
72
73
std::string
LArHVIdMappingReader::fromFile
()
const
74
{
75
ATH_MSG_WARNING
(
" Cannot find /LAR/IdentifierOfl/HVLineToElectrodeMap from database, Use ASCII file indeed !!!"
);
76
std::string tablename =
PathResolver::find_file
(
"HVLineToElectrode.data"
,
"DATAPATH"
);
77
if
(tablename.empty()) {
78
ATH_MSG_FATAL
(
"[fillHVMap] Could not locate HVLineToElectrode.data file as well"
);
79
return
""
;
80
}
81
else
{
82
ATH_MSG_DEBUG
(
"[fillHVMap] have located HVLineToElectrode.data OK !"
);
83
}
84
const
char
* tablefile = tablename.c_str() ;
85
std::ifstream myfile(tablefile);
86
// get pointer to associated buffer object
87
std::filebuf* pbuf = myfile.rdbuf();
88
int
size
= pbuf->pubseekoff (0,std::ios::end,std::ios::in);
89
pbuf->pubseekpos (0,std::ios::in);
90
// allocate memory to contain file data
91
std::string buffer;
92
buffer.resize (
size
,
' '
);
93
// get file data
94
pbuf->sgetn (buffer.data(),
size
);
95
myfile.close();
96
return
buffer;
97
}
98
99
100
StatusCode
101
LArHVIdMappingReader::fillHV
(
const
std::string& content,
102
const
LArHVLineID
& hvlineHelper,
103
const
LArElectrodeID
& electrodeHelper,
104
hvlineMap_t
& hvlineMap,
105
electrodeMap_t
& electrodeMap)
const
106
{
107
ATH_MSG_DEBUG
(
"[fillHVMap] entering fillHVMap()..."
);
108
109
hvlineMap.clear();
110
electrodeMap.clear();
111
112
std::istringstream infile;
113
infile.str (content);
114
115
int
dummy;
116
int
hvcannode;
117
int
hvline;
118
int
hvpartition;
119
int
hvcanline;
120
int
detect;
121
int
side;
122
int
mod;
123
int
hvphi;
124
int
hveta;
125
int
hvgap;
126
int
min
;
127
int
max
;
128
ATH_MSG_DEBUG
(
"start reading infile "
);
129
while
(infile
130
>> dummy
131
>> hvcannode
132
>> hvline
133
>> hvpartition
134
>> hvcanline
135
>> detect
136
>> side
137
>> mod
138
>> hvphi
139
>> hveta
140
>> hvgap
141
>>
min
142
>>
max
)
143
{
// Fill Maps
144
if
(
max
> 1000)
// Crude check against reading nonsense.
145
std::abort();
146
ATH_MSG_DEBUG
(
"[fillHVMap] listing HVLineToElectrode :("
147
<< dummy <<
") hvline=["
148
<< hvpartition <<
"."
149
<< hvcanline <<
"."
150
<< hvcannode <<
"."
151
<< hvline <<
"] electrode=["
152
<< detect <<
"."
153
<< side <<
"."
154
<< mod <<
"."
155
<< hvphi <<
"."
156
<< hveta <<
"."
157
<< hvgap <<
" min="
158
<<
min
<<
" max="
159
<<
max
<<
"]"
160
);
161
162
std::vector<HWIdentifier> electrodeIdvec;
163
HWIdentifier
hvlineId = hvlineHelper.
HVLineId
(hvpartition,hvcanline,hvcannode,hvline);
164
165
if
(
max
>
min
){
166
if
(
min
< 0)
min
= 0;
167
if
(
max
< 0)
max
= 0;
168
if
(
min
> 1000)
min
= 1000;
// Shouldn't happen.
169
for
(
int
ielec=
min
; ielec<
max
+1; ielec++){
170
ATH_MSG_VERBOSE
(
"[fillHVMap] defining electrodeId: [det="
171
<< detect <<
" side="
172
<< side <<
" mod="
173
<< mod <<
" phi="
174
<< hvphi <<
" eta="
175
<< hveta <<
" gap="
176
<< hvgap <<
" ielec="
177
<< ielec <<
"]"
);
178
HWIdentifier
electrodeId =
179
electrodeHelper.
ElectrodeId
(detect,side,mod,hvphi,hveta,hvgap,ielec);
180
electrodeIdvec.push_back(electrodeId);
181
182
// Check if electrode is already in map ?
183
hvlineMap.emplace (electrodeId, hvlineId);
184
}
185
}
186
else
{
187
HWIdentifier
electrodeId = electrodeHelper.
ElectrodeId
(detect,side,mod,hvphi,hveta,hvgap,
min
);
188
electrodeIdvec.push_back(electrodeId);
189
190
// Check if electrode is already in map ?
191
hvlineMap.emplace (electrodeId, hvlineId);
192
}
193
194
std::vector<HWIdentifier>& l = electrodeMap[hvlineId];
195
l.insert (l.end(), electrodeIdvec.begin(), electrodeIdvec.end());
196
}
197
198
ATH_MSG_DEBUG
(
" end reading infile "
);
199
ATH_MSG_DEBUG
(
"[fillHV] Mapping electrode-to-hvline : number of Ids= "
<<hvlineMap.size());
200
ATH_MSG_DEBUG
(
"[fillHV] Mapping hvline-to-electrode : number of Ids= "
<<electrodeMap.size());
201
ATH_MSG_DEBUG
(
"[fillHV] exiting fillHVMap ... OK"
);
202
return
StatusCode::SUCCESS;
203
}
204
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
AthenaAttributeList.h
LArElectrodeID.h
LArHVIdMappingReader.h
Helper to read HV ID mapping data from a file or conditions.
LArHVLineID.h
PathResolver.h
size
size_t size() const
Number of registered mappings.
min
#define min(a, b)
Definition
cfImp.cxx:40
max
#define max(a, b)
Definition
cfImp.cxx:41
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table.
Definition
PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:46
HWIdentifier
Definition
HWIdentifier.h:13
LArElectrodeID
Helper for the Liquid Argon Calorimeter cell at the electrode level.
Definition
LArElectrodeID.h:95
LArElectrodeID::ElectrodeId
HWIdentifier ElectrodeId(int det, int side, int mod, int phi, int eta, int gap, int elec) const
Create an Electrode identifier from fields.
Definition
LArElectrodeID.h:300
LArHVIdMappingReader::fillHV
StatusCode fillHV(const std::string &content, const LArHVLineID &hvlineHelper, const LArElectrodeID &electrodeHelper, hvlineMap_t &hvlineMap, electrodeMap_t &electrodeMap) const
Definition
LArHVIdMappingReader.cxx:101
LArHVIdMappingReader::LArHVIdMappingReader
LArHVIdMappingReader()
Definition
LArHVIdMappingReader.cxx:21
LArHVIdMappingReader::fromFile
std::string fromFile() const
Definition
LArHVIdMappingReader.cxx:73
LArHVIdMappingReader::hvlineMap_t
std::map< HWIdentifier, HWIdentifier > hvlineMap_t
Definition
LArHVIdMappingReader.h:35
LArHVIdMappingReader::read
StatusCode read(const AthenaAttributeList *attrList, const LArHVLineID &hvlineHelper, const LArElectrodeID &electrodeHelper, hvlineMap_t &hvlineMap, electrodeMap_t &electrodeMap) const
Definition
LArHVIdMappingReader.cxx:27
LArHVIdMappingReader::fromAttrList
std::string fromAttrList(const AthenaAttributeList &attrList) const
Definition
LArHVIdMappingReader.cxx:57
LArHVIdMappingReader::electrodeMap_t
std::map< HWIdentifier, std::vector< HWIdentifier > > electrodeMap_t
Definition
LArHVIdMappingReader.h:36
LArHVLineID
Helper for the Liquid Argon Calorimeter High-Voltage identifiers.
Definition
LArHVLineID.h:43
LArHVLineID::HVLineId
HWIdentifier HVLineId(int part, int canline, int cannode, int line) const
Create an HighVoltage line identifier from fields.
Definition
LArHVLineID.h:211
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Definition
PathResolver.cxx:220
Generated on
for ATLAS Offline Software by
1.17.0