Index: /trunk/MagicSoft/Mars/mastro/MObservatory.cc
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MObservatory.cc	(revision 3327)
+++ /trunk/MagicSoft/Mars/mastro/MObservatory.cc	(revision 3328)
@@ -27,4 +27,7 @@
 //
 // MObservatory
+//
+// BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM IS BASED
+// ON IT!
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -60,8 +63,15 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM IS BASED
+// ON IT!
+//
 void MObservatory::SetLocation(LocationName_t name)
 {
     switch (name)
     {
+        // BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM
+        // IS BASED ON IT!
     case kMagic1:
         // Values taken from the GPS Receiver (avg 20h)
Index: /trunk/MagicSoft/Mars/merpp.cc
===================================================================
--- /trunk/MagicSoft/Mars/merpp.cc	(revision 3327)
+++ /trunk/MagicSoft/Mars/merpp.cc	(revision 3328)
@@ -6,4 +6,5 @@
 
 #include "MRawFileRead.h"
+#include "MSqlInsertRun.h"
 #include "MRawFileWrite.h"
 
@@ -60,5 +61,5 @@
     gLog << all << endl;
     gLog << "Sorry the usage is:" << endl;
-    gLog << "   merpp [-h] [-?] [-a0] [-vn] [-cn] [-u1]" << endl;
+    gLog << "   merpp [-h] [-?] [-a] [-vn] [-cn] [-u]" << endl;
     gLog << "         inputfile[.rep,[.raw],[.txt]] [outputfile[.root]]" << endl << endl;
     gLog << "     inputfile.raw:  Magic DAQ binary file." << endl;
@@ -70,12 +71,13 @@
     gLog << "     -u, --update:                    Update file" << endl;
     gLog << "     -a, --no-colors:                 Do not use Ansii color codes" << endl;
+    gLog << "     --sql=mysql://user:password@url  Insert run into database <raw data only>" << endl;
     gLog << "     --start=yyyy-mm-dd/hh:mm:ss.mmm: Start event time for merpping report files" << endl;
     gLog << "     --stop=yyyy-mm-dd/hh:mm:ss.mmm:  Stop  event time for merpping report files" << endl;
-    gLog << "     --run=#:                         Only merpp data corresponding to this run number" << endl;
+    gLog << "     --run=#:                         Only data corresponding to this run number" << endl;
     gLog << "     -?, -h, --help:                  This help" << endl << endl;
     gLog << "   REMARK: At the moment you can process a .raw _or_ a .rep file, only!" << endl << endl;
 }
 
-// FIXME: Move to MTime (maybe 'InterpreteCmdline'
+// FIXME: Move to MTime (maybe 'InterpreteCmdline')
 MTime AnalyseTime(TString str)
 {
@@ -118,5 +120,6 @@
     kTimeStop.SetName("MTimeStop");
 
-    const Int_t kRunNumber = arg.HasOption("--run=") ? arg.GetIntAndRemove("--run=") : -1;
+    const Int_t   kRunNumber   = arg.HasOption("--run=") ? arg.GetIntAndRemove("--run=") : -1;
+    const TString kSqlDataBase(arg.GetStringAndRemove("--sql="));
 
     if (kTimeStart)
@@ -142,6 +145,7 @@
     const Bool_t isreport = kNamein.EndsWith(".rep");
     const Bool_t isdc     = kNamein.EndsWith(".txt");
-
-    if (!kNamein.EndsWith(".raw") && !isreport && !isdc)
+    const Bool_t israw    = !isreport && !israw;
+
+    if (!kNamein.EndsWith(".raw") && israw)
         kNamein += ".raw";
 
@@ -151,4 +155,7 @@
     if (!kNameout.EndsWith(".root"))
         kNameout += ".root";
+
+    if (!kSqlDataBase.IsNull() && !israw)
+        gLog << warn << "WARNING - Option '--sql=' only valid for raw-files... ignored." << endl;
 
     //
@@ -292,4 +299,10 @@
     if (filter)
         tasks.AddToList(filter);
+    if (israw && !kSqlDataBase.IsNull())
+    {
+        MSqlInsertRun *ins = new MSqlInsertRun(kSqlDataBase);
+        ins->SetUpdate();
+        tasks.AddToList(ins);
+    }
     tasks.AddToList(write);
 
@@ -319,4 +332,2 @@
     return 0;
 }
-
-
Index: /trunk/MagicSoft/Mars/mraw/MRawFileRead.h
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 3327)
+++ /trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 3328)
@@ -20,4 +20,6 @@
     ~MRawFileRead();
 
+    const TString &GetFileName() const { return fFileName; }
+
     ClassDef(MRawFileRead, 0)	// Task to read the raw data binary file
 };
Index: /trunk/MagicSoft/Mars/msql/MSQLServer.cc
===================================================================
--- /trunk/MagicSoft/Mars/msql/MSQLServer.cc	(revision 3328)
+++ /trunk/MagicSoft/Mars/msql/MSQLServer.cc	(revision 3328)
@@ -0,0 +1,533 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 2/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+////////////////////////////////////////////////////////////////////////
+//
+//  MSQLServer
+//
+//  Using this instead of a TSQLServer gives the possibility to
+//  browse a database server through the TBrowser and it will offer
+//  many features usefull working with relational tables.
+//
+////////////////////////////////////////////////////////////////////////
+#include "MSQLServer.h"
+
+#include <iostream>
+#include <iomanip>
+
+#include <TROOT.h>
+
+#include <TH1.h>
+
+#include <TSQLResult.h>
+#include <TSQLServer.h>
+#include <TSQLRow.h>
+
+#include <TBrowser.h>
+
+ClassImp(MSQLServer);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Used in virtual function TObject::Browse() to create the
+//
+void MSQLServer::BrowseColumn(TBrowser *b) /*FOLD00*/
+{
+    const TString query0(Form("EXPLAIN %s.%s %s", (const char*)fDataBase, (const char*)fTable, (const char*)fColumn));
+    const TString query1(Form("SELECT %s FROM %s.%s", (const char*)fColumn, (const char*)fDataBase, (const char*)fTable));
+
+    //cout << query0 << endl;
+    TSQLResult *res = fServ->Query(query0);
+    if (!res)
+    {
+        cout << "query - failed: " << query0 << endl;
+        return;
+    }
+
+    TSQLRow *row=res->Next();
+    const TString desc((*row)[1]);
+
+    //cout << "Column Type: " << desc << endl;
+
+    const Bool_t isnum =
+        !desc.Contains("char", TString::kIgnoreCase) &&
+        !desc.Contains("text", TString::kIgnoreCase);
+
+    cout << query1 << endl;
+    res = fServ->Query(query1);
+    if (!res)
+    {
+        cout << "query - failed: " << query1 << endl;
+        return;
+    }
+
+    TArrayD arr(2);
+    Int_t num=0;
+    Double_t max=0;
+    Double_t min=0;
+    Double_t sum=0;
+    Double_t sqr=0;
+
+    while ((row=res->Next()))
+    {
+        const TString row0((*row)[0]);
+
+        if (!isnum)
+        {
+            cout << row0 << endl;
+            continue;
+        }
+
+        if (num==arr.GetSize())
+            arr.Set(arr.GetSize()*2);
+
+        arr[num] = atof(row0.Data());
+
+        if (num==0)
+            min=max=arr[0];
+
+        if (arr[num]>max) max = arr[num];
+        if (arr[num]<min) min = arr[num];
+
+        sum += arr[num];
+        sqr += arr[num]*arr[num];
+
+        num++;
+    }
+
+    if (!isnum)
+        return;
+
+    if (max==min) max += 1;
+
+    Int_t num0 = 1;
+
+    if (num>0)
+    {
+        /*
+         cout << "Num:   " << num << endl;
+         cout << "Mean:  " << sum/num << endl;
+         cout << "Range: " << max-min << endl;
+         cout << "RMS:   " << TMath::Sqrt(sqr/num-sum*sum/num/num) << endl;
+         */
+
+        num0 = (Int_t)((max-min)*40/TMath::Sqrt(sqr/num-sum*sum/num/num));
+    }
+
+    const TString title(Form("#splitline{%s}{<%s>}", (const char*)query1, (const char*)desc));
+
+    TH1F *hist=new TH1F(fColumn, title, num0, min, max);
+    for (int i=0; i<num; i++)
+        hist->Fill(arr[i]);
+
+    //cout << "Done." << endl;
+
+    hist->Draw();
+    hist->SetBit(kCanDelete);
+}
+
+void MSQLServer::BrowseTable(TBrowser *b) /*FOLD00*/
+{
+    TSQLResult *res = fServ->GetColumns(fDataBase, fTable);
+    if (!res)
+        return;
+
+    TSQLRow *row;
+    while ((row=res->Next()))
+    {
+        TString row0((*row)[0]);
+
+        MSQLServer *sql = (MSQLServer*)fList.FindObject(Form("%s/%s/%s", (const char*)fDataBase, (const char*)fTable, (const char*)row0));
+        if (!sql)
+        {
+            sql = new MSQLColumn(fServ, fDataBase, fTable, row0);
+            fList.Add(sql);
+        }
+        b->Add(sql, row0);
+    }
+}
+
+void MSQLServer::BrowseDataBase(TBrowser *b) /*FOLD00*/
+{
+    TSQLResult *res = fServ->GetTables(fDataBase);
+    if (!res)
+        return;
+
+    TSQLRow *row;
+    while ((row=res->Next()))
+    {
+        TString row0((*row)[0]);
+
+        MSQLServer *sql = (MSQLServer*)fList.FindObject(Form("%s/%s", (const char*)fDataBase, (const char*)row0));
+        if (!sql)
+        {
+            sql = new MSQLServer(fServ, fDataBase, row0);
+            fList.Add(sql);
+        }
+        b->Add(sql, row0);
+    }
+}
+
+void MSQLServer::BrowseServer(TBrowser *b) /*FOLD00*/
+{
+    TSQLResult *res = fServ->GetDataBases();
+    if (!res)
+        return;
+
+    TSQLRow *row;
+    while ((row=res->Next()))
+    {
+        const TString row0((*row)[0]);
+
+        MSQLServer *sql = (MSQLServer*)fList.FindObject(row0);
+        if (!sql)
+        {
+            sql = new MSQLServer(fServ, row0);
+            fList.Add(sql);
+        }
+        b->Add(sql, row0);
+    }
+}
+
+void MSQLServer::PrintLine(const TArrayI &max) const /*FOLD00*/
+{
+    cout << "+" << setfill('-');
+    for (int i=0; i<max.GetSize(); i++)
+        cout << setw(max[i]+1) << "-" << "-+";
+    cout << endl;
+}
+
+void MSQLServer::PrintTable(TSQLResult *res) const /*FOLD00*/
+{
+    Int_t n = res->GetFieldCount();
+
+    TArrayI max(n);
+
+    for (int i=0; i<n; i++)
+        max[i] = strlen(res->GetFieldName(i));
+
+    TSQLRow *row;
+
+    TList rows;
+    while ((row=res->Next()))
+    {
+        for (int i=0; i<n; i++)
+            max[i] = TMath::Max((ULong_t)max[i], row->GetFieldLength(i));
+        rows.Add(row);
+    }
+
+    cout << endl;
+
+    PrintLine(max);
+
+    cout << "|" << setfill(' ');
+    for (int i=0; i<n; i++)
+        cout << setw(max[i]+1) << res->GetFieldName(i) << " |";
+    cout << endl;
+
+    PrintLine(max);
+
+    cout << setfill(' ');
+    TIter Next(&rows);
+    while ((row=(TSQLRow*)Next()))
+    {
+        cout << "|";
+        for (int i=0; i<n; i++)
+        {
+            const char *c = (*row)[i];
+            cout << setw(max[i]+1) << (c?c:"") << " |";
+        }
+        cout << endl;
+    }
+
+    PrintLine(max);
+}
+
+TString MSQLServer::GetFields() const /*FOLD00*/
+{
+    TSQLResult *res = fServ->GetColumns(fDataBase, fTable);
+    if (!res)
+        return "";
+
+    TString fields;
+
+    TSQLRow *row;
+
+    TList rows;
+    while ((row=res->Next()))
+        rows.Add(row);
+
+    TIter Next(&rows);
+    while ((row=(TSQLRow*)Next()))
+    {
+        fields += (*row)[0];
+        if (row!=rows.Last())
+            fields += ", ";
+    }
+
+    return fields;
+}
+
+void MSQLServer::PrintQuery(const char *query) const /*FOLD00*/
+{
+    TSQLResult *res = fServ->Query(query);
+    if (res)
+        PrintTable(res);
+    else
+        cout << "Query failed: " << query << endl;
+}
+
+void MSQLServer::Print(Option_t *o) const /*FOLD00*/
+{
+    switch (fType)
+    {
+    case kIsServer:
+        PrintQuery("SHOW DATABASES");
+        break;
+
+    case kIsDataBase:
+        PrintQuery(Form("SHOW TABLES FROM %s", (const char*)fDataBase));
+        break;
+
+    case kIsTable:
+        PrintQuery(Form("SELECT * FROM %s.%s", (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    case kIsColumn:
+        PrintQuery(Form("SELECT %s FROM %s.%s", (const char*)fColumn, (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    default:
+        break;
+    }
+}
+
+void MSQLServer::ShowColumns() const /*FOLD00*/
+{
+    switch (fType)
+    {
+    case kIsTable:
+        PrintQuery(Form("SHOW FULl COLUMNS FROM %s.%s", (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    case kIsColumn:
+        PrintQuery(Form("SHOW FULl COLUMNS FROM %s.%s LIKE %s", (const char*)fDataBase, (const char*)fTable, (const char*)fColumn));
+        break;
+
+    default:
+        //Print();
+        break;
+    }
+}
+
+void MSQLServer::ShowStatus() const /*FOLD00*/
+{
+    switch (fType)
+    {
+    case kIsServer:
+        PrintQuery("SHOW STATUS");
+        break;
+
+    case kIsDataBase:
+        PrintQuery(Form("SHOW TABLE STATUS FROM %s", (const char*)fDataBase));
+        break;
+
+    case kIsTable:
+        PrintQuery(Form("SHOW TABLE STATUS FROM %s LIKE %s", (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    default:
+        break;
+    }
+}
+
+void MSQLServer::ShowTableIndex() const /*FOLD00*/
+{
+    switch (fType)
+    {
+    case kIsTable:
+    case kIsColumn:
+        PrintQuery(Form("SHOW INDEX FROM %s.%s", (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    default:
+        break;
+    }
+}
+
+void MSQLServer::ShowTableCreate() const /*FOLD00*/
+{
+    switch (fType)
+    {
+    case kIsTable:
+    case kIsColumn:
+        PrintQuery(Form("SHOW CREATE TABLE %s.%s", (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    default:
+        break;
+    }
+}
+
+void MSQLServer::Close(Option_t *option) /*FOLD00*/
+{
+    if (fType==kIsServer)
+        fServ->Close(option);
+}
+
+TSQLResult *MSQLServer::Query(const char *sql) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->Query(sql) : NULL;
+}
+
+Int_t MSQLServer::SelectDataBase(const char *dbname) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->SelectDataBase(dbname) : 0;
+}
+
+TSQLResult *MSQLServer::GetDataBases(const char *wild) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->GetDataBases(wild) : NULL;
+}
+
+TSQLResult *MSQLServer::GetTables(const char *dbname, const char *wild) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->GetTables(dbname, wild) : NULL;
+}
+
+TSQLResult *MSQLServer::GetColumns(const char *dbname, const char *table, const char *wild) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->GetColumns(dbname, table, wild) : NULL;
+}
+
+Int_t MSQLServer::CreateDataBase(const char *dbname) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->CreateDataBase(dbname) : 0;
+}
+
+Int_t MSQLServer::DropDataBase(const char *dbname) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->DropDataBase(dbname) : 0;
+}
+
+Int_t MSQLServer::Reload() /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->Reload() : 0;
+}
+
+Int_t MSQLServer::Shutdown() /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->Shutdown() : 0;
+}
+
+const char *MSQLServer::ServerInfo() /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->ServerInfo() : "";
+}
+
+void MSQLServer::Init(const char *connection, const char *user, const char *password) /*FOLD00*/
+{
+    fServ = TSQLServer::Connect(connection, user, password);
+    if (fServ)
+    {
+        gROOT->GetListOfBrowsables()->Add(this, connection);
+        fType = kIsServer;
+    }
+    else
+        fType = kIsZombie;
+
+    fList.SetOwner();
+}
+
+MSQLServer::MSQLServer(const char *connection, const char *user, const char *password) /*FOLD00*/
+{
+    Init(connection, user, password);
+}
+
+MSQLServer::MSQLServer(const char *u) /*FOLD00*/
+{
+    TString url(u);
+
+    const Ssiz_t pos1 = url.First("://")+3;
+    const Ssiz_t pos2 = url.Last(':')   +1;
+    const Ssiz_t pos3 = url.First('@');
+
+    if (pos1<0 || pos2<0 || pos3<0 || pos1>pos2 || pos2>pos3)
+        return;
+
+    const TString user = url(pos1, pos2-pos1-1);
+    const TString pasw = url(pos2, pos3-pos2);
+
+    url.Remove(pos1, pos3+1-pos1);
+
+    Init(url, user, pasw);
+
+}
+
+MSQLServer::~MSQLServer() /*FOLD00*/
+{
+    Close();
+    cout << "Delete: " << GetName() << endl;
+}
+
+Bool_t MSQLServer::PrintError(const char *txt, const char *q) const /*FOLD00*/
+{
+    cout << "Fatal error acessing database: " << txt << endl;
+    cout << "Query: " << q << endl;
+    return kFALSE;
+}
+
+TString MSQLServer::GetEntry(const char *where, const char *col, const char *table) const /*FOLD00*/
+{
+    if (!fServ)
+        return "";
+
+    if (table==0)
+        table = Form("%s.%s", (const char *)fDataBase, (const char*)fTable);
+    if (col==0)
+        col = (const char *)fColumn;
+
+    const TString query(Form("SELECT %s FROM %s WHERE %s", col, table, where));
+
+    TSQLResult *res = fServ->Query(query);
+    if (!res)
+        return (PrintError("GetEntry - TSQLResult==NULL", query), "");
+
+    if (res->GetFieldCount()!=1)
+        return (PrintError("GetEntry - Number of columns != 1", query), "");
+
+    if (res->GetRowCount()>1)
+        return (PrintError("GetEntry - Number of rows > 1", query), "");
+
+    if (res->GetRowCount()==0)
+        return "";
+
+    const char *fld = res->Next()->GetField(0);
+    if (!fld)
+        return (PrintError("GetEntry - Entry is empty", query), "");
+
+    return TString(fld);
+}
Index: /trunk/MagicSoft/Mars/msql/MSQLServer.h
===================================================================
--- /trunk/MagicSoft/Mars/msql/MSQLServer.h	(revision 3328)
+++ /trunk/MagicSoft/Mars/msql/MSQLServer.h	(revision 3328)
@@ -0,0 +1,138 @@
+#ifndef MARS_MSQLServer
+#define MARS_MSQLServer
+
+#ifndef ROOT_TList
+#include <TList.h>
+#endif
+
+class TArrayI;
+class TSQLServer;
+class TSQLResult;
+
+class MSQLServer : public TObject
+{
+    TSQLServer *fServ;
+
+    TString fDataBase;
+    TString fTable;
+    TString fColumn;
+
+    TList   fList;
+
+    enum Type_t { kIsZombie, kIsServer, kIsDataBase, kIsTable, kIsColumn };
+
+    Type_t  fType;
+
+    Bool_t IsFolder() const { return kTRUE; }
+
+    Bool_t PrintError(const char *txt, const char *q) const;
+
+    void PrintLine(const TArrayI &max) const;
+    void PrintTable(TSQLResult *res) const;
+    TString GetFields() const;
+
+    void BrowseDataBase(TBrowser *b);
+    void BrowseTable(TBrowser *b);
+    void BrowseColumn(TBrowser *b);
+    void BrowseServer(TBrowser *b);
+
+    void Browse(TBrowser *b)
+    {
+        if (!b)
+            return;
+
+        switch (fType)
+        {
+        case kIsServer:   BrowseServer(b);   break;
+        case kIsDataBase: BrowseDataBase(b); break;
+        case kIsTable:    BrowseTable(b);    break;
+        case kIsColumn:   BrowseColumn(b);   break;
+        default:
+            break;
+        }
+    }
+
+    const char *GetNameDataBase() const { return fDataBase; }
+    const char *GetNameTable()    const { return Form("%s/%s",    (const char*)fDataBase, (const char*)fTable); }
+    const char *GetNameColumn()   const { return Form("%s/%s/%s", (const char*)fDataBase, (const char*)fTable, (const char*)fColumn); }
+
+    const char *GetName() const
+    {
+        switch (fType)
+        {
+        case kIsDataBase: return GetNameDataBase();
+        case kIsTable:    return GetNameTable();
+        case kIsColumn:   return GetNameColumn();
+        default:          return "n/a";
+        }
+    }
+
+    void Init(const char *connection, const char *user, const char *password);
+
+public:
+    MSQLServer(TSQLServer *serv, const char *dbname=0, const char *tname=0, const char *col=0)
+        : fServ(serv), fDataBase(dbname), fTable(tname), fColumn(col)
+    {
+        fList.SetOwner();
+
+        fType = kIsColumn;
+
+        if (fColumn.IsNull())
+            fType = kIsTable;
+
+        if (fTable.IsNull() && fColumn.IsNull())
+            fType = kIsDataBase;
+
+        if (fDataBase.IsNull() && fTable.IsNull() && fColumn.IsNull())
+            fType = kIsZombie;
+
+        if (!serv)
+            fType = kIsZombie;
+    }
+
+    MSQLServer(const char *connection, const char *user, const char *password);
+    MSQLServer(const char *link);
+
+    ~MSQLServer();
+
+    void Print(Option_t *o) const;
+    void Print() const { Print(""); } //*MENU*
+    void PrintQuery(const char *query) const; //*MENU*
+    void ShowColumns() const; //*MENU*
+    void ShowStatus() const; //*MENU*
+    void ShowTableIndex() const; //*MENU*
+    void ShowTableCreate() const; //*MENU*
+    void ShowVariables() const { PrintQuery("SHOW VARIABLES"); } //*MENU*
+    void ShowProcesses() const { PrintQuery("SHOW PROCESSLIST"); } //*MENU*
+
+    void Close(Option_t *option="");
+    TSQLResult *Query(const char *sql);
+    Int_t       SelectDataBase(const char *dbname);
+    TSQLResult *GetDataBases(const char *wild = 0);
+    TSQLResult *GetTables(const char *dbname, const char *wild = 0);
+    TSQLResult *GetColumns(const char *dbname, const char *table, const char *wild = 0);
+    Int_t       CreateDataBase(const char *dbname);
+    Int_t       DropDataBase(const char *dbname);
+    Int_t       Reload();
+    Int_t       Shutdown();
+    const char *ServerInfo();
+
+    TString     GetEntry(const char *where, const char *col=0, const char *table=0) const;
+
+    ClassDef(MSQLServer, 0) // An enhancement of TSQLServer
+};
+
+class MSQLColumn : public MSQLServer
+{
+private:
+    Bool_t IsFolder() const { return kFALSE; }
+
+public:
+    MSQLColumn(TSQLServer *serv, const char *dbname=0, const char *tname=0, const char *col=0)
+        : MSQLServer(serv, dbname, tname, col)
+    {
+    }
+    ClassDef(MSQLColumn, 0) // A workarount to let MSQLServer return kFALSE for IsFolder
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/msql/MSqlInsertRun.cc
===================================================================
--- /trunk/MagicSoft/Mars/msql/MSqlInsertRun.cc	(revision 3328)
+++ /trunk/MagicSoft/Mars/msql/MSqlInsertRun.cc	(revision 3328)
@@ -0,0 +1,512 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 2/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+////////////////////////////////////////////////////////////////////////
+//
+//  MSqlInsertRun
+//
+//  Input Containers:
+//   MRawRunHeader
+//
+//  Output Containers:
+//    -/-
+//
+////////////////////////////////////////////////////////////////////////
+#include "MSqlInsertRun.h"
+
+#include <TSystem.h>
+
+#include <TSQLResult.h>
+#include <TSQLRow.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+#include "MRawFileRead.h"
+#include "MRawRunHeader.h"
+
+#include "MSQLServer.h"
+
+ClassImp(MSqlInsertRun);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+MSqlInsertRun::MSqlInsertRun(const char *db, const char *user, const char *pw)
+    : fIsUpdate(kFALSE)
+{
+    fName  = "MSqlInsertRun";
+    fTitle = "Write run into database";
+
+    *fLog << dbg << "Connecting to: " << db << " as " << user << " <" << pw << ">" << endl;
+
+    fSqlServer = new MSQLServer(db, user, pw);
+}
+
+// --------------------------------------------------------------------------
+//
+MSqlInsertRun::MSqlInsertRun(const char *u)
+    : fSqlServer(0), fIsUpdate(kFALSE)
+{
+    fName  = "MSqlInsertRun";
+    fTitle = "Write run into database";
+
+    fSqlServer = new MSQLServer(u); //::Connect(url, user, pasw);
+}
+
+MSqlInsertRun::~MSqlInsertRun()
+{
+    if (fSqlServer)
+        delete fSqlServer;
+}
+
+Bool_t MSqlInsertRun::PrintError(const char *txt, const char *q) const
+{
+    *fLog << err;
+    *fLog << "Fatal error acessing database: " << txt << endl;
+    fLog->Underline();
+    *fLog << "Query:" << flush << " " << q << endl;
+    return kFALSE;
+}
+
+TString MSqlInsertRun::GetEntry(const char *table, const char *col, const char *where)
+{
+    return fSqlServer->GetEntry(where, col, table);
+}
+
+Bool_t MSqlInsertRun::IsRunExisting(MRawRunHeader *h, Bool_t &exist)
+{
+    exist = kFALSE;
+
+    const TString str(GetEntry("RunData", "fRunNumber", Form("fRunNumber=%d", h->GetRunNumber())));
+    if (str.IsNull())
+        return kFALSE;
+
+    exist = kTRUE;
+    return kTRUE;
+}
+
+Int_t MSqlInsertRun::GetKey(const char *table, const char *where)
+{
+    const TString str(GetEntry(table, Form("f%sKEY", table), where));
+
+    Int_t key;
+    return sscanf(str.Data(), "%d", &key)==1 ? key : -1;
+}
+
+TString MSqlInsertRun::GetKeyStr(const char *table, const char *where, Bool_t &rc)
+{
+    const TString str(GetEntry(table, Form("f%sKEY", table), where));
+    if (str.IsNull())
+        rc = kFALSE;
+
+    return str;
+}
+
+TString MSqlInsertRun::MagicNumber(MRawRunHeader *h, Bool_t &ok)
+{
+    Int_t key = GetKey("MagicNumber", Form("fMagicNumber=%d", h->GetMagicNumber()));
+    if (key<0)
+        key = GetKey("MagicNumber", "fMagicNumber=0xffff");
+    if (key<0)
+    {
+        ok = kFALSE;
+        return TString("");
+    }
+    return TString(Form("%d", key));
+}
+
+TString MSqlInsertRun::RunType(MRawRunHeader *h, Bool_t &ok)
+{
+    Int_t key = GetKey("RunType", Form("fRunType=%d", h->GetRunType()));
+    if (key<0)
+        key = GetKey("RunType", "fRunTye=0xffff");
+    if (key<0)
+    {
+        ok = kFALSE;
+        return TString("");
+    }
+    return TString(Form("%d", key));
+}
+
+TString MSqlInsertRun::Source(MRawRunHeader *h, Bool_t &ok)
+{
+    Int_t key = GetKey("Source", Form("fSourceName='%s'", h->GetSourceName()));
+    if (key<0)
+    {
+        const char *q = Form("INSERT Source (fSourceName, fSourceTxt) VALUES ('%s', 'MSqlInsert: %s')",
+                             h->GetSourceName(), h->GetSourceName());
+
+        TSQLResult *res = fSqlServer->Query(q);
+        if (!res)
+        {
+            ok = kFALSE;
+            return TString("");
+        }
+        key = GetKey("Source", Form("fSourceName='%s'", h->GetSourceName()));
+        if (key>0)
+            *fLog << inf << "New Source '" << h->GetSourceName() << "' inserted into table Source of database." << endl;
+    }
+    else
+    {
+        // FIXME: check for consistency!
+    }
+    if (key<0)
+    {
+        ok = kFALSE;
+        return TString("");
+    }
+
+    return TString(Form("%d", key));
+}
+
+TString MSqlInsertRun::Project(MRawRunHeader *h, Bool_t &ok)
+{
+    Int_t key = GetKey("Project", Form("fProjectName='%s'", h->GetProjectName()));
+    if (key<0)
+    {
+        const char *q = Form("INSERT Project (fProjectName, fProjectTxt) VALUES ('%s', 'MSqlInsert: %s')",
+                             h->GetProjectName(), h->GetProjectName());
+
+        TSQLResult *res = fSqlServer->Query(q);
+        if (!res)
+        {
+            ok = kFALSE;
+            return TString("");
+        }
+        key = GetKey("Project", Form("fProjectName='%s'", h->GetProjectName()));
+        if (key>0)
+            *fLog << inf << "New Project '" << h->GetProjectName() << "' inserted into table Project of database." << endl;
+    }
+    if (key<0)
+    {
+        ok = kFALSE;
+        return TString("");
+    }
+
+    return TString(Form("%d", key));
+}
+
+TString MSqlInsertRun::RawFilePath(const char *path, Bool_t &ok)
+{
+    Int_t key = GetKey("FilePath", Form("fFilePathName='%s'", path));
+    if (key<0)
+    {
+        const char *q = Form("INSERT FilePath (fFilePathName, fFilePath) VALUES ('%s', 'MSqlInsert: %s')",
+                             path, path);
+
+        TSQLResult *res = fSqlServer->Query(q);
+        if (!res)
+        {
+            ok = kFALSE;
+            return TString("");
+        }
+        key = GetKey("FilePath", Form("fFilePathName='%s'", path));
+        if (key>0)
+            *fLog << inf << "New FilePath '" << path << "' inserted into table FilePath of database." << endl;
+
+    }
+    if (key<0)
+    {
+        ok = kFALSE;
+        return TString("");
+    }
+
+    return TString(Form("%d", key));
+}
+/*
+#include <TArrayI.h>
+
+void Line(const TArrayI &max)
+{
+    cout << "+" << setfill('-');
+    for (int i=0; i<max.GetSize(); i++)
+        cout << setw(max[i]+1) << "-" << "-+";
+    cout << endl;
+}
+
+void PrintResult(TSQLResult *res)
+{
+    Int_t n = res->GetFieldCount();
+
+    TArrayI max(n);
+
+    for (int i=0; i<n; i++)
+        max[i] = strlen(res->GetFieldName(i));
+
+    TSQLRow *row;
+
+    TList rows;
+    while ((row=res->Next()))
+    {
+        for (int i=0; i<n; i++)
+            max[i] = TMath::Max((ULong_t)max[i], row->GetFieldLength(i));
+        rows.Add(row);
+    }
+
+    Line(max);
+
+    cout << "|" << setfill(' ');
+    for (int i=0; i<n; i++)
+        cout << setw(max[i]+1) << res->GetFieldName(i) << " |";
+    cout << endl;
+
+    Line(max);
+
+    cout << setfill(' ');
+    TIter Next(&rows);
+    while ((row=(TSQLRow*)Next()))
+    {
+        cout << "|";
+        for (int i=0; i<n; i++)
+        {
+            const char *c = (*row)[i];
+            cout << setw(max[i]+1) << (c?c:"") << " |";
+        }
+        cout << endl;
+    }
+
+    Line(max);
+}
+*/
+Bool_t MSqlInsertRun::InsertRun(MRawRunHeader *h, Bool_t update)
+{
+    // FIXME: Insert input file (PreProcess), output file (PostProcess)
+
+    TString query(update ? "UPDATE" : "INSERT");
+
+    Bool_t ok=kTRUE;
+
+    query += " RunData SET fMagicNumberKEY='";
+    query += MagicNumber(h, ok);
+    query += "', fFormatVersion='";
+    query += h->GetFormatVersion();
+    query += "', fRunTypeKEY='";
+    query += RunType(h, ok);
+    query += "', fRunNumber='";
+    query += h->GetRunNumber();
+    query += "', fProjectKEY='";
+    query += Project(h, ok);
+    query += "', fSourceKEY='";
+    query += Source(h, ok);
+    query += "', fNumEvents='";
+    query += h->GetNumEvents();
+    query += "', fRunStart='";
+    query += h->GetRunStart().GetSqlDateTime();
+    query += "', fRunStop='";
+    query += h->GetRunEnd().GetSqlDateTime();
+    query += "'";
+
+    if (update)
+    {
+        query += " WHERE fRunNumber=";
+        query += h->GetRunNumber();
+    }
+
+    if (!ok)
+    {
+        *fLog << err << "ERROR - while concatenating query..." << endl;
+        *fLog << query << endl;
+        return kFALSE;
+    }
+
+    TSQLResult *res = fSqlServer->Query(query);
+    if (!res)
+        return PrintError("TSQLResult==NULL", query);
+
+    *fLog << inf << dec;
+    *fLog << "Run #" << h->GetRunNumber() << " ";
+    *fLog << (update ? "updated" : "inserted");
+    *fLog << " in database successfully." << endl;
+
+    return kTRUE;
+}
+
+Int_t MSqlInsertRun::GetIndex(MRawRunHeader *h)
+{
+    Bool_t ok=kTRUE;
+
+    TString query("SELECT fRunDataKEY from RunData WHERE fMagicNumberKEY='");
+
+    query += MagicNumber(h, ok);
+    query += "' AND fFormatVersion='";
+    query += h->GetFormatVersion();
+    query += "' AND fRunTypeKEY='";
+    query += RunType(h, ok);
+    query += "' AND fRunNumber='";
+    query += h->GetRunNumber();
+    query += "' AND fProjectKEY='";
+    query += Project(h, ok);
+    query += "' AND fSourceKEY='";
+    query += Source(h, ok);
+    query += "' AND fNumEvents='";
+    query += h->GetNumEvents();
+    query += "' AND fRunStart='";
+    query += h->GetRunStart().GetSqlDateTime();
+    query += "' AND fRunStop='";
+    query += h->GetRunEnd().GetSqlDateTime();
+    query += "'";
+
+    if (!ok)
+    {
+        *fLog << err << "ERROR - while concatenating query..." << endl;
+        *fLog << query << endl;
+        return -1;
+    }
+
+    TSQLResult *res = fSqlServer->Query(query);
+    if (!res)
+        return (PrintError("TSQLResult==NULL", query), -1);
+
+    if (res->GetFieldCount()!=1)
+        return (PrintError("Number of columns != 1", query), -1);
+
+    if (res->GetRowCount()>1)
+        return (PrintError("Number of rows > 1", query), -1);
+
+    if (res->GetRowCount()==0)
+        return 0;
+
+    const char *fld = res->Next()->GetField(0);
+    if (!fld)
+        return (PrintError("Entry is empty", query), -1);
+
+    return atoi(fld);
+}
+
+Bool_t MSqlInsertRun::InsertFile(MRawRunHeader *h, MParList *pList, Bool_t update)
+{
+    const Int_t key = GetIndex(h);
+    if (key<0)
+        return kFALSE;
+
+    if (key==0)
+        return kTRUE;
+
+    MTaskList *tasks = (MTaskList*)pList->FindObject("MTaskList");
+    if (!tasks)
+    {
+        *fLog << err << "MTaskList not found in parameter list... aborting." << endl;
+        return kFALSE;
+    }
+    MRawFileRead *read = (MRawFileRead*)tasks->FindObject("MRawFileRead");
+    if (!read)
+    {
+        *fLog << err << "MRawFileRead not found in task list... aborting." << endl;
+        return kFALSE;
+    }
+
+    const char *base = gSystem->BaseName(read->GetFileName());
+    const char *path = gSystem->DirName(read->GetFileName());
+
+    const TString str(GetEntry("RawFile", "fRawFileName", Form("fRawFileName='%s'", base)));
+    if (!update && !str.IsNull())
+    {
+        *fLog << err << "ERROR - fRawFileName=" << base << " already existing in RawFile... aborting." << endl;
+        return kFALSE;
+    }
+
+    Bool_t ok = kTRUE;
+
+    TString query(update ? "UPDATE" : "INSERT");
+    query += " RawFile SET fRawFileName='";
+    query += base;
+    query += "', fFilePathKEY=";
+    query += RawFilePath(path, ok);
+    query += ", fRawFileKEY=";
+    query += key;
+
+    if (!ok)
+    {
+        *fLog << err << "ERROR - while concatenating query..." << endl;
+        *fLog << query << endl;
+        return kFALSE;
+    }
+
+    TSQLResult *res = fSqlServer->Query(query);
+    if (!res)
+        return PrintError("TSQLResult==NULL", query);
+
+    *fLog << inf << dec;
+    *fLog << "File '" << base << "' ";
+    *fLog << (update ? "updated" : "inserted");
+    *fLog << " in database successfully." << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MSqlInsertRun::PreProcess(MParList *pList)
+{
+    if (!fSqlServer)
+    {
+        *fLog << err << "Connection to SQL server failed... aborting." << endl;
+        return kFALSE;
+    }
+
+    MRawRunHeader *header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!header)
+    {
+        *fLog << err << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+/*
+    if (header->GetFormatVersion()<3)
+    {
+        *fLog << err << "MSqlInsertRun cannot be used for files with format <3... abort." << endl;
+        return kTRUE;
+    }
+ */
+    Bool_t update = kFALSE;
+
+    // Is run already in databae?
+    const TString str(GetEntry("MRawRunHeader", "fRunNumber", Form("fRunNumber=%d", header->GetRunNumber())));
+    if (!str.IsNull())
+    {
+        if (!fIsUpdate)
+        {
+            *fLog << err << "Run #" << dec << header->GetRunNumber() << " already in database... abort." << endl;
+            return kFALSE;
+        }
+        update=kTRUE;
+    }
+
+    if (!InsertRun(header, update))
+        return kFALSE;
+
+    if (!InsertFile(header, pList, update))
+        return kFALSE;
+
+    return kTRUE;
+}
+
+Int_t MSqlInsertRun::PostProcess()
+{
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/msql/MSqlInsertRun.h
===================================================================
--- /trunk/MagicSoft/Mars/msql/MSqlInsertRun.h	(revision 3328)
+++ /trunk/MagicSoft/Mars/msql/MSqlInsertRun.h	(revision 3328)
@@ -0,0 +1,51 @@
+#ifndef MARS_MRawRunInsertSql
+#define MARS_MRawRunInsertSql
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MSQLServer;
+
+class MRawRunHeader;
+
+class MSqlInsertRun : public MTask
+{
+private:
+    MSQLServer *fSqlServer;
+
+    Bool_t fIsUpdate;
+
+    Int_t   GetIndex(MRawRunHeader *h);
+    Int_t   GetKey(const char *table, const char *where);
+    TString GetKeyStr(const char *table, const char *where, Bool_t &rc);
+    TString GetEntry(const char *table, const char *col, const char *where);
+
+    Bool_t  IsRunExisting(MRawRunHeader *h, Bool_t &ok);
+    Bool_t  IsFileExisting(MRawRunHeader *h, Bool_t &ok);
+
+    TString MagicNumber(MRawRunHeader *h, Bool_t &ok);
+    TString RunType(MRawRunHeader *h, Bool_t &ok);
+    TString Source(MRawRunHeader *h, Bool_t &ok);
+    TString Project(MRawRunHeader *h, Bool_t &ok);
+    TString RawFilePath(const char *path, Bool_t &ok);
+
+    Bool_t InsertRun(MRawRunHeader *h, Bool_t update);
+    Bool_t InsertFile(MRawRunHeader *h, MParList *pList, Bool_t update);
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  PostProcess();
+
+    Bool_t PrintError(const char *txt, const char *q) const;
+
+public:
+    MSqlInsertRun(const char *db, const char *user, const char *pw);
+    MSqlInsertRun(const char *url);
+    ~MSqlInsertRun();
+
+    void SetUpdate(Bool_t u=kTRUE) { fIsUpdate=u; }
+
+    ClassDef(MSqlInsertRun, 0) // Task to insert run into database
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/msql/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/msql/Makefile	(revision 3328)
+++ /trunk/MagicSoft/Mars/msql/Makefile	(revision 3328)
@@ -0,0 +1,48 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Sql
+
+#
+# Library name to creatre
+#
+LIB   = msql.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mraw
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = \
+	MSQLServer.cc \
+	MSqlInsertRun.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+#clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
+
Index: /trunk/MagicSoft/Mars/msql/SqlIncl.h
===================================================================
--- /trunk/MagicSoft/Mars/msql/SqlIncl.h	(revision 3328)
+++ /trunk/MagicSoft/Mars/msql/SqlIncl.h	(revision 3328)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /trunk/MagicSoft/Mars/msql/SqlLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/msql/SqlLinkDef.h	(revision 3328)
+++ /trunk/MagicSoft/Mars/msql/SqlLinkDef.h	(revision 3328)
@@ -0,0 +1,12 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MSqlInsertRun+;
+
+#pragma link C++ class MSQLColumn+;
+#pragma link C++ class MSQLServer+;
+
+#endif
Index: unk/MagicSoft/Mars/mtemp/MObservatory.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/MObservatory.cc	(revision 3327)
+++ 	(revision )
@@ -1,91 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Robert Wagner  10/2002 <mailto:magicsoft@rwagner.de>
-!   Author(s): Thomas Bretz   2/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
-!
-!   Copyright: MAGIC Software Development, 2002-2003
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MObservatory                                                            //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-#include "MObservatory.h"
-
-#include "MAstro.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-ClassImp(MObservatory);
-
-void MObservatory::Init(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MObservatory";
-    fTitle = title ? title : "Storage container for coordinates of an observatory";   
-}
-
-MObservatory::MObservatory(const char *name, const char *title)
-{
-    Init(name, title);
-
-    SetLocation(kMagic1);
-}
-
-MObservatory::MObservatory(LocationName_t key, const char *name=NULL, const char *title=NULL)
-{
-    Init(name, title);
-
-    SetLocation(key);
-}
-
-void MObservatory::SetLocation(LocationName_t name)
-{
-    switch (name)
-    {
-    case kMagic1:
-        // Values taken from the GPS Receiver (avg 20h)
-        // on 26/11/2003 at 17h30 in the counting house
-        fLatitude  = MAstro::Dms2Rad(28, 45, 42.576, '+');
-        fLongitude = MAstro::Dms2Rad(17, 53, 26.460, '-');
-        fHeight    = 2196.5; // m
-        fObservatoryName = "Observatorio del Roque de los Muchachos (Magic1)";
-        return;
-
-    case kWuerzburgCity:
-        fLatitude  = MAstro::Dms2Rad(51, 38, 48.0);
-        fLongitude = MAstro::Dms2Rad( 9, 56, 36.0);
-        fHeight    = 300;
-        fObservatoryName = "Wuerzburg City";
-        return;
-
-    }
-}
-
-void MObservatory::Print(Option_t *) const
-{
-    *fLog << all;
-    *fLog << fObservatoryName << endl;
-    *fLog << "Latitude " << (fLatitude > 0 ? (fLatitude*kRad2Deg) : -(fLatitude*kRad2Deg)) << " deg " << (fLatitude > 0 ? "W" : "E") << endl;
-    *fLog << "Longitude " << (fLongitude > 0 ? (fLongitude*kRad2Deg) : -(fLongitude*kRad2Deg)) <<" deg " << (fLongitude < 0 ? "N" : "S") << endl;
-    *fLog << "Height " << fHeight << "m" << endl;
-}
-
Index: unk/MagicSoft/Mars/mtemp/MObservatory.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/MObservatory.h	(revision 3327)
+++ 	(revision )
@@ -1,55 +1,0 @@
-#ifndef MARS_MObservatory
-#define MARS_MObservatory
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-class MObservatory : public MParContainer
-{
-public:
-    enum LocationName_t
-    {
-        kMagic1,
-        kWuerzburgCity
-    };
-
-private:
-    LocationName_t fObservatoryKey;  //!
-
-    TString  fObservatoryName;       //! Name of the observatory
-
-    Double_t fLongitude;             //! [rad] Longitude of observatory (+ east)
-    Double_t fLatitude;              //! [rad] Latitude of observatory (+ north)
-
-    Double_t fHeight;                //! [m] height of observatory
-
-    void Init(const char *name, const char *title);
-
-public:
-    MObservatory(const char *name=NULL, const char *title=NULL);
-    MObservatory(LocationName_t key, const char *name=NULL, const char *title=NULL);
-
-    void SetLocation(LocationName_t name);
-
-    void Print(Option_t *o=0) const;
-
-    const TString &GetObservatoryName() const { return fObservatoryName; }
-
-    Double_t GetLatitudeDeg() const     { return fLatitude*kRad2Deg; }  //[deg]
-    Double_t GetLongitudeDeg() const    { return fLongitude*kRad2Deg; } //[deg]
-
-    Double_t GetLatitudeRad() const     { return fLatitude; }           //[rad]
-    Double_t GetLongitudeRad() const    { return fLongitude; }          //[rad]
-
-    Double_t GetPhi() const             { return fLatitude; }           //[rad]
-    Double_t GetElong() const           { return fLongitude; }          //[rad]
-
-    Double_t GetHeight() const          { return fHeight; }
-
-    LocationName_t GetObservatoryKey() const { return fObservatoryKey; }
-
-    ClassDef(MObservatory, 0)
-};
-
-#endif
Index: unk/MagicSoft/Mars/mtemp/MObservatoryLocation.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/MObservatoryLocation.cc	(revision 3327)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Robert Wagner  10/2002 <mailto:magicsoft@rwagner.de>
-!
-!   Copyright: MAGIC Software Development, 2002
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MObservatoryLocation                                                    //
-//                                                                         //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-#include "MObservatoryLocation.h"
-
-#include <TMath.h>
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-ClassImp(MObservatoryLocation);
-
-void MObservatoryLocation::Init(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MObservatoryLocation";
-    fTitle = title ? title : "Storage container for coordinates of an observatory";   
-}
-
-MObservatoryLocation::MObservatoryLocation(const char *name, const char *title)
-{
-    Init();
-
-    fLatitude  =  28.7594 / kRad2Deg; // rad; 28 45 34
-    fLongitude =  17.8761 / kRad2Deg; // rad; 17 52 34;
-                                        // slalib uses + for WEST !!!
-    fElevation = 2300; // m
-    fObsName = "Observatorio del Roque de los Muchachos";
-}
-
-MObservatoryLocation::MObservatoryLocation(LocationName_t name, const char *name=NULL, const char *title=NULL)
-{
-    Init();
-
-    switch (name)
-    {
-    case kMagic1:
-    case kMagic2:
-    case kRobertGarten:
-        fLatitude  =  28.7594 / kRad2Deg; // rad; 28 45 34
-        fLongitude =  17.8761 / kRad2Deg; // rad; 17 52 34;
-                                          // slalib uses + for WEST !!!
-        fElevation = 2300; // m
-        fObsName = "Observatorio del Roque de los Muchachos";
-        break;
-    }
-}
-
-//Double_t GetHorizon(Double_t phi);
-//TF1 SetHorizonLine() { return fHorizon; }
-//TF1 GetHorizonLine() { return fHorizon; }
-
-MObservatoryLocation::~MObservatoryLocation()
-{
-  // do nothing special.
-}
-
-void MObservatoryLocation::Print(Option_t *) const
-{
-  *fLog << all;
-  *fLog << fObsName << endl;
-  *fLog << "Latitude " << (fLatitude > 0 ? (fLatitude*kRad2Deg) : -(fLatitude*kRad2Deg)) << " deg " << (fLatitude > 0 ? "W" : "E") << endl;
-  *fLog << "Longitude " << (fLongitude > 0 ? (fLongitude*kRad2Deg) : -(fLongitude*kRad2Deg)) <<" deg " << (fLongitude < 0 ? "N" : "S") << endl;
-  *fLog << "Elevation " << fElevation << "m" << endl;
-}
-
Index: unk/MagicSoft/Mars/mtemp/MObservatoryLocation.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/MObservatoryLocation.h	(revision 3327)
+++ 	(revision )
@@ -1,54 +1,0 @@
-#ifndef MARS_MObservatoryLocation
-#define MARS_MObservatoryLocation
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-class MObservatoryLocation : public MParContainer
-{
-private:
-  TString  fObsName;
-  Double_t fLatitude;
-  Double_t fLongitude;
-  Double_t fElevation;
-  static Double_t fgDegToRad;
-  //  TH1F     fHorizon;
-
-  void Init(const char *name, const char *title);
-
-public:
-    enum LocationName_t
-    {
-        kMagic1,
-        kMagic2,
-        kRobertGarten
-    };
-
-  MObservatoryLocation(const char *name=NULL, const char *title=NULL);
-  MObservatoryLocation(LocationName_t name, const char *name=NULL, const char *title=NULL);
-  ~MObservatoryLocation();
-
-  void SetLatitude(Double_t latitude)   { fLatitude = latitude; }
-  void SetLongitude(Double_t longitude) { fLongitude = longitude; }
-  void SetElevation(Double_t elevation) { fElevation = elevation; }
-  void SetObservatoryName(TString name) { fObsName = name; }
-  
-  void Print(Option_t *) const;
-  
-  Double_t GetLatitude() const        { return fLatitude*kRad2Deg; }
-  Double_t GetLongitude() const       { return fLongitude*kRad2Deg; }
-  Double_t GetElevation() const       { return fElevation; }
-  Double_t GetLatitudeRad() const     { return fLatitude; }
-  Double_t GetLongitudeRad() const    { return fLongitude; }
-  TString  GetObservatoryName() const { return fObsName; }
-  // Double_t GetHorizon(Double_t phi);
-  // void SetHorizonLine(TF1 hor) { fHorizon = hor; }
-  // TH1F GetHorizonLine() { return fHorizon; }
-  
-  ClassDef(MObservatoryLocation, 1)
-
-};
-
-#endif
-
