Drawing canvas into new canvas

Hi,

I have a root file which consist out of several canvases (=instead of the histogram the canvas was saved into the root file).

In an interactive root session I’d like to have a new canvas (which is divided into several parts) and draw each of the canvases into the new canvas. This is fairly easy if one draws histograms, but does it also work with canvases? if so, how?

Cheers,
Carsten

This is quite easy via TPad::DrawClonePad
available from the pad/canvas context menu.
Assume an existing canvas c1 containing
possibily other pads.
Create a new canvas c2 that you divide
in eg 2x2. You can draw a full copy of c1
into subpad 3 by;
-setting subpad 3 the current pad (click with the middle button).
-move the mouse to c1, click the right button
to get the context menu, select DrawClonePad. That’s all

Rene

Using ROOT 3.05/04 this doesn’t seem to work - unless of course I’m doing the wrong thing…

Pressing TCanvas::DrawClonePad of TCanvas c1 produces the canvas in TCanvas c2, however only the data points are drawn and not the MC of the histogram. I’m quite sure this is not meant to be this way… Does the DrawClonePad method care about the (overlaying) histograms which it is supposed to clone?

Is there a way to achieve the same in a script (not using the mouse)? Is the activation of c2 one by TCanvas::SetSelectedPad?

Cheers,
Carsten

DrawClonePad was not operational in 3.05/04. I had assumed that you were using the pro version 3.05/07.
Move to 3.05/07 or 3.10.
Here is an example of script showing DrawClonePad in action.

Rene

void clonepad() {
TCanvas *c1 = new TCanvas(“c1”);
c1->Divide(2,2);
c1->cd(1);
TH1F *h1 = new TH1F(“h1”,“test”,30,-3,3);
h1->FillRandom(“gaus”,2000);
TH1F *h1copy = h1->DrawCopy();
c1->cd(2);
h1->DrawCopy(“lego2”);
c1->cd(3);
h1->Fit(“gaus”);
h1->DrawCopy();
c1->cd(4);
h1->Draw(“e1p”);

TCanvas *c2 = new TCanvas(“c2”);
c2->Divide(2,2);
c2->cd(2);
c1->DrawClonePad();
c2->cd(3);
h1copy->SetFillColor(kRed);
c1->DrawClonePad();
}

Hi,

I’ve switched to ROOT 3.05/07, and your example work fine. However I’m still having the same problems with my root file. To make things easy I’ve attached the root tuple and the macro I’m using.

Cheers,
Carsten
em_trig.root (24.8 KB)
clonepad2.C (241 Bytes)

Looking at your file, I see that all the objects: canvas, histograms, etc
have the same name “ett1_eta”. Not good for DrawClonePad.
Could you send me the script producing the original canvas?
Anyway, I suggest assigning separate names to your objects.

Rene

Hi,

attached is the file which produces the root tuple. Basically a couple of files are opened (which all have the same histograms), then a loop over all histograms of interest is performed. The original histograms where produced using for example:

TH1F *ett1_eta = new TH1F(“ett1_eta”,“em eta (tau type 1)”,250,-5.,5.);

How do you “look” at the root file? If I do View->Detail I see that “Name” and “Title” are identical, is that the problem you’re referring to?

Thanks for your help!
Carsten
electron.C (10.9 KB)