CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 50 of file HltComparatorCreateWorkflow.py.

Referenced by CreateAnalysisConfig().

50 
51 def CheckEnvironment():
52  cwd = os.getcwd()
53  t = cwd.split("/")
54  if t[-1] != "python":
55  raise SystemExit("Must run from a Module/Package/python directory")
56 
# Converts an online HLT configuration into offline suitable format
def HltComparatorCreateWorkflow.ConvertHltOnlineToOffline (   config,
  frontierString 
)

Definition at line 57 of file HltComparatorCreateWorkflow.py.

References RemovePSet().

Referenced by GetHltConfiguration().

57 
58 def ConvertHltOnlineToOffline(config, frontierString):
59  # Replace the frontier string
60  onlineFrontier = re.search('"(frontier:.*)"', config)
61  if not onlineFrontier:
62  print "WARNING: Could not find Frontier string in HLT configuration. Will ignore."
63  else:
64  config = config.replace(onlineFrontier.group(1), frontierString)
65 
66  # Replace the global tag
67  config = config.replace("H::All", "P::All")
68 
69  # print config -- debugging
70  # Remove unwanted PSets
71  config = RemovePSet(config, "MessageLogger")
72 # config = RemovePSet(config, "DQMStore")
73  config = RemovePSet(config, "DQM")
74  config = RemovePSet(config, "FUShmDQMOutputService")
75 
76  return config
def HltComparatorCreateWorkflow.CreateAnalysisConfig (   analysis,
  hltInclude 
)

Definition at line 147 of file HltComparatorCreateWorkflow.py.

References CheckEnvironment().

148 def CreateAnalysisConfig(analysis, hltInclude):
149  anaName = "JobAnalysisConfig_%s_cfg.py" % jobHash
150  f = open(analysis)
151  g = open(anaName, "w")
152  g.write(f.read())
153  g.write("\n")
154  g.write(hltInclude)
155  g.close()
156  f.close()
157  return anaName
158 
159 # Quick sanity check of the environment
161 
# Get the required HLT config snippet
def HltComparatorCreateWorkflow.FormatHltCff (   cffPath)

Definition at line 133 of file HltComparatorCreateWorkflow.py.

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

Definition at line 140 of file HltComparatorCreateWorkflow.py.

141 def GetHltCompileCode(subsystem, package, hltConfig):
142  tmpCode = compileCode.replace("SUBSYSTEM", subsystem)
143  tmpCode = tmpCode.replace("PACKAGE", package)
144  tmpCode = tmpCode.replace("CONFIG", hltConfig + "c")
145  return tmpCode
146 
# Prepares the analysis configuration
def HltComparatorCreateWorkflow.GetHltConfiguration (   hltKey,
  frontierString 
)

Definition at line 106 of file HltComparatorCreateWorkflow.py.

References ConvertHltOnlineToOffline(), and SiPixelLorentzAngle_cfi.read.

107 def GetHltConfiguration(hltKey, frontierString):
108  # Format the config path for include
109  cwd = os.getcwd()
110  t = cwd.split("/")
111  module = t[-3]
112  package = t[-2]
113 
114  # Get the HLT config
115  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()
116  #config = os.popen2("edmConfigFromDB --debug --configName %s --orcoff --format Python --nooutput --cff" % hltKey)[1].read()
117  configName = "JobHLTConfig_%s_cff.py" % jobHash
118 
119  # Perform online --> offline conversion
120  config = ConvertHltOnlineToOffline(config, frontierString)
121 
122  # Write the config
123  f = open(configName, "w")
124  f.write(config)
125  f.close()
126 
127  return 'process.load("%s.%s.%s")' % (module, package, configName.split(".")[0])
128 
# Fetches the HLT key from ConfDB - turned off in options for now
def HltComparatorCreateWorkflow.GetHltKeyForRun (   run)

Definition at line 129 of file HltComparatorCreateWorkflow.py.

130 def GetHltKeyForRun(run):
131  raise SystemExit("Not implemented yet")
132 
# Formats an HLT CFF path into a suitable python include statement
def HltComparatorCreateWorkflow.RemovePSet (   config,
  pset 
)

Definition at line 77 of file HltComparatorCreateWorkflow.py.

Referenced by ConvertHltOnlineToOffline().

77 
78 def RemovePSet(config, pset):
79  startLoc = config.find(pset)
80  started = False
81  count = 0
82  curLoc = startLoc
83  endLoc = 0
84 
85  # Find starting parenthesis
86  while not started:
87  if config[curLoc] == "(":
88  started = True
89  count = 1
90  curLoc += 1
91 
92  # Find end parenthesis
93  while endLoc == 0:
94  if config[curLoc] == "(":
95  count += 1
96  elif config[curLoc] == ")":
97  count -= 1
98  if count == 0:
99  endLoc = curLoc
100  curLoc += 1
101 
102  config = config.replace(config[startLoc:endLoc + 1], "")
103 
104  return config
105 
# Fetches the HLT configuration from ConfDB

Variable Documentation

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

Definition at line 172 of file HltComparatorCreateWorkflow.py.

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

Definition at line 30 of file HltComparatorCreateWorkflow.py.

string HltComparatorCreateWorkflow.help = "analysis configuration file"

Definition at line 18 of file HltComparatorCreateWorkflow.py.

tuple HltComparatorCreateWorkflow.hltConfig = None

Definition at line 162 of file HltComparatorCreateWorkflow.py.

Referenced by HeavyFlavorValidation.beginRun(), EgHLTOfflineSummaryClient.beginRun(), EgHLTOfflineClient.beginRun(), EgHLTOfflineSource.beginRun(), HLTOniaSource.checkHLTConfiguration(), MuScleFit.duringLoop(), and DQMProvInfo.makeHLTKeyInfo().

tuple HltComparatorCreateWorkflow.hltKey = GetHltKeyForRun(0)

Definition at line 168 of file HltComparatorCreateWorkflow.py.

Referenced by DQMProvInfo.makeHLTKeyInfo().

string HltComparatorCreateWorkflow.jobHash = "%s_%s_%s"

Definition at line 13 of file HltComparatorCreateWorkflow.py.

string HltComparatorCreateWorkflow.metavar = "KEY"

Definition at line 24 of file HltComparatorCreateWorkflow.py.

tuple HltComparatorCreateWorkflow.parser = OptionParser(usage)

Definition at line 16 of file HltComparatorCreateWorkflow.py.

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

Definition at line 15 of file HltComparatorCreateWorkflow.py.