Project

General

Profile

diff.log

David Adams, 12/31/2019 04:02 PM

 
1
diff --git a/dam/source/cc/src/TpcTrimmedRange.hh b/dam/source/cc/src/TpcTrimmedRange.hh
2
index 462f3f6..5f7584c 100644
3
--- a/dam/source/cc/src/TpcTrimmedRange.hh
4
+++ b/dam/source/cc/src/TpcTrimmedRange.hh
5
@@ -50,6 +50,8 @@
6
 
7
 #include "TpcStream-Impl.hh"
8
 #include "TpcCompressed-Impl.hh"
9
+#include <string>
10
+#include <iostream>
11
 
12
 namespace pdd    {
13
 namespace access {
14
@@ -299,6 +301,7 @@ inline uint32_t TpcTrimmedRange::Location::
15
                         int                               nTotFrames,
16
                         bool                                   begin)
17
 {
18
+   std::string myname = "TpcTrimmedRange::Location::locate: ";
19
    auto pktNum = pdd::access::TpcRangesIndices::getPacket (pktIdx);
20
    auto pktOff = pdd::access::TpcRangesIndices::getOffset (pktIdx);
21
    int   wfOff = nframesPerPkt * pktNum + pktOff;
22
@@ -311,20 +314,21 @@ inline uint32_t TpcTrimmedRange::Location::
23
    // the calculation, which depends on the data not
24
    // having certain pathologies, on the RCE fails.
25
    // ------------------------------------------------
26
-   if (wfOff > nTotFrames)
27
+   if (wfOff >= nTotFrames)
28
    {
29
       // ------------
30
       // Try guessing
31
       // ------------
32
-      wfOff = (timestamp - firstTimestamp) / 25;
33
+      //  
34
+      int wfOffNew = (timestamp - firstTimestamp) / 25;
35
 
36
       // ---------------------------------------------
37
       // Hopeless if this occurs before the timestamp
38
       // of the first WIB frame in the untrimmed data.
39
       // This likely indicates a complete corruption.
40
       // ---------------------------------------------
41
-      if (wfOff < 0) 
42
-      {
43
+      if ( wfOffNew < 0 || wfOffNew >= nTotFrames ) {
44
+         std::cout << myname << "WARNING: Invalid frame index: " << wfOffNew << " >= " << nTotFrames << std::endl;
45
          m_wibOff = 0;
46
          m_pktNum = 0;
47
          m_pktOff = 0;
48
@@ -332,6 +336,10 @@ inline uint32_t TpcTrimmedRange::Location::
49
          return -1;
50
       }
51
 
52
+      std::cout << myname << "WARNING: Guess fixed invalid frame index: " << wfOff << " --> "
53
+                << wfOffNew << " / " << nTotFrames << std::endl;
54
+      wfOff = wfOffNew;
55
+
56
       pktNum = wfOff / nframesPerPkt;
57
       pktOff = wfOff % nframesPerPkt;
58
    }
59
@@ -359,7 +367,6 @@ inline uint32_t TpcTrimmedRange::Location::
60
       return 0;
61
    }
62
 
63
-
64
    // ----------------------------------------
65
    // Get the timestamp at the predicted point
66
    // ----------------------------------------