Index: /trunk/Mars/Changelog
===================================================================
--- /trunk/Mars/Changelog	(revision 11870)
+++ /trunk/Mars/Changelog	(revision 11871)
@@ -27,4 +27,7 @@
      - when setting a pixel map, subtract one to get from the id to
        the index
+
+   * mraw/MRawFitsRead.[h,cc]:
+     - added the possibility to read the pixel map from a file 
 
 
Index: /trunk/Mars/mraw/MRawFitsRead.cc
===================================================================
--- /trunk/Mars/mraw/MRawFitsRead.cc	(revision 11870)
+++ /trunk/Mars/mraw/MRawFitsRead.cc	(revision 11871)
@@ -38,4 +38,6 @@
 #include "MRawFitsRead.h"
 
+#include <fstream>
+
 #include <TClass.h>
 
@@ -64,4 +66,52 @@
     : MRawFileRead(fname, name, title)
 {
+}
+
+Bool_t MRawFitsRead::LoadMap(const char *name)
+{
+    fPixelMap.resize(1440);
+
+    ifstream fin(name);
+
+    int l = 0;
+
+    string buf;
+    while (getline(fin, buf, '\n'))
+    {
+        if (l>1439)
+            break;
+
+        const TString bf = TString(buf.c_str()).Strip(TString::kBoth);
+        if (bf[0]=='#')
+            continue;
+
+        stringstream str(bf.Data());
+
+        int index, cbpx;
+
+        str >> index;
+        str >> cbpx;
+
+        const int c =  cbpx/1000;
+        const int b = (cbpx/100)%10;
+        const int p = (cbpx/10)%10;
+        const int x =  cbpx%10;
+
+        const int hw = x+p*9+b*36+c*360;
+        if (hw>1439)
+            break;
+
+        fPixelMap[hw] = index;
+        l++;
+    }
+
+    if (l!=1440)
+    {
+        gLog << err << "ERROR - Problems reading FACTmapV5.txt" << endl;
+        fPixelMap.resize(0);
+        return kFALSE;
+    }
+
+    return kTRUE;
 }
 
@@ -91,5 +141,5 @@
     fRawRunHeader->SetObservation("", "FACT");
     fRawRunHeader->SetRunInfo(0, fin.GetUInt("NIGHT"), fin.GetUInt("RUNID"));
-    fRawRunHeader->InitFact(fin.GetUInt("NPIX")/9, 9, fin.GetUInt("NROI"));
+    fRawRunHeader->InitFact(fin.GetUInt("NPIX")/9, 9, fin.GetUInt("NROI"), fPixelMap.size()==0?0:fPixelMap.data());
     fRawRunHeader->SetFormat(0xf172, fin.GetUInt("BLDVER"));
     fRawRunHeader->SetRunType(0/*data*/);
@@ -129,5 +179,5 @@
         return kFALSE;
 
-    fRawEvtData1->SetIndices();
+    fRawEvtData1->SetIndices(fRawRunHeader->GetPixAssignment());
 
     return kTRUE;
Index: /trunk/Mars/mraw/MRawFitsRead.h
===================================================================
--- /trunk/Mars/mraw/MRawFitsRead.h	(revision 11870)
+++ /trunk/Mars/mraw/MRawFitsRead.h	(revision 11871)
@@ -11,5 +11,6 @@
 {
 private:
-    std::vector<UInt_t> fPCTime; //! Buffer
+    std::vector<UInt_t>   fPCTime;   //! Buffer
+    std::vector<UShort_t> fPixelMap; //! 
 
     istream *OpenFile(const char *filename);
@@ -24,4 +25,6 @@
     static Bool_t IsFits(const char *name);
 
+    Bool_t LoadMap(const char *name);
+
     ClassDef(MRawFitsRead, 0)	// Task to read the raw data binary file
 };
