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

Referenced by CreateAnalysisConfig().

48 
49 def CheckEnvironment():
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 
# 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 
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
def HltComparatorCreateWorkflow.CreateAnalysisConfig (   analysis,
  hltInclude 
)

Definition at line 145 of file HltComparatorCreateWorkflow.py.

References CheckEnvironment().

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 
# Get the required HLT config snippet
def HltComparatorCreateWorkflow.FormatHltCff (   cffPath)

Definition at line 131 of file HltComparatorCreateWorkflow.py.

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 
# Returns python code to compile an HLT configuration
def HltComparatorCreateWorkflow.GetHltCompileCode (   subsystem,
  package,
  hltConfig 
)

Definition at line 138 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 
# Prepares the analysis configuration
def HltComparatorCreateWorkflow.GetHltConfiguration (   hltKey,
  frontierString 
)

Definition at line 104 of file HltComparatorCreateWorkflow.py.

References ConvertHltOnlineToOffline(), and SiPixelLorentzAngle_cfi.read.

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 
# Fetches the HLT key from ConfDB - turned off in options for now
def HltComparatorCreateWorkflow.GetHltKeyForRun (   run)

Definition at line 127 of file HltComparatorCreateWorkflow.py.

128 def GetHltKeyForRun(run):
129  raise SystemExit("Not implemented yet")
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 
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 
# Fetches the HLT configuration from ConfDB

Variable Documentation

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

Definition at line 170 of file HltComparatorCreateWorkflow.py.

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

Definition at line 28 of file HltComparatorCreateWorkflow.py.

string HltComparatorCreateWorkflow.help = "analysis configuration file"

Definition at line 16 of file HltComparatorCreateWorkflow.py.

tuple HltComparatorCreateWorkflow.hltConfig = None

Definition at line 160 of file HltComparatorCreateWorkflow.py.

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

tuple HltComparatorCreateWorkflow.hltKey = GetHltKeyForRun(0)

Definition at line 166 of file HltComparatorCreateWorkflow.py.

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

Definition at line 11 of file HltComparatorCreateWorkflow.py.

string HltComparatorCreateWorkflow.metavar = "KEY"

Definition at line 22 of file HltComparatorCreateWorkflow.py.

tuple HltComparatorCreateWorkflow.parser = OptionParser(usage)

Definition at line 14 of file HltComparatorCreateWorkflow.py.

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

Definition at line 13 of file HltComparatorCreateWorkflow.py.