Hi,
I cannot believe that you had a "difficult time" in doing something as
simple as what you want. Did you look at the tutorials?
Anyhow, here is a simple example
//file nsimple.C
void nsimple(Int_t ntimes=1000) {
TFile f("nsimple.root","recreate");
TNtuple *ntuple = new TNtuple("ntuple","example","x:y:z");
TRandom r;
Float_t x,y,z;
for (Int_t i=0;i<ntimes;i++) {
x = r.Uniform(1,10);
y = r.Uniform(1,10);
z = r.Uniform(1,10);
ntuple->Fill(x,y,z);
}
ntuple->Write();
}
In a Root session, do:
root > .x nsimple.C
In another session, you can do, eg:
root > TFile f("nsimple.root");
root > ntuple->Draw("x")
Rene Brun
On Wed, 11
Jun
2003, Mark VanAsseldonk wrote:
> Hi
>
> I have been having a difficult time creating what should be a basic straightforward task ie. a random number generator. I want to generate 3 random numbers each between say 1 and 10 and then assign them to an ntuple x,y,z and loop this several times to create 3 ntuple files of random data. Any assistance towards the code necessary in the loop would be greatly appreciated.
>
> Mark
>
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET