Fast Simulation - Random Number Generation

Complete: 5

IMPORTANT: Since CMSSW_6_0_0_pre3, no specific module is needed anymore for Fast Simulation (thanks to an update in IOMC/RandomEngine). This page stays as a documentation for earlier releases.

Random number initialization (RandomNumberGeneratorService)

Random generator initialization is steered by the RandomNumberGenerator service, a complete documentation of its use can be found here. In short, you just have to include in your cfg_py file

# Include the RandomNumberGeneratorService definition

It contains he following cryptic sequence:

 RandomNumberGeneratorService = cms.Service(


    # To save the status of the last event (useful for crashes)
    # Just give a name to the file you want the status to be saved
    # otherwise just put saveFileName = ""
    saveFileName = cms.untracked.string(''),

    # To restore the status of the last event, just un-comment the
    # following line (and comment the saveFileName line!)
    # restoreFileName = cms.string('RandomEngineState.log'),

    # To reproduce events using the RandomEngineStateProducer (source
    # excluded), comment the sourceSeed definition, and un-comment 
    # the restoreStateLabel
    # restoreStateLabel = cms.string('randomEngineStateProducer'),

    # This is to initialize the random engine of the source
    generator = cms.PSet(
        initialSeed = cms.untracked.uint32(123456789),
        engineName = cms.untracked.string('TRandom3')

    # This is to initialize the random engines used for  Famos
    VtxSmeared = cms.PSet(
        initialSeed = cms.untracked.uint32(123456789),
        engineName = cms.untracked.string('TRandom3')

    famosPileUp = cms.PSet(
        initialSeed = cms.untracked.uint32(918273),
        engineName = cms.untracked.string('TRandom3')

    famosSimHits = cms.PSet(
        initialSeed = cms.untracked.uint32(13579),
        engineName = cms.untracked.string('TRandom3')

It is important to remember that the seeds are provided to the RandomGeneratorService through this sequence, and that the random seeds have to be changed by hand, through a script, or with the method explained below in a case of a private production.

Random sequence initialization

As alluded earlier, it is possible to initialize the RandomGeneratorService with random values, and it can be useful in case of private Monte-Carlo productions when home-made tools. The technique has been described in this thread and consists in adding the following lines in the file
from IOMC.RandomEngine.RandomServiceHelper import  RandomNumberServiceHelper
randHelper =  RandomNumberServiceHelper(process.RandomNumberGeneratorService)

Then, it is safer to keep track of the RandomNumberGeneratorService state, adding

process.RandomNumberGeneratorService.saveFileName =  cms.untracked.string("RandomEngineState.log")

Review status

Reviewer/Editor and Date (copy from screen) Comments
FlorianBeaudette - 12 Nov 2008 Python update, added randhelper
PatrickJanot - 26 Apr 2007 Documentation complete
JennyWilliams - 23 Mar 2007 created template page

Responsible: AndreaGiammanco
Last reviewed by: Reviewer

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r6 - 2012-04-24 - AndreaGiammanco

    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback