Private MC generation

🏗️ Work in progress 🚧

This guide describes private MC production. Comprehensive documentation about central MC production in CMS can be found here: https://cms-pdmv.gitbook.io.

The MC generation pipeline contains multiple steps (see figure below), which include simulation of physics processes, interactions of particles with detector material, reconstruction and triggering algorithms, etc.

_images/mc_gen.png

Reference: https://cms-pdmv.gitbook.io/project/monte-carlo-management-mcm-introduction

In this tutorial, we provide examples for generation of:

  • Run 2 Ultra Legacy (UL) datasets

  • Run 3 datasets

The generator used in these examples is MadGraph. A short MadGraph tutorial can be found here.

Typically, the conditions that should be decided before beginning the production are the following:

  • GlobalTag

  • Detector alignment (CMSSW release)

  • HLT menus

  • NanoAOD versions

In this example we are going to produce \(DY(pp\rightarrow ll)\) samples for the Run 2 Ultra Legacy (UL) campaign.

The first step of production is generation of LHE files (python files with settings) via Madgraph. In this example we are going to use the UL18 Drell-Yan LHE file already produced by the CMS PPD.

Test dataset: DYJetsToLL_M-50_TuneCP5_13TeV-madgraphMLM-pythia8

Step 0: Create your gridpack

Step 1 : LHE → GEN → SIM

In this step, we will generate a dataset in GEN-SIM format. We will start by producing events at the generator level (the four-vectors of particles), and simulate the energy footprint left by the particles interacting with detector material.

Some of the important parameters to keep in mind for such campaigns:

  • Beamspot

  • Generator fragment (specifies the process which needs to be generated)

  • Detector geometry

We start with downloading the LHE fragment (process definition, pythia settings, path to MadGraph gridpack) from McM (Monte Carlo Production Management):

mkdir run2ul_mcgen
cd run2ul_mcgen

curl -s -k https://cms-pdmv-prod.web.cern.ch/mcm/public/restapi/requests/get_fragment/TAU-RunIISummer20UL18wmLHEGEN-00001 \
    --retry 3 \
    --create-dirs \
    -o Configuration/GenProduction/python/TAU-RunIISummer20UL18wmLHEGEN-00001-fragment.py

[ -s Configuration/GenProduction/python/TAU-RunIISummer20UL18wmLHEGEN-00001-fragment.py ] || exit $?;

Then, install the CMSSW release:

For Run 2 production, we will use the CMSSW_10_6_17_patch1 release.

export SCRAM_ARCH=slc7_amd64_gcc700
source /cvmfs/cms.cern.ch/cmsset_default.sh
voms-proxy-init -voms cms

cmsrel CMSSW_10_6_17_patch1
cd CMSSW_10_6_17_patch1/src

eval `scram runtime -sh`
mv ../../Configuration .
scram b -j8
cd ../..

Finally, run cmsDriver.py to generate the events. In this example, we generate only 10 events locally. For full production, please submit this via CRAB jobs.

cmsDriver.py Configuration/GenProduction/python/TAU-RunIISummer20UL18wmLHEGEN-00001-fragment.py \
    --python_filename TAU-RunIISummer20UL18wmLHEGEN-00001_1_cfg.py \
    --eventcontent RAWSIM \
    --customise Configuration/DataProcessing/Utils.addMonitoring \
    --datatier GEN-SIM \
    --fileout file:TAU-RunIISummer20UL18GS.root \
    --conditions 106X_upgrade2018_realistic_v4 \
    --beamspot Realistic25ns13TeVEarly2018Collision \
    --customise_commands process.source.numberEventsInLuminosityBlock="cms.untracked.uint32(250)" \
    --step LHE,GEN,SIM \
    --geometry DB:Extended \
    --era Run2_2018 \
    --no_exec \
    --mc \
    -n 10

cmsRun TAU-RunIISummer20UL18wmLHEGEN-00001_1_cfg.py

Step 1 will produce a GEN-SIM output file.

Step 2 DIGI → L1 → DIGI2RAW → HLT

With pile-up

cmsDriver.py  \
    --python_filename TAU-RunIISummer20UL18DIGI-00007_1_cfg.py \
    --eventcontent RAWSIM \
    --pileup 2018_25ns_UltraLegacy_PoissonOOTPU \
    --customise Configuration/DataProcessing/Utils.addMonitoring \
    --datatier GEN-SIM-DIGI \
    --fileout file:TAU-RunIISummer20UL18DIGI-00007.root \
    --pileup_input "dbs:/MinBias_TuneCP5_13TeV-pythia8/RunIISummer20UL18SIM-106X_upgrade2018_realistic_v11_L1v1-v2/GEN-SIM" \
    --conditions 106X_upgrade2018_realistic_v11_L1v1 \
    --step DIGI,L1,DIGI2RAW \
    --geometry DB:Extended \
    --filein file:TAU-RunIISummer20UL18GS.root \
    --era Run2_2018 \
    --runUnscheduled \
    --no_exec \
    --mc \
    -n 10

Without pile-up

cmsDriver.py \
    --python_filename TAU-RunIISummer20UL18DIGI-00007_1_cfg.py \
    --eventcontent RAWSIM \
    --customise Configuration/DataProcessing/Utils.addMonitoring \
    --datatier GEN-SIM-DIGI \
    --fileout file:TAU-RunIISummer20UL18DIGI-00007.root  \
    --conditions 106X_upgrade2018_realistic_v11_L1v1 \
    --step DIGI,L1,DIGI2RAW \
    --geometry DB:Extended \
    --filein file:TAU-RunIISummer20UL18GS.root \
    --era Run2_2018 \
    --runUnscheduled \
    --no_exec \
    --mc \
    -n 10

Output : TAU-RunIISummer20UL18DIGI-00007.root

Adding the HLT objects /information.

For these samples: HLTv32 is added, which is present in CMSSW_10_2_16_UL release - note that it is different from the originally used CMSSW release!.

Create a new directory and set up CMSSW_10_2_16_UL release:

mkdir HLT_step
cd HLT_step/
export SCRAM_ARCH=slc7_amd64_gcc700
source /cvmfs/cms.cern.ch/cmsset_default.sh

cmsrel CMSSW_10_2_16_UL
cd CMSSW_10_2_16_UL/src/
voms-proxy-init -voms cms

eval `scram runtime -sh`
scram b

cd ../..

cmsDriver.py \
    --python_filename TAU-RunIISummer20UL18HLT-00011_1_cfg.py \
    --eventcontent RAWSIM \
    --customise Configuration/DataProcessing/Utils.addMonitoring \
    --datatier GEN-SIM-RAW \
    --fileout file:TAU-RunIISummer20UL18HLT-00011.root \
    --conditions 102X_upgrade2018_realistic_v15 \
    --customise_commands 'process.source.bypassVersionCheck = cms.untracked.bool(True)' \
    --step HLT:2018v32 \
    --geometry DB:Extended \
    --filein file:TAU-RunIISummer20UL18DIGI-00007.root \
    --era Run2_2018 \
    --no_exec \
    --mc \
    -n 10

cmsRun TAU-RunIISummer20UL18HLT-00011_1_cfg.py

Output: TAU-RunIISummer20UL18HLT-00011.root

Step3: AOD

This step is performed with CMSSW_10_6_17_patch1, which we already used in previous steps.

We will switch to CMSSW_10_6_17_patch1 and scram again to load CMSSW-related libraries.

cmsDriver.py \
    --python_filename TAU-RunIISummer20UL18RECO-00011_1_cfg.py \
    --eventcontent AODSIM \
    --customise Configuration/DataProcessing/Utils.addMonitoring \
    --datatier AODSIM \
    --fileout file:TAU-RunIISummer20UL18RECO-00011.root \
    --conditions 106X_upgrade2018_realistic_v11_L1v1 \
    --step RAW2DIGI,L1Reco,RECO,RECOSIM,EI \
    --geometry DB:Extended \
    --filein file:TAU-RunIISummer20UL18HLT-00011.root \
    --era Run2_2018 \
    --runUnscheduled \
    --no_exec \
    --mc \
    -n 10

cmsRun TAU-RunIISummer20UL18RECO-00011_1_cfg.py

Output : TAU-RunIISummer20UL18RECO-00011.root

Step 4: MiniAOD

MiniAODv2

This is supported in CMSSW versions starting from CMSSW_10_6_27.

cmsDriver.py \
    --python_filename TAU-RunIISummer20UL18MiniAODv2-00015_1_cfg.py \
    --eventcontent MINIAODSIM \
    --customise Configuration/DataProcessing/Utils.addMonitoring \
    --datatier MINIAODSIM \
    --fileout file:TAU-RunIISummer20UL18MiniAODv2-00015.root \
    --conditions 106X_upgrade2018_realistic_v16_L1v1 \
    --step PAT \
    --procModifiers run2_miniAOD_UL \
    --geometry DB:Extended \
    --filein file:TAU-RunIISummer20UL18RECO-00011.root \
    --era Run2_2018 \
    --runUnscheduled \
    --no_exec \
    --mc \
    -n 10

cmsRun TAU-RunIISummer20UL18MiniAODv2-00015_1_cfg.py

Step 5 : NanoAOD

NanoAODv9

For more details: https://gitlab.cern.ch/cms-nanoAOD/nanoaod-doc/-/wikis/Instructions/Private-production

mkdir nano_step
cd nano_step
source /cvmfs/cms.cern.ch/cmsset_default.sh
export SCRAM_ARCH=slc7_amd64_gcc700
voms-proxy-init -voms cms
cmsrel CMSSW_10_6_26
cd CMSSW_10_6_26/src/
eval `scram runtime -sh`
scram b
cd ../..

cmsDriver.py \
    --python_filename TAU-RunIISummer20UL18NanoAODv9-00020_1_cfg.py \
    --eventcontent NANOAODSIM \
    --customise Configuration/DataProcessing/Utils.addMonitoring \
    --datatier NANOAODSIM \
    --fileout file:TAU-RunIISummer20UL18NanoAODv9-00020.root \
    --conditions 106X_upgrade2018_realistic_v16_L1v1 \
    --customise_commands "process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False))) \\n from PhysicsTools.NanoAOD.custom_jme_cff import PrepJMECustomNanoAOD_MC; PrepJMECustomNanoAOD_MC(process)" \
    --step NANO \
    --filein file:TAU-RunIISummer20UL18MiniAODv2-00015.root \
    --era Run2_2018,run2_nanoAOD_106Xv2 \
    --no_exec \
    --mc \
    -n 10

cmsRun TAU-RunIISummer20UL18NanoAODv9-00020_1_cfg.py

This tutorial was prepared by Amandeep Kaur and Dmitry Kondratyev @ Purdue University CMS group.