Index: /trunk/MagicSoft/Cosy/Changelog
===================================================================
--- /trunk/MagicSoft/Cosy/Changelog	(revision 1757)
+++ /trunk/MagicSoft/Cosy/Changelog	(revision 1758)
@@ -32,4 +32,21 @@
      - added dat
      - added rcc
+
+   * starg.cc, catalog/SlaStars.[h,cc], catalog/Slalib.[h,cc],
+     catalog/StarCatalog.[h,cc], devdrv/macs.cc, devdrv/shaftencoder.cc,
+     gui/MGCosy.[h,cc], gui/MGSkyPosition.[h,cc], gui/MGStarguider.[h,cc]:
+     - changed to use MObservatory
+     - changed usage of timer to new style
+   
+   * catalog/SlaPlanets.[h,cc]:
+     - removed old style calculation
+     - added fTt
+
+   * gui/MGCosy.cc:
+     - added new tab for SE Test
+
+   * main/MCosy.[h,cc]:
+     - don't use second SE when only one is attached
+     - added SE Test stuff
 
 
Index: /trunk/MagicSoft/Cosy/catalog/SlaPlanets.cc
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/SlaPlanets.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/catalog/SlaPlanets.cc	(revision 1758)
@@ -7,5 +7,5 @@
 ClassImp(SlaPlanets);
 
-SlaPlanets::SlaPlanets() : Slalib(), fDt(slaDt(2000.0)/60./60./24.)
+SlaPlanets::SlaPlanets(MObservatory::LocationName_t key) : Slalib(key), fDt(slaDt(2000.0)/60./60./24.)
 {
 }
@@ -15,7 +15,9 @@
 }
 
-void SlaPlanets::SetMjd(const double mjd)
+void SlaPlanets::SetMjd(double mjd)
 {
     Slalib::SetMjd(mjd);
+
+    fTt = mjd + slaDtt(mjd)/60./60./24.;
 
     //
@@ -29,101 +31,19 @@
 }
 
-#include "SlaStars.h"
-
 void SlaPlanets::UpdatePlanetPos(ePlanets_t planet)
 {
-    /*
-    double cp[6] = { 0, 0, 0, 0, 0, 0 };
-
-    double coord[6];
-
-    switch (planet)
-    {
-    case kEMoon:
-        //
-        // -- approximate geocentric pos and vel --
-        //
-        slaDmoon(GetMjd() + fDt, coord);
-        break;
-
-    case kEMercury:
-    case kEVenus:
-    case kEMars:
-    case kEJupiter:
-    case kESaturn:
-    case kEUranus:
-    case kENeptune:
-    case kEPluto:
-    case kESun:
-        {
-        */
     //
-    // coordinates of planet: heliocentric, equatoril, J2000
+    // coordinates of planet: topocentric, equatorial, J2000
     //
-    double ra,dec,diam;
-    // TDB, planet, elong, phi, *ra, *dec, *diam
+    double ra, dec, diam;
 
     // One can use TT instead of TDB for all plenets
     // (except the moon)
-
-    const double tt = GetMjd() + slaDtt(GetMjd())/60./60./24.;
-
-    // FIXME: Shell be UT1
-    const double ut1 = fmod(GetMjd(), 1);
-
-    // tt should be tdb, but tt can be used
-    const double tdb = tt + slaRcc(tt, ut1, GetElong(), 8300*cos(GetPhi()), 8300*sin(GetPhi() ))/60./60./24.;
-    /*
-     cout << "Dt: " << slaDtt(GetMjd()) << endl;
-     cout << "Rc: " << slaRcc(tt, ut1, GetElong(), 8300*cos(GetPhi()), 8300*sin(GetPhi() )) << endl;
-     */
-    slaRdplan(tt, planet, GetElong(), GetPhi(),
-              &ra, &dec, &diam);
-    /*
-     switch (planet)
-     {
-     case kEMoon: cout << "Moon: "; break;
-     case kEMercury: cout << "Merkur: "; break;
-     case kEVenus: cout << "Venus: "; break;
-     case kEMars: cout << "Mars: "; break;
-     case kEJupiter: cout << "Jupiter: "; break;
-     case kESaturn: cout << "Saturn: "; break;
-     case kEUranus: cout << "Uranus: "; break;
-     case kENeptune: cout << "Neptun: "; break;
-     case kEPluto: cout << "Pluto: "; break;
-     case kESun: cout << "Sonne: "; break;
-     }
-
-     cout << (int)(ra*12/TMath::Pi()) << "h"<< (int)(ra*12/TMath::Pi()*60)%60 <<"min ";
-     cout << (int)(dec*kRad2Deg) << "deg" << (int)(dec*kRad2Deg*60)%60 << "min" << endl;
-     */
-    /*
-     SlaStars sla;
-     sla.SetMjd(GetMjd());
-     ZdAz za = sla.CalcZdAz(RaDec(ra,dec));
-     cout << za.Zd()*kRad2Deg << " " << fmod(za.Az()*kRad2Deg+720,360.) << endl;
-     fZdAz[planet] = za;
-     */
+    // TDB, planet, elong, phi, *ra, *dec, *diam
+    slaRdplan(fTt, planet, GetElong(), GetPhi(), &ra, &dec, &diam);
 
     double az, el;
     slaDe2h(GetAlpha()-ra, dec, GetPhi(), &az, &el);
 
-    cout << 90-el*kRad2Deg << " " << fmod(az*kRad2Deg+720,360.) << endl;
     fZdAz[planet].Set(TMath::Pi()/2-el, az);
-    /*
-     }
-     // !! Fall through!
-     break;
-     case kESun:
-     coord[0] = cp[0] - fEarth[0];
-     coord[1] = cp[1] - fEarth[1];
-     coord[2] = cp[2] - fEarth[2];
-     break;
-     }
-     fZdAz[planet] = XYZ2ZdAz(coord);
-
-     if (planet==kESun)
-     {
-     cout << fZdAz[kESun].Zd()*kRad2Deg << " " <<  fZdAz[kESun].Az()*kRad2Deg << endl;
-     }*/
 }
Index: /trunk/MagicSoft/Cosy/catalog/SlaPlanets.h
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/SlaPlanets.h	(revision 1757)
+++ /trunk/MagicSoft/Cosy/catalog/SlaPlanets.h	(revision 1758)
@@ -23,5 +23,6 @@
 {
 private:
-    double fDt; // const: rootcint/TMemberInspector
+    double fDt;        // [mjd] const: rootcint/TMemberInspector
+    double fTt;        // [mjd] timescale TT
 
     ZdAz fZdAz[10];    // [rad]
@@ -32,12 +33,8 @@
 
 public:
-    SlaPlanets();
+    SlaPlanets(MObservatory::LocationName_t key);
     virtual ~SlaPlanets();
 
-    //    const AltAz GetAltAz() const { return fAltAz*360/D2PI; }
-    //    const ZdAz  GetZdAz()  const { return ZdAz(DPI/2-fAltAz.Alt(), fAltAz.Az())*360/D2PI; }
-    //    const RaDec GetRaDec() const { return fRaDec*360/D2PI; }
-
-    void SetMjd(const double mjd);
+    void SetMjd(double mjd);
 
     void UpdatePlanetPos(ePlanets_t planet);
Index: /trunk/MagicSoft/Cosy/catalog/SlaStars.cc
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/SlaStars.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/catalog/SlaStars.cc	(revision 1758)
@@ -5,5 +5,5 @@
 ClassImp(SlaStars);
 
-SlaStars::SlaStars() : Slalib()
+SlaStars::SlaStars(MObservatory::LocationName_t key) : Slalib(key)
 {
 }
Index: /trunk/MagicSoft/Cosy/catalog/SlaStars.h
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/SlaStars.h	(revision 1757)
+++ /trunk/MagicSoft/Cosy/catalog/SlaStars.h	(revision 1758)
@@ -16,5 +16,5 @@
 
 public:
-    SlaStars();
+    SlaStars(MObservatory::LocationName_t key);
     virtual ~SlaStars();
 
Index: /trunk/MagicSoft/Cosy/catalog/Slalib.cc
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/Slalib.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/catalog/Slalib.cc	(revision 1758)
@@ -10,24 +10,6 @@
 ClassImp(Slalib);
 
-Slalib::Slalib() : Timer()
+Slalib::Slalib(MObservatory::LocationName_t key) : Timer(), MObservatory(key)
 {
-    // p = pointer to MainFrame (not owner)
-
-    //
-    // calculate observers location (goe)
-    //
-    int status;
-    //slaDaf2r(51, 38, 48.0, &fPhi,   &status);
-    //slaDaf2r( 9, 56, 36.0, &fElong, &status);
-    //fHeight = 300;
-
-    slaDaf2r(28, 45, 30.0, &fPhi,   &status);
-    slaDaf2r(17, 52, 48.0, &fElong, &status);
-
-    fElong *= -1;
-    fHeight = 2326;
-
-    cout << "Latitude: 51\x9c 38'48.0\" = " <<  kRad2Deg*fPhi << "   ";
-    cout << "Longitude: 9\x9c 56'36.0\" = " <<  kRad2Deg*fElong << endl;
 }
 
@@ -36,23 +18,9 @@
 }
 
-void Slalib::SetMjd(const double mjd)
+void Slalib::SetMjd(double mjd)
 {
-    fMjd   = mjd;
-    fAlpha = slaGmst(fMjd) + fElong;
+    Timer::SetMjd(mjd);
+    fAlpha = slaGmst(mjd) + GetElong();
 }
-
-void Slalib::SetMjd2Now()
-{
-    Now();
-    SetMjd(CalcMjd());
-//    cout << "GetMjd: "<< (*this)() << " " << GetMjd() << endl;
-}
-
-void Slalib::SetMjd(const struct timeval *tm)
-{
-    SetTimer(tm);
-    SetMjd(CalcMjd());
-}
-
 
 ZdAz Slalib::XYZ2ZdAz(double coord[3]) const
@@ -73,5 +41,5 @@
     //
     double alt, az;
-    slaDe2h(ha, dec, fPhi, &az, &alt);
+    slaDe2h(ha, dec, GetPhi(), &az, &alt);
 
     return ZdAz(kPiDiv2-alt, az);
Index: /trunk/MagicSoft/Cosy/catalog/Slalib.h
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/Slalib.h	(revision 1757)
+++ /trunk/MagicSoft/Cosy/catalog/Slalib.h	(revision 1758)
@@ -5,37 +5,19 @@
 
 #include "coord.h"
-#include "base/timer.h"
+#include "timer.h"
+#include "MObservatory.h"
 
-class Slalib : public Timer
+class Slalib : public Timer, public MObservatory
 {
 private:
-    double   fAlpha;
-    double   fMjd;
-
-    double   fPhi;      // location of observatory
-    double   fElong;
-
-    double   fHeight;
+    double fAlpha;
 
 public:
-    Slalib();
+    Slalib(MObservatory::LocationName_t key);
     virtual ~Slalib();
 
-    //    const AltAz GetAltAz() const { return fAltAz*360/D2PI; }
-    //    const ZdAz  GetZdAz()  const { return ZdAz(DPI/2-fAltAz.Alt(), fAltAz.Az())*360/D2PI; }
-    //    const RaDec GetRaDec() const { return fRaDec*360/D2PI; }
-
-    void SetMjd2Now();
-    void SetMjd(const struct timeval *tm);
-
-    virtual void SetMjd(const double mjd);
+    virtual void SetMjd(double mjd);
 
     double GetAlpha() const  { return fAlpha; }
-    double GetMjd() const    { return fMjd; }
-
-    double GetPhi() const    { return fPhi; }
-    double GetElong() const  { return fElong; }
-
-    double GetHeight() const { return fHeight; }
 
     ZdAz   XYZ2ZdAz(double coord[3]) const;
Index: /trunk/MagicSoft/Cosy/catalog/StarCatalog.cc
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/StarCatalog.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/catalog/StarCatalog.cc	(revision 1758)
@@ -14,5 +14,5 @@
 ClassImp(StarCatalog);
 
-StarCatalog::StarCatalog() : SlaStars(), fEntries(0)
+StarCatalog::StarCatalog(MObservatory::LocationName_t key) : SlaStars(key), fEntries(0)
 {
     // p = pointer to MainFrame (not owner)
Index: /trunk/MagicSoft/Cosy/catalog/StarCatalog.h
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/StarCatalog.h	(revision 1757)
+++ /trunk/MagicSoft/Cosy/catalog/StarCatalog.h	(revision 1758)
@@ -71,5 +71,5 @@
 
 public:
-    StarCatalog();
+    StarCatalog(MObservatory::LocationName_t key);
     virtual ~StarCatalog();
 
Index: /trunk/MagicSoft/Cosy/devdrv/macs.cc
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/macs.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/devdrv/macs.cc	(revision 1758)
@@ -233,5 +233,5 @@
     StopGuarding();
 
-    usleep(2000.*GetGuardTime());
+    usleep(2000*GetGuardTime());
 
     lout << "- " << GetNodeName() << ": Requesting Mac Software Version." << endl;
@@ -610,5 +610,5 @@
 double Macs::GetMjd()
 {
-    return fPosTime.CalcMjd();
+    return fPosTime.GetMjd();
 }
 
@@ -620,5 +620,5 @@
 double Macs::GetPdoMjd()
 {
-    return fPdoTime.CalcMjd();
+    return fPdoTime.GetMjd();
 }
 
Index: /trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc	(revision 1758)
@@ -213,5 +213,5 @@
 double ShaftEncoder::GetMjd()
 {
-    return fTime.CalcMjd();
+    return fTime.GetMjd();
 }
 
Index: /trunk/MagicSoft/Cosy/gui/MGCosy.cc
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 1758)
@@ -311,5 +311,6 @@
     TGCompositeFrame *tf2 = fTab->AddTab("Track");
     TGCompositeFrame *tf4 = fTab->AddTab("Calibration");
-    TGCompositeFrame *tf3 = fTab->AddTab("Demo");
+    TGCompositeFrame *tf5 = fTab->AddTab("Test SE");
+    /*TGCompositeFrame *tf3 =*/ fTab->AddTab("Demo");
 
     fCZdAz = new MGCoordinates(tf1, kETypeZdAz);
@@ -359,4 +360,17 @@
     l3 = new TGLabel(tf4, "the TPoint button. To set the Shaftencoder offset");
     l4 = new TGLabel(tf4, "use the Calib SE button.");
+    l1->Move(x, y);
+    l2->Move(x, y+h);
+    l3->Move(x, y+2*h);
+    l4->Move(x, y+3*h);
+    fList->Add(l1);
+    fList->Add(l2);
+    fList->Add(l3);
+    fList->Add(l4);
+
+    l1 = new TGLabel(tf5, "START starts histograming the differences of");
+    l2 = new TGLabel(tf5, "the two shaftencoders at the elevation axis.");
+    l3 = new TGLabel(tf5, "Use STOP to stop histograming and display the");
+    l4 = new TGLabel(tf5, "results on the screen.");
     l1->Move(x, y);
     l2->Move(x, y+h);
@@ -569,6 +583,6 @@
 }
 
-MGCosy::MGCosy(MsgQueue *q, const TGWindow *p, UInt_t w, UInt_t h)
-    : TGMainFrame(p, w, h), fQueue(q)
+MGCosy::MGCosy(MObservatory::LocationName_t key, MsgQueue *q, const TGWindow *p, UInt_t w, UInt_t h)
+    : TGMainFrame(p, w, h), fObservatory(key), fQueue(q)
 {
     fList = new MGList;
@@ -596,5 +610,5 @@
     cout << "MGCosy: Creating MGSkyPosition" << endl;
 #endif
-    fSkyPosition = new MGSkyPosition(f1, 300);
+    fSkyPosition = new MGSkyPosition(fObservatory, f1, 300);
 #ifdef DEBUG
     cout << "MGCosy: Creating MGAccuracy" << endl;
@@ -750,5 +764,5 @@
     static Int_t decs=~0;
 
-    static SlaStars sla;
+    static SlaStars sla(fObservatory);
     sla.SetMjd(mjd);
 
@@ -863,5 +877,5 @@
     fUtc->SetText(new TGString(text));
 
-    double mjd = time.CalcMjd();
+    double mjd = time.GetMjd();
 
     sprintf(text, "%12.6f", mjd);
@@ -1114,4 +1128,7 @@
                     return kTRUE;
                 case 3:
+                    fQueue->Proc(WM_TESTSE, (void*)1);
+                    return kTRUE;
+                case 4:
                     StartDemo();
                     return kTRUE;
@@ -1123,4 +1140,6 @@
                 StopDemo();
                 fQueue->PostMsg(WM_STOP, 0, 0);
+                if (fTab->GetCurrent()==3)
+                    fQueue->Proc(WM_TESTSE, NULL);
                 cout << "PostMsg (WM_Stop) returned." << endl;
                 return kTRUE;
Index: /trunk/MagicSoft/Cosy/gui/MGCosy.h
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 1757)
+++ /trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 1758)
@@ -4,4 +4,8 @@
 #ifndef ROOT_TGFrame
 #include <TGFrame.h>
+#endif
+
+#ifndef MARS_MObservatory
+#include <MObservatory.h>
 #endif
 
@@ -31,4 +35,5 @@
 {
 private:
+    const MObservatory::LocationName_t fObservatory;
 
     //
@@ -104,5 +109,5 @@
 
 public:
-    MGCosy(MsgQueue *q, const TGWindow *p, UInt_t w, UInt_t h);
+    MGCosy(MObservatory::LocationName_t key, MsgQueue *q, const TGWindow *p, UInt_t w, UInt_t h);
     ~MGCosy();
 
Index: /trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 1758)
@@ -43,6 +43,6 @@
     //   Neptun     7.8
     //
-    fSlaPlanet = new SlaPlanets;
-    fSlaStar   = new SlaStars;
+    fSlaPlanet = new SlaPlanets(fObservatory);
+    fSlaStar   = new SlaStars(fObservatory);
 
     //
@@ -177,6 +177,6 @@
 }
 
-MGSkyPosition::MGSkyPosition(const TGWindow* p, const UInt_t w)
-    : MGEmbeddedCanvas("SkyPosition", p, w, 110)
+MGSkyPosition::MGSkyPosition(MObservatory::LocationName_t key, const TGWindow* p, const UInt_t w)
+    : MGEmbeddedCanvas("SkyPosition", p, w, 110), fObservatory(key)
 {
     DrawCoordinateSystem();
Index: /trunk/MagicSoft/Cosy/gui/MGSkyPosition.h
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGSkyPosition.h	(revision 1757)
+++ /trunk/MagicSoft/Cosy/gui/MGSkyPosition.h	(revision 1758)
@@ -11,4 +11,8 @@
 #ifndef MGEMBEDDEDCANVAS_H
 #include "MGEmbeddedCanvas.h"
+#endif
+
+#ifndef MARS_MObservatory
+#include "MObservatory.h"
 #endif
 
@@ -46,4 +50,6 @@
     SlaPlanets *fSlaPlanet;
 
+    const MObservatory::LocationName_t fObservatory;
+
     Int_t fX[9];
     Int_t fY[9];
@@ -66,5 +72,5 @@
 
 public:
-    MGSkyPosition(const TGWindow* p, const UInt_t w);
+    MGSkyPosition(MObservatory::LocationName_t key, const TGWindow* p, const UInt_t w);
     ~MGSkyPosition();
 
Index: /trunk/MagicSoft/Cosy/gui/MGStarguider.cc
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGStarguider.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/gui/MGStarguider.cc	(revision 1758)
@@ -72,6 +72,6 @@
 #define kZOOM 96
 
-MGStarguider::MGStarguider()
-: Camera(), TGMainFrame(gClient->GetRoot(), 768, 700), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2)
+MGStarguider::MGStarguider(MObservatory::LocationName_t key)
+: Camera(), TGMainFrame(gClient->GetRoot(), 768, 700), fObservatory(key), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2)
 {
     gVirtualX->GrabButton(fId, kButton2, /*kButtonPressMask|kButtonReleaseMask|*/kNone, kNone, kNone, kNone);
@@ -80,5 +80,5 @@
     fList = new MGList;
 
-    fSao = new StarCatalog;
+    fSao = new StarCatalog(fObservatory);
     fRaDec = new RaDec(180, 40);
 
@@ -612,5 +612,5 @@
 
         MStarList stars;
-        fSao->GetStars(stars, time.CalcMjd(), *fRaDec);
+        fSao->GetStars(stars, time.GetMjd(), *fRaDec);
         fSao->GetImg(c, cimg, stars);
         //fSao->GetImg(c, cimg, time.CalcMjd(), *fRaDec);
Index: /trunk/MagicSoft/Cosy/gui/MGStarguider.h
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGStarguider.h	(revision 1757)
+++ /trunk/MagicSoft/Cosy/gui/MGStarguider.h	(revision 1758)
@@ -11,4 +11,8 @@
 #include "MGList.h"
 #include "MGImage.h"
+
+#ifndef MARS_MObservatory
+#include "MObservatory.h"
+#endif
 
 class AltAz;
@@ -56,4 +60,6 @@
     TTimer *fTimer;
 
+    const MObservatory::LocationName_t fObservatory;
+
     Int_t fDx;
     Int_t fDy;
@@ -70,5 +76,5 @@
 
 public:
-    MGStarguider();
+    MGStarguider(MObservatory::LocationName_t key);
     virtual ~MGStarguider();
 
Index: /trunk/MagicSoft/Cosy/main/MCosy.cc
===================================================================
--- /trunk/MagicSoft/Cosy/main/MCosy.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/main/MCosy.cc	(revision 1758)
@@ -10,4 +10,8 @@
 #include <TApplication.h>
 #include <TTimer.h>
+
+#include <TH2.h>
+#include <TProfile.h>
+#include <TCanvas.h>
 
 #include "MGCosy.h"
@@ -147,4 +151,7 @@
 //  are avaraged. The values are returned as a ZdAz object.
 //
+//  If one of the two shaftencoders on the elevation axis is missing
+//  the other one's position is returned.
+//
 //  The positions are alway up-to-date because the shaftencoders are
 //  sending all changes immediatly.
@@ -152,20 +159,28 @@
 ZdAz MCosy::GetSePos()
 {
+    const int pa = fAz->GetPos();
+    if (fZd1->IsZombieNode() && fZd2->IsZombieNode())
+        return ZdAz(0, pa);
+
     //
     // Get the values
     //
-    const int p0 = fZd1->GetPos();
-    const int p1 = fZd2->GetPos();
-    const int p2 = fAz->GetPos();
+    const int p1 =  fZd1->GetPos();
+    const int p2 = -fZd2->GetPos();
+
+    if (fZd1->IsZombieNode())
+        return ZdAz(p2, pa);
+    if (fZd2->IsZombieNode())
+        return ZdAz(p1, pa);
 
     //
     // interpolate shaft encoder positions
     //
-    const float p = (float)(p0-p1)/2;
+    float p = (float)(p1+p2)/2;
 
     //
     // calculate 'regelabweichung'
     //
-    return ZdAz(p, p2);
+    return ZdAz(p, pa);
 }
 
@@ -655,10 +670,10 @@
 void MCosy::TrackPosition(const RaDec &dst) // ra, dec [rad]
 {
-    SlaStars sla;
+    SlaStars sla(fObservatory);
 
     //
     // Position to actual position
     //
-    sla.SetMjd2Now();
+    sla.Now();
     ZdAz dest = sla.CalcZdAz(dst);
 
@@ -707,5 +722,5 @@
     //
     fRaDec = dst;
-    fTracking = kTRUE;
+    fBackground = kBgdTracking;
 
 //---    ofstream fout("log/cosy.pos");
@@ -729,5 +744,5 @@
         // Request theoretical Position for a time in the future (To+dt) from CPU
         //
-        sla.SetMjd(sla.CalcMjd()+dt/(60*60*24));
+        sla.SetMjd(sla.GetMjd()+dt/(60*60*24));
         ZdAz dummy = fBending(sla.CalcZdAz(fRaDec));
         dest = CorrectTarget(GetSePos(), dummy); // [se]
@@ -817,5 +832,5 @@
     }
 
-    fTracking = kFALSE;
+    fBackground = kBgdNone;
     StopMovement();
     lout << "Tracking stopped." << endl;
@@ -915,6 +930,6 @@
                 return (void*)0xebb0;
 
-            SlaStars sla;
-            sla.SetMjd2Now();
+            SlaStars sla(fObservatory);
+            sla.Now();
 
             RaDec rd = *((RaDec*)mp);
@@ -943,6 +958,6 @@
         {
             cout << "WM_TPoint: start." << endl;
-            SlaStars sla;
-            sla.SetMjd2Now();
+            SlaStars sla(fObservatory);
+            sla.Now();
 
             RaDec rd = *((RaDec*)mp);
@@ -976,4 +991,10 @@
         cout << "WM_Position: done. (return 0x7777)" << endl;
         return (void*)0x7777;
+
+    case WM_TESTSE:
+        cout << "WM_TestSe: start." << endl;
+        fBackground = mp ? kBgdSeTest : kBgdNone;
+        cout << "WM_TestSe: done. (return 0x1e51)" << endl;
+        return (void*)0x1e51;
 
     case WM_TRACK:
@@ -1040,6 +1061,6 @@
             cout << endl;
 
-            SlaStars sla;
-            sla.SetMjd2Now();
+            SlaStars sla(fObservatory);
+            sla.Now();
 
             XY xy = *((XY*)mp);
@@ -1160,4 +1181,171 @@
 }
 
+void MCosy::TalkThreadTracking()
+{
+    if (fZd1->IsZombieNode() || fZd2->IsZombieNode() || fAz->IsZombieNode())
+        return;
+    if (!fMac1 || !fMac2)
+        return;
+
+    SlaStars sla(fObservatory);
+
+    ZdAz old;
+    ZdAz ist;
+
+    ZdAz sollzd;
+    ZdAz sollaz;
+
+    ZdAz istre = -fOffset;                // [re]
+    ZdAz time;
+
+    //
+    // only update fTrackingError while tracking
+    //
+    bool phca1=false;
+    bool phca2=false;
+    bool phcaz=false;
+
+    while (fBackground==kBgdTracking)
+    {
+        //
+        // Make changes (eg wind) smoother - attenuation of control function
+        //
+        const float weight = 1.; //0.3;
+
+        //
+        // This is the time constant which defines how fast
+        // you correct for external influences (like wind)
+        //
+        fZd1->ResetPosHasChanged();
+        fZd2->ResetPosHasChanged();
+        fAz->ResetPosHasChanged();
+        do
+        {
+            phca1 = fZd1->PosHasChanged();
+            phca2 = fZd2->PosHasChanged();
+            phcaz = fAz->PosHasChanged();
+            usleep(1);
+        } while (!phca1 && !phca2 && !phcaz && fBackground==kBgdTracking);
+
+        //---usleep(100000); // 0.1s
+
+        //
+        // get position, where we are
+        //
+        old = ist;
+        ist = GetSePos(); // [se]
+
+        //
+        // if the position didn't change continue
+        //
+        /*---
+         if ((int)ist.Zd() == (int)old.Zd() &&
+         (int)ist.Az() == (int)old.Az())
+         continue;
+         */
+        istre = GetRePosPdo();
+
+        //
+        // Get time from last shaftencoder position change (position: ist)
+        // FIXME: I cannot take the avarage
+        //
+        if (fZd1->GetMjd()>fZd2->GetMjd())
+            time.Zd(fZd1->GetMjd());
+        else
+            time.Zd(fZd2->GetMjd());
+        //time.Zd((fZd1->GetMjd()+fZd2->GetMjd())/2.0);
+        time.Az(fAz->GetMjd());
+
+        //
+        // if Shaftencoder changed position
+        // calculate were we should be
+        //
+        if (phca1 || phca2 /*(int)ist.Zd() != (int)old.Zd()*/)
+        {
+            sla.SetMjd(time.Zd());
+
+            ZdAz dummy = fBending(sla.CalcZdAz(fRaDec));
+            sollzd = CorrectTarget(ist, dummy); // [se]
+
+            fOffset.Zd(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight);
+        }
+
+        if (phcaz /*(int)ist.Az() != (int)old.Az()*/)
+        {
+            sla.SetMjd(time.Az());
+
+            ZdAz dummy = fBending(sla.CalcZdAz(fRaDec));
+            sollaz = CorrectTarget(ist, dummy); // [se]
+
+            fOffset.Az(fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight);
+        }
+
+        ZdAz soll(sollzd.Zd(), sollaz.Az());
+        fZdAzSoll = fBending.CorrectBack(soll*2*TMath::Pi()/16384);
+
+        fTrackingError.Set((ist.Zd()-sollzd.Zd())*kGearRatio.X(),
+                           (ist.Az()-sollaz.Az())*kGearRatio.Y());
+
+        //---            fout << setprecision(15) << setw(17) << time.Zd()*60.*60.*24. << " ";
+        //---            fout << setprecision(5)  << setw(7)  << fTrackingError.Zd() << "  ";
+        //---            fout << setprecision(15) << setw(17) << time.Az()*60.*60.*24. << " ";
+        //---            fout << setprecision(5)  << setw(7)  << fTrackingError.Az() << endl;
+    }
+    //---        fout << endl << endl;
+}
+
+void MCosy::TalkThreadSeTest()
+{
+//    if (fZd1->IsZombieNode() || fZd2->IsZombieNode())
+    //        return;
+
+    if (fHistTestSe)
+    {
+        lout << "You are much too fast... try again." << endl;
+        return;
+    }
+
+    fHistTestSe = new TH2F("Diff", "Difference of SE values",
+                           201, fMin.Zd(), fMax.Zd(), 101, -50, 50);
+    fHistTestSe->SetXTitle("ZA [\\circ]");
+    fHistTestSe->SetYTitle("\\Delta SE");
+
+    Double_t offset = 0;
+
+    int cnt = 0;
+
+    lout << "Starting Shaftencoder Test..." << endl;
+
+    while (fBackground==kBgdSeTest)
+    {
+        fZd1->ResetPosHasChanged();
+        fZd2->ResetPosHasChanged();
+
+        while (!fZd1->PosHasChanged() && !fZd2->PosHasChanged() &&
+               fBackground==kBgdSeTest)
+            usleep(1);
+
+        const Double_t pos[3] = { fZd1->GetPos(), fZd2->GetPos(), fAz->GetPos() };
+
+        //
+        //  Estimate Offset from the first ten positions
+        //
+        if (cnt++<10)
+            offset += pos[0]+pos[1];
+        if (cnt++==10)
+            offset /= 10;
+        if (cnt<11)
+            continue;
+
+        Double_t apos = (pos[0]-pos[1])/2 * TMath::Pi()*2 / 16384;
+
+        ZdAz bend = fBending(ZdAz(apos, pos[2]))*kRad2Deg;
+
+        fHistTestSe->Fill(bend.Zd(), pos[0]+pos[1]-offset);
+    }
+
+    lout << "Shaftencoder Test Stopped... displaying Histogram." << endl;
+}
+
 void MCosy::TalkThread()
 {
@@ -1180,25 +1368,7 @@
     /*** FOR DEMO MODE ***/
 
-    if (fZd1->IsZombieNode() || fZd2->IsZombieNode() || fAz->IsZombieNode())
-        return;
-
-    if (!fMac1 || !fMac2)
-        return;
-
     //
     // Start the Network
     //
-    /*
-     TEnv env(".cosyrc");
-
-     cout << "Setting up software endswitch..." << flush;
-     fMac1->SetNegEndswitch(Deg2AzRE(env.GetValue("Az_Min[Deg]", -1.0)));
-     fMac1->SetPosEndswitch(Deg2AzRE(env.GetValue("Az_Max[Deg]", +1.0)));
-
-     fMac2->SetNegEndswitch(Deg2ZdRE(env.GetValue("Zd_Min[Deg]", -1.0)));
-     fMac2->SetPosEndswitch(Deg2ZdRE(env.GetValue("Zd_Max[Deg]", +1.0)));
-     cout << "done." << endl;
-    */
-    SlaStars sla;
     while (1)
     {
@@ -1206,118 +1376,20 @@
         // wait until a tracking session is started
         //
-        while (!fTracking)
+        while (fBackground==kBgdNone)
             usleep(1);
 
-//---        ofstream fout("log/cosy.err");
-//---        fout << "Tracking:";
-//---        fout << " Ra: " << Rad2Deg(fRaDec.Ra())  << "\x9c  ";
-//---        fout << "Dec: " << Rad2Deg(fRaDec.Dec()) << "\x9c" << endl << endl;
-//---        fout << "     MjdZd/10ms    ErrZd/re";
-//---        fout << "     MjdAz/10ms    ErrAd/re" << endl;
-
-        ZdAz old;
-        ZdAz ist;
-
-        ZdAz sollzd;
-        ZdAz sollaz;
-
-        ZdAz istre = -fOffset;                // [re]
-        ZdAz time;
-
-        //
-        // only update fTrackingError while tracking
-        //
-        bool phca1=false;
-        bool phca2=false;
-        bool phcaz=false;
-
-        while (fTracking)
+        switch (fBackground)
         {
-            //
-            // Make changes (eg wind) smoother - attenuation of control function
-            //
-            const float weight = 1.; //0.3;
-
-            //
-            // This is the time constant which defines how fast
-            // you correct for external influences (like wind)
-            //
-            fZd1->ResetPosHasChanged();
-            fZd2->ResetPosHasChanged();
-            fAz->ResetPosHasChanged();
-            do
-            {
-                phca1 = fZd1->PosHasChanged();
-                phca2 = fZd2->PosHasChanged();
-                phcaz = fAz->PosHasChanged();
-                usleep(1);
-            } while (!phca1 && !phca2 && !phcaz && fTracking);
-
-            //---usleep(100000); // 0.1s
-
-            //
-            // get position, where we are
-            //
-            old = ist;
-            ist = GetSePos(); // [se]
-
-            //
-            // if the position didn't change continue
-            //
-            /*---
-            if ((int)ist.Zd() == (int)old.Zd() &&
-                (int)ist.Az() == (int)old.Az())
-                continue;
-            */
-            istre = GetRePosPdo();
-
-            //
-            // Get time from last shaftencoder position change (position: ist)
-            // FIXME: I cannot take the avarage
-            //
-            if (fZd1->GetMjd()>fZd2->GetMjd())
-                time.Zd(fZd1->GetMjd());
-            else
-                time.Zd(fZd2->GetMjd());
-            //time.Zd((fZd1->GetMjd()+fZd2->GetMjd())/2.0);
-            time.Az(fAz->GetMjd());
-
-            //
-            // if Shaftencoder changed position
-            // calculate were we should be
-            //
-            if (phca1 || phca2 /*(int)ist.Zd() != (int)old.Zd()*/)
-            {
-                sla.SetMjd(time.Zd());
-
-                ZdAz dummy = fBending(sla.CalcZdAz(fRaDec));
-                sollzd = CorrectTarget(ist, dummy); // [se]
-
-                fOffset.Zd(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight);
-            }
-
-            if (phcaz /*(int)ist.Az() != (int)old.Az()*/)
-            {
-                sla.SetMjd(time.Az());
-
-                ZdAz dummy = fBending(sla.CalcZdAz(fRaDec));
-                sollaz = CorrectTarget(ist, dummy); // [se]
-
-                fOffset.Az(fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight);
-            }
-
-            ZdAz soll(sollzd.Zd(), sollaz.Az());
-            fZdAzSoll = fBending.CorrectBack(soll*2*TMath::Pi()/16384);
-
-            fTrackingError.Set((ist.Zd()-sollzd.Zd())*kGearRatio.X(),
-                               (ist.Az()-sollaz.Az())*kGearRatio.Y());
-
-//---            fout << setprecision(15) << setw(17) << time.Zd()*60.*60.*24. << " ";
-//---            fout << setprecision(5)  << setw(7)  << fTrackingError.Zd() << "  ";
-//---            fout << setprecision(15) << setw(17) << time.Az()*60.*60.*24. << " ";
-//---            fout << setprecision(5)  << setw(7)  << fTrackingError.Az() << endl;
+        case kBgdNone:
+            continue;
+
+        case kBgdTracking:
+            TalkThreadTracking();
+            continue;
+
+        case kBgdSeTest:
+            TalkThreadSeTest();
+            continue;
         }
-
-//---        fout << endl << endl;
     }
 }
@@ -1355,5 +1427,4 @@
                  fVelocity, fOffset, fRaDec, fZdAzSoll, fStatus, avail);
 
-
     /*
      cout << (int)(fMac1->GetStatus()&Macs::kOutOfControl) << " ";
@@ -1362,7 +1433,41 @@
      */
 
+    if (fBackground==kBgdSeTest || fHistTestSe==NULL)
+        return kTRUE;
+
+    DisplayHistTestSe();
+
     return kTRUE;
 }
 
+void MCosy::DisplayHistTestSe()
+{
+    TH2F &hist = *fHistTestSe;
+    fHistTestSe = NULL;
+
+    TCanvas *c=new TCanvas("c1", "", 1000, 1000);
+    c->Divide(1,2);
+
+    c->cd(1);
+    TH2 *h=(TH2*)hist.DrawCopy();
+
+    TProfile *p = h->ProfileX("_pfx", -1, 9999, "s");
+    p->SetLineColor(kBlue);
+    p->Draw("same");
+    p->SetBit(kCanDelete);
+
+    c->cd(2);
+
+    TH1F p2("spread", "Spread of the differences", hist.GetNbinsX(), hist.GetBinLowEdge(1),
+            hist.GetBinLowEdge(hist.GetNbinsX()+1));
+    p2.SetXTitle("ZA [\\circ]");
+    for (int i=0; i<hist.GetNbinsX(); i++)
+        p2.SetBinError(i, p->GetBinError(i));
+    p2.SetLineColor(kRed);
+    p2.SetStats(0);
+    p2.DrawCopy();
+
+    delete &hist;
+}
 
 // --------------------------------------------------------------------------
@@ -1450,5 +1555,5 @@
 
     lout << "- Starting GUI." << endl;
-    fWin=new MGCosy(this, gClient->GetRoot(), 1, 1);
+    fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1);
 }
 
@@ -1480,5 +1585,5 @@
 
     lout << "- Starting GUI." << endl;
-    fWin=new MGCosy(this, gClient->GetRoot(), 1, 1);
+    fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1);
 }
 
@@ -1497,9 +1602,9 @@
 
     lout << "- Starting GUI." << endl;
-    fWin=new MGCosy(this, gClient->GetRoot(), 1, 1);
+    fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1);
 }
 
 MCosy::MCosy(int mode, const char *dev, const int baud, MLog &out)
-: Network(dev, baud, out), fZd1(0), fZd2(0), fAz(0), fMac1(0), fMac2(0), fMac3(0), fTracking(kFALSE)
+: Network(dev, baud, out), fObservatory(MObservatory::kMagic1), fZd1(0), fZd2(0), fAz(0), fMac1(0), fMac2(0), fMac3(0), fBackground(kBgdNone)
 {
     TEnv env(".cosyrc");
Index: /trunk/MagicSoft/Cosy/main/MCosy.h
===================================================================
--- /trunk/MagicSoft/Cosy/main/MCosy.h	(revision 1757)
+++ /trunk/MagicSoft/Cosy/main/MCosy.h	(revision 1758)
@@ -7,4 +7,8 @@
 #include "MThread.h"
 #include "MBending.h"
+
+#ifndef MARS_Mobservatory
+#include "MObservatory.h"
+#endif
 
 #define kDEG ((char)0x9c)  // Linux 'ø'
@@ -22,4 +26,5 @@
 #define WM_CALCALTAZ    0x1009
 #define WM_HOME         0x100a
+#define WM_TESTSE       0x100b
 
 
@@ -28,4 +33,5 @@
 class MGCosy;
 class MCosy;
+class TH2F;
 
 class MTTalk : public MThread
@@ -46,5 +52,4 @@
 };
 
-
 class TTimer;
 class MCosy : public Network, public MsgQueue, public TObject
@@ -62,4 +67,6 @@
     };
 
+    const MObservatory::LocationName_t fObservatory;
+
     ShaftEncoder *fZd1;
     ShaftEncoder *fZd2;
@@ -76,13 +83,23 @@
                           // with a generic interface to both...
 
+    enum BackgroundAction_t
+    {
+        kBgdNone,
+        kBgdTracking,
+        kBgdSeTest
+    };
+
+    BackgroundAction_t fBackground;    // Flag for present backgroundthread
+
     ZdAz  fTrackingError; // Tracking Offset between SE and calc-pos [re]
     ZdAz  fOffset;        // Offset between se and re coordinate system [re]
     ZdAz  fZdAzSoll;      // Soll position when moving
     RaDec fRaDec;         // Position to track
-    int   fTracking;      // Flag for present tracking action
     ZdAz  fAccuracy;      // Actual accuracy of Tracking
     ZdAz  fVelocity;      // Actual velocity of Tracking
     ZdAz  fMin;
     ZdAz  fMax;
+
+    TH2F *fHistTestSe;
 
     XY kGearRatio;        // describing the gear of the system [re/se]
@@ -119,4 +136,8 @@
 
     void TalkThread();
+    void TalkThreadTracking();
+    void TalkThreadSeTest();
+
+    void DisplayHistTestSe();
 
     int  SetPosition(const ZdAz &dst);
Index: /trunk/MagicSoft/Cosy/main/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/main/Makefile	(revision 1757)
+++ /trunk/MagicSoft/Cosy/main/Makefile	(revision 1758)
@@ -33,6 +33,5 @@
 
 SRCFILES = MCosy.cc \
-           MBending.cc \
-           MStarguider.cc
+           MBending.cc
 
 SRCS        = $(SRCFILES)
Index: /trunk/MagicSoft/Cosy/starg.cc
===================================================================
--- /trunk/MagicSoft/Cosy/starg.cc	(revision 1757)
+++ /trunk/MagicSoft/Cosy/starg.cc	(revision 1758)
@@ -16,5 +16,5 @@
     TApplication *app=new TApplication("Starguider", &argc, argv);
 
-    MGStarguider starg;
+    MGStarguider starg(MObservatory::kMagic1);
 
     starg.Loop(0);
Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 1757)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 1758)
@@ -1,4 +1,11 @@
 
                                                          -*-*- END -*-*-
+ 2003/02/14: Thomas Bretz
+ 
+    * mtemp/MObservatory.[h,cc]:
+      - added
+
+
+
  2003/02/10: Abelardo Moralejo
 
@@ -8,4 +15,6 @@
     * manalysis/Makefile, AnalysisLinkDef.h
       - Changed MApplyPadding for MPadding
+
+
 
  2003/02/07: Wolfgang Wittek
@@ -43,8 +52,11 @@
       - does the padding ala Thomas Schweizer 
 
+
+
  2003/02/06: Thomas Bretz
 
     * mgeom/MGeomCam.[h,cc]:
       - fixed a warning (GetPixRatio(int) --> GetPixRatio(Uint)
+
 
 
Index: /trunk/MagicSoft/Mars/mtemp/MObservatory.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/MObservatory.cc	(revision 1758)
+++ /trunk/MagicSoft/Mars/mtemp/MObservatory.cc	(revision 1758)
@@ -0,0 +1,87 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner  10/2002 <mailto:magicsoft@rwagner.de>
+!   Author(s): Thomas Bretz   2/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2002-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MObservatory                                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MObservatory.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MObservatory);
+
+void MObservatory::Init(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MObservatory";
+    fTitle = title ? title : "Storage container for coordinates of an observatory";   
+}
+
+MObservatory::MObservatory(const char *name, const char *title)
+{
+    Init(name, title);
+
+    SetLocation(kMagic1);
+}
+
+MObservatory::MObservatory(LocationName_t key, const char *name=NULL, const char *title=NULL)
+{
+    Init(name, title);
+
+    SetLocation(key);
+}
+
+void MObservatory::SetLocation(LocationName_t name)
+{
+    switch (name)
+    {
+    case kMagic1:
+        fLatitude  =  Daf2rad( 28, 45, 30.0);
+        fLongitude =  Daf2rad(-17, 52, 48.0);
+        fHeight    = 2326; // m
+        fObservatoryName = "Observatorio del Roque de los Muchachos (Magic1)";
+        return;
+
+    case kWuerzburgCity:
+        fLatitude  = Daf2rad(51, 38, 48.0);
+        fLongitude = Daf2rad( 9, 56, 36.0);
+        fHeight    = 300;
+        fObservatoryName = "Wuerzburg City";
+        return;
+
+    }
+}
+
+void MObservatory::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << fObservatoryName << endl;
+    *fLog << "Latitude " << (fLatitude > 0 ? (fLatitude*kRad2Deg) : -(fLatitude*kRad2Deg)) << " deg " << (fLatitude > 0 ? "W" : "E") << endl;
+    *fLog << "Longitude " << (fLongitude > 0 ? (fLongitude*kRad2Deg) : -(fLongitude*kRad2Deg)) <<" deg " << (fLongitude < 0 ? "N" : "S") << endl;
+    *fLog << "Height " << fHeight << "m" << endl;
+}
+
Index: /trunk/MagicSoft/Mars/mtemp/MObservatory.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/MObservatory.h	(revision 1758)
+++ /trunk/MagicSoft/Mars/mtemp/MObservatory.h	(revision 1758)
@@ -0,0 +1,64 @@
+#ifndef MARS_MObservatory
+#define MARS_MObservatory
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MObservatory : public MParContainer
+{
+public:
+    enum LocationName_t
+    {
+        kMagic1,
+        kWuerzburgCity
+    };
+
+private:
+    LocationName_t fObservatoryKey;  //!
+
+    TString  fObservatoryName;       //! Name of the observatory
+
+    Double_t fLongitude;             //! [rad] Longitude of observatory (+ east)
+    Double_t fLatitude;              //! [rad] Latitude of observatory (+ north)
+
+    Double_t fHeight;                //! [m] height of observatory
+
+    void Init(const char *name, const char *title);
+
+    Double_t Daf2rad(Int_t deg, UInt_t min, Double_t sec)
+    {
+        /* pi/(180*3600):  arcseconds to radians */
+#define DAS2R 4.8481368110953599358991410235794797595635330237270e-6
+        return DAS2R * (60.0 * (60.0 * (Double_t)deg + (Double_t)min) + sec);
+    }
+
+public:
+    MObservatory(const char *name=NULL, const char *title=NULL);
+    MObservatory(LocationName_t key, const char *name=NULL, const char *title=NULL);
+
+    void SetLocation(LocationName_t name);
+
+    void Print(Option_t *) const;
+
+    const TString &GetObservatoryName() const { return fObservatoryName; }
+
+    Double_t GetLatitudeDeg() const     { return fLatitude*kRad2Deg; }  //[deg]
+    Double_t GetLongitudeDeg() const    { return fLongitude*kRad2Deg; } //[deg]
+
+    Double_t GetLatitudeRad() const     { return fLatitude; }           //[rad]
+    Double_t GetLongitudeRad() const    { return fLongitude; }          //[rad]
+
+    Double_t GetPhi() const             { return fLatitude; }           //[rad]
+    Double_t GetElong() const           { return fLongitude; }          //[rad]
+
+    Double_t GetHeight() const          { return fHeight; }
+
+    LocationName_t GetObservatoryKey() const { return fObservatoryKey; }
+
+    ClassDef(MObservatory, 0)
+
+};
+
+#endif
+
