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
