Re: [ROOT] shift hist contents / RebinAxis

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sun Dec 21 2003 - 11:33:29 MET


See example below

Because the number of combinations of this kind of game is infinite,
there is no point in providing a standard function.

Rene Brun

void payman() {
   const Int_t nbins = 20;
   TH1F *h = new TH1F("h","test",nbins,-3,3);
   h->FillRandom("gaus",1000);
   TCanvas *c1 = new TCanvas("c1","c1",600,800);
   c1->Divide(1,2);
   c1->cd(1)
   h->SetFillColor(50);
   h->DrawCopy("bar2");
   c1->cd(2);
   Double_t stats[5]={0,0,0,0,0};
   h->PutStats(stats); // reset mean value, etc
   for (Int_t i=1;i<=nbins-5;i++) 
   h->SetBinContent(i,h->GetBinContent(i+5));
   for (i=nbins-5;i<=nbins;i++) h->SetBinContent(i,0);
   h->Draw("bar2");
}

On 
Sat, 20 Dec 2003, payman hosseini wrote:

> hi
> 
> i have a filled histogram, and i want to shift the bins by 5, so bins
> 1,2,3,4 and 5 will be lost. contents of bin 6 become bin 1, contents of
> bin 7 become bin 2. and the last 5 bins will be zero.
> is there a way to do this?
> 
> can you please provide a 
> RebinAxis(Axis_t x, Option_t* axis = "X")
> example?
> > 
> > i am using:
> > Windows/NT/w2000 with VC++ 7.0,compiled with debug info, version 3.10/02
> > (good old tar file)**WIN32GDKDEBUG 
> > 
> thanks,
> paymon
>  
>  
> 



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