1 / 11

Random Numbers in GAUDI

Random Numbers in GAUDI. Requirements Interface Usage. Requirements. Distinguish between generator and distribution Flexibility Change the random number generator if necessary No need to change user code Generate any distribution using a single generator Reproducibility

kosey
Download Presentation

Random Numbers in GAUDI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Random Numbers in GAUDI Requirements Interface Usage

  2. Requirements • Distinguish between generator and distribution • Flexibility • Change the random number generator if necessary • No need to change user code • Generate any distribution using a single generator • Reproducibility • Start simulation at any point • Initialization at each event • Set the seed necessary to restart GAUDI

  3. Architecture RndmGenSvc owns & initializes Distribution: Gauss owns uses RndmEngine RndmGen GAUDI

  4. Interface • Generator Interface • Service Interface • There is a wrapper to simplify the code /// Single shot returning single random number virtual double shoot() const = 0; /// Multiple shots returning vector with random number virtual StatusCode shootArray( std::vector<double>& array, long howmany, long start = 0) const = 0; /// Retrieve a valid generator from the service. virtual StatusCode generator( const IRndmGen::Param& par, IRndmGen*& refpGen) = 0; GAUDI

  5. IRndmGen::Param ???!!! • Defines the shape of the generated distribution • Rndm::Bit() • Rndm::Flat(double mi, double ma) • Rndm::Gauss(double mean, double sigma) • Rndm::Poisson(double mean) • Rndm::Binomial(long n, double p) • Rndm::Exponential(double mean) • Rndm::Chi2(long n_dof) • Rndm::BreitWigner(double mean, double gamma) • Rndm::BreitWignerCutOff (mean, gamma, cut-off) • Rndm::Landau(double mean, double sigma) • Rndm::DefinedPdf(const std::vector<double>& pdf, long intpol) See Gaudi/RandmGenSvc/RndmGenerators.h GAUDI

  6. Local Usage • I just need a number how do I get it quickly ? • Needs to be initialized for every event • There are some useful examples, but not always! #include “Gaudi/RandmGenSvc/RndmGenerators.h” Rndm::Numbers gauss(randSvc(), Rndm::Gauss(0.5,0.2)); if ( gauss ) { IHistogram1D* his = histoSvc()->book(); for ( long i = 0; i < 5000; i++ ) his->fill(gauss(), 1.0); } GAUDI

  7. Global Usage • Get the generator once, then keep it! • In the header file or your algorithm: • In myAlgorithm::initialize • In myAlgorithm::execute: use it! #include “Gaudi/RandmGenSvc/RndmGenerators.h” class myAlgorithm : public Algorithm { Rndm::Numbers m_gaussDist; StatusCode sc = m_gaussDist.initialize( randSvc(), Rndm::Gauss(0.5,0.2)); his->fill(m_gaussDist(), 1.0); GAUDI

  8. Dos and Don’ts • The interface allows to retrieve a bunch of random numbers • Do not keep numbers across events: Reproducibility! • Often caching does more harm than it helps • If there is a performance penalty, better find another solution • Use the wrapper • it’s easier • Do not access the RndmEngine directly • Do not manipulate the engine: Reproducability GAUDI

  9. Summary • Random generator is flexible • Many distributions possible • Easy to use • Wrapper is straight forward • Wrapper can be used with STL: operator() • Allows to be initialized by the framework in a way to ensure reproducability • As long as everyone sticks to the rules GAUDI

  10. GAUDI: Shared Libraries • LD_LIBRARY_PATH: It’s a mess! • String becomes too long for some shells • Load Shared libraries by environment • requirements: set GaudiSvcShr "${GAUDISVCROOT}/${BINDIR}/libGaudiSvc” • jobOptions: ApplicationMgr.DLLs += {“GaudiSvc”}; • LD_LIBRARY_PATHbecomes much shorter • Contains only path to images needed to start the program • Better control over usage of modules GAUDI

  11. GAUDI: CMT requirements • Include path • Instead of include_dirs $(GAUDISVCROOT) • Do the following for component libraries include_path none • Or for public libraries: include_path $(GAUDISVCROOT) • This shortens the compile statement(s) dramatically GAUDI

More Related