Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7776)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7777)
@@ -18,4 +18,24 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2006/07/05 Thomas Bretz
+
+   * datacenter/macros/checkfileavail.C,
+     datacenter/macros/checkstardone.C, 
+     datacenter/macros/doexclusions.C, 
+     datacenter/macros/filldotraw.C,
+     datacenter/macros/fillganymed.C,
+     datacenter/macros/fillsignal.C,
+     datacenter/macros/fillstar.C,
+     datacenter/macros/setupdb.C:
+     - make sure that 'res' is correctly deleted
+     
+   * datacenter/macros/doexclusions.C:
+     - fixed some variable name overrides
+
+   * mhflux/MAlphaFitter.[h,cc]:
+     - added the possibility to DrawResult()
+
+
 
  2006/07/04 Daniela Dorner
Index: trunk/MagicSoft/Mars/datacenter/macros/checkfileavail.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/checkfileavail.C	(revision 7776)
+++ trunk/MagicSoft/Mars/datacenter/macros/checkfileavail.C	(revision 7777)
@@ -77,14 +77,9 @@
     }
 
-    TSQLRow *row=0;
-    while ((row = res->Next()))
-    {
-//        TString entry=(*row)[0];
-//        if (entry=="1970-01-01 00:00:00")
-//            return "";
-        return (*row)[0];
-    }
+    TString rc = (*row)[0];
 
-    return "";
+    delete res;
+
+    return rc;
 }
 
@@ -138,10 +133,10 @@
         cout << "run#: " << runno << endl;
         //if one value returns "" (i.e. column is NULL), 0 is returned
-        if (GetStatus(serv, rc, runno, "RunProcessStatus", "fCCFileAvail")==""
-            || GetStatus(serv, rc, runno, "RunProcessStatus", "fCaCoFileAvail")==""
-            || GetStatus(serv, rc, runno, "RunProcessStatus", "fCaCoFileFound")==""
-            || GetStatus(serv, rc, runno, "RunProcessStatus", "fTimingCorrection")==""
+        if (GetStatus(serv, rc, runno, "RunProcessStatus", "fCCFileAvail").IsNull()
+            || GetStatus(serv, rc, runno, "RunProcessStatus", "fCaCoFileAvail").IsNull()
+            || GetStatus(serv, rc, runno, "RunProcessStatus", "fCaCoFileFound").IsNull()
+            || GetStatus(serv, rc, runno, "RunProcessStatus", "fTimingCorrection").IsNull()
 //            || GetStatus(serv, rc, runno, "RunProcessStatus", "fTimingCorrection")=="1970-01-01 00:00:00"
-            || GetStatus(serv, rc, runno, "RunProcessStatus", "fRawFileAvail")=="")
+            || GetStatus(serv, rc, runno, "RunProcessStatus", "fRawFileAvail").IsNull())
             return 2;
     }
Index: trunk/MagicSoft/Mars/datacenter/macros/checkstardone.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/checkstardone.C	(revision 7776)
+++ trunk/MagicSoft/Mars/datacenter/macros/checkstardone.C	(revision 7777)
@@ -74,9 +74,9 @@
     }
 
-    TSQLRow *row=0;
-    while ((row = res->Next()))
-        return (*row)[0];
+    TString rc = (*row)[0];
 
-    return "";
+    delete res;
+
+    return rc;
 }
 
@@ -100,5 +100,5 @@
 
     //check if fStar not NULL for sequence 
-    if (GetStatus(serv, rc, datasetno, "SequenceProcessStatus", "fStar")=="")
+    if (GetStatus(serv, rc, datasetno, "SequenceProcessStatus", "fStar").IsNull())
         return 2;
 
Index: trunk/MagicSoft/Mars/datacenter/macros/doexclusions.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/doexclusions.C	(revision 7776)
+++ trunk/MagicSoft/Mars/datacenter/macros/doexclusions.C	(revision 7777)
@@ -174,6 +174,6 @@
         //get importance of exclusion-reason from database
         TString query(Form("SELECT fExcludedFDAImportance from ExcludedFDA where fExcludedFDAKEY=%s ", key.Data()));
-        TSQLResult *res = serv.Query(query);
-        if (!res)
+        TSQLResult *res2 = serv.Query(query);
+        if (!res2)
         {
             cout << "Error - could not get importance." << endl;
@@ -181,7 +181,7 @@
         }
 
-        TSQLRow *row2=res->Next();
+        TSQLRow *row2=res2->Next();
         Int_t newimp=atoi((*row2)[0]);
-        delete res;
+        delete res2;
 
         //get current importance from database
@@ -210,6 +210,6 @@
         cout << query << endl;
 
-        res = serv.Query(query);
-        if (!res)
+        res2 = serv.Query(query);
+        if (!res2)
         {
             cout << "Error - no runs to exclude" << endl;
@@ -219,5 +219,5 @@
         //compare new and old importance
         //change or keep the exclusion-reason accordingly
-        while ((row2 = res->Next()))
+        while ((row2 = res2->Next()))
         {
             if (TString((*row2)[1]).IsNull() || atoi((*row2)[1])>newimp)
@@ -227,11 +227,11 @@
                                    key.Data(), (*row2)[0]));
                 cout << "QU: " << query << endl;
-                TSQLResult *res = serv.Query(query);
-                if (!res)
+                TSQLResult *res3 = serv.Query(query);
+                if (!res3)
                 {
                     cout << "Error - could not insert exclusion" << endl;
                     return 2;
                 }
-                delete res;
+                delete res3;
                 continue;
             }
@@ -239,5 +239,5 @@
             cout << "run#: " << (*row2)[0] << " reason for exclusion is still the same" << endl;
         }
-        delete res;
+        delete res2;
     }
     delete res;
Index: trunk/MagicSoft/Mars/datacenter/macros/filldotraw.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/filldotraw.C	(revision 7776)
+++ trunk/MagicSoft/Mars/datacenter/macros/filldotraw.C	(revision 7777)
@@ -94,5 +94,9 @@
     }
 
-    return atoi((*row)[0]);
+    Int_t rc = atoi((*row)[0]);
+
+    delete res;
+
+    return rc;
 }
 
@@ -168,5 +172,5 @@
         return 2;
     }
-
+    delete res;
     return 1;
 }
Index: trunk/MagicSoft/Mars/datacenter/macros/fillganymed.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillganymed.C	(revision 7776)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillganymed.C	(revision 7777)
@@ -212,4 +212,5 @@
         return 2;
     }
+    delete res;
     return 1;
 }
Index: trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C	(revision 7776)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C	(revision 7777)
@@ -235,5 +235,5 @@
         return 2;
     }
-
+    delete res;
     return 1;
 }
Index: trunk/MagicSoft/Mars/datacenter/macros/fillstar.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillstar.C	(revision 7776)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillstar.C	(revision 7777)
@@ -337,4 +337,5 @@
         return 2;
     }
+    delete res;
 
     return 1;
Index: trunk/MagicSoft/Mars/datacenter/macros/setupdb.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/setupdb.C	(revision 7776)
+++ trunk/MagicSoft/Mars/datacenter/macros/setupdb.C	(revision 7777)
@@ -140,4 +140,6 @@
             fields += ", ";
     }
+
+    delete res;
 
     return fields;
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 7776)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 7777)
@@ -330,9 +330,9 @@
     // Assuming that bg and fit2.GetEventsBackground() are rather identical:
     const Double_t sc = er*er / fit.GetEventsBackground();
-    /*
+
      cout << MMath::SignificanceLiMaSigned(hon.Integral(1, bin), fit.GetEventsBackground()/sc, sc) << " ";
      cout << sc << " ";
      cout << fit.fChiSqBg << endl;
-     */
+
     return sc;
 }
@@ -404,5 +404,5 @@
 }
 
-void MAlphaFitter::PaintResult(Float_t x, Float_t y, Float_t size) const
+void MAlphaFitter::PaintResult(Float_t x, Float_t y, Float_t size, Bool_t draw) const
 {
     const Double_t w  = GetGausSigma();
@@ -413,16 +413,24 @@
     const TString fmt = Form("\\sigma_{L/M}=%%.1f  \\omega=%%.%df\\circ  E=%%d B=%%d  x<%%.%df  \\tilde\\chi_{b}=%%.1f  \\tilde\\chi_{s}=%%.1f  c=%%.1f  f=%%.2f",
                              l1<1?1:l1+1, l2<1?1:l2+1);
-
-    TLatex text(x, y, Form(fmt.Data(), fSignificance, w, (int)fEventsExcess,
-                           (int)fEventsBackground, m, fChiSqBg, fChiSqSignal,
-                           fCoefficients[3], fScaleFactor));
-
+    const TString txt = Form(fmt.Data(), fSignificance, w, (int)fEventsExcess,
+                             (int)fEventsBackground, m, fChiSqBg, fChiSqSignal,
+                             fCoefficients[3], fScaleFactor);
+
+    // This is totaly weired but the only way to get both options
+    // working with this nonsense implementation of TLatex
+    TLatex text(x, y, txt);
     text.SetBit(TLatex::kTextNDC);
     text.SetTextSize(size);
-    text.Paint();
+    if (draw)
+        text.DrawLatex(x, y, txt);
+    else
+        text.Paint();
 
     TLine line;
     line.SetLineColor(14);
-    line.PaintLine(m, gPad->GetUymin(), m, gPad->GetUymax());
+    if (draw)
+        line.DrawLine(m, gPad->GetUymin(), m, gPad->GetUymax());
+    else
+        line.PaintLine(m, gPad->GetUymin(), m, gPad->GetUymax());
 }
 
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 7776)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 7777)
@@ -237,5 +237,6 @@
 
     // Interface to result
-    void PaintResult(Float_t x=0.04, Float_t y=0.94, Float_t size=0.035) const;
+    void PaintResult(Float_t x=0.04, Float_t y=0.94, Float_t size=0.035, Bool_t draw=kFALSE) const;
+    void DrawResult(Float_t x=0.04, Float_t y=0.94, Float_t size=0.035) const { PaintResult(x, y, size, kTRUE); }
 
     // MTask
