Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 8454)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 8455)
@@ -238,4 +238,18 @@
     fDisplay->AddTab(name);
     obj->DrawClone(opt);
+}
+
+void MJCalibration::DrawBadPixel(TPaveText &pave, const MHCamera &h, Int_t n, Float_t f, const char *str) const
+{
+    Int_t cnt = 0;
+    for (UInt_t pix=0; pix<h.GetNumPixels(); pix++)
+        if (TMath::Nint(h.GetPixContent(pix)) == n)
+            cnt++;
+
+    const TString txt = Form(n<10?"  %d) %s%3i pixels":"%d) %s%3i pixels", n, str, cnt);
+
+    TText *p = pave.AddText(txt);
+    p->SetTextColor(gStyle->GetColorPalette(TMath::FloorNint((n-1)*f)));
+    p->SetTextAlign(12);
 }
 
@@ -804,24 +818,27 @@
       TCanvas &c4 = fDisplay->AddTab("Defect");
       c4.Divide(2,2, 0.005, 0.005);
-      
+
       c4.cd(1);
       gPad->SetBorderMode(0);
       gPad->SetTicks();
+
       MHCamera *obj8=(MHCamera*)disp24.DrawCopy("hist");
-      //
-      // for the datacheck, fix the ranges!!
-      //
+
+      gStyle->SetPalette(1);
+      const Int_t numcol = gStyle->GetNumberOfColors();
+
+      const Double_t min = 1;
       const Double_t max = 12.;
-      obj8->SetMinimum(0.);
+      const Double_t f   = (numcol-1)/(max-min);
+
+      obj8->SetStats(kFALSE);
+      obj8->SetMinimum(min);
       obj8->SetMaximum(max);
+
       //
       // Set the datacheck sizes:
       //
       FixDataCheckHist((TH1D*)obj8);
-      obj8->SetStats(kFALSE);
-
-      gStyle->SetPalette(1);
-      const Int_t numcol = gStyle->GetNumberOfColors()-3;
-      
+
       TPaveText *pave = new TPaveText(0.05,0.02,0.975,0.999);
       pave->SetBit(kCanDelete);
@@ -829,81 +846,42 @@
       pave->SetTextSize(0.045);
       pave->AddText("  ");
-      TText *t1 = pave->AddText(Form("Signal smaller 4.5 Pedestal RMS:               %3i pixels",
-                                       CountBadPixels(&disp24,1)));
-      t1->SetTextColor(gStyle->GetColorPalette(Int_t(1./max*numcol)));
-      t1->SetTextAlign(12);
-      TText *t4 = pave->AddText(Form("Low Gain Saturation:                                   %3i pixels",
-                                       CountBadPixels(&disp24,2)));
-      t4->SetTextColor(gStyle->GetColorPalette(Int_t(2./max*numcol)));
-      t4->SetTextAlign(12);
-      TText *t5 = pave->AddText(Form("Mean Arr. Time In First Extraction Bin:      %3i pixels",
-                                       CountBadPixels(&disp24,3)));
-      t5->SetTextColor(gStyle->GetColorPalette(Int_t(3./max*numcol)));
-      t5->SetTextAlign(12);
-      TText *t6 = pave->AddText(Form("Mean Arr. Time In Last 2 Extraction Bins:  %3i pixels",
-                                       CountBadPixels(&disp24,4)));
-      t6->SetTextColor(gStyle->GetColorPalette(Int_t(4./max*numcol)));
-      t6->SetTextAlign(12);
-      TText *t10= pave->AddText(Form("High-Gain Histogram Overflow:                  %3i pixels",
-                                       CountBadPixels(&disp24,5 )));
-      t10->SetTextColor(gStyle->GetColorPalette(Int_t(5./max*numcol)));
-      t10->SetTextAlign(12);
-      TText *t11= pave->AddText(Form("Low-Gain Histogram Overflow:                   %3i pixels",
-                                       CountBadPixels(&disp24,6 )));
-      t11->SetTextColor(gStyle->GetColorPalette(Int_t(6./max*numcol)));
-      t11->SetTextAlign(12);
-      TText *t12= pave->AddText(Form("Presumably dead from Ped. Rms:              %3i pixels",
-                                       CountBadPixels(&disp24,7 )));
-      t12->SetTextColor(gStyle->GetColorPalette(Int_t(7./max*numcol)));
-      t12->SetTextAlign(12);
-      TText *t13= pave->AddText(Form("Fluctuating Pulse Arrival Times:                 %3i pixels",
-                                       CountBadPixels(&disp24,8 )));
-      t13->SetTextColor(gStyle->GetColorPalette(Int_t(8./max*numcol)));
-      t13->SetTextAlign(12);
-      TText *t17 = pave->AddText(Form("Deviating Number of Photo-electrons:       %3i pixels",
-                                       CountBadPixels(&disp24,9 )));
-      t17->SetTextColor(gStyle->GetColorPalette(Int_t(9./max*numcol)));
-      t17->SetTextAlign(12);
-      TText *t18 = pave->AddText(Form("Deviating Rel. Arrival Time RMS:                %3i pixels",
-                                       CountBadPixels(&disp24,10 )));
-      t18->SetTextColor(gStyle->GetColorPalette(Int_t(10./max*numcol)));
-      t18->SetTextAlign(12);
-      TText *t15= pave->AddText(Form("Too many Low-Gain Blackout Events:       %3i pixels",
-                                       CountBadPixels(&disp24,11 )));
-      t15->SetTextColor(gStyle->GetColorPalette(Int_t(11./max*numcol)));
-      t15->SetTextAlign(12);
-      TText *t14= pave->AddText(Form("Previously Excluded:                                   %3i pixels",
-                                       CountBadPixels(&disp24,12)));
-      t14->SetTextColor(gStyle->GetColorPalette(Int_t(12./max*numcol)));
-      t14->SetTextAlign(12);
+      DrawBadPixel(*pave, disp24,  1, f, "Signal smaller 4.5 Pedestal RMS:               ");
+      DrawBadPixel(*pave, disp24,  2, f, "Low Gain Saturation:                                   ");
+      DrawBadPixel(*pave, disp24,  3, f, "Mean Arr. Time In First Extraction Bin:      ");
+      DrawBadPixel(*pave, disp24,  4, f, "Mean Arr. Time In Last 2 Extraction Bins:  ");
+      DrawBadPixel(*pave, disp24,  5, f, "High-Gain Histogram Overflow:                  ");
+      DrawBadPixel(*pave, disp24,  6, f, "Low-Gain Histogram Overflow:                   ");
+      DrawBadPixel(*pave, disp24,  7, f, "Presumably dead from Ped. Rms:              ");
+      DrawBadPixel(*pave, disp24,  8, f, "Fluctuating Pulse Arrival Times:                 ");
+      DrawBadPixel(*pave, disp24,  9, f, "Deviating Number of Photo-electrons:       ");
+      DrawBadPixel(*pave, disp24, 10, f, "Deviating Rel. Arrival Time RMS:                ");
+      DrawBadPixel(*pave, disp24, 11, f, "Too many Low-Gain Blackout Events:       ");
+      DrawBadPixel(*pave, disp24, 12, f, "Previously Excluded:                                   ");
       pave->Draw();
 
       c4.cd(3);
       gPad->SetBorderMode(0);
+      obj8->SetPrettyPalette();
       obj8->Draw();
-      obj8->SetPrettyPalette();
 
       //
       // UNRELIABLE PIXELS
       // 
-      
       c4.cd(2);
       gPad->SetBorderMode(0);
       gPad->SetTicks();
       MHCamera *obj9=(MHCamera*)disp25.DrawCopy("hist");
-      //
-      // for the datacheck, fix the ranges!!
-      //
-      const Double_t max2 = 9.;
-      obj9->SetMinimum(0.);
+
+      const Double_t min2 = 1;
+      const Double_t max2 = 8;
+      const Double_t f2   = (numcol-1)/(max2-min2);
+      obj9->SetMinimum(min2);
       obj9->SetMaximum(max2);
-      //
-      // Set the datacheck sizes:
-      //
+      obj9->SetStats(kFALSE);
+
       FixDataCheckHist((TH1D*)obj9);
-      obj9->SetStats(kFALSE);
 
       gStyle->SetPalette(1);
-      
+
       TPaveText *pave2 = new TPaveText(0.025,0.02,0.95,0.999);
       pave2->SetBit(kCanDelete);
@@ -911,36 +889,12 @@
       pave2->SetTextSize(0.05);
       pave2->AddText("  ");
-      TText *t3 = pave2->AddText(Form("Signal Sigma smaller Pedestal RMS:      %3i pixels",
-                                       CountBadPixels(&disp25,1)));
-      t3->SetTextColor(gStyle->GetColorPalette(Int_t(1./max2*numcol)));
-      t3->SetTextAlign(12);
-      TText *tt1 = pave2->AddText(Form("High Gain Signals could not be fitted:    %3i pixels",
-                                       CountBadPixels(&disp25,3)));
-      tt1->SetTextColor(gStyle->GetColorPalette(Int_t(3./max2*numcol)));
-      tt1->SetTextAlign(12);
-      TText *tt2 = pave2->AddText(Form("Low  Gain Signals could not be fitted:    %3i pixels",
-                                       CountBadPixels(&disp25,4)));
-      tt2->SetTextColor(gStyle->GetColorPalette(Int_t(4./max2*numcol)));
-      tt2->SetTextAlign(12);
-      TText *tt3 = pave2->AddText(Form("Relative Arr. Times could not be fitted:   %3i pixels",
-                                       CountBadPixels(&disp25,5)));
-      tt3->SetTextColor(gStyle->GetColorPalette(Int_t(5./max2*numcol)));
-      tt3->SetTextAlign(12);
-      TText *tt4 = pave2->AddText(Form("High Gain Signals Oscillation:                 %3i pixels",
-                                       CountBadPixels(&disp25,6)));
-      tt4->SetTextColor(gStyle->GetColorPalette(Int_t(6./max2*numcol)));
-      tt4->SetTextAlign(12);
-      TText *tt5 = pave2->AddText(Form("Low  Gain Signals Oscillation:                %3i pixels",
-                                       CountBadPixels(&disp25,7)));
-      tt5->SetTextColor(gStyle->GetColorPalette(Int_t(7./max2*numcol)));
-      tt5->SetTextAlign(12); 
-      TText *tt6 = pave2->AddText(Form("Relative Arr. Times Oscillation:               %3i pixels",
-                                       CountBadPixels(&disp25,8)));
-      tt6->SetTextColor(gStyle->GetColorPalette(Int_t(8./max2*numcol)));
-      tt6->SetTextAlign(12);
-      TText *tt8 = pave2->AddText(Form("Deviating global F-Factor:                       %3i pixels",
-                                       CountBadPixels(&disp25,9)));
-      tt8->SetTextColor(gStyle->GetColorPalette(Int_t(9./max2*numcol)));
-      tt8->SetTextAlign(12);
+      DrawBadPixel(*pave2, disp25,  1, f2, "Signal Sigma smaller Pedestal RMS:      ");
+      DrawBadPixel(*pave2, disp25,  2, f2, "High Gain Signals could not be fitted:    ");
+      DrawBadPixel(*pave2, disp25,  3, f2, "Low  Gain Signals could not be fitted:    ");
+      DrawBadPixel(*pave2, disp25,  4, f2, "Relative Arr. Times could not be fitted:   ");
+      DrawBadPixel(*pave2, disp25,  5, f2, "High Gain Signals Oscillation:                 ");
+      DrawBadPixel(*pave2, disp25,  6, f2, "Low  Gain Signals Oscillation:                ");
+      DrawBadPixel(*pave2, disp25,  7, f2, "Relative Arr. Times Oscillation:               ");
+      DrawBadPixel(*pave2, disp25,  8, f2, "Deviating global F-Factor:                       ");
       pave2->Draw();
 
@@ -1341,15 +1295,4 @@
 }
 
-const Int_t MJCalibration::CountBadPixels(MHCamera *cam, const Int_t what) const
-{
-    Int_t cnt = 0;
-
-    for (UInt_t pix=0; pix<cam->GetNumPixels(); pix++)
-        if (TMath::Nint(cam->GetPixContent(pix)) == what)
-            cnt++;
-
-    return cnt;
-}
-
 // --------------------------------------------------------------------------
 //
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 8454)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 8455)
@@ -28,4 +28,5 @@
 
 class TH1D;
+class TPaveText;
 
 class MTask;
@@ -76,5 +77,4 @@
   Float_t  fRefArrivalTimeRmsInner;        //! Reference value for the arrival time - inner
   Float_t  fRefArrivalTimeRmsOuter;        //! Reference value for the arrival time - outer
-  Float_t  fRefTimeOffsetInner;            //! Reference value for the time offset - inner
   Float_t  fRefTimeOffsetOuter;            //! Reference value for the time offset - outer
   Float_t  fRefTimeResolutionInner;  	   //! Reference value for the time resolution - inner
@@ -116,5 +116,6 @@
   Bool_t IsDebug        () const { return TESTBIT(fFlags,kDebug);          }
 
-  void   DrawTab(MParList &plist, const char *cont, const char *name, Option_t *opt);
+  void DrawBadPixel(TPaveText &pave, const MHCamera &h, Int_t n, Float_t f, const char *str) const;
+  void DrawTab(MParList &plist, const char *cont, const char *name, Option_t *opt);
   
   void   DisplayResult        ( MParList &plist );
@@ -122,5 +123,4 @@
   void   DisplayOutliers      ( TH1D     *hist, const char* whatsmall, const char* whatbig ) const;
   void   DisplayDoubleProject ( MHCamera *cam , const char* whatsmall, const char* whatbig ) const;
-  const  Int_t CountBadPixels ( MHCamera *cam , const Int_t what                           ) const;
   void   FixDataCheckHist     ( TH1D     *hist  ) const;
 
