source: trunk/Mars/mcore/DrsCalib.h@ 16561

Last change on this file since 16561 was 16561, checked in by tbretz, 11 years ago
Performance improved and heavily tested version of the DRS calibration algorithms.
File size: 44.4 KB
Line 
1#ifndef MARS_DrsCalib
2#define MARS_DrsCalib
3
4#include <math.h> // fabs
5#include <errno.h> // errno
6
7#ifndef MARS_fits
8#include "fits.h"
9#endif
10
11#ifndef MARS_ofits
12#include "ofits.h"
13#endif
14
15#ifdef __MARS__
16#include "MTime.h"
17#endif
18
19class DrsCalibrate
20{
21protected:
22 uint64_t fNumEntries;
23
24 size_t fNumSamples;
25 size_t fNumChannels;
26
27 std::vector<int64_t> fSum;
28 std::vector<int64_t> fSum2;
29
30public:
31 DrsCalibrate() : fNumEntries(0), fNumSamples(0), fNumChannels(0) { }
32 void Reset()
33 {
34 fNumEntries = 0;
35 fNumSamples = 0;
36 fNumChannels = 0;
37
38 fSum.clear();
39 fSum2.clear();
40 }
41
42 void InitSize(uint16_t channels, uint16_t samples)
43 {
44 fNumChannels = channels;
45 fNumSamples = samples;
46
47 fSum.resize(samples*channels);
48 fSum2.resize(samples*channels);
49 }
50
51 void AddRel(const int16_t *val, const int16_t *start)
52 {
53 /*
54 for (size_t ch=0; ch<fNumChannels; ch++)
55 {
56 const int16_t &spos = start[ch];
57 if (spos<0)
58 continue;
59
60 const size_t pos = ch*1024;
61 for (size_t i=0; i<1024; i++)
62 {
63 // Value is relative to trigger
64 // Abs is corresponding index relative to DRS pipeline
65 const size_t rel = pos + i;
66 const size_t abs = pos + (spos+i)%1024;
67
68 const int64_t v = val[rel];
69
70 fSum[abs] += v;
71 fSum2[abs] += v*v;
72 }
73 */
74
75 // This version is 2.5 times faster because the compilers optimization
76 // is not biased by the evaluation of %1024
77 for (size_t ch=0; ch<fNumChannels; ch++)
78 {
79 const int16_t &spos = start[ch];
80 if (spos<0)
81 continue;
82
83 const size_t pos = ch*1024;
84
85 const int16_t *pval = val + pos;
86 const int16_t *end_val = val + 1024;
87
88 int64_t *beg_sum = fSum.data() + pos;
89 int64_t *beg_sum2 = fSum2.data() + pos;
90
91 int64_t *psum = beg_sum + spos;
92 int64_t *psum2 = beg_sum2 + spos;
93
94 while (psum<beg_sum+1024)
95 {
96 const int64_t v = *pval++;
97
98 *psum++ = v;
99 *psum2++ = v*v;
100 }
101
102 psum = beg_sum;
103 psum2 = beg_sum2;
104
105 while (pval<end_val)
106 {
107 const int64_t v = *pval++;
108
109 *psum++ = v;
110 *psum2++ = v*v;
111 }
112 }
113
114 fNumEntries++;
115 }
116
117 void AddRel(const int16_t *val, const int16_t *start,
118 const int32_t *offset, const uint32_t scale)
119 {
120 /*
121 for (size_t ch=0; ch<fNumChannels; ch++)
122 {
123 const int16_t spos = start[ch];
124 if (spos<0)
125 continue;
126
127 const size_t pos = ch*1024;
128
129 for (size_t i=0; i<fNumSamples; i++)
130 {
131 // Value is relative to trigger
132 // Offset is relative to DRS pipeline
133 // Abs is corresponding index relative to DRS pipeline
134 const size_t rel = pos + i;
135 const size_t abs = pos + (spos+i)%1024;
136
137 const int64_t v = int64_t(val[rel])*scale-offset[abs];
138
139 fSum[abs] += v;
140 fSum2[abs] += v*v;
141 }
142 }*/
143
144 // This version is 2.5 times faster because the compilers optimization
145 // is not biased by the evaluation of %1024
146 for (size_t ch=0; ch<fNumChannels; ch++)
147 {
148 const int16_t &spos = start[ch];
149 if (spos<0)
150 continue;
151
152 const size_t pos = ch*1024;
153
154 const int16_t *pval = val + pos;
155 const int16_t *end_val = val + 1024;
156
157 const int32_t *beg_offset = offset + pos;
158 const int32_t *poffset = beg_offset + spos;
159
160 int64_t *beg_sum = fSum.data() + pos;
161 int64_t *beg_sum2 = fSum2.data() + pos;
162
163 int64_t *psum = beg_sum + spos;
164 int64_t *psum2 = beg_sum2 + spos;
165
166 while (psum<beg_sum+1024)
167 {
168 const int64_t v = int64_t(*pval++)*scale - *poffset++;
169
170 *psum++ = v;
171 *psum2++ = v*v;
172 }
173
174 psum = beg_sum;
175 psum2 = beg_sum2;
176 poffset = beg_offset;
177
178 while (pval<end_val)
179 {
180 const int64_t v = int64_t(*pval++)*scale - *poffset++;
181
182 *psum++ = v;
183 *psum2++ = v*v;
184 }
185 }
186
187 fNumEntries++;
188 }
189 /*
190 void AddAbs(const int16_t *val, const int16_t *start,
191 const int32_t *offset, const uint32_t scale)
192 {
193 for (size_t ch=0; ch<fNumChannels; ch++)
194 {
195 const int16_t spos = start[ch];
196 if (spos<0)
197 continue;
198
199 const size_t pos = ch*fNumSamples;
200
201 for (size_t i=0; i<fNumSamples; i++)
202 {
203 // Value is relative to trigger
204 // Offset is relative to DRS pipeline
205 // Abs is corresponding index relative to DRS pipeline
206 const size_t rel = pos + i;
207 const size_t abs = pos + (spos+i)%1024;
208
209 const int64_t v = int64_t(val[rel])*scale-offset[abs];
210
211 fSum[rel] += v;
212 fSum2[rel] += v*v;
213 }
214 }
215
216 fNumEntries++;
217 }*/
218
219 void AddAbs(const int16_t *val, const int16_t *start,
220 const int32_t *offset, const uint32_t scale)
221 {
222 /*
223 // 1440 without tm, 1600 with tm
224 for (size_t ch=0; ch<fNumChannels; ch++)
225 {
226 const int16_t spos = start[ch];
227 if (spos<0)
228 continue;
229
230 const size_t pos = ch*fNumSamples;
231 const size_t drs = ch>1439 ? ((ch-1440)*9+8)*1024 : ch*1024;
232
233 for (size_t i=0; i<fNumSamples; i++)
234 {
235 // Value is relative to trigger
236 // Offset is relative to DRS pipeline
237 // Abs is corresponding index relative to DRS pipeline
238 const size_t rel = pos + i;
239 const size_t abs = drs + (spos+i)%1024;
240
241 const int64_t v = int64_t(val[rel])*scale-offset[abs];
242
243 fSum[rel] += v;
244 fSum2[rel] += v*v;
245 }
246 }*/
247
248 // This version is 1.5 times faster because the compilers optimization
249 // is not biased by the evaluation of %1024
250 for (size_t ch=0; ch<fNumChannels; ch++)
251 {
252 const int16_t &spos = start[ch];
253 if (spos<0)
254 continue;
255
256 const size_t pos = ch*fNumSamples;
257
258 const int16_t *pval = val + pos;
259
260 const int32_t *beg_offset = offset + ch*1024;
261 const int32_t *poffset = beg_offset + spos;
262
263 int64_t *beg_sum = fSum.data() + pos;
264 int64_t *beg_sum2 = fSum2.data() + pos;
265
266 int64_t *psum = beg_sum;
267 int64_t *psum2 = beg_sum2;
268
269 if (spos+fNumSamples>1024)
270 {
271 while (poffset<beg_offset+1024)
272 {
273 const int64_t v = int64_t(*pval++)*scale - *poffset++;
274
275 *psum++ = v;
276 *psum2++ = v*v;
277 }
278
279 poffset = beg_offset;
280 }
281
282 while (psum<beg_sum+fNumSamples)
283 {
284 const int64_t v = int64_t(*pval++)*scale - *poffset++;
285
286 *psum++ = v;
287 *psum2++ = v*v;
288 }
289 }
290
291 fNumEntries++;
292 }
293
294
295 static void ApplyCh(float *vec, const int16_t *val, int16_t start, uint32_t roi,
296 const int32_t *offset, const uint32_t scaleabs,
297 const int64_t *gain, const uint64_t scalegain)
298 {
299 if (start<0)
300 {
301 memset(vec, 0, roi);
302 return;
303 }
304
305 /*
306 for (size_t i=0; i<roi; i++)
307 {
308 // Value is relative to trigger
309 // Offset is relative to DRS pipeline
310 // Abs is corresponding index relative to DRS pipeline
311 const size_t abs = (start+i)%1024;
312
313 const int64_t v =
314 + int64_t(val[i])*scaleabs-offset[abs]
315 ;
316
317 const int64_t div = gain[abs];
318 vec[i] = div==0 ? 0 : double(v)*scalegain/div;
319 }*/
320
321 // This version is faster because the compilers optimization
322 // is not biased by the evaluation of %1024
323 // (Here we are dominated by numerics... improvement ~10%)
324 const int32_t *poffset = offset + start;
325 const int64_t *pgain = gain + start;
326 const int16_t *pval = val;
327
328 float *pvec = vec;
329
330 if (start+roi>1024)
331 {
332 while (poffset<offset+1024)
333 {
334 const int64_t v =
335 + int64_t(*pval++)*scaleabs - *poffset++
336 ;
337
338 *pvec++ = *pgain==0 ? 0 : double(v)*scalegain / *pgain;
339
340 pgain++;
341 }
342
343 poffset = offset;
344 pgain = gain;
345 }
346
347 while (pvec<vec+roi)
348 {
349 const int64_t v =
350 + int64_t(*pval++)*scaleabs - *poffset++
351 ;
352
353 *pvec++ = *pgain==0 ? 0 : double(v)*scalegain / *pgain;
354
355 pgain++;
356 }
357 }
358
359 static void ApplyCh(float *vec, const int16_t *val, int16_t start, uint32_t roi,
360 const int32_t *offset, const uint32_t scaleabs,
361 const int64_t *gain, const uint64_t scalegain,
362 const int64_t *trgoff, const uint64_t scalerel)
363 {
364 if (start<0)
365 {
366 memset(vec, 0, roi);
367 return;
368 }
369 /*
370 for (size_t i=0; i<roi; i++)
371 {
372 // Value is relative to trigger
373 // Offset is relative to DRS pipeline
374 // Abs is corresponding index relative to DRS pipeline
375 const size_t abs = (start+i)%1024;
376
377 const int64_t v =
378 + (int64_t(val[i])*scaleabs-offset[abs])*scalerel
379 - trgoff[i]
380 ;
381
382 const int64_t div = gain[abs]*scalerel;
383 vec[i] = div==0 ? 0 : double(v)*scalegain/div;
384 }*/
385
386 // (Here we are dominated by numerics... improvement ~10%)
387 const int32_t *poffset = offset + start;
388 const int64_t *pgain = gain + start;
389 const int16_t *pval = val;
390 const int64_t *ptrgoff = trgoff;
391
392 float *pvec = vec;
393
394 if (start+roi>1024)
395 {
396 while (poffset<offset+1024)
397 {
398 const int64_t v =
399 + (int64_t(*pval++)*scaleabs - *poffset++)*scalerel
400 - *ptrgoff++;
401 ;
402
403 const int64_t div = *pgain * scalerel;
404 *pvec++ = div==0 ? 0 : double(v)*scalegain / div;
405
406 pgain++;
407 }
408
409 poffset = offset;
410 pgain = gain;
411 }
412
413 while (pvec<vec+roi)
414 {
415 const int64_t v =
416 + (int64_t(*pval++)*scaleabs - *poffset++)*scalerel
417 - *ptrgoff++;
418 ;
419
420 const int64_t div = *pgain * scalerel;
421 *pvec++ = div==0 ? 0 : double(v)*scalegain / div;
422
423 pgain++;
424 }
425 }
426
427 static double FindStep(const size_t ch0, const float *vec, int16_t roi, const int16_t pos, const uint16_t *map=NULL)
428 {
429 // We have about 1% of all cases which are not ahndled here,
430 // because the baseline jumps up just before the readout window
431 // and down just after it. In this cases we could determine the jump
432 // from the board time difference or throw the event away.
433 if (pos==0 || pos>=roi)
434 return 0;
435
436 double step = 0; // before
437 double rms = 0; // before
438 int cnt = 0;
439
440 // Exclude TM channel
441 for (int p=0; p<8; p++)
442 {
443 const size_t hw = ch0+p;
444 const size_t sw = (map?map[hw]:hw)*roi + pos;
445
446 const double diff = vec[sw]-vec[sw-1];
447
448 step += diff;
449 rms += (vec[sw]-vec[sw-1])*(vec[sw]-vec[sw-1]);
450
451 cnt++;
452 }
453
454 return cnt==0 ? 0 : step/cnt;
455 }
456
457 static void SubtractStep(const size_t ch0, const double avg, float *vec, int16_t roi, int32_t pos, const uint16_t *map=NULL)
458 {
459 if (pos==0 || pos>=roi)
460 return;
461
462 const int begin = avg>0 ? pos : 0;
463 const int end = avg>0 ? roi : pos;
464
465 const double sub = fabs(avg);
466
467 for (int p=0; p<9; p++)
468 {
469 for (int j=begin; j<end; j++)
470 {
471 const size_t hw = ch0+p;
472 const size_t sw = (map?map[hw]:hw)*roi + j;
473
474 vec[sw] -= sub;
475 }
476 }
477 }
478
479 struct Step
480 {
481 Step() : avg(0), rms(0), pos(0), cnt(0) { }
482 double avg;
483 double rms;
484 double pos;
485 uint16_t cnt;
486
487 static bool sort(const Step &s, const Step &r) { return s.avg<r.avg; }
488 };
489
490 static Step AverageSteps(const std::vector<Step>::iterator beg, const std::vector<Step>::iterator end)
491 {
492 Step rc;
493 for (auto it=beg; it!=end; it++)
494 {
495 rc.pos += it->pos;
496 rc.avg += it->avg;
497 rc.rms += it->avg*it->avg;
498 }
499
500 rc.cnt = end-beg;
501
502 rc.pos /= rc.cnt;
503 rc.avg /= rc.cnt;
504 rc.rms /= rc.cnt;
505
506 rc.rms = sqrt(rc.rms-rc.avg*rc.avg);
507
508 return rc;
509 }
510
511
512 static Step CorrectStep(float *vec, uint16_t nch, uint16_t roi,
513 const int16_t *prev, const int16_t *start,
514 const int16_t offset, const uint16_t *map=NULL)
515 {
516
517 std::vector<Step> list;
518 list.reserve(nch);
519
520 // Fill steps into array
521 // Exclude broken pixels?
522 // Remove maximum and minimum patches (4max and 4min)?
523 for (size_t ch=0; ch<nch; ch += 9)
524 {
525 if (prev[ch]<0 || start[ch]<0)
526 continue;
527
528 const int16_t dist = (prev[ch]-start[ch]+1024+offset)%1024;
529 const double step = FindStep(ch, vec, roi, dist, map);
530 if (step==0)
531 continue;
532
533 Step rc;
534 rc.pos = dist;
535 rc.avg = step;
536 list.push_back(rc);
537 }
538
539 if (list.empty())
540 return Step();
541
542 Step rc = AverageSteps(list.begin(), list.begin()+list.size());;
543
544 if (rc.avg==0)
545 return Step();
546
547 // std::cout << " A0=" << rc.avg << " rms=" << rc.rms << std::endl;
548 if (rc.rms>5)
549 {
550 sort(list.begin(), list.end(), Step::sort);
551
552 //for (auto it=list.begin(); it!=list.end(); it++)
553 // std::cout << " " << it->avg << std::endl;
554
555 const size_t skip = list.size()/10;
556 rc = AverageSteps(list.begin()+skip, list.begin()+list.size()-skip);
557
558 // std::cout << " A1=" << rc.avg << " rms=" << rc.rms << std::endl;
559 }
560
561 for (size_t ch=0; ch<nch; ch += 9)
562 {
563 const int16_t dist = (prev[ch]-start[ch]+1024+offset)%1024;
564 SubtractStep(ch, rc.avg, vec, roi, dist, map);
565 }
566
567 return rc;
568 }
569
570 static void RemoveSpikes(float *vec, uint32_t roi)
571 {
572 if (roi<4)
573 return;
574
575 for (size_t ch=0; ch<1440; ch++)
576 {
577 float *p = vec + ch*roi;
578
579 for (size_t i=1; i<roi-2; i++)
580 {
581 if (p[i]-p[i-1]>25 && p[i]-p[i+1]>25)
582 {
583 p[i] = (p[i-1]+p[i+1])/2;
584 }
585
586 if (p[i]-p[i-1]>22 && fabs(p[i]-p[i+1])<4 && p[i+1]-p[i+2]>22)
587 {
588 p[i] = (p[i-1]+p[i+2])/2;
589 p[i+1] = p[i];
590 }
591 }
592 }
593 }
594
595 static void RemoveSpikes2(float *vec, uint32_t roi)//from Werner
596 {
597 if (roi<4)
598 return;
599
600 for (size_t ch=0; ch<1440; ch++)
601 {
602 float *p = vec + ch*roi;
603
604 std::vector<float> Ameas(p, p+roi);
605
606 std::vector<float> diff(roi);
607 for (size_t i=1; i<roi-1; i++)
608 diff[i] = (p[i-1] + p[i+1])/2 - p[i];
609
610 //std::vector<float> N1mean(roi);
611 //for (size_t i=1; i<roi-1; i++)
612 // N1mean[i] = (p[i-1] + p[i+1])/2;
613
614 const float fract = 0.8;
615
616 for (size_t i=0; i<roi-3; i++)
617 {
618 if (diff[i]<5)
619 continue;
620
621 if (Ameas[i+2] - (Ameas[i] + Ameas[i+3])/2 > 10)
622 {
623 p[i+1]= (Ameas[i+3] - Ameas[i])/3 + Ameas[i];
624 p[i+2]= 2*(Ameas[i+3] - Ameas[i])/3 + Ameas[i];
625
626 i += 3;
627
628 continue;
629 }
630
631 if ( (diff[i+1]<-diff[i]*fract*2) && (diff[i+2]>10) )
632 {
633 p[i+1] = (Ameas[i]+Ameas[i+2])/2;
634 diff[i+2] = (p[i+1] + Ameas[i+3])/2 - Ameas[i+2];
635
636 i += 2;
637 }
638
639 // const float x = Ameas[i] - N1mean[i];
640 // if (x > -5.)
641 // continue;
642
643 // if (Ameas[i+2] - (Ameas[i] + Ameas[i+3])/2. > 10.)
644 // {
645 // p[i+1]= (Ameas[i+3] - Ameas[i])/3 + Ameas[i];
646 // p[i+2]= 2*(Ameas[i+3] - Ameas[i])/3 + Ameas[i];
647 // i += 3;
648 // continue;
649 // }
650
651 // const float xp = Ameas[i+1] - N1mean[i+1];
652 // const float xpp = Ameas[i+2] - N1mean[i+2];
653
654 // if ( (xp > -2.*x*fract) && (xpp < -10.) )
655 // {
656 // p[i+1] = N1mean[i+1];
657 // N1mean[i+2] = Ameas[i+1] - Ameas[i+3]/2;
658 //
659 // i += 2;
660 // }
661 }
662 }
663 }
664
665 static void RemoveSpikes3(float *vec, uint32_t roi)//from Werner
666 {
667 const float SingleCandidateTHR = -10.;
668 const float DoubleCandidateTHR = -5.;
669
670 const std::vector<float> src(vec, vec+roi);
671
672 std::vector<float> diff(roi);
673 for (size_t i=1; i<roi-1; i++)
674 diff[i] = src[i] - (src[i-1] + src[i+1])/2;
675
676 // find the spike and replace it by mean value of neighbors
677 for (unsigned int i=1; i<roi-3; i++)
678 {
679 // Speed up (no leading edge)
680 if (diff[i]>=DoubleCandidateTHR)
681 continue;
682
683 //bool checkDouble = false;
684
685 // a single spike candidate
686 if (diff[i]<SingleCandidateTHR)
687 {
688 // check consistency with a single channel spike
689 if (diff[i+1] > -1.6*diff[i])
690 {
691 vec[i+1] = (src[i] + src[i+2]) / 2;
692
693 i += 2;
694
695 /*** NEW ***/
696 continue;
697 /*** NEW ***/
698 }
699 /*
700 else
701 {
702 // do nothing - not really a single spike,
703 // but check if it is a double
704 checkDouble = true;
705 }*/
706 }
707
708 // a double spike candidate
709 //if (diff[i]>DoubleCandidateTHR || checkDouble == 1)
710 {
711 // check the consistency with a double spike
712 if ((diff[i+1] > -DoubleCandidateTHR) &&
713 (diff[i+2] > -DoubleCandidateTHR))
714 {
715 vec[i+1] = (src[i+3] - src[i])/3 + src[i];
716 vec[i+2] = 2*(src[i+3] - src[i])/3 + src[i];
717
718 //vec[i] = (src[i-1] + src[i+2]) / 2.;
719 //vec[i+1] = (src[i-1] + src[i+2]) / 2.;
720
721 //do not care about the next sample it was the spike
722 i += 3;
723 }
724 }
725 }
726 }
727
728 static void SlidingAverage(float *const vec, const uint32_t roi, const uint16_t w)
729 {
730 if (w==0 || w>roi)
731 return;
732
733 for (float *pix=vec; pix<vec+1440*roi; pix += roi)
734 {
735 for (float *ptr=pix; ptr<pix+roi-w; ptr++)
736 {
737 for (float *p=ptr+1; p<ptr+w; p++)
738 *ptr += *p;
739 *ptr /= w;
740 }
741 }
742 }
743
744 std::pair<std::vector<double>,std::vector<double> > GetSampleStats() const
745 {
746 if (fNumEntries==0)
747 return make_pair(std::vector<double>(),std::vector<double>());
748
749 std::vector<double> mean(fSum.size());
750 std::vector<double> error(fSum.size());
751
752 std::vector<int64_t>::const_iterator it = fSum.begin();
753 std::vector<int64_t>::const_iterator i2 = fSum2.begin();
754 std::vector<double>::iterator im = mean.begin();
755 std::vector<double>::iterator ie = error.begin();
756
757 while (it!=fSum.end())
758 {
759 *im = /*cnt<fResult.size() ? fResult[cnt] :*/ double(*it)/fNumEntries;
760 *ie = sqrt(double(*i2*int64_t(fNumEntries) - *it * *it))/fNumEntries;
761
762 im++;
763 ie++;
764 it++;
765 i2++;
766 }
767
768
769 /*
770 valarray<double> ...
771
772 mean /= fNumEntries;
773 error = sqrt(error/fNumEntries - mean*mean);
774 */
775
776 return make_pair(mean, error);
777 }
778
779 void GetSampleStats(float *ptr, float scale) const
780 {
781 const size_t sz = fNumSamples*fNumChannels;
782
783 if (fNumEntries==0)
784 {
785 memset(ptr, 0, sizeof(float)*sz*2);
786 return;
787 }
788
789 std::vector<int64_t>::const_iterator it = fSum.begin();
790 std::vector<int64_t>::const_iterator i2 = fSum2.begin();
791
792 while (it!=fSum.end())
793 {
794 *ptr = scale*double(*it)/fNumEntries;
795 *(ptr+sz) = scale*sqrt(double(*i2*int64_t(fNumEntries) - *it * *it))/fNumEntries;
796
797 ptr++;
798 it++;
799 i2++;
800 }
801 }
802
803 static double GetPixelStats(float *ptr, const float *data, uint16_t roi)
804 {
805 if (roi==0)
806 return -1;
807
808 const int beg = roi>10 ? 10 : 0;
809
810 double max = 0;
811 for (int i=0; i<1440; i++)
812 {
813 const float *vec = data+i*roi;
814
815 int pos = beg;
816 double sum = vec[beg];
817 double sum2 = vec[beg]*vec[beg];
818 for (int j=beg+1; j<roi; j++)
819 {
820 sum += vec[j];
821 sum2 += vec[j]*vec[j];
822
823 if (vec[j]>vec[pos])
824 pos = j;
825 }
826 sum /= roi-beg;
827 sum2 /= roi-beg;
828
829 if (vec[pos]>0)
830 max = vec[pos];
831
832 *(ptr+0*1440+i) = sum;
833 *(ptr+1*1440+i) = sqrt(sum2 - sum * sum);
834 *(ptr+2*1440+i) = vec[pos];
835 *(ptr+3*1440+i) = pos;
836 }
837
838 return max;
839 }
840
841 static void GetPixelMax(float *max, const float *data, uint16_t roi, int32_t first, int32_t last)
842 {
843 if (roi==0 || first<0 || last<0 || first>=roi || last>=roi || last<first)
844 return;
845
846 for (int i=0; i<1440; i++)
847 {
848 const float *beg = data+i*roi+first;
849 const float *end = data+i*roi+last;
850
851 const float *pmax = beg;
852
853 for (const float *ptr=beg+1; ptr<=end; ptr++)
854 if (*ptr>*pmax)
855 pmax = ptr;
856
857 max[i] = *pmax;
858 }
859 }
860
861 const std::vector<int64_t> &GetSum() const { return fSum; }
862
863 uint64_t GetNumEntries() const { return fNumEntries; }
864};
865
866class DrsCalibrateTime
867{
868public:
869 uint64_t fNumEntries;
870
871 size_t fNumSamples;
872 size_t fNumChannels;
873
874 std::vector<std::pair<double, double>> fStat;
875
876public:
877 DrsCalibrateTime() : fNumEntries(0), fNumSamples(0), fNumChannels(0)
878 {
879 InitSize(160, 1024);
880 }
881
882 DrsCalibrateTime(const DrsCalibrateTime &p) : fNumEntries(p.fNumEntries), fNumSamples(p.fNumSamples), fNumChannels(p.fNumChannels), fStat(p.fStat)
883 {
884 }
885 virtual ~DrsCalibrateTime()
886 {
887 }
888
889 double Sum(uint32_t i) const { return fStat[i].first; }
890 double W(uint32_t i) const { return fStat[i].second; }
891
892 virtual void InitSize(uint16_t channels, uint16_t samples)
893 {
894 fNumChannels = channels;
895 fNumSamples = samples;
896
897 fNumEntries = 0;
898
899 fStat.clear();
900
901 fStat.resize(samples*channels);
902 }
903
904 void AddT(const float *val, const int16_t *start, signed char edge=0)
905 {
906 if (fNumSamples!=1024 || fNumChannels!=160)
907 return;
908
909 // Rising or falling edge detection has the advantage that
910 // we are much less sensitive to baseline shifts
911
912 for (size_t ch=0; ch<160; ch++)
913 {
914 const size_t tm = ch*9+8;
915
916 const int16_t spos = start[tm];
917 if (spos<0)
918 continue;
919
920 const size_t pos = ch*1024;
921
922 double p_prev = 0;
923 int32_t i_prev = -1;
924
925 for (size_t i=0; i<1024-1; i++)
926 {
927 const size_t rel = tm*1024 + i;
928
929 const float &v0 = val[rel]; //-avg;
930 const float &v1 = val[rel+1];//-avg;
931
932 // If edge is positive ignore all falling edges
933 if (edge>0 && v0>0)
934 continue;
935
936 // If edge is negative ignore all falling edges
937 if (edge<0 && v0<0)
938 continue;
939
940 // Check if there is a zero crossing
941 if ((v0<0 && v1<0) || (v0>0 && v1>0))
942 continue;
943
944 // Calculate the position p of the zero-crossing
945 // within the interval [rel, rel+1] relative to rel
946 // by linear interpolation.
947 const double p = v0==v1 ? 0.5 : v0/(v0-v1);
948
949 // If this was at least the second zero-crossing detected
950 if (i_prev>=0)
951 {
952 // Calculate the distance l between the
953 // current and the last zero-crossing
954 const double l = i+p - (i_prev+p_prev);
955
956 // By summation, the average length of each
957 // cell is calculated. For the first and last
958 // fraction of a cell, the fraction is applied
959 // as a weight.
960 const double w0 = 1-p_prev;
961 fStat[pos+(spos+i_prev)%1024].first += w0*l;
962 fStat[pos+(spos+i_prev)%1024].second += w0;
963
964 for (size_t k=i_prev+1; k<i; k++)
965 {
966 fStat[pos+(spos+k)%1024].first += l;
967 fStat[pos+(spos+k)%1024].second += 1;
968 }
969
970 const double w1 = p;
971 fStat[pos+(spos+i)%1024].first += w1*l;
972 fStat[pos+(spos+i)%1024].second += w1;
973 }
974
975 // Remember this zero-crossing position
976 p_prev = p;
977 i_prev = i;
978 }
979 }
980 fNumEntries++;
981 }
982
983 void FillEmptyBins()
984 {
985 for (int ch=0; ch<160; ch++)
986 {
987 const auto beg = fStat.begin() + ch*1024;
988 const auto end = beg + 1024;
989
990 double avg = 0;
991 uint32_t num = 0;
992 for (auto it=beg; it!=end; it++)
993 {
994 if (it->second<fNumEntries-0.5)
995 continue;
996
997 avg += it->first / it->second;
998 num++;
999 }
1000 avg /= num;
1001
1002 for (auto it=beg; it!=end; it++)
1003 {
1004 if (it->second>=fNumEntries-0.5)
1005 continue;
1006
1007 // {
1008 // result[i+1].first = *is2;
1009 // result[i+1].second = *iw2;
1010 // }
1011 // else
1012 // {
1013 it->first = avg*fNumEntries;
1014 it->second = fNumEntries;
1015 // }
1016 }
1017 }
1018 }
1019
1020 DrsCalibrateTime GetComplete() const
1021 {
1022 DrsCalibrateTime rc(*this);
1023 rc.FillEmptyBins();
1024 return rc;
1025 }
1026
1027 void CalcResult()
1028 {
1029 for (int ch=0; ch<160; ch++)
1030 {
1031 const auto beg = fStat.begin() + ch*1024;
1032 const auto end = beg + 1024;
1033
1034 // First calculate the average length s of a single
1035 // zero-crossing interval in the whole range [0;1023]
1036 // (which is identical to the/ wavelength of the
1037 // calibration signal)
1038 double s = 0;
1039 double w = 0;
1040 for (auto it=beg; it!=end; it++)
1041 {
1042 s += it->first;
1043 w += it->second;
1044 }
1045 s /= w;
1046
1047 // Dividing the average length s of the zero-crossing
1048 // interval in the range [0;1023] by the average length
1049 // in the interval [0;n] yields the relative size of
1050 // the interval in the range [0;n].
1051 //
1052 // Example:
1053 // Average [0;1023]: 10.00 (global interval size in samples)
1054 // Average [0;512]: 8.00 (local interval size in samples)
1055 //
1056 // Globally, on average one interval is sampled by 10 samples.
1057 // In the sub-range [0;512] one interval is sampled on average
1058 // by 8 samples.
1059 // That means that the interval contains 64 periods, while
1060 // in the ideal case (each sample has the same length), it
1061 // should contain 51.2 periods.
1062 // So, the sampling position 512 corresponds to a time 640,
1063 // while in the ideal case with equally spaces samples,
1064 // it would correspond to a time 512.
1065 //
1066 // The offset (defined as 'ideal - real') is then calculated
1067 // as 512*(1-10/8) = -128, so that the time is calculated as
1068 // 'sampling position minus offset'
1069 //
1070 double sumw = 0;
1071 double sumv = 0;
1072 int n = 0;
1073
1074 // Sums about many values are numerically less stable than
1075 // just sums over less. So we do the exercise from both sides.
1076 // First from the left
1077 for (auto it=beg; it!=end-512; it++, n++)
1078 {
1079 const double valv = it->first;
1080 const double valw = it->second;
1081
1082 it->first = sumv>0 ? n*(1-s*sumw/sumv) : 0;
1083
1084 sumv += valv;
1085 sumw += valw;
1086 }
1087
1088 sumw = 0;
1089 sumv = 0;
1090 n = 1;
1091
1092 // Second from the right
1093 for (auto it=end-1; it!=beg-1+512; it--, n++)
1094 {
1095 const double valv = it->first;
1096 const double valw = it->second;
1097
1098 sumv += valv;
1099 sumw += valw;
1100
1101 it->first = sumv>0 ? n*(s*sumw/sumv-1) : 0;
1102 }
1103
1104 // A crosscheck has shown, that the values from the left
1105 // and right perfectly agree over the whole range. This means
1106 // the a calculation from just one side would be enough, but
1107 // doing it from both sides might still make the numerics
1108 // a bit more stable.
1109 }
1110 }
1111
1112 DrsCalibrateTime GetResult() const
1113 {
1114 DrsCalibrateTime rc(*this);
1115 rc.CalcResult();
1116 return rc;
1117 }
1118
1119 double Offset(uint32_t ch, double pos) const
1120 {
1121 const auto p = fStat.begin() + ch*1024;
1122
1123 const uint32_t f = floor(pos);
1124
1125 const double v0 = p[f].first;
1126 const double v1 = p[(f+1)%1024].first;
1127
1128 return v0 + fmod(pos, 1)*(v1-v0);
1129 }
1130
1131 double Calib(uint32_t ch, double pos) const
1132 {
1133 return pos-Offset(ch, pos);
1134 }
1135};
1136
1137struct DrsCalibration
1138{
1139 std::vector<int32_t> fOffset;
1140 std::vector<int64_t> fGain;
1141 std::vector<int64_t> fTrgOff;
1142
1143 uint64_t fNumOffset;
1144 uint64_t fNumGain;
1145 uint64_t fNumTrgOff;
1146
1147 uint32_t fStep;
1148 uint16_t fRoi; // Region of interest for trgoff
1149 uint16_t fNumTm; // Number of time marker channels in trgoff
1150
1151 std::string fDateObs;
1152 std::string fDateRunBeg[3];
1153 std::string fDateRunEnd[3];
1154 std::string fDateEnd;
1155
1156// uint16_t fDAC[8];
1157
1158 DrsCalibration() :
1159 fOffset(1440*1024, 0),
1160 fGain(1440*1024, 4096),
1161 fTrgOff (1600*1024, 0),
1162 fNumOffset(1),
1163 fNumGain(2000),
1164 fNumTrgOff(1),
1165 fStep(0),
1166 fDateObs("1970-01-01T00:00:00"),
1167 fDateEnd("1970-01-01T00:00:00")
1168 {
1169 for (int i=0; i<3; i++)
1170 {
1171 fDateRunBeg[i] = "1970-01-01T00:00:00";
1172 fDateRunEnd[i] = "1970-01-01T00:00:00";
1173 }
1174 }
1175
1176 DrsCalibration(const DrsCalibration &cpy) :
1177 fOffset(cpy.fOffset),
1178 fGain(cpy.fGain),
1179 fTrgOff(cpy.fTrgOff),
1180 fNumOffset(cpy.fNumOffset),
1181 fNumGain(cpy.fNumGain),
1182 fNumTrgOff(cpy.fNumTrgOff),
1183 fStep(cpy.fStep),
1184 fRoi(cpy.fRoi),
1185 fNumTm(cpy.fNumTm),
1186 fDateObs(cpy.fDateObs),
1187 fDateRunBeg(cpy.fDateRunBeg),
1188 fDateRunEnd(cpy.fDateRunEnd),
1189 fDateEnd(cpy.fDateEnd)
1190 {
1191 }
1192
1193 void Clear()
1194 {
1195 // Default gain:
1196 // 0.575*[45590]*2.5V / 2^16 = 0.99999 V
1197 fOffset.assign(1440*1024, 0);
1198 fGain.assign (1440*1024, 4096);
1199 fTrgOff.assign(1600*1024, 0);
1200
1201 fNumOffset = 1;
1202 fNumGain = 2000;
1203 fNumTrgOff = 1;
1204
1205 fStep = 0;
1206
1207 fDateObs = "1970-01-01T00:00:00";
1208 fDateEnd = "1970-01-01T00:00:00";
1209
1210 for (int i=0; i<3; i++)
1211 {
1212 fDateRunBeg[i] = "1970-01-01T00:00:00";
1213 fDateRunEnd[i] = "1970-01-01T00:00:00";
1214 }
1215 }
1216
1217 std::string ReadFitsImp(const std::string &str, std::vector<float> &vec)
1218 {
1219#ifndef __MARS__
1220 std::fits file(str);
1221#else
1222 fits file(str);
1223#endif
1224 if (!file)
1225 {
1226 std::ostringstream msg;
1227 msg << "Could not open file '" << str << "': " << strerror(errno);
1228 return msg.str();
1229 }
1230
1231 if (file.GetStr("TELESCOP")!="FACT")
1232 {
1233 std::ostringstream msg;
1234 msg << "Reading '" << str << "' failed: Not a valid FACT file (TELESCOP not FACT in header)";
1235 return msg.str();
1236 }
1237
1238 if (!file.HasKey("STEP"))
1239 {
1240 std::ostringstream msg;
1241 msg << "Reading '" << str << "' failed: Is not a DRS calib file (STEP not found in header)";
1242 return msg.str();
1243 }
1244
1245 if (file.GetNumRows()!=1)
1246 {
1247 std::ostringstream msg;
1248 msg << "Reading '" << str << "' failed: Number of rows in table is not 1.";
1249 return msg.str();
1250 }
1251
1252 fStep = file.GetUInt("STEP");
1253 fNumOffset = file.GetUInt("NBOFFSET");
1254 fNumGain = file.GetUInt("NBGAIN");
1255 fNumTrgOff = file.GetUInt("NBTRGOFF");
1256 fRoi = file.GetUInt("NROI");
1257 fNumTm = file.HasKey("NTM") ? file.GetUInt("NTM") : 0;
1258
1259 if (file.HasKey("DATE-OBS"))
1260 fDateObs = file.GetStr("DATE-OBS");
1261 if (file.HasKey("DATE-END"))
1262 fDateEnd = file.GetStr("DATE-END");
1263
1264 if (file.HasKey("RUN0-BEG"))
1265 fDateRunBeg[0]= file.GetStr("RUN0-BEG");
1266 if (file.HasKey("RUN1-BEG"))
1267 fDateRunBeg[1]= file.GetStr("RUN1-BEG");
1268 if (file.HasKey("RUN2-BEG"))
1269 fDateRunBeg[2]= file.GetStr("RUN2-BEG");
1270 if (file.HasKey("RUN0-END"))
1271 fDateRunEnd[0]= file.GetStr("RUN0-END");
1272 if (file.HasKey("RUN1-END"))
1273 fDateRunEnd[1]= file.GetStr("RUN1-END");
1274 if (file.HasKey("RUN2-END"))
1275 fDateRunEnd[2]= file.GetStr("RUN2-END");
1276/*
1277 fDAC[0] = file.GetUInt("DAC_A");
1278 fDAC[1] = file.GetUInt("DAC_B");
1279 fDAC[4] = file.GetUInt("DAC_C");
1280*/
1281 vec.resize(1440*1024*4 + (1440+fNumTm)*fRoi*2 + 4);
1282
1283 float *base = vec.data();
1284
1285 reinterpret_cast<uint32_t*>(base)[0] = fRoi;
1286
1287 file.SetPtrAddress("RunNumberBaseline", base+1, 1);
1288 file.SetPtrAddress("RunNumberGain", base+2, 1);
1289 file.SetPtrAddress("RunNumberTriggerOffset", base+3, 1);
1290 file.SetPtrAddress("BaselineMean", base+4+0*1024*1440, 1024*1440);
1291 file.SetPtrAddress("BaselineRms", base+4+1*1024*1440, 1024*1440);
1292 file.SetPtrAddress("GainMean", base+4+2*1024*1440, 1024*1440);
1293 file.SetPtrAddress("GainRms", base+4+3*1024*1440, 1024*1440);
1294 file.SetPtrAddress("TriggerOffsetMean", base+4+4*1024*1440, fRoi*1440);
1295 file.SetPtrAddress("TriggerOffsetRms", base+4+4*1024*1440+fRoi*1440, fRoi*1440);
1296 if (fNumTm>0)
1297 {
1298 file.SetPtrAddress("TriggerOffsetTMMean", base+4+4*1024*1440+ 2*fRoi*1440, fRoi*fNumTm);
1299 file.SetPtrAddress("TriggerOffsetTMRms", base+4+4*1024*1440+ 2*fRoi*1440+ fRoi*fNumTm, fRoi*fNumTm);
1300 }
1301
1302 if (!file.GetNextRow())
1303 {
1304 std::ostringstream msg;
1305 msg << "Reading data from " << str << " failed.";
1306 return msg.str();
1307 }
1308/*
1309 fDAC[2] = fDAC[1];
1310 fDAC[4] = fDAC[1];
1311
1312 fDAC[5] = fDAC[4];
1313 fDAC[6] = fDAC[4];
1314 fDAC[7] = fDAC[4];
1315*/
1316 fOffset.resize(1024*1440);
1317 fGain.resize(1024*1440);
1318
1319 fTrgOff.resize(fRoi*(1440+fNumTm));
1320
1321 // Convert back to ADC counts: 256/125 = 4096/2000
1322 // Convert back to sum (mean * num_entries)
1323 for (int i=0; i<1024*1440; i++)
1324 {
1325 fOffset[i] = fNumOffset *256*base[i+1024*1440*0+4]/125;
1326 fGain[i] = fNumOffset*fNumGain*256*base[i+1024*1440*2+4]/125;
1327 }
1328
1329 for (int i=0; i<fRoi*1440; i++)
1330 fTrgOff[i] = fNumOffset*fNumTrgOff*256*base[i+1024*1440*4+4]/125;
1331
1332 for (int i=0; i<fRoi*fNumTm; i++)
1333 fTrgOff[i+1440*fRoi] = fNumOffset*fNumTrgOff*256*base[i+1024*1440*4+2*fRoi*1440+4]/125;
1334
1335
1336 // DAC: 0..2.5V == 0..65535
1337 // V-mV: 1000
1338 //fNumGain *= 2500*50000;
1339 //for (int i=0; i<1024*1440; i++)
1340 // fGain[i] *= 65536;
1341 if (fStep==0)
1342 {
1343 for (int i=0; i<1024*1440; i++)
1344 fGain[i] = fNumOffset*4096;
1345 }
1346 else
1347 {
1348 fNumGain *= 1953125;
1349 for (int i=0; i<1024*1440; i++)
1350 fGain[i] *= 1024;
1351 }
1352
1353 // Now mark the stored DRS data as "officially valid"
1354 // However, this is not thread safe. It only ensures that
1355 // this data is not used before it is completely and correctly
1356 // read.
1357 fStep++;
1358
1359 return std::string();
1360 }
1361
1362 std::string WriteFitsImp(const std::string &filename, const std::vector<float> &vec) const
1363 {
1364 const size_t n = 1440*1024*4 + 1440*fRoi*2 + fNumTm*fRoi*2 + 3;
1365
1366#ifndef __MARS__
1367 std::ofits file(filename.c_str());
1368#else
1369 ofits file(filename.c_str());
1370#endif
1371 if (!file)
1372 {
1373 std::ostringstream msg;
1374 msg << "Could not open file '" << filename << "': " << strerror(errno);
1375 return msg.str();
1376 }
1377
1378 file.AddColumnInt("RunNumberBaseline");
1379 file.AddColumnInt("RunNumberGain");
1380 file.AddColumnInt("RunNumberTriggerOffset");
1381
1382 file.AddColumnFloat(1024*1440, "BaselineMean", "mV");
1383 file.AddColumnFloat(1024*1440, "BaselineRms", "mV");
1384 file.AddColumnFloat(1024*1440, "GainMean", "mV");
1385 file.AddColumnFloat(1024*1440, "GainRms", "mV");
1386 file.AddColumnFloat(fRoi*1440, "TriggerOffsetMean", "mV");
1387 file.AddColumnFloat(fRoi*1440, "TriggerOffsetRms", "mV");
1388 file.AddColumnFloat(fRoi*fNumTm, "TriggerOffsetTMMean", "mV");
1389 file.AddColumnFloat(fRoi*fNumTm, "TriggerOffsetTMRms", "mV");
1390
1391#ifdef __MARS__
1392 const MTime now(-1);
1393 file.SetStr( "TELESCOP", "FACT", "Telescope that acquired this data");
1394 file.SetStr( "PACKAGE", "MARS", "Package name");
1395 file.SetStr( "VERSION", "1.0", "Package description");
1396 //file.SetStr( "CREATOR", "root", "Program that wrote this file");
1397 file.SetFloat("EXTREL", 1.0, "Release Number");
1398 file.SetStr( "COMPILED", __DATE__" "__TIME__, "Compile time");
1399 //file.SetStr( "REVISION", REVISION, "SVN revision");
1400 file.SetStr( "ORIGIN", "FACT", "Institution that wrote the file");
1401 file.SetStr( "DATE", now.GetStringFmt("%Y-%m-%dT%H:%M:%S").Data(), "File creation date");
1402 file.SetInt( "NIGHT", now.GetNightAsInt(), "Night as int");
1403 file.SetStr( "TIMESYS", "UTC", "Time system");
1404 file.SetStr( "TIMEUNIT", "d", "Time given in days w.r.t. to MJDREF");
1405 file.SetInt( "MJDREF", 40587, "MJD to UNIX time (seconds since 1970/1/1)");
1406#else
1407 DataWriteFits2::WriteDefaultKeys(file);
1408#endif
1409 file.SetStr("DATE-OBS", fDateObs, "First event of whole DRS calibration");
1410 file.SetStr("DATE-END", fDateEnd, "Last event of whole DRS calibration");
1411 file.SetStr("RUN0-BEG", fDateRunBeg[0], "First event of run 0");
1412 file.SetStr("RUN1-BEG", fDateRunBeg[1], "First event of run 1");
1413 file.SetStr("RUN2-BEG", fDateRunBeg[2], "First event of run 2");
1414 file.SetStr("RUN0-END", fDateRunEnd[0], "Last event of run 0");
1415 file.SetStr("RUN1-END", fDateRunEnd[1], "Last event of run 1");
1416 file.SetStr("RUN2-END", fDateRunEnd[2], "Last event of run 2");
1417
1418 file.SetInt("STEP", fStep, "");
1419
1420 file.SetInt("ADCRANGE", 2000, "Dynamic range of the ADC in mV");
1421 file.SetInt("DACRANGE", 2500, "Dynamic range of the DAC in mV");
1422 file.SetInt("ADC", 12, "Resolution of ADC in bits");
1423 file.SetInt("DAC", 16, "Resolution of DAC in bits");
1424 file.SetInt("NPIX", 1440, "Number of channels in the camera");
1425 file.SetInt("NTM", fNumTm, "Number of time marker channels");
1426 file.SetInt("NROI", fRoi, "Region of interest");
1427
1428 file.SetInt("NBOFFSET", fNumOffset, "Num of entries for offset calibration");
1429 file.SetInt("NBGAIN", fNumGain/1953125, "Num of entries for gain calibration");
1430 file.SetInt("NBTRGOFF", fNumTrgOff, "Num of entries for trigger offset calibration");
1431
1432 // file.WriteKeyNT("DAC_A", fData.fDAC[0], "Level of DAC 0 in DAC counts") ||
1433 // file.WriteKeyNT("DAC_B", fData.fDAC[1], "Leval of DAC 1-3 in DAC counts") ||
1434 // file.WriteKeyNT("DAC_C", fData.fDAC[4], "Leval of DAC 4-7 in DAC counts") ||
1435
1436 file.WriteTableHeader("DrsCalibration");
1437
1438 if (!file.WriteRow(vec.data()+1, n*sizeof(float)))
1439 {
1440 std::ostringstream msg;
1441 msg << "Writing data to " << filename << " failed.";
1442 return msg.str();
1443 }
1444
1445 return std::string();
1446 }
1447
1448
1449 std::string ReadFitsImp(const std::string &str)
1450 {
1451 std::vector<float> vec;
1452 return ReadFitsImp(str, vec);
1453 }
1454
1455 bool IsValid() { return fStep>2; }
1456
1457 bool Apply(float *vec, const int16_t *val, const int16_t *start, uint32_t roi)
1458 {
1459 if (roi!=fRoi)
1460 {
1461 for (size_t ch=0; ch<1440; ch++)
1462 {
1463 const size_t pos = ch*roi;
1464 const size_t drs = ch*1024;
1465
1466 DrsCalibrate::ApplyCh(vec+pos, val+pos, start[ch], roi,
1467 fOffset.data()+drs, fNumOffset,
1468 fGain.data() +drs, fNumGain);
1469 }
1470
1471 return false;
1472 }
1473
1474 for (size_t ch=0; ch<1440; ch++)
1475 {
1476 const size_t pos = ch*fRoi;
1477 const size_t drs = ch*1024;
1478
1479 DrsCalibrate::ApplyCh(vec+pos, val+pos, start[ch], roi,
1480 fOffset.data()+drs, fNumOffset,
1481 fGain.data() +drs, fNumGain,
1482 fTrgOff.data()+pos, fNumTrgOff);
1483 }
1484
1485 for (size_t ch=0; ch<fNumTm; ch++)
1486 {
1487 const size_t pos = (ch+1440)*fRoi;
1488 const size_t drs = (ch*9+8)*1024;
1489
1490 DrsCalibrate::ApplyCh(vec+pos, val+pos, start[ch], roi,
1491 fOffset.data()+drs, fNumOffset,
1492 fGain.data() +drs, fNumGain,
1493 fTrgOff.data()+pos, fNumTrgOff);
1494 }
1495
1496 return true;
1497 }
1498};
1499
1500#endif
Note: See TracBrowser for help on using the repository browser.