Index: trunk/MagicSoft/Mars/mtemp/mpisa/classes/MReportFileRead.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/classes/MReportFileRead.h	(revision 4890)
+++ trunk/MagicSoft/Mars/mtemp/mpisa/classes/MReportFileRead.h	(revision 4890)
@@ -0,0 +1,66 @@
+#ifndef MARS_MReportFileRead
+#define MARS_MReportFileRead
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+#ifndef MARS_MTime
+#include "MTime.h"
+#endif
+
+/*// gcc 3.2
+//class ifstream;
+#include <iosfwd>
+*/
+
+class THashTable;
+
+class MTime;
+class MReport;
+class MReportHelp;
+
+class MReportFileRead : public MTask
+{
+private:
+    TString     fFileName;  // Name of the input file
+
+    THashTable *fList;      // List of possible reports to be interpreted
+
+    MTime   fStart;         // Time range which should be read from file
+    MTime   fStop;          // Time range which should be read from file
+
+    ULong_t fNumLine;       // line counter
+
+    Int_t   fVersion;       // File format version
+
+    enum { kHasNoHeader = BIT(14) };
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    virtual Int_t CheckFileHeader() { return 0; }
+    MReport *GetReport(const TString &str) const;
+    MReport *GetReport(MReportHelp *help) const;
+    MReportHelp *GetReportHelp(const TString &str) const;
+
+protected:
+    ifstream   *fIn;         //! buffered input stream (file to read from)
+    void SetVersion(Int_t v) { fVersion = v; }
+
+public:
+    MReportFileRead(const char *filename, const char *name=NULL, const char *title=NULL);
+    ~MReportFileRead();
+
+    void SetHasNoHeader() { SetBit(kHasNoHeader); }
+    void SetTimeStart(const MTime &tm) { fStart = tm; }
+    void SetTimeStop(const MTime &tm)  { fStop = tm; }
+
+    Int_t GetVersion() {return fVersion; }
+
+    Bool_t AddToList(const char *name) const;
+
+    ClassDef(MReportFileRead, 0)// Task to read general report file
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mtemp/mpisa/classes/MReportTrigger.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/classes/MReportTrigger.cc	(revision 4438)
+++ trunk/MagicSoft/Mars/mtemp/mpisa/classes/MReportTrigger.cc	(revision 4890)
@@ -29,5 +29,28 @@
 //
 // This is the class interpreting and storing the TRIGGER-REPORT information.
-//  Updated to add IPR; data format follows TDAS 00-07
+//  Updated to add IPR; data format follows TDAS 00-07 ver.6.3 jul-04
+//  http://hegra1.mppmu.mpg.de/MAGIC/private/software/doc/control/tdas0007_v6.3.ps.gz
+//  
+//  *Input:
+//
+//  The report is divided into 8 sections: 
+//  - the cell rates                       (32 fields)
+//  - L1 and L2 table name                 ( 2 fields)
+//  - prescaling factors                  (2x8 fields)
+//  - livetime and deadtime               (5x4 fields)
+//  - L2 output bit rates                (20 integers)
+//  - global rates (before/after presc.)    (2 floats)
+//  - 18 dummy fields                      (18 fields)
+//  - IPR                    (325 hexs + 397 integers) 
+//
+//  *Output:
+//
+//  The values read from the report string are used to fill the following 
+//  containers:
+//  - MTriggerIPR        (Individual Pixel Rates)
+//  - MTriggerCell       (Rate of trigger cells)
+//  - MTriggerBit        (Output Bits from prescaler (before and after presc.)
+//  - MTriggerPrescFact  (Prescaling factors for each bit)
+//  - MTriggerLiveTime   (Values of counters for dead/livetime)
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -37,4 +60,5 @@
 
 #include "MLogManip.h"
+
 #include "MTriggerIPR.h"
 #include "MTriggerCell.h"
@@ -43,4 +67,6 @@
 #include "MTriggerLiveTime.h"
 
+#include "MReportFileRead.h"
+
 ClassImp(MReportTrigger);
 
@@ -64,4 +90,5 @@
 //  - MTriggerBit
 //  - MTriggerPrescFact
+//  - MTriggerLiveTime
 //
 Bool_t MReportTrigger::SetupReading(MParList &plist)
@@ -86,11 +113,13 @@
   if (!fLiveTime)
     return kFALSE;
+
   
   return MReport::SetupReading(plist);
 }
 
-// --------------------------------------------------------------------------
-//
-// Interprete the Cell rates part of the report
+
+// --------------------------------------------------------------------------
+//
+// Interprete the Cell rates section of the report
 //  Read 32 floats separated with a blank
 //
@@ -113,11 +142,10 @@
   str=str.Strip(TString::kLeading);  
 
-      *fLog << warn << "Cell ok!" <<endl;
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Interprete the Prescaling factors part of the report
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the Prescaling factors section of the report
 //
 Bool_t MReportTrigger::InterpretePrescFact(TString &str)
@@ -127,5 +155,4 @@
   
   str.Remove(0, 1);
-  *fLog << warn << str<<endl;
 
   for (i=0;i<gsNPrescFacts;i++)
@@ -157,5 +184,5 @@
 // --------------------------------------------------------------------------
 //
-// Interprete the Scaler with Live-Deadtime part of the report
+// Interprete the Scaler with Live-Deadtime section of the report
 //  Read 4x5 integers separated with a blank
 //
@@ -190,5 +217,5 @@
 // --------------------------------------------------------------------------
 //
-// Interprete the Bit rates part of the report
+// Interprete the Bit rates section of the report
 // 20 integers. First and last two are not used
 //
@@ -260,5 +287,5 @@
 // --------------------------------------------------------------------------
 //
-// Interprete a part of the report without meaning by this time
+// Interprete an unused section of the report 
 // 18 integers
 //
@@ -282,10 +309,11 @@
   str=str.Strip(TString::kLeading);  
 
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Interprete the IPR part of the report
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the IPR section of the report
 //
 Bool_t MReportTrigger::InterpreteIPR(TString &str)
@@ -303,6 +331,7 @@
 //  Read comments for details
 //
-Int_t MReportTrigger::InterpreteBody(TString &str)
-{
+Int_t MReportTrigger::InterpreteBody(TString &str, Int_t ver )
+{
+
     str = str.Strip(TString::kLeading);
  
@@ -318,4 +347,19 @@
     TString tablename = str(0, ws);
     str.Remove(0, ws);
+
+    // Check the Version of CC file, and takes care of the differences
+    // introduced in the format of the report.
+
+    //if (ver<)....
+	
+    // Check the length of the report to take care of the differences
+    // introduced in the format of the report (!Preliminary! the 
+    // Version number of the CC file should be used instead)
+
+    if (str.Length() < 1000)
+      {
+	*fLog << warn << " TRIGGER-REPORT: old report without IPRs" <<endl;
+        return InterpreteOldBody(str);
+      }
 
     // Read the cell rates (32 fields)
@@ -384,2 +428,49 @@
     return str==(TString)"OVER" ? kTRUE : kCONTINUE;
 }
+
+
+// --------------------------------------------------------------------------
+//
+// Interprete the body of the TRIGGER-REPORT string
+//  for OLD runs (older than may-04)
+//
+Bool_t MReportTrigger::InterpreteOldBody(TString &str)
+{
+
+  Int_t len, n;
+  Float_t fPrescalerRates[100]; 
+
+    const char *pos = str.Data();
+    for (int i=0; i<19; i++)
+      {
+        n = sscanf(pos, " %f %n", &fPrescalerRates[i], &len);
+        if (n!=1)
+	  {
+            *fLog << warn << "WARNING - Scaler Value #" << i << " missing." << endl;
+            return kCONTINUE;
+	  }
+        pos += len;
+      }
+
+    n = sscanf(pos, " %f %f %n", &fL2BeforePrescaler, &fL2AfterPrescaler, &len);    if (n!=2)
+      {
+        *fLog << warn << "WARNING - Couldn't read Trigger rates." << endl;
+        return kFALSE;
+      }
+    pos += len;
+    for (int i=0; i<11; i++)
+      {
+        Float_t dummy;
+        n = sscanf(pos, " %f %n", &dummy/*fRates[i]*/, &len);
+        if (n!=1)
+	  {
+            *fLog << warn << "WARNING - Rate #" << i << " missing." << endl;
+            return kFALSE;
+	  }
+        pos += len;
+      }
+    str.Remove(0, pos-str.Data());
+    str.Strip(TString::kBoth);
+    
+    return str==(TString)"OVER" ? kTRUE : kCONTINUE;
+}
Index: trunk/MagicSoft/Mars/mtemp/mpisa/classes/MReportTrigger.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/classes/MReportTrigger.h	(revision 4438)
+++ trunk/MagicSoft/Mars/mtemp/mpisa/classes/MReportTrigger.h	(revision 4890)
@@ -39,6 +39,8 @@
   Bool_t InterpreteL1L2Table(TString &str);
 
-  Int_t InterpreteBody(TString &str);
+  Int_t InterpreteBody(TString &str, Int_t ver);
   
+  Bool_t InterpreteOldBody(TString &str);
+
 public:
     MReportTrigger();
