// ---------------------------------------------------------------------------- // Utility functions to fill histograms with user defined random distributions. // // The first function will fill a histogram referred to by HepHist1D& hist // with num samplings drawn from the CLHEP Random distribution referred to // by HepRandom& dist. It is assumed that the user has already instantiated // the HepRandom distribution with the desired shape parameters as well as // the HepHist1D histogram with the desired range and binning. // // Usage: // // HBookFile* tManager = new HBookFile( "fillRandom.rz" ); // RanluxEngine Ranlux(19735091); // RandGamma Gamma(Ranlux,3.0,2.0); // // HepHist1D& refhist = Manager->hist1D("Gamma(3,2) 100000 entries", // 50,0.0f,10.0f); // fillRandom( Gamma, refhist, 100000 ); // // The second function will fill a histogram referred to by HepHist1D& subhist // with num samplings drawn from the histogram referred to by HepHist1D& // refhist. It is assumed that the reference histogram exists and represents // a reasonably high statistics object with the desired shape parameters. // Neither the range nor the binning of the subsample histogram is required to // be the same as that for the reference histogram. Note however that changing // the binning can produce some rather odd looking side effects. // // Usage: // // Assuming the high statistics reference histogram from the earlier example, // we make subsets from it as follows - // // HepHist1D & subhist = Manager->hist1D("Gamma(3,2) 10000 samples", // 40,-3.0f,7.0f); // fillRandom( refhist, subhist, 10000 ); // // A valid question here is, "Why is this thing in ZMtools and not in // either CLHEP/Random or HepTuple?" The answer is that we don't want // either of those to be dependent on the other. That's a nice sentiment // but putting it here makes ZMtools dependent on both CLHEP and HepTuple. // Is that a good compromise? You should live so long! // // History: // 21-Dec-1999 JMM Initial draft. // // ---------------------------------------------------------------------------- #ifndef HEPFILLRANDOM_H #define HEPFILLRANDOM_H #include "ZMutility/ZMenvironment.h" #include "HepTuple/HepHist1D.h" #include "CLHEP/Random/Randomize.h" ZM_BEGIN_NAMESPACE( zmht ) /* namespace zmht { */ void fillRandom( HepRandom& dist, HepHist1D& hist, int num ); void fillRandom( HepHist1D& refhist, HepHist1D& subhist, int num ); ZM_END_NAMESPACE( zmht ) /* } // namespace zmht */ #endif // HEPFILLRANDOM_H