Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc	(revision 4902)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc	(revision 4903)
@@ -260,5 +260,5 @@
   }
 
-  MHGausEvents::Clear();
+  MHCalibrationPix::Clear();
   return;
 }
@@ -266,5 +266,5 @@
 // --------------------------------------------------------------------------
 //
-// Empty function to overload MHGausEvents::Reset()
+// Empty function to overload MHCalibrationChargePix::Reset()
 //
 void MHCalibrationChargeBlindPix::Reset()
@@ -385,5 +385,5 @@
     }
 
-  MHGausEvents::InitBins();
+  MHCalibrationPix::InitBins();
   
   return kTRUE;
@@ -1164,15 +1164,15 @@
 
   oldpad->cd(2);
-  MHGausEvents::Draw("fourierevents");
-}
-
-
-
-
-
-
-
-
-
-
-
+  MHCalibrationPix::Draw("fourierevents");
+}
+
+
+
+
+
+
+
+
+
+
+
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc	(revision 4902)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc	(revision 4903)
@@ -26,5 +26,5 @@
 // MHCalibrationChargeCam                                               
 //
-// Fills the extracted signals of MExtractedSignalCam into the MHGausEvents-classes 
+// Fills the extracted signals of MExtractedSignalCam into the MHCalibrationPix-classes 
 // MHCalibrationChargeHiGainPix and MHCalibrationChargeLoGainPix for every:
 //
@@ -54,13 +54,13 @@
 // the fit is declared valid.
 // Otherwise, the fit is repeated within ranges of the previous mean 
-// +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
+// +- MHCalibrationPix::fPickupLimit (default: 5) sigma (see MHCalibrationPix::RepeatFit())
 // In case this does not make the fit valid, the histogram means and RMS's are 
-// taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
+// taken directly (see MHCalibrationPix::BypassFit()) and the following flags are set:
 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) or  
 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) and 
 // - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun   ) 
 // 
-// Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas 
-// from the mean are counted as Pickup events (stored in MHGausEvents::fPickup) 
+// Outliers of more than MHCalibrationPix::fPickupLimit (default: 5) sigmas 
+// from the mean are counted as Pickup events (stored in MHCalibrationPix::fPickup) 
 //
 // Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC 
@@ -120,7 +120,7 @@
 #include "MHCalibrationChargeLoGainPix.h"
 #include "MHCalibrationChargePix.h"
-
-#include "MCalibrationCam.h"
-
+#include "MHCalibrationPix.h"
+
+#include "MCalibrationIntensityCam.h"
 #include "MCalibrationChargeCam.h"
 #include "MCalibrationChargePix.h"
@@ -128,6 +128,4 @@
 #include "MGeomCam.h"
 #include "MGeomPix.h"
-
-#include "MHGausEvents.h"
 
 #include "MBadPixelsCam.h"
@@ -260,15 +258,20 @@
   }
 
-  fCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
-  if (!fCam)
-    {
-      fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationChargeCam"));
+  fIntensCam = (MCalibrationIntensityCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityChargeCam"));
+  if (fIntensCam)
+    *fLog << inf << "Found MCalibrationIntensityChargeCam ... " << endl;
+  else
+    {
+      fCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
       if (!fCam)
         {
-          gLog << err << "Cannot find nor create MCalibrationChargeCam ... abort." << endl;
-          return kFALSE;
+          fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationChargeCam"));
+          if (!fCam)
+            {
+              *fLog << err << "Cannot find nor create MCalibrationChargeCam ... abort." << endl;
+              return kFALSE;
+            }
+          fCam->Init(*fGeom);
         }
-      else 
-        fCam->Init(*fGeom);
     }
 
@@ -278,25 +281,32 @@
   fLastLoGain  = signal->GetLastUsedSliceLoGain();
 
+  /*
   const Float_t numhigain = signal->GetNumUsedHiGainFADCSlices();
   const Float_t numlogain = signal->GetNumUsedLoGainFADCSlices();  
 
-  if (fCam->GetNumHiGainFADCSlices() == 0.)
-    fCam->SetNumHiGainFADCSlices ( numhigain );
-  else if (fCam->GetNumHiGainFADCSlices() != numhigain)
-    {
-      *fLog << err << GetDescriptor() 
-            << ": Number of High Gain FADC extraction slices has changed, abort..." << endl;
-      return kFALSE;
-    }
-
-  if (fCam->GetNumLoGainFADCSlices() == 0.)
-    fCam->SetNumLoGainFADCSlices ( numlogain );
-  else if (fCam->GetNumLoGainFADCSlices() != numlogain)
-    {
-      *fLog << err << GetDescriptor() 
-            << ": Number of Low Gain FADC extraction slices has changes, abort..." << endl;
-      return kFALSE;
-    }
-
+
+  if (fCam)
+    {
+      if (fCam->GetNumHiGainFADCSlices() == 0.)
+        fCam->SetNumHiGainFADCSlices ( numhigain );
+      else if (fCam->GetNumHiGainFADCSlices() != numhigain)
+        {
+          *fLog << err << GetDescriptor() 
+                << ": Number of High Gain FADC extraction slices has changed, abort..." << endl;
+          return kFALSE;
+        }
+      
+      if (fCam->GetNumLoGainFADCSlices() == 0.)
+        fCam->SetNumLoGainFADCSlices ( numlogain );
+      else if (fCam->GetNumLoGainFADCSlices() != numlogain)
+        {
+          *fLog << err << GetDescriptor() 
+                << ": Number of Low Gain FADC extraction slices has changes, abort..." << endl;
+          return kFALSE;
+        }
+    }
+  */
+
+  
   const Int_t npixels  = fGeom->GetNumPixels();
   const Int_t nsectors = fGeom->GetNumSectors();
@@ -311,5 +321,5 @@
       for (Int_t i=0; i<npixels; i++)
       {
-        (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
+        (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix("ChargeHiGainPix");
         MHCalibrationChargePix &pix = (MHCalibrationChargePix&)(*this)[i];
         pix.SetAbsTimeNbins(higainsamples);
@@ -317,5 +327,4 @@
         InitHists((*this)[i],(*fBadPixels)[i],i);
       }
-      fHiGainOverFlow.Set(npixels);
   }
 
@@ -326,6 +335,6 @@
       for (Int_t i=0; i<npixels; i++)
         {
-          (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
-          MHGausEvents &lopix = (*this)(i);
+          (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix("ChargeLoGainPix");
+          MHCalibrationPix &lopix = (*this)(i);
           //
           // Adapt the range for the case, the intense blue is used:
@@ -345,5 +354,4 @@
           InitHists(lopix,(*fBadPixels)[i],i);
       }
-      fLoGainOverFlow.Set(npixels);  
   }
 
@@ -355,5 +363,5 @@
       {
         (*fAverageHiGainAreas)[j] = 
-          new MHCalibrationChargeHiGainPix("AverageHiGainArea",
+          new MHCalibrationChargeHiGainPix("ChargeAverageHiGainArea",
                                            "Average HiGain FADC sums area idx ");
 
@@ -373,5 +381,5 @@
           {
             hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
-            InitHists(hist,fCam->GetAverageBadArea(j),j);
+            InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
           }
       }
@@ -386,5 +394,5 @@
         {
 	  (*fAverageLoGainAreas)[j] = 
-            new MHCalibrationChargeLoGainPix("AverageLoGainArea",
+            new MHCalibrationChargeLoGainPix("ChargeAverageLoGainArea",
                                              "Average LoGain FADC sums of pixel area idx ");
 
@@ -418,6 +426,6 @@
         else
           {
-            hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
-            InitHists(hist,fCam->GetAverageBadArea(j),j);
+            hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis Low Gain Area Idx ");
+            InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
           }
         }
@@ -431,15 +439,14 @@
       {
 	  (*fAverageHiGainSectors)[j] = 
-            new MHCalibrationChargeHiGainPix("AverageHiGainSector",
-                                             "Average HiGain FADC sums of pixel sector ");
+            new MHCalibrationChargeHiGainPix("ChargeAverageHiGainSector",
+                                             "Averaged HiGain Signals Sector ");
 
           MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
 
-          hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Sector ");
+          hist.GetHGausHist()->SetTitle("Signals averaged on event-by-event basis HiGain Sector ");
           hist.SetNbins(fAverageNbins);
           hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Sector ");
 
-          InitHists(hist,fCam->GetAverageBadSector(j),j);
-
+          InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
       }
   }
@@ -452,10 +459,10 @@
       {
 	  (*fAverageLoGainSectors)[j] = 
-            new MHCalibrationChargeLoGainPix("AverageLoGainSector",
-                                             "Average LoGain FADC sums of pixel sector ");
+            new MHCalibrationChargeLoGainPix("ChargeAverageLoGainSector",
+                                             "Average LoGain Signals Sector ");
 
           MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
 
-          hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Sector ");
+          hist.GetHGausHist()->SetTitle("Signals averaged on event-by-event basis LoGain Sector ");
           hist.SetNbins(fgAverageNbinsLoGain);
           
@@ -477,5 +484,5 @@
           hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Sector ");
 
-          InitHists(hist,fCam->GetAverageBadSector(j),j);
+          InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
       }
   }
@@ -565,7 +572,5 @@
       const Int_t   sathi = (Int_t)pix.GetNumHiGainSaturated();
 
-      if (!histhi.FillHistAndArray(sumhi))
-        fHiGainOverFlow[i]++;
-
+      histhi.FillHistAndArray(sumhi);
       histhi.SetSaturated(sathi); 
 
@@ -585,7 +590,5 @@
           const Int_t   satlo = (Int_t)pix.GetNumLoGainSaturated();
           
-          if (!histlo.FillHistAndArray(sumlo))
-            fLoGainOverFlow[i]++;
-
+          histlo.FillHistAndArray(sumlo);
           histlo.SetSaturated(satlo); 
           
@@ -706,10 +709,12 @@
       
       MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
-      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)(*fCam)[i];
-      MBadPixelsPix          &bad    = (*fBadPixels)[i];
       
       if (histhi.IsExcluded())
         continue;
       
+      MCalibrationChargePix  &pix    = fIntensCam 
+        ? (MCalibrationChargePix&)(*fIntensCam)[i] 
+        : (MCalibrationChargePix&)(*fCam)[i];
+
       if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
         {
@@ -719,8 +724,20 @@
         }
 
-      if (fHiGainOverFlow[i])
+      MBadPixelsPix          &bad    = (*fBadPixels)[i];
+
+      Stat_t overflow = histhi.GetHGausHist()->GetBinContent(histhi.GetHGausHist()->GetNbinsX()+1);
+      if (overflow > 0.1)
         {
           *fLog << warn << GetDescriptor()
-                << ": Hi-Gain Histogram Overflow occurred " << fHiGainOverFlow[i] 
+                << ": HiGain Histogram Overflow occurred " << overflow 
+                << " times in pixel: " << i << " (without saturation!) " << endl;
+          bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow ); 
+        }
+
+      overflow = histhi.GetHGausHist()->GetBinContent(0);
+      if (overflow > 0.1)
+        {
+          *fLog << warn << GetDescriptor()
+                << ": HiGain Histogram Underflow occurred " << overflow
                 << " times in pixel: " << i << " (without saturation!) " << endl;
           bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow ); 
@@ -748,13 +765,25 @@
           }
         
-        if (fLoGainOverFlow[i] > 1)
+        Stat_t overflow = histlo.GetHGausHist()->GetBinContent(histlo.GetHGausHist()->GetNbinsX()+1);
+        if (overflow > 0.1)
           {
             *fLog << warn << GetDescriptor()
-                  << ": Lo-Gain Histogram Overflow occurred " << fLoGainOverFlow[i] 
+                  << ": Lo-Gain Histogram Overflow occurred " << overflow
+                  << " times in pixel: " << i << " (without saturation!) " << endl;
+            bad.SetUncalibrated( MBadPixelsPix::kLoGainOverFlow ); 
+          }
+
+        overflow = histlo.GetHGausHist()->GetBinContent(0);
+        if (overflow > 0.1)
+          {
+            *fLog << warn << GetDescriptor()
+                  << ": Lo-Gain Histogram Underflow occurred " << overflow
                   << " times in pixel: " << i << " (without saturation!) " << endl;
             bad.SetUncalibrated( MBadPixelsPix::kLoGainOverFlow ); 
           }
         
-        MCalibrationChargePix &pix    = (MCalibrationChargePix&)(*fCam)[i];
+        MCalibrationChargePix &pix = fIntensCam 
+          ? (MCalibrationChargePix&)(*fIntensCam)[i]
+          : (MCalibrationChargePix&)(*fCam)[i];
         
         if (pix.IsHiGainSaturation())
@@ -766,7 +795,8 @@
       
       MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);      
-      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)fCam->GetAverageArea(j);
-      MBadPixelsPix          &bad    = fCam->GetAverageBadArea(j);
-      
+      MCalibrationChargePix  &pix    = fIntensCam 
+        ? (MCalibrationChargePix&)fIntensCam->GetAverageArea(j)
+        : (MCalibrationChargePix&)fCam->GetAverageArea(j);
+
       if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
         {
@@ -775,4 +805,8 @@
           continue;
         }
+
+      MBadPixelsPix          &bad    = fIntensCam 
+        ? fIntensCam->GetAverageBadArea(j)
+        : fCam->GetAverageBadArea(j);
 
       FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
@@ -784,7 +818,5 @@
         
         MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);      
-        MCalibrationChargePix  &pix    = (MCalibrationChargePix&)fCam->GetAverageArea(j);
-        MBadPixelsPix          &bad    = fCam->GetAverageBadArea(j);      
-        
+
         if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
           {
@@ -794,6 +826,16 @@
           }
         
+        MCalibrationChargePix  &pix    = fIntensCam
+          ? (MCalibrationChargePix&)fIntensCam->GetAverageArea(j) 
+          : (MCalibrationChargePix&)fCam->GetAverageArea(j) ;
+
         if (pix.IsHiGainSaturation())
-          FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
+          {
+            MBadPixelsPix          &bad    = fIntensCam
+              ? fIntensCam->GetAverageBadArea(j)  
+              : fCam->GetAverageBadArea(j);      
+            FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
+          }
+        
       }
   
@@ -802,6 +844,7 @@
       
       MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);      
-      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)fCam->GetAverageSector(j);
-      MBadPixelsPix          &bad    = fCam->GetAverageBadSector(j);      
+      MCalibrationChargePix  &pix    = fIntensCam
+        ? (MCalibrationChargePix&)fIntensCam->GetAverageSector(j)  
+        : (MCalibrationChargePix&)fCam->GetAverageSector(j);
 
       if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
@@ -811,4 +854,8 @@
           continue;
         }
+
+      MBadPixelsPix          &bad    = fIntensCam 
+        ? fIntensCam->GetAverageBadSector(j)
+        : fCam->GetAverageBadSector(j);      
 
       FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
@@ -820,6 +867,7 @@
         
         MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);      
-        MCalibrationChargePix  &pix    = (MCalibrationChargePix&)fCam->GetAverageSector(j);
-        MBadPixelsPix          &bad    = fCam->GetAverageBadSector(j);        
+        MBadPixelsPix          &bad    = fIntensCam
+          ? fIntensCam->GetAverageBadSector(j)
+          : fCam->GetAverageBadSector(j);        
         
         if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
@@ -831,4 +879,8 @@
           }
         
+        MCalibrationChargePix  &pix    = fIntensCam 
+          ? (MCalibrationChargePix&)fIntensCam->GetAverageSector(j)
+          : (MCalibrationChargePix&)fCam->GetAverageSector(j);
+
         if (pix.IsHiGainSaturation())
           FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
@@ -838,15 +890,18 @@
   // Perform the fitting for the High Gain (done in MHCalibrationCam)
   //
-  FitHiGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
+  FitHiGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
+                  *fBadPixels,
                   MBadPixelsPix::kHiGainNotFitted,
                   MBadPixelsPix::kHiGainOscillating);
+  
   //
   // Perform the fitting for the Low Gain (done in MHCalibrationCam)
   //
   if (fLoGain)
-    FitLoGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
+    FitLoGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
+                    *fBadPixels,
                     MBadPixelsPix::kLoGainNotFitted,
                     MBadPixelsPix::kLoGainOscillating);
-      
+
   return kTRUE;
 }
@@ -908,5 +963,5 @@
       
       MBadPixelsPix    &bad    = (*fBadPixels)[i];
-      MCalibrationPix  &pix    = (*fCam)[i];
+      MCalibrationPix  &pix    = fIntensCam ? (*fIntensCam)[i] : (*fCam)[i];
 
       if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
@@ -941,5 +996,5 @@
 // --------------------------------------------------------------------------
 //
-// Calls MHGausEvents::DrawClone() for pixel idx
+// Calls MHCalibrationPix::DrawClone() for pixel idx
 //
 void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
@@ -1077,4 +1132,5 @@
   null->SetDirectory(NULL);
   null->SetBit(kCanDelete);
+  null->SetStats(kFALSE);
   //
   // set the labels bigger
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.cc	(revision 4902)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.cc	(revision 4903)
@@ -154,5 +154,5 @@
 {
 
-  MHGausEvents::InitBins();
+  MHCalibrationPix::InitBins();
 
   fHAbsTime.  SetBins(fAbsTimeNbins,  fAbsTimeFirst,  fAbsTimeLast);
@@ -339,5 +339,5 @@
 //
 // "": displays the fHGausHist with fits and fHRmsCharge
-// "all": executes additionally MHGausEvents::Draw(), with option "fourierevents"
+// "all": executes additionally MHCalibrationPix::Draw(), with option "fourierevents"
 //
 void MHCalibrationChargePINDiode::Draw(const Option_t *opt)
@@ -391,8 +391,8 @@
 
   oldpad->cd(2);
-  MHGausEvents::Draw("fourierevents");
-}
-
-
-
-
+  MHCalibrationPix::Draw("fourierevents");
+}
+
+
+
+
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.h	(revision 4902)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.h	(revision 4903)
@@ -10,5 +10,4 @@
 class MExtractedSignalPINDiode;
 class MCalibrationChargePINDiode;
-
 class MHCalibrationChargePINDiode : public MHCalibrationChargePix
 {
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimeCam.cc	(revision 4902)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimeCam.cc	(revision 4903)
@@ -27,5 +27,5 @@
 //                                                                        
 // Fills the extracted relative arrival times of MArrivalTimeCam into 
-// the MHGausEvents-classes MHCalibrationRelTimePix for every:
+// the MHCalibrationPix-classes MHCalibrationRelTimePix for every:
 //
 // - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray  
@@ -52,12 +52,12 @@
 // the fit is declared valid.
 // Otherwise, the fit is repeated within ranges of the previous mean 
-// +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
+// +- MHCalibrationPix::fPickupLimit (default: 5) sigma (see MHCalibrationPix::RepeatFit())
 // In case this does not make the fit valid, the histogram means and RMS's are 
-// taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
+// taken directly (see MHCalibrationPix::BypassFit()) and the following flags are set:
 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kRelTimeNotFitted ) and
 // - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun    ) 
 // 
-// Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas 
-// from the mean are counted as Pickup events (stored in MHGausEvents::fPickup) 
+// Outliers of more than MHCalibrationPix::fPickupLimit (default: 5) sigmas 
+// from the mean are counted as Pickup events (stored in MHCalibrationPix::fPickup) 
 //
 // The class also fills arrays with the signal vs. event number, creates a fourier 
@@ -88,4 +88,6 @@
 #include "MHCalibrationRelTimePix.h"
 
+#include "MHCalibrationPix.h"
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -93,5 +95,8 @@
 #include "MParList.h"
 
+#include "MCalibrationIntensityRelTimeCam.h"
+
 #include "MCalibrationRelTimeCam.h"
+#include "MCalibrationRelTimePix.h"
 #include "MCalibrationPix.h"
 
@@ -104,6 +109,4 @@
 #include "MBadPixelsCam.h"
 #include "MBadPixelsPix.h"
-
-#include "MHGausEvents.h"
 
 ClassImp(MHCalibrationRelTimeCam);
@@ -163,18 +166,21 @@
 {
 
-  
-  fCam = (MCalibrationCam*)pList->FindObject("MCalibrationRelTimeCam");
-  if (!fCam)
-    {
-      fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationRelTimeCam"));
+  fIntensCam = (MCalibrationIntensityCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityRelTimeCam"));
+  if (fIntensCam)
+    *fLog << inf << "Found MCalibrationIntensityRelTimeCam ... " << endl;
+  else
+    {
+      fCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
       if (!fCam)
         {
-          gLog << err << "Cannot find nor create MCalibrationRelTimeCam ... abort." << endl;
-          return kFALSE;
-        }
-      else 
-        fCam->Init(*fGeom);
-    }
-  
+          fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationRelTimeCam"));
+          if (!fCam)
+            {
+              *fLog << err << "Cannot find nor create MCalibrationRelTimeCam ... abort." << endl;
+              return kFALSE;
+            }
+          fCam->Init(*fGeom);
+        }
+    }
 
   MArrivalTimeCam *signal = (MArrivalTimeCam*)pList->FindObject("MArrivalTimeCam");
@@ -219,11 +225,24 @@
       {
         (*fAverageHiGainAreas)[j] = 
-          new MHCalibrationRelTimePix("MHCalibrationRelTimeAverageAreaHiGain",
+          new MHCalibrationRelTimePix("RelTimeAverageHiGainArea",
                                       "Average Rel. Arr. Times Hi-Gain Area Idx ");
 
-        GetAverageHiGainArea(j).GetHGausHist()->SetTitle("Rel. Arr. Times HiGain Area Idx ");
-        GetAverageHiGainArea(j).SetNbins(fAverageNbins);
-
-        InitHists(GetAverageHiGainArea(j),fCam->GetAverageBadArea(j),j);
+        MHCalibrationRelTimePix &hist = (MHCalibrationRelTimePix&)GetAverageHiGainArea(j);
+
+        hist.SetNbins(fAverageNbins);
+        hist.GetHGausHist()->SetTitle("Rel. Arr. Times average HiGain Area Idx ");
+
+        if (fGeom->InheritsFrom("MGeomCamMagic"))
+          {
+            hist.GetHGausHist()->SetTitle(Form("%s%s%s","Signal averaged on event-by-event basis ",
+                                               j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
+            hist.InitBins();
+            hist.SetEventFrequency(fPulserFrequency);
+          }
+        else
+          {
+            hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
+            InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
+          }
       }
   }
@@ -236,11 +255,22 @@
       {
         (*fAverageLoGainAreas)[j] = 
-          new MHCalibrationRelTimePix("MHCalibrationRelTimeAverageAreaLoGain",
+          new MHCalibrationRelTimePix("RelTimeAverageAreaLoGain",
                                       "Average Rel. Arr. Times Lo-Gain Area Idx ");
 
-        GetAverageLoGainArea(j).GetHGausHist()->SetTitle("Rel. Arr. Times LoGain Area Idx ");
-        GetAverageLoGainArea(j).SetNbins(fAverageNbins);
-
-        InitHists(GetAverageLoGainArea(j),fCam->GetAverageBadArea(j),j);
+        MHCalibrationRelTimePix &hist = (MHCalibrationRelTimePix&)GetAverageLoGainArea(j);
+        hist.SetNbins(fAverageNbins);
+
+        if (fGeom->InheritsFrom("MGeomCamMagic"))
+          {
+            hist.GetHGausHist()->SetTitle(Form("%s%s%s","Rel. Arr. Times averaged on event-by-event basis ",
+                                               j==0 ? "Inner Pixels " : "Outer Pixels ","Low Gain Runs: "));
+            hist.InitBins();
+            hist.SetEventFrequency(fPulserFrequency);
+          }
+        else
+          {
+            hist.GetHGausHist()->SetTitle("Rel. Arr. Times averaged on event-by-event basis Low Gain Area Idx ");
+            InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
+          }
       }
   }
@@ -253,11 +283,13 @@
         {
 	  (*fAverageHiGainSectors)[j] = 
-            new MHCalibrationRelTimePix("MHCalibrationRelTimeAverageSectorHiGain",
-                                        "Average Rel. Arr. Times Hi-Gain Sector ");
+            new MHCalibrationRelTimePix("RelTimeAverageSectorHiGain",
+                                        "Average HiGain Rel. Arr. Times Sector ");
           
-          GetAverageHiGainSector(j).GetHGausHist()->SetTitle("Rel. Arr. Times HiGain Sector ");
-          GetAverageHiGainSector(j).SetNbins(fAverageNbins);
+          MHCalibrationRelTimePix &hist = (MHCalibrationRelTimePix&)GetAverageHiGainSector(j);
+
+          hist.GetHGausHist()->SetTitle("Rel. Arr. Times averaged on event-by-event basis HiGain Sector ");
+          hist.SetNbins(fAverageNbins);
           
-          InitHists(GetAverageHiGainSector(j),fCam->GetAverageBadSector(j),j);
+          InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
       }
   }
@@ -270,12 +302,13 @@
         {
 	  (*fAverageLoGainSectors)[j] = 
-            new MHCalibrationRelTimePix("MHCalibrationRelTimeAverageSectorLoGain",
-                                        "Average Rel. Arr. Times Lo-Gain Sector ");
+            new MHCalibrationRelTimePix("RelTimeAverageSectorLoGain",
+                                        "Average LoGain Rel. Arr. Times Sector ");
           
-          GetAverageLoGainSector(j).GetHGausHist()->SetTitle("Rel. Arr. Times LoGain Sector ");
-          GetAverageLoGainSector(j).SetNbins(fAverageNbins);
+          MHCalibrationRelTimePix &hist = (MHCalibrationRelTimePix&)GetAverageLoGainSector(j);
+
+          hist.GetHGausHist()->SetTitle("Rel. Arr. Times averaged on event-by-event basis LoGain Sector ");
+          hist.SetNbins(fAverageNbins);
           
-          InitHists(GetAverageLoGainSector(j),fCam->GetAverageBadSector(j),j);
-          
+          InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
         }
     }
@@ -338,6 +371,6 @@
     {
 
-      MHGausEvents &histhi = (*this)[i];
-      MHGausEvents &histlo = (*this)(i);
+      MHCalibrationPix &histhi = (*this)[i];
+      MHCalibrationPix &histlo = (*this)(i);
 
       if (histhi.IsExcluded())
@@ -372,10 +405,10 @@
   for (Int_t j=0; j<nareas; j++)
     {
-      MHGausEvents &histhi = GetAverageHiGainArea(j);
+      MHCalibrationPix &histhi = GetAverageHiGainArea(j);
       histhi.FillHistAndArray(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
 
       if (fLoGain)
         {
-          MHGausEvents &histlo = GetAverageLoGainArea(j);
+          MHCalibrationPix &histlo = GetAverageLoGainArea(j);
           histlo.FillHistAndArray(fNumarealo[j] == 0 ? 0. : fSumarealo[j]/fNumarealo[j]);
         }
@@ -384,10 +417,10 @@
   for (Int_t j=0; j<nsectors; j++)
     {
-      MHGausEvents &histhi = GetAverageHiGainSector(j);
+      MHCalibrationPix &histhi = GetAverageHiGainSector(j);
       histhi.FillHistAndArray(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
 
       if (fLoGain)
         {
-          MHGausEvents &histlo = GetAverageLoGainSector(j);
+          MHCalibrationPix &histlo = GetAverageLoGainSector(j);
           histlo.FillHistAndArray(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
         }
@@ -415,7 +448,11 @@
         continue;
       
+      MCalibrationRelTimePix  &pix    = fIntensCam 
+        ? (MCalibrationRelTimePix&)(*fIntensCam)[i] 
+        : (MCalibrationRelTimePix&)(*fCam)[i];
+
       if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
         {
-          (*fCam)[i].SetHiGainSaturation();
+          pix.SetHiGainSaturation();
           histhi.SetExcluded();
         }
@@ -423,7 +460,23 @@
         if (fLoGain)
           (*this)(i).SetExcluded();
-      
-    }
-
+
+      Stat_t overflow = histhi.GetHGausHist()->GetBinContent(histhi.GetHGausHist()->GetNbinsX()+1);
+      if (overflow > 0.1)
+        {
+          *fLog << warn << GetDescriptor()
+                << ": HiGain Histogram Overflow occurred " << overflow 
+                << " times in pixel: " << i << " (without saturation!) " << endl;
+          //          bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow ); 
+        }
+
+      overflow = histhi.GetHGausHist()->GetBinContent(0);
+      if (overflow > 0.1)
+        {
+          *fLog << warn << GetDescriptor()
+                << ": HiGain Histogram Underflow occurred " << overflow
+                << " times in pixel: " << i << " (without saturation!) " << endl;
+          //          bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow ); 
+        }
+    }
 
   for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
@@ -434,5 +487,8 @@
       if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
         {
-          fCam->GetAverageArea(j).SetHiGainSaturation();
+          MCalibrationRelTimePix  &pix    = fIntensCam 
+            ? (MCalibrationRelTimePix&)fIntensCam->GetAverageArea(j)
+            : (MCalibrationRelTimePix&)fCam->GetAverageArea(j);
+          pix.SetHiGainSaturation();
           histhi.SetExcluded();
         }
@@ -447,8 +503,11 @@
       
       MHCalibrationRelTimePix &histhi = (MHCalibrationRelTimePix&)GetAverageHiGainSector(j);      
+      MCalibrationRelTimePix  &pix    = fIntensCam
+        ? (MCalibrationRelTimePix&)fIntensCam->GetAverageSector(j)  
+        : (MCalibrationRelTimePix&)fCam->GetAverageSector(j);
 
       if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
         {
-          fCam->GetAverageSector(j).SetHiGainSaturation();
+          pix.SetHiGainSaturation();
           histhi.SetExcluded();
         }
@@ -458,10 +517,12 @@
     }
 
-  FitHiGainArrays((*fCam),*fBadPixels,
+  FitHiGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
+                  *fBadPixels,
                   MBadPixelsPix::kRelTimeNotFitted,
                   MBadPixelsPix::kRelTimeOscillating);
   
   if (fLoGain)        
-    FitLoGainArrays((*fCam),*fBadPixels,
+    FitLoGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
+                    *fBadPixels,
                     MBadPixelsPix::kRelTimeNotFitted,
                     MBadPixelsPix::kRelTimeOscillating);
@@ -557,5 +618,5 @@
 // --------------------------------------------------------------------------
 //
-// Calls MHGausEvents::DrawClone() for pixel idx
+// Calls MHCalibrationPix::DrawClone() for pixel idx
 //
 void MHCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationTestCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationTestCam.cc	(revision 4902)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationTestCam.cc	(revision 4903)
@@ -49,12 +49,12 @@
 // the fit is declared valid.
 // Otherwise, the fit is repeated within ranges of the previous mean 
-// +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
+// +- MHCalibrationPix::fPickupLimit (default: 5) sigma (see MHCalibrationPix::RepeatFit())
 // In case this does not make the fit valid, the histogram means and RMS's are 
-// taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
+// taken directly (see MHCalibrationPix::BypassFit()) and the following flags are set:
 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) and
 // - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun    ) 
 // 
-// Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas 
-// from the mean are counted as Pickup events (stored in MHGausEvents::fPickup) 
+// Outliers of more than MHCalibrationPix::fPickupLimit (default: 5) sigmas 
+// from the mean are counted as Pickup events (stored in MHCalibrationPix::fPickup) 
 //
 // The class also fills arrays with the signal vs. event number, creates a fourier 
@@ -85,4 +85,6 @@
 #include "MHCalibrationTestPix.h"
 
+#include "MHCalibrationPix.h"
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -130,8 +132,8 @@
 //
 // Initializes, if empty to MGeomCam::GetNumAreas() for:
-// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+// - MHCalibrationCam::fAverageHiGainAreas
 //
 // Initializes, if empty to MGeomCam::GetNumSectors() for:
-// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+// - MHCalibrationCam::fAverageHiGainSectors
 // 
 // Calls MHCalibrationCam::InitHists() for every entry in:
@@ -174,15 +176,4 @@
   }
 
-  if (fLoGainArray->GetEntries()==0)
-  {
-      fLoGainArray->Expand(npixels);
-      for (Int_t i=0; i<npixels; i++)
-      {
-	  (*fLoGainArray)[i] = new MHCalibrationTestPix("Calibrated Events",
-                                                "Test Calibration Pixel");
-          InitHists((*this)(i),(*fBadPixels)[i],i);
-      }
-  }
-
 
   if (fAverageHiGainAreas->GetEntries()==0)
@@ -207,23 +198,4 @@
   }
 
-  if (fAverageLoGainAreas->GetEntries()==0)
-  {
-    fAverageLoGainAreas->Expand(nareas);
-    
-    for (Int_t j=0; j<nareas; j++)
-      {
-        (*fAverageLoGainAreas)[j] = 
-          new MHCalibrationTestPix("MHCalibrationTestAverageArea",
-                           "Average Test Calibrations Area Idx ");
-
-        GetAverageLoGainArea(j).GetHGausHist()->SetTitle("Test Calibrations Area Idx ");
-        GetAverageLoGainArea(j).SetNbins(fAverageNbins);
-        GetAverageLoGainArea(j).InitBins();
-        GetAverageLoGainArea(j).ChangeHistId(j);
-        GetAverageLoGainArea(j).SetEventFrequency(fPulserFrequency);
-
-      }
-  }
-
 
   if (fAverageHiGainSectors->GetEntries()==0)
@@ -250,27 +222,10 @@
 
 
-  if (fAverageLoGainSectors->GetEntries()==0)
-  {
-      fAverageLoGainSectors->Expand(nsectors);
-
-      for (Int_t j=0; j<nsectors; j++)
-      {
-	  (*fAverageLoGainSectors)[j] = 
-            new MHCalibrationTestPix("MHCalibrationTestAverageSector",
-                             "Average Test Calibrations Sector ");
-
-          GetAverageLoGainSector(j).GetHGausHist()->SetTitle("Test Calibrations Sector ");
-          GetAverageLoGainSector(j).SetNbins(fAverageNbins);
-          GetAverageLoGainSector(j).InitBins();
-          GetAverageLoGainSector(j).ChangeHistId(j);
-          GetAverageLoGainSector(j).SetEventFrequency(fPulserFrequency);
-      }
-  }
-
-
   fMeanMeanPhotPerArea.Set(nareas);   
   fRmsMeanPhotPerArea .Set(nareas); 
   fMeanSigmaPhotPerArea.Set(nareas);  
   fRmsSigmaPhotPerArea.Set(nareas);
+
+  fLoGain = kFALSE;
  
   return kTRUE;
@@ -287,8 +242,7 @@
 // - number of sectors
 //
-// Fills HiGain or LoGain histograms (MHGausEvents::FillHistAndArray()), respectively
-// depending on MCerPhotPix::IsLoGainUsed(), with:
-// - MCerPhotPix::GetArrivalTime(pixid) - MCerPhotPix::GetArrivalTime(1);
-//   (i.e. the time difference between pixel i and pixel 1 (hardware number: 2) )
+// Fills HiGain histograms (MHGausEvents::FillHistAndArray())
+// with:
+// - MCerPhotPix::GetNumPhotons(pixid);
 //
 Bool_t MHCalibrationTestCam::FillHists(const MParContainer *par, const Stat_t w)
@@ -298,5 +252,5 @@
   if (!calibration)
     {
-      gLog << err << "No argument in MHCalibrationRelTimeCam::Fill... abort." << endl;
+      gLog << err << "No argument in MHCalibrationTestCam::Fill... abort." << endl;
       return kFALSE;
     }
@@ -314,5 +268,5 @@
     {
 
-      MHGausEvents &histhi = (*this)[i];
+      MHCalibrationPix &histhi = (*this)[i];
 
       const MCerPhotPix *pix = calibration->GetPixById(i);
@@ -339,5 +293,5 @@
   for (Int_t j=0; j<nareas; j++)
     {
-      MHGausEvents &histhi = GetAverageHiGainArea(j);
+      MHCalibrationPix &histhi = GetAverageHiGainArea(j);
       histhi.FillHistAndArray(numareahi[j] == 0 ? 0. : sumareahi[j]/numareahi[j]);
     }
@@ -345,5 +299,5 @@
   for (Int_t j=0; j<nsectors; j++)
     {
-      MHGausEvents &histhi = GetAverageHiGainSector(j);
+      MHCalibrationPix &histhi = GetAverageHiGainSector(j);
       histhi.FillHistAndArray(numsectorhi[j] == 0 ? 0. : sumsectorhi[j]/numsectorhi[j]);
 
@@ -358,6 +312,4 @@
 // - MHCalibrationCam::FitHiGainArrays() with flags:
 //   MBadPixelsPix::kTestNotFitted and MBadPixelsPix::kTestOscillating
-// - MHCalibrationCam::FitLoGainArrays() with flags:
-//   MBadPixelsPix::kTestNotFitted and MBadPixelsPix::kTestOscillating
 // 
 Bool_t MHCalibrationTestCam::FinalizeHists()
@@ -372,5 +324,5 @@
     {
       
-      MHGausEvents &hist = (*this)[i];
+      MHCalibrationPix &hist = (*this)[i];
       
       if (hist.IsEmpty())
@@ -397,5 +349,5 @@
     {
       
-      MHGausEvents     &hist = GetAverageHiGainArea(j);      
+      MHCalibrationPix     &hist = GetAverageHiGainArea(j);      
       if (hist.IsEmpty())
         continue;
@@ -424,5 +376,5 @@
     {
       
-      MHGausEvents     &hist = GetAverageHiGainSector(j);      
+      MHCalibrationPix     &hist = GetAverageHiGainSector(j);      
       if (hist.IsEmpty())
         continue;
@@ -476,5 +428,5 @@
     return kFALSE;
 
-  const MHGausEvents &pix = (*this)[idx];
+  const MHCalibrationPix &pix = (*this)[idx];
 
   if (pix.IsEmpty())
@@ -526,5 +478,5 @@
 // --------------------------------------------------------------------------
 //
-// Calls MHGausEvents::DrawClone() for pixel idx
+// Calls MHCalibrationPix::DrawClone() for pixel idx
 //
 void MHCalibrationTestCam::DrawPixelContent(Int_t idx) const
@@ -545,5 +497,5 @@
     {
   
-      MHGausEvents &hist    = GetAverageHiGainArea(j);
+      MHCalibrationPix &hist    = GetAverageHiGainArea(j);
 
       const Float_t numsqr    = TMath::Sqrt((Float_t)fAverageAreaNum[j]);
