Hi Lionel, It is not completely clear to me what you want, but probably you've just noticed the fact that if you change the values in a histogram and you redraw it, the old histogram will disappear (this is normally very convenient). So you probably want a resa->DrawCopy("same") instead of resa->Draw("same"). This will give you 12 superimposed histograms... Note that internally, for each DrawCopy, a new TH1F-object will be generated, so you might have to take care not to use this procedure too often. Ah, and you will also have to take care to get the correct Y-axis range during drawing; the way you do it now you'll get the default for an empty histogram (-1 to 1 or so). You could use a gPad->DrawFrame(xmin,ymin,xmax,ymax) instead, or use an if-statement to get the first histogram drawn without the "same" option. Good luck, Marco van Leeuwen. 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"); > c1->Update(); > } > free(text); > }
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:24 MET