Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3536)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3537)
@@ -19,8 +19,31 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2004/03/17: Thomas Bretz
+
+   * mastro/MAstroCatalog.[h,cc]:
+     - some simplifications and changes
+
+   * mastro/MAstroCatalog.[h,cc]:
+     - some simplifications and changes
+
+   * mastro/MAstroSky2Local.[h,cc]:
+     - rotation matrix from sky to local coordinates
+     - added
+
+   * mastro/Makefile, mastro/AstroLinkDef.h:
+     - MAstroSky2Local added
+
+   * mraw/MRawEvtPixelIter.cc:
+     - GetIdxMaxLoGainSample(const Byte_t lofirst) const
+       accelerated and fixed (the first slice was compared to itself
+       and the last slice was not taken into account)
+
+
+
  2004/03/17: Antonio Stamerra
 
    * macros/datatrigcheck.C
      - added macro for time and trigger data-checking
+
 
 
@@ -36,4 +59,5 @@
 
 
+
  2004/03/17: Wolfgang Wittek
 
@@ -45,21 +69,24 @@
  2004/03/16: Markus Gaug
  
-  * mhist/MHCamera.[h,cc]
-    - added function RadialProfile which returns a TProfile of the 
-      value along the radius from the camera center
+   * mhist/MHCamera.[h,cc]
+     - added function RadialProfile which returns a TProfile of the 
+       value along the radius from the camera center
+
 
 
  2004/03/16: Oscar Blanch Bigas
 
-  * mimage/MConcentration.[h,cc]
-    - new class for Concentration stuff.
-    - It computes and stores Concentration 1-8
-
-  * mimage/MNewImagePar.[h,cc]
-    - New Concentration stuff is moved to MConcentration.
-
-  * mimage/MHillasCalc.[h,cc], Makefile, ImageLinkDef.h
-    - Modifications needed to support and compile new 
-      MConcentration class.
+   * mimage/MConcentration.[h,cc]
+     - new class for Concentration stuff.
+     - It computes and stores Concentration 1-8
+
+   * mimage/MNewImagePar.[h,cc]
+     - New Concentration stuff is moved to MConcentration.
+
+   * mimage/MHillasCalc.[h,cc], Makefile, ImageLinkDef.h
+     - Modifications needed to support and compile new 
+       MConcentration class.
+
+
 
  2004/03/16: Thomas Bretz
@@ -190,9 +217,4 @@
      - added MStatusArray
 
-   * mraw/MRawEvtPixelIter.cc:
-     - GetIdxMaxLoGainSample(const Byte_t lofirst) const
-       accelerated and fixed (the first slice was compared to itself
-       and the last slice was not taken into account)
-
    * mhits/MHCamera.[h,cc], mgui/MHexagon.[h,cc]:
      - improved drawing MHCamera with 'same' option
Index: trunk/MagicSoft/Mars/mastro/AstroLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/AstroLinkDef.h	(revision 3536)
+++ trunk/MagicSoft/Mars/mastro/AstroLinkDef.h	(revision 3537)
@@ -7,7 +7,9 @@
 #pragma link C++ class MVector3+;
 
+#pragma link C++ class MAstro+;
+#pragma link C++ class MAstroSky2Local+;
+#pragma link C++ class MAstroCatalog+;
+//#pragma link C++ class MAstroCamera+;
 
-#pragma link C++ class MAstro+;
-#pragma link C++ class MAstroCatalog+;
 #pragma link C++ class MObservatory+;
 
Index: trunk/MagicSoft/Mars/mastro/MAstro.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstro.cc	(revision 3536)
+++ trunk/MagicSoft/Mars/mastro/MAstro.cc	(revision 3537)
@@ -31,13 +31,17 @@
 #include "MAstro.h"
 
+#include <iostream>
+
 #include <TVector3.h> // TVector3
 
 #include "MTime.h"    // MTime::GetGmst
 
+using namespace std;
+
 ClassImp(MAstro);
 
 Double_t MAstro::Trunc(Double_t val)
 {
-    /* dint(A) - truncate to nearest whole number towards zero (double) */
+    // dint(A) - truncate to nearest whole number towards zero (double)
     return val<0 ? TMath::Ceil(val) : TMath::Floor(val);
 }
@@ -45,5 +49,5 @@
 Double_t MAstro::Round(Double_t val)
 {
-    /* dnint(A) - round to nearest whole number (double) */
+    // dnint(A) - round to nearest whole number (double)
     return val<0 ? TMath::Ceil(val-0.5) : TMath::Floor(val+0.5);
 }
@@ -57,5 +61,5 @@
 Double_t MAstro::Dms2Rad(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
 {
-    /* pi/(180*3600):  arcseconds to radians */
+    // pi/(180*3600):  arcseconds to radians
     //#define DAS2R 4.8481368110953599358991410235794797595635330237270e-6
     return Hms2Sec(deg, min, sec, sgn)*TMath::Pi()/(180*3600)/**DAS2R*/;
@@ -64,5 +68,5 @@
 Double_t MAstro::Hms2Rad(Int_t hor, UInt_t min, Double_t sec, Char_t sgn)
 {
-    /* pi/(12*3600):  seconds of time to radians */
+    // pi/(12*3600):  seconds of time to radians
 //#define DS2R 7.2722052166430399038487115353692196393452995355905e-5
     return Hms2Sec(hor, min, sec, sgn)*TMath::Pi()/(12*3600)/**DS2R*/;
Index: trunk/MagicSoft/Mars/mastro/MAstroCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCamera.cc	(revision 3536)
+++ trunk/MagicSoft/Mars/mastro/MAstroCamera.cc	(revision 3537)
@@ -49,4 +49,5 @@
 
 #include "MTime.h"
+#include "MAstroSky2Local.h"
 #include "../mhist/MHCamera.h"
 #include "MObservatory.h"
@@ -97,23 +98,6 @@
 }
 
-Int_t MAstroCamera::Convert(const TRotation &rot, TVector2 &v, Int_t type)
-{
-    MVector3 w;
-
-    switch (type)
-    {
-    case 1:
-        w.SetRaDec(v.X(), v.Y(), 1);
-        w = w.GetZdAz(*fTime, *fObservatory);
-        break;
-    case 2:
-        w.SetZdAz(v.Y(), v.X(), 1);
-        break;
-    default:
-        return kFALSE;
-    }
-
-    w *= rot;
-
+Int_t MAstroCamera::ConvertToPad(const TVector3 &w, TVector2 &v)
+{
     const TVector3 spot = fMirror0->GetReflection(w, fGeom->GetCameraDist())*1000;
 
@@ -129,4 +113,5 @@
         */
 
+
     v.Set(spot(0), spot(1));
 
@@ -135,12 +120,14 @@
 }
 
-void MAstroCamera::DrawNet(const TRotation &rot)
-{
-    TVector2 radec(fRaDec.Phi(), TMath::Pi()/2-fRaDec.Theta());
-    MAstroCatalog::DrawNet(radec, rot, 1);
-
-    const TVector3 zdaz0 = fRaDec.GetZdAz(*fTime, *fObservatory);
+void MAstroCamera::DrawNet(const TRotation &trans)
+{
+    const TRotation rot(MAstroSky2Local(*fTime, *fObservatory));
+
+    TVector2 radec(fRaDec.Phi(), fRaDec.Theta());
+    MAstroCatalog::DrawNet(radec, trans*rot, 2);
+
+    const TVector3 zdaz0 = MAstroSky2Local(*fTime, *fObservatory)*fRaDec;
     TVector2 zdaz(zdaz0.Phi(), zdaz0.Theta());
-    MAstroCatalog::DrawNet(zdaz, rot, 2);
+    MAstroCatalog::DrawNet(zdaz, trans, 1);
 }
 
@@ -185,5 +172,7 @@
     const Bool_t usecam  = opt.Contains("c", TString::kIgnoreCase);
 
-    const Float_t rho = fObservatory->RotationAngle(fRaDec.Phi(), TMath::Pi()/2-fRaDec.Theta(), *fTime);
+    MAstroSky2Local rot(*fTime, *fObservatory);
+
+    const Float_t rho = rot.RotationAngle(fRaDec.Phi(), TMath::Pi()/2-fRaDec.Theta());
 
     TString str = fTime->GetSqlDateTime();
@@ -232,12 +221,20 @@
     }
 
-    const TVector3 zdaz0 = fRaDec.GetZdAz(*fTime, *fObservatory);
-
-    TRotation rot;
-    rot.RotateZ(-zdaz0.Phi());
-    rot.RotateY(-zdaz0.Theta());
-    rot.RotateZ(-TMath::Pi()/2); // align coordinate system
-
-    DrawNet(rot);
+    TVector3 zdaz0 = fRaDec;
+    zdaz0 *= rot;
+
+    cout << zdaz0.Phi()*TMath::RadToDeg() << " " << zdaz0.Theta()*TMath::RadToDeg() << endl;
+
+    TVector3 test = zdaz0;
+    test *= rot.Inverse();
+
+    cout << test.Phi()*TMath::RadToDeg()/15 << " " << test.Theta()*TMath::RadToDeg() << endl;
+
+    TRotation rot2;
+    rot2.RotateZ(-zdaz0.Phi());
+    rot2.RotateY(-zdaz0.Theta());
+    rot2.RotateZ(-TMath::Pi()/2); // align coordinate system
+
+    DrawNet(rot2);
 
     MVector3 *radec;
@@ -248,8 +245,10 @@
         const Double_t mag = radec->Magnitude();
 
-        TVector3 star = radec->GetZdAz(*fTime, *fObservatory);
-
+        TVector3 star(*radec);
+
+        // Calculate local coordinates
+        star *= rot;
         // Rotate Star into telescope system
-        star *= rot;
+        star *= rot2;
 
         TVector3 mean;
Index: trunk/MagicSoft/Mars/mastro/MAstroCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCamera.h	(revision 3536)
+++ trunk/MagicSoft/Mars/mastro/MAstroCamera.h	(revision 3537)
@@ -21,5 +21,5 @@
     MGeomMirror  *fMirror0;     //!
 
-    Int_t  Convert(const TRotation &rot, TVector2 &v, Int_t type);
+    Int_t  ConvertToPad(const TVector3 &w, TVector2 &v);
     void   AddPrimitives(Option_t *o);
     void   SetRangePad() { }
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 3536)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 3537)
@@ -52,4 +52,5 @@
 #include "MTime.h"
 #include "MAstro.h"
+#include "MAstroSky2Local.h"
 #include "MObservatory.h"
 
@@ -59,4 +60,22 @@
 using namespace std;
 
+class MRotation : public TRotation
+{
+public:
+    MRotation(Double_t gmst, const MObservatory &obs) : TRotation(1, 0, 0, 0, -1, 0, 0, 0, 1)
+    {
+        RotateZ(gmst + obs.GetElong());
+        RotateY(obs.GetPhi()-TMath::Pi()/2);
+        RotateZ(TMath::Pi());
+    }
+    MRotation(const MTime &t, const MObservatory &obs) : TRotation(1, 0, 0, 0, -1, 0, 0, 0, 1)
+    {
+        RotateZ(t.GetGmst() + obs.GetElong());
+        RotateY(obs.GetPhi()-TMath::Pi()/2);
+        RotateZ(TMath::Pi());
+    }
+};
+
+/*
 MVector3 MVector3::GetZdAz(const MObservatory &obs, Double_t gmst) const
 {
@@ -64,20 +83,20 @@
         return MVector3();
 
-    const Double_t alpha = gmst + obs.GetElong();
-
-    MVector3 zdaz;
-    zdaz.SetZdAz(Theta(), alpha-Phi(), Mag());
-    zdaz.RotateY(obs.GetPhi()-TMath::Pi()/2);
-
-    return zdaz;
-
-    /*
+    MVector3 v(*this);
+    v *= MAstroSky2Local(gmst, obs);
+
+    return v;
+
+     // ------ Using vectors -------
+     // v(1) = -v(1);                     //  phi -->      -phi
+     // v.RotateZ(gmst + obs.GetElong()); // -phi --> alpha-phi
+     // v.RotateY(obs.GetPhi()-TMath::Pi()/2);
+     // v.RotateZ(TMath::Pi());
+
      // ------ The same using slalib, tested in the drive system -------
-     const Double_t alpha = slaGmst(mjd) + obs.GetElong();
-     Double_t el;
-     slaDe2h(fAlpha-ra, dec, obs.GetPhi(), &az, &el);
-     zd = TMath::Pi()/2-el;
-     return;
-     */
+     // const Double_t alpha = slaGmst(mjd) + obs.GetElong();
+     // Double_t el;
+     // slaDe2h(fAlpha-ra, dec, obs.GetPhi(), &az, &el);
+     // zd = TMath::Pi()/2-el;
 }
 
@@ -92,21 +111,20 @@
         return MVector3();
 
-    const Double_t alpha = gmst + obs.GetElong();
-
     MVector3 v(*this);
-    v.RotateY(TMath::Pi()/2-obs.GetPhi());
-
-    MVector3 rd;
-    rd.SetRaDec(alpha-v.Phi(), TMath::Pi()/2-v.Theta(), Mag());
-    return rd;
-
-    /*
+    v *= MAstroSky2Local(gmst, obs).Inverse();
+
+    return v;
+
+     // ------ Using vectors -------
+     // v.RotateZ(-TMath::Pi());
+     // v.RotateY(TMath::Pi()/2-obs.GetPhi());
+     // v.RotateZ(-gmst - obs.GetElong()); // alpha-phi --> -phi
+     // v(1) = -v(1);                      //      -phi -->  phi
+
      // ------ The same using slalib, tested in the drive system -------
-     const Double_t alpha = slaGmst(mjd) + obs.GetElong();
-     Double_t el;
-     slaDe2h(fAlpha-ra, dec, obs.GetPhi(), &az, &el);
-     zd = TMath::Pi()/2-el;
-     return;
-     */
+     // const Double_t alpha = slaGmst(mjd) + obs.GetElong();
+     // Double_t el;
+     // slaDe2h(fAlpha-ra, dec, obs.GetPhi(), &az, &el);
+     // zd = TMath::Pi()/2-el;
 }
 
@@ -115,5 +133,5 @@
     return GetRaDec(obs, time.GetGmst());
 }
-
+*/
 MAstroCatalog::MAstroCatalog() : fLimMag(99), fRadiusFOV(99), fToolTip(0), fObservatory(0), fTime(0)
 {
@@ -386,27 +404,59 @@
 }
 
-Int_t MAstroCatalog::Convert(const TRotation &rot, TVector2 &v, Int_t type)
-{
-    MVector3 w;
-
-    switch (type)
-    {
-    case 1:
-        w.SetRaDec(v.X()-fRaDec.Phi(), v.Y(), 1);
-        break;
-
-    case 2:
-        if (!fTime || !fObservatory)
-            return kFALSE;
-        w.SetZdAz(v.Y(), v.X(), 1);
-        w = w.GetRaDec(*fTime, *fObservatory);
-        w.RotateZ(-fRaDec.Phi());
-        break;
-
-    default:
-        return kFALSE;
-    }
-
-    w *= rot;
+void MAstroCatalog::Paint(Option_t *o)
+{
+//    if (!gPad->IsBatch())
+//        gVirtualX->ClearWindow();
+
+    if (TestBit(kHasChanged))
+        DrawPrimitives(o);
+}
+
+void MAstroCatalog::DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t transparent, const char *txt)
+{
+    const Double_t ra  = v.Phi()*TMath::RadToDeg()/15;
+    const Double_t dec = (TMath::Pi()/2-v.Theta())*TMath::RadToDeg();
+
+    TString str = v.GetName();
+    str += Form(":  Ra=%.2fh", ra);
+    str += Form("  Dec=%.1fd", dec);
+    str += Form("  Mag=%.1f", -2.5*log10(v.Mag()));
+    if (txt)
+        str += Form("  (%s)", txt);
+
+    // draw star on the camera display
+    TMarker *tip=new TMarker(x, y, transparent ? kDot : kFullDotLarge);;
+    tip->SetMarkerColor(kBlack);
+    tip->SetBit(kCanDelete);
+    tip->SetBit(kCannotPick);
+    AddMap(tip, new TString(str));
+}
+
+void MAstroCatalog::Update()
+{
+    if (gPad && TestBit(kMustCleanup))
+    {
+        SetBit(kHasChanged);
+        gPad->Modified();
+    }
+}
+
+void MAstroCatalog::SetTime(const MTime &time)
+{
+    if (fTime)
+        delete fTime;
+    fTime=(MTime*)time.Clone();
+}
+
+void MAstroCatalog::SetObservatory(const MObservatory &obs)
+{
+    if (fObservatory)
+        delete fObservatory;
+    fObservatory=(MObservatory*)obs.Clone();
+}
+
+Int_t MAstroCatalog::ConvertToPad(const TVector3 &w0, TVector2 &v)
+{
+    TVector3 w(w0);
 
     // Stretch such, that the X-component is alwas the same. Now
@@ -427,4 +477,13 @@
 }
 
+Int_t MAstroCatalog::Convert(const TRotation &rot, TVector2 &v)
+{
+    MVector3 w;
+    w.SetMagThetaPhi(1, v.Y(), v.X());
+    w *= rot;
+
+    return ConvertToPad(w, v);
+}
+
 Bool_t MAstroCatalog::DrawLine(const TVector2 &v, Double_t dx, Double_t dy, const TRotation &rot, Int_t type)
 {
@@ -434,6 +493,7 @@
     TVector2 v1 = v+add;
 
-    const Int_t rc0 = Convert(rot, v0, type);
-    const Int_t rc1 = Convert(rot, v1, type);
+    const Int_t rc0 = Convert(rot, v0);
+    const Int_t rc1 = Convert(rot, v1);
+
     // Both are kFALSE or both are kERROR
     if ((rc0|rc1)==kFALSE || (rc0&rc1)==kERROR)
@@ -449,5 +509,5 @@
     const TVector2 deg = v*TMath::RadToDeg();
     TString txt = type==1 ?
-        Form("Ra=%.1fh  Dec=%.1fd", fmod(deg.X()/15+48, 24),  fmod(deg.Y()+270,180)-90) :
+        Form("Ra=%.1fh  Dec=%.1fd", fmod(deg.X()/15+48, 24),  fmod(90-deg.Y()+270,180)-90) :
         Form("Zd=%.1fd  Az=%.1fd",  fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360));
 
@@ -461,13 +521,8 @@
 }
 
+
 void MAstroCatalog::Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type)
 {
     const TVector2 v1 = v0 + TVector2(dx[0]*TMath::DegToRad(), dy[0]*TMath::DegToRad());
-
-    //    if (TMath::Abs(v1.Y())>TMath::Pi()/2)
-    //        return;
-
-    //    const Int_t v0x = (int)(v0.X()*TMath::RadToDeg());
-    //    const Int_t v0y = (int)(v0.Y()*TMath::RadToDeg());
 
     Int_t idx[] = {1, 1, 1, 1};
@@ -501,8 +556,8 @@
         {
             // Calculate new position
-            //dx[0] = (d[0]+dirs[i][0]+540-v0x)%360-180+v0x;
-            //dy[0] = (d[1]+dirs[i][1]+270-v0y)%180- 90+v0y;
             dx[0] = d[0]+dirs[i][0];
             dy[0] = d[1]+dirs[i][1];
+
+            //cout << dx[0] << " " << dy[0] << endl;
 
             // Draw corresponding line and iterate through grid
@@ -510,5 +565,6 @@
                 Draw(v0, rot, dx, dy, stepx, stepy, type);
 
-            dx[0]=d[0]; dy[0]=d[1];
+            dx[0]=d[0];
+            dy[0]=d[1];
         }
 }
@@ -516,6 +572,4 @@
 void MAstroCatalog::DrawNet(const TVector2 &v0, const TRotation &rot, Int_t type)
 {
-    //const Double_t step = TMath::DegToRad();
-
     TArrayI dx(1);
     TArrayI dy(1);
@@ -527,5 +581,6 @@
     // calculate stepsizes based on visible FOV
     Int_t stepx=1;
-    if (fabs(v.Y())>90-fRadiusFOV || fabs(v.Y())<fRadiusFOV)
+
+    if (fabs(90-v.Y())>90-fRadiusFOV || fabs(90-v.Y())<fRadiusFOV)
         stepx = 180/10;
     else
@@ -534,6 +589,6 @@
         const Float_t m = log(fRadiusFOV/180.)/log(90./fRadiusFOV-1);
         const Float_t t = log(180.)-m*log(fRadiusFOV);
-        const Int_t n = (Int_t)(exp(m*log(90-fabs(v.Y()))+t)+0.5);
-        stepx = n<4 ? 1 : n/4;
+        const Int_t n = (Int_t)(exp(m*log(90-fabs(90-v.Y()))+t)+0.5);
+        stepx = n<6 ? 1 : n/6;
     }
 
@@ -556,74 +611,25 @@
     // draw...
     v *= TMath::DegToRad();
+
     Draw(v, rot, dx, dy, stepx, stepy, type);
 }
 
-void MAstroCatalog::Paint(Option_t *o)
-{
-//    if (!gPad->IsBatch())
-//        gVirtualX->ClearWindow();
-
-    if (TestBit(kHasChanged))
-        DrawPrimitives(o);
-}
-
-void MAstroCatalog::DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t transparent, const char *txt)
-{
-    const Double_t ra  = v.Phi()*TMath::RadToDeg()/15;
-    const Double_t dec = (TMath::Pi()/2-v.Theta())*TMath::RadToDeg();
-
-    TString str = v.GetName();
-    str += Form(":  Ra=%.1fh", ra);
-    str += Form("  Dec=%.1fd", dec);
-    str += Form("  Mag=%.1f", -2.5*log10(v.Mag()));
-    if (txt)
-        str += Form("  (%s)", txt);
-
-    // draw star on the camera display
-    TMarker *tip=new TMarker(x, y, transparent ? kDot : kFullDotLarge);;
-    tip->SetMarkerColor(kBlack);
-    tip->SetBit(kCanDelete);
-    tip->SetBit(kCannotPick);
-    AddMap(tip, new TString(str));
-}
-
-void MAstroCatalog::Update()
-{
-    if (gPad && TestBit(kMustCleanup))
-    {
-        SetBit(kHasChanged);
-        gPad->Modified();
-    }
-}
-
-void MAstroCatalog::SetTime(const MTime &time)
-{
-    if (fTime)
-        delete fTime;
-    fTime=(MTime*)time.Clone();
-}
-
-void MAstroCatalog::SetObservatory(const MObservatory &obs)
-{
-    if (fObservatory)
-        delete fObservatory;
-    fObservatory=(MObservatory*)obs.Clone();
-}
-
 void MAstroCatalog::AddPrimitives(Option_t *o)
 {
-    const Double_t ra  = fRaDec.Phi();
-    const Double_t dec = TMath::Pi()/2-fRaDec.Theta();
-
     // Precalc Sin/Cos...
     TRotation trans;
-    trans.Rotate(dec, TVector3(0, 1, 0));
-
-    const TVector3 zdaz0 = fRaDec.GetZdAz(*fTime, *fObservatory);
-    TVector2 zdaz(zdaz0.Phi(), zdaz0.Theta());
-    MAstroCatalog::DrawNet(zdaz, trans, 2);
-
-    TVector2 radec(ra, dec);
-    MAstroCatalog::DrawNet(radec, trans, 1);
+    trans.RotateZ(-fRaDec.Phi());
+    trans.Rotate(TMath::Pi()/2-fRaDec.Theta(), TVector3(0, 1, 0));
+
+    if (fTime && fObservatory)
+    {
+        const TRotation rot(MAstroSky2Local(*fTime, *fObservatory));
+        const TVector3 zdaz0 = rot*fRaDec;
+        const TVector2 zdaz(zdaz0.Phi(), zdaz0.Theta());
+        DrawNet(zdaz, trans*rot.Inverse(), 2);
+    }
+
+    const TVector2 radec(fRaDec.Phi(), fRaDec.Theta());
+    DrawNet(radec, trans, 1);
 
     TIter Next(&fList);
@@ -632,7 +638,7 @@
     {
         // FIXME: Check Magnitude!
-        TVector2 s(v->Phi(), TMath::Pi()/2-v->Theta());
-        if (Convert(trans, s, 1)==kTRUE)
-            DrawStar(s.X(), s.Y(), *v, kFALSE);
+        TVector2 s(v->Phi(), v->Theta());
+        if (Convert(trans, s)==kTRUE)
+            DrawStar(s.X(), TMath::Pi()/2-s.Y(), *v, kFALSE);
     }
 }
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.h	(revision 3536)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.h	(revision 3537)
@@ -62,10 +62,10 @@
 
     const char *GetName() const { return fName; }
-
+/*
     MVector3 GetZdAz(const MObservatory &obs, Double_t gmst) const;
     MVector3 GetZdAz(const MTime &time, MObservatory &obs) const;
     MVector3 GetRaDec(const MObservatory &obs, Double_t gmst) const;
     MVector3 GetRaDec(const MTime &time, MObservatory &obs) const;
-
+  */
     ClassDef(MVector3, 1)
 };
@@ -106,5 +106,6 @@
     MTime        *fTime;        // Possible observation time
 
-    virtual Int_t  Convert(const TRotation &rot, TVector2 &v, Int_t type=0);
+    virtual Int_t  ConvertToPad(const TVector3 &w, TVector2 &v);
+    virtual Int_t  Convert(const TRotation &rot, TVector2 &v);
     virtual Bool_t DrawLine(const TVector2 &v0, Double_t dx, Double_t dy, const TRotation &rot, Int_t type);
     virtual void   AddPrimitives(Option_t *o);
Index: trunk/MagicSoft/Mars/mastro/MAstroSky2Local.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroSky2Local.cc	(revision 3536)
+++ trunk/MagicSoft/Mars/mastro/MAstroSky2Local.cc	(revision 3537)
@@ -54,4 +54,8 @@
 //
 //   v *= MAstroSky2Local(time, obs).Inverse();
+//
+// Reminder: This tranformation only does a simple coordinate
+//           transformation. It completely ignores all other atrometric
+//           effects, like nutation, abberation, precission, ...
 //
 ////////////////////////////////////////////////////////////////////////////
Index: trunk/MagicSoft/Mars/mastro/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mastro/Makefile	(revision 3536)
+++ trunk/MagicSoft/Mars/mastro/Makefile	(revision 3537)
@@ -22,11 +22,7 @@
 #  connect the include files defined in the config.mk file
 #
-INCLUDES =  -I. -I../mbase
+INCLUDES =  -I. -I../mbase -I../mgeom
 
-# mgui (MCamEvent):         MExtractSignalCam
-# mgeom(MGeomCam):          MArrivalTime
-# mtools(MCubicSpline):     MArrivalTime
-# mraw (MRawEvtData):       MExtractSignal
-# manalysis (MPedestalCam): MExtractSignal
+# mgeom (MAstroCamera): MGeomCam, MGeomMirror
 
 #------------------------------------------------------------------------------
@@ -35,6 +31,8 @@
 
 SRCFILES = MAstro.cc \
+	   MAstroSky2Local.cc \
 	   MAstroCatalog.cc \
            MObservatory.cc
+#           MAstroCamera.cc \
 
 SRCS    = $(SRCFILES)
Index: trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc	(revision 3536)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc	(revision 3537)
@@ -239,7 +239,8 @@
     return -1; // means: not found
   
-  Byte_t *ptr = fLoGainPos+lofirst;
-  Byte_t *max = ptr;
-  const Byte_t *end = fLoGainPos + fNumLoGainSamples;
+  Byte_t *max = fLoGainPos+lofirst;
+  Byte_t *ptr = max+1;
+
+  const Byte_t *end = fLoGainPos + fNumLoGainSamples + 1;
   
   do if (*ptr>*max) max = ptr;
