Index: /trunk/FACT++/src/EventBuilder.c
===================================================================
--- /trunk/FACT++/src/EventBuilder.c	(revision 11180)
+++ /trunk/FACT++/src/EventBuilder.c	(revision 11181)
@@ -48,5 +48,5 @@
 extern void debugHead(int i, void *buf); 
 
-extern void debugRead(int isock, int ibyte, int32_t event, int state, 
+extern void debugRead(int isock, int ibyte, int32_t event,int32_t ftmevt, int32_t runnr, int state, 
                       uint32_t tsec, uint32_t tusec ) ;
 extern void debugStream(int isock, void *buf, int len) ;
@@ -129,5 +129,6 @@
   int  evtID  ;          // event ID of event currently read
   int  runID  ;          // run       "
-  uint  fadLen ;          // FADlength of event currently read
+  int  ftmID  ;          // event ID from FTM
+  uint  fadLen ;         // FADlength of event currently read
   int  fadVers ;         // Version of FAD
   int  board ;           // boardID (softwareID: 0..40 )
@@ -612,5 +613,5 @@
              rd[i].bufPos += jrd ;        //==> prepare for continuation
              rd[i].bufLen -= jrd ;
-             debugRead(i,jrd,rd[i].evtID, 0,tsec,tusec) ; // i=socket; jrd=#bytes; ievt=eventid; 0=reading data
+             debugRead(i,jrd,rd[i].evtID,rd[i].ftmID,rd[i].runID, 0,tsec,tusec) ; // i=socket; jrd=#bytes; ievt=eventid; 0=reading data
            } else {                     //full dataset read
              rd[i].bufLen  = 0 ;
@@ -624,5 +625,5 @@
 
              } 
-             debugRead(i,jrd,rd[i].evtID, 1,tsec,tusec) ; // i=socket; jrd=#bytes; ievt=eventid; 1=finished event
+             debugRead(i,jrd,rd[i].evtID,rd[i].ftmID,rd[i].runID, 1,tsec,tusec) ; // i=socket; jrd=#bytes; ievt=eventid; 1=finished event
 
              //we have a complete buffer, copy to WORK area
@@ -760,4 +761,5 @@
                  rd[i].fadVers= ntohs(rd[i].rBuf->S[2]) ;
                  rd[i].evtID  = ntohl(rd[i].rBuf->I[4]) ; //(FADevt)
+                 rd[i].ftmID  = ntohl(rd[i].rBuf->I[5]) ; //(FTMevt)
                  rd[i].runID  = ntohl(rd[i].rBuf->I[11]) ;
                  if (rd[i].runID ==0 ) rd[i].runID = myRun ;
@@ -766,10 +768,10 @@
                  if (rd[i].bufLen <=0 ) rd[i].bufLen = 100000 ;    //?
                  debugHead(i,rd[i].rBuf); 
-                 debugRead(i,jrd,rd[i].evtID,-1,tsec,tusec) ; // i=socket; jrd=#bytes; ievt=eventid;-1=start event
+                 debugRead(i,jrd,rd[i].evtID,rd[i].ftmID,rd[i].runID,-1,tsec,tusec) ; // i=socket; jrd=#bytes; ievt=eventid;-1=start event
               } else {
-                 debugRead(i,jrd,0,-2,tsec,tusec) ; // i=socket; jrd=#bytes; ievt=eventid; -2=start event, unknown id yet
+                 debugRead(i,jrd,0,0,0,-2,tsec,tusec) ; // i=socket; jrd=#bytes; ievt=eventid; -2=start event, unknown id yet
               }
            } else {
-              debugRead(i,jrd,0,-2,tsec,tusec) ; // i=socket; jrd=#bytes; ievt=eventid; -2=start event, unknown id yet
+              debugRead(i,jrd,0,0,0,-2,tsec,tusec) ; // i=socket; jrd=#bytes; ievt=eventid; -2=start event, unknown id yet
            }
 
@@ -1339,5 +1341,5 @@
 
 
-/*
+
      xwait.tv_sec = 20;;
      xwait.tv_nsec= 0 ;  // sleep for ~20sec
@@ -1357,5 +1359,5 @@
 
      g_runStat = -1 ;
-*/
+
 
 
@@ -1423,5 +1425,5 @@
 
 
-void debugRead(int isock, int ibyte, int32_t event, int state, uint32_t tsec, uint32_t tusec ) {
+void debugRead(int isock, int ibyte, int32_t event, int32_t ftmevt, int32_t runnr, int state, uint32_t tsec, uint32_t tusec ) {
 //  printf("%3d %5d %9d %3d %12d\n",isock, ibyte, event, state, tusec) ;
 }
Index: /trunk/FACT++/src/EventBuilderWrapper.h
===================================================================
--- /trunk/FACT++/src/EventBuilderWrapper.h	(revision 11180)
+++ /trunk/FACT++/src/EventBuilderWrapper.h	(revision 11181)
@@ -1075,5 +1075,5 @@
     ofstream fDumpRead; // Stream to possibly dump docket events
 
-    void debugRead(int isock, int ibyte, int32_t event, int state, uint32_t tsec, uint32_t tusec)
+    void debugRead(int isock, int ibyte, uint32_t event, uint32_t ftmevt, uint32_t runno, int state, uint32_t tsec, uint32_t tusec)
     {
         //   isock = socketID (0-279)
@@ -1103,4 +1103,7 @@
 
             fMsg.Message("Opened file 'socket_events.txt' for writing.");
+
+            fDumpRead << "# START: " << Time().GetAsStr() << endl;
+            fDumpRead << "# state time_sec time_usec socket slot runno event_id trigger_id bytes_received" << endl;
         }
 
@@ -1111,5 +1114,7 @@
             << setw(3) << isock   << " "
             << setw(2) << isock/7 << " "
-            << event << " "
+            << runno  << " "
+            << event  << " "
+            << ftmevt << " "
             << ibyte << endl;
     }
@@ -1358,5 +1363,8 @@
 
             if (gi_NumConnect[i/7]!=7)
+            {
+                vec[i+3] = -1;
                 continue;
+            }
 
             if (!val)
@@ -1407,5 +1415,8 @@
 
             if (gi_NumConnect[i/7]!=7)
+            {
+                vec[i+2] = 0;
                 continue;
+            }
 
             if (first)
@@ -1413,5 +1424,5 @@
                 first = false;
                 val = *ref;
-                rc = ~0;
+                rc = 0;
             }
 
@@ -1419,5 +1430,5 @@
         }
 
-        vec[0] = rc;
+        vec[0] = ~rc;
         vec[1] = val;
 
@@ -1552,7 +1563,7 @@
     }
 
-    void debugRead(int isock, int ibyte, int32_t event, int state, uint32_t tsec, uint32_t tusec)
-    {
-        return EventBuilderWrapper::This->debugRead(isock, ibyte, event, state, tsec, tusec);
+    void debugRead(int isock, int ibyte, int32_t event, int32_t ftmevt, int32_t runno, int state, uint32_t tsec, uint32_t tusec)
+    {
+        return EventBuilderWrapper::This->debugRead(isock, ibyte, event, ftmevt, runno, state, tsec, tusec);
     }
 
