Index: /trunk/MagicSoft/Cosy/Changelog
===================================================================
--- /trunk/MagicSoft/Cosy/Changelog	(revision 2567)
+++ /trunk/MagicSoft/Cosy/Changelog	(revision 2568)
@@ -1,3 +1,34 @@
                                                                   -*-*- END -*-*-
+ 2003/11/25 - Thomas Bretz (La Palma)
+
+  * slog:
+    - added this small script to analyze log-files
+    
+   * bending_magic.txt:
+     - changed to new values comming from new fit
+       with the new algorithm
+       
+   * cosy.cc:
+     - removed old style InitGUI stuff
+     - removed TROOT instance
+     - changed to support gcc 3.3
+     - added come log-output
+     - undeclared HAVE_CAMERA
+
+   * stars.txt:
+     - added some magnitudes
+     - removed Mars
+     
+   * main/MBending.cc:
+     - exchanged order: moved NPAE and CA behind AN and AW
+     - replaced the approximation for AN/AW by the correct algorithm.
+       For Magic (1.5deg) the small angle approximation is wrong
+     - added some DEBUG option
+     
+   * tpoint/gui.C:
+     - small changes
+
+
+
  2003/11/17 - Thomas Bretz (La Palma)
  
Index: /trunk/MagicSoft/Cosy/bending_magic.txt
===================================================================
--- /trunk/MagicSoft/Cosy/bending_magic.txt	(revision 2567)
+++ /trunk/MagicSoft/Cosy/bending_magic.txt	(revision 2568)
@@ -1,17 +1,22 @@
-MAGIC1 2003/07/16 16:15:09.783074
+MAGIC1 2003/11/23 0:46:12.880585
 S   00   000000   000000  0000000
- IA     501.79683 -1
- IE     -9.0710418 -1
- CA     0 -1
- NPAE   0.14889374 -1
- AN     0 -1
- AW     -1.5600339 -1
- NRX    0 -1
- NRY    0 -1
- CRX    0 -1
- CRY    0 -1
- ECES   0 -1
- ACES   0 -1
- ECEC   0 -1
- ACEC   0 -1
+     IA      501.6639   0.034618314
+     IE    -9.0592286   0.020049537
+   FLOP             0             0
+     AN             0             0
+     AW    -1.5593339   0.022280707
+   NPAE   0.073756927   0.039384952
+     CA             0             0
+     TF             0             0
+     TX             0             0
+   ECES             0             0
+   ACES             0             0
+   ECEC             0             0
+   ACEC             0             0
+    NRX             0             0
+    NRY             0             0
+    CRX             0             0
+    CRY             0             0
+ MAGIC1             0             0
+ MAGIC2             0             0
 END
Index: /trunk/MagicSoft/Cosy/cosy.cc
===================================================================
--- /trunk/MagicSoft/Cosy/cosy.cc	(revision 2567)
+++ /trunk/MagicSoft/Cosy/cosy.cc	(revision 2568)
@@ -1,7 +1,6 @@
-#include <iomanip.h>
-#include <fstream.h>
-#include <iostream.h>
+#include <iostream>
+#include <iomanip>
+#include <fstream>
 
-#include <TROOT.h>
 #include <TSystem.h>
 #include <TApplication.h>
@@ -16,5 +15,5 @@
 
 //#define EXPERT
-#define HAVE_CAMERA
+//#define HAVE_CAMERA
 
 #define clog(txt) \
@@ -26,10 +25,5 @@
     }
 
-TROOT root("Cosy", "Magic Control System");
-
 /* ---------------------------------------------------------------------- */
-//extern void InitGui();
-//VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
-
 int main(int argc, char **argv)
 {
@@ -57,8 +51,10 @@
     }
 
+    cout << "Open Logfile: " << name << endl;
+
     MLog *l = new MLog(name, kTRUE);
     MLog &lout = *l;
 
-    clog("Starting Cosy at " << time.GetTimeStr() << " ...");
+    clog("Starting Cosy at " << time << " ...");
 
     //
@@ -67,5 +63,6 @@
     clog("- Initialising Root environment.");
 
-    TApplication* app = new TApplication("App", &argc, argv);
+    // FIXME: Fails deleteing something in TGClient::fWlist
+    TApplication *app=new TApplication("App", &argc, argv);
 
     //
@@ -125,9 +122,12 @@
     clog("- Stopping cosy.");
     cosy->Stop();
-    clog("- cosy stopped."); 
+
+    time.Now();
+    clog(time << ": MCosy stopped.");
 
     delete cosy;
 
-    clog("- Terminating Program.");
+    time.Now();
+    clog("Terminating cosy at " << time);
 
     delete l;
Index: /trunk/MagicSoft/Cosy/main/MBending.cc
===================================================================
--- /trunk/MagicSoft/Cosy/main/MBending.cc	(revision 2567)
+++ /trunk/MagicSoft/Cosy/main/MBending.cc	(revision 2568)
@@ -61,4 +61,5 @@
 #include <fstream.h>
 #include <iomanip.h>
+#include <TVector3.h>
 
 #include <TMinuit.h>
@@ -69,6 +70,6 @@
 
 #undef DEBUG
-#define DEBUG(txt) txt
-//#define DEBUG(txt)
+//#define DEBUG(txt) txt
+#define DEBUG(txt)
 
 const Int_t MBending::fNumPar=19;
@@ -83,8 +84,8 @@
     fCoeff[ 1] = &fIe;      fName[ 1] = "IE";
     fCoeff[ 2] = &fFlop;    fName[ 2] = "FLOP";
-    fCoeff[ 3] = &fNpae;    fName[ 3] = "NPAE";
-    fCoeff[ 4] = &fCa;      fName[ 4] = "CA";
-    fCoeff[ 5] = &fAn;      fName[ 5] = "AN";
-    fCoeff[ 6] = &fAw;      fName[ 6] = "AW";
+    fCoeff[ 3] = &fAn;      fName[ 3] = "AN";
+    fCoeff[ 4] = &fAw;      fName[ 4] = "AW";
+    fCoeff[ 5] = &fNpae;    fName[ 5] = "NPAE";
+    fCoeff[ 6] = &fCa;      fName[ 6] = "CA";
     fCoeff[ 7] = &fTf;      fName[ 7] = "TF";
     fCoeff[ 8] = &fTx;      fName[ 8] = "TX";
@@ -103,8 +104,8 @@
     fDescr[ 1] =  "Index Error Zenith Distance";
     fDescr[ 2] =  "Vertical Sag";
-    fDescr[ 3] =  "Az-El Nonperpendicularity";
-    fDescr[ 4] =  "Left-Right Collimation Error";
-    fDescr[ 5] =  "Azimuth Axis Misalignment (N-S)";
-    fDescr[ 6] =  "Azimuth Axis Misalignment (E-W)";
+    fDescr[ 3] =  "Azimuth Axis Misalignment (N-S)";
+    fDescr[ 4] =  "Azimuth Axis Misalignment (E-W)";
+    fDescr[ 5] =  "Az-El Nonperpendicularity";
+    fDescr[ 6] =  "Left-Right Collimation Error";
     fDescr[ 7] =  "Tube fluxture (sin)";
     fDescr[ 8] =  "Tube fluxture (tan)";
@@ -291,5 +292,5 @@
 
     DEBUG(cout << setprecision(16));
-    DEBUG(cout << "Bend8: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+    DEBUG(cout << "Bend7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
 
     const AltAz CRX(-fCrx*sin(p.Az()-p.Alt()),  fCrx*cos(p.Az()-p.Alt())/cos(p.Alt()));
@@ -298,5 +299,5 @@
     p += CRY;
 
-    DEBUG(cout << "Bend7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+    DEBUG(cout << "Bend6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
 
     const AltAz NRX(fNrx*sin(p.Alt()), -fNrx);
@@ -305,5 +306,5 @@
     p += NRY;
 
-    DEBUG(cout << "Bend6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+    DEBUG(cout << "Bend5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
 
     const AltAz CES(-fEces*sin(p.Alt()), -fAces*sin(p.Az()));
@@ -312,5 +313,5 @@
     p += CEC;
 
-    DEBUG(cout << "Bend5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+    DEBUG(cout << "Bend4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
 
     const AltAz TX(Sign(fTx/tan(p.Alt()), p.Alt()), 0);
@@ -319,6 +320,48 @@
     p += TF;
 
-    DEBUG(cout << "Bend4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
-
+
+    DEBUG(cout << "Bend3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+
+    /*
+     //New Corrections for NPAE and CA:
+     TVector3 v(1.,1.,1.); // Vector in cartesian coordinates
+
+     //Set Azimuth and Elevation
+     v.SetPhi(p.Az());
+     v.SetTheta(TMath::Pi()/2-p.Alt());
+     //Rotation Vectors:
+     TVector3 vNpae(             cos(p.Az()),              sin(p.Az()),             0);
+     TVector3   vCa( -cos(p.Az())*cos(p.Alt()), -sin(p.Az())*cos(p.Alt()), sin(p.Alt()));
+     //Rotate around the vectors vNpae and vCa
+     v.Rotate(fNpae, vNpae);
+     v.Rotate(fCa,     vCa);
+
+     p.Az(v.Phi());
+     p.Alt(TMath::Pi()/2-v.Theta());
+     */
+
+    //Old correction terms for Npae and Ca:
+    const AltAz CA(0, -fCa/cos(p.Alt()));
+    p += CA;
+
+    const AltAz NPAE(0, -fNpae*tan(p.Alt()));
+    p += NPAE;
+
+    DEBUG(cout << "Bend2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+
+    // New Corrections for AW and AN:
+    TVector3 v2(1.,1.,1.); // Vector in cartesian coordinates
+    // Set Azimuth and Elevation
+    v2.SetPhi(p.Az());
+    v2.SetTheta(TMath::Pi()/2-p.Alt());
+    // Rotate around the x- and y-axis
+    v2.RotateX(fAw);
+    v2.RotateY(fAn);
+    // Get Azimuth and Elevation
+    p.Az(v2.Phi());
+    p.Alt(TMath::Pi()/2-v2.Theta());
+
+    /*
+    // Old correction terms for An and Aw:
     cout << fAw << " " << cos(p.Az()) << " " << tan(p.Alt()) << endl;
     cout << fAw* cos(p.Az())*tan(p.Alt())*180/3.1415 << endl;
@@ -328,14 +371,8 @@
     p += AW;
     p += AN;
-
-    DEBUG(cout << "Bend3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
-
-    const AltAz CA(0, -fCa/cos(p.Alt()));
-    p += CA;
-
-    DEBUG(cout << "Bend2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
-
-    const AltAz NPAE(0, -fNpae*tan(p.Alt()));
-    p += NPAE;
+    */
+
+
+
 
     DEBUG(cout << "Bend1: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
@@ -381,23 +418,52 @@
     DEBUG(cout << "Back1: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
 
+    /*
+     //Old correction terms for An and Aw:
+     const AltAz AN(-fAn*cos(p.Az()), -fAn*sin(p.Az())*tan(p.Alt()));
+     const AltAz AW( fAw*sin(p.Az()), -fAw*cos(p.Az())*tan(p.Alt()));
+     p -= AN;
+     p -= AW;
+     */
+
+    // New Corrections for AN and AW:
+    TVector3 v(1.,1.,1.); // Vector in cartesian coordinates
+    // Set Azimuth and Elevation
+    v.SetPhi(p.Az());
+    v.SetTheta(TMath::Pi()/2-p.Alt());
+    // Rotate around the x- and y-axis
+    v.RotateY(-fAn);
+    v.RotateX(-fAw);
+    // Get Azimuth and Elevation
+    p.Az(v.Phi());
+    p.Alt(TMath::Pi()/2-v.Theta());
+
+
+    DEBUG(cout << "Back2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+
+    //Old Correction terms for Npae and Ca:
     const AltAz NPAE(0, -fNpae*tan(p.Alt()));
     p -= NPAE;
 
-    DEBUG(cout << "Back2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
-
     const AltAz CA(0, -fCa/cos(p.Alt()));
     p -= CA;
 
+    /*
+     //New Correction term for Npae and Ca:
+     TVector3 v2(1.,1.,1.); // Vector in cartesian coordinates
+     //Set Azimuth and Elevation
+     v2.SetPhi(p.Az());
+     v2.SetTheta(TMath::Pi()/2-p.Alt());
+     //Rotation Vectors:
+     TVector3 vNpae(             cos(p.Az()),              sin(p.Az()),             0);
+     TVector3   vCa( -cos(p.Az())*cos(p.Alt()), -sin(p.Az())*cos(p.Alt()), sin(p.Alt()));
+     //Rotate around the vectors vCa and vNpae
+     v2.Rotate(-fCa,     vCa);
+     v2.Rotate(-fNpae, vNpae);
+
+     p.Az(v2.Phi());
+     p.Alt(TMath::Pi()/2-v2.Theta());
+    */
+
     DEBUG(cout << "Back3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
-
-    cout << fAw << " " << cos(p.Az()) << " " << tan(p.Alt()) << endl;
-    cout << fAw* cos(p.Az())*tan(p.Alt())*180/3.1415 << endl;
-
-    const AltAz AN(-fAn*cos(p.Az()), -fAn*sin(p.Az())*tan(p.Alt()));
-    const AltAz AW( fAw*sin(p.Az()), -fAw*cos(p.Az())*tan(p.Alt()));
-    p -= AN;
-    p -= AW;
-
-    DEBUG(cout << "Back4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
 
     const AltAz TF(Sign(fTf*cos(p.Alt()), p.Alt()), 0);
@@ -406,5 +472,5 @@
     //p -= TX;
 
-    DEBUG(cout << "Back5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+    DEBUG(cout << "Back4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
 
     const AltAz CEC(-fEcec*cos(p.Alt()), -fAcec*cos(p.Az()));
@@ -413,5 +479,5 @@
     p -= CES;
 
-    DEBUG(cout << "Back6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+    DEBUG(cout << "Back5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
 
     const AltAz NRY(fNry*cos(p.Alt()), -fNry*tan(p.Alt()));
@@ -420,5 +486,5 @@
     p -= NRX;
 
-    DEBUG(cout << "Back7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+    DEBUG(cout << "Back6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
 
     const AltAz CRY(-fCry*cos(p.Az()-p.Alt()), -fCry*sin(p.Az()-p.Alt())/cos(p.Alt()));
@@ -427,5 +493,5 @@
     p -= CRX;
 
-    DEBUG(cout << "Back8: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
+    DEBUG(cout << "Back7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
 
     return p;
Index: /trunk/MagicSoft/Cosy/slog
===================================================================
--- /trunk/MagicSoft/Cosy/slog	(revision 2568)
+++ /trunk/MagicSoft/Cosy/slog	(revision 2568)
@@ -0,0 +1,3 @@
+grep -v ^-\  $* | grep -v ^Step | grep -v ^Node | grep -v ^Do\ Rel | grep -v ^Relative | grep -v ^Tracking\ Thread
+grep cosy\ stopped $*
+grep Terminating\ Program $*
Index: /trunk/MagicSoft/Cosy/stars.txt
===================================================================
--- /trunk/MagicSoft/Cosy/stars.txt	(revision 2567)
+++ /trunk/MagicSoft/Cosy/stars.txt	(revision 2568)
@@ -1,6 +1,6 @@
-14 28 33   42 40 21  1ES1426+428
-20 00 00   65 08 55  1ES1959+650
-12 29 07   02 03 09  3C273
-12 56 11  -05 47 22  3C279
+14 28 33   42 40 21  1ES1426+428 (16.45)
+20 00 00   65 08 55  1ES1959+650 (12.8)
+12 29 07   02 03 09  3C273 (12.86)
+12 56 11  -05 47 22  3C279 (17.75)
 12 54 02   55 57 35  Alioth (1.77)
 00 08 24   29 05 26  Alpheratz (2.06)
@@ -9,9 +9,9 @@
 14 15 40   19 10 57  Arcturus (-0.04)
 13 47 33   49 18 48  Benetnasch (1.86)
-22 02 43   42 16 40  BL-Lac
+22 02 43   42 16 40  BL-Lac (14.5)
 00 09 11   59 08 59  Caph (2.27)
-12 59 49   27 58 50  Coma Cluster
+12 59 49   27 58 50  Coma Cluster (10.70)
 05 34 32   22 00 52  Crab
-20 32 26   40 57 28  Cygnus-X3
+20 32 26   40 57 28  Cygnus-X3 
 21 45 41   31 43 09  Dark Patch 2
 20 41 26   45 16 49  Deneb (1.25)
@@ -20,5 +20,4 @@
 18 24 10  -34 23 05  Kaus Australis (1.85)
 05 34 32   22 00 52  M1 (8.4)
-22 22 08  -13 51 08  Mars
 13 23 56   54 55 31  Mizar A (2.23)
 11 04 26   38 12 36  Markarian-421
Index: /trunk/MagicSoft/Cosy/tpoint/gui.C
===================================================================
--- /trunk/MagicSoft/Cosy/tpoint/gui.C	(revision 2567)
+++ /trunk/MagicSoft/Cosy/tpoint/gui.C	(revision 2568)
@@ -647,5 +647,5 @@
         const Int_t size = fOriginal.GetSize();
 
-        ifstream fin("../tpoint_new.txt");
+        ifstream fin("tpoint.txt");
 
         while (fin && fin.get()!='\n');
@@ -654,5 +654,5 @@
         if (!fin)
         {
-            cout << "File not found!" << endl;
+            cout << "File 'tpoint.txt' not found!" << endl;
             return;
         }
Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2567)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2568)
@@ -4,5 +4,13 @@
 
                                                  -*-*- END OF LINE -*-*-
-  2003/11/25: Abelardo Moralejo
+ 2003/11/25: Thomas Bretz
+ 
+   * mgeom/MGeomMirror.h:
+     - added Getter functions for Mirror Center and Mirror 
+       Normal vector
+
+
+
+ 2003/11/25: Abelardo Moralejo
 
    * mimage/MStereoPar.[h,cc]
@@ -14,5 +22,7 @@
      - Updated accordingly.
 
-  2003/11/23: Thomas Bretz
+
+
+ 2003/11/23: Thomas Bretz
 
    * star.cc:
@@ -87,5 +97,5 @@
 
 
-  2003/11/22: Thomas Bretz
+ 2003/11/22: Thomas Bretz
 
    * mreport/MReportCamera.cc:
@@ -189,5 +199,5 @@
 
 
-  2003/11/21: Thomas Bretz
+ 2003/11/21: Thomas Bretz
 
    * mraw/MRawEvtData.cc:
@@ -255,5 +265,5 @@
 
 
-  2003/11/20: Markus Gaug
+ 2003/11/20: Markus Gaug
 
    * macros/calibration.C
Index: /trunk/MagicSoft/Mars/mgeom/MGeomMirror.h
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeomMirror.h	(revision 2567)
+++ /trunk/MagicSoft/Mars/mgeom/MGeomMirror.h	(revision 2568)
@@ -8,4 +8,8 @@
 #ifndef ROOT_TArrayF
 #include <TArrayF.h>
+#endif
+
+#ifndef ROOT_TVector3
+#include <TVector3.h>
 #endif
 
@@ -46,5 +50,8 @@
     void  SetReflectivity(const TArrayF &wav, const TArrayF &ref);
 
-    void    SetArraySize(Int_t dim) { fWavelength.Set(dim); fReflectivity.Set(dim); }
+    void  SetArraySize(Int_t dim) { fWavelength.Set(dim); fReflectivity.Set(dim); }
+
+    TVector3 GetMirrorCenter() const { return TVector3(fX/100, fY/100, fZ/100); }
+    TVector3 GetMirrorNorm() const   { return TVector3(fXN, fYN, fZN); }
 
     ClassDef(MGeomMirror, 2)  // geometry class describing one mirror
