コード例 #1
0
    def use_table(self, tabletype, spacing=0.002):
        """Turn on the xvg table option, and generate a user-defined table 
    defined in self.xvg_lines, generated by the TableMaker object, with the specifications:showParams

    OPTIONS 
        tabletype =  a TableMaker.Dielectric derived class:
                     'Switch_Shift'	(default) GROMACS-style tapered cutoffs
                     'SF3'		ShenFreed 3 table
                     'ReactionField'    rxn field dielectric solvent model

    TableMaker examples:
    # table=TableMaker(spacing=0.002)

    # tabletype=SF3(length_scale=4.0)
    # tabletype=Switch_Shift()
    # tabletype=ReactionField(rc=1.0)

    # settings for eps->Infinity
    # tabletype.krf = 1.0 / ( 2.0 * tabletype.rc )
    # tabletype.crf = 3.0 / ( 2.0 * tabletype.rc ) 

    # table=table.make(tabletype)

    # print table
    """

        self.use_xvg = True
        self.tabletype = tabletype
        self.tablemaker = TableMaker(spacing=spacing)
        self.tabletxt = self.tablemaker.make(self.tabletype)

        # set the user-table flags in the the mdp file
        self.setParameter('coulombtype', 'user')
        self.setParameter('vdwtype', 'user')
コード例 #2
0
def test():
    """To test code in imported modules"""
    tableMaker.test()
    boardAnalyser.test()
    game.test()
    player.test()
    utils.test()
    ui.test()
コード例 #3
0
ファイル: MdpFile.py プロジェクト: dkyu/mmtools
  def use_table(self, tabletype, spacing=0.002):   
    """Turn on the xvg table option, and generate a user-defined table 
    defined in self.xvg_lines, generated by the TableMaker object, with the specifications:showParams

    OPTIONS 
        tabletype =  a TableMaker.Dielectric derived class:
                     'Switch_Shift'	(default) GROMACS-style tapered cutoffs
                     'SF3'		ShenFreed 3 table
                     'ReactionField'    rxn field dielectric solvent model

    TableMaker examples:
    # table=TableMaker(spacing=0.002)

    # tabletype=SF3(length_scale=4.0)
    # tabletype=Switch_Shift()
    # tabletype=ReactionField(rc=1.0)

    # settings for eps->Infinity
    # tabletype.krf = 1.0 / ( 2.0 * tabletype.rc )
    # tabletype.crf = 3.0 / ( 2.0 * tabletype.rc ) 

    # table=table.make(tabletype)

    # print table
    """

    self.use_xvg = True
    self.tabletype = tabletype
    self.tablemaker = TableMaker(spacing=spacing)
    self.tabletxt = self.tablemaker.make(self.tabletype)
    
    # set the user-table flags in the the mdp file 
    self.setParameter('coulombtype','user')
    self.setParameter('vdwtype','user')
コード例 #4
0
# the command line option. If the file doesn't exist, execution will stop
net = kicad_netlist_reader.netlist(sys.argv[1])
Components = net.getInterestingComponents()

# Create the NetList and componentList lists
NetList = getNetList(net)
componentList = getComponentList(net)

# printNetList(NetList);
# printComponentList(componentList);

# Get an Anchor component and start Paths
Tables = []
tableCount = 0
while (len(componentList) > 0):
    Tables.append(TableMaker())
    table = Tables[tableCount]
    Paths = CablePaths()
    for component in componentList:
        if (component['isAnchor'] == True):
            # start Paths
            for i, connection in enumerate(component['connections']):
                position = connection['pin']
                pathName = Paths.addPath(position, component['ref'],
                                         connection['net'])
                table.addPath(pathName)
            table.sortTable()
            # Add Headers
            for path in Paths.getPaths():
                table.addComponent(component, path, Components,
                                   Paths.getPaths(), NetList)
コード例 #5
0
class MdpFile(object):
    """A class to store and manipulate Gromacs mdp files.

  TODO
    Can we make use of the Units class to allow user to specify parameters with units attached and automatically convert to/from gromacs units?
  """

    # Class data
    MAXSEED = 2**30  # maximum random number seed

    def __init__(self, mdpfile=None, debug=False):
        """Constructor to initialize mdp file container.
  
    OPTIONAL ARGUMENTS
      mdpfile        filename (string) or contents (list of strings) of a gromacs .mdp file to be read
    """

        # set debug flag
        self.debug = debug

        # store filename of .mdp file initialized from, if any
        self.templatefile = None
        if type(mdpfile) == str:
            self.templatefile = mdpfile

        # initialize internal storage
        self.lines = []
        self.params = {
        }  # {keyword:value} dictionary.  NOTE: All values are stored as strings: i.e. {'rlist':'4.0'}
        self.keywords = [
        ]  # keep a list of the keyword order, just so we can write oiut *.mdp files in the same order as the template

        # read .mdp file or process contents, if give
        if mdpfile:
            [self.lines, self.params, self.keywords,
             self.keyword_line_index] = self.read(mdpfile)

        # settings for user-defined tables
        self.use_xvg = False
        self.tablemaker = None
        self.tabletype = None
        self.tabletxt = None

        return

    def use_table(self, tabletype, spacing=0.002):
        """Turn on the xvg table option, and generate a user-defined table 
    defined in self.xvg_lines, generated by the TableMaker object, with the specifications:showParams

    OPTIONS 
        tabletype =  a TableMaker.Dielectric derived class:
                     'Switch_Shift'	(default) GROMACS-style tapered cutoffs
                     'SF3'		ShenFreed 3 table
                     'ReactionField'    rxn field dielectric solvent model

    TableMaker examples:
    # table=TableMaker(spacing=0.002)

    # tabletype=SF3(length_scale=4.0)
    # tabletype=Switch_Shift()
    # tabletype=ReactionField(rc=1.0)

    # settings for eps->Infinity
    # tabletype.krf = 1.0 / ( 2.0 * tabletype.rc )
    # tabletype.crf = 3.0 / ( 2.0 * tabletype.rc ) 

    # table=table.make(tabletype)

    # print table
    """

        self.use_xvg = True
        self.tabletype = tabletype
        self.tablemaker = TableMaker(spacing=spacing)
        self.tabletxt = self.tablemaker.make(self.tabletype)

        # set the user-table flags in the the mdp file
        self.setParameter('coulombtype', 'user')
        self.setParameter('vdwtype', 'user')

        # NOTE: the acual 'table.xvg' file will be written by System.prepare()

    def read(self, mdpfile):
        """Read the contents of a gromacs .mdp file.

    ARGUMENTS
      mdpfile (string or list of strings) - if a string is provided, the contents of the file are read;
                                            if a list is provided, this is interpreted as the contents of an mdp file
    """

        # handle multiple argument types
        if (type(mdpfile) == list):
            lines = mdpfile
        elif (type(mdpfile) == str):
            # if a filename is provided, get its contents
            fin = open(mdpfile, 'r')
            lines = fin.readlines()
            # remove extraneous newlines
            lines = map(lambda x: x.rstrip("\n"), lines)
            fin.close()
        else:
            raise "Unrecognized argument: " + repr(mdpfile)

        # build an initial dictionary of key:values from the lines
        [params, keywords, keyword_line_index] = self.buildParameterDict(lines)

        return [lines, params, keywords, keyword_line_index]

    def write(self, filename):
        """Write contents of .mdp file to disk.

    ARGUMENTS
      filename (string) - the filename to write to
    """

        fout = open(filename, 'w')
        for line in self.lines:
            fout.write(line + '\n')
        fout.close()

        return

    def write_table(self, filename):
        """Writes the lines of self.tabletxt to user-supplied filename in correct directory -- should be 'table.xvg'

    ARGUMENTS
      filename (string) - the name of the file to be written

    """

        fout = open(filename, 'w')
        fout.write(self.tabletxt)
        fout.close()

        return

    def buildParameterDict(self, lines):
        """Goes through each line of the file,and parses keywords into a key:value dictionary

    ARGUMENTS
      lines (list) - the contents of the .mdp file from which the dictionary is to be built

    RETURNS
      params (dict) - dictionary of key:value processed from contents of file
      keywords (list) - list of keywords found in the file
      keyword_line_index (dict) - keyword_line_index[keyword] is the line index on which 'keyword' appears

    TODO
      The processing here is very rudimentary -- may need to be modified to accomodate multiple arguments per line.
      We should store the corresponding original line from the file, or store the complete contents of the line (including comments?)
      
    """

        params = dict()
        keywords = list()
        keyword_line_index = dict()
        line_index = 0
        for line in lines:
            # strip comments
            index = line.find(';')
            if index > -1:
                line = line[0:index]
            # strip whitespace from both ends of line
            line = line.strip()
            # split off keyword
            fields = line.split()
            # if key = values ... is found, store
            if (len(fields) >= 3) and (fields[1] == '='):
                # extract keywords
                keyword = fields[0]
                # extract value(s)
                index = line.find('=')
                values = line[index + 1:len(line)].strip()
                # store
                params[keyword] = values
                keywords.append(keyword)
                keyword_line_index[keyword] = line_index
            # increment line index
            line_index += 1

        return [params, keywords, keyword_line_index]

    def showParams(self):
        """Display dictionary of recognized key:value pairs from mdp file.
    """
        outstr = ''
        for key in self.keywords:
            outstr = outstr + self.keyword2line(key)
        print outstr

        return

    def showLines(self):
        """Display lines.
    """
        contents = ''
        for line in self.lines:
            contents += line + '\n'
        print contents

        return

    def keyword2line(self, keyword):
        """Takes in a parameter keyword and returns a formatted mdp file line.

    ARGUMENTS
      keyword (string) - the keyword specifying the formatted mdp line to retrieve

    RETURNS
      the formatted mdp line corresponding to the keyword, if found

    TODO
      What if keyword isn't found?
      We should store the corresponding original line from the file, or store the complete contents of the line (including comments?)      

    """
        return '%-20s = %-20s\n' % (keyword, self.params[keyword])

    def setParameter(self, keyword, valuestr):
        """Sets a particular mdp keyword to a value (string) in the parameter dictionary, updates mdp lines.

    ARGUMENTS
      keyword (string) - the keyword to which the parameter is to be assigned
      valuestr (string) - the corresponding parameter value to assign to the keyword

    TODO
      Searching in the parameter file can be facilitated if we store a dictionary of which line a keyword is specified on.
    """

        # determine whether the keyword already exists
        keyword_exists = self.keyword_line_index.has_key(keyword)

        # set keyword in dictionary (creating or overriding)
        self.params[keyword] = valuestr

        # create a new line from this keyword-value pair
        line = self.keyword2line(keyword)

        if keyword_exists:
            # if keyword exists, replace the line
            line_index = self.keyword_line_index[keyword]
            self.lines[line_index] = line
        else:
            # if keyword does not exists, add a line
            self.lines.append(line)
            self.keywords.append(keyword)  # add the keyword to the list
            self.keyword_line_index[keyword] = len(
                self.lines) - 1  # store line number of the appended line

        return

    def getParameter(self, keyword):
        """Returns the value associated with a particular parameter; or None if the parameter is not set"""
        if keyword not in self.params:
            return None
        return self.params[keyword]

    def setTemperature(self, temperature):
        """Set the temperature of the various options.

    """

        # Set the temperature parameters
        self.setParameter('gen_temp', temperature)
        self.setParameter('ref_t', temperature)
        return

    def randomizeSeed(self):
        """Randomize the random seed, adding one if none exists.

    TODO
    Uses range from 1 to 2**30 for now, but should figure out acceptable range for gromacs.
    """

        # choose a new random seed
        import random
        self.setParameter('gen_seed', str(random.randint(1, self.MAXSEED)))
        self.setParameter('mc_seed', str(random.randint(1, self.MAXSEED)))

        return

    def setParametersFromDict(self, paramdict):
        """Takes in a set of parameters as a dictionary of {keyword:value} entries (values are strings) and sets parameters for each.

    ARGUMENTS
      paramdict (dict) - a dictionary of keyword:value pairs to be used to update parameters
    """

        for [key, value] in paramdict.iteritems():
            if self.debug: print 'DEBUG: key, value of paramdict{}', key, value
            self.setParameter(key, value)

        return

    def delParameter(self, keyword):
        """Removes a particular mdp keyword (and its value (string)) from the parameter dictionary, and deletes mdp line.

    ARGUMENTS
      keyword (string) - the keyword to be cleared

    TODO
      Propose new name of clearParameter or removeParameter
    """

        # remove keyword from dictionary
        if self.params.has_key(keyword):
            del self.params[keyword]

        # replace instances of this 'keyword = value' in the mdp lines
        i = 0
        while i < len(self.lines):
            fields = self.lines[i].strip().split()
            if len(fields) > 0:
                if fields[0] == keyword:
                    self.lines.pop(i)
                else:
                    i = i + 1
            else:
                i = i + 1

        return
コード例 #6
0
ファイル: plot_cfg.py プロジェクト: mtrovato/Analysis_CMS
    process.start()

for process in p_plot:
    process.join()

print '\n'

     ####################
     ### MAKE TABLES! ###
     ####################

if doYields:
    doPresel        = True
    outFile         = file('yields/.yields_tmp.tex', 'w')
    categoryNames   = []
    yieldTable      = TableMaker('fcncAnalysis/combined_histos/' + selection + '_cut1_' + period + batch + '.root', outFile, scale = LUMIDATA, delimiter = '&', doSumBG = True)

    yieldTable.set_period(period)

    yieldTable._columnList  = ['higgs', 'Triboson', 'ttV', 'Diboson', 'top', 'VJets', 'BG', 'DATA', 'FCNH']#, 'Significance'] 
    #yieldTable._columnList  = ['BG', 'DATA', 'FCNH']#, 'Significance'] 

    yieldTable.add_datasets(samples, Clear = True)
    yieldTable.add_datasets('FCNH')
    yieldTable.add_datasets('DATA')

    print '\n\n Printing yields...\n'

    if doOS:
        categoryNames.extend(catOS)
    if doSS:
コード例 #7
0
ファイル: plot_cfg.py プロジェクト: naodell/FCNH
### End of configuration for PlotProducer ###

for process in p_plot:
    print 'Plotting {0}'.format(process.name)
    process.start()

for process in p_plot:
    process.join()

print '\n'

if doYields:
    ### Initialize table maker ###
    tableFile       = file('yields/.yields_tmp.tex', 'w')
    yieldTable      = TableMaker('fcncAnalysis/combined_histos/{0}_cut1_{1}_{2}.root'.format(selection, period, batch), 
                                    tableFile, scale = LUMIDATA, 
                                    delimiter = '&', doSumBG = True)
    yieldTable.set_period(period)
    yieldTable.add_datasets(samples['all'], Clear = True)
    if not doPlots:
        #yieldTable.get_scale_factors()
        yieldTable.get_scale_factors(['FCNH', 'FCNHUp'])

    if do3l:
        yieldTable._columnList  = ['Rare', 'WZJets3LNu', 'Fakes', 'BG', 'DATA', 'FCNH']
        #yieldTable._columnList  = ['Rare', 'WZJets3LNu', 'Fakes', 'BG', 'DATA', 'FCNHWW', 'FCNHTauTau', 'FCNHZZ']
        #yieldTable._columnList  = ['Rare', 'WZJets3LNu', 'Fakes', 'BG', 'DATA', 'FCNHUpWW', 'FCNHUpZZ', 'FCNHUpTauTau']
        #yieldTable._columnList  = ['Rare', 'WZJets3LNu', 'Fakes', 'BG', 'DATA', 'TTH_M-125']
        #yieldTable._columnList  = samples['3l_inclusive'] + ['BG', 'DATA', 'FCNH']
        #yieldTable._columnList  = ['BG', 'DATA', 'FCNHWW', 'FCNHZZ', 'FCNHTauTau']
        #yieldTable._columnList  = ['BG', 'DATA', 'FCNH']#, 'Significance'] 
コード例 #8
0
ファイル: KiCable-Table.py プロジェクト: bveenema/KiCable
# printNetList(NetList)
# printComponentList(componentList)

# Get an Anchor component and start Paths
Tables = []
tableCount = 0

# if componentList does not change between consecutive iterations, terminate Pathing
previousComponentList = []
while (len(componentList) > 0 and previousComponentList != componentList):
    import copy
    previousComponentList = copy.deepcopy(componentList)

    Paths = CablePaths()

    Tables.append(TableMaker(componentList, Paths, NetList))
    table = Tables[tableCount]
    tableCount += 1

    for component in componentList:
        if (component['isAnchor'] == True):
            # start Paths
            for i, connection in enumerate(component['connections']):
                position = connection['pin']
                pathName = Paths.addPath(position, component['ref'],
                                         connection['net'])
                table.addPath(pathName)
            table.sortTable()
            # Add Headers
            for path in Paths.getPaths():
                table.addComponent(component, path)
コード例 #9
0
ファイル: MdpFile.py プロジェクト: dkyu/mmtools
class MdpFile(object):
  """A class to store and manipulate Gromacs mdp files.

  TODO
    Can we make use of the Units class to allow user to specify parameters with units attached and automatically convert to/from gromacs units?
  """

  # Class data
  MAXSEED = 2**30 # maximum random number seed
    
  def __init__(self, mdpfile = None, debug = False): 
    """Constructor to initialize mdp file container.
  
    OPTIONAL ARGUMENTS
      mdpfile        filename (string) or contents (list of strings) of a gromacs .mdp file to be read
    """

    # set debug flag
    self.debug = debug 

    # store filename of .mdp file initialized from, if any
    self.templatefile = None
    if type(mdpfile) == str:
      self.templatefile = mdpfile
          
    # initialize internal storage
    self.lines = []
    self.params = {}    # {keyword:value} dictionary.  NOTE: All values are stored as strings: i.e. {'rlist':'4.0'}
    self.keywords = []  # keep a list of the keyword order, just so we can write oiut *.mdp files in the same order as the template 

    # read .mdp file or process contents, if give
    if mdpfile:
      [self.lines, self.params, self.keywords, self.keyword_line_index] = self.read(mdpfile)

    # settings for user-defined tables    
    self.use_xvg = False
    self.tablemaker = None
    self.tabletype = None
    self.tabletxt = None

    return

  def use_table(self, tabletype, spacing=0.002):   
    """Turn on the xvg table option, and generate a user-defined table 
    defined in self.xvg_lines, generated by the TableMaker object, with the specifications:showParams

    OPTIONS 
        tabletype =  a TableMaker.Dielectric derived class:
                     'Switch_Shift'	(default) GROMACS-style tapered cutoffs
                     'SF3'		ShenFreed 3 table
                     'ReactionField'    rxn field dielectric solvent model

    TableMaker examples:
    # table=TableMaker(spacing=0.002)

    # tabletype=SF3(length_scale=4.0)
    # tabletype=Switch_Shift()
    # tabletype=ReactionField(rc=1.0)

    # settings for eps->Infinity
    # tabletype.krf = 1.0 / ( 2.0 * tabletype.rc )
    # tabletype.crf = 3.0 / ( 2.0 * tabletype.rc ) 

    # table=table.make(tabletype)

    # print table
    """

    self.use_xvg = True
    self.tabletype = tabletype
    self.tablemaker = TableMaker(spacing=spacing)
    self.tabletxt = self.tablemaker.make(self.tabletype)
    
    # set the user-table flags in the the mdp file 
    self.setParameter('coulombtype','user')
    self.setParameter('vdwtype','user')

    # NOTE: the acual 'table.xvg' file will be written by System.prepare()
    
  def read(self, mdpfile):
    """Read the contents of a gromacs .mdp file.

    ARGUMENTS
      mdpfile (string or list of strings) - if a string is provided, the contents of the file are read;
                                            if a list is provided, this is interpreted as the contents of an mdp file
    """

    # handle multiple argument types
    if (type(mdpfile) == list):
      lines = mdpfile
    elif (type(mdpfile) == str):
      # if a filename is provided, get its contents
      fin = open(mdpfile, 'r')
      lines = fin.readlines()
      # remove extraneous newlines 
      lines = map(lambda x:x.rstrip("\n"),lines)
      fin.close()
    else:
      raise "Unrecognized argument: " + repr(mdpfile)
      
    # build an initial dictionary of key:values from the lines
    [params, keywords, keyword_line_index] = self.buildParameterDict(lines)    

    return [lines, params, keywords, keyword_line_index]

  def write(self, filename):
    """Write contents of .mdp file to disk.

    ARGUMENTS
      filename (string) - the filename to write to
    """

    fout = open(filename, 'w')
    for line in self.lines:
      fout.write(line + '\n')
    fout.close()

    return
  
  def write_table(self, filename):
    """Writes the lines of self.tabletxt to user-supplied filename in correct directory -- should be 'table.xvg'

    ARGUMENTS
      filename (string) - the name of the file to be written

    """

    fout = open(filename, 'w')
    fout.write(self.tabletxt)
    fout.close()

    return

  def buildParameterDict(self, lines):
    """Goes through each line of the file,and parses keywords into a key:value dictionary

    ARGUMENTS
      lines (list) - the contents of the .mdp file from which the dictionary is to be built

    RETURNS
      params (dict) - dictionary of key:value processed from contents of file
      keywords (list) - list of keywords found in the file
      keyword_line_index (dict) - keyword_line_index[keyword] is the line index on which 'keyword' appears

    TODO
      The processing here is very rudimentary -- may need to be modified to accomodate multiple arguments per line.
      We should store the corresponding original line from the file, or store the complete contents of the line (including comments?)
      
    """
    
    params = dict()
    keywords = list()
    keyword_line_index = dict()
    line_index = 0
    for line in lines:
      # strip comments
      index = line.find(';')
      if index > -1:
        line = line[0:index]
      # strip whitespace from both ends of line
      line = line.strip()
      # split off keyword
      fields = line.split()
      # if key = values ... is found, store
      if (len(fields) >= 3) and (fields[1] == '='):
        # extract keywords
        keyword = fields[0]
        # extract value(s)
        index = line.find('=')
        values = line[index+1:len(line)].strip()
        # store
        params[keyword] = values
        keywords.append(keyword)
        keyword_line_index[keyword] = line_index        
      # increment line index
      line_index += 1

    return [params, keywords, keyword_line_index]
              
  def showParams(self):
    """Display dictionary of recognized key:value pairs from mdp file.
    """
    outstr = ''
    for key in self.keywords:
        outstr = outstr + self.keyword2line(key)
    print outstr

    return
  
  def showLines(self):
    """Display lines.
    """
    contents = ''
    for line in self.lines:
      contents += line + '\n'
    print contents

    return

  def keyword2line(self, keyword):
    """Takes in a parameter keyword and returns a formatted mdp file line.

    ARGUMENTS
      keyword (string) - the keyword specifying the formatted mdp line to retrieve

    RETURNS
      the formatted mdp line corresponding to the keyword, if found

    TODO
      What if keyword isn't found?
      We should store the corresponding original line from the file, or store the complete contents of the line (including comments?)      

    """ 
    return '%-20s = %-20s\n'%(keyword, self.params[keyword])
    
  def setParameter(self, keyword, valuestr):
    """Sets a particular mdp keyword to a value (string) in the parameter dictionary, updates mdp lines.

    ARGUMENTS
      keyword (string) - the keyword to which the parameter is to be assigned
      valuestr (string) - the corresponding parameter value to assign to the keyword

    TODO
      Searching in the parameter file can be facilitated if we store a dictionary of which line a keyword is specified on.
    """

    # determine whether the keyword already exists
    keyword_exists = self.keyword_line_index.has_key(keyword)

    # set keyword in dictionary (creating or overriding)
    self.params[keyword] = valuestr

    # create a new line from this keyword-value pair
    line = self.keyword2line(keyword)
    
    if keyword_exists:
      # if keyword exists, replace the line      
      line_index = self.keyword_line_index[keyword]
      self.lines[line_index] = line
    else:
      # if keyword does not exists, add a line
      self.lines.append(line)      
      self.keywords.append(keyword) # add the keyword to the list            
      self.keyword_line_index[keyword] = len(self.lines) - 1 # store line number of the appended line

    return

  def getParameter(self,keyword):
      """Returns the value associated with a particular parameter; or None if the parameter is not set"""
      if keyword not in self.params:
          return None
      return self.params[keyword]
        
  def setTemperature(self,temperature):
    """Set the temperature of the various options.

    """

    # Set the temperature parameters
    self.setParameter('gen_temp', temperature)
    self.setParameter('ref_t', temperature)
    return

  def randomizeSeed(self):
    """Randomize the random seed, adding one if none exists.

    TODO
    Uses range from 1 to 2**30 for now, but should figure out acceptable range for gromacs.
    """

    # choose a new random seed
    import random
    self.setParameter('gen_seed', str(random.randint(1, self.MAXSEED)))
    self.setParameter('mc_seed', str(random.randint(1, self.MAXSEED)))

    return
  
  def setParametersFromDict(self, paramdict):
    """Takes in a set of parameters as a dictionary of {keyword:value} entries (values are strings) and sets parameters for each.

    ARGUMENTS
      paramdict (dict) - a dictionary of keyword:value pairs to be used to update parameters
    """
    
    for [key,value] in paramdict.iteritems():
      if self.debug:  print 'DEBUG: key, value of paramdict{}', key, value
      self.setParameter(key, value)

    return
      
  def delParameter(self, keyword):
    """Removes a particular mdp keyword (and its value (string)) from the parameter dictionary, and deletes mdp line.

    ARGUMENTS
      keyword (string) - the keyword to be cleared

    TODO
      Propose new name of clearParameter or removeParameter
    """
  
    # remove keyword from dictionary
    if self.params.has_key(keyword):
        del self.params[keyword]

    # replace instances of this 'keyword = value' in the mdp lines
    i=0
    while i < len(self.lines):
        fields = self.lines[i].strip().split()
        if len(fields) > 0:
            if fields[0] == keyword:
                self.lines.pop(i)
            else:
                i=i+1
        else:
            i=i+1

    return
コード例 #10
0
ファイル: bjet_cfg.py プロジェクト: mtrovato/Analysis_CMS
        LUMIDATA += .3709 
        LUMIDATA += .6630 
        #LUMIDATA *= 1.0514
    if period in ['Combined', '2011B']:
        LUMIDATA += 2.511
elif selection in ['electron', 'eGamma']:
    if period in ['Combined', '2011A']:
        LUMIDATA += .2151 
        LUMIDATA += .7982 
        LUMIDATA += .3132 
        LUMIDATA += .6332 
        #LUMIDATA *= 1.053
    if period in ['Combined', '2011B']:
        LUMIDATA += 2.482

bTable = TableMaker('../HiggsAnalyzer/histos/higgsHistograms_'+dataSet+period+'.root', LUMIDATA)

samples = ['tW', 'ttbar', 'GluGluWW', 'WWJets', 'WZJets', 'ZZJets']
if selection in ['muGamma', 'eGamma']:
    samples.append('PhotonJets')
elif selection == 'muEG':
    samples.append('DYToTauTau')
elif doZJets:
    samples.append('ZJets')
elif not doZJets:
    if selection == 'muon':
        samples.append('DYToMuMu')
        samples.append('DYToTauTau')
    if selection == 'electron':
        samples.append('DYToEE')
        samples.append('DYToTauTau')