Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 1548)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 1914)
@@ -62,4 +62,5 @@
 #include "MArrayB.h"
 #include "MRawRunHeader.h"
+#include "MRawEvtPixelIter.h"
 
 ClassImp(MRawEvtData);
@@ -217,28 +218,37 @@
     TString str(opt);
 
-    UInt_t num = 0;
+    UInt_t id = 0;
 
     if (str.BeginsWith("GRAPH", TString::kIgnoreCase))
-    {
         if (str.Length()>5)
-            sscanf(&str[5], "%d", &num);
-
-        if (num>=GetNumPixels())
-            num= GetNumPixels();
-
-        *fLog << inf << "Drawing Graph: Pixel #" << num << " of " << (int)GetNumPixels() << endl;
-
-        const Int_t n = GetNumHiGainSamples();
-
-        Float_t *x = new Float_t[n];
-        Float_t *y = new Float_t[n];
+            sscanf(&str[5], "%d", &id);
+    if (str.BeginsWith("HIST", TString::kIgnoreCase))
+        if (str.Length()>4)
+            sscanf(&str[4], "%d", &id);
+
+    MRawEvtPixelIter pix(this);
+    if (!pix.Jump(id))
+    {
+        *fLog << warn << "Pixel Id #" << id << " doesn't exist!" << endl;
+        return;
+    }
+
+    const Byte_t *higains = pix.GetHiGainSamples();
+
+    const Int_t n = GetNumHiGainSamples();
+
+    TString name = "Pixel No.";
+    name += pix.GetPixelId();
+
+    if (str.BeginsWith("GRAPH", TString::kIgnoreCase))
+    {
+        *fLog << inf << "Drawing Graph: Pixel Id #" << pix.GetPixelId();
+        *fLog << " of " << (int)GetNumPixels() << "Pixels" << endl;
+
+        TGraph *graph = new TGraph;
 
         for (int i=0; i<n; i++)
-        {
-            x[i] = i;
-            y[i] = (*fHiGainFadcSamples)[i + num*GetNumHiGainSamples()];
-        }
-
-        TGraph *graph = new TGraph(n, x, y);
+            graph->SetPoint(graph->GetN(), i, higains[i]);
+
         graph->SetMaximum(256);
         graph->SetMinimum(0);
@@ -257,19 +267,5 @@
     if (str.BeginsWith("HIST", TString::kIgnoreCase))
     {
-        *fLog << "Length: " << str.Length() << endl;
-
-        if (str.Length()>4)
-            sscanf(&str[4], "%d", &num);
-
-        if (num>=GetNumPixels())
-            num= GetNumPixels();
-
-        *fLog << "Drawing Histogram of Pixel " << num << endl;
-
-        const Int_t n = GetNumHiGainSamples();
-
-        char *name = new char[16];
-
-        sprintf(name, "Pixel No.%d", (*fHiGainPixId)[num]);
+        *fLog << "Drawing Histogram of Pixel with Id " << pix.GetPixelId() << endl;
 
         TH1F *hist = new TH1F(name, "Hi Gain Samples FADC", n, 0, n);
@@ -278,5 +274,5 @@
 
         for (int i=0; i<n; i++)
-            hist->Fill(0.5+i, (*fHiGainFadcSamples)[i + num*GetNumHiGainSamples()]);
+            hist->Fill(0.5+i, higains[i]);
 
         hist->SetBit(kCanDelete);
