Index: trunk/Mars/mfileio/MWriteFitsFile.cc
===================================================================
--- trunk/Mars/mfileio/MWriteFitsFile.cc	(revision 15277)
+++ trunk/Mars/mfileio/MWriteFitsFile.cc	(revision 17148)
@@ -15,4 +15,6 @@
 #include "MWriteFitsFile.h"
 #include "MFitsArray.h"
+
+#include "MTime.h"
 
 //for find
@@ -337,4 +339,81 @@
     return kTRUE;
 }
+
+void MWriteFitsFile::SetupHeaderKeys(MRawRunHeader &header)
+{
+    const MTime now(-1);
+    SetHeaderKey("ISMC",true,"Bool if File is Montecarlo File");
+    SetHeaderKey("TELESCOP", "FACT", "");
+    SetHeaderKey("PACKAGE", "MARS Cheobs", "");
+    SetHeaderKey("VERSION", "1.0", "");
+    SetHeaderKey("CREATOR", "Ceres", "");
+    SetHeaderKey("EXTREL", 1., "");
+    SetHeaderKey("COMPILED", __DATE__" "__TIME__, "");
+    //SetHeaderKey("REVISION", "0", "");
+    SetHeaderKey("ORIGIN", "FACT", "");
+    SetHeaderKey("DATE", now.GetStringFmt("%Y-%m-%dT%H:%M:%S").Data(), "");
+    SetHeaderKey("NIGHT", now.GetNightAsInt(), "");
+    SetHeaderKey("TIMESYS", "UTC", "");
+    SetHeaderKey("TIMEUNIT", "d", "");
+    SetHeaderKey("MJDREF", 40587, "");
+    //SetHeaderKey("BLDVER", 1, "");
+    SetHeaderKey("RUNID", header.GetRunNumber(), "");
+    SetHeaderKey("NBOARD", 40, "");
+    SetHeaderKey("NPIX", header.GetNumPixel(), "");
+    SetHeaderKey("NROI", header.GetNumSamplesHiGain(), "");
+    SetHeaderKey("NROITM", 0, "");
+    SetHeaderKey("TMSHIFT", 0, "");
+    SetHeaderKey("CAMERA", "MGeomCamFACT", "Montecarlo File");
+    SetHeaderKey("DAQ", "DRS4", "Montecarlo File");
+
+    // FTemme: ADCRANGE and ADC have to be calculated, using the values for
+    // the fadctype.
+//    SetHeaderKey("ADCRANGE", 2000, "Dynamic range in mV");
+//    SetHeaderKey("ADC", 12, "Resolution in bits");
+
+    switch(header.GetRunType())
+    {
+    case MRawRunHeader::kRTData|MRawRunHeader::kRTMonteCarlo:
+        SetHeaderKey("RUNTYPE", "data", "");
+        break;
+    case MRawRunHeader::kRTPedestal|MRawRunHeader::kRTMonteCarlo:
+        SetHeaderKey("RUNTYPE", "pedestal", "");
+        break;
+    case MRawRunHeader::kRTCalibration|MRawRunHeader::kRTMonteCarlo:
+        SetHeaderKey("RUNTYPE", "calibration", "");
+        break;
+    }
+//    SetHeaderKey("ID", 777, "Board  0: Board ID");
+//    SetHeaderKey("FMVER", 532, "Board  0: Firmware Version");
+//    SetHeaderKey("DNA", "0", "");
+//    SetHeaderKey("BOARD", 0, "");
+//    SetHeaderKey("PRESC", 40, "");
+//    SetHeaderKey("PHASE", 0, "");
+//    SetHeaderKey("DAC0", 26500, "");
+//    SetHeaderKey("DAC1", 0, "");
+//    SetHeaderKey("DAC2", 0, "");
+//    SetHeaderKey("DAC3", 0, "");
+//    SetHeaderKey("DAC4", 28800, "");
+//    SetHeaderKey("DAC5", 28800, "");
+//    SetHeaderKey("DAC6", 28800, "");
+//    SetHeaderKey("DAC7", 28800, "");
+    SetHeaderKey("REFCLK", header.GetFreqSampling(), "");
+    SetHeaderKey("DRSCALIB", false, "");
+//    SetHeaderKey("TSTARTI", 0, "");
+//    SetHeaderKey("TSTARTF", 0., "");
+//    SetHeaderKey("TSTOPI", 0, "");
+//    SetHeaderKey("TSTOPF", 0., "");
+//    SetHeaderKey("DATE-OBS", "1970-01-01T00:00:00", "");
+//    SetHeaderKey("DATE-END", "1970-01-01T00:00:00", "");
+//    SetHeaderKey("NTRG", 0, "");
+//    SetHeaderKey("NTRGPED", 0, "");
+//    SetHeaderKey("NTRGLPE", 0, "");
+//    SetHeaderKey("NTRGTIM", 0, "");
+//    SetHeaderKey("NTRGLPI", 0, "");
+//    SetHeaderKey("NTRGEXT1", 0, "");
+//    SetHeaderKey("NTRGEXT2", 0, "");
+//    SetHeaderKey("NTRGMISC", 0, "");
+}
+
 template<>
 std::string MWriteFitsFile::GetFitsString(const double& value)
@@ -1127,4 +1206,8 @@
       return kFALSE;
 
+
+   MRawRunHeader* header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+   SetupHeaderKeys(*header);
+
    if (GetContainer(pList) == kFALSE)
       return kFALSE;
Index: trunk/Mars/mfileio/MWriteFitsFile.h
===================================================================
--- trunk/Mars/mfileio/MWriteFitsFile.h	(revision 15277)
+++ trunk/Mars/mfileio/MWriteFitsFile.h	(revision 17148)
@@ -19,4 +19,10 @@
 #include "MFitsArray.h"
 #endif
+
+#ifndef MARS_MRawRunHeader
+#include "MRawRunHeader.h"
+#endif
+
+class MRawRunHeader;
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -137,4 +143,6 @@
    Int_t       PreProcess(MParList *pList);
    Int_t       PostProcess();
+
+   void        SetupHeaderKeys(MRawRunHeader &header);
 
    //Header keys related stuff
