Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2108)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2109)
@@ -1,5 +1,5 @@
                                                  -*-*- END OF LINE -*-*-
 
- 2003/05/10: Abelardo Moralejo
+ 2003/05/10: Thomas Bretz
 
    * Makefile.rules:
Index: trunk/MagicSoft/Mars/Makefile.rules
===================================================================
--- trunk/MagicSoft/Mars/Makefile.rules	(revision 2108)
+++ trunk/MagicSoft/Mars/Makefile.rules	(revision 2109)
@@ -68,3 +68,4 @@
 	@echo $(INCLUDES) $(CXXFLAGS)
 
-
+diff:
+	@cvs diff | grep -v "^? " > mars.diff
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 2108)
+++ trunk/MagicSoft/Mars/NEWS	(revision 2109)
@@ -59,4 +59,10 @@
 
    - colors in logging output to screen
+
+   - changes to the Image Parameter declaration:
+       + moved fConc, fConc1 from MHillasSrc to MNewImagePar
+       + moved fNumUsedPix, fNumCorePix from MHillas to MNewImagePar
+       + MHillasExt now derives from MParContainer instead of MHillas
+     --> Files written with the old definition are more or less unreadable
 
 
Index: trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.cc	(revision 2108)
+++ trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.cc	(revision 2109)
@@ -235,6 +235,6 @@
 Bool_t MCT1SupercutsCalc::Process()
 {
-    const Double_t dNOMLOGSIZE = 4.1;
-    const Double_t dNOMCOSZA   = 1.0;
+    const Double_t kNomLogSize = 4.1;
+    const Double_t kNomCosZA   = 1.0;
 
     const Double_t newdist = fHilSrc->GetDist() * fMm2Deg;
@@ -245,8 +245,8 @@
     const Double_t dd2     = dist * dist;
 
-    const Double_t dmls    = log(fHil->GetSize()) - dNOMLOGSIZE;
+    const Double_t dmls    = log(fHil->GetSize()) - kNomLogSize;
     const Double_t dmls2   = dmls * dmls;
 
-    const Double_t dmcza = cos(fMcEvt->GetTelescopeTheta()) - dNOMCOSZA;
+    const Double_t dmcza   = cos(fMcEvt->GetTelescopeTheta()) - kNomCosZA;
 
     const Double_t length  = fHil->GetLength() * fMm2Deg;
Index: trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 2108)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 2109)
@@ -376,5 +376,5 @@
     TMethodCall *call = NULL;
 
-    *fLog << warn << "Trying to find MethodCall '" << IsA()->GetName();
+    *fLog << warn << "Trying to find MethodCall '" << ClassName();
     *fLog << "::Get" << name << "' instead <LEAKS MEMORY>" << endl;
     call = new TMethodCall(IsA(), (TString)"Get"+name, "");
@@ -384,5 +384,5 @@
     delete call;
 
-    *fLog << warn << "Trying to find MethodCall '" << IsA()->GetName();
+    *fLog << warn << "Trying to find MethodCall '" << ClassName();
     *fLog << "::" << name << "' instead <LEAKS MEMORY>" << endl;
     call = new TMethodCall(IsA(), name, "");
@@ -482,5 +482,5 @@
         return kFALSE;
 
-    *fLog << warn << "WARNING - Resource " << prefix+fName << " found, but no " << IsA()->GetName() << "::ReadEnv." << endl;
+    *fLog << warn << "WARNING - Resource " << prefix+fName << " found, but no " << ClassName() << "::ReadEnv." << endl;
     return kTRUE;
 }
@@ -513,5 +513,5 @@
         return kFALSE;
 
-    *fLog << warn << "WARNING - Resource " << prefix+fName << " found, but " << IsA()->GetName() << "::WriteEnv not overloaded." << endl;
+    *fLog << warn << "WARNING - Resource " << prefix+fName << " found, but " << ClassName() << "::WriteEnv not overloaded." << endl;
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mbase/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mbase/Makefile	(revision 2108)
+++ trunk/MagicSoft/Mars/mbase/Makefile	(revision 2109)
@@ -20,6 +20,6 @@
 # @endcode 
 
-INCLUDES = -I. -I../mraw -I../MRawFormat -I../mmc -I../mfileio \
-	   -I../mmain -I../mfilter
+INCLUDES = -I. -I../mmain -I../mfileio -I../mfilter
+# MStatusDisplay (MTask), MRead (MEvtLoop), MF (MContinue)
 
 # @code 
Index: trunk/MagicSoft/Mars/mdata/MDataArray.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataArray.cc	(revision 2108)
+++ trunk/MagicSoft/Mars/mdata/MDataArray.cc	(revision 2109)
@@ -163,4 +163,9 @@
 }
 
+TString MDataArray::GetRule(int i) const
+{
+    return (*this)[i].GetRule();
+}
+
 // --------------------------------------------------------------------------
 //
Index: trunk/MagicSoft/Mars/mdata/MDataArray.h
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataArray.h	(revision 2108)
+++ trunk/MagicSoft/Mars/mdata/MDataArray.h	(revision 2109)
@@ -33,4 +33,6 @@
     Double_t operator()(Int_t i);
 
+    TString GetRule(int i) const;
+
     Bool_t PreProcess(const MParList *plist);
 
Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 2108)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 2109)
@@ -787,2 +787,23 @@
 }
 
+// ------------------------------------------------------------------------
+//
+// Returns string containing info about the object at position (px,py).
+// Returned string will be re-used (lock in MT environment).
+//
+char *MCamDisplay::GetObjectInfo(Int_t px, Int_t py) const
+{
+    static char info[64];
+
+    Int_t dist = 999999;
+    UInt_t i;
+    for (i=0; i<fNumPixels; i++)
+    {
+        if ((*fPixels)[i]->DistancetoPrimitive(px, py)>0)
+            continue;
+
+        sprintf(info, "Pixel Id: %d", i);
+        return info;
+    }
+    return TObject::GetObjectInfo(px, py);
+}
Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 2108)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 2109)
@@ -77,9 +77,10 @@
     void DrawPixelNumbers();
 
-    void     Paint(Option_t *option="");
-    void     Reset();
-    void     Draw(Option_t *option="");
-    void     SavePrimitive(ofstream &out, Option_t *);
-    Int_t    DistancetoPrimitive(Int_t px, Int_t py);
+    void  Paint(Option_t *option="");
+    void  Reset();
+    void  Draw(Option_t *option="");
+    void  SavePrimitive(ofstream &out, Option_t *);
+    Int_t DistancetoPrimitive(Int_t px, Int_t py);
+    char *GetObjectInfo(Int_t px, Int_t py) const;
     //virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
 
@@ -90,5 +91,5 @@
     void SetInvDeepBlueSeaPalette(); // *MENU*
 
-    void  SetPix(const Int_t pixnum, const Int_t color, Float_t min, Float_t max);      // New function added by M.Lopez in 31-01-03
+    void SetPix(const Int_t pixnum, const Int_t color, Float_t min, Float_t max);      // New function added by M.Lopez in 31-01-03
 
     ClassDef(MCamDisplay, 0) // Displays the magic camera
Index: trunk/MagicSoft/Mars/mhist/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH.cc	(revision 2108)
+++ trunk/MagicSoft/Mars/mhist/MH.cc	(revision 2109)
@@ -819,2 +819,130 @@
     return kFALSE;
 }
+
+void MH::ProjectionX(TH1D &dest, const TH2 &src, Int_t firstybin, Int_t lastybin)
+{
+    //*-*-*-*-*Project a 2-D histogram into a 1-D histogram along X*-*-*-*-*-*-*
+    //*-*      ====================================================
+    //
+    //   The projection dest is always of the type TH1D.
+    //   The projection is made from the channels along the Y axis
+    //   ranging from firstybin to lastybin included.
+    //   By default, bins 1 to ny are included
+    //   When all bins are included, the number of entries in the projection
+    //   is set to the number of entries of the 2-D histogram, otherwise
+    //   the number of entries is incremented by 1 for all non empty cells.
+    //
+    //   if Sumw2() was called for dest, the errors are computed.
+    //
+    TAxis &axex = *((TH2&)src).GetXaxis();
+    TAxis &axey = *((TH2&)src).GetYaxis();
+
+    const Int_t nx = axex.GetNbins();
+    const Int_t ny = axey.GetNbins();
+    if (firstybin < 0)
+        firstybin = 1;
+    if (lastybin > ny)
+        lastybin = ny;
+
+    dest.Reset();
+    SetBinning(&dest, &axex);
+
+    // Create the projection histogram
+    const Bool_t computeErrors = dest.GetSumw2N() ? 1 : 0;
+
+    // Fill the projected histogram
+    for (Int_t binx=0; binx<=nx+1; binx++)
+    {
+        Double_t err2 = 0;
+        for (Int_t biny=firstybin; biny<=lastybin; biny++)
+        {
+            const Double_t cont = src.GetCellContent(binx,biny);
+            const Double_t err1 = src.GetCellError(binx,biny);
+            err2 += err1*err1;
+            if (cont)
+                dest.Fill(axex.GetBinCenter(binx), cont);
+        }
+        if (computeErrors)
+            dest.SetBinError(binx, TMath::Sqrt(err2));
+    }
+    if (firstybin <=1 && lastybin >= ny)
+        dest.SetEntries(src.GetEntries());
+}
+
+void MH::ProjectionY(TH1D &dest, const TH2 &src, Int_t firstxbin, Int_t lastxbin)
+{
+    //*-*-*-*-*Project a 2-D histogram into a 1-D histogram along X*-*-*-*-*-*-*
+    //*-*      ====================================================
+    //
+    //   The projection dest is always of the type TH1D.
+    //   The projection is made from the channels along the Y axis
+    //   ranging from firstybin to lastybin included.
+    //   By default, bins 1 to ny are included
+    //   When all bins are included, the number of entries in the projection
+    //   is set to the number of entries of the 2-D histogram, otherwise
+    //   the number of entries is incremented by 1 for all non empty cells.
+    //
+    //   if Sumw2() was called for dest, the errors are computed.
+    //
+    TAxis &axex = *((TH2&)src).GetXaxis();
+    TAxis &axey = *((TH2&)src).GetYaxis();
+
+    const Int_t nx = axex.GetNbins();
+    const Int_t ny = axey.GetNbins();
+    if (firstxbin < 0)
+        firstxbin = 1;
+    if (lastxbin > nx)
+        lastxbin = nx;
+
+    dest.Reset();
+    SetBinning(&dest, &axey);
+
+    // Create the projection histogram
+    const Bool_t computeErrors = dest.GetSumw2N() ? 1 : 0;
+
+    // Fill the projected histogram
+    for (Int_t biny=0; biny<=ny+1; biny++)
+    {
+        Double_t err2 = 0;
+        for (Int_t binx=firstxbin; binx<=lastxbin; binx++)
+        {
+            const Double_t cont = src.GetCellContent(binx,biny);
+            const Double_t err1 = src.GetCellError(binx,biny);
+            err2 += err1*err1;
+            if (cont)
+                dest.Fill(axey.GetBinCenter(biny), cont);
+        }
+        if (computeErrors)
+            dest.SetBinError(biny, TMath::Sqrt(err2));
+    }
+    if (firstxbin <=1 && lastxbin >= nx)
+        dest.SetEntries(src.GetEntries());
+}
+
+// --------------------------------------------------------------------------
+//
+// In contradiction to TPad::FindObject this function searches recursively
+// in a pad for an object. gPad is the default.
+//
+TObject *MH::FindObjectInPad(const char *name, TVirtualPad *pad)
+{
+    if (!pad)
+        pad = gPad;
+
+    if (!pad)
+        return NULL;
+
+    TObject *o;
+
+    TIter Next(pad->GetListOfPrimitives());
+    while ((o=Next()))
+    {
+        if (!strcmp(o->GetName(), name))
+            return o;
+
+        if (o->InheritsFrom("TPad"))
+            if ((o = FindObjectInPad(name, (TVirtualPad*)o)))
+                return o;
+    }
+    return NULL;
+}
Index: trunk/MagicSoft/Mars/mhist/MH.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH.h	(revision 2108)
+++ trunk/MagicSoft/Mars/mhist/MH.h	(revision 2109)
@@ -7,4 +7,5 @@
 
 class TH1;
+class TH1D;
 class TH2;
 class TH3;
@@ -75,4 +76,9 @@
     static Double_t GetMinimumGT(const TH1 &h, Double_t gt=0);
 
+    static void ProjectionX(TH1D &dest, const TH2 &src, Int_t firstybin=-1, Int_t lastybin=9999);
+    static void ProjectionY(TH1D &dest, const TH2 &src, Int_t firstxbin=-1, Int_t lastxbin=9999);
+
+    static TObject *FindObjectInPad(const char *name, TVirtualPad *pad=NULL);
+
     ClassDef(MH, 0) //A base class for Mars histograms
 };
Index: trunk/MagicSoft/Mars/mhist/MHSigmaTheta.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHSigmaTheta.cc	(revision 2108)
+++ trunk/MagicSoft/Mars/mhist/MHSigmaTheta.cc	(revision 2109)
@@ -223,4 +223,29 @@
 // --------------------------------------------------------------------------
 //
+// Update the projections and (if possible) set log scales before painting
+//
+void MHSigmaTheta::Paint(Option_t *opt)
+{
+    TVirtualPad *padsave = gPad;
+
+    TH1D* h;
+
+    padsave->cd(1);
+    if ((h = (TH1D*)gPad->FindObject("ProjX-Theta")))
+    {
+        ProjectionX(*h, fSigmaTheta);
+        if (h->GetEntries()!=0)
+            gPad->SetLogy();
+    }
+
+    padsave->cd(4);
+    if ((h = (TH1D*)gPad->FindObject("ProjY-sigma")))
+        ProjectionY(*h, fSigmaTheta);
+
+    gPad = padsave;
+}
+
+// --------------------------------------------------------------------------
+//
 // Draw the histogram
 //
@@ -239,5 +264,4 @@
     pad->cd(1);
     gPad->SetBorderMode(0);
-    // gPad->SetLogy();
     h = fSigmaTheta.ProjectionX("ProjX-Theta", -1, 9999, "E");
     h->SetDirectory(NULL);
Index: trunk/MagicSoft/Mars/mhist/MHSigmaTheta.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHSigmaTheta.h	(revision 2108)
+++ trunk/MagicSoft/Mars/mhist/MHSigmaTheta.h	(revision 2109)
@@ -37,4 +37,5 @@
     TH3D fDiffPixTheta;  // 3D-distr.:Theta, pixel, sigma^2-sigmabar^2
 
+    void Paint(Option_t *opt="");
 
 public:
Index: trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2108)
+++ trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2109)
@@ -72,4 +72,5 @@
 #include <TDatime.h>              // TDatime
 #include <TRandom.h>              // TRandom
+#include <TBrowser.h>             // TBrowser
 #include <TObjArray.h>            // TObjArray
 #include <TPostScript.h>          // TPostScript
@@ -169,6 +170,8 @@
     //
     MGPopupMenu *filemenu = new MGPopupMenu(gClient->GetRoot());
-    // filemenu->AddEntry("S&ave [F2]", kFileSave);
-    // filemenu->AddEntry("Save &As... [Shift-F2]", kFileSaveAs);
+    // filemenu->AddEntry("Save &As...", kFileSaveAs);
+    filemenu->AddEntry("New Can&vas",   kFileCanvas);
+    filemenu->AddEntry("New &Browser",  kFileBrowser);
+    filemenu->AddSeparator();
     filemenu->AddEntry("Save As status.&ps",   kFileSaveAsPS);
     filemenu->AddEntry("Save As status.&gif",  kFileSaveAsGIF);
@@ -177,5 +180,5 @@
     filemenu->AddSeparator();
     filemenu->AddEntry("Print with &lpr",      kFilePrint);
-    filemenu->AddEntry("Set printer &name",    kFilePrinterName);
+    //filemenu->AddEntry("Set printer &name",    kFilePrinterName);
     filemenu->AddSeparator();
     filemenu->AddEntry("E&xit", kFileExit);
@@ -186,6 +189,5 @@
     //
     MGPopupMenu *tabmenu = new MGPopupMenu(gClient->GetRoot());
-    // tabmenu->AddEntry("S&ave [F2]", kFileSave);
-    // tabmenu->AddEntry("Save &As... [Shift-F2]", kFileSaveAs);
+    // tabmenu->AddEntry("Save &As...", kFileSaveAs);
     tabmenu->AddEntry("Save As tab-i.&ps",   kTabSaveAsPS);
     tabmenu->AddEntry("Save As tab-i.&gif",  kTabSaveAsGIF);
@@ -760,5 +762,14 @@
         fStatus = (Status_t)id;
         return kTRUE;
-/*
+
+    case kFileCanvas:
+        new TCanvas;
+        return kTRUE;
+
+    case kFileBrowser:
+        new TBrowser;
+        return kTRUE;
+
+        /*
     case kFileSave:
         cout << "Save..." << endl;
@@ -1356,4 +1367,8 @@
     TPostScript ps(name, 112);
     ps.SetBit(TPad::kPrintingPS);
+
+    //%%DocumentPaperSizes: a4
+    //%%Orientation: Portrait
+
     ps.PrintFast(13, "/nan {1} def ");
 
Index: trunk/MagicSoft/Mars/mmain/MStatusDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mmain/MStatusDisplay.h	(revision 2108)
+++ trunk/MagicSoft/Mars/mmain/MStatusDisplay.h	(revision 2109)
@@ -33,7 +33,7 @@
     typedef enum {
         // KFile
-        kFileSave, kFileSaveAs, kFileSaveAsPS, kFileSaveAsRoot,
-        kFileSaveAsGIF, kFileSaveAsC, kFilePrint, kFilePrinterName,
-        kFileExit,
+        kFileBrowser, kFileCanvas, kFileSave, kFileSaveAs, kFileSaveAsPS,
+        kFileSaveAsRoot, kFileSaveAsGIF, kFileSaveAsC, kFilePrint,
+        kFilePrinterName, kFileExit,
         // kLoop
         kLoopNone, kLoopStop,
