Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 8767)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 8775)
@@ -630,4 +630,5 @@
 }
 */
+
 Bool_t MAlphaFitter::FitAlpha(const TH3D &hon, const TH3D &hof, Bool_t paint)
 {
@@ -646,4 +647,37 @@
 
     return rc;
+}
+
+Bool_t MAlphaFitter::ApplyScaling(const TH3D &hon, TH3D &hof, UInt_t bin) const
+{
+    const TString name1(Form("TempAlpha%06d_on",  gRandom->Integer(1000000)));
+    const TString name0(Form("TempAlpha%06d_off", gRandom->Integer(1000000)));
+
+    TH1D *h1 = hon.ProjectionZ(name1, -1, -1, bin, bin, "E");
+    TH1D *h0 = hof.ProjectionZ(name0, -1, -1, bin, bin, "E");
+    h1->SetDirectory(0);
+    h0->SetDirectory(0);
+
+    const Double_t scale = Scale(*h0, *h1);
+
+    delete h0;
+    delete h1;
+
+    for (int x=0; x<=hof.GetNbinsX()+1; x++)
+        for (int z=0; z<=hof.GetNbinsZ()+1; z++)
+        {
+            hof.SetBinContent(x, bin, z, hof.GetBinContent(x, bin, z)*scale);
+            hof.SetBinError(  x, bin, z, hof.GetBinError(  x, bin, z)*scale);
+        }
+
+    return scale>0;
+}
+
+Bool_t MAlphaFitter::ApplyScaling(const TH3D &hon, TH3D &hof) const
+{
+    for (int y=0; y<=hof.GetNbinsY()+1; y++)
+        ApplyScaling(hon, hof, y);
+
+    return kTRUE;
 }
 
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 8767)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 8775)
@@ -237,4 +237,7 @@
     Double_t Scale(TH1D &off, const TH1D &on) const;
 
+    Bool_t ApplyScaling(const TH3D &hon, TH3D &hof, UInt_t bin) const;
+    Bool_t ApplyScaling(const TH3D &hon, TH3D &hof) const;
+
     // Interface to result
     void PaintResult(Float_t x=0.04, Float_t y=0.94, Float_t size=0.035, Bool_t draw=kFALSE) const;
Index: trunk/MagicSoft/Mars/mhflux/MHAlpha.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 8767)
+++ trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 8775)
@@ -1010,10 +1010,5 @@
 Bool_t MHAlpha::Finalize()
 {
-    //TH1D *h = fHist.ProjectionZ("AlphaExc_px", -1, 9999, -1, 9999, "E");
-    //h->SetDirectory(0);
-    //Bool_t rc = fFit.Fit(*h);
-    //delete h;
-
-    if (!fFit.FitAlpha(fHist, fOffData))
+    if (!FitAlpha())
     {
         *fLog << warn << "MAlphaFitter - Fit failed..." << endl;
@@ -1099,4 +1094,12 @@
 }
 
+void MHAlpha::ApplyScaling()
+{
+    if (!fOffData)
+        return;
+
+    fFit.ApplyScaling(fHist, *const_cast<TH3D*>(fOffData));
+}
+
 Int_t MHAlpha::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
Index: trunk/MagicSoft/Mars/mhflux/MHAlpha.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHAlpha.h	(revision 8767)
+++ trunk/MagicSoft/Mars/mhflux/MHAlpha.h	(revision 8775)
@@ -104,4 +104,6 @@
     const TH1D &GetHEnergy() const { return fHEnergy; }
 
+    const TH3D *GetOffData() const { return fOffData; }
+
     // Setter
     void SetNameParameter(const char *name) { fNameParameter=name; }
@@ -132,4 +134,9 @@
     void ForceUsingSize(Bool_t b=kTRUE) { fForceUsingSize=b; }
 
+    Bool_t FitAlpha()
+    {
+        return fFit.FitAlpha(fHist, fOffData);
+    }
+
     void DrawNicePlot(const char *title="MAGIC Telescope observation", const char *watermark="preliminary") { DrawNicePlot(kTRUE, title, watermark); } //*MENU*
     void DrawNicePlot(Bool_t newc, const char *title=0, const char *watermark=0);
@@ -139,4 +146,6 @@
     virtual void InitMapping(MHMatrix *mat, Int_t type=0);
     void StopMapping();
+
+    void ApplyScaling();
 
     // TObject
