Index: trunk/MagicSoft/Cosy/tpoint/gui.C
===================================================================
--- trunk/MagicSoft/Cosy/tpoint/gui.C	(revision 7312)
+++ trunk/MagicSoft/Cosy/tpoint/gui.C	(revision 7313)
@@ -65,4 +65,5 @@
         const Double_t del = fRawEl-fStarEl;
         const Double_t daz = fRawAz-fStarAz;
+
         /*
         const Double_t dphi2 = daz/2.;
@@ -71,5 +72,4 @@
         const Double_t d = cos(del)*cos2 - cos(fRawEl+fStarEl)*sin2;
         */
-
         const Double_t d  = cos(del) - cos(fRawEl)*cos(fStarEl)*(1.-cos(daz));
 
@@ -208,4 +208,5 @@
         bend.SetParameters(par); // Set Parameters [deg] to MPointing
 
+        Int_t n=0;
         for (int i=0; i<fCoordinates.GetSize(); i++)
         {
@@ -214,6 +215,6 @@
             set.Adjust(bend);
 
-            Double_t err;// = 0.005; // [deg] = 0.25SE
-            Double_t res = set.GetResidual(&err);
+            Double_t err = 0.01; // [deg] = 0.25SE
+            Double_t res = set.GetResidual(); //(&err);
             res /= err;
 
@@ -221,7 +222,4 @@
         }
 
-        //f /= (fCoordinates.GetSize()-7)*(fCoordinates.GetSize()-7);
-        //f /= fCoordinates.GetSize()*fCoordinates.GetSize();
-        //cout << f << ": " << fCoordinates.GetSize() << endl;
         f /= fCoordinates.GetSize();
     }
@@ -256,5 +254,5 @@
         //Double_t x1[3] = { r1*cos(phi1), r1*sin(phi1), 0};
 
-        Double_t y0[3], y1[3];
+        Double_t y0[3];//, y1[3];
     
         view->WCtoNDC(x0, y0);
@@ -412,7 +410,7 @@
         TGraph gaz;
         TGraph gzd;
-        TGraph graz;
-        TGraph grzd;
-        TGraph grmag;
+        TGraphErrors graz;
+        TGraphErrors grzd;
+        TGraphErrors grmag;
         TGraph gmaz;
         TGraph gmzd;
@@ -513,14 +511,19 @@
             if (dz>180)
                 dz -= 360;
+
+            Double_t err;
     
             gdzd.SetPoint(i, za.Az(), set0.GetDZd());
             gdaz.SetPoint(i, za.Zd(), dz);
-            graz.SetPoint(i, za.Az(), set0.GetResidual());
-            grzd.SetPoint(i, za.Zd(), set0.GetResidual());
+            graz.SetPoint(i, za.Az(), set0.GetResidual(&err));
+            graz.SetPointError(i, 0, err);
+            grzd.SetPoint(i, za.Zd(), set0.GetResidual(&err));
+            grzd.SetPointError(i, 0, err);
             gaz.SetPoint( i, za.Az(), dz);
             gzd.SetPoint( i, za.Zd(), set0.GetDZd());
             if (set0.GetMag()>=-20)
             {
-                grmag.SetPoint(i, set0.GetMag(), set0.GetResidual());
+                grmag.SetPoint(i, set0.GetMag(), set0.GetResidual(&err));
+                grmag.SetPointError(i, 0, err);
                 gmaz.SetPoint( i, set0.GetMag(), dz);
                 gmzd.SetPoint( i, set0.GetMag(), set0.GetDZd());
@@ -575,13 +578,4 @@
         cout << "OK." << endl;
         cout << endl;
-    
-
-        TCanvas *c1;
-
-        if ((c1 = (TCanvas*)gROOT->FindObject("CanvGraphs")))
-            delete c1;
-        if ((c1 = (TCanvas*)gROOT->FindObject("CanvResiduals")))
-            delete c1;
-
 
         const Double_t max1 = TMath::Max(gaz.GetHistogram()->GetMaximum(), gdaz.GetHistogram()->GetMaximum());
@@ -616,5 +610,15 @@
         grmag.SetMinimum(0);
 
-        c1=new TCanvas("CanvGraphs", "Graphs");
+        TCanvas *c1;
+
+        if (gROOT->FindObject("CanvGraphs"))
+            c1 = dynamic_cast<TCanvas*>(gROOT->FindObject("CanvGraphs"));
+        else
+            c1=new TCanvas("CanvGraphs", "Graphs");
+
+        gROOT->SetSelectedPad(0);
+        c1->SetSelectedPad(0);
+        c1->Clear();
+
         c1->SetFillColor(kWhite);
         c1->Divide(3,3,1e-10,1e-10);
@@ -698,5 +702,5 @@
         gPad->SetGridx();
         gPad->SetGridy();
-        g=(TGraph*)graz.DrawClone("A*");
+        g=(TGraph*)graz.DrawClone("AP");
         g->SetBit(kCanDelete);
         g->GetHistogram()->SetXTitle("Az [\\circ]");
@@ -708,5 +712,5 @@
         gPad->SetGridx();
         gPad->SetGridy();
-        g=(TGraph*)grzd.DrawClone("A*");
+        g=(TGraph*)grzd.DrawClone("AP");
         g->SetBit(kCanDelete);
         g->GetHistogram()->SetXTitle("Zd [\\circ]");
@@ -718,5 +722,5 @@
         gPad->SetGridx();
         gPad->SetGridy();
-        g=(TGraph*)grmag.DrawClone("A*");
+        g=(TGraph*)grmag.DrawClone("AP");
         g->SetBit(kCanDelete);
         g->GetHistogram()->SetXTitle("Mag");
@@ -757,6 +761,13 @@
         gStyle->SetStatFormat("6.2g");
 
-
-        c1=new TCanvas("CanvResiduals", "Residuals", 800, 800);
+        if (gROOT->FindObject("CanvResiduals"))
+            c1 = dynamic_cast<TCanvas*>(gROOT->FindObject("CanvResiduals"));
+        else
+            c1=new TCanvas("CanvResiduals", "Residuals", 800, 800);
+
+        gROOT->SetSelectedPad(0);
+        c1->SetSelectedPad(0);
+        c1->Clear();
+
         c1->Divide(2, 2, 1e-10, 1e-10);
     
@@ -866,5 +877,5 @@
         };
 
-        static TString dir(".");
+        static TString dir("tpoint/");
 
         TGFileInfo fi; // fFileName and fIniDir deleted in ~TGFileInfo
