Index: trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc	(revision 9336)
+++ trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc	(revision 9337)
@@ -89,22 +89,4 @@
 // --------------------------------------------------------------------------
 //
-// Check for the run type. Return kTRUE if it is a MC run or if there
-// is no MC run header (old camera files) kFALSE in case of a different
-// run type
-//
-Bool_t MMcCalibrationUpdate::CheckRunType(MParList *pList) const
-{
-    const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
-    if (!run)
-    {
-        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
-        return kTRUE;
-    }
-
-    return run->IsMonteCarloRun();
-}
-
-// --------------------------------------------------------------------------
-//
 // Make sure, that there is an MCalibrationCam Object in the Parameter List.
 //
@@ -150,13 +132,36 @@
 Bool_t MMcCalibrationUpdate::ReInit(MParList *pList)
 {
+    const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
+    if (!run)
+    {
+        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
+        return kTRUE;
+    }
+
     //
     // If it is no MC file skip this function...
     //
     fGeom = 0;
-    if (!CheckRunType(pList))
+    if (run->IsMonteCarloRun())
     {
         *fLog << inf << "This is no MC file... skipping." << endl;
         return kTRUE;
     }
+
+    const MMcRunHeader* mcrunh = (MMcRunHeader*) pList->FindObject(AddSerialNumber("MMcRunHeader"));
+    if (!mcrunh)
+    {
+        *fLog << err << AddSerialNumber("MMcRunHeader") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (mcrunh->IsCeres())
+    {
+        *fLog << inf;
+        *fLog << "This is a ceres file... skipping." << endl;
+        *fLog << "   MCalibrationChargeCam (calibration constants), MCalibrationQECam (avg quantum efficiency)" << endl;
+        *fLog << "   and MPedPhotCam (randomly extracted pedestal) not updated." << endl;
+        return kTRUE;
+    }
 	
     //
@@ -174,11 +179,4 @@
     {
         *fLog << err << AddSerialNumber("MMcFadcHeader") << " not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    MMcRunHeader* mcrunh = (MMcRunHeader*) pList->FindObject(AddSerialNumber("MMcRunHeader"));
-    if (!mcrunh)
-    {
-        *fLog << err << AddSerialNumber("MMcRunHeader") << " not found... aborting." << endl;
         return kFALSE;
     }
Index: trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc	(revision 9336)
+++ trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc	(revision 9337)
@@ -41,5 +41,5 @@
 //  -------
 //
-//   - Corsika spectrun: dN/dE = A * E^(a)
+//   - Corsika spectrum: dN/dE = A * E^(a)
 //     with a = fOldSlope, and A = N/integral{E*de} from ELowLim to EUppLim
 //
@@ -90,4 +90,5 @@
 #include "MLogManip.h"
 
+#include "MString.h"
 #include "MParList.h"
 #include "MParameters.h"
@@ -204,5 +205,5 @@
 TString MMcSpectrumWeight::ReplaceX(TString str) const
 {
-    return str.ReplaceAll(Form("%s.fEnergy", fNameMcEvt.Data()), "(x)");
+    return str.ReplaceAll(MString::Format("%s.fEnergy", fNameMcEvt.Data()), "(x)");
 }
 
@@ -216,5 +217,5 @@
 TString MMcSpectrumWeight::GetFormulaSpecOld(const char *name) const
 {
-    return Form("pow(%s.fEnergy, %.3f)", name, fOldSlope);
+    return MString::Format("pow(%s.fEnergy, %.3f)", name, fOldSlope);
 }
 
@@ -231,7 +232,7 @@
 TString MMcSpectrumWeight::GetFormulaSpecNew(const char *name) const
 {
-    TString str = fFormula.IsNull() ? Form("pow(%s.fEnergy, %.3f)", name, fNewSlope) : fFormula.Data();
+    TString str = fFormula.IsNull() ? MString::Format("pow(%s.fEnergy, %.3f)", name, fNewSlope) : fFormula;
     if (!fFormula.IsNull())
-        str.ReplaceAll("X", Form("(%s.fEnergy)", name));
+        str.ReplaceAll("X", MString::Format("(%s.fEnergy)", name));
 
     return str;
@@ -265,5 +266,5 @@
 {
     if (GetFormulaSpecOld()==GetFormulaSpecNew())
-        return Form("%.16e", fNorm);
+        return MString::Format("%.16e", fNorm);
 
     const Double_t iold = fNormEnergy<0 ? GetSpecOldIntegral() : CalcSpecOld(fNormEnergy);
@@ -272,5 +273,5 @@
     const Double_t norm = fNorm*iold/inew;
 
-    return Form("%.16e*(%s)/(%s)", norm, GetFormulaSpecNew(name).Data(), GetFormulaSpecOld(name).Data());
+    return MString::Format("%.16e*(%s)/(%s)", norm, GetFormulaSpecNew(name).Data(), GetFormulaSpecOld(name).Data());
 }
 
@@ -388,4 +389,16 @@
     }
 
+    if (fNormEnergy<0 && fEnergyMin>0 && TMath::Abs(fEnergyMin-rh.GetELowLim())>1e-10)
+    {
+        *fLog << err;
+        *fLog << "You try to use changing minimum simulated Monte Carlo energies" << endl;
+        *fLog << "together with a normalization calculated from the integral." << endl;
+        *fLog << "This is not yet supported. Please switch to a normalization" << endl;
+        *fLog << "at a dedicated energy by specifying the energy" << endl;
+        *fLog << "    MMcSpectrumWeight.NormEnergy: 500" << endl;
+        *fLog << "in your sponde.rc." << endl;
+        return kFALSE;
+    }
+
     fOldSlope  = rh.GetSlopeSpec();
     fEnergyMin = rh.GetELowLim();
@@ -413,6 +426,6 @@
 
     fFunc = new TF1("", GetFormulaWeightsX().Data());
+    fFunc->SetName("SpectralWeighs");
     gROOT->GetListOfFunctions()->Remove(fFunc);
-    fFunc->SetName("SpectralWeighs");
 
     return kTRUE;
@@ -465,10 +478,10 @@
     const TAxis &axey = *h.GetYaxis();
 
-    // Find energy range between the minimum energy to be filles (emin)
+    // Find energy range between the minimum energy to be filled (emin)
     // and the minimum energy corresponding to the data filled into
     // this histogram (fEnergyMin)
     const Int_t first = axey.FindFixBin(emin);
-    const Int_t last  = axey.FindFixBin(fEnergyMin);
-    const Int_t max   = axey.FindFixBin(fEnergyMax);
+    const Int_t last  = axey.FindFixBin(fEnergyMin); // data range min energy
+    const Int_t max   = axey.FindFixBin(fEnergyMax); // data range max energy
 
     for (int x=1; x<=h.GetNbinsX(); x++)
@@ -537,5 +550,5 @@
     }
     *fLog << " Additional user norm.:    " << fNorm << endl;
-    *fLog << " Spectra are normalized:   " << (fNormEnergy<0?"by integral":Form("at %.1fGeV", fNormEnergy)) << endl;
+    *fLog << " Spectra are normalized:   " << (fNormEnergy<0?"by integral":MString::Format("at %.1fGeV", fNormEnergy)) << endl;
     if (hasold)
     {
