Index: trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.cc	(revision 8564)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.cc	(revision 8565)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MPedestalSubtract.cc,v 1.5 2007-05-14 09:53:15 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MPedestalSubtract.cc,v 1.6 2007-06-16 22:05:27 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -129,4 +129,19 @@
 }
 
+void MPedestalSubtract::Memcpy(void *dest, Int_t offset, void *src, Int_t cnt) const
+{
+        memcpy(dest+offset, src, cnt);
+/*
+    if (fRawEvt->GetNumBytesPerSample()==2)
+        memcpy((UShort_t*)dest+offset, src, cnt*2);
+    else
+    {
+        const Byte_t *b = (Byte_t*)src+offset;
+        for (USample_t *ptr=(USample_t*)dest; ptr<(USample_t*)dest+cnt; ptr++)
+            *ptr = *b++;
+    }
+ */
+}
+
 // --------------------------------------------------------------------------
 //
@@ -137,4 +152,6 @@
     const Int_t numh = fRawEvt->GetNumHiGainSamples();
     const Int_t numl = fRawEvt->GetNumLoGainSamples();
+
+    const UInt_t scale = fRawEvt->GetScale();
 
     // initialize fSignal
@@ -154,9 +171,9 @@
         }
         // Get pointer were to store merged raw data
-        Byte_t *sample = fSignal->GetSamplesRaw(pixidx);
+        USample_t *sample = fSignal->GetSamplesRaw(pixidx);
 
         // copy hi- and lo-gains samples together
-        memcpy(sample,      pixel.GetHiGainSamples(), numh);
-        memcpy(sample+numh, pixel.GetLoGainSamples(), numl);
+        Memcpy(sample, 0,    pixel.GetHiGainSamples(), numh);
+        Memcpy(sample, numh, pixel.GetLoGainSamples(), numl);
 
         // start of destination array, end of hi-gain destination array
@@ -165,5 +182,5 @@
         Float_t *end = beg + fSignal->GetNumSamples();
 
-        const Byte_t *src = sample;
+        const USample_t *src = sample;
 
         // if no pedestals are given just convert the data into
@@ -172,5 +189,5 @@
         {
             while (beg<end)
-                *beg++ = *src++;
+                *beg++ = *src;//Float_t(*src++)/scale;
             continue;
         }
@@ -191,5 +208,5 @@
         // FIXME: Shell we really subtract the pedestal from saturating slices???
         for (Float_t *ptr=beg; ptr<end; ptr++)
-            *ptr = (Float_t)*src++ - mean[(ptr-beg)&1];
+            *ptr = Float_t(*src++)/scale - mean[(ptr-beg)&1];
     }
 
Index: trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.h	(revision 8564)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.h	(revision 8565)
@@ -26,4 +26,6 @@
     Int_t  Process();
 
+    void Memcpy(void *sample, Int_t offset, void *ptr, Int_t cnt) const;
+
 public:
     MPedestalSubtract(const char *name=NULL, const char *title=NULL);
Index: trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc	(revision 8564)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc	(revision 8565)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MPedestalSubtractedEvt.cc,v 1.5 2007-06-15 12:58:57 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MPedestalSubtractedEvt.cc,v 1.6 2007-06-16 22:08:00 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -82,5 +82,5 @@
 // The user is responsible not to exceed the slices for one pixel!
 //
-Byte_t *MPedestalSubtractedEvt::GetSamplesRaw(UInt_t pixel) const
+USample_t *MPedestalSubtractedEvt::GetSamplesRaw(UInt_t pixel) const
 {
     return pixel>=fNumPixels ? NULL : fSamplesRaw.GetArray()+pixel*fNumSamples;
@@ -103,13 +103,13 @@
 {
     // Determin saturation of hi-gains
-    Byte_t *p0 = GetSamplesRaw(idx);
-
-    Byte_t *sat0 = 0; // first saturating slice
-    Byte_t *sat1 = 0; // last  saturating slice
+    USample_t *p0 = GetSamplesRaw(idx);
+
+    USample_t *sat0 = 0; // first saturating slice
+    USample_t *sat1 = 0; // last  saturating slice
 
     Int_t num = 0;
 
-    const Byte_t *end = p0+last;
-    for (Byte_t *ptr=p0+first; ptr<=end; ptr++)
+    const USample_t *end = p0+last;
+    for (USample_t *ptr=p0+first; ptr<=end; ptr++)
     {
         if (*ptr>=limit)
@@ -170,12 +170,12 @@
 {
     // Get pointer to first slice to be considered
-    Byte_t const *sam = GetSamplesRaw(idx);
-
-    Byte_t const *beg = sam+first;
+    USample_t const *sam = GetSamplesRaw(idx);
+
+    USample_t const *beg = sam+first;
 
     // The best information so far: the first slice is the maximum
-    const Byte_t *max = beg;
-
-    for (const Byte_t *ptr=beg+1; ptr<=sam+last; ptr++)
+    const USample_t *max = beg;
+
+    for (const USample_t *ptr=beg+1; ptr<=sam+last; ptr++)
         if (*ptr>*max)
             max = ptr;
Index: trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h	(revision 8564)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h	(revision 8565)
@@ -11,7 +11,10 @@
 #include "MArrayF.h"
 #endif
-#ifndef MARS_MArrayB
-#include "MArrayB.h"
+#ifndef MARS_MArrayS
+#include "MArrayS.h"
 #endif
+
+//typedef UShort_t USample_t;
+typedef Byte_t USample_t;
 
 class MPedestalSubtractedEvt : public MParContainer, public MCamEvent
@@ -20,4 +23,5 @@
     MArrayF fSamples;        // list of all samples with pedestal subtracted
     MArrayB fSamplesRaw;     // list of all samples (raw)
+//    MArrayS fSamplesRaw;     // list of all samples (raw)
 
     UInt_t fNumSamples;      // number of samples per pixel
@@ -33,6 +37,6 @@
     void InitSamples(UInt_t samples, UInt_t pixels=0);
 
-    Float_t *GetSamples(UInt_t pixel) const;
-    Byte_t *GetSamplesRaw(UInt_t pixel) const;
+    Float_t   *GetSamples(UInt_t pixel) const;
+    USample_t *GetSamplesRaw(UInt_t pixel) const;
 
     UInt_t   GetNumSamples() const { return fNumSamples; }
@@ -101,7 +105,7 @@
     Int_t GetIntegralRaw(Int_t idx, Int_t first, Int_t last) const
     {
-        Byte_t *ptr = GetSamplesRaw(idx);
+        USample_t *ptr = GetSamplesRaw(idx);
 
-        const Byte_t *end = ptr + last - first + 1;
+        const USample_t *end = ptr + last - first + 1;
 
         Int_t sum = 0;
