Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3141)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3142)
@@ -79,4 +79,17 @@
    * macros/readMagic.C:
      - changed to use MInteractiveTask
+
+   * mbase/MPrint.cc:
+     - fixed debugging level of some output
+     
+   * mhist/MHCamera.[h,cc]:
+     - fixed handling in AddNotify (necessayr due to change of
+       inheritance from MCamEvent)
+     - replaced cout by gLog
+     - added fNotify to list of cleanups
+
+   * mhist/MHEvent.cc, mjobs/MJCalibration.cc,
+     mjobs/MJPedestal.cc:
+     - fixed usage of AddNotify
 
 
Index: trunk/MagicSoft/Mars/mbase/MPrint.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MPrint.cc	(revision 3141)
+++ trunk/MagicSoft/Mars/mbase/MPrint.cc	(revision 3142)
@@ -131,13 +131,12 @@
     // If it couldn't get found stop Eventloop
     //
-    *fLog << err << dbginf << fObjName << " not found... ";
     if (TestBit(kSkip))
     {
-        *fLog << "removing task from list." << endl;
+        *fLog << warn << fObjName << " not found... removing task from list." << endl;
         return kSKIP;
     }
     else
     {
-        *fLog << "aborting." << endl;
+        *fLog << err << fObjName << " not found... aborting." << endl;
         return kFALSE;
     }
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3141)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3142)
@@ -35,4 +35,6 @@
 // Be carefull: Entries in this context means Entries/bin or Events
 //
+// FIXME? Maybe MHCamera can take the fLog object from MGeomCam?
+//
 ////////////////////////////////////////////////////////////////////////////
 #include "MHCamera.h"
@@ -83,4 +85,6 @@
 
     fNotify  = new TList;
+    fNotify->SetBit(kMustCleanup);
+    gROOT->GetListOfCleanups()->Add(fNotify);
 
 #if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
@@ -611,12 +615,12 @@
 void MHCamera::Print(Option_t *) const
 {
-    cout << "Minimum: " << GetMinimum();
+    gLog << all << "Minimum: " << GetMinimum();
     if (fMinimum==-1111)
-        cout << " <autoscaled>";
-    cout << endl;
-    cout << "Maximum: " << GetMaximum();
+        gLog << " <autoscaled>";
+    gLog << endl;
+    gLog << "Maximum: " << GetMaximum();
     if (fMaximum==-1111)
-        cout << " <autoscaled>";
-    cout << endl;
+        gLog << " <autoscaled>";
+    gLog << endl;
 }
 
@@ -718,5 +722,5 @@
     if (ncolors>1 && ncolors<50)
     {
-        cout << "MHCamera::SetPalette: Only default palettes with 50 colors are allowed... ignored." << endl;
+        gLog << err << "MHCamera::SetPalette: Only default palettes with 50 colors are allowed... ignored." << endl;
         return;
     }
@@ -1157,5 +1161,5 @@
 void MHCamera::SavePrimitive(ofstream &out, Option_t *opt)
 {
-    cout << "MHCamera::SavePrimitive: Must be rewritten!" << endl;
+    gLog << err << "MHCamera::SavePrimitive: Must be rewritten!" << endl;
     /*
     if (!gROOT->ClassSaved(TCanvas::Class()))
@@ -1257,4 +1261,27 @@
 // ------------------------------------------------------------------------
 //
+// Add a MCamEvent which should be displayed when the user clicks on a
+// pixel.
+// Warning: The object MUST inherit from TObject AND MCamEvent
+//
+void MHCamera::AddNotify(TObject *obj)
+{
+    // Make sure, that the object derives from MCamEvent!
+    MCamEvent *evt = dynamic_cast<MCamEvent*>(obj);
+    if (!evt)
+    {
+        gLog << err << "ERROR: MHCamera::AddNotify - TObject doesn't inherit from MCamEvent... ignored." << endl;
+        return;
+    }
+
+    // Make sure, that it is deleted from the list too, if the obj is deleted
+    obj->SetBit(kMustCleanup);
+
+    // Add object to list
+    fNotify->Add(obj);
+}
+
+// ------------------------------------------------------------------------
+//
 // Execute a mouse event on the camera
 //
@@ -1275,11 +1302,11 @@
         return;
 
-    cout << GetTitle() << " <" << GetName() << ">" << endl;
-    cout << "Software Pixel Index: " << idx << endl;
-    cout << "Hardware Pixel Id:    " << idx+1 << endl;
-    cout << "Contents:             " << GetBinContent(idx+1);
+    gLog << all << GetTitle() << " <" << GetName() << ">" << endl;
+    gLog << "Software Pixel Index: " << idx << endl;
+    gLog << "Hardware Pixel Id:    " << idx+1 << endl;
+    gLog << "Contents:             " << GetBinContent(idx+1);
     if (GetBinError(idx+1)>0)
-        cout << " +/- " << GetBinError(idx+1);
-    cout << "  <" << (IsUsed(idx)?"on":"off") << ">" << endl;
+        gLog << " +/- " << GetBinError(idx+1);
+    gLog << "  <" << (IsUsed(idx)?"on":"off") << ">" << endl;
 
     if (fNotify && fNotify->GetSize()>0)
@@ -1306,5 +1333,11 @@
         // FIXME: Make sure, that the old histograms are really deleted.
         //        Are they already deleted?
-        fNotify->ForEach(MCamEvent, DrawPixelContent)(idx);
+
+        // The dynamic_cast is necessary here: We cannot use ForEach
+        TIter Next(fNotify);
+        MCamEvent *evt;
+        while ((evt=dynamic_cast<MCamEvent*>(Next())))
+            evt->DrawPixelContent(idx);
+
         gPad->Modified();
         gPad->Update();
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 3141)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 3142)
@@ -179,5 +179,5 @@
     //void  SetOptStat(Int_t os=-1) { fOptStat = os; } // *MENU*
 
-    void     AddNotify(const MCamEvent &event) { fNotify->Add((TObject*)(&event)); }
+    void     AddNotify(TObject *event);
 
     Stat_t   GetMean(Int_t axis=-1) const;
@@ -187,6 +187,4 @@
 
     TH1D    *Projection(const char *name="_py") const;
-
-    //void SetStatusBar(TGStatusBar *bar) { fStatusBar = bar; }
 
     const MGeomCam &GetGeomCam() const { return *fGeomCam; }
Index: trunk/MagicSoft/Mars/mhist/MHEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHEvent.cc	(revision 3141)
+++ trunk/MagicSoft/Mars/mhist/MHEvent.cc	(revision 3142)
@@ -118,5 +118,5 @@
 
     fHist = new MHCamera(*cam);
-    fHist->AddNotify(*fClone);
+    fHist->AddNotify(fClone);
 
     switch (fType)
@@ -182,5 +182,7 @@
     switch (fType)
     {
-    case kEvtSignal:
+    case kEvtSignal: // Get NumPhotons without pixel-size scaling
+        //        fHist->SetCamContent(*event, 3);
+        //        break;
     case kEvtPedestal:
         fHist->SetCamContent(*event, 0);
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 3141)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 3142)
@@ -166,10 +166,8 @@
 void MJCalibration::CamDraw(TCanvas &c, const Int_t x, const Int_t y, const MHCamera &cam1, const Int_t fit)
 {
-
-
     c.cd(x);
     gPad->SetBorderMode(0);
     MHCamera *obj1=(MHCamera*)cam1.DrawCopy("hist");
-    obj1->AddNotify(fCalibrationCam);
+    obj1->AddNotify(static_cast<TObject*>(&fCalibrationCam));
 
     c.cd(x+y);
@@ -177,10 +175,10 @@
     obj1->Draw();
 
-    if (fit)
-      {
-        c.cd(x+2*y);
-        gPad->SetBorderMode(0);
-        DrawProjection(obj1, fit);
-      }
+    if (!fit)
+        return;
+
+    c.cd(x+2*y);
+    gPad->SetBorderMode(0);
+    DrawProjection(obj1, fit);
 }
 
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 3141)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 3142)
@@ -174,5 +174,5 @@
     gPad->SetBorderMode(0);
     MHCamera *obj1=(MHCamera*)cam1.DrawCopy("hist");
-    obj1->AddNotify(fPedestalCam);
+    obj1->AddNotify(static_cast<TObject*>(&fPedestalCam));
 
     c.cd(x+y);
