~maddevelopers/mg5amcnlo/eft_width_expansion

« back to all changes in this revision

Viewing changes to models/check_param_card.py

  • Committer: olivier-mattelaer
  • Date: 2018-02-07 21:30:27 UTC
  • Revision ID: olivier-mattelaer-20180207213027-l1jxbycyqww1idcl
include the value of auto with in the scan summary

Show diffs side-by-side

added added

removed removed

Lines of Context:
922
922
    def iterate(self):
923
923
        """create the actual generator"""
924
924
        all_iterators = {} # dictionary of key -> block of object to scan [([param, [values]), ...]
925
 
        auto = 'Auto'
926
925
        pattern = re.compile(r'''scan\s*(?P<id>\d*)\s*:\s*(?P<value>[^#]*)''', re.I)
 
926
        self.autowidth = []
927
927
        # First determine which parameter to change and in which group
928
928
        # so far only explicit value of the scan (no lambda function are allowed)
929
929
        for block in self.order:
941
941
                        all_iterators[key].append( (param, eval(def_list)))
942
942
                    except SyntaxError, error:
943
943
                        raise Exception, "Fail to handle your scan definition. Please check your syntax:\n entry: %s \n Error reported: %s" %(def_list, error)
944
 
                    
 
944
                elif isinstance(param.value, str) and param.value.strip().lower().startswith('auto'):
 
945
                    self.autowidth.append(param)
945
946
        keys = all_iterators.keys() # need to fix an order for the scan
946
947
        param_card = ParamCard(self)
947
948
        #store the type of parameter
948
949
        for key in keys:
949
950
            for param, values in all_iterators[key]:
950
951
                self.param_order.append("%s#%s" % (param.lhablock, '_'.join(`i` for i in param.lhacode)))
951
 
 
 
952
            
952
953
        # do the loop
953
954
        lengths = [range(len(all_iterators[key][0][1])) for key in keys]
954
955
        for positions in itertools.product(*lengths):
970
971
            yield param_card
971
972
        
972
973
    
973
 
    def store_entry(self, run_name, cross, error=None):
 
974
    def store_entry(self, run_name, cross, error=None, param_card_path=None):
974
975
        """store the value of the cross-section"""
975
976
        if isinstance(cross, dict):
976
977
            info = dict(cross)
980
981
            if error is None:
981
982
                self.cross.append({'bench' : self.itertag, 'run_name': run_name, 'cross(pb)':cross})
982
983
            else:
983
 
                self.cross.append({'bench' : self.itertag, 'run_name': run_name, 'cross(pb)':cross, 'error(pb)':error})        
984
 
 
 
984
                self.cross.append({'bench' : self.itertag, 'run_name': run_name, 'cross(pb)':cross, 'error(pb)':error})   
 
985
        
 
986
        if self.autowidth and param_card_path:
 
987
            paramcard = ParamCard(param_card_path)
 
988
        for param in self.autowidth:
 
989
            self.cross[-1]['width#%s' % param.lhacode[0]] = paramcard.get_value(param.lhablock, param.lhacode)
 
990
            
985
991
    def write_summary(self, path, order=None, lastline=False, nbcol=20):
986
992
        """ """
987
993
        
996
1002
            keys.remove('bench')
997
1003
            keys.remove('run_name')
998
1004
            keys.sort()
 
1005
            if 'cross(pb)' in keys:
 
1006
                keys.remove('cross(pb)')
 
1007
                keys.append('cross(pb)')
 
1008
            if 'error(pb)' in keys:
 
1009
                keys.remove('error(pb)')
 
1010
                keys.append('error(pb)')
999
1011
 
1000
1012
        formatting = "#%s%s%s\n" %('%%-%is ' % (nbcol-1), ('%%-%is ' % (nbcol))* len(self.param_order),
1001
1013
                                             ('%%-%is ' % (nbcol))* len(keys))