//-------------------------------------------------------------------- // // Play around with some random number generators. // //-------------------------------------------------------------------- #include "HepTuple/HepHBookHist1D.h" #include "HepTuple/TupleManager.h" #include "HepTuple/HBookFile.h" #include "CLHEP/Random/DRand48Engine.h" #include "CLHEP/Random/RandFlat.h" #include "CLHEP/Random/RandGauss.h" #include "CLHEP/Random/RandExponential.h" ZM_USING_NAMESPACE( zmht ) #include #include "ZMutility/iostream" #include USING( namespace std ) DRand48Engine someEngine; RandFlat Rflat(someEngine); RandGauss Rgauss(someEngine); RandExponential Rexp(someEngine); // Declare the pointer to the file manager at this level to // make it available at file scope. HBookFile * tManager; int main() { int nsamp=10000; void generate(long); tManager = new HBookFile( "x1.rz" ); // Book and fill some histograms in a function named generate. generate(nsamp); // Write out the corresponding RZ file, clean up and bail out. delete tManager; return 0; } void generate(long samples) { double x; double mu=-0.5; double sig=0.9; double lambda = 2.0; cout << "Function generate called to produce " << samples << " events." << endl; // Book a gang of histograms. cout << "\n>>> Populate some 1D histograms." << endl; HepHist1D & rflat = tManager->hist1D("Flat distribution", 10, 0.0f,10.0f); HepHist1D & rgaus = tManager->hist1D("Gauss distribution", 50,-6.0f, 6.0f); HepHist1D & rexp = tManager->hist1D("Exponential distribution",50, 0.0f,10.0f); // Make some entries. Fill with random numbers from a flat distributions. for( int j=0; j>> Histograms filled. Write the file." << endl; tManager->write(); return; }