Fast Simulation Configuration

Complete: 3

IMPORTANT: the recommended way to create your configuration file is via cmsDriver, see documentation here.
This page stays as a reference for developers.


The Fast Simulation is fully integrated in CMSSW, therefore it is configured exactly the same way as any other CMSSW job. There are of course some FastSim-specific items, and possibilities which are described below. As you may have seen reading the FastSim documentation, the Fast Simulation is not only simulation, it is also reconstruction and trigger simulation. One can choose to do only simulation, simulation and reconstruction, simulation and HLT, simulation HLT and reconstruction. In the latter case, one can also choose to run the reconstruction only the events which pass the trigger, or an all the events. In addition, one may also want to apply a filtering on based on the GEN information. All the above possibilities can be configured, it is very flexible. As a result, one should be careful properly setting up the config files.

Configuration in the python language

Setting up the simplest configuration file (example)

In this paragraph, a very simple Fast Simulation job will be set-up. This job will do the simulation and reconstruction, no HLT and no tracker mis-alignment nor calorimeter mis-calibration will be simulated.

import FWCore.ParameterSet.Config as cms
process = cms.Process("PROD")

#number of events
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(100) )

# Include the RandomNumberGeneratorService definition

# Include the source

The first two lines are required by CMSSW. The number of events to be processed is specified with maxEvents. If this number is set to -1, all the events defined in the source will be processed, so it should be used only when an input file is read, and not when the events are generated on the fly ! The RandomNumberGeneratorService initialization is Fast Simulation-specific and is mandatory for the Fast Sim to run. The random number generator seeds for the simulation are defined therein. Follow this link to learn to generate the random seeds randomly. Finally, the source is defined. In this example, a source file present in the [[][ Configuration/Generator/python directory] is used (note that the /python/ directory is not present in the path definition). In the above example, H->ZZ->4l events for a 200 GeV/c^2 Higgs boson mass at a centre-of-mass energy of 10 TeV are simulated. These generator files are standard and have nothing Fast Simulation-specific. Some other generator files can be found here. Most of them are defined for a centre-of-mass energy of 10 TeV. Alternatively, an input file containing the GEN (or genParticles) information can be used. In this case, the syntax is as follows

process.source = cms.Source("PoolSource",
    fileNames = cms.untracked.vstring('file:input.root')

Now, some Fast Sim-specific includes. Since we don't want to simulate any tracker mis-alignment nor calorimeter mis-calibration, one should include the so-called CommonInputsFake_cff file. Since it is planned to get rid of the fake conditions sooner or later, this is going to change.

# Famos sequences (Fake conditions)
Then, the magnetic field map should be loaded:
# Parametrized magnetic field (new mapping, 3.8T)

Then, the most important file has to be included.

This file contains most of the sequences used in the Fast Simulation.

Finally, one should tell CMSSW what to run

process.p1 = cms.Path(process.famosWithTracksAndEcalClusters)

The famosWithTracksAndEcalClusters sequence is defined in FamosSequences_cff. The so-called famosWithEverything sequence contains all the reconstruction algorithm currently able to run within the Fast Simulation.

Finally, it can be wise to make the job crash in case of a missing product

process.options = cms.untracked.PSet( Rethrow = cms.untracked.vstring('ProductNotFound') )

The file thus obtained can be saved under the name and run with


In principle you should see printouts indicating the processing of the events (unless they have been removed by someone), but no output file is created. To save the output in a file for later use, the output module definition should be added

process.o1 = cms.OutputModule(
    fileName = cms.untracked.string("MyFirstFamosFile.root"),
process.outpath = cms.EndPath(process.o1)

The above lines will result in the full event content to be written into the output file. It is usually clearly overkill. Therefore several EventContents, such as the AODSIMEventContent have been defined. To apply it, one should simply include

and add process.AODSIMEventContent as a parameter of the OutputModule.


Only a few usual customizations of the configuration file thus obtained are listed in this section. Please look into the twiki for more information.

Add pile-up events

Pile-up events can be added easily with
process.famosPileUp.PileUpSimulator.averageNumber = 5.0
The default value is 0.0. See the relevant documentation SWGuideFastSimPileUp

Simulate tracker mis-alignment and calorimeter mis-calibration (example)

Follow these links for the tracker , for the ECAL and for the HCAL for a detailed documentation.

To apply the so-called start-up conditions. Remove the line with CommonInputsFake and replace it with

Add the line to define the CMS.GlobalTag. More information can be found here SWGuideFrontierConditions
process.GlobalTag.globaltag = "STARTUP_V8::All"

Tell the Fast Sim to apply the tracker mis-alignment and the calorimeter mis-calibration with

# Apply ECAL/HCAL miscalibration
process.caloRecHits.RecHitsFactory.doMiscalib = True

# Apply Tracker misalignment
process.famosSimHits.ApplyAlignment = True
process.misalignedTrackerGeometry.applyAlignment = True


  • The HCAL mis-calibration is not done through Frontier. Therefore, if you apply this recipe to use ideal conditions, you should disable the calorimeter mis-calibration by setting doMiscalib to false
  • The muon system mis-alignment is not simulated yet.
  • The so-called ideal conditions can be applied exactly the same way

Add a filter

A filter based on the generated particles can easily be included in the sequence. Several pre-defined filters exist, but in case you need to write your own, some information can be found here.

Assuming that filter1 has been defined, either directly in the configuration or in a separate file included in your configuration file:

process.filter1 = cms.EDFilter("Filter1", ...... )

one has simply to modify the path and include the filter

process.p1 = cms.Path(process.filter1*process.famosEverything)

With the previous modification in the configuration file, the generated information will be written for all the events and the reconstructed objects will be written only for the events. This is not very convenient, so the OutputModule has also to be configured to save only the events which have passed the filter. The OutputModule section thus becomes

process.o1 = cms.OutputModule(
    SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring('p1')), 
    fileName = cms.untracked.string("MyFirstFamosFile.root")

Change the vertex smearing

Be very careful, it is not the same as in the Full Sim/Reco. Have a look here

Change the geometry scenario (simulate the preshower)

Have a look at the FAQ

Setting up a configuration file with the HLT only (example)

To start with, a configuration running only the simulation and the HLT will be set-up, without calorimeter mis-calibration nor tracker mis-alignment (so the file will be used and no pile-up. As usal, it has to start with several mandatory includes that have been described in the previous section. Note that it is convenient to call the process "HLT"
import FWCore.ParameterSet.Config as cms
process = cms.Process("HLT")
# Number of events to be generated
process.maxEvents = cms.untracked.PSet(
    input = cms.untracked.int32(100)
# Include the RandomNumberGeneratorService definition
# Generate ttbar events
# Common inputs, with fake conditions
# Famos sequences
# Load the magnetic field 
This time, it has been chosen to simulate TTbar events.

Then, the L1 and HLT trigger menu have to be loaded

# L1 Emulator and HLT Setup

Contrary to what had been done in the first section of this documentation, one cannot choose randomly in FamosSequence a convenient sequence to run. Indeed, the sequences which prepare the ingredients for the HLT have to be there. As a result a simulationWithFamos has been prepared. It has to be put into an other sequence called simulation (do not change its name), which is inserted in the beginning of each HLT path. Somehow, the simulation thus becomes part of the HLT. The trigger menu is contained in the file, this file can be updated to include a different trigger menu as explained below

# Simulation sequence
process.simulation = cms.Sequence(process.simulationWithFamos)
# No reconstruction - only HLT
process.HLTEndSequence = cms.Sequence(process.dummyModule)

# HLT schedule
process.schedule = cms.Schedule()

Finally, as explained earlier, it is safer to make CMSSW crash in case of a missing product with

process.options = cms.untracked.PSet( Rethrow = cms.untracked.vstring('ProductNotFound') )
The OutputModule can also be defined if one so wish (see the first example), in this case, the outpath has to be added to the schedule with

Setting up a configuration file with the HLT and the reconstruction

There are two different possibilites. The reconstruction can be run on all the events, regardless the HLT result, or only on the events which pass the trigger, we will start with the latter.

Running the reconstruction only on the events which pass the HLT

To achieve this, the reconstruction sequence is put in the HLTEndSequence which is run at the end of each HLT path. As a result, if one of the HLT path goes up to the end, the reconstruction will be run.
process.HLTEndSequence = cms.Sequence(process.reconstructionWithFamos)
If you started from the previous simple example, the previous relines replaces the one with the dummyModule.

Running the reconstruction on all the events

In this case, the reconstruction sequence should be put into a separate path with:
process.reconstruction = cms.Path(process.reconstructionWithFamos)
The reconstruction sequence can also be in the HLTEndSequence as it was done in the previous example, it doesn't matter.

Customization with HLT

Most of the customizations listed above are applied exactly the same way.

Add a filter based on the Monte-Carlo information

The filter should be introduced in the simulation sequence, and will be therefore be present in the beginning of each HLT path. Assuming that you the HLT is run on all the events regardless of the HLT result, the filter should also be put in the reconstruction sequence.
process.simulation =  cms.Sequence(process.filter1*process.simulationWithFamos)
process.reconstruction =  cms.Path(process.filter1*process.reconstructionWithFamos)
Similarly to what has be done before, the OutputModule should be configured as to save only the events passing filter1. It can be done with
SelectEvents = cms.untracked.PSet(SelectEvents =  cms.vstring('reconstruction'))

Note: in the case when the reconstruction is run only on the events which pass the HLT, I (Florian) does not know how to save only those events.

Choose an alternate L1 menu

As you may noticed earlier, a standard L1 configuration has been included with the line
which loads the default configuration. As it can be seen from CVS, this file is loading (at least in CMSSW_2_2_0) the so-called L1Menu_2008MC_2E30_Unprescaled_cff. Some other files for various luminosity scenarii can be found here. Please contact the L1 conveners/experts for more information.

Choose a different HLT menu

A detailed documentation of the HLT simulation in the Fast Simulation can be found here. In short, the trigger menu is stored in a database (confDB). The content of the trigger menu is regularly retrieved from the database, modified to run in the Fast Simulation, and dumped into FastSimulation/Configuration/python/ The trigger menu version is therefore not part of the configuration file. The default trigger menu version is release-dependent. If one wants to change the version of trigger menu, one should first make sure that it is compatible with the release. The fact that it is listed here is mandatory, but might not be sufficient.
  • Get locally the relevant Fast Sim directory :
     addpkg FastSimulation/Configuration
  •  cd FastSimulation/Configuration/test 
  • Edit the HLTVersion file and put the new HLT menu version
  • Run the script
    . This script will retrieve the trigger menu corresponding to HLTVersion, adapt it to the Fast Sim, save the file, compile the config file and start a basic test.
  • If the test goes well, you can now run your own configuration file

Review Status

Reviewer/Editor and Date Comments
AndreaGiammanco - 24 Apr 2012 Deprecated for standard users
FlorianBeaudette - 24 Nov 2008 Completed HLT configuration
FlorianBeaudette - 08 Nov 2008 Configuration & customization without HLT
FlorianBeaudette - 05 Nov 2008 Page creation

Responsible: FlorianBeaudette
Last reviewed by:

Edit | Attach | Watch | Print version | History: r17 < r16 < r15 < r14 < r13 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r17 - 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