Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2761)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2762)
@@ -103,5 +103,5 @@
 //  Default Constructor. To be used by the root system ONLY.
 //
-MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend)
+MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend), fYProj(NULL)
 {
     Init();
@@ -116,5 +116,5 @@
 MHCamera::MHCamera(const MGeomCam &geom, const char *name, const char *title)
 : fGeomCam(NULL), /*TH1D(name, title, geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5),
-fUsed(geom.GetNumPixels()),*/ fColors(kItemsLegend)
+                    fUsed(geom.GetNumPixels()),*/ fColors(kItemsLegend), fYProj(NULL)
 {
     //fGeomCam = (MGeomCam*)geom.Clone();
@@ -160,7 +160,10 @@
 {
     if (fGeomCam)
-        delete fGeomCam;
+      delete fGeomCam;
     if (fNotify)
-        delete fNotify;
+      delete fNotify;
+    if (fYProj)
+      delete fYProj;
+
 }
 
@@ -399,4 +402,7 @@
     gPad->SetBorderMode(0);
 
+    TString opt(option);
+    opt.ToLower();
+
     AppendPad(option);
 
@@ -414,5 +420,5 @@
 // If this makes trouble please write a bug report.
 //
-TObject *MHCamera::DrawClone(Option_t *option) const
+TObject *MHCamera::DrawClone(Option_t *option) const 
 {
    // Draw a clone of this object in the current pad
@@ -423,4 +429,5 @@
 
    TObject *newobj = Clone();
+
    if (!newobj)
        return 0;
@@ -437,5 +444,7 @@
    */
 
-   const TString opt(option);
+   TString opt(option);
+   opt.ToLower();
+
    newobj->Draw(opt.IsNull() ? GetDrawOption() : option);
 
@@ -445,4 +454,27 @@
    return newobj;
 }
+
+void MHCamera::CreateProjection()
+{
+  
+  Int_t nbins = 50;
+
+  // Create the projection histogram
+  TString ytitle(GetYaxis()->GetTitle());
+  fYProj = new TH1D(ytitle.Data(),GetTitle(),nbins,GetMinimum()-0.1,GetMaximum()+0.1);
+  fYProj->SetXTitle(ytitle.Data());
+  fYProj->SetYTitle("Nr. of pixels");
+  fYProj->Sumw2();
+  fYProj->SetDirectory(NULL);
+
+  // Fill the projected histogram
+  Double_t cont;
+  for (Int_t binx =0;binx<=GetNbinsX()+1;binx++) {
+    cont  = GetBinContent(binx);
+    if (cont) 
+      fYProj->Fill(cont);
+  }
+}
+
 
 // ------------------------------------------------------------------------
@@ -592,4 +624,13 @@
     }
 
+    if (opt.Contains("proj"))
+    {
+
+      CreateProjection();
+      opt.ReplaceAll("proj", "");
+      fYProj->Paint(opt);
+      return;
+    }
+    
     gPad->Clear();
 
