Index: trunk/Mars/mcore/DrsCalib.h
===================================================================
--- trunk/Mars/mcore/DrsCalib.h	(revision 12485)
+++ trunk/Mars/mcore/DrsCalib.h	(revision 12487)
@@ -149,4 +149,48 @@
                 fSum[rel]  += v;
                 fSum2[rel] += v*v;
+            }
+        }
+
+        fNumEntries++;
+    }
+
+    void AddT(const int16_t *val, const int16_t *start)
+    {
+        // 1440 without tm, 1600 with tm
+        for (size_t ch=0; ch<fNumChannels; ch++)
+        {
+            const int16_t spos = start[ch];
+            if (spos<0)
+                continue;
+
+            const size_t pos = ch*fNumSamples;
+
+            uint32_t nperiods = 0;
+
+            for (size_t i=0; i<fNumSamples; i++)
+            {
+                const size_t abs0 = pos + (spos+i  )%1024;
+                const size_t abs1 = pos + (spos+i+1)%1024;
+
+                const float &v0 = val[abs0];
+                const float &v1 = val[abs1];
+
+                // Has sign changed?
+                if (v0*v1>0)
+                {
+                    // Sign has not changed
+                    fSum[abs]  += nperiods;
+                    fSum2[abs] += nperiods*nperiods;
+                    continue;
+                }
+
+                const double p = v0==v1 ? 1 : v0/(v0-v1);
+
+                const double val = nperiods*p + (nperiods+1)*(1-p);
+
+                fSum[abs]  += val;
+                fSum2[abs] += val;
+
+                nperiods++;
             }
         }
