From one window with drawn histogram, on mouseclick I create a new window and draw a different histogram:
def pixel_click(self):
hist = ROOT.gPad.GetSelected()
if not hist: return
# Check if it was the histogram that was clicked
if not isinstance(hist, ROOT.TH2): return
# Check if it was a mouse click (mouse-up)
if ROOT.gPad.GetEvent()==11:
print ROOT.gPad
canv = self.Canvas.GetCanvas()
cx, cy = canv.GetEventX(), canv.GetEventY()
# Get the histogram bin
pix_x = int(canv.AbsPixeltoX(cx))
pix_y = int(canv.AbsPixeltoY(cy))
# Calculate the pdm pixel number
pmt_num = pix_x/8+pix_y/8*6
x1 = pix_x-pmt_num%6*8
y1 = pix_y-pmt_num/6*8
pix_num = (y1+8*x1)*36+pmt_num
print pix_num
print pix_x, pix_y, hist.GetBinContent(pix_x+1, pix_y+1), cx, cy, canv.PadtoX(pix_x)
if not self.AnalysisFrame: self.AnalysisFrame = pAnalysisFrame(self.parent, 800, 800)
else: self.AnalysisFrame.Canvas.GetCanvas().cd()
self.etosTree.Draw("avg_pc_data["+str(pix_num)+"]:threshold[0]", "", "*")
The problem is, that the coordinated computed by AbsPixelTo… od Padto… are wrong after such operation - probably they have now coordinates of the new histogram even when I cd() to the old pad (cd() is succesfull, for if I attempt to draw just after cd in the same procedure, I draw in the old window). The coordinates on clicking are correct again if I resize the old window. So during resize something is recomputed. Can you tell me what and how can I do it manually? Calling ResizePad() did not help.