Index: /trunk/FACT++/src/DataCalib.cc
===================================================================
--- /trunk/FACT++/src/DataCalib.cc	(revision 11731)
+++ /trunk/FACT++/src/DataCalib.cc	(revision 11732)
@@ -7,5 +7,6 @@
 using namespace std;
 
-int DataCalib::fStep = 0;
+int  DataCalib::fStep = 0;
+bool DataCalib::fProcessing = false;
 
 vector<int32_t> DataCalib::fOffset(1440*1024, 0);
@@ -43,4 +44,5 @@
 
     fStep = 0;
+    fProcessing = false;
 }
 
@@ -52,4 +54,22 @@
 bool DataCalib::Open(RUN_HEAD* h)
 {
+    if (h->NPix != 1440)
+    {
+        fMsg.Error("Number of pixels in header not 1440.");
+        return false;
+    }
+
+    if (h->Nroi != 1024)
+    {
+        fMsg.Error("Region of interest not 1024.");
+        return false;
+    }
+
+    if (fProcessing)
+    {
+        fMsg.Warn("Previous run not yet finished!");
+        return false;
+    }
+
     if (fStep==4)
     {
@@ -58,15 +78,5 @@
     }
 
-    if (h->NPix != 1440)
-    {
-        fMsg.Error("Number of pixels in header not 1440.");
-        return false;
-    }
-
-    if (h->Nroi != 1024)
-    {
-        fMsg.Error("Region of interest not 1024.");
-        return false;
-    }
+    fProcessing = true;
 
     ostringstream name;
@@ -76,6 +86,4 @@
     Reset();
     InitSize(1440, 1024);
-
-    fFileName = FormFileName(GetRunId(), "drs.fits");
 
     return true;
@@ -117,4 +125,6 @@
     file.AddColumn('F', "TriggerOffsetRms", 1024*1440);
 
+    fFileName = FormFileName(GetRunId(), "drs.fits");
+
     if (!file.OpenFile(fFileName))
         return;
@@ -148,4 +158,8 @@
     if (!file.WriteData(buf.data(), 1024*1440*sizeof(float)*6+3))
         return;
+
+    ostringstream str;
+    str << "Wrote DRS calibration data (step=" << fStep << ") to '" << fFileName << "'";
+    Info(str.str());
 #endif
 }
@@ -190,7 +204,7 @@
         WriteFits();
 
+    fProcessing = false;
+
     fDim.Update(fStats);
-
-    fStep++;
 
     return true;
