Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 7188)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 7189)
@@ -20,4 +20,13 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2005/07/14 Thomas Bretz
+
+   * mbadpixels/MBadPixelCam.[h,cc]:
+     - added new function GetNumSuitable
+
+   * mcalib/MCalibrationChargeCalc.cc:
+      simplified FinalizeUnsuitablePixels()
+
+
 
  2005/07/13 Abelardo Moralejo (2005/07/12)
@@ -64,4 +73,13 @@
        also absolute calibration (=SIZE in phes) is made.
 
+  * mcalib/MCalibrateData.cc
+    - In PreProcess, changed initialization of fRenormFactor. Formerly 
+      it was fixed to MCalibrationQEPix::gkDefaultAverageQE. Now we check
+      first if there is a valid average QE for inner pixels in 
+      MCalibrationQECam, and if so, we inititalize fRenormFactor with it. 
+      Else, the default gkDefaultAverageQE is taken. fRenormFactor is
+      used to convert back from photons to "equivalent inner pixel phes"
+      in the (now default) case of calibrating in phes.
+
 
 
@@ -287,4 +305,31 @@
      - check for existence of pointer fRawEvt in PostProcess.
 
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - implement possibility to set reference number of photo-electrons from 
+       outside (stored in fExternalNumPhes).
+
+   * mcalib/MCalibrateData.[h,cc], mcalib/MCalibCalcFromPast.cc, 
+     mjobs/MJCalibrateSignal.cc:
+     - write calibration constants now in separate 
+       MCalibrationIntensityConstCam. This is necessary since with the 
+       introduction of the averageing of mean photo-electrons, the 
+       MCalibrationIntensityChargeCam does not hold the correct conv. 
+       factors any more. 
+
+   * mcalib/MCalibrateData.[h,cc]
+     - get also pointers to the IntensityCams and use them if exist 
+       (previously, only the first calibration cam was used together 
+       with the updatecam.)
+
+
+
+ 2005/07/13 Markus Gaug (2005/06/17)
+
+   * mcalib/MCalibrationIntensityCam.[h,cc]
+     - take out some un-used or commented code (variables fOffsets and
+       fSlopes). These data members were not in the streamter either.
+     - put some of the most-used code from the .cc file into the .h file
+     - add new function: SetCam().
+
 
 
@@ -305,4 +350,17 @@
      - In CalibrateData, the sigma is used for the statistical error of the
        converted signal to equiv. high-gain charges.
+
+   * mcalib/MCalibCalcFromPast.[h,cc]
+     - implement the mean photo-electron averageing for a desired number of 
+       calibration updates.
+
+   * mcalib/MCalibrateData.cc
+     - use MCalibrationChargePix::GetConversionHiLoSigma() to calculate the
+       error (was previously MCalibrationChargePix::GetConversionHiLoErr(). 
+
+  * callisto.cc
+    - calculate first fixed window pedestal in MJPedestalY2, 
+      then sliding window pedestal in MJPedestalY3 (order reversed).
+
 
 
@@ -347,4 +405,24 @@
       now, depending on the study, one wants to make.
 
+  * mcalib/MCalibrationChargeCalc.[h,cc]
+    - set a limit to the number of un-suitable and un-reliables pixels
+      for the run to succeed: 0.1 unsuitables and 0.3 un-reliables
+    - set UseExtractorRes to kTRUE, will raise the number of 
+      photo-electrons for the spline extractor by 1-2% (correctly).
+    - re-normalize the pedestal RMS of the event-by-event averaged 
+      area events to the sqrt of the number of used pixels.
+    - re-normalize the sigma of the event-by-event averaged area events
+      by 1/F-Factor.
+    - introduce switch to choose if un-reliables should be used for the
+      calculation of mean number of phes (default: kTRUE).
+    - print out the number of high-gain saturated pixels.
+
+
+
+ 2005/07/13 Markus Gaug (2005/06/10) 
+
+  * mjobs/MJCalibrateSignal.[h,cc]
+    - skip also the PIN Diode events from the data calibration.
+
 
 
@@ -357,4 +435,17 @@
      - introduce flags to steer the setting of unreliability like done 
        in MCalibrationChargeCalc. Can be steered from the conf-file.
+
+   * mbadpixels/MBadPixelsIntensityCam.[h,cc]
+     - implement two Get and Draw-functions to display bad pixels over 
+       time like in the mcalib/MCalibrationIntensityChargeCam
+
+
+
+ 2005/07/13 Markus Gaug (2005/06/03) 
+
+   * mhcalib/MHCalibrationPulseTimeCam.cc
+     -  fill arrays only if IsOscillations() was asked. This is a speed 
+        bug and could cause important memory leaks. It does not affect the 
+        outcome of an analysis, however.
 
 
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 7188)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 7189)
@@ -76,4 +76,7 @@
      a good precision is needed.
 
+   - callisto: Set UseExtractorRes to kTRUE, will raise the number of 
+     photo-electrons for the spline extractor by 1-2% (correctly).
+
    - star: fixed a bug which caused MEffectiveOnTime containers not to
      be written. In the worst case they were skipped almost all, in the
@@ -96,4 +99,8 @@
 
    - ganymed: optimized palettes for MHDisp
+
+   - ganymed: Fixed an important bug when using ThetaSq as fit function:
+     The result for the sigma of the gauss(sqrt(x)) fit was a factor
+     sqrt(2) to large
 
    - sponde: the zenith angle distribution is now weighted instead of
Index: /trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- /trunk/MagicSoft/Mars/callisto.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/callisto.cc	(revision 7189)
@@ -358,5 +358,5 @@
         job1.SetExtractionFundamental();
         // job1.SetPathOut(kOutpathC); // not yet needed
-        // job1.SetPathIn(kInpathC);   // not yet needed
+        // job1.SetPathIn(kInpathC);   // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
 
         if (!job1.Process())
@@ -387,5 +387,5 @@
         job2.SetDeadPixelCheck();
         // job1.SetPathOut(kOutpathC); // not yet needed
-        // job1.SetPathIn(kInpathC);   // not yet needed
+        // job1.SetPathIn(kInpathC);   // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
 
         //job2.SetExtractorResolution();
@@ -488,5 +488,5 @@
         job1.SetOverwrite(kOverwrite);
         job1.SetPathData(kInpathD);
-        job1.SetPathIn(kInpathY);
+        job1.SetPathIn(kInpathY);   // --> READ Extractor from calib-file
         job1.SetDataType(kDataType);
         //job1.SetPathOut(kOutpathY);   // not yet needed
@@ -525,5 +525,5 @@
 
         job2.SetUseData();
-        job2.SetExtractionWithExtractor();
+        job2.SetExtractionWithExtractorRndm();
         job2.SetExtractor(job1.GetExtractor());
         job2.SetPedestals(job1.GetPedestalCam());
@@ -563,6 +563,6 @@
 
         job3.SetUseData();
-        job3.SetExtractionWithExtractorRndm();
-        job3.SetExtractor(job1.GetExtractor());
+        job3.SetExtractionWithExtractor();
+        job3.SetExtractor(job2.GetExtractor());
         job3.SetPedestals(job1.GetPedestalCam());
         job3.SetBadPixels(job1.GetBadPixels());
Index: /trunk/MagicSoft/Mars/callisto.rc
===================================================================
--- /trunk/MagicSoft/Mars/callisto.rc	(revision 7188)
+++ /trunk/MagicSoft/Mars/callisto.rc	(revision 7189)
@@ -376,8 +376,11 @@
 
 # -------------------------------------------------------------------------
-# use the entire results obtained with the F-Factor method (including a
-# new number of mean photo-electrons)
+# Configure the interlaced calibration updates
 # -------------------------------------------------------------------------
 #MJCalibrateSignal.MCalibCalcFromPast.UpdateWithFFactorMethod: yes
+#MJCalibrateSignal.MCalibCalcFromPast.NumEventsDump: 500
+#MJCalibrateSignal.MCalibCalcFromPast.UpdateNumPhes: yes
+#MJCalibrateSignal.MCalibCalcFromPast.NumPhesDump: 10
+#MJCalibrateSignal.MCalibrationChargeCalc.Debug: no
 
 # -------------------------------------------------------------------------
@@ -431,6 +434,6 @@
 #MJCalibrateSignal.MHCalibrationChargeCam.HiGainLast:   1899.5
 MJCalibrateSignal.MHCalibrationChargeCam.LoGainNbins:   250
-#MJCalibrateSignal.MHCalibrationChargeCam.LoGainFirst:  -99.
-#MJCalibrateSignal.MHCalibrationChargeCam.LoGainLast:   901.
+MJCalibrateSignal.MHCalibrationChargeCam.LoGainFirst:   -98
+MJCalibrateSignal.MHCalibrationChargeCam.LoGainLast:    902
 #MJCalibrateSignal.MHCalibrationChargeCam.TimeLowerLimit: 1. 
 #MJCalibrateSignal.MHCalibrationChargeCam.TimeUpperLimit: 3. 
Index: /trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc
===================================================================
--- /trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc	(revision 7188)
+++ /trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc	(revision 7189)
@@ -88,5 +88,5 @@
 #MJPedestalC1.ExtractSignal.Resolution:        0.05
 #MJPedestalC1.ExtractSignal.RiseTimeHiGain:    0.5
-MJPedestalC1.ExtractSignal.FallTimeHiGain:     0.5
+#MJPedestalC1.ExtractSignal.FallTimeHiGain:     0.5
 #MJPedestalC1.ExtractSignal.LoGainStretch:     1.5
 #MJPedestalC1.ExtractSignal.ExtractionType: Integral <default>
@@ -339,5 +339,5 @@
 #MJPedestalY2.PulsePosCheck: yes
 MJPedestalY2.ExtractWinLeft:  3.0
-MJPedestalY2.ExtractWinRight: 2.0
+MJPedestalY2.ExtractWinRight: 2.5
 #MJCalibrateSignal.ModifiedExtractWin: yes
 # -------------------------------------------------------------------------
@@ -389,7 +389,11 @@
 
 # -------------------------------------------------------------------------
-# Use this if you want to change to time from run headers instead of event time
-# -------------------------------------------------------------------------
-#MJCalibrateSignal.MPointingPosInterpolate.TimeMode: eventtime, runtime
+# Configure the interlaced calibration updates
+# -------------------------------------------------------------------------
+#MJCalibrateSignal.MCalibCalcFromPast.UpdateWithFFactorMethod: yes
+#MJCalibrateSignal.MCalibCalcFromPast.NumEventsDump: 500
+#MJCalibrateSignal.MCalibCalcFromPast.UpdateNumPhes: yes
+#MJCalibrateSignal.MCalibCalcFromPast.NumPhesDump: 10
+#MJCalibrateSignal.MCalibrationChargeCalc.Debug: no
 
 # -------------------------------------------------------------------------
@@ -440,6 +444,6 @@
 #MJCalibrateSignal.MHCalibrationChargeCam.HiGainLast:   1899.5
 MJCalibrateSignal.MHCalibrationChargeCam.LoGainNbins:   250
-#MJCalibrateSignal.MHCalibrationChargeCam.LoGainFirst:  -100.5
-#MJCalibrateSignal.MHCalibrationChargeCam.LoGainLast:   899.5
+MJCalibrateSignal.MHCalibrationChargeCam.LoGainFirst:   -98
+MJCalibrateSignal.MHCalibrationChargeCam.LoGainLast:    902
 #MJCalibrateSignal.MHCalibrationChargeCam.TimeLowerLimit: 1. 
 #MJCalibrateSignal.MHCalibrationChargeCam.TimeUpperLimit: 3. 
Index: /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc	(revision 7189)
@@ -180,5 +180,5 @@
 // --------------------------------------------------------------------------
 //
-// Calculate the number of pixels with the given type-flags.
+// Calculate the number of pixels without the given type-flags.
 //
 // The second argument aidx is the area index (see MGeomCam, MGeomPix)
@@ -187,9 +187,9 @@
 // Returns -1 if the geometry doesn't match.
 //
-Short_t MBadPixelsCam::GetNumUnsuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx) const
+Short_t MBadPixelsCam::GetNumSuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx) const
 {
     const UInt_t n = GetSize();
 
-    if (aidx>=0 && geom->GetNumPixels()!=n)
+    if (aidx>=0 && (!geom || geom->GetNumPixels()!=n))
     {
         *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom->ClassName() << ") size mismatch!" << endl;
@@ -200,5 +200,36 @@
     for (UInt_t i=0; i<n; i++)
     {
-        if (aidx>=0 && (*geom)[i].GetAidx()!=aidx)
+        if (aidx>=0 && geom && (*geom)[i].GetAidx()!=aidx)
+            continue;
+
+        if (!(*this)[i].IsUnsuitable(type))
+            rc++;
+    }
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the number of pixels with the given type-flags.
+//
+// The second argument aidx is the area index (see MGeomCam, MGeomPix)
+// The default (or any value less than 0) means: all
+//
+// Returns -1 if the geometry doesn't match.
+//
+Short_t MBadPixelsCam::GetNumUnsuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx) const
+{
+    const UInt_t n = GetSize();
+
+    if (aidx>=0 && geom && geom->GetNumPixels()!=n)
+    {
+        *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom->ClassName() << ") size mismatch!" << endl;
+        return -1;
+    }
+
+    Short_t rc = 0;
+    for (UInt_t i=0; i<n; i++)
+    {
+        if (aidx>=0 && geom && (*geom)[i].GetAidx()!=aidx)
             continue;
 
@@ -334,5 +365,4 @@
 void MBadPixelsCam::Print(Option_t *o) const
 {
-
   *fLog << all << GetDescriptor() << ":" << endl;
   *fLog << "Pixels without problems:" << endl;
@@ -477,6 +507,4 @@
 void MBadPixelsCam::PrintBadPixels( MBadPixelsPix::UncalibratedType_t typ, const char *text) const 
 {
-
-
   *fLog << "Pixels with " << text << ": " << endl;
   UInt_t count = 0;
Index: /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.h	(revision 7188)
+++ /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.h	(revision 7189)
@@ -42,4 +42,6 @@
     Short_t GetNumUnsuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx=-1) const;
     Short_t GetNumUnsuitable(MBadPixelsPix::UnsuitableType_t type) const { return GetNumUnsuitable(type, 0); }
+    Short_t GetNumSuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx=-1) const;
+    Short_t GetNumSuitable(MBadPixelsPix::UnsuitableType_t type) const { return GetNumSuitable(type, 0); }
     Short_t GetNumIsolated(MBadPixelsPix::UnsuitableType_t type, const MGeomCam &geom, Int_t aidx=-1) const;
     Short_t GetNumIsolated(const MGeomCam &geom, Int_t aidx=-1) const { return GetNumIsolated(MBadPixelsPix::kUnsuitableRun, geom, aidx); }
Index: /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.cc	(revision 7189)
@@ -44,6 +44,9 @@
 
 #include <TOrdCollection.h>
-
-#include "MGeomCam.h"
+#include <TGraph.h>
+
+#include "MGeomPix.h"
+#include "MHCamera.h"
+#include "MLogManip.h"
 
 ClassImp(MBadPixelsIntensityCam);
@@ -268,2 +271,286 @@
 }
 
+
+// -------------------------------------------------------------------
+//
+// Returns a TGraph with the number of uncalibrated type pixels per area index
+// vs. the calibration camera.
+//
+TGraph *MBadPixelsIntensityCam::GetUncalibratedPerAreaVsTime(const MBadPixelsPix::UncalibratedType_t typ,
+                                                             const Int_t aidx, const MGeomCam &geom)
+{
+  
+  const Int_t size = GetSize();
+  
+  if (size == 0)
+    return NULL;
+  
+  TArrayF uncal(size);
+  TArrayF time(size);
+  
+  for (Int_t i=0;i<GetSize();i++)
+    {
+      //
+      // Get the calibration cam from the intensity cam
+      //
+      MBadPixelsCam *cam = GetCam(i);
+
+      //
+      // Get the calibration pix from the calibration cam
+      //
+      for (Int_t j=0; j<cam->GetSize(); j++)
+        {
+
+          if (geom[j].GetAidx() != aidx && aidx > -1)
+            continue;
+
+          const MBadPixelsPix &pix = (*cam)[j];
+          //
+          // Don't use bad pixels
+          //
+          if (pix.IsUncalibrated(typ))
+            uncal[i]++;
+        }
+      time[i] = i;
+    }
+  
+  TGraph *gr = new TGraph(size,time.GetArray(),uncal.GetArray());
+  
+  gr->SetTitle(Form("Uncalibrated Pixels Area %d",aidx));
+  gr->GetXaxis()->SetTitle("Camera Nr.");
+  gr->GetYaxis()->SetTitle("<N_{uncal}> [1]");      
+  return gr;
+}
+
+TGraph *MBadPixelsIntensityCam::GetUnsuitablePerAreaVsTime(const MBadPixelsPix::UnsuitableType_t typ, const Int_t aidx, const MGeomCam &geom)
+{
+  const Int_t size = GetSize();
+  
+  if (size == 0)
+    return NULL;
+  
+  TArrayF unsuit(size);
+  TArrayF time(size);
+  
+  for (Int_t i=0;i<GetSize();i++)
+    {
+      //
+      // Get the calibration cam from the intensity cam
+      //
+      MBadPixelsCam *cam = GetCam(i);
+
+      //
+      // Get the calibration pix from the calibration cam
+      //
+      for (Int_t j=0; j<cam->GetSize(); j++)
+        {
+          if (geom[j].GetAidx() != aidx && aidx > -1)
+            continue;
+
+          const MBadPixelsPix &pix = (*cam)[j];
+          //
+          // Don't use bad pixels
+          //
+          if (pix.IsUnsuitable(typ))
+            unsuit[i]++;
+        }
+      time[i] = i;
+    }
+  
+  TGraph *gr = new TGraph(size,time.GetArray(),unsuit.GetArray());
+  
+  gr->SetTitle(Form("Unsuitable Pixels Area %d",aidx));
+  gr->GetXaxis()->SetTitle("Camera Nr.");
+  gr->GetYaxis()->SetTitle("<N_{unsuit}> [1]");      
+  return gr;
+}
+
+MHCamera *MBadPixelsIntensityCam::GetUnsuitableSpectrum(const MBadPixelsPix::UnsuitableType_t typ, const MGeomCam &geom)
+{
+  const Int_t size = GetSize();
+  
+  if (size == 0)
+    return NULL;
+  
+  TString title;
+  TString axist;
+  
+  switch (typ)
+    {
+    case MBadPixelsPix::kUnsuitableRun:
+      title = "Unsuitable Pixels";
+      break;
+    case MBadPixelsPix::kUnreliableRun:
+      title = "Unreliable Pixels";
+      break;
+    default:
+      *fLog << warn << "Could not determine unsuitable type ... abort " << endl;
+      return NULL;
+    }
+  
+  MHCamera *camunsuit = new MHCamera(geom,"Unsuitables",title.Data());
+
+  for (Int_t i=0;i<GetSize();i++)
+    {
+      //
+      // Get the calibration cam from the intensity cam
+      //
+      MBadPixelsCam *cam = GetCam(i);
+
+      //
+      // Get the calibration pix from the calibration cam
+      //
+      for (Int_t j=0; j<cam->GetSize(); j++)
+        {
+          const MBadPixelsPix &pix = (*cam)[j];
+          //
+          // Don't use bad pixels
+          //
+          if (pix.IsUnsuitable(typ))
+            {
+              camunsuit->Fill(j,1);
+              camunsuit->SetUsed(j);
+            }
+        }
+    }
+  
+  return camunsuit;
+}
+
+MHCamera *MBadPixelsIntensityCam::GetUncalibratedSpectrum(const MBadPixelsPix::UncalibratedType_t typ, const MGeomCam &geom)
+{
+
+  const Int_t size = GetSize();
+  
+  if (size == 0)
+    return NULL;
+  
+  TString title;
+  TString axist;
+  
+  switch (typ)
+    {
+      case MBadPixelsPix::kPreviouslyExcluded:
+        title = "PreviouslyExcluded";
+        break;
+      case MBadPixelsPix::kHiGainNotFitted:
+        title = "HiGainNotFitted";
+        break;
+      case MBadPixelsPix::kLoGainNotFitted:
+        title = "LoGainNotFitted";
+        break;
+      case MBadPixelsPix::kRelTimeNotFitted:
+        title = "RelTimeNotFitted";
+        break;
+      case MBadPixelsPix::kHiGainOscillating:
+        title = "HiGainOscillating";
+        break;
+      case MBadPixelsPix::kLoGainOscillating:
+        title = "LoGainOscillating";
+        break;
+      case MBadPixelsPix::kRelTimeOscillating:
+        title = "RelTimeOscillating";
+        break;
+      case MBadPixelsPix::kLoGainSaturation:
+        title = "LoGainSaturation";
+        break;
+      case MBadPixelsPix::kChargeIsPedestal:
+        title = "ChargeIsPedestal";
+        break;
+      case MBadPixelsPix::kChargeErrNotValid:
+        title = "ChargeErrNotValid";
+        break;
+      case MBadPixelsPix::kChargeRelErrNotValid:
+        title = "ChargeRelErrNotValid";
+        break;
+      case MBadPixelsPix::kChargeSigmaNotValid:
+        title = "ChargeSigmaNotValid";
+        break;
+      case MBadPixelsPix::kMeanTimeInFirstBin:
+        title = "MeanTimeInFirstBin";
+        break;
+      case MBadPixelsPix::kMeanTimeInLast2Bins:
+        title = "MeanTimeInLast2Bins";
+        break;
+      case MBadPixelsPix::kDeviatingNumPhes:
+        title = "DeviatingNumPhes";
+        break;
+      case MBadPixelsPix::kDeviatingNumPhots:
+        title = "DeviatingNumPhots";
+        break;
+      case MBadPixelsPix::kDeviatingFFactor:
+        title = "DeviatingFFactor";
+        break;
+      case MBadPixelsPix::kDeviatingTimeResolution:
+        title = "DeviatingTimeResolution";
+        break;
+      case MBadPixelsPix::kConversionHiLoNotValid:
+        title = "ConversionHiLoNotValid";
+        break;
+      case MBadPixelsPix::kHiGainOverFlow:
+        title = "HiGainOverFlow";
+        break;
+      case MBadPixelsPix::kLoGainOverFlow:
+        title = "LoGainOverFlow";
+        break;
+      case MBadPixelsPix::kHiLoNotFitted:
+        title = "HiLoNotFitted";
+        break;
+      case MBadPixelsPix::kHiLoOscillating:
+        title = "HiLoOscillating";
+        break;
+      case MBadPixelsPix::kDeadPedestalRms:
+        title = "DeadPedestalRms";
+        break;
+      case MBadPixelsPix::kFluctuatingArrivalTimes:
+        title = "FluctuatingArrivalTimes";
+        break;
+    default:
+      *fLog << warn << "Could not determine uncalibrated type ... abort " << endl;
+      return NULL;
+    }
+  
+  MHCamera *camuncal = new MHCamera(geom,"Uncalibrated",title.Data());
+
+  for (Int_t i=0;i<GetSize();i++)
+    {
+      //
+      // Get the calibration cam from the intensity cam
+      //
+      MBadPixelsCam *cam = GetCam(i);
+
+      //
+      // Get the calibration pix from the calibration cam
+      //
+      for (Int_t j=0; j<cam->GetSize(); j++)
+        {
+          const MBadPixelsPix &pix = (*cam)[j];
+          //
+          // Don't use bad pixels
+          //
+          if (pix.IsUncalibrated(typ))
+            {
+              camuncal->Fill(j,1);
+              camuncal->SetUsed(j);
+            }
+        }
+    }
+  
+  return camuncal;
+}
+
+
+
+void MBadPixelsIntensityCam::DrawUnsuitablePerAreaVsTime(const MBadPixelsPix::UnsuitableType_t typ, const Int_t aidx, const MGeomCam &geom)
+{
+  TGraph *gr = GetUnsuitablePerAreaVsTime(typ,aidx,geom);
+  gr->SetBit(kCanDelete);
+  gr->Draw("A*");
+}
+
+void MBadPixelsIntensityCam::DrawUncalibratedPerAreaVsTime(const MBadPixelsPix::UncalibratedType_t typ, const Int_t aidx, const MGeomCam &geom)
+{
+  TGraph *gr = GetUncalibratedPerAreaVsTime(typ,aidx,geom);
+  gr->SetBit(kCanDelete);
+  gr->Draw("A*");
+}
Index: /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.h	(revision 7188)
+++ /trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.h	(revision 7189)
@@ -11,7 +11,11 @@
 #include "MBadPixelsCam.h"
 #endif
+#ifndef MARS_MGeomCamMagic
+#include "MGeomCamMagic.h"
+#endif
 
 class TOrdCollection;
-class MGeomCam;
+class TGraph;
+class MHCamera;
 class MBadPixelsIntensityCam : public MParContainer, public MCamEvent
 {
@@ -74,4 +78,20 @@
   void   DrawPixelContent( Int_t num) const;
 
+  TGraph *GetUncalibratedPerAreaVsTime( const MBadPixelsPix::UncalibratedType_t typ,
+                                        const Int_t aidx=-1, const MGeomCam &geom=MGeomCamMagic());
+  TGraph *GetUnsuitablePerAreaVsTime( const MBadPixelsPix::UnsuitableType_t typ,
+                                      const Int_t aidx=-1, const MGeomCam &geom=MGeomCamMagic());
+
+  MHCamera *GetUnsuitableSpectrum( const MBadPixelsPix::UnsuitableType_t typ, const MGeomCam &geom=MGeomCamMagic());
+
+  MHCamera *GetUncalibratedSpectrum( const MBadPixelsPix::UncalibratedType_t typ, const MGeomCam &geom=MGeomCamMagic());
+
+  void DrawUncalibratedPerAreaVsTime( const MBadPixelsPix::UncalibratedType_t typ,
+                                        const Int_t aidx=-1, const MGeomCam &geom=MGeomCamMagic()); // *MENU*
+  void DrawUnsuitablePerAreaVsTime( const MBadPixelsPix::UnsuitableType_t typ,
+                                      const Int_t aidx=-1, const MGeomCam &geom=MGeomCamMagic()); // *MENU*
+  
+
+
   ClassDef(MBadPixelsIntensityCam, 1) // Base Container Intensity BadPixels Results
 };
Index: /trunk/MagicSoft/Mars/mbadpixels/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mbadpixels/Makefile	(revision 7188)
+++ /trunk/MagicSoft/Mars/mbadpixels/Makefile	(revision 7189)
@@ -21,5 +21,5 @@
 INCLUDES = -I. -I../mbase -I../manalysis -I../mgeom -I../mgui \
            -I../mmc -I../mpedestal -I../msignal -I../mpointing \
-           -I../mhbase
+           -I../mhbase -I../mhist
 # MBadPixelsCalc  (manalysis): MPedPhotCam, MSigmabar
 # MBadPixelsCalc  (mgeom):     MGeomCam
Index: /trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc	(revision 7189)
@@ -32,4 +32,5 @@
 //   MCalibrationIntensityChargeCam
 //   MCalibrationIntensityRelTimeCam
+//   MCalibrationIntensityConstCam
 //   MBadPixelsIntensityCam 
 //
@@ -37,5 +38,13 @@
 //   MCalibrationIntensityChargeCam
 //   MCalibrationIntensityRelTimeCam
-//   MBadPixelsIntensityCam 
+//   MBadPixelsIntensityCam
+//
+// Class version 2:
+//  +  UInt_t  fNumPhesDump;         // Number of cams after which the number of phes gets averaged
+//  +  Float_t fMeanPhes;
+//  +  Float_t fMeanPhesRelVar;
+//  +  Bool_t  fUpdateNumPhes;       // Update the number of photo-electrons only after fNumPhesDump number of Cams
+//  +  TArrayF fPhes;
+//  +  TArrayF fPhesVar;
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -55,7 +64,9 @@
 #include "MCalibrationIntensityQECam.h"
 #include "MCalibrationIntensityRelTimeCam.h"
+#include "MCalibrationIntensityConstCam.h"
 
 #include "MBadPixelsIntensityCam.h"
 
+#include "MCalibrationChargePix.h"
 #include "MCalibrationChargeCalc.h"
 #include "MCalibrationRelTimeCalc.h"
@@ -67,4 +78,5 @@
 
 const UInt_t MCalibCalcFromPast::fgNumEventsDump = 500;
+const UInt_t MCalibCalcFromPast::fgNumPhesDump   = 10;
 
 // --------------------------------------------------------------------------
@@ -74,11 +86,12 @@
 // Sets:
 // - fNumEventsDump to fgNumEventsDump
+// - fNumPhesDump to fgNumPhesDump
 //
 MCalibCalcFromPast::MCalibCalcFromPast(const char *name, const char *title)
     : fGeom(NULL), fParList(NULL), fRunHeader(NULL),
-    fIntensCharge(NULL), fIntensBlind(NULL), fIntensQE(NULL),
-    fIntensRelTime(NULL), fIntensBad(NULL), fChargeCalc(NULL),
-    fRelTimeCalc(NULL), fCalibrate(NULL), fNumEvents(0), fNumCam(0),
-    fUpdateWithFFactorMethod(kFALSE)
+      fIntensCharge(NULL), fIntensBlind(NULL), fIntensRelTime(NULL), fIntensConst(NULL),
+      fIntensBad(NULL),
+      fChargeCalc(NULL), fRelTimeCalc(NULL), fCalibrate(NULL),
+      fNumCam(0), fNumEvents(0), fUpdateWithFFactorMethod(kTRUE), fUpdateNumPhes(kTRUE)
 {
 
@@ -87,4 +100,5 @@
 
   SetNumEventsDump();
+  SetNumPhesDump  ();
 }
 
@@ -150,4 +164,20 @@
     fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
     fIntensQE     = (MCalibrationIntensityQECam*)    pList->FindCreateObj("MCalibrationIntensityQECam");
+    fIntensConst  = (MCalibrationIntensityConstCam*) pList->FindCreateObj("MCalibrationIntensityConstCam");
+
+    MCalibrationChargeCam *chargeinit = (MCalibrationChargeCam*)pList->FindObject("MCalibrationChargeCam");
+    MCalibrationQECam     *qeinit     = (MCalibrationQECam*)    pList->FindObject("MCalibrationQECam");
+
+    if (chargeinit)
+      fIntensCharge->SetCam(chargeinit,0);
+    else
+      *fLog << "Could not find initial MCalibrationChargeCam, cannot initialize intensity cam" << endl;
+
+    if (qeinit)
+      fIntensQE->SetCam(qeinit,0);
+    else
+      *fLog << "Could not find initial MCalibrationQECam, cannot initialize intensity cam" << endl;
+
+    fIntensConst->GetCam()->Init(*fGeom);
 
     if (!fChargeCalc)
@@ -212,4 +242,13 @@
   fNumCam    = 0;
   fNumEvents = 0;
+  fNumPhes   = 0;
+
+  fChargeCalc->SetUseExternalNumPhes(kFALSE);
+
+  if (fUpdateNumPhes)
+    {
+      fPhes.Set(fNumPhesDump);
+      fPhesVar.Set(fNumPhesDump);
+    }
 
   return kTRUE;
@@ -231,4 +270,6 @@
   
   fNumEvents = 0;
+  ReInitialize();
+
   //
   // Finalize Possible calibration histogram classes...
@@ -246,12 +287,41 @@
   *fLog << inf << "Finalize calibration calculations..." << endl;
   if (fChargeCalc)
-    fChargeCalc->Finalize();
+    {
+      fChargeCalc->Finalize();
+      if (fUpdateNumPhes)
+        {
+          MCalibrationChargePix &avpix =(MCalibrationChargePix&)fIntensCharge->GetCam()->GetAverageArea(0);
+          fPhes   [fNumPhes] = avpix.GetPheFFactorMethod();
+          fPhesVar[fNumPhes] = avpix.GetPheFFactorMethodVar();
+
+          fNumPhes++;
+
+          if (fNumPhes == fNumPhesDump)
+            {
+              fNumPhes = 0;
+              if (!UpdateMeanPhes())
+                {
+                  *fLog << warn << "Could not update mean number of photo-electrons. "
+                        << "Skip it until next update" << endl;
+                  fChargeCalc->SetUseExternalNumPhes(kFALSE);
+                }
+              else
+                {
+                  *fLog << inf << "New averaged number photo-electrons: " << fMeanPhes << endl;
+                  fChargeCalc->SetExternalNumPhes      ( fMeanPhes );
+                  fChargeCalc->SetExternalNumPhesRelVar( fMeanPhesRelVar );
+                  fChargeCalc->SetUseExternalNumPhes();
+                }
+            }
+        }
+    }
+
   if (fRelTimeCalc)
     fRelTimeCalc->Finalize();
+
   if (fCalibrate)
-      fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL :
-                                          (MCalibrationChargeCam*)fIntensCharge->GetCam());
-
-  ReInitialize();
+    fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL
+                                        : (MCalibrationChargeCam*)fIntensCharge->GetCam() );
+
   return kTRUE;
 }
@@ -289,5 +359,5 @@
   fNumCam++;
 
-  *fLog << inf << "MCalibCalcFromPast::ReInitialize #" << fNumCam << " ";
+  *fLog << inf << "MCalibCalcFromPast::ReInitialize #" << fNumCam << ": ";
 
   const Int_t runnumber = fRunHeader->GetRunNumber();
@@ -331,4 +401,29 @@
 }
 
+
+Bool_t MCalibCalcFromPast::UpdateMeanPhes()
+{
+    Float_t sumw = 0.;
+    Float_t sum  = 0.;
+
+    for (Int_t i=0; i<fPhes.GetSize(); i++)
+    {
+        const Float_t weight = 1./fPhesVar[i];
+        sum  += fPhes[i]*weight;
+        sumw += weight;
+    }
+
+    if (sumw < 0.000001)
+        return kFALSE;
+
+    if (sum < 0.000001)
+        return kFALSE;
+
+    fMeanPhes       = sum/sumw;
+    fMeanPhesRelVar = sumw/sum/sum;
+
+    return kTRUE;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -336,4 +431,6 @@
 //   MCalibCalcFromPast.UpdateWithFFactorMethod: Off, On
 //   MCalibCalcFromPast.NumEventsDump: 500
+//   MCalibCalcFromPast.UpdateNumPhes: yes/no
+//   MCalibCalcFromPast.NumPhesDump: 10
 //
 Int_t MCalibCalcFromPast::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
@@ -352,4 +449,23 @@
     }
 
+    if (IsEnvDefined(env, prefix, "UpdateNumPhes", print))
+    {
+        TString s = GetEnvValue(env, prefix, "UpdateNumPhes", "");
+        s.ToLower();
+        if (s.BeginsWith("no"))
+            SetUpdateNumPhes(kFALSE);
+        if (s.BeginsWith("yes"))
+            SetUpdateNumPhes(kTRUE);
+        rc = kTRUE;
+    }
+
+    if (IsEnvDefined(env, prefix, "NumPhesDump", print))
+    {
+        SetNumPhesDump(GetEnvValue(env, prefix, "NumPhesDump", (Int_t)fNumPhesDump));
+        rc = kTRUE;
+    }
+
+
+
     return rc;
 }
Index: /trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h	(revision 7188)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h	(revision 7189)
@@ -4,4 +4,8 @@
 #ifndef MARS_MTask
 #include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
 #endif
 
@@ -17,4 +21,5 @@
 class MCalibrationIntensityQECam;
 class MCalibrationIntensityRelTimeCam;
+class MCalibrationIntensityConstCam;
 class MBadPixelsIntensityCam;
 
@@ -22,6 +27,6 @@
 {
 private:
-
   static const UInt_t fgNumEventsDump;               //! Default for fNumEventsDump
+  static const UInt_t fgNumPhesDump;                 //! Default for fNumPhesDump
   
   MGeomCam                        *fGeom;            //! Camera Geometry
@@ -32,4 +37,5 @@
   MCalibrationIntensityQECam      *fIntensQE;        //! Intensity QE     Cam (to be created)
   MCalibrationIntensityRelTimeCam *fIntensRelTime;   //! Intensity Rel. Time Cam (to be created)
+  MCalibrationIntensityConstCam   *fIntensConst;     //! Intensity Rel. Time Cam (to be created)
   MBadPixelsIntensityCam          *fIntensBad;       //! Intensity Bad Pixels Cam (to be created)
   
@@ -38,35 +44,51 @@
   MCalibrateData                  *fCalibrate;       //! Data Calibration Task
                                                      
+  UInt_t fNumCam;              //! Number of currently used Calibration Cam
   UInt_t fNumEventsDump;       // Number of event after which the MCalibrationCams gets updated
   UInt_t fNumEvents;           //! Event counter only for calibration events
-  UInt_t fNumCam;              //! Number of currently used Calibration Cam
+  UInt_t fNumPhesDump;         // Number of cams after which the number of phes gets averaged
+  UInt_t fNumPhes;             //! Event counter for photo-electron updates
+
+  Float_t fMeanPhes;
+  Float_t fMeanPhesRelVar;
 
   Bool_t fUpdateWithFFactorMethod; // Update the interlaced calib events with the full F-Factor method
+  Bool_t fUpdateNumPhes;           // Update the number of photo-electrons only after fNumPhesDump number of Cams
 
+  TArrayF fPhes;
+  TArrayF fPhesVar;
+
+  // MTask
   Int_t  PreProcess(MParList *pList);
   Int_t  Process();
   Int_t  PostProcess();  
 
+  // MCalibCalcFromPast
   Bool_t ReInitialize();
   Bool_t Finalize(const char* name);
 
+  Bool_t UpdateMeanPhes();
+
+  // MParContainer
   Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
 public:
+  MCalibCalcFromPast(const char *name=NULL, const char *title=NULL);
 
-  MCalibCalcFromPast(const char *name=NULL, const char *title=NULL);
-  ~MCalibCalcFromPast() {}
-  
+  // Getter
   UInt_t GetNumEventsDump() const   {  return fNumEventsDump;   }
-  
+
+  // Setter
   void SetNumEventsDump( const UInt_t i=fgNumEventsDump )   { fNumEventsDump = i; }
+  void SetNumPhesDump  ( const UInt_t i=fgNumPhesDump   )   { fNumPhesDump   = i; }
   
   void SetCalibrate    ( MCalibrateData          *c )  { fCalibrate   = c; }
   void SetChargeCalc   ( MCalibrationChargeCalc  *c )  { fChargeCalc  = c; }
   void SetRelTimeCalc  ( MCalibrationRelTimeCalc *c )  { fRelTimeCalc = c; }
+  void SetUpdateNumPhes      ( const Bool_t b=kTRUE )  { fUpdateNumPhes           = b;  }
 
   void SetUpdateWithFFactorMethod(const Bool_t b=kTRUE){ fUpdateWithFFactorMethod = b; }
   
-  ClassDef(MCalibCalcFromPast, 1) // Task to steer the processing of interlace calibration events
+  ClassDef(MCalibCalcFromPast, 2) // Task to steer the processing of interlace calibration events
 };
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc	(revision 7189)
@@ -92,5 +92,5 @@
 //
 // See also: MJCalibration, MJPedestal, MJExtractSignal, MJExtractCalibTest
-// 
+//
 //////////////////////////////////////////////////////////////////////////////
 #include "MCalibrateData.h"
@@ -112,10 +112,13 @@
 #include "MPedestalPix.h"
 
+#include "MCalibrationIntensityChargeCam.h"
 #include "MCalibrationChargeCam.h"
 #include "MCalibrationChargePix.h"
-
+ 
+#include "MCalibrationIntensityQECam.h"
 #include "MCalibrationQECam.h"
 #include "MCalibrationQEPix.h"
-
+ 
+#include "MCalibrationIntensityConstCam.h"
 #include "MCalibConstCam.h"
 #include "MCalibConstPix.h"
@@ -152,7 +155,8 @@
 //
 MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title) 
-    : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL), 
-      fQEs(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL),
-      fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.), fScaleFactor(1.)
+    : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL), fIntensCalib(NULL),
+      fQEs(NULL), fIntensQE(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL),
+      fIntensConst(NULL), fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.),
+      fScaleFactor(1.)
 {
 
@@ -226,7 +230,13 @@
             return kFALSE;
 
-        fCalibConstCam = (MCalibConstCam*)pList->FindCreateObj(AddSerialNumber("MCalibConstCam"));
-        if (!fCalibConstCam)
-            return kFALSE;
+        fIntensConst = (MCalibrationIntensityConstCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityConstCam"));
+        if (fIntensConst)
+            *fLog << inf << "Found MCalibrationIntensityConstCam ... " << endl;
+        else
+        {
+            fCalibConstCam = (MCalibConstCam*)pList->FindCreateObj(AddSerialNumber("MCalibConstCam"));
+            if (!fCalibConstCam)
+                return kFALSE;
+        }
     }
 
@@ -235,4 +245,8 @@
     if (fCalibrationMode>kNone)
     {
+        fIntensCalib = (MCalibrationIntensityChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityChargeCam"));
+        if (fIntensCalib)
+          *fLog << inf << "Found MCalibrationIntensityChargeCam ... " << endl;
+
         fCalibrations = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
         if (!fCalibrations)
@@ -241,4 +255,8 @@
             return kFALSE;
         }
+
+        fIntensQE = (MCalibrationIntensityQECam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityQECam"));
+        if (fIntensQE)
+          *fLog << inf << "Found MCalibrationIntensityQECam ... " << endl;
 
         fQEs = (MCalibrationQECam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
@@ -290,9 +308,21 @@
       {
       case kPhe:
-        fRenormFactor = MCalibrationQEPix::gkDefaultAverageQE;
-        break;
+          //
+          // Average QE for C-photons, for pixels in the inner pixel region ("area 0"),
+          // used later to convert from C-photons into "equivalent phes":
+          //
+          if (fQEs->GetAverageAreas() > 0)
+          {
+              MCalibrationQEPix& avqepix = (MCalibrationQEPix&)(fQEs->GetAverageArea(0));
+              fRenormFactor = avqepix.GetAverageQE();
+          }
+          else // Average areas not yet initialized, use default value
+              fRenormFactor = MCalibrationQEPix::gkDefaultAverageQE;
+
+          fRenormFactor = MCalibrationQEPix::gkDefaultAverageQE;
+          break;
       case kPhot:
-        fRenormFactor = 1.;
-        break;
+          fRenormFactor = 1.;
+          break;
       }
 
@@ -346,5 +376,6 @@
     }
 
-    if(fCalibrationMode == kBlindPixel && !fQEs->IsBlindPixelMethodValid())
+    const MCalibrationQECam *qecam = fIntensQE ? (MCalibrationQECam*)fIntensQE->GetCam() : fQEs;
+    if(fCalibrationMode == kBlindPixel && !qecam->IsBlindPixelMethodValid())
     {
         *fLog << warn << "Blind pixel calibration method not valid, switching to F-factor method" << endl;
@@ -352,5 +383,5 @@
     }
 
-    if(fCalibrationMode == kPinDiode && !fQEs->IsPINDiodeMethodValid())
+    if(fCalibrationMode == kPinDiode && !qecam->IsPINDiodeMethodValid())
     {
         *fLog << warn << "PIN diode calibration method not valid, switching to F-factor method" << endl;
@@ -358,5 +389,5 @@
     }
 
-    if(fCalibrationMode == kCombined && !fQEs->IsCombinedMethodValid())
+    if(fCalibrationMode == kCombined && !qecam->IsCombinedMethodValid())
     {
         *fLog << warn << "Combined calibration method not valid, switching to F-factor method" << endl;
@@ -419,17 +450,18 @@
 
     if (fCalibrationMode > kNone)
-      {
-        
-        if (fCalibrations->GetSize() != npixels)
-          {
+    {
+
+        const MCalibrationCam *chargecam = fIntensCalib ? fIntensCalib->GetCam() : fCalibrations;
+        if (chargecam->GetSize() != npixels)
+        {
             *fLog << "Size mismatch between MGeomCam and MCalibrationChargeCam... abort!" << endl;
             return kFALSE;
-          }
-        
+        }
+
         if (fBadPixels->GetSize() != npixels)
-          {
+        {
             *fLog << "Size mismatch between MGeomCam and MBadPixelsCam... abort!" << endl;
             return kFALSE;
-          }
+        }
       }
     
@@ -466,5 +498,20 @@
     fHiLoConv.Reset();
     fHiLoConvErr.Reset();
-    
+
+    MCalibConstCam *constcam = fIntensConst ? fIntensConst->GetCam() : fCalibConstCam;
+
+    MCalibrationChargeCam *chargecam = NULL;
+    MCalibrationQECam     *qecam     = NULL;
+    if (updatecam)
+    {
+        chargecam = fCalibrations;
+        qecam     = fQEs;
+    }
+    else
+    {
+        chargecam = fIntensCalib ? (MCalibrationChargeCam*)fIntensCalib->GetCam() : fCalibrations;
+        qecam     = fIntensQE    ? (MCalibrationQECam*)    fIntensQE->GetCam()    : fQEs;
+    }
+
     //
     // For the moment, we use only a dummy zenith for the calibration:
@@ -488,5 +535,5 @@
         Float_t calibUpdate   = 1.;
 
-	MCalibConstPix &cpix  = (*fCalibConstCam)[pixidx];
+	MCalibConstPix &cpix  = (*constcam)[pixidx];
 	    
         if(fCalibrationMode!=kNone)
@@ -499,9 +546,9 @@
              }
             
-            MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*fCalibrations)[pixidx];
-            MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCalibrations->GetAverageArea(0);
-            
-            hiloconv   = pix.GetConversionHiLo   ();
-            hiloconverr= pix.GetConversionHiLoErr();
+            const MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[pixidx];
+            const MCalibrationChargePix &avpix = (MCalibrationChargePix&)chargecam->GetAverageArea(0);
+
+            hiloconv   = pix.GetConversionHiLo     ();
+            hiloconverr= pix.GetConversionHiLoSigma();
             
             calibConv    = pix.GetMeanConvFADC2Phe();
@@ -509,5 +556,5 @@
             calibFFactor = pix.GetMeanFFactorFADC2Phot();
             
-            MCalibrationQEPix &qe = (MCalibrationQEPix&) (*fQEs)[pixidx];
+            const MCalibrationQEPix &qe = (MCalibrationQEPix&)(*qecam)[pixidx];
 
             if (updatecam)
@@ -613,5 +660,5 @@
         calibConv /= calibQE;
 
-        if (calibConv != 0. && calibQE != 0.)
+        if (calibConv > 0.00001 && calibQE > 0.00001)
           {
             calibConvVar  = calibConvVar/(calibConv*calibConv) + calibQEVar/(calibQE*calibQE);
@@ -632,4 +679,5 @@
 	    calibConv    = -1.;
 	    calibFFactor = -1.;
+            *fLog << warn << "Conversion factor of Pixel " << pixidx << " out of range " << endl;
 	  }
 	cpix.SetCalibConst(calibConv);
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrateData.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrateData.h	(revision 7188)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrateData.h	(revision 7189)
@@ -13,11 +13,15 @@
 class MBadPixelsCam;
 class MPedestalCam;
-class MCalibrationChargeCam;
-class MCalibrationQECam;
-class MExtractedSignalCam;
-
 class MPedPhotCam;
 class MSignalCam;
 class MCalibConstCam;
+class MExtractedSignalCam;
+
+class MCalibrationChargeCam;
+class MCalibrationQECam;
+
+class MCalibrationIntensityChargeCam;
+class MCalibrationIntensityQECam;
+class MCalibrationIntensityConstCam;
 
 class MCalibrateData : public MTask
@@ -58,11 +62,14 @@
   Float_t  fCalibConvMaxLimit;           // Maximum limit for conv. factor
     
-  MGeomCam              *fGeomCam;       //! Camera geometry container
-  MBadPixelsCam         *fBadPixels;     //! Bad Pixels information
-  MCalibrationChargeCam *fCalibrations;  //! Calibration constants
-  MCalibrationQECam     *fQEs;           //! Quantum efficiencies
-  MExtractedSignalCam   *fSignals;       //! Integrated charge in FADCs counts
-  MSignalCam            *fCerPhotEvt;    //! Cerenkov Photon Event used for calculation
-  MCalibConstCam        *fCalibConstCam; //! Temporary calib consts storage
+  MGeomCam                       *fGeomCam;       //! Camera geometry container
+  MBadPixelsCam                  *fBadPixels;     //! Bad Pixels information
+  MCalibrationChargeCam          *fCalibrations;  //! Calibration constants
+  MCalibrationIntensityChargeCam *fIntensCalib;   //! Calibration constants from interlaced calib.
+  MCalibrationQECam              *fQEs;           //! Quantum efficiencies
+  MCalibrationIntensityQECam     *fIntensQE;      //! Quantum efficiencies  from interlaced calib.
+  MExtractedSignalCam            *fSignals;       //! Integrated charge in FADCs counts
+  MSignalCam                     *fCerPhotEvt;    //! Cerenkov Photon Event used for calculation
+  MCalibConstCam                 *fCalibConstCam; //! Temporary calib consts storage
+  MCalibrationIntensityConstCam  *fIntensConst;   //! Temporary calib consts storage
   
   CalibrationMode_t fCalibrationMode;    // Flag defining the calibration mode (CalibrationMode_t)
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 7189)
@@ -184,6 +184,13 @@
 //   + Float_t fPheErrUpperLimit; // Upper limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
 //
+//
 //  ClassVersion 3:
 //   + Bool_t  fUseExtractorRes;  // Include extractor resolution in F-Factor method
+//
+//  ClassVersion 3:
+//   +  Float_t fUnsuitablesLimit;                   // Limit for relative number of unsuitable pixels
+//   +  Float_t fUnreliablesLimit;                   // Limit for relative number of unreliable pixels
+//   +  Float_t fExternalNumPhes;                    // External mean number of photo-electrons set from outside
+//   +  Float_t fExternalNumPhesRelVar;              // External rel. var. number of photo-electrons set from outside  
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -198,6 +205,4 @@
 
 #include "MParList.h"
-
-#include "MStatusDisplay.h"
 
 #include "MCalibrationPattern.h"
@@ -247,4 +252,6 @@
 const Float_t MCalibrationChargeCalc::fgFFactorErrLimit        = 4.5;
 const Float_t MCalibrationChargeCalc::fgArrTimeRmsLimit        = 3.5;
+const Float_t MCalibrationChargeCalc::fgUnsuitablesLimit       = 0.1;
+const Float_t MCalibrationChargeCalc::fgUnreliablesLimit       = 0.3;
 const TString MCalibrationChargeCalc::fgNamePedestalCam = "MPedestalCam";
 
@@ -263,18 +270,22 @@
 //
 // Initializes:
-// - fArrTimeRmsLimit   to fgArrTimeRmsLimit
-// - fChargeLimit       to fgChargeLimit 
-// - fChargeErrLimit    to fgChargeErrLimit   
-// - fChargeRelErrLimit to fgChargeRelErrLimit
-// - fFFactorErrLimit   to fgFFactorErrLimit
-// - fLambdaCheckLimit  to fgLambdaCheckLimit 
-// - fLambdaErrLimit    to fgLambdaErrLimit 
-// - fNamePedestalCam   to fgNamePedestalCam
-// - fPheErrLowerLimit  to fgPheErrLowerLimit
-// - fPheErrUpperLimit  to fgPheErrUpperLimit
-// - fPulserColor       to MCalibrationCam::kCT1
-// - fOutputPath        to "."
-// - fOutputFile        to "ChargeCalibStat.txt"
-// - flag debug         to kFALSE
+// - fArrTimeRmsLimit     to fgArrTimeRmsLimit
+// - fChargeLimit         to fgChargeLimit
+// - fChargeErrLimit      to fgChargeErrLimit
+// - fChargeRelErrLimit   to fgChargeRelErrLimit
+// - fFFactorErrLimit     to fgFFactorErrLimit
+// - fLambdaCheckLimit    to fgLambdaCheckLimit
+// - fLambdaErrLimit      to fgLambdaErrLimit
+// - fNamePedestalCam     to fgNamePedestalCam
+// - fPheErrLowerLimit    to fgPheErrLowerLimit
+// - fPheErrUpperLimit    to fgPheErrUpperLimit
+// - fPulserColor         to MCalibrationCam::kCT1
+// - fOutputPath          to "."
+// - fOutputFile          to "ChargeCalibStat.txt"
+// - flag debug           to kFALSE
+// - IsUseExtractorRes    to kFALSE
+// - IsUseExternalNumPhes to kFALSE
+// - fExternalNumPhes     to 0.
+// - fExternalNumPhesRelVar to 0.
 //
 // Sets all checks
@@ -284,6 +295,5 @@
 //
 MCalibrationChargeCalc::MCalibrationChargeCalc(const char *name, const char *title)
-    : fUseExtractorRes(kFALSE),
-    fGeom(NULL), fSignal(NULL), fCalibPattern(NULL), fExtractor(NULL)
+    : fGeom(NULL), fSignal(NULL), fCalibPattern(NULL), fExtractor(NULL)
 {
         
@@ -309,4 +319,12 @@
   SetPheErrLowerLimit  ();
   SetPheErrUpperLimit  ();
+  SetUnsuitablesLimit  ();
+  SetUnreliablesLimit  ();
+  SetUseExtractorRes   ();
+  SetUseUnreliables    ();
+  SetUseExternalNumPhes(kFALSE);
+ 
+  SetExternalNumPhes      ();
+  SetExternalNumPhesRelVar();
 
   SetCheckArrivalTimes     ();
@@ -560,4 +578,6 @@
     }
 
+  fResultFlags.Set(fGeom->GetNumAreas());
+
   return kTRUE;
 }
@@ -777,8 +797,18 @@
     {
 
-      const MPedestalPix     &ped = fPedestals->GetAverageArea(aidx);
+      const MPedestalPix    &ped = fPedestals->GetAverageArea(aidx);
       MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageArea(aidx);
+      const MArrayI &arr         = fHCam->GetAverageAreaNum();
 
       FinalizePedestals(ped,pix,aidx);
+
+      //
+      // Correct for sqrt(number of valid pixels) in the pedestal RMS
+      // (already done for calibration sigma in MHCalibrationCam::CalcAverageSigma()
+      //
+      pix.SetPedRMS(pix.GetPedRms()*TMath::Sqrt((Float_t)arr[aidx]),
+                    pix.GetPedRmsErr()*TMath::Sqrt((Float_t)arr[aidx]));
+      pix.SetSigma (pix.GetSigma()/pix.GetFFactorFADC2Phe());
+
       FinalizeCharges(pix, chargecam->GetAverageBadArea(aidx),"area id");
       FinalizeArrivalTimes(pix, chargecam->GetAverageBadArea(aidx), "area id");
@@ -847,18 +877,4 @@
   }
 
-  //
-  // Finalize calibration statistics
-  //
-  FinalizeUnsuitablePixels();
-
-  chargecam->SetReadyToSave();
-  qecam    ->SetReadyToSave();
-  badcam   ->SetReadyToSave();
-  
-  if (blindcam)
-    blindcam->SetReadyToSave();
-  if (fPINDiode)
-    fPINDiode->SetReadyToSave();
-  
   *fLog << inf << endl;
   *fLog << GetDescriptor() << ": Fatal errors statistics:" << endl;  
@@ -884,4 +900,6 @@
   PrintUncalibrated(MBadPixelsPix::kDeviatingNumPhes,
                     "Deviating number of phes:                         ");
+  PrintUncalibrated(MBadPixelsPix::kLoGainBlackout,
+                    "Too many blackout events in low gain:             ");
   PrintUncalibrated(MBadPixelsPix::kPreviouslyExcluded,
                     "Previously excluded:                              ");
@@ -906,5 +924,17 @@
       SetLogStream(oldlog);
 
-  return kTRUE;
+  chargecam->SetReadyToSave();
+  qecam    ->SetReadyToSave();
+  badcam   ->SetReadyToSave();
+
+  if (blindcam)
+    blindcam->SetReadyToSave();
+  if (fPINDiode)
+    fPINDiode->SetReadyToSave();
+
+  //
+  // Finalize calibration statistics
+  //
+  return FinalizeUnsuitablePixels();
 }
 
@@ -1042,5 +1072,5 @@
     }
 
-  if (!fUseExtractorRes)
+  if (!IsUseExtractorRes())
     return kTRUE;
 
@@ -1059,8 +1089,9 @@
     : resinphes/cal.GetMeanConvFADC2Phe();
 
-  if (resinfadc > 1.5*cal.GetPedRms() )
-    {
-      *fLog << warn << " Extractor Resolution: " << resinfadc << " bigger than Pedestal RMS " << cal.GetPedRms() << endl;
-      resinfadc = cal.GetPedRms();
+  if (resinfadc > 3.0*cal.GetPedRms() )
+    {
+      *fLog << warn << " Extractor Resolution: " << resinfadc << " bigger than 3 Pedestal RMS "
+            << cal.GetPedRms() << endl;
+      resinfadc = 3.0*cal.GetPedRms();
     }
 
@@ -1152,10 +1183,4 @@
           if (bad.IsUncalibrated( MBadPixelsPix::kChargeIsPedestal))
             bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun   );
- 
-          if (bad.IsUncalibrated( MBadPixelsPix::kChargeErrNotValid ))
-            bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
-
-          if (bad.IsUncalibrated( MBadPixelsPix::kChargeRelErrNotValid ))
-            bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
         }
       
@@ -1268,5 +1293,9 @@
       if (bad.IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid))
         continue;
-      
+
+      if (!IsUseUnreliables())
+        if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+          continue;
+
       const Float_t nphe  = pix.GetPheFFactorMethod();
       const Int_t   aidx  = (*fGeom)[i].GetAidx();
@@ -1322,10 +1351,11 @@
       if (ndf < 5)
         {
-          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " 
-                << "in the camera with area index: " << i << endl;
-          *fLog << warn << GetDescriptor() << ": Number of dof.: " << ndf << " is smaller than 5 " << endl;
-          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
-          delete hist;
-          continue;
+            *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " << endl;
+            *fLog << " in the camera with area index: " << i << endl;
+            *fLog << " Number of dof.: " << ndf << " is smaller than 5 " << endl;
+            *fLog << " Will use the simple mean and rms " << endl;
+            delete hist;
+            SetPheFitOK(i,kFALSE);
+            continue;
         }
       
@@ -1334,20 +1364,21 @@
       if (prob < 0.001)
         {
-          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " 
-                << "in the camera with area index: " << i << endl;
-          *fLog << warn << GetDescriptor() << ": Fit probability " << prob 
-                << " is smaller than 0.001 " << endl;
-          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
-          delete hist;
-          continue;
+            *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " << endl;
+            *fLog << " in the camera with area index: " << i << endl;
+            *fLog << " Fit probability " << prob << " is smaller than 0.001 " << endl;
+            *fLog << " Will use the simple mean and rms " << endl;
+            delete hist;
+            SetPheFitOK(i,kFALSE);
+            continue;
         }
       
       if (mean < 0.)
         {
-          *fLog << inf << GetDescriptor() << ": Fitted mean number of photo-electrons " 
-                << "with area idx " << i << ": " << mean << " is smaller than 0. " << endl;
-          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;          
-          delete hist;
-          continue;
+            *fLog << inf << GetDescriptor() << ": Fitted mean number of photo-electrons " << endl;
+            *fLog << " with area idx " << i << ": " << mean << " is smaller than 0. " << endl;
+            *fLog << warn << " Will use the simple mean and rms " << endl;
+            SetPheFitOK(i,kFALSE);
+            delete hist;
+            continue;
         }
       
@@ -1359,4 +1390,6 @@
 
       delete hist;
+
+      SetPheFitOK(i,kTRUE);
     }
 
@@ -1383,4 +1416,8 @@
       if (bad.IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid))
         continue;
+
+      if (!IsUseUnreliables())
+        if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+          continue;
 
       const Float_t nvar  = pix.GetPheFFactorMethodVar();
@@ -1730,5 +1767,11 @@
   MCalibrationQEPix     &qepix = (MCalibrationQEPix&)    qecam->GetAverageArea(0);
 
-  const Float_t avphotons   = avpix.GetPheFFactorMethod()       
+  if (IsDebug())
+    *fLog << dbginf << "External Phes: " << fExternalNumPhes
+          << " Internal Phes: " << avpix.GetPheFFactorMethod() << endl;
+
+  const Float_t avphotons   = ( IsUseExternalNumPhes()
+                                ? fExternalNumPhes
+                                : avpix.GetPheFFactorMethod() )
                            / qepix.GetDefaultQE(fPulserColor) 
                            / qepix.GetPMTCollectionEff()
@@ -1736,5 +1779,7 @@
                            / qecam->GetPlexiglassQE();
 
-  const Float_t avphotrelvar = avpix.GetPheFFactorMethodRelVar() 
+  const Float_t avphotrelvar = ( IsUseExternalNumPhes()
+                                 ? fExternalNumPhesRelVar
+                                 : avpix.GetPheFFactorMethodRelVar() )
                             + qepix.GetDefaultQERelVar(fPulserColor) / fNumInnerFFactorMethodUsed
                             + qepix.GetPMTCollectionEffRelVar()
@@ -1846,9 +1891,10 @@
       if (ndf < 2)
         {
-          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " 
-                << "in the camera with area index: " << i << endl;
-          *fLog << "Number of dof.: " << ndf << " is smaller than 2 " << endl;
-          *fLog << "Will use the simple mean and rms." << endl;
+          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " << endl;
+          *fLog << " in the camera with area index: " << i << endl;
+          *fLog << " Number of dof.: " << ndf << " is smaller than 2 " << endl;
+          *fLog << " Will use the simple mean and rms." << endl;
           delete hist;
+          SetFFactorFitOK(i,kFALSE);
           continue;
         }
@@ -1858,16 +1904,15 @@
       if (prob < 0.001)
         {
-          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " 
-                << "in the camera with area index: " << i << endl;
-          *fLog << "Fit probability " << prob
-                << " is smaller than 0.001 " << endl;
-          *fLog << "Will use the simple mean and rms." << endl;
+          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " << endl;
+          *fLog << " in the camera with area index: " << i << endl;
+          *fLog << " Fit probability " << prob << " is smaller than 0.001 " << endl;
+          *fLog << " Will use the simple mean and rms." << endl;
           delete hist;
-          continue;
+          SetFFactorFitOK(i,kFALSE);
+         continue;
         }
 
       *fLog << inf << GetDescriptor() << ": Mean F-Factor " 
-          << "with area index #" << i << ": "
-            << Form("%4.2f+-%4.2f",mean,sigma) << endl;
+          << "with area index #" << i << ": " << Form("%4.2f+-%4.2f",mean,sigma) << endl;
 
       lowlim  [i] = 1.;
@@ -1875,4 +1920,6 @@
 
       delete hist;
+
+      SetFFactorFitOK(i,kTRUE);
     }
   
@@ -2134,5 +2181,5 @@
 // - store numbers of bad pixels of each type in fCam or fIntensCam
 //
-void MCalibrationChargeCalc::FinalizeUnsuitablePixels()
+Bool_t MCalibrationChargeCalc::FinalizeUnsuitablePixels()
 {
   
@@ -2143,65 +2190,68 @@
   const Int_t nareas = fGeom->GetNumAreas();
 
+  TArrayI suit(nareas);
+  TArrayI unsuit(nareas);
+  TArrayI unrel(nareas);
+
+  const MBadPixelsCam *badcam = fIntensBad ? (MBadPixelsCam*)fIntensBad->GetCam() : fBadPixels;
+  MCalibrationChargeCam *chargecam = fIntensCam ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;
+
+  Int_t unsuitcnt=0;
+  Int_t unrelcnt =0;
+
+  // Count number of succesfully calibrated pixels
+  for (Int_t aidx=0; aidx<nareas; aidx++)
+  {
+      suit[aidx]   = badcam->GetNumSuitable(MBadPixelsPix::kUnsuitableRun,   fGeom, aidx);
+      unsuit[aidx] = badcam->GetNumUnsuitable(MBadPixelsPix::kUnsuitableRun, fGeom, aidx);
+      unrel[aidx]  = badcam->GetNumUnsuitable(MBadPixelsPix::kUnreliableRun, fGeom, aidx);
+
+      unsuitcnt   += unsuit[aidx];
+      unrelcnt    += unrel[aidx];
+
+      chargecam->SetNumUnsuitable(unsuit[aidx], aidx);
+      chargecam->SetNumUnreliable(unrel[aidx],  aidx);
+  }
+
   TArrayI counts(nareas);
-
-  MBadPixelsCam         *badcam    = fIntensBad 
-    ? (MBadPixelsCam*)fIntensBad->GetCam()  : fBadPixels;
-  MCalibrationChargeCam *chargecam = fIntensCam 
-    ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
-
-  for (Int_t i=0; i<badcam->GetSize(); i++)
-    {
-      MBadPixelsPix &bad = (*badcam)[i];
-      if (!bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
-        {
+  for (Int_t i=0; i<chargecam->GetSize(); i++)
+  {
+      MCalibrationPix &pix = (*chargecam)[i];
+      if (pix.IsHiGainSaturation())
+      {
           const Int_t aidx = (*fGeom)[i].GetAidx();
           counts[aidx]++;
-        }
-    }
+      }
+  }
 
   if (fGeom->InheritsFrom("MGeomCamMagic"))
-    *fLog << " " << setw(7) << "Successfully calibrated Pixels: " 
-          << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
-  
-  counts.Reset();
-
-  for (Int_t i=0; i<badcam->GetSize(); i++)
-    {
-      MBadPixelsPix &bad =  (*badcam)[i];
-
-      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
-        {
-          const Int_t aidx = (*fGeom)[i].GetAidx();
-          counts[aidx]++;
-        }
-    }
-
-  for (Int_t aidx=0; aidx<nareas; aidx++)
-    chargecam->SetNumUnsuitable(counts[aidx], aidx);
-
-  if (fGeom->InheritsFrom("MGeomCamMagic"))
-    *fLog << " " << setw(7) << "Uncalibrated Pixels:            " 
-          << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
-
-  counts.Reset();
-
-  for (Int_t i=0; i<badcam->GetSize(); i++)
-    {
-
-      MBadPixelsPix &bad = (*badcam)[i];
-
-      if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
-        {
-          const Int_t aidx = (*fGeom)[i].GetAidx();
-          counts[aidx]++;
-        }
-    }
-
-  for (Int_t aidx=0; aidx<nareas; aidx++)
-    chargecam->SetNumUnreliable(counts[aidx], aidx);
-
-  *fLog << " " << setw(7) << "Unreliable Pixels:              "
-        << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
-
+  {
+      *fLog << " Successfully calibrated Pixels: Inner: "
+          << Form("%3i",suit[0])   << " Outer: " << Form("%3i",suit[1])   << endl;
+      *fLog << " Uncalibrated Pixels:            Inner: "
+          << Form("%3i",unsuit[0]) << " Outer: " << Form("%3i",unsuit[1]) << endl;
+      *fLog << " Unreliable Pixels:              Inner: "
+          << Form("%3i",unrel[0])  << " Outer: " << Form("%3i",unrel[1])  << endl;
+      *fLog << " High-gain saturated Pixels:     Inner: "
+          << Form("%3i",counts[0]) << " Outer: " << Form("%3i",counts[1]) << endl;
+      *fLog << endl;
+  }
+
+  return kTRUE;
+
+  if (unsuitcnt > fUnsuitablesLimit*fGeom->GetNumPixels())
+  {
+      *fLog << err << "Number of unsuitable pixels: " << 100.*unsuitcnt/fGeom->GetNumPixels()
+          << "% exceeds limit of " << fUnsuitablesLimit*100 << "%" <<  endl;
+      return kFALSE;
+  }
+
+  if (unrelcnt > fUnreliablesLimit*fGeom->GetNumPixels())
+  {
+      *fLog << err << "Relative number of unreliable pixels: " << 100.*unrelcnt/fGeom->GetNumPixels()
+          << "% exceeds limit of " << fUnreliablesLimit*100 << "%" << endl;
+      return kFALSE;
+  }
+  return kTRUE;
 }
 
@@ -2232,6 +2282,6 @@
     }
 
-  *fLog << " " << setw(7) << text  
-        << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
+  *fLog << " " << setw(7) << text << "Inner: " << Form("%3i",countinner)
+      << " Outer: " << Form("%3i", countouter) << endl;
 }
 
@@ -2361,9 +2411,33 @@
       rc = kTRUE;
     }
-  if (IsEnvDefined(env, prefix, "UseExtractorRes", print))
-    {
-      SetUseExtractorRes(GetEnvValue(env, prefix, "UseExtractorRes", fUseExtractorRes));
+   if (IsEnvDefined(env, prefix, "UseExtractorRes", print))
+     {
+       SetUseExtractorRes(GetEnvValue(env, prefix, "UseExtractorRes", IsUseExtractorRes()));
       rc = kTRUE;
     }
+  if (IsEnvDefined(env, prefix, "UseUnreliables", print))
+    {
+      SetUseUnreliables(GetEnvValue(env, prefix, "UseUnreliables", IsUseUnreliables()));
+      rc = kTRUE;
+    }
+
+  if (IsEnvDefined(env, prefix, "UseExternalNumPhes", print))
+    {
+      SetUseExternalNumPhes(GetEnvValue(env, prefix, "UseExternalNumPhes", IsUseExternalNumPhes()));
+      rc = kTRUE;
+    }
+
+  if (IsEnvDefined(env, prefix, "UnsuitablesLimit", print))
+    {
+      SetUnsuitablesLimit(GetEnvValue(env, prefix, "UnsuitablesLimit", fUnsuitablesLimit));
+      rc = kTRUE;
+    }
+
+  if (IsEnvDefined(env, prefix, "UnreliablesLimit", print))
+    {
+       SetUnreliablesLimit(GetEnvValue(env, prefix, "UnreliablesLimit", fUnreliablesLimit));
+       rc = kTRUE;
+     }
+ 
 
   return rc;
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 7188)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 7189)
@@ -50,11 +50,15 @@
   static const Float_t fgFFactorErrLimit;      //! Default for fFFactorErrLimit    (now set to: 4.5)
   static const Float_t fgArrTimeRmsLimit;      //! Default for fArrTimeRmsLimit    (now set to: 3.5)
+  static const Float_t fgUnsuitablesLimit;     //! Default for fUnsuitableLimit    (now set to: 0.1)
+  static const Float_t fgUnreliablesLimit;     //! Default for fUnreliableLimit    (now set to: 0.3)
  
   static const TString fgNamePedestalCam;      //! "MPedestalCam"
   
   // Variables
+  Float_t fArrTimeRmsLimit;                    // Limit acceptance RMS of absolute arrival times
   Float_t fChargeLimit;                        // Limit acceptance mean charge  (in units of PedRMS)
   Float_t fChargeErrLimit;                     // Limit acceptance charge error (in abs. numbers)
   Float_t fChargeRelErrLimit;                  // Limit acceptance rel. error mean (in abs. numbers)
+  Float_t fFFactorErrLimit;                    // Limit acceptance F-Factor w.r.t. area idx mean
   Float_t fLambdaCheckLimit;                   // Limit rel. diff. lambda and lambdacheck in Blind Pixel
   Float_t fLambdaErrLimit;                     // Limit acceptance lambda error in Blind Pixel
@@ -63,8 +67,11 @@
   Float_t fPheErrLowerLimit;                   // Lower limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
   Float_t fPheErrUpperLimit;                   // Upper limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
-  Float_t fFFactorErrLimit;                    // Limit acceptance F-Factor w.r.t. area idx mean
-  Float_t fArrTimeRmsLimit;                    // Limit acceptance RMS of absolute arrival times
   Float_t fSqrtHiGainSamples;                  // Square root nr. High-Gain FADC slices used by extractor
   Float_t fSqrtLoGainSamples;                  // Square root nr. Low -Gain FADC slices used by extractor 
+  Float_t fUnsuitablesLimit;                   // Limit for relative number of unsuitable pixels
+  Float_t fUnreliablesLimit;                   // Limit for relative number of unreliable pixels
+
+  Float_t fExternalNumPhes;                    // External mean number of photo-electrons set from outside
+  Float_t fExternalNumPhesRelVar;              // External rel. var. number of photo-electrons set from outside  
 
   MCalibrationCam::PulserColor_t fPulserColor; // Calibration LEDs colour 
@@ -73,9 +80,4 @@
   Int_t   fNumInnerFFactorMethodUsed;          // Number of inner pixels used for F-Factor Method calibration
 
-  Byte_t  fFlags;                              // Bit-field for the general flags
-  TArrayC fResultFlags;                        // Bit-fields for the fitting results   (one field per area index)
-  TArrayC fBlindPixelFlags;                    // Bit-fields for the blind pixel flags (one field per blind pixel)
-  TArrayC fPINDiodeFlags;                      // Bit-fields for the PIN Diode flags   (one field per PIN Diode  )
-  
   TString fOutputPath;                         // Path to the output file
   TString fOutputFile;                         // Name of the output file  
@@ -83,5 +85,4 @@
 
   Int_t   fNumProcessed;                       // Number of processed events (for Intensity calibration)
-  Bool_t  fUseExtractorRes;                    // Include extractor resolution in F-Factor method
   
   // Pointers
@@ -115,21 +116,35 @@
 
   Byte_t fCheckFlags;                          // Bit-field to hold the possible check flags
-  
+
+  enum  FitResult_t { kPheFitOK,
+                      kFFactorFitOK,
+                      kBlindPixelFitOK,
+                      kBlindPixelPedFitOK,
+                      kPINDiodeFitOK };        // Possible Fit Result flags
+
+  TArrayC fResultFlags;                        // Bit-fields for the fitting results   (one field per area index)
+  TArrayC fBlindPixelFlags;                    // Bit-fields for the blind pixel flags (one field per blind pixel)
+  TArrayC fPINDiodeFlags;                      // Bit-fields for the PIN Diode flags   (one field per PIN Diode  )
+
   enum  { kDebug,
-          kPheFitOK, kFFactorFitOK, kBlindPixelFitOK, kBlindPixelPedFitOK, kPINDiodeFitOK };
+          kUseExtractorRes,
+          kUseUnreliables,
+          kUseExternalNumPhes };               // Possible general flags
+
+  Byte_t fFlags;                               // Bit-field to hold the general flags
 
   // functions
+  void   FinalizeArrivalTimes    ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
+  void   FinalizeBadPixels       ();
+  Bool_t FinalizeBlindCam        ();  
+  void   FinalizeBlindPixelQECam ();
+  Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
+  void   FinalizeCombinedQECam   ();
+  void   FinalizeFFactorQECam    ();  
+  Bool_t FinalizeFFactorMethod   ();
   void   FinalizePedestals       ( const MPedestalPix    &ped, MCalibrationChargePix &cal, const Int_t aidx );
-  void   FinalizeArrivalTimes    ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
-  Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
   Bool_t FinalizePINDiode        ();
-  Bool_t FinalizeBlindCam        ();  
-  Bool_t FinalizeFFactorMethod   ();
-  void   FinalizeBadPixels       ();
-  void   FinalizeFFactorQECam    ();  
-  void   FinalizeBlindPixelQECam ();
   void   FinalizePINDiodeQECam   ();
-  void   FinalizeCombinedQECam   ();
-  void   FinalizeUnsuitablePixels();
+  Bool_t FinalizeUnsuitablePixels();
 
   const char* GetOutputFile();
@@ -143,22 +158,17 @@
   Bool_t IsCheckArrivalTimes     () const { return TESTBIT(fCheckFlags,kCheckArrivalTimes);      }
 
+  Bool_t IsDebug                 () const { return TESTBIT(fFlags,kDebug);                       }
+  Bool_t IsUseExtractorRes       () const { return TESTBIT(fFlags,kUseExtractorRes);             }
+  Bool_t IsUseUnreliables        () const { return TESTBIT(fFlags,kUseUnreliables);              }
+  Bool_t IsUseExternalNumPhes    () const { return TESTBIT(fFlags,kUseExternalNumPhes);          }
+
   void   PrintUncalibrated( MBadPixelsPix::UncalibratedType_t typ, const char *text) const;
 
   // Global fit results
-  void   SetPheFitOK          ( const Int_t aidx, const Bool_t b=kTRUE ) {
-    b ? SETBIT(fResultFlags[aidx], kPheFitOK) 
-      : CLRBIT(fResultFlags[aidx], kPheFitOK);      }
-  void   SetFFactorFitOK      ( const Int_t aidx, const Bool_t b=kTRUE ) {
-    b ? SETBIT(fResultFlags[aidx], kFFactorFitOK) 
-      : CLRBIT(fResultFlags[aidx], kFFactorFitOK);  }
-  void   SetBlindPixelFitOK   ( const Int_t  idx, const Bool_t b=kTRUE ) {
-    b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelFitOK) 
-      : CLRBIT(fBlindPixelFlags[idx], kBlindPixelFitOK); }
-  void   SetBlindPixelPedFitOK( const Int_t  idx, const Bool_t b=kTRUE ) {
-    b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK) 
-      : CLRBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK); }
-  void   SetPINDiodeFitOK     ( const Int_t  idx, const Bool_t b=kTRUE ) {
-    b ? SETBIT(fPINDiodeFlags[idx], kPINDiodeFitOK) 
-      : CLRBIT(fPINDiodeFlags[idx], kPINDiodeFitOK); }
+  void   SetPheFitOK          (const Int_t aidx, const Bool_t b=kTRUE) { b ? SETBIT(fResultFlags[aidx], kPheFitOK) : CLRBIT(fResultFlags[aidx], kPheFitOK);      }
+  void   SetFFactorFitOK      (const Int_t aidx, const Bool_t b=kTRUE) { b ? SETBIT(fResultFlags[aidx], kFFactorFitOK) : CLRBIT(fResultFlags[aidx], kFFactorFitOK);  }
+  void   SetBlindPixelFitOK   (const Int_t  idx, const Bool_t b=kTRUE) { b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelFitOK) : CLRBIT(fBlindPixelFlags[idx], kBlindPixelFitOK); }
+  void   SetBlindPixelPedFitOK(const Int_t  idx, const Bool_t b=kTRUE) { b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK): CLRBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK); }
+  void   SetPINDiodeFitOK     (const Int_t  idx, const Bool_t b=kTRUE) { b ? SETBIT(fPINDiodeFlags[idx], kPINDiodeFitOK): CLRBIT(fPINDiodeFlags[idx], kPINDiodeFitOK); }
 
   Int_t  PreProcess (MParList *pList);
@@ -169,5 +179,4 @@
 
 public:
-
   MCalibrationChargeCalc(const char *name=NULL, const char *title=NULL);
 
@@ -176,49 +185,43 @@
   Int_t Finalize();
 
-  Bool_t IsDebug() const   {  return TESTBIT(fFlags,kDebug); }
+  void SetChargeLimit      (const Float_t f=fgChargeLimit      ) { fChargeLimit       = f; }
+  void SetChargeErrLimit   (const Float_t f=fgChargeErrLimit   ) { fChargeErrLimit    = f; }
+  void SetChargeRelErrLimit(const Float_t f=fgChargeRelErrLimit) { fChargeRelErrLimit = f; }
+
+  // Checks
+  void SetCheckArrivalTimes(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckArrivalTimes)      : CLRBIT(fCheckFlags,kCheckArrivalTimes); }
+  void SetCheckDeadPixels(const Bool_t b=kTRUE)        { b ? SETBIT(fCheckFlags,kCheckDeadPixels)        : CLRBIT(fCheckFlags,kCheckDeadPixels); }
+  void SetCheckDeviatingBehavior(const Bool_t b=kTRUE) { b ? SETBIT(fCheckFlags,kCheckDeviatingBehavior) : CLRBIT(fCheckFlags,kCheckDeviatingBehavior); }
+  void SetCheckExtractionWindow(const Bool_t b=kTRUE)  { b ? SETBIT(fCheckFlags,kCheckExtractionWindow)  : CLRBIT(fCheckFlags,kCheckExtractionWindow); }
+  void SetCheckHistOverflow(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckHistOverflow)      : CLRBIT(fCheckFlags,kCheckHistOverflow); }
+  void SetCheckOscillations(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckOscillations)      : CLRBIT(fCheckFlags,kCheckOscillations); }
+  void SetDebug(const Bool_t b=kTRUE)                  { b ? SETBIT(fFlags, kDebug)                      : CLRBIT(fFlags, kDebug); }
+  void SetUseExtractorRes(const Bool_t b=kTRUE)        { b ? SETBIT(fFlags, kUseExtractorRes)            : CLRBIT(fFlags, kUseExtractorRes); }
+  void SetUseUnreliables(const Bool_t b=kTRUE)         { b ? SETBIT(fFlags, kUseUnreliables)             : CLRBIT(fFlags, kUseUnreliables); }
+  void SetUseExternalNumPhes(const Bool_t b=kTRUE)     { b ? SETBIT(fFlags, kUseExternalNumPhes)         : CLRBIT(fFlags, kUseExternalNumPhes); }
+
+  // pointers
+  void SetPedestals(MPedestalCam *cam) { fPedestals=cam; }
+  void SetExtractor(MExtractor   *ext) { fExtractor=ext; }
+
+  // limits
+  void SetArrTimeRmsLimit (const Float_t f=fgArrTimeRmsLimit ) { fArrTimeRmsLimit   = f; }
+  void SetFFactorErrLimit (const Float_t f=fgFFactorErrLimit ) { fFFactorErrLimit   = f; }
+  void SetLambdaErrLimit  (const Float_t f=fgLambdaErrLimit  ) { fLambdaErrLimit    = f; }
+  void SetLambdaCheckLimit(const Float_t f=fgLambdaCheckLimit) { fLambdaCheckLimit  = f; }
+  void SetUnsuitablesLimit(const Float_t f=fgUnsuitablesLimit) { fUnsuitablesLimit  = f; }
+  void SetUnreliablesLimit(const Float_t f=fgUnreliablesLimit) { fUnreliablesLimit  = f; }
+
+  // others
+  void SetExternalNumPhes      ( const Float_t f=0.                       ) { fExternalNumPhes       = f; }
+  void SetExternalNumPhesRelVar( const Float_t f=0.                       ) { fExternalNumPhesRelVar = f; }  
+  void SetNamePedestalCam      ( const char *name=fgNamePedestalCam.Data()) { fNamePedestalCam    = name; }
+  void SetOutputPath           ( const TString path="."                   );
+  void SetOutputFile           ( const TString file="ChargeCalibStat.txt" );
+  void SetPheErrLowerLimit     ( const Float_t f=fgPheErrLowerLimit       ) { fPheErrLowerLimit  = f;    }
+  void SetPheErrUpperLimit     ( const Float_t f=fgPheErrUpperLimit       ) { fPheErrUpperLimit  = f;    }    
+  void SetPulserColor          ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;  }
   
-  void SetChargeLimit       ( const Float_t f=fgChargeLimit            ) { fChargeLimit       = f;     }
-  void SetChargeErrLimit    ( const Float_t f=fgChargeErrLimit         ) { fChargeErrLimit    = f;     }
-  void SetChargeRelErrLimit ( const Float_t f=fgChargeRelErrLimit      ) { fChargeRelErrLimit = f;     }
-
-  // Checks
-  void SetCheckArrivalTimes( const Bool_t b=kTRUE ) {
-    b ? SETBIT(fCheckFlags,kCheckArrivalTimes)
-      : CLRBIT(fCheckFlags,kCheckArrivalTimes); }
-  void SetCheckDeadPixels( const Bool_t b=kTRUE ) {
-    b ? SETBIT(fCheckFlags,kCheckDeadPixels)
-      : CLRBIT(fCheckFlags,kCheckDeadPixels); }
-  void SetCheckDeviatingBehavior( const Bool_t b=kTRUE ) {
-    b ? SETBIT(fCheckFlags,kCheckDeviatingBehavior)
-      : CLRBIT(fCheckFlags,kCheckDeviatingBehavior); }
-  void SetCheckExtractionWindow( const Bool_t b=kTRUE ) {
-    b ? SETBIT(fCheckFlags,kCheckExtractionWindow)
-      : CLRBIT(fCheckFlags,kCheckExtractionWindow); }
-  void SetCheckHistOverflow( const Bool_t b=kTRUE ) {
-    b ? SETBIT(fCheckFlags,kCheckHistOverflow)
-      : CLRBIT(fCheckFlags,kCheckHistOverflow); }
-  void SetCheckOscillations( const Bool_t b=kTRUE ) {
-    b ? SETBIT(fCheckFlags,kCheckOscillations)
-      : CLRBIT(fCheckFlags,kCheckOscillations); }
-  void SetDebug            ( const Bool_t b=kTRUE ) { 
-    b ? SETBIT(fFlags, kDebug) 
-      : CLRBIT(fFlags, kDebug); }
-
-  void SetExtractor(MExtractor   *ext) { fExtractor=ext; }
-  void SetPedestals(MPedestalCam *cam) { fPedestals=cam; }
-									 
-  void SetArrTimeRmsLimit   ( const Float_t f=fgArrTimeRmsLimit        ) { fArrTimeRmsLimit   = f;     }
-  void SetFFactorErrLimit   ( const Float_t f=fgFFactorErrLimit        ) { fFFactorErrLimit   = f;     }
-  void SetLambdaErrLimit    ( const Float_t f=fgLambdaErrLimit         ) { fLambdaErrLimit    = f;     }
-  void SetLambdaCheckLimit  ( const Float_t f=fgLambdaCheckLimit       ) { fLambdaCheckLimit  = f;     }
-  void SetNamePedestalCam   ( const char *name=fgNamePedestalCam.Data()) { fNamePedestalCam   = name;  }
-  void SetOutputPath        ( TString path="."                   );
-  void SetOutputFile        ( TString file="ChargeCalibStat.txt" );
-  void SetPheErrLowerLimit  ( const Float_t f=fgPheErrLowerLimit       ) { fPheErrLowerLimit  = f;     }
-  void SetPheErrUpperLimit  ( const Float_t f=fgPheErrUpperLimit       ) { fPheErrUpperLimit  = f;     }
-  void SetPulserColor       ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;   }
-  void SetUseExtractorRes(Bool_t b=kTRUE) { fUseExtractorRes = b; }
-
-  ClassDef(MCalibrationChargeCalc, 3)   // Task calculating Calibration Containers and Quantum Efficiencies
+  ClassDef(MCalibrationChargeCalc, 4)   // Task calculating Calibration Containers and Quantum Efficiencies
 };
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 7188)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 7189)
@@ -188,5 +188,5 @@
   Bool_t CalcMeanFFactor(const Float_t nphotons, const Float_t nphotonsrelvar);
   
-  ClassDef(MCalibrationChargePix, 3)	// Container Charge Calibration Results Pixel
+  ClassDef(MCalibrationChargePix, 4)	// Container Charge Calibration Results Pixel
 };
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc	(revision 7189)
@@ -41,6 +41,47 @@
 //           MCalibrationChargeBlindPix, MCalibrationChargePINDiode
 //
+// Inline Functions:
+// -----------------
+//
+// GetSize(): Returns the current size of the TOrdCollection fCams
+//  independently if the MCalibrationCam is filled with values or not.
+//
+// GetAverageAreas(): Returns the current size of the TOrdCollection
+//  fAverageAreas of the current camera.
+//
+// GetAverageArea(UInt_t i): Get i-th High Gain pixel Area from the
+//  current camera
+//
+// GetAverageArea(UInt_t i): Get i-th High Gain pixel Area from the
+//  current camera
+//
+// GetAverageBadArea(UInt_t i): Get i-th High Gain pixel Area from the
+//  current camera
+//
+// GetAverageBadArea(UInt_t i): Get i-th High Gain pixel Area from the
+//  current camera
+//
+// GetAverageSectors(): Returns the current size of the TOrdCollection
+//  fAverageSectors or the current camera
+//
+// GetAverageSector(UInt_t i): Get i-th High Gain Sector from the
+//  current camera
+//
+// GetAverageSector(UInt_t i): Get i-th High Gain Sector from the current
+//  camera
+//
+// GetAverageBadSector(UInt_t i): Get i-th High Gain Sector from the
+//  current camera
+//
+// GetAverageBadSector(UInt_t i): Get i-th High Gain Sector from the
+//  current camera
+//
+//
 // ClassVersion 2:
 //  + fHists
+//
+// ClassVersion 3:
+//  - MArrayD fOffsets;           //! Arrays of Higain-vs-LoGain fit result Offsets
+//  - MArrayD fSlopes;            //! Arrays of Higain-vs-LoGain fit result Slopes
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -127,7 +168,4 @@
 
     MParContainer::Copy(calib);
-
-    calib.fOffsets = fOffsets;
-    calib.fSlopes  = fSlopes;
 
     const UInt_t n = GetSize();
@@ -163,51 +201,4 @@
 }
 
-// -----------------------------------------------------
-//
-// Not yet installed...
-//
-void MCalibrationIntensityCam::DrawHiLoFits()
-{
-
-  /*
-  if (!fOffsets)
-    fOffsets = new TH1D("pp","Offsets of the HiGain LoGain Fit",100,-600.,400.);
-  if (!fSlopes)
-    fSlopes  = new TH1D("mm","Slopes of the HiGain LoGain Fit",100,-2.,2.);
-  if (!fOffvsSlope)
-    fOffvsSlope = new TH2D("aa","Slopes vs Offsets of the HiGain LoGain Fit",100,-600.,400.,100,-2.,2.);
-  
-  TIter Next(fPixels);
-  MCalibrationPix *pix;
-  MHCalibrationPixel *hist;
-  while ((pix=(MCalibrationPix*)Next()))
-    {
-      hist = pix->GetHist();
-      hist->FitHiGainvsLoGain();
-      fOffsets->Fill(hist->GetOffset(),1.);
-      fSlopes->Fill(hist->GetSlope(),1.);
-      fOffvsSlope->Fill(hist->GetOffset(),hist->GetSlope(),1.);
-    }
-
-   TCanvas *c1 = new TCanvas();
-
-   c1->Divide(1,3);
-   c1->cd(1);
-   fOffsets->Draw();
-   gPad->Modified();
-   gPad->Update();
-
-   c1->cd(2);
-  fSlopes->Draw();
-  gPad->Modified();
-  gPad->Update();
-
-  c1->cd(3);
-  fOffvsSlope->Draw("col1");
-  gPad->Modified();
-  gPad->Update();
-  */
-}
-
 // -------------------------------------------------------------------
 //
@@ -256,180 +247,7 @@
 }
 
-
-// --------------------------------------------------------------------------
-//
-// Returns the current size of the TOrdCollection fCams 
-// independently if the MCalibrationCam is filled with values or not.
-//
-const Int_t MCalibrationIntensityCam::GetSize() const 
-{
-  return fCams->GetSize();
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th pixel from current camera
-//
-MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
-{
-  return (*GetCam())[i];
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th pixel from current camera
-//
-const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const 
-{
-  return (*GetCam())[i];
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Returns the current size of the TOrdCollection fAverageAreas of the current camera.
-//
-const Int_t MCalibrationIntensityCam::GetAverageAreas() const
-{
-  return GetCam()->GetAverageAreas();
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th High Gain pixel Area from the current camera
-//
-MCalibrationPix  &MCalibrationIntensityCam::GetAverageArea(UInt_t i)
-{
-  return GetCam()->GetAverageArea(i);
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th High Gain pixel Area from the current camera
-//
-const MCalibrationPix  &MCalibrationIntensityCam::GetAverageArea(UInt_t i) const
-{
-  return GetCam()->GetAverageArea(i);
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th High Gain pixel Area from the current camera
-//
-MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i)
-{
-  return GetCam()->GetAverageBadArea(i);
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th High Gain pixel Area from the current camera
-//
-const MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i) const
-{
-  return GetCam()->GetAverageBadArea(i);
-}
-
-// --------------------------------------------------------------------------
-//
-// Returns the current size of the TOrdCollection fAverageSectors or the current camera
-//
-const Int_t MCalibrationIntensityCam::GetAverageSectors() const
-{
-  return GetCam()->GetAverageSectors();
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th High Gain Sector from the current camera
-//
-MCalibrationPix  &MCalibrationIntensityCam::GetAverageSector(UInt_t i)
-{
-  return GetCam()->GetAverageSector(i);
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th High Gain Sector from the current camera
-//
-const MCalibrationPix  &MCalibrationIntensityCam::GetAverageSector(UInt_t i) const
-{
-  return GetCam()->GetAverageSector(i);
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th High Gain Sector from the current camera
-//
-MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i)
-{
-  return GetCam()->GetAverageBadSector(i);
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th High Gain Sector from the current camera
-//
-const MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i) const
-{
-  return GetCam()->GetAverageBadSector(i);
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Get i-th camera 
-//
-MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i)
-{
-  return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th camera 
-//
-const MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i) const 
-{
-  return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get camera with name 'name' 
-//
-MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name )
-{
-  return static_cast<MCalibrationCam*>(fCams->FindObject(name));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get camera with name 'name' 
-//
-const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name ) const 
-{
-  return static_cast<MCalibrationCam*>(fCams->FindObject(name));
-}
-
-// --------------------------------------------------------------------------
-//
-// Calls GetPixelContent for the current entry in fCams
-//
-Bool_t MCalibrationIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
-{
-  return GetCam()->GetPixelContent(val,idx,cam,type);
-}
-
-// --------------------------------------------------------------------------
-//
-// Calls DrawPixelContent for the current entry in fCams
-//
-void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
-{
-  return GetCam()->DrawPixelContent(num);
-}
-
-Int_t MCalibrationIntensityCam::CountNumEntries(const MCalibrationCam::PulserColor_t col) const 
+// --------------------------------------------------------------------------
+//
+Int_t MCalibrationIntensityCam::CountNumEntries(const MCalibrationCam::PulserColor_t col) const
 {
   
@@ -451,23 +269,59 @@
 // --------------------------------------------------------------------------
 //
+// Get i-th pixel from current camera
+//
+MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
+{
+  return (*GetCam())[i];
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel from current camera
+//
+const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const 
+{
+  return (*GetCam())[i];
+}
+
+// --------------------------------------------------------------------------
+//
+// Get camera with name 'name' 
+//
+MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name)
+{
+  return static_cast<MCalibrationCam*>(fCams->FindObject(name));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get camera with name 'name' 
+//
+const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name) const
+{
+  return static_cast<MCalibrationCam*>(fCams->FindObject(name));
+}
+
+// --------------------------------------------------------------------------
+//
 // Get i-th histogram class 
 //
 MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i)
 {
-    return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th histogram class
-//
-const MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i) const
-{
-    return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get histogram class with name 'name'
+  return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th histogram class 
+//
+const MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i) const 
+{
+  return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get histogram class with name 'name' 
 //
 MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name )
@@ -478,8 +332,17 @@
 // --------------------------------------------------------------------------
 //
-// Get histogram class with name 'name'
-//
-const MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name ) const
-{
-    return static_cast<MHCalibrationCam*>(fHists->FindObject(name));
-}
+// Get histogram class with name 'name' 
+//
+const MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name ) const 
+{
+  return static_cast<MHCalibrationCam*>(fHists->FindObject(name));
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls DrawPixelContent for the current entry in fCams
+//
+void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
+{
+  return GetCam()->DrawPixelContent(num);
+}
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h	(revision 7188)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h	(revision 7189)
@@ -14,5 +14,8 @@
 #endif
 
-class TOrdCollection;
+#ifndef ROOT_TOrdCollection
+#include <TOrdCollection.h>
+#endif
+
 class MCalibrationPix;
 class MBadPixelsPix;
@@ -22,8 +25,4 @@
 class MCalibrationIntensityCam : public MParContainer, public MCamEvent
 {
-private:
-  MArrayD fOffsets;        //! Arrays of Higain-vs-LoGain fit result Offsets
-  MArrayD fSlopes;         //! Arrays of Higain-vs-LoGain fit result Slopes
-
 protected:  
   TOrdCollection *fCams;   // Array of MCalibrationCams, one per pulse colour and intensity
@@ -45,33 +44,29 @@
   Int_t CountNumEntries(const MCalibrationCam::PulserColor_t col) const;  
 
-  // Draws
-  void DrawHiLoFits();
-  void DrawPixelContent( Int_t num) const;
-  
-  // Getters
-  Bool_t GetPixelContent( Double_t &val, Int_t idx, const MGeomCam &cam,Int_t type=0) const;
-  const Int_t GetSize() const;
+  const Int_t GetSize() const  { return fCams->GetSize();  }
 
-  const Int_t            GetAverageAreas     ()            const;	 
-        MCalibrationPix &GetAverageArea      ( UInt_t i );
-  const MCalibrationPix &GetAverageArea      ( UInt_t i )  const;
-        MBadPixelsPix   &GetAverageBadArea   ( UInt_t i );
-  const MBadPixelsPix   &GetAverageBadArea   ( UInt_t i )  const;
-  const Int_t            GetAverageSectors   ()            const;
-        MCalibrationPix &GetAverageSector    ( UInt_t i );
-  const MCalibrationPix &GetAverageSector    ( UInt_t i )  const;
-        MBadPixelsPix   &GetAverageBadSector ( UInt_t i );
-  const MBadPixelsPix   &GetAverageBadSector ( UInt_t i )  const;
+  const Int_t            GetAverageAreas     ()            const   { return GetCam()->GetAverageAreas(); }
+        MCalibrationPix &GetAverageArea      ( UInt_t i )          { return GetCam()->GetAverageArea(i);  }
+  const MCalibrationPix &GetAverageArea      ( UInt_t i )  const   { return GetCam()->GetAverageArea(i);  }
+        MBadPixelsPix   &GetAverageBadArea   ( UInt_t i )          { return GetCam()->GetAverageBadArea(i); }  
+  const MBadPixelsPix   &GetAverageBadArea   ( UInt_t i )  const   { return GetCam()->GetAverageBadArea(i); }
+  const Int_t            GetAverageSectors   ()            const   { return GetCam()->GetAverageSectors();  }
+        MCalibrationPix &GetAverageSector    ( UInt_t i )          { return GetCam()->GetAverageSector(i);  }
+  const MCalibrationPix &GetAverageSector    ( UInt_t i )  const   { return GetCam()->GetAverageSector(i);  }
+        MBadPixelsPix   &GetAverageBadSector ( UInt_t i )          { return GetCam()->GetAverageBadSector(i); }
+  const MBadPixelsPix   &GetAverageBadSector ( UInt_t i )  const   { return GetCam()->GetAverageBadSector(i); }
 
-        MCalibrationCam *GetCam              ( Int_t i=-1);
-  const MCalibrationCam *GetCam              ( Int_t i=-1) const;
+	MCalibrationCam *GetCam              ( Int_t i=-1)       { 
+	return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i)); }
+  const MCalibrationCam *GetCam              ( Int_t i=-1) const {
+        return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i)); }
 
         MCalibrationCam *GetCam              ( const char *name );
   const MCalibrationCam *GetCam              ( const char *name ) const;
 
-        MHCalibrationCam *GetHist            ( Int_t i=-1);
+        MHCalibrationCam *GetHist            ( Int_t i=-1);      
   const MHCalibrationCam *GetHist            ( Int_t i=-1) const;
 
-        MHCalibrationCam *GetHist            ( const char *name );
+        MHCalibrationCam *GetHist            ( const char *name );      
   const MHCalibrationCam *GetHist            ( const char *name ) const;
 
@@ -87,5 +82,5 @@
   void  Init   ( const MGeomCam &geom );
   
-  // Prints
+   // Prints
   void   Print(Option_t *o="")         const;
 
@@ -96,7 +91,13 @@
   void  SetNumUnreliable      ( const UInt_t i,  const Int_t aidx  ) { GetCam()->SetNumUnreliable(i,aidx);       }
   void  SetPulserColor        ( const MCalibrationCam::PulserColor_t col=MCalibrationCam::kCT1) {
-                                                                GetCam()->SetPulserColor(col);            }
+                                                                       GetCam()->SetPulserColor(col);            }
+  void  SetCam( MCalibrationCam *cam, const Int_t i)                 {  fCams->PutAt(cam,i);  }
+  
+  // MCamEvent
+  Bool_t GetPixelContent( Double_t &val, Int_t idx, const MGeomCam &cam,Int_t type=0) const 
+	{ return GetCam()->GetPixelContent(val,idx,cam,type);  }
+  void DrawPixelContent( Int_t num) const;
 
-  ClassDef(MCalibrationIntensityCam, 2) // Base Container Intensity Calibration Results
+  ClassDef(MCalibrationIntensityCam, 3) // Base Container Intensity Calibration Results
 };
 
Index: /trunk/MagicSoft/Mars/mhcalib/MHCalibrationHiLoCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHCalibrationHiLoCam.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mhcalib/MHCalibrationHiLoCam.cc	(revision 7189)
@@ -81,26 +81,4 @@
 /////////////////////////////////////////////////////////////////////////////
 #include "MHCalibrationHiLoCam.h"
-#include "MHCalibrationPix.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-
-#include "MCalibrationHiLoCam.h"
-#include "MCalibrationCam.h"
-#include "MCalibrationPix.h"
-
-#include "MExtractedSignalCam.h"
-#include "MExtractedSignalPix.h"
-#include "MArrivalTimeCam.h"
-#include "MArrivalTimePix.h"
-
-#include "MGeomCam.h"
-#include "MGeomPix.h"
-
-#include "MBadPixelsIntensityCam.h"
-#include "MBadPixelsCam.h"
-#include "MBadPixelsPix.h"
 
 #include <TOrdCollection.h>
@@ -114,4 +92,30 @@
 #include <TLegend.h>
 #include <TGraph.h>
+#include <TProfile.h>
+
+#include "MHCalibrationHiLoPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MCalibrationHiLoCam.h"
+#include "MCalibrationHiLoPix.h"
+#include "MCalibrationCam.h"
+#include "MCalibrationIntensityCam.h"
+#include "MCalibrationPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimePix.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MBadPixelsIntensityCam.h"
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
 
 ClassImp(MHCalibrationHiLoCam);
@@ -123,8 +127,17 @@
 const Axis_t  MHCalibrationHiLoCam::fgLast     = 29.9;
 const Float_t MHCalibrationHiLoCam::fgProbLimit = 0.;
+const Int_t   MHCalibrationHiLoCam::fgHivsLoNbins = 90;
+const Axis_t  MHCalibrationHiLoCam::fgHivsLoFirst = 95.;
+const Axis_t  MHCalibrationHiLoCam::fgHivsLoLast  = 995.;
+const Axis_t  MHCalibrationHiLoCam::fgLowerFitLimitProfile = 480.;
+const Axis_t  MHCalibrationHiLoCam::fgUpperFitLimitProfile = 680.;
 const TString MHCalibrationHiLoCam::gsHistName  = "HiLo";
 const TString MHCalibrationHiLoCam::gsHistTitle = "HiGain vs. LoGain";
 const TString MHCalibrationHiLoCam::gsHistXTitle = "Amplification Ratio [1]";
 const TString MHCalibrationHiLoCam::gsHistYTitle = "Nr. events";
+const TString MHCalibrationHiLoCam::gsHivsLoHistName   = "HivsLo";
+const TString MHCalibrationHiLoCam::gsHivsLoHistTitle  = "High-gain vs. Low-gain Charge";
+const TString MHCalibrationHiLoCam::gsHivsLoHistXTitle = "Q High-Gain [FADC counts]";
+const TString MHCalibrationHiLoCam::gsHivsLoHistYTitle = "Q Low-Gain [FADC counts]";
 
 // --------------------------------------------------------------------------
@@ -146,5 +159,7 @@
 //
 MHCalibrationHiLoCam::MHCalibrationHiLoCam(const char *name, const char *title) 
-  : fArrTimes(NULL)
+  : fArrTimes(NULL), fHivsLoResults("Results","Fit Results high-gain vs. low-gain",
+				    200,-10.,10.,200,0.,20.),
+    fUsedLoGainSlices(0)
 {
 
@@ -163,5 +178,22 @@
   SetHistYTitle(gsHistYTitle.Data());
 
+  SetHivsLoNbins(fgHivsLoNbins);
+  SetHivsLoFirst(fgHivsLoFirst);
+  SetHivsLoLast (fgHivsLoLast );
+
+  SetLowerFitLimitProfile();
+  SetUpperFitLimitProfile();
+
+  SetHivsLoHistName  (gsHivsLoHistName  .Data());
+  SetHivsLoHistTitle (gsHivsLoHistTitle .Data());
+  SetHivsLoHistXTitle(gsHivsLoHistXTitle.Data());
+  SetHivsLoHistYTitle(gsHivsLoHistYTitle.Data());
+
   SetOscillations(kFALSE);
+  
+  fHivsLoResults.GetXaxis()->SetTitle("Offset per FADC slices [FADC cnts]");
+  fHivsLoResults.GetYaxis()->SetTitle("Gains ratio [1]");
+  fHivsLoResults.SetDirectory(0);
+
 }
 
@@ -254,4 +286,6 @@
   }
 
+  fUsedLoGainSlices = signal->GetNumUsedLoGainFADCSlices();
+
   fArrTimes = (MArrivalTimeCam*)pList->FindObject("MArrivalTimeCam");
   if (!fArrTimes)
@@ -282,4 +316,250 @@
   return kTRUE;
 }
+
+// --------------------------------------------------------------------------
+//
+// Retrieve:
+// - fRunHeader->GetNumSamplesHiGain();
+//
+// Initializes the High Gain Arrays:
+//
+// - For every entry in the expanded arrays: 
+//   * Initialize an MHCalibrationHiLoPix
+//   * Set Binning from  fNbins, fFirst and fLast
+//   * Set Binning of Abs Times histogram from  fAbsNbins, fAbsFirst and fAbsLast
+//   * Set Histgram names and titles from fHistName and fHistTitle
+//   * Set Abs Times Histgram names and titles from fAbsHistName and fAbsHistTitle
+//   * Set X-axis and Y-axis titles from fHistXTitle and fHistYTitle
+//   * Set X-axis and Y-axis titles of Abs Times Histogram from fAbsHistXTitle and fAbsHistYTitle
+//   * Call InitHists
+//
+//
+void MHCalibrationHiLoCam::InitHiGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
+{
+  
+  TProfile *h;
+
+  if (fHiGainArray->GetSize()==0)
+  {
+      for (Int_t i=0; i<npixels; i++)
+      {
+        fHiGainArray->AddAt(new MHCalibrationHiLoPix(Form("%sHiGainPix%04d",fHistName.Data(),i),
+                                                       Form("%s High Gain Pixel%04d",fHistTitle.Data(),i)),i);
+
+        MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)(*this)[i];
+
+        pix.SetNbins(fNbins);
+        pix.SetFirst(fFirst);
+        pix.SetLast (fLast);
+
+        pix.SetProbLimit(fProbLimit);
+
+        pix.SetHivsLoNbins(fHivsLoNbins);
+        pix.SetHivsLoFirst(fHivsLoFirst);
+        pix.SetHivsLoLast (fHivsLoLast);
+
+        InitHists(pix,(*fBadPixels)[i],i);
+
+	if (fCam)
+	  (*fCam)[i].SetPixId(i);
+
+        h = pix.GetHivsLo();
+
+        h->SetName (Form("H%sHiGainPix%04d",fHivsLoHistName.Data(),i));
+        h->SetTitle(Form("%s High Gain Pixel %04d",fHivsLoHistTitle.Data(),i));
+        h->SetXTitle(fHivsLoHistXTitle.Data());
+        h->SetYTitle(fHivsLoHistYTitle.Data());
+        h->SetDirectory(0);
+      }
+  }
+
+
+  if (fAverageHiGainAreas->GetSize()==0)
+  {
+    for (Int_t j=0; j<nareas; j++)
+      {
+        fAverageHiGainAreas->AddAt(new MHCalibrationHiLoPix(Form("%sHiGainArea%d",fHistName.Data(),j),
+                                                  Form("%s High Gain Area Idx %d",fHistTitle.Data(),j)),j);
+        
+        MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)GetAverageHiGainArea(j);
+        
+        pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
+        pix.SetFirst(fFirst);
+        pix.SetLast (fLast);
+        
+        pix.SetHivsLoNbins(fHivsLoNbins);
+        pix.SetHivsLoFirst(fHivsLoFirst);
+        pix.SetHivsLoLast (fHivsLoLast);
+
+        InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
+
+	if (fCam)
+	  fCam->GetAverageArea(j).SetPixId(j);
+
+        h =  pix.GetHivsLo();
+        
+        h->SetName (Form("H%sHiGainArea%d",fHivsLoHistName.Data(),j));
+        h->SetTitle(Form("%s averaged on event-by-event basis High Gain Area Idx %d",
+                         fHivsLoHistTitle.Data(), j));
+        h->SetXTitle(fHivsLoHistXTitle.Data());
+        h->SetYTitle(fHivsLoHistYTitle.Data());
+        h->SetDirectory(0);
+      }
+  }
+  
+  if (fAverageHiGainSectors->GetSize()==0)
+  {
+      for (Int_t j=0; j<nsectors; j++)
+        {
+	  fAverageHiGainSectors->AddAt(new MHCalibrationHiLoPix(Form("%sHiGainSector%02d",fHistName.Data(),j),
+                                                      Form("%s High Gain Sector %02d",fHistTitle.Data(),j)),j);
+
+          MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)GetAverageHiGainSector(j);
+
+          pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
+          pix.SetFirst(fFirst);
+          pix.SetLast (fLast);
+
+          pix.SetHivsLoNbins(fHivsLoNbins);
+          pix.SetHivsLoFirst(fHivsLoFirst);
+          pix.SetHivsLoLast (fHivsLoLast);
+          
+          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
+
+	  if (fCam)
+	    fCam->GetAverageSector(j).SetPixId(j);
+
+          h =  pix.GetHivsLo();
+          
+          h->SetName (Form("H%sHiGainSector%02d",fHivsLoHistName.Data(),j));
+          h->SetTitle(Form("%s averaged on event-by-event basis High Gain Area Sector %02d",
+                           fHivsLoHistTitle.Data(),j));
+          h->SetXTitle(fHivsLoHistXTitle.Data());
+          h->SetYTitle(fHivsLoHistYTitle.Data());
+          h->SetDirectory(0);
+      }
+  }
+}
+
+//--------------------------------------------------------------------------------------
+//
+// Return, if IsLoGain() is kFALSE 
+//
+// Retrieve:
+// - fRunHeader->GetNumSamplesHiGain();
+//
+// Initializes the Low Gain Arrays:
+//
+// - For every entry in the expanded arrays: 
+//   * Initialize an MHCalibrationHiLoPix
+//   * Set Binning from  fNbins, fFirst and fLast
+//   * Set Binning of HivsLo Times histogram from  fHivsLoNbins, fHivsLoFirst and fHivsLoLast
+//   * Set Histgram names and titles from fHistName and fHistTitle
+//   * Set HivsLo Times Histgram names and titles from fHivsLoHistName and fHivsLoHistTitle
+//   * Set X-axis and Y-axis titles from fHistXTitle and fHistYTitle
+//   * Set X-axis and Y-axis titles of HivsLo Times Histogram from fHivsLoHistXTitle and fHivsLoHistYTitle
+//   * Call InitHists
+//
+void MHCalibrationHiLoCam::InitLoGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
+{
+  if (!IsLoGain())
+    return;
+
+  TProfile *h;
+
+  if (fLoGainArray->GetSize()==0 )
+    {
+      for (Int_t i=0; i<npixels; i++)
+        {
+          fLoGainArray->AddAt(new MHCalibrationHiLoPix(Form("%sLoGainPix%04d",fHistName.Data(),i),
+                                       Form("%s Low Gain Pixel %04d",fHistTitle.Data(),i)),i);
+
+          MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)(*this)(i);
+
+          pix.SetNbins(fNbins);
+          pix.SetFirst(fFirst);
+          pix.SetLast (fLast);
+          
+          pix.SetProbLimit(fProbLimit);
+
+          pix.SetHivsLoNbins(fHivsLoNbins);
+          pix.SetHivsLoFirst(fHivsLoFirst);
+          pix.SetHivsLoLast (fHivsLoLast );
+          
+          InitHists(pix,(*fBadPixels)[i],i);
+
+          h = pix.GetHivsLo();
+          
+          h->SetName (Form("H%sLoGainPix%04d",fHivsLoHistName.Data(),i));
+          h->SetTitle(Form("%s Low Gain Pixel %04d",fHivsLoHistTitle.Data(),i));
+          h->SetXTitle(fHivsLoHistXTitle.Data());
+          h->SetYTitle(fHivsLoHistYTitle.Data());
+          h->SetDirectory(0);
+      }
+  }
+
+  if (fAverageLoGainAreas->GetSize()==0)
+    {
+      for (Int_t j=0; j<nareas; j++)
+        {
+	  fAverageLoGainAreas->AddAt(new MHCalibrationHiLoPix(Form("%sLoGainArea%d",fHistName.Data(),j),
+                                       Form("%s Low Gain Area Idx %d",fHistTitle.Data(),j)),j);
+        
+          MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)GetAverageLoGainArea(j);
+          
+          pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
+          pix.SetFirst(fFirst);
+          pix.SetLast (fLast);
+          
+          pix.SetHivsLoNbins(fHivsLoNbins);
+          pix.SetHivsLoFirst(fHivsLoFirst);
+          pix.SetHivsLoLast (fHivsLoLast );
+          
+          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
+
+          h =  pix.GetHivsLo();
+          
+          h->SetName (Form("H%sLoGainArea%02d",fHivsLoHistName.Data(),j));
+          h->SetTitle(Form("%s%s%02d",fHivsLoHistTitle.Data(),
+                           " averaged on event-by-event basis Low Gain Area Idx ",j));
+          h->SetXTitle(fHivsLoHistXTitle.Data());
+          h->SetYTitle(fHivsLoHistYTitle.Data());
+          h->SetDirectory(0);
+        }
+    }
+  
+
+  if (fAverageLoGainSectors->GetSize()==0 && IsLoGain())
+  {
+    for (Int_t j=0; j<nsectors; j++)
+      {
+        fAverageLoGainSectors->AddAt(new MHCalibrationHiLoPix(Form("%sLoGainSector%02d",fHistName.Data(),j),
+                                                        Form("%s Low Gain Sector %02d",fHistTitle.Data(),j)),j);
+        
+        MHCalibrationHiLoPix &pix = (MHCalibrationHiLoPix&)GetAverageLoGainSector(j);
+        
+        pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
+        pix.SetFirst(fFirst);
+        pix.SetLast (fLast);
+        
+        pix.SetHivsLoNbins(fHivsLoNbins);
+        pix.SetHivsLoFirst(fHivsLoFirst);
+        pix.SetHivsLoLast (fHivsLoLast);
+        
+        InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
+
+        h =  pix.GetHivsLo();
+        
+        h->SetName (Form("H%sLoGainSector%02d",fHivsLoHistName.Data(),j));
+        h->SetTitle(Form("%s%s%02d",fHivsLoHistTitle.Data(),
+                           " averaged on event-by-event basis Low Gain Area Sector ",j));
+        h->SetXTitle(fHivsLoHistXTitle.Data());
+        h->SetYTitle(fHivsLoHistYTitle.Data());
+        h->SetDirectory(0);
+      }
+  }
+}
+
+
 
 // -------------------------------------------------------------------------------
@@ -341,9 +621,19 @@
 
       const Float_t sighi = pix.GetExtractedSignalHiGain();
+
+      //      *fLog << err << sighi << "  " << siglo << endl;
       const Float_t ratio = sighi / siglo;
       
-      MHCalibrationPix &histhi = (*this)[i];
+      MHCalibrationHiLoPix &histhi = (MHCalibrationHiLoPix&)(*this)[i];
 
       histhi.FillHist(ratio);
+      histhi.FillHivsLo(sighi,siglo);
+
+      if (IsAverageing())
+	{
+	  MHCalibrationHiLoPix &histhi = (MHCalibrationHiLoPix&)GetAverageHiGainArea(aidx);
+	  histhi.FillHivsLo(sighi,siglo);
+	}
+
       fSumareahi  [aidx]   += ratio;
       fNumareahi  [aidx]   ++;
@@ -371,5 +661,7 @@
   for (Int_t j=0; j<nareas; j++)
     {
-      MHCalibrationPix &histhi = GetAverageHiGainArea(j);
+
+      MHCalibrationHiLoPix &histhi = (MHCalibrationHiLoPix&)GetAverageHiGainArea(j);
+      
       if (IsOscillations())
 	histhi.FillHistAndArray(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
@@ -390,4 +682,5 @@
     {
       MHCalibrationPix &hist = GetAverageHiGainSector(j);
+
       if (IsOscillations())
 	hist.FillHistAndArray(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
@@ -397,5 +690,7 @@
       if (IsLoGain())
 	{
+
 	  MHCalibrationPix &histlo = GetAverageLoGainSector(j);
+
 	  if (IsOscillations())
 	    histlo.FillHistAndArray(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
@@ -425,10 +720,9 @@
 
   const Int_t nareas   = fAverageHiGainAreas->GetSize();
-  const Int_t nsectors = fAverageHiGainSectors->GetSize();
 
   for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
     {
       
-      MHCalibrationPix &hist = (*this)[i];
+      MHCalibrationHiLoPix &hist = (MHCalibrationHiLoPix&)(*this)[i];
 
       if (hist.IsExcluded())
@@ -436,4 +730,21 @@
       
       CheckOverflow(hist);
+
+      TProfile *h = hist.GetHivsLo();
+      h->Fit("pol1","RQ","",fLowerFitLimitProfile,fUpperFitLimitProfile);
+
+      TF1 *fit = h->GetFunction("pol1");
+
+      const Float_t gainr  = fit->GetParameter(1) > 0.001 
+	? 1./fit->GetParameter(1) 
+	: 0.;
+      const Float_t offset = fit->GetParameter(0)/fUsedLoGainSlices;
+
+      fHivsLoResults.Fill(offset,gainr);
+      
+      MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)(*fCam)[i];
+      pix.SetOffsetPerSlice(offset);
+      pix.SetGainRatio     (gainr );
+
     }
 
@@ -472,8 +783,52 @@
   {
       for (Int_t j=0; j<nareas; j++)
-          CheckOverflow(GetAverageLoGainArea(j));
-
-      for (Int_t j=0; j<nsectors; j++)
-          CheckOverflow(GetAverageLoGainSector(j));
+        {
+	  
+	  MHCalibrationHiLoPix &hist = (MHCalibrationHiLoPix&)GetAverageHiGainArea(j);
+	  //
+	  // Check histogram overflow
+	  // 
+	  CheckOverflow(hist);
+	  
+	  TProfile *h = hist.GetHivsLo();
+	  h->Fit("pol1","RQ","",fLowerFitLimitProfile,fUpperFitLimitProfile);
+
+	  TF1 *fit = h->GetFunction("pol1");
+	  
+	  const Float_t gainr  = fit->GetParameter(1) > 0.001 
+	    ? 1./fit->GetParameter(1) 
+	    : 0.;
+	  const Float_t offset = fit->GetParameter(0)/fUsedLoGainSlices;
+	  
+	  MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)fCam->GetAverageArea(0);
+	  pix.SetOffsetPerSlice(offset);
+	  pix.SetGainRatio     (gainr );
+
+        }
+      
+      for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
+        {
+	  
+          MHCalibrationHiLoPix &hist = (MHCalibrationHiLoPix&)GetAverageHiGainSector(j);      
+          //
+          // Check histogram overflow
+          // 
+          CheckOverflow(hist);
+
+	  TProfile *h = hist.GetHivsLo();
+	  h->Fit("pol1","RQ","",fLowerFitLimitProfile,fUpperFitLimitProfile);
+
+	  TF1 *fit = h->GetFunction("pol1");
+	  
+	  const Float_t gainr  = fit->GetParameter(1) > 0.001 
+	    ? 1./fit->GetParameter(1) 
+	    : 0.;
+	  const Float_t offset = fit->GetParameter(0)/fUsedLoGainSlices;
+	  
+	  MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)fCam->GetAverageSector(0);
+	  pix.SetOffsetPerSlice(offset);
+	  pix.SetGainRatio     (gainr );
+
+        }
   }
 
@@ -680,2 +1035,42 @@
 }
 
+Int_t MHCalibrationHiLoCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+
+  Bool_t rc = kFALSE;
+
+  if (MHCalibrationCam::ReadEnv(env,prefix,print))
+    rc = kTRUE;
+   
+  if (IsEnvDefined(env, prefix, "LowerFitLimitProfile", print))
+    {
+      SetLowerFitLimitProfile(GetEnvValue(env, prefix, "LowerFitLimitProfile", fLowerFitLimitProfile));
+      rc = kTRUE;
+    }
+  
+  if (IsEnvDefined(env, prefix, "UpperFitLimitProfile", print))
+    {
+      SetUpperFitLimitProfile(GetEnvValue(env, prefix, "UpperFitLimitProfile", fUpperFitLimitProfile));
+      rc = kTRUE;
+    }
+  
+  if (IsEnvDefined(env, prefix, "HivsLoNbins", print))
+    {
+      SetHivsLoNbins(GetEnvValue(env, prefix, "HivsLoNbins", fHivsLoNbins));
+      rc = kTRUE;
+    }
+  
+  if (IsEnvDefined(env, prefix, "HivsLoFirst", print))
+    {
+      SetHivsLoFirst(GetEnvValue(env, prefix, "HivsLoFirst", fHivsLoFirst));
+      rc = kTRUE;
+    }
+  
+  if (IsEnvDefined(env, prefix, "HivsLoLast", print))
+    {
+      SetHivsLoLast(GetEnvValue(env, prefix, "HivsLoLast", fHivsLoLast));
+      rc = kTRUE;
+    }
+  
+  return rc;
+}
Index: /trunk/MagicSoft/Mars/mhcalib/MHCalibrationHiLoCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHCalibrationHiLoCam.h	(revision 7188)
+++ /trunk/MagicSoft/Mars/mhcalib/MHCalibrationHiLoCam.h	(revision 7189)
@@ -14,39 +14,76 @@
 #endif
 
-class TH1F;
+#ifndef ROOT_TH2F
+#include <TH2F.h>
+#endif
 
 class MGeomCam;
 class MArrivalTimeCam;
+class MHCalibrationHiLoPix;
 
 class MHCalibrationHiLoCam : public MHCalibrationCam
 {
 private:
-  static const Int_t   fgNbins;                      //! Default number of bins        (now set to: 900   )
-  static const Axis_t  fgFirst;                      //! Default lower histogram limit (now set to: -13.5 )
-  static const Axis_t  fgLast;                       //! Default upper histogram limit (now set to:  13.5 )
-  static const Float_t fgProbLimit;                  //! The default for fProbLimit    (now set to: 0.0)  
-  
-  static const TString gsHistName;                   //! Default Histogram names
-  static const TString gsHistTitle;                  //! Default Histogram titles
-  static const TString gsHistXTitle;                 //! Default Histogram x-axis titles
-  static const TString gsHistYTitle;                 //! Default Histogram y-axis titles
+   static const Int_t   fgNbins;                //! Default number of bins        (now set to: 900   )
+   static const Axis_t  fgFirst;                //! Default lower histogram limit (now set to: -13.5 )
+   static const Axis_t  fgLast;                 //! Default upper histogram limit (now set to:  13.5 )
+   static const Float_t fgProbLimit;            //! The default for fProbLimit    (now set to: 0.0)
 
-  MArrayD fSumareahi  ;                               //
-  MArrayD fSumsectorhi;                               //
-  MArrayI fNumareahi  ;                               //
-  MArrayI fNumsectorhi;                               //
-  MArrayD fSumarealo  ;                               //
-  MArrayD fSumsectorlo;                               //
-  MArrayI fNumarealo  ;                               //
-  MArrayI fNumsectorlo;                               //
+   static const Int_t   fgHivsLoNbins;          //! Default number of bins        (now set to: 900   )
+   static const Axis_t  fgHivsLoFirst;          //! Default lower histogram limit (now set to: -13.5 )
+   static const Axis_t  fgHivsLoLast;           //! Default upper histogram limit (now set to:  13.5 )
 
-  MArrivalTimeCam *fArrTimes;                         //! Pointer to arrival times
+   static const Axis_t  fgLowerFitLimitProfile; //! Default for fLowerFitLimitProfile    (now set to: 480. )
+   static const Axis_t  fgUpperFitLimitProfile; //! Default for fUpperFitLimitProfile    (now set to: 680. )
 
-  Bool_t ReInitHists(MParList *pList);
-  Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
-  Bool_t FinalizeHists();
-  void   FinalizeBadPixels();
+   static const TString gsHistName;          //! Default Histogram names
+   static const TString gsHistTitle;         //! Default Histogram titles
+   static const TString gsHistXTitle;        //! Default Histogram x-axis titles
+   static const TString gsHistYTitle;        //! Default Histogram y-axis titles
 
-  void   CheckOverflow( MHCalibrationPix &pix);
+   static const TString gsHivsLoHistName;    //! Default  names hi vs. lo profile
+   static const TString gsHivsLoHistTitle;   //! Default  titles hi vs. lo profile
+   static const TString gsHivsLoHistXTitle;  //! Default  x-axis titles hi vs. lo profile
+   static const TString gsHivsLoHistYTitle;  //! Default  y-axis titles hi vs. lo profile
+
+   TString fHivsLoHistName;                  //  names hi vs. lo profile
+   TString fHivsLoHistTitle;                 //  titles hi vs. lo profile
+   TString fHivsLoHistXTitle;                //  x-axis titles hi vs. lo profile
+   TString fHivsLoHistYTitle;                //  y-axis titles hi vs. lo profile
+
+   Int_t   fHivsLoNbins;                     // Number of HivsLo bins
+   Axis_t  fHivsLoFirst;                     // Lower histogram limit low gain
+   Axis_t  fHivsLoLast;                      // Upper histogram limit low gain
+
+   Axis_t  fLowerFitLimitProfile;            // Lower limit for hi-vs. logain fit
+   Axis_t  fUpperFitLimitProfile;            // Upper limit for hi-vs. logain fit
+
+   MArrayD fSumareahi  ;                     //
+   MArrayD fSumsectorhi;                     //
+   MArrayI fNumareahi  ;                     //
+   MArrayI fNumsectorhi;                     //
+   MArrayD fSumarealo  ;                     //
+   MArrayD fSumsectorlo;                     //
+   MArrayI fNumarealo  ;                     //
+   MArrayI fNumsectorlo;                     //
+
+   MArrivalTimeCam *fArrTimes;               //! Pointer to arrival times
+
+   TH2F    fHivsLoResults;                   // Results from pol1-fit
+
+   Float_t fUsedLoGainSlices;                // Used low-gain FADC slices
+   Bool_t ReInitHists(MParList *pList);
+   Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
+   Bool_t FinalizeHists();
+   void   FinalizeBadPixels();
+
+   void   InitHiGainArrays( const Int_t npix, const Int_t nareas, const Int_t nsectors );
+   void   InitLoGainArrays( const Int_t npix, const Int_t nareas, const Int_t nsectors );
+
+   void   FinalizeHivsLo (MHCalibrationHiLoPix &hist);
+
+   void   CheckOverflow( MHCalibrationPix &pix);
+
+   Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
   
 public:
@@ -55,4 +92,18 @@
   // Clone
   TObject *Clone(const char *name="") const;
+
+  TH2F &GetHivsLoResults() { return fHivsLoResults; }
+
+  void SetHivsLoHistName   ( const char *name )  { fHivsLoHistName   = name; }
+  void SetHivsLoHistTitle  ( const char *name )  { fHivsLoHistTitle  = name; }
+  void SetHivsLoHistXTitle ( const char *name )  { fHivsLoHistXTitle = name; }
+  void SetHivsLoHistYTitle ( const char *name )  { fHivsLoHistYTitle = name; }
+
+  void SetHivsLoNbins      ( const Int_t  i=fgHivsLoNbins   ) { fHivsLoNbins   = i; }
+  void SetHivsLoFirst      ( const Axis_t f=fgHivsLoFirst   ) { fHivsLoFirst   = f; }
+  void SetHivsLoLast       ( const Axis_t f=fgHivsLoLast    ) { fHivsLoLast    = f; }
+
+  void SetLowerFitLimitProfile( const Axis_t f=fgLowerFitLimitProfile ) { fLowerFitLimitProfile = f; }
+  void SetUpperFitLimitProfile( const Axis_t f=fgUpperFitLimitProfile ) { fUpperFitLimitProfile = f; }
 
   // Draw
Index: /trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc	(revision 7189)
@@ -464,5 +464,11 @@
 
       if (npix > fNumPixelsRequired)
-        GetAverageHiGainArea(j).FillHist(fSumhiarea[j]/npix);
+	{
+	   if (IsOscillations())
+	        GetAverageHiGainArea(j).FillHistAndArray(fSumhiarea[j]/npix);
+	   else
+	        GetAverageHiGainArea(j).FillHist(fSumhiarea[j]/npix);
+
+	}
     }
 
@@ -473,5 +479,10 @@
 
       if (npix > 0)
-        GetAverageHiGainSector(j).FillHist(fSumhisector [j]/npix);
+	{
+	   if (IsOscillations())
+	        GetAverageHiGainSector(j).FillHistAndArray(fSumhisector [j]/npix);
+	   else
+	        GetAverageHiGainSector(j).FillHist(fSumhisector [j]/npix);
+	}
     }
 
@@ -560,4 +571,5 @@
     {
       *fLog << dbginf << GetDescriptor() << ": ID " << GetName() 
+            << " "<<pix.GetPixId()
             << " Mean: "         << hist.GetMean    ()
             << " MeanErr: "      << hist.GetMeanErr ()
Index: /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h	(revision 7188)
+++ /trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h	(revision 7189)
@@ -169,5 +169,5 @@
   void  SimulateGausEvents(const Float_t mean, const Float_t sigma, const Int_t nevts=4096);     // *MENU*
 
-  ClassDef(MHGausEvents, 3) // Base class for events with Gaussian distributed values
+  ClassDef(MHGausEvents, 4) // Base class for events with Gaussian distributed values
 };
 
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 7189)
@@ -74,4 +74,5 @@
 #include "MCalibrationIntensityRelTimeCam.h"
 #include "MCalibrationIntensityQECam.h"
+#include "MCalibrationIntensityConstCam.h"
 #include "MBadPixelsIntensityCam.h"
 
@@ -268,4 +269,5 @@
     MCalibrationIntensityBlindCam       iblcam;
     MCalibrationIntensityRelTimeCam     itmcam;
+    MCalibrationIntensityConstCam       icncam;
     MBadPixelsIntensityCam              ibdcam;
 
@@ -299,4 +301,5 @@
         interlacedcont.Add(&itmcam);
         interlacedcont.Add(&ibdcam);
+        interlacedcont.Add(&icncam);
         interlacedcont.Add(&hchacam);
 	if (IsUseBlindPixel())
@@ -317,6 +320,7 @@
     calibcont.Add(&qecam);
     calibcont.Add(&bndcam);
-    calibcont.Add(&pind);
     calibcont.Add(&tmcam);
+    if (IsUseBlindPixel())
+        calibcont.Add(&bndcam);
 
     if (!ReadCalibration(calibcont, badpix, extractor2, extractor3, geom))
@@ -362,4 +366,5 @@
     // This is necessary for the case in which it is not in the files
     MBadPixelsCam badcam;
+    icncam.SetBadPixels(&badpix);
 
     // Setup Parlist
@@ -524,4 +529,6 @@
 
     MCalibrationChargeCalc  chcalc;
+    chcalc.SetExtractor(extractor3);
+
     MCalibrationRelTimeCalc recalc;
     MCalibCalcFromPast      pacalc;
@@ -570,5 +577,5 @@
     // MHCamEvent evt3(4, "PedPhot",    "Calibrated Pedestal;;P [phe]");
     MHCamEvent evt4(  5, "PedRMS",     "Calibrated RMS from Extractor applied to ped.;;\\sigma_{p} [phe]");
-    MHCamEvent evt5(  0, "Interp'd",   "Interpolated Signal per area scale A/A_{0};;S [phe]");
+    MHCamEvent evt5(  0, "Interp'd",   "Interpolated Signal scaled with A/A_{0};;S [phe]");
     MHCamEvent evt6(102, "Unsuitable", "Fraction of unsuitable events per Pixel;;[1]");
     MHCamEvent evt7(  6, "Times",      "Calibrated Arrival Time;;T [fadc sl]");
@@ -577,14 +584,14 @@
     evt6.SetThreshold();
 
-    MFillH fill0(&evt0, "MPedestalFundamental",       "FillPedFLG");
-    MFillH fill1(&evt1, "MPedestalFromExtractorRndm", "FillPedRmsFLG");
-    MFillH fill2(&evt2, "MExtractedSignalCam",        "FillExtracted");
+    MFillH fill0(&evt0, "MPedestalFundamental",          "FillPedFLG");
+    MFillH fill1(&evt1, "MPedestalFromExtractorRndm",    "FillPedRmsFLG");
+    MFillH fill2(&evt2, "MExtractedSignalCam",           "FillExtracted");
     // MFillH fill3(&evt3, "MPedPhotFundamental",  "FillPedPhot");
-    MFillH fill4(&evt4, "MPedPhotFromExtractorRndm",  "FillPedRMS");
-    MFillH fill5(&evt5, "MSignalCam",                 "FillInterpolated");
-    MFillH fill6(&evt6, "MBadPixelsCam",              "FillUnsuitable");
-    MFillH fill7(&evt7, "MSignalCam",                 "FillTimes");
-    MFillH fill8(&evt8, "MCalibConstCam",             "FillConv");
-    MFillH fill9(&evt9, "MSignalCam",                 "FillPulse");
+    MFillH fill4(&evt4, "MPedPhotFromExtractorRndm",     "FillPedRMS");
+    MFillH fill5(&evt5, "MSignalCam",                    "FillInterpolated");
+    MFillH fill6(&evt6, "MBadPixelsCam",                 "FillUnsuitable");
+    MFillH fill7(&evt7, "MSignalCam",                    "FillTimes");
+    MFillH fill8(&evt8, "MCalibrationIntensityConstCam", "FillConv");
+    MFillH fill9(&evt9, "MSignalCam",                    "FillPulse");
 
     MTaskEnv fillflorian("FinalFantasy");
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 7189)
@@ -1838,4 +1838,5 @@
     MCalibrationChargeCalc   calcalc;
     MCalibrationRelTimeCalc  timecalc;
+    calcalc.SetExtractor(fExtractor);
     calcalc.SetOutputFile("");
     timecalc.SetOutputFile("");
Index: /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 7188)
+++ /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 7189)
@@ -174,11 +174,4 @@
     }
 
-    TObject *o = file.Get("ExtractSignal");
-    if (o && !o->InheritsFrom(MExtractor::Class()))
-    {
-        *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
-        return NULL;
-    }
-
     if (file.FindKey("MBadPixelsCam"))
     {
@@ -190,4 +183,14 @@
     }
 
+    if (fExtractor)
+        return fExtractor;
+
+    TObject *o=0;
+    o = file.Get("ExtractSignal");
+    if (o && !o->InheritsFrom(MExtractor::Class()))
+    {
+        *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
+        return NULL;
+    }
     return o ? (MExtractor*)o->Clone("ExtractSignal") : NULL;
 }
