Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7178)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7179)
@@ -21,4 +21,43 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2005/07/11 Thomas Bretz
+
+   * callisto.cc, ganymed.cc, mars.cc, showlog.cc,
+     showplot.cc, sponde.cc, mimage/MImgCleanStd.cc:
+     - fixed some typos
+
+   * mastro/MAstro.[h,cc]:
+     - added new member function GetStringDeg and GetStringHor
+
+   * mastro/MAstroCatalog.cc:
+     - don't display empty ":  " in tooltip for sources without name
+
+   * mbase/MParContainer.cc, mbase/MTask.cc:
+     - fixed usage of a ?:-operator
+
+   * mbase/MString.h:
+     - added two new constructors
+
+   * mjobs/MDataSet.cc:
+     - made sure that all files read later are sorted correctly.
+       This is necessary to ensure correct reading of subsystem
+       data.
+     - skipped adding a sequence twice
+
+     - print effective on time only in debug mode
+     
+   * mjobs/MSequence.cc:
+     - skipped adding a run twice
+
+   * mpointing/MSrcPosCalc.cc:
+     - reformatted the comments
+     - add MTime and MPointingPos to branch list
+     - fTime and fObservatory are now presearched in PreProcess
+       to allow usage in macros having no RunHeaders (if they are
+       not found no warning is printed!)
+     - added sanity checks for these pointers in Process
+
+
 
  2005/07/08 Thomas Bretz
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 7178)
+++ trunk/MagicSoft/Mars/NEWS	(revision 7179)
@@ -16,4 +16,12 @@
 
    - general: MHillas - the case of CorrXY==0 is now handled properly
+
+   - general: Runs in sequences and datasets are now automatically 
+     ordered (it is assumed that the order of their filenames correctly
+     represents the order of observations) to ensure correct reading
+     of the subsystem data
+
+   - general: Runs cannot be added to a sequence twice anymore. Also
+     Sequences cannot be added twice anymore to a dataset.
 
    - showplot: got a new option to start a root interpreter, too
Index: trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- trunk/MagicSoft/Mars/callisto.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/callisto.cc	(revision 7179)
@@ -46,5 +46,5 @@
     gLog << " callisto [-c] [-y] [options] sequence.txt" << endl << endl;
     gLog << " Arguments:" << endl;
-    gLog << "   sequence.txt:             Ascii file defining a sequence of runs" << endl;
+    gLog << "   sequence.txt:             ASCII file defining a sequence of runs" << endl;
     gLog << "                             For more details see MSequence" << endl;
     gLog << " Root Options:" << endl;
@@ -94,9 +94,9 @@
     gLog << " is used." << endl << endl;
     gLog << " Using  --iny=,  --outc=,  --outy=,  --out=  or --path= automatically" << endl;
-    gLog << " enables the corresponmding modes.  In this case  -c/-y are obsolete." << endl << endl;
+    gLog << " enables the corresponding modes.  In this case  -c/-y are obsolete." << endl << endl;
     gLog << "Description:" << endl;
     gLog << " callisto will calculate pedestals  from  pedestal-files defined in a" << endl;
     gLog << " sequence-file.  This pedestals are used to calculate the calibration" << endl;
-    gLog << " contants. These constants are stored in a so called calibration-file" << endl;
+    gLog << " constants. These constants are stored in a so called calibration-file" << endl;
     gLog << " together with some datacheck plots  which can be viewed using either" << endl;
     gLog << " showplot or MStatusDisplay in the interpreter.  A description  of  a" << endl;
@@ -111,5 +111,5 @@
     gLog << " Jupiter at a mean distance of 1,883,000km. Its mass is 1.1e23 kg. It" << endl;
     gLog << " takes Callisto  16.7 days to orbit  Jupiter  in a synchronous orbit." << endl;
-    gLog << " Jupiter's moon Callisto was discovered independantly by  Galileo and" << endl;
+    gLog << " Jupiter's moon Callisto was discovered independently by  Galileo and" << endl;
     gLog << " S.Marius in 1610." << endl << endl;
     gLog << "Example:" << endl;
Index: trunk/MagicSoft/Mars/ganymed.cc
===================================================================
--- trunk/MagicSoft/Mars/ganymed.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/ganymed.cc	(revision 7179)
@@ -43,5 +43,5 @@
     gLog << " ganymed [options] sequences.txt" << endl << endl;
     gLog << " Arguments:" << endl;
-    gLog << "   dataset.txt:              Ascii file defining a collection of sequences" << endl;
+    gLog << "   dataset.txt:              ASCII file defining a collection of sequences" << endl;
     gLog << "                             For more details see MDataSet." << endl;
     gLog << " Root Options:" << endl;
@@ -142,5 +142,5 @@
     if (arg.GetNumOptions()>0)
     {
-        gLog << warn << "WARNING - Unknown commandline options..." << endl;
+        gLog << warn << "WARNING - Unknown command-line options..." << endl;
         arg.Print("options");
         gLog << endl;
@@ -158,5 +158,5 @@
 
     //
-    // Setup sequence file and check for its existance
+    // Setup sequence file and check for its existence
     //
     const TString kSequences = arg.GetArgumentStr(0);
Index: trunk/MagicSoft/Mars/mars.cc
===================================================================
--- trunk/MagicSoft/Mars/mars.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/mars.cc	(revision 7179)
@@ -23,6 +23,6 @@
 //    MARS main program  
 //
-//    The only job of the main program is the initialisation of ROOT and 
-//    the start of the guiinterface for the mars program
+//    The only job of the main program is the initialization of ROOT and 
+//    the start of the GUI interface for the mars program
 //
 //    started by  h. kornmayer      january, 3rd  2001 
@@ -68,5 +68,5 @@
 
     //
-    // This is to make argv[i] more readable insidethe code
+    // This is to make argv[i] more readable inside the code
     //
     const TString kFilename = arg.GetArgumentStr(0);
@@ -78,5 +78,5 @@
 
     //
-    // initialise ROOT
+    // initialize ROOT
     //
     TApplication app("mars", &argc, argv);
@@ -88,5 +88,5 @@
 
     //
-    // Swtich of TObjectStreamer in our base classes derived from TObject
+    // Switch of TObject Streamer in our base classes derived from TObject
     //
     MArray::Class()->IgnoreTObjectStreamer();
Index: trunk/MagicSoft/Mars/mastro/MAstro.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstro.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/mastro/MAstro.cc	(revision 7179)
@@ -36,4 +36,5 @@
 
 #include "MTime.h"    // MTime::GetGmst
+#include "MString.h"
 
 #include "MAstroCatalog.h" // FIXME: replace by MVector3!
@@ -191,4 +192,26 @@
 {
     Day2Hm(h/24, sgn, deg, min);
+}
+
+TString MAstro::GetStringDeg(Double_t deg, const char *fmt)
+{
+    Char_t sgn;
+    UShort_t d, m, s;
+    Deg2Dms(deg, sgn, d, m, s);
+
+    MString str;
+    str.Print(fmt, sgn, d, m ,s);
+    return str;
+}
+
+TString MAstro::GetStringHor(Double_t deg, const char *fmt)
+{
+    Char_t sgn;
+    UShort_t h, m, s;
+    Hor2Hms(deg, sgn, h, m, s);
+
+    MString str;
+    str.Print(fmt, sgn, h, m ,s);
+    return str;
 }
 
Index: trunk/MagicSoft/Mars/mastro/MAstro.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstro.h	(revision 7178)
+++ trunk/MagicSoft/Mars/mastro/MAstro.h	(revision 7179)
@@ -45,4 +45,8 @@
     static void Hor2Hm(Double_t rad, Char_t &sgn, UShort_t &hor, Double_t &min);
 
+    // Print funtions
+    static TString GetStringDeg(Double_t deg, const char *fmt="%c%d:%02d:%02d");
+    static TString GetStringHor(Double_t deg, const char *fmt="%c%d:%02d:%02d");
+
     // Angle treatment functions
     static Bool_t  String2Angle(TString &str, Double_t &ret);
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 7179)
@@ -733,6 +733,8 @@
     const Double_t mag = -2.5*log10(v.Mag());
 
-    MString str;
-    str.Print("%s:  Ra=%.2fh  Dec=%.1fd  Mag=%.1f", v.GetName(), ra, dec, mag);
+    TString str(v.GetName());
+    if (!str.IsNull())
+        str += ":  ";
+    str += MString::Form("Ra=%.2fh  Dec=%.1fd  Mag=%.1f", ra, dec, mag);
     if (txt)
     {
Index: trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 7179)
@@ -229,7 +229,6 @@
     // point to a random memory segment, because the TString has gone.
     //
-    MString desc;
-    desc.Print("%s [%s]", o.GetName(), o.ClassName());
-    return (TString)o.GetName()==o.ClassName() ? o.ClassName() : desc;
+    return (TString)o.GetName()==o.ClassName() ? (TString)o.ClassName() :
+        MString::Form("%s [%s]", o.GetName(), o.ClassName());
 }
 
Index: trunk/MagicSoft/Mars/mbase/MString.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MString.h	(revision 7178)
+++ trunk/MagicSoft/Mars/mbase/MString.h	(revision 7179)
@@ -12,4 +12,7 @@
 {
 public:
+    MString(const char *txt=0)  : TString(txt) { }
+    MString(const TString &txt) : TString(txt) { }
+
     MString &Print(const char *fmt, va_list &ap);
     MString &Print(const char *fmt, ...);
Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 7179)
@@ -356,9 +356,9 @@
     //
     if (fName==ClassName())
-        return fSerialNumber==0 ? ClassName() : MString::Form("%s;%d", ClassName(), fSerialNumber);
+        return fSerialNumber==0 ? (TString)ClassName() : MString::Form("%s;%d", ClassName(), fSerialNumber);
 
     return fSerialNumber>0 ?
         MString::Form("%s;%d [%s]", fName.Data(), fSerialNumber, ClassName()) :
-        MString::Form("%s [%s]", fName.Data(), ClassName());
+        MString::Form("%s [%s]",    fName.Data(), ClassName());
 }
 
Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 7179)
@@ -39,5 +39,5 @@
 // In both cases, the possibility to have a camera with pixels of
 // different area is taken into account.
-// The too noisy pixels can be recognized and eventally switched off
+// The too noisy pixels can be recognized and eventually switched off
 // (Unmap: set blind pixels to UNUSED) separately, using the
 // MBlindPixelCalc Class. In the MBlindPixelCalc class there is also the
@@ -170,5 +170,5 @@
 // ===================
 // You use this cleaning method when you want to compare the number of
-// photo-electons of each pixel with the average pedestal RMS of the
+// photo-electrons of each pixel with the average pedestal RMS of the
 // inner pixels (for the MAGIC camera they are the smaller ones):
 //Begin_Html
@@ -259,5 +259,5 @@
 // informations of the boundary part of the shower only on the first
 // neighbors of the CORE pixels.
-// There is the possibility now to look not only at the firs neighbors
+// There is the possibility now to look not only at the first neighbors
 // (first ring),but also further away, around the CORE pixels. All the new
 // pixels you can find with this method, are tested with the second level
@@ -511,5 +511,5 @@
 //  Look for the boundary pixels around the core pixels
 //  if a pixel has more than 2.5 (clean level 2.5) sigma, and
-//  a core neigbor, it is declared as used.
+//  a core neighbor, it is declared as used.
 //
 void MImgCleanStd::CleanStep3()
@@ -744,5 +744,5 @@
 // --------------------------------------------------------------------------
 //
-//  Process the GUI Events comming from the two text entry fields.
+//  Process the GUI Events coming from the two text entry fields.
 //
 Bool_t MImgCleanStd::ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2)
Index: trunk/MagicSoft/Mars/mjobs/MDataSet.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 7179)
@@ -49,5 +49,6 @@
 //
 // The sequence number are used to concatenate the filenames of the
-// sequences using the file structure used in the datacenter.
+// sequences using the file structure used in the datacenter. Each sequence
+// can be added to the on and off data at the same time but only once.
 //
 // If you have different file names you can overwrite the default file names
@@ -60,4 +61,10 @@
 //
 // Resource file entries are case sensitive!
+//
+// IMPORTANT:
+//   * Run filenames must begin with a string which allows correct
+//     ordering in time, otherwise synchronization might fail.
+//   * Sequence filenames should also have names allowing to order them
+//     in time, but it is not necessary.
 //
 // MISSING (27/01/04): The default name and paths cannot be used yet, because
@@ -90,5 +97,7 @@
 // --------------------------------------------------------------------------
 //
-// Copy the run numbers from the TString runs into the TArrayI data
+// Copy the sequence numbers from the TString runs into the TArrayI data
+// Sequences which are twice in the list are only added once. In this case
+// a warning is emitted.
 //
 void MDataSet::Split(TString &runs, TArrayI &data) const
@@ -103,12 +112,35 @@
         TString num = runs(regexp);
 
-        const Int_t n = data.GetSize();
+        const Int_t seq = atoi(num.Data());
+        const Int_t n   = data.GetSize();
+
+        // skip already existing entries
+        int i;
+        for (i=0; i<n; i++)
+            if (data[i] == seq)
+                break;
+
+        if (i<n)
+        {
+            *fLog << warn << "WARNING - Sequence #" << seq << " alraedy in list... skipped." << endl;
+            continue;
+        }
+
+        // set new entry
         data.Set(n+1);
-        data[n] = atoi(num.Data());
-
+        data[n] = seq;
+
+        // remove entry from string
         runs.Remove(0, runs.First(num)+num.Length());
     }
 }
 
+// --------------------------------------------------------------------------
+//
+// After resolving the sequence filename and directory either from the
+// default (/magic/data/sequences/0004/sequence00004000.txt) or from
+// the corresponding entries in the dataset file.
+// The entries are sorted by filename.
+//
 void MDataSet::ResolveSequences(TEnv &env, const TArrayI &num, TList &list) const
 {
@@ -235,4 +267,9 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Adds all sequences contained in list to the MDirIter. After adding
+// everything MDirIter::Sort is called to sort all entries by name.
+//
 Bool_t MDataSet::AddSequencesFromList(const TList &list, MDirIter &files)
 {
@@ -251,4 +288,10 @@
         seq.SetupDatRuns(files, MSequence::kImages, dir.IsNull() ? 0 : dir.Data());
     }
+
+    // This is important in case of synchronisation, because the
+    // files in the sequences can be interleaved (eg W1, W2)
+    // Filenames MUST begin with an appropriate string which allow
+    // to order them correctly in time!
+    files.Sort();
 
     if (gLog.GetDebugLevel()>4)
Index: trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 7179)
@@ -31,4 +31,5 @@
 //
 //  A sequence is a collection of runs which should be used together.
+//  Any run can be contained only once.
 //
 //  Here is an example how a file describing a sequence could look like:
@@ -152,5 +153,7 @@
 // --------------------------------------------------------------------------
 //
-// Copy the run numbers from the TString runs into the TArrayI data
+// Copy the run numbers from the TString runs into the TArrayI data.
+// Runs which are twice in the list are only added once. In this case
+// a warning is emitted.
 //
 void MSequence::Split(TString &runs, TArrayI &data) const
@@ -165,47 +168,27 @@
         TString num = runs(regexp);
 
-        const Int_t n = data.GetSize();
+        const Int_t run = atoi(num.Data());
+        const Int_t n   = data.GetSize();
+
+        // skip already existing entries
+        int i;
+        for (i=0; i<n; i++)
+            if (data[i] == run)
+                break;
+
+        if (i<n)
+        {
+            *fLog << warn << "WARNING - Run #" << run << " alraedy in list... skipped." << endl;
+            continue;
+        }
+
+        // set new entry
         data.Set(n+1);
-        data[n] = atoi(num.Data());
+        data[n] = run;
 
         runs.Remove(0, runs.First(num)+num.Length());
     }
 }
-/*
-UInt_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, char *id, Bool_t raw) const
-{
-    TString d(path);
-
-    // Setup path
-    if (d.IsNull())
-    {
-        d = GetStandardPath();
-        d += raw ? "rawfiles/" : "merpp/";
-        d += fNight.GetStringFmt("%Y/%m/%d");
-    }
-    else
-        gSystem->ExpandPathName(d);
-
-    for (int i=0; i<arr.GetSize(); i++)
-    {
-        // R. DeLosReyes and T. Bretz
-        // Changes to read the DAQ numbering format. Changes takes place
-        // between runs 35487 and 00035488 (2004_08_30)
-        const char *fmt = arr[i]>35487 ? "%08d_%s_*_E" : "%05d_%s_*_E";
-
-        TString n;
-
-        // Create file name
-        n =  fNight.GetStringFmt("%Y%m%d_");
-        n += Form(fmt, arr[i], id);
-        n += raw ? ".raw" : ".root";
-
-        // Add Path/File to TIter
-        iter.AddDirectory(d, n, 0);
-    }
-
-    return iter.GetNumEntries();
-}
-*/
+
 UInt_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, FileType_t type, const char *path) const
 {
Index: trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc	(revision 7179)
@@ -19,5 +19,5 @@
 !   Author(s): Abelardo Moralejo 1/2005 <mailto:moralejo@pd.infn.it>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2005
 !
 !
@@ -28,18 +28,19 @@
 // MSrcPosCalc
 //
-// Calculate the current source position in the camera from the (possibly already
-// corrected, by starguider) J2000 sky coordinates of the camera center (contained
-// in MPointingPos), and the source J2000 sky coordinates contained in MSourcePos
-// (of type MPointingPos as well). If no MSourcePos is found in the parameter list, 
-// source position is assumed to be the same for all events, that specified in 
-// MSrcPosCam (if it already existed in the parameter list), or (0,0), the center 
-// of the camera, if no MSrcPosCam was present in the parameter list. In both cases,
-// no calculation is necessary and then the PreProcess returns kSKIP so that the task
-// is removed from the task list.
-//
-// The conversion factor between the camera plain (mm) and the
-// sky (deg) is taken from MGeomCam. The time is taken from MTime, and the coordinates
-// of the observatory from MObservatory.
-//
+// Calculate the current source position in the camera from the (possibly
+// already corrected, by starguider) J2000 sky coordinates of the camera
+// center (contained in MPointingPos), and the source J2000 sky
+// coordinates contained in MSourcePos (of type MPointingPos as well). If
+// no MSourcePos is found in the parameter list,  source position is
+// assumed to be the same for all events, that specified in  MSrcPosCam
+// (if it already existed in the parameter list), or (0,0), the center  of
+// the camera, if no MSrcPosCam was present in the parameter list. In both
+// cases, no calculation is necessary and then the PreProcess returns
+// kSKIP so that the task is removed from the task list.
+// 
+// The conversion factor between the camera plain (mm) and the sky (deg)
+// is taken from MGeomCam. The time is taken from MTime, and the
+// coordinates of the observatory from MObservatory.
+// 
 // Input Container:
 //   MPointingPos
@@ -53,6 +54,4 @@
 //
 // To be done:
-//   - wobble mode missing   /// NOTE, A. Moralejo: I see no need for special code
-//
 //   - a switch between using sky-coordinates and time or local-coordinates
 //     from MPointingPos for determine the rotation angle
@@ -98,4 +97,7 @@
     fName  = name  ? name  : "MSrcPosCalc";
     fTitle = title ? title : "Calculates the source position in the camera";
+
+    AddToBranchList("MTime.*");
+    AddToBranchList("MPointingPos.*");
 }
 
@@ -191,4 +193,9 @@
     //*fLog << "Pointing Position: " << GetRaDec(*fPointPos)  << endl;
     *fLog << "Source Position: " << GetRaDec(*fSourcePos) << endl;
+
+    // For the case ReInit is never called we try:
+    fObservatory = (MObservatory*)pList->FindObject("MObservatory");
+    fTime        = (MTime*)       pList->FindObject("MTime");
+    fRunType     = MRawRunHeader::kRTNone;
 
     return kTRUE;
@@ -321,59 +328,40 @@
 Int_t MSrcPosCalc::Process()
 {
-    if (fRunType==MRawRunHeader::kRTMonteCarlo || !fSourcePos)
+    if (fRunType==MRawRunHeader::kRTMonteCarlo || !fSourcePos || !fTime || !fObservatory)
         return kTRUE;
 
-  //     *fLog << dbg << "Camera center : Zd=" << fPointPos->GetZd() << " Az=" << fPointPos->GetAz() << endl;
-  //     *fLog << dbg << "Camera center : RA=" << fPointPos->GetRa() << " Dec=" << fPointPos->GetDec() << endl;
-  //     *fLog << dbg << "MJD: " << fTime->GetMjd() << ", time [ms]: " << fTime->GetTime() << endl;
-
-  MVector3 pos, pos0;  // pos: source position;  pos0: camera center
-
-  if (fSourcePos)
-    {
-      // Set Sky coordinates of source, taken from container "MSourcePos" of type MPointingPos. The sky 
-      // coordinates must be J2000, as the sky coordinates of the camera center that we get from the container 
-      // "MPointingPos" filled by the Drive.
-
-      pos.SetRaDec(fSourcePos->GetRaRad(), fSourcePos->GetDecRad());
-
-      // 	*fLog << dbg << "Sky position of source: Ra=" << fSourcePos->GetRa() << 
-      // 	  " Dec=" << fSourcePos->GetDec() << endl;
-    }
-
-  // Convert sky coordinates of source to local coordinates. Warning! These are not the "true" local 
-  // coordinates, since this transformation ignores precession and nutation effects.
-  const MAstroSky2Local conv(*fTime, *fObservatory);
-  pos *= conv;
-
-
-  // Set sky coordinates of camera center in pos0, and then convert to local. Same comment as above. These 
-  // coordinates differ from the true local coordinates of the camera center that one could get from 
-  // "MPointingPos", calculated by the Drive: the reason is that the Drive takes into account precession 
-  // and nutation corrections, while MAstroSky2Local (as of Jan 27 2005 at least) does not. Since we just 
-  // want to get the source position on the camera from the local coordinates of the center and the source,
-  // it does not matter that the coordinates contained in pos and pos0 ignore precession and nutation... 
-  // since the shift would be the same in both cases. What would be wrong is to set in pos0 directly the 
-  // local coordinates found in MPointingPos!
-
-  pos0.SetRaDec(fPointPos->GetRaRad(), fPointPos->GetDecRad());
-  pos0 *= conv;
-
-  //     *fLog << dbg << "From MAstroSky2Local, without precession and nutation corrections:" << endl;
-  //     *fLog << dbg << "- Camera center (2) from RA,dec and time : Zd=" << pos0.Theta()*180./TMath::Pi() 
-  //  	  << " Az=" << pos0.Phi()*180./TMath::Pi() << endl;
-  //     *fLog << dbg << "- Local position of source: Zd=" << pos.Theta()*TMath::RadToDeg() << " Az=" << pos.Phi()*TMath::RadToDeg() << endl;
-
-
-  // Calculate source position in camera, and convert to mm:
-  TVector2 v = CalcXYinCamera(pos0, pos)*fGeom->GetCameraDist()*1000;
-  SetSrcPos(v);
-
-  //     v *= fGeom->GetConvMm2Deg();
-  //     *fLog << dbg << "X=" << v.X() << " deg,  Y=" << v.Y() << " deg" << endl;
-  //     *fLog << *fTime << endl;
-  //     *fLog << endl;
-
-  return kTRUE;
+    // Set Sky coordinates of source, taken from container "MSourcePos"
+    // of type MPointingPos. The sky coordinates must be J2000, as the
+    // sky coordinates of the camera center that we get from the container
+    // "MPointingPos" filled by the Drive.
+    MVector3 pos;  // pos: source position
+    pos.SetRaDec(fSourcePos->GetRaRad(), fSourcePos->GetDecRad());
+
+    // Convert sky coordinates of source to local coordinates. Warning! These are not the "true" local
+    // coordinates, since this transformation ignores precession and nutation effects.
+    const MAstroSky2Local conv(*fTime, *fObservatory);
+    pos *= conv;
+
+    // Set sky coordinates of camera center in pos0, and then convert to
+    // local. Same comment as above. These coordinates differ from the true
+    // local coordinates of the camera center that one could get from
+    // "MPointingPos", calculated by the Drive: the reason is that the Drive
+    // takes into account precession and nutation corrections, while
+    // MAstroSky2Local (as of Jan 27 2005 at least) does not. Since we just
+    // want to get the source position on the camera from the local
+    // coordinates of the center and the source, it does not matter that
+    // the coordinates contained in pos and pos0 ignore precession and
+    // nutation... since the shift would be the same in both cases. What
+    // would be wrong is to set in pos0 directly the local coordinates
+    // found in MPointingPos!
+    MVector3 pos0;  // pos0: camera center
+    pos0.SetRaDec(fPointPos->GetRaRad(), fPointPos->GetDecRad());
+    pos0 *= conv;
+
+    // Calculate source position in camera, and convert to mm:
+    TVector2 v = CalcXYinCamera(pos0, pos)*fGeom->GetCameraDist()*1000;
+    SetSrcPos(v);
+
+    return kTRUE;
 }
 
Index: trunk/MagicSoft/Mars/showlog.cc
===================================================================
--- trunk/MagicSoft/Mars/showlog.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/showlog.cc	(revision 7179)
@@ -22,8 +22,8 @@
     gLog << "   -?, -h, --help            This help" << endl;
     gLog << endl;
-    gLog << " This program converts colored output  made with ansi codes" << endl;
+    gLog << " This program converts colored output  made with ANSI codes" << endl;
     gLog << " (like it is done by MLog)  and redirected into a file back" << endl;
     gLog << " into colored output." << endl << endl;
-    gLog << " It cannot be used to get rid of the Ansi codes. To display" << endl;
+    gLog << " It cannot be used to get rid of the ANSI codes. To display" << endl;
     gLog << " colored output with less use the option -R, eg." << endl;
     gLog << "   less -R logfile.log" << endl << endl;
@@ -45,5 +45,5 @@
 }
 
-// FIXME: Enhance this tool with a converter to HTMl, etc.
+// FIXME: Enhance this tool with a converter to HTML, etc.
 //        Add option for 'no-colors'
 int main(int argc, char **argv)
@@ -66,5 +66,5 @@
     if (arg.GetNumOptions()>0)
     {
-        gLog << warn << "WARNING - Unknown commandline options..." << endl;
+        gLog << warn << "WARNING - Unknown command line options..." << endl;
         arg.Print("options");
         gLog << endl;
Index: trunk/MagicSoft/Mars/showplot.cc
===================================================================
--- trunk/MagicSoft/Mars/showplot.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/showplot.cc	(revision 7179)
@@ -130,5 +130,5 @@
     if (arg.GetNumOptions()>0)
     {
-        gLog << err << "Unknown commandline options..." << endl;
+        gLog << err << "Unknown command line options..." << endl;
         arg.Print("options");
         gLog << endl;
Index: trunk/MagicSoft/Mars/sponde.cc
===================================================================
--- trunk/MagicSoft/Mars/sponde.cc	(revision 7178)
+++ trunk/MagicSoft/Mars/sponde.cc	(revision 7179)
@@ -123,5 +123,5 @@
     if (arg.GetNumOptions()>0)
     {
-        gLog << warn << "WARNING - Unknown commandline options..." << endl;
+        gLog << warn << "WARNING - Unknown command line options..." << endl;
         arg.Print("options");
         gLog << endl;
@@ -139,5 +139,5 @@
 
     //
-    // Setup sequence file and check for its existance
+    // Setup sequence file and check for its existence
     //
     const TString kInfile  = arg.GetArgumentStr(0);
