[ROOT] TNtuple::Draw("sth>>hist") and hist->Write() didn't work

From: Weijiang Dong (wjdong@physics.ucla.edu)
Date: Tue Jul 22 2003 - 02:58:56 MEST


Hi,
I have a root file which contains a Ntuple. I want to draw some of the
variables in the Ntuple into a few histograms and save the histograms into
a new root file. I have a macro to do this. When the macro ran, root 
didn't complain anything. But later when I open the new root file, the
histogram keys were visible, but they were all empty. Need your help!
btw, when I do it step by step, I can see the histrograms were correctly
plotted on the canvas, but none of them were correctly wrote into the new
root file.

here is my macro(xbadrun.C):

xbadrun(const char* input, const char* output)
{

        TH1F *pointetah = new TH1F("pointetah","emc point eta",80,-1,1);
        TH1F *pointphih = new TH1F("pointphih","emc point
phi",240,-TMath::Pi(),TMath::Pi());

        TH2F *pointetaphih = new TH2F("pointetaphih","emc point eta and
phi",80,-1,1,240,-TMath::Pi(),TMath::Pi());
        TFile f(input);
        TCut cut1="RunId!=4033025";
        TCut cut2="RunId!=4034002";
        TCut cut3="RunId!=4034005";
        TCut runcut=cut1 && cut2 && cut3;

        all->Draw("pointeta>>pointetah",runcut);
        all->Draw("pointphi>>pointphih",runcut);
        all->Draw("pointeta:pointphi>>pointetaphih",runcut);
 
        TFile fout(output,"RECREATE");
        fout.cd();
        pointetah->Write();
        pointphih->Write();
        pointetaphih->Write();

        fout.Close();
        f.Close();
}

Thanks.
Weijiang



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET