19 reinterpret_cast<uint32_t*
>(fStats.data())[0] = 0;
20 reinterpret_cast<uint32_t*
>(fStats.data())[1] = 0;
21 reinterpret_cast<uint32_t*
>(fStats.data())[2] = 0;
22 reinterpret_cast<uint32_t*
>(fStats.data())[3] = 0;
25 while (i<1024*1440*2+4)
27 while (i<1024*1440*3+4)
28 fStats[i++] = 2000./4096;
29 while (i<1440*1024*6+160*1024*2+4)
40 for (
int i=1024*1440*4+4;
i<1440*1024*6+160*1024*2+4;
i++)
43 reinterpret_cast<uint32_t*
>(fStats.data())[0] = 0;
44 reinterpret_cast<uint32_t*
>(fStats.data())[3] = 0;
47 fData.fDateRunBeg[2] =
"1970-01-01T00:00:00";
48 fData.fDateRunEnd[2] =
"1970-01-01T00:00:00";
58 const uint16_t roi =
fData.fRoi;
59 const uint16_t ntm =
fData.fNumTm;
61 vector<float> buf(1440*1024*6+160*1024*2+4);
63 memcpy(buf.data(), fStats.data(), (4*1024*1440+4)*
sizeof(
float));
65 for (
int i=0;
i<1440;
i++)
67 memcpy(buf.data()+4+1440*1024*4 +
i*1024, fStats.data()+4 + 4*1024*1440 + roi*
i, roi*
sizeof(float));
68 memcpy(buf.data()+4+1440*1024*5 + i*1024, fStats.data()+4 + 4*1024*1440 + roi*1440 + roi*
i, roi*
sizeof(float));
78 #warning Time marker channels not sent 87 vector<uint32_t>
data(5);
88 memcpy(data.data(), buf.data(), 4*
sizeof(uint32_t));
89 data[4] = night<19700000 ? 0 : night;
100 Error(
"Number of pixels in header for run "+to_string(GetRunId())+
" not 1440.");
106 Warn(
"Previous DRS calibration run not yet finished (current run "+to_string(GetRunId())+
")");
112 Warn(
"DRS Calibration already finished before current run "+to_string(GetRunId())+
"... please restart!");
119 msg <<
"Region of interest of run " << GetRunId() <<
" not 1024, but " << h.
Nroi <<
" in step " <<
fData.fStep <<
" ... as it ought to be.";
124 vector<uint16_t> dac(8);
174 InitSize(hastm ? 1600 : 1440, h.
Nroi);
176 fData.fRoi = fNumSamples;
177 fData.fNumTm = hastm ? 160 : 0;
186 const EVENT &e = *evt.
fEvent;
190 AddRel(e.Adc_Data, e.StartPix);
194 AddRel(e.Adc_Data, e.StartPix,
fData.fOffset.data(),
fData.fNumOffset);
198 AddAbs(e.Adc_Data, e.StartPix,
fData.fOffset.data(),
fData.fNumOffset);
208 msg.
Error(
"Reading "+str+
" failed: DRS calibration in process.");
214 const string txt =
fData.ReadFitsImp(str, fStats);
221 catch (
const runtime_error &e)
223 msg.
Error(
"Exception reading "+str+
": "+e.what());
283 str <<
"DRS calibration run (run=" << GetRunId() <<
", step=" <<
fData.fStep <<
", roi=" <<
fData.fRoi <<
") has 0 events.";
289 fData.fOffset.assign(fSum.begin(), fSum.end());
290 fData.fNumOffset = fNumEntries;
292 for (
int i=0;
i<1024*1440;
i++)
293 fData.fGain[
i] = 4096*fNumEntries;
296 GetSampleStats(fStats.data()+4, 2000./4096);
297 reinterpret_cast<uint32_t*
>(fStats.data())[1] = GetRunId();;
301 fData.fGain.assign(fSum.begin(), fSum.end());
302 fData.fNumGain = fNumEntries;
309 fData.fNumGain *= 1953125;
310 for (
int i=0;
i<1024*1440;
i++)
314 GetSampleStats(fStats.data()+1024*1440*2+4, 2000./4096/
fData.fNumOffset);
315 reinterpret_cast<uint32_t*
>(fStats.data())[2] = GetRunId();;
319 fData.fTrgOff.assign(fSum.begin(), fSum.end());
320 fData.fNumTrgOff = fNumEntries;
323 GetSampleStats(fStats.data()+1024*1440*4+4, 2000./4096/
fData.fNumOffset);
324 reinterpret_cast<uint32_t*
>(fStats.data())[0] = fNumSamples;
325 reinterpret_cast<uint32_t*
>(fStats.data())[3] = GetRunId();
328 const string beg = GetTstart().Iso();
329 const string end = GetTstop().Iso();
332 fData.fDateObs = beg;
340 const string filename = FormFileName(
"drs.fits");
343 fData.WriteFitsImp(filename, fStats, GetNight());
346 str <<
"Wrote DRS calibration data (run=" << GetRunId() <<
", step=" <<
fData.fStep <<
", roi=" <<
fData.fRoi <<
") to '" << filename <<
"'";
349 catch (
const exception &e)
351 Error(
"Exception writing run "+to_string(GetRunId())+
" '"+filename+
"': "+e.what());
355 Update(fDim, fDimRuns);
static std::vector< float > fStats
static bool ResetTrgOff(DimDescribedService &dim, DimDescribedService &runs)
void setQuality(int quality)
The base implementation of a distributed messaging system.
Adds some functionality to boost::posix_time::ptime for our needs.
uint32_t NightAsInt() const
bool Close(const EVT_CTRL2 &)
bool WriteEvt(const EVT_CTRL2 &e)
bool Open(const RUN_HEAD &h, const FAD::RunDescription &d)
void setData(const void *ptr, size_t sz)
int Error(const std::string &str)
static DrsCalibration fData
bool Open(const RUN_HEAD &h, const FAD::RunDescription &d)
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
static bool ReadFits(const string &fname, MessageImp &msg)
bool WriteEvt(const EVT_CTRL2 &)
static bool fProcessing
Storage for mean and rms values.
bool Close(const EVT_CTRL2 &)
static void Update(DimDescribedService &dim, DimDescribedService &runs)