Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 8499)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 8500)
@@ -89,4 +89,11 @@
      - removed data members fPedestal and fPedestalsIn respectively,
        and all referencing functions because it was never used at all
+
+   * mextralgo/MExtralgoDigitalFilter.[h,cc], 
+     mextralgo/MExtralgoSpline.cc
+     msignal/MExtractTimeAndChargeDigitalFilter.cc:
+     - made the noise extraction completely random and automatic
+     - gave the noise extraction completely into the hand of 
+       the extractors
 
 
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 8499)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 8500)
@@ -23,4 +23,9 @@
      simplified the process of producing several movies from a single
      sequence with different setup.
+
+   - callisto: The extraction of the pedestal with the extractor was
+     not random. It seems that extracting at one position is still biased
+     (for example in the first or last slices we could still suffer from
+     switching noise) Now it is completely random.
 
    - callisto: In MPedCalcPedRun (which is the pedestal extraction from
Index: /trunk/MagicSoft/Mars/mextralgo/MExtralgoDigitalFilter.cc
===================================================================
--- /trunk/MagicSoft/Mars/mextralgo/MExtralgoDigitalFilter.cc	(revision 8499)
+++ /trunk/MagicSoft/Mars/mextralgo/MExtralgoDigitalFilter.cc	(revision 8500)
@@ -31,9 +31,14 @@
 #include "MExtralgoDigitalFilter.h"
 
+#include <TRandom.h>
+
 using namespace std;
 
-Float_t MExtralgoDigitalFilter::ExtractNoise(Int_t iter) const
+Float_t MExtralgoDigitalFilter::ExtractNoise() const
 {
-    return Eval(fWeightsAmp, 0, iter-fWeightsPerBin/2);
+    const Int_t pos  = gRandom->Integer(fNum-fWindowSize+1);
+    const Int_t frac = gRandom->Integer(fWeightsPerBin);
+
+    return Eval(fWeightsAmp, pos, frac-fWeightsPerBin/2);
 }
 
Index: /trunk/MagicSoft/Mars/mextralgo/MExtralgoDigitalFilter.h
===================================================================
--- /trunk/MagicSoft/Mars/mextralgo/MExtralgoDigitalFilter.h	(revision 8499)
+++ /trunk/MagicSoft/Mars/mextralgo/MExtralgoDigitalFilter.h	(revision 8500)
@@ -161,5 +161,5 @@
     void GetTime(Float_t &sig, Float_t &dsig) const   { sig=fTime; dsig=fTimeDev; }
 
-    Float_t ExtractNoise(Int_t iter) const;
+    Float_t ExtractNoise() const;
     void Extract(Int_t maxpos=-1);
 
Index: /trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.cc
===================================================================
--- /trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.cc	(revision 8499)
+++ /trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.cc	(revision 8500)
@@ -225,17 +225,20 @@
 }
 
-Float_t MExtralgoSpline::ExtractNoise(/*Int_t iter*/)
+Float_t MExtralgoSpline::ExtractNoise()
 {
     if (fNum<5)
         return 0;
 
-    // FIXME: Shell we keep the extraction inside one slice
-    // or randomize it along the extraction window?
-    const Float_t nsx = gRandom->Uniform(); //iter * fResolution;
-
     if (fExtractionType == kAmplitude)
-        return Eval(2, nsx);
+    {
+        const Int_t   pos = gRandom->Integer(fNum-1);
+        const Float_t nsx = gRandom->Uniform();
+        return Eval(pos, nsx);
+    }
     else
-        return CalcIntegral(2 + nsx);
+    {
+        const Float_t pos = gRandom->Uniform(fNum-1-fRiseTime-fFallTime)+fRiseTime;
+        return CalcIntegral(pos);
+    }
 }
 
Index: /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc	(revision 8499)
+++ /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc	(revision 8500)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MExtractTimeAndChargeDigitalFilter.cc,v 1.77 2007-02-04 15:30:16 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MExtractTimeAndChargeDigitalFilter.cc,v 1.78 2007-05-11 18:29:42 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -305,5 +305,5 @@
     if (IsNoiseCalculation())
     {
-        sum = df.ExtractNoise(gRandom->Integer(fBinningResolutionHiGain));
+        sum = df.ExtractNoise();
         return;
     }
@@ -328,5 +328,5 @@
     if (IsNoiseCalculation())
     {
-        sum = df.ExtractNoise(gRandom->Integer(fBinningResolutionHiGain));
+        sum = df.ExtractNoise();
         return;
     }
