Index: trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc	(revision 3674)
+++ trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc	(revision 3675)
@@ -50,5 +50,5 @@
 //       Accordingly, a flag IsGausFitOK() is set.
 //     - One can repeat the fit within a given amount of sigmas from the previous mean 
-//       (specified by the variable fPickupLimit) with the function RepeatFit()
+//       (specified by the variables fPickupLimit and fBlackoutLimit) with the function RepeatFit()
 //     - One can completely skip the fitting to set mean, sigma and its errors directly 
 //       from the histograms with the function BypassFit()
@@ -99,9 +99,10 @@
 using namespace std;
 
-const Float_t  MHGausEvents::fgProbLimit            = 0.001;
+const Int_t    MHGausEvents::fgBinsAfterStripping   = 40;
+const Float_t  MHGausEvents::fgBlackoutLimit        = 5.;
 const Int_t    MHGausEvents::fgNDFLimit             = 2;
 const Float_t  MHGausEvents::fgPickupLimit          = 5.;
+const Float_t  MHGausEvents::fgProbLimit            = 0.001;
 const Int_t    MHGausEvents::fgPowerProbabilityBins = 20;
-const Int_t    MHGausEvents::fgBinsAfterStripping   = 40;
 // --------------------------------------------------------------------------
 //
@@ -110,10 +111,11 @@
 // - the default Probability Bins for fPowerProbabilityBins (fgPowerProbabilityBins)
 // - the default Probability Limit for fProbLimit  (fgProbLimit)
-// - the default NDF Limit for fNDFLimit  (fgNDFLimit)
-// - the default number for fPickupLimit  (fgPickupLimit)
+// - the default NDF Limit for fNDFLimit           (fgNDFLimit)
+// - the default number for fPickupLimit           (fgPickupLimit)
+// - the default number for fBlackoutLimit         (fgBlackoutLimit)
 // - the default number of bins after stripping for fBinsAfterStipping (fgBinsAfterStipping)
-// - the default name of the fHGausHist   ("HGausHist")
-// - the default title of the fHGausHist  ("Histogram of Events with Gaussian Distribution")
-// - the default directory of the fHGausHist (NULL)
+// - the default name of the fHGausHist            ("HGausHist")
+// - the default title of the fHGausHist           ("Histogram of Events with Gaussian Distribution")
+// - the default directory of the fHGausHist       (NULL)
 // - the default for fNbins (100)
 // - the default for fFirst (0.)
@@ -141,9 +143,10 @@
   Clear();
   
+  SetBinsAfterStripping();
+  SetBlackoutLimit();
+  SetNDFLimit();
+  SetPickupLimit();
   SetPowerProbabilityBins();
   SetProbLimit();
-  SetNDFLimit();
-  SetPickupLimit();
-  SetBinsAfterStripping();
 
   fHGausHist.SetName("HGausHist");
@@ -614,6 +617,6 @@
 // Repeats the Gauss fit in a smaller range, defined by: 
 // 
-// min = GetMean() - fPickupLimit * GetSigma();
-// max = GetMean() + fPickupLimit * GetSigma();
+// min = GetMean() - fBlackoutLimit * GetSigma();
+// max = GetMean() + fPickupLimit   * GetSigma();
 //
 // The fit results are retrieved and stored in class-own variables.  
@@ -635,6 +638,6 @@
   // Get new fitting ranges
   //
-  Axis_t rmin = fMean - fPickupLimit * fSigma;
-  Axis_t rmax = fMean + fPickupLimit * fSigma;
+  Axis_t rmin = fMean - fBlackoutLimit * fSigma;
+  Axis_t rmax = fMean + fPickupLimit   * fSigma;
 
   Axis_t hmin = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetFirst());
@@ -937,3 +940,18 @@
 }
 
-
+const Double_t MHGausEvents::GetBlackout() const 
+{
+  
+  if ((fMean == 0.) && (fSigma == 0.))
+    return -1.;
+
+  const Int_t first = fHGausHist.GetXaxis()->GetFirst();
+  const Int_t last  = fHGausHist.GetXaxis()->FindBin(fMean-fBlackoutLimit*fSigma);
+
+  if (first >= last)
+    return 0.;
+  
+  return fHGausHist.Integral(first, last, "width");
+}
+
+
Index: trunk/MagicSoft/Mars/mcalib/MHGausEvents.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHGausEvents.h	(revision 3674)
+++ trunk/MagicSoft/Mars/mcalib/MHGausEvents.h	(revision 3675)
@@ -20,50 +20,43 @@
 private:
 
-  const static Float_t  fgProbLimit;            //! Default for fProbLimit (now set to: 0.001)
-  const static Int_t    fgNDFLimit;             //! Default for fNDFLimit  (now set to: 2)
-  const static Float_t  fgPickupLimit;          //! Default for fPickupLimit (now set to: 5. )
+  const static Int_t    fgBinsAfterStripping;   //! Default for fBinsAfterStripping   (now set to: 40)
+  const static Float_t  fgBlackoutLimit;        //! Default for fBlackoutLimit        (now set to: 5. )
+  const static Int_t    fgNDFLimit;             //! Default for fNDFLimit             (now set to: 2)
+  const static Float_t  fgProbLimit;            //! Default for fProbLimit            (now set to: 0.001)
+  const static Float_t  fgPickupLimit;          //! Default for fPickupLimit          (now set to: 5. )
   const static Int_t    fgPowerProbabilityBins; //! Default for fPowerProbabilityBins (now set to: 20)
-  const static Int_t    fgBinsAfterStripping;   //! Default for fBinsAfterStripping (now set to: 40)
   
+  Int_t    fBinsAfterStripping;        // Bins for the Gauss Histogram after stripping off the zeros at both ends
+  Int_t    fCurrentSize;               // Current size of the array fEvents
+  Float_t  fEventFrequency;            // Event frequency in Hertz (to be set)
+  Byte_t   fFlags;                     // Bit field for the fit result bits
   Int_t    fPowerProbabilityBins;      // Bins for the projected power spectrum
-  Int_t    fBinsAfterStripping;        // Bins for the Gauss Histogram after stripping off the zeros at both ends
-  Float_t  fEventFrequency;            // Event frequency in Hertz (to be set)
   
   TH1I    *fHPowerProbability;         // Fourier transform of fEvents projected on y-axis
   TArrayF *fPowerSpectrum;             // Fourier transform of fEvents
-
   TGraph  *fGraphEvents;               //! TGraph to display the event array (will not be cloned!!)
   TGraph  *fGraphPowerSpectrum;        //! TGraph to display the power spectrum array (will not be cloned!!)
 
-
-  enum { kGausFitOK, kExpFitOK, kFourierSpectrumOK,
-         kExcluded };                  //  Bits to hold information about fit results 
+  enum { kGausFitOK, kExpFitOK, kFourierSpectrumOK, kExcluded }; // Bits for information about fit results 
   
-  Byte_t fFlags;                       //  Byte to hold the bits fit result bits
-  
-  Int_t fCurrentSize;                  //  Current size of the array fEvents
-
 protected:
 
-  Double_t fMean;                      // Mean of the Gauss fit
-  Double_t fSigma;                     // Sigma of the Gauss fit
-  Double_t fMeanErr;                   // Error of the mean of the Gauss fit
-  Double_t fSigmaErr;                  // Error of the sigma of the Gauss fit
-  Double_t fProb;                      // Probability of the Gauss fit 
-
-  Int_t   fNbins;                      // Number histogram bins for fHGausHist (used by InitBins())
-  Axis_t  fFirst;                      // Lower histogram edge  for fHGausHist (used by InitBins()) 
-  Axis_t  fLast;                       // Upper histogram edge  for fHGausHist (used by InitBins()) 
-  Int_t   fPixId;                      // Pixel ID 
-  
-  TH1F    fHGausHist;                  // Histogram which should hold the Gaussian distribution
-  TArrayF fEvents;                     // Array which holds the entries of GausHist
-
+  Float_t  fBlackoutLimit;             // Lower number sigmas from mean until event is considered blackout
+  TArrayF  fEvents;                    // Array which holds the entries of GausHist
   TF1     *fFGausFit;                  // Gauss fit for fHGausHist
   TF1     *fFExpFit;                   // Exponential fit for FHPowerProbability
-  
+  Axis_t   fFirst;                     // Lower histogram edge  for fHGausHist (used by InitBins()) 
+  TH1F     fHGausHist;                 // Histogram to hold the Gaussian distribution
+  Axis_t   fLast;                      // Upper histogram edge  for fHGausHist (used by InitBins()) 
+  Double_t fMean;                      // Mean of the Gauss fit
+  Double_t fMeanErr;                   // Error of the mean of the Gauss fit
+  Int_t    fNbins;                     // Number histogram bins for fHGausHist (used by InitBins())
+  Int_t    fNDFLimit;                  // NDF limit for judgement if fit is OK
+  Double_t fSigma;                     // Sigma of the Gauss fit
+  Double_t fSigmaErr;                  // Error of the sigma of the Gauss fit
+  Float_t  fPickupLimit;               // Upper number sigmas from mean until event is considered pickup
+  Int_t    fPixId;                     // Pixel ID 
+  Double_t fProb;                      // Probability of the Gauss fit 
   Float_t  fProbLimit;                 // Probability limit for judgement if fit is OK 
-  Int_t    fNDFLimit;                  // NDF limit for judgement if fit is OK
-  Float_t  fPickupLimit;               // Upper number of sigmas from the mean until events are considered as pickup
 
   Float_t *CreateEventXaxis(Int_t n);  // Create an x-axis for the Event TGraphs
@@ -74,6 +67,6 @@
 
   // Setters
-  void  SetPowerProbabilityBins ( const Int_t nbins=fgPowerProbabilityBins ) { fPowerProbabilityBins = nbins;  }
-  void  SetBinsAfterStripping   ( const Int_t nbins=fgBinsAfterStripping   ) { fBinsAfterStripping   = nbins;  }
+  void  SetPowerProbabilityBins ( const Int_t nbins=fgPowerProbabilityBins ) { fPowerProbabilityBins=nbins; }
+  void  SetBinsAfterStripping   ( const Int_t nbins=fgBinsAfterStripping   ) { fBinsAfterStripping  =nbins; }
 
  public:
@@ -87,83 +80,71 @@
   
   // Setters
-  void  SetEventFrequency(const Float_t f)   { fEventFrequency = f; }
-
-  void  SetMean    ( const Double_t d )   { fMean     = d;   }
-  void  SetMeanErr ( const Double_t d )   { fMeanErr  = d;   }
-  void  SetSigma   ( const Double_t d )   { fSigma    = d;   }
-  void  SetSigmaErr( const Double_t d )   { fSigmaErr = d;   }
-  void  SetProb    ( const Double_t d )   { fProb     = d;   }
-  void  SetPixId   ( const Int_t i    )   { fPixId    = i;   }
-
-  void  SetNbins   ( const Int_t i    )   { fNbins    = i;   }  
-  void  SetFirst   ( const Double_t d )   { fFirst    = d;   }
-  void  SetLast    ( const Double_t d )   { fLast     = d;   }
-  
-  void  SetNDFLimit    ( const Int_t   lim=fgNDFLimit    ) { fNDFLimit    = lim; }  
-  void  SetPickupLimit ( const Float_t lim=fgPickupLimit ) { fPickupLimit = lim; }
-  void  SetProbLimit   ( const Float_t lim=fgProbLimit   ) { fProbLimit   = lim; }
-
-  // Setters ONLY for MC:
-  void  SetGausFitOK(         const Bool_t b=kTRUE );
-  void  SetExpFitOK(          const Bool_t b=kTRUE );
-  void  SetFourierSpectrumOK( const Bool_t b=kTRUE );
-  void  SetExcluded         ( const Bool_t b=kTRUE );  
+  void  SetBlackoutLimit    ( const Float_t  lim=fgBlackoutLimit ) { fBlackoutLimit  = lim; }
+  void  SetEventFrequency   ( const Float_t  f                   ) { fEventFrequency = f;   }
+  void  SetExcluded         ( const Bool_t   b=kTRUE             );  
+  void  SetExpFitOK         ( const Bool_t   b=kTRUE             );
+  void  SetFourierSpectrumOK( const Bool_t   b=kTRUE             );
+  void  SetGausFitOK        ( const Bool_t   b=kTRUE             );
+  void  SetLast             ( const Double_t d                   ) { fLast           = d;   }
+  void  SetFirst            ( const Double_t d                   ) { fFirst          = d;   }
+  void  SetMean             ( const Double_t d                   ) { fMean           = d;   }
+  void  SetMeanErr          ( const Double_t d                   ) { fMeanErr        = d;   }
+  void  SetNbins            ( const Int_t    i                   ) { fNbins          = i;   }  
+  void  SetNDFLimit         ( const Int_t    lim=fgNDFLimit      ) { fNDFLimit       = lim; }  
+  void  SetPickupLimit      ( const Float_t  lim=fgPickupLimit   ) { fPickupLimit    = lim; }
+  void  SetPixId            ( const Int_t    i                   ) { fPixId          = i;   }
+  void  SetProb             ( const Double_t d                   ) { fProb           = d;   }
+  void  SetProbLimit        ( const Float_t  lim=fgProbLimit     ) { fProbLimit      = lim; }
+  void  SetSigma            ( const Double_t d                   ) { fSigma          = d;   }
+  void  SetSigmaErr         ( const Double_t d                   ) { fSigmaErr       = d;   }
 
   // Getters
-  const Double_t GetMean()          const { return fMean;      }
-  const Double_t GetMeanErr()       const { return fMeanErr;   }
-  const Double_t GetSigma()         const { return fSigma;     }
-  const Double_t GetSigmaErr()      const { return fSigmaErr;  }
-  const Double_t GetChiSquare()     const;
-  const Double_t GetProb()          const { return fProb;      }
-  const Int_t    GetNdf()           const;
-  const Double_t GetPickup()        const;
-  const Int_t    GetPixId()         const { return fPixId;     }
+  const Double_t GetBlackout()           const;  
+  const Double_t GetChiSquare()          const;
+  const Double_t GetExpChiSquare()       const;
+  const Int_t    GetExpNdf()             const;
+  const Double_t GetExpProb()            const;
+        TArrayF *GetEvents()                   { return &fEvents;            }  
+  const TArrayF *GetEvents()             const { return &fEvents;            }
+        TF1     *GetFExpFit()                  { return fFExpFit;            }
+  const TF1     *GetFExpFit()            const { return fFExpFit;            } 
+        TF1     *GetFGausFit()                 { return fFGausFit;           }
+  const TF1     *GetFGausFit()           const { return fFGausFit;           } 
+        TGraph  *GetGraphEvents()              { return fGraphEvents;        }
+  const TGraph  *GetGraphEvents()        const { return fGraphEvents;        }
+        TGraph  *GetGraphPowerSpectrum()       { return fGraphPowerSpectrum; }
+  const TGraph  *GetGraphPowerSpectrum() const { return fGraphPowerSpectrum; }
+        TH1F    *GetHGausHist()                { return &fHGausHist;         }
+  const TH1F    *GetHGausHist()          const { return &fHGausHist;         } 
+        TH1I    *GetHPowerProbability()        { return fHPowerProbability;  }
+  const TH1I    *GetHPowerProbability()  const { return fHPowerProbability;  } 
+  const Double_t GetMean()               const { return fMean;               }
+  const Double_t GetMeanErr()            const { return fMeanErr;            }
+  const Int_t    GetNdf()                const;
+  const Double_t GetOffset()             const;
+  const Double_t GetPickup()             const;
+  const Int_t    GetPixId()              const { return fPixId;              }
+        TArrayF *GetPowerSpectrum()            { return fPowerSpectrum;      }  
+  const TArrayF *GetPowerSpectrum()      const { return fPowerSpectrum;      }
+  const Double_t GetProb()               const { return fProb;               }
+  const Double_t GetSigma()              const { return fSigma;              }
+  const Double_t GetSigmaErr()           const { return fSigmaErr;           }
+  const Double_t GetSlope()              const;
 
-  const Double_t GetSlope()        const;
-  const Double_t GetOffset()       const;
-  const Double_t GetExpChiSquare() const;
-  const Double_t GetExpProb()      const;
-  const Int_t    GetExpNdf()       const;
-
-  TH1F *GetHGausHist()                     { return &fHGausHist;     }
-  const TH1F *GetHGausHist()         const { return &fHGausHist;     } 
-
-  TArrayF *GetEvents()                     { return &fEvents;        }  
-  const TArrayF *GetEvents()         const { return &fEvents;        }
-  
-  TArrayF *GetPowerSpectrum()              { return fPowerSpectrum;  }  
-  const TArrayF *GetPowerSpectrum()  const { return fPowerSpectrum;  }
-  
-  TF1 *GetFGausFit()                       { return fFGausFit;       }
-  const TF1 *GetFGausFit()           const { return fFGausFit;       } 
-
-  TH1I *GetHPowerProbability()             { return fHPowerProbability; }
-  const TH1I *GetHPowerProbability() const { return fHPowerProbability; } 
-
-  TF1 *GetFExpFit()                        { return fFExpFit;        }
-  const TF1 *GetFExpFit()            const { return fFExpFit;        } 
-
-  TGraph *GetGraphEvents()                 { return fGraphEvents;    }
-  const TGraph *GetGraphEvents()     const { return fGraphEvents;    }
-  
-  TGraph *GetGraphPowerSpectrum()             { return fGraphPowerSpectrum;  }
-  const TGraph *GetGraphPowerSpectrum() const { return fGraphPowerSpectrum;  }
-  
-  const Bool_t IsGausFitOK()          const; 
-  const Bool_t IsExpFitOK()           const; 
-  const Bool_t IsEmpty()              const;
-  const Bool_t IsFourierSpectrumOK()  const;
-  const Bool_t IsExcluded         ()  const;
+  const Bool_t IsExcluded()              const;
+  const Bool_t IsExpFitOK()              const; 
+  const Bool_t IsEmpty()                 const;
+  const Bool_t IsFourierSpectrumOK()     const;
+  const Bool_t IsGausFitOK()             const; 
 
   // Fill
-  void FillArray(const Float_t f);            // Fill only the array fEvents 
-  Bool_t FillHist(const Float_t f);           // Fill only the histogram HGausHist 
-  Bool_t FillHistAndArray(const Float_t f);   // Fill bothe the array fEvents and the histogram HGausHist
+  void   FillArray       ( const Float_t f );     // Fill only the array fEvents 
+  Bool_t FillHist        ( const Float_t f );     // Fill only the histogram HGausHist 
+  Bool_t FillHistAndArray( const Float_t f );     // Fill bothe the array fEvents and the histogram HGausHist
   
   // Fits
-  Bool_t FitGaus(Option_t *option="RQ0",
-                 const Double_t xmin=0., 
-	         const Double_t xmax=0.);         // Fit the histogram HGausHist with a Gaussian
+  Bool_t FitGaus(  Option_t *option="RQ0",
+                   const Double_t xmin=0., 
+	           const Double_t xmax=0.);       // Fit the histogram HGausHist with a Gaussian
   Bool_t RepeatFit(const Option_t *option="RQ0"); // Repeat fit within limits defined by fPickupLimit
   void BypassFit();                               // Take mean and RMS from the histogram
@@ -176,10 +157,10 @@
   
   // Miscelleaneous
-  virtual void ChangeHistId(const Int_t id); // Changes names and titles of the histogram
-  virtual void Renorm();                     // Re-normalize the results 
+  virtual void ChangeHistId(const Int_t id);      // Changes names and titles of the histogram
+  virtual void Renorm();                          // Re-normalize the results 
   
-  void CreateFourierSpectrum();              // Create the fourier spectrum out of fEvents
-  void CreateGraphEvents();                  // Create the TGraph fGraphEvents of fEvents 
-  void CreateGraphPowerSpectrum();           // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
+  void CreateFourierSpectrum();                   // Create the fourier spectrum out of fEvents
+  void CreateGraphEvents();                       // Create the TGraph fGraphEvents of fEvents 
+  void CreateGraphPowerSpectrum();                // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
   
   ClassDef(MHGausEvents, 1) // Base class for events with Gaussian distributed values
