- Timestamp:
- 06/01/12 16:05:58 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/DataCalib.cc
r14000 r14022 211 211 } 212 212 213 void ReverseCopy(const void *src, void *dest)214 {215 reverse_copy(reinterpret_cast<const char*>(src),216 reinterpret_cast<const char*>(src)+sizeof(float),217 reinterpret_cast<char*>(dest));218 }219 220 213 void DataCalib::WriteFits() 221 214 { 222 #ifdef HAVE_FITS 223 FitsFile file(fMsg); 215 // EXCEPTION HANDLEING! 216 const string filename = FormFileName("drs.fits"); 217 218 ofits file(filename.c_str()); 224 219 225 220 const uint16_t roi = fData.fRoi; 226 221 const uint16_t ntm = fData.fNumTm; 227 222 228 file.AddColumn('I', "RunNumberBaseline"); 229 file.AddColumn('I', "RunNumberGain"); 230 file.AddColumn('I', "RunNumberTriggerOffset"); 231 file.AddColumn('F', "BaselineMean", 1024*1440, "mV"); 232 file.AddColumn('F', "BaselineRms", 1024*1440, "mV"); 233 file.AddColumn('F', "GainMean", 1024*1440, "mV"); 234 file.AddColumn('F', "GainRms", 1024*1440, "mV"); 235 file.AddColumn('F', "TriggerOffsetMean", roi*1440, "mV"); 236 file.AddColumn('F', "TriggerOffsetRms", roi*1440, "mV"); 237 file.AddColumn('F', "TriggerOffsetTMMean", roi*ntm, "mV"); 238 file.AddColumn('F', "TriggerOffsetTMRms", roi*ntm, "mV"); 239 240 const string filename = FormFileName("drs.fits"); 241 242 if (!file.OpenFile(filename)) 243 return; 244 245 if (!file.OpenTable("DrsCalibration")) 246 return; 247 248 if (!file.WriteDefaultKeys("fadctrl")) 249 return; 250 251 if (!file.WriteKeyNT("STEP", fData.fStep, "") || 252 !file.WriteKeyNT("ADCRANGE", 2000, "Dynamic range of the ADC in mV") || 253 !file.WriteKeyNT("DACRANGE", 2500, "Dynamic range of the DAC in mV") || 254 !file.WriteKeyNT("ADC", 12, "Resolution of ADC in bits") || 255 !file.WriteKeyNT("DAC", 16, "Resolution of DAC in bits") || 256 // !file.WriteKeyNT("DAC_A", fData.fDAC[0], "Level of DAC 0 in DAC counts") || 257 // !file.WriteKeyNT("DAC_B", fData.fDAC[1], "Leval of DAC 1-3 in DAC counts") || 258 // !file.WriteKeyNT("DAC_C", fData.fDAC[4], "Leval of DAC 4-7 in DAC counts") || 259 !file.WriteKeyNT("NBOFFSET", fData.fNumOffset, "Number of entries for offset calibration") || 260 !file.WriteKeyNT("NBGAIN", fData.fNumGain/1953125, "Number of entries for gain calibration") || 261 !file.WriteKeyNT("NBTRGOFF", fData.fNumTrgOff, "Number of entries for trigger offset calibration") || 262 !file.WriteKeyNT("NPIX", 1440, "Number of channels in the camera") || 263 !file.WriteKeyNT("NTM", ntm, "Number of time marker channels") || 264 !file.WriteKeyNT("NROI", roi, "Region of interest") 265 ) 266 return; 267 268 vector<char> buf(fStats.size()*sizeof(float)); 269 270 char *src = reinterpret_cast<char*>(fStats.data()); 271 char *end = reinterpret_cast<char*>(fStats.data()+fStats.size()); 272 char *dest = buf.data(); 273 274 while (src<end) 275 { 276 reverse_copy(src, src+sizeof(float), dest); 277 src += sizeof(float); 278 dest += sizeof(float); 279 } 280 281 if (!file.AddRow()) 282 return; 283 284 if (!file.WriteData(buf.data()+sizeof(float), (1440*1024*4 + 1440*roi*2 + ntm*roi*2 + 3)*sizeof(float))) 285 return; 223 file.AddColumnInt("RunNumberBaseline"); 224 file.AddColumnInt("RunNumberGain"); 225 file.AddColumnInt("RunNumberTriggerOffset"); 226 227 file.AddColumnFloat(1024*1440, "BaselineMean", "mV"); 228 file.AddColumnFloat(1024*1440, "BaselineRms", "mV"); 229 file.AddColumnFloat(1024*1440, "GainMean", "mV"); 230 file.AddColumnFloat(1024*1440, "GainRms", "mV"); 231 file.AddColumnFloat( roi*1440, "TriggerOffsetMean", "mV"); 232 file.AddColumnFloat( roi*1440, "TriggerOffsetRms", "mV"); 233 file.AddColumnFloat( roi*ntm, "TriggerOffsetTMMean", "mV"); 234 file.AddColumnFloat( roi*ntm, "TriggerOffsetTMRms", "mV"); 235 236 DataWriteFits2::WriteDefaultKeys(file); 237 238 file.SetInt("STEP", fData.fStep, ""); 239 240 file.SetInt("ADCRANGE", 2000, "Dynamic range of the ADC in mV"); 241 file.SetInt("DACRANGE", 2500, "Dynamic range of the DAC in mV"); 242 file.SetInt("ADC", 12, "Resolution of ADC in bits"); 243 file.SetInt("DAC", 16, "Resolution of DAC in bits"); 244 file.SetInt("NPIX", 1440, "Number of channels in the camera"); 245 file.SetInt("NTM", ntm, "Number of time marker channels"); 246 file.SetInt("NROI", roi, "Region of interest"); 247 248 file.SetInt("NBOFFSET", fData.fNumOffset, "Number of entries for offset calibration"); 249 file.SetInt("NBGAIN", fData.fNumGain/1953125, "Number of entries for gain calibration"); 250 file.SetInt("NBTRGOFF", fData.fNumTrgOff, "Number of entries for trigger offset calibration"); 251 252 // file.WriteKeyNT("DAC_A", fData.fDAC[0], "Level of DAC 0 in DAC counts") || 253 // file.WriteKeyNT("DAC_B", fData.fDAC[1], "Leval of DAC 1-3 in DAC counts") || 254 // file.WriteKeyNT("DAC_C", fData.fDAC[4], "Leval of DAC 4-7 in DAC counts") || 255 256 file.WriteTableHeader("DrsCalibration"); 257 258 const int n = (1440*1024*4 + 1440*roi*2 + ntm*roi*2 + 3)*sizeof(float); 259 file.WriteRow(fStats.data()+1, n); 286 260 287 261 ostringstream str; 288 262 str << "Wrote DRS calibration data (step=" << fData.fStep << ", roi=" << roi << ") to '" << filename << "'"; 289 263 Info(str.str()); 290 #endif291 264 } 292 265
Note:
See TracChangeset
for help on using the changeset viewer.