Index: /trunk/MagicSoft/Mars/mdata/MDataChain.cc
===================================================================
--- /trunk/MagicSoft/Mars/mdata/MDataChain.cc	(revision 1333)
+++ /trunk/MagicSoft/Mars/mdata/MDataChain.cc	(revision 1334)
@@ -103,4 +103,5 @@
 
 MDataChain::MDataChain(const char *rule, const char *name, const char *title)
+    : fOperatorType(kENoop)
 {
     fName  = name  ? name  : "MDataChain";
@@ -382,5 +383,8 @@
 {
     if (!fMember)
+    {
+        *fLog << warn << "MDataChain not valid." << endl;
         return 0;
+    }
 
     const Double_t val = fMember->GetValue();
@@ -405,4 +409,6 @@
     case kENoop:  return val;
     }
+
+    *fLog << warn << "No Case for " << fOperatorType << " available." << endl;
 
     return 0;
Index: /trunk/MagicSoft/Mars/mdata/MDataMember.cc
===================================================================
--- /trunk/MagicSoft/Mars/mdata/MDataMember.cc	(revision 1333)
+++ /trunk/MagicSoft/Mars/mdata/MDataMember.cc	(revision 1334)
@@ -68,5 +68,9 @@
 {
     if (!fCall)
+    {
+        *fLog << err << "No TMethodCall for " << fName << " of ";
+        *fLog << fObject->GetName() << " available... returning 0." << endl;
         return 0;
+    }
 
     switch (fCall->ReturnType())
@@ -84,5 +88,5 @@
     default:
         *fLog << err << "DataMember " << fName << " of ";
-        *fLog << fObject->GetName() << " neither int nor float... abort." << endl;
+        *fLog << fObject->GetName() << " neither int nor float... returning 0." << endl;
         return 0;
     }
Index: /trunk/MagicSoft/Mars/mgui/MGeomCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MGeomCam.cc	(revision 1333)
+++ /trunk/MagicSoft/Mars/mgui/MGeomCam.cc	(revision 1334)
@@ -50,5 +50,5 @@
 //
 MGeomCam::MGeomCam(UInt_t npix, Float_t dist, const char *name, const char *title)
-    : fNumPixels(npix), fCamDist(dist), fMm2Deg(kRad2Deg/(dist*1000))
+    : fNumPixels(npix), fCamDist(dist), fConvMm2Deg(kRad2Deg/(dist*1000))
 {
     fName  = name  ? name  : "MGeomCam";
Index: /trunk/MagicSoft/Mars/mgui/MGeomCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MGeomCam.h	(revision 1333)
+++ /trunk/MagicSoft/Mars/mgui/MGeomCam.h	(revision 1334)
@@ -18,5 +18,5 @@
 
     Float_t  fCamDist;    // [m] Average distance of the camera from the mirror
-    Float_t  fMm2Deg;     // conversion factor to convert mm in the camera plain into degrees
+    Float_t  fConvMm2Deg; // conversion factor to convert mm in the camera plain into degrees
 
     TObjArray *fPixels;   // Array of singel pixels storing the geometry
@@ -32,5 +32,5 @@
 
     Float_t GetCameraDist() const { return fCamDist; }
-    Float_t GetConvMm2Deg() const { return fMm2Deg; }
+    Float_t GetConvMm2Deg() const { return fConvMm2Deg; }
 
     UInt_t  GetNumPixels() const { return fNumPixels; }
Index: /trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 1333)
+++ /trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 1334)
@@ -9,4 +9,5 @@
 #pragma link C++ class MH+;
 #pragma link C++ class MH3+;
+#pragma link C++ class MHMatrix+;
 #pragma link C++ class MHFadcCam+;
 #pragma link C++ class MHFadcPix+;
Index: /trunk/MagicSoft/Mars/mhist/MFillH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1333)
+++ /trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1334)
@@ -313,4 +313,15 @@
 Bool_t MFillH::PostProcess()
 {
+    //
+    // Now all data is in the histogram. Maybe some final action is
+    // necessary.
+    //
+    if (!fH->Finalize())
+    {
+        *fLog << err << dbginf << "Error: calling Finalize for ";
+        *fLog << fH->GetDescriptor() << "... aborting." << endl;
+        return kFALSE;
+    }
+
     fH->SetReadyToSave();
     return kTRUE;
Index: /trunk/MagicSoft/Mars/mhist/MH.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MH.h	(revision 1333)
+++ /trunk/MagicSoft/Mars/mhist/MH.h	(revision 1334)
@@ -23,4 +23,5 @@
     virtual Bool_t SetupFill(const MParList *pList) { return kTRUE; }
     virtual Bool_t Fill(const MParContainer *par) = 0;
+    virtual Bool_t Finalize() { return kTRUE; }
 
     static TCanvas *MakeDefCanvas(TString name="", const char *title="",
Index: /trunk/MagicSoft/Mars/mhist/MH3.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MH3.cc	(revision 1333)
+++ /trunk/MagicSoft/Mars/mhist/MH3.cc	(revision 1334)
@@ -67,6 +67,4 @@
 #include <TPad.h>
 #include <TCanvas.h>
-#include <TDataMember.h>
-#include <TMethodCall.h>
 
 #include "MLog.h"
Index: /trunk/MagicSoft/Mars/mhist/MHMatrix.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMatrix.cc	(revision 1334)
+++ /trunk/MagicSoft/Mars/mhist/MHMatrix.cc	(revision 1334)
@@ -0,0 +1,276 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHMatrix
+//
+// This is a histogram container which holds a matrix with one column per
+// data variable. The data variable can be a complex rule (MDataChain).
+// Each event for wich Fill is called (by MFillH) is added as a new
+// row to the matrix.
+//
+// For example:
+//   MHMatrix m;
+//   m.AddColumn("MHillas.fSize");
+//   m.AddColumn("MMcEvt.fImpact/100");
+//   m.AddColumn("HillasSource.fDist*MGeomCam.fConvMm2Deg");
+//   MFillH fillm(&m);
+//   taskliost.AddToList(&fillm);
+//   [...]
+//   m.Print();
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MHMatrix.h"
+
+#include <TList.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MDataChain.h"
+
+ClassImp(MHMatrix);
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor
+//
+MHMatrix::MHMatrix()
+    : fNumRow(0)
+{
+    fData = new TList;
+    fData->SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor
+//
+MHMatrix::~MHMatrix()
+{
+    delete fData;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new column to the matrix. This can only be done before the first
+// event (row) was filled into the matrix. For the syntax of the rule
+// see MDataChain.
+//
+void MHMatrix::AddColumn(const char *rule)
+{
+    if (fM.IsValid())
+    {
+        *fLog << warn << "Warning - matrix is already in use. Can't add a new column... skipped." << endl;
+        return;
+    }
+
+    MDataChain &chain = *new MDataChain(name);
+    if (!chain.IsValid())
+    {
+        *fLog << err << "Error - Rule cannot be translated... ignored." << endl;
+        delete &chain;
+        return;
+    }
+
+    fData->Add(&chain);
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether at least one column is available and PreProcesses all
+// data chains.
+//
+Bool_t MHMatrix::SetupFill(const MParList *plist)
+{
+    if (fData->GetSize()==0)
+    {
+        *fLog << err << "Error - No Column specified... aborting." << endl;
+        return kFALSE;
+    }
+
+    TIter Next(fData);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+        if (!data->PreProcess(plist))
+            return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// If the matrix has not enough rows double the number of available rows.
+//
+void MHMatrix::AddRow()
+{
+    fNumRow++;
+
+    if (fM.GetNrows() > fNumRow)
+        return;
+
+    if (!fM.IsValid())
+    {
+        fM.ResizeTo(1, fData->GetSize());
+        return;
+    }
+
+    TMatrix m(fM);
+
+    fM.ResizeTo(fM.GetNrows()*2, fData->GetSize());
+
+    for (int x=0; x<m.GetNcols(); x++)
+        for (int y=0; y<m.GetNrows(); y++)
+            fM(y, x) = m(y, x);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add the values correspoding to the columns to the new row
+//
+Bool_t MHMatrix::Fill(const MParContainer *par)
+{
+    AddRow();
+
+    int col=0;
+    TIter Next(fData);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+        fM(fNumRow-1, col++) = data->GetValue();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Resize the matrix to a number of rows which corresponds to the number of
+// rows which have really been filled with values.
+//
+Bool_t MHMatrix::Finalize()
+{
+    TMatrix m(fM);
+
+    fM.ResizeTo(fNumRow, fData->GetSize());
+
+    for (int x=0; x<fM.GetNcols(); x++)
+        for (int y=0; y<fM.GetNrows(); y++)
+            fM(y, x) = m(y, x);
+
+    return kTRUE;
+}
+/*
+// --------------------------------------------------------------------------
+//
+// Draw clone of histogram. So that the object can be deleted
+// and the histogram is still visible in the canvas.
+// The cloned object are deleted together with the canvas if the canvas is
+// destroyed. If you want to handle destroying the canvas you can get a
+// pointer to it from this function
+//
+TObject *MHMatrix::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MH::MakeDefCanvas(fHist);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    fHist->DrawCopy(opt);
+
+    TString str(opt);
+    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileX();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileY();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the histogram into it.
+// Be careful: The histogram belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHMatrix::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(fHist);
+
+    fHist->Draw(opt);
+
+    TString str(opt);
+    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileX();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileY();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+
+    gPad->Modified();
+    gPad->Update();
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Prints the meaning of the columns and the contents of the matrix.
+// Becareful, this can take a long time for matrices with many rows.
+//
+void MHMatrix::Print(Option_t *) const
+{
+    int n=0;
+    TIter Next(fData);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+    {
+        *fLog << all << " Column " << setw(3) << n++ << ": ";
+        data->Print();
+        *fLog << endl;
+    }
+
+    fM.Print();
+}
Index: /trunk/MagicSoft/Mars/mhist/MHMatrix.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMatrix.h	(revision 1334)
+++ /trunk/MagicSoft/Mars/mhist/MHMatrix.h	(revision 1334)
@@ -0,0 +1,44 @@
+#ifndef MARS_MHMatrix
+#define MARS_MHMatrix
+
+#ifndef ROOT_TMatrix
+#include <TMatrix.h>
+#endif
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class MDataChain;
+
+class MHMatrix : public MH
+{
+protected:
+    Int_t   fNumRow; // Number of dimensions of histogram
+    TMatrix fM;      // Matrix to be filled
+
+    TList  *fData;   // List of data members (columns)
+
+    void AddRow();
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par);
+    Bool_t Finalize();
+
+public:
+    MHMatrix();
+    ~MHMatrix();
+
+    void AddColumn(const char *name);
+
+    TMatrix &GetM() { return fM; }
+    const TMatrix &GetM() const { return fM; }
+
+    //void Draw(Option_t *opt=NULL);
+    //TObject *DrawClone(Option_t *opt=NULL) const;
+
+    void Print(Option_t *) const;
+
+    ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mhist/Makefile	(revision 1333)
+++ /trunk/MagicSoft/Mars/mhist/Makefile	(revision 1334)
@@ -32,4 +32,5 @@
            MH.cc \
            MH3.cc \
+           MHMatrix.cc \
            MHFadcPix.cc \
            MHFadcCam.cc \
@@ -53,6 +54,4 @@
            MHMcEnergyImpact.cc \
            MHThetabarTime.cc \
-           MHThetabarTheta.cc \
-           MHMcEnergyMigration.cc \
 	   MHMcRate.cc \
 	   MHMcIntRate.cc \
