Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3709)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3710)
@@ -18,4 +18,24 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/04/13: Thomas Bretz
+
+   * mastro/MAstroCamera.cc, mastro/MAstroCatalog.[h,cc]:
+     - enhanced comments
+     - added some new features
+     
+   * mbase/MAGIC.h:
+     - removed some empty lines
+     
+   * mfileio/MWriteRootFile.cc:
+     - fixed a compiler warning
+     
+   * mgeom/MGeomCorsikaCT.h:
+     - removed obsolete include of TArrayF
+
+   * mgeom/MGeomMirror.[h,cc]:
+     - replaced fReflector by *fReflector
+
+
+
  2004/04/10: Markus Gaug
   
@@ -29,4 +49,5 @@
      - scheme of the calibration classes, used for documentation in 
        MJCalibration.cc
+
 
 
Index: trunk/MagicSoft/Mars/mastro/MAstroCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCamera.cc	(revision 3709)
+++ trunk/MagicSoft/Mars/mastro/MAstroCamera.cc	(revision 3710)
@@ -26,11 +26,23 @@
 //
 // MAstroCamera
+// ============
 //
 // A tools displaying stars from a catalog in the camera display.
-//
+// PRELIMINARY!!
+//
+//
+// Usage:
+// ------
 // For a usage example see macros/starfield.C
 //
-// PRELIMINARY!!
-//
+// To be able to reflect the star-light you need the geometry of the
+// mirror and the distance of the plain screen.
+//
+// You can get the mirror geometry from a MC file and the distance of
+// the screen from MGeomCam.
+//
+//
+// Algorithm:
+// ----------
 // The caluclation of the position of the reflection in the camera is
 // done by:
@@ -44,15 +56,23 @@
 //     individual mirror
 //
-// GUI: You can use the the cursor keys to change the pointing position
-//      and plus/minus to change the time by a quarter of an hour.
+//
+// GUI:
+// ----
+//  * You can use the the cursor keys to change the pointing position
+//    and plus/minus to change the time by a quarter of an hour.
+//
+// ToDo:
+// -----
+//  * possibility to overwrite distance from mirror to screen
+//  * read the mirror geometry directly from the MC input file
 //
 /////////////////////////////////////////////////////////////////////////////
 #include "MAstroCamera.h"
 
-#include <KeySymbols.h>
-
-#include <TH2.h>
-#include <TMarker.h>
-#include <TVirtualPad.h>
+#include <KeySymbols.h>       // kKey_*
+
+#include <TH2.h>              // TH2D
+#include <TMarker.h>          // TMarker
+#include <TVirtualPad.h>      // gPad
 
 #include "MLog.h"
@@ -64,6 +84,8 @@
 #include "MTime.h"
 #include "MAstroSky2Local.h"
-#include "../mhist/MHCamera.h"
 #include "MObservatory.h"
+
+#include "../mhist/MHCamera.h" // FIXME: This dependancy is very bad!
+                               // HOW TO GET RID OF IT? Move MHCamera to mgeom?
 
 ClassImp(MAstroCamera);
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 3709)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 3710)
@@ -25,10 +25,15 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// MAstroCatalog
-//
-// THIS IMPLEMENTATION IS PRELIMINARY AND WILL BE MERGED WITH
-// SOME PARTS OF THE DRIVE SOFTWARE SOON!
-//
-// To display a starfield you must have a supported catalog, then do:
+//  MAstroCatalog
+//  =============
+//
+//  THIS IMPLEMENTATION IS PRELIMINARY AND WILL BE MERGED WITH
+//  SOME PARTS OF THE DRIVE SOFTWARE SOON!
+//
+//
+//  Usage:
+//  ------
+//
+//  To display a starfield you must have a supported catalog, then do:
 //
 //    MTime time;
@@ -63,4 +68,7 @@
 //  information is displayed.
 //
+//
+//  Coordinate Transformation:
+//  -------------------------
 //  The conversion from sky coordinates to local coordinates is done using
 //  MAstroSky2Local which does a simple rotation of the coordinate system.
@@ -68,9 +76,10 @@
 //  astrometrical corrections (nutation, precission, abberation, ...)
 //
+//
 //  GUI:
+//  ----
 //    * If the gui is interactive you can use the cursor keys to change
 //      the position you are looking at and with plus/minus you
 //      can (un)zoom the FOV (Field Of View)
-//
 //    * The displayed values mean the following:
 //        + alpha: Right Ascension
@@ -81,29 +90,37 @@
 //                 coordinate system
 //        + time of display
-//
 //    * Move the mouse on top of the grid points or the stars to get
 //      more setailed information.
+//    * Enable the event-info in a canvas to see the current
+//      ObjectInfo=tooltip-text
+//    * call SetNoToolTips to supress the tooltips
+//    * the blue lines are the local coordinat system
+//    * the red lines are sky coordinate system
+//
 //
 //  ToDo:
+//  -----
 //   - replace MVetcor3 by a more convinient class. Maybe use TExMap, too.
+//   - change tooltips to multi-line tools tips as soon as root
+//     supports them
+//   - a derived class is missing which supports all astrometrical
+//     correction (base on slalib and useable in Cosy)
 //
 //////////////////////////////////////////////////////////////////////////////
 #include "MAstroCatalog.h"
 
-#include <errno.h>
-#include <fstream>
-#include <stdlib.h>
-#include <limits.h> // INT_MAX (Suse 7.3/gcc 2.95)
-
-#include <KeySymbols.h>
-
-#include <TPad.h> // TPad::GetMaxPickDistance
-#include <TLine.h>
-#include <TMarker.h>
-#include <TCanvas.h>
-#include <TArrayI.h>
-#include <TGToolTip.h>
-#include <TRotation.h>
-#include <TPaveText.h>
+#include <errno.h>      // strerror
+#include <fstream>      // ifstream
+#include <stdlib.h>     // ati, atof
+#include <limits.h>     // INT_MAX (Suse 7.3/gcc 2.95)
+
+#include <KeySymbols.h> // kKey_*
+
+#include <TLine.h>      // TLine
+#include <TMarker.h>    // TMarker
+#include <TCanvas.h>    // TCanvas
+#include <TArrayI.h>    // TArrayI
+#include <TGToolTip.h>  // TGToolTip
+#include <TPaveText.h>  // TPaveText
 
 #include "MLog.h"
@@ -997,8 +1014,33 @@
 // --------------------------------------------------------------------------
 //
+// Search for an object at px, py in fMapG. Return the pointer to it
+// if found. Set str accordingly if a tooltip string is found.
+//
+TObject *MAstroCatalog::PickObject(Int_t px, Int_t py, TString &str) const
+{
+    Long_t key, val;
+    TExMapIter map(&fMapG);
+    while (map.Next(key, val))
+    {
+        if (!val)
+            continue;
+
+        TObject *o=(TObject*)key;
+        if (o->DistancetoPrimitive(px, py)>TPad::GetMaxPickDistance())
+            continue;
+
+        str = *(TString*)val;
+        return o;
+    }
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
 // This function was connected to all created canvases. It is used
 // to redirect GetObjectInfo into our own status bar.
 //
-// The 'connection' is done in AddTab
+// The 'connection' is done in Draw. It seems that 'connected'
+// functions must be public.
 //
 void MAstroCatalog::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
@@ -1012,23 +1054,7 @@
     // Try to find a corresponding object with kCannotPick set and
     // an available TString (for a tool tip)
-    TString *str=0;
+    TString str;
     if (!selected || selected==this)
-    {
-        Long_t key, val;
-        TExMapIter map(&fMapG);
-        while (map.Next(key, val))
-        {
-            if (!val)
-                continue;
-
-            TObject *o=(TObject*)key;
-            if (o->DistancetoPrimitive(px, py)>TPad::GetMaxPickDistance())
-                continue;
-
-            selected = o;
-            str = (TString*)val;
-            break;
-        }
-    }
+        selected = PickObject(px, py, str);
 
     if (!selected)
@@ -1039,6 +1065,6 @@
     {
     case kMouseMotion:
-        if (!fToolTip->IsMapped() && str)
-            ShowToolTip(px, py, *str);
+        if (!fToolTip->IsMapped() && !str.IsNull())
+            ShowToolTip(px, py, str);
         break;
 
@@ -1136,6 +1162,12 @@
 
 // --------------------------------------------------------------------------
+//
+// Displays a tooltip
+//
 void MAstroCatalog::ShowToolTip(Int_t px, Int_t py, const char *txt)
 {
+    if (TestBit(kNoToolTips))
+        return;
+
     Int_t x=0;
     Int_t y=0;
@@ -1151,4 +1183,22 @@
     fToolTip->Show(x+4, y+4);
 }
+
+// ------------------------------------------------------------------------
+//
+// Returns string containing info about the object at position (px,py).
+// Returned string will be re-used (lock in MT environment).
+//
+char *MAstroCatalog::GetObjectInfo(Int_t px, Int_t py) const
+{
+
+    TString str;
+    PickObject(px, py, str);
+
+    static char txt[129];
+    txt[128]=0;
+
+    return strncpy(txt, str.Data(), 128);
+}
+
 
 /*
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.h	(revision 3709)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.h	(revision 3710)
@@ -127,5 +127,6 @@
         kPlainScreen = BIT(17), // View is a plain screen view
         kMirrorX     = BIT(18), // Mirror display in X
-        kMirrorY     = BIT(19)  // Mirror display in Y
+        kMirrorY     = BIT(19), // Mirror display in Y
+        kNoToolTips  = BIT(20)  // suppress tooltips
     };
 
@@ -141,6 +142,8 @@
     void      Update(Bool_t upd=kFALSE);
 
-    void ExecuteEventKbd(Int_t keycode, Int_t keysym);
-    void ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
+    void      ExecuteEventKbd(Int_t keycode, Int_t keysym);
+    void      ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
+    TObject  *PickObject(Int_t px, Int_t py, TString &str) const;
+    char     *GetObjectInfo(Int_t px, Int_t py) const;
 
     void AddMap(TObject *k, void *v=0)
@@ -176,4 +179,7 @@
     Bool_t IsPlainScreen() const             { return TestBit(kPlainScreen); }
 
+    void   SetNoToolTips(Bool_t b=kTRUE)     { b ? SetBit(kNoToolTips) : ResetBit(kNoToolTips); } // *TOGGLE* *GETTER=HasNoToolTips
+    Bool_t HasNoToolTips() const             { return TestBit(kNoToolTips); }
+
     Double_t GetLimMag() const { return fLimMag; } // Get Limiting Magnitude
     Double_t GetRadiusFOV() const { return fRadiusFOV; } // Get maximum radius of Field Of View
Index: trunk/MagicSoft/Mars/mbase/MAGIC.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MAGIC.h	(revision 3709)
+++ trunk/MagicSoft/Mars/mbase/MAGIC.h	(revision 3710)
@@ -31,8 +31,2 @@
 
 #endif
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 3709)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 3710)
@@ -202,5 +202,5 @@
 
     if (tname && tname[0])
-        AddToBranchList(Form("%s.%s", AddSerialNumber(cname), tname));
+        AddToBranchList(Form("%s.%s", (const char*)AddSerialNumber(cname), tname));
 }
 
Index: trunk/MagicSoft/Mars/mgeom/MGeomCorsikaCT.h
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomCorsikaCT.h	(revision 3709)
+++ trunk/MagicSoft/Mars/mgeom/MGeomCorsikaCT.h	(revision 3710)
@@ -2,7 +2,4 @@
 #define MARS_MGeomCorsikaCT
 
-#ifndef ROOT_TArrayF
-#include <TArrayF.h>
-#endif
 #ifndef MARS_MParContainer
 #include "MParContainer.h"
Index: trunk/MagicSoft/Mars/mgeom/MGeomMirror.cc
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomMirror.cc	(revision 3709)
+++ trunk/MagicSoft/Mars/mgeom/MGeomMirror.cc	(revision 3710)
@@ -30,6 +30,7 @@
 //
 /////////////////////////////////////////////////////////////////////////////
+#include "MGeomMirror.h"
 
-#include "MGeomMirror.h"
+#include <TRotation.h>
 
 #include "MLog.h"
@@ -45,4 +46,5 @@
 //
 MGeomMirror::MGeomMirror(Int_t mir, const char *name, const char *title)
+    : fReflector(0)
 {
     fName  = name  ? name  : "MGeomMirror";
@@ -131,8 +133,8 @@
 TVector3 MGeomMirror::GetReflection(const TVector3 &star, Double_t dist)
 {
-    if (fReflector==TRotation())
+    if (!fReflector)
     {
-        fReflector = TRotation(); // unit matrix
-        fReflector.Rotate(TMath::Pi(), GetMirrorNorm());
+        fReflector = new TRotation; // unit matrix
+        fReflector->Rotate(TMath::Pi(), GetMirrorNorm());
     }
 
@@ -140,5 +142,5 @@
     // around the normal vector of the mirror center
     TVector3 light(star);
-    light *= fReflector;
+    light *= *fReflector;
 
     if (dist<0)
Index: trunk/MagicSoft/Mars/mgeom/MGeomMirror.h
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomMirror.h	(revision 3709)
+++ trunk/MagicSoft/Mars/mgeom/MGeomMirror.h	(revision 3710)
@@ -10,7 +10,5 @@
 #endif
 
-#ifndef ROOT_TRotation
-#include <TRotation.h>
-#endif
+class TRotation;
 
 class MGeomMirror : public MParContainer
@@ -37,5 +35,5 @@
     TArrayF fReflectivity; // Mirror reflectivity
 
-    TRotation fReflector;  //! Store this for acceleration
+    TRotation *fReflector; //! Store this for acceleration
 
 public:
