Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:37

0001 // $Id: NonRandomEngine.h,v 1.7 2011/07/01 15:20:30 garren Exp $
0002 // -*- C++ -*-
0003 //
0004 // -----------------------------------------------------------------------
0005 //                             HEP Random
0006 //                        --- NonRandomEngine ---
0007 //                          class header file
0008 // -----------------------------------------------------------------------
0009 
0010 // This class is present EXCLUSIVELY as a means to test distributions (and
0011 // other programs that depend on random numbers) by feeding them a stream
0012 // of "randoms" that the testing program supplies explicitly.
0013 //
0014 // The testing program calls setNextRandom (double) to setup the next
0015 // value to be produced when flat() is done.  
0016 //
0017 // To protect against accidental use of this NON-RANDOM engine as a random
0018 // engine, if setNextRandom () is never called, all attempts to generate
0019 // a random will fail and exit.
0020 
0021 // =======================================================================
0022 // Mark Fischler  - Created: 9/30/99
0023 // Mark Fischler    methods for distrib. instance save/restore 12/8/04    
0024 // Mark Fischler    methods for anonymous save/restore 12/27/04    
0025 // =======================================================================
0026 
0027 #ifndef NonRandomEngine_h
0028 #define NonRandomEngine_h 1
0029 
0030 #include "CLHEP/Random/defs.h"
0031 #include "CLHEP/Random/RandomEngine.h"
0032 #include <vector>
0033 
0034 namespace CLHEP {
0035 
0036 /**
0037  * @author
0038  * @ingroup random
0039  */
0040 class NonRandomEngine : public HepRandomEngine {
0041 
0042 public:
0043 
0044   NonRandomEngine();
0045   virtual ~NonRandomEngine();
0046   // Constructors and destructor
0047 
0048   void setNextRandom     (double r);
0049     // Preset the next random to be delivered
0050   void setRandomSequence (double *s, int n);
0051     // Establish a sequence of n next randoms; 
0052     // replaces setNextRandom n times.
0053   void setRandomInterval (double x);
0054     // Establish that if there is no sequence active each 
0055     // random should be bumped by this interval (mod 1) compared 
0056     // to the last.  x should be between 0 and 1.
0057 
0058   double flat();
0059   // It returns the previously established setNextRandom and bumps that up
0060   // by the non-zero randomInterval supplied.  Thus repeated calls to flat()
0061   // generate an evenly spaced sequence (mod 1).
0062 
0063   void flatArray (const int size, double* vect);
0064   // Fills the array "vect" of specified size with flat random values.
0065 
0066   virtual std::ostream & put (std::ostream & os) const;
0067   virtual std::istream & get (std::istream & is);
0068   static  std::string beginTag ( );
0069   virtual std::istream & getState ( std::istream & is );
0070 
0071   std::string name() const;
0072   static std::string engineName() {return "NonRandomEngine";}
0073 
0074   std::vector<unsigned long> put () const;
0075   bool get (const std::vector<unsigned long> & v);
0076   bool getState (const std::vector<unsigned long> & v);
0077   
0078 private:
0079 
0080   bool nextHasBeenSet;
0081   bool sequenceHasBeenSet;
0082   bool intervalHasBeenSet;
0083   double  nextRandom;
0084   std::vector<double> sequence;
0085   unsigned int nInSeq;
0086   double  randomInterval;
0087 
0088   // The following are necessary to fill virtual methods but should never 
0089   // be used:
0090 
0091   virtual void setSeed(long , int) {};
0092   virtual void setSeeds(const long * , int) {};
0093   virtual void saveStatus( const char* ) const {};
0094   virtual void restoreStatus( const char* ) {};
0095   virtual void showStatus() const {};
0096 
0097  
0098 };
0099 
0100 }  // namespace CLHEP
0101 
0102 #endif