Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5360)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5361)
@@ -1,3 +1,3 @@
-
+ 
 Please  do  not write behind the end of line tag so that it is  possible
 to   send  a   Changelog   file  to  a  line  printer  directly.  Thanks.
@@ -22,4 +22,22 @@
 
  2004/11/08: Markus Gaug
+
+   * mjobs/MJPedestal.[h,cc]
+     - implemented the possibility to use the extractor to calculate the 
+       pedestals. Now, there are three possibilities: 
+
+       1) SetUseData(): will use MPedCalcFromLoGain together with a data
+                        file (and possibly a signal extractor to 
+                        determine the ranges)
+       2) SetUsePedRun(): will use MPedCalcPedRun together with a 
+                          pedestal run (and possibly a signal extractor
+                          to determine the ranges)
+       3) SetUseExtractor(): Will use the extractor itself and checks 
+                          that the flag IsNoiseCalculation() is set.
+
+   * msignal/MExtractor.[h,cc] 
+     - introduced flag "fNoiseCalculation" to be used by the 
+       deriving classes to calculate the noise from a fixed window in 
+       time.
 
    * mpedestal/MPedCalcFromLoGain.[h,cc]
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 5360)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 5361)
@@ -93,10 +93,10 @@
 // - fExtractor to NULL, 
 // - fDataCheck to kFALSE, 
-// - fUseData to kFALSE
+// - fExtractType to kUsePedRun
 // - fStorage to Normal Storage
 //
 MJPedestal::MJPedestal(const char *name, const char *title) 
     : fRuns(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
-      fDataCheck(kFALSE), fUseData(kFALSE)
+      fDataCheck(kFALSE)
 {
     fName  = name  ? name  : "MJPedestal";
@@ -104,4 +104,5 @@
 
     SetNormalStorage();
+    SetUsePedRun();
 }
 
@@ -502,11 +503,20 @@
 Bool_t MJPedestal::CheckEnvLocal()
 {
-    SetDataCheck(GetEnv("DataCheck", fDataCheck));
-    if (HasEnv("DataCheckDisplay"))
-        fDisplayType = GetEnv("DataCheckDisplay", kFALSE) ? kDataCheckDisplay : kNormalDisplay;
-    SetUseData(GetEnv("UseData", fUseData));
-    SetNoStorage(GetEnv("DisableOutput", IsNoStorage()));
-
-    return kTRUE;
+
+  SetDataCheck(GetEnv("DataCheck", fDataCheck));
+  
+  if (HasEnv("DataCheckDisplay"))
+    fDisplayType = GetEnv("DataCheckDisplay", kFALSE) ? kDataCheckDisplay : kNormalDisplay;
+
+  if (HasEnv("UseData"))
+    fExtractType = GetEnv("UseData",kFALSE) ? kUseData : kUsePedRun;
+  
+  if (HasEnv("UseExtractor"))
+    if (GetEnv("UseExtractor",kFALSE))
+      fExtractType = kUseExtractor;
+
+  SetNoStorage   ( GetEnv("DisableOutput", IsNoStorage()   ));
+  
+  return kTRUE;
 }
 
@@ -590,5 +600,5 @@
     // --------------------------------------------------------------------------------
 
-    const TString type = fUseData ? "data" : "pedestal";
+    const TString type = IsUseData() ? "data" : "pedestal";
 
     *fLog << inf;
@@ -617,6 +627,6 @@
     if (fSequence.IsValid())
     {
-        const Int_t n0 = fUseData ? fSequence.SetupDatRuns(iter, fPathData, "D", fDataCheck) : fSequence.SetupPedRuns(iter, fPathData, "P", fDataCheck);
-        const Int_t n1 = fUseData ? fSequence.GetNumDatRuns() : fSequence.GetNumPedRuns();
+        const Int_t n0 = IsUseData() ? fSequence.SetupDatRuns(iter, fPathData, "D", fDataCheck) : fSequence.SetupPedRuns(iter, fPathData, "P", fDataCheck);
+        const Int_t n1 = IsUseData() ? fSequence.GetNumDatRuns() : fSequence.GetNumPedRuns();
         if (n0==0)
         {
@@ -654,9 +664,10 @@
     MPedCalcPedRun     pedcalc;
     MPedCalcFromLoGain pedlogain;
-    pedlogain.SetPedestalUpdate(kFALSE);
 
     MTaskEnv taskenv("ExtractPedestal");
     if (IsUseData())
       taskenv.SetDefault(&pedlogain);
+    else if (IsUseExtractor())
+      taskenv.SetDefault(fExtractor);
     else
       taskenv.SetDefault(&pedcalc);
@@ -666,10 +677,24 @@
       if (IsUseData())
         pedlogain.SetExtractWindow(15,(Int_t)fExtractor->GetNumHiGainSamples());          
-      else
+      else if (IsUsePedRun())
         {
           pedcalc.SetWindowSize((Int_t)fExtractor->GetNumHiGainSamples());
           pedcalc.SetRange(fExtractor->GetHiGainFirst(), fExtractor->GetHiGainLast());
         }
-    }
+      else if (IsUseExtractor())
+        if (!fExtractor->IsNoiseCalculation())
+          {
+            *fLog << err << GetDescriptor() 
+                  << "Extraction Type kUseExtractor is chosen, but the extractor has no flag kNoiseCalculation set! " << endl;
+            return kFALSE;
+          }
+    }
+    else if (IsUseExtractor())
+      {
+        *fLog << err << GetDescriptor()
+              << "Extraction Type kUseExtractor is chosen, but no extractor has been handed over" << endl;
+        return kFALSE;
+      }
+    
   /*
     else
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 5360)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 5361)
@@ -41,20 +41,20 @@
   static const Float_t  fgRefPedRmsGalacticOuter;      //! Ref. line ped. RMS for galactic source - outer pixels     
     
-  MRunIter   *fRuns;                                  // Used pedestal runs
-  MExtractor *fExtractor;                             // Signal extractor, used to find the nr. of used FADC slices
+  MRunIter   *fRuns;                                   // Used pedestal runs
+  MExtractor *fExtractor;                              // Signal extractor, used to find the nr. of used FADC slices
   
-  MPedestalCam  fPedestalCam;                         // Created pedestal results
-  MBadPixelsCam fBadPixels;                           // Bad Pixels
+  MPedestalCam  fPedestalCam;                          // Created pedestal results
+  MBadPixelsCam fBadPixels;                            // Bad Pixels
   
-  enum Display_t {kDataCheckDisplay, kNormalDisplay}; // Possible Display types
+  enum Display_t {kDataCheckDisplay, kNormalDisplay};  // Possible Display types
+  Display_t fDisplayType;                              // Chosen Display type    
+  
+  enum Storage_t { kNoStorage };                       // Possible flags for the storage of results
+  Byte_t fStorage;                                     // Bit-field for chosen storage type
+    
+  Bool_t fDataCheck;                                   // Flag if the data check is run on raw data
 
-  Display_t fDisplayType;                             // Chosen Display type    
-  
-  enum Storage_t { kNoStorage };                      // Possible flags for the storage of results
-  
-  Byte_t fStorage;                                    // Bit-field for chosen storage type
-    
-  Bool_t fDataCheck;                                  // Flag if the data check is run on raw data
-  Bool_t fUseData;                                    // Use data-runs from sequence instead of pedestal runs
+  enum Extract_t {kUseData, kUsePedRun, kUseExtractor}; // Possible flags for the extraction of the pedestal
+  Extract_t fExtractType;                              // Chosen extractor type
   
   Bool_t ReadPedestalCam();
@@ -80,5 +80,7 @@
   const char*  GetOutputFile() const;
   const Bool_t IsDataCheck  () const    { return fDataCheck; }
-  const Bool_t IsUseData    () const    { return fUseData;   }    
+  const Bool_t IsUseData    () const    { return fExtractType == kUseData;   }
+  const Bool_t IsUseExtractor () const    { return fExtractType == kUseExtractor;   }
+  const Bool_t IsUsePedRun   () const    { return fExtractType == kUsePedRun;   }  
   
   Bool_t Process    ();
@@ -88,6 +90,8 @@
   void SetExtractor (       MExtractor* ext   ) { fExtractor = ext;     }
   void SetInput     (       MRunIter  *iter   ) { fRuns      = iter;    }
-  void SetUseData   ( const Bool_t b=kTRUE    ) { fUseData   = b;       }
-  void SetDataCheck ( const Bool_t b=kTRUE    ) { fDataCheck = b; 
+  void SetUseData     ()                        { fExtractType = kUseData;      }
+  void SetUseExtractor()                        { fExtractType = kUseExtractor; }
+  void SetUsePedRun   ()                        { fExtractType = kUsePedRun;    }
+  void SetDataCheck   ( const Bool_t b=kTRUE  ) { fDataCheck = b; 
                                                   b ? SetDataCheckDisplay() : SetNormalDisplay(); }
   void SetDataCheckDisplay()                    { fDisplayType = kDataCheckDisplay; }
Index: trunk/MagicSoft/Mars/msignal/MExtractor.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractor.h	(revision 5360)
+++ trunk/MagicSoft/Mars/msignal/MExtractor.h	(revision 5361)
@@ -57,6 +57,4 @@
   TString  fNamePedestalCam;              // Name of the 'MPedestalCam' container
 
-  Bool_t IsNoiseCalculation()   {   return fNoiseCalculation;   }
-  
   virtual void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const { }
   virtual void FindSignalLoGain(Byte_t *firstused, Float_t &sum, Byte_t &sat) const { }
@@ -78,4 +76,6 @@
   Float_t GetNumLoGainSamples() const { return fNumLoGainSamples; }
   
+  Bool_t IsNoiseCalculation()   {   return fNoiseCalculation;   }
+  
   virtual void SetRange    ( Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0 );
 
