Skip to content

Instantly share code, notes, and snippets.

@kpedro88
Created September 25, 2019 22:03
Show Gist options
  • Save kpedro88/c3b6a7d3172a15650d28956e9ec4908c to your computer and use it in GitHub Desktop.
Save kpedro88/c3b6a7d3172a15650d28956e9ec4908c to your computer and use it in GitHub Desktop.
#!/bin/bash
WHICH_CMSSW=CMSSW_9_4_14_patch1
export SCRAM_ARCH=slc6_amd64_gcc630
scramv1 project CMSSW $WHICH_CMSSW
cd $WHICH_CMSSW
eval `scramv1 runtime -sh`
# some really bad ways to get info out of scram
HEPMC_BASE=$(scram tool info hepmc | grep "HEPMC_BASE" | sed 's/HEPMC_BASE=//')
BOOST_BASE=$(scram tool info boost | grep "BOOST_BASE" | sed 's/BOOST_BASE=//')
LHAPDF_BASE=$(scram tool info lhapdf | grep "LHAPDF_BASE" | sed 's/LHAPDF_BASE=//')
# get pythia8 source and compile
git clone git@github.com:cms-externals/pythia8 -b "cms/240"
cd pythia8
./configure --enable-shared --with-boost=${BOOST_BASE} --with-hepmc2=${HEPMC_BASE} --with-lhapdf6=${LHAPDF_BASE} --with-lhapdf6-plugin=LHAPDF6.h
make -j 8
make install
# create xml for tool
cd $CMSSW_BASE
cat << 'EOF_TOOLFILE' > pythia8.xml
<tool name="pythia8" version="240">
<lib name="pythia8"/>
<client>
<environment name="PYTHIA8_BASE" default="$CMSSW_BASE/pythia8"/>
<environment name="LIBDIR" default="$PYTHIA8_BASE/lib"/>
<environment name="INCLUDE" default="$PYTHIA8_BASE/include"/>
</client>
<runtime name="PYTHIA8DATA" value="$PYTHIA8_BASE/share/Pythia8/xmldoc"/>
<use name="hepmc"/>
<use name="lhapdf"/>
</tool>
EOF_TOOLFILE
# install tool in scram
mv ${CMSSW_BASE}/pythia8.xml ${CMSSW_BASE}/config/toolbox/${SCRAM_ARCH}/tools/selected
scram setup pythia8
PYTHIA8_BASE=$(scram tool info pythia8 | grep "PYTHIA8_BASE" | sed 's/PYTHIA8_BASE=//')
# update dependent external dire, ref: https://github.com/cms-sw/cmsdist/pull/4624
cd $CMSSW_BASE
wget https://dire.gitlab.io/Downloads/DIRE-2.003.tar.gz
tar -xzf DIRE-2.003.tar.gz
cd DIRE-2.003
./configure --with-pythia8=${PYTHIA8_BASE} --enable-shared
make -j 8
make install
# toolfile for dire
cd $CMSSW_BASE
cat << 'EOF_TOOLFILE' > dire.xml
<tool name="dire" version="2.003">
<lib name="dire"/>
<client>
<environment name="DIRE_BASE" default="$CMSSW_BASE/DIRE-2.003"/>
<environment name="LIBDIR" default="$DIRE_BASE/lib"/>
<environment name="INCLUDE" default="$DIRE_BASE/include"/>
<environment name="BINDIR" default="$DIRE_BASE/bin"/>
</client>
<runtime name="PATH" default="$BINDIR" type="path"/>
<use name="root_cxxdefaults"/>
<use name="pythia8"/>
</tool>
EOF_TOOLFILE
# install
mv ${CMSSW_BASE}/dire.xml ${CMSSW_BASE}/config/toolbox/${SCRAM_ARCH}/tools/selected
scram setup dire
# update dependent external vincia, ref: https://github.com/cms-sw/cmsdist/pull/4624
cd $CMSSW_BASE
wget https://www.hepforge.org/archive/vincia/vincia-2.2.04.tgz
tar -xzf vincia-2.2.04.tgz
cd vincia-2.2.04
./configure --prefix=./ --with-pythia8=${PYTHIA8_BASE} --enable-shared
make -j 8
make install
# toolfile for vincia
cd $CMSSW_BASE
cat << 'EOF_TOOLFILE' > vincia.xml
<tool name="vincia" version="2.2.04">
<lib name="vincia"/>
<lib name="VinciaMG4"/>
<lib name="VinciaMG5"/>
<client>
<environment name="VINCIA_BASE" default="$CMSSW_BASE/vincia-2.2.04"/>
<environment name="LIBDIR" default="$VINCIA_BASE/lib"/>
<environment name="INCLUDE" default="$VINCIA_BASE/include"/>
</client>
<runtime name="VINCIADATA" value="$VINCIA_BASE/share/Vincia/xmldoc"/>
<use name="root_cxxdefaults"/>
<use name="pythia8"/>
</tool>
EOF_TOOLFILE
# install
mv ${CMSSW_BASE}/vincia.xml ${CMSSW_BASE}/config/toolbox/${SCRAM_ARCH}/tools/selected
scram setup vincia
# update CMSSW dependencies
cd $CMSSW_BASE/src
eval `scramv1 runtime -sh`
# ref: https://github.com/cms-sw/cmssw/pull/25602
git cms-merge-topic kpedro88:pythia8240_interface_9414p1
scram b checkdeps
scram b -j 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment