Sihyun Jeon

L3 Convener of CMS-EXO MC & Interpretations Subgroup.

PhD Student of Seoul National University,

Department of Physics & Astronomy, Seoul National University,

1 Gwanak-ro, Gwanak-gu, Seoul, Korea, Bldg. 23, Room. 305.

Skype : sihyun_jeon

Email :

Phone : (+82)10-6357-6284

Something before Nov 2020

Sherpa Tutorial

Setting up CMSSW environment with Sherpa v2.2.5, OpenLoops v2.0b.

source /cvmfs/
cmsrel CMSSW_10_3_0
cd CMSSW_10_3_0/src

As for the next step, checkout the SherpaInterface.

git cms-addpkg GeneratorInterface/SherpaInterface

Now get the needed run cards from the github

git clone
cd SherpaTutorial/ZtoEE_tutorial

In the directory, there are shell scripts, run cards, and rivet customisation file.

Let's create Sherpack with one of the run cards. In this tutorial session, we will only try to make LO samples with up to 1 jet in the matrix element level. Other samples would be provided from us.

mkdir python
mkdir test
cd test
cp ../data/*sh .
cp ../data/Run.dat_13TeV_ZtoEE_LO01j_OpenLoops . is the shell script containing needed options to make Sherpa libraries.

-p : name of the process (in this tutorial, it would be "13TeV_ZtoEE_LO01j_OpenLoops")

-o : this should be set to LBCR

-m mpirun -M '-n [XXX]' : Sherpa supports mpi parallelisation, [XXX] is the number of cores that would be used (in this tutorial, we will use "8" cores)

./ 13TeV_ZtoEE_LO01j_OpenLoops

After MakeSherpaLibs is finished, there would be tarball files created in the directory. The tarball files contain information about run card, integration results, compiled libraries, multiple parton interaction. Also total cross section would be calculated like below :

| |
| Total XS is 1804.62 pb +- ( 57.2028 pb = 3.16 % ) |
| |
+-----------------------------------------------------+ is the shell script to make Sherpack using prepared tarball ingredients. The only option here is "-p" where name of the process should be put in.

./ 13TeV_ZtoEE_LO01j_OpenLoops

Once the PrepareSherpaLibs is finished, python fragment would be created. We will use to later run this fragment with cmsRun.

cp ../python/

We also need to compile rivet customisation file as well in order to create yoda files which would be used for plotting. We will use Rivet-implemented code for Z->ee samples MC_ZINC_EL, MC_ZJETS_EL, ATLAS_2017_I1514251_EL.

Before compiling rivet_customisation file,'s cross section is set to 1 as below :

process.rivetAnalyzer.CrossSection = cms.double(1.)

Change the cross section to the total cross section you obtained after MakeSherpaLibs (in pb) to make fair comparison agains actual data (ATLAS_2017_I1514251_EL)

cp ../data/ ../python/
cd ..
scram b -j 4
cd test

Now using the, we will create python file to generate events.

The option added in the end (--customise=SherpaTutorial/ZtoEE_tutorial) allows us to create yoda files which would be used to make plots with Rivet. SherpaTutorial/ZtoEE_tutorial/python/ -s GEN -n 100 --no_exec --conditions auto:mc --eventcontent RAWSIM --customise=SherpaTutorial/ZtoEE_tutorial/

After doing cmsRun, there would be a newly created an yoda file named sherpa_output.yoda.

Rivet codes do not work under CMSSW_10_3_0 (not sure why) so we will use different release, CMSSW_10_0_0.

cmsrel CMSSW_10_0_0
cd CMSSW_10_0_0/src
git-cms-addpkg GeneratorInterface/RivetInterface
source GeneratorInterface/RivetInterface/test/
mkdir test
cd test

Now bring your sherpa_output.yoda to current path and copy paste existing yoda files with different number of jets/order settings from /afs/

cp /afs/*yoda .
rivet-mkhtml --mc-errs sherpa_output.yoda ZtoEE_LO012jet.yoda ZtoEE_NLO01jet.yoda ZtoEE_NLO0LO12jet.yoda

The above command line would produce rivet-plots directory containing validation results using Rivet.

Legacy Sample Recipes (2016)

source /cvmfs/
cmsrel CMSSW_9_4_6_patch1
cd CMSSW_9_4_6_patch1/src
git clone
cd sample_production_2016miniaodsim/sample_production
python &>
source /cvmfs/


Setup Rivet in CMS environment

Rivet v2.5.4 with CMSSW_10_0_0 Prerequirements : Setup gitlab ssh keys in

cmsrel CMSSW_10_0_0
cd CMSSW_10_0_0/src
git-cms-addpkg GeneratorInterface/RivetInterface
git-cms-addpkg Configuration/Generator
git clone${USER}/Rivet.git
source Rivet/
scram b -j8

Check if Rivet setup is done properly with following lines.

(1) This lists all the prestored Rivet validation codes :

rivet --list-analyses

(2) This shows detailed information of CMS_2012_I1102908 :

rivet --show-analysis CMS_2012_I1102908

NOTE When trying to compare MC samples with analyses with CMS or ATLAS data, the collision energy should be the same (can't compare 8 TeV data with 13 TeV MC samples).

Running Rivet with prestored codes

Rivet input file should be in HepMC format which is large in size (10K events ~ 1 GB). So rather than using actual HepMC event files, using filesystem pipe (fifo) is recommended.

NOTE Sacrifice is not running properly due to library issues. I put DY to dielectron samples for test runs for the time being. /afs/ Using fifo needs to be updated.

mkdir test
cp /afs/ ./
rivet -a CMS_2012_I1102908 DYtoEE _LO_0jet.hepmc

Line above would create an YODA formatted file which can be used for histogramming. Line below would create histograms defined in CMS_2012_I1102908 codes.

rivet-mkhtml Rivet.yoda

Running Rivet with new codes

This would create a new code structure for Rivet.

rivet-mkanalysis SherpaTEST

Basic structure of Rivet code is below.

//@this part only needs to be performed only once in the beginning : definition of particles, histogram settings, etc.

void init(){

FinalState fs(Cuts::abseta < 5. && Cuts::pT > 0.*GeV);

declare(fs, "FinalState"); //final state particles with |eta| < 2.5 and pT > 10 declared

ZFinder zfinder(fs, Cuts::abseta < 2.5 && Cuts::pT > 10.*GeV, PID::ELECTRON, 80*GeV, 100*GeV, 0.0, ZFinder::CLUSTERNODECAY, ZFinder::TRACK); //ZFinder input information in

declare(zfinder, "ZFinder"); //Z bosons defined with cuts on electrons, electron clusterings, and Z boson mass window 80~100 GeV

_histogram_Z_mass = bookHisto1D("Z_mass", 50, 0., 200.); //histogram booked for Z boson mass range 0~200 GeV with 50 bins


//@this part needs to be performed for every single event

void analyze(const Event& event){

const double weight = event.weight();

if(zfinder.bosons().size() = 0){

const Particle& eefromZ = zfinder.bosons()[0];

_histogram_Z_mass.fill(eefromZ.mass(), weight);



//@this part only needs to be performed only once in the end

void finalize(){

normalize(_histogram_Z_mass, 100.);//normalize histogram areas to 100.


After constructing the codes fully, scramb and check whether SherpaTEST is shown in the list with

rivet --list-analyses

Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r12 - 2020-12-01 - SiHyunJeon
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2022 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