Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 8249)
+++ trunk/MagicSoft/Mars/Changelog	(revision 8250)
@@ -18,4 +18,18 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2007/01/15 Thomas Bretz
+
+   * mpedestal/MPedestalSubtract.cc:
+     - added a sanity check tomake sure that the pixel array has the
+       correct size when filled
+     - made sure the the number of pixels in the camera nd not the 
+       number of connected pixels is used to initialize the size of
+       the arrays.
+
+   * mpedestal/MPedestalSubtractedEvt.[h,cc]:
+     - allow the initialization of nuber of pixels and samples
+       independanly.
+
 
  2007/01/15 Daniela Dorner
Index: trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.cc	(revision 8249)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.cc	(revision 8250)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MPedestalSubtract.cc,v 1.3 2006-10-24 12:39:00 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MPedestalSubtract.cc,v 1.4 2007-01-15 12:06:15 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -128,5 +128,5 @@
 
     // initialize fSignal
-    fSignal->InitSamples(fRawEvt->GetNumPixels(), numh+numl);
+    fSignal->InitSamples(numh+numl);//, fRawEvt->GetNumPixels(), numh+numl);
 
     // iterate over all pixels
@@ -137,4 +137,9 @@
         const Int_t pixidx = pixel.GetPixelId();
 
+        if (pixidx>=fSignal->GetNumPixels())
+        {
+            *fLog << err << "ERROR - Pixel index " << pixidx << " out of bounds... abort." << endl;
+            return kERROR;
+        }
         // Get pointer were to store merged raw data
         Byte_t *sample = fSignal->GetSamplesRaw(pixidx);
Index: trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc	(revision 8249)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc	(revision 8250)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MPedestalSubtractedEvt.cc,v 1.1 2006-10-24 08:22:41 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MPedestalSubtractedEvt.cc,v 1.2 2007-01-15 12:06:15 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -47,11 +47,13 @@
 // And reset its contents to 0.
 //
-void MPedestalSubtractedEvt::InitSamples(UInt_t pixels, UInt_t samples)
+void MPedestalSubtractedEvt::InitSamples(UInt_t samples, UInt_t pixels)
 {
     fNumSamples = samples;
-    fNumPixels  = pixels;
-
-    fSamples.Set(pixels*samples);
-    fSamplesRaw.Set(pixels*samples);
+
+    if (pixels>0)
+        fNumPixels = pixels;
+
+    fSamples.Set(fNumPixels*fNumSamples);
+    fSamplesRaw.Set(fNumPixels*fNumSamples);
 
     fSamples.Reset();
@@ -169,2 +171,31 @@
 }
 
+/*
+#include <TSpline.h>
+#include "MArrayD.h"
+void  MPedestalSubtractedEvt::InterpolateSaturation(const Int_t idx, Int_t limit, Int_t first, Int_t last) const
+{
+    MArrayD x(GetNumSamples());
+    MArrayD y(GetNumSamples());
+
+    Float_t *s = GetSamples(idx);
+
+    Int_t n = 0;
+    for (unsigned int i=0; i<GetNumSamples(); i++)
+    {
+        if (s[i]>limit)
+            continue;
+        x[n] = i;
+        y[n] = s[i];
+        n++;
+    }
+
+    TSpline5 sp("", x.GetArray(), y.GetArray(), n);
+
+    for (unsigned int i=0; i<GetNumSamples(); i++)
+    {
+        if (s[i]>limit)
+            s[i] = sp.Eval(i);
+    }
+}
+*/
Index: trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h	(revision 8249)
+++ trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h	(revision 8250)
@@ -30,5 +30,6 @@
     }
 
-    void InitSamples(UInt_t pixels, UInt_t samples);
+    void InitSize(const UInt_t i) { fNumPixels=i; }
+    void InitSamples(UInt_t samples, UInt_t pixels=0);
 
     Float_t *GetSamples(UInt_t pixel) const;
@@ -39,4 +40,5 @@
 
     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, Int_t &val) const;
     Int_t GetMax(const Int_t pixidx, const Int_t first, const Int_t last) const
