void tryhistos() { TH1F *histos[3]; for(Int_t i=0;i<3;i++) { histos[i]=new TH1F(Form("histoname%d",i),Form("histotitle%d",i),300,-0.5,29.5); } TCanvas *c1=new TCanvas("c1","c1"); c1->Divide(1,3); TCanvas *c2=new TCanvas("c2","c2"); c2->Divide(1,3); for(Int_t iii=0;iii<5;iii++){ printf("n1 %d\n",iii); for(Int_t j=0;j<3;j++) { histos[0]->FillRandom("gaus",10000); histos[1]->FillRandom("landau",10000); histos[2]->FillRandom("expo",10000); } } TPaveText *pave[2]; for(Int_t gg=0;gg<2;gg++){ pave[gg]=NULL;} for(Int_t hh=0;hh<5;hh++) { TH1 *histos2[3]; for(Int_t i=0;i<3;i++) { histos2[i]=NULL; } for(Int_t uu=0;uu<2;uu++){ pave[uu]=new TPaveText(0.3,0.88,0.9,0.99,"NDC"); pave[uu]->AddText(Form("text %d",uu)); pave[uu]->AddText(Form("text 2 %d",uu)); pave[uu]->SetFillColor(4); pave[uu]->SetBorderSize(1); pave[uu]->SetLineWidth(1); } histos[0]->GetListOfFunctions()->Add(pave); histos[1]->GetListOfFunctions()->Add(pave); histos[2]->GetListOfFunctions()->Add(pave); for(Int_t gg=0;gg<3;gg++) histos2[gg]=(TH1*)histos[gg]->Clone(Form("%s_cpy",histos[gg]->GetName())); c1->cd(); for(Int_t z =0;z<3;z++) { c1->cd(z+1); histos[z]->Draw(); c1->Update(); } c2->cd(); for(Int_t z =0;z<3;z++) { c2->cd(z+1); histos2[z]->DrawCopy(); c2->Update(); } for(Int_t d=0;d<3;d++) { delete histos2[d]; histos2[d]=NULL; } for(Int_t vv=0;vv<2;vv++) { pave[vv]=NULL; } } for(Int_t ss=0;ss<2;ss++) { delete pave[ss]=NULL; pave[ss]=NULL; } }