- Timestamp:
- 07/28/11 09:13:54 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilderWrapper.h
r11651 r11677 120 120 } 121 121 }; 122 123 #include "DrsCalib.h" 124 125 class DataFileCalib : public DataFileImp, CalibData 126 { 127 static vector<int32_t> fOffset; 128 static vector<int32_t> fGain; 129 static vector<int32_t> fTrgOff; 130 131 static uint32_t fNumOffset; 132 static uint32_t fNumGain; 133 static uint32_t fNumTrgOff; 134 135 static int fStep; 136 137 public: 138 DataFileCalib(uint32_t id, MessageImp &imp) : DataFileImp(id, imp) { } 139 140 static void Restart() { fStep = 0; } 141 142 bool OpenFile(RUN_HEAD* h) 143 { 144 if (fStep==4) 145 { 146 fMsg.Warn("DRS Calibration already finished... please restart!"); 147 return false; 148 } 149 150 if (h->NPix != 1440) 151 { 152 fMsg.Error("Number of pixels in header not 1440."); 153 return false; 154 } 155 156 if (h->Nroi != 1024) 157 { 158 fMsg.Error("Region of interest not 1024."); 159 return false; 160 } 161 162 ostringstream name; 163 name << "drs-calib-" << fStep; 164 fFileName = name.str(); 165 166 Reset(); 167 InitSize(1440, 1024); 168 169 if (fStep==0) 170 { 171 fGain.assign(1440*1024, 1); 172 fTrgOff.assign(1440*1024, 0); 173 174 fNumGain = 1; 175 fNumTrgOff = 1; 176 } 177 178 return true; 179 } 180 bool WriteEvt(EVENT *e) 181 { 182 // FIXME: SET StartPix to 0 if StartPix is -1 183 184 if (fStep==0) 185 { 186 AddRel(e->Adc_Data, e->StartPix); 187 } 188 if (fStep==1) 189 { 190 AddRel(e->Adc_Data, e->StartPix, fOffset.data(), fNumOffset); 191 } 192 if (fStep==2) 193 { 194 AddAbs(e->Adc_Data, e->StartPix, fOffset.data(), fNumOffset); 195 } 196 197 return true; 198 } 199 bool Close(RUN_TAIL * = 0) 200 { 201 if (fStep==0) 202 { 203 fOffset.assign(fSum.begin(), fSum.end()); 204 fNumOffset = fNumEntries; 205 } 206 if (fStep==1) 207 { 208 fGain.assign(fSum.begin(), fSum.end()); 209 fNumGain = fNumEntries*32768; 210 for (int i=0; i<1024*1440; i++) 211 fOffset -= 16384; 212 // Now we have a scale from -16384 to 16384 213 } 214 if (fStep==2) 215 { 216 fTrgOff.assign(fSum.begin(), fSum.end()); 217 fNumTrgOff = fNumEntries; 218 } 219 fStep++; 220 221 return true; 222 } 223 224 static void Apply(int16_t *val, const int16_t *start, uint32_t roi) 225 { 226 if (fStep==0) 227 return; 228 229 CalibData::Apply(val, start, roi, 230 fOffset.data(), fNumOffset, 231 fGain.data(), fNumGain, 232 fTrgOff.data(), fNumTrgOff); 233 } 234 }; 235 236 int DataFileCalib::fStep = 0; 237 238 vector<int32_t> DataFileCalib::fOffset; 239 vector<int32_t> DataFileCalib::fGain; 240 vector<int32_t> DataFileCalib::fTrgOff; 241 242 uint32_t DataFileCalib::fNumOffset = 0; 243 uint32_t DataFileCalib::fNumGain = 0; 244 uint32_t DataFileCalib::fNumTrgOff = 0; 245 122 246 123 247 class DataFileDebug : public DataFileNone … … 779 903 kDebug, 780 904 kFits, 781 kRaw 905 kRaw, 906 kCalib 782 907 }; 783 908 … … 1064 1189 bool IsIgnored(int i) const { return g_port[i].sockDef==-1; } 1065 1190 1066 void SetOutputFormat(FileFormat_t f) { fFileFormat = f; } 1191 void SetOutputFormat(FileFormat_t f) 1192 { 1193 fFileFormat = f; 1194 if (fFileFormat==kCalib) 1195 DataFileCalib::Restart(); 1196 } 1067 1197 1068 1198 void SetDebugLog(bool b) { fDebugLog = b; } … … 1166 1296 switch (fFileFormat) 1167 1297 { 1168 case kNone: file = new DataFileNone(runid, fMsg);break;1298 case kNone: file = new DataFileNone(runid, fMsg); break; 1169 1299 case kDebug: file = new DataFileDebug(runid, fMsg); break; 1170 case kFits: file = new DataFileFits(runid, fMsg); break; 1171 case kRaw: file = new DataFileRaw(runid, fMsg); break; 1300 case kFits: file = new DataFileFits(runid, fMsg); break; 1301 case kRaw: file = new DataFileRaw(runid, fMsg); break; 1302 case kCalib: file = new DataFileCalib(runid, fMsg); break; 1172 1303 } 1173 1304 … … 1430 1561 oldt = newt; 1431 1562 1563 DataFileCalib::Apply(event->Adc_Data, event->StartPix, event->Roi); 1564 1432 1565 const size_t sz = sizeof(EVENT)+event->Roi*2*1440; 1433 1566
Note:
See TracChangeset
for help on using the changeset viewer.