FACT++  1.0
void factfits::readDrsCalib ( const std::string &  fileName)
inlineprivate

Definition at line 129 of file factfits.h.

References ___err___, clear(), fOffsetCalibration, fits::GetNextRow(), zfits::GetNumRows(), fits::GetStr(), gLog, fits::HasKey(), fits::IsCompressedFITS(), and fits::SetPtrAddress().

Referenced by factfits().

130  {
131  //should not be mandatory, but improves the perfs a lot when reading not compressed, gzipped files
132  if (!IsCompressedFITS())
133  return;
134 
135  zfits calib(fileName, "ZDrsCellOffsets");
136 
137  if (calib.bad())
138  {
139  clear(rdstate()|std::ios::badbit);
140  return;
141  }
142 
143  if (calib.eof())
144  return;
145 
146  // Check correct size and format of table
147  if (calib.GetNumRows() != 1)
148  {
149  clear(rdstate()|std::ios::badbit);
150 #ifdef __EXCEPTIONS
151  throw std::runtime_error("Table 'ZDrsCellOffsets' found, but not with one row as expected");
152 #else
153  gLog << ___err___ << "ERROR - Table 'ZDrsCellOffsets' found, but not with one row as expected" << std::endl;
154  return;
155 #endif
156  }
157  if (calib.GetStr("TTYPE1") != "OffsetCalibration")
158  {
159  clear(rdstate()|std::ios::badbit);
160 #ifdef __EXCEPTIONS
161  throw std::runtime_error("Table 'ZDrsCellOffsets' found, but first column is not the one expected");
162 #else
163  gLog << ___err___ << "ERROR - Table 'ZDrsCellOffsets' found, but first column is not the one expected" << std::endl;
164  return;
165 #endif
166  }
167  bool isColumnPresent = false;
168  if (calib.HasKey("TFORM1") && calib.GetStr("TFORM1") == "1474560I") isColumnPresent = true;
169  if (calib.HasKey("ZFORM1") && calib.GetStr("ZFORM1") == "1474560I") isColumnPresent = true;
170  if (!isColumnPresent) // 1024*1440
171  {
172  clear(rdstate()|std::ios::badbit);
173 #ifdef __EXCEPTIONS
174  throw std::runtime_error("Table 'ZDrsCellOffsets' has wrong column format (TFROM1)");
175 #else
176  gLog << ___err___ << "ERROR - Table 'ZDrsCellOffsets' has wrong column format (TFORM1)" << std::endl;
177  return;
178 #endif
179  }
180 
181  fOffsetCalibration.resize(1024*1440);
182 
183  calib.SetPtrAddress("OffsetCalibration", fOffsetCalibration.data());
184  if (calib.GetNextRow())
185  return;
186 
187  clear(rdstate()|std::ios::badbit);
188 
189 #ifdef __EXCEPTIONS
190  throw std::runtime_error("Reading column 'OffsetCalibration' failed.");
191 #else
192  gLog << ___err___ << "ERROR - Reading column 'OffsetCalibration' failed." << std::endl;
193 #endif
194 
195  }
bool IsCompressedFITS() const
Definition: fits.h:1029
#define gLog
Definition: fits.h:36
#define ___err___
Definition: fits.h:37
std::vector< int16_t > fOffsetCalibration
integer values of the drs calibration used for compression
Definition: factfits.h:197
Definition: zfits.h:16
void clear()
Definition: HeadersFTM.h:216

+ Here is the call graph for this function:

+ Here is the caller graph for this function: