Index: trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc
===================================================================
--- trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 19368)
+++ trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 19373)
@@ -370,5 +370,4 @@
     selectedPixel = 393;
     inputFile = NULL;
-    eventData = NULL;
     drawPatch = false;
     drawImpulse = true;
@@ -430,9 +429,4 @@
         inputFile->close();
         delete inputFile;
-    }
-    if (eventData != NULL) {
-        delete[] eventData;
-        delete[] rawEventData;
-        delete[] waveLetArray;
     }
     if (fZeroArray != NULL)
@@ -687,16 +681,10 @@
     eventNum = 1;
 
-    if (eventData != NULL) {
-        delete[] eventData;
-        delete[] rawEventData;
-        delete[] waveLetArray;
-    }
-    eventData = new float[1440*nRoi + 160*nRoiTM];//(1440+160)*nRoi];
-
-    rawEventData = new int16_t[1440*nRoi + 160*nRoiTM];//(1440+160)*nRoi];
-    waveLetArray = new int16_t[1024*1440];
+    eventData.resize(1440*nRoi + 160*nRoiTM);
+    rawEventData.resize(1440*nRoi + 160*nRoiTM);
+    waveLetArray.resize(1024*1440);
     try
     {
-        inputFile->SetPtrAddress("Data", rawEventData);
+        inputFile->SetPtrAddress("Data", rawEventData.data());
         if (inputFile->HasColumn("EventNum"))
             inputFile->SetPtrAddress("EventNum", &eventNum);
@@ -724,5 +712,5 @@
             cout << "Warning: could not find column \"StartCellTimeMarker\"" << endl;
         if (inputFile->HasColumn("TimeMarker"))
-            inputFile->SetPtrAddress("TimeMarker", &rawEventData[1440*nRoi]);
+            inputFile->SetPtrAddress("TimeMarker", rawEventData.data()+1440*nRoi);
         else
             cout << "Warning: could not find column \"TimeMarker\"" << endl;
@@ -804,6 +792,5 @@
                                                  const int roiTM)
 {
-
-    eventData = new float[1440*roi + 160*roiTM];//(1440+160)*nRoi];
+    eventData.assign(inputData.begin(), inputData.end());
     nRoi=roi;
     nRoiTM=roiTM;
@@ -813,5 +800,4 @@
     mean=0;
     for (int i=0;i<1440*roi + 160*roiTM;i++) {
-        eventData[i] = (float)inputData[i];
         mean += inputData[i];
         if (inputData[i] > max)
@@ -854,11 +840,10 @@
 void RawDataViewer::ApplyCalibration()
 {
-    for (int i=0;i<1440*nRoi + 160*nRoiTM;i++)//(1440+160)*nRoi;i++)
-        eventData[i] = (float)rawEventData[i];
+    eventData.assign(rawEventData.begin(), rawEventData.end());
 
     if (fIsDrsCalibration)
     {
-        fDrsCalib.Apply(eventData, rawEventData, startPix, nRoi);
-        DrsCalibrate::RemoveSpikes(eventData, nRoi);
+        fDrsCalib.Apply(eventData.data(), rawEventData.data(), startPix, nRoi);
+        DrsCalibrate::RemoveSpikes(eventData.data(), nRoi);
         //TODO apply calibration to the Time markers
     }
@@ -891,5 +876,5 @@
 
     vector<float> pixelStatsData(1440*4);
-    DrsCalibrate::GetPixelStats(pixelStatsData.data(), eventData, nRoi);
+    DrsCalibrate::GetPixelStats(pixelStatsData.data(), eventData.data(), nRoi);
 
     for (vector<PixelMapEntry>::const_iterator it=fPixelMap.begin(); it!=fPixelMap.end(); it++)
@@ -951,13 +936,9 @@
             cout << "Warning: did not expect Time Markers data from Monte-Carlo simulations. These will not be mapped properly." << endl;
         //first copy the data
-        int16_t* tempData = new int16_t[1440*nRoi];
-        for (int i=0;i<1440*nRoi;i++)
-            tempData[i] = rawEventData[i];
+        vector<int16_t> tempData(rawEventData.begin(), rawEventData.begin()+1440*nRoi);
         //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];
-
-        delete[] tempData;
     }
 //    cout << "Getting row " << rowNum << endl;
@@ -1178,5 +1159,5 @@
     GLWindow->ApplyCalibration();
 
-    threeD_Window->setData(GLWindow->eventData);
+    threeD_Window->setData(GLWindow->eventData.data());
 
     on_autoScaleColor_clicked();
@@ -1490,5 +1471,5 @@
     PosOfMax_window->SetData(GLWindow->PosOfMaxvalues);
     Max_window->SetData(GLWindow->Maxvalues);
-    threeD_Window->setData(GLWindow->eventData);//rawEventData);
+    threeD_Window->setData(GLWindow->eventData.data());//rawEventData);
 
     if (RMS_window->isVisible())
@@ -1590,7 +1571,7 @@
         str.str("");
         str << i << " | ";
-        for (int j=0;j<GLWindow->nRoi;j++)
-        {
-            int value = GLWindow->eventData[1440*GLWindow->nRoi + i*GLWindow->nRoi + j];
+        for (int j=0;j<GLWindow->nRoiTM;j++)
+        {
+            int value = GLWindow->eventData[1440*GLWindow->nRoi + i*GLWindow->nRoiTM + j];
             if (delayMap.find(value) != delayMap.end())
                  delayMap[value]++;
@@ -2045,5 +2026,4 @@
     }
 
-
 int realNumSamples = GLWindow->nRoi;
     if (GLWindow->nRoiTM != 0)
Index: trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h
===================================================================
--- trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h	(revision 19368)
+++ trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h	(revision 19373)
@@ -91,8 +91,8 @@
 //    void drawHexagon(int index, bool solid);
     int selectedPixel;
-    float *eventData;
-    float *rmsData;
-    int16_t* rawEventData;
-    int16_t* waveLetArray;
+    vector<float> eventData;
+    //vector<float> rmsData;
+    vector<int16_t> rawEventData;
+    vector<int16_t> waveLetArray;
     valarray<double> RMSvalues;//(1440);
     valarray<double> Meanvalues;
