Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2579)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2580)
@@ -30,4 +30,19 @@
    * mtemp/MObservatory.cc:
      - changed telescope position (kMagic1) according to new data from GPS clock
+
+   * readraw.cc:
+     - changed includes
+     
+   * mbase/MPrint.[h,cc]:
+     - added kSeperator
+
+   * mbase/MTime.[h,cc]:
+     - added SetTime(const TTime&)
+
+   * mraw/MRawEvtHeader.cc:
+     - added 'nogains' option to Print
+     
+   * readdaq.cc:
+     - added
 
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 2579)
+++ trunk/MagicSoft/Mars/NEWS	(revision 2580)
@@ -36,4 +36,6 @@
   - added classes to calculate event rate
     (preliminary: MEventRateCalc, MEventRate)
+
+  - added new executable 'readdaq' to read *.raw files from the DAQ directly
 
 
Index: trunk/MagicSoft/Mars/mbase/MPrint.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MPrint.cc	(revision 2579)
+++ trunk/MagicSoft/Mars/mbase/MPrint.cc	(revision 2580)
@@ -62,4 +62,10 @@
 }
 
+MPrint::MPrint()
+{
+    Init(0, 0);
+    SetBit(kSeperator);
+}
+
 // --------------------------------------------------------------------------
 //
@@ -112,5 +118,5 @@
     // The pointer is already given by the user.
     //
-    if (fObject)
+    if (fObject || TestBit(kSeperator))
         return kTRUE;
 
@@ -144,5 +150,8 @@
 Int_t MPrint::Process()
 {
-    fObject->Print(fOption);
+    if (TestBit(kSeperator))
+        gLog << endl << setfill('-') << setw(72) << "-" << endl << endl;
+    else
+        fObject->Print(fOption);
     return kTRUE;
 } 
Index: trunk/MagicSoft/Mars/mbase/MPrint.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MPrint.h	(revision 2579)
+++ trunk/MagicSoft/Mars/mbase/MPrint.h	(revision 2580)
@@ -15,9 +15,10 @@
     TString fOption;         // Print option
 
-    enum { kSkip = BIT(14) };
+    enum { kSkip = BIT(14), kSeperator = BIT(15) };
 
     void Init(const char *name, const char *title);
 
 public:
+    MPrint();
     MPrint(const char *obj,    const char *option="", const char *name=NULL, const char *title=NULL);
     MPrint(const TObject *obj, const char *option="", const char *name=NULL, const char *title=NULL);
Index: trunk/MagicSoft/Mars/mbase/MTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTime.cc	(revision 2579)
+++ trunk/MagicSoft/Mars/mbase/MTime.cc	(revision 2580)
@@ -43,4 +43,6 @@
 #include <iomanip>
 
+#include <TTime.h>
+
 #include "MLog.h"
 
@@ -48,4 +50,9 @@
 
 using namespace std;
+
+void MTime::SetTime(const TTime &t)
+{
+    SetTime((ULong_t)t);
+}
 
 void MTime::Print(Option_t *) const
Index: trunk/MagicSoft/Mars/mbase/MTime.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTime.h	(revision 2579)
+++ trunk/MagicSoft/Mars/mbase/MTime.h	(revision 2580)
@@ -14,4 +14,6 @@
 #endif
 
+class TTime;
+
 class MTime : public MParContainer
 {
@@ -24,4 +26,10 @@
     Byte_t   fSec;
     UInt_t   fNanoSec;
+
+    /*
+     UInt_t   fMjd;     // Day in the century        (Day of sun rise)
+     TTime    fTime;    // Time of Day               (43,200,000<x<43,200,000)
+     UShort_t fNanoSec; // NanoSec part of TimeOfDay (<1000)
+     */
 
 public:
@@ -71,4 +79,6 @@
         fHour     = t%24;
     }
+
+    void SetTime(const TTime &t);
 
     void SetTime(Double_t t)
Index: trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 2579)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 2580)
@@ -207,4 +207,10 @@
     *fLog << "Number of Lo Gains On: " << fNumLoGainOn << endl;
 
+    TString str(o);
+    str.ToLower();
+
+    if (str.Contains("nogains"))
+        return;
+
     for (unsigned int i=0; i<fPixLoGainOn->GetSize(); i++)
     {
@@ -245,11 +251,13 @@
     // store the time of the event in the corresponding container
     //
-    const Double_t mhz = 9.375;                        // [1e6 ticks/s]
-    const Double_t t   = (Double_t)abstime[0]/mhz;     // [ns]
-    const UShort_t ns  = (UShort_t)fmod(t*1e-3, 1e9);
-    const Byte_t s     = (Byte_t)fmod(t/1e12, 60);
-    const Byte_t m     = (Byte_t)fmod(t/60e12, 60);
-    const Byte_t h     = (Byte_t)(t/3600e12);
-    fTime->SetTime(h, m, s, ns);
+    /*
+     const Double_t mhz = 9.375;                        // [1e6 ticks/s]
+     const Double_t t   = (Double_t)abstime[0]/mhz;     // [ns]
+     const UShort_t ns  = (UShort_t)fmod(t*1e-3, 1e9);
+     const Byte_t s     = (Byte_t)fmod(t/1e12, 60);
+     const Byte_t m     = (Byte_t)fmod(t/60e12, 60);
+     const Byte_t h     = (Byte_t)(t/3600e12);
+     fTime->SetTime(h, m, s, ns);
+     */
 
     Byte_t dummy[4];
Index: trunk/MagicSoft/Mars/readdaq.cc
===================================================================
--- trunk/MagicSoft/Mars/readdaq.cc	(revision 2580)
+++ trunk/MagicSoft/Mars/readdaq.cc	(revision 2580)
@@ -0,0 +1,194 @@
+#include <TSystem.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MArgs.h"
+#include "MTime.h"
+#include "MPrint.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MRawEvtData.h"
+#include "MRawCrateArray.h"
+#include "MRawFileRead.h"
+
+
+//#include "MInputStreamID.h"
+//#include "MMcEvt.hxx"
+//#include "MMcTrig.hxx"
+
+using namespace std;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// This is an demonstration how to read in a unmerpped daq file
+//
+/////////////////////////////////////////////////////////////////////////////
+
+static void StartUpMessage()
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "              ReadDaq - MARS V" << MARSVER          << endl;
+    gLog << "       MARS - Read and print daq data files"        << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "               Using ROOT v" << ROOTVER             << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+}
+
+static void Usage()
+{
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << "   readdaq [-h] [-?] [-vn] [-dec] [-a0] inputfile[.raw]" << endl << endl;
+    gLog << "     input file:   Magic DAQ binary file." << endl;
+    gLog << "     -a0: Do not use Ansii codes." << endl;
+    gLog << "     -vn: Verbosity level n [default=2]" << endl;
+    gLog << "     -d1: print data in decimal values" << endl;
+    gLog << "     -?/-h: This help" << endl << endl;
+}
+
+int main(int argc, char **argv)
+{
+    StartUpMessage();
+
+    //
+    // Evaluate arguments
+    //
+    MArgs arg(argc, argv);
+
+    if (arg.HasOption("-?") || arg.HasOption("-h"))
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // Set verbosity to highest level.
+    //
+    gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
+
+    if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
+        gLog.SetNoColors();
+
+    const bool kDecimal = arg.HasOption("-d") && arg.GetIntAndRemove("-d")==1;
+
+    //
+    // check for the right usage of the program
+    //
+    if (arg.GetNumArguments()!=1)
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // This is to make argv[i] more readable insidethe code
+    //
+    TString kNamein = arg.GetArgumentStr(0);
+  
+    if (!kNamein.EndsWith(".raw"))
+        kNamein += ".raw";
+
+    //
+    // Initialize Non-GUI (batch) mode
+    //
+    gROOT->SetBatch();
+
+    //
+    // check whether the given files are OK.
+    //
+    if (gSystem->AccessPathName(kNamein, kFileExists))
+    {
+        gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
+        return -1;
+    }
+
+    //
+    //  open the file
+    //
+    gLog << " Open the file '" << kNamein << "'" << endl;
+
+
+    //
+    // create a (empty) list of parameters which can be used by the tasks
+    // and an (empty) list of tasks which should be executed
+    //
+    MParList plist;
+
+    MTaskList tasks;
+    tasks.SetOwner();
+    plist.AddToList(&tasks);
+
+    //
+    // ---- The following is only necessary to supress some output ----
+    //
+    MRawRunHeader runheader;
+    plist.AddToList(&runheader);
+
+    MRawEvtHeader evtheader;
+    plist.AddToList(&evtheader);
+
+    MRawEvtData evtdata;
+    plist.AddToList(&evtdata);
+
+    MRawCrateArray cratearray;
+    plist.AddToList(&cratearray);
+
+    MTime evttime;
+    plist.AddToList(&evttime);
+
+    //
+    // create the tasks which should be executed and add them to the list
+    // in the case you don't need parameter containers, all of them can
+    // be created by MRawFileRead::PreProcess
+    //
+    MRawFileRead read(kNamein);
+    tasks.AddToList(&read);
+
+    MPrint print0;
+    MPrint print1("MRawEvtHeader",  "nogains", "PrintEvtHeader");
+    MPrint print2("MTime",          "", "PrintTime");
+    MPrint print3("MRawCrateArray", "", "PrintCrateArray");
+    MPrint print4("MRawEvtData", kDecimal?"dec":"hex", "PrintEvtData");
+
+    tasks.AddToList(&print0);
+    tasks.AddToList(&print1);
+    tasks.AddToList(&print2);
+    tasks.AddToList(&print3);
+    tasks.AddToList(&print4);
+
+    //
+    // create the looping object and tell it about the parameters to use
+    // and the tasks to execute
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // Start the eventloop which reads the raw file (MRawFileRead) and
+    // write all the information into a root file (MRawFileWrite)
+    //
+    // between reading and writing we can do, transformations, checks, etc.
+    // (I'm think of a task like MRawDataCheck)
+    //
+    if (!magic.Eventloop())
+    {
+        gLog << err << "ERROR: Reading DAQ file failed!" << endl;
+        return -1;
+    }
+
+    gLog << all << "Reading DAQ file finished successfull!" << endl;
+
+    // end of small readin program
+
+    return 0;
+}
Index: trunk/MagicSoft/Mars/readraw.cc
===================================================================
--- trunk/MagicSoft/Mars/readraw.cc	(revision 2579)
+++ trunk/MagicSoft/Mars/readraw.cc	(revision 2580)
@@ -1,7 +1,7 @@
 #include <TSystem.h>
 
-#include "TFile.h"
-#include "TTree.h"
-#include "TBranch.h"
+#include <TFile.h>
+#include <TTree.h>
+#include <TBranch.h>
 
 #include "MParList.h"
