Index: trunk/Mars/mhbase/MH3.cc
===================================================================
--- trunk/Mars/mhbase/MH3.cc	(revision 9821)
+++ trunk/Mars/mhbase/MH3.cc	(revision 9829)
@@ -231,4 +231,5 @@
         break;
     case kProfile:
+    case kProfileSpread:
         fDimension = -TMath::Abs(fDimension);
         if (fDimension<-2)
@@ -246,5 +247,6 @@
         fHist = new TProfile;
         fHist->SetYTitle("Average");
-        static_cast<TProfile*>(fHist)->SetErrorOption("s");
+        if (type==kProfileSpread)
+            static_cast<TProfile*>(fHist)->SetErrorOption("s");
         break;
     case 2:
@@ -255,5 +257,6 @@
         fHist = new TProfile2D;
         fHist->SetZTitle("Average");
-        static_cast<TProfile2D*>(fHist)->SetErrorOption("s");
+        if (type==kProfileSpread)
+            static_cast<TProfile2D*>(fHist)->SetErrorOption("s");
         break;
     case 3:
@@ -330,5 +333,5 @@
 //
 MH3::MH3(const char *memberx, const char *membery, Type_t type)
-    : fDimension(type&kProfile?-1:2)
+    : fDimension(type==kHistogram?2:-1)
 {
 
@@ -340,5 +343,6 @@
     case -1:
         fHist = static_cast<TH1*>(new TProfile);
-        static_cast<TProfile*>(fHist)->SetErrorOption("s");
+        if (type==kProfileSpread)
+            static_cast<TProfile*>(fHist)->SetErrorOption("s");
 
         break;
@@ -363,12 +367,14 @@
     : fDimension(type==kHistogram?3:-2)
 {
-    if (type&kProfile)
-    {
+    switch (fDimension)
+    {
+    case 3:
+        fHist = static_cast<TH1*>(new TH3D);
+        break;
+    case -2:
         fHist = static_cast<TH1*>(new TProfile2D);
-        static_cast<TProfile2D*>(fHist)->SetErrorOption("s");
-    }
-    else
-        fHist = static_cast<TH1*>(new TH3D);
-
+        if (type==kProfileSpread)
+            static_cast<TProfile2D*>(fHist)->SetErrorOption("s");
+    }
 
     fData[0] = new MDataPhrase(memberx);
@@ -902,6 +908,12 @@
 // store the result in h.
 //
+// In the case of a TProfile we keep it a TProfile to keep the mean and
+// rms in y displayed. To get the error correctly we have to reverse
+// the calculation done in TProfile::GetBinError of course.
+//
 void MH3::Convert(TH1 &h) const
 {
+    const Bool_t prof = h.InheritsFrom(TProfile::Class()) || h.InheritsFrom(TProfile2D::Class());
+
     for (Int_t z=0; z<=h.GetNbinsZ()+1; z++)
         for (Int_t y=0; y<=h.GetNbinsY()+1; y++)
@@ -909,14 +921,21 @@
             {
                 h.SetBinContent(x, y, z, fConversion->Eval(fHist->GetBinContent(x, y, z)));
-                h.SetBinError(  x, y, z, fConversion->Eval(fHist->GetBinError(  x, y, z)));
+
+                if (prof)
+                    h.SetBinError(x, y, z, TMath::Hypot(fConversion->Eval(fHist->GetBinContent(x, y, z)),
+                                                        fConversion->Eval(fHist->GetBinError(  x, y, z))));
+                else
+                    h.SetBinError(x, y, z, fConversion->Eval(fHist->GetBinError(x, y, z)));
             }
 
-    if (h.InheritsFrom(TProfile::Class()))
-        for (Int_t x=0; x<=h.GetNbinsX()+1; x++)
-            static_cast<TProfile&>(h).SetBinEntries(x, 1);
-
-    if (h.InheritsFrom(TProfile2D::Class()))
-        for (Int_t x=0; x<=h.GetNbinsX()+1; x++)
-            static_cast<TProfile2D&>(h).SetBinEntries(x, 1);
+    TProfile *p1 = dynamic_cast<TProfile*>(fHist);
+    if (p1)
+        for (Int_t i=0; i<p1->GetSize(); i++)
+            static_cast<TProfile&>(h).SetBinEntries(i, p1->GetBinEntries(i)>0 ? 1 : 0);
+
+    TProfile *p2 = dynamic_cast<TProfile*>(fHist);
+    if (p2)
+        for (Int_t i=0; i<p2->GetSize(); i++)
+            static_cast<TProfile2D&>(h).SetBinEntries(i, p2->GetBinEntries(i)>0 ? 1 : 0);
 }
 
@@ -1054,4 +1073,5 @@
     {
         h = static_cast<TH1*>(fHist->Clone());
+
         h->SetDirectory(0);
         h->SetBit(kCanDelete);
@@ -1147,4 +1167,16 @@
 }
 
+MH3::Type_t MH3::GetType() const
+{
+    switch (fDimension)
+    {
+    case -1:
+        return TString(static_cast<TProfile*>(fHist)->GetErrorOption())=="s" ? kProfileSpread : kProfile;
+    case -2:
+        return TString(static_cast<TProfile2D*>(fHist)->GetErrorOption())=="s" ? kProfileSpread : kProfile;
+    }
+    return kHistogram;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -1167,14 +1199,10 @@
             break;
         case 2:
-            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule());
-            break;
         case -1:
-            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), MH3::kProfile);
+            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), GetType());
             break;
         case 3:
-            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule());
-            break;
         case -2:
-            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule(), MH3::kProfile);
+            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule(), GetType());
             break;
         }
Index: trunk/Mars/mhbase/MH3.h
===================================================================
--- trunk/Mars/mhbase/MH3.h	(revision 9821)
+++ trunk/Mars/mhbase/MH3.h	(revision 9829)
@@ -31,4 +31,10 @@
     };
 
+    enum Type_t {
+        kHistogram     = 0,
+        kProfile       = 1,
+        kProfileSpread = kProfile | 2,
+    };
+
 private:
     static const TString gsDefName;
@@ -44,4 +50,10 @@
     Labels_t    GetLabels() const;
     const char *GetLabel(Int_t axe, Double_t val) const;
+
+    // Get type
+    Type_t GetType() const;
+
+    // Helper for conversion
+    void Convert(TH1 &h) const;
 
     MObjLookup fLabels[3];       //! Lookup table to conflate and name labels
@@ -59,5 +71,4 @@
 
     void HandleLogAxis(TAxis &axe) const;
-    void Convert(TH1 &h) const;
 
     void StreamPrimitive(ostream &out) const;
@@ -71,9 +82,4 @@
 
 public:
-    enum Type_t {
-        kHistogram,
-        kProfile,
-    };
-
     MH3(const Int_t dim=0, Type_t type=MH3::kHistogram);
     MH3(const TH1 &h1);
