Download presentation
Presentation is loading. Please wait.
Published byLydia Ramsey Modified over 9 years ago
1
M.Frank LHCb/CERN Random Numbers in GAUDI ã Requirements ã Interface ã Usage
2
M.Frank LHCb/CERNGAUDI 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
M.Frank LHCb/CERNGAUDI Architecture RndmGenSvc RndmGen RndmEngine Distribution: Gauss owns & initializes uses owns
4
M.Frank LHCb/CERNGAUDI Interface /// Single shot returning single random number virtual double shoot() const = 0; /// Multiple shots returning vector with random number virtual StatusCode shootArray( std::vector & array, long howmany, long start = 0) const = 0; ã Generator Interface ã Service Interface ã There is a wrapper to simplify the code /// Retrieve a valid generator from the service. virtual StatusCode generator( const IRndmGen::Param& par, IRndmGen*& refpGen) = 0;
5
M.Frank LHCb/CERNGAUDI 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 & pdf, long intpol) See Gaudi/RandmGenSvc/RndmGenerators.h
6
M.Frank LHCb/CERNGAUDI ã 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); } Local Usage
7
M.Frank LHCb/CERNGAUDI ã Get the generator once, then keep it! ä In the header file or your algorithm: ã In myAlgorithm::initialize ã In myAlgorithm::execute: use it! StatusCode sc = m_gaussDist.initialize( randSvc(), Rndm::Gauss(0.5,0.2)); Global Usage #include “Gaudi/RandmGenSvc/RndmGenerators.h” class myAlgorithm : public Algorithm { Rndm::Numbers m_gaussDist; his->fill(m_gaussDist(), 1.0);
8
M.Frank LHCb/CERNGAUDI 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
9
M.Frank LHCb/CERNGAUDI 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
M.Frank LHCb/CERNGAUDI 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_PATH becomes much shorter ä Contains only path to images needed to start the program ã Better control over usage of modules
11
M.Frank LHCb/CERNGAUDI 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.