Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 8336)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 8337)
@@ -19,4 +19,25 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2007/02/28 Thomas Bretz
+
+  * macros/tutorials/mirrordelay.C:
+     - fixed the formula for the spherical mirror
+     - fixed the calculation of the time-delay
+
+   * mastro/MObservatory.[h,cc]:
+     - added constructors and functions to set the observatory location
+       manually
+
+   * mbase/MTime.[h,cc]:
+     - added constructor to construct MTime by date
+     - added AsDouble for new root streamers (allowing to view MTime in 
+       a TBrowser)
+     - added GetRootDatime to return TDatime object
+
+   * mcalib/MCalibrateData.cc:
+     - added more meaningful output in case a conversion factor exceeds a limit
+
+
+
  2007/02/26 Daniela Dorner
 
Index: /trunk/MagicSoft/Mars/macros/tutorials/mirrordelay.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/tutorials/mirrordelay.C	(revision 8336)
+++ /trunk/MagicSoft/Mars/macros/tutorials/mirrordelay.C	(revision 8337)
@@ -25,15 +25,15 @@
 void mirrordelay()
 {
-    TF1 fpar("Parab",  "[0]*x*x");
-    TF1 fsph("Sphere", "-sqrt([0]*[0] - x*x)+[0]");
+    TF1 fpar("Parab",  "x*x/(4*[0])");
+    TF1 fsph("Sphere", "-sqrt(4*[0]*[0] - x*x) + 2*[0]");
 
     Double_t F = 4.92; // Fokallaenge = 1/4a
     Double_t D = 4.5;  // Mirror Diameter
     Double_t x = 1.85; // incident point for photon
-
+                                     
     fsph.SetRange(-D*0.55, D*0.55);
     fpar.SetRange(-D*0.55, D*0.55);
 
-    fpar.SetParameter(0, 1./(4*F));
+    fpar.SetParameter(0, F);
     fsph.SetParameter(0, F);
 
@@ -79,12 +79,19 @@
     TLegend leg(0.40, 0.6, 0.60, 0.85);//, "NDC");
 
-    TF1 fdel("Diff", "(Sphere-Parab+TMath::Hypot(x-0, Parab-[0])-[0])/3e8*1e9");
-    fdel.SetRange(-D*0.55, D*0.55);
-    fdel.SetLineWidth(2);
-
     for (int i=-2; i<3; i++)
     {
+        // Make sure to set the parameters BEFORE reusing the function!
+        fsph.SetParameter(0, F+i*0.10*F);
+        fpar.SetParameter(0, F+i*0.10*F);
 
+        TF1 fdel1("Diff1", "Sphere-Parab");
+        TF1 fdel2("Diff2", "TMath::Hypot(x-0, Parab-[0])-TMath::Hypot(x-0, Sphere-[0])");
+        fdel2.SetParameter(0, F+i*0.10*F);
+
+        TF1 fdel("Diff", "(Diff1+Diff2)/3e8*1e9");
+        fdel.SetRange(-D*0.55, D*0.55);
+        fdel.SetLineWidth(2);
         fdel.SetParameter(0, F+i*0.10*F);
+
         fdel.SetLineColor(kBlack+(abs(i)==2?3:abs(i)));
         if (i<0)
@@ -98,5 +105,5 @@
 
         f->GetXaxis()->SetTitle("x [m]");
-        f->GetYaxis()->SetTitle("Delay \\Delta t [ns]");
+        f->GetYaxis()->SetTitle("Delay  \\Delta t [ns]");
         f->GetXaxis()->CenterTitle();
 
Index: /trunk/MagicSoft/Mars/mastro/MObservatory.cc
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MObservatory.cc	(revision 8336)
+++ /trunk/MagicSoft/Mars/mastro/MObservatory.cc	(revision 8337)
@@ -53,4 +53,9 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Default constructor sets name and title of instace.
+// Default location is kMagic1
+//
 MObservatory::MObservatory(const char *name, const char *title)
 {
@@ -60,4 +65,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// For example "MObservator(MObservatory::kMagic1)"
+//
 MObservatory::MObservatory(LocationName_t key, const char *name, const char *title)
 {
@@ -65,4 +74,26 @@
 
     SetLocation(key);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls SetLocation
+//
+MObservatory::MObservatory(Double_t lon, Double_t lat, const char *name)
+{
+    Init();
+
+    SetLocation(lon, lat, 0, name);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls SetLocation
+//
+MObservatory::MObservatory(Double_t lon, Double_t lat, Double_t h, const char *name)
+{
+    Init();
+
+    SetLocation(lon, lat, h, name);
 }
 
@@ -106,4 +137,22 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Longitude/Latitude [rad]
+// Height             [m]
+//
+void MObservatory::SetLocation(Double_t lon, Double_t lat, Double_t h, const char *name)
+{
+    fLongitude = lon;
+    fLatitude  = lat;
+    fHeight    = h;
+
+    fSinLatitude = TMath::Sin(fLatitude);
+    fCosLatitude = TMath::Cos(fLatitude);
+
+    if (name)
+        fObservatoryName = name;
+}
+
 void MObservatory::Print(Option_t *) const
 {
Index: /trunk/MagicSoft/Mars/mastro/MObservatory.h
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MObservatory.h	(revision 8336)
+++ /trunk/MagicSoft/Mars/mastro/MObservatory.h	(revision 8337)
@@ -32,9 +32,11 @@
     Double_t fHeight;                //! [m] height of observatory
 
-    void Init(const char *name, const char *title);
+    void Init(const char *name=NULL, const char *title=NULL);
 
 public:
     MObservatory(const char *name=NULL, const char *title=NULL);
     MObservatory(LocationName_t key, const char *name=NULL, const char *title=NULL);
+    MObservatory(Double_t lon, Double_t lat, const char *name="<n/a>");
+    MObservatory(Double_t lon, Double_t lat, Double_t h, const char *name="<n/a>");
 
     void Copy(TObject &obj) const
@@ -50,4 +52,5 @@
 
     void SetLocation(LocationName_t name);
+    void SetLocation(Double_t lon, Double_t lat, Double_t h=0, const char *name=NULL);
 
     void Print(Option_t *o=0) const;
Index: /trunk/MagicSoft/Mars/mbase/MTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTime.cc	(revision 8336)
+++ /trunk/MagicSoft/Mars/mbase/MTime.cc	(revision 8337)
@@ -108,4 +108,14 @@
 // --------------------------------------------------------------------------
 //
+// Constructor. Calls Set(y, m, d, h, min, s, ms, ns).
+// To check validity test for (*this)==MTime()
+//
+MTime::MTime(UShort_t y, Byte_t m, Byte_t d, Byte_t h, Byte_t min, Byte_t s, UShort_t ms, UInt_t ns)
+{
+    Set(y, m, d, h, min, s, ms, ns);
+}
+
+// --------------------------------------------------------------------------
+//
 // Return date as year(y), month(m), day(d)
 //
@@ -218,4 +228,15 @@
 {
     return (ULong_t)((GetMjd()-49718)*kDay);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a time which is expressed in seconds since 01/01/1970 0:00h
+// This is compatible with root's definition used in the constructor of
+// TDatime.
+//
+TDatime MTime::GetRootDatime() const
+{
+    return TDatime((UInt_t)((GetMjd()-40587)*kDay/1000));
 }
 
Index: /trunk/MagicSoft/Mars/mbase/MTime.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTime.h	(revision 8336)
+++ /trunk/MagicSoft/Mars/mbase/MTime.h	(revision 8337)
@@ -64,8 +64,12 @@
     }
     MTime(Double_t mjd);
+    MTime(UShort_t y, Byte_t m, Byte_t d, Byte_t h=13, Byte_t min=0, Byte_t s=0, UShort_t ms=0, UInt_t ns=0);
     MTime(const MTime& t) : MParContainer(), fMjd(t.fMjd), fTime(t.fTime), fNanoSec(t.fNanoSec)
     {
         Init(NULL, NULL);
     }
+
+    //static Int_t Hour() { return 3600; }
+    //static Int_t Day()  { return 3600;*24 }
 
     void operator=(const MTime &t)
@@ -108,4 +112,5 @@
     void     GetDateOfSunrise(UShort_t &y, Byte_t &m, Byte_t &d) const;
     TTime    GetRootTime() const;
+    TDatime  GetRootDatime() const;
     Double_t GetAxisTime() const;
     Double_t GetMoonPhase() const;
@@ -143,4 +148,8 @@
     operator double() const;   //[s]
     double operator()() const; //[s]
+
+    Double_t    AsDouble() const    { return GetMjd(); }
+    //const char *AsString() const    { return GetString(); }
+    //const char *AsSQLString() const { return GetSqldateTime(); }
 
     // Calculation functions
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc	(revision 8336)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc	(revision 8337)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.63 2007-01-29 13:03:43 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.64 2007-02-28 13:29:52 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -723,6 +723,7 @@
 	    calibConv    = -1.;
 	    calibFFactor = -1.;
-            *fLog << warn << GetDescriptor()
-                << ": WARNING - Conversion factor of Pixel " << pixidx << " out of range... set to 0. " << endl;
+            *fLog << warn << GetDescriptor() << ": WARNING - ";
+            *fLog << "Conversion factor " << calibConv << " of Pixel " << pixidx << " out of range ]";
+            *fLog << fCalibConvMinLimit << "," << fCalibConvMaxLimit << "[... set to 0. " << endl;
 	  }
 	cpix.SetCalibConst(calibConv);
@@ -733,6 +734,6 @@
     if (skip>fGeomCam->GetNumPixels()*0.9)
     {
-        *fLog << warn << GetDescriptor() 
-              << ": WARNING - GetConversionFactor has skipped more than 90% of the pixels... abort." << endl;
+        *fLog << err << GetDescriptor() << ": ERROR - ";
+        *fLog << "GetConversionFactor has skipped more than 90% of the pixels... abort." << endl;
         return kFALSE;
     }
