Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 3081)
+++ trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 3112)
@@ -1082,84 +1082,92 @@
 }
 
-TH1I* MH::ProjectArray(const TArrayF *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 max = 0.;
-  Double_t min = 0.;
-  Int_t newbins = 0;
-
-  // first loop over array to find the maximum:
-  for (Int_t i=0; i<size;i++)
-    if (array->At(i) > max)
-      max = array->At(i);
-
-  FindGoodLimits(nbins, newbins, min, max, kFALSE);
-
-  if (!h1)
-    {
-      h1 = new TH1I(name, title, newbins, min, max);
-      h1->SetXTitle("");
-      h1->SetYTitle("Counts");
-      h1->SetDirectory(NULL);
-    }
-  
+// --------------------------------------------------------------------------
+//
+// M.Gaug added this withouz Documentation
+//
+TH1I* MH::ProjectArray(const TArrayF &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, 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->At(i));
-
-    h1->SetEntries(size);
-    
+    for (Int_t i=0;i<size;i++)
+        h1->Fill(array[i]);
+
     return h1;
 }
 
-TH1I* MH::ProjectArray(const TArrayD *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 max = 0.;
-  Double_t min = 0.;
-  Int_t newbins = 0;
-
-  // first loop over array to find the maximum:
-  for (Int_t i=0; i<size;i++)
-    if (array->At(i) > max)
-      max = array->At(i);
-
-  FindGoodLimits( nbins, newbins, min, max, kFALSE);
-
-  if (!h1)
-    {
-      h1 = new TH1I(name, title, newbins, min, max);
-      h1->SetXTitle("");
-      h1->SetYTitle("Counts");
-      h1->SetDirectory(NULL);
-    }
-  
+// --------------------------------------------------------------------------
+//
+// M.Gaug added this withouz Documentation
+//
+TH1I* MH::ProjectArray(const TArrayD &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->At(i));
-
-    h1->SetEntries(size);
-    
+    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 3081)
+++ trunk/MagicSoft/Mars/mhbase/MH.h	(revision 3112)
@@ -92,8 +92,8 @@
     static Int_t CutEdges(TH1 *h, Int_t nbins);
 
-    static TH1I* ProjectArray(const TArrayF *array, Int_t nbins=30, const char* name="ProjectArray",
-                                                              const char* title="Projected Array");
-    static TH1I* ProjectArray(const TArrayD *array, Int_t nbins=30, const char* name="ProjectArray",
-                                                              const char* title="Projected Array");
+    static TH1I* ProjectArray(const TArrayF &array, Int_t nbins=30,
+                              const char* name="ProjectArray", const char* title="Projected Array");
+    static TH1I* ProjectArray(const TArrayD &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);
