//----------- hrandom.C #include "TStopwatch.h" #include "TRandom2.h" #include "TRandom3.h" #include "TH1.h" #include "TCanvas.h" #include void hrandom2() { const unsigned int nfills = 100000; cout << "Histograma 2D para " << nfills << " puntos" << endl; //////////////////////////////////////////////////// // First fill a histogram with a constant number //Create a 2D histogram (see documentation) TH2F *h2d = new TH2F("h2D","Histogram in 2D (#sigma = 0)",40,-5,5,40,-5,5); //Create random generator (see documentation) TRandom r1; //Loop over histogram and fill it for (unsigned int i=0; iFill(r1.Gaus(), r1.Gaus()); //Draw the histogram h2d->SetXTitle("Eje X"); h2d->SetYTitle("Eje Y"); h2d->SetZTitle("Eje Z"); h2d->Draw("LEGO2"); }