Index: trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc
===================================================================
--- trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 12671)
+++ trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 12677)
@@ -489,5 +489,5 @@
  * CONSTRUCTOR.
  ************************************************************/
-RawDataViewer::RawDataViewer(QWidget *cParent) : BasicGlCamera(cParent), RMSvalues(1440)
+RawDataViewer::RawDataViewer(QWidget *cParent) : BasicGlCamera(cParent), RMSvalues(1440), Meanvalues(1440), Maxvalues(1440), PosOfMaxvalues(1440)
 {
  //   setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer));
@@ -1192,6 +1192,11 @@
 
     for (vector<PixelMapEntry>::const_iterator it=fPixelMap.begin(); it!=fPixelMap.end(); it++)
-        RMSvalues[it->index] = pixelStatsData[1*1440+it->hw()];
-
+    {
+        Meanvalues[it->index]     = pixelStatsData[0*1440+it->hw()];
+        RMSvalues[it->index]      = pixelStatsData[1*1440+it->hw()];
+        Maxvalues[it->index]      = pixelStatsData[2*1440+it->hw()];
+        PosOfMaxvalues[it->index] = pixelStatsData[3*1440+it->hw()];
+
+    }
     if (nRoiTM == 0)//move back the data back in place
     {
@@ -1391,6 +1396,10 @@
     entireCameraScale->setChecked(true);
 
-    GLWindow_2->enableText(false);
- //   GLWindow_2->ShowPatchCursor(true);
+    RMS_window->enableText(false);
+    Mean_window->enableText(false);
+    PosOfMax_window->enableText(false);
+    Max_window->enableText(false);
+
+ //   RMS_window->ShowPatchCursor(true);
 
     QObject::connect(GLWindow, SIGNAL(colorPaletteHasChanged()),
@@ -1405,6 +1414,13 @@
                      this, SLOT(newFileLoaded()));
 
-    QObject::connect(GLWindow_2, SIGNAL(signalCurrentPixel(int)),
+    QObject::connect(RMS_window, SIGNAL(signalCurrentPixel(int)),
                      GLWindow, SLOT(setCurrentPixel(int)));
+    QObject::connect(Max_window, SIGNAL(signalCurrentPixel(int)),
+                     GLWindow, SLOT(setCurrentPixel(int)));
+    QObject::connect(PosOfMax_window, SIGNAL(signalCurrentPixel(int)),
+                     GLWindow, SLOT(setCurrentPixel(int)));
+    QObject::connect(Mean_window, SIGNAL(signalCurrentPixel(int)),
+                     GLWindow, SLOT(setCurrentPixel(int)));
+
 
 
@@ -1418,8 +1434,10 @@
     grid4->detach();
     grid5->detach();
+    grid6->detach();
     boardsTimeHistoItem.detach();
     startCellHistoItem.detach();
     startTimeMarkHistoItem.detach();
     pixelValueCurveItem.detach();
+    pixelAverageCurveItem.detach();
     aMeanCurveItem.detach();
     vCorrCurveItem.detach();
@@ -1702,7 +1720,17 @@
 {
 
-    GLWindow_2->SetData(GLWindow->RMSvalues);
-    if (GLWindow_2->isVisible())
-        GLWindow_2->updateGL();
+    RMS_window->SetData(GLWindow->RMSvalues);
+    Mean_window->SetData(GLWindow->Meanvalues);
+    PosOfMax_window->SetData(GLWindow->PosOfMaxvalues);
+    Max_window->SetData(GLWindow->Maxvalues);
+
+    if (RMS_window->isVisible())
+        RMS_window->updateGL();
+    if (Mean_window->isVisible())
+        Mean_window->updateGL();
+    if (PosOfMax_window->isVisible())
+        PosOfMax_window->updateGL();
+    if (Max_window->isVisible())
+        Max_window->updateGL();
     ostringstream str;
 //    str << "Displaying Event " << cEvent;
@@ -2115,4 +2143,12 @@
     grid4->attach(pixelValueCurve);
 
+    grid6 = new QwtPlotGrid;
+    grid6->enableX(false);
+    grid6->enableY(true);
+    grid6->enableXMin(false);
+    grid6->enableYMin(false);
+    grid6->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
+    grid6->attach(pixelAverageCurve);
+
     grid5 = new QwtPlotGrid;
     grid5->enableX(false);
@@ -2127,4 +2163,5 @@
     startTimeMarkHisto->setAutoReplot(true);
     pixelValueCurve->setAutoReplot(true);
+    pixelAverageCurve->setAutoReplot(true);
     triggerDelayHisto->setAutoReplot(true);
     boardsTimeHisto->setTitle("Boards time values");
@@ -2132,4 +2169,5 @@
     startTimeMarkHisto->setTitle("Start Time Marks values");
     pixelValueCurve->setTitle("Current pixel values");
+    pixelAverageCurve->setTitle("Average pixels values");
     triggerDelayHisto->setTitle("Trigger Delays");
 
@@ -2157,8 +2195,10 @@
 //    pixelValueCurveItem.setSymbol(new QwtSymbol(QwtSymbol::Cross, Qt::NoBrush, QPen(Qt::black), QSize(5,5)));
     pixelValueCurveItem.setPen(QColor(Qt::black));
+    pixelAverageCurveItem.setPen(QColor(Qt::black));
     aMeanCurveItem.setPen(QColor(Qt::darkGreen));
     vCorrCurveItem.setPen(QColor(Qt::red));
     meanCurveItem.setPen(QColor(Qt::blue));
     pixelValueCurveItem.setStyle(QwtPlotCurve::Lines);
+    pixelAverageCurveItem.setStyle(QwtPlotCurve::Lines);
     aMeanCurveItem.setStyle(QwtPlotCurve::Lines);
     vCorrCurveItem.setStyle(QwtPlotCurve::Lines);
@@ -2167,4 +2207,5 @@
 //    pixelValueCurveItem.setCurveAttribute(QwtPlotCurve::Fitted);
     pixelValueCurveItem.attach(pixelValueCurve);
+    pixelAverageCurveItem.attach(pixelAverageCurve);
 //    aMeanCurveItem.attach(pixelValueCurve);
  //   vCorrCurveItem.attach(pixelValueCurve);
@@ -2175,4 +2216,7 @@
     curveZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
     curveZoom->setTrackerPen(QPen(Qt::gray));
+    averageCurveZoom = new QwtPlotZoomer(pixelAverageCurve->canvas());
+    averageCurveZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
+    averageCurveZoom->setTrackerPen(QPen(Qt::gray));
 
     boardsTimeHistoZoom = new QwtPlotZoomer(boardsTimeHisto->canvas());
@@ -2197,9 +2241,22 @@
 void UIConnector::pixelChanged(int pixel)
 {
-    GLWindow_2->fWhite = pixel;
+    RMS_window->fWhite = pixel;
+    Mean_window->fWhite = pixel;
+    Max_window->fWhite = pixel;
+    PosOfMax_window->fWhite = pixel;
     if (pixel != -1)
-        GLWindow_2->fWhitePatch = GLWindow_2->pixelsPatch[pixel];
+    {
+        RMS_window->fWhitePatch = RMS_window->pixelsPatch[pixel];
+        Mean_window->fWhitePatch = Mean_window->pixelsPatch[pixel];
+        Max_window->fWhitePatch = Max_window->pixelsPatch[pixel];
+        PosOfMax_window->fWhitePatch = PosOfMax_window->pixelsPatch[pixel];
+    }
     else
-        GLWindow_2->fWhitePatch = -1;
+    {
+        RMS_window->fWhitePatch = -1;
+        Mean_window->fWhitePatch = -1;
+        Max_window->fWhitePatch = -1;
+        PosOfMax_window->fWhitePatch = -1;
+    }
     if (pixel == -1)
         return;
@@ -2213,21 +2270,12 @@
 
 int currentPixel = pixel;
-//IN ORDER TO GET THE AVERAGE OF ALL PIXELS DISPLAYED IN THE CURVE OF THE VIEWER
-//UNCOMMENT THE 9 LINES BELOW, i.e. UNTIL THE END OF AVERAGE DISPLAY COMMENT MARK
-//int currentPixel = 0;
-//    for (int i=0;i<GLWindow->nRoi;i++)
-//        yval[i] = 0;
-//    for (int j=0;j<1440;j++) {
-//        currentPixel = j;
+
     for (int i=0;i<GLWindow->nRoi;i++)
     {
         xval[i] = i;
         yval[i] = GLWindow->eventData[GLWindow->nRoi*currentPixel + i];
-//        yval[i] += GLWindow->eventData[GLWindow->nRoi*currentPixel + i];
-    }
-//    }
-//    for (int i=0;i<GLWindow->nRoi;i++)
-//        yval[i] /= 1440;
-//END OF AVERAGE DISPLAY COMMENTS
+    }
+
+
 int realNumSamples = GLWindow->nRoi;
     if (GLWindow->nRoiTM != 0)
@@ -2256,22 +2304,37 @@
       //  cout << pixelIdInPatch << " " ;
     }
-//cout << realNumSamples << endl;
-  //  GLWindow->computePulsesStatistics();
+
 #if QWT_VERSION < 0x060000
     pixelValueCurveItem.setData(xval, yval, realNumSamples);
-////    aMeanCurveItem.setData(xval, GLWindow->aMeas, GLWindow->nRoi);
- //   meanCurveItem.setData(xval, GLWindow->n1mean, GLWindow->nRoi);
- //   vCorrCurveItem.setData(xval, GLWindow->vCorr, GLWindow->nRoi-3);
 #else
        pixelValueCurveItem.setSamples(xval, yval, realNumSamples);
-//       aMeanCurveItem.setSamples(xval, GLWindow->aMeas, GLWindow->nRoi);
- //      meanCurveItem.setSamples(xval, GLWindow->n1mean, GLWindow->nRoi);
- //      vCorrCurveItem.setSamples(xval, GLWindow->vCorr, GLWindow->nRoi-3);
 #endif
 
+//now compute the average value of all pixels
+       currentPixel = 0;
+       for (int i=0;i<GLWindow->nRoi;i++)
+           yval[i] = 0;
+       for (int j=0;j<1440;j++) {
+           currentPixel = j;
+           for (int i=0;i<GLWindow->nRoi;i++)
+           {
+               xval[i] = i;
+               yval[i] += GLWindow->eventData[GLWindow->nRoi*currentPixel + i];
+           }
+       }
+       for (int i=0;i<GLWindow->nRoi;i++)
+           yval[i] /= 1440;
+#if QWT_VERSION < 0x060000
+       pixelAverageCurveItem.setData(xval, yval, GLWindow->nRoi);
+#else
+    pixelAverageCurveItem.setSamples(xval, yval, realNumSamples);
+#endif
 
     QStack< QRectF > stack;
     stack.push(scaleBoundingRectangle(pixelValueCurveItem.boundingRect(), 1.5f));
     curveZoom->setZoomStack(stack);
+    stack.pop();
+    stack.push(scaleBoundingRectangle(pixelAverageCurveItem.boundingRect(), 1.5f));
+    averageCurveZoom->setZoomStack(stack);
     stack.pop();
 
Index: trunk/FACT++/gui/RawEventsViewer/viewer.ui
===================================================================
--- trunk/FACT++/gui/RawEventsViewer/viewer.ui	(revision 12671)
+++ trunk/FACT++/gui/RawEventsViewer/viewer.ui	(revision 12677)
@@ -8,5 +8,5 @@
     <y>0</y>
     <width>984</width>
-    <height>894</height>
+    <height>712</height>
    </rect>
   </property>
@@ -27,6 +27,6 @@
           <property name="sizePolicy">
            <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
+            <horstretch>1</horstretch>
+            <verstretch>1</verstretch>
            </sizepolicy>
           </property>
@@ -48,14 +48,8 @@
               </property>
               <property name="sizePolicy">
-               <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
-                <horstretch>0</horstretch>
-                <verstretch>0</verstretch>
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>1</horstretch>
+                <verstretch>1</verstretch>
                </sizepolicy>
-              </property>
-              <property name="maximumSize">
-               <size>
-                <width>10000</width>
-                <height>10000</height>
-               </size>
               </property>
              </widget>
@@ -197,4 +191,14 @@
                </layout>
               </widget>
+              <widget class="QWidget" name="tab_7">
+               <attribute name="title">
+                <string>Average Curve</string>
+               </attribute>
+               <layout class="QGridLayout" name="gridLayout_41">
+                <item row="0" column="0">
+                 <widget class="QwtPlot" name="pixelAverageCurve"/>
+                </item>
+               </layout>
+              </widget>
              </widget>
             </item>
@@ -207,10 +211,10 @@
            <layout class="QGridLayout" name="gridLayout_6">
             <item row="0" column="0">
-             <widget class="QCameraWidget" name="GLWindow_2" native="true">
+             <widget class="QCameraWidget" name="RMS_window" native="true">
               <property name="enabled">
                <bool>true</bool>
               </property>
               <property name="sizePolicy">
-               <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
@@ -227,4 +231,82 @@
            </layout>
           </widget>
+          <widget class="QWidget" name="tab_8">
+           <attribute name="title">
+            <string>Mean</string>
+           </attribute>
+           <layout class="QGridLayout" name="gridLayout_61">
+            <item row="0" column="0">
+             <widget class="QCameraWidget" name="Mean_window" native="true">
+              <property name="enabled">
+               <bool>true</bool>
+              </property>
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>10000</width>
+                <height>10000</height>
+               </size>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </widget>
+          <widget class="QWidget" name="tab_9">
+           <attribute name="title">
+            <string>Max</string>
+           </attribute>
+           <layout class="QGridLayout" name="gridLayout_62">
+            <item row="0" column="0">
+             <widget class="QCameraWidget" name="Max_window" native="true">
+              <property name="enabled">
+               <bool>true</bool>
+              </property>
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>10000</width>
+                <height>10000</height>
+               </size>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </widget>
+          <widget class="QWidget" name="tab_10">
+           <attribute name="title">
+            <string>Pos. of Max.</string>
+           </attribute>
+           <layout class="QGridLayout" name="gridLayout_63">
+            <item row="0" column="0">
+             <widget class="QCameraWidget" name="PosOfMax_window" native="true">
+              <property name="enabled">
+               <bool>true</bool>
+              </property>
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>10000</width>
+                <height>10000</height>
+               </size>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </widget>
          </widget>
         </item>
@@ -246,5 +328,5 @@
          <widget class="QLabel" name="extraInfoLabel">
           <property name="sizePolicy">
-           <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
             <horstretch>0</horstretch>
             <verstretch>0</verstretch>
@@ -295,5 +377,5 @@
             <property name="font">
              <font>
-              <pointsize>12</pointsize>
+              <pointsize>11</pointsize>
               <weight>75</weight>
               <bold>true</bold>
@@ -313,5 +395,5 @@
              <widget class="QLabel" name="label_10">
               <property name="text">
-               <string>Hardware ID</string>
+               <string>Hw ID</string>
               </property>
               <property name="alignment">
@@ -330,12 +412,8 @@
              </widget>
             </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QHBoxLayout" name="horizontalLayout_7">
             <item>
              <widget class="QLabel" name="label_11">
               <property name="text">
-               <string>Software ID</string>
+               <string>Sw ID</string>
               </property>
               <property name="alignment">
@@ -454,5 +532,5 @@
              <widget class="QLabel" name="displayingEventLabel">
               <property name="text">
-               <string>Displaying Event</string>
+               <string>Event</string>
               </property>
              </widget>
@@ -461,12 +539,8 @@
              <widget class="QSpinBox" name="displayingEventBox"/>
             </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QHBoxLayout" name="horizontalLayout_9">
             <item>
              <widget class="QLabel" name="displayingSliceLabel">
               <property name="text">
-               <string>Displaying Slice  </string>
+               <string>Slice  </string>
               </property>
              </widget>
