Index: trunk/Mars/mhflux/MHEnergyEst.cc
===================================================================
--- trunk/Mars/mhflux/MHEnergyEst.cc	(revision 10166)
+++ trunk/Mars/mhflux/MHEnergyEst.cc	(revision 10281)
@@ -254,7 +254,12 @@
     *fLog << " RMS   of Delta E/E: " << Form("%4.2f%%",  100*h->GetRMS()) << endl;
     *fLog << "Results from Histogram-Fit:" << endl;
-    *fLog << " Bias  of Delta E/E: " << Form("%+4.2f%%", 100*f->GetParameter(1)) << endl;
-    *fLog << " Sigma of Delta E/E: " << Form("%4.2f%%",  100*f->GetParameter(2)) << endl;
-    *fLog << " Res   of Delta E/E: " << Form("%4.2f%%",  100*TMath::Hypot(f->GetParameter(1), f->GetParameter(2))) << endl;
+    if (!f)
+        *fLog << " <fit did not succeed>" << endl;
+    else
+    {
+        *fLog << " Bias  of Delta E/E: " << Form("%+4.2f%%", 100*f->GetParameter(1)) << endl;
+        *fLog << " Sigma of Delta E/E: " << Form("%4.2f%%",  100*f->GetParameter(2)) << endl;
+        *fLog << " Res   of Delta E/E: " << Form("%4.2f%%",  100*TMath::Hypot(f->GetParameter(1), f->GetParameter(2))) << endl;
+    }
 
     delete h;
@@ -341,9 +346,15 @@
                 }
 
-                hx->Fit("gaus", "Q", "", -0.25, 1.0);
-                hx->GetFunction("gaus")->SetLineColor(kBlue);
-                hx->GetFunction("gaus")->SetLineWidth(2);
-                gPad=NULL;
-                gStyle->SetOptFit(101);
+                if (hx->GetEntries()>0)
+                {
+                    hx->Fit("gaus", "Q", "", -0.25, 1.0);
+                    if (hx->GetFunction("gaus"))
+                    {
+                        hx->GetFunction("gaus")->SetLineColor(kBlue);
+                        hx->GetFunction("gaus")->SetLineWidth(2);
+                        gPad=NULL;
+                        gStyle->SetOptFit(101);
+                    }
+                }
             }
         }
