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_DIGIRANDOMENGINE_H
0014 #define DDDIGI_DIGIRANDOMENGINE_H
0015 #if 0
0016 /// Framework include files
0017 
0018 
0019 /// C/C++ include files
0020 #include <random>
0021 #include <functional>
0022 
0023 /// Namespace for the AIDA detector description toolkit
0024 namespace dd4hep {
0025 
0026   /// Namespace for the Digitization part of the AIDA detector description toolkit
0027   namespace digi {
0028 
0029     /// Generic engine source with a random distribution
0030     /**
0031      *  Generate random engine as it appears e.g. from electronic engine
0032      *  with a given mean and a given sigma
0033      *
0034      *  \author  M.Frank
0035      *  \version 1.0
0036      *  \ingroup DD4HEP_DIGITIZATION
0037      */
0038     class DigiRandomEngine {
0039     public:
0040       typedef unsigned int result_type;
0041       std::function<double()> m_generator;
0042     public:
0043       /// Initializing constructor
0044       template <typename ENGINE> DigiRandomEngine(ENGINE* engine);
0045       /// Default destructor
0046       virtual ~DigiRandomEngine();
0047       static constexpr result_type min()   { return std::default_random_engine::min(); }
0048       static constexpr result_type max()   { return std::default_random_engine::max(); }
0049       static constexpr double      range() { return double(max()) - double(min());     }
0050       /// Callback to read event randomengine
0051       unsigned int operator()()  const     { return m_generator();                     }
0052     };
0053     /// Initializing constructor
0054     template <typename ENGINE> DigiRandomEngine::DigiRandomEngine(ENGINE* engine)   {
0055       m_generator = [this,engine]()  {
0056         static constexpr double norm =
0057           DigiRandomEngine::range() / (double(ENGINE::max() - ENGINE::min()));
0058         return result_type(double((*engine())) * norm);
0059       };
0060     }
0061   }    // End namespace digi
0062 }      // End namespace dd4hep
0063 #endif
0064 #endif // DDDIGI_DIGIRANDOMENGINE_H