Index: branches/Corsika7405Compatibility/Makefile
===================================================================
--- branches/Corsika7405Compatibility/Makefile	(revision 18175)
+++ branches/Corsika7405Compatibility/Makefile	(revision 18179)
@@ -78,5 +78,6 @@
           mmovie \
           mtools \
-          mmuon
+          mmuon \
+	  mdebug 
 
 LIBNOVA_PATH := `which libnovaconfig`
Index: branches/Corsika7405Compatibility/mbase/MQuaternion.h
===================================================================
--- branches/Corsika7405Compatibility/mbase/MQuaternion.h	(revision 18175)
+++ branches/Corsika7405Compatibility/mbase/MQuaternion.h	(revision 18179)
@@ -9,5 +9,5 @@
 #ifndef ROOT_TQuaternion
 #include <math.h>
-#define sqrt ::sqrt
+//#define sqrt ::sqrt
 #include <TQuaternion.h>
 #undef sqrt
Index: branches/Corsika7405Compatibility/mcorsika/MCorsikaFormat.cc
===================================================================
--- branches/Corsika7405Compatibility/mcorsika/MCorsikaFormat.cc	(revision 18175)
+++ branches/Corsika7405Compatibility/mcorsika/MCorsikaFormat.cc	(revision 18179)
@@ -57,8 +57,8 @@
     }
 
-    char *buffer = new char[5];
-    memset(buffer, 0, 5);
-    fileIn->read(buffer, 4);
-    fileIn->seekg(-4, ios::cur);
+    char *buffer = new char[9];
+    memset(buffer, 0, 9);
+    fileIn->read(buffer, 8);
+    fileIn->seekg(-8, ios::cur);
 
     if (strcmp(buffer, "RUNH") == 0)
@@ -67,7 +67,13 @@
         return new MCorsikaFormatRaw(fileIn);
     }
-
+    else if(strcmp(&buffer[4], "RUNH") == 0)
+    {
+    	fileIn->seekg(4, ios::cur);
+    	delete [] buffer;
+    	return new MCorsikaFormatRaw(fileIn, true);
+    }
     if (*reinterpret_cast<unsigned int*>(buffer) == kSyncMarker)
     {
+    	//std::cout << "EventIO!!" << std::endl;
         delete [] buffer;
         return new MCorsikaFormatEventIO(fileIn);
@@ -84,4 +90,5 @@
 Bool_t MCorsikaFormat::Read(void *ptr, Int_t i) const
 {
+	//std::cout << "RawRead of " << i << " Bytes" << std::endl;
    fIn->read((char*)ptr, i);
    return !fIn->fail();
@@ -114,5 +121,5 @@
                                     Int_t & blockLength) const
 {
-
+	//std::cout << "||||||| NextBlock " << std::endl;
     int blockHeader;
     fIn->read((char*)&blockHeader, 4);
@@ -120,4 +127,5 @@
         return kFALSE;
 
+
     blockVersion = 0;
     blockIdentifier = 0;
@@ -134,8 +142,8 @@
       case 1213486661 : // EVTH
          if (readState != 10)
-            blockType = 1202;
+         { blockType = 1202; }
          else
             {
-            blockType = 1105;
+        	 blockType = 1105;
             fIn->seekg(-4, ios::cur);
             blockLength += 4;
@@ -159,5 +167,8 @@
     for (int i=1; i<22; i++)
     {
-        fIn->seekg(-i*273*4, ios::end);
+    	if(fFortranRaw)
+    		fIn->seekg(-i*273*4 - 4, ios::end);
+    	else
+    		fIn->seekg(-i*273*4, ios::end);
 
         char runh[5]="\0\0\0\0";
@@ -196,5 +207,5 @@
       fIn->read((char*)blockHeader, 3 * sizeof(int));
 
-      if (fIn->eof())
+     if (fIn->eof())
          return kFALSE;
 
@@ -204,4 +215,8 @@
       blockIdentifier = blockHeader[1];
       blockLength     = blockHeader[2] & 0x3FFFFFFF;
+
+      std::cout << "ReadState " << readState << " | Type:"
+                << blockType << " Version:" << blockVersion << " Length:" << blockLength << " Id:" << blockIdentifier << std::endl;
+
       }
    else
@@ -210,5 +225,5 @@
        fIn->read((char*)blockHeader, 4 * sizeof(int));
 
-       if (fIn->eof())
+      if (fIn->eof())
            return kFALSE;
 
@@ -218,4 +233,8 @@
        blockIdentifier = blockHeader[2];
        blockLength     = blockHeader[3] & 0x3FFFFFFF;
+
+       std::cout << "ReadState " << readState << " | Type:"
+                 << blockType << " Version:" << blockVersion << " Length:" << blockLength << " Id:" << blockIdentifier << std::endl;
+
 
        if (blockType == 1200  || blockType == 1210 ||
Index: branches/Corsika7405Compatibility/mcorsika/MCorsikaFormat.h
===================================================================
--- branches/Corsika7405Compatibility/mcorsika/MCorsikaFormat.h	(revision 18175)
+++ branches/Corsika7405Compatibility/mcorsika/MCorsikaFormat.h	(revision 18179)
@@ -17,4 +17,6 @@
 protected:
    std::istream  *fIn;
+
+   Bool_t fMMCS = true;
 
 public:
@@ -38,5 +40,8 @@
            Bool_t Read(void *ptr, Int_t i) const;
 
+
    static MCorsikaFormat *CorsikaFormatFactory(const char *fileName);
+
+   const Bool_t isMMCS() {return fMMCS;}
 };
 
@@ -45,8 +50,11 @@
 {
 private:
+	Bool_t fFortranRaw = false;
 
 public:
    MCorsikaFormatRaw(std::istream * in)
         : MCorsikaFormat(in) {}
+   MCorsikaFormatRaw(std::istream* in, Bool_t fortranRaw)
+   	    : MCorsikaFormat(in), fFortranRaw (fortranRaw) {}
 
    Bool_t NextBlock(Int_t   readState, Int_t & blockType, Int_t & blockVersion,
Index: branches/Corsika7405Compatibility/mcorsika/MCorsikaRead.cc
===================================================================
--- branches/Corsika7405Compatibility/mcorsika/MCorsikaRead.cc	(revision 18175)
+++ branches/Corsika7405Compatibility/mcorsika/MCorsikaRead.cc	(revision 18179)
@@ -290,4 +290,6 @@
                   status = fInFormat->Read(buffer, 272 * sizeof(Float_t));
                   status = fRunHeader->ReadEventHeader(buffer);
+                  //std::cout << "\x1b[31;1m EVTH Header: \x1b[0m";
+                  //fRunHeader->Print(nullptr);
                   break;
                   }
@@ -329,5 +331,5 @@
 Int_t MCorsikaRead::ReadTelescopePosition()
 {
-   if (!fInFormat->Read(&fNumTelescopes, 4)) return kERROR;
+	if (!fInFormat->Read(&fNumTelescopes, 4)) return kERROR;
 
    if (fTelescopeIdx>=fNumTelescopes)
@@ -474,6 +476,9 @@
 Int_t MCorsikaRead::Process()
 {
+	//std::cout << "Process \n\n" << std::endl;
    while (1)  // loop for multiple input files
    {
+	   //std::cout << "OuterLoop \n\n" << std::endl;
+
       if (fInFormat)
       {
@@ -492,4 +497,8 @@
 
          Int_t status = kTRUE;
+
+         //std::cout << "||||ReadState: " << fReadState
+        //		 << "  Block: " << fBlockType << "\n\n" << std::endl;
+
          switch (fBlockType)
             {
@@ -500,4 +509,5 @@
 
             case 1201:       // telescope position
+            //	std::cout << "TelescopPos ||||||" << std::endl;
                status = ReadTelescopePosition();
                break;
@@ -505,4 +515,6 @@
             case 1202:  // the event header
                Float_t buffer[272];
+               static int asd = 0;
+              // std::cout << "EventHeader |||||| " << ++asd << std::endl;
                if (!fInFormat->Read(buffer, 272 * sizeof(Float_t))) 
                   return kFALSE;
@@ -511,8 +523,12 @@
                   {
                   fRunHeader->ReadEventHeader(buffer);
-                  fRunHeader->Print();
+                  //fRunHeader->Print();
                   }
 
                status = fEvtHeader->ReadEvt(buffer);
+
+               //fEvtHeader->Print();
+               //std::cout << "TotReuse: " << fEvtHeader->GetTotReuse();
+
                if (fArrayIdx >= (Int_t)fEvtHeader->GetTotReuse())
                   {
@@ -527,4 +543,5 @@
 
             case 1204: // top level block for one array (only for eventio data)
+            //	std::cout << "EventIO1 |||||||" << std::endl;
                if (fArrayIdx < 0 || fArrayIdx == fBlockIdentifier)
                   { 
@@ -535,5 +552,5 @@
                   // skip this array of telescopes
                   fInFormat->Seek(fBlockLength);
-
+               	   std::cout << "Skip Array!" << std::endl;
                break;
 
@@ -541,9 +558,14 @@
             case 1205: // eventio data
                {
+              // std::cout << "EventIO2 |||||||" << std::endl;
                Int_t telIdx   = fBlockIdentifier % 1000;
-               if (fBlockVersion == 0                               &&
-                     (fTelescopeIdx < 0 || fTelescopeIdx ==  telIdx)     )
-                  {
+           //    std::cout << "TelIDX: " << telIdx << " fTelescopeIdx:" << fTelescopeIdx
+            //		   << " fBlockVersion" << fBlockVersion << std::endl;
+
+               if (fBlockVersion == 0  && (fTelescopeIdx < 0 || fTelescopeIdx ==  telIdx) )
+               {
                   status = fEvent->ReadEventIoEvt(fInFormat);
+
+                  //std::cout << " ArrayIdx:" << fBlockIdentifier / 1000.0 << std::endl;
 
                   Int_t arrayIdx = fBlockIdentifier / 1000;
@@ -560,9 +582,14 @@
                else
                   // skip this telescope
+               {
                   fInFormat->Seek(fBlockLength);
+
+               	   std::cout << "Skip this telescope!" << std::endl;
+               }
                }
                break;
 
             case 1209:  // the event end
+           // 	std::cout << "EventEnd ||||||" << std::endl;
                status = fEvtHeader->ReadEvtEnd(fInFormat);
                
@@ -581,4 +608,5 @@
 
             case 1210:  // the run end
+            	//std::cout << "RunEnd ||||||" << std::endl;
                status = fRunHeader->ReadEvtEnd(fInFormat, kTRUE);
                fNumEvents += fRunHeader->GetNumEvents();
@@ -594,4 +622,6 @@
 
             case 1105:  // event block of raw format
+            	static int NmrEventBlock = 0;
+            	//std::cout << "EventBlock ||||||" << ++NmrEventBlock << std::endl;
                if (fReadState == 2 || fReadState == 10)
                   {
@@ -607,4 +637,5 @@
 
             case 1109:  // save corsika events
+            	//std::cout << "SaveCorsika ||||||" << std::endl;
                fEvtHeader->InitXY();
                status = fEvent->ReadCorsikaEvt(&fRawEvemtBuffer[0], 
@@ -630,8 +661,11 @@
             default:
                // unknown block, we skip it
+               std::cout << "UnknownBlock " << fBlockType << std::endl;
                fReadState = 15;
                fInFormat->Seek(fBlockLength);
 
             }
+
+         std::cout << "Status: " << status << std::endl;
 
          if (status != kTRUE)
@@ -640,4 +674,8 @@
 
          Int_t headerStatus =  ReadNextBlockHeader();
+
+         std::cout << "Header Status: " << headerStatus << std::endl;
+
+
          if (headerStatus == kFALSE) 
             // end of file
Index: branches/Corsika7405Compatibility/mcorsika/MCorsikaRunHeader.cc
===================================================================
--- branches/Corsika7405Compatibility/mcorsika/MCorsikaRunHeader.cc	(revision 18175)
+++ branches/Corsika7405Compatibility/mcorsika/MCorsikaRunHeader.cc	(revision 18179)
@@ -179,8 +179,8 @@
     fCerenkovFlag = TMath::Nint(g[75]);
 
-    fZdMin = g[79];                // lower edge of theta in °
-    fZdMax = g[80];                // upper edge of theta in °
-    fAzMin = 180-g[81];            // lower edge of phi   in °
-    fAzMax = 180-g[82];            // upper edge of phi   in °
+    fZdMin = g[79];                // lower edge of theta in �
+    fZdMax = g[80];                // upper edge of theta in �
+    fAzMin = 180-g[81];            // lower edge of phi   in �
+    fAzMax = 180-g[82];            // upper edge of phi   in �
     // FIXME: Correct for direction of magnetic field!
 
@@ -207,6 +207,10 @@
     fWavelengthMax = g[95];        // Cherenkov bandwidth upper end in nm
 
-    fViewConeInnerAngle = g[151];  // inner angle of view cone (°)
-    fViewConeOuterAngle = g[152];  // outer angle of view cone (°)
+    std::cout << "Version: " << fProgramVersion << std::endl;
+    std::cout << "Wavelength: " << fWavelengthMin << " - " << fWavelengthMax << std::endl;
+    if((abs(fWavelengthMax - 700)< 0.1) && (abs(fProgramVersion - 7.4005)< 1E-5)) fWavelengthMax = 900;
+
+    fViewConeInnerAngle = g[151];  // inner angle of view cone (�)
+    fViewConeOuterAngle = g[152];  // outer angle of view cone (�)
 
     return kTRUE;
Index: branches/Corsika7405Compatibility/mdebug/MDebugOut.cc
===================================================================
--- branches/Corsika7405Compatibility/mdebug/MDebugOut.cc	(revision 18179)
+++ branches/Corsika7405Compatibility/mdebug/MDebugOut.cc	(revision 18179)
@@ -0,0 +1,79 @@
+/*
+ * MTraceOut.cpp
+ *
+ *  Created on: 07.05.2015
+ *      Author: dominik
+ */
+
+#include "MDebugOut.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+#include "MRawRunHeader.h"
+
+#include "MCorsikaRunHeader.h"
+#include "MCorsikaEvtHeader.h"
+
+#include "MMcRunHeader.hxx"
+#include "MMcCorsikaRunHeader.h"
+
+#include "MPhotonEvent.h"
+#include "MPhotonData.h
+
+ClassImp(MDebugOut);
+
+MDebugOut::MDebugOut() {
+	// TODO Auto-generated constructor stub
+
+}
+
+// MTask
+Int_t MDebugOut::PreProcess(MParList *plist)
+{
+	fEvtHeader = (MCorsikaEvtHeader*) plist->FindObject("MCorsikaEvtHeader");
+	if (!fEvtHeader)
+	{
+		*fLog << err << "MCorsikaEvtHeader not found... aborting." << std::endl;
+		return kFALSE;
+	}
+
+	fRunHeader = (MCorsikaRunHeader*) plist->FindObject("MCorsikaRunHeader");
+	if (!fRunHeader)
+	{
+		*fLog << err << "MCorsikaRunHeader not found... aborting." << std::endl;
+		return kFALSE;
+	}
+
+	fEvt = (MPhotonEvent*) plist->FindObject("MPhotonEvent");
+	if (!fEvt)
+	{
+		*fLog << err << "MPhotonEvent not found... aborting." << endl;
+		return kFALSE;
+	}
+
+	fStat = (MPhotonStatistics*) plist->FindObject("MPhotonStatistics");
+	if (!fStat)
+	{
+		*fLog << err << "MPhotonStatistics not found... aborting." << endl;
+		return kFALSE;
+	}
+
+
+	return kTRUE;
+}
+
+Bool_t MDebugOut::ReInit(MParList *pList)
+{
+	return kTRUE;
+}
+
+Int_t MDebugOut::Process()
+{
+	std::cout << "";
+	return kTRUE;
+}
Index: branches/Corsika7405Compatibility/mdebug/MDebugOut.h
===================================================================
--- branches/Corsika7405Compatibility/mdebug/MDebugOut.h	(revision 18179)
+++ branches/Corsika7405Compatibility/mdebug/MDebugOut.h	(revision 18179)
@@ -0,0 +1,38 @@
+/*
+ * MTraceOut.h
+ *
+ *  Created on: 07.05.2015
+ *      Author: dominik
+ */
+
+#ifndef MTEST_MTRACEOUT_H_
+#define MTEST_MTRACEOUT_H_
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MDebugOut :	public MTask
+{
+private:
+	// MTask
+	Int_t  PreProcess(MParList *pList);
+	Bool_t ReInit(MParList *pList);
+	Int_t  Process();
+
+
+	MCorsikaEvtHeader *fEvtHeader;    //!
+	MCorsikaRunHeader *fRunHeader;    //!
+	MMcRunHeader      *fMcRunHeader;  //!
+	MPhotonEvent      *fEvt;     //! Event storing the photons
+	MPhotonStatistics *fStat;    //! Event statistics needed for crosschecks
+
+public:
+	MDebugOut();
+
+
+	ClassDef(MDebugOut, 0) // Output and trace things for debugging
+
+};
+
+#endif /* MTEST_MTRACEOUT_H_ */
Index: branches/Corsika7405Compatibility/mdebug/Makefile
===================================================================
--- branches/Corsika7405Compatibility/mdebug/Makefile	(revision 18179)
+++ branches/Corsika7405Compatibility/mdebug/Makefile	(revision 18179)
@@ -0,0 +1,32 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.general
+include ../Makefile.conf.$(OSTYPE)
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Debug
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgui
+# mgui - MCameraDC <MCamEvent>
+
+SRCFILES = MDebugOut.cc 
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: branches/Corsika7405Compatibility/msim/MPhotonData.cc
===================================================================
--- branches/Corsika7405Compatibility/msim/MPhotonData.cc	(revision 18175)
+++ branches/Corsika7405Compatibility/msim/MPhotonData.cc	(revision 18179)
@@ -273,5 +273,5 @@
 Int_t MPhotonData::FillEventIO(Float_t f[8])
 {
-    // photons in this bunch
+	// photons in this bunch
     const UInt_t n = TMath::Nint(f[6]);
     if (n==0)
@@ -292,4 +292,5 @@
     fTag        = -1;
     fWeight     =  1;
+
 
     return n;
Index: branches/Corsika7405Compatibility/msim/MPhotonData.h
===================================================================
--- branches/Corsika7405Compatibility/msim/MPhotonData.h	(revision 18175)
+++ branches/Corsika7405Compatibility/msim/MPhotonData.h	(revision 18179)
@@ -16,5 +16,5 @@
 #ifndef ROOT_TQuaternion
 #include <math.h>
-#define sqrt ::sqrt
+//#define sqrt ::sqrt
 #include <TQuaternion.h>
 #undef sqrt
Index: branches/Corsika7405Compatibility/msim/MPhotonEvent.cc
===================================================================
--- branches/Corsika7405Compatibility/msim/MPhotonEvent.cc	(revision 18175)
+++ branches/Corsika7405Compatibility/msim/MPhotonEvent.cc	(revision 18179)
@@ -512,4 +512,9 @@
    fInFormat->Read(bunchHeader, 3 * sizeof(Int_t));
 
+
+   //std::cout << "BunchHeader: " << bunchHeader[0] << " "
+	//	   << bunchHeader[1] << " "
+	//	   << bunchHeader[2] << std::endl;
+
    Int_t n = 0;
 
@@ -520,5 +525,5 @@
 
       if (Add(n).FillEventIO(buffer))
-         n++;
+          n++;
       }
 
Index: branches/Corsika7405Compatibility/msimcamera/MSimAPD.cc
===================================================================
--- branches/Corsika7405Compatibility/msimcamera/MSimAPD.cc	(revision 18175)
+++ branches/Corsika7405Compatibility/msimcamera/MSimAPD.cc	(revision 18179)
@@ -307,5 +307,5 @@
             *fLog << err << "ERROR - MSimAPD: Weight of " << i << "-th photon not 1, but " << ph.GetWeight() << endl;
             ph.Print();
-            return kERROR;
+            //return kERROR;
         }
 
