#include "TH1.h" #include "TCanvas.h" #include "TF1.h" #include using namespace std; void drawcloneexfixed() { TH1F* hOne = new TH1F("hist1","hist1",40,-10,10); TH1F* hTwo = new TH1F("hist2","hist2",40,-10,10); // ===== work on canvas 1.... =========== TCanvas* c1 = new TCanvas("canvas1","canvas1"); hOne->FillRandom("pol0"); hOne->Draw(); // ... do stuff; c1->Modified();c1->Update(); //line not required // ===== work on canvas 2.... ============ TCanvas* c2 = new TCanvas("canvas2","canvas2"); hTwo->FillRandom("gaus"); hTwo->Fit( "gaus", "MIL", "", -10,0 ); c2->Modified();c2->Update(); //line not required // if ( debug ) // { TF1* gf = hTwo->GetFunction("gaus"); gf->DrawClone("same"); // !!!!!!!!! <- Draws on canvas 1 !?!!! // } // ... do more stuff; }