Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc	(revision 4325)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc	(revision 4326)
@@ -141,4 +141,10 @@
 #include <TVirtualPad.h>
 #include <TCanvas.h>
+#include <TStyle.h>
+#include <TF1.h>
+#include <TH2D.h>
+#include <TLine.h>
+#include <TLatex.h>
+#include <TLegend.h>
 
 ClassImp(MHCalibrationChargeCam);
@@ -150,4 +156,5 @@
 const Float_t MHCalibrationChargeCam::fgTimeLowerLimit           = 1.;
 const Float_t MHCalibrationChargeCam::fgTimeUpperLimit           = 2.;
+const Int_t   MHCalibrationChargeCam::gkNumRefColours            = 6;
 // --------------------------------------------------------------------------
 //
@@ -173,4 +180,39 @@
   SetTimeLowerLimit();
   SetTimeUpperLimit();
+
+  gkHiGainInnerRefLines.Set(gkNumRefColours);
+  gkHiGainOuterRefLines.Set(gkNumRefColours);
+  gkLoGainInnerRefLines.Set(gkNumRefColours);
+  gkLoGainOuterRefLines.Set(gkNumRefColours);
+
+  gkHiGainInnerRefLines.AddAt(245. ,0);
+  gkHiGainOuterRefLines.AddAt(217. ,0);
+  gkLoGainInnerRefLines.AddAt(20.8 ,0);
+  gkLoGainOuterRefLines.AddAt(18.9 ,0);
+
+  gkHiGainInnerRefLines.AddAt(323. ,1);
+  gkHiGainOuterRefLines.AddAt(307.5,1);
+  gkLoGainInnerRefLines.AddAt(28.0 ,1);
+  gkLoGainOuterRefLines.AddAt(26.0 ,1);
+
+  gkHiGainInnerRefLines.AddAt(1065.,2);
+  gkHiGainOuterRefLines.AddAt(932. ,2);
+  gkLoGainInnerRefLines.AddAt(121. ,2);
+  gkLoGainOuterRefLines.AddAt(108.3,2);
+
+  gkHiGainInnerRefLines.AddAt(1467.,3);
+  gkHiGainOuterRefLines.AddAt(1405.,3);
+  gkLoGainInnerRefLines.AddAt(200.2,3);
+  gkLoGainOuterRefLines.AddAt(198. ,3);
+
+  gkHiGainInnerRefLines.AddAt(180.,4);
+  gkHiGainOuterRefLines.AddAt(167.,4);
+  gkLoGainInnerRefLines.AddAt(16.5,4);
+  gkLoGainOuterRefLines.AddAt(14.0,4);
+
+  gkHiGainInnerRefLines.AddAt(211.,5);
+  gkHiGainOuterRefLines.AddAt(183.5,5);
+  gkLoGainInnerRefLines.AddAt(13.5,5);
+  gkLoGainOuterRefLines.AddAt(11.,5);
 }
 
@@ -312,11 +354,20 @@
         MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
 
-        hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Area Idx ");
         hist.SetNbins(fAverageNbins);
         hist.SetLast(2.*hist.GetLast());
         hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Area Idx ");
 
-        InitHists(hist,fCam->GetAverageBadArea(j),j);
-
+        if (fGeom->InheritsFrom("MGeomCamMagic"))
+          {
+            hist.GetHGausHist()->SetTitle(Form("%s%s%s","Signal averaged on event-by-event basis ",
+                                               j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
+            hist.InitBins();
+            hist.SetEventFrequency(fPulserFrequency);
+          }
+        else
+          {
+            hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
+            InitHists(hist,fCam->GetAverageBadArea(j),j);
+          }
       }
   }
@@ -335,10 +386,19 @@
         MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
 
-        hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Area Idx ");
         hist.SetNbins(fAverageNbins);
         hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Area Idx ");
 
-        InitHists(hist,fCam->GetAverageBadArea(j),j);
-
+        if (fGeom->InheritsFrom("MGeomCamMagic"))
+          {
+            hist.GetHGausHist()->SetTitle(Form("%s%s%s","Signal averaged on event-by-event basis ",
+                                               j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
+            hist.InitBins();
+            hist.SetEventFrequency(fPulserFrequency);
+          }
+        else
+          {
+            hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
+            InitHists(hist,fCam->GetAverageBadArea(j),j);
+          }
         }
     }
@@ -833,7 +893,20 @@
     {
       pad->cd(2*(i+1)-1);
-      GetAverageHiGainArea(i).Draw("datacheck");
+      MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(i);
+
+      if (i==0)
+        DrawDataCheckPixel(hipix,gkHiGainInnerRefLines);
+      else
+        DrawDataCheckPixel(hipix,gkHiGainOuterRefLines);
+
       pad->cd(2*(i+1));
-      GetAverageLoGainArea(i).Draw("datacheck");
+
+      MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(i);
+
+      if (i==0)
+        DrawDataCheckPixel(lopix,gkLoGainInnerRefLines);
+      else
+        DrawDataCheckPixel(lopix,gkLoGainOuterRefLines);
+
     }      
 }
@@ -907,2 +980,106 @@
 }
 
+void MHCalibrationChargeCam::DrawDataCheckPixel(MHCalibrationChargePix &pix, const TArrayF &refline)
+{
+  
+  TVirtualPad *newpad = gPad;
+  newpad->Divide(1,2);
+  newpad->cd(1);
+  
+  gPad->SetTicks();
+  if (!pix.IsEmpty())
+    gPad->SetLogy();
+
+  gStyle->SetOptStat(0);
+
+  TH1F *hist = pix.GetHGausHist();
+  
+
+  TH2D *null = new TH2D("Null",hist->GetTitle(),100,pix.GetFirst(),pix.GetLast(),
+                        100,0.,hist->GetEntries()/10.);
+
+  null->SetDirectory(NULL);
+  null->SetBit(kCanDelete);
+  null->GetXaxis()->SetTitle(hist->GetXaxis()->GetTitle());
+  null->GetYaxis()->SetTitle(hist->GetYaxis()->GetTitle());  
+  null->GetXaxis()->CenterTitle();
+  null->GetYaxis()->CenterTitle();
+  null->Draw();
+  hist->Draw("same");
+
+  gStyle->SetOptFit();
+
+  if (pix.GetFGausFit())
+  {
+      pix.GetFGausFit()->SetLineColor(pix.IsGausFitOK() ? kGreen : kRed);
+      pix.GetFGausFit()->Draw("same");
+  }
+
+  DisplayRefLines(null,refline);
+
+
+  newpad->cd(2);
+  gPad->SetTicks();
+
+  pix.DrawEvents();
+  return;
+  
+}
+
+
+void  MHCalibrationChargeCam::DisplayRefLines(const TH2D *hist, const TArrayF &refline) const
+{
+
+  TLine *green1 = new TLine(refline.At(0),0.,refline.At(0),hist->GetYaxis()->GetXmax());
+  green1->SetBit(kCanDelete);
+  green1->SetLineColor(kGreen);
+  green1->SetLineStyle(2);
+  green1->SetLineWidth(3);
+  green1->Draw();
+
+  TLine *blue1   = new TLine(refline.At(1),0.,refline.At(1),hist->GetYaxis()->GetXmax());
+  blue1->SetBit(kCanDelete);
+  blue1->SetLineColor(007);
+  blue1->SetLineStyle(2);
+  blue1->SetLineWidth(3);
+  blue1->Draw();
+
+  TLine *blue5   = new TLine(refline.At(2),0.,refline.At(2),hist->GetYaxis()->GetXmax());
+  blue5->SetBit(kCanDelete);
+  blue5->SetLineColor(062);
+  blue5->SetLineStyle(2);
+  blue5->SetLineWidth(3);
+  blue5->Draw();
+
+  TLine *blue10   = new TLine(refline.At(3),0.,refline.At(3),hist->GetYaxis()->GetXmax());
+  blue10->SetBit(kCanDelete);
+  blue10->SetLineColor(004);
+  blue10->SetLineStyle(2);
+  blue10->SetLineWidth(3);
+  blue10->Draw();
+
+  TLine *uv10    = new TLine(refline.At(4),0.,refline.At(4),hist->GetYaxis()->GetXmax());
+  uv10->SetBit(kCanDelete);
+  uv10->SetLineColor(106);
+  uv10->SetLineStyle(2);
+  uv10->SetLineWidth(3);
+  uv10->Draw();
+
+  TLine *ct1    = new TLine(refline.At(5),0.,refline.At(5),hist->GetYaxis()->GetXmax());
+  ct1->SetBit(kCanDelete);
+  ct1->SetLineColor(006);
+  ct1->SetLineStyle(2);
+  ct1->SetLineWidth(3);
+  ct1->Draw();
+
+  TLegend *leg = new TLegend(0.4,0.75,0.7,0.99);
+  leg->SetBit(kCanDelete);
+  leg->AddEntry(green1,"1 Led GREEN","l");
+  leg->AddEntry(blue1,"1 Led BLUE","l");
+  leg->AddEntry(blue5,"5 Leds BLUE","l");
+  leg->AddEntry(blue10,"10 Leds BLUE","l");
+  leg->AddEntry(uv10,"10 Leds UV","l");
+  leg->AddEntry(ct1,"CT1-Pulser","l");
+
+  leg->Draw();
+}
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h	(revision 4325)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h	(revision 4326)
@@ -6,4 +6,9 @@
 #endif
 
+#ifndef ROOT_TArrayF
+#include "TArrayF.h"
+#endif
+
+class TH2D;
 class MRawEvtData;
 class MExtractedSignalCam;
@@ -18,4 +23,10 @@
   static const Float_t fgTimeLowerLimit;             //! Default for fTimeLowerLimit    (now set to: 1.) 
   static const Float_t fgTimeUpperLimit;             //! Default for fTimeUpperLimit    (now set to: 2.)
+  static const Int_t   gkNumRefColours;
+  
+  TArrayF gkHiGainInnerRefLines;
+  TArrayF gkHiGainOuterRefLines;
+  TArrayF gkLoGainInnerRefLines;
+  TArrayF gkLoGainOuterRefLines;
   
   Float_t fTimeLowerLimit;            // Limit dist. to first signal slice (in units of FADC slices) 
@@ -37,6 +48,8 @@
   void   FinalizeBadPixels();
 
-
- public:
+  void   DrawDataCheckPixel(MHCalibrationChargePix &pix, const TArrayF &refline);
+  void   DisplayRefLines(const TH2D *hist, const TArrayF &refline) const;
+  
+public:
 
   MHCalibrationChargeCam(const char *name=NULL, const char *title=NULL);
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeLoGainPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeLoGainPix.cc	(revision 4325)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeLoGainPix.cc	(revision 4326)
@@ -42,5 +42,5 @@
 const Int_t   MHCalibrationChargeLoGainPix::fgChargeNbins     = 350;
 const Axis_t  MHCalibrationChargeLoGainPix::fgChargeFirst     = -0.5;
-const Axis_t  MHCalibrationChargeLoGainPix::fgChargeLast      = 249.5;
+const Axis_t  MHCalibrationChargeLoGainPix::fgChargeLast      = 349.5;
 const Int_t   MHCalibrationChargeLoGainPix::fgAbsTimeNbins    = 15;
 const Axis_t  MHCalibrationChargeLoGainPix::fgAbsTimeFirst    = -0.5;
