#include #include #include #include #include #include /* To compile : g++ -g -I/opt/root/include -pthread -m64 -fPIC -W -Wall -Wextra -Wconversion -Wdisabled-optimization -Wno-unused -Wall -Wshadow -Wextra -Wredundant-decls -L/opt/root/lib -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -lm -ldl ex_drawclonepad.cpp -o ex_drawclonepad To run : ./ex_drawclonepad To valgrind : valgrind --suppressions=$ROOTSYS/etc/valgrind-root.supp --log-file=valgrind-drawclonepaddelete.output --leak-check=full --tool=memcheck --show-reachable=no --num-callers=35 ./ex_drawclonepad */ int main(int argc, char *argv[]) { TApplication myApp("App", &argc, &argv); gROOT->SetBatch(); // create a tcanvas with pads, draw a h1 in a pad std::cout << "create first canvas" << std::endl; TCanvas *c1 = new TCanvas("test1", "test1", 0, 0, 600, 300); TH1F h1("h1", "h1", 100, 0, 99); //c1->cd(); h1.Draw(); c1->SaveAs("test.ps"); // ok // Create a summary canvas std::cout << "create summary canvas" << std::endl; TCanvas* summary = new TCanvas("summary"); // 3 attempts to draw the initial canvas onto the second one. // Uncomment only one at a time summary->cd(); //c1->Draw(); //summary->SaveAs("test2.ps"); // empty //c1->DrawClone(); //summary->SaveAs("test3.ps"); // empty TObject *o = c1->DrawClonePad(); summary->SaveAs("test4.ps"); // ok but memory leak // Deletion std::cout << "clean up" << std::endl; delete o; delete summary; delete c1; }