Index: trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc
===================================================================
--- trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 19685)
+++ trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 19686)
@@ -198,5 +198,5 @@
 //            color = float(eventData[nRoi*i + whichSlice] + (VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
 //        else
-            color = float(eventData[nRoi*hardwareMapping[i] + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
+            color = i<nPixels ? float(eventData[nRoi*hardwareMapping[i] + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1) : 0;
         if (logScale)
         {
@@ -623,10 +623,10 @@
     nTM =            inputFile->HasKey("NTMARK") ? inputFile->GetInt("NTMARK") : 0;
 
-    runType = "unkown";
+    runType = "unknown";
     if (inputFile->HasKey("RUNTYPE"))
     {
         runType = inputFile->GetStr("RUNTYPE");
         if (runType == "")
-            runType = "unkown";
+            runType = "unknown";
     }
     firstDataTime =  inputFile->HasKey("TSTART") ? inputFile->GetInt("TSTART") : -1;
@@ -648,4 +648,9 @@
         nPixels = 1440;
     }
+    if (nPixels > 1440)
+        cout << "More than 1440 pixels not supported." << endl;
+    if (nPixels==1440 && nRoi!=0)
+        cout << "Time marker not suppoerted with number of pixel not euqal 1440." << endl;
+
     if (nRoi == 0 && !inputFile->HasKey("NROI"))
     {//let's try to figure out the roi from the column's format
@@ -889,13 +894,15 @@
         if (nRoiTM != 0)
             cout << "Warning: did not expect Time Markers data from Monte-Carlo simulations. These will not be mapped properly." << endl;
+
         //first copy the data
-        vector<int16_t> tempData(rawEventData.begin(), rawEventData.begin()+1440*nRoi);
+        const vector<int16_t> tempData(rawEventData);//.begin(), rawEventData.begin()+1440*nRoi);
+        rawEventData.assign(rawEventData.size(), 0);
         //copy back the data and re-map it on the fly
         for (int i=0;i<1440;i++)
-            for (int j=0;j<nRoi;j++)
-                rawEventData[i*nRoi + j] = tempData[softwareMapping[i]*nRoi + j];
+            if (softwareMapping[i]<nPixels)
+                for (int j=0;j<nRoi;j++)
+                    rawEventData[i*nRoi + j] = tempData[softwareMapping[i]*nRoi + j];
     }
 //    cout << "Getting row " << rowNum << endl;
-
 
     ApplyCalibration();
@@ -2141,4 +2148,8 @@
         if (i==863)//keep crazy pixel out of the autoscale
             continue;
+
+        if (GLWindow->softwareMapping[i]>=GLWindow->nPixels)
+            continue;
+
         for (int j=10;j<GLWindow->nRoi-50;j++)
         {
