Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4955)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4956)
@@ -33,4 +33,8 @@
    * mbase/BaseLinkDef.h
      - new class analogously to MArrayD
+
+   * mhbase/MH.[h,cc]
+     - added functions ProjectArray(MArrayD,...) 
+       and ProjectArray(MArrayF,...)
 
 
Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 4955)
+++ trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 4956)
@@ -73,4 +73,7 @@
 #include "MBinning.h"
 
+#include "MArrayD.h"
+#include "MArrayF.h"
+
 ClassImp(MH);
 
@@ -1142,5 +1145,6 @@
 // M.Gaug added this withouz Documentation
 //
-TH1I* MH::ProjectArray(const TArrayF &array, Int_t nbins, const char* name, const char* title)
+TH1I* MH::ProjectArray(const TArrayF &array, Int_t nbins, 
+                       const char* name, const char* title)
 {
     const Int_t size = array.GetSize();
@@ -1229,2 +1233,94 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// M.Gaug added this withouz Documentation
+//
+TH1I* MH::ProjectArray(const MArrayF &array, Int_t nbins, 
+                       const char* name, const char* title)
+{
+    const Int_t size = array.GetSize();
+
+    TH1I *h1=0;
+
+    //check if histogram with identical name exist
+    TObject *h1obj = gROOT->FindObject(name);
+    if (h1obj && h1obj->InheritsFrom("TH1I"))
+    {
+        h1 = (TH1I*)h1obj;
+        h1->Reset();
+    }
+
+    Double_t min = size>0 ? array[0] : 0;
+    Double_t max = size>0 ? array[0] : 1;
+
+    // first loop over array to find the min and max
+    for (Int_t i=1; i<size;i++)
+    {
+        max = TMath::Max((Double_t)array[i], max);
+        min = TMath::Min((Double_t)array[i], min);
+    }
+
+    Int_t newbins = 0;
+    FindGoodLimits(nbins, newbins, min, max, kFALSE);
+
+    if (!h1)
+    {
+        h1 = new TH1I(name, title, nbins, min, max);
+        h1->SetXTitle("");
+        h1->SetYTitle("Counts");
+        h1->SetDirectory(gROOT);
+    }
+
+    // Second loop to fill the histogram
+    for (Int_t i=0;i<size;i++)
+        h1->Fill(array[i]);
+
+    return h1;
+}
+
+// --------------------------------------------------------------------------
+//
+// M.Gaug added this withouz Documentation
+//
+TH1I* MH::ProjectArray(const MArrayD &array, Int_t nbins, const char* name, const char* title)
+{
+    const Int_t size = array.GetSize();
+    TH1I *h1=0;
+
+    //check if histogram with identical name exist
+    TObject *h1obj = gROOT->FindObject(name);
+    if (h1obj && h1obj->InheritsFrom("TH1I"))
+    {
+        h1 = (TH1I*)h1obj;
+        h1->Reset();
+    }
+
+    Double_t min = size>0 ? array[0] : 0;
+    Double_t max = size>0 ? array[0] : 1;
+
+    // first loop over array to find the min and max
+    for (Int_t i=1; i<size;i++)
+    {
+        max = TMath::Max(array[i], max);
+        min = TMath::Min(array[i], min);
+    }
+
+    Int_t newbins = 0;
+    FindGoodLimits(nbins, newbins, min, max, kFALSE);
+
+    if (!h1)
+    {
+        h1 = new TH1I(name, title, newbins, min, max);
+        h1->SetXTitle("");
+        h1->SetYTitle("Counts");
+        h1->SetDirectory(gROOT);
+    }
+
+    // Second loop to fill the histogram
+    for (Int_t i=0;i<size;i++)
+        h1->Fill(array[i]);
+
+    return h1;
+}
+
Index: trunk/MagicSoft/Mars/mhbase/MH.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.h	(revision 4955)
+++ trunk/MagicSoft/Mars/mhbase/MH.h	(revision 4956)
@@ -14,4 +14,6 @@
 class TArrayF;
 class TArrayD;
+class MArrayF;
+class MArrayD;
 class TCanvas;
 
@@ -96,4 +98,8 @@
     static TH1I* ProjectArray(const TArrayD &array, Int_t nbins=30,
                               const char* name="ProjectArray", const char* title="Projected Array");
+    static TH1I* ProjectArray(const MArrayF &array, Int_t nbins=30,
+                              const char* name="ProjectArray", const char* title="Projected Array");
+    static TH1I* ProjectArray(const MArrayD &array, Int_t nbins=30,
+                              const char* name="ProjectArray", const char* title="Projected Array");
     
     static void ProjectionX(TH1D &dest, const TH2 &src, Int_t firstybin=-1, Int_t lastybin=9999);
