Index: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MBadPixelsPix.cc	(revision 3558)
+++ trunk/MagicSoft/Mars/mbadpixels/MBadPixelsPix.cc	(revision 3559)
@@ -17,5 +17,6 @@
 !
 !   Author(s): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
-!
+!              Markus Gaug,  3/2004 <mailto:markus@ifae.es>
+! 
 !   Copyright: MAGIC Software Development, 2000-2004
 !
Index: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsPix.h
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MBadPixelsPix.h	(revision 3558)
+++ trunk/MagicSoft/Mars/mbadpixels/MBadPixelsPix.h	(revision 3559)
@@ -41,5 +41,6 @@
       kMeanTimeInFirstBin       = BIT(12),
       kMeanTimeInLastBin        = BIT(13), 
-      kNotCalibrated            = BIT(14)   
+      kDeviatingNumPhes         = BIT(14),
+      kNotCalibrated            = BIT(15)   
     };
     
@@ -69,4 +70,5 @@
     void SetLoGainNotFitted          () { fInfo[1] |= kLoGainNotFitted; }
     void SetHiGainNotFitted          () { fInfo[1] |= kHiGainNotFitted; }
+    void SetDeviatingNumPhes         () { fInfo[1] |= kDeviatingNumPhes; }
 
     // Getter
@@ -90,5 +92,7 @@
     Bool_t IsLoGainNotFitted          () const      { return fInfo[1] & kLoGainNotFitted;          }
     Bool_t IsHiGainNotFitted          () const      { return fInfo[1] & kHiGainNotFitted;          }
+    Bool_t IsDeviatingNumPhes         () const      { return fInfo[1] & kDeviatingNumPhes;         }    
 
+    
     Bool_t IsLoGainBad() const { return IsLoGainSaturation() || IsConvHiLoNotValid() || IsLoGainOscillating() ;}
     Bool_t IsHiGainBad() const { return (IsHiGainSaturation() && IsConvHiLoNotValid()) || IsHiGainOscillating(); }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 3558)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 3559)
@@ -365,4 +365,5 @@
   for (UInt_t i=0; i<npixels; i++)
     {
+
       MCalibrationChargePix &pix = (*fCam)      [i];
       MCalibrationQEPix     &pqe = (*fQECam)    [i];
@@ -506,4 +507,7 @@
 Int_t MCalibrationChargeCalc::PostProcess()
 {
+
+  if (GetNumExecutions()==0)
+    return kFALSE;
 
   //
@@ -626,6 +630,259 @@
       }
   }
+
   fCam->SetReadyToSave();
-  
-return kTRUE;
-}
+
+  PrintInfo();
+  
+  return kTRUE;
+}
+
+void MCalibrationChargeCalc::PrintInfo()
+{
+  
+  *fLog << inf << endl;
+  *fLog << GetDescriptor() << ": Calibration statistics:" << endl;
+  *fLog << dec << setfill(' ');
+  
+  UInt_t countinner = 0;
+  UInt_t countouter = 0;  
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsOK())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Successfully calibrated Pixels: " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+  
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Bad Pixels:                     " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Unreliable Pixels:              " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+
+  *fLog << inf << endl;
+  *fLog << GetDescriptor() << ": Errors statistics:" << endl;  
+
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsChargeIsPedestal())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Signal less than 3 Pedestal RMS:                 " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsChargeErrNotValid())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Signal Error smaller than 0:                     " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+  
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsChargeRelErrNotValid())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Signal Error bigger than Mean Signal:            " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+  
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsChargeSigmaNotValid())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Signal Sigma smaller than Pedestal RMS:          " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+  
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsLoGainSaturation())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Pixels with Low Gain Saturation:                 " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsMeanTimeInFirstBin())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Pixels with Mean Abs. Arr. Time in First Bin:    " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsMeanTimeInLastBin())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Pixels with Mean Abs. Arr. Time in Last 2 Bins:  " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+  
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsHiGainOscillating())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Pixels with changing Hi Gain signal over time:   " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsLoGainOscillating())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Pixels with changing Lo Gain signal over time:   " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (!bad.IsCalibrationFitOK())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Pixels with unsuccessful signal fit:             " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+
+  countinner = 0;
+  countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsDeviatingNumPhes())
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << "Pixels with deviating number of phes:            " 
+        << "Inner: " << countinner << " Outer: " << countouter << endl;
+
+}
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 3558)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 3559)
@@ -66,6 +66,6 @@
                          Float_t &avped, Float_t &avrms);
   void FinalizeAvPedestals(MCalibrationChargePix &cal, Float_t avped, Float_t avrms, Int_t avnum);
-  
   Bool_t FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad);
+  void PrintInfo();
   
 public:
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3558)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3559)
@@ -13,5 +13,4 @@
 ! * in supporting documentation. It is provided "as is" without express
 ! * or implied warranty.
-
 ! *
 !
@@ -895,4 +894,5 @@
               if (nphe < lowerpheinnerlimit || nphe > upperpheinnerlimit)
                 {
+                  bad[idx].SetDeviatingNumPhes();
                   bad[idx].SetUnsuitable(MBadPixelsPix::kUnreliableRun);
                   continue;
@@ -909,4 +909,5 @@
               if (nphe < lowerpheouterlimit || nphe > upperpheouterlimit)
                 {
+                  bad[idx].SetDeviatingNumPhes();
                   bad[idx].SetUnsuitable(MBadPixelsPix::kUnreliableRun);
                   continue;
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc	(revision 3558)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc	(revision 3559)
@@ -697,8 +697,8 @@
     }
   
-  if ( fAbsTimeMean > (Float_t)upperedge-1)
-    {
-      *fLog << warn << "WARNING: Mean ArrivalTime in last extraction bin of the Pixel " << fPixId << endl;
-      *fLog << fAbsTimeMean << "   " << (Float_t)upperedge-1. << endl;
+  if ( fAbsTimeMean > (Float_t)upperedge-2)
+    {
+      *fLog << warn << "WARNING: Mean ArrivalTime in last two extraction bins of the Pixel " << fPixId << endl;
+      *fLog << fAbsTimeMean << "   " << (Float_t)upperedge-2. << endl;
       bad->SetMeanTimeInLastBin();
       bad->SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 3558)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 3559)
@@ -115,5 +115,4 @@
           kExcluded, 
           kChargeValid, kTimeFitValid,
-          kHiGainFitted, kLoGainFitted, 
           kBlindPixelMethodValid, kFFactorMethodValid, 
 	  kPINDiodeMethodValid, kCombinedMethodValid };
@@ -185,6 +184,4 @@
   void SetLoGainSaturation    (  const Bool_t b = kTRUE );
   void SetExcluded            (  const Bool_t b = kTRUE );
-  void SetHiGainFitted        (  const Bool_t b = kTRUE );
-  void SetLoGainFitted        (  const Bool_t b = kTRUE );
   void SetBlindPixelMethodValid( const Bool_t b = kTRUE );
   void SetFFactorMethodValid  (  const Bool_t b = kTRUE );
@@ -268,7 +265,4 @@
   Bool_t IsHiGainSaturation()                  const;
   Bool_t IsLoGainSaturation()                  const;
-  Bool_t IsHiGainFitted()                      const;
-  Bool_t IsLoGainFitted()                      const;
-  Bool_t IsFitted()                            const;
   Bool_t IsBlindPixelMethodValid()             const;
   Bool_t IsPINDiodeMethodValid()               const;
