Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3837)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3838)
@@ -44,4 +44,9 @@
    * mcalib/MCalibrationChargeCalc.[h,cc]
      - calculate and store the above numbers.
+
+
+   * mbadpixels/MBadPixelsPix.[h,cc]
+     - removed bits: kHiGainNotCalibrated and kLoGainNotCalibrated
+     - added bit: kDeviatingFFactor
 
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 3837)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 3838)
@@ -647,4 +647,9 @@
   FinalizePINDiodeQECam();
 
+  //
+  // Finalize calibration statistics
+  //
+  FinalizeUnsuitablePixels();
+
   fCam      ->SetReadyToSave();
   fQECam    ->SetReadyToSave();
@@ -656,30 +661,4 @@
     fPINDiode->SetReadyToSave();
   
-
-  
-  *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;
-  
-  PrintUnsuitable(MBadPixelsPix::kUnsuitableRun, "Bad Pixels:                     ");
-  PrintUnsuitable(MBadPixelsPix::kUnreliableRun, "Unreliable Pixels:              ");
-
   *fLog << inf << endl;
   *fLog << GetDescriptor() << ": Errors statistics:" << endl;  
@@ -1395,9 +1374,79 @@
 // -----------------------------------------------------------------------------------------------
 //
-// Print out statistics about BadPixels of type UnsuitableType_t 
-// 
-void MCalibrationChargeCalc::PrintUnsuitable(MBadPixelsPix::UnsuitableType_t typ, const char *text) const 
-{
-
+// - Print out statistics about BadPixels of type UnsuitableType_t 
+// - store numbers of bad pixels of each type in fCam
+//
+void MCalibrationChargeCalc::FinalizeUnsuitablePixels()
+{
+  
+  *fLog << inf << endl;
+  *fLog << GetDescriptor() << ": Calibration statistics:" << endl;
+  *fLog << dec << setfill(' ');
+
+  const Int_t nareas = fGeom->GetNumAreas();
+
+  Int_t counts[nareas];
+  memset(counts,0,nareas*sizeof(Int_t));
+
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsOK())
+        {
+          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;
+  
+  memset(counts,0,nareas*sizeof(Int_t));
+
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        {
+          const Int_t aidx = (*fGeom)[i].GetAidx();
+          counts[aidx]++;
+        }
+    }
+
+  for (Int_t aidx=0; aidx<nareas; aidx++)
+    fCam->SetNumUncalibrated(counts[aidx], aidx);
+
+  if (fGeom->InheritsFrom("MGeomCamMagic"))
+    *fLog << " " << setw(7) << "Uncalibrated Pixels:            " 
+          << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
+
+  memset(counts,0,nareas*sizeof(Int_t));
+
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+        {
+          const Int_t aidx = (*fGeom)[i].GetAidx();
+          counts[aidx]++;
+        }
+    }
+
+  for (Int_t aidx=0; aidx<nareas; aidx++)
+    fCam->SetNumUnreliable(counts[aidx], aidx);
+
+  *fLog << " " << setw(7) << "Unreliable Pixels:              "
+        << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
+
+}
+
+// -----------------------------------------------------------------------------------------------
+//
+// Print out statistics about BadPixels of type UncalibratedType_t 
+// 
+void MCalibrationChargeCalc::PrintUncalibrated(MBadPixelsPix::UncalibratedType_t typ, const char *text) const 
+{
+  
   UInt_t countinner = 0;
   UInt_t countouter = 0;
@@ -1405,5 +1454,5 @@
     {
       MBadPixelsPix &bad = (*fBadPixels)[i];
-      if (bad.IsUnsuitable(typ))
+      if (bad.IsUncalibrated(typ))
         {
           if (fGeom->GetPixRatio(i) == 1.)
@@ -1414,29 +1463,4 @@
     }
 
-  *fLog << " " << setw(7) << text 
-        << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
-}
-
-// -----------------------------------------------------------------------------------------------
-//
-// Print out statistics about BadPixels of type UncalibratedType_t 
-// 
-void MCalibrationChargeCalc::PrintUncalibrated(MBadPixelsPix::UncalibratedType_t typ, const char *text) const 
-{
-  
-  UInt_t countinner = 0;
-  UInt_t countouter = 0;
-  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
-    {
-      MBadPixelsPix &bad = (*fBadPixels)[i];
-      if (bad.IsUncalibrated(typ))
-        {
-          if (fGeom->GetPixRatio(i) == 1.)
-            countinner++;
-          else
-            countouter++;
-        }
-    }
-
   *fLog << " " << setw(7) << text  
         << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 3837)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 3838)
@@ -87,6 +87,6 @@
   void   FinalizeBlindPixelQECam();
   void   FinalizePINDiodeQECam  ();
-  
-  void   PrintUnsuitable  ( MBadPixelsPix::UnsuitableType_t typ  , const char *text) const;   
+  void   FinalizeUnsuitablePixels();
+
   void   PrintUncalibrated( MBadPixelsPix::UncalibratedType_t typ, const char *text) const;
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3837)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3838)
@@ -46,4 +46,8 @@
 // sigmas. 
 //
+// Final numbers of uncalibrated or unreliable pixels can be retrieved via the commands:
+// GetNumUncalibrated(aidx) and GetNumUnreliable(aidx) where aidx is the area index (0 for 
+// inner and 1 for outer pixels in the MAGIC camera).
+//
 // The following "calibration" constants are used for the calibration of each pixel 
 // (see MCalibrate and MCalibrateData):
@@ -147,4 +151,17 @@
 }
 
+// -------------------------------------------------------------------
+//
+// Calls:
+// - MCalibrationCam::Init()
+// - fNumUncalibrated.Set(NumAreas);
+// - fNumUnreliable.Set(NumAreas);
+//
+void MCalibrationChargeCam::Init(const MGeomCam &geom)
+{
+  fNumUncalibrated.Set(geom.GetNumAreas());
+  fNumUnreliable  .Set(geom.GetNumAreas());
+  MCalibrationCam::Init(geom);
+}
 
 // -----------------------------------------------
