Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 7601)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 7602)
@@ -18,4 +18,39 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2006/03/14 Thomas Bretz
+
+   * mhflux/MHEffectiveOnTime.cc:
+     - skip the fit not only if the integral is empty but
+       also if the first bin is empty
+     - changed upper limit to 95% according to a study from
+       David Paneque
+     - replaced the fit with the exponential used in the BCN Mars
+       version
+     - use the correct number of entries
+     - use a likelihood fit
+     - calculate the fit quality from the probability
+     - ignore the fit quality for the theta-plot
+
+   * mimage/MHNewImagePar.cc:
+     - fixed the handling of the "same" option in Draw/Paint
+
+   * mpointing/MPointingDev.h:
+     - fDx and fDy initialized in the constructor
+
+   * mbase/MTask.[h,cc]:
+     - removed the kDontCount option. Instead don't use the TStopwatch
+       counter anymore. By this the class to TStopwatch can be
+       suppressed completely if kDontTime is set.
+
+   * mbase/MContinue.cc, mbase/MTaskEnv.cc, mfbase/MF.cc, 
+     mfbase/MFilterList.[h,cc]:
+     - pipe the accelerator flag to the filter or task
+
+   * mjobs/MJCut.cc:
+     - also accelerate the reading task
+
+
+
  2006/03/13
 
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 7601)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 7602)
@@ -3,4 +3,10 @@
  *** Version  <cvs>
 
+   - ganymed: In the second loop the MHNewImagePar histograms disapeared.
+     To display them just delete the pads displayed on top.
+
+   - ganymed: fixed a bug which could cause strange behaviour in wobble
+     mode if no starguider information was available due to an incorrect
+     initialization of the starguider calibration
 
 
Index: /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc	(revision 7601)
+++ /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc	(revision 7602)
@@ -474,5 +474,5 @@
 
     // FIXME: Do fit only if contents of bin has changed
-    if (Nm<=0)
+    if (Nm<=0 || h->GetBinContent(1)<=0)
         return kFALSE;
 
@@ -483,24 +483,18 @@
     // within the range (yq[0], yq[1]) there must be no empty bin;
     // choose pedestrian approach as long as GetQuantiles is not available
-    Double_t xq[2] = { 0.6, 0.99 };
+    Double_t xq[2] = { 0.6, 0.95 }; // previously 0.99
     Double_t yq[2];
     h->GetQuantiles(2, yq, xq);
 
-    // Nmdel = Nm * binwidth,  with Nm = number of observed events
-    const Double_t Nmdel = h->Integral("width");
-
-    //
-    // Setup Poisson function for the fit:
-    // lambda [Hz], N0 = ideal no of evts, del = bin width of dt
-    //
-    // parameter 0 = lambda
-    // parameter 1 = N0*del
-    //
-    TF1 func("Poisson", " [1]*[2] * [0] * exp(-[0] *x)");
-    //func.SetParNames("lambda", "N0", "del");
+    //
+    // Setup exponential function for the fit:
+    //
+    // parameter 0 = rate [Hz]
+    // parameter 1 = normalization
+    //
+    TF1 func("Exp", " exp([1]-[0]*x)");
 
     func.SetParameter(0, 200);       // Hz
-    func.SetParameter(1, Nm);
-    func.FixParameter(2, Nmdel/Nm);
+    func.SetParameter(1, log(h->GetBinContent(1)));       // Hz
 
     // options : N  do not store the function, do not draw
@@ -508,11 +502,13 @@
     //           R  use the range specified in the function range
     //           Q  quiet mode
-    h->Fit(&func, "NIQE", "", yq[0], yq[1]);
+    //           L  Use log-likelihood (better for low statistics)
+    h->Fit(&func, "NIQEL", "", h->GetBinLowEdge(3)/*yq[0]*/, yq[1]);
 
     const Double_t chi2 = func.GetChisquare();
+    const Double_t prob = func.GetProb();
     const Int_t    NDF  = func.GetNDF();
 
     // was fit successful ?
-    const Bool_t ok = NDF>0 && chi2<3*NDF;
+    const Bool_t ok = prob>0.001; //NDF>0 && chi2<3*NDF;
 
     if (paint)
@@ -523,27 +519,12 @@
     }
 
+    // The effective on time is the "real rate" (slope of the exponential)
+    // divided by the total number of events (histogram integral including 
+    // under- and overflows)
     const Double_t lambda = func.GetParameter(0);
-    //const Double_t N0     = func.GetParameter(1);
-    const Double_t prob   = func.GetProb();
-
-    /*
-     *fLog << all << "Nm/lambda=" << Nm/lambda << "  chi2/NDF=";
-     *fLog << (NDF ? chi2/NDF : 0.0) << "  lambda=";
-     *fLog << lambda << "  N0=" << N0 << endl;
-     */
-
-    Double_t emat[2][2];
-    gMinuit->mnemat((Double_t*)emat, 2);
-
-    const Double_t dldl  = emat[0][0];
-    //const Double_t dN0dN0 = emat[1][1];
-
-    const Double_t teff  = Nm/lambda;
-    const Double_t dteff = teff * TMath::Sqrt(dldl/(lambda*lambda) + 1.0/Nm);
-    const Double_t dl    = TMath::Sqrt(dldl);
-
-    //const Double_t kappa  = Nm/N0;
-    //const Double_t Rdead  = 1.0 - kappa;
-    //const Double_t dRdead = kappa * TMath::Sqrt(dN0dN0/(N0*N0) + 1.0/Nm);
+    const Double_t dldl   = func.GetParError(0)*func.GetParError(0);
+    const Double_t teff   = Nm / lambda;
+    const Double_t dteff  = teff * TMath::Sqrt(dldl/(lambda*lambda) + 1.0/Nm);
+    const Double_t dl     = TMath::Sqrt(dldl);
 
     // the effective on time is Nm/lambda
@@ -563,8 +544,4 @@
     // Chi2
     res[6] = chi2;
-
-    // Rdead (from fit) is the fraction from real time lost by the dead time
-    //fHRdead.SetBinContent(i, Rdead);
-    //fHRdead.SetBinError  (i,dRdead);
 
     return ok;
@@ -583,4 +560,5 @@
     fHThetaNDF.Reset();
 
+    // Use a random name to make sure the object is unique
     const TString name = Form("CalcTheta%d", (UInt_t)gRandom->Uniform(999999999));
 
@@ -594,6 +572,10 @@
         h = fH2DeltaT.ProjectionX(name, i, i, "E");
 
-        Double_t res[7];
-        if (!FitH(h, res))
+        Double_t res[7] = {0, 0, 0, 0, 0, 0, 0};
+        //if (!FitH(h, res))
+        //    continue;
+        FitH(h, res);
+
+        if (res[0]==0)
             continue;
 
