I would like to increase the statistic of a 1D histogram using GetRandom().
Here my initial histo:
TH1F *initial= new TH1F(“initial”,“energy histo”,1000,emin,emax);
and I filled a new histogram defined by
TH1F *highstat = new TH1F(“highstat”,“energy histo hs”,10000,emin,emax);
like this:
for (int i=1;i<=10000;i++) {
highstat->Fill(energy->GetRandom());
}
My problem is that, If I echo energy->GetRandom(), I see some repeated values (may be it is a problem of precision).
Do you know how I can avoid this ?
by advance thank you
cheers
olivier dadoun
Could you provide a short script reproducing this problem and indicate which version of ROOT you use?
see also the description and comments in class TRandom root.cern.ch/root/html514/TRandom.html
I am using Root Version 5.11/02 (19 April 2006) under mac os x10.4.
Here a short script which reproduce my problem (in attachement the input file energy.txt).
I will have a look on class TRandom .
Thank you
olivier
{
ifstream in_beam;
Double_t e;
Double_t emin=10000.,emax=0.;
in_beam.open(“energy.txt”);
TNtuple *low = new TNtuple(“low”,“ntuple energy”,“e”);
while (1)
{
in_beam >> e ;
if (!in_beam.good()) break;
low->Fill(e);
emin=TMath::Min(emin,e);
emax=TMath::Max(emax,e);
}
TH1F *energy = new TH1F(“energy”,“energy histo”,100,emin,emax);
low->Project(“energy”,“e”);
in_beam.close();
You do not write your “energy->GetRandom” numbers with enough precision on your output file. By defauly you get 6 or 7 significative digits. This is not enough in your example since your numbers are between 0 and 0.18.