Index: trunk/MagicSoft/Mars/mreport/MReport.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReport.cc	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReport.cc	(revision 8955)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -55,4 +55,34 @@
 // --------------------------------------------------------------------------
 //
+// Copy fState and fTime
+//
+void MReport::Copy(TObject &obj) const
+{
+    MReport &rep = static_cast<MReport&>(obj);
+
+    rep.fState = fState;
+
+    if (rep.fTime && fTime)
+        *rep.fTime = *fTime;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check whether the given TString begins with the given tag. Remove
+// the tag from the string.
+//
+Bool_t MReport::CheckTag(TString &str, const char *tag) const
+{
+    if (!str.BeginsWith(tag))
+    {
+        *fLog << warn << "WARNING - '" << tag << "' tag not found." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, strlen(tag)); // Remove Tag
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
 // Interpretes the beginning of a line which starts like:
 //   status hour minute second millisec skip skip skip skip skip
@@ -63,17 +93,22 @@
 // SetupReading must be called successfully before.
 //
-Bool_t MReport::InterpreteHeader(TString &str)
+Bool_t MReport::InterpreteHeader(TString &str, Int_t ver)
 {
     int len, state;
     int yea, mon, day, hor, min, sec, ms;
 
-    int n = sscanf(str.Data(),
-                   fHasReportTime ?
-                   " %d %d %d %d %d %d %d %d %*d %*d %*d %*d %*d %*d %*d %*d %n" :
-                   " %d %d %d %d %d %d %d %d %n",
+    TString fmt(fHasReportTime ?
+                " %d %d %d %d %d %d %d %d %*d %*d %*d %*d %*d %*d %*d %*d %n" :
+                " %d %d %d %d %d %d %d %d %n");
+
+    // M1/M2 telescope number (FIXME: Readout, check?)
+    if (ver>=200805190)
+        fmt.Prepend(" %*c%*d");
+
+    int n = sscanf(str.Data(), fmt.Data(),
                    &state, &yea, &mon, &day, &hor, &min, &sec, &ms, &len);
     if (n!=8)
     {
-        *fLog << err << "ERROR - Cannot interprete Body of " << fIdentifier << " (n=" << n << ")" << endl;
+        *fLog << err << "ERROR - Cannot interprete header of " << fIdentifier << " (n=" << n << ")" << endl;
         return kFALSE;
     }
@@ -136,5 +171,5 @@
 {
     // Interprete header (time, status, etc) of report
-    if (!InterpreteHeader(str))
+    if (!InterpreteHeader(str, ver))
         return kFALSE;
 
Index: trunk/MagicSoft/Mars/mreport/MReport.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReport.h	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReport.h	(revision 8955)
@@ -19,5 +19,10 @@
 
     ULong_t Hash() const { return fIdentifier.Hash(); }
-    Bool_t InterpreteHeader(TString &str);
+    Bool_t InterpreteHeader(TString &str, Int_t ver);
+
+protected:
+    Bool_t CheckTag(TString &str, const char *tag) const;
+
+    void Copy(TObject &obj) const;
 
 public:
Index: trunk/MagicSoft/Mars/mreport/MReportCC.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportCC.cc	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReportCC.cc	(revision 8955)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -44,4 +44,6 @@
 
 #include "MParList.h"
+
+#include "MReportRec.h"
 
 #include "MCameraTH.h"
@@ -71,4 +73,13 @@
 Bool_t MReportCC::SetupReading(MParList &plist)
 {
+    fRecRep = (MReportRec*)plist.FindCreateObj("MReportRec");
+    if (!fRecRep)
+        return kFALSE;
+
+    fRecTime = (MTime*)plist.FindCreateObj("MTime", "MTimeRec");
+    if (!fRecTime)
+        return kFALSE;
+
+
     fTH = (MCameraTH*)plist.FindCreateObj("MCameraTH");
     if (!fTH)
@@ -83,23 +94,7 @@
         return kFALSE;
 
+
     return MReport::SetupReading(plist);
 }
-
-// --------------------------------------------------------------------------
-//
-// Check whether the given TString begins with the given tag. Remove
-// the tag from the string.
-//
-Bool_t MReportCC::CheckTag(TString &str, const char *tag) const
-{
-    if (!str.BeginsWith(tag))
-    {
-        *fLog << warn << "WARNING - '" << tag << "' tag not found." << endl;
-        return kFALSE;
-    }
-    str.Remove(0, strlen(tag)); // Remove Tag
-    return kTRUE;
-}
-
 
 // --------------------------------------------------------------------------
@@ -123,152 +118,10 @@
     if (n!=6)
     {
-        *fLog << warn << "WARNING - Wrong number of arguments." << endl;
+        cout << n << endl;
+        *fLog << warn << "WARNING - Wrong number of arguments (should be 6)." << endl;
         return kFALSE;
     }
 
     str.Remove(0, len);
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Interprete the TH (discriminator thresholds) part of the report
-//
-Bool_t MReportCC::InterpreteTH(TString &str, Int_t ver)
-{
-    if (!CheckTag(str, "TH "))
-        return kFALSE;
-
-    // Skip the TH (discriminator thresholds) part of the report (for old
-    // CC files with wrong or nonsense number of TH-Bytes)
-    if (ver<200507190)
-    {
-        Ssiz_t pr = str.First(' ');
-        if (pr<0)
-        {
-            *fLog << warn << "WARNING - No TH information found at all." << endl;
-            return kFALSE;
-        }
-        if (pr!=1154)
-        {
-            fTD->Invalidate();
-
-            str.Remove(0, pr);
-            str=str.Strip(TString::kLeading);
-            return kTRUE;
-        }
-    }
-
-    const char *pos = str.Data();
-    const char *end = str.Data()+577*2;
-
-    Int_t i=0;
-    while (pos<end)
-    {
-        const Char_t hex[3] = { pos[0], pos[1], 0 };
-        pos += 2;
-
-        const Int_t n=sscanf(hex, "%2hhx", &fTH->fTH[i++]);
-        if (n==1)
-            continue;
-
-        *fLog << warn << "WARNING - Reading hexadecimal TH information." << endl;
-        return kFALSE;
-    }
-
-    fTH->SetValid();
-
-    str.Remove(0, end-str.Data()); // Remove TH
-    str=str.Strip(TString::kLeading);
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Interprete the TD (discriminator delays) part of the report
-//
-Bool_t MReportCC::InterpreteTD(TString &str, Int_t ver)
-{
-    if (!CheckTag(str, "TD "))
-        return kFALSE;
-
-    // Skip the TD (discriminator delays) part of the report (for old
-    // CC files with wrong or nonsense number of TD-Bytes)
-    if (ver<200412210)
-    {
-        Ssiz_t pr = str.First(' ');
-        if (pr<0)
-        {
-            *fLog << warn << "WARNING - No TD information found at all." << endl;
-            return kFALSE;
-        }
-        if (pr!=1000)
-        {
-            fTD->Invalidate();
-
-            str.Remove(0, pr);
-            str=str.Strip(TString::kLeading);
-            return kTRUE;
-        }
-    }
-
-    // Older files have less bytes (pixels) stored
-    const Int_t numpix = ver<200510250 ? 500 : 577;
-
-    const char *pos = str.Data();
-    const char *end = str.Data()+numpix*2;
-
-    Int_t i=0;
-    while (pos<end)
-    {
-        const Char_t hex[3] = { pos[0], pos[1], 0 };
-        pos += 2;
-
-        const Int_t n=sscanf(hex, "%2hhx", &fTD->fTD[i++]);
-        if (n==1)
-            continue;
-
-        *fLog << warn << "WARNING - Reading hexadecimal TD information." << endl;
-        return kFALSE;
-    }
-
-    fTD->SetValid();
-
-    str.Remove(0, end-str.Data()); // Remove TD
-    str=str.Strip(TString::kLeading);
-
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Interprete the receiver board temperature part of the report
-//
-Bool_t MReportCC::InterpreteRecTemp(TString &str)
-{
-    if (!CheckTag(str, "RECTEMP "))
-        return kFALSE;
-
-    Int_t len;
-    for (Int_t i=0; i<76; i++)
-    {
-        const Int_t n=sscanf(str.Data(), "%f %n", &fRecTemp->fRecTemp[i], &len);
-        str.Remove(0, len);
-
-        if (n==1)
-            continue;
-
-        if (n==0 && i==0)
-        {
-            *fLog << inf << "Receiver Board Temperatures empty." << endl;
-            fRecTemp->Invalidate();
-            break;
-        }
-
-        *fLog << warn << "WARNING - Reading Receiver Board Temperature information." << endl;
-        return kFALSE;
-    }
 
     return kTRUE;
@@ -291,23 +144,9 @@
         return kCONTINUE;
 
-    if (str.BeginsWith("RECEIVERS-COM-ERROR"))
+    if (ver<200805190)
     {
-        *fLog << inf << "Receiver Com-error... threshold setting and receiver board temp. invalid." << endl;
-        fTD->Invalidate();
-        fTH->Invalidate();
-        fRecTemp->Invalidate();
-        str.Remove(0, 19);
-    }
-    else
-    {
-        if (!InterpreteTH(str, ver))
-            return kCONTINUE;
-
-        if (!InterpreteTD(str, ver))
-            return kCONTINUE;
-
-        if (ver>=200510250)
-            if (!InterpreteRecTemp(str))
-                return kCONTINUE;
+        fRecRep->InterpreteRec(str, ver, *fTH, *fTD, *fRecTemp);
+        fRecRep->Copy(*this);
+        fRecRep->SetReadyToSave();
     }
 
Index: trunk/MagicSoft/Mars/mreport/MReportCC.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportCC.h	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReportCC.h	(revision 8955)
@@ -6,4 +6,5 @@
 #endif
 
+class MReportRec;
 class MCameraTH;
 class MCameraTD;
@@ -25,12 +26,10 @@
     MCameraRecTemp *fRecTemp; //! Receiver Board temperatures
 
+    MReportRec     *fRecRep;  //! Pipe interpretation to MReportRec if necessary
+    MTime          *fRecTime; //! Time stamp for Receiver part of reports
+
     // Internal
     Bool_t SetupReading(MParList &plist);
-    Bool_t CheckTag(TString &str, const char *tag) const;
-
     Bool_t InterpreteCC(TString &str, Int_t ver);
-    Bool_t InterpreteTH(TString &str, Int_t ver);
-    Bool_t InterpreteTD(TString &str, Int_t ver);
-    Bool_t InterpreteRecTemp(TString &str);
 
     // MReport
Index: trunk/MagicSoft/Mars/mreport/MReportCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportCamera.cc	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReportCamera.cc	(revision 8955)
@@ -19,5 +19,5 @@
 !   Author(s): Daniel Mazin, 04/2005 <mailto:mazin@mppmu.mpg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -111,20 +111,4 @@
 
     return MReport::SetupReading(plist);
-}
-
-// --------------------------------------------------------------------------
-//
-// Check whether the given TString begins with the given tag. Remove
-// the tag from the string.
-//
-Bool_t MReportCamera::CheckTag(TString &str, const char *tag) const
-{
-    if (!str.BeginsWith(tag))
-    {
-        *fLog << warn << "WARNING - '" << tag << "' tag not found." << endl;
-        return kFALSE;
-    }
-    str.Remove(0, strlen(tag)); // Remove DC currents
-    return kTRUE;
 }
 
Index: trunk/MagicSoft/Mars/mreport/MReportCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportCamera.h	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReportCamera.h	(revision 8955)
@@ -34,5 +34,4 @@
 
     Bool_t SetupReading(MParList &plist);
-    Bool_t CheckTag(TString &str, const char *tag) const;
 
     Bool_t InterpreteCamera(TString &str, Int_t ver);
Index: trunk/MagicSoft/Mars/mreport/MReportFileRead.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportFileRead.cc	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReportFileRead.cc	(revision 8955)
@@ -172,7 +172,6 @@
         return kTRUE;
 
-    const Int_t n = CheckFileHeader();
-    fNumLine += n;
-    return n==2;
+    fNumLine = CheckFileHeader();
+    return fNumLine>0;
 }
 
Index: trunk/MagicSoft/Mars/mreport/MReportFileRead.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportFileRead.h	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReportFileRead.h	(revision 8955)
@@ -30,5 +30,5 @@
     MTime   fStop;          // Time range which should be read from file
 
-    ULong_t fNumLine;       // line counter
+    Long_t  fNumLine;       // line counter
 
     Int_t   fVersion;       // File format version
Index: trunk/MagicSoft/Mars/mreport/MReportFileReadCC.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportFileReadCC.cc	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReportFileReadCC.cc	(revision 8955)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -61,8 +61,99 @@
 //
 MReportFileReadCC::MReportFileReadCC(const char *fname, const char *name, const char *title)
-    : MReportFileRead(fname, name, title), fRunNumber(-1)
+    : MReportFileRead(fname, name, title), fTelescope(-1), fRunNumber(-1), fFileNumber(-1)
 {
     fName  = name  ? name  : "MReportFileReadCC";
     fTitle = title ? title : "Read task to read Central Control report files";
+}
+
+Int_t MReportFileReadCC::GetRunNumber(const TString &str) const
+{
+    Int_t run = -1;
+
+    // whole night report file
+    if (str==TString("[CC Report File]"))
+        run = 0;
+
+    // report file matching a single run
+    if (!str(TRegexp("^[CC Run [0-9]+ Control File]$")).IsNull())
+        run = atoi(str(TRegexp(" [0-9]+")).Data());
+
+    if (run<0)
+    {
+        *fLog << err << "ERROR - First line doesn't match '[CC Report File]' ";
+        *fLog << "nor '^[CC Run [0-9]+ Control File]$'" << endl;
+        return -1;
+    }
+
+    if (fRunNumber!=-1 && fRunNumber!=run)
+    {
+        *fLog << err << "ERROR - Requested run #" << fRunNumber << " doesn't ";
+        *fLog << "match, found run #" << run << endl;
+        return -1;
+    }
+
+    return run;
+}
+
+Int_t MReportFileReadCC::GetVersion(const TString &str) const
+{
+    if (str(TRegexp("^Arehucas Version Number [0-9]+-[0-9]$")).IsNull())
+    {
+        *fLog << err << "ERROR - Version '^Arehucas Version Number [0-9]+-[0-9]$' ";
+        *fLog << "not found in second line." << endl;
+        return -1;
+    }
+
+    TString num = str(TRegexp("[0-9]+-[0-9]"));
+    num.Prepend("20");
+    num.ReplaceAll("-", "");
+
+    return atoi(num.Data());
+}
+
+Int_t MReportFileReadCC::GetTelescope(const TString &str) const
+{
+    if (str(TRegexp("^Telescope M[0-9]$")).IsNull())
+    {
+        *fLog << err << "ERROR - '^Telescope M[0-9]$' not found in third line." << endl;
+        return -1;
+    }
+
+    const Int_t num = atoi(str.Data()+11);
+
+    if (fTelescope != 1 && fTelescope !=2)
+    {
+        *fLog << err << "ERROR - Telsope number M" << num << " in third line unknown." << endl;
+        return -1;
+    }
+
+    if (fTelescope!=-1 && fTelescope!=num)
+    {
+        *fLog << err << "ERROR - Requested telescope M" << fTelescope << " doesn't ";
+        *fLog << "match, found M" << num << endl;
+        return -1;
+    }
+
+    return num;
+}
+
+Int_t MReportFileReadCC::GetFileNumber(const TString &str) const
+{
+    if (str(TRegexp("^Subrun [0-9]+$")).IsNull())
+    {
+        *fLog << err << "ERROR - '^Subrun [0-9]+$' not found in fourth line." << endl;
+        return -1;
+    }
+
+    const Int_t num = atoi(str.Data()+7);
+
+    if (fFileNumber!=-1 && fFileNumber!=num)
+    {
+        *fLog << err << "ERROR - Requested file number (subrun) " << fFileNumber << " doesn't ";
+        *fLog << "match, found " << num << endl;
+        return -1;
+    }
+
+    return num;
 }
 
@@ -76,59 +167,74 @@
 Int_t MReportFileReadCC::CheckFileHeader()
 {
-    Int_t line = 0;
-
     TString str;
     str.ReadLine(*fIn);   // Read to EOF or newline
     if (!*fIn)
-        return line;
-
-    line++;
-
-    Int_t run = -1;
-
-    // whole night report file
-    if (str==TString("[CC Report File]"))
-        run = 0;
-
-    // report file matching a single run
-    if (!str(TRegexp("^[CC Run [0-9]+ Control File]$")).IsNull())
-        run = atoi(str(TRegexp(" [0-9]+")).Data());
-
+    {
+        *fLog << "ERROR - Unexpected end of file (file empty)" << endl;
+        return -1;
+    }
+
+    const Int_t run = GetRunNumber(str);
     if (run<0)
-    {
-        *fLog << err << "ERROR - First line doesn't match '[CC Report File]' ";
-        *fLog << "nor '^[CC Run [0-9]+ Control File]$'" << endl;
-        return line;
-    }
-
-    if (fRunNumber!=-1 && fRunNumber!=run)
-    {
-        *fLog << err << "ERROR - Requested run #" << fRunNumber << " doesn't ";
-        *fLog << "match found run #" << run << endl;
-        return line;
-    }
-
-    str.ReadLine(*fIn);   // Read to EOF or newline
-    if (!*fIn)
-        return line;
-
-    if (str(TRegexp("^Arehucas Version Number [0-9]+-[0-9]$")).IsNull())
-    {
-        *fLog << err << "ERROR - Version '^Arehucas Version Number [0-9]+-[0-9]$' ";
-        *fLog << "not found in second line." << endl;
-        return line;
-    }
-    line++;
-
-    str = str(TRegexp("[0-9]+-[0-9]"));
-    str.Prepend("20");
-    str.ReplaceAll("-", "");
-
-    const Int_t ver = atoi(str.Data());
+        return -1;
+
+    fRunNumber = run;
+
+    // -----------------------------------------------------------
+
+    str.ReadLine(*fIn);   // Read to EOF or newline
+    if (!*fIn)
+    {
+        *fLog << "ERROR - Unexpected end of file after line 1." << endl;
+        return -1;
+    }
+
+    const Int_t ver = GetVersion(str);
+    if (ver<0)
+        return -1;
 
     *fLog << all << "Report File version: <" << ver << ">" << endl;
-
     SetVersion(ver);
 
-    return line;
-}
+    // -----------------------------------------------------------
+
+    fTelescope = 1;
+
+    if (ver<200805190)
+        return 3;
+
+    str.ReadLine(*fIn);   // Read to EOF or newline
+    if (!*fIn)
+    {
+        *fLog << "ERROR - Unexpected end of file after line 2." << endl;
+        return -1;
+    }
+
+    const Int_t tel = GetTelescope(str);
+    if (tel<0)
+        return -1;
+
+    fTelescope = tel;
+
+    // -----------------------------------------------------------
+
+    if (fRunNumber==0)
+        return kTRUE;
+
+    str.ReadLine(*fIn);   // Read to EOF or newline
+    if (!*fIn)
+    {
+        *fLog << "ERROR - Unexpected end of file after line 3." << endl;
+        return -1;
+    }
+
+    const Int_t num = GetFileNumber(str);
+    if (num<0)
+        return -1;
+
+    fFileNumber = num;
+
+    // -----------------------------------------------------------
+
+    return 4;
+}
Index: trunk/MagicSoft/Mars/mreport/MReportFileReadCC.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportFileReadCC.h	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReportFileReadCC.h	(revision 8955)
@@ -9,5 +9,12 @@
 {
 private:
+    Int_t fTelescope;
     Int_t fRunNumber;
+    Int_t fFileNumber;
+
+    Int_t GetRunNumber(const TString &str) const;
+    Int_t GetVersion(const TString &str) const;
+    Int_t GetTelescope(const TString &str) const;
+    Int_t GetFileNumber(const TString &str) const;
 
     Int_t CheckFileHeader();
@@ -15,5 +22,8 @@
 public:
     MReportFileReadCC(const char *filename, const char *name=NULL, const char *title=NULL);
-    void SetRunNumber(Int_t run) { fRunNumber = run; }
+
+    void SetTelescope(Int_t num)  { fTelescope  = num; }
+    void SetRunNumber(Int_t run)  { fRunNumber  = run; }
+    void SetFileNumber(Int_t run) { fFileNumber = run; }
 
     ClassDef(MReportFileReadCC, 0)// Task to read the central control report file
Index: trunk/MagicSoft/Mars/mreport/MReportRec.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportRec.cc	(revision 8955)
+++ trunk/MagicSoft/Mars/mreport/MReportRec.cc	(revision 8955)
@@ -0,0 +1,131 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 6/2008 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2008
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportRec
+//
+// This is the class interpreting and storing the REC-REPORT information.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportRec.h"
+
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MCameraTH.h"
+#include "MCameraTD.h"
+#include "MCameraRecTemp.h"
+
+ClassImp(MReportRec);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default construtor. Initialize identifier to "CC-REPORT" Report
+// is expected to have no 'subsystem' time.
+//
+MReportRec::MReportRec() : MReport("REC-REPORT", kFALSE)
+{
+    fName  = "MReportRec";
+    fTitle = "Class for REC-REPORT information";
+}
+
+// --------------------------------------------------------------------------
+//
+// FindCreate the following objects:
+//  - MCameraTH
+//
+Bool_t MReportRec::SetupReading(MParList &plist)
+{
+    fTH = (MCameraTH*)plist.FindCreateObj("MCameraTH");
+    if (!fTH)
+        return kFALSE;
+
+    fTD = (MCameraTD*)plist.FindCreateObj("MCameraTD");
+    if (!fTD)
+        return kFALSE;
+
+    fRecTemp = (MCameraRecTemp*)plist.FindCreateObj("MCameraRecTemp");
+    if (!fRecTemp)
+        return kFALSE;
+
+    return MReport::SetupReading(plist);
+}
+
+Int_t MReportRec::InterpreteRec(TString &str, Int_t ver, MCameraTH &th, MCameraTD &td, MCameraRecTemp &temp)
+{
+    if (str.BeginsWith("RECEIVERS-COM-ERROR"))
+    {
+        *fLog << inf << "Receiver Com-error... threshold setting and receiver board temp. invalid." << endl;
+        td.Invalidate();
+        th.Invalidate();
+        temp.Invalidate();
+        str.Remove(0, 19);
+
+        return kTRUE;
+    }
+
+    if (!CheckTag(str, "TH "))
+        return kFALSE;
+
+    if (!th.InterpreteTH(str, ver, td))
+        return kCONTINUE;
+
+    if (!CheckTag(str, "TD "))
+        return kFALSE;
+
+    if (!td.InterpreteTD(str, ver))
+        return kCONTINUE;
+
+    if (ver<200510250)
+        return kTRUE;
+
+    if (!CheckTag(str, "RECTEMP "))
+        return kFALSE;
+
+    if (!temp.InterpreteRecTemp(str))
+        return kCONTINUE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the body of the CC-REPORT string
+//
+Int_t MReportRec::InterpreteBody(TString &str, Int_t ver)
+{
+    InterpreteRec(str, ver, *fTH, *fTD, *fRecTemp);
+
+    if (str.Strip(TString::kBoth)!=(TString)"OVER")
+    {
+        *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
+        return kCONTINUE;
+    }
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/mreport/MReportRec.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportRec.h	(revision 8955)
+++ trunk/MagicSoft/Mars/mreport/MReportRec.h	(revision 8955)
@@ -0,0 +1,37 @@
+#ifndef MARS_MReportRec
+#define MARS_MReportRec
+
+#ifndef MARS_MReport
+#include "MReport.h"
+#endif
+
+class MCameraTH;
+class MCameraTD;
+class MCameraRecTemp;
+
+class MReportRec : public MReport
+{
+    friend class MReportCC;
+private:
+    MCameraTH      *fTH;      //! Discriminator thresholds
+    MCameraTD      *fTD;      //! Discriminator delays
+    MCameraRecTemp *fRecTemp; //! Receiver Board temperatures
+
+    // Internal
+    Bool_t SetupReading(MParList &plist);
+
+    Bool_t InterpreteTH(TString &str, Int_t ver);
+    Bool_t InterpreteTD(TString &str, Int_t ver);
+    Bool_t InterpreteRecTemp(TString &str);
+
+    // MReport
+    Int_t InterpreteRec(TString &str, Int_t ver, MCameraTH &th, MCameraTD &td, MCameraRecTemp &temp);
+    Int_t InterpreteBody(TString &str, Int_t ver);
+
+public:
+    MReportRec();
+
+    ClassDef(MReportRec, 1) // Class for REC-REPORT information
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mreport/MReportRun.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportRun.cc	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReportRun.cc	(revision 8955)
@@ -57,4 +57,6 @@
 Int_t MReportRun::InterpreteBody(TString &str, Int_t ver)
 {
+    // --------- Get Token (START/STOP) ---------
+
     const Int_t ws = str.First(' ');
     if (ws<0)
@@ -68,4 +70,6 @@
     str = str.Strip(TString::kBoth);
 
+    // --------- Get Run Number ---------
+
     Int_t len, run;
     const Int_t n=sscanf(str.Data(), "%d %n", &run, &len);
@@ -77,21 +81,50 @@
     str.Remove(0, len);
 
+    // --------- Get File Number ---------
+    Int_t file = 0;
+    if (ver>=200805190)
+    {
+        Int_t len;
+        const Int_t n=sscanf(str.Data(), "%d %n", &file, &len);
+        if (n!=1)
+        {
+            *fLog << warn << "WARNING - Wrong number of arguments." << endl;
+            return kCONTINUE;
+        }
+        str.Remove(0, len);
+    }
+
+    // --------- Invalidate Run/File Number if run was stopped ---------
     if (tok=="START")
     {
         if (fRunNumber!=-1)
             *fLog << warn << "WARNING - RUN-REPORT STOP missing for run #" << dec << fRunNumber <<  endl;
-        fRunNumber = run;
+
+        fRunNumber  = run;
+        fFileNumber = file;
     }
+
     if (tok=="STOP")
     {
         if (fRunNumber==-1)
             *fLog << warn << "WARNING - RUN-REPORT START missing for run #" << dec << fRunNumber << endl;
-        fRunNumber = -1;
+        else
+        {
+            if (fRunNumber!=run)
+                *fLog << warn << "WARNING - RUN-REPORT STOP run number #" << dec << run << " doesn't match started run #" << fRunNumber << "." << endl;
+
+            if (fFileNumber!=file)
+                *fLog << warn << "WARNING - RUN-REPORT STOP file number #" << dec << run << " doesn't match started file #" << fFileNumber << "." << endl;
+        }
+
+        fRunNumber  = -1;
+        fFileNumber = -1;
     }
 
+    // --------- Get source name ---------
     Ssiz_t pos = str.First(' ');
     if (pos<0)
         pos = str.Length();
-    fSourceName = str(0, pos+1);
+    fSourceName = TString(str(0, pos+1)).Strip(TString::kBoth);
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mreport/MReportRun.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportRun.h	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/MReportRun.h	(revision 8955)
@@ -10,4 +10,5 @@
 private:
     Int_t   fRunNumber;
+    Int_t   fFileNumber;
     TString fSourceName;
 
@@ -20,5 +21,6 @@
     TString GetSourceName() { return fSourceName; }
 
-    Int_t GetRunNumber() const { return fRunNumber; }
+    Int_t GetRunNumber() const  { return fRunNumber; }
+    Int_t GetFileNumber() const { return fFileNumber; }
 
     ClassDef(MReportRun, 0) // Class for RUN-REPORT information
Index: trunk/MagicSoft/Mars/mreport/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mreport/Makefile	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/Makefile	(revision 8955)
@@ -24,4 +24,5 @@
 SRCFILES = MReport.cc \
            MReportCC.cc \
+           MReportRec.cc \
            MReportRun.cc \
            MReportDAQ.cc \
Index: trunk/MagicSoft/Mars/mreport/ReportLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/ReportLinkDef.h	(revision 8936)
+++ trunk/MagicSoft/Mars/mreport/ReportLinkDef.h	(revision 8955)
@@ -8,4 +8,5 @@
 
 #pragma link C++ class MReportCC+;
+#pragma link C++ class MReportRec+;
 #pragma link C++ class MReportRun+;
 #pragma link C++ class MReportDAQ+;
