class CalibData { protected: uint64_t fNumEntries; size_t fNumSamples; size_t fNumChannels; vector fSum; vector fSum2; /* vector > fMedian; vector fResult; */ public: CalibData() : fNumEntries(0), fNumSamples(0), fNumChannels(0) { } void Reset() { fNumEntries = 0; fNumSamples = 0; fNumChannels = 0; fSum.clear(); fSum2.clear(); } void InitSize(uint16_t channels, uint16_t samples) { fNumChannels = channels; fNumSamples = samples; fSum.resize(samples*channels); fSum2.resize(samples*channels); //fMedian.resize(40*9*1024); } /* continue; if (ch<40*9) { fMedian[abs][val[rel]]++; int n= 8; if (fNumEntries>0 && fNumEntries%(n*100)==0) { fResult.resize(40*9*1024); uint16_t sum = 0; for (map::const_iterator it=fMedian[abs].begin(); it!=fMedian[abs].end(); it++) { map::const_iterator is = it; is++; if (is==fMedian[abs].end()) break; sum += it->second; double med = 0; med += int64_t(it->second)*int64_t(it->first); med += int64_t(is->second)*int64_t(is->first); med /= int64_t(it->second)+int64_t(is->second); if (sum==n*50) { fResult[abs] = it->first; cout << ch << " MED+(50): " << it->first << endl; } if (sumsecond>n*50) { fResult[abs] = med; cout << ch << " MED-(50): " << med << endl; } } cout << ch << " AVG=" << float(fSum[abs])/fNumEntries << endl; fMedian[abs].clear(); } } // -2029 -2012 -2003 -1996 -1990 // -1955 */ void AddRel(const int16_t *val, const int16_t *start) { for (size_t ch=0; ch,vector > GetSampleStats() const { if (fNumEntries==0) return make_pair(vector(),vector()); vector mean(fSum.size()); vector error(fSum.size()); vector::const_iterator it = fSum.begin(); vector::const_iterator i2 = fSum2.begin(); vector::iterator im = mean.begin(); vector::iterator ie = error.begin(); while (it!=fSum.end()) { *im = /*cnt ... mean /= fNumEntries; error = sqrt(error/fNumEntries - mean*mean); */ return make_pair(mean, error); } void GetSampleStats(float *ptr, float scale) const { if (fNumEntries==0) { memset(ptr, 0, sizeof(float)*1024*1440); return; } vector::const_iterator it = fSum.begin(); vector::const_iterator i2 = fSum2.begin(); while (it!=fSum.end()) { *ptr = scale*double(*it)/fNumEntries; *(ptr+1024*1440) = scale*sqrt(double(*i2*int64_t(fNumEntries) - *it * *it))/fNumEntries; ptr++; it++; i2++; } } const vector &GetSum() const { return fSum; } uint64_t GetNumEntries() const { return fNumEntries; } }; /* Int_t TH1::MyFill(Int_t x, Double_t w) { fEntries++; fArrayBin[x] += w; fSumw2.fArray[x] += w*w fTsumw += w; fTsumw2 += w*w; fTsumwx += w*x; fTsumwx2 += w*x*x; return bin; } */