CMS 3D CMS Logo

Functions
HltComparatorCreateWorkflow Namespace Reference

Functions

def CheckEnvironment ()
 
def ConvertHltOnlineToOffline (config, frontierString)
 
def CreateAnalysisConfig (analysis, hltInclude)
 
def FormatHltCff (cffPath)
 
def GetHltCompileCode (subsystem, package, hltConfig)
 
def GetHltConfiguration (hltKey, frontierString)
 
def GetHltKeyForRun (run)
 
def RemovePSet (config, pset)
 

Function Documentation

def HltComparatorCreateWorkflow.CheckEnvironment ( )

Definition at line 48 of file HltComparatorCreateWorkflow.py.

Referenced by CreateAnalysisConfig().

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

Definition at line 55 of file HltComparatorCreateWorkflow.py.

References RemovePSet().

Referenced by GetHltConfiguration().

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

Definition at line 145 of file HltComparatorCreateWorkflow.py.

References CheckEnvironment(), FormatHltCff(), GetHltConfiguration(), and GetHltKeyForRun().

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

Definition at line 131 of file HltComparatorCreateWorkflow.py.

Referenced by CreateAnalysisConfig().

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

Definition at line 138 of file HltComparatorCreateWorkflow.py.

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

Definition at line 104 of file HltComparatorCreateWorkflow.py.

References ConvertHltOnlineToOffline().

Referenced by CreateAnalysisConfig().

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

Definition at line 127 of file HltComparatorCreateWorkflow.py.

Referenced by CreateAnalysisConfig().

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

Definition at line 75 of file HltComparatorCreateWorkflow.py.

Referenced by ConvertHltOnlineToOffline().

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