Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 9570)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 9571)
@@ -18,4 +18,18 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2010/04/19 Thomas Bretz
+
+   * mase/MStatusArray.cc:
+     - added a workaround to prevent crashes in case of double
+       deleteion of the fHistogram in TGraphs
+
+   * mcorsika/MCorsikaEvtHeader.cc:
+     - replaced special characters by UTF8 characters
+
+   * mgeom/MGeom.[h,cc]:
+     - implemented function to return the distance squared
+
+
 
  2010/04/13 Daniela Dorner
Index: /trunk/MagicSoft/Mars/mbase/MStatusArray.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MStatusArray.cc	(revision 9570)
+++ /trunk/MagicSoft/Mars/mbase/MStatusArray.cc	(revision 9571)
@@ -49,4 +49,7 @@
 #include <TCanvas.h>
 
+#include <TGraph.h>           // For the TGraph workaround
+#include <TPaveText.h>        // For the TPaveText workaround
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -56,6 +59,4 @@
 
 ClassImp(MStatusArray);
-
-#include <TGraph.h>
 
 using namespace std;
@@ -77,5 +78,4 @@
 // name) recuresively
 //
-#include<TPaveText.h>
 void MStatusArray::RecursiveDelete(TVirtualPad *p, const char id) const
 {
@@ -98,4 +98,15 @@
                 continue;
 
+            /*
+            // This is necessary because the histogram can get deleted
+            // but is not treated in TGraph recursive remove. Unfortunately,
+            // we have no possibility to find out whether it was already
+            // deleted. Fortunately these histograms don't contain data
+            // and threfore don't consume memory.
+            TGraph *g = dynamic_cast<TGraph*>(o);
+            if (g)
+                g->SetHistogram(0);
+             */
+
             delete o;
 
@@ -153,7 +164,11 @@
         if (dynamic_cast<TGraph*>(o))
         {
+            // FIXME: This should not be called for the TGraph
+            // which is currently getting deleted.
             TGraph *g = static_cast<TGraph*>(o);
             if (g->GetHistogram()==obj)
                 g->SetHistogram(0);
+            else
+                g->GetHistogram()->SetBit(kMustCleanup);
 
             continue;
@@ -175,4 +190,6 @@
     TObjArray::RecursiveRemove(obj);
 
+    // FIXME: Maybe we still have to call SetBit(kMustCleanup) ???
+#if ROOT_VERSION_CODE <= ROOT_VERSION(5,26,00)
     TObject *o = 0;
 
@@ -180,4 +197,5 @@
     while ((o=Next()))
         RecursiveRemove(dynamic_cast<TVirtualPad*>(o), obj);
+#endif
 }
 
Index: /trunk/MagicSoft/Mars/mcorsika/MCorsikaEvtHeader.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcorsika/MCorsikaEvtHeader.cc	(revision 9570)
+++ /trunk/MagicSoft/Mars/mcorsika/MCorsikaEvtHeader.cc	(revision 9571)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz 11/2008 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: Software Development, 2000-2009
+!   Copyright: Software Development, 2000-2010
 !
 !
@@ -106,9 +106,9 @@
 //    *fLog << "Particle ID:               " << MMcEvt::GetParticleName(fParticleID) << endl;
     *fLog << "Energy:                    " << fTotalEnergy << "GeV" << endl;
-    *fLog << "Starting Altitude:         " << fStartAltitude << "g/cm²" << endl;
+    *fLog << "Starting Altitude:         " << fStartAltitude << "g/cm" << UTF8::kSquare << endl;
     *fLog << "Number of 1st Target:      " << fFirstTargetNum << endl,
     *fLog << "Height of 1st Interaction: " << fFirstInteractionHeight/100. << "m" << endl;
     *fLog << "Momentum X/Y/Z (GeV/c):    " << fMomentumX << "/" << fMomentumY << "/" << fMomentumZ << endl;
-    *fLog << "Zenith/Azimuth Angle:      " << fZd*TMath::RadToDeg() << "°/" << fAz*TMath::RadToDeg() << "°" << endl;
+    *fLog << "Zenith/Azimuth Angle:      " << fZd*TMath::RadToDeg() << UTF8::kDeg << "/" << fAz*TMath::RadToDeg() << UTF8::kDeg << endl;
     *fLog << "Impact X/Y:                " << fX/100. << "m/" << fY/100. << "m  (r=" << TMath::Hypot(fX, fY)/100. << "m)" << endl;
     *fLog << "Weighted Num Photons:      " << fWeightedNumPhotons << endl;
Index: /trunk/MagicSoft/Mars/mgeom/MGeom.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeom.cc	(revision 9570)
+++ /trunk/MagicSoft/Mars/mgeom/MGeom.cc	(revision 9571)
@@ -158,4 +158,16 @@
 // ------------------------------------------------------------------------
 //
+// Return distance squared of center to center of pix:
+//  (fX-pix.fX)^2+(fY-pix.fY)^2
+//
+Float_t MGeom::GetDist2(const MGeom &pix) const
+{
+    const Double_t dx = fX-pix.fX;
+    const Double_t dy = fY-pix.fY;
+    return dx*dx + dy*dy;
+}
+
+// ------------------------------------------------------------------------
+//
 // Return angle defined by the center and the center of pix:
 //  atan2(fX-pix.fX,fY-pix.fY)
Index: /trunk/MagicSoft/Mars/mgeom/MGeom.h
===================================================================
--- /trunk/MagicSoft/Mars/mgeom/MGeom.h	(revision 9570)
+++ /trunk/MagicSoft/Mars/mgeom/MGeom.h	(revision 9571)
@@ -87,4 +87,5 @@
     Float_t GetDist() const;
     Float_t GetDist(const MGeom &pix) const;
+    Float_t GetDist2(const MGeom &pix) const;
     Float_t GetAngle(const MGeom &pix) const;
 
