~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to madgraph/interface/common_run_interface.py

  • Committer: Paolo Torrielli
  • Date: 2016-02-18 17:03:15 UTC
  • mfrom: (262.1.71 2.3.4)
  • mto: (262.1.75 2.3.4)
  • mto: This revision was merged to the branch mainline in revision 263.
  • Revision ID: torriell@physik.uzh.ch-20160218170315-gjajinyn9929pef3
merged with newest 2.3.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
175
175
    def check_set(self, args):
176
176
        """ check the validity of the line"""
177
177
 
 
178
 
178
179
        if len(args) < 2:
179
 
            self.help_set()
180
 
            raise self.InvalidCmd('set needs an option and an argument')
 
180
            if len(args)==1 and "=" in args[0]:
 
181
                args[:] = args[0].split("=",1)
 
182
            else:
 
183
                self.help_set()
 
184
                raise self.InvalidCmd('set needs an option and an argument')
181
185
 
182
186
        if args[0] not in self._set_options + self.options.keys():
183
187
            self.help_set()
184
188
            raise self.InvalidCmd('Possible options for set are %s' % \
185
 
                                  self._set_options)
 
189
                                  (self._set_options+self.options.keys()))
186
190
 
187
191
        if args[0] in ['stdout_level']:
188
192
            if args[1] not in ['DEBUG','INFO','WARNING','ERROR','CRITICAL'] \
1062
1066
        path = pjoin(self.me_dir, 'Cards', 'reweight_card.dat')
1063
1067
        reweight_cmd.me_dir = self.me_dir
1064
1068
        reweight_cmd.import_command_file(path)
1065
 
        
 
1069
        reweight_cmd.do_quit('')
1066
1070
        # re-define current run
1067
1071
        try:
1068
1072
            self.results.def_current(self.run_name, self.run_tag)
1072
1076
    ############################################################################
1073
1077
    def do_pgs(self, line):
1074
1078
        """launch pgs"""
1075
 
 
 
1079
        
1076
1080
        args = self.split_arg(line)
1077
1081
        # Check argument's validity
1078
1082
        if '--no_default' in args:
1081
1085
        else:
1082
1086
            no_default = False
1083
1087
 
 
1088
        if no_default and not os.path.exists(pjoin(self.me_dir, 'Cards', 'pgs_card.dat')):
 
1089
            logger.info('No pgs_card detected, so not run pgs')
 
1090
            return
 
1091
 
1084
1092
        # Check all arguments
1085
1093
        # This might launch a gunzip in another thread. After the question
1086
1094
        # This thread need to be wait for completion. (This allow to have the
1087
1095
        # question right away and have the computer working in the same time)
1088
1096
        # if lock is define this a locker for the completion of the thread
1089
 
        lock = self.check_pgs(args)
 
1097
        lock = self.check_pgs(args,  no_default=no_default)
1090
1098
 
1091
1099
        # Check that the pgs_card exists. If not copy the default
1092
1100
        if not os.path.exists(pjoin(self.me_dir, 'Cards', 'pgs_card.dat')):
1093
 
            if no_default:
1094
 
                logger.info('No pgs_card detected, so not run pgs')
1095
 
                return
1096
 
 
1097
1101
            files.cp(pjoin(self.me_dir, 'Cards', 'pgs_card_default.dat'),
1098
1102
                     pjoin(self.me_dir, 'Cards', 'pgs_card.dat'))
1099
1103
            logger.info('No pgs card found. Take the default one.')
1269
1273
            args.remove('--no_default')
1270
1274
        else:
1271
1275
            no_default = False
 
1276
            
 
1277
        if no_default and  not os.path.exists(pjoin(self.me_dir, 'Cards', 'delphes_card.dat')):
 
1278
            logger.info('No delphes_card detected, so not run Delphes')
 
1279
            return
 
1280
            
1272
1281
        # Check all arguments
1273
1282
        # This might launch a gunzip in another thread. After the question
1274
1283
        # This thread need to be wait for completion. (This allow to have the
2054
2063
        return self.deal_multiple_categories(completion)
2055
2064
        
2056
2065
 
 
2066
    def update_make_opts(self):
 
2067
        """update the make_opts file writing the environmental variables
 
2068
        stored in make_opts_var"""
 
2069
        make_opts = os.path.join(self.me_dir, 'Source', 'make_opts')
 
2070
        tag = '#end_of_make_opts_variables\n'
 
2071
        content = open(make_opts).read()
 
2072
 
 
2073
        # if this is not the first time that the file is updated, there
 
2074
        # should be a line #end_of_make_opts_variables
 
2075
        if tag in content:
 
2076
            content = content.split(tag)[1]
 
2077
 
 
2078
        variables = '\n'.join('%s=%s' % (k,v) for k, v in self.make_opts_var.items())
 
2079
        variables += '\n%s' % tag
 
2080
 
 
2081
        open(make_opts, 'w').write(variables + content)
 
2082
        return
 
2083
 
 
2084
 
 
2085
 
2057
2086
# lhapdf-related functions
2058
2087
    def link_lhapdf(self, libdir, extra_dirs = []):
2059
2088
        """links lhapdf into libdir"""
2080
2109
        # just create the PDFsets dir, the needed PDF set will be copied at run time
2081
2110
        if not os.path.isdir(pjoin(libdir, 'PDFsets')):
2082
2111
            os.mkdir(pjoin(libdir, 'PDFsets'))
2083
 
        os.environ['lhapdf'] = 'True'
2084
 
        os.environ['lhapdf_config'] = self.options['lhapdf']
 
2112
        self.make_opts_var['lhapdf'] = self.options['lhapdf']
 
2113
        self.make_opts_var['lhapdfversion'] = lhapdf_version[0]
 
2114
        self.make_opts_var['lhapdf_config'] = self.options['lhapdf']
2085
2115
 
2086
2116
 
2087
2117
    def get_characteristics(self, path=None):