Hi Guillaume, OK, your original message was not clear. Assuming, eg TH1F *h, you can do: h->ComputeIntegral(); Double_t *integral = h->GetIntegral(); h->SetContent(integral); h->Draw(); Rene Brun On Mon, 14 Oct 2002, Guillaume Blanc wrote: > Dear Rene, > > I'm not sure I understand what you mean. I just would like to get an > histogram which is the cumulative version of an existing one. > Here is a piece of code doing what I what. Just would like to know if > there is an easier (more rapid) way to get the same result: > > { > TCanvas *c1 = new TCanvas("c1",""); > c1->Divide(1,2); > > int nbbin =100; > double xmin = -3; > double xmax = 3.; > TH1F *gau = new TH1F("gau","", nbbin, xmin, xmax); > gau->FillRandom("gaus",10000); > c1->cd(1); > gau->Draw(); > > // We compute the cumulative version of "gau" > TH1F *toto = new TH1F("toto","", nbbin, xmin, xmax); > int total = 0; > for (int i=0;i<nbbin;i++) > { > total += gau->GetBinContent(i); > for (int k=0;k<total;k++) > { > toto->AddBinContent(i); > } > } > double norme = 1/gau->Integral(); > cout << norme << endl; > toto->Scale(norme); > c1->cd(2); > toto->Draw(); > } > > Guillaume Blanc > > > > On Sat, 12 Oct 2002, Rene Brun wrote: > > > Hi Guillaume, > > > > Have a look at > > TH1::GetRandom, FillRandom (2 functions) > > TH2::...same > > TH3::..same > > > > Rene Brun > > > > On Fri, 11 Oct 2002, Guillaume Blanc wrote: > > > > > Hello, > > > > > > I would like to know if there is an easy way to get a cumulative > > > histogram? (like "call hrndm1(histo)" in PAW) > > > > > > Guillaume Blanc > > > > > > > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:14 MET