Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 8065)
+++ trunk/MagicSoft/Mars/Changelog	(revision 8066)
@@ -59,4 +59,7 @@
    * mmc/MMcRunHeader.cxx:
      - initalize fImpactMax to -1
+
+   * macros/starvisday.C, macros/starvisyear.C:
+     - added
 
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 8065)
+++ trunk/MagicSoft/Mars/NEWS	(revision 8066)
@@ -2,4 +2,16 @@
 
  *** <cvs>
+
+   - general: changed the building of the sequence files such, that
+     the source-/project name in case of wobble-sources is not the
+     source/project of the first data run anymore but the new generalized
+     wobble source/project
+
+   - general: Added some functions to MAstro to calculate sun and
+     moon properties
+
+   - general: Added two new macros (starvisday.C and starvisyear.C)
+     which allow to plot the visibility of several stars in one day
+     or of one star along one year
 
 
Index: trunk/MagicSoft/Mars/macros/starvisday.C
===================================================================
--- trunk/MagicSoft/Mars/macros/starvisday.C	(revision 8066)
+++ trunk/MagicSoft/Mars/macros/starvisday.C	(revision 8066)
@@ -0,0 +1,151 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 10/2006 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2004-2006
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// starvisday.C
+//
+// displays the star visibility of several stars for one day
+//
+// See the code for ducumentation and setup
+//
+///////////////////////////////////////////////////////////////////////////
+
+void starvisday()
+{
+    // Date (UTC) for which to get the visibility plot
+    MTime time(-1); // -1 means NOW
+
+    // Setup a different time as you like
+    // time.Set(2006, 10, 10);
+
+    // Current observatory (see class reference of MObservatory)
+    const MObservatory obs(MObservatory::kMagic1);
+
+    // The class contaning the catalog
+    MAstroCatalog stars;
+    stars.SetObservatory(obs);
+    stars.SetTime(time);
+
+    // Read the stars from a star catalog. The catalogs can be downloaded
+    // from the Mars web page. For more information see class reference.
+    stars.ReadXephem("/magic/datacenter/setup/magic_favorites.edb");
+
+    // Mark the stars you would like to display (see the names in the catalog)
+    stars.MarkObject("CrabNebula");
+    stars.MarkObject("1ES1218+304");
+    stars.MarkObject("1ES1426+428");
+    stars.MarkObject("Mrk421");
+    stars.MarkObject("Mrk501");
+    stars.MarkObject("1ES1959+650");
+    stars.MarkObject("1ES2344+514");
+
+    // --------------------------------------------------------------------------
+    //
+    //  Start producing the nice plot
+    //
+
+    // open and setup a new canvas
+    TCanvas *c = new TCanvas;
+    c->SetBorderMode(0);
+    c->SetFillColor(kWhite);
+    c->SetFrameBorderMode(0);
+    c->SetFrameFillStyle(0);
+
+    c->SetGridx();
+    c->SetGridy();
+
+    // Draw the twilight and dark time
+    TBox box;
+    box.SetFillStyle(4100);
+    for (int i=0; i<4; i++)
+    {
+        double set = obs.GetSunRiseSet(time.GetMjd()-1, -6*i)[1];
+        double ris = obs.GetSunRiseSet(time.GetMjd(),   -6*i)[0];
+
+        box.SetFillColor(19-i);
+        box.DrawBox(MTime(set).GetAxisTime(),  5,
+                    MTime(ris).GetAxisTime(), 90);
+    }
+
+    // Setup the TGraph which is drawn
+    TGraph g;
+    g.SetTitle(Form("Visibility at %s, %s",
+                    obs.GetObservatoryName().Data(),
+                    time.GetStringFmt("%A %e.%B %Y").Data()));
+    g.SetLineWidth(2);
+
+    // Some helper to iterate these three colors
+    Int_t col[] = { kBlack, kBlue, kRed };
+
+    // Loop over all stars in the catalog
+    int k=0;
+    TIter Next(stars.GetList());
+    TObject *o=0;
+    while ((o=Next()))
+    {
+        // Check if the star was previously marked
+        if (!o->TestBit(1<<14))
+            continue;
+
+        // Set graph name to object name
+        g.SetName(o->GetName());
+
+        // produce visibility curve
+        stars.GetVisibilityCurve(g);
+
+        // Setup description
+        TText txt;
+        txt.SetTextFont(102);
+        txt.SetTextSize(0.03);
+        txt.SetTextColor(col[k%3]);
+
+        // Setup color and style of TGraph
+        g.SetLineColor(col[k%3]);
+        g.SetLineStyle(1+k/3);
+
+        // Draw TGraph
+        g.DrawClone(k++?"c":"ac")->SetBit(kCanDelete);
+
+        // Search for culmination
+        Long64_t max = TMath::LocMax(g.GetN(), g.GetY());
+
+        // draw name at culmination
+        txt.DrawText(g.GetX()[max]-1.0*3600, g.GetY()[max]+1, o->GetName());
+    }
+
+    c->Modified();
+    c->Update();
+
+    // Draw a line for the "best observation conditions"
+    TLine line;
+    line.SetLineWidth(2);
+    line.SetLineStyle(9);
+    line.SetLineColor(13);
+
+    TAxis &axe = *g.GetHistogram()->GetXaxis();
+    line.DrawLine(axe.GetBinLowEdge(axe.GetFirst()), 65,
+                  axe.GetBinLowEdge(axe.GetLast()),  65);
+
+}
Index: trunk/MagicSoft/Mars/macros/starvisyear.C
===================================================================
--- trunk/MagicSoft/Mars/macros/starvisyear.C	(revision 8066)
+++ trunk/MagicSoft/Mars/macros/starvisyear.C	(revision 8066)
@@ -0,0 +1,197 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 10/2006 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2004-2006
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// starvisyear.C
+//
+// displays the star visibility along one year
+//
+// See the code for ducumentation and setup
+//
+///////////////////////////////////////////////////////////////////////////
+
+void starvisyear()
+{
+    // Setup the observatory location (see MObservatory for details)
+    MObservatory obs(MObservatory::kTuorla);;
+
+    // Setup the start time of the year (365 days) to be displayed
+    MTime time(-1);  // -1 mean NOW
+
+    // Setup a different time if you like
+    time.Set(2006, 1, 1, 0);
+
+    // Setup right ascension and declination of the source to display
+    const Double_t ra  = MAstro::Hms2Rad(5, 34, 31.9);
+    const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0);
+
+    // Setup the name of the source
+    TString source("CrabNebula");
+
+    // Setup palette you would like to see (99 is fixed)
+    // for more details see MH::SetPalette
+    MH::SetPalette("glow2", 99);
+
+    // --------------------------------------------------------------------------
+    //
+    //  Start producing the data for the plot
+    //
+
+    // Setup the source in the appropriate format
+    MVector3 v;
+    v.SetRaDec(ra, dec);
+
+    // For simplicity get mjd of time
+    Double_t mjd = time.GetMjd();
+
+    // Setup axis ranges
+    Double_t first = time.GetAxisTime();
+    Double_t last  = MTime(mjd+365).GetAxisTime();
+
+    Int_t h0 = 13-obs.GetLongitudeDeg()/15;
+
+    // Define histograms
+    TH2D hist( "1", "", 365, first, last, 24*12, first+h0*60*60, first+(h0+24)*60*60);//h0/24.+1, (h0+24)/24.+1);
+    TH2D hmoon("2", "", 365, first, last, 24*12, first+h0*60*60, first+(h0+24)*60*60);//h0/24.+1, (h0+24)/24.+1);
+
+    // Fill histograms
+    TGraph sunset[4], sunrise[4];
+    for (int x=0; x<365; x++)
+    {
+        // Get moon phase and axis time for mjd+x
+        Double_t moon = MAstro::GetMoonPhase(mjd+x);
+        Double_t tmx  = MTime(mjd+x).GetAxisTime();
+
+        // get sunrise and sunset for the current day
+        Double_t sunst[4], sunri[4];
+        for (int i=0; i<4; i++)
+        {
+            // get sunset and sunrise of next day
+            sunri[i] = obs.GetSunRiseSet(mjd+x+1,-18+6*i)[0];
+            sunst[i] = obs.GetSunRiseSet(mjd+x,  -18+6*i)[1];
+
+            // fill both into the TGraphs
+            sunset[i].SetPoint( sunset[i].GetN(),  tmx, MTime(sunst[i]).GetAxisTime()-x*24*60*60);
+            sunrise[i].SetPoint(sunrise[i].GetN(), tmx, MTime(sunri[i]).GetAxisTime()-x*24*60*60);
+        }
+
+        // If nautical twilight doesn#t take place skip the rest
+        if (sunri[1]<0 || sunst[1]<0)
+            continue;
+
+        // Now calculate in steps of five minutes
+        for (int hor=0; hor<24*12; hor++)
+        {
+            Double_t hr = hor/12. + h0;
+            Double_t offset = x + hr/24.;
+
+            // mjd of the current time
+            MTime tm(mjd+offset);
+
+            // Check if current time is within darkness
+            if (tm.GetMjd()>sunri[1] || tm.GetMjd()<sunst[1])
+                continue;
+
+            // Initialize conversion from sky coordinates to local coordinates
+            MAstroSky2Local conv(tm.GetGmst(), obs);
+
+            // get moon position on the sky
+            Double_t moonra, moondec;
+            MAstro::GetMoonRaDec(tm.GetMjd(), moonra, moondec);
+
+            // calculate moon position as seen by the telescope
+            v.SetRaDec(moonra, moondec);
+            v *= conv;
+
+            // check if moon is above or elow horizont
+            if (v.Theta()*TMath::RadToDeg()<90)
+                moon = 0;
+
+            // fill moon visibility into hostpogram
+            hmoon.SetBinContent(x+1, hor+1, moon);
+
+            // calculate source position as seen by the telescope
+            v.SetRaDec(ra, dec);
+            v *= conv;
+
+            // fill altitude of source into histogram
+            hist.SetBinContent(x+1, hor+1, v.Theta()*TMath::RadToDeg());
+        }
+    }
+
+    // --------------------------------------------------------------------------
+    //
+    //  Start producing the nice plot
+    //
+
+    // Setup canvas
+    TCanvas *c = new TCanvas;
+    c->SetBorderMode(0);
+    c->SetGridx();
+    c->SetGridy();
+
+    // Setup histogram
+    TString name = obs.GetObservatoryName();
+    hist.SetTitle(Form("Zenith distance of %s at %s", source.Data(), name.Data()));
+
+    hist.SetXTitle("Day");
+    hist.SetYTitle("UTC");
+
+    hist.GetXaxis()->CenterTitle();
+    hist.GetYaxis()->CenterTitle();
+
+    hist.GetXaxis()->SetTimeFormat("%d/%m/%y %F1995-01-01 00:00:00 GMT");
+    hist.GetXaxis()->SetTimeDisplay(1);
+    hist.GetXaxis()->SetLabelSize(0.033);
+
+    hist.GetYaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
+    hist.GetYaxis()->SetTimeDisplay(1);
+    hist.GetYaxis()->SetLabelSize(0.033);
+    hist.GetYaxis()->SetTitleOffset(1.3);
+
+    hist.SetContour(99);
+    hist.SetMinimum(0);
+    hist.SetMaximum(90);
+
+    hist.SetStats(kFALSE);
+
+    // draw histograms
+    hist.DrawCopy("colz");
+    hmoon.DrawCopy("scat=7 same");
+
+    // Draw rise and set time of sun
+    Int_t style[] = { kSolid, 5, 4, kDotted };
+    for (int i=0; i<4; i++)
+    {
+        sunset[i].SetLineColor(kBlue);
+        sunrise[i].SetLineColor(kBlue);
+        sunset[i].SetLineWidth(2);
+        sunrise[i].SetLineWidth(2);
+        sunset[i].SetLineStyle(style[i]);
+        sunrise[i].SetLineStyle(style[i]);
+        sunset[i].DrawClone("L");
+        sunrise[i].DrawClone("L");
+    }
+}
Index: trunk/MagicSoft/Mars/mastro/AstroIncl.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/AstroIncl.h	(revision 8065)
+++ trunk/MagicSoft/Mars/mastro/AstroIncl.h	(revision 8066)
@@ -2,4 +2,5 @@
 
 #include <TArrayC.h>
+#include <TArrayD.h>
 #include "MArrayB.h"
 #include "MArrayS.h"
Index: trunk/MagicSoft/Mars/mastro/MAstro.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstro.cc	(revision 8065)
+++ trunk/MagicSoft/Mars/mastro/MAstro.cc	(revision 8066)
@@ -33,4 +33,5 @@
 #include <iostream>
 
+#include <TArrayD.h>  // TArrayD
 #include <TVector3.h> // TVector3
 
@@ -585,4 +586,207 @@
 // --------------------------------------------------------------------------
 //
+// Returns right ascension and declination [rad] of the sun at the
+// given mjd (ra, dec).
+//
+// returns the mean longitude [rad].
+//
+// from http://xoomer.alice.it/vtomezzo/sunriset/formulas/index.html
+//
+Double_t MAstro::GetSunRaDec(Double_t mjd, Double_t &ra, Double_t &dec)
+{
+    const Double_t T = (mjd-51544.5)/36525;// +  (h-12)/24.0;
+
+    const Double_t T2 = T<0 ? -T*T : T*T;
+    const Double_t T3 = T*T*T;
+
+    // Find the ecliptic longitude of the Sun
+
+    // Geometric mean longitude of the Sun
+    const Double_t L = 280.46646 + 36000.76983*T + 0.0003032*T2;
+
+    // mean anomaly of the Sun
+    Double_t g = 357.52911 + 35999.05029*T - 0.0001537*T2;
+    g *= TMath::DegToRad();
+
+    // Longitude of the moon's ascending node
+    Double_t omega = 125.04452 - 1934.136261*T + 0.0020708*T2 + T3/450000;
+    omega *= TMath::DegToRad();
+
+    const Double_t coso = cos(omega);
+    const Double_t sino = sin(omega);
+
+    // Equation of the center
+    const Double_t C = (1.914602 - 0.004817*T - 0.000014*T2)*sin(g) +
+        (0.019993 - 0.000101*T)*sin(2*g) + 0.000289*sin(3*g);
+
+    // True longitude of the sun
+    const Double_t tlong = L + C;
+
+    // Apperent longitude of the Sun (ecliptic)
+    Double_t lambda = tlong - 0.00569 - 0.00478*sino;
+    lambda *= TMath::DegToRad();
+
+    // Obliquity of the ecliptic
+    Double_t obliq = 23.4392911 - 0.01300416667*T - 0.00000016389*T2 + 0.00000050361*T3 + 0.00255625*coso;
+    obliq *= TMath::DegToRad();
+
+    // Find the RA and DEC of the Sun
+    const Double_t sinl =  sin(lambda);
+
+    ra  = atan2(cos(obliq) * sinl, cos(lambda));
+    dec = asin(sin(obliq) * sinl);
+
+    return L*TMath::DegToRad();
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns right ascension and declination [rad] of the moon at the
+// given mjd (ra, dec).
+//
+void MAstro::GetMoonRaDec(Double_t mjd, Double_t &ra, Double_t &dec)
+{
+    // Mean Moon orbit elements as of 1990.0
+    const Double_t l0 = 318.351648 * TMath::DegToRad();
+    const Double_t P0 =  36.340410 * TMath::DegToRad();
+    const Double_t N0 = 318.510107 * TMath::DegToRad();
+    const Double_t i  =   5.145396 * TMath::DegToRad();
+
+    Double_t sunra, sundec, g;
+    {
+        const Double_t T = (mjd-51544.5)/36525;// +  (h-12)/24.0;
+        const Double_t T2 = T<0 ? -T*T : T*T;
+
+        GetSunRaDec(mjd, sunra, sundec);
+
+        // mean anomaly of the Sun
+        g = 357.52911 + 35999.05029*T - 0.0001537*T2;
+        g *= TMath::DegToRad();
+    }
+
+    const Double_t sing   = sin(g)*TMath::DegToRad();
+
+    const Double_t D      = (mjd-47891) * TMath::DegToRad();
+    const Double_t l      =    13.1763966*D + l0;
+    const Double_t MMoon  = l  -0.1114041*D - P0; // Moon's mean anomaly M
+    const Double_t N      = N0 -0.0529539*D;      // Moon's mean ascending node longitude
+
+    const Double_t C      = l-sunra;
+    const Double_t Ev     = 1.2739 * sin(2*C-MMoon) * TMath::DegToRad();
+    const Double_t Ae     = 0.1858 * sing;
+    const Double_t A3     = 0.37   * sing;
+    const Double_t MMoon2 = MMoon+Ev-Ae-A3;  // corrected Moon anomaly
+
+    const Double_t Ec     = 6.2886 * sin(MMoon2)  * TMath::DegToRad();  // equation of centre
+    const Double_t A4     = 0.214  * sin(2*MMoon2)* TMath::DegToRad();
+    const Double_t l2     = l+Ev+Ec-Ae+A4; // corrected Moon's longitude
+
+    const Double_t V      = 0.6583 * sin(2*(l2-sunra)) * TMath::DegToRad();
+    const Double_t l3     = l2+V; // true orbital longitude;
+
+    const Double_t N2     = N -0.16*sing;
+
+    ra  = fmod( N2 + atan2( sin(l3-N2)*cos(i), cos(l3-N2) ), TMath::TwoPi() );
+    dec = asin(sin(l3-N2)*sin(i) );
+}
+
+// --------------------------------------------------------------------------
+//
+// Return Euqation of time in hours for given mjd
+//
+Double_t MAstro::GetEquationOfTime(Double_t mjd)
+{
+    Double_t ra, dec;
+    const Double_t L = fmod(GetSunRaDec(mjd, ra, dec), TMath::TwoPi());
+
+    if (L-ra>TMath::Pi())
+        ra += TMath::TwoPi();
+
+    return 24*(L - ra)/TMath::TwoPi();
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns noon time (the time of the highest altitude of the sun)
+// at the given mjd and at the given observers longitude [deg]
+//
+// The maximum altitude reached at noon time is
+//   altmax = 90.0 + dec - latit;
+//   if (dec > latit)
+//      altmax = 90.0 + latit - dec;
+// dec=Declination of the sun
+//
+Double_t MAstro::GetNoonTime(Double_t mjd, Double_t longit)
+{
+    const Double_t equation = GetEquationOfTime(TMath::Floor(mjd));
+    return 12. + equation - longit/15;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the time (in hours) between noon (the sun culmination)
+// and the sun being at height alt[deg] (90=zenith, 0=horizont)
+//
+//       civil twilight:      0deg to  -6deg
+//       nautical twilight:  -6deg to -12deg
+//       astronom twilight: -12deg to -18deg
+//
+// latit is the observers latitude in rad
+//
+// returns -1 in case the sun doesn't reach this altitude.
+// (eg. alt=0: Polarnight or -day)
+//
+// To get the sun rise/set:
+//    double timediff = MAstro::GetTimeFromNoonToAlt(mjd, latit*TMath::DegToRad(), par[0]);
+//    double noon     = MAstro::GetNoonTime(mjd, longit);
+//    double N        = TMath::Floor(mjd)+noon/24.;
+//    double risetime = N-timediff/24.;
+//    double settime  = N+timediff/24.;
+//
+Double_t MAstro::GetTimeFromNoonToAlt(Double_t mjd, Double_t latit, Double_t alt)
+{
+    Double_t ra, dec;
+    GetSunRaDec(mjd, ra, dec);
+
+    const Double_t h = alt*TMath::DegToRad();
+
+    const Double_t arg = (sin(h) - sin(latit)*sin(dec))/(cos(latit)*cos(dec));
+
+    return TMath::Abs(arg)>1 ? -1 : 12*acos(arg)/TMath::Pi();
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the time of the sunrise/set calculated before and after
+// the noon of floor(mjd) (TO BE IMPROVED)
+//
+// Being longit and latit the longitude and latitude of the observer
+// in deg and alt the hight above or below the horizont in deg.
+//
+//       civil twilight:      0deg to  -6deg
+//       nautical twilight:  -6deg to -12deg
+//       astronom twilight: -12deg to -18deg
+//
+// A TArrayD(2) is returned with the the mjd of the sunrise in
+// TArray[0] and the mjd of the sunset in TArrayD[1].
+//
+TArrayD MAstro::GetSunRiseSet(Double_t mjd, Double_t longit, Double_t latit, Double_t alt)
+{
+    const Double_t timediff = MAstro::GetTimeFromNoonToAlt(mjd, latit*TMath::DegToRad(), alt);
+    const Double_t noon     = MAstro::GetNoonTime(mjd, longit);
+
+    const Double_t N = TMath::Floor(mjd)+noon/24.;
+
+    const Double_t rise = timediff<0 ? N-0.5 : N-timediff/24.;
+    const Double_t set  = timediff<0 ? N+0.5 : N+timediff/24.;
+
+    TArrayD rc(2);
+    rc[0] = rise;
+    rc[1] = set;
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
 // Returns the distance in x,y between two polar-vectors (eg. Alt/Az, Ra/Dec)
 // projected on aplain in a distance dist. For Magic this this the distance
Index: trunk/MagicSoft/Mars/mastro/MAstro.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstro.h	(revision 8065)
+++ trunk/MagicSoft/Mars/mastro/MAstro.h	(revision 8066)
@@ -9,4 +9,5 @@
 #endif
 
+class TArrayD;
 class TVector3;
 class MTime;
@@ -74,7 +75,16 @@
     static Double_t RotationAngle(Double_t sinl, Double_t cosl, Double_t theta, Double_t phi);
 
+    static void     GetMoonRaDec(Double_t mjd, Double_t &ra, Double_t &dec);
+
     static Double_t GetMoonPhase(Double_t mjd);
     static Double_t GetMoonPeriod(Double_t mjd);
     static Int_t    GetMagicPeriod(Double_t mjd);
+
+    // Estimate some parameters around the sun
+    static Double_t GetSunRaDec(Double_t mjd, Double_t &ra, Double_t &dec);
+    static Double_t GetEquationOfTime(Double_t mjd);
+    static Double_t GetNoonTime(Double_t mjd, Double_t longit);
+    static Double_t GetTimeFromNoonToAlt(Double_t mjd, Double_t latit, Double_t alt);
+    static TArrayD  GetSunRiseSet(Double_t mjd, Double_t longit, Double_t latit, Double_t alt=0);
 
     // Get distance between v1 and v0 in a plain perpendicular to v0 in distance dist
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 8065)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 8066)
@@ -141,4 +141,6 @@
 #include <TPaveText.h>  // TPaveText
 
+#include <TGraph.h>
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -312,5 +314,5 @@
             continue;
 
-        if (epoch!="2000")
+        if (epoch.Atoi()!=2000)
         {
             gLog << warn << "Epoch != 2000... skipped." << endl;
@@ -646,4 +648,63 @@
     fList.AddLast(star);
     return 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the visibility curve (altitude vs time) for the current time
+// and observatory for the catalog entry with name name.
+// If name==0 the name of the TGraph is taken instead.
+// The day is divided into as many points as the graph has
+// points. If the graph has no points the default is 96.
+//
+void MAstroCatalog::GetVisibilityCurve(TGraph &g, const char *name) const
+{
+    if (!fTime || !fObservatory)
+    {
+        g.Set(0);
+        return;
+    }
+
+    MVector3 *star = static_cast<MVector3*>(FindObject(name ? name : g.GetName()));
+    if (!star)
+        return;
+
+    const Double_t mjd = TMath::Floor(fTime->GetMjd());
+    const Double_t lng = fObservatory->GetLongitudeDeg()/360;
+
+    if (g.GetN()==0)
+        g.Set(96);
+
+    for (int i=0; i<g.GetN(); i++)
+    {
+        const Double_t offset = (Double_t)i/g.GetN() - 0.5;
+
+        const MTime tm(mjd-lng+offset);
+
+        MVector3 v(*star);
+        v *= MAstroSky2Local(tm.GetGmst(), *fObservatory);
+
+        g.SetPoint(i, tm.GetAxisTime(), 90-v.Theta()*TMath::RadToDeg());
+    }
+
+    TH1   &h = *g.GetHistogram();
+    TAxis &x = *h.GetXaxis();
+    TAxis &y = *h.GetYaxis();
+
+    y.SetTitle("Altitude [\\circ]");
+    y.CenterTitle();
+
+    x.SetTitle("UTC");
+    x.CenterTitle();
+    x.SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
+    x.SetTimeDisplay(1);
+    x.SetLabelSize(0.033);
+
+    const Double_t atm = MTime(mjd).GetAxisTime();
+
+    x.SetRangeUser(atm-(0.5+lng)*24*60*60+15*60, atm+(0.5-lng)*24*60*60-15*60);
+
+    g.SetMinimum(5);
+    g.SetMaximum(90);
 }
 
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.h	(revision 8065)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.h	(revision 8066)
@@ -22,4 +22,5 @@
 class TArrayI;
 class TGToolTip;
+class TGraph;
 
 class MAttLine : public TObject, public TAttLine
@@ -69,4 +70,5 @@
 protected:
     enum {
+        kMark         = BIT(14), // A mark for the sources in the list
         kHasChanged   = BIT(15), // Display has changed
         kGuiActive    = BIT(16), // GUI is interactive
@@ -152,4 +154,9 @@
     TList *GetList() { return &fList; } // Return list of stars
     UInt_t GetNumStars() const { return fList.GetEntries(); }
+    TObject *FindObject(const char *name) const { return fList.FindObject(name); }
+    TObject *FindObject(const TObject *obj) const { return fList.FindObject(obj); }
+    void MarkObject(const char *name) const { TObject *o=FindObject(name); if (o) o->SetBit(kMark); }
+
+    void GetVisibilityCurve(TGraph &g, const char *name=0) const;
 
     // TObject
Index: trunk/MagicSoft/Mars/mastro/MObservatory.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MObservatory.cc	(revision 8065)
+++ trunk/MagicSoft/Mars/mastro/MObservatory.cc	(revision 8066)
@@ -34,4 +34,5 @@
 #include "MObservatory.h"
 
+#include <TArrayD.h>
 #include <TVector3.h>
 
@@ -92,4 +93,11 @@
         fObservatoryName = "Wuerzburg City";
         break;
+
+    case kTuorla:
+        fLatitude  = MAstro::Dms2Rad(60, 24, 57.0);
+        fLongitude = MAstro::Dms2Rad(22, 26, 42.0);
+        fHeight    = 53;
+        fObservatoryName = "Tuorla";
+        break;
     }
 
@@ -131,4 +139,18 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Get the time (as mjd) of sunrise/sunset at the day floor(mjd)
+// above/below alt[deg]
+//
+// For more information see MAstro::GetSunRiseSet
+//
+// A TArrayD(2) is returned with the sunrise in TArray[0] and the
+// sunset in TArrayD[1].
+//
+TArrayD MObservatory::GetSunRiseSet(Double_t mjd, Double_t alt) const
+{
+    return MAstro::GetSunRiseSet(mjd, GetLongitudeDeg(), GetLatitudeDeg(), alt);
+}
 
 // --------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mastro/MObservatory.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/MObservatory.h	(revision 8065)
+++ trunk/MagicSoft/Mars/mastro/MObservatory.h	(revision 8066)
@@ -7,4 +7,5 @@
 
 class MTime;
+class TArrayD;
 
 class MObservatory : public MParContainer
@@ -14,5 +15,6 @@
     {
         kMagic1,
-        kWuerzburgCity
+        kWuerzburgCity,
+        kTuorla
     };
 
@@ -67,4 +69,6 @@
     Double_t GetHeight() const          { return fHeight; }
 
+    TArrayD GetSunRiseSet(Double_t mjd, Double_t alt=0) const;
+
     void RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const;
     Double_t RotationAngle(Double_t theta, Double_t phi) const;
Index: trunk/MagicSoft/Mars/mbase/MTime.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTime.h	(revision 8065)
+++ trunk/MagicSoft/Mars/mbase/MTime.h	(revision 8066)
@@ -97,4 +97,5 @@
 
     // Getter functions
+    Double_t GetJD() const { return GetMjd()+2400000.5; }
     Double_t GetMjd() const;
     Double_t GetGmst() const;
Index: trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc	(revision 8065)
+++ trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc	(revision 8066)
@@ -19,5 +19,5 @@
 !   Author(s): Harald Kornmayer 1/2001
 !
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 8065)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 8066)
@@ -105,5 +105,6 @@
 
     // This is a trick to remove TH1 entries from the context menu
-    TH1 *Rebin(Int_t ngroup=2, const char*newname="") { return this; }
+    TH1 *Rebin(Int_t ngroup=2, const char *newname="", const Double_t *bin=0) { return this; }
+    TH1 *Rebin(Int_t ngroup=2, const char *newname="") { return this; }
     void DrawPanel() {}
 
Index: trunk/MagicSoft/include-Classes/MMcFormat/MMcRunHeader.cxx
===================================================================
--- trunk/MagicSoft/include-Classes/MMcFormat/MMcRunHeader.cxx	(revision 8065)
+++ trunk/MagicSoft/include-Classes/MMcFormat/MMcRunHeader.cxx	(revision 8066)
@@ -126,4 +126,6 @@
     fShowerPhiMax = 0.0;
     fShowerPhiMin = 0.0;
+
+    fImpactMax = -1;
 
     fCWaveLower = 0.0;
