Index: trunk/MagicSoft/Mars/mmain/MAnalysis.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MAnalysis.cc	(revision 949)
+++ trunk/MagicSoft/Mars/mmain/MAnalysis.cc	(revision 949)
@@ -0,0 +1,208 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  9/2001 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MAnalysis.h"
+
+#include <TGButton.h>  // TGTextButton
+
+ClassImp(MAnalysis)
+
+enum {
+  M_BUTTON_HILLAS
+};
+
+MAnalysis::MAnalysis(const TGWindow *main, const TGWindow *p,
+                     const UInt_t w, const UInt_t h)
+: MBrowser(main, p, w, h)
+{
+    TGTextButton *hillas = new TGTextButton(fTop2, "Calculate Standard Hillas", M_BUTTON_HILLAS);
+
+    hillas->Associate(this);
+
+    fList->Add(hillas);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsLeft, 10, 10, 5, 5);
+    fList->Add(laybut);
+
+    fTop2->AddFrame(hillas, laybut);
+
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("Analysis Window");
+    SetIconName("Analysis");
+
+    MapWindow();
+}
+
+// ======================================================================
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MGeomCamMagic.h"
+#include "MPedestalCam.h"
+#include "MHHillas.h"
+#include "MHStarMap.h"
+#include "MReadTree.h"
+#include "MCerPhotCalc.h"
+#include "MImgCleanStd.h"
+#include "MHillasCalc.h"
+#include "MFillH.h"
+#include "MEvtLoop.h"
+#include "MHillas.h"
+
+void MAnalysis::CalculateHillas(const char *fname)
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file.
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // The geometry container must be created by yourself to make sure
+    // that you don't choos a wrong geometry by chance
+    //
+    MGeomCamMagic geomcam;
+    plist.AddToList(&geomcam);
+
+    MPedestalCam pedest;
+    plist.AddToList(&pedest);
+
+    //
+    // The Hillas histograms (MHHillas) could be created automatically
+    // but to make sure, that they are not deleted when the macro is
+    // finished you must create them yourself and add it to the list
+    //
+    MHillas hillas;
+    plist.AddToList(&hillas);
+
+    MHHillas *hists = new MHHillas;
+    plist.AddToList(hists);
+
+    MHStarMap *smap = new MHStarMap;
+    plist.AddToList(smap);
+
+    // FIXME: Where do we delete this two objects???
+
+    //
+    // Now setup the tasks and tasklist:
+    //
+    //  1) read in the data from a magic root file   MReadTree
+    //  2) calculate number of cerenkov photons      MCerPhotCalc
+    //  3) clean the image                           MImgCleanStd
+    //  4) calculate hillas                          MHillasCalc
+    //  5) fill the hillas into the histograms       MFillH
+    //
+
+    //
+    // The first argument is the tree you want to read.
+    //   Events:     Cosmic ray events
+    //   PedEvents:  Pedestal Events
+    //   CalEvents:  Calibration Events
+    //
+    MReadTree      read("Events", fname);
+    MCerPhotCalc   ncalc;
+    MImgCleanStd   clean;
+    MHillasCalc    hcalc;
+    MFillH         hfill(&hillas, hists);
+    MFillH         sfill(&hillas, smap);
+    //
+    // FIXME:
+    // -----
+    // I cannot use MFillH fill("name", "name") here.
+    // for me it is not yet clear why this doesn't work
+    //
+
+    /*
+     MWriteRootFile write("hillas.root");
+     write.AddContainer("MHillas");
+     write.AddContainer("MHHillas");
+     write.AddContainer(smap);
+     */
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&hfill);
+    tlist.AddToList(&sfill);
+    //tlist.AddToList(&write);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    //
+    // After the analysis is finished we can display the histograms
+    //
+    hists->Draw();
+    smap->Draw();
+}
+
+// ======================================================================
+
+Bool_t MAnalysis::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    // Process events generated by the buttons in the frame.
+
+    if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
+        return MBrowser::ProcessMessage(msg, parm1, parm2);
+
+    switch (parm1)
+    {
+    case M_BUTTON_HILLAS:
+        if (!InputFileSelected())
+        {
+            DisplError("No Input (root) File selected!");
+            return kTRUE;
+        }
+
+        switch (parm1)
+        {
+        case M_BUTTON_HILLAS:
+            CalculateHillas(fInputFile);
+            return kTRUE;
+        }
+        return kTRUE;
+    }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+}
Index: trunk/MagicSoft/Mars/mmain/MAnalysis.h
===================================================================
--- trunk/MagicSoft/Mars/mmain/MAnalysis.h	(revision 949)
+++ trunk/MagicSoft/Mars/mmain/MAnalysis.h	(revision 949)
@@ -0,0 +1,28 @@
+#ifndef MANALYSIS_H
+#define MANALYSIS_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef MBROWSER_H
+#include "MBrowser.h"
+#endif
+
+class MAnalysis : public MBrowser
+{
+private:
+    void CalculateHillas(const char *fname);
+
+public:
+    MAnalysis(const TGWindow *main=NULL, const TGWindow *p=NULL,
+              const UInt_t w=500, const UInt_t h=500) ;
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MAnalysis, 0) // GUI: The 'data-check' window.
+};
+
+#endif
+
+
Index: trunk/MagicSoft/Mars/mmain/MMars.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MMars.cc	(revision 947)
+++ trunk/MagicSoft/Mars/mmain/MMars.cc	(revision 949)
@@ -36,4 +36,5 @@
 
 #include "MEvtDisp.h"
+#include "MAnalysis.h"
 #include "MDataCheck.h"
 #include "MMonteCarlo.h"
@@ -54,5 +55,5 @@
   M_BUTTON_ANALYSE,
   M_BUTTON_MONTECARLO
-} ; 
+};
 
 void MMars::CreateMenuBar()
@@ -263,5 +264,5 @@
 
             case M_BUTTON_ANALYSE:
-                DisplWarning("Analysis not yet implemented!");
+                new MAnalysis(this);
                 return kTRUE;
 
Index: trunk/MagicSoft/Mars/mmain/MainLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mmain/MainLinkDef.h	(revision 947)
+++ trunk/MagicSoft/Mars/mmain/MainLinkDef.h	(revision 949)
@@ -8,4 +8,5 @@
 
 #pragma link C++ class MMars;
+#pragma link C++ class MAnalysis;
 #pragma link C++ class MEvtDisp;
 #pragma link C++ class MDataCheck;
Index: trunk/MagicSoft/Mars/mmain/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mmain/Makefile	(revision 947)
+++ trunk/MagicSoft/Mars/mmain/Makefile	(revision 949)
@@ -22,5 +22,6 @@
 #  connect the include files defined in the config.mk file
 #
-INCLUDES = -I. -I../mbase -I../manalysis -I../mdatacheck -I../meventdisp
+INCLUDES = -I. -I../mbase -I../manalysis -I../mdatacheck -I../meventdisp \
+	   -I../mgui -I../mhist
 
 #------------------------------------------------------------------------------
@@ -31,4 +32,5 @@
 	   MEvtDisp.cc \
 	   MMars.cc \
+           MAnalysis.cc \
 	   MMonteCarlo.cc \
            MBrowser.cc
