CMS 3D CMS Logo

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

Referenced by CreateAnalysisConfig().

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

Definition at line 56 of file HltComparatorCreateWorkflow.py.

References print(), and RemovePSet().

Referenced by GetHltConfiguration().

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

Definition at line 146 of file HltComparatorCreateWorkflow.py.

References CheckEnvironment().

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

Definition at line 132 of file HltComparatorCreateWorkflow.py.

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

Definition at line 139 of file HltComparatorCreateWorkflow.py.

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

Definition at line 105 of file HltComparatorCreateWorkflow.py.

References ConvertHltOnlineToOffline(), and SiPixelLorentzAngle_cfi.read.

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

Definition at line 128 of file HltComparatorCreateWorkflow.py.

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

Variable Documentation

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

Definition at line 171 of file HltComparatorCreateWorkflow.py.

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

Definition at line 29 of file HltComparatorCreateWorkflow.py.

string HltComparatorCreateWorkflow.help = "analysis configuration file"

Definition at line 17 of file HltComparatorCreateWorkflow.py.

tuple HltComparatorCreateWorkflow.hltConfig = None

Definition at line 161 of file HltComparatorCreateWorkflow.py.

Referenced by HLTEventAnalyzerAOD.analyze(), IsoTrig.analyze(), HLTEventAnalyzerAOD.analyzeTrigger(), HLTEventAnalyzerAOD.beginRun(), EgHLTOfflineClient.beginRun(), pat::PATTriggerProducer.beginRun(), EgHLTOfflineSummaryClient.beginRun(), TrigObjTnPSource.bookHistograms(), EgHLTOfflineSource.bookHistograms(), DQMProvInfo.dqmBeginRun(), HigPhotonJetHLTOfflineSource.dqmBeginRun(), HeavyFlavorValidation.dqmBeginRun(), MuScleFit.duringLoop(), PrescaleWeightProvider.initRun(), PrescaleWeightProvider.prescaleWeight(), CandidateTriggerObjectProducer.produce(), TriggerMatchProducer< object >.produce(), and pat::PATTriggerProducer.produce().

tuple HltComparatorCreateWorkflow.hltKey = GetHltKeyForRun(0)

Definition at line 167 of file HltComparatorCreateWorkflow.py.

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

Definition at line 12 of file HltComparatorCreateWorkflow.py.

string HltComparatorCreateWorkflow.metavar = "KEY"

Definition at line 23 of file HltComparatorCreateWorkflow.py.

tuple HltComparatorCreateWorkflow.parser = OptionParser(usage)

Definition at line 15 of file HltComparatorCreateWorkflow.py.

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

Definition at line 14 of file HltComparatorCreateWorkflow.py.