// Program to illustrate use of ROOT random number and histogram classes // Glen Cowan, RHUL, Physics, November 2007 #include #include #include #include #include using namespace std; int main(){ // Open output file (apparently needs to be done before booking) TFile file("simpleMC.root", "recreate"); // Book histograms, i.e., create TH1D objects // 1st argument is a string; by convention same as object name // 2nd argument is histogram title (will appear on plots) // 3rd argument is number of bins (type int) // 4th and 5th arguments: upper and lower limits of histogram (type double) TH1D h_Uniform("h_Uniform", "uniform random numbers", 100, 0, 1.0); // Create a TRandom3 object to generate random numbers int seed = 12345; TRandom3 ran(seed); // Generate some random numbers and fill histograms const int numValues = 10000; for (int i=0; i