Hi Jayoung, as you create the ntuple file before your ntuples, the global scope (means gDirectory) is on this file during object creation. This causes root to add your new ntuples to this directory. Then you do > aticwrk.Write(); > si_adc.Write(); > scnadc.Write(); > bgoadc.Write(); which leads to a Key for each object in this directory. During execution of > ntfile->Write(); root will create another key for all your objects which are connected to this directory(file). So in this case all your objects are written a second time. To avoid this there are three possibilities: - Use only the objects' Write method, means do only: > aticwrk.Write(); ... > bgoadc.Write(); - Use only the file's write method: ntfile->Write(); - or use the option argument of Write ntfile->Write(0,TObject::kOverwrite); If you want to get rid of older cycles (versions) of your objects in a file look at the documentation of TDirectory::Purge() Tim Jayoung Wu wrote: > > Hi all, > > After I produced a root file called ntfile.root, I see the contents of > the file in the following: > > root [0] TFile file("ntfile.root"); > root [1] .ls(); > TFile** ntfile.root > TFile* ntfile.root > KEY: ATICwrk aticwrk;1 The ATIC analysis Framework > KEY: TTree T;2 ATICwrk tree > KEY: TTree T;1 ATICwrk tree > KEY: TNtuple si_adc;2 SI ADC > KEY: TNtuple si_adc;1 SI ADC > KEY: TNtuple scnadc;2 SCN ADC > KEY: TNtuple scnadc;1 SCN ADC > KEY: TNtuple bgoadc;2 BGO ADC > KEY: TNtuple bgoadc;1 BGO ADC > > Could you explain how 2 KEYs are produced for each object? > > --- my code --- > TFile *ntfile = new TFile("ntuple.root","RECREATE","ATIC PEDESTAL NTUPLE > file,2); > TNtuple *si_adc = new TNtuple("si_adc","SI ADC","lay:lad:pat:pix:a0"); > TNtuple *scnadc = new TNtuple("scnadc","SCN ADC","lay:str:sid:a0:a1"); > TNtuple *bgoadc = new TNtuple("bgoadc","BGO ADC","lay:cry:a0:a1:a2"); > ATICwrk aticwrk("aticwrk"); > ... > aticwrk.Write(); > si_adc.Write(); > scnadc.Write(); > bgoadc.Write(); > ntfile->Write(); > > --- > Thanks, > Jayoung -- ------------------------------------------------------------------------ Tim Welters, III.Physikalisches Institut at the RWTH Aachen, Lehrstuhl B Room: H.116 Tel.: +49(241)80-6355 Fax: +49(241)8888-244 Postal Address: Physikzentrum, RWTH Aachen, D-52056 Aachen e-mail: welters@physik.rwth-aachen.de or Tim.Welters@cern.ch ------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET