Index: trunk/MagicSoft/Mars/mraw/MRawCrateData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawCrateData.cc	(revision 8943)
+++ trunk/MagicSoft/Mars/mraw/MRawCrateData.cc	(revision 8944)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -33,8 +33,7 @@
 #include "MRawCrateData.h"
 
-#include <iostream>
-#include <iomanip>
+#include <fstream>
 
-#include <fstream>
+#include <TArrayC.h>
 
 #include "MLog.h"
@@ -54,5 +53,5 @@
 //  like specified in a TDAS note
 //
-void MRawCrateData::ReadEvt(istream& fin, UShort_t ver)
+Bool_t MRawCrateData::ReadEvtOld(istream& fin, UShort_t ver)
 {
     if (ver<7)
@@ -97,4 +96,39 @@
         fin.read((char*)&dummys, 2); //   U16 TrigTimeInterpol;
     }
+
+    return fin.eof() ? kFALSE : kTRUE;
+}
+
+Bool_t MRawCrateData::ReadEvt(istream& fin, UShort_t ver, UInt_t size)
+{
+    if (ver<11)
+        return ReadEvtOld(fin, ver);
+
+    if (size==0)
+    {
+        *fLog << err << "ERROR - Event header size unknown." << endl;
+        return kFALSE;
+    }
+
+    if (size<28)
+    {
+        *fLog << err << "ERROR - Event header too small (<28b)." << endl;
+        return kFALSE;
+    }
+
+    TArrayC h(size);
+    fin.read(h.GetArray(), h.GetSize());
+    if (!fin)
+        return kFALSE;
+
+    // ----- convert -----
+    //const Byte_t  *Char  = reinterpret_cast<Byte_t* >(h.GetArray());
+    const UInt_t  *Int   = reinterpret_cast<UInt_t* >(h.GetArray());
+    //const Float_t *Float = reinterpret_cast<Float_t*>(h.GetArray());
+
+    fDAQCrateNumber = Int[0];
+    fFADCEvtNumber  = Int[3];
+
+    return kTRUE;
 }
 
Index: trunk/MagicSoft/Mars/mraw/MRawCrateData.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawCrateData.h	(revision 8943)
+++ trunk/MagicSoft/Mars/mraw/MRawCrateData.h	(revision 8944)
@@ -18,4 +18,6 @@
     Byte_t   fABFlags;         // flag describing in which two-slice block the trigger was raised
 
+    Bool_t ReadEvtOld(istream& fin, UShort_t ver);
+
 public:
     MRawCrateData();
@@ -28,6 +30,6 @@
     void Print(Option_t *t=NULL) const;
 
-    void ReadEvt(istream& fin, UShort_t ver);
-    void SkipEvt(istream& fin, UShort_t ver);
+    Bool_t ReadEvt(istream& fin, UShort_t ver, UInt_t size);
+    void   SkipEvt(istream& fin, UShort_t ver);
 
     ClassDef(MRawCrateData, 2) //Container to store the Raw CRATE DATA
Index: trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 8943)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 8944)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -109,6 +109,7 @@
 #include "MRawEvtHeader.h"
 
-#include <iomanip>
 #include <fstream>
+
+#include <TArrayC.h>
 
 #include "MLog.h"
@@ -268,5 +269,5 @@
 // source code.
 //
-Bool_t MRawEvtHeader::DecodeTime(UInt_t abstime[2], UShort_t ver) const
+Bool_t MRawEvtHeader::DecodeTime(const UInt_t tm[2], UShort_t ver) const
 {
     //
@@ -277,4 +278,6 @@
     // Swap bits: 23->16, 22->17, 21->16, 20->19
     //
+    UInt_t abstime[2] = { tm[0], tm[1] };
+
     abstime[0] =
         abstime[0]>>7 & 0x00010000 |
@@ -338,7 +341,7 @@
 // Remark: This 'feature' disallows single runs of more than 11h!
 //
-Int_t MRawEvtHeader::ReadEvt(istream &fin, UShort_t ver)
-{
-    Bool_t rc = kTRUE;
+Int_t MRawEvtHeader::ReadEvtOld(istream &fin, UShort_t ver)
+{
+    Int_t rc = kTRUE;
 
     fin.read((char*)&fDAQEvtNumber, 4);  // Total=4
@@ -379,4 +382,48 @@
 
     return fin.eof() ? kFALSE : rc;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MRawEvtHeader::ReadEvt(istream &fin, UShort_t ver, UInt_t size)
+{
+    if (ver<11)
+        return ReadEvtOld(fin, ver);
+
+    if (size==0)
+    {
+        *fLog << err << "ERROR - Event header size unknown." << endl;
+        return kFALSE;
+    }
+
+    if (size<32)
+    {
+        *fLog << err << "ERROR - Event header too small (<32b)." << endl;
+        return kFALSE;
+    }
+
+    TArrayC h(size);
+    fin.read(h.GetArray(), h.GetSize());
+    if (!fin)
+        return kFALSE;
+
+    // ----- convert -----
+    //const Byte_t  *Char  = reinterpret_cast<Byte_t* >(h.GetArray());
+    const UInt_t  *Int   = reinterpret_cast<UInt_t* >(h.GetArray());
+    //const Float_t *Float = reinterpret_cast<Float_t*>(h.GetArray());
+
+    fDAQEvtNumber   = Int[0];
+    // Decode Time
+    fNumTrigLvl1    = Int[3];
+    fNumTrigLvl2    = Int[4];
+    fTrigPattern[0] = Int[5];
+    fTrigPattern[1] = Int[6];
+    fTrigType       = Int[7];
+
+    // No LoGains for version 7 data
+    fPixLoGainOn->Reset();
+    fNumLoGainOn = 0;
+
+    return DecodeTime(Int+1, ver) ? kTRUE : kCONTINUE;
 }
 
Index: trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 8943)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 8944)
@@ -69,7 +69,9 @@
     MArrayB *fPixLoGainOn;     //! Array which tell you which pixels have lo gain on
 
-    Bool_t DecodeTime(UInt_t abstime[2], UShort_t ver) const;
+    Bool_t DecodeTime(const UInt_t abstime[2], UShort_t ver) const;
 
     Int_t GetNumBytes() const;
+
+    Int_t ReadEvtOld(istream& fin, UShort_t ver);
 
 public:
@@ -77,24 +79,29 @@
     ~MRawEvtHeader();
 
+    // MRawEvtHeader
     void InitRead(MRawRunHeader *rh, MTime *t);
 
+    // Getter
+    UShort_t GetTrigType() const     { return fTrigType; }
+    UInt_t   GetNumTrigLvl1() const  { return fNumTrigLvl1; }
+    UInt_t   GetNumTrigLvl2() const  { return fNumTrigLvl2; }
+    UInt_t   GetDAQEvtNumber() const { return fDAQEvtNumber; }
+    
+    UInt_t   GetTriggerID() const;
+    UInt_t   GetCalibrationPattern() const;
+    UInt_t   GetPulserSlotPattern()  const;
+
+    // Setter
+    void FillHeader(UInt_t, Float_t=0);
+
+    void  SetTriggerPattern( const UInt_t pattern )  {  fTrigPattern[0] = pattern; } // Only for MC!
+    void  SetCalibrationPattern( const UInt_t pattern )  {  fTrigPattern[1] = pattern; } // Only for MC!
+
+    // TObject
     void Clear(Option_t * = NULL);
     void Print(Option_t * = NULL) const;
 
-    void FillHeader(UInt_t, Float_t=0);
-
-    UShort_t   GetTrigType() const     { return fTrigType; }
-    UInt_t     GetNumTrigLvl1() const  { return fNumTrigLvl1; }
-    UInt_t     GetNumTrigLvl2() const  { return fNumTrigLvl2; }
-    UInt_t     GetDAQEvtNumber() const { return fDAQEvtNumber; }
-    
-    UInt_t     GetTriggerID() const;
-    UInt_t     GetCalibrationPattern() const;
-    UInt_t     GetPulserSlotPattern()  const;
-
-    void       SetTriggerPattern( const UInt_t pattern )  {  fTrigPattern[0] = pattern; } // Only for MC!
-    void       SetCalibrationPattern( const UInt_t pattern )  {  fTrigPattern[1] = pattern; } // Only for MC!
-
-    Int_t ReadEvt(istream& fin, UShort_t ver);
+    // I/O
+    Int_t ReadEvt(istream& fin, UShort_t ver, UInt_t size);
     void  SkipEvt(istream& fin, UShort_t ver);
 
