Hi,
I think there are two points that could be improved in TH1::FillRandom :
1/ Arguments specifying the range would be welcome.
2/ TH1::FillRandom should take care of the TF1 range.
For instance, say that I want to fill a histogram defined from 0 to 10 in the range 3 to 6 with 1000 events randomly chosen from a distribution y=x. I would do :
TF1* f = new TF1("f","x",3,6);
TH1* h = new TH1("h","h",10,0,10);
h -> FillRandom("h",1000,3,6);
Or :
TF1* f = new TF1("f","x",3,6);
TH1* h = new TH1("h","h",10,0,10);
h -> FillRandom("h",1000);
Currently the first function is not implemented (it would be welcome), and the second example does not behave as expected, but fills the histogram from 0 to 10 while the TF1 is defined only from 3 to 6.
Any reason for the second behaviour ? And comment on the first suggestion ?
The main workaround is to use GetRandom in a loop :
TF1* f = new TF1("f","x",3,6);
TH1* h = new TH1("h","h",10,0,10);
for (int i=0; i<1000; i++) h -> Fill(f->GetRandom(3,6));
Cheers.
Edit : Would probably have been better placed in ROOT Discussion…