Dear ROOT expert,
I’m drawing a lot of TGraph in several loops, since the TGraph are very similar I’m drawing them with DrawClone(), then I recreate then, then I draw them again and so on. I’d like to delete these objets both for cleaning up memory and for cleaning the canvas. Is it possibile?
General idea
// create graphWithAxis
auto c1 = TCanvas();
c1->Divide(2,2);
graphWithAxis->Draw("AP");
for(int iEvt=0; iEvt<nEvents;iEvt++){
//set branches to iEvt
for(int iMB=1; iMB<=4; iMB++){
vector<float> x[5], y[5];
// fill x and y, depending on iMB
TGraph **gr = new TGraph*[5];
c1->cd(iMB)
for(int i=0;i<5;i++){
if(xPhiLeg[i].size()>0){
gr[i] = new TGraph(x[i].size(),&x[i][0],&y[i][0]);
gr[i]->DrawClone("PSAME");
}else{ gr[i]=nullptr; }
}
for(int i=0;i<5;i++) delete gr[i];
delete[] gr;
}
c1->Print("blabla.png");
// DELETE CLONES <-------
}
delete c1;
Many Thanks,
Alberto