Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 8770)
+++ trunk/MagicSoft/Mars/Changelog	(revision 8775)
@@ -18,4 +18,32 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2007/12/03 Thomas Bretz
+
+   * mdata/MData.h:
+     - added Print to context menu
+
+   * mhflux/MAlphaFitter.[h,cc]:
+     - added new member functions to apply scaling to off-data
+
+   * mhflux/MHAlpha.[h,cc]:
+     - added new member functions to apply scaling to off-data
+     - added a public member function which allows to reinitiate fitting
+
+   * mhist/MHCamera.cc:
+     - replaced a loop to reset the used pixels by a call to fUsed.Reset()
+
+   * mmuon/MHSingleMuon.[h,cc]:
+     - keep mean and rms of relative arrival time of the fit
+     - increased class Version accordingly
+
+   * mmuon/MMuonCalibPar.[h,cc]:
+     - keep mean and rms of relative arrival time of the fit
+     - increased class Version accordingly
+
+   * mmuon/MMuonCalibParCalc.cc:
+     - copy result of arrival time fit from histogram to storage container
+
+
 
  2007/11/28 Daniela Dorner
Index: trunk/MagicSoft/Mars/mdata/MData.h
===================================================================
--- trunk/MagicSoft/Mars/mdata/MData.h	(revision 8770)
+++ trunk/MagicSoft/Mars/mdata/MData.h	(revision 8775)
@@ -25,5 +25,5 @@
     Double_t operator()() { return GetValue(); }
 
-    void Print(Option_t *opt = "") const;
+    void Print(Option_t *opt = "") const; //*MENU*
     Bool_t AsciiWrite(ostream &out) const;
 
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 8770)
+++ 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 8770)
+++ 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 8770)
+++ 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 8770)
+++ 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
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 8770)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 8775)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.106 2007-10-13 18:56:27 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.107 2007-12-03 17:44:46 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -165,4 +165,5 @@
     rc->SetDirectory(NULL);
 
+    // fGeomCam need special treatment due to its TObjArray
     if (rc->fGeomCam && fGeomCam)
     {
@@ -191,6 +192,5 @@
 
     fUsed.Set(geom.GetNumPixels());
-    for (Int_t i=0; i<fNcells-2; i++)
-        ResetUsed(i);
+    fUsed.Reset();
 
     fBinEntries.Set(geom.GetNumPixels()+2);
Index: trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc	(revision 8770)
+++ trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc	(revision 8775)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHSingleMuon.cc,v 1.16 2007-08-06 16:50:45 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHSingleMuon.cc,v 1.17 2007-12-03 17:44:59 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -70,8 +70,13 @@
 // your results!!
 //
-// Inputcontainer:
+// InputContainer:
 //   - MGeomCam
 //   - MMuonSearchPar
 //
+//
+// Class Version 2:
+// ----------------
+//   + Double_t fRelTimeMean;   // Result of the gaus fit to the arrival time
+//   + Double_t fRelTimeSigma;  // Result of the gaus fit to the arrival time
 //
 ////////////////////////////////////////////////////////////////////////////
@@ -194,4 +199,7 @@
 Bool_t MHSingleMuon::Fill(const MParContainer *par, const Stat_t w)
 {
+    fRelTimeMean  =  0;
+    fRelTimeSigma = -1;
+
     fHistPhi.Reset();
     fHistWidth.Reset();
@@ -247,12 +255,11 @@
     fHistTime.Fit(&g1, "QNB");
 
-    //    Double_t err;
-    Double_t sig, mean, dummy;
-    gMinuit->GetParameter(1, mean, dummy);  // get the mean  value
-    gMinuit->GetParameter(2, sig,  dummy);  // get the sigma value
+    Double_t dummy;
+    gMinuit->GetParameter(1, fRelTimeMean,   dummy);  // get the mean  value
+    gMinuit->GetParameter(2, fRelTimeSigma,  dummy);  // get the sigma value
 
     // The mean arrival time which was subtracted before will
     // be added again, now
-    const Double_t tm0 = fMuonSearchPar->GetTime()+mean;
+    const Double_t tm0 = fMuonSearchPar->GetTime()+fRelTimeMean;
 
     for (Int_t i=0; i<entries; i++)
@@ -268,5 +275,5 @@
         // if the signal is not near the estimated circle, it is ignored.
         if (TMath::Abs(dist-fMuonSearchPar->GetRadius())<fMargin &&
-            TMath::Abs(pix.GetArrivalTime()-tm0) < 2*sig)
+            TMath::Abs(pix.GetArrivalTime()-tm0) < 2*fRelTimeSigma)
         {
             fHistPhi.Fill(TMath::ATan2(dx, dy)*TMath::RadToDeg(), pix.GetNumPhotons());
