forked from smsharma/semi-visible-jets
-
Notifications
You must be signed in to change notification settings - Fork 4
/
cmssw_info.py
66 lines (53 loc) · 3.61 KB
/
cmssw_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from __future__ import print_function
import os
from subprocess import call
import sys
this_dir = os.path.dirname(os.path.realpath(__file__))
this_sys = os.environ['SCRAM_ARCH']
class CmsswInfo(object):
""" Store CMSSW information (i.e., version and architecture) for different years """
def __init__(self, year):
self.year = year
if self.year == 2016:
self.gensim = {'version': 'CMSSW_7_1_38_patch1', 'arch': 'slc6_amd64_gcc481'} # earlier versions don't have CMSSW plug-ins for dark quark/Z2 filters
self.aod = {'version': 'CMSSW_8_0_31', 'arch': 'slc6_amd64_gcc530'}
self.mini = {'version': 'CMSSW_9_4_9', 'arch': 'slc6_amd64_gcc630'} # for miniAODv3
self.nano = {'version': 'CMSSW_10_2_15_patch2', 'arch': 'slc6_amd64_gcc700'} # using patch2 because architecture is slc6. don't want to interfere and cause issues if 2017/18 are being run in same work_space
self.install_new_pythia = True # CMSSW_7_1_38_patch1 ships with old Pythia version
elif self.year == 2017:
self.gensim = {'version': 'CMSSW_9_3_15', 'arch': 'slc7_amd64_gcc630'} # earlier versions (at least <=9_3_12) don't have CMSSW plug-ins for dark quark/Z2 filters
self.aod = {'version': 'CMSSW_9_4_10', 'arch': 'slc7_amd64_gcc630'}
self.mini = {'version': 'CMSSW_9_4_10', 'arch': 'slc7_amd64_gcc630'}
self.nano = {'version': 'CMSSW_10_2_15', 'arch': 'slc7_amd64_gcc700'}
self.install_new_pythia = False # CMSSW_9_3_15 already ships with Pythia 8.230
elif self.year == 2018:
self.gensim = {'version': 'CMSSW_10_2_15', 'arch': 'slc7_amd64_gcc700'} # earlier versions (at least <=10_2_3) don't have CMSSW plug-ins for dark quark/Z2 filters
self.aod = {'version': 'CMSSW_10_2_15', 'arch': 'slc7_amd64_gcc700'}
self.mini = {'version': 'CMSSW_10_2_15', 'arch': 'slc7_amd64_gcc700'}
self.nano = {'version': 'CMSSW_10_2_15', 'arch': 'slc7_amd64_gcc700'}
self.install_new_pythia = False # CMSSW_10_2_15 already ships with Pythia 8.230
else:
sys.exit("Only years 2016, 2017, and 2018 are supported")
self.stages = [self.gensim, self.aod, self.mini, self.nano]
def initialise_envs(self, location):
""" Initialise CMSSW environments """
for stage in self.stages:
if os.path.exists(os.path.join(location, stage['version'], 'src')):
print("{} release already exists!".format(stage['version']))
else:
_command = '{}/sourceCMSSW.sh {} {} {}'.format(this_dir, stage['version'], stage['arch'], location)
run_in_slc6_env(_command, target_arch=stage['arch'])
# Install new Pythia version if not already done so
if self.install_new_pythia:
_command = '{}/sourceNewPythiaVer.sh {} {} {}'.format(this_dir, location, self.gensim['version'], self.gensim['arch'])
run_in_slc6_env(_command, target_arch=self.gensim['arch'])
def compile_env(self, location, version, arch):
""" Compile CMSSW env """
_command = '{}/utils/compile_cmssw.sh {} {} {}'.format(os.environ['SVJ_TOP_DIR'], location, version, arch)
run_in_slc6_env(_command, target_arch=arch)
def run_in_slc6_env(command, target_arch="slc6_amd64_gcc481", current_sys=this_sys, singularity_dir=this_dir):
""" Call Singularity to set up SLC6 env if required """
if target_arch.startswith('slc6') and not current_sys.startswith('slc6'):
call('{}/run_singularity.sh "{}"'.format(singularity_dir, command), shell=True)
else:
call(command, shell=True)