CMSSW Configuration Using python

Download Report

Transcript CMSSW Configuration Using python

CMSSW Configuration Using python
Rick Wilkinson
Python configurations

Your cfg, cfi, and cffs will not be supported in
CMSSW_2_1_0.

They’ll be replaced by python equivalents

Most of the cfis and cffs have been translated,
committed, and published to CMSSW_2_1_X
 My “day job”
Why python?
Nice, readable syntax
Easy to learn
Popular
Interfaces easily to C++
Through boost::python
Why change?
Job configurations are getting big and complex
Need to easily edit configurations, both by users and
by scripts in GRID jobs
In old system, every “replace” functionality had to
be coded by hand
Some still missing, such as random access to
vectors
We’ve already had to write two systems to convert
configurations to python and back.
How different is the syntax?
Not very different. It’s based on the old system
process DIGI = {
hcalDigis = HcalDigiProducer {
bool doNoise = true
}
replace hcalDigis.doNoise = false
import FWCore.ParameterSet.Config as cms
process = cms.Process(“DIGI”)
process.hcalDigis = cms.EDProducer(“HcalDigiProducer”,
doNoise = cms.bool(True)
)
process.hcalDigis.doNoise = False
Sample
The process is the basic object representing the configuration.
import FWCore.ParameterSet.Config as cms
process = cms.Process(“SIM”)
# Input source
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring('file:gen.root')
)
# Modules
process.load(“Configuration.StandardSequences.VtxSmearedGauss_cff”)
process.load(“SimG4Core.Application.g4SimHits_cfi”)
process.g4SimHits.UseMagneticField = False
# Output
process.load(“Configuration.EventContent.EventContent_cff”)
process.FEVT = cms.OutputModule("PoolOutputModule",
process.FEVTSIMEventContent,
fileName = cms.untracked.string('sim.root')
)
# Execution paths
process.p1 = cms.Path(process.VtxSmeared+process.g4SimHits)
Translation Tools
Tools exists that will translate your file, and
automatically translate any files you include.
> python FWCore/ParameterSet/python/cfg2py.py your.cfg
dumps python-language output
> python FWCore/ParameterSet/python/translate.py Sub/Package/data/your.cff
creates a file, Sub/Package/python/your_cff.py, overwriting what was there.
> python FWCore/ParameterSet/python/comments.py Sub/Package/data/your.cff
transfers the comments in your cff to the appropriate cff.py
Other Documentation
Wiki page:
https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideAboutPythonConfigFile
Benedikt’s Tutorial:
http://indico.cern.ch/conferenceDisplay.py?confId=28445