Displaying and labeling peaks using DynamicSlice

As noticed in another thread, the trick with defining “t2” as a list does not help when one resizes or double-clicks the corresponding canvas (all drawn texts disappear).

Unfortunately, as written in my first post here, ROOT with python2 will automatically delete “cloned” texts (note: the simple “gROOT.SetSelectedPad(gPad); t2.DrawClone()” sequence seems to work in ROOT with python3).

So, I’ve found another brutal fix which works in both python versions.

Right in the beginning use:

from ROOT import *
gInterpreter.Declare("void DrawClone(TObject *object, Option_t *option = \"\") { if (gROOT && gPad && object) {gROOT->SetSelectedPad(gPad); object->DrawClone(option);} }")

and then simply instead of “t2.Draw()” use: “DrawClone(t2)

1 Like