Changeset 18122
- Timestamp:
- 02/12/15 16:25:53 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/DrsCalib.h
r17757 r18122 1197 1197 return pos-Offset(ch, pos); 1198 1198 } 1199 1200 std::string ReadFitsImp(const std::string &str) 1201 { 1202 fits file(str); 1203 if (!file) 1204 { 1205 std::ostringstream msg; 1206 msg << "Could not open file '" << str << "': " << strerror(errno); 1207 return msg.str(); 1208 } 1209 1210 if (file.GetStr("TELESCOP")!="FACT") 1211 { 1212 std::ostringstream msg; 1213 msg << "Reading '" << str << "' failed: Not a valid FACT file (TELESCOP not FACT in header)"; 1214 return msg.str(); 1215 } 1216 1217 if (file.GetNumRows()!=1) 1218 { 1219 std::ostringstream msg; 1220 msg << "Reading '" << str << "' failed: Number of rows in table is not 1."; 1221 return msg.str(); 1222 } 1223 1224 fNumSamples = file.GetUInt("NROI"); 1225 fNumChannels = file.GetUInt("NCH"); 1226 fNumEntries = file.GetUInt("NBTIME"); 1227 1228 fStat.resize(fNumSamples*fNumChannels); 1229 1230 double *f = reinterpret_cast<double*>(file.SetPtrAddress("CellWidthMean")); 1231 double *s = reinterpret_cast<double*>(file.SetPtrAddress("CellWidthRms")); 1232 1233 if (!file.GetNextRow()) 1234 { 1235 std::ostringstream msg; 1236 msg << "Reading data from " << str << " failed."; 1237 return msg.str(); 1238 } 1239 1240 for (uint32_t i=0; i<fNumSamples*fNumChannels; i++) 1241 { 1242 fStat[i].first = f[i]; 1243 fStat[i].second = s[i]; 1244 } 1245 1246 return std::string(); 1247 } 1248 1249 std::string WriteFitsImp(const std::string &filename, uint32_t night=0) const 1250 { 1251 ofits file(filename.c_str()); 1252 if (!file) 1253 { 1254 std::ostringstream msg; 1255 msg << "Could not open file '" << filename << "': " << strerror(errno); 1256 return msg.str(); 1257 } 1258 1259 file.SetDefaultKeys(); 1260 file.AddColumnDouble(fStat.size(), "CellWidth", "ratio", "Relative cell width"); 1261 1262 file.SetInt("ADCRANGE", 2000, "Dynamic range of the ADC in mV"); 1263 file.SetInt("DACRANGE", 2500, "Dynamic range of the DAC in mV"); 1264 file.SetInt("ADC", 12, "Resolution of ADC in bits"); 1265 file.SetInt("DAC", 16, "Resolution of DAC in bits"); 1266 file.SetInt("NPIX", 1440, "Number of channels in the camera"); 1267 file.SetInt("NTM", 0, "Number of time marker channels"); 1268 file.SetInt("NROI", fNumSamples, "Region of interest"); 1269 file.SetInt("NCH", fNumChannels, "Number of chips"); 1270 file.SetInt("NBTIME", fNumEntries, "Num of entries for time calibration"); 1271 1272 file.WriteTableHeader("DrsCellTimes"); 1273 if (night>0) 1274 file.SetInt("NIGHT", night, "Night as int"); 1275 1276 /* 1277 file.SetStr("DATE-OBS", fDateObs, "First event of whole DRS calibration"); 1278 file.SetStr("DATE-END", fDateEnd, "Last event of whole DRS calibration"); 1279 file.SetStr("RUN-BEG", fDateRunBeg[0], "First event of run 0"); 1280 file.SetStr("RUN-END", fDateRunEnd[0], "Last event of run 0"); 1281 */ 1282 1283 std::vector<double> data(fNumSamples*fNumChannels*2); 1284 1285 for (uint32_t i=0; i<fNumSamples*fNumChannels; i++) 1286 { 1287 data[i] = fStat[i].first; 1288 data[fNumSamples*fNumChannels+i] = fStat[i].second; 1289 } 1290 1291 if (!file.WriteRow(data.data(), data.size()*sizeof(double))) 1292 { 1293 std::ostringstream msg; 1294 msg << "Writing data to " << filename << " failed."; 1295 return msg.str(); 1296 } 1297 1298 return std::string(); 1299 } 1199 1300 }; 1200 1301
Note:
See TracChangeset
for help on using the changeset viewer.