strange behavior of FillRandom

From: Julien Bolmont <bolmont_at_in2p3.fr>
Date: Thu, 31 Mar 2011 16:32:07 +0200

Hi all,

I'm doing some experiments with FillRandom and I cannot explain what's happening. I use a TF1 with the sum of 2 gaussian curves with different separations between them to generate a TH1. If you run the macro below, you will see that the histogram looks ok at the beginning but that at the end, it doesn't reflect at all the shape of the TF1...

Is there a way to make this work ?

I use root 5.28/00 on Mac OS X 10.6.7.

Thanks a lot for your help !
Cheers,
Julien

test_bin() {

	int NbSteps = 10;
	float Peak1Pos = 2000;
	float Peak1Width = 400;
	float Peak2Pos_init = 4000;
	float Peak2Width = 400;

	TCanvas *c_lc = new TCanvas("c_lc", "c_lc", 1000, 500);
	c_lc->Divide(2, 1);


// Binning 1 minute
TH1D *h1 = new TH1D("test_h1", "test_h1", 100, 0, 6000);
// Binning 30 seconds
TH1D *h2 = new TH1D("test_h2", "test_h2", 200, 0, 6000);
// Function for generation
TF1 *f_gauss = new TF1("f_gauss","gaus(0)+gaus(3)", 0, 6000); f_gauss->SetNpx(1000); for(int k = 0; k <= NbSteps; k++) { float Peak2Pos = Peak2Pos_init - k * (Peak2Pos_init - Peak1Pos)/NbSteps; cout << "Separation (s) = " << Peak2Pos - Peak1Pos << endl; f_gauss->SetParameters(1, Peak1Pos, Peak1Width, 1, Peak2Pos, Peak2Width); c_lc->cd(1); f_gauss->Draw(); c_lc->cd(2); h2->FillRandom("f_gauss",3000); h2->Draw("E"); c_lc->Update(); sleep(2); }

} Received on Thu Mar 31 2011 - 16:32:11 CEST

This archive was generated by hypermail 2.2.0 : Thu Mar 31 2011 - 17:50:01 CEST