Index: trunk/MagicSoft/Mars/msim/MSimMMCS.cc
===================================================================
--- trunk/MagicSoft/Mars/msim/MSimMMCS.cc	(revision 9319)
+++ trunk/MagicSoft/Mars/msim/MSimMMCS.cc	(revision 9319)
@@ -0,0 +1,182 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of CheObs, the Modular Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appears in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz,  2/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: CheObs Software Development, 2000-2009
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MSimMMCS
+//
+// Task to copy the Mars CheObs MC headers to the old Mars style
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MSimMMCS.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 "MPointingPos.h"
+
+ClassImp(MSimMMCS);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MSimMMCS::MSimMMCS(const char* name, const char *title)
+{
+    fName  = name  ? name  : "MSimMMCS";
+    fTitle = title ? title : "Task to copy the Mars CheObs MC headers to the old Mars style";
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MSimMMCS::PreProcess(MParList *plist)
+{
+    if (!plist->FindCreateObj("MMcRunHeader"))
+        return kFALSE;
+
+    if (!plist->FindCreateObj("MMcCorsikaRunHeader"))
+        return kFALSE;
+
+    if (!plist->FindCreateObj("MRawRunHeader"))
+        return kFALSE;
+
+    fMcEvtBasic = (MMcEvtBasic*)plist->FindCreateObj("MMcEvtBasic");
+    if (!fMcEvtBasic)
+        return kFALSE;
+
+    fMcEvt = (MMcEvt*)plist->FindCreateObj("MMcEvt");
+    if (!fMcEvt)
+        return kFALSE;
+
+    fPointingPos = (MPointingPos*)plist->FindObject("MPointingPos");
+    if (!fPointingPos)
+    {
+        *fLog << err << "MPointingPos not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fEvtHeader = (MCorsikaEvtHeader*)plist->FindObject("MCorsikaEvtHeader");
+    if (!fEvtHeader)
+    {
+        *fLog << err << "MCorsikaEvtHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRunHeader = (MCorsikaRunHeader*)plist->FindObject("MCorsikaRunHeader");
+    if (!fRunHeader)
+    {
+        *fLog << err << "MCorsikaRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MSimMMCS::ReInit(MParList *plist)
+{
+    MMcCorsikaRunHeader *mch = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader");
+    if (!mch)
+    {
+        *fLog << err << "MMcCorsikaRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    mch->SetSpectrum(fRunHeader->GetSlopeSpectrum(),
+                     fRunHeader->GetEnergyMin(), fRunHeader->GetEnergyMax());
+    mch->SetReadyToSave();
+
+    // ----------------------------------------------------
+
+    MMcRunHeader *mrh = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
+    if (!mrh)
+    {
+        *fLog << err << "MMcRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    //    fNumPheFromDNSB        MMcPedestalNSBAdd   // Number of phe/ns from diffuse NSB
+    mrh->SetNumSimulatedShowers(fRunHeader->GetNumEvents());
+    mrh->SetImpactMax(fRunHeader->GetImpactMax());
+
+    // ----------------------------------------------------
+
+    MRawRunHeader *rh = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
+    if (!rh)
+    {
+        *fLog << err << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    const UInt_t id = fRunHeader->GetParticleID();
+
+    rh->SetRunInfo(1, fRunHeader->GetRunNumber(), 0);
+    rh->SetSourceInfo(MMcEvtBasic::GetParticleName(id));
+    rh->SetReadyToSave();
+
+    // ----------------------------------------------------
+
+    fMcEvtBasic->SetPartId(MMcEvtBasic::ParticleId_t(id));
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MSimMMCS::Process()
+{
+    fMcEvtBasic->SetEnergy(fEvtHeader->GetTotalEnergy());
+    fMcEvtBasic->SetImpact(fEvtHeader->GetImpact());
+
+    fMcEvtBasic->SetTelescopeTheta(fPointingPos->GetZdRad());
+    fMcEvtBasic->SetTelescopePhi(fPointingPos->GetAzRad());
+
+    fMcEvtBasic->SetReadyToSave();
+
+    static_cast<MMcEvtBasic&>(*fMcEvt) = *fMcEvtBasic;
+
+    fMcEvt->SetTheta(fEvtHeader->GetZd());
+    fMcEvt->SetPhi(fEvtHeader->GetAz());
+
+    fMcEvt->SetEvtNumber(fEvtHeader->GetEvtNumber());
+    fMcEvt->SetPhotElfromShower(0);
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/msim/MSimMMCS.h
===================================================================
--- trunk/MagicSoft/Mars/msim/MSimMMCS.h	(revision 9319)
+++ trunk/MagicSoft/Mars/msim/MSimMMCS.h	(revision 9319)
@@ -0,0 +1,35 @@
+#ifndef MARS_MSimMMCS
+#define MARS_MSimMMCS
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+class MMcEvt;
+class MMcEvtBasic;
+class MPointingPos;
+class MCorsikaEvtHeader;
+class MCorsikaRunHeader;
+
+class MSimMMCS : public MTask
+{
+private:
+    MMcEvtBasic       *fMcEvtBasic;
+    MMcEvt            *fMcEvt;
+    MPointingPos      *fPointingPos;
+    MCorsikaEvtHeader *fEvtHeader;
+    MCorsikaRunHeader *fRunHeader;
+
+    // MTask
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t  Process();
+
+public:
+    MSimMMCS(const char* name=0, const char *title=0);
+
+    ClassDef(MSimMMCS, 0) // Task to copy the Mars CheObs MC headers to the old Mars style
+};
+
+#endif
Index: trunk/MagicSoft/Mars/msim/Makefile
===================================================================
--- trunk/MagicSoft/Mars/msim/Makefile	(revision 9308)
+++ trunk/MagicSoft/Mars/msim/Makefile	(revision 9319)
@@ -20,9 +20,10 @@
 #
 INCLUDES = -I. -I../mbase -I../mmc -I../mgeom -I../mgui -I../mcorsika \
-           -I../mpointing -I../msimreflector -I../mhbase 
+           -I../mpointing -I../msimreflector -I../mhbase -I../mraw
 
 SRCFILES = MPhotonData.cc \
 	   MPhotonEvent.cc \
 	   MHPhotonEvent.cc \
+	   MSimMMCS.cc \
 	   MSimAbsorption.cc \
 	   MSimPointingPos.cc
Index: trunk/MagicSoft/Mars/msim/SimLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/msim/SimLinkDef.h	(revision 9308)
+++ trunk/MagicSoft/Mars/msim/SimLinkDef.h	(revision 9319)
@@ -15,3 +15,5 @@
 #pragma link C++ class MSimAbsorption+;
 
+#pragma link C++ class MSimMMCS+;
+
 #endif
