Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:21

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef DDDIGI_DIGIRANDOMGENERATOR_H
0014 #define DDDIGI_DIGIRANDOMGENERATOR_H
0015 
0016 /// Framework include files
0017 
0018 /// C/C++ include files
0019 #include <functional>
0020 
0021 /// Namespace for the AIDA detector description toolkit
0022 namespace dd4hep {
0023 
0024   /// Namespace for the Digitization part of the AIDA detector description toolkit
0025   namespace digi {
0026 
0027     /// Generic generator source with a random distribution
0028     /**
0029      *  Generate random numbers according to a given distribution
0030      *
0031      *  Attention:
0032      *  ================================================================ 
0033      *  Before this distribution generator is usable, the 
0034      *  function object 'engine' must be validated!
0035      *  ================================================================ 
0036      *
0037      *  Please note:
0038      *  ============
0039      *  This code comes straight from the TRandom class of ROOT
0040      *  See for details:  https:* root.cern.ch/root/html534/TRandom.html
0041      * 
0042      *  The basic [0...1] generator is a std::function object to allow users
0043      *  to plug their own implementations
0044      * 
0045      *  I know this is not nice, but I did not see any other way to overcome
0046      *  the virtualization mechanism
0047      * 
0048      *
0049      *  \author  M.Frank
0050      *  \version 1.0
0051      *  \ingroup DD4HEP_DIGITIZATION
0052      */
0053     class DigiRandomGenerator {
0054     public:
0055       std::function<double()>  engine;
0056     public:
0057       /// Initializing constructor
0058       DigiRandomGenerator() = default;
0059       /// Default destructor
0060       virtual ~DigiRandomGenerator() = default;
0061       double random()  const;
0062       double uniform(double x1 = 1.0)   const;
0063       double uniform(double x1, double x2)   const;
0064       int    binomial(int ntotal, double probabaility)  const;
0065       double exponential(double tau)  const;
0066       double gaussian(double mean = 0.0, double sigma = 1.0)  const;
0067       double landau  (double mean = 0.0, double sigma = 1.0)  const;
0068       double breitWigner(double mean = 0.0, double gamma = 1.0)  const;
0069       double poisson(double mean)  const;
0070       void   rannor(float& a, float& b)   const;
0071       void   rannor(double& a, double& b)   const;
0072       void   sphere(double& x, double& y, double& z, double r)   const;
0073       void   circle(double &x, double &y, double r)  const;
0074     };
0075   }    // End namespace digi
0076 }      // End namespace dd4hep
0077 #endif // DDDIGI_DIGIRANDOMGENERATOR_H