Re: [ROOT] What do i wrong ?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue May 02 2000 - 18:04:16 MEST


Hi Lionel,

Once you have called object.Draw in a canvas, to see an updated version
of the canvas in case your object has been modified since the initial
object.Draw, you have to declare that the canvas has been modified.
You do not need to draw again the object.
I have replaced in your code below, the statement
   resa->Draw("same");
by
   c1->Modified();

For explanations of the Drawing principles of Root, see URL:

http://root.cern.ch/root/HowtoDraw.html

Rene Brun

Neukermans Lionel wrote:
> 
> Dear Rooters,
> 
> I writed a simple macro below which takes a TH1F *resb in a file
> toto.root,
> made a x-axis translation of resb and put it in a TH1F *resa
> I want to draw all resa in the same canvas
> When i run this macro, it is like the "SAME" option is unconsidered.
> So, what do i wrong?
> Thanks.
> 
> Lionel NEUKERMANS.
> 
> {
>  gROOT->Reset();
> 
> TFile *toto =  new TFile("toto.root","read");
> toto->cd();
> c1 = new TCanvas("c1","c1",5,5,500,500);
> c1->Draw();
> c1->Update();
> 
> char *text;
> text = (char*) calloc (100,sizeof(char));
> 
> Float_t resval;
> TH1F *resa, *resb;
> 
> resa = new TH1F("resa","resa",150,0.,150.);
> resa->Draw();
> 
> Int_t ieta;
> Int_t ibin, itime;
> 
> for(ieta=32;ieta<44;ieta++) {
>       sprintf(text,"h%d",ieta);
>       resb = (TH1F*) toto->Get(text);
>       printf("lay=%d phi=%d eta=%d ",ilay,iphi,ieta);
> 
>       for(ibin=0;ibin<125;ibin++)  {
>         itime =  ibin-eta;
> 
>         if(itime<0)  resval=0.;
>         else {
>           resval = resb->GetBinContent(ibin);
>           resa->SetBinContent(itime+1,resval);
>           }
>       }
//   >       resa->Draw("SAME"); //<=======this line commented
        c1->Modified();  //<===========new line
>       c1->Update();
>    }
> free(text);
> }



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:24 MET