Problem deleting histograms


_ROOT Version: ROOT 6.17/01
_Platform: linuxx8664gcc
_Compiler:_gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC)


Hello,

I am trying to delete histograms using the following method. But it is NOT working!

root [0] TFile *f = new TFile("test1.root", "UPDATE");
root [1] .ls
TFile**		test1.root	
 TFile*		test1.root	
  KEY: TH2F	his2D_clean;1	2Dbg and 2Drand_GG subtracted his2D
  KEY: TH1D	pY_528_his2D_clean;1	2Dbg and 2Drand_GG subtracted his2D
  KEY: TH1D	pY_670_his2D_clean;1	2Dbg and 2Drand_GG subtracted his2D
root [2] delete his2D_clean;
root [3] delete pY_670_his2D_clean;
root [4] f->Write();
root [5] f->Close();
root [6] .ls
root [7] TFile *f1 = new TFile("test1.root", "UPDATE");
root [8] .ls
TFile**		test1.root	
 TFile*		test1.root	
  KEY: TH2F	his2D_clean;1	2Dbg and 2Drand_GG subtracted his2D
  KEY: TH1D	pY_528_his2D_clean;1	2Dbg and 2Drand_GG subtracted his2D
  KEY: TH1D	pY_670_his2D_clean;1	2Dbg and 2Drand_GG subtracted his2D
root [9] 

Am I doing any obvious mistake? Again, I don’t use ROOT often, and this may sound a naive question.

Regards,

Ajay

Try to use TFile::Delete():

f->Delete("his2D_clean;1");
f->Delete("pY_670_his2D_clean;1");

Thank you very much for your help. It worked as expected.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.