```
#define MAXFLAT 8
//--------------------------------------------------------------------
//
//  Make some 1D histograms
//
//--------------------------------------------------------------------

#include <string>
#include "CLHEP/Random/DRand48Engine.h"
#include "CLHEP/Random/RandFlat.h"
#include "CLHEP/Random/RandGauss.h"
#include "CLHEP/Random/RandExponential.h"

#include "HepTuple/HepHBookHist1D.h"
#include "HepTuple/TupleManager.h"
#include "HepTuple/HBookFile.h"

#include <stdlib.h>
#include <iostream.h>
#include <math.h>

DRand48Engine someEngine;
RandFlat Rflat(someEngine);
RandGauss Rgauss(someEngine);
RandExponential Rexp(someEngine);

main()  {

int nsamp=10000;
void generate(long);

//  Book and fill some histograms in a function named generate.
generate(nsamp);

return 0;
}

void generate(long samples)  {

double x;
double mu=-0.5;
double sig=0.9;
double lambda = 2.0;
HBookFile * tManager = new HBookFile( "x2.rz" );
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",       50, 1.0f,11.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 various distributions.

for( int j=0; j<samples; j++ ) {
x = Rflat.fireInt( MAXFLAT-1 )+2;
rflat.accumulate((float)x);
x = Rgauss.fire( mu, sig );
rgaus.accumulate((float)x);
x = Rexp.fire( lambda );
rexp.accumulate((float)x);
}
rflat.release();
rgaus.release();
rexp.release();

//  Write out the histograms and bail out
cout << "\n Histograms filled.  Write the file." << endl;

tManager->write();
delete tManager;
return;
}

```