Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3956)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3957)
@@ -19,4 +19,35 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2004/05/04: Thomas Bretz
+ 
+   * macros/MagicHillas.C, macros/comprob.C, macros/derotatedc.C, 
+     macros/dohtml.C, macros/evtrate.C, macros/merpp.C, 
+     macros/pixfirerate.C, macros/pixsatrate.C, macros/plot.C, 
+     macros/plot2.C, macros/pointing.C, macros/readMagic.C, 
+     macros/rootlogon.C, macros/runbook.C, macros/sectorvstime.C, 
+     macros/star.C, macros/sumcurrents.C, macros/tar.C, 
+     macros/testenv.C, macros/weights.C:
+     - updated documentation
+
+   * mastro/MAstroCamera.[h,cc]:
+     - added member function to read MC .def files for mirror geometry
+     - added GetDiffZdAz
+
+   * mastro/MObservatory.[h,cc]:
+     - added Copy-member function
+
+   * mbase/MLog.[h,cc]:
+     - updated handling of mutices
+     - added a new mutex to lock the stream
+
+   * mhist/MHCamera.[h,cc]:
+     - added functionality to linear deform the camera display
+       (to correct for abberation)
+
+   * mtools/MFFT.cc:
+     - added more documentation
+
+
+
  2004/05/04: Markus Gaug
  
@@ -24,4 +55,5 @@
      - intialized the 2 vectors differently, now they don't give 
        warnings any more.
+
 
 
Index: /trunk/MagicSoft/Mars/macros/MagicHillas.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/MagicHillas.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/MagicHillas.C	(revision 3957)
@@ -16,19 +16,27 @@
 !
 !
-!   Author(s): Thomas Bretz et al,  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
 \* ======================================================================== */
 
+///////////////////////////////////////////////////////////////////////////
+//
+// MagicHillas.C
+// =============
+//
+// This is a demonstration program which calculates image (Hillas +)
+// parameters using as input a Merpp output file (raw data).
+// All parameters are written to an output file called hillas.root. Also
+// filles histograms are displayed.
+// For the calculation an arbitrary signal extractor (MCerPhotAnal2/Calc)
+// is used.
+//
+///////////////////////////////////////////////////////////////////////////
 
 void MagicHillas(const char *filename="~/data/Gamma_20_N*.root")
 {
-    //
-    // This is a demonstration program which calculates the Hillas
-    // parameter out of a Magic root file (raw data file).
-    //
-
     //
     // Create a empty Parameter List and an empty Task List
@@ -80,9 +88,15 @@
     read.DisableAutoScheme();
 
+    // Setup a task which makes sure that all used arrays have
+    // the correct size
     MGeomApply geomapl;
 
+    // tasks used if MC files are detected to calculate pedestals
     MMcPedestalCopy pcopy;
     MMcPedestalNSBAdd pnsb;
 
+    // calculate the signal in a very simple way
+    // for real adat files use MCerPhotAnal2 instead which also
+    // calculates the pedestal.
     MCerPhotCalc ncalc;
     //
@@ -95,15 +109,21 @@
     //
 
+    // setup image cleaning and blind pixel treatment
     MImgCleanStd    clean;
     MBlindPixelCalc blind;
+
     //
-    // Instead of unmapping the pixels you can also
+    // Instead of unmapping the pixels you can also (The use of this
+    // class is deprecated, it will be replaced by MBadPixels*)
     //
     // blind.SetUseInterpolation();
     // blind.SetUseCetralPixel();
     //
+
+    // setup tasks to calculate image parameters
     MHillasCalc    hcalc;
     MHillasSrcCalc csrc1;
 
+    // setup tasks to fill histograms
     MFillH hfill1("MHHillas", "MHillas");
     MFillH hfill2("MHHillasExt");
@@ -113,4 +133,5 @@
     MFillH hfill6("MHNewImagePar");
 
+    // setup task to write containers to a file
     MWriteRootFile write("hillas.root");
     write.AddContainer("MHStarMap");
@@ -121,4 +142,5 @@
     write.AddContainer("MHNewImagePar");
 
+    // Setup the contents of zour tasklist
     tlist.AddToList(&read);
     tlist.AddToList(&geomapl);
Index: /trunk/MagicSoft/Mars/macros/comprob.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/comprob.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/comprob.C	(revision 3957)
@@ -1,29 +1,29 @@
 /* ======================================================================== *\
- !
- ! *
- ! * 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.
- ! *
- !
- !   macro comprob.C
- !
- !   Author(s): Abelardo Moralejo
- !   Author(s): Thomas Bretz, 2002 <mailto:tbretz@astro.uni-wuerzburg.de>
- !
- !   Copyright: MAGIC Software Development, 2000-2002
- !
- !
- \* ======================================================================== */
+!
+! *
+! * 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.
+! *
+!
+!   macro comprob.C
+!
+!   Author(s): Abelardo Moralejo
+!   Author(s): Thomas Bretz, 2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
 
-// -------------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////
 //
 //  This macro demonstrates one way of gamma hadron separation using the
@@ -31,4 +31,5 @@
 //  a file ouput by the star.C macro containing image parameters)
 //
+///////////////////////////////////////////////////////////////////////////
 void comprob()
 {
Index: /trunk/MagicSoft/Mars/macros/derotatedc.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/derotatedc.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/derotatedc.C	(revision 3957)
@@ -25,8 +25,18 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-//  derotate.C - STandard Analysis and Reconstruction (MC example)
+// derotatedc.C
+// ============
 //
-//  Derotate a MCamEvent and fill a histogram with derotated data
-//  (sky-plot)
+// Derotate a MCamEvent and fill a histogram with derotated data
+// (sky-plot).
+//
+// As an input you need a merpped root file conataining DC information
+// from a camera report file. To be able to derotate you also need
+// aproproitate time-stamps and the corresponding pointing information.
+//
+// All events are filled into a 2D histograms - derotated.
+//
+// The example shows the usage of MHCamEventRot. The output is the derotated
+// sky-plot.
 //
 /////////////////////////////////////////////////////////////////////////////
Index: /trunk/MagicSoft/Mars/macros/dohtml.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/dohtml.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/dohtml.C	(revision 3957)
@@ -22,4 +22,18 @@
 !
 \* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// dohtml.C
+// ========
+//
+// This is a service macro used to create the html-documentation from
+// source code (THtml)
+//
+// Add here all directories in which files are stored from which the
+// documentation should be created an add all macros which should be
+// converted to HTML.
+//
+///////////////////////////////////////////////////////////////////////////
 
 void dohtml()
Index: /trunk/MagicSoft/Mars/macros/evtrate.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/evtrate.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/evtrate.C	(revision 3957)
@@ -1,28 +1,78 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// evtrate.C
+// =========
+//
+// Example macro how to calulate the eventrate (per event) and display
+// the result versus time.
+//
+// As an input you need a merpped raw-data file containing correct times.
+// The output is the plot: Eventrate vs. time.
+//
+///////////////////////////////////////////////////////////////////////////
+
 void evtrate()
 {
+    // Setup parameter- and tasklist
     MParList plist;
     MTaskList tlist;
     plist.AddToList(&tlist);
 
+    // Setup reading task
     MReadMarsFile read("Events");
     read.DisableAutoScheme();
     read.AddFile("test-time.root");
 
+    // Setup event rate calculator
     MEventRateCalc calc;
+    // Setup number of events to be averaged
     calc.SetNumEvents(200);
 
+    // Setup histogram to be filles with rate
     MHVsTime rate("MEventRate.fRate");
 
+    // Setup task to fill the histogram
     MFillH fill(&rate, "MTime");
 
+    // Setup tasklist
     tlist.AddToList(&read);
     tlist.AddToList(&calc);
     tlist.AddToList(&fill);
 
+    // Execute your eventloop
     MEvtLoop loop;
     loop.SetParList(&plist);
 
-    loop.Eventloop();
+    if (!loop.Eventloop())
+        return;
 
+    // print some execution statistics
+    tlist.PrintStatistics();
+
+    // Draw result
     rate.DrawClone();
 }
Index: /trunk/MagicSoft/Mars/macros/merpp.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/merpp.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/merpp.C	(revision 3957)
@@ -16,17 +16,19 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
 \* ======================================================================== */
 
-
 /////////////////////////////////////////////////////////////////////////////
+//
+// merpp.C
+// =======
 //
 // This is an easy implementation of the Merging process (as root Macro)
 //
-// at the moment it reads a binary file ("rawtest.bin") which was written
+// at the moment it reads a binary file ("rawtest.raw") which was written
 // in the DAQ raw format.
 //
@@ -35,4 +37,7 @@
 //
 // This containers are written to a root file ("rawtest.root")
+//
+// It also demonstrates how you can loop over files in a single or more
+// than one directory and process them. For details see MRunIter.
 //
 /////////////////////////////////////////////////////////////////////////////
Index: /trunk/MagicSoft/Mars/macros/pixfirerate.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/pixfirerate.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/pixfirerate.C	(revision 3957)
@@ -17,6 +17,7 @@
 !
 !   Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -26,4 +27,5 @@
 //
 // pixfirerate.C
+// =============
 //
 // This macro can help to  find "hot" pixels firing too often
@@ -73,4 +75,6 @@
     tlist.AddToList(&geomapl);
 
+    // A list of threshold which should be displayed. The last entry
+    // MUST be -1.
     Double_t threshold[] = { 10, 20, 100, 200, -1 };
 
@@ -78,4 +82,5 @@
     while (threshold[cnt]>0) cnt++;
 
+    // Create the corresponding fill tasks and containers
     for (int i=0; i<cnt; i++)
     {
@@ -95,4 +100,5 @@
     }
 
+    // create the eventloop
     MEvtLoop evtloop;
     evtloop.SetParList(&plist);
Index: /trunk/MagicSoft/Mars/macros/pixsatrate.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/pixsatrate.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/pixsatrate.C	(revision 3957)
@@ -17,6 +17,7 @@
 !
 !   Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -26,4 +27,5 @@
 //
 // pixfirerate.C
+// =============
 //
 // This macro can help to  find "hot" pixels firing too often
@@ -73,4 +75,5 @@
     tlist.AddToList(&geomapl);
 
+    // Create histograms with saturation limits at 254
     MHTriggerLvl0 trighi(254, "SaturationHi", "Saturation Rate of Hi Gains");
     MHTriggerLvl0 triglo(254, "SaturationLo", "Saturation Rate of Lo Gains");
@@ -78,4 +81,5 @@
     triglo.SetType(2);
 
+    // craete fill tasks to fill the histogarms
     MFillH fillhi(&trighi, "MRawEvtData");
     MFillH filllo(&triglo, "MRawEvtData");
@@ -83,4 +87,5 @@
     tlist.AddToList(&filllo);
 
+    // create eventloop
     MEvtLoop evtloop;
     evtloop.SetParList(&plist);
Index: /trunk/MagicSoft/Mars/macros/plot.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/plot.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/plot.C	(revision 3957)
@@ -19,17 +19,31 @@
 !   Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
 \* ======================================================================== */
 
-// -------------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////
 //
 //  plot.C
+//  ======
 //
 //  This macro shows how to fill and display a histogram using Mars
 //
+//  The advantage of using Mars histograms instead of root-trees is that
+//  you can fill values in your histogram which is calculated in the
+//  eventloop.
+//
+//  In this particular sample we fill a histogram with the size parameter
+//  of gammas and one with hadron's size. At the end we display both in a
+//  single plot.
+//
+//  The input is a star-macro already conatining image parameters.
+//
+///////////////////////////////////////////////////////////////////////////
+
 void plot()
 {
+    // Create a status display for graphical output
     MStatusDisplay *d = new MStatusDisplay;
     d->SetLogStream(&gLog);
@@ -57,9 +71,9 @@
 
     // Create a filter for Gammas
-    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
+    MFParticleId fgamma("MMcEvt", '=', MMcEvt::kGAMMA);
     tlist.AddToList(&fgamma);
 
     // Create a filter for Non-Gammas
-    MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
+    MFParticleId fhadrons("MMcEvt", '!', MMcEvt::kGAMMA);
     tlist.AddToList(&fhadrons);
 
Index: /trunk/MagicSoft/Mars/macros/plot2.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/plot2.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/plot2.C	(revision 3957)
@@ -19,15 +19,27 @@
 !   Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
 \* ======================================================================== */
 
-// -------------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////
 //
-//  plot.C
+//  plot2.C
+//  =======
 //
-//  This macro shows how to fill and display a 2D histogram using Mars
+//  This macro shows how to fill and display a histogram using Mars
 //
+//  The advantage of using Mars histograms instead of root-trees is that
+//  you can fill values in your histogram which is calculated in the
+//  eventloop.
+//
+//  In this particular sample we fill a histogram with width vs length
+//  of gammas and hadrons. At the end we display both in a single plot.
+//
+//  The input is a star-macro already conatining image parameters.
+//
+///////////////////////////////////////////////////////////////////////////
+
 void plot2()
 {
@@ -52,9 +64,9 @@
 
     // Create a filter for the gamma events
-    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
+    MFParticleId fgamma("MMcEvt", '=', MMcEvt::kGAMMA);
     tlist.AddToList(&fgamma);
 
     // Create a filter for the non-gamma events
-    MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
+    MFParticleId fhadrons("MMcEvt", '!', MMcEvt::kGAMMA);
     tlist.AddToList(&fhadrons);
 
@@ -66,7 +78,9 @@
     plist.AddToList(&cam);
 
+    // Set the variables (converted to deg)
     TString vary("MHillas.fWidth*MGeomCam.fConvMm2Deg");
     TString varx("MHillas.fLength*MGeomCam.fConvMm2Deg");
 
+    // Set the binning
     MBinning binsy("BinningMH3Y");
     MBinning binsx("BinningMH3X");
Index: /trunk/MagicSoft/Mars/macros/pointing.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/pointing.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/pointing.C	(revision 3957)
@@ -1,2 +1,42 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// pointing.C
+// ==========
+//
+// This macro is a demonstartion how check plots for a subsystem
+// (here the drive) can be made using Mars.
+//
+// In this case a merpped (root-) cc-report file is read in. The data
+// of the Drive branch is extracted using MReadReports and the
+// Stream-Id feature of MTaskList (second argument in AddToList).
+//
+// The output are plots showing (hopefully) the peformance of the system.
+//
+/////////////////////////////////////////////////////////////////////////////
+
 /*
  class MGraph : public TGraph
Index: /trunk/MagicSoft/Mars/macros/readMagic.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/readMagic.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/readMagic.C	(revision 3957)
@@ -16,14 +16,30 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
 \* ======================================================================== */
 
+///////////////////////////////////////////////////////////////////////////
+//
+// readMagic.C
+// ===========
+//
+// This is a demonstration program showing how to do particular processing
+// on a single event basis. Here we simply display uncleand und cleand
+// images.
+// Therefor MInteractiveTask is used, which gives you the possibility
+// to develop new tasks without the need of compilation.
+// The input is a merpp raw-data file.
+//
+///////////////////////////////////////////////////////////////////////////
 
 Bool_t HandleInput()
 {
+    // This must be there to get accesss to the GUI while the macro
+    // is still running!
+
     TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
     while (1)
@@ -46,4 +62,7 @@
 }
 
+//
+// Setup the data-members of your 'virtual' class
+//
 MHCamera display[4];
 
@@ -52,11 +71,18 @@
 MTaskList *fTaskList;
 
+//
+// Called like all PreProcess functions of tasks. Get the access to
+// the containers necessary for you.
+//
 Int_t PreProcess(MParList *plist)
 {
+    // Get parameter and tasklist, see Process
     fParList = plist;
     fTaskList = (MTaskList*)plist->FindObject("MTaskList");
 
+    // Get camera geoemtry
     MGeomCam *geomcam = (MGeomCam*)plist->FindObject("MGeomCam");
 
+    // setup canvas and camera-histograms
     c = new TCanvas("Events", "Real Events", 600, 600);
     c->SetBorderMode(0);
@@ -73,6 +99,13 @@
 }
 
+//
+// Called like all Process functions of tasks. Process a single
+// event - here display it.
+//
 Int_t Process()
 {
+    // For simplicity we search in the Process function for the
+    // objects. This is deprectaed! Store the pointers to the objects
+    // as data member and get the pointers in PreProcess.
     MReadMarsFile *read = (MReadMarsFile*)fTaskList->FindObject("MRead");
     MClone *clone = (MClone*)fTaskList->FindObject("MClone");
@@ -80,6 +113,8 @@
     MGeomCam *geom = (MGeomCam*)fParList->FindObject("MGeomCam");
 
+    // Ouput event number
     cout << "Event #" << read->GetNumEntry() << ":" << endl;
 
+    // Fill the data into your camera-histograms
     display[0].SetCamContent(*(MCerPhotEvt*)clone->GetClone());
     display[1].SetCamContent(*(MCerPhotEvt*)fParList->FindObject("MCerPhotEvt"));
@@ -87,4 +122,5 @@
     display[3].SetCamContent(*(MCameraData*)fParList->FindObject("MCameraData"));
 
+    // Setup the cleaning level histogram
     TArrayF lvl(2);
     lvl[0] = clean->GetCleanLvl2();
@@ -92,4 +128,5 @@
     display[3].SetLevels(lvl);
 
+    // Update the display
     for (int i=1; i<=4; i++)
     {
@@ -98,11 +135,17 @@
     }
 
+    // print the data on the console
     ((MHillas*)fParList->FindObject("MHillas"))->Print(*geom);
     ((MHillasExt*)fParList->FindObject("MHillasExt"))->Print(*geom);
     ((MNewImagePar*)fParList->FindObject("MNewImagePar"))->Print(*geom);
 
+    // wait for 'return'
     return HandleInput();
 }
 
+//
+// Called like all PostProcess functions of tasks. Delete
+// instanciated objects.
+//
 Int_t PostProcess()
 {
@@ -111,5 +154,6 @@
 
 void readMagic(const char *fname="../Proton*.root")
-{               
+{
+    // Setup parameter- and tasklist
     MParList  plist;
     MTaskList tlist;
@@ -117,21 +161,41 @@
     plist.AddToList(&tlist);
 
+    // setup reading task
     MReadMarsFile read("Events", fname);
     read.DisableAutoScheme();
 
+    // setup a task making sure that all arrays are resized correctly
     MGeomApply geomapl;
+
+    // Setup a print task calling TObject::Print
     MPrint print1("MMcEvt");
     MPrint print2("MRawEvtHeader");
+    // Skip them if conatainers are not found
     print1.EnableSkip();
     print2.EnableSkip();
 
+    // Copy MC pedestals to apropriate conatiners (if MC file)
     MMcPedestalCopy   pcopy;
     MMcPedestalNSBAdd pnsb;
+
+    // Calculate signal and pedestal from data (use MCerPhotCalc
+    // in case of MC files)
     MCerPhotAnal2     ncalc;
+
+    // Blind Pixel Treatment (deprecated, will be replaced by
+    // MBadPixel*)
     MBlindPixelCalc   blind;
     blind.SetUseInterpolation();
+
+    // Clone MCerPhotEvt befor eimage cleaning
     MClone            clone("MCerPhotEvt");
+
+    // Setup image cleaning
     MImgCleanStd      clean;
+
+    // Setup calculation of Image parameters
     MHillasCalc       hcalc;
+
+    // Setup intercative task calling the functions defined above
     MTaskInteractive  mytask;
 
@@ -139,4 +203,5 @@
     mytask.SetProcess(Process);
 
+    // Setup your tasklist
     tlist.AddToList(&read);
     tlist.AddToList(&geomapl);
@@ -152,4 +217,5 @@
     tlist.AddToList(&mytask);
 
+    // Run your analysis
     MEvtLoop evtloop;
     evtloop.SetParList(&plist);
@@ -158,4 +224,5 @@
         return;
 
+    // Print statistics information about your loop
     tlist.PrintStatistics();
 }
Index: /trunk/MagicSoft/Mars/macros/rootlogon.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/rootlogon.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/rootlogon.C	(revision 3957)
@@ -16,10 +16,33 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
 \* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// rootlogon.C
+// ===========
+//
+// This file is the startup script ("autoexec.bat") executed when root is
+// started. The definition which file to start is done in ".rootrc".
+// There are three files which are automatically processed by root at
+// startup: A systemwide .rootrc, one in your home directory and one
+// in the current directory.
+// So rootlogon.C is correctly executed if your start root from your
+// Mars directory.
+//
+// The script setupts some small environmental things and makes
+// sure that the Mars shared object (libmars.so) is loaded. This shared
+// object gives you access to all Mars features from within the root
+// interpreter.
+//
+// If libmars.so is not found in the current directory we search in the
+// directory given in "MARSSYS" environment variable.
+//
+///////////////////////////////////////////////////////////////////////////
 
 Bool_t isloaded()
Index: /trunk/MagicSoft/Mars/macros/runbook.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/runbook.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/runbook.C	(revision 3957)
@@ -1,4 +1,47 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// runbook.C
+// =========
+//
+// This is an example macro how to extract the runbook information of
+// a given date from the runbook files.
+//
+// The argument is a date in regexp format, eg.
+//   .x runbook.C("2004-05-1[0-9]")
+//
+// With an MDirIter you can tell the macro which directories and files
+// should be searched.
+//
+// The output are the runbook entries matching your query.
+//
+///////////////////////////////////////////////////////////////////////////
+
 void Wrap(TString &str)
 {
+    // Wrap lines to 80 chars
     while (str.Length()>80)
     {
@@ -15,6 +58,8 @@
 void ProcessFile(TString fname, TString date)
 {
+    // File processed
     cout << fname << endl;
 
+    // Open file
     ifstream fin(fname);
 
@@ -32,4 +77,5 @@
     while (!fin.eof())
     {
+        // Read file line by line
         char *txt=new char[i];
         fin.getline(txt, i-1);
@@ -58,7 +104,9 @@
         }
 
+        // Check whether line matches regexp
         if (!line(r0).IsNull())
             print = !line(r1).IsNull();
 
+        // Wrap lines to 80 chars
         if (print)
             Wrap(line);
@@ -71,4 +119,5 @@
 void runbook(const char *d="20[0-2][0-9]-[0-1][0-9]-[0-3][0-9]")
 {
+    // Regexp to check for valid date
     TString regexp = "20[0-2][0-9]-[0-1][0-9]-[0-3][0-9]";
 
@@ -85,7 +134,9 @@
     }
 
+    // Tell which dierctories and files to search
     MDirIter Next;
     Next.AddDirectory("/home/MAGIC/online_data/runbook", "CC_*.rbk");
 
+    // Loop over files
     TString name;
     while (1)
Index: /trunk/MagicSoft/Mars/macros/sectorvstime.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/sectorvstime.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/sectorvstime.C	(revision 3957)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -25,6 +25,12 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-//  This macro is an example of how to plot the value of a part of the
-// camera or the whole camera.
+// sectorvstime.C
+// ==============
+//
+// In this example we plot the mean content of the right and left half of
+// camera. As an input we use a class derived from MCamEvent. Here this
+// are dc currents read directly from a camera control report file.
+//
+// The output are two histograms one for each half.
 //
 /////////////////////////////////////////////////////////////////////////////
Index: /trunk/MagicSoft/Mars/macros/star.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/star.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/star.C	(revision 3957)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -27,6 +27,12 @@
 //  STAR - STandard Analysis and Reconstruction
 //
-//  This macro is the standard converter to convert raw data into image
-//  parameters
+// This macro is the standard converter to convert raw data into image
+// parameters. It is a demonstration how the star-executable implementation
+// looks like.
+//
+// As an input you need a Merpp output file (raw data).
+// All parameters are written to an output file called starfile.root.
+// For the calculation an arbitrary signal extractor (MCerPhotAnal2/Calc)
+// is used.
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -34,8 +40,4 @@
 void star()
 {
-    //
-    // This is a demonstration program which calculates the image 
-    // parameters from a Magic raw data root file.
-
     //
     // Create a empty Parameter List and an empty Task List
@@ -101,5 +103,4 @@
     //
     // tlist.SetSerialNumber(1); // Serial number of telescope
-
     write.AddContainer(write.AddSerialNumber("MMcEvt"),       "Events", kFALSE);
     write.AddContainer(write.AddSerialNumber("MSigmabar"),    "Events");
Index: /trunk/MagicSoft/Mars/macros/sumcurrents.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/sumcurrents.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/sumcurrents.C	(revision 3957)
@@ -18,8 +18,20 @@
 !   Author(s): Thomas Bretz, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
 \* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// sumcurrents.C
+// =============
+//
+// This is a demonstration macro to display mean DC currents for all pixels.
+// The input is cc report file. The output are histograms and plots.
+// Using the MDirIter functionality you can process more than one file
+// in one or more directories. For more information see MDirIter.
+//
+///////////////////////////////////////////////////////////////////////////
 
 void ProcessFile(TString fname)
@@ -39,4 +51,5 @@
     //
 
+    // Create the magic geometry
     MGeomCamMagic geom;
     plist.AddToList(&geom);
@@ -49,4 +62,5 @@
     tlist.AddToList(&read);
 
+    // create a task to fill a histogram
     MFillH fill("MHCamEvent", "MCameraDC");
     tlist.AddToList(&fill);
@@ -66,4 +80,7 @@
     tlist.PrintStatistics();
 
+    //
+    // Now display the result of the loop
+    //
     MHCamEvent &h2 = *(MHCamEvent*)plist->FindObject("MHCamEvent");
     MHCamera &h = *(MHCamera*)h2.GetHistByName("sum");
@@ -129,10 +146,4 @@
 }
 
-// -------------------------------------------------------------------------
-//
-//  plot.C
-//
-//  This macro shows how to fill and display a histogram using Mars
-//
 void sumcurrents(const char *dirname=".")
 {
Index: /trunk/MagicSoft/Mars/macros/tar.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/tar.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/tar.C	(revision 3957)
@@ -1,2 +1,36 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// tar.C
+// =====
+//
+// Service script. used to create the tar archive for an release. It makes
+// sure that the correct files are included and the name of the archive is
+// the name of the current directory (+.tar.gz)
+//
+///////////////////////////////////////////////////////////////////////////
 void tar()
 {
Index: /trunk/MagicSoft/Mars/macros/testenv.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/testenv.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/testenv.C	(revision 3957)
@@ -1,2 +1,43 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// testenv.C
+// =========
+//
+// This example reads an config-file (steering card, input card, ...)
+// The contents of the file a forwarded to the apropriate eventloop
+// setup in your file.
+//
+// All tasks and containers in an eventloop should implement the
+// ReadEnv/WriteEnv function (for an example see the tasks used below).
+//
+// The functions gets the corresponding setup data from the file as an
+// argument and can change their behaviour and setup on this information.
+//
+///////////////////////////////////////////////////////////////////////////
+
 void testenv()
 {
Index: /trunk/MagicSoft/Mars/macros/weights.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/weights.C	(revision 3956)
+++ /trunk/MagicSoft/Mars/macros/weights.C	(revision 3957)
@@ -18,22 +18,20 @@
 !   Author(s): Marcos Lopez, 10/2003 <mailto:marcos@gae.ucm.es>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
 \* ======================================================================== */
 
-
 //////////////////////////////////////////////////////////////////////////////
-//                                                                          //
-// This macro shows how to use the class MMcWeightEnergySpecCalc            //
-// to convert the energy spectrum of the MC showers generated with Corsika, //
-// to a different one.                                                      //
-//                                                                          //
+//
+// weights.C
+// =========
+//
+// This macro shows how to use the class MMcWeightEnergySpecCalc
+// to convert the energy spectrum of the MC showers generated with Corsika,
+// to a different one.
+//
 //////////////////////////////////////////////////////////////////////////////
 
-
-// --------------------------------------------------------------------------
-//
-//
 Double_t myfunction(Double_t *x, Double_t *par)
 {
@@ -43,9 +41,4 @@
 }
 
-
-
-// --------------------------------------------------------------------------
-//
-//
 void weights(TString filename="/up1/data/Magic-MC/CameraAll/Gammas/zbin0/Gamma_zbin0_0_7_1000to1009_w0-4:4:2.root")
 {
@@ -109,5 +102,4 @@
     //-------------------------------------------------------------
 
-
     MFillH hfill(&h1,"MMcEvt");
     MFillH hfill2(&h2,"MMcEvt");
@@ -118,5 +110,4 @@
     tasklist.AddToList(&hfill);
     tasklist.AddToList(&hfill2);
-
 
     //
@@ -132,6 +123,5 @@
     parlist.Print();
 
-
-    // 
+    //
     // Draw the Results
     //
@@ -146,17 +136,3 @@
     hist1->DrawClone();
     hist2->DrawClone("same");    
-
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: /trunk/MagicSoft/Mars/mastro/MAstroCamera.cc
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MAstroCamera.cc	(revision 3956)
+++ /trunk/MagicSoft/Mars/mastro/MAstroCamera.cc	(revision 3957)
@@ -70,9 +70,12 @@
 #include "MAstroCamera.h"
 
-#include <KeySymbols.h>       // kKey_*
-
-#include <TH2.h>              // TH2D
-#include <TMarker.h>          // TMarker
-#include <TVirtualPad.h>      // gPad
+#include <errno.h>        // strerror
+#include <fstream>        // ifstream
+
+#include <KeySymbols.h>   // kKey_*
+
+#include <TH2.h>          // TH2D
+#include <TMarker.h>      // TMarker
+#include <TVirtualPad.h>  // gPad
 
 #include "MLog.h"
@@ -144,4 +147,75 @@
         memcpy((*fMirrors)[i], arr[i], sizeof(MGeomMirror));
 
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the mirror geometry from a MC .def file. The following
+// structure is expected:
+//
+// #*  TYPE=1  (MAGIC)
+// #*      i  f   sx   sy   x   y   z   thetan  phin 
+// #* 
+// #*       i : number of the mirror
+// #*       f : focal distance of that mirror
+// #*      sx : curvilinear coordinate of mirror's center in X[cm]
+// #*      sy : curvilinear coordinate of mirror's center in X[cm]
+// #*       x : x coordinate of the center of the mirror [cm]
+// #*       y : y coordinate of the center of the mirror [cm]
+// #*       z : z coordinate of the center of the mirror [cm]
+// #*  thetan : polar theta angle of the direction where the mirror points to
+// #*    phin : polar phi angle of the direction where the mirror points to
+// #*      xn : xn coordinate of the normal vector in the center (normalized)
+// #*      yn : yn coordinate of the normal vector in the center (normalized)
+// #*      zn : zn coordinate of the normal vector in the center (normalized)
+// #
+// define_mirrors
+//   1 1700.9200   25.0002   75.0061   25.0000   75.0000    0.9207 0.02328894 1.24904577 -0.00736394 -0.02209183 0.99972882
+//   2 ...
+//
+void MAstroCamera::SetMirrors(const char *fname)
+{
+    ifstream fin(fname);
+    if (!fin)
+    {
+        gLog << err << "Cannot open file " << fname << ": ";
+        gLog << strerror(errno) << endl;
+        return;
+    }
+
+    TString line;
+    while (1)
+    {
+        line.ReadLine(fin);
+        if (!fin)
+            return;
+
+        line = line.Strip(TString::kBoth);
+
+        if (line.BeginsWith("n_mirrors"))
+        {
+            Int_t n;
+            sscanf(line.Data(), "%*s %d", &n);
+
+            if (!fMirrors)
+                fMirrors = new TClonesArray(MGeomMirror::Class(), n);
+
+            fMirrors->ExpandCreate(n);
+            continue;
+        }
+
+
+        Int_t id;
+        Float_t f, sx, sy, x, y, z, thetan, phin, xn, yn, zn;
+
+        const Int_t n = sscanf(line.Data(), "%d %f %f %f %f %f %f %f %f %f %f %f",
+                               &id, &f, &sx, &sy, &x, &y, &z, &thetan,
+                               &phin, &xn, &yn, &zn);
+        if (n!=12)
+            continue;
+
+        new ((*fMirrors)[id-1]) MGeomMirror;
+        ((MGeomMirror*)(*fMirrors)[id-1])->SetMirrorContent(id, f, sx, sy, x, y, z, thetan, phin, xn, yn, zn);
+    }
 }
 
@@ -287,4 +361,6 @@
     {
         const Double_t mag = radec->Magnitude();
+        if (mag>GetLimMag())
+            continue;
 
         TVector3 star(*radec);
@@ -334,4 +410,5 @@
             const TVector3 spot = fMirror0->GetReflection(star, fGeom->GetCameraDist())*1000;
             DrawStar(spot(0), spot(1), *radec, !hasmean, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)));
+            //cout << TMath::Hypot(spot(0), spot(1)) << " " << TMath::Hypot(mean(0)-spot(0), mean(1)-spot(1)) << endl;
         }
     }
@@ -362,22 +439,9 @@
     }
 
-    // Get camera
-    MHCamera *camera=(MHCamera*)FindObjectInPad("MHCamera", gPad);
-    if (camera)
-    {
-        if (!camera->GetGeometry() || camera->GetGeometry()->IsA()!=fGeom->IsA())
-            camera->SetGeometry(*fGeom);
-    }
-    else
-    {
-        camera = new MHCamera(*fGeom);
-        camera->SetName("MHCamera");
-        camera->SetStats(0);
-        camera->SetInvDeepBlueSeaPalette();
-        camera->SetBit(kCanDelete);
-        camera->Draw();
-    }
-
-    const TRotation rot(GetGrid(kTRUE));
+    const MAstroSky2Local s2l(*fTime, *fObservatory);
+    const TRotation trans(AlignCoordinates(rot*fRaDec));
+
+    // Return the correct rotation matrix
+    const TRotation rot = trans*s2l;
 
     MVector3 *radec;
@@ -397,4 +461,8 @@
 	list->Add(starpos);
     }
+    // For MAGIC the distance of the mean of the light distribution
+    // to the Mirror0 reflection of the star (Abberation) can be
+    // expressed as:  dr = (0.0713 +/- 0.0002) * r = r/14.03
+    // with r = hypot(mean(0), mean(1))
 }
 */
@@ -402,8 +470,71 @@
 // ------------------------------------------------------------------------
 //
+// Uses fRaDec as a reference point.
+//
+// Return dZd and dAz corresponding to the distance from x,y to fRaDec
+//
+// Before calling this function you should correct for abberation. In
+// case of MAGIC you can do this by:
+//    x /= 1.0713;
+//    y /= 1.0713;
+//
+// x [mm]: x coordinate in the camera plane (assuming a perfect mirror)
+// y [mm]: y coordinate in the camera plane (assuming a perfect mirror)
+//
+// dzd [deg]: Delta Zd
+// daz [deg]: Delta Az
+//
+void MAstroCamera::GetDiffZdAz(Double_t x, Double_t y, Double_t &dzd, Double_t &daz)
+{
+    // Reflect the corrected pixel on a perfect mirror
+    TVector3 v(x, y, fGeom->GetCameraDist()*1000);
+    TVector3 spot = fMirror0->GetReflection(v);
+    
+    // Derotate into the local coordinate system
+    const MAstroSky2Local rot(*fTime, *fObservatory);
+    const TRotation align(AlignCoordinates(rot*fRaDec).Inverse());
+    spot *= align;
+
+    cout << "Zd="<<spot.Theta()*TMath::RadToDeg() << " ";
+    cout << "Az="<<spot.Phi()  *TMath::RadToDeg()+360 << endl;
+
+    // Derotatet the center of the camera
+    TVector3 c(0, 0, 1);
+    c *= align;
+
+    dzd = (spot.Theta()-c.Theta())*TMath::RadToDeg();
+    daz = (spot.Phi()  -c.Phi())  *TMath::RadToDeg();
+
+    if (daz> 180) daz -= 360;
+    if (daz<-180) daz += 360;
+}
+
+// ------------------------------------------------------------------------
+//
 // Execute a gui event on the camera
 //
 void MAstroCamera::ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2)
 {
+    // if (mp1>0 && mp2>0)
+    // {
+    //     // Calculate World coordinates from pixel
+    //     Double_t x = gPad->AbsPixeltoX(mp1);
+    //     Double_t y = gPad->AbsPixeltoY(mp2);
+    //
+    //     // Correct for abberation
+    //     x /= 1.0713;
+    //     y /= 1.0713;
+    //
+    //     Double_t dzd, daz;
+    //     GetDiffZdAz(x, y, dzd, daz);
+    //
+    //     cout << "dZd="<< dzd << " " << "dAz="<< daz << endl;
+    // }
+    //
+    // For MAGIC the distance of the mean of the light distribution
+    // to the Mirror0 reflection of the star (Abberation) can be
+    // expressed as:  dr = 0.0713*r = r/14.03
+    //                   +-0.0002
+
     if (event==kKeyPress && fTime)
         switch (mp2)
Index: /trunk/MagicSoft/Mars/mastro/MAstroCamera.h
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MAstroCamera.h	(revision 3956)
+++ /trunk/MagicSoft/Mars/mastro/MAstroCamera.h	(revision 3957)
@@ -32,5 +32,8 @@
 
     void SetMirrors(TClonesArray &arr);
+    void SetMirrors(const char *fname);
     void SetGeom(const MGeomCam &cam);
+
+    void GetDiffZdAz(Double_t x, Double_t y, Double_t &dzd, Double_t &daz);
 
     ClassDef(MAstroCamera, 1) // Display class to display stars on the camera
Index: /trunk/MagicSoft/Mars/mastro/MObservatory.h
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MObservatory.h	(revision 3956)
+++ /trunk/MagicSoft/Mars/mastro/MObservatory.h	(revision 3957)
@@ -36,4 +36,15 @@
     MObservatory(LocationName_t key, const char *name=NULL, const char *title=NULL);
 
+    void Copy(TObject &obj) const
+    {
+        MObservatory &obs = (MObservatory&)obj;
+        obs.fObservatoryName = fObservatoryName;
+        obs.fLongitude = fLongitude;
+        obs.fLatitude = fLatitude;
+        obs.fSinLatitude = fSinLatitude;
+        obs.fCosLatitude = fCosLatitude;
+        obs.fHeight = fHeight;
+    }
+
     void SetLocation(LocationName_t name);
 
Index: /trunk/MagicSoft/Mars/mbase/MLog.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 3956)
+++ /trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 3957)
@@ -149,5 +149,6 @@
     //
 #ifdef _REENTRANT
-    fMuxGui = new TMutex;
+    fMuxGui    = new TMutex;
+    fMuxStream = new TMutex;
 #endif
 
@@ -213,4 +214,5 @@
     delete fPlugins;
 #ifdef _REENTRANT
+    delete fMuxStream;
     delete fMuxGui;
 #endif
@@ -359,5 +361,5 @@
 
     // lock mutex
-    Lock("UpdateGui");
+    LockUpdate("UpdateGui");
 
     TGText &txt=*fGui->GetText();
@@ -387,5 +389,21 @@
 
     // release mutex
-    UnLock("UpdateGui");
+    UnLockUpdate("UpdateGui");
+}
+
+void MLog::LockUpdate(const char *msg)
+{
+#ifdef _REENTRANT
+    if (fMuxGui->Lock()==13)
+        Error("LockUpdate", "%s - mutex is already locked by this thread\n", msg);
+#endif
+}
+
+void MLog::UnLockUpdate(const char *msg)
+{
+#ifdef _REENTRANT
+    if (fMuxGui->UnLock()==13)
+        Error("UnLockUpdate", "%s - tried to unlock mutex locked by other thread\n", msg);
+#endif
 }
 
@@ -393,5 +411,5 @@
 {
 #ifdef _REENTRANT
-    if (fMuxGui->Lock()==13)
+    if (fMuxStream->Lock()==13)
         Error("Lock", "%s - mutex is already locked by this thread\n", msg);
 #endif
@@ -401,5 +419,5 @@
 {
 #ifdef _REENTRANT
-    if (fMuxGui->UnLock()==13)
+    if (fMuxStream->UnLock()==13)
         Error("UnLock", "%s - tried to unlock mutex locked by other thread\n", msg);
 #endif
@@ -412,7 +430,7 @@
 int MLog::sync()
 {
-    Lock("sync");
+    LockUpdate("sync");
     WriteBuffer();
-    UnLock("sync");
+    UnLockUpdate("sync");
 
     if (fDevice&eStdout)
@@ -448,5 +466,5 @@
     if (fOutputLevel <= fDebugLevel)
     {
-        Lock("overflow");
+        LockUpdate("overflow");
 
         *fPPtr++ = (char)i;
@@ -455,5 +473,5 @@
             WriteBuffer();
 
-        UnLock("overflow");
+        UnLockUpdate("overflow");
     }
 
Index: /trunk/MagicSoft/Mars/mbase/MLog.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MLog.h	(revision 3956)
+++ /trunk/MagicSoft/Mars/mbase/MLog.h	(revision 3957)
@@ -71,4 +71,5 @@
 #ifdef _REENTRANT
     TMutex *fMuxGui;          //! Mutex locking access of TGListBox
+    TMutex *fMuxStream;       //! Mutex locking access to streaming
 #endif
 
@@ -102,6 +103,9 @@
     ~MLog();
 
-    void Lock(const char *msg);
-    void UnLock(const char *msg);
+    void LockUpdate(const char *msg);
+    void UnLockUpdate(const char *msg);
+
+    void Lock(const char *msg="");
+    void UnLock(const char *msg="");
 
     void EnableDirectGui()  { fIsDirectGui = kTRUE; }
Index: /trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3956)
+++ /trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3957)
@@ -34,4 +34,13 @@
 // To change the scale to a logarithmic scale SetLogy() of the Pad.
 //
+// You can correct for the abberation. Assuming that the distance
+// between the mean position of the light distribution and the position
+// of a perfect reflection on a perfect mirror in the distance r on
+// the camera plane is dr it is  d = a*dr  while a is the abberation
+// constant (for the MAGIC mirror it is roughly 0.0713). You can
+// set this constant by calling SetAbberation(a) which results in a
+// 'corrected' display (all outer pixels are shifted towards the center
+// of the camera to correct for this abberation)
+//
 // Be carefull: Entries in this context means Entries/bin or Events
 //
@@ -102,5 +111,5 @@
 //  Default Constructor. To be used by the root system ONLY.
 //
-MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend)
+MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend), fAbberation(0)
 {
     Init();
@@ -114,5 +123,5 @@
 //
 MHCamera::MHCamera(const MGeomCam &geom, const char *name, const char *title)
-: fGeomCam(NULL), fColors(kItemsLegend)
+: fGeomCam(NULL), fColors(kItemsLegend), fAbberation(0)
 {
     //fGeomCam = (MGeomCam*)geom.Clone();
@@ -759,7 +768,7 @@
         const MGeomPix &pix = (*fGeomCam)[i];
 
-        const Float_t x = pix.GetX()*conv;
-        const Float_t y = pix.GetY()*conv;
-        const Float_t d = pix.GetD()*conv;
+        Float_t x = pix.GetX()*conv/(fAbberation+1);
+        Float_t y = pix.GetY()*conv/(fAbberation+1);
+        Float_t d = pix.GetD()*conv;
 
         if (!isbox)
Index: /trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 3956)
+++ /trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 3957)
@@ -47,4 +47,6 @@
 //#endif
 
+    Float_t fAbberation;
+
     void Init();
 
@@ -188,6 +190,6 @@
     void     Draw(Option_t *option="");
     TObject *DrawClone(Option_t *option="") const;
-    void     DrawProjection (Int_t fit=0) const;        
-    void     DrawRadialProfile()           const;       
+    void     DrawProjection (Int_t fit=0) const;
+    void     DrawRadialProfile()           const;
 
     void     SavePrimitive(ofstream &out, Option_t *);
@@ -209,4 +211,6 @@
     Bool_t   IsFreezed() const { return TestBit(kFreezed); }
     //void  SetOptStat(Int_t os=-1) { fOptStat = os; } // *MENU*
+
+    void     SetAbberation(Float_t f=0.0713) { fAbberation=f; } // *MENU*
 
     void     AddNotify(TObject *event);
Index: /trunk/MagicSoft/Mars/mtools/MFFT.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtools/MFFT.cc	(revision 3956)
+++ /trunk/MagicSoft/Mars/mtools/MFFT.cc	(revision 3957)
@@ -63,5 +63,35 @@
 //     * If the PSD does NOT CONVERGE to 0 at the maximum bin,              //
 //       you HAVE TO sample your data finer!                                //
-//                                                                          //
+//
+// Fourier-Transformation:
+// =======================
+
+// (taken from http://www.parasitaere-kapazitaeten.net/Pd/ft.htm)
+//
+//  The Fourier-Transformation is a mathematical function that breaks
+// down a signal (like sound) into its frequency-spectrum as a set of
+// sinusoidal components, converting it from the Time Domain to the
+// Frequency Domain.
+// 
+//  In the Time Domain the signal x[ ] consists of N samples, labeled
+// from 0 to N-1. In the Frequency Domain the RFFT produces two signals
+// (signalvectors), treated as complex numbers representing the Real Part:
+// Re X[ ] and the Imaginary Part: Im X[ ]. They are seen as the Cosine-
+// und Sine-Components of the base frequencies. Each of these two signals
+// contains one more sample than the half of the original signal: N/2 + 1
+// samples. (this results from the fact, that the sine-components of the
+// first frequency (0) and the last (nyquist, N/2) are always 0). With the
+// complex Fourier-Transformation N complexe values are transformed to N
+// new complex values. For both it applies to: the Frequency Domain
+// contains exactly the same information as the Time-Domain.
+// 
+//  A Real FFT over 64 samples produces values for 33 cosine- and 33
+// sine-wave-amplitudes with the frequencies 0, 1, 2, 3, ..., 30, 31, 32.
+// The first value (frequency 0) is the DC (direct current), the other
+// values have to be seen in practice as factors of a
+// fundamental-frequency which can be calculated by dividing samplerate by
+// windowsize. The highest frequency is the nyquist-frequency
+// (samplerate/2).
+// 
 //////////////////////////////////////////////////////////////////////////////
 
