Index: trunk/MagicSoft/Mars/macros/starfield.C
===================================================================
--- trunk/MagicSoft/Mars/macros/starfield.C	(revision 4356)
+++ trunk/MagicSoft/Mars/macros/starfield.C	(revision 4358)
@@ -1,2 +1,44 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Thomas Bretz 5/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// starfield.C
+// ===========
+//
+// This is a macro demonstrating how to use Mars to display a starfield.
+// It also is a tutorial for MAstroCatalog and MAstroCamera.
+//
+// For more details on this classes see the class-reference.
+//
+// If you want to display stars in a camera you need the camera geometry
+// and the mirror definition. You can get this either from a Monte Carlo
+// file containing both or create your MGeomCam object manually and
+// read a magic.def file which you will find in the camera simulation
+// program.
+//
+///////////////////////////////////////////////////////////////////////////
+
 void ReadSetup(TString fname, MAstroCamera &cam)
 {
@@ -13,4 +55,11 @@
     cam.SetMirrors(*config->GetMirrors());
     cam.SetGeom(*geom);
+
+    /* Alternative:
+
+     MGeomCamMagic geom;
+     cam.SetGeom(geom);
+     cam.SetMirrors("magic.def");
+     */
 }
 
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 4356)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 4358)
@@ -30,4 +30,15 @@
 //  THIS IMPLEMENTATION IS PRELIMINARY AND WILL BE MERGED WITH
 //  SOME PARTS OF THE DRIVE SOFTWARE SOON!
+//
+//
+//  Catalogs:
+//  ---------
+//
+//  To be able to use this class you need a catalog file suppored by
+//  MAstroCatalog.
+//  Catalog files can be found at
+//  http://magic.astro.uni-wuerzburg.de/mars/catalogs.html
+//  You must copy the file into the directory from which you start your macro
+//  or give an abolute path loading the catalog.
 //
 //
@@ -106,4 +117,6 @@
 //   - a derived class is missing which supports all astrometrical
 //     correction (base on slalib and useable in Cosy)
+//   - Implement a general loader for heasarc catlogs, see
+//     http://heasarc.gsfc.nasa.gov/W3Browse/star-catalog/
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -517,4 +530,7 @@
 // to a file outname. This files will contain an apropriate compressed
 // file format. You can read such files again using ReadCompressed.
+//
+// FIXME: A General loader for heasarc catlogs is missing, see
+//        http://heasarc.gsfc.nasa.gov/W3Browse/star-catalog/
 //
 Int_t MAstroCatalog::ReadHeasarcPPM(TString catalog, TString outname)
Index: trunk/MagicSoft/Mars/mbase/MTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTime.cc	(revision 4356)
+++ trunk/MagicSoft/Mars/mbase/MTime.cc	(revision 4358)
@@ -77,4 +77,6 @@
 
 #include "MLog.h"
+#include "MLogManip.h"
+
 #include "MAstro.h"
 
@@ -504,5 +506,5 @@
     GetTime(h, m, s, ms);
 
-    *fLog << GetDescriptor() << ": ";
+    *fLog << all << GetDescriptor() << ": ";
     *fLog << GetString() << Form(" (+%dns)", fNanoSec) << endl;
 } 
Index: trunk/MagicSoft/Mars/mfit/MTFitLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mfit/MTFitLoop.cc	(revision 4356)
+++ trunk/MagicSoft/Mars/mfit/MTFitLoop.cc	(revision 4358)
@@ -47,13 +47,22 @@
 #include "MTFitLoop.h"
 
+#include <TArrayD.h>
 #include <TMinuit.h>
 #include <TStopwatch.h>
 
 #include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MParameters.h"
+
 #include "MRead.h"
-#include "MEvtLoop.h"
 
 #include "MLog.h"
 #include "MLogManip.h"
+
+ClassImp(MTFitLoop);
+
+using namespace std;
 
 //------------------------------------------------------------------------
@@ -74,6 +83,6 @@
     MParList *plist = fEvtLoop->GetParList();
 
-    MParameterD   *eval = (MParameterD*)plist->FindCreateObj("MParameterD", fFitParameter);
-    MParContainer *pars = plist->FindObject(fParametersName);
+    MParameterD   *eval = (MParameterD*)  plist->FindCreateObj("MParameterD", fFitParameter);
+    MParContainer *pars = (MParContainer*)plist->FindObject(fParametersName);
 
     MRead *read = (MRead*)plist->FindObject("MTaskList")->FindObject("MRead");
@@ -104,6 +113,6 @@
     if (fDebug>=0)
     {
-        *fLog << inf << "Set: ";
-        for (Int_t i=0; i<7; i++)
+        *fLog << inf << "Set(" << gMinuit->fMaxpar << "): ";
+        for (Int_t i=0; i<gMinuit->fMaxpar; i++)
             *fLog << par[i] << " ";
         *fLog << endl;
@@ -129,5 +138,5 @@
 }
 
-MTFitLoop::MTFitLoop()
+MTFitLoop::MTFitLoop(Int_t num) : fNum(num), fMaxIterations(1000)
 {
     fDebug     = -1;
@@ -135,23 +144,24 @@
 }
 
-void MTFitLoop::Optimize(MEvtLoop &loop)
+void MTFitLoop::Optimize(MEvtLoop &loop, TArrayD &pars)
 {
     *fLog << inf << "Event loop was setup" << endl;
-    MParList *parlist = loop->GetParList();
+    MParList *parlist = loop.GetParList();
     if (!parlist)
         return;
 
-    MParContainer *pars = plist->FindObject(fParametersName);
-    if (!pars)
-        return;
-
-    fEvtLoop = evtloop;
-
-    MParContainer &parameters = *pars;
+//    MParContainer *pars = (MParContainer*)parlist->FindObject(fParametersName);
+//    if (!pars)
+//        return;
+
+    fEvtLoop = &loop;
+
+//    MParContainer &parameters = *pars;
 
     TMinuit *minsave = gMinuit;
 
-    gMinuit = new TMinuit(parameters.GetSize());
+    gMinuit = new TMinuit(pars.GetSize());
     gMinuit->SetPrintLevel(-1);
+    gMinuit->SetMaxIterations(fMaxIterations);
 
     gMinuit->SetFCN(fcn);
@@ -164,5 +174,5 @@
      // less than 0.001*[tolerance]*UP (see [SET ERRordef]).");
      //
-    if (gMinuit->SetErrorDef(1000))
+    if (gMinuit->SetErrorDef(1))
     {
         *fLog << err << dbginf << "SetErrorDef failed." << endl;
@@ -173,11 +183,11 @@
     // Set starting values and step sizes for parameters
     //
-    for (Int_t i=0; i<parameters.GetSize(); i++)
+    for (Int_t i=0; i<pars.GetSize(); i++)
     {
         TString name = "par[";
         name += i;
         name += "]";
-        Double_t vinit = parameters[i];
-        Double_t step  = fabs(parameters[i]/3);
+        Double_t vinit = pars[i];
+        Double_t step  = fabs(pars[i]/3);
 
         Double_t limlo = 0; // limlo=limup=0: no limits
@@ -192,9 +202,7 @@
     }
 
-    for (int i=0; i<parameters.GetSize(); i++)
-        if (i<fFixParams.GetSize() && fFixParams[i]!=0)
+    for (int i=0; i<pars.GetSize() && i<fFixedParams.GetSize(); i++)
+        if (fFixedParams[i]!=0)
             gMinuit->FixParameter(i);
-        else
-            gMinuit->Release(i);
 
     // Now ready for minimization step:
@@ -217,13 +225,13 @@
     // Update values of fA, fB:
     //
-    for (Int_t i=0; i<parameters.GetSize(); i++)
+    for (Int_t i=0; i<pars.GetSize(); i++)
     {
         Double_t x1, x2;
         gMinuit->GetParameter(i,x1,x2);
-        parameters[i] = x1;
-        cout << i << ": " << parameters[i] << endl;
-    }
-
-    list.SetVariables(parameters);
+        pars[i] = x1;
+        cout << i << ": " << pars[i] << endl;
+    }
+
+    //list.SetVariables(pars);
 
     gMinuit = minsave;
Index: trunk/MagicSoft/Mars/mfit/MTFitLoop.h
===================================================================
--- trunk/MagicSoft/Mars/mfit/MTFitLoop.h	(revision 4356)
+++ trunk/MagicSoft/Mars/mfit/MTFitLoop.h	(revision 4358)
@@ -28,8 +28,11 @@
     TArrayC   fFixedParams;
 
+    Int_t fNum;
+    Int_t fMaxIterations;
+
 public:
-    MTFitLoop();
+    MTFitLoop(const Int_t num=0);
 
-    void Optimize(MEvtLoop &loop);
+    void Optimize(MEvtLoop &loop, TArrayD &pars);
 
     void SetNameParameters(const char *parm) { fParametersName = parm; }
@@ -37,4 +40,5 @@
 
     void SetFixedParameters(const TArrayC &c) { fFixedParams = c; }
+    void SetMaxIterations(Int_t maxiter=500) {fMaxIterations = maxiter;} // for debugging
 
     void SetDebug(Int_t n)     { fDebug = n; }
Index: trunk/MagicSoft/Mars/mhist/MHFalseSource.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFalseSource.cc	(revision 4356)
+++ trunk/MagicSoft/Mars/mhist/MHFalseSource.cc	(revision 4358)
@@ -233,8 +233,4 @@
 {
     return MMath::SignificanceLiMaSigned(s, b);
-    /*
-     const Double_t lima = MMath::SignificanceLiMa(s, b);
-     return lima<0 ? 0 : lima;
-     */
 }
 
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 4356)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 4358)
@@ -525,8 +525,7 @@
 // --------------------------------------------------------------------------
 //
-// Make sure, that you skip the whole event. This function only skips a part
-// of the event - see MRawRead::SkipEvent
-//
-void MRawEvtData::SkipEvt(istream &fin)
+// Return the size in bytes of one event data block
+//
+Int_t MRawEvtData::GetNumBytes() const
 {
     const UShort_t nlo  = fRunHeader->GetNumSamplesLoGain();
@@ -534,5 +533,15 @@
     const UShort_t npic = fRunHeader->GetNumPixInCrate();
 
-    fin.seekg((nhi+nlo)*npic, ios::cur);
+    return (nhi+nlo)*npic;
+}
+
+// --------------------------------------------------------------------------
+//
+// Make sure, that you skip the whole event. This function only skips a part
+// of the event - see MRawRead::SkipEvent
+//
+void MRawEvtData::SkipEvt(istream &fin)
+{
+    fin.seekg(GetNumBytes(), ios::cur);
 }
 
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 4356)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 4358)
@@ -43,4 +43,6 @@
     void InitArrays(Bool_t flag=kFALSE);
     void DeleteArrays();
+
+    Int_t GetNumBytes() const;
 
 public:
