Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4301)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4303)
@@ -33,8 +33,10 @@
 #include <TF1.h>
 #include <TFile.h>
-#include <TStyle.h>
 #include <TString.h>
 #include <TCanvas.h>
 #include <TSystem.h>
+#include <TLine.h>
+#include <TLegend.h>
+#include <TLatex.h>
 
 #include "MLog.h"
@@ -68,4 +70,10 @@
 const Double_t MJPedestal::fgPedRmsMin   = 0.;
 const Double_t MJPedestal::fgPedRmsMax   = 20.;
+const Float_t  MJPedestal::fgRefPedClosedLids    = 9.635;
+const Float_t  MJPedestal::fgRefPedExtraGalactic = 9.93;
+const Float_t  MJPedestal::fgRefPedGalactic      = 10.03;
+const Float_t  MJPedestal::fgRefPedRmsClosedLids = 1.7;
+const Float_t  MJPedestal::fgRefPedRmsExtraGalactic = 5.6;
+const Float_t  MJPedestal::fgRefPedRmsGalactic      = 6.92;
 // --------------------------------------------------------------------------
 //
@@ -173,4 +181,5 @@
     if (fDataCheck)
       {
+
         c3.cd(1);
         gPad->SetBorderMode(0);
@@ -178,9 +187,16 @@
         MHCamera *obj1=(MHCamera*)disp0.DrawCopy("hist");
         obj1->SetDirectory(NULL);
+	//
+	// for the datacheck, fix the ranges!!
+	//
         obj1->SetMinimum(fgPedestalMin);
         obj1->SetMaximum(fgPedestalMax);
-        gPad->Modified();
-        gPad->Update();
-
+	//
+	// set reference lines
+	//
+	DisplayReferenceLines(obj1,0);
+	//
+	// end reference lines
+	//
         c3.cd(3);
         gPad->SetBorderMode(0);
@@ -191,7 +207,5 @@
         gPad->SetBorderMode(0);
         gPad->SetTicks();
-        disp0.DrawProjection(7);
-        gPad->Modified();
-        gPad->Update();
+        obj1->DrawProjection(7);
 
         c3.cd(2);
@@ -202,6 +216,8 @@
         obj2->SetMinimum(fgPedRmsMin);
         obj2->SetMaximum(fgPedRmsMax);
-        gPad->Modified();
-        gPad->Update();
+	//
+	// set reference lines
+	//
+	DisplayReferenceLines(obj1,1);
 
         c3.cd(4);
@@ -213,6 +229,76 @@
         gPad->SetBorderMode(0);
         gPad->SetTicks();
-        disp1.DrawProjection(6);
-
+
+	TArrayI inner(1);
+	inner[0] = 0;
+	
+	TArrayI outer(1);
+	outer[0] = 1;
+
+        if (geomcam.InheritsFrom("MGeomCamMagic"))
+        {
+          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;
+
+          gPad->Clear();
+          TVirtualPad *pad = gPad;
+          pad->Divide(2,1);
+          
+          TH1D *inout[2];
+          inout[0] = disp1.ProjectionS(s0, inner, "Inner");
+          inout[1] = disp1.ProjectionS(s0, outer, "Outer");
+          
+          inout[0]->SetDirectory(NULL);
+          inout[1]->SetDirectory(NULL);
+
+          for (int i=0; i<2; i++)
+            {
+	      TLegend *leg2 = new TLegend(0.6,0.2,0.9,0.55);
+	      leg2->SetHeader(inout[i]->GetName());
+              pad->cd(i+1);
+              inout[i]->SetLineColor(kRed+i);
+              inout[i]->SetBit(kCanDelete);
+              inout[i]->Draw();
+              inout[i]->Fit("gaus","Q");
+	      leg2->AddEntry(inout[i],inout[i]->GetName(),"l");
+              
+	      //
+	      // Display the outliers as dead and noisy pixels
+	      //
+	      DisplayOutliers(inout[i]);
+
+	      //
+	      // Display the two half of the camera separately
+	      //
+	      TH1D *half[2];
+	      half[0] = disp1.ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
+	      half[1] = disp1.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();
+	    }
+	}
       }
     else
@@ -221,4 +307,58 @@
         disp1.CamDraw(c3, 2, 2, 6);
       }
+}
+
+void  MJPedestal::DisplayReferenceLines(MHCamera *cam, const Int_t what) const
+{
+
+  TLine *gala = new TLine(0,
+			  what ? fgRefPedRmsGalactic : fgRefPedGalactic,cam->GetNbinsX(),
+			  what ? fgRefPedRmsGalactic : fgRefPedGalactic);
+  gala->SetBit(kCanDelete);
+  gala->SetLineColor(4);
+  gala->SetLineStyle(2);
+  gala->SetLineWidth(3);
+  gala->Draw();
+  TLine *extr = new TLine(0,
+			  what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic,cam->GetNbinsX(),
+			  what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic);  
+  extr->SetBit(kCanDelete);
+  extr->SetLineColor(5);
+  extr->SetLineStyle(2);
+  extr->SetLineWidth(3);
+  extr->Draw();
+  TLine *close = new TLine(0,
+			  what ? fgRefPedRmsClosedLids : fgRefPedClosedLids,cam->GetNbinsX(),
+			  what ? fgRefPedRmsClosedLids : fgRefPedClosedLids);  
+  close->SetBit(kCanDelete);
+  close->SetLineColor(6);
+  close->SetLineStyle(2);
+  close->SetLineWidth(3);
+  close->Draw();
+  TLegend *leg = new TLegend(0.4,0.75,0.7,0.99);
+  leg->SetBit(kCanDelete);
+  leg->AddEntry(gala,"Galactic Source","l");
+  leg->AddEntry(extr,"Extra-Galactic Source","l");
+  leg->AddEntry(close,"Closed Lids","l");
+  leg->Draw();
+}
+
+void  MJPedestal::DisplayOutliers(TH1D *hist) const
+{
+  
+  const Float_t mean  = hist->GetFunction("gaus")->GetParameter(1);
+  const Float_t lolim = mean - 3.5*hist->GetFunction("gaus")->GetParameter(2);
+  const Float_t uplim = mean + 3.5*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);
+	      
+  TLatex deadtex;
+  deadtex.SetTextSize(0.06);
+  deadtex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.1,Form("%3i dead pixels",(Int_t)dead));
+  
+  TLatex noisytex;
+  noisytex.SetTextSize(0.06);
+  noisytex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.2,Form("%3i noisy pixels",(Int_t)noisy));
+  
 }
 
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4301)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4303)
@@ -13,4 +13,5 @@
 class MRunIter;
 class MHCamera;
+class TH1D;
 class MExtractor;
 class MJPedestal : public MParContainer  
@@ -22,4 +23,12 @@
   static const Double_t fgPedRmsMin;
   static const Double_t fgPedRmsMax;  
+
+  static const Float_t  fgRefPedClosedLids;
+  static const Float_t  fgRefPedExtraGalactic;
+  static const Float_t  fgRefPedGalactic;
+
+  static const Float_t  fgRefPedRmsClosedLids;
+  static const Float_t  fgRefPedRmsExtraGalactic;
+  static const Float_t  fgRefPedRmsGalactic;
 
   TString fOutputPath;
@@ -37,4 +46,6 @@
   
   void   DisplayResult(MParList &plist);
+  void   DisplayReferenceLines(MHCamera *cam, const Int_t what) const;
+  void   DisplayOutliers(      TH1D *hist) const;
   
 public:
