FACT++  1.0
bool BiasMap::Read ( const std::string &  fname)
inline

Definition at line 226 of file PixelMap.h.

References gLog, BiasMapEntry::hv(), BiasMapEntry::hv_board, BiasMapEntry::hv_channel, size, str, BiasMapEntry::Vnom, BiasMapEntry::Voff, and BiasMapEntry::Vslope.

Referenced by StateMachineBias< T, S >::EvalOptions(), and StateMachineBias< T, S >::ExpertLoadMapFile().

227  {
228  std::ifstream fin(fname);
229 
230  int l = 0;
231 
232  std::string buf;
233  while (getline(fin, buf, '\n'))
234  {
235  if (l>416)
236  break;
237 
238  buf.erase(buf.find_last_not_of(' ')+1); //surfixing spaces
239  buf.erase(0, buf.find_first_not_of(' ')); //prefixing spaces
240 
241  if (buf.empty() || buf[0]=='#')
242  continue;
243 
244  std::stringstream str(buf);
245 
246  BiasMapEntry entry;
247 
248  str >> entry.hv_board;
249  str >> entry.hv_channel;
250  str >> entry.Vnom;
251  str >> entry.Voff;
252  str >> entry.Vslope;
253 
254 #ifdef __EXCEPTIONS
255  if (entry.hv_channel+32*entry.hv_board>=416)
256  throw std::runtime_error("Invalid board/channel read from "+fname+".");
257 #endif
258 #ifdef __MARS__
259  if (entry.hv_channel+32*entry.hv_board>=416)
260  {
261  gLog << err << "Invalid board/channel read from " << fname << "." << std::endl;
262  return false;
263  }
264 #endif
265 
266  (*this)[entry.hv()] = entry;
267 
268  l++;
269  }
270 
271 #ifdef __EXCEPTIONS
272  if (l!=416)
273  throw std::runtime_error("Number of lines ("+std::to_string(static_cast<long long>(l))+") read from "+fname+" does not match 416.");
274 
275  if (size()!=416)
276  throw std::runtime_error("Number of entries read from "+fname+" does not match 416.");
277 #endif
278 
279 #ifdef __MARS__
280  if (l!=416)
281  {
282  gLog << err << "Number of lines read from " << fname << " does not match 416." << std::endl;
283  return false;
284  }
285 
286  if (size()!=416)
287  {
288  gLog << "Number of entries read from " << fname << " does not match 416." << std::endl;
289  return false;
290  }
291 #endif
292 
293  return true;
294  }
float Vnom
Bias supply channel.
Definition: PixelMap.h:203
int hv() const
Definition: PixelMap.h:209
char str[80]
Definition: test_client.c:7
#define gLog
Definition: fits.h:36
float Vslope
Channel bias voltage offset [V].
Definition: PixelMap.h:205
int size
Definition: db_dim_server.c:17
float Voff
Channel bias voltage nominal.
Definition: PixelMap.h:204
int hv_channel
Bias suppply board.
Definition: PixelMap.h:202
int hv_board
Definition: PixelMap.h:201

+ Here is the call graph for this function:

+ Here is the caller graph for this function: