Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2585)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2586)
@@ -83,4 +83,9 @@
      - changed output in PostProcess according to the style in MHillasCalc etc.
      - changed nonsense derivement from MF to MFilter
+
+   * mhist/MHCamera.[h,cc]:
+     - added DrawClone to get rid of the usage of gROOT->GetSelectedPad.
+       this resulted in some trouble in the past. If it will make more
+       trouble than before we can remove it again - please report problems.
 
 
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2585)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2586)
@@ -355,5 +355,6 @@
 // Setup a drawing canvas. Add this object and all child objects
 // (hexagons, etc) to the current pad. If no pad exists a new one is
-// created.
+// created. (To access the 'real' pad containing the camera you have
+// to do a cd(1) in the current layer.
 //
 // To draw a camera into its own pad do something like:
@@ -403,4 +404,42 @@
     //
     pad->cd();
+}
+
+// ------------------------------------------------------------------------
+//
+// This is TObject::DrawClone but completely ignores
+// gROOT->GetSelectedPad(). tbretz had trouble with this in the past.
+// If this makes trouble please write a bug report.
+//
+TObject *MHCamera::DrawClone(Option_t *option) const
+{
+   // Draw a clone of this object in the current pad
+
+   //TVirtualPad *pad = gROOT->GetSelectedPad();
+   TVirtualPad *padsav = gPad;
+   //if (pad) pad->cd();
+
+   TObject *newobj = Clone();
+   if (!newobj)
+       return 0;
+
+   /*
+   if (pad) {
+      if (strlen(option)) pad->GetListOfPrimitives()->Add(newobj,option);
+      else                pad->GetListOfPrimitives()->Add(newobj,GetDrawOption());
+      pad->Modified(kTRUE);
+      pad->Update();
+      if (padsav) padsav->cd();
+      return newobj;
+   }
+   */
+
+   const TString opt(option);
+   newobj->Draw(opt.IsNull() ? GetDrawOption() : option);
+
+   if (padsav)
+       padsav->cd();
+
+   return newobj;
 }
 
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2585)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2586)
@@ -127,10 +127,10 @@
     virtual void     CntCamContent(const TArrayD &evt, Double_t threshold, Bool_t ispos=kTRUE);
 
-    Stat_t GetBinContent(Int_t bin) const { return Profile(TH1D::GetBinContent(bin)); }
-    Stat_t GetBinContent(Int_t binx, Int_t biny) const { return GetBinContent(binx); }
-    Stat_t GetBinContent(Int_t binx, Int_t biny, Int_t binz) const { return GetBinContent(binx); }
-    Stat_t GetBinError(Int_t bin) const { return Profile(TH1D::GetBinError(bin)); }
-    Stat_t GetBinError(Int_t binx, Int_t biny) const { return GetBinError(binx); }
-    Stat_t GetBinError(Int_t binx, Int_t biny, Int_t binz) const { return GetBinError(binx); }
+    Stat_t   GetBinContent(Int_t bin) const { return Profile(TH1D::GetBinContent(bin)); }
+    Stat_t   GetBinContent(Int_t binx, Int_t biny) const { return GetBinContent(binx); }
+    Stat_t   GetBinContent(Int_t binx, Int_t biny, Int_t binz) const { return GetBinContent(binx); }
+    Stat_t   GetBinError(Int_t bin) const { return Profile(TH1D::GetBinError(bin)); }
+    Stat_t   GetBinError(Int_t binx, Int_t biny) const { return GetBinError(binx); }
+    Stat_t   GetBinError(Int_t binx, Int_t biny, Int_t binz) const { return GetBinError(binx); }
 
     Double_t GetMinimum(Bool_t all) const;
@@ -140,46 +140,47 @@
     Double_t GetMaximum() const { return GetMaximum(0/*kTRUE*/); }
 
-    void SetLevels(const TArrayF &arr);
-
-    void  FillRandom(const char *fname, Int_t ntimes=5000) { TH1::FillRandom(fname, ntimes); }
-    void  FillRandom(TH1 *h, Int_t ntimes=5000) { TH1::FillRandom(h, ntimes); }
-    void  FillRandom();
-
-    void  PrintInfo() const { Print(""); } // *MENU*
-    void  Reset(Option_t *);
-    void  Reset() { Reset(""); } // *MENU*
-    TH1  *DrawCopy() const/* { gPad=NULL; return TH1D::DrawCopy(); }*/; // *MENU*
-    TH1  *DrawCopy(Option_t *o) const { return TH1D::DrawCopy(o); }
-
-    void  Print(Option_t *) const;
-    void  Paint(Option_t *option="");
-    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;
-    void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
-
-    void  SetPalette(Int_t ncolors, Int_t *colors);
-
-    void  SetPrettyPalette(); // *MENU*
-    void  SetDeepBlueSeaPalette(); // *MENU*
-    void  SetInvDeepBlueSeaPalette(); // *MENU*
-
-    void  SetAutoScale() { fMinimum = fMaximum = -1111; } // *MENU*
-    void  DisplayAsHistogram() { SetDrawOption("histEP"); } // *MENU*
-    void  DisplayAsCamera() { SetDrawOption(""); } // *MENU*
-
-    void  SetFreezed(Bool_t f=kTRUE) { f ? SetBit(kFreezed) : ResetBit(kFreezed); } // *TOGGLE*
-    Bool_t IsFreezed() const { return TestBit(kFreezed); }
+    void     SetLevels(const TArrayF &arr);
+
+    void     FillRandom(const char *fname, Int_t ntimes=5000) { TH1::FillRandom(fname, ntimes); }
+    void     FillRandom(TH1 *h, Int_t ntimes=5000) { TH1::FillRandom(h, ntimes); }
+    void     FillRandom();
+
+    void     PrintInfo() const { Print(""); } // *MENU*
+    void     Reset(Option_t *);
+    void     Reset() { Reset(""); } // *MENU*
+    TH1     *DrawCopy() const/* { gPad=NULL; return TH1D::DrawCopy(); }*/; // *MENU*
+    TH1     *DrawCopy(Option_t *o) const { return TH1D::DrawCopy(o); }
+
+    void     Print(Option_t *) const;
+    void     Paint(Option_t *option="");
+    void     Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option) const;
+    void     SavePrimitive(ofstream &out, Option_t *);
+    Int_t    DistancetoPrimitive(Int_t px, Int_t py);
+    char    *GetObjectInfo(Int_t px, Int_t py) const;
+    void     ExecuteEvent(Int_t event, Int_t px, Int_t py);
+
+    void     SetPalette(Int_t ncolors, Int_t *colors);
+
+    void     SetPrettyPalette(); // *MENU*
+    void     SetDeepBlueSeaPalette(); // *MENU*
+    void     SetInvDeepBlueSeaPalette(); // *MENU*
+
+    void     SetAutoScale() { fMinimum = fMaximum = -1111; } // *MENU*
+    void     DisplayAsHistogram() { SetDrawOption("histEP"); } // *MENU*
+    void     DisplayAsCamera() { SetDrawOption(""); } // *MENU*
+
+    void     SetFreezed(Bool_t f=kTRUE) { f ? SetBit(kFreezed) : ResetBit(kFreezed); } // *TOGGLE*
+    Bool_t   IsFreezed() const { return TestBit(kFreezed); }
     //void  SetOptStat(Int_t os=-1) { fOptStat = os; } // *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  AddNotify(const MCamEvent &event) { fNotify->Add((TObject*)(&event)); }
-
-    Stat_t GetMean(Int_t axis=-1) const;
-    Stat_t GetRMS(Int_t axis=-1) const;
-
-    UInt_t GetNumPixels() const;
+    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     AddNotify(const MCamEvent &event) { fNotify->Add((TObject*)(&event)); }
+
+    Stat_t   GetMean(Int_t axis=-1) const;
+    Stat_t   GetRMS(Int_t axis=-1) const;
+
+    UInt_t   GetNumPixels() const;
 
     //void SetStatusBar(TGStatusBar *bar) { fStatusBar = bar; }
