Index: trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc	(revision 8502)
+++ trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc	(revision 8519)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MExtractPedestal.cc,v 1.30 2007-05-11 15:47:18 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MExtractPedestal.cc,v 1.31 2007-05-16 13:56:17 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -648,5 +648,5 @@
 
     // Do some handling if maxpos is last slice?
-    const Int_t maxposhi = fSignal->GetMax(idx, start, start+range-1);
+    const Int_t maxposhi = fSignal->GetMaxPos(idx, start, start+range-1);
 
     const Float_t *sig = fSignal->GetSamples(idx);
Index: trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc	(revision 8502)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc	(revision 8519)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MPedestalSubtractedEvt.cc,v 1.3 2007-03-04 12:01:37 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MPedestalSubtractedEvt.cc,v 1.4 2007-05-16 13:56:17 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -130,43 +130,57 @@
 // --------------------------------------------------------------------------
 //
-// Get the maximum of the slices [first,last] of pixel index.
+// Get the maximum of the pedestal subtracted slices [first,last] of
+// pixel with index idx.
 //
 // The position returned is the index of the position of the pedestal
 // subtracted maximum w.r.t. to first.
-// The value returned is the maximum of the raw-data.
+// The value returned is the maximum corresponding to this index.
 //
 // Warning: No range checks and no sanity checks are done!
 //
-Int_t MPedestalSubtractedEvt::GetMax(const Int_t idx, const Int_t first, const Int_t last, UInt_t &val) const
+Int_t MPedestalSubtractedEvt::GetMax(const Int_t idx, const Int_t first, const Int_t last, Float_t &val) const
 {
     // Get pointer to first slice to be considered
-    Byte_t  const *samb = GetSamplesRaw(idx);
-    Float_t const *samf = GetSamples(idx);
-
-    Byte_t  const *ptrb = samb+first;
-    Float_t const *ptrf = samf+first;
+    Float_t const *sam = GetSamples(idx);
+
+    Float_t const *beg = sam+first;
 
     // The best information so far: the first slice is the maximum
-    const Byte_t  *maxb = ptrb;
-    const Float_t *maxf = ptrf;
-
-    // Store the pointer to the first slice
-//    const Byte_t  *begb = ptrb;
-    const Float_t *begf = ptrf;
-
-    // Calculate the last slice to be considered
-    const Byte_t  *endb = samb+last;
-
-    while (ptrb<endb)
-    {
-        // Pre-increment: check the second slice first
-        if (*++ptrb>*maxb)
-            maxb = ptrb;
-        if (*++ptrf>*maxf)
-            maxf = ptrf;
-    }
-
-    val = *maxb;
-    return maxf-begf;
+    const Float_t *max = beg;
+
+    for (const Float_t *ptr=beg+1; ptr<=sam+last; ptr++)
+        if (*++ptr>*max)
+            max = ptr;
+
+    val = *max;
+    return max-beg;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the maximum of the raw slices [first,last] of pixel with index idx.
+//
+// The position returned is the index of the position of the raw-data
+// w.r.t. to first.
+// The value returned is the maximum corresponding to this index.
+//
+// Warning: No range checks and no sanity checks are done!
+//
+Int_t MPedestalSubtractedEvt::GetRawMax(const Int_t idx, const Int_t first, const Int_t last, UInt_t &val) const
+{
+    // Get pointer to first slice to be considered
+    Byte_t const *sam = GetSamplesRaw(idx);
+
+    Byte_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++)
+        if (*++ptr>*max)
+            max = ptr;
+
+    val = *max;
+    return max-beg;
 }
 
Index: trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h	(revision 8502)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h	(revision 8519)
@@ -41,20 +41,55 @@
     Int_t GetSaturation(const Int_t idx, Int_t limit, Int_t &first, Int_t &last) const;
     //void  InterpolateSaturation(const Int_t idx, Int_t limit, Int_t first, Int_t last) const;
-    Int_t GetMax(const Int_t pixidx, const Int_t first, const Int_t last, UInt_t &val) const;
-    Int_t GetMax(const Int_t pixidx, const Int_t first, const Int_t last) const
+
+    Int_t GetMax(const Int_t pixidx, const Int_t first, const Int_t last, Float_t &val) const;
+    Int_t GetMax(const Int_t pixidx, Float_t &val) const
     {
-        UInt_t val;
+        return GetMax(pixidx, 0, fNumSamples-1, val);
+    }
+    Int_t GetMaxPos(const Int_t pixidx, const Int_t first, const Int_t last) const
+    {
+        Float_t val;
         return GetMax(pixidx, first, last, val);
     }
-    Int_t GetMax(const Int_t pixidx, UInt_t &val) const
+    Int_t GetMaxPos(const Int_t pixidx, Float_t &val) const
     {
         return GetMax(pixidx, 0, fNumSamples-1, val);
     }
 
-    Int_t GetMax(const Int_t pixidx) const
+    Int_t GetMaxPos(const Int_t pixidx) const
+    {
+        Float_t val;
+        return GetMax(pixidx, 0, fNumSamples-1, val);
+    }
+
+    Int_t GetRawMax(const Int_t idx, const Int_t first, const Int_t last, UInt_t &val) const;
+    Int_t GetRawMax(const Int_t pixidx, UInt_t &val) const
+    {
+        return GetRawMax(pixidx, 0, fNumSamples-1, val);
+    }
+    Int_t GetRawMaxPos(const Int_t pixidx, const Int_t first, const Int_t last) const
     {
         UInt_t val;
-        return GetMax(pixidx, 0, fNumSamples-1, val);
+        return GetRawMax(pixidx, first, last, val);
     }
+    Int_t GetRawMaxPos(const Int_t pixidx, UInt_t &val) const
+    {
+        return GetRawMax(pixidx, 0, fNumSamples-1, val);
+    }
+
+    Int_t GetRawMaxPos(const Int_t pixidx) const
+    {
+        UInt_t val;
+        return GetRawMax(pixidx, 0, fNumSamples-1, val);
+    }
+
+    UInt_t GetRawMaxVal(const Int_t idx, const Int_t first, const Int_t last) const
+    {
+        UInt_t val;
+        GetRawMax(idx, first, last, val);
+        return val;
+    }
+
+
     Int_t GetSaturation(const Int_t pixidx, Int_t limit) const
     {
