Hi,
I would like to make use of TExec (or AddExec()) to show a histogram (TH1F) plotted on a single pad of a TCanvas divided into several pads on another (larger) TCanvas for easier inspection.
What I tried so far is the following code:
TCanvas *c2 = 0;
void show()
{
auto event = gPad->GetEvent();
if (event != 11) return;
TObject *select = gPad->GetSelected();
if (!select) return;
if (!select->InheritsFrom(TH1::Class())) return;
TH1F *h = (TH1F*)select;
c2->cd();
h->Draw();
c2->Update();
}
void testexec()
{
TCanvas *c1 = new TCanvas("c1","c1",10,10,800,600);
c1->Divide(4,3);
c2 = new TCanvas("c2","c2",900,20,500,500);
TH1F *h[12];
for (int i=0; i<12; ++i) {
h[i] = new TH1F(Form("h%d",i), Form("h%d",i), 100,0,1);
for (int j=0; j<10000; ++j) h[i]->Fill(gRandom->Gaus(0.1+0.05*i,0.01*i+0.05));
c1->cd(i+1);
h[i]->Draw();
gPad->AddExec("ex","show()");
}
}
This doesn’t do anything, i.e. nothing happens when clicking on the histograms. If I comment out the ‘InheritsFrom’ line, strange stuff is drawn on c2, and the histograms on c1 vanish.
Could somebody help me with that?
Best regards and thanks,
Klaus
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.22/06
Platform: Not Provided
Compiler: Not Provided