Drawing a TCanvas (from a TFile) in a current TPad

As the subject line says, I’m attempting to draw a TCanvas that was saved within a TFile, in the current pad of a new canvas.

Using the TCanvas::DrawClonePad() gives me this error (and crash):

> root ROOTfiles/ntuple_ana.root 
root [0] 
Attaching file ROOTfiles/ntuple_ana.root as _file0...
root [1] new TCanvas
(class TCanvas*)0x1b87ae0
root [2] Effi_BIL_2A05->DrawClonePad()
(class TObject*)0x0
root [3] Warning in <TCanvas::ResizePad>: Effi_BIL_2A05 width changed from 32000 to 10

Warning in <TCanvas::ResizePad>: Effi_BIL_2A05 width changed from 32000 to 10

Error in <RootX11ErrorHandler>: BadAlloc (insufficient resources for operation) (XID: 50331918, XREQ: 53)

Is there a better (or correct) way to do this? I’d like to incorporate this type of feature into a more involved code where I draw multiple TCanvas (from a TFile) on the same (newly created) TCanvas.

Maybe this is silly… and I shouldn’t do it.

Thanks.

By default a new canvas is named “c1”. It is likely that the canvas in the file is also named “c1”. In this case drawing the old canvas will clear the current canvas (ie internal pad) before drawing itself. Try the following:

new TCanvas("c2"); //create your subpad and cd to it Effi_BIL_2A05->DrawClonePad();
Rene

Using the “c2” in the TCanvas constructor, I still get the same error message and crash.

Maybe this was fixed in a later release? I’ve tried this on 5.14/00b and 5.14/00e.

Using TCanvas::DrawClonePad() is the way to get my desired result, right?

Thanks.

I cannot reproduce this problem with 5.14. Could you send me a script reproducing the problem? + the file with the canvas.

Rene

Attached are both.
ntuple_ana.root (1.89 MB)
try.C (386 Bytes)

OK problem understood. Due to the Draw option used when generating the original canvas with the markers.
This problem was fixed in January. Simply move to 5.16 or 5.17

Rene

Ok!

Thanks for the help!