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 49 of file HltComparatorCreateWorkflow.py.

Referenced by CreateAnalysisConfig().

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

Definition at line 56 of file HltComparatorCreateWorkflow.py.

References edm.print(), and RemovePSet().

Referenced by GetHltConfiguration().

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

Definition at line 146 of file HltComparatorCreateWorkflow.py.

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

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

Definition at line 132 of file HltComparatorCreateWorkflow.py.

Referenced by CreateAnalysisConfig().

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

Definition at line 139 of file HltComparatorCreateWorkflow.py.

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

Definition at line 105 of file HltComparatorCreateWorkflow.py.

References ConvertHltOnlineToOffline().

Referenced by CreateAnalysisConfig().

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

Referenced by CreateAnalysisConfig().

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

Definition at line 76 of file HltComparatorCreateWorkflow.py.

Referenced by ConvertHltOnlineToOffline().

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