Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 8954)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 8955)
@@ -37,4 +37,51 @@
    * mjobs/MJCalibrateSignal.cc:
      - changed the named of the MFTriggerPattern
+
+   * merpp.cc:
+     - added new option --only, --rep-run, --rep-file, --header-run,
+       --header-file, --telescope
+     - moved Receiver information from tree CC to tree Rec
+
+   * mbase/MStatusDisplay.cc:
+     - replacedMTime by TDatime
+
+   * mcamera/MCameraRecTemp.[h,cc], mcamera/MCameraTD.[h,cc],
+     mcamera/MCameraTH.[h,cc], mreport/MReportCC.[h,cc]:
+     - moved interpretation of sub-parts of the reports from 
+       MReportCC to the corresponding MCamera* classes
+
+   * mreport/MReport.[h,cc]:
+     - added Copy member function to copy time and state
+     - added CheckTag member function
+     - Implemented skipping of the Telescope number in the reports
+       for version >=200805190
+
+   * mreport/MReportCC.[h,cc]:
+     - access Receiver infomations via new class MReportRec
+       even for old file formats
+     - skip this block in new formats
+     - moved CheckTag to base class
+
+   * mreport/MReportCamera.[h,cc]:
+     - removed CheckTag
+
+   * mreport/MReportFileRead.[h,cc]:
+     - don't check for the number of lines anymore but for -1 instead
+     - changed fNumLine from ULong to Long to allow a negative
+       return value. We don't expect so many lines in a file anyway,
+       do we?
+
+   * mreport/MReportFileReadCC.[h,cc]:
+     - splitted CheckFileHeader into several subfunction
+     - added checks and reading of telescope number and file number
+
+   * mreport/MReportRun.[h,cc]:
+     - added file number from new format
+
+   * mreport/Makefile, mreport/ReportLinkDef.h:
+     - added MReportRec
+
+   * mreport/MReportRec.[h,cc]:
+     - added
 
 
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 8954)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 8955)
@@ -69,5 +69,11 @@
  ;merpp
 
-   * Implemented cc file version 2008-20-02/0
+   * Implemented cc file version 2008-02-20/0
+
+   * Implemented cc file version 2008-05-19/0
+
+   * With new options merpping can be restricted (in addition to the
+     run-number) also by telescope and file number. 
+        For details see "merpp --help"
 
    * Implemented raw data format 11 (the most important change, except
@@ -77,6 +83,11 @@
      compatible, so old programs will be able to read newer formats.
 
-   * Added Pyrometer information to output (stored in a new Tree
+   * Added Pyrometer information to default output (stored in a new Tree
      Pyrometer, needs a complete new merpp, i.e. new calibration)
+
+   * Merpping (also update) can now be restricted to one single report.
+     For example: 
+     If you want to update an old file with Pyrometer information call 
+        merpp --only=Pyrometer --update
 
  ;callisto
Index: /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 8954)
+++ /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 8955)
@@ -478,5 +478,5 @@
 
     // Add copyright notice
-    l = new TGLabel(f, Form("(c) MARS Software Development, 2000-%d", MTime(-1).Year());
+    l = new TGLabel(f, Form("(c) MARS Software Development, 2000-%d", TDatime().GetYear()));
     fList->Add(l);
     f->AddFrame(l, layb);
@@ -2619,5 +2619,5 @@
             PSToolsTextNDC(*ps, 0, -0.015, TString("  ")+txt);
             ps->SetTextAlign(31); // right top
-            PSToolsTextNDC(*ps, 1, -0.015, Form("(c) 2000-%d, Thomas Bretz  ", MTime(-1).Year()));
+            PSToolsTextNDC(*ps, 1, -0.015, Form("(c) 2000-%d, Thomas Bretz  ", TDatime().GetYear()));
         }
 
Index: /trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.cc	(revision 8954)
+++ /trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.cc	(revision 8955)
@@ -57,4 +57,34 @@
 // --------------------------------------------------------------------------
 //
+// Interprete the receiver board temperature part of the report
+//
+Bool_t MCameraRecTemp::InterpreteRecTemp(TString &str)
+{
+    Int_t len;
+    for (Int_t i=0; i<76; i++)
+    {
+        const Int_t n=sscanf(str.Data(), "%f %n", &fRecTemp[i], &len);
+        str.Remove(0, len);
+
+        if (n==1)
+            continue;
+
+        if (n==0 && i==0)
+        {
+            *fLog << inf << "Receiver Board Temperatures empty." << endl;
+            Invalidate();
+            break;
+        }
+
+        *fLog << warn << "WARNING - Reading Receiver Board Temperature information." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
 // Print the dc currents
 //
Index: /trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.h
===================================================================
--- /trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.h	(revision 8954)
+++ /trunk/MagicSoft/Mars/mcamera/MCameraRecTemp.h	(revision 8955)
@@ -13,7 +13,10 @@
 {
     friend class MReportCC;
+    friend class MReportRec;
 private:
     TArrayF fRecTemp; // [deg C] receiver board temperatures
     Bool_t  fIsValid; // fRecTemp contains valid information
+
+    Bool_t InterpreteRecTemp(TString &str);
 
 public:
Index: /trunk/MagicSoft/Mars/mcamera/MCameraTD.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcamera/MCameraTD.cc	(revision 8954)
+++ /trunk/MagicSoft/Mars/mcamera/MCameraTD.cc	(revision 8955)
@@ -19,5 +19,5 @@
 !   Author(s): Florian Goebel 11/2005 <mailto:fgoebel@mppmu.mpg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2006
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -57,4 +57,58 @@
 // --------------------------------------------------------------------------
 //
+// Interprete the TD (discriminator delays) part of the report
+//
+Bool_t MCameraTD::InterpreteTD(TString &str, Int_t ver)
+{
+    // 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)
+        {
+            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[i++]);
+        if (n==1)
+            continue;
+
+        *fLog << warn << "WARNING - Reading hexadecimal TD information." << endl;
+        return kFALSE;
+    }
+
+    SetValid();
+
+    str.Remove(0, end-str.Data()); // Remove TD
+    str=str.Strip(TString::kLeading);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
 // Print the discrimintaor delays
 //
Index: /trunk/MagicSoft/Mars/mcamera/MCameraTD.h
===================================================================
--- /trunk/MagicSoft/Mars/mcamera/MCameraTD.h	(revision 8954)
+++ /trunk/MagicSoft/Mars/mcamera/MCameraTD.h	(revision 8955)
@@ -16,7 +16,10 @@
 {
     friend class MReportCC;
+    friend class MReportRec;
 private:
     TArrayC fTD;      // [au] discriminator delays
     Bool_t  fIsValid; // fTD contains valid information
+
+    Bool_t InterpreteTD(TString &str, Int_t ver);
 
 public:
Index: /trunk/MagicSoft/Mars/mcamera/MCameraTH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcamera/MCameraTH.cc	(revision 8954)
+++ /trunk/MagicSoft/Mars/mcamera/MCameraTH.cc	(revision 8955)
@@ -40,4 +40,6 @@
 #include "MLogManip.h"
 
+#include "MCameraTD.h"
+
 ClassImp(MCameraTH);
 
@@ -53,4 +55,54 @@
     fName  = name  ? name  : "MCameraTH";
     fTitle = title ? title : "Storage container for the pixel discriminator threshold";
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the TH (discriminator thresholds) part of the report
+//
+Bool_t MCameraTH::InterpreteTH(TString &str, Int_t ver, MCameraTD &td)
+{
+    // 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)
+        {
+            td.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[i++]);
+        if (n==1)
+            continue;
+
+        *fLog << warn << "WARNING - Reading hexadecimal TH information." << endl;
+        return kFALSE;
+    }
+
+    SetValid();
+
+    str.Remove(0, end-str.Data()); // Remove TH
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
 }
 
Index: /trunk/MagicSoft/Mars/mcamera/MCameraTH.h
===================================================================
--- /trunk/MagicSoft/Mars/mcamera/MCameraTH.h	(revision 8954)
+++ /trunk/MagicSoft/Mars/mcamera/MCameraTH.h	(revision 8955)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-!  $Name: not supported by cvs2svn $:$Id: MCameraTH.h,v 1.7 2007-02-01 15:56:17 tbretz Exp $
+!  $Name: not supported by cvs2svn $:$Id: MCameraTH.h,v 1.8 2008-06-14 14:19:03 tbretz Exp $
 \* ======================================================================== */
 #ifndef MARS_MCameraTH
@@ -16,10 +16,15 @@
 #endif
 
+class MCameraTD;
+
 class MCameraTH : public MParContainer, public MCamEvent
 {
     friend class MReportCC;
+    friend class MReportRec;
 private:
     TArrayC fTH;      // [au] discriminator thresholds
     Bool_t  fIsValid; // fTH contains valid information
+
+    Bool_t InterpreteTH(TString &str, Int_t ver, MCameraTD &td);
 
 public:
Index: /trunk/MagicSoft/Mars/merpp.cc
===================================================================
--- /trunk/MagicSoft/Mars/merpp.cc	(revision 8954)
+++ /trunk/MagicSoft/Mars/merpp.cc	(revision 8955)
@@ -25,5 +25,5 @@
 #include "MRawCrateArray.h"
 
-#include "MFDataMember.h"
+#include "MFDataPhrase.h"
 
 using namespace std;
@@ -77,5 +77,7 @@
     gLog << "   -c#                       Compression level #=1..9 [default=2]" << endl;
     gLog << "   -f                        Force overwrite of an existing file" << endl;
-    gLog << "   -u, --update              Update an existing file." << endl << endl;
+    gLog << "   -u, --update              Update an existing file." << endl;
+    gLog << "   --only=Name               Read only reports described by MReportName. See the" << endl;
+    gLog << "                                mreport-directory for available classes." << endl << endl;
     gLog << " Raw Data Options:" << endl;
     gLog << "   -ff                       Force merpp to ignore broken events and don't stop" << endl;
@@ -84,17 +86,26 @@
     gLog << " Report File Options:" << endl;
     gLog << "   --auto-time-start         Take time automatically from MRawRunHeader" << endl;
-    gLog << "                             (overwrites --start=)" << endl;
+    gLog << "                                (overwrites --start=)" << endl;
     gLog << "   --auto-time-stop          Take time automatically from MRawRunHeader" << endl;
-    gLog << "                             (overwrites --stop=)" << endl;
-    gLog << "   --auto-time               Abbreviation for --auto-time-start and auto-time-stop" << endl;
+    gLog << "                                (overwrites --stop=)" << endl;
+    gLog << "   --auto-time               Abbrev. for --auto-time-start and auto-time-stop" << endl;
     gLog << "   --start=date/time         Start event time" << endl;
     gLog << "   --stop=date/time          Stop  event time" << endl;
-    gLog << "   --run=#                   Only data corresponding to this run number" << endl;
-    gLog << "                             (from RUN-REPORT)" << endl;
-    gLog << "   --runfile=#               Allow only run-control files" << endl;
-    gLog << "                             (from .rep header)" << endl;
+    gLog << "   --rep-run=#               Only data corresponding to this run number as" << endl;
+    gLog << "                                taken from the RUN-REPORT is extracted" << endl;
+    gLog << "   --rep-file=#              Only data corresponding to this file number as" << endl;
+    gLog << "                                taken from the RUN-REPORT is extracted" << endl;
+    gLog << "   --header-run=#            Allow only run-control .rep-files with this" << endl;
+    gLog << "                                run number in there header" << endl;
+    gLog << "   --header-file=#           Allow only run-control .rep-files with this" << endl;
+    gLog << "                                file number in there header" << endl;
+    gLog << "   --telescope=#             Allow only run-control .rep-files with this" << endl;
+    gLog << "                                telescope number in there header" << endl;
     gLog << "   --sumfile                 Check for an all night summary file" << endl;
-    gLog << "                             (from .rep header)" << endl;
+    gLog << "                                (from .rep header)" << endl;
     gLog << "   --allfiles                Don't check file type <default>" << endl << endl;
+    gLog << " Compatibility (deprecated):" << endl;
+    gLog << "   --run=#                   See --rep-run (overwritten by --rep-run)" << endl;
+    gLog << "   --runfile=#               See --header-run (overwritten by --header-run)" << endl << endl;
     gLog << " REMARK: - At the moment you can process a .raw _or_ a .rep file, only!" << endl;
     gLog << "         - 'date/time' has the format 'yyyy-mm-dd/hh:mm:ss.mmm'" << endl << endl;
@@ -145,4 +156,12 @@
 }
 
+void Add(MReportFileReadCC *r, const TString &rep, const TString &only)
+{
+    if (!only.IsNull() && rep!=only)
+        return;
+
+    r->AddToList(Form("MReport%s", rep.Data()));
+}
+
 int main(const int argc, char **argv)
 {
@@ -169,14 +188,20 @@
     }
 
-    const Int_t  kComprlvl      = arg.GetIntAndRemove("-c", 2);
-    const Bool_t kInterleave    = arg.GetIntAndRemove("--interleave=", 1);
-    const Bool_t kForce         = arg.HasOnlyAndRemove("-f");
-    const Bool_t kForceProc     = arg.HasOnlyAndRemove("-ff");
-    const Int_t  kRunNumber     = arg.GetIntAndRemove("--run=", -1);
-    const Bool_t kAutoTime      = arg.HasOnlyAndRemove("--auto-time");
-    const Bool_t kAutoTimeStart = arg.HasOnlyAndRemove("--auto-time-start") || kAutoTime;
-    const Bool_t kAutoTimeStop  = arg.HasOnlyAndRemove("--auto-time-stop")  || kAutoTime;
-          Int_t  kRunFile       = arg.GetIntAndRemove("--runfile=", -1);
-          Bool_t kUpdate        = arg.HasOnlyAndRemove("--update") || arg.HasOnlyAndRemove("-u");
+    const Int_t   kComprlvl      = arg.GetIntAndRemove("-c", 2);
+    const Bool_t  kInterleave    = arg.GetIntAndRemove("--interleave=", 1);
+    const Bool_t  kForce         = arg.HasOnlyAndRemove("-f");
+    const Bool_t  kForceProc     = arg.HasOnlyAndRemove("-ff");
+    const Int_t   run            = arg.GetIntAndRemove("--run=", -1);
+    const Int_t   kRunNumber     = arg.GetIntAndRemove("--rep-run=", run);
+    const Int_t   kFileNumber    = arg.GetIntAndRemove("--rep-file=", -1);
+    const Bool_t  kAutoTime      = arg.HasOnlyAndRemove("--auto-time");
+    const Bool_t  kAutoTimeStart = arg.HasOnlyAndRemove("--auto-time-start") || kAutoTime;
+    const Bool_t  kAutoTimeStop  = arg.HasOnlyAndRemove("--auto-time-stop")  || kAutoTime;
+    const Int_t   runfile        = arg.GetIntAndRemove("--runfile=", -1);
+          Int_t   kHeaderRun     = arg.GetIntAndRemove("--header-run=", runfile);
+    const Int_t   kHeaderFile    = arg.GetIntAndRemove("--header-file=", -1);
+    const Int_t   kTelescope     = arg.GetIntAndRemove("--telescope=", -1);
+          Bool_t  kUpdate        = arg.HasOnlyAndRemove("--update") || arg.HasOnlyAndRemove("-u");
+    const TString kOnly          = arg.GetStringAndRemove("--only=", "");
 
     MTime kTimeStart;
@@ -190,5 +215,5 @@
 
     if (arg.HasOnlyAndRemove("--sumfile"))
-        kRunFile = 0;
+        kHeaderRun  = 0;
 
     if (arg.GetNumOptions()>0)
@@ -197,4 +222,5 @@
         arg.Print("options");
         gLog << endl;
+        return 2;
     }
 
@@ -332,31 +358,34 @@
         else
         {
-            w->AddContainer("MReportCamera",      "Camera");
-            w->AddContainer("MTimeCamera",        "Camera");
-            w->AddContainer("MCameraAUX",         "Camera");
-            w->AddContainer("MCameraCalibration", "Camera");
-            w->AddContainer("MCameraCooling",     "Camera");
-            w->AddContainer("MCameraActiveLoad",  "Camera");
-            w->AddContainer("MCameraHV",          "Camera");
-            w->AddContainer("MCameraLV",          "Camera");
-            w->AddContainer("MCameraLids",        "Camera");
-            w->AddContainer("MReportTrigger",     "Trigger");
-            w->AddContainer("MTimeTrigger",       "Trigger");
-            w->AddContainer("MTriggerBit",        "Trigger");
-            w->AddContainer("MTriggerIPR",        "Trigger");
-            w->AddContainer("MTriggerCell",       "Trigger");
-            w->AddContainer("MTriggerPrescFact",  "Trigger");
-            w->AddContainer("MTriggerLiveTime",   "Trigger");
-            w->AddContainer("MReportDrive",       "Drive");
-            w->AddContainer("MTimeDrive",         "Drive");
-            w->AddContainer("MReportCC",          "CC");
-            w->AddContainer("MCameraTH",          "CC");
-            w->AddContainer("MCameraTD",          "CC");
-            w->AddContainer("MCameraRecTemp",     "CC");
-            w->AddContainer("MTimeCC",            "CC");
-            w->AddContainer("MReportStarguider",  "Starguider");
-            w->AddContainer("MTimeStarguider",    "Starguider");
-            w->AddContainer("MReportPyrometer",   "Pyrometer");
-            w->AddContainer("MTimePyrometer",     "Pyrometer");
+            const Bool_t required = kOnly.IsNull();
+            w->AddContainer("MReportCamera",      "Camera",     required);
+            w->AddContainer("MTimeCamera",        "Camera",     required);
+            w->AddContainer("MCameraAUX",         "Camera",     required);
+            w->AddContainer("MCameraCalibration", "Camera",     required);
+            w->AddContainer("MCameraCooling",     "Camera",     required);
+            w->AddContainer("MCameraActiveLoad",  "Camera",     required);
+            w->AddContainer("MCameraHV",          "Camera",     required);
+            w->AddContainer("MCameraLV",          "Camera",     required);
+            w->AddContainer("MCameraLids",        "Camera",     required);
+            w->AddContainer("MReportTrigger",     "Trigger",    required);
+            w->AddContainer("MTimeTrigger",       "Trigger",    required);
+            w->AddContainer("MTriggerBit",        "Trigger",    required);
+            w->AddContainer("MTriggerIPR",        "Trigger",    required);
+            w->AddContainer("MTriggerCell",       "Trigger",    required);
+            w->AddContainer("MTriggerPrescFact",  "Trigger",    required);
+            w->AddContainer("MTriggerLiveTime",   "Trigger",    required);
+            w->AddContainer("MReportDrive",       "Drive",      required);
+            w->AddContainer("MTimeDrive",         "Drive",      required);
+            w->AddContainer("MCameraTH",          "Rec",        required);
+            w->AddContainer("MCameraTD",          "Rec",        required);
+            w->AddContainer("MCameraRecTemp",     "Rec",        required);
+            w->AddContainer("MReportRec",         "Rec",        required);
+            w->AddContainer("MTimeRec",           "Rec",        required);
+            w->AddContainer("MReportCC",          "CC",         required);
+            w->AddContainer("MTimeCC",            "CC",         required);
+            w->AddContainer("MReportStarguider",  "Starguider", required);
+            w->AddContainer("MTimeStarguider",    "Starguider", required);
+            w->AddContainer("MReportPyrometer",   "Pyrometer",  required);
+            w->AddContainer("MTimePyrometer",     "Pyrometer",  required);
             // w->AddContainer("MReportDAQ",         "DAQ");
             // w->AddContainer("MTimeDAQ",           "DAQ");
@@ -374,16 +403,25 @@
         else
         {
-            r->SetRunNumber(kRunFile);
-            r->AddToList("MReportCC");
-            //r->AddToList("MReportDAQ");
-            r->AddToList("MReportDrive");
-            r->AddToList("MReportCamera");
-            r->AddToList("MReportTrigger");
-            r->AddToList("MReportStarguider");
-            r->AddToList("MReportPyrometer");
+            r->SetTelescope(kTelescope);
+            r->SetRunNumber(kHeaderRun);
+            r->SetFileNumber(kHeaderFile);
+            Add(r, "CC",         kOnly);
+            Add(r, "Rec",        kOnly);
+            Add(r, "Drive",      kOnly);
+            Add(r, "Camera",     kOnly);
+            Add(r, "Trigger",    kOnly);
+            Add(r, "Starguider", kOnly);
+            Add(r, "Pyrometer",  kOnly);
+            // Add(r, "DAQ",  kUpdateOnly);
             if (kRunNumber>0)
             {
+                const TString f1 = kRunNumber>0  ? Form("MReportRun.fRunNumber==%d",  kRunNumber)  : "";
+                const TString f2 = kFileNumber>0 ? Form("MReportRun.fFileNumber==%d", kFileNumber) : "";
+
+                const TString f = Form(kRunNumber>0 && kFileNumber>0 ? "%s && %s" : "%s%s",
+                                       f1.Data(), f2.Data());
+
                 r->AddToList("MReportRun");
-                filter = new MFDataMember("MReportRun.fRunNumber", '=', kRunNumber);
+                filter = new MFDataPhrase(f.Data());
                 w->SetFilter(filter);
             }
Index: /trunk/MagicSoft/Mars/mreport/MReport.cc
===================================================================
--- /trunk/MagicSoft/Mars/mreport/MReport.cc	(revision 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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 8954)
+++ /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+;
