Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7718)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7719)
@@ -19,4 +19,31 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2006/05/19 Thomas Bretz
+
+   * mbase/MMath.h:
+     - added default to second argument of GaussProb
+
+   * mcamera/MCameraTD.[h,cc], mcamera/MCameraTH.[h,cc]:
+     - added a data member fIsValid giving the status of the arrays
+       in case the CC reports contained nonsense (mainly for files 
+       before summer 2005)
+     - increased class version by 1
+
+   * mhflux/MHAlpha.h:
+     - made SetOffData virtual
+
+   * mreport/MReport.cc:
+     - small changes to some comments
+
+   * mreport/MReportCC.[h,cc]:
+     - better handling of problems with the TH and TD part of the 
+       CC-REPORT for files older than 200507190 and 200412210 
+       respectively
+
+   * mreport/MReportFileReadCC.cc:
+     - always output the file format version
+
+
+
  2006/05/18 Thomas Bretz
 
@@ -27,5 +54,4 @@
      - made fHillas data member protected
      - increased size of fMap
-     - made SetOffData virtual
 
    * mhflux/MHThetaSq.[h,cc]:
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 7718)
+++ trunk/MagicSoft/Mars/NEWS	(revision 7719)
@@ -3,4 +3,7 @@
  *** Version  <cvs>
 
+   - merpp: better handling of problems with the TH and TD part of the 
+       CC-REPORT for files older than 200507190 and 200412210 
+       respectively
 
 
Index: trunk/MagicSoft/Mars/mbase/MMath.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MMath.h	(revision 7718)
+++ trunk/MagicSoft/Mars/mbase/MMath.h	(revision 7719)
@@ -17,5 +17,5 @@
     inline Double_t HorToRad() { return 15/TMath::RadToDeg(); }
 
-    Double_t GaussProb(Double_t x, Double_t sigma, Double_t mean=0);
+    Double_t GaussProb(Double_t x, Double_t sigma=1, Double_t mean=0);
 
     Double_t Significance(Double_t s, Double_t b);
Index: trunk/MagicSoft/Mars/mcamera/MCameraTD.cc
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraTD.cc	(revision 7718)
+++ trunk/MagicSoft/Mars/mcamera/MCameraTD.cc	(revision 7719)
@@ -19,5 +19,5 @@
 !   Author(s): Florian Goebel 11/2005 <mailto:fgoebel@mppmu.mpg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
@@ -27,4 +27,8 @@
 //
 // MCameraTD
+//
+// Class Version 2:
+// ----------------
+//   + Bool_t  fIsValid; // fTD contains valid information
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -45,5 +49,5 @@
 //
 MCameraTD::MCameraTD(Int_t size, const char *name, const char *title)
-    : fTD(size)
+    : fTD(size), fIsValid(kTRUE)
 {
     fName  = name  ? name  : "MCameraTD";
Index: trunk/MagicSoft/Mars/mcamera/MCameraTD.h
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraTD.h	(revision 7718)
+++ trunk/MagicSoft/Mars/mcamera/MCameraTD.h	(revision 7719)
@@ -17,5 +17,6 @@
     friend class MReportCC;
 private:
-    TArrayC fTD; // [au] discriminator delays
+    TArrayC fTD;      // [au] discriminator delays
+    Bool_t  fIsValid; // fTD contains valid information
 
 public:
@@ -28,4 +29,9 @@
 
     void Print(Option_t *opt=NULL) const;
+
+    void Invalidate() { fTD.Reset(); fIsValid=kFALSE; }
+
+    void SetValid(Bool_t v=kTRUE) { fIsValid=v; }
+    Bool_t IsValid() const { return fIsValid; }
 
     Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
@@ -41,5 +47,5 @@
     }
 
-    ClassDef(MCameraTD, 1) // Storage Container for Discriminator Delays
+    ClassDef(MCameraTD, 2) // Storage Container for Discriminator Delays
 };
 
Index: trunk/MagicSoft/Mars/mcamera/MCameraTH.cc
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraTH.cc	(revision 7718)
+++ trunk/MagicSoft/Mars/mcamera/MCameraTH.cc	(revision 7719)
@@ -19,5 +19,5 @@
 !   Author(s): Florian Goebel 11/2005 <mailto:fgoebel@mppmu.mpg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
@@ -26,5 +26,9 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// MCameraTH (PRELIMINARY)
+// MCameraTH
+//
+// Class Version 2:
+// ----------------
+//   + Bool_t  fIsValid; // fTH contains valid information
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -45,5 +49,5 @@
 //
 MCameraTH::MCameraTH(Int_t size, const char *name, const char *title)
-    : fTH(size)
+    : fTH(size), fIsValid(kTRUE)
 {
     fName  = name  ? name  : "MCameraTH";
Index: trunk/MagicSoft/Mars/mcamera/MCameraTH.h
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraTH.h	(revision 7718)
+++ trunk/MagicSoft/Mars/mcamera/MCameraTH.h	(revision 7719)
@@ -17,5 +17,6 @@
     friend class MReportCC;
 private:
-    TArrayC fTH; // [au] discriminator thresholds
+    TArrayC fTH;      // [au] discriminator thresholds
+    Bool_t  fIsValid; // fTH contains valid information
 
 public:
@@ -28,4 +29,9 @@
 
     void Print(Option_t *opt=NULL) const;
+
+    void Invalidate() { fTH.Reset(); fIsValid=kFALSE; }
+
+    void SetValid(Bool_t v=kTRUE) { fIsValid=v; }
+    Bool_t IsValid() const { return fIsValid; }
 
     Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
@@ -41,5 +47,5 @@
     }
 
-    ClassDef(MCameraTH, 1) // Storage Container for the discriminator thresholds
+    ClassDef(MCameraTH, 2) // Storage Container for the discriminator thresholds
 };
 
Index: trunk/MagicSoft/Mars/mhflux/MHAlpha.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHAlpha.h	(revision 7718)
+++ trunk/MagicSoft/Mars/mhflux/MHAlpha.h	(revision 7719)
@@ -102,5 +102,5 @@
     // Setter
     void SetNameParameter(const char *name) { fNameParameter=name; }
-    void SetOffData(const MHAlpha &h)
+    virtual void SetOffData(const MHAlpha &h)
     {
         fOffData        = &h.fHist;
Index: trunk/MagicSoft/Mars/mreport/MReport.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReport.cc	(revision 7718)
+++ trunk/MagicSoft/Mars/mreport/MReport.cc	(revision 7719)
@@ -36,7 +36,5 @@
 //   Old Version | MjdMin  | MjdMax  | New Version
 //  -------------+---------+---------+-------------
-//   200504130   | 53548.0 | 53567.0 | 200506300
-//   200503170   | 53446.5 | 53447.5 | 200502240
-//
+//    see MReport::Interprete()
 //
 //  Be carefull: The class name of all classes derived from this class
Index: trunk/MagicSoft/Mars/mreport/MReportCC.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportCC.cc	(revision 7718)
+++ trunk/MagicSoft/Mars/mreport/MReportCC.cc	(revision 7719)
@@ -136,8 +136,28 @@
 // Interprete the TH (discriminator thresholds) part of the report
 //
-Bool_t MReportCC::InterpreteTH(TString &str)
+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();
@@ -158,4 +178,6 @@
     }
 
+    fTH->SetValid();
+
     str.Remove(0, end-str.Data()); // Remove TH
     str=str.Strip(TString::kLeading);
@@ -170,6 +192,27 @@
 {
     if (!CheckTag(str, "TD "))
-        return kFALSE;
-
+        return kTRUE;
+
+    // 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;
 
@@ -191,6 +234,9 @@
     }
 
+    fTD->SetValid();
+
     str.Remove(0, end-str.Data()); // Remove TD
     str=str.Strip(TString::kLeading);
+
     return kTRUE;
 }
@@ -238,9 +284,18 @@
         return kCONTINUE;
 
-    if (!InterpreteTH(str))
-        return kCONTINUE;
-
-    if (!InterpreteTD(str, ver))
-        return kCONTINUE;
+    if (str.BeginsWith("RECEIVERS-COM-ERROR"))
+    {
+        fTD->Invalidate();
+        fTH->Invalidate();
+        str.Remove(0, 19);
+    }
+    else
+    {
+        if (!InterpreteTH(str, ver))
+            return kCONTINUE;
+
+        if (!InterpreteTD(str, ver))
+            return kCONTINUE;
+    }
 
     if (ver>=200510250)
Index: trunk/MagicSoft/Mars/mreport/MReportCC.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportCC.h	(revision 7718)
+++ trunk/MagicSoft/Mars/mreport/MReportCC.h	(revision 7719)
@@ -30,5 +30,5 @@
 
     Bool_t InterpreteCC(TString &str, Int_t ver);
-    Bool_t InterpreteTH(TString &str);
+    Bool_t InterpreteTH(TString &str, Int_t ver);
     Bool_t InterpreteTD(TString &str, Int_t ver);
     Bool_t InterpreteRecTemp(TString &str);
Index: trunk/MagicSoft/Mars/mreport/MReportFileReadCC.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportFileReadCC.cc	(revision 7718)
+++ trunk/MagicSoft/Mars/mreport/MReportFileReadCC.cc	(revision 7719)
@@ -127,5 +127,5 @@
     const Int_t ver = atoi(str.Data());
 
-    *fLog << dbg << "Report File version: <" << ver << ">" << endl;
+    *fLog << all << "Report File version: <" << ver << ">" << endl;
 
     SetVersion(ver);
