Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 9341)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 9342)
@@ -19,4 +19,18 @@
                                                  -*-*- END OF LINE -*-*-
  2009/02/15 Thomas Bretz
+
+   * mpointing/MSrcPosCalc.cc:
+     - ignore the WobbleMode from the MMcCorsikaRunHeader 
+       if it is a ceres file
+
+   * msim/MPhotonEvent.[h,cc]:
+     - added function GetTimeFirst
+     - added function GetTimeLast
+     - added function GetTimeMedianDev
+     - added fLength to MPhotonStatistics
+
+   * msimcamera/MSimGeomCam.cc:
+     - make use of the new functions
+     - set length to statistics container
 
    * mpointing/MHSrcPosCam.[h,cc], mpointing/MSrcPosRndm.[h,cc],
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 9341)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 9342)
@@ -2,4 +2,11 @@
 
 == <cvs> ==
+
+ ;SUGGESTION
+
+   * There is no need to re-run any data because no change took place which
+     could have an effect on the output. However, if you want a 
+     meaningful SrcPos plot for your MCs in sponde you must re-process
+     star for your MCs first.
 
  ;general
@@ -10,4 +17,10 @@
    * in sequence file the date can now be omittet. In this case the
      leading date with the underscore is missing in the expected filename
+
+ ;automation
+
+   * added magnetic field Azimuth direction (ARRANG), currently
+     at ~ -7deg at La Palma
+ 
 
  ;database
@@ -53,4 +66,14 @@
    * A new tab ''info'' now display basic things like the reflector
      layout
+
+ ;star
+
+   * Now outputs MSrcPosCam for Monte Carlos in the Events tree.
+
+ ;sponde
+
+   * The SrcPos plot for your MCs was so far meaningless because it just
+     displayes the MSrcPosCam data from the input star-files. Unfortunately,
+     this containes was never written to the star-files yet.
 
 
Index: /trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc	(revision 9341)
+++ /trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc	(revision 9342)
@@ -342,4 +342,7 @@
     }
 
+    if (fMcHeader->IsCeres())
+        return kTRUE;
+
     const MMcCorsikaRunHeader *h = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader");
     if (!h)
Index: /trunk/MagicSoft/Mars/msim/MPhotonEvent.cc
===================================================================
--- /trunk/MagicSoft/Mars/msim/MPhotonEvent.cc	(revision 9341)
+++ /trunk/MagicSoft/Mars/msim/MPhotonEvent.cc	(revision 9342)
@@ -113,4 +113,8 @@
 #include <TMarker.h>
 
+#include <MMath.h>
+
+#include "MArrayF.h"
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -213,4 +217,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Return the number of "external" photons, i.e. which are not NightSky
+//
 Int_t MPhotonEvent::GetNumExternal() const
 {
@@ -222,4 +230,46 @@
 
     return n;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return time of first photon, 0 if none in array.
+// Note: If you want this to be the earliest make sure that the array
+// is properly sorted.
+//
+Float_t MPhotonEvent::GetTimeFirst() const
+{
+    const MPhotonData *dat=GetFirst();
+    return dat ? dat->GetTime() : 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return time of first photon, 0 if none in array.
+// Note: If you want this to be the latest make sure that the array
+// is properly sorted.
+//
+Float_t MPhotonEvent::GetTimeLast() const
+{
+    const MPhotonData *dat=GetLast();
+    return dat ? dat->GetTime() : 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the median devian from the median of all arrival times.
+// The median deviation is calculated using MMath::MedianDev.
+// It is the half width in which one sigma (~68%) of all times are
+// contained around the median.
+//
+Double_t MPhotonEvent::GetTimeMedianDev() const
+{
+    const UInt_t n = GetNumPhotons();
+
+    MArrayF arr(n);
+    for (UInt_t i=0; i<n; i++)
+        arr[i] = operator[](i).GetTime();
+
+    return MMath::MedianDev(n, arr.GetArray()/*, Double_t &med*/);
 }
 
Index: /trunk/MagicSoft/Mars/msim/MPhotonEvent.h
===================================================================
--- /trunk/MagicSoft/Mars/msim/MPhotonEvent.h	(revision 9341)
+++ /trunk/MagicSoft/Mars/msim/MPhotonEvent.h	(revision 9342)
@@ -80,4 +80,8 @@
     Int_t GetNumExternal() const;
 
+    Float_t  GetTimeFirst() const;
+    Float_t  GetTimeLast() const;
+    Double_t GetTimeMedianDev() const;
+
     TClonesArray &GetArray() { return fData; }
     const TClonesArray &GetArray() const { return fData; }
@@ -131,11 +135,14 @@
 {
 private:
-    Float_t fTimeFirst;
-    Float_t fTimeLast;
+    Float_t fTimeFirst;  //! Start of (simulated) sampling window
+    Float_t fTimeLast;   //! Start of (simulated) sampling window
+
+    Float_t fLength;     // Time between first and last photon
+    Float_t fTimeMedDev; // Median deviation
 
 //    Float_t fOffset;
 //    Float_t fWindow;
 
-    Int_t fMaxIndex;
+    Int_t fMaxIndex;     //!
 
 public:
@@ -147,5 +154,7 @@
 
     void SetTime(Float_t first, Float_t last) { fTimeFirst=first; fTimeLast=last; }
+    void SetLength(Float_t len) { fLength=len; }
     void SetMaxIndex(UInt_t idx) { fMaxIndex=idx; }
+    void SetTimeMedDev(Float_t dev) { fTimeMedDev=dev; }
 
 //    Float_t GetRawTimeFirst() const { return fTimeFirst; }
@@ -154,4 +163,7 @@
     Float_t GetTimeFirst() const { return fTimeFirst; }
     Float_t GetTimeLast() const { return fTimeLast; }
+
+    Float_t GetLength() const { return fLength; }
+    Float_t GetTimeMedDev() const { return fTimeMedDev; }
 
     Int_t GetMaxIndex() const { return fMaxIndex; }
Index: /trunk/MagicSoft/Mars/msimcamera/MSimGeomCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/msimcamera/MSimGeomCam.cc	(revision 9341)
+++ /trunk/MagicSoft/Mars/msimcamera/MSimGeomCam.cc	(revision 9342)
@@ -181,6 +181,6 @@
     const Int_t   ns   = fHeader->GetNumSamplesHiGain()+1;
 
-    const Float_t first = cnt>0 ? fEvt->GetFirst()->GetTime() :  0;
-    const Float_t last  = cnt>0 ? fEvt->GetLast()->GetTime()  : ns*freq;
+    const Float_t first = cnt>0 ? fEvt->GetTimeFirst() :  0;
+    const Float_t last  = cnt>0 ? fEvt->GetTimeLast()  : ns*freq;
 
     // Length (ns), Pulse position (Units ns)
@@ -188,5 +188,7 @@
     const Float_t pw   = fPulse->GetPulseWidth();
 
+    fStat->SetTimeMedDev(fEvt->GetTimeMedianDev());
     fStat->SetTime(first-pp-pw, last-pp+pw + ns*freq);
+    fStat->SetLength(last-first);
     fStat->SetMaxIndex(fGeom->GetNumPixels()-1);
     fStat->SetReadyToSave();
