How to get value from histogram ?

From: Le Hoang Nguyen <chrono341989_at_gmail.com>
Date: Thu, 11 Aug 2011 22:35:19 +0700


Hello

I am new to Root and I am having some problem in taking data from histogram e.g :

void getrandomh() {
> TH1F *source = new TH1F("source","source hist",100,-3,3);
> source->FillRandom("gaus",1000);
> TH1F *final = new TH1F("final","final hist",100,-3,3);
> for (Int_t i=0;i<1000000;i++) {
> final->Fill(source->GetRandom());
> }
> double highestvalue;

> highestvalue = final->GetBinContent(0);
> std::cout << highestvalue << std::endl;

> TCanvas *c1 = new TCanvas("c1","c1",800,1000);
> c1->Divide(1,2);
> c1->cd(1);
> source->Draw();
> c1->cd(2);
> final->Draw();
> c1->cd();
> }
>

So what I need is the exported value is about ~20000 but the result is just zero ?
So would you please point out what is my problem here ? What should I use for a right result ?

With regards

L.H. Received on Thu Aug 11 2011 - 17:35:25 CEST

This archive was generated by hypermail 2.2.0 : Thu Aug 11 2011 - 23:50:01 CEST