Index: /trunk/FACT++/drive/TPointGui.cc
===================================================================
--- /trunk/FACT++/drive/TPointGui.cc	(revision 18624)
+++ /trunk/FACT++/drive/TPointGui.cc	(revision 18625)
@@ -1,6 +1,11 @@
 #include "TPointGui.h"
 
+#include <iomanip>
 #include <fstream>
 #include <stdlib.h>
+
+#include <TROOT.h>
+#include <TClass.h>
+#include <TSystem.h>
 
 #include <TGLabel.h>
@@ -24,23 +29,19 @@
 #include <TGraphErrors.h>
 
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MGList.h"
-
 #include "TPointStar.h"
 
-ClassImp(TPointGui);
-
 using namespace std;
 
-TPointGui::TPointGui(const char *fname, const char *mod) : TGMainFrame(gClient->GetRoot(), 750, 435, kHorizontalFrame), fExitLoopOnClose(kFALSE),
-   fAzMin(-180), fAzMax(180), fZdMin(0), fZdMax(90), fMagMin(0), fLimit(0.05)
+TPointGui::TPointGui(const string fname, const string mod) : TGMainFrame(gClient->GetRoot(), 650, 435, kHorizontalFrame), fExitLoopOnClose(kFALSE),
+   fAzMin(0), fAzMax(360), fZdMin(0), fZdMax(90), fMagMax(10), fLimit(0.05)
 {
     fCoordinates.SetOwner();
     fOriginal.SetOwner();
 
-    fList = new MGList;
+    fList = new TList;
     fList->SetOwner();
+
+    gROOT->GetListOfCleanups()->Add(fList);
+    fList->SetBit(kMustCleanup);
 
     fFont = gVirtualX->LoadQueryFont("7x13bold");
@@ -90,5 +91,5 @@
         AddCheckButton(vframe, fBending.GetVarName(i), i);
 
-    TGButton *but = (TGButton*)fList->FindWidget(0);
+    TGButton *but = (TGButton*)FindWidget(0);
 
     comp->AddFrame(vframe, hints3);
@@ -213,5 +214,5 @@
     TGTextEntry *entry1 = new TGTextEntry(v1, Form("%.1f", fAzMin),  kIdAzMin);
     TGTextEntry *entry2 = new TGTextEntry(v2, Form("%.1f", fAzMax),  kIdAzMax);
-    TGTextEntry *entry3 = new TGTextEntry(v3, Form("%.1f", fMagMin), kIdMagMin);
+    TGTextEntry *entry3 = new TGTextEntry(v3, Form("%.1f", fMagMax), kIdMagMax);
     TGTextEntry *entry4 = new TGTextEntry(v1, Form("%.1f", fZdMin),  kIdZdMin);
     TGTextEntry *entry5 = new TGTextEntry(v2, Form("%.1f", fZdMax),  kIdZdMax);
@@ -251,24 +252,27 @@
 
     // FIXME: Move this to the rc-file.
-    ((TGCheckButton*)fList->FindWidget(0))->SetState(kButtonDown);
-    ((TGCheckButton*)fList->FindWidget(1))->SetState(kButtonDown);
-    ((TGCheckButton*)fList->FindWidget(5))->SetState(kButtonDown);
-    ((TGCheckButton*)fList->FindWidget(6))->SetState(kButtonDown);
-    ((TGCheckButton*)fList->FindWidget(9))->SetState(kButtonDown);
-    ((TGCheckButton*)fList->FindWidget(11))->SetState(kButtonDown);
-    ((TGCheckButton*)fList->FindWidget(15))->SetState(kButtonDown);
-    ((TGCheckButton*)fList->FindWidget(16))->SetState(kButtonDown);
-    ((TGCheckButton*)fList->FindWidget(17))->SetState(kButtonDown);
-
-    ((TGCheckButton*)fList->FindWidget(19))->SetState(kButtonDisabled);
-    ((TGCheckButton*)fList->FindWidget(20))->SetState(kButtonDisabled);
-    ((TGCheckButton*)fList->FindWidget(21))->SetState(kButtonDisabled);
-    ((TGCheckButton*)fList->FindWidget(22))->SetState(kButtonDisabled);
-
-    ((TGCheckButton*)fList->FindWidget(19+2*MPointing::GetNumPar()))->SetState(kButtonDisabled);
-    ((TGCheckButton*)fList->FindWidget(20+2*MPointing::GetNumPar()))->SetState(kButtonDisabled);
-    ((TGCheckButton*)fList->FindWidget(21+2*MPointing::GetNumPar()))->SetState(kButtonDisabled);
-    ((TGCheckButton*)fList->FindWidget(22+2*MPointing::GetNumPar()))->SetState(kButtonDisabled);
-
+    ((TGCheckButton*)FindWidget(0))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(1))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(3))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(4))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(5))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(6))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(7))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(8))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(11))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(12))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(13))->SetState(kButtonDown);
+    ((TGCheckButton*)FindWidget(14))->SetState(kButtonDown);
+/*
+    ((TGCheckButton*)FindWidget(19))->SetState(kButtonDisabled);
+    ((TGCheckButton*)FindWidget(20))->SetState(kButtonDisabled);
+    ((TGCheckButton*)FindWidget(21))->SetState(kButtonDisabled);
+    ((TGCheckButton*)FindWidget(22))->SetState(kButtonDisabled);
+
+    ((TGCheckButton*)FindWidget(19+2*MPointing::GetNumPar()))->SetState(kButtonDisabled);
+    ((TGCheckButton*)FindWidget(20+2*MPointing::GetNumPar()))->SetState(kButtonDisabled);
+    ((TGCheckButton*)FindWidget(21+2*MPointing::GetNumPar()))->SetState(kButtonDisabled);
+    ((TGCheckButton*)FindWidget(22+2*MPointing::GetNumPar()))->SetState(kButtonDisabled);
+*/
     SetWindowName("Telesto");
     SetIconName("Telesto");
@@ -279,8 +283,8 @@
     MapWindow();
 
-    if (!TString(fname).IsNull())
-        LoadStars(fname);
-    if (!TString(mod).IsNull())
-        fBending.Load(mod);
+    if (!fname.empty())
+        LoadStars(fname.c_str());
+    if (!mod.empty())
+        fBending.Load(mod.c_str());
 
     DisplayBending();
@@ -306,4 +310,5 @@
     bend.SetParameters(par); // Set Parameters [deg] to MPointing
 
+    int cnt = 0;
     for (int i=0; i<fCoordinates.GetSize(); i++)
     {
@@ -312,17 +317,18 @@
         if (set.GetStarZd()<fZdMin || set.GetStarZd()>fZdMax ||
             set.GetStarAz()<fAzMin || set.GetStarAz()>fAzMax ||
-            set.GetMag()   <fMagMin)
+            set.GetMag()   >fMagMax)
             continue;
 
         set.Adjust(bend);
 
-        Double_t err = 0.01; // [deg] = 0.25SE
+        Double_t err = 0.0043; // [deg]
         Double_t res = set.GetResidual();//(&err);
         res /= err;
 
         f += res*res;
-    }
-
-    f /= fCoordinates.GetSize();
+        cnt++;
+    }
+
+    f /= cnt;
 }
 
@@ -351,5 +357,5 @@
 void TPointGui::AddResetButton(TGCompositeFrame *f, Int_t id, TGLayoutHints *h, Int_t height)
 {
-    TGPictureButton *but = new TGPictureButton(f, "tpoint/skull.xpm", id);
+    TGPictureButton *but = new TGPictureButton(f, "drive/skull.xpm", id);
     but->SetHeight(height); // Offsets from TGLayout
     but->SetWidth(height);
@@ -395,11 +401,11 @@
 {
     TGLabel *l1 = (TGLabel*)fLabel.At(3*MPointing::GetNumPar()+1);
-    l1->SetText(Form("Before: %.1f +- %.1f SE", before, 0.));
+    l1->SetText(Form("Before: %.1f arcsec", before*360*3600/16384));
 
     TGLabel *l2 = (TGLabel*)fLabel.At(3*MPointing::GetNumPar()+2);
-    l2->SetText(Form("After:  %.1f +- %.1f SE", after, 0.));
+    l2->SetText(Form("After:  %.1f arcsec", after*360*3600/16384));
 
     TGLabel *l3 = (TGLabel*)fLabel.At(3*MPointing::GetNumPar()+3);
-    l3->SetText(Form("Backw:  %.1f +- %.1f SE", backw, 0.));
+    l3->SetText(Form("Backw:  %.1f arcsec", backw*360*3600/16384));
 }
 
@@ -410,5 +416,5 @@
     if (!view)
     {
-        gLog << err << "No View!" << endl;
+        cout << "No View!" << endl;
         return;
     }
@@ -434,5 +440,5 @@
     if (!view)
     {
-        gLog << err << "No View!" << endl;
+        cout << "No View!" << endl;
         return;
     }
@@ -548,5 +554,5 @@
     if (!view)
     {
-        gLog << err << "No View!" << endl;
+        cout << "No View!" << endl;
         return;
     }
@@ -555,5 +561,5 @@
     if (!fin)
     {
-        gLog << err << "ERROR - " << fname << " not found." << endl;
+        cout << "ERROR - " << fname << " not found." << endl;
         return;
     }
@@ -621,5 +627,5 @@
     if (!fin)
     {
-        gLog << err << "Collection '" << fname << "' not found!" << endl;
+        cout << "Collection '" << fname << "' not found!" << endl;
         return;
     }
@@ -637,11 +643,11 @@
         if (line.Length()==0)
             continue;
-
+/*
         if (!line.EndsWith(".txt"))
         {
-            gLog << warn << "WARNING: " << line << endl;
+            cout << "WARNING: " << line << endl;
             continue;
         }
-
+*/
         LoadStars(line);
     }
@@ -667,5 +673,5 @@
     if (!fin)
     {
-        gLog << err << "File '" << fname << "' not found!" << endl;
+        cout << "File '" << fname << "' not found!" << endl;
         return;
     }
@@ -685,7 +691,7 @@
     }
 
-    gLog << all << "Found " << fOriginal.GetSize()-size;
-    gLog << " sets of coordinates in " << fname;
-    gLog << " (Total=" << fOriginal.GetSize() << ")" << endl;
+    cout << "Found " << fOriginal.GetSize()-size;
+    cout << " sets of coordinates in " << fname;
+    cout << " (Total=" << fOriginal.GetSize() << ")" << endl;
 
     fFileNameStars = fname;
@@ -695,5 +701,5 @@
 Float_t TPointGui::GetFloat(Int_t id) const
 {
-    return atof(static_cast<TGTextEntry*>(fList->FindWidget(id))->GetText());
+    return atof(static_cast<TGTextEntry*>(FindWidget(id))->GetText());
 }
 
@@ -775,6 +781,6 @@
                 fZdMax = GetFloat(kIdZdMax);
                 return kTRUE;
-            case kIdMagMin:
-                fMagMin = GetFloat(kIdMagMin);
+            case kIdMagMax:
+                fMagMax = GetFloat(kIdMagMax);
                 return kTRUE;
             case kIdLimit:
@@ -795,5 +801,5 @@
     if (fOriginal.GetSize()==0)
     {
-        gLog << warn << "Sorry, no input data loaded..." << endl;
+        cout << "Sorry, no input data loaded..." << endl;
         return;
     }
@@ -803,5 +809,5 @@
         fCoordinates.Add(new TPointStar(*(TPointStar*)fOriginal.At(i)));
 
-    gLog << all << "-----------------------------------------------------------------------" << endl;
+    cout << "-----------------------------------------------------------------------" << endl;
 
     gStyle->SetOptStat("emro");
@@ -811,7 +817,7 @@
     TH1F hres3("Res3", " Residuals after backward correction ",  fOriginal.GetSize()/3, 0, 0.3);
 
-    TProfile proaz ("ProAz",  " \\Delta profile vs. Az",  48, -180, 180);
-    TProfile prozd ("ProZd",  " \\Delta profile vs. Zd",  60,    0, 90);
-    TProfile promag("ProMag", " \\Delta profile vs. Mag", 40,    1,  4);
+    TProfile proaz ("ProAz",  " \\Delta profile vs. Az",  24, 0, 360);
+    TProfile prozd ("ProZd",  " \\Delta profile vs. Zd",  30, 0,  90);
+    TProfile promag("ProMag", " \\Delta profile vs. Mag", 10, 1,  10);
 
     hres1.SetXTitle("\\Delta [\\circ]");
@@ -856,5 +862,5 @@
     for (int i=0; i<MPointing::GetNumPar(); i++)
     {
-        TGButton *l = (TGButton*)fList->FindWidget(i);
+        TGButton *l = (TGButton*)FindWidget(i);
         minuit.FixParameter(i);
         if (l->GetState()==kButtonDown)
@@ -865,16 +871,16 @@
     //minuit.Command("SHOW LIMITS");
 
-    gLog << inf << endl;
-    gLog << "Starting fit..." << endl;
-    gLog << "For the fit an measurement error in the residual of ";
-    gLog << "0.02deg (=1SE) is assumed." << endl;
-    gLog << endl;
+    cout << endl;
+    cout << "Starting fit..." << endl;
+    cout << "For the fit an measurement error in the residual of ";
+    cout << "0.02deg (=1SE) is assumed." << endl;
+    cout << endl;
 
     Int_t ierflg = 0;
     ierflg = minuit.Migrad();
-    gLog << inf << "Migrad returns " << ierflg << endl;
+    cout << "Migrad returns " << ierflg << endl;
     // minuit.Release(2);
     ierflg = minuit.Migrad();
-    gLog << inf << "Migrad returns " << ierflg << endl << endl;
+    cout << "Migrad returns " << ierflg << endl << endl;
 
     //
@@ -883,5 +889,5 @@
     fBending.GetMinuitParameters(minuit);
     fBending.PrintMinuitParameters(minuit);
-    gLog << endl;
+    cout << endl;
     //fBending.Save("bending_magic.txt");
 
@@ -906,6 +912,6 @@
     b2.SetParameters(par);
 
-    gLog << all << endl << "Sets with Residual exceeding " << fLimit << "deg:" << endl;
-    gLog << "   StarAz  StarEl      RawAz   RawEl      Mag Residual  Filename" << endl;
+    cout << endl << "Sets with Residual exceeding " << fLimit << "deg:" << endl;
+    cout << "   StarAz  StarEl      RawAz   RawEl      Mag Residual  Filename" << endl;
 
     //
@@ -919,5 +925,5 @@
 
         ZdAz za(set0.GetStarZdAz());
-        za *=kRad2Deg;
+        za *= 180/M_PI;
 
         //
@@ -947,5 +953,5 @@
 
         if (resi>fLimit) // 0.13
-            gLog << all << " " << orig << "  <" << Form("%5.3f", resi) << ">  " << orig.GetName() << endl;
+            cout << " " << orig << "  <" << Form("%5.3f", resi) << ">  " << orig.GetName() << endl;
 
         proaz.Fill(za.Az(), set0.GetResidual(&err));
@@ -964,5 +970,5 @@
     }
 
-    gLog << "done." << endl << endl;
+    cout << "done." << endl << endl;
 
     //
@@ -971,13 +977,13 @@
     const Stat_t ov = hres2.GetBinContent(hres2.GetNbinsX()+1);
     if (ov>0)
-        gLog << warn << "WARNING: " << ov << " overflows in residuals." << endl;
-
-
-
-    gLog << inf << dec << endl;
-    gLog << "              Number of calls to FCN: " << minuit.fNfcn << endl;
-    gLog << "Minimum value found for FCN (Chi^2?): " << minuit.fAmin << endl;
-    gLog << "                  Fit-Probability(?): " << TMath::Prob(minuit.fAmin/*fOriginal.GetSize()*/, fOriginal.GetSize()-minuit.GetNumFreePars())*100 << "%" << endl;
-    gLog << "                           Chi^2/NDF: " << minuit.fAmin/(fOriginal.GetSize()-minuit.GetNumFreePars()) << endl;
+        cout << "WARNING: " << ov << " overflows in residuals." << endl;
+
+
+
+    cout << dec << endl;
+    cout << "             Number of calls to FCN: " << minuit.fNfcn << endl;
+    cout << "Minimum value found for FCN (Chi^2): " << minuit.fAmin << endl;
+    cout << "                    Fit-Probability: " << TMath::Prob(minuit.fAmin/*fOriginal.GetSize()*/, fOriginal.GetSize()-minuit.GetNumFreePars())*100 << "%" << endl;
+    cout << "                          Chi^2/NDF: " << minuit.fAmin/(fOriginal.GetSize()-minuit.GetNumFreePars()) << endl;
     //cout << "Prob(?): " << TMath::Prob(fChisquare,ndf);
 
@@ -989,6 +995,6 @@
     // bending correction itself
     //
-    gLog << endl;
-    gLog << "Checking backward correction (raw-->star):" << endl;
+    cout << endl;
+    cout << "Checking backward correction (raw-->star):" << endl;
     for (int i=0; i<fCoordinates.GetSize(); i++)
     {
@@ -1008,9 +1014,9 @@
             continue;
 
-        gLog << "DBack: " << setw(6) << set0.GetStarZd() << " " << setw(7) << set0.GetStarAz() << ":  ";
-        gLog << "ResB="<< setw(7) << res0*60 << "  ResF=" << setw(7) << res1*60 << "  |ResB-ResF|=" << setw(7) << diff*60 << " arcmin" << endl;
-    }
-    gLog << "OK." << endl;
-    gLog << endl;
+        cout << "DBack: " << setw(6) << set0.GetStarZd() << " " << setw(7) << set0.GetStarAz() << ":  ";
+        cout << "ResB="<< setw(7) << res0*60 << "  ResF=" << setw(7) << res1*60 << "  |ResB-ResF|=" << setw(7) << diff*60 << " arcmin" << endl;
+    }
+    cout << "OK." << endl;
+    cout << endl;
 
     const Double_t max1 = TMath::Max(gaz.GetHistogram()->GetMaximum(), gdaz.GetHistogram()->GetMaximum());
@@ -1022,7 +1028,7 @@
     const Double_t min3 = TMath::Min(grzd.GetHistogram()->GetMinimum(), graz.GetHistogram()->GetMinimum());
 
-    const Double_t absmax1 = TMath::Max(max1, TMath::Abs(min1));
-    const Double_t absmax2 = TMath::Max(max2, TMath::Abs(min2));
-    const Double_t absmax3 = TMath::Max(max3, TMath::Abs(min3));
+    const Double_t absmax1 = 0.05;//TMath::Max(max1, TMath::Abs(min1));
+    const Double_t absmax2 = 0.05;//TMath::Max(max2, TMath::Abs(min2));
+    const Double_t absmax3 = 0.05;//TMath::Max(max3, TMath::Abs(min3));
 
     gaz.SetMaximum(absmax1);
@@ -1232,9 +1238,9 @@
     cout << "-------------------------" << endl;
     cout << "before: " << Form("%6.4f", hres1.GetMean()) << " \xb1 " << Form("%6.4f", hres1.GetRMS()) << " deg \t";
-    cout << "before: " << Form("%4.1f", hres1.GetMean()*60) << " \xb1 " << Form("%.1f", hres1.GetRMS()*60) << " arcmin" << endl;
+    cout << "before: " << Form("%4.1f", hres1.GetMean()*3600) << " \xb1 " << Form("%.1f", hres1.GetRMS()*3600) << " arcsec" << endl;
     cout << "after:  " << Form("%6.4f", hres2.GetMean()) << " \xb1 " << Form("%6.4f", hres2.GetRMS()) << " deg \t";
-    cout << "after:  " << Form("%4.1f", hres2.GetMean()*60) << " \xb1 " << Form("%.1f", hres2.GetRMS()*60) << " arcmin" << endl;
+    cout << "after:  " << Form("%4.1f", hres2.GetMean()*3600) << " \xb1 " << Form("%.1f", hres2.GetRMS()*3600) << " arcsec" << endl;
     cout << "backw:  " << Form("%6.4f", hres3.GetMean()) << " \xb1 " << Form("%6.4f", hres3.GetRMS()) << " deg \t";
-    cout << "backw:  " << Form("%4.1f", hres3.GetMean()*60) << " \xb1 " << Form("%.1f", hres3.GetRMS()*60) << " arcmin" << endl;
+    cout << "backw:  " << Form("%4.1f", hres3.GetMean()*3600) << " \xb1 " << Form("%.1f", hres3.GetRMS()*3600) << " arcsec" << endl;
     cout << endl;
     cout << "before: " << Form("%4.1f", hres1.GetMean()*16348/360) << " \xb1 " << Form("%.1f", hres1.GetRMS()*16384/360) << " SE \t\t";
@@ -1335,2 +1341,20 @@
 }
 
+TObject *TPointGui::FindWidget(Int_t id) const
+{
+    if (id<0)
+        return NULL;
+
+    TObject *obj;
+    TIter Next(fList);
+    while ((obj=Next()))
+    {
+        const TGWidget *wid = (TGWidget*)obj->IsA()->DynamicCast(TGWidget::Class(), obj);
+        if (!wid)
+            continue;
+
+        if (id == wid->WidgetId())
+            return obj;
+    }
+    return NULL;
+}
Index: /trunk/FACT++/drive/TPointGui.h
===================================================================
--- /trunk/FACT++/drive/TPointGui.h	(revision 18624)
+++ /trunk/FACT++/drive/TPointGui.h	(revision 18625)
@@ -12,8 +12,8 @@
 #include "MPointing.h"
 
-class MGList; // To be removed!!!
 class TPointStar;
-
+class TVirtualPad;
 class TGLabel;
+class TList;
 
 class TPointGui : public TGMainFrame
@@ -33,9 +33,9 @@
         kIdZdMin,
         kIdZdMax,
-        kIdMagMin,
+        kIdMagMax,
         kIdLimit,
     };
 
-    MGList *fList;
+    TList *fList;
 
     TList fOriginal;
@@ -55,5 +55,5 @@
     Float_t fZdMin;
     Float_t fZdMax;
-    Float_t fMagMin;
+    Float_t fMagMax;
 
     Float_t fLimit;
@@ -61,4 +61,6 @@
     void Fcn(Int_t &/*npar*/, Double_t */*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/);
     static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
+
+    TObject *FindWidget(Int_t id) const;
 
     void AddTextButton(TGCompositeFrame *f, TString txt, Int_t id=-1, TGLayoutHints *h=0);
@@ -74,5 +76,5 @@
     void DrawPolLine(TVirtualPad *pad, Double_t r0, Double_t phi0, Double_t r1, Double_t phi1);
     void DrawSet(TVirtualPad *pad, TPointStar &set, Float_t scale=-1, Float_t angle=0);
-    void DrawHorizon(TVirtualPad *pad, const char *fname="horizon.dat") const;
+    void DrawHorizon(TVirtualPad *pad, const char *fname="drive/horizon.dat") const;
 
     TString OpenDialog(TString &dir, EFileDialogMode mode=kFDOpen);
@@ -88,10 +90,8 @@
 
 public:
-    TPointGui(const char *fname=NULL, const char *mod=NULL);
+    TPointGui(const std::string fname, const std::string mod);
     ~TPointGui();
 
     void SetExitLoopOnClose(Bool_t b=kTRUE) { fExitLoopOnClose=b; }
-
-    ClassDef(TPointGui, 0)
 };
 
