Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 7042)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 7043)
@@ -21,4 +21,77 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2005/05/17 Thomas Bretz
+ 
+   * callisto.rc, callisto_Dec04Jan05.rc:
+     - added new comments diescribing setup of MFCosmics
+
+   * mfilter/MFCosmics.[h,cc]:
+     - skip bad pixels using MBadPixelsCam
+     - implemented a check in PostProcess about the fraction
+       of events which survived or were rejected
+     - added ReadEnv for setup
+
+   * mfilter/Makefile:
+     - added mbadpixels
+     - removed mmain and manalysis
+
+   * mhcalib/MHCalibrationChargeCam.h:
+     - removed numbers from data member descrition -- too much
+       to maintain
+
+   * mhcalib/MHCalibrationChargePINDiode.h:
+     - incremented version number (undocumented from bcn)
+
+   * mjobs/MJCalibration.cc:
+     - reorganized some TText output (undocumented from bcn)
+     - overwrite the default of MaxNumberEmptyPixels by 0.05
+       (undocumented from bcn)
+
+   * msignal/MExtractTimeAndChargeDigitalFilter.cc:
+     - changed fgLoGainStartShift from -2.8 to -1.8 
+       (undocumented from bcn)
+
+   * msignal/MExtractTimeAndChargeSlidingWindow.h:
+     - increased version number from 0 to 1 (undocumented from bcn)
+
+
+
+ 2005/05/17 Markus Gaug (2005/05/16)
+
+   * msignal/MExtractor.[h,cc]
+     - introduce two new variables: fResolutionPerPheHiGain and 
+       fResolutionPerPheLoGain, to be set by deriving extractors. 
+     - set version number one higher.
+
+   * msignal/MExtractFixedWindow.[h,cc]
+   * msignal/MExtractTimeAndChargeSlidingWindow.[h,cc]
+   * msignal/MExtractTimeAndChargeSpline.[h,cc]
+   * msignal/MExtractTimeAndChargeDigitalFilter.[h,cc]
+     - set the variables fResolutionPerPheHiGain and 
+       fResolutionPerPheLoGain
+
+   * msignal/MExtractPINDiode.[h,cc]
+     - adapt to current PIN Diode signal, fit signal with Gaussian
+     - set version number up by one.
+     
+   * msignal/MExtractedSignalPINDiode.[h,cc]
+     - set new data member fExtractedChi2
+     - set version number up by one.
+
+   * mhcalib/MHCalibrationChargePINDiode.cc
+     - adapt one function to newly used names.
+     - adapt signal tests.
+
+   * mjobs/MJPedestal.[h,cc]
+     - read MBadPixelsCam together with extractor, if exisiting 
+       (necessary for bad pixels exclusion in pulse position search).
+
+   * mjobs/MJCalibration.[h,cc]
+     - use MFCosmics in any case (not only for CT1-pulses) and apply 
+       a quality criteria depending on number of rejected events: 
+       MaxExcludedEvents (default: 50%). 
+
+
+
  2005/05/17 Daniela Dorner
 
Index: /trunk/MagicSoft/Mars/callisto.rc
===================================================================
--- /trunk/MagicSoft/Mars/callisto.rc	(revision 7042)
+++ /trunk/MagicSoft/Mars/callisto.rc	(revision 7043)
@@ -112,10 +112,9 @@
 # Configure MJCalibration
 # -------------------------------------------------------------------------
+
 # Switch on relative time calibration
 #MJCalibration.RelTimeCalibration: Yes
 # Switch on intensity calibration
 #MJCalibration.IntensityCalibration: Yes
-# Set color to be used
-#MJCalibration.Color:
 # Type of used data format: raw, root, mc
 #MJCalibration.DataType: Root
@@ -131,4 +130,12 @@
 #MJCalibration.PixelCheck: Yes
 #MJCalibTest.PixelCheck: Yes
+
+# -------------------------------------------------------------------------
+# Individual events check for calibration results
+# -------------------------------------------------------------------------
+
+#ContCosmics.MaxEmptyPixels:      0.2
+#ContCosmics.MaxExcludedFraction: 1
+#ContCosmics.MinAcceptedFraction: 0
 
 # -------------------------------------------------------------------------
Index: /trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc
===================================================================
--- /trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc	(revision 7042)
+++ /trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc	(revision 7043)
@@ -122,4 +122,5 @@
 # Configure MJCalibration
 # -------------------------------------------------------------------------
+
 # Switch on relative time calibration
 #MJCalibration.RelTimeCalibration: Yes
@@ -143,4 +144,12 @@
 
 # -------------------------------------------------------------------------
+# Individual events check for calibration results
+# -------------------------------------------------------------------------
+
+#ContCosmics.MaxEmptyPixels:      0.2
+#ContCosmics.MaxExcludedFraction: 1
+#ContCosmics.MinAcceptedFraction: 0
+
+# -------------------------------------------------------------------------
 # In case of MOON DATA, uncomment the following lines:
 # (better: call callisto with option "-moon")
Index: /trunk/MagicSoft/Mars/mfilter/MFCosmics.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfilter/MFCosmics.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/mfilter/MFCosmics.cc	(revision 7043)
@@ -17,6 +17,7 @@
 !
 !   Author(s): Markus Gaug  02/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2005
 !
 !
@@ -33,7 +34,14 @@
 //   the outer pixels have some defect).
 //
+//   In the PostProcess we...
+//    a) check the ratio of events which were accepted against
+//       fMinAcceptedFraction.
+//    b) check the ratio of events which were rejected against
+//       fMaxExcludedFraction.
+//
 //  Input Containers:
 //   MRawEvtData
 //   MPedestalCam
+//   MBadPixelsCam
 //   MExtractedSignalCam
 //
@@ -55,4 +63,7 @@
 #include "MPedestalPix.h"
 
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
 #include "MExtractedSignalCam.h"
 #include "MExtractedSignalPix.h"
@@ -69,6 +80,7 @@
 //
 MFCosmics::MFCosmics(const char *name, const char *title)
-    : fPedestals(NULL), fSignals(NULL), fRawEvt(NULL),
-    fNamePedestalCam(fgNamePedestalCam), fMaxEmptyPixels(0.2)
+    : fPedestals(NULL), fSignals(NULL), fBadPixels(NULL), fRawEvt(NULL),
+    fNamePedestalCam(fgNamePedestalCam), fMaxEmptyPixels(0.2),
+    fMinAcceptedFraction(0), fMaxExcludedFraction(1)
 {
     fName  = name  ? name  : "MFCosmics";
@@ -99,4 +111,11 @@
     }
 
+    fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
+    if (!fBadPixels)
+    {
+        *fLog << err << "MBadPixelsCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
     fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
     if (!fSignals)
@@ -133,6 +152,6 @@
 {
     fResult = CosmicsRejection();
-
     fCut[fResult ? 0 : 1]++;
+
     return kTRUE;
 }
@@ -163,6 +182,9 @@
         const UInt_t idx = pixel.GetPixelId();
 
-        MExtractedSignalPix &sig =  (*fSignals)[idx];
-        MPedestalPix        &ped =  (*fPedestals)[idx];
+        if ((*fBadPixels)[idx].IsUnsuitable())
+            continue;
+
+        const MExtractedSignalPix &sig =  (*fSignals)[idx];
+        const MPedestalPix        &ped =  (*fPedestals)[idx];
 
         const Float_t pedrms = ped.GetPedestalRms()*fSqrtHiGainSamples;
@@ -186,7 +208,18 @@
 }
 
+// ---------------------------------------------------------
+//
+//   In the PostProcess we...
+//    a) check the ratio of events which were accepted against
+//       fMinAcceptedFraction.
+//    b) check the ratio of events which were rejected against
+//       fMaxExcludedFraction.
+//
+//   return failure (kFALSE) if condition is not fullfilled.
+//
 Int_t MFCosmics::PostProcess()
 {
-    if (GetNumExecutions()==0)
+    const UInt_t n = GetNumExecutions();
+    if (n==0)
         return kTRUE;
 
@@ -196,14 +229,56 @@
 
     *fLog << " " << setw(7) << fCut[0] << " (" << setw(3) ;
-    *fLog << (int)(fCut[0]*100/GetNumExecutions()) ;
+    *fLog << (int)(fCut[0]*100/n);
     *fLog << "%) Detected cosmics " ;
     *fLog << " (with fMaxEmptyPixels = " << fMaxEmptyPixels*100 << "%)" << endl;
 
     *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
-    *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
+    *fLog << (int)(fCut[1]*100/n);
     *fLog << "%) No cosmics!" << endl;
     *fLog << endl;
 
-    return kTRUE;
-}
-
+    const Float_t min = fMinAcceptedFraction*n;
+    const Float_t max = fMaxExcludedFraction*n;
+    if (fCut[0]<min)
+    {
+        *fLog << err << "ERROR - Fraction of accepted events " << min*100;
+        *fLog << "% underrun " << fMinAcceptedFraction*100 << "%... abort." << endl;
+        return kFALSE;
+    }
+    if (fCut[1]>max)
+    {
+        *fLog << err << "ERROR - Fraction of excluded events " << max*100;
+        *fLog << "% exceeded " << fMaxExcludedFraction*100 << "%... abort." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv, eg:
+//   MFCosmics.MaxEmptyPixels:    0.2
+//   MFCosmics.MaxExcludedFraction: 1
+//   MFCosmics.MinAcceptedFraction: 0
+//
+Int_t MFCosmics::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Bool_t rc = kFALSE;
+    if (IsEnvDefined(env, prefix, "MaxEmptyPixels", print))
+    {
+        rc = kTRUE;
+        SetMaxEmptyPixels(GetEnvValue(env, prefix, "MaxEmptyPixels", fMaxEmptyPixels));
+    }
+    if (IsEnvDefined(env, prefix, "MaxExcludedFraction", print))
+    {
+        rc = kTRUE;
+        SetMaxExcludedFraction(GetEnvValue(env, prefix, "MaxExcludedFraction", fMaxExcludedFraction));
+    }
+    if (IsEnvDefined(env, prefix, "MinAcceptedFraction", print))
+    {
+        rc = kTRUE;
+        fMinAcceptedFraction = GetEnvValue(env, prefix, "MinAcceptedFraction", fMinAcceptedFraction);
+    }
+    return rc;
+}
Index: /trunk/MagicSoft/Mars/mfilter/MFCosmics.h
===================================================================
--- /trunk/MagicSoft/Mars/mfilter/MFCosmics.h	(revision 7042)
+++ /trunk/MagicSoft/Mars/mfilter/MFCosmics.h	(revision 7043)
@@ -9,4 +9,5 @@
 
 class MPedestalCam;
+class MBadPixelsCam;
 class MExtractedSignalCam;
 
@@ -18,4 +19,5 @@
     MPedestalCam        *fPedestals; // Pedestals of all pixels in the camera
     MExtractedSignalCam *fSignals;   // Calibration events of all pixels in the camera
+    MBadPixelsCam       *fBadPixels; // Bad pixel used for exclusions
 
     MRawEvtData         *fRawEvt;    // raw event data (time slices)
@@ -29,11 +31,18 @@
     Float_t fSqrtHiGainSamples;      // Square root of the number of used Hi-Gain Samples
 
+    Float_t fMinAcceptedFraction;      // return error if exceeded
+    Float_t fMaxExcludedFraction;      // return error if exceeded
+
+    // MFCosmics
+    Bool_t CosmicsRejection() const;
+
+    // MTask
     Bool_t ReInit(MParList *pList);
     Int_t  PreProcess(MParList *pList);
     Int_t  Process();
     Int_t  PostProcess();
+    Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
 
-    Bool_t CosmicsRejection() const;
-
+    // MFilter
     Bool_t IsExpressionTrue() const { return fResult; }
   
@@ -44,5 +53,8 @@
     Float_t GetMaxEmptyPixels() const          { return fMaxEmptyPixels; }
 
-    void SetNamePedestalCam(const char *name) { fNamePedestalCam = name; }
+    void    SetMaxExcludedFraction(const Float_t n) { fMaxExcludedFraction = n;    }
+    void    SetMinAcceptedFraction(const Float_t n) { fMinAcceptedFraction = n;    }
+
+    void    SetNamePedestalCam(const char *name) { fNamePedestalCam = name; }
 
     ClassDef(MFCosmics, 0)   // Filter to perform a cosmics rejection
Index: /trunk/MagicSoft/Mars/mfilter/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mfilter/Makefile	(revision 7042)
+++ /trunk/MagicSoft/Mars/mfilter/Makefile	(revision 7043)
@@ -11,8 +11,7 @@
 #------------------------------------------------------------------------------
 
-INCLUDES = -I. -I../mbase -I../mfbase -I../mraw -I../mmc -I../mdata \
-           -I../manalysis -I../mfileio  -I../mgeom -I../mimage      \
-           -I../mhbase -I../mmain -I../mgui -I../msignal -I../mpointing  \
-           -I../mpedestal
+INCLUDES = -I. -I../mbase -I../mfbase -I../mraw -I../mdata \
+           -I../mfileio  -I../mgeom -I../mimage -I../mgui  \
+           -I../mhbase -I../msignal -I../mpedestal -I../mbadpixels
 
 CINT     = Filter
Index: /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h	(revision 7042)
+++ /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h	(revision 7043)
@@ -24,13 +24,13 @@
 private:
 
-  static const Int_t   fgChargeHiGainNbins;          //! Nr. bins of HiGain Histograms  (now set to:  550  )
-  static const Axis_t  fgChargeHiGainFirst;          //! First Bin of HiGain Histograms (now set to: -100.5)
-  static const Axis_t  fgChargeHiGainLast;           //! Last Bin of HiGain Histograms  (now set to:  999.5)
-  static const Int_t   fgChargeLoGainNbins;          //! First Bin of LoGain Histograms (now set to:  325  )
-  static const Axis_t  fgChargeLoGainFirst;          //! First Bin of LoGain Histograms (now set to: -150.5)
-  static const Axis_t  fgChargeLoGainLast;           //! Last Bin of LoGain Histograms  (now set to:  499.5)
-  static const Float_t fgProbLimit;                  //! The default for fProbLimit    (now set to: 0.00001)
+  static const Int_t   fgChargeHiGainNbins;          //! Nr. bins of HiGain Histograms
+  static const Axis_t  fgChargeHiGainFirst;          //! First Bin of HiGain Histograms
+  static const Axis_t  fgChargeHiGainLast;           //! Last Bin of HiGain Histograms
+  static const Int_t   fgChargeLoGainNbins;          //! First Bin of LoGain Histograms
+  static const Axis_t  fgChargeLoGainFirst;          //! First Bin of LoGain Histograms
+  static const Axis_t  fgChargeLoGainLast;           //! Last Bin of LoGain Histograms
+  static const Float_t fgProbLimit;                  //! The default for fProbLimit
   
-  static const TString fgReferenceFile;              //! default for fReferenceFile ("mjobs/calibrationref.rc")
+  static const TString fgReferenceFile;              //! default for fReferenceFile
 
   static const TString gsHistName;                   //! Default Histogram names
@@ -44,13 +44,13 @@
   static const TString gsAbsHistYTitle;              //! Default Histogram y-axis titles abs.times
   
-  static const Float_t fgNumHiGainSaturationLimit;   //! The default for fNumHiGainSaturationLimit (now at: 0.01)
-  static const Float_t fgNumLoGainSaturationLimit;   //! The default for fNumLoGainSaturationLimit (now at: 0.005)
+  static const Float_t fgNumHiGainSaturationLimit;   //! The default for fNumHiGainSaturationLimit
+  static const Float_t fgNumLoGainSaturationLimit;   //! The default for fNumLoGainSaturationLimit
 
-  static const Float_t fgTimeLowerLimit;             //! Default for fTimeLowerLimit    (now set to: 1.) 
-  static const Float_t fgTimeUpperLimit;             //! Default for fTimeUpperLimit    (now set to: 2.)
+  static const Float_t fgTimeLowerLimit;             //! Default for fTimeLowerLimit
+  static const Float_t fgTimeUpperLimit;             //! Default for fTimeUpperLimit
   
-  Int_t   fLoGainNbins;                              // Number of LoGain bins        
+  Int_t   fLoGainNbins;                              // Number of LoGain bins
   Axis_t  fLoGainFirst;                              // Lower histogram limit low gain
-  Axis_t  fLoGainLast;                               // Upper histogram limit low gain  
+  Axis_t  fLoGainLast;                               // Upper histogram limit low gain
 
   TString fAbsHistName;                              // Histogram names abs.times
Index: /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePINDiode.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePINDiode.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePINDiode.cc	(revision 7043)
@@ -191,4 +191,8 @@
   fHRmsCharge.SetBins(fRmsChargeNbins,fRmsChargeFirst,fRmsChargeLast);
 
+  fExclusionMean  = 0;
+  fExclusionSigma = 0;  
+  fExclusionChi2  = 0;
+
   return kTRUE;
 
@@ -250,9 +254,28 @@
   const Float_t signal = (float)extractor->GetExtractedSignal();
   const Float_t time   = extractor->GetExtractedTime();
-  const Float_t rms    = extractor->GetExtractedRms();
-
+  const Float_t sigma    = extractor->GetExtractedSigma();
+  const Float_t chi2    = extractor->GetExtractedChi2();
+
+  if (time < 3. || time > 24.)
+    {
+      fExclusionMean++;
+      return kTRUE;
+    }
+  
+  if (sigma < 5. || sigma > 18.)
+    {
+      fExclusionSigma++;
+      return kTRUE;
+    }
+  
+  if (chi2  > 0.35)
+    {
+      fExclusionChi2++;
+      return kTRUE;
+    }
+  
   FillHistAndArray(signal);
   FillAbsTime(time);
-  FillRmsCharge(rms);
+  FillRmsCharge(sigma);
 
   return kTRUE;
@@ -293,7 +316,4 @@
   FitRmsCharge();
 
-  CreateFourierSpectrum();
-  fPINDiode->SetOscillating  ( !IsFourierSpectrumOK() );
-
   fPINDiode->SetMean     (  fMean     );
   fPINDiode->SetMeanVar  (  fMeanErr  * fMeanErr );
@@ -311,27 +331,4 @@
 
   fPINDiode->SetValid(kTRUE);
-
-  const Byte_t  loweredge  = fSigPIN->GetFirstUsedSlice();
-  const Byte_t  upperedge  = fSigPIN->GetLastUsedSlice();
-  const Float_t lowerlimit = (Float_t)loweredge + fTimeLowerLimit;
-  const Float_t upperlimit = (Float_t)upperedge + fTimeUpperLimit;  
-
-  if (GetAbsTimeMean() < lowerlimit)
-    {
-      *fLog << warn << GetDescriptor() 
-            << Form("%s%3.1f%s%2.1f%s",": Mean ArrivalTime: ",GetAbsTimeMean()," smaller than ",
-                    lowerlimit," FADC slices from lower edge in PIN Diode") << endl;
-      *fLog << warn << GetDescriptor() << ": No PIN Diode calibration!! " << endl;
-      fPINDiode->SetValid(kFALSE);
-    }
-  
-  if ( GetAbsTimeMean() > upperlimit )
-    {
-      *fLog << warn << GetDescriptor() 
-            << Form("%s%3.1f%s%2.1f%s",": Mean ArrivalTime: ",GetAbsTimeMean()," bigger than ",
-                    upperlimit," FADC slices from upper edge in PIN Diode") << endl;
-      *fLog << warn << GetDescriptor() << ": No PIN Diode calibration!! " << endl;
-      fPINDiode->SetValid(kFALSE);
-    }
 
   return kTRUE;
Index: /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePINDiode.h
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePINDiode.h	(revision 7042)
+++ /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePINDiode.h	(revision 7043)
@@ -60,4 +60,8 @@
   Float_t fTimeLowerLimit;                //  Limit dist. to first signal slice (units: FADC slices) 
   Float_t fTimeUpperLimit;                //  Limit dist. to last signal slice  (units: FADC slices) 
+
+  Int_t   fExclusionMean;                 //  Number of events excluded by deviating mean
+  Int_t   fExclusionSigma;                //  Number of events excluded by deviating sigma
+  Int_t   fExclusionChi2;                 //  Number of events excluded by deviating chi2
   
 public:
@@ -77,9 +81,14 @@
         TH1F *GetHRmsCharge()                  { return &fHRmsCharge;       }
   const TH1F *GetHRmsCharge()            const { return &fHRmsCharge;       }
-  Float_t     GetRmsChargeMean()         const { return fRmsChargeMean;     }
-  Float_t     GetRmsChargeMeanErr()      const { return fRmsChargeMeanErr;  }
-  Float_t     GetRmsChargeSigma()        const { return fRmsChargeSigma;    }
-  Float_t     GetRmsChargeSigmaErr()     const { return fRmsChargeSigmaErr; }
+  Float_t     GetRmsChargeMean()      const { return fRmsChargeMean;     }
+  Float_t     GetRmsChargeMeanErr()   const { return fRmsChargeMeanErr;  }
+  Float_t     GetRmsChargeSigma()     const { return fRmsChargeSigma;    }
+  Float_t     GetRmsChargeSigmaErr()  const { return fRmsChargeSigmaErr; }
 
+  Int_t       GetExclusionMean()      const { return fExclusionMean;     }
+  Int_t       GetExclusionSigma()     const { return fExclusionSigma;    }
+  Int_t       GetExclusionChi2()      const { return fExclusionChi2;     }
+  
+  
   // Fill histos
   Bool_t FillRmsCharge(const Float_t q);
@@ -108,5 +117,5 @@
   void SetHistYTitle( const char *name )  { fHistYTitle = name; }
    
-  ClassDef(MHCalibrationChargePINDiode, 1)  // Histogram class for Charge PIN Diode Calibration 
+  ClassDef(MHCalibrationChargePINDiode, 2)  // Histogram class for Charge PIN Diode Calibration 
 };
 
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 7043)
@@ -943,39 +943,33 @@
       TText *t3 = pave2->AddText(Form("Signal Sigma smaller Pedestal RMS:      %3i pixels",
                                        CountBadPixels(&disp25,1)));
-      t3->SetTextColor(gStyle->GetColorPalette(Int_t(1./max2*numcol + 1.)));
+      t3->SetTextColor(gStyle->GetColorPalette(Int_t(1./max2*numcol)));
       t3->SetTextAlign(12);
-
-      TText *t7 = pave2->AddText(Form("Deviating Number of Photo-electrons:     %3i pixels",
-                                       CountBadPixels(&disp25,2)));
-      t7->SetTextColor(gStyle->GetColorPalette(Int_t(2./max*numcol + 1.)));
-      t7->SetTextAlign(12);
-
-      TText *tt1 = pave2->AddText(Form("High Gain Signals could not be fitted:   %3i pixels",
+      TText *tt1 = pave2->AddText(Form("High Gain Signals could not be fitted:    %3i pixels",
                                        CountBadPixels(&disp25,3)));
-      tt1->SetTextColor(gStyle->GetColorPalette(Int_t(3./max2*numcol + 1.)));
+      tt1->SetTextColor(gStyle->GetColorPalette(Int_t(3./max2*numcol)));
       tt1->SetTextAlign(12);
-      TText *tt2 = pave2->AddText(Form("Low  Gain Signals could not be fitted:   %3i pixels",
+      TText *tt2 = pave2->AddText(Form("Low  Gain Signals could not be fitted:    %3i pixels",
                                        CountBadPixels(&disp25,4)));
-      tt2->SetTextColor(gStyle->GetColorPalette(Int_t(4./max2*numcol + 1.)));
+      tt2->SetTextColor(gStyle->GetColorPalette(Int_t(4./max2*numcol)));
       tt2->SetTextAlign(12);
-      TText *tt3 = pave2->AddText(Form("Relative Arr. Times could not be fitted:  %3i pixels",
+      TText *tt3 = pave2->AddText(Form("Relative Arr. Times could not be fitted:   %3i pixels",
                                        CountBadPixels(&disp25,5)));
-      tt3->SetTextColor(gStyle->GetColorPalette(Int_t(5./max2*numcol + 1.)));
+      tt3->SetTextColor(gStyle->GetColorPalette(Int_t(5./max2*numcol)));
       tt3->SetTextAlign(12);
-      TText *tt4 = pave2->AddText(Form("High Gain Signals Oscillation:                %3i pixels",
+      TText *tt4 = pave2->AddText(Form("High Gain Signals Oscillation:                 %3i pixels",
                                        CountBadPixels(&disp25,6)));
-      tt4->SetTextColor(gStyle->GetColorPalette(Int_t(6./max2*numcol + 1.)));
+      tt4->SetTextColor(gStyle->GetColorPalette(Int_t(6./max2*numcol)));
       tt4->SetTextAlign(12);
       TText *tt5 = pave2->AddText(Form("Low  Gain Signals Oscillation:                %3i pixels",
                                        CountBadPixels(&disp25,7)));
-      tt5->SetTextColor(gStyle->GetColorPalette(Int_t(7./max2*numcol + 1.)));
+      tt5->SetTextColor(gStyle->GetColorPalette(Int_t(7./max2*numcol)));
       tt5->SetTextAlign(12); 
       TText *tt6 = pave2->AddText(Form("Relative Arr. Times Oscillation:               %3i pixels",
                                        CountBadPixels(&disp25,8)));
-      tt6->SetTextColor(gStyle->GetColorPalette(Int_t(8./max2*numcol + 1.)));
+      tt6->SetTextColor(gStyle->GetColorPalette(Int_t(8./max2*numcol)));
       tt6->SetTextAlign(12);
-      TText *tt8 = pave2->AddText(Form("Deviating global F-Factor:                        %3i pixels",
+      TText *tt8 = pave2->AddText(Form("Deviating global F-Factor:                       %3i pixels",
                                        CountBadPixels(&disp25,9)));
-      tt8->SetTextColor(gStyle->GetColorPalette(Int_t(9./max2*numcol + 1.)));
+      tt8->SetTextColor(gStyle->GetColorPalette(Int_t(9./max2*numcol)));
       tt8->SetTextAlign(12);
       pave2->Draw();
@@ -1561,5 +1555,4 @@
 Bool_t MJCalibration::CheckEnvLocal()
 {
-
     TString dis = GetEnv("Display", "");
     if (dis.BeginsWith("Full", TString::kIgnoreCase))
@@ -1935,8 +1928,9 @@
     //
     MFCosmics cosmics;
-    MContinue cont(&cosmics);
-
-    if (fColor == MCalibrationCam::kCT1)
-      tlist.AddToList(&cont);
+    cosmics.SetMaxEmptyPixels(0.05);
+    cosmics.SetMinAcceptedFraction(0.5);
+
+    MContinue cont(&cosmics, "ContCosmics");
+    tlist.AddToList(&cont);
 
     MCalibColorSteer steer;
Index: /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 7043)
@@ -154,5 +154,5 @@
 }
 
-MExtractor *MJPedestal::ReadCalibration() const
+MExtractor *MJPedestal::ReadCalibration()
 {
     const TString fname = Form("%s/calib%08d.root", fPathIn.Data(), fSequence.GetSequence());
@@ -172,4 +172,13 @@
         *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
         return NULL;
+    }
+
+    if (file.FindKey("MBadPixelsCam"))
+    {
+        MBadPixelsCam bad;
+        if (bad.Read()<=0)
+            *fLog << warn << "Unable to read MBadPixelsCam from " << fname << endl;
+        else
+            fBadPixels.Merge(bad);
     }
 
Index: /trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 7042)
+++ /trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 7043)
@@ -74,5 +74,5 @@
     Bool_t fIsUseHists;                      // Switch on histogramming or not
 
-    MExtractor *ReadCalibration() const;
+    MExtractor *ReadCalibration();
     Bool_t ReadPedestalCam();
     Bool_t WriteResult();
Index: /trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.cc
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.cc	(revision 7043)
@@ -150,5 +150,40 @@
   fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
   fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);  
-  
+
+  const Int_t wshigain = fHiGainLast-fHiGainFirst+1;
+  const Int_t wslogain = fLoGainLast-fLoGainFirst+1;
+
+  switch (wshigain)
+    {
+    case 2:
+      SetResolutionPerPheHiGain(0.021);
+      break;
+    case 4:
+    case 6:
+    case 8:
+    case 10:
+    case 12:
+    case 14:
+      SetResolutionPerPheHiGain(0.011);      
+      break;
+    default:
+        *fLog << warn << GetDescriptor() << ": Could not set the hi-gain extractor resolution/phe for window size " << wshigain << endl;
+    }
+  
+  switch (wslogain)
+    {
+    case 4:
+      SetResolutionPerPheLoGain(0.063);
+      break;
+    case 6:
+      SetResolutionPerPheLoGain(0.017);
+      break;
+    case 8:
+    case 10:
+      SetResolutionPerPheLoGain(0.011);      
+      break;
+    default:
+      *fLog << warn << GetDescriptor() << ": Could not set the lo-gain extractor resolution/phe for window size " << wslogain << endl;
+    }
 }
 
Index: /trunk/MagicSoft/Mars/msignal/MExtractPINDiode.cc
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractPINDiode.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractPINDiode.cc	(revision 7043)
@@ -25,17 +25,36 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-//   MExtractPINDiode
+//  MExtractPINDiode
 //
 //  Extracts the signal from a fixed window in a given range.
 //
 //  Call: SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast) 
-//  to modify the ranges. Ranges have to be an even number. In case of odd 
-//  ranges, the last slice will be reduced by one.
+//  to modify the ranges.
+//
 //  Defaults are: 
 // 
-//   fHiGainFirst =  fgHiGainFirst =  3 
-//   fHiGainLast  =  fgHiGainLast  =  14
-//   fLoGainFirst =  fgLoGainFirst =  3 
-//   fLoGainLast  =  fgLoGainLast  =  14
+//   fHiGainFirst =  fgHiGainFirst =  0 
+//   fHiGainLast  =  fgHiGainLast  =  29
+//   fLoGainFirst =  fgLoGainFirst =  0
+//   fLoGainLast  =  fgLoGainLast  =  0
+//
+//  The FADC slices are fit by a Gaussian around the pulse maximum. 
+//  The following figures show two typical (high-intensity and low-intensity) 
+//  pulses together with the applied fit:
+//
+//Begin_Html
+/*
+<img src="images/PINDiode_pulse_high.gif">
+<img src="images/PINDiode_pulse_low.gif">
+*/
+//End_Html
+//
+// The fit ranges can be modified with the functions:
+// - SetLowerFitLimit() 
+// - SetUpperFitLimit()
+//
+// Defaults are:
+//   - fLowerFitLimit: 2
+//   - fUpperFitLimit: 5
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -44,4 +63,8 @@
 #include <fstream>
 
+#include <TF1.h>
+#include <TH1.h>
+#include <TPad.h>
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -61,9 +84,12 @@
 using namespace std;
 
-const UInt_t MExtractPINDiode::fgPINDiodeIdx     = 100;
-const Byte_t MExtractPINDiode::fgHiGainFirst =  0;
-const Byte_t MExtractPINDiode::fgHiGainLast  =  14;
-const Byte_t MExtractPINDiode::fgLoGainFirst =  0;
-const Byte_t MExtractPINDiode::fgLoGainLast  =  14;
+const UInt_t MExtractPINDiode::fgPINDiodeIdx   =  3;
+const Byte_t MExtractPINDiode::fgHiGainFirst   =  0;
+const Byte_t MExtractPINDiode::fgHiGainLast    = 29;
+const Byte_t MExtractPINDiode::fgLoGainFirst   =  0;
+const Byte_t MExtractPINDiode::fgLoGainLast    =  0;
+const Byte_t MExtractPINDiode::fgLowerFitLimit =  2;
+const Byte_t MExtractPINDiode::fgUpperFitLimit =  5;
+
 // --------------------------------------------------------------------------
 //
@@ -72,9 +98,13 @@
 // Calls: 
 // - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
-// - SetPINDiodeIdx()
+//
+// - Set fPINDiodeIdx   to fgPINDiodeIdx
+// - Set fLowerFitLimit to fgLowerFitLimit
+// - Set fUpperFitLimit to fgUpperFitLimit
 //
 MExtractPINDiode::MExtractPINDiode(const char *name, const char *title)
-{
-  
+    : fSlices(NULL)
+{
+
   fName  = name  ? name  : "MExtractPINDiode";
   fTitle = title ? title : "Task to extract the signal from the FADC slices";
@@ -82,4 +112,19 @@
   SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
   SetPINDiodeIdx();
+
+  SetLowerFitLimit();
+  SetUpperFitLimit();  
+
+  fPedMean.Set(2);
+}
+
+// --------------------------------------------------------------------------
+//
+// - delete the histogram fSlices, if it exists
+//
+MExtractPINDiode::~MExtractPINDiode()
+{
+  if (fSlices)
+    delete fSlices;
 }
 
@@ -89,8 +134,5 @@
 //
 // Checks: 
-// - if the window defined by (fHiGainLast-fHiGainFirst-1) are odd, subtract one
-// - if the window defined by (fLoGainLast-fLoGainFirst-1) are odd, subtract one
-// - if the Hi Gain window is smaller than 2, set fHiGainLast to fHiGainFirst+1
-// - if the Lo Gain window is smaller than 2, set fLoGainLast to fLoGainFirst+1
+// - if the Hi Gain window is smaller than 4, set fHiGainLast to fHiGainFirst+3
 // 
 // Calls:
@@ -99,43 +141,31 @@
 // Sets:
 // - fNumHiGainSamples to: (Float_t)(fHiGainLast-fHiGainFirst+1)
-// - fNumLoGainSamples to: (Float_t)(fLoGainLast-fLoGainFirst+1)
+// - fNumLoGainSamples to: 0.
 // - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
-// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)  
+// - fSqrtLoGainSamples to: 0.
 //  
 void MExtractPINDiode::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
 {
 
-  const Byte_t window = hilast-hifirst+1+lolast-lofirst+1;
-  const Byte_t weven  = window & ~1;
-
-  if (weven != window)
+  lofirst = 0;
+  lolast  = 0;
+
+  const Byte_t window = hilast-hifirst+1;
+
+  if (window<4) 
     {
       *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s%2i",": Total window size has to be even, set last slice from "
-                    ,(int)lolast," to ",(int)(lolast-1)) << endl;
-      lolast -= 1;
-    }
-  
-  if (window<2) 
-    {
-      *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s%2i",": Total window is smaller than 2 FADC sampes, set last slice from" 
-                    ,(int)lolast," to ",(int)(lofirst+1)) << endl;
-      hilast = hifirst+1;
-    }
-  
+            << Form("%s%2i%s%2i",": Total window is smaller than 4 FADC sampes, set last slice from" 
+                    ,(int)lolast," to ",(int)(lofirst+3)) << endl;
+      hilast = hifirst+3;
+    }
 
   MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
 
   fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1);
-  fNumLoGainSamples = (fLoGainLast == 0) ? 0. : (Float_t)(fLoGainLast-fLoGainFirst+1);  
+  fNumLoGainSamples = 0.;
 
   fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
-  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);  
-  
-  fNumSamples = (fLoGainLast == 0) 
-    ? fHiGainLast-fHiGainFirst+1 
-    : fHiGainLast-fHiGainFirst+1+fLoGainLast-fLoGainFirst+1;
-  fSqrtSamples = TMath::Sqrt((Float_t)fNumSamples);
+  fSqrtLoGainSamples = 0.;
   
 }
@@ -149,5 +179,12 @@
 // they were not found:
 //
+//  - MRawEvtData2
 //  - MExtractedPINDiode
+//
+// Initializes fPedMean to:
+// - fPedMean[0]: pedestal + AB-offset
+// - fPedMean[1]: pedestal - AB-offset
+//
+// Initializes TH1F fSlices to [fHiGainFirst-0.5,fHiGainLast+0.5]
 //
 Int_t MExtractPINDiode::PreProcess(MParList *pList)
@@ -157,23 +194,40 @@
     return kFALSE;
   
+  fRawEvt = NULL;
+  fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData2"));
+  if (!fRawEvt)
+    {
+      *fLog << err << AddSerialNumber("MRawEvtData2") << " not found... aborting." << endl;
+      return kFALSE;
+    }
+
   fPINDiode = (MExtractedSignalPINDiode*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalPINDiode"));
   if (!fPINDiode)
     return kFALSE;
 
+  fPedMean.Reset();
+
   const MPedestalPix &ped   = (*fPedestals)[fPINDiodeIdx]; 
 
-    if (&ped)
-      {
-        fPedestal = ped.GetPedestal();
-        fPedRms   = ped.GetPedestalRms();
-      }
-    else
-      {
-        *fLog << err << " Cannot find MPedestalPix of the PIN Diode (idx=" 
-              << fPINDiodeIdx << ")" << endl;
+  if (&ped)
+    {
+      fPedMean[0] = ped.GetPedestal() + ped.GetPedestalABoffset();
+      fPedMean[1] = ped.GetPedestal() - ped.GetPedestalABoffset();      
+    }
+  else
+    {
+      *fLog << err << " Cannot find MPedestalPix of the PIN Diode (idx=" 
+            << fPINDiodeIdx << ")" << endl;
         return kFALSE;
-      }
-
-    return kTRUE;
+    }
+  
+  if (fSlices)
+    delete fSlices;
+
+  fSlices = new TH1F("PINDiode","PIN Diode fitted slices",(Int_t)(fHiGainLast-fHiGainFirst+1),
+                     fHiGainFirst-0.5,fHiGainLast+0.5);
+  fSlices->SetDirectory(NULL);
+
+  return kTRUE;
 }
 
@@ -190,91 +244,137 @@
   
   fPINDiode->SetUsedFADCSlices(fHiGainFirst, fLoGainLast);
-  
+
+  *fLog << endl;
+  *fLog << inf << "Taking " << fNumHiGainSamples
+        << " HiGain samples from slice " << (Int_t)fHiGainFirst
+        << " to " << (Int_t)(fHiGainLast+fHiLoLast) << " incl" << endl;
+
   return kTRUE;
-  
-}
-
-
-
-void MExtractPINDiode::FindSignalandVarianceHiGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const
-{
-
-  Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
-
+}
+
+
+
+
+// ----------------------------------------------------------------------------------
+//
+// Extracts the (pedestal-subtracted) FADC slices between fHiGainFirst and fHiGainLast 
+// and fills them into the histogram fSlices. Memorizes the position of maximum at 
+// maxpos.
+//
+// Checks for saturation
+// 
+// Fits fSlices to a Gaussian in the ranges: maxpos-fLowerFitLimit, maxpos+fUpperFitLimit
+//
+// Writes fit results into MExtractedSignalPINDiode
+//
+Int_t MExtractPINDiode::Process()
+{
+
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  
+  fPINDiode->Clear();
+  fSlices->Reset();
+  
+  pixel.Jump(fPINDiodeIdx);
+  
+  Byte_t sat  = 0;
+
+  Int_t higainsamples = pixel.GetNumHiGainSamples();
+  Int_t logainsamples = pixel.GetNumLoGainSamples();
+  
+  const Bool_t higainabflag = pixel.HasABFlag();
+  Byte_t *ptr = pixel.GetHiGainSamples()+fHiGainFirst;
+  Byte_t *end = ptr+higainsamples;
+  
+  Int_t cnt=0;
+
+  Float_t max = 0.;
+  Int_t maxpos = 0;
+  
   while (ptr<end)
     {
-      sum  += *ptr;
-      sum2 += *ptr * *ptr;
-
-      if (*ptr++ >= fSaturationLimit)
-        sat++;
-    }
-}
-
-void MExtractPINDiode::FindSignalandVarianceLoGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const
-{
-
-  Byte_t *end = ptr +  fLoGainLast - fLoGainFirst  + 1;
-
-  while (ptr<end)
-    {
-      sum  += *ptr;
-      sum2 += *ptr * *ptr;
       
-      if (*ptr++ >= fSaturationLimit)
-        sat++;
-    }
-}
-
-
-
-// --------------------------------------------------------------------------
-//
-// Calculate the integral of the FADC time slices and store them as a new
-// pixel in the MExtractedPINDiode container.
-//
-Int_t MExtractPINDiode::Process()
-{
-
-
-  MRawEvtPixelIter pixel(fRawEvt);
-  
-  fPINDiode->Clear();
-  
-  pixel.Jump(fPINDiodeIdx);
-  
-  Int_t sum   = 0;
-  Int_t sum2  = 0;
-  Byte_t sat  = 0;
-  Int_t max   = 0;
-  
-  // 
-  // Calculate first the time:
-  //
-  const Int_t maxhi = pixel.GetIdxMaxHiGainSample();
-  const Int_t maxlo = pixel.GetIdxMaxLoGainSample();
-  
-  if (maxhi > maxlo)
-    max = maxhi;
-  else
-    max = maxlo + pixel.GetNumHiGainSamples();
-  
-  FindSignalandVarianceHiGain(pixel.GetHiGainSamples()+fHiGainFirst,sum,sum2,sat);
-  if (pixel.HasLoGain())
-    FindSignalandVarianceLoGain(pixel.GetLoGainSamples()+fLoGainFirst,sum,sum2,sat);
-
-  const Float_t var = ((Float_t)sum2 - (Float_t)sum*sum/fNumSamples)/(fNumSamples-1);
-  const Float_t rms = TMath::Sqrt(var);
-  
-  // 
-  // FIXME: The following formulae have to be revised!!
-  //
-  fPINDiode->SetExtractedSignal(sum - fPedestal*fNumSamples, fPedRms*fSqrtSamples);
-  fPINDiode->SetExtractedRms   (rms, rms/2./fSqrtSamples);
-  fPINDiode->SetExtractedTime  (max, rms/fSqrtSamples);
-  fPINDiode->SetSaturation(sat);
+      if (*ptr >= fSaturationLimit)
+        {
+          sat++;
+          break;
+        }
+
+      const Float_t cont = (Float_t)*ptr - fPedMean[(cnt + higainabflag) & 0x1];
+      fSlices->Fill(cnt,cont);
+
+      if (cont > max)
+      {
+        max = cont;
+        maxpos = cnt;
+      }
+
+      ptr++;
+      cnt++;
+    }
+  
+  cnt = 0;
+  
+  if (pixel.HasLoGain() && !sat)
+    {
+      
+      ptr = pixel.GetLoGainSamples();
+      end = ptr+logainsamples;
+      
+      const Bool_t logainabflag = (higainabflag + pixel.GetNumHiGainSamples()) & 0x1;
+      
+      while (ptr<end)
+        {
+          
+          if (*ptr >= fSaturationLimit)
+            {
+              sat++;
+              break;
+            }
+
+          const Float_t cont = (Float_t)*ptr - fPedMean[(cnt + logainabflag) & 0x1];
+          
+          fSlices->Fill(cnt+ higainsamples,cont);
+          
+          if (cont > max) 
+            {
+              max    = cont;
+              maxpos = cnt+higainsamples;
+            }
+          ptr++;
+          cnt++;
+        }
+    }
+          
+  if (sat)
+    {
+      fPINDiode->SetSaturation(1);
+      return kTRUE;
+    }
+
+  fSlices->Fit("gaus", "RQ", "", maxpos-fLowerFitLimit,maxpos+fUpperFitLimit);
+  
+  TF1 *gausfunc = fSlices->GetFunction("gaus");
+
+  fPINDiode->SetExtractedSignal(gausfunc->GetParameter(0), gausfunc->GetParError(0));
+  fPINDiode->SetExtractedTime  (gausfunc->GetParameter(1), gausfunc->GetParError(1));
+  fPINDiode->SetExtractedSigma (gausfunc->GetParameter(2), gausfunc->GetParError(2));
+  fPINDiode->SetExtractedChi2  (gausfunc->GetChisquare());
   fPINDiode->SetReadyToSave();
-  
+
   return kTRUE;
 }
 
+// ----------------------------------------------------------------------------------
+//
+// deletes fSlices and sets pointer to NULL
+//
+Int_t MExtractPINDiode::PostProcess()
+{
+  
+  delete fSlices;
+  fSlices = NULL;
+  
+  return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/msignal/MExtractPINDiode.h
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractPINDiode.h	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractPINDiode.h	(revision 7043)
@@ -15,5 +15,11 @@
 #endif
 
+#ifndef MARS_MArrayF
+#include "MArrayF.h"
+#endif
+
+class TH1F;
 class MExtractedSignalPINDiode;
+
 class MExtractPINDiode : public MExtractor
 {
@@ -21,33 +27,39 @@
 
   static const UInt_t fgPINDiodeIdx;  
-  static const Byte_t fgHiGainFirst;     // First FADC slice Hi-Gain (currently set to: 3) 
-  static const Byte_t fgHiGainLast;      // Last FADC slice Hi-Gain (currently set to: 14) 
-  static const Byte_t fgLoGainFirst;     // First FADC slice Lo-Gain (currently set to: 3) 
-  static const Byte_t fgLoGainLast;      // Last FADC slice Lo-Gain (currently set to: 14) 
+  static const Byte_t fgHiGainFirst;     // First FADC slice Hi-Gain (now set to: 3) 
+  static const Byte_t fgHiGainLast;      // Last  FADC slice Hi-Gain (now set to: 14) 
+  static const Byte_t fgLoGainFirst;     // First FADC slice Lo-Gain (now set to: 3) 
+  static const Byte_t fgLoGainLast;      // Last  FADC slice Lo-Gain (now set to: 14) 
 
-  MExtractedSignalPINDiode  *fPINDiode;     // Extracted signal of the PIN Diode
+  static const Byte_t fgLowerFitLimit;   // Default for fLowerFitLimit (now set to: 2)
+  static const Byte_t fgUpperFitLimit;   // Default for fUpperFitLimit (now set to: 5)
 
-  UInt_t  fPINDiodeIdx;
-  Float_t fPedestal;
-  Float_t fPedRms;
-  Int_t   fNumSamples;
-  Float_t fSqrtSamples;
+  Byte_t fLowerFitLimit;                 // Number of FADC slices before maximum to start fit
+  Byte_t fUpperFitLimit;                 // Number of FADC slices after maximum to end fit
   
-  void   FindSignalandVarianceHiGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const;
-  void   FindSignalandVarianceLoGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const;
-
-  Int_t  PreProcess(MParList *pList);
-  Bool_t ReInit(MParList *pList);  
-  Int_t  Process();
+  MExtractedSignalPINDiode  *fPINDiode;  // Extracted signal of the PIN Diode
+  TH1F                      *fSlices;    // Histogram to fit the slices
+  
+  UInt_t  fPINDiodeIdx;                  // PIN Diode pixel ID
+  
+  MArrayF fPedMean;                      // The used pedestals (0: ped+AB, 1: ped-AB)
+  
+  Int_t  PreProcess( MParList *pList );
+  Bool_t ReInit    ( MParList *pList );  
+  Int_t  Process    ();
+  Int_t  PostProcess();
   
 public:
 
   MExtractPINDiode(const char *name=NULL, const char *title=NULL);
+  ~MExtractPINDiode();  
 
   // Setters
   void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
-  void SetPINDiodeIdx(    const UInt_t idx=fgPINDiodeIdx    ) { fPINDiodeIdx     = idx; }   
+  void SetPINDiodeIdx  ( const UInt_t idx=fgPINDiodeIdx    ) { fPINDiodeIdx   = idx; }
+  void SetLowerFitLimit( const Byte_t lim=fgLowerFitLimit  ) { fLowerFitLimit = lim; }
+  void SetUpperFitLimit( const Byte_t lim=fgUpperFitLimit  ) { fUpperFitLimit = lim; }     
 
-  ClassDef(MExtractPINDiode, 0) // Signal Extractor for the PIN Diode
+  ClassDef(MExtractPINDiode, 1) // Signal Extractor for the PIN Diode
 };
 
Index: /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc	(revision 7043)
@@ -78,7 +78,7 @@
 const Int_t  MExtractTimeAndChargeDigitalFilter::fgSignalStartBinHiGain    =  4;
 const Int_t  MExtractTimeAndChargeDigitalFilter::fgSignalStartBinLoGain    =  4;
-const TString MExtractTimeAndChargeDigitalFilter::fgNameWeightsFile        = "msignal/cosmics_weights46.dat";
+const TString MExtractTimeAndChargeDigitalFilter::fgNameWeightsFile        = "msignal/cosmics_weights.dat";
 const Float_t MExtractTimeAndChargeDigitalFilter::fgOffsetLoGain           =  1.7; // 5 ns
-const Float_t MExtractTimeAndChargeDigitalFilter::fgLoGainStartShift       = -2.8;
+const Float_t MExtractTimeAndChargeDigitalFilter::fgLoGainStartShift       = -1.8;
 
 // --------------------------------------------------------------------------
@@ -753,4 +753,30 @@
 
     CalcBinningResArrays();
+
+    switch (fWindowSizeHiGain)
+      {
+      case 4:
+	SetResolutionPerPheHiGain(0.036);
+	break;
+      case 6:
+	SetResolutionPerPheHiGain(0.021);
+	break;
+      default:
+	*fLog << warn << "Could not set the high-gain extractor resolution per phe for window size " 
+	      << fWindowSizeHiGain << endl;
+      }
+
+    switch (fWindowSizeLoGain)
+      {
+      case 4:
+	SetResolutionPerPheLoGain(0.005);
+	break;
+      case 6:
+	SetResolutionPerPheLoGain(0.004);
+	break;
+      default:
+	*fLog << warn << "Could not set the low-gain extractor resolution per phe for window size " 
+	      << fWindowSizeLoGain << endl;
+      }
 
     fWeightsSet = kTRUE;
Index: /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSlidingWindow.cc
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSlidingWindow.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSlidingWindow.cc	(revision 7043)
@@ -76,4 +76,5 @@
 const Byte_t  MExtractTimeAndChargeSlidingWindow::fgHiGainWindowSize = 6;
 const Byte_t  MExtractTimeAndChargeSlidingWindow::fgLoGainWindowSize = 6;
+
 // --------------------------------------------------------------------------
 //
@@ -176,4 +177,43 @@
   fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
 
+  switch (fWindowSizeHiGain)
+    {
+    case 2:
+      SetResolutionPerPheHiGain(0.050);
+      break;
+    case 4:
+      SetResolutionPerPheHiGain(0.039);
+      break;
+    case 6:
+    case 8:
+      SetResolutionPerPheHiGain(0.011);
+      break;
+    case 14:
+      SetResolutionPerPheHiGain(0.009);
+      break;
+    default:
+      *fLog << warn << GetDescriptor() << ": Could not set the high-gain extractor resolution per phe for window size " 
+            << fWindowSizeHiGain << endl;
+    }
+  
+  switch (fWindowSizeLoGain)
+    {
+    case 2:
+      SetResolutionPerPheLoGain(0.028);
+      break;
+    case 4:
+      SetResolutionPerPheLoGain(0.013);
+      break;
+    case 6:
+      SetResolutionPerPheLoGain(0.008);
+      break;
+    case 8:
+    case 10:
+      SetResolutionPerPheLoGain(0.005);
+      break;
+    default:
+      *fLog << warn << GetDescriptor() << ": Could not set the low-gain extractor resolution per phe for window size " 
+            << fWindowSizeLoGain << endl;
+    }
 }
 
Index: /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSlidingWindow.h
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSlidingWindow.h	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSlidingWindow.h	(revision 7043)
@@ -11,9 +11,8 @@
 
 class MPedestalPix;
+
 class MExtractTimeAndChargeSlidingWindow : public MExtractTimeAndCharge
 {
-
 private:
-  
   static const Byte_t fgHiGainFirst;      //! Default for fHiGainFirst  (now set to: 2)
   static const Byte_t fgHiGainLast;       //! Default for fHiGainLast   (now set to: 14)
@@ -49,5 +48,5 @@
                                Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag);
 
-  ClassDef(MExtractTimeAndChargeSlidingWindow, 0)   // Task to Extract Times and Charges using a Sliding Window
+  ClassDef(MExtractTimeAndChargeSlidingWindow, 1)   // Task to Extract Times and Charges using a Sliding Window
 };
 
Index: /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc	(revision 7043)
@@ -233,4 +233,7 @@
       fWindowSizeLoGain  = 1;
       fRiseTimeHiGain    = 0.5;
+
+      SetResolutionPerPheHiGain(0.053);
+      SetResolutionPerPheLoGain(0.016);
       
       return;
@@ -242,12 +245,58 @@
       fNumHiGainSamples  = fRiseTimeHiGain + fFallTimeHiGain;
       fNumLoGainSamples  = fLoGainLast ? fRiseTimeLoGain + fFallTimeLoGain : 0.;
-      //      fNumLoGainSamples  *= 0.75;      
 
       fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
       fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
-      fWindowSizeHiGain  = (Int_t)(fRiseTimeHiGain + fFallTimeHiGain);
-      fWindowSizeLoGain  = (Int_t)((fRiseTimeLoGain + fFallTimeLoGain)*fLoGainStretch);
-      //      fNumLoGainSamples  *= 0.75;      
-    }
+      fWindowSizeHiGain  = TMath::Nint(fRiseTimeHiGain + fFallTimeHiGain);
+      // to ensure that for the case: 1.5, the window size becomes: 2 (at any compiler)
+      fWindowSizeLoGain  = TMath::Nint(TMath::Ceil((fRiseTimeLoGain + fFallTimeLoGain)*fLoGainStretch));
+    }
+
+    switch (fWindowSizeHiGain)
+    {
+    case 1:
+      SetResolutionPerPheHiGain(0.041);
+      break;
+    case 2:
+      SetResolutionPerPheHiGain(0.064);
+      break;
+    case 3:
+    case 4:
+      SetResolutionPerPheHiGain(0.050);
+      break;
+    case 5:
+    case 6:
+      SetResolutionPerPheHiGain(0.030);
+      break;
+    default:
+	*fLog << warn << GetDescriptor() << ": Could not set the high-gain extractor resolution per phe for window size " 
+	      << fWindowSizeHiGain << endl;
+	break;
+    }
+
+    switch (fWindowSizeLoGain)
+    {
+    case 1:
+    case 2:
+      SetResolutionPerPheLoGain(0.005);
+      break;
+    case 3:
+    case 4:
+      SetResolutionPerPheLoGain(0.017);
+      break;
+    case 5:
+    case 6:
+    case 7:
+      SetResolutionPerPheLoGain(0.005);
+      break;
+    case 8:
+    case 9:
+      SetResolutionPerPheLoGain(0.005);
+      break;
+    default:
+	*fLog << warn << "Could not set the low-gain extractor resolution per phe for window size " 
+	      << fWindowSizeLoGain << endl;
+	break;
+     }
 }
 
Index: /trunk/MagicSoft/Mars/msignal/MExtractedSignalPINDiode.cc
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractedSignalPINDiode.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractedSignalPINDiode.cc	(revision 7043)
@@ -39,7 +39,4 @@
 
 using namespace std;
-
-static const Float_t gkSignalInitializer = 99999.9;
-
 // ------------------------------------------------------------------------
 //
@@ -49,5 +46,5 @@
 // Additionally, the number of saturated Slices are stored. 
 // 
-// Default values for the extracted signals are: 99999.9 
+// Default values for the extracted signals are: -1. 
 //
 MExtractedSignalPINDiode::MExtractedSignalPINDiode(const char* name, const char* title)
@@ -62,16 +59,19 @@
 // ------------------------------------------------------------------------
 //
-// Invalidate values
+// Invalidate values to -1.
 //
 void MExtractedSignalPINDiode::Clear(Option_t *o)
 {
-  fExtractedSignal          = gkSignalInitializer;
-  fExtractedSignalErr       = gkSignalInitializer;
-  fExtractedTime            = gkSignalInitializer;
-  fExtractedTimeErr         = gkSignalInitializer; 
-  fExtractedRms             = gkSignalInitializer; 
-  fExtractedRmsErr          = gkSignalInitializer; 
 
-  fNumSaturated       = 0;
+  fExtractedSignal          = -1.;
+  fExtractedSignalErr       = -1.;
+  fExtractedTime            = -1.;
+  fExtractedTimeErr         = -1.; 
+  fExtractedSigma           = -1.; 
+  fExtractedSigmaErr        = -1.; 
+  fExtractedChi2            = -1.; 
+
+  fSaturated  = kFALSE;
+  
 }
 
@@ -85,36 +85,35 @@
 void MExtractedSignalPINDiode::SetExtractedSignal(const Float_t sig, const Float_t sigerr)   
 {
-  fExtractedSignal      = sig; 
+  fExtractedSignal    = sig; 
   fExtractedSignalErr = sigerr;
 }
 
-void MExtractedSignalPINDiode::SetExtractedRms(const Float_t sig, const Float_t sigerr)   
+void MExtractedSignalPINDiode::SetExtractedSigma(const Float_t sig, const Float_t sigerr)   
 {
-  fExtractedRms      = sig; 
-  fExtractedRmsErr = sigerr;
+  fExtractedSigma    = sig; 
+  fExtractedSigmaErr = sigerr;
 }
 
 void MExtractedSignalPINDiode::SetExtractedTime(const Float_t sig, const Float_t sigerr)   
 {
-  fExtractedTime      = sig; 
+  fExtractedTime    = sig; 
   fExtractedTimeErr = sigerr;
 }
 
-
 Bool_t MExtractedSignalPINDiode::IsValid() const
 {
-    return fExtractedSignal >= 0. || fExtractedSignalErr >= 0.;
-}
-
-void MExtractedSignalPINDiode::SetSaturation(const Byte_t numsat)
-{
-  fNumSaturated = numsat; 
+  if (fSaturated)
+    return kFALSE;
+  
+  return fExtractedSignal >= 0. || fExtractedSignalErr >= 0.;
 }
 
 void MExtractedSignalPINDiode::Print(Option_t *o) const
 {
-  *fLog << " Signal: " << fExtractedSignal
-        << " +- " << fExtractedSignalErr
-        << " Nr. Saturation: " <<  fNumSaturated
+  *fLog << Form(" Signal: %4.2f+-%4.2f",fExtractedSignal,fExtractedSignalErr) 
+        << Form(" Arr.Time: %4.2f+-%4.2f",fExtractedTime,fExtractedTimeErr) 
+        << Form(" Sigma: %4.2f+-%4.2f",fExtractedSigma,fExtractedSigmaErr) 
+        << Form(" Chi2: %5.2f",fExtractedChi2) 
+        << Form(" Saturation: %s",fSaturated ? "yes" : "no")
         << endl;
 }
Index: /trunk/MagicSoft/Mars/msignal/MExtractedSignalPINDiode.h
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractedSignalPINDiode.h	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractedSignalPINDiode.h	(revision 7043)
@@ -10,42 +10,47 @@
 private:
 
-  Float_t fExtractedSignal;    // mean value of the extracted signal
-  Float_t fExtractedSignalErr; // error of the mean value of the extracted signal
-  Float_t fExtractedTime; 
-  Float_t fExtractedTimeErr; 
-  Float_t fExtractedRms; 
-  Float_t fExtractedRmsErr; 
-
-  Byte_t fFirst;
-  Byte_t fNumFADCSamples;
-  Byte_t fNumSaturated;
+  Float_t fExtractedSignal;    // Extracted signal amplitude
+  Float_t fExtractedSignalErr; // Error extracted signal amplitude
+  Float_t fExtractedTime;      // Position of signal amplitude
+  Float_t fExtractedTimeErr;   // Error position of signal amplitude
+  Float_t fExtractedSigma;     // Width Gauss fit 
+  Float_t fExtractedSigmaErr;  // Error of width
+  Float_t fExtractedChi2;      // Chi2 Gauss fit   
+ 
+  Byte_t fNumFADCSamples;      // Number of used FADC slices
+  Byte_t fFirst;               // First FADC slice to start extraction
+  
+  Bool_t fSaturated;           // FADC saturation occurrance flag
 
 public:
-    MExtractedSignalPINDiode(const char* name=NULL, const char* title=NULL);
 
-    void Clear(Option_t *o="");
-    void Print(Option_t *o="") const;
+  MExtractedSignalPINDiode(const char* name=NULL, const char* title=NULL);
+  
+  void Clear(Option_t *o="");
+  
+  // Getter
+  Float_t GetExtractedSignal()    const { return fExtractedSignal;       }
+  Float_t GetExtractedSignalErr() const { return fExtractedSignalErr;    }
+  Float_t GetExtractedTime()      const { return fExtractedTime;         }
+  Float_t GetExtractedTimeErr()   const { return fExtractedTimeErr;      }
+  Float_t GetExtractedSigma()     const { return fExtractedSigma;        }
+  Float_t GetExtractedSigmaErr()  const { return fExtractedSigmaErr;     }
+  Float_t GetExtractedChi2()      const { return fExtractedChi2;         }  
+  Byte_t  GetNumFADCSamples()     const { return fNumFADCSamples;        }
+  
+  Bool_t  IsValid()    const;   
+  
+  // Print
+  void Print(Option_t *o="") const;
 
-    // Setter
-    void SetExtractedSignal(const Float_t sig, const Float_t sigerr);
-    void SetExtractedRms(  const Float_t sig, const Float_t sigerr);
-    void SetExtractedTime(  const Float_t sig, const Float_t sigerr);
-    void SetSaturation(   const Byte_t numsat);
-    void SetUsedFADCSlices( const Byte_t first, const Byte_t num);
-    
-    // Getter
-    Float_t GetExtractedSignal()    const { return fExtractedSignal;       }
-    Float_t GetExtractedSignalErr() const { return fExtractedSignalErr;    }
-    Float_t GetExtractedTime()      const { return fExtractedTime;         }
-    Float_t GetExtractedTimeErr()   const { return fExtractedTimeErr;      }
-    Float_t GetExtractedRms()       const { return fExtractedRms;          }
-    Float_t GetExtractedRmsErr()    const { return fExtractedRmsErr;       }
-    Byte_t  GetNumFADCSamples()     const { return fNumFADCSamples;        }
-    Byte_t  GetFirstUsedSlice()     const { return fFirst;                 }
-    Byte_t  GetLastUsedSlice()      const { return fFirst+fNumFADCSamples; }    
-    
-    Bool_t IsValid() const;   
+  // Setter
+  void SetExtractedSignal(const Float_t sig, const Float_t sigerr);
+  void SetExtractedSigma(  const Float_t sig, const Float_t sigerr);
+  void SetExtractedTime(  const Float_t sig, const Float_t sigerr);
+  void SetExtractedChi2(  const Float_t chi ) { fExtractedChi2 = chi; }
+  void SetSaturation  (   const Bool_t b=kTRUE) { fSaturated = b;  }
+  void SetUsedFADCSlices( const Byte_t first, const Byte_t num);
 
-    ClassDef(MExtractedSignalPINDiode, 1)	// Storage Container for Extracted Signal information of one pixel
+  ClassDef(MExtractedSignalPINDiode, 2)	// Storage Container for Extracted Signal information of one pixel
 };
 
Index: /trunk/MagicSoft/Mars/msignal/MExtractor.cc
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 7043)
@@ -64,4 +64,9 @@
 //End_Html
 //
+// Class Version 6:
+//  +Float_t fResolutionPerPheHiGain; // Extractor-dependent charge resolution per phe for high-gain (see TDAS-0502).
+//  +Float_t fResolutionPerPheLoGain; // Extractor-dependent charge resolution per phe for low-gain  (see TDAS-0502).
+//
+//
 // Input Containers:
 //   MRawEvtData
@@ -100,4 +105,5 @@
 const TString MExtractor::fgNameSignalCam   = "MExtractedSignalCam";
 const Float_t MExtractor::fgOffsetLoGain    = 1.51;   // 5 ns
+
 // --------------------------------------------------------------------------
 //
@@ -116,6 +122,7 @@
 //
 MExtractor::MExtractor(const char *name, const char *title)
-    : fPedestals(NULL), fSignals(NULL), fRawEvt(NULL), fRunHeader(NULL),
-      fHiLoLast(0), fNumHiGainSamples(0.), fNumLoGainSamples(0.)
+    : fResolutionPerPheHiGain(0), fResolutionPerPheLoGain(0),
+      fPedestals(NULL), fSignals(NULL), fRawEvt(NULL), fRunHeader(NULL),
+      fHiLoLast(0), fNumHiGainSamples(0), fNumLoGainSamples(0)
 {
     fName  = name  ? name  : "MExtractor";
Index: /trunk/MagicSoft/Mars/msignal/MExtractor.h
===================================================================
--- /trunk/MagicSoft/Mars/msignal/MExtractor.h	(revision 7042)
+++ /trunk/MagicSoft/Mars/msignal/MExtractor.h	(revision 7043)
@@ -23,11 +23,12 @@
 {
 private:
-
   static const Float_t fgOffsetLoGain;     //! Default for fOffsetLoGain (now set to 1.51 (= 5ns)
   
   Bool_t  fNoiseCalculation;               //! Flag if extractor determines noise contribution from pedestal file.
+
+  Float_t fResolutionPerPheHiGain;         // Extractor-dependent charge resolution per phe for high-gain (see TDAS-0502).
+  Float_t fResolutionPerPheLoGain;         // Extractor-dependent charge resolution per phe for low-gain  (see TDAS-0502).
   
 protected:
-
   static const Byte_t  fgSaturationLimit;  //! Default for fSaturationLimit (now set to: 254)
   static const TString fgNamePedestalCam;  //! "MPedestalCam"
@@ -54,13 +55,20 @@
   Float_t  fSqrtHiGainSamples;             // Sqrt. nr. High Gain FADC slices used to extract the signal
   Float_t  fSqrtLoGainSamples;             // Sqrt. nr. Low  Gain FADC slices used to extract the signal
-                                           
+
   Byte_t   fSaturationLimit;               // Highest FADC slice value until being declared saturated
+
   TString  fNamePedestalCam;               // Name of the 'MPedestalCam' container
   TString  fNameSignalCam;                 // Name of the 'MExtractedSignalCam' container
 
+  // MExtractor
   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 { }
-  
+
+  void SetResolutionPerPheHiGain(Float_t f) { fResolutionPerPheHiGain=f; }
+  void SetResolutionPerPheLoGain(Float_t f) { fResolutionPerPheLoGain=f; }
+
   Int_t   PreProcessStd(MParList *pList);
+
+  // MTask
   Int_t   PreProcess( MParList *pList );
   Bool_t  ReInit    ( MParList *pList );
@@ -69,12 +77,9 @@
   Int_t   ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
+
 public:
   MExtractor(const char *name=NULL, const char *title=NULL);
   
-  void Clear(Option_t *o="") 
-    {
-      fHiGainFirst = fHiGainLast = fLoGainFirst = fLoGainLast = fHiLoLast = 0;
-    }
-
+  // getter
   Byte_t  GetHiGainFirst()      const { return fHiGainFirst;      }
   Byte_t  GetHiGainLast ()      const { return fHiGainLast ;      }
@@ -86,5 +91,9 @@
 
   Bool_t  IsNoiseCalculation () const { return fNoiseCalculation; }
-  
+
+  // Setter
+  Float_t SetResolutionPerPheHiGain() const { return fResolutionPerPheHiGain; }
+  Float_t SetResolutionPerPheLoGain() const { return fResolutionPerPheLoGain; }
+
   virtual void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
 
@@ -97,7 +106,13 @@
   void SetPedestals (MPedestalCam *pedcam)   { fPedestals = pedcam; }
 
+  // TObject
+  void Clear(Option_t *o="") 
+    {
+      fHiGainFirst = fHiGainLast = fLoGainFirst = fLoGainLast = fHiLoLast = 0;
+    }
+
   void Print(Option_t *o="") const;
 
-  ClassDef(MExtractor, 5) // Signal Extractor Base Class
+  ClassDef(MExtractor, 6) // Signal Extractor Base Class
 };
 
