/* University College London Dept of P&A Course in C++ 3C59 | all rights reserved 1999 | | class: RanCom | | | This class provides a method to generates an angle in the range 0-180 degrees | which has the correct probability distribution for Compton scattering. | | The method is: | float scatter( ) | | To use this class you need to copy RanCom.h and RanCom.cpp into your directory. | Then you need to: | #include RanCom.h into any file where you need to use this class | #include RanCom.cpp somewhere - typically at the bottom of your file containing main() | | | NOTE: In this class the angles are in degrees ! | | Author: P.Clarke */ #ifndef _rancom_hpp #define _rancom_hpp 1 #include #include class RanCom { public: //Constructor which takes two parameters //- the electron mass is in KeV //- the incident photon energy in KeV RanCom( float emass, float incident ) ; //This is the method the user needs. //It returns an angle picked randomly using the Compton scattering //probability distribution. float scatter( ) ; private: // Member variable to store electron mass in KeV float electronMass ; // Member variable to store the incident photon energy in KeV float incidentEnergy ; // Method to calculate the Compton probability functin for a givven // scattering angle float probability( float phi ) ; // Private method to return a uniform random number in the range 0-1 float uniform( ) ; }; #endif