Changeset 18282 for branches/MarsGapdTimeJitter/mcore/DrsCalib.h
- Timestamp:
- 08/18/15 10:28:44 (9 years ago)
- Location:
- branches/MarsGapdTimeJitter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MarsGapdTimeJitter
- Property svn:mergeinfo changed
-
branches/MarsGapdTimeJitter/mcore/DrsCalib.h
r17757 r18282 964 964 965 965 fStat.resize(samples*channels); 966 } 967 968 void Reset() 969 { 970 for (auto it=fStat.begin(); it!=fStat.end(); it++) 971 { 972 it->first = 0; 973 it->second = 0; 974 } 966 975 } 967 976 … … 1144 1153 const double valw = it->second; 1145 1154 1146 it->first = sumv>0 ? n*(1-s*sumw/sumv) : 0;1155 it->first = sumv>0 ? n*(1-s*sumw/sumv) : 0; 1147 1156 1148 1157 sumv += valv; … … 1163 1172 sumw += valw; 1164 1173 1165 it->first = sumv>0 ? n*(s*sumw/sumv-1) : 0;1174 it->first = sumv>0 ? n*(s*sumw/sumv-1) : 0; 1166 1175 } 1167 1176 … … 1197 1206 return pos-Offset(ch, pos); 1198 1207 } 1208 1209 /* 1210 // See MDrsCalibrationTime 1211 std::string ReadFitsImp(const std::string &str) 1212 { 1213 fits file(str); 1214 if (!file) 1215 { 1216 std::ostringstream msg; 1217 msg << "Could not open file '" << str << "': " << strerror(errno); 1218 return msg.str(); 1219 } 1220 1221 if (file.GetStr("TELESCOP")!="FACT") 1222 { 1223 std::ostringstream msg; 1224 msg << "Reading '" << str << "' failed: Not a valid FACT file (TELESCOP not FACT in header)"; 1225 return msg.str(); 1226 } 1227 1228 if (file.GetNumRows()!=1) 1229 { 1230 std::ostringstream msg; 1231 msg << "Reading '" << str << "' failed: Number of rows in table is not 1."; 1232 return msg.str(); 1233 } 1234 1235 fNumSamples = file.GetUInt("NROI"); 1236 fNumChannels = file.GetUInt("NCH"); 1237 fNumEntries = file.GetUInt("NBTIME"); 1238 1239 fStat.resize(fNumSamples*fNumChannels); 1240 1241 double *f = reinterpret_cast<double*>(file.SetPtrAddress("CellWidthMean")); 1242 double *s = reinterpret_cast<double*>(file.SetPtrAddress("CellWidthRms")); 1243 1244 if (!file.GetNextRow()) 1245 { 1246 std::ostringstream msg; 1247 msg << "Reading data from " << str << " failed."; 1248 return msg.str(); 1249 } 1250 1251 for (uint32_t i=0; i<fNumSamples*fNumChannels; i++) 1252 { 1253 fStat[i].first = f[i]; 1254 fStat[i].second = s[i]; 1255 } 1256 1257 return std::string(); 1258 } 1259 1260 std::string WriteFitsImp(const std::string &filename, uint32_t night=0) const 1261 { 1262 ofits file(filename.c_str()); 1263 if (!file) 1264 { 1265 std::ostringstream msg; 1266 msg << "Could not open file '" << filename << "': " << strerror(errno); 1267 return msg.str(); 1268 } 1269 1270 file.SetDefaultKeys(); 1271 file.AddColumnDouble(fStat.size(), "CellWidthMean", "ratio", "Relative cell width mean"); 1272 file.AddColumnDouble(fStat.size(), "CellWidthRms", "ratio", "Relative cell width rms"); 1273 1274 file.SetInt("ADCRANGE", 2000, "Dynamic range of the ADC in mV"); 1275 file.SetInt("DACRANGE", 2500, "Dynamic range of the DAC in mV"); 1276 file.SetInt("ADC", 12, "Resolution of ADC in bits"); 1277 file.SetInt("DAC", 16, "Resolution of DAC in bits"); 1278 file.SetInt("NPIX", 1440, "Number of channels in the camera"); 1279 file.SetInt("NTM", 0, "Number of time marker channels"); 1280 file.SetInt("NROI", fNumSamples, "Region of interest"); 1281 file.SetInt("NCH", fNumChannels, "Number of chips"); 1282 file.SetInt("NBTIME", fNumEntries, "Num of entries for time calibration"); 1283 1284 file.WriteTableHeader("DrsCellTimes"); 1285 if (night>0) 1286 file.SetInt("NIGHT", night, "Night as int"); 1287 1288 std::vector<double> data(fNumSamples*fNumChannels*2); 1289 1290 for (uint32_t i=0; i<fNumSamples*fNumChannels; i++) 1291 { 1292 data[i] = fStat[i].first; 1293 data[fNumSamples*fNumChannels+i] = fStat[i].second; 1294 } 1295 1296 if (!file.WriteRow(data.data(), data.size()*sizeof(double))) 1297 { 1298 std::ostringstream msg; 1299 msg << "Writing data to " << filename << " failed."; 1300 return msg.str(); 1301 } 1302 1303 return std::string(); 1304 }*/ 1199 1305 }; 1200 1306
Note:
See TracChangeset
for help on using the changeset viewer.