Tom Whyntie's CMSSW Notes

Useful links:

Goals of this page

This page aims, basically, to provide me with an area for writing down my experiences with CMSSW.

Frequently Asked Questions

How do run the full chain on an event with CMSSW? More Less

See the example in Configuration/Examples/python/FullChainExample_cfg.py. This uses a particle (see below), but you can also specify Pythia-generated events.

How do you generate events with a particle gun in CMSSW? More Less

The particle gun provides a simple way of generating single particles (with their antipartners, if requested) with specified kinematic properties. Simply add the following as your "source" in your configuration file.

process.source = cms.Source("FlatRandomEGunSource",
    PGunParameters = cms.untracked.PSet(
        # you can request more than 1 particle
        # since PartID is a vector, you can place in as many 
        # PDG id's as you wish, comma seaparated
        #
        PartID = cms.untracked.vint32(211),
        MinEta = cms.untracked.double(-0.1),
        MaxEta = cms.untracked.double(0.1),
        MinPhi = cms.untracked.double(-3.14159265359), ## in radians
        MaxPhi = cms.untracked.double(3.14159265359),
        MinE = cms.untracked.double(100.0),
        MaxE = cms.untracked.double(100.0),
    ),
    Verbosity = cms.untracked.int32(0), ## set to 1 (or greater)  for printouts

    AddAntiParticle = cms.untracked.bool(True) ## back-to-back particles

)
You can also use FlatRandomPtGunSource, specifying the MinPt and MaxPt of the particles you create.

How do you generate events with Pythia in CMSSW? More Less

You need to specify a source based on the Pythia event generator.

There are actually many pre-defined sources available in Configuration/Generator/python that can be used "out of the box" in your configuration file. To include them, add the following to your Python script before the Generator_cff process load:

...
# Includes the script specifying the Pythia source
process.load("Configuration.Generator.[name_of_genconfig]")
...

You can, of course, copy the code from these cfi.py files, include them directly in your config and edit them to your heart's desire. But that would be extra work.

Here's an example of a pure generator config: More Less


# My Generator test config.
import FWCore.ParameterSet.Config as cms

process = cms.Process("MYGENTEST")

# Load the standard services (including random number generator...?)
process.load("Configuration.StandardSequences.Services_cff")

# Load the message logger
process.load("FWCore.MessageService.MessageLogger_cfi")

# Include the QCD Pythia source
# See Configuration/Generator/python for more examples.
process.load("Configuration.Generator.QCD_Pt_120_170_cfi")

# Load the vertex smearing - needed for particle generation.
# See Configuration/StandardSequences/python for the other options available.
process.load("Configuration.StandardSequences.VtxSmearedBetafuncEarlyCollision_cff")

# This config fragment brings you the generator information
# Loading the sequences required to generated particles, pgen.
process.load("Configuration.StandardSequences.Generator_cff")

# Event output
process.load("Configuration.EventContent.EventContent_cff")

# Specify the number of events required.
process.maxEvents = cms.untracked.PSet(
    input = cms.untracked.int32(1)
)

# Specify the output ROOT file.
process.FEVT = cms.OutputModule("PoolOutputModule",
    process.FEVTSIMEventContent,
    fileName = cms.untracked.string('MyGenTest.root')
)

# Add the generator process to the path.
process.p0 = cms.Path(process.pgen)

# Specify the output path - i.e. dumping the event content.
process.outpath = cms.EndPath(process.FEVT)

# Schedule all the required processes.
process.schedule = cms.Schedule(process.p0,process.outpath)

How do you generate ee events instead of pp? Is this done in the Pythia interface code, as opposed to the being able to simply select a source from the parameters? Might be fun to investigate...!

How do you run the Fast Simulation with CMSSW? More Less

The Fast Simulation is a little bit fiddly, but worth using as it's pretty, um, fast. As I understand things, it doesn't quite use the "standard" procedures as used in the Full Chain procedures, so proceed with caution (or at least take everything here with a pinch of salt until I've understood it all properly!).

An example python configuration can be found here: FastSimulation/Configuration/test/Example_cfg.py. I've hacked it about a bit to produce this: More Less


My example fast sim config...

How do I output to a logger from my EDAnalyzer? More Less

This has been obtained from the WorkBook example.

Add the following to your EDAnalyzer:

...
#include "FWCore/MessageLogger/interface/MessageLogger.h"
...
// The following outputs whatever you like to the logger "Test".
LogInfo("Test") << "This is going to the logger.";
...

and the following to your config python file:

...
# The MessageLogger line should be there anyway
process.load("FWCore.MessageService.MessageLogger_cfi")
# This is added. "Test" is the name of the logger you post to from the EDAnalyzer.
process.MessageLogger.cerr.threshold = "INFO"
process.MessageLogger.categories.append("Test")
process.MessageLogger.cerr.INFO = cms.untracked.PSet(
    default = cms.untracked.PSet( limit = cms.untracked.int32(0) ),
    Test = cms.untracked.PSet( limit = cms.untracked.int32(-1) )
)
...

How do you extract PSimHit information from the Full and Fast Sim events? More Less

The PSimHits are...

How do you determine the DetId of a PSimHit?

How do you determine which layer a PSimHit was generated in?

How do you determine the geometric position of a PSimHit?

How do you add histogramming to your EDAnalyzer? More Less

See the CMSSW WorkBook here.

More Less

-- TomWhyntie - 02 Mar 2009

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r7 - 2009-03-03 - TomWhyntie
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

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