Random Numbers in GAUDI - PowerPoint PPT Presentation

About This Presentation
Title:

Random Numbers in GAUDI

Description:

Set the seed necessary to restart. M.Frank LHCb/CERN. GAUDI. Architecture. RndmGenSvc ... In the header file or your algorithm: In myAlgorithm::initialize ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 12
Provided by: Fra9
Category:

less

Transcript and Presenter's Notes

Title: Random Numbers in GAUDI


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

3
Architecture
RndmGenSvc
owns initializes
Distribution Gauss
owns
uses
RndmGen
RndmEngine
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(
stdvectorltdoublegt array,
long howmany,
long start 0) const 0
/// Retrieve a valid generator from the
service. virtual StatusCode generator( const
IRndmGenParam par,
IRndmGen refpGen) 0
5
IRndmGenParam ???!!!
  • Defines the shape of the generated distribution
  • RndmBit()
  • RndmFlat(double mi, double ma)
  • RndmGauss(double mean, double sigma)
  • RndmPoisson(double mean)
  • RndmBinomial(long n, double p)
  • RndmExponential(double mean)
  • RndmChi2(long n_dof)
  • RndmBreitWigner(double mean, double gamma)
  • RndmBreitWignerCutOff (mean, gamma, cut-off)
  • RndmLandau(double mean, double sigma)
  • RndmDefinedPdf(const stdvectorltdoublegt pdf,
    long intpol)

See Gaudi/RandmGenSvc/RndmGenerators.h
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
RndmNumbers gauss(randSvc(),
RndmGauss(0.5,0.2)) if ( gauss )
IHistogram1D his histoSvc()-gtbook() for (
long i 0 i lt 5000 i )
his-gtfill(gauss(), 1.0)
7
Global Usage
  • Get the generator once, then keep it!
  • In the header file or your algorithm
  • In myAlgorithminitialize
  • In myAlgorithmexecute use it!

include Gaudi/RandmGenSvc/RndmGenerators.h cla
ss myAlgorithm public Algorithm
RndmNumbers m_gaussDist
StatusCode sc m_gaussDist.initialize( randSvc(
), RndmGauss(0.5,0.2))
his-gtfill(m_gaussDist(), 1.0)
8
Dos and Donts
  • 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
  • its easier
  • Do not access the RndmEngine directly
  • Do not manipulate the engine Reproducability

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

10
GAUDI Shared Libraries
  • LD_LIBRARY_PATH Its a mess!
  • String becomes too long for some shells
  • Load Shared libraries by environment
  • requirements
  • set GaudiSvcShr "GAUDISVCROOT/BINDIR/libGau
    diSvc
  • jobOptions
  • ApplicationMgr.DLLs GaudiSvc
  • LD_LIBRARY_PATH becomes much shorter
  • Contains only path to images needed to start the
    program
  • Better control over usage of modules

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
Write a Comment
User Comments (0)
About PowerShow.com