Ignore:
Timestamp:
11/11/11 00:47:33 (13 years ago)
Author:
tbretz
Message:
Preliminary version of a time calibration algorithm
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mcore/DrsCalib.h

    r12479 r12487  
    149149                fSum[rel]  += v;
    150150                fSum2[rel] += v*v;
     151            }
     152        }
     153
     154        fNumEntries++;
     155    }
     156
     157    void AddT(const int16_t *val, const int16_t *start)
     158    {
     159        // 1440 without tm, 1600 with tm
     160        for (size_t ch=0; ch<fNumChannels; ch++)
     161        {
     162            const int16_t spos = start[ch];
     163            if (spos<0)
     164                continue;
     165
     166            const size_t pos = ch*fNumSamples;
     167
     168            uint32_t nperiods = 0;
     169
     170            for (size_t i=0; i<fNumSamples; i++)
     171            {
     172                const size_t abs0 = pos + (spos+i  )%1024;
     173                const size_t abs1 = pos + (spos+i+1)%1024;
     174
     175                const float &v0 = val[abs0];
     176                const float &v1 = val[abs1];
     177
     178                // Has sign changed?
     179                if (v0*v1>0)
     180                {
     181                    // Sign has not changed
     182                    fSum[abs]  += nperiods;
     183                    fSum2[abs] += nperiods*nperiods;
     184                    continue;
     185                }
     186
     187                const double p = v0==v1 ? 1 : v0/(v0-v1);
     188
     189                const double val = nperiods*p + (nperiods+1)*(1-p);
     190
     191                fSum[abs]  += val;
     192                fSum2[abs] += val;
     193
     194                nperiods++;
    151195            }
    152196        }
Note: See TracChangeset for help on using the changeset viewer.