Index: trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc	(revision 5570)
+++ trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc	(revision 5715)
@@ -189,6 +189,6 @@
 //
 MExtractPedestal::MExtractPedestal(const char *name, const char *title)
-    : fGeom(NULL), fPedestalsIn(NULL), fPedestalsOut(NULL), fExtractor(NULL),
-      fExtractWinFirst(0), fExtractWinSize(0)
+    : fRandomCalculation(kTRUE), fGeom(NULL), fPedestalsIn(NULL), fPedestalsOut(NULL), 
+      fExtractor(NULL), fExtractWinFirst(0), fExtractWinSize(0)
 {
     fName  = name  ? name  : "MExtractPedestal";
@@ -204,7 +204,5 @@
     SetNamePedestalCamIn();
     SetNamePedestalCamOut();
-    SetNumEventsDump();
-    SetNumAreasDump();
-    SetNumSectorsDump();
+    SetNumDump();
 
     Clear();
@@ -361,5 +359,19 @@
   Print();
 
+  // FIMXE: MUST call fExtractor->PreProcess()???
   return kTRUE;
+}
+
+Int_t MExtractPedestal::Process()
+{
+    if (fExtractor)
+        fExtractor->SetNoiseCalculation(fRandomCalculation);
+
+    const Int_t rc = Calc();
+
+    if (fExtractor)
+        fExtractor->SetNoiseCalculation(kFALSE);
+
+    return rc;
 }
 
@@ -447,4 +459,5 @@
 //    NumEventsDump:        500
 //    PedestalUpdate:       yes
+//    RandomCalculation:    yes
 //
 Int_t MExtractPedestal::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
@@ -477,4 +490,11 @@
     {
         SetPedestalUpdate(GetEnvValue(env, prefix, "PedestalUpdate", fPedestalUpdate));
+        rc = kTRUE;
+    }
+
+    // find resource for random calculation
+    if (IsEnvDefined(env, prefix, "RandomCalculation", print))
+    {
+        SetRandomCalculation(GetEnvValue(env, prefix, "RandomCalculation", fRandomCalculation));
         rc = kTRUE;
     }
@@ -640,5 +660,8 @@
     }
     if (fExtractor)
-        *fLog << "Extractor used:               " << fExtractor->ClassName() << endl;
+    {
+        *fLog << "Extractor used:               " << fExtractor->ClassName() << " (";
+        *fLog << (fRandomCalculation?"":"non-") << "random)" << endl;
+    }
     *fLog << "ExtractWindow from slice " << fExtractWinFirst << " to " << fExtractWinLast << " incl." << endl;
 }
Index: trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.h	(revision 5570)
+++ trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.h	(revision 5715)
@@ -26,4 +26,9 @@
   static const TString  fgNamePedestalCam;  //! "MPedestalCam"
 
+  TString fNamePedestalCamIn;   // name of the incoming 'MPedestalCam' container
+  TString fNamePedestalCamOut;  // name of the outgoing 'MPedestalCam' container  
+
+  Bool_t  fRandomCalculation;  // Is pedestalextraction by extractor random?
+
 protected:
   
@@ -39,7 +44,4 @@
   UShort_t fExtractWinSize;     // Number of slices to calculate the pedestal from
   UShort_t fExtractWinLast;     // Last FADC slice to extract pedestal from 
-
-  TString fNamePedestalCamIn;   // name of the incoming 'MPedestalCam' container
-  TString fNamePedestalCamOut;  // name of the outgoing 'MPedestalCam' container  
 
   UInt_t  fNumEventsDump;       // Number of event after which MPedestalCam gets updated
@@ -66,11 +68,16 @@
   MArrayI fSectorValid;        // number of valid pixels within sector idx
 
+  // MTask virtual functions
   Int_t  PreProcess(MParList *pList);
+  Int_t  Process();
   Int_t  PostProcess();
   Bool_t ReInit(MParList *pList);
   Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
-  virtual void ResetArrays();
+  // Interface to be overwritten by a new class
+  virtual void  ResetArrays();
+  virtual Int_t Calc() = 0;
 
+  // Helper functions
   void CalcPixResults   (const UInt_t nevts, const UInt_t pixid);
   void CalcAreaResults  (const UInt_t nevts, const UInt_t napix, const UInt_t aidx);
@@ -85,7 +92,8 @@
   Bool_t SetExtractWindow(UShort_t first, UShort_t size);
 
-  void SetNumEventsDump  (UInt_t dumpevents=500)  { fNumEventsDump  = dumpevents; }
-  void SetNumAreasDump   (UInt_t dumpevents=500)  { fNumAreasDump   = dumpevents; }
-  void SetNumSectorsDump (UInt_t dumpevents=500)  { fNumSectorsDump = dumpevents; }
+  void SetNumEventsDump(UInt_t dumpevents=500)  { fNumEventsDump  = dumpevents; }
+  void SetNumAreasDump(UInt_t dumpevents=500)  { fNumAreasDump   = dumpevents; }
+  void SetNumSectorsDump(UInt_t dumpevents=500)  { fNumSectorsDump = dumpevents; }
+  void SetNumDump(UInt_t n=500) { fNumEventsDump=n; fNumAreasDump=n; fNumSectorsDump=n; }
   void SetPedestalUpdate (Bool_t pedupdate=kTRUE) { fPedestalUpdate = pedupdate;  }
 
@@ -97,4 +105,5 @@
 
   void SetExtractor(MExtractTimeAndCharge *e) { fExtractor = e; }
+  void SetRandomCalculation(Bool_t b=kTRUE) { fRandomCalculation = b; }
 
   ClassDef(MExtractPedestal, 0)   // Base class for pedestal extractors
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 5570)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 5715)
@@ -280,5 +280,5 @@
 // calculate the overall mean and rms in the PostProcess()
 //
-Int_t MPedCalcFromLoGain::Process()
+Int_t MPedCalcFromLoGain::Calc()
 {
     // This is the workaround to put hi- and lo-gains together
@@ -422,7 +422,5 @@
 
     Float_t dummy;
-    fExtractor->SetNoiseCalculation(kTRUE);
     fExtractor->FindTimeAndChargeHiGain(logain,logain,sum,dummy,dummy,dummy,sat,ped,logainabflag);
-    fExtractor->SetNoiseCalculation(kFALSE);
 }
 
@@ -500,6 +498,5 @@
     MExtractPedestal::Print(o);
 
-    *fLog << "CheckWindow   from slice  " << fCheckWinFirst   << " to " << fCheckWinLast << " incl." << endl;
-    *fLog << "Max. allowed signal variation:             " << fMaxSignalVar << endl;
-    *fLog << endl;
-}
+    *fLog << "Max.allowed signal variation: " << fMaxSignalVar << endl;
+    *fLog << "CheckWindow from slice " << fCheckWinFirst   << " to " << fCheckWinLast << " incl." << endl;
+}
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h	(revision 5570)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h	(revision 5715)
@@ -35,6 +35,8 @@
     MArrayB fSlices;             //! workaround to put hi- and lo-gain slices together
 
+    Bool_t fRandomCalculation;
+
     Bool_t ReInit(MParList *pList);
-    Int_t  Process();
+    Int_t  Calc();
     Int_t  PostProcess();
 
@@ -49,5 +51,4 @@
 
 public:
-
     MPedCalcFromLoGain(const char *name=NULL, const char *title=NULL);
 
@@ -56,5 +57,5 @@
     // Setters
     Bool_t SetCheckRange(UShort_t checkfirst=fgCheckWinFirst, UShort_t checklast=fgCheckWinLast);
-    void SetMaxSignalVar(UShort_t maxvar=40)       { fMaxSignalVar = maxvar;    }
+    void SetMaxSignalVar(UShort_t maxvar=40)  { fMaxSignalVar = maxvar;    }
 
     // Getters
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc	(revision 5570)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc	(revision 5715)
@@ -251,5 +251,5 @@
 // calculate the overall mean and rms in the PostProcess()
 //
-Int_t MPedCalcPedRun::Process()
+Int_t MPedCalcPedRun::Calc()
 {
     if (!IsPedBitSet())
@@ -316,7 +316,5 @@
 
     Float_t dummy;
-    fExtractor->SetNoiseCalculation(kTRUE);
     fExtractor->FindTimeAndChargeHiGain(first,logain,sum,dummy,dummy,dummy,sat,ped,abflag);
-    fExtractor->SetNoiseCalculation(kFALSE);
 }
 
@@ -433,15 +431,9 @@
 void MPedCalcPedRun::Print(Option_t *o) const
 {
-    *fLog << GetDescriptor() << ":" << endl;
-    *fLog << "Name of input  MPedestalCam:   " << (fPedestalsIn?fPedestalsIn->GetName():fNamePedestalCamIn.Data()) << " (" << fPedestalsIn << ")" << endl;
-    *fLog << "Name of output MPedestalCam:   " << (fPedestalsOut?fPedestalsOut->GetName():fNamePedestalCamOut.Data()) << " (" << fPedestalsOut << ")" << endl;
-    *fLog << "ExtractWindow from slice       " << fExtractWinFirst << " to " << fExtractWinLast << " incl." << endl;
-    *fLog << "Number overlap lo-gain slices: " << fOverlap << endl;
-    *fLog << "First ped run out of sequence: " << (fIsFirstPedRun?"yes":"no") << endl;
-    *fLog << "Number of used events so far:  " << fUsedEvents << endl;
-
-    if (fExtractor)
-        *fLog << "Extractor used:                " << fExtractor->ClassName() << endl;
-
-    *fLog << endl;
-}
+    MExtractPedestal::Print(o);
+
+    *fLog << "ExtractWindow from slice      " << fExtractWinFirst << " to " << fExtractWinLast << " incl." << endl;
+    *fLog << "Num overlap lo-gain slices:   " << fOverlap << endl;
+    *fLog << "First pedrun out of sequence: " << (fIsFirstPedRun?"yes":"no") << endl;
+    *fLog << "Number of used events so far: " << fUsedEvents << endl;
+}
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.h	(revision 5570)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.h	(revision 5715)
@@ -25,5 +25,5 @@
     Bool_t ReInit(MParList *pList);
     Int_t  PreProcess(MParList *pList);
-    Int_t  Process();
+    Int_t  Calc();
     Int_t  PostProcess();
 
