Previous page
Overview
This page contains a few instructions on how to make RIVET routine for quick analysis
On this page:
Useful links
Official Rivet Homepage:
http://projects.hepforge.org/rivet/
CMS Rivet twiki page:
CMS/Rivet
Setting up RIVET in CMSSW
Setup your own fork of the
Rivet GitLab
repository. Version 3.1.0 is available since CMSSW_11_1_0.
cmsrel CMSSW_11_1_0
cd CMSSW_11_1_0/src
cmsenv
git clone ssh://git@gitlab.cern.ch:7999/${USER}/Rivet.git
cd Rivet
git remote add cms-gen ssh://git@gitlab.cern.ch:7999/cms-gen/Rivet.git
git pull cms-gen master
source rivetSetup.sh
scram b -j8
Create a new empty/template plugin
If the routine is prepared for a new analysis according to the CADI ID or the final Inspire ID for publications, please follow the instructions in
CMS/Rivet. Here we create code for internal tests (this example used for truth studies in
top width measurement).
Create the template:
cmsRivetMkPlugin --pag TOP --pubYear 2020 --cadiId TOP-20-999
scram b -j
It will create three files: the routine (CMS_2020_PAS_TOP_20_999.cc in
TOP/src
and two files in
TOP/data
)
Example of such code can be found in
~mpitt/public/TopWidth/rivet/Rivet/TOP/data
Creating a CMSSW Rivet generator fragment
Running the code over a gridpack
TO FILL THE INSTRUCTIONS
Running the code on GEN step output
When producing the GEN files, keep
edmHepMCProduct_generator_unsmeared
container in the output folder (for example add
--customise_commands "process.GENRAWoutput.outputCommands.append(\"keep edmHepMCProduct_generator_unsmeared_*\")"
to your cmsDriver.py command when you produce the ntuples). The following fragment (
TOP/test/runRivetAnalyzer_LHE_cfg.py
) will run the example above:
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing
options = VarParsing.VarParsing('python')
options.register('yodafile', 'test.yoda', VarParsing.VarParsing.multiplicity.singleton,VarParsing.VarParsing.varType.string, "Name of yoda output file")
options.parseArguments()
process = cms.Process("runRivetAnalysis")
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(options.maxEvents))
process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring(options.inputFiles))
process.load("GeneratorInterface.RivetInterface.rivetAnalyzer_cfi")
process.rivetAnalyzer.AnalysisNames = cms.vstring('CMS_WbWb_internal')
process.rivetAnalyzer.OutputFile = options.yodafile
process.rivetAnalyzer.HepMCCollection = cms.InputTag("generator:unsmeared")
process.p = cms.Path(process.rivetAnalyzer)
Then you can run the analysis using the following command:
file=/eos/home-m/mpitt/TopWidth/GEN/ST_4f_w_lo_diag_slc7_amd64_gcc630_CMSSW_9_3_16_tarball/output-50.root
cmsRun ${CMSSW_BASE}/src/Rivet/TOP/test/runRivetAnalyzer_LHE_cfg.py yodafile=test.yoda inputFiles=file:$file
Running the code on MINIAOD files
To run the code over the MINIAOD you should add few extra lines to the job fragment (for more info see
RivetontoAODSIM):
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing
options = VarParsing.VarParsing('python')
options.register('yodafile', 'test.yoda', VarParsing.VarParsing.multiplicity.singleton,VarParsing.VarParsing.varType.string, "Name of yoda output file")
options.parseArguments()
process = cms.Process("runRivetAnalysis")
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(options.maxEvents))
process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring(options.inputFiles))
process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
process.generator = cms.EDProducer("GenParticles2HepMCConverter",
genParticles = cms.InputTag("prunedGenParticles"),
genEventInfo = cms.InputTag("generator"),
signalParticlePdgIds = cms.vint32(),
)
process.load("GeneratorInterface.RivetInterface.rivetAnalyzer_cfi")
process.rivetAnalyzer.AnalysisNames = cms.vstring('CMS_WbWb_internal')
process.rivetAnalyzer.OutputFile = options.yodafile
process.rivetAnalyzer.HepMCCollection = cms.InputTag("generator:unsmeared")
process.p = cms.Path(process.generator*process.rivetAnalyzer)
Then you can run the analysis using the following command:
file=/store/mc/RunIISummer19UL17MiniAOD/TTJets_TuneCP5_13TeV-amcatnloFXFX-pythia8/MINIAODSIM/106X_mc2017_realistic_v6-v2/230000/30B61B0A-4A1C-0A48-8642-9232C402817E.root
cmsRun ${CMSSW_BASE}/src/Rivet/TOP/test/runRivetAnalyzer_AOD_cfg.py inputFiles=$file
Working with YODA files:
Converting to ROOT files:
To convert to a root output with histograms run
yoda2root test.yoda test.root
--
MichaelPitt - 2020-11-16