Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 8892)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 8938)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2007
+!   Copyright: MAGIC Software Development, 2000-2008
 !
 !
@@ -263,9 +263,7 @@
 
     if (str.BeginsWith("graph"))
-        if (str.Length()>5)
-            sscanf(&str[5], "%d", &id);
+        sscanf(str.Data()+5, "%d", &id);
     if (str.BeginsWith("hist"))
-        if (str.Length()>4)
-            sscanf(&str[4], "%d", &id);
+        sscanf(str.Data()+4, "%d", &id);
 
     MRawEvtPixelIter pix(this);
@@ -299,5 +297,5 @@
             graphhi->SetPoint(graphhi->GetN(), i+nh, GetSample(logains, i));
 
-        graphhi->SetMaximum(256);
+        graphhi->SetMaximum(GetMax()+0.5);
         graphhi->SetMinimum(0);
 
@@ -307,5 +305,5 @@
         TH1F *histhi = graphhi->GetHistogram();
         histhi->SetMinimum(0);
-        histhi->SetMaximum(255);
+        histhi->SetMaximum(GetMax()+0.5);
  
         histhi->SetXTitle("Time/FADC Slices");
@@ -320,7 +318,7 @@
         *fLog << inf << "Drawing Histogram of Pixel with Idx #" << dec << pix.GetPixelId() << " to " << gPad << endl;
 
-        TH1F *histh = new TH1F(name, "FADC Samples", nh, -0.5, nh-.5);
+        TH1F *histh = new TH1F(name, "FADC Samples", nh+nl, -0.5, nh+nl-.5);
         histh->SetMinimum(0);
-        histh->SetMaximum(255);
+        histh->SetMaximum(GetMax()+0.5);
         histh->SetXTitle("Time [FADC Slices]");
         histh->SetYTitle("Signal [FADC Units]");
@@ -329,5 +327,5 @@
             histh->Fill(i, GetSample(higains, i));
         for (int i=0; i<nl; i++)
-            histh->Fill(i, GetSample(logains, i));
+            histh->Fill(i+nl, GetSample(logains, i));
         histh->SetBit(kCanDelete);
         histh->Draw(same ? "same" : "");
@@ -613,3 +611,5 @@
 
     evt.fConnectedPixels = fConnectedPixels;
-}
+
+    evt.fNumBytesPerSample = fNumBytesPerSample;
+}
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 8892)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 8938)
@@ -47,9 +47,9 @@
     UInt_t GetSample(const void *ptr, Int_t n) // Helper for Draw
     {
-        switch (n)
+        switch (fNumBytesPerSample)
         {
-        case 1: return *(Byte_t*)ptr;
-        case 2: return *(UShort_t*)ptr;
-        case 3: return *(Int_t*)ptr;
+        case 1: return reinterpret_cast<const Byte_t*>(ptr)[n];
+        case 2: return reinterpret_cast<const UShort_t*>(ptr)[n];
+        case 3: return reinterpret_cast<const UInt_t*>(ptr)[n];
         }
         return 0;
@@ -83,4 +83,5 @@
     UShort_t GetNumBytesPerSample() const { return fNumBytesPerSample; }
     UInt_t   GetScale() const { return 1<<((fNumBytesPerSample-1)*8); }
+    UInt_t   GetMax() const   { return (UInt_t)(~1)>>((4-fNumBytesPerSample)*8); }
 
     void ReadPixel(istream &fin, Int_t npix);
