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10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/clhep/include/CLHEP/Random/RandGeneral.h (Version 11.3.0) and /externals/clhep/include/CLHEP/Random/RandGeneral.h (Version 8.2)


  1 // -*- C++ -*-                                      1 
  2 //                                                
  3 // -------------------------------------------    
  4 //                             HEP Random         
  5 //                          --- RandGeneral --    
  6 //                          class header file     
  7 // -------------------------------------------    
  8                                                   
  9 // Class defining methods for shooting general    
 10 // given a user-defined probability distributi    
 11                                                   
 12 // ===========================================    
 13 // S.Magni & G.Pieri  - Created: 29 April 1998    
 14 // G.Cosmo            - Added constructor usin    
 15 //                      static generator: 20 A    
 16 // S.Magni & G.Pieri  - Added linear interpola    
 17 // M. Fischler        - Added private methods     
 18 //      prepareTables(), useFlatDistribution()    
 19 //          - Added private variable oneOverNb    
 20 //              - Made the warning about shoot    
 21 //      more prominent.       14 May 1999         
 22 // M Fischler         - put and get to/from st    
 23 // ===========================================    
 24                                                   
 25 #ifndef RandGeneral_h                             
 26 #define RandGeneral_h 1                           
 27                                                   
 28 #include "CLHEP/Random/Random.h"                  
 29 #include "CLHEP/Utility/memory.h"                 
 30 #include <vector>                                 
 31                                                   
 32 namespace CLHEP {                                 
 33                                                   
 34 /**                                               
 35  * @author                                        
 36  * @ingroup random                                
 37  */                                               
 38 class RandGeneral : public HepRandom {            
 39                                                   
 40 public:                                           
 41                                                   
 42   RandGeneral ( const double* aProbFunc,          
 43     int theProbSize,                              
 44     int IntType=0 );                              
 45   RandGeneral ( HepRandomEngine& anEngine,        
 46                 const double* aProbFunc,          
 47     int theProbSize,                              
 48     int IntType=0 );                              
 49   RandGeneral ( HepRandomEngine* anEngine,        
 50                 const double* aProbFunc,          
 51     int theProbSize,                              
 52     int IntType=0 );                              
 53   // These constructors should be used to inst    
 54   // distribution object defining a local engi    
 55   // The static generator will be skipped by u    
 56   // defined below. In case no engine is speci    
 57   // default engine used by the static generat    
 58   // If the engine is passed by pointer the co    
 59   // will be deleted by the RandGeneral destru    
 60   // If the engine is passed by reference the     
 61   // will not be deleted by the RandGeneral de    
 62   // The probability distribution function (Pd    
 63   // as an array of positive real number. The     
 64   // provided. The Pdf doesn't need to be norm    
 65   // if IntType = 0 ( default value ) a unifor    
 66   // generated using the engine. The uniform n    
 67   // to the user's distribution using the cumu    
 68   // distribution constructed from his histogr    
 69   // distribution is inverted using a binary s    
 70   // bin boundary and a linear interpolation w    
 71   // bin. RandGeneral therefore generates a co    
 72   // each bin.                                    
 73   // if IntType = 1 no interpolation is perfor    
 74   // discrete distribution.                       
 75                                                   
 76   virtual ~RandGeneral();                         
 77   // Destructor                                   
 78                                                   
 79   // Methods to shoot random values using the     
 80   // N.B.: The methods are NOT static since th    
 81   // theIntegralPdf & nBins                       
 82                                                   
 83   /////////////////////                           
 84   //       //                                     
 85   // BIG RED WARNING //                           
 86   //       //                                     
 87   /////////////////////                           
 88   //                                              
 89   // The above N.B. is telling users that the     
 90   // class are NOT STATIC.  You cannot do         
 91   //  double x = RandGeneral::shoot();            
 92   // It would not make sense to provide a stat    
 93   // the default probability function look lik    
 94                                                   
 95   inline double shoot();                          
 96                                                   
 97   inline void shootArray ( const int size, dou    
 98                                                   
 99   //  Methods to shoot random values using a g    
100   //  by-passing the static generator.            
101                                                   
102   double shoot( HepRandomEngine* anEngine );      
103                                                   
104   void shootArray ( HepRandomEngine* anEngine,    
105                     double* vect );               
106                                                   
107   //  Methods using the localEngine to shoot r    
108   //  the static generator.                       
109                                                   
110   double fire();                                  
111                                                   
112   void fireArray ( const int size, double* vec    
113                                                   
114   double operator()();                            
115                                                   
116   // Save and restore to/from streams             
117                                                   
118   std::ostream & put ( std::ostream & os ) con    
119   std::istream & get ( std::istream & is );       
120                                                   
121   std::string name() const;                       
122   HepRandomEngine & engine();                     
123                                                   
124   static std::string distributionName() {retur    
125   // Provides the name of this distribution cl    
126                                                   
127                                                   
128 private:                                          
129                                                   
130   std::shared_ptr<HepRandomEngine> localEngine    
131   std::vector<double> theIntegralPdf;             
132   int nBins;                                      
133   double oneOverNbins;                            
134   int InterpolationType;                          
135                                                   
136   // Private methods to factor out replicated     
137   void prepareTable(const double* aProbFunc);     
138   void useFlatDistribution();                     
139   double mapRandom(double rand) const;            
140                                                   
141 };                                                
142                                                   
143 }  // namespace CLHEP                             
144                                                   
145 #include "CLHEP/Random/RandGeneral.icc"           
146                                                   
147 #endif                                            
148