19 #include "MLogManip.h" 35 int crate()
const {
return cbpx/1000; }
36 int board()
const {
return (cbpx/100)%10; }
37 int patch()
const {
return (cbpx/10)%10; }
38 int pixel()
const {
return cbpx%10; }
42 int hv()
const {
return hv_channel+hv_board*32; }
44 operator bool()
const {
return index>=0; }
49 class PixelMap :
public std::vector<PixelMapEntry>
56 bool Read(
const std::string &fname)
58 std::ifstream fin(fname);
63 while (getline(fin, buf,
'\n'))
68 buf.erase(buf.find_last_not_of(
' ')+1);
69 buf.erase(0, buf.find_first_not_of(
' '));
71 if (buf.empty() || buf[0]==
'#')
74 std::stringstream
str(buf);
96 cerr <<
"Invalid board/channel read from FACTmapV5.txt." << endl;
101 (*this)[l++] = entry;
109 for (std::vector<PixelMapEntry>::const_iterator it=
begin(); it!=
end(); it++)
113 std::cerr <<
"PixelMap: index " << idx <<
" not found" << std::endl;
120 for (std::vector<PixelMapEntry>::const_iterator it=
begin(); it!=
end(); it++)
124 std::cerr <<
"PixelMap: cbpx " << c <<
" not found" << std::endl;
131 return cbpx(px + p*10 + b*100 + c*1000);
136 return cbpx(idx/360, (idx/36)%10, (idx/9)%4, idx%9);
141 for (std::vector<PixelMapEntry>::const_iterator it=
begin(); it!=
end(); it++)
142 if (it->hv_board==board && it->hv_channel==channel)
145 std::cerr <<
"PixelMap: hv " << board <<
"/" << channel <<
" not found" << std::endl;
152 return hv(idx/32, idx%32);
209 int hv()
const {
return hv_channel+hv_board*32; }
211 operator bool()
const {
return hv_board>=0; }
216 class BiasMap :
public std::vector<BiasMapEntry>
224 void Retrieve(
const std::string &database);
226 bool Read(
const std::string &fname)
228 std::ifstream fin(fname);
233 while (getline(fin, buf,
'\n'))
238 buf.erase(buf.find_last_not_of(
' ')+1);
239 buf.erase(0, buf.find_first_not_of(
' '));
241 if (buf.empty() || buf[0]==
'#')
244 std::stringstream
str(buf);
256 throw std::runtime_error(
"Invalid board/channel read from "+fname+
".");
261 gLog << err <<
"Invalid board/channel read from " << fname <<
"." << std::endl;
266 (*this)[entry.
hv()] = entry;
273 throw std::runtime_error(
"Number of lines ("+std::to_string(static_cast<long long>(l))+
") read from "+fname+
" does not match 416.");
276 throw std::runtime_error(
"Number of entries read from "+fname+
" does not match 416.");
282 gLog << err <<
"Number of lines read from " << fname <<
" does not match 416." << std::endl;
288 gLog <<
"Number of entries read from " << fname <<
" does not match 416." << std::endl;
298 for (std::vector<BiasMapEntry>::const_iterator it=
begin(); it!=
end(); it++)
299 if (it->hv_board==board && it->hv_channel==channel)
302 std::cerr <<
"PixelMap: hv " << board <<
"/" << channel <<
" not found" << std::endl;
309 return hv(idx/32, idx%32);
331 std::vector<float> volt(416);
333 for (std::vector<BiasMapEntry>::const_iterator it=
begin(); it!=
end(); it++)
335 const int ch = it->hv_board*32 + it->hv_channel;
343 std::vector<float> volt(416);
345 for (std::vector<BiasMapEntry>::const_iterator it=
begin(); it!=
end(); it++)
347 const int ch = it->hv_board*32 + it->hv_channel;
356 std::vector<float> slope(416);
358 for (std::vector<BiasMapEntry>::const_iterator it=
begin(); it!=
end(); it++)
360 const int ch = it->hv_board*32 + it->hv_channel;
361 slope[ch] = it->Vslope;
std::vector< float > Vslope() const
const PixelMapEntry & hw(int idx) const
int crate() const
Bias supply channel.
float Vnom
Bias supply channel.
const PixelMapEntry & hv(int idx) const
const PixelMapEntry & cbpx(int c) const
int gapd
Hardware index as CBPX.
static const BiasMapEntry & empty()
const PixelMapEntry & index(int idx) const
int hv_channel
Bias suppply board.
float Vslope
Channel bias voltage offset [V].
const PixelMapEntry & cbpx(int c, int b, int p, int px) const
const BiasMapEntry & hv(int board, int channel) const
std::vector< float > Voffset() const
std::vector< float > Vgapd() const
BiasMapEntry()
Channel bias voltage slope [Ohm].
const BiasMapEntry & hv(const PixelMapEntry &p) const
float Voff
Channel bias voltage nominal.
bool Read(const std::string &fname)
int hv_channel
Bias suppply board.
static const PixelMapEntry & empty()
bool Read(const std::string &fname)
const BiasMapEntry & hv(int idx) const
const PixelMapEntry & hv(int board, int channel) const