CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

RandGaussT.cc

Go to the documentation of this file.
00001 // $Id: RandGaussT.cc,v 1.3.4.1 2005/03/18 22:26:48 garren Exp $
00002 // -*- C++ -*-
00003 //
00004 // -----------------------------------------------------------------------
00005 //                             HEP Random
00006 //                          --- RandGaussT ---
00007 //                      class implementation file
00008 // -----------------------------------------------------------------------
00009 
00010 // =======================================================================
00011 // M Fischler     - Created 04 Feb 2000
00012 // M Fischler     - put and get to/from streams 12/13/04
00013 // M Fischler     - operator() modified to use localEngine 12/13/04
00014 // =======================================================================
00015 
00016 #include "CLHEP/Random/defs.h"
00017 #include "CLHEP/Random/RandGaussT.h"
00018 #include <iostream>
00019 
00020 namespace CLHEP {
00021 
00022 std::string RandGaussT::name() const {return "RandGaussT";}
00023 HepRandomEngine & RandGaussT::engine() {return RandGauss::engine();}
00024 
00025 RandGaussT::~RandGaussT() {
00026 }
00027 
00028 RandGaussT::RandGaussT(const RandGaussT& right) :  RandGauss(right) {
00029 }
00030 
00031 double RandGaussT::operator()() {
00032   return HepStat::flatToGaussian(localEngine->flat()) * defaultStdDev 
00033                                                                 + defaultMean;
00034 }
00035 
00036 double RandGaussT::operator()( double mean, double stdDev ) {
00037   return HepStat::flatToGaussian(localEngine->flat()) * stdDev + mean;
00038 }
00039 
00040 void RandGaussT::shootArray( const int size, double* vect,
00041                             double mean, double stdDev )
00042 {
00043    int i;
00044 
00045    for (i=0; i<size; ++i) {
00046      vect[i] = shoot(mean,stdDev);
00047    }
00048 }
00049 
00050 void RandGaussT::shootArray( HepRandomEngine* anEngine,
00051                             const int size, double* vect,
00052                             double mean, double stdDev )
00053 {
00054    int i;
00055 
00056    for (i=0; i<size; ++i) {
00057      vect[i] = shoot(anEngine,mean,stdDev);
00058    }
00059 }
00060 
00061 void RandGaussT::fireArray( const int size, double* vect)
00062 {
00063    int i;
00064 
00065    for (i=0; i<size; ++i) {
00066      vect[i] = fire( defaultMean, defaultStdDev );
00067    }
00068 }
00069 
00070 void RandGaussT::fireArray( const int size, double* vect,
00071                            double mean, double stdDev )
00072 {
00073    int i;
00074 
00075    for (i=0; i<size; ++i) {
00076      vect[i] = fire( mean, stdDev );
00077    }
00078 }
00079 
00080 std::ostream & RandGaussT::put ( std::ostream & os ) const {
00081   int pr=os.precision(20);
00082   os << " " << name() << "\n";
00083   RandGauss::put(os);
00084   os.precision(pr);
00085   return os;
00086 }
00087 
00088 std::istream & RandGaussT::get ( std::istream & is ) {
00089   std::string inName;
00090   is >> inName;
00091   if (inName != name()) {
00092     is.clear(std::ios::badbit | is.rdstate());
00093     std::cerr << "Mismatch when expecting to read state of a "
00094               << name() << " distribution\n"
00095               << "Name found was " << inName
00096               << "\nistream is left in the badbit state\n";
00097     return is;
00098   }
00099   RandGauss::get(is);
00100   return is;
00101 }
00102 
00103 }  // namespace CLHEP
00104 

Generated on Thu Jul 1 22:02:30 2010 for CLHEP by  doxygen 1.4.7