Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:03:29

0001 // $Id: RandBreitWigner.h,v 1.5 2010/06/16 17:24:53 garren Exp $
0002 // -*- C++ -*-
0003 //
0004 // -----------------------------------------------------------------------
0005 //                             HEP Random
0006 //                        --- RandBreitWigner ---
0007 //                           class header file
0008 // -----------------------------------------------------------------------
0009 // This file is part of Geant4 (simulation toolkit for HEP).
0010 //
0011 // Class defining methods for shooting numbers according to the
0012 // Breit-Wigner distribution algorithms (plain or mean^2).
0013 // Default values are set: mean=1, gamma=.2, cut=1.
0014 // Plain algorithm is used for shootArray() and fireArray().
0015 // Plain algorithm with default values is used for operator()(). 
0016 
0017 // =======================================================================
0018 // Gabriele Cosmo - Created: 5th September 1995
0019 //                - Added methods to shoot arrays: 28th July 1997
0020 // J.Marraffino   - Added default arguments as attributes and
0021 //                  operator() with arguments: 16th Feb 1998
0022 // M Fischler      - put and get to/from streams 12/10/04
0023 // =======================================================================
0024 
0025 #ifndef RandBreitWigner_h
0026 #define RandBreitWigner_h 1
0027 
0028 #include "CLHEP/Random/defs.h"
0029 #include "CLHEP/Random/RandFlat.h"
0030 #include "CLHEP/Utility/memory.h"
0031 
0032 namespace CLHEP {
0033 
0034 /**
0035  * @author <Gabriele.Cosmo@cern.ch>
0036  * @ingroup random
0037  */
0038 class RandBreitWigner : public HepRandom {
0039 
0040 public:
0041 
0042   inline RandBreitWigner ( HepRandomEngine& anEngine, double a=1.0,
0043                                        double b=0.2 );
0044   inline RandBreitWigner ( HepRandomEngine* anEngine, double a=1.0,
0045                                        double b=0.2 );
0046   // These constructors should be used to instantiate a RandBreitWigner
0047   // distribution object defining a local engine for it.
0048   // The static generator will be skipped using the non-static methods
0049   // defined below.
0050   // If the engine is passed by pointer the corresponding engine object
0051   // will be deleted by the RandBreitWigner destructor.
0052   // If the engine is passed by reference the corresponding engine object
0053   // will not be deleted by the RandBreitWigner destructor.
0054 
0055   virtual ~RandBreitWigner();
0056   // Destructor
0057 
0058   // Static methods to shoot random values using the static generator
0059 
0060   static  double shoot( double a=1.0, double b=0.2 );
0061 
0062   static  double shoot( double a, double b, double c );
0063 
0064   static  double shootM2( double a=1.0, double b=0.2 );
0065 
0066   static  double shootM2( double a, double b, double c );
0067 
0068   static  void shootArray ( const int size, double* vect);
0069 
0070   static  void shootArray ( const int size, double* vect,
0071                             double a, double b );
0072 
0073   static  void shootArray ( const int size, double* vect,
0074                             double a, double b, double c );
0075                            
0076   //  Static methods to shoot random values using a given engine
0077   //  by-passing the static generator.
0078 
0079   static  double shoot( HepRandomEngine* anEngine, double a=1.0,
0080                            double b=0.2 );
0081   static  double shoot( HepRandomEngine* anEngine, double a,
0082                            double b, double c );
0083   static  double shootM2( HepRandomEngine* anEngine, double a=1.0,
0084                              double b=0.2 );
0085   static  double shootM2( HepRandomEngine* anEngine, double a,
0086                              double b, double c );
0087   static  void shootArray ( HepRandomEngine* anEngine,
0088                             const int size, double* vect );
0089   static  void shootArray ( HepRandomEngine* anEngine,
0090                             const int size, double* vect,
0091                             double a, double b );
0092   static  void shootArray ( HepRandomEngine* anEngine,
0093                             const int size, double* vect,
0094                             double a, double b, double c );
0095 
0096   //  Methods using the localEngine to shoot random values, by-passing
0097   //  the static generator. These methods respect distribution parameters
0098   //  passed by the user at instantiation unless superseded by actual
0099   //  arguments in the call.
0100 
0101   double fire();
0102 
0103   double fire( double a, double b );
0104 
0105   double fire( double a, double b, double c );
0106 
0107   double fireM2();
0108 
0109   double fireM2( double a, double b );
0110 
0111   double fireM2( double a, double b, double c );
0112 
0113   void fireArray ( const int size, double* vect);
0114 
0115   void fireArray ( const int size, double* vect,
0116                    double a, double b );
0117 
0118   void fireArray ( const int size, double* vect,
0119                    double a, double b, double c );
0120   double operator()();
0121   double operator()( double a, double b );
0122   double operator()( double a, double b, double c );
0123 
0124   // Save and restore to/from streams
0125   
0126   std::ostream & put ( std::ostream & os ) const;
0127   std::istream & get ( std::istream & is );
0128 
0129   std::string name() const;
0130   HepRandomEngine & engine();
0131 
0132   static std::string distributionName() {return "RandBreitWigner";}  
0133   // Provides the name of this distribution class
0134          
0135 private:
0136 
0137   std::shared_ptr<HepRandomEngine> localEngine;
0138   double defaultA;
0139   double defaultB;
0140 
0141 };
0142 
0143 }  // namespace CLHEP
0144 
0145 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0146 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
0147 using namespace CLHEP;
0148 #endif
0149 
0150 #include "CLHEP/Random/RandBreitWigner.icc"
0151 
0152 #endif