Index: /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4619)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4620)
@@ -92,4 +92,7 @@
 #include <TCanvas.h>
 #include <TSystem.h>
+#include <TLine.h>
+#include <TLatex.h>
+#include <TLegend.h>
 
 #include "MLog.h"
@@ -108,5 +111,7 @@
 #include "MCalibrationCam.h"
 #include "MCalibrationQECam.h"
+#include "MCalibrationQEPix.h"
 #include "MCalibrationChargeCam.h"
+#include "MCalibrationChargePix.h"
 #include "MCalibrationChargePINDiode.h"
 #include "MCalibrationChargeBlindPix.h"
@@ -246,6 +251,6 @@
     MHCamera disp3 (geomcam, "RSigma",            "Reduced Sigmas");
     MHCamera disp4 (geomcam, "RSigmaPerCharge",   "Reduced Sigma per Charge");
-    MHCamera disp5 (geomcam, "NumPhes",           "Nr. of Phe's (F-Factor Method)");
-    MHCamera disp6 (geomcam, "ConvFADC2Phes",     "Conversion Factor (F-Factor Method)");
+    MHCamera disp5 (geomcam, "NumPhes",           "Number of Phes");
+    MHCamera disp6 (geomcam, "ConvFADC2Phes",     "Conversion Factor to Phes");
     MHCamera disp7 (geomcam, "TotalFFactor",      "Total F-Factor (F-Factor Method)");
     MHCamera disp8 (geomcam, "CascadesQEFFactor", "Cascades QE (F-Factor Method)");
@@ -276,4 +281,5 @@
     MHCamera disp33(geomcam, "TimeNotFitValid",   "Pixels with not valid fit results");
     MHCamera disp34(geomcam, "TimeOscillating",   "Oscillating Pixels");
+    MHCamera disp35(geomcam, "TotalConv",         "Conversion Factor to photons");
 
     // Fitted charge means and sigmas
@@ -346,5 +352,5 @@
     disp4.SetYTitle("Red.Sigma/<Q> [1]");
 
-    disp5.SetYTitle("Nr. Phe's [1]");
+    disp5.SetYTitle("Phes [1]");
     disp6.SetYTitle("Conv.Factor [PhE/FADC counts]");
     disp7.SetYTitle("Total F-Factor [1]");
@@ -376,4 +382,23 @@
     disp28.SetYTitle("Mean Abs. Time [FADC slice]");
     disp29.SetYTitle("RMS Abs. Time [FADC slices]");
+
+    disp35.SetYTitle("Conv.Factor [Ph/FADC counts]");
+
+    for (UInt_t i=0;i<geomcam.GetNumPixels();i++)
+      {
+
+        MCalibrationChargePix &pix = (MCalibrationChargePix&)fCalibrationCam[i];
+        MCalibrationQEPix     &qe  = (MCalibrationQEPix&)    fQECam         [i];
+
+        if (!pix.IsFFactorMethodValid())
+          continue;
+
+        const Float_t convphe  = pix.GetMeanConvFADC2Phe();
+        const Float_t quaeff   = qe.GetQECascadesFFactor(0.);
+        
+        disp35.Fill(i,convphe/quaeff);
+        disp35.SetUsed(i);
+      }
+    
 
     if (fRelTimes)
@@ -393,54 +418,254 @@
         disp34.SetYTitle("[1]");
     }
+
+
     
     if (fDisplayType == kDataCheckDisplay)
     {
-
-        TCanvas &c1 = fDisplay->AddTab("Fit.Charge");
-        c1.Divide(3, 3);
-        
-        disp1.CamDraw( c1, 1, 3, 5);
-        disp4.CamDraw( c1, 2, 3, 5);
-        disp28.CamDraw(c1, 3, 3, 5);
-
-        //  F-Factor
-        TCanvas &c2 = fDisplay->AddTab("Phe's");
-        c2.Divide(3,4);
-        
-        disp6.CamDraw(c2, 1, 3,  5, 1);
-        disp7.CamDraw(c2, 2, 3,  5, 1);
-        disp8.CamDraw(c2, 3, 3,  5, 1);
-
-        // QE's
-        TCanvas &c3 = fDisplay->AddTab("QE's");
-        c3.Divide(3,4);
-
-        disp8.CamDraw(c3, 1, 3,  5, 1);
-        disp9.CamDraw(c3, 2, 3,  5, 1);
-        disp10.CamDraw(c3, 3, 3,  5, 1);
-
-        // Defects
-        TCanvas &c4 = fDisplay->AddTab("Defect");
-        c4.Divide(2,2);
-
-        disp24.CamDraw(c4, 1, 2, 0);
-        disp25.CamDraw(c4, 2, 2, 0);
-
-        if (fRelTimes)
+      
+      TCanvas &c1 = fDisplay->AddTab("Fit.Charge");
+      c1.Divide(3, 3);
+      
+      //
+      // MEAN CHARGES
+      // 
+      
+      c1.cd(1);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      MHCamera *obj1=(MHCamera*)disp1.DrawCopy("hist");
+      //
+      // for the datacheck, fix the ranges!!
+      //
+      // obj1->SetMinimum(fgChargeMin);
+      // obj1->SetMaximum(fgChargeMax);
+      //
+      // Set the datacheck sizes:
+      //
+      FixDataCheckHist((TH1D*)obj1);
+      //
+      // set reference lines
+      //
+      //        DisplayReferenceLines(obj1,0);
+      
+      c1.cd(4);
+      gPad->SetBorderMode(0);
+      obj1->SetPrettyPalette();
+      obj1->Draw();
+      
+      c1.cd(7);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      TH1D *obj2 = (TH1D*)obj1->Projection(obj1->GetName());
+      obj2->Draw();
+      obj2->SetBit(kCanDelete);
+      obj2->Fit("gaus","Q");
+      TF1 *fun2 = obj2->GetFunction("gaus");
+      fun2->SetLineColor(kYellow);
+      //
+      // Set the datacheck sizes:
+      //
+      FixDataCheckHist(obj2);
+      obj2->SetStats(1);
+      
+      //
+      // Display the outliers as dead and noisy pixels
+      //
+      DisplayOutliers(obj2,"dead","noisy");
+      TLatex flattex;
+      flattex.SetTextSize(0.06);
+      const Double_t minl = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
+      const Double_t maxl = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
+      flattex.DrawLatex(minl+0.1*(maxl-minl),obj2->GetBinContent(obj2->GetMaximumBin())/1.3,
+                        Form("Flatfielding precision: %4.2f%%",
+                             fun2->GetParameter(2)/fun2->GetParameter(1)*100.));
+      
+      //
+      // REDUCED SIGMAS
+      // 
+      
+      c1.cd(2);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      MHCamera *obj3=(MHCamera*)disp4.DrawCopy("hist");
+      //
+      // for the datacheck, fix the ranges!!
+      //
+      // obj3->SetMinimum(fgChargeMin);
+      // obj3->SetMaximum(fgChargeMax);
+      //
+      // Set the datacheck sizes:
+      //
+      FixDataCheckHist((TH1D*)obj3);
+      //
+      // set reference lines
+      //
+      //        DisplayReferenceLines(obj3,0);
+      
+      c1.cd(5);
+      gPad->SetBorderMode(0);
+      obj3->SetPrettyPalette();
+      obj3->Draw();
+      
+      c1.cd(8);
+      gPad->SetBorderMode(0);
+      if (geomcam.InheritsFrom("MGeomCamMagic"))
+        DisplayDoubleProject(&disp4, "dead", "noisy");
+      
+      //
+      // PHOTO ELECTRONS
+      // 
+      
+      c1.cd(3);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      MHCamera *obj4=(MHCamera*)disp5.DrawCopy("hist");
+      //
+      // for the datacheck, fix the ranges!!
+      //
+      // obj3->SetMinimum(fgChargeMin);
+      // obj3->SetMaximum(fgChargeMax);
+      //
+      // Set the datacheck sizes:
+      //
+      FixDataCheckHist((TH1D*)obj4);
+      //
+      // set reference lines
+      //
+      //        DisplayReferenceLines(obj3,0);
+      
+      c1.cd(6);
+      gPad->SetBorderMode(0);
+      obj4->SetPrettyPalette();
+      obj4->Draw();
+      
+      c1.cd(9);
+      gPad->SetBorderMode(0);
+      if (geomcam.InheritsFrom("MGeomCamMagic"))
+        DisplayDoubleProject(&disp5, "dead", "noisy");
+      
+      //
+      // CONVERSION FACTORS
+      // 
+
+      TCanvas &c2 = fDisplay->AddTab("Conversion");
+      c2.Divide(3,3);
+      
+      c2.cd(1);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      MHCamera *obj5=(MHCamera*)disp6.DrawCopy("hist");
+      //
+      // for the datacheck, fix the ranges!!
+      //
+      // obj5->SetMinimum(fgChargeMin);
+      // obj5->SetMaximum(fgChargeMax);
+      //
+      // Set the datacheck sizes:
+      //
+      FixDataCheckHist((TH1D*)obj5);
+      //
+      // set reference lines
+      //
+      //        DisplayReferenceLines(obj5,0);
+      
+      c2.cd(4);
+      gPad->SetBorderMode(0);
+      obj5->SetPrettyPalette();
+      obj5->Draw();
+      
+      c2.cd(7);
+      gPad->SetBorderMode(0);
+      if (geomcam.InheritsFrom("MGeomCamMagic"))
+        DisplayDoubleProject(&disp6, "noisy", "dead");
+      
+      //
+      // QUANTUM EFFICIENCY
+      //
+      
+      c2.cd(2);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      MHCamera *obj6=(MHCamera*)disp8.DrawCopy("hist");
+      //
+      // for the datacheck, fix the ranges!!
+      //
+      // obj6->SetMinimum(fgChargeMin);
+      // obj6->SetMaximum(fgChargeMax);
+      //
+      // Set the datacheck sizes:
+      //
+      FixDataCheckHist((TH1D*)obj6);
+      //
+      // set reference lines
+      //
+      //        DisplayReferenceLines(obj6,0);
+      
+      c2.cd(5);
+      gPad->SetBorderMode(0);
+      obj6->SetPrettyPalette();
+      obj6->Draw();
+      
+      c2.cd(8);
+      gPad->SetBorderMode(0);
+      if (geomcam.InheritsFrom("MGeomCamMagic"))
+        DisplayDoubleProject(&disp8, "noisy", "dead");
+      
+      //
+      // CONVERSION FADC TO PHOTONS
+      // 
+      
+      c2.cd(3);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      MHCamera *obj7=(MHCamera*)disp35.DrawCopy("hist");
+      //
+      // for the datacheck, fix the ranges!!
+      //
+      // obj3->SetMinimum(fgChargeMin);
+      // obj3->SetMaximum(fgChargeMax);
+      //
+      // Set the datacheck sizes:
+      //
+      FixDataCheckHist((TH1D*)obj7);
+      //
+      // set reference lines
+      //
+      //        DisplayReferenceLines(obj3,0);
+      
+      c2.cd(6);
+      gPad->SetBorderMode(0);
+      obj7->SetPrettyPalette();
+      obj7->Draw();
+      c2.cd(9);
+      gPad->SetBorderMode(0);
+      if (geomcam.InheritsFrom("MGeomCamMagic"))
+        DisplayDoubleProject(&disp35, "noisy", "dead");
+
+      //
+      // DEFECTS
+      //
+      TCanvas &c4 = fDisplay->AddTab("Defect");
+      c4.Divide(2,2);
+      
+      disp24.CamDraw(c4, 1, 2, 0);
+      disp25.CamDraw(c4, 2, 2, 0);
+      
+      if (fRelTimes)
         {
-            // Rel. Times
-            TCanvas &c5 = fDisplay->AddTab("Rel. Times");
-            c5.Divide(2,4);
-
-            disp30.CamDraw(c5, 1, 2, 2);
-            disp31.CamDraw(c5, 2, 2, 2);
+          // Rel. Times
+          TCanvas &c5 = fDisplay->AddTab("Rel. Times");
+          c5.Divide(2,4);
+          
+          disp30.CamDraw(c5, 1, 2, 2);
+          disp31.CamDraw(c5, 2, 2, 2);
         }
-
-        return;
-    }
-
+      
+      return;
+    }
+    
     if (fDisplayType == kNormalDisplay)
-    {
-
+      {
+        
         // Charges
         TCanvas &c11 = fDisplay->AddTab("Fit.Charge");
@@ -625,6 +850,109 @@
     }
 }
-
-
+    
+
+void  MJCalibration::DisplayReferenceLines(MHCamera *cam, const Int_t what) const
+{
+
+  Double_t x = cam->GetNbinsX();
+  
+  const MGeomCam *geom = cam->GetGeometry();
+
+  if (geom->InheritsFrom("MGeomCamMagic"))
+    x = what ? 397 : cam->GetNbinsX();
+
+  TLine line;
+  line.SetLineStyle(kDashed);
+  line.SetLineWidth(3);
+  
+  /*
+  line.SetLineColor(kBlue);
+  TLine *l1 = line.DrawLine(0, what ? fgRefPedRmsGalacticInner : fgRefPedGalactic,
+                            x, what ? fgRefPedRmsGalacticInner : fgRefPedGalactic);
+  
+  line.SetLineColor(kYellow);
+  TLine *l2 = line.DrawLine(0, what ? fgRefPedRmsExtraGalacticInner : fgRefPedExtraGalactic,
+                            x, what ? fgRefPedRmsExtraGalacticInner : fgRefPedExtraGalactic);
+  
+  line.SetLineColor(kMagenta);
+  TLine *l3 = line.DrawLine(0, what ? fgRefPedRmsClosedLidsInner : fgRefPedClosedLids,
+                            x, what ? fgRefPedRmsClosedLidsInner : fgRefPedClosedLids);
+
+  if (geom->InheritsFrom("MGeomCamMagic"))
+    if (what)
+      {
+        const Double_t x2 = cam->GetNbinsX();
+
+        line.SetLineColor(kBlue);
+        line.DrawLine(398, fgRefPedRmsGalacticOuter,
+                      x2,  fgRefPedRmsGalacticOuter);
+        
+        line.SetLineColor(kYellow);
+        line.DrawLine(398, fgRefPedRmsExtraGalacticOuter,
+                      x2,  fgRefPedRmsExtraGalacticOuter);
+        
+        line.SetLineColor(kMagenta);
+        line.DrawLine(398, fgRefPedRmsClosedLidsOuter,
+                      x2,  fgRefPedRmsClosedLidsOuter);
+      }
+    
+  TLegend *leg = new TLegend(0.4,0.75,0.7,0.99);
+  leg->SetBit(kCanDelete);
+  leg->AddEntry(l1, "Galactic Source","l");
+  leg->AddEntry(l2, "Extra-Galactic Source","l");
+  leg->AddEntry(l3, "Closed Lids","l");
+  leg->Draw();
+  */    
+
+
+}
+
+void  MJCalibration::DisplayOutliers(TH1D *hist, const char* whatsmall, const char* whatbig) const
+{
+
+  const Float_t mean  = hist->GetFunction("gaus")->GetParameter(1);
+  const Float_t lolim = mean - 4.0*hist->GetFunction("gaus")->GetParameter(2);
+  const Float_t uplim = mean + 4.0*hist->GetFunction("gaus")->GetParameter(2);
+  const Stat_t  dead  = hist->Integral(0,hist->FindBin(lolim)-1);
+  const Stat_t  noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1);
+
+  const Double_t max = hist->GetBinContent(hist->GetMaximumBin());                                           
+  
+  const Double_t minl = hist->GetBinCenter(hist->GetXaxis()->GetFirst());
+  const Double_t maxl = hist->GetBinCenter(hist->GetXaxis()->GetLast());
+
+  TLatex deadtex;
+  deadtex.SetTextSize(0.06);
+  deadtex.DrawLatex(minl+0.1*(maxl-minl),max/1.1,
+                    Form("%3i %s pixels",(Int_t)dead,whatsmall));
+
+  TLatex noisytex;
+  noisytex.SetTextSize(0.06);
+  noisytex.DrawLatex(minl+0.1*(maxl-minl),max/1.2,
+                     Form("%3i %s pixels",(Int_t)noisy,whatbig));
+
+}
+
+void MJCalibration::FixDataCheckHist(TH1D *hist) const 
+{
+
+    hist->SetDirectory(NULL);
+
+    //
+    // set the labels bigger
+    //
+    TAxis *xaxe = hist->GetXaxis();
+    TAxis *yaxe = hist->GetYaxis();
+    
+    xaxe->CenterTitle();
+    yaxe->CenterTitle();    
+    xaxe->SetTitleSize(0.06);
+    yaxe->SetTitleSize(0.06);    
+    xaxe->SetTitleOffset(0.8);
+    yaxe->SetTitleOffset(0.85);    
+    xaxe->SetLabelSize(0.05);
+    yaxe->SetLabelSize(0.05);    
+
+}
 
 // --------------------------------------------------------------------------
@@ -637,12 +965,13 @@
 Bool_t MJCalibration::FindColor() 
 {
-    if (fSequence)
-    {
-        fColor = MCalibrationCam::kCT1;
-        return kTRUE;
-    }
-
-const UInt_t nruns = fRuns->GetNumRuns();
-
+  
+  if (fSequence)
+    {
+      fColor = MCalibrationCam::kCT1;
+      return kTRUE;
+    }
+  
+  const UInt_t nruns = fRuns->GetNumRuns();
+  
   if (nruns == 0)
     return kFALSE;
@@ -939,34 +1268,35 @@
                                    MHCalibrationChargeBlindCam &blindcam)
 {
-    Int_t run = fSequence ? fSequence->GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];
-
-    //
-    // Initialize the blind pixel. Unfortunately, there is a hardware difference
-    // in the first blind pixel until run "gkSecondBlindPixelInstallation" and the
-    // later setup. The first needs to use a filter because of the length of
-    // spurious NSB photon signals. The latter get better along extracting the amplitude
-    // from a small window.
-    //
-    if (run < gkSecondBlindPixelInstallation)
-    {
-        blindext.SetModified(kFALSE);
-        blindext.SetExtractionType(MExtractBlindPixel::kIntegral);
-        blindext.SetExtractionType(MExtractBlindPixel::kFilter);
-        blindext.SetRange(10,19,0,6);
-        blindext.SetNSBFilterLimit(70);
-        blindcam.SetFitFunc( MHCalibrationChargeBlindPix::kEPoisson5 );
-    }
-    else
-    {
-        blindext.SetModified(kTRUE);
-        blindext.SetExtractionType(MExtractBlindPixel::kAmplitude);
-        blindext.SetExtractionType(MExtractBlindPixel::kFilter);
-        blindext.SetRange(5,8,0,2);
-        blindext.SetNSBFilterLimit(38);
-
-        if (run < gkThirdBlindPixelInstallation)
-            blindext.SetNumBlindPixels(2);
-        else
-            blindext.SetNumBlindPixels(3);
+
+  Int_t run = fSequence ? fSequence->GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];
+  
+  //
+  // Initialize the blind pixel. Unfortunately, there is a hardware difference
+  // in the first blind pixel until run "gkSecondBlindPixelInstallation" and the
+  // later setup. The first needs to use a filter because of the length of
+  // spurious NSB photon signals. The latter get better along extracting the amplitude
+  // from a small window.
+  //
+  if (run < gkSecondBlindPixelInstallation)
+    {
+      blindext.SetModified(kFALSE);
+      blindext.SetExtractionType(MExtractBlindPixel::kIntegral);
+      blindext.SetExtractionType(MExtractBlindPixel::kFilter);
+      blindext.SetRange(10,19,0,6);
+      blindext.SetNSBFilterLimit(70);
+      blindcam.SetFitFunc( MHCalibrationChargeBlindPix::kEPoisson5 );
+    }
+  else
+    {
+      blindext.SetModified(kTRUE);
+      blindext.SetExtractionType(MExtractBlindPixel::kAmplitude);
+      blindext.SetExtractionType(MExtractBlindPixel::kFilter);
+      blindext.SetRange(5,8,0,2);
+      blindext.SetNSBFilterLimit(38);
+      
+      if (run < gkThirdBlindPixelInstallation)
+        blindext.SetNumBlindPixels(2);
+      else
+        blindext.SetNumBlindPixels(3);
     }
 }
@@ -1083,4 +1413,6 @@
     MExtractTimeFastSpline   timespline;
     MCalibrationChargeCalc   calcalc;
+    MCalibrationRelTimeCalc  timecalc;
+
     if (!fSequence)
     {
@@ -1149,7 +1481,5 @@
 
     tlist.AddToList(&fillcam);
-    tlist.AddToList(&calcalc);
-
-    MCalibrationRelTimeCalc timecalc;
+
     if (fRelTimes)
     {
@@ -1158,4 +1488,10 @@
     }
 
+    if (IsUseBlindPixel())
+      tlist.AddToList(&fillbnd);
+    if (IsUsePINDiode())
+      tlist.AddToList(&fillpin);
+
+    tlist.AddToList(&calcalc);
 
     // Create and setup the eventloop
@@ -1181,34 +1517,32 @@
     // the display. No idea where this comes from...
     //
-    /*
     if (fDisplay)
     {
-        if (IsUsePINDiode())
+      if (IsUsePINDiode())
         {
-            MHCalibrationChargePINDiode *pin =
-                (MHCalibrationChargePINDiode*)plist.FindObject("MHCalibrationChargePINDiode");
-            pin->DrawClone(Form("nonew %s",drawoption.Data()));
+          MHCalibrationChargePINDiode *pin =
+            (MHCalibrationChargePINDiode*)plist.FindObject("MHCalibrationChargePINDiode");
+          pin->DrawClone(Form("nonew %s",drawoption.Data()));
         }
-        else if (IsUseBlindPixel())
+      else if (IsUseBlindPixel())
         {
-            MHCalibrationChargeBlindCam *cam =
-                (MHCalibrationChargeBlindCam*)plist.FindObject("MHCalibrationChargeBlindCam");
+          MHCalibrationChargeBlindCam *cam =
+            (MHCalibrationChargeBlindCam*)plist.FindObject("MHCalibrationChargeBlindCam");
+          cam->DrawClone(Form("nonew %s",drawoption.Data()));
+        }
+      else if (fRelTimes)
+        {
+          MHCalibrationRelTimeCam *cam =
+            (MHCalibrationRelTimeCam*)plist.FindObject("MHCalibrationRelTimeCam");
             cam->DrawClone(Form("nonew %s",drawoption.Data()));
         }
-        else if (fRelTimes)
+      else
         {
-            MHCalibrationRelTimeCam *cam =
-                (MHCalibrationRelTimeCam*)plist.FindObject("MHCalibrationRelTimeCam");
-            cam->DrawClone(Form("nonew %s",drawoption.Data()));
+          MHCalibrationChargeCam *cam =
+            (MHCalibrationChargeCam*)plist.FindObject("MHCalibrationChargeCam");
+          cam->DrawClone(Form("nonew %s",drawoption.Data()));
         }
-        else
-        {
-            MHCalibrationChargeCam *cam =
-                (MHCalibrationChargeCam*)plist.FindObject("MHCalibrationChargeCam");
-            cam->DrawClone(Form("nonew %s",drawoption.Data()));
-        }
-    }
-    */
-
+    }
+    
     DisplayResult(plist);
 
@@ -1377,2 +1711,77 @@
 }
 
+void MJCalibration::DisplayDoubleProject(MHCamera *cam, const char* whatsmall, const char* whatbig) const
+{
+  
+  TArrayI inner(1);
+  inner[0] = 0;
+  
+  TArrayI outer(1);
+  outer[0] = 1;
+          
+  TArrayI s0(6);
+  s0[0] = 6;
+  s0[1] = 1;
+  s0[2] = 2;
+  s0[3] = 3;
+  s0[4] = 4;
+  s0[5] = 5;
+  
+  TArrayI s1(3);
+  s1[0] = 6;
+  s1[1] = 1;
+  s1[2] = 2;
+  
+  TArrayI s2(3);
+  s2[0] = 3;
+  s2[1] = 4;
+  s2[2] = 5;
+  
+  TVirtualPad *pad = gPad;
+  pad->Divide(2,1);
+  
+  TH1D *inout[2];
+  inout[0] = cam->ProjectionS(s0, inner, "Inner");
+  inout[1] = cam->ProjectionS(s0, outer, "Outer");
+  FixDataCheckHist(inout[0]);
+  FixDataCheckHist(inout[1]);
+  
+  inout[0]->SetTitle(Form("%s %s",cam->GetTitle(),"Inner"));
+  inout[1]->SetTitle(Form("%s %s",cam->GetTitle(),"Outer"));
+  
+  for (int i=0; i<2; i++)
+    {
+      pad->cd(i+1);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      
+      inout[i]->SetDirectory(NULL);
+      inout[i]->SetLineColor(kRed+i);
+      inout[i]->SetBit(kCanDelete);
+      inout[i]->Draw();
+      inout[i]->Fit("gaus", "Q");
+      
+      TLegend *leg2 = new TLegend(0.6,0.5,0.9,0.7);
+      //
+      // Display the outliers as dead and noisy pixels
+      //
+      DisplayOutliers(inout[i],whatsmall,whatbig);
+      
+      //
+      // Display the two half of the camera separately
+      //
+      TH1D *half[2];
+      half[0] = cam->ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
+      half[1] = cam->ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
+      
+      for (int j=0; j<2; j++)
+        {
+          half[j]->SetLineColor(kRed+i+2*j+1);
+          half[j]->SetDirectory(NULL);
+          half[j]->SetBit(kCanDelete);
+          half[j]->Draw("same");
+          leg2->AddEntry(half[j], half[j]->GetName(), "l");
+        }
+      leg2->Draw();
+    }
+}
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibration.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 4619)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 4620)
@@ -31,5 +31,6 @@
 class MExtractBlindPixel;
 class MHCalibrationChargeBlindCam;
-
+class MHCamera;
+class TH1D;
 class MJCalibration : public MParContainer
 {
@@ -79,4 +80,9 @@
 
     void   DisplayResult(MParList &plist);
+    void   DisplayReferenceLines(MHCamera *cam, const Int_t what) const;
+    void   DisplayOutliers(TH1D *hist, const char* whatsmall, const char* whatbig) const;
+    void   DisplayDoubleProject(MHCamera *cam, const char* whatsmall, const char* whatbig) const;
+    void   FixDataCheckHist(TH1D *hist) const;
+
     Bool_t WriteResult();
     void   CheckEnv();
