Index: trunk/Mars/mraw/MRawFitsRead.cc
===================================================================
--- trunk/Mars/mraw/MRawFitsRead.cc	(revision 18562)
+++ trunk/Mars/mraw/MRawFitsRead.cc	(revision 18563)
@@ -156,4 +156,6 @@
     }
 
+    fIsMc = fin.HasKey("ISMC");
+
     const string type = fin.GetStr("RUNTYPE");
 
@@ -164,10 +166,9 @@
     fRawRunHeader->SetRunInfo(0, fin.GetUInt("NIGHT"), fin.GetUInt("RUNID"));
     fRawRunHeader->InitFact(fin.GetUInt("NPIX")/9, 9, fin.GetUInt("NROI"), fPixelMap.size()==0?0:fPixelMap.data());
-    if (!fin.HasKey("ISMC")){
-        fRawRunHeader->SetFormat(0xf172, fin.GetUInt("BLDVER"));
-    }
+    fRawRunHeader->SetFormat(0xf172, fIsMc ? 0 : fin.GetUInt("BLDVER"));
     fRawRunHeader->SetRunType(0/*data*/);
 
-    if (!fin.HasKey("ISMC")){
+    if (!fIsMc)
+    {
         const string runstart = fin.GetStr("DATE-OBS");
         const string runstop  = fin.GetStr("DATE-END");
@@ -176,13 +177,20 @@
     }
 
-    if (!fin.HasKey("ISMC"))
-        return
-            fin.HasKey("NPIX") && fin.HasKey("RUNID")  &&
-            fin.HasKey("NROI") && fin.HasKey("BLDVER") &&
-            fin.HasKey("NIGHT");
-    else
-        return
-            fin.HasKey("NPIX") && fin.HasKey("RUNID")  &&
-            fin.HasKey("NROI") && fin.HasKey("NIGHT");
+    for (int i=0; i<1000; i++)
+    {
+        const string clnamed = Form("CLNAME%d", i);
+        if (!fin.HasKey(clnamed))
+            break;
+
+        const string clname = fin.GetStr(clnamed);
+
+        MParContainer *par = (MParContainer*)fParList->FindCreateObj(clname.c_str());
+        if (par)
+            par->SetupFits(fin);
+    }
+
+    return
+        fin.HasKey("NPIX") && fin.HasKey("RUNID")  &&
+        fin.HasKey("NROI") && fin.HasKey("NIGHT");
 }
 
@@ -211,5 +219,6 @@
         return kFALSE;
 
-    if (!fin.HasKey("ISMC")){
+    if (!fIsMc)
+    {
         if (!fin.SetRefAddress("NumBoards", fNumBoards))
             return kFALSE;
@@ -220,11 +229,7 @@
                 return kFALSE;
 
-
         if (!fin.SetPtrAddress("BoardTime", fRawBoards->fFadTime, 40))
             return kFALSE;
     }
-    else
-        fIsMc = kTRUE;
-
 
     if (!fin.SetPtrAddress("Data", (int16_t*)(*data)->GetArray(), (*data)->GetSize()/2))
@@ -253,6 +258,4 @@
 
     }    
-    // FIXME: Correctly sort the pixels here!
-
     fRawEvtData1->SetReadyToSave();
     fRawEvtData2->SetReadyToSave();
