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

Referenced by CreateAnalysisConfig().

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

Definition at line 61 of file HltComparatorCreateWorkflow.py.

References RemovePSet().

Referenced by GetHltConfiguration().

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

Definition at line 151 of file HltComparatorCreateWorkflow.py.

References CheckEnvironment().

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

Definition at line 137 of file HltComparatorCreateWorkflow.py.

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

Definition at line 144 of file HltComparatorCreateWorkflow.py.

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

Definition at line 110 of file HltComparatorCreateWorkflow.py.

References ConvertHltOnlineToOffline(), and SiPixelLorentzAngle_cfi.read.

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

Definition at line 133 of file HltComparatorCreateWorkflow.py.

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

Definition at line 81 of file HltComparatorCreateWorkflow.py.

Referenced by ConvertHltOnlineToOffline().

81 
82 def RemovePSet(config, pset):
83  startLoc = config.find(pset)
84  started = False
85  count = 0
86  curLoc = startLoc
87  endLoc = 0
88 
89  # Find starting parenthesis
90  while not started:
91  if config[curLoc] == "(":
92  started = True
93  count = 1
94  curLoc += 1
95 
96  # Find end parenthesis
97  while endLoc == 0:
98  if config[curLoc] == "(":
99  count += 1
100  elif config[curLoc] == ")":
101  count -= 1
102  if count == 0:
103  endLoc = curLoc
104  curLoc += 1
105 
106  config = config.replace(config[startLoc:endLoc + 1], "")
107 
108  return config
109 
# 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.hltConfig = None

Definition at line 166 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 172 of file HltComparatorCreateWorkflow.py.

Referenced by DQMProvInfo.makeHLTKeyInfo().

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

Definition at line 17 of file HltComparatorCreateWorkflow.py.

string HltComparatorCreateWorkflow.metavar = "KEY"

Definition at line 28 of file HltComparatorCreateWorkflow.py.

tuple HltComparatorCreateWorkflow.parser = OptionParser(usage)

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.