Index: trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 1761)
+++ trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 1809)
@@ -122,4 +122,5 @@
 {
     const char *name = gSystem->ExpandPathName(txt);
+
     TString fname(name);
     delete [] name;
@@ -336,6 +337,15 @@
     // float   frms_pedsig_phot[iMAXNUMPIX];      // standard deviation of the calibrated signals from the pedestal run */
     fPedest->InitSize(iMAXNUMPIX);
+    *fLog << "PedestalRMS : ";
     for (Int_t i=0; i<iMAXNUMPIX; i++)
+    {
         (*fPedest)[i].SetMeanRms(outpars.frms_pedsig_phot[i]);
+        *fLog << outpars.frms_pedsig_phot[i] << " "; 
+ 
+        //$$$$$$$$$$$$$$$$$$$$$$$$$
+        savePedRMS[i] =  outpars.frms_pedsig_phot[i];
+        //$$$$$$$$$$$$$$$$$$$$$$$$$
+    }
+    *fLog << endl;
 
     fPedest->SetReadyToSave();
@@ -373,10 +383,24 @@
      *         be treated further. */
 
+    *fLog << "outpars.bmontecarlo = " << outpars.bmontecarlo << endl;
+    *fLog << "outpars.imcparticle = " << outpars.imcparticle << endl;
+    *fLog << "outpars.dsourcera_hours = " << outpars.dsourcera_hours << endl;
+    *fLog << "outpars.dsourcedec_deg = " << outpars.dsourcedec_deg << endl;
+
+    //*fLog << "File is a ";
+    //*fLog << (outpars.bmontecarlo ? "Monte Carlo" : "Real Data");
+    //*fLog << " file." << endl;
+
+
+    // Next statement commented out because bmontecarlo was set wrongly
+    //fIsMcFile = outpars.bmontecarlo==TRUE;
+    fIsMcFile = (outpars.dsourcera_hours == 0.0 &&
+                 outpars.dsourcedec_deg  == 0.0 &&
+                 outpars.imcparticle != 0          );
+
     *fLog << "File is a ";
-    *fLog << (outpars.bmontecarlo ? "Monte Carlo" : "Real Data");
+    *fLog << (fIsMcFile ? "Monte Carlo" : "Real Data");
     *fLog << " file." << endl;
-
-    fIsMcFile = outpars.bmontecarlo==TRUE;
-
+    *fLog << " " << endl;
 }
 
@@ -433,6 +457,8 @@
     ProcessRunHeader(outpars);
 
+
     //rwagner: ReInit whenever new run commences
     // rc==-1 means: ReInit didn't work out
+
     if (!fTaskList->ReInit(fParList))
         return -1;
@@ -453,4 +479,5 @@
     TString m = cEND_EVENTS_TEMPLATE;
     Int_t p = m.First('%');
+
 
     if (!s.BeginsWith(m(0,p)))
@@ -515,5 +542,5 @@
 
     //
-    // Check for the existance of a next file to read
+    // Check for the existence of a next file to read
     //
     TNamed *file = (TNamed*)fFileNames->First();
@@ -538,9 +565,13 @@
 
     if (!CheckHeader(fname))
-        return kFALSE;
+    {
+        *fLog << "OpenNextFile : CheckHeader(fname) is FALSE" << endl;
+        return kFALSE;
+    }
 
     fIn = new ifstream(fname);
 
     *fLog << inf << "-----------------------------------------------------------------------" << endl;
+
 
     switch (ReadRunHeader())
@@ -553,6 +584,11 @@
 	return kFALSE;
       default:
+        *fLog << "OpenNextFile : after ReadRunHeader, FnumEventsInRun = " 
+              << fNumEventsInRun << endl;
         return kTRUE;
       }
+
+
+
 }
 
@@ -752,4 +788,32 @@
 void MCT1ReadPreProc::ProcessEvent(const struct eventrecord &event)
 {
+  if (fRawRunHeader->GetRunNumber() == 1)
+  {
+  *fLog << "eventrecord" << endl;
+  *fLog << "isecs_since_midday = " << event.isecs_since_midday << endl;
+  *fLog << "isecfrac_200ns     = " << event.isecfrac_200ns << endl;
+  *fLog << "snot_ok_flags      = " << event.snot_ok_flags << endl;
+  *fLog << "ialt_arcs          = " << event.ialt_arcs << endl;
+  *fLog << "iaz_arcs           = " << event.iaz_arcs << endl;
+  *fLog << "ipreproc_alt_arcs  = " << event.ipreproc_alt_arcs << endl;
+  *fLog << "ipreproc_az_arcs   = " << event.ipreproc_az_arcs << endl;
+  *fLog << "ifieldrot_arcs     = " << event.ifieldrot_arcs << endl;
+
+  *fLog << "srate_millihz      = " << event.srate_millihz << endl;
+  *fLog << "fhourangle         = " << event.fhourangle << endl;
+  *fLog << "fmcenergy_tev      = " << event.fmcenergy_tev << endl;
+  *fLog << "fmcsize_phel       = " << event.fmcsize_phel << endl;
+  *fLog << "imcimpact_m        = " << event.imcimpact_m << endl;
+  *fLog << "imcparticle        = " << event.imcparticle << endl;
+  *fLog << "imctriggerflag     = " << event.imctriggerflag << endl;
+  }  
+
+
+    for (Int_t i=0; i<iMAXNUMPIX; i++)
+    {
+        (*fPedest)[i].SetMeanRms(savePedRMS[i]);
+    }
+
+
     //  int   isecs_since_midday; // seconds passed since midday before sunset (JD of run start)
     //  int   isecfrac_200ns;     // fractional part of isecs_since_midday
@@ -788,6 +852,9 @@
     // actual number of pixels (outputpars.inumpixels) is written out
     // short spixsig_10thphot[iMAXNUMPIX];
+    //*fLog << "spixsig_10thphot : " << endl;
     for (Int_t i=0; i<iMAXNUMPIX; i++)
     {
+      //*fLog << event.spixsig_10thphot[i] << " ";
+
         if (event.spixsig_10thphot[i]==0)
             continue;
@@ -796,4 +863,6 @@
                          (*fPedest)[i].GetMeanRms());
     }
+    //*fLog << "" << endl;
+
     fNphot->SetReadyToSave();
 
@@ -801,5 +870,5 @@
     // int ipreproc_az_arcs;  // "should be" az according to preproc (arcseconds)
 
-    fMcEvt->Fill(0, /*fEvtNum*/
+    fMcEvt->Fill(event.isecs_since_midday,     //0, /*fEvtNum*/
                  fIsMcFile ? event.imcparticle : 0, /*corsika particle type*/
                  fIsMcFile ? event.fmcenergy_tev*1000 : 0,
@@ -867,5 +936,11 @@
         // an event
         //
-        if (fIn->peek()!=cEND_EVENTS_TEMPLATE[0])
+
+      // "goto TONI" was introduced in order to check for a footer record
+      // after reading a run header; this is necessary for runs with
+      // zero events after the filter
+      TONI:
+
+      if (fIn->peek()!=cEND_EVENTS_TEMPLATE[0])
             return kTRUE;
 
@@ -874,4 +949,5 @@
         // must be an event
         //
+
         switch (ReadRunFooter())
         {
@@ -906,4 +982,5 @@
         *fLog << "-----------------------------------------------------------------------" << endl;
 
+
         if (ReadRunHeader() < 0)
         {
@@ -911,4 +988,7 @@
             return kFALSE;
         }
+
+	goto TONI;
+
         return kTRUE;
     }
Index: trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 1761)
+++ trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 1809)
@@ -48,4 +48,7 @@
     UInt_t fNumFilterEvts;  // number of events mentioned in the runs footers
 
+    Float_t savePedRMS[127];
+
+
     Bool_t OpenNextFile();
 
