CMS 3D CMS Logo

Functions | Variables

HltComparatorCreateWorkflow Namespace Reference

Functions

def CheckEnvironment
def ConvertHltOnlineToOffline
def CreateAnalysisConfig
def FormatHltCff
def GetHltCompileCode
def GetHltConfiguration
def GetHltKeyForRun
def RemovePSet

Variables

tuple anaConfig = CreateAnalysisConfig(options.analysis, hltConfig)
string default = "frontier://FrontierProd/CMS_COND_31X_GLOBALTAG"
string help = "analysis configuration file"
 hltConfig = None
tuple hltKey = GetHltKeyForRun(0)
string jobHash = "%s_%s_%s"
string metavar = "KEY"
tuple parser = OptionParser(usage)
string usage = '%prog [options]. \n\t-a and -k required, -h for help.'

Function Documentation

def HltComparatorCreateWorkflow::CheckEnvironment ( )

Definition at line 54 of file HltComparatorCreateWorkflow.py.

00055                       :
00056    cwd = os.getcwd()
00057    t = cwd.split("/")
00058    if t[-1] != "python":
00059       raise SystemExit("Must run from a Module/Package/python directory")
00060 
# Converts an online HLT configuration into offline suitable format
def HltComparatorCreateWorkflow::ConvertHltOnlineToOffline (   config,
  frontierString 
)

Definition at line 61 of file HltComparatorCreateWorkflow.py.

00062                                                      :
00063    # Replace the frontier string
00064    onlineFrontier = re.search('"(frontier:.*)"', config)
00065    if not onlineFrontier:
00066       print "WARNING: Could not find Frontier string in HLT configuration. Will ignore."
00067    else:
00068       config = config.replace(onlineFrontier.group(1), frontierString)
00069 
00070    # Replace the global tag
00071    config = config.replace("H::All", "P::All")
00072 
00073    # print config -- debugging
00074    # Remove unwanted PSets
00075    config = RemovePSet(config, "MessageLogger")
00076 #   config = RemovePSet(config, "DQMStore")
00077    config = RemovePSet(config, "DQM")
00078    config = RemovePSet(config, "FUShmDQMOutputService")
00079 
00080    return config

def HltComparatorCreateWorkflow::CreateAnalysisConfig (   analysis,
  hltInclude 
)

Definition at line 151 of file HltComparatorCreateWorkflow.py.

00152                                               :
00153    anaName = "JobAnalysisConfig_%s_cfg.py" % jobHash
00154    f = open(analysis)
00155    g = open(anaName, "w")
00156    g.write(f.read())
00157    g.write("\n")
00158    g.write(hltInclude)
00159    g.close()
00160    f.close()
00161    return anaName
00162 
00163 # Quick sanity check of the environment
00164 CheckEnvironment()
00165 
# Get the required HLT config snippet
def HltComparatorCreateWorkflow::FormatHltCff (   cffPath)

Definition at line 137 of file HltComparatorCreateWorkflow.py.

00138                          :
00139    pathParts = cffPath.split(".")
00140    if not re.match("^[_A-Za-z0-9]*\.[_A-Za-z0-9]*\.[_A-Za-z0-9]*$", cffPath):
00141       raise SystemExit("Expected cff in form Package.Module.configName_cff")
00142    return 'process.load("%s")' % cffPath
00143 
# Returns python code to compile an HLT configuration
def HltComparatorCreateWorkflow::GetHltCompileCode (   subsystem,
  package,
  hltConfig 
)

Definition at line 144 of file HltComparatorCreateWorkflow.py.

00145                                                     :
00146    tmpCode = compileCode.replace("SUBSYSTEM", subsystem)
00147    tmpCode = tmpCode.replace("PACKAGE", package)
00148    tmpCode = tmpCode.replace("CONFIG", hltConfig + "c")
00149    return tmpCode
00150 
# Prepares the analysis configuration
def HltComparatorCreateWorkflow::GetHltConfiguration (   hltKey,
  frontierString 
)

Definition at line 110 of file HltComparatorCreateWorkflow.py.

00111                                                :
00112    # Format the config path for include
00113    cwd = os.getcwd()
00114    t = cwd.split("/")
00115    module = t[-3]
00116    package = t[-2]
00117 
00118    # Get the HLT config
00119    config = os.popen2('wget "http://cms-project-confdb-hltdev.web.cern.ch/cms-project-confdb-hltdev/get.jsp?dbName=ORCOFF&configName=%s&cff=&nooutput=&format=Python" -O- -o /dev/null' % hltKey)[1].read()
00120    #config = os.popen2("edmConfigFromDB --debug --configName %s --orcoff --format Python --nooutput --cff" % hltKey)[1].read() 
00121    configName = "JobHLTConfig_%s_cff.py" % jobHash
00122 
00123    # Perform online --> offline conversion
00124    config = ConvertHltOnlineToOffline(config, frontierString)
00125 
00126    # Write the config
00127    f = open(configName, "w")
00128    f.write(config)
00129    f.close()
00130 
00131    return 'process.load("%s.%s.%s")' % (module, package, configName.split(".")[0])
00132 
# Fetches the HLT key from ConfDB - turned off in options for now
def HltComparatorCreateWorkflow::GetHltKeyForRun (   run)

Definition at line 133 of file HltComparatorCreateWorkflow.py.

00134                         :
00135    raise SystemExit("Not implemented yet")
00136 
# Formats an HLT CFF path into a suitable python include statement
def HltComparatorCreateWorkflow::RemovePSet (   config,
  pset 
)

Definition at line 81 of file HltComparatorCreateWorkflow.py.

00082                             :
00083    startLoc = config.find(pset)
00084    started = False
00085    count = 0
00086    curLoc = startLoc
00087    endLoc = 0
00088 
00089    # Find starting parenthesis
00090    while not started:
00091       if config[curLoc] == "(":
00092          started = True
00093          count = 1
00094       curLoc += 1
00095 
00096    # Find end parenthesis
00097    while endLoc == 0:
00098       if config[curLoc] == "(":
00099          count += 1
00100       elif config[curLoc] == ")":
00101          count -= 1
00102       if count == 0:
00103          endLoc = curLoc
00104       curLoc += 1
00105 
00106    config = config.replace(config[startLoc:endLoc + 1], "")
00107 
00108    return config
00109 
# Fetches the HLT configuration from ConfDB

Variable Documentation

tuple HltComparatorCreateWorkflow::anaConfig = CreateAnalysisConfig(options.analysis, hltConfig)

Definition at line 176 of file HltComparatorCreateWorkflow.py.

string HltComparatorCreateWorkflow::default = "frontier://FrontierProd/CMS_COND_31X_GLOBALTAG"

Definition at line 34 of file HltComparatorCreateWorkflow.py.

string HltComparatorCreateWorkflow::help = "analysis configuration file"

Definition at line 22 of file HltComparatorCreateWorkflow.py.

tuple HltComparatorCreateWorkflow::hltKey = GetHltKeyForRun(0)

Definition at line 172 of file HltComparatorCreateWorkflow.py.

Definition at line 17 of file HltComparatorCreateWorkflow.py.

Definition at line 28 of file HltComparatorCreateWorkflow.py.

Definition at line 20 of file HltComparatorCreateWorkflow.py.

string HltComparatorCreateWorkflow::usage = '%prog [options]. \n\t-a and -k required, -h for help.'

Definition at line 19 of file HltComparatorCreateWorkflow.py.