Re: [ROOT] To Draw or not to Draw?

From: Annalisa De Caro (decaro@mail6.cern.ch)
Date: Thu Nov 15 2001 - 10:58:15 MET


                    Hi Tommaso,
i think that i had the same problem.
I resolved it in this fashion:

>    TCanvas *nc = new TCanvas("nc");
>    hp->Draw("");
   nc-> Update();

I hope that it is good for you also.
            Annalisa

*************************************************************************
*    University of Bologna    |                   |  decaro@bo.infn.it  *
*     Physics Department      | +39 051  20 91103 |                     *
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*    University of Salerno    |                   |                     *
* Physics Sciences Department | +39 089  96 5359  |  decaro@sa.infn.it  *
*       (INFN of Napoli)      |                   |                     *
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*     CERN - EP division      |                   | decaro@mail.cern.ch *
*        (Bld.29 R019)        | +41  22  76 77767 |                     *
*************************************************************************

On Wed, 14 Nov 2001, Tommaso Chiarusi wrote:

> Dear Rooters, I cannot see the plot I draw() using the following procedure
> that I put in my class' method Deco::PDistrib() (I generated Deco.C con
> MakeClass)
> 
> 
> 
> void Deco::PDistrib(double pmin, double pmax) 
> {
> 
>    TFile *hfile = new TFile("Pdist.root","RECREATE","DATA"); 
> 
>    _pmin = pmin; _pmax=pmax;
>    Int_t nentries = Int_t(fChain->GetEntries());
>    
>    TH1F *hp = new TH1F("hp","P distrib",_nbin,pmin,pmax);
> 
>    double areamin=100000,areamax=0;
>    Int_t nbytes = 0, nb = 0;
>    for (Int_t jentry=0; jentry<nentries;jentry++) {
>       Int_t ientry = LoadTree(jentry); 
>       nb = fChain->GetEntry(jentry);   nbytes += nb;
>       // if (Cut(ientry) < 0) continue;
> 
>       hp->Fill(tp); 
>    }
>    
>    hp->Write();
>    hfile->Close();
> 
>    TCanvas *nc = new TCanvas("nc");
>    hp->Draw(""); 
> 
> }
> 
> The fact is that the plot exist but does not appear in the canvas!
> I think that the problem is in creating and closing of TFile *hfile.
> I tried to change the position of the line 
> 
> TFile *hfile = new TFile("Pdist.root","RECREATE","DATA");
> 
> postponing it after the iteration over "jentry" but, naturally, it is the
> same!
> Neither mooving the lines
> 
>    TCanvas *nc = new TCanvas("nc");
>    hp->Draw("");
> 
> out from the "scope"
> 
> TFile *hfile = new TFile("Pdist.root","RECREATE","DATA");
> 
> ...
> 
> hfile->Close();
> 
> but it yelded the same result: no plot on the screen.
> 
> Why does it happen?
> Which mistake do I  commit?
> 
> Thanks and Cheers, Tommaso
> 
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:08 MET