Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
|
def | __init__ (self, flags, algClassOrObj=None, name=None, *args, **kwargs) |
|
def | defineDQAlgorithm (self, name, hanConfig, thresholdConfig=None) |
|
def | defineHistogram (self, *args, fillGroup=None, hanConfig={}, paths=[], **kwargs) |
|
def | defineTree (self, *args, fillGroup=None, **kwargs) |
|
def | result (self) |
|
This class is designed to handle registering all of L1Calo's monitoring histograms and trees in a
coherent way. It will also generate the han config file for all the histograms.
Definition at line 5 of file LVL1CaloMonitoringConfig.py.
◆ __init__()
def LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.__init__ |
( |
|
self, |
|
|
|
flags, |
|
|
|
algClassOrObj = None , |
|
|
|
name = None , |
|
|
* |
args, |
|
|
** |
kwargs |
|
) |
| |
Create the configuration helper.
Arguments:
flags -- the configuration flag object
algClassOrObj -- the name you want to assign the family of algorithms
Definition at line 205 of file LVL1CaloMonitoringConfig.py.
205 def __init__(self, flags, algClassOrObj = None, name = None, *args, **kwargs):
207 Create the configuration helper.
210 flags -- the configuration flag object
211 algClassOrObj -- the name you want to assign the family of algorithms
213 from AthenaMonitoring
import AthMonitorCfgHelper
214 self.helper = AthMonitorCfgHelper(flags,name)
215 self.alg = self.helper.addAlgorithm(algClassOrObj,name,*args, **kwargs)
if algClassOrObj
is not None else None
217 self.dqEnv = flags.DQ.Environment
◆ createXmls()
def LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.createXmls |
( |
| ) |
|
|
static |
Definition at line 24 of file LVL1CaloMonitoringConfig.py.
27 db = config.Configuration()
28 db.create_db(
"l1calo_gen_phase1.data.xml",[
"daq/schema/dqm.schema.xml",
"daq/sw/dqm-algorithms.data.xml",
"daq/sw/repository.data.xml",
"daq/sw/dqm-default-streams.data.xml"])
31 for confName,conf
in L1CaloMonitorCfgHelper.hanAlgConfigs.items():
34 for histPath,value
in L1CaloMonitorCfgHelper.xmlConfigs.items():
35 if value.get(
"algorithm",
"") == confName:
38 if not algUsed:
continue
41 dqAlgo = db.get_dal(
"DQAlgorithm",conf[
"name"])
45 db.create_obj(
"DQAlgorithm",conf[
"name"])
46 dqAlgo = db.get_dal(
"DQAlgorithm",conf[
"name"])
47 dqAlgo.LibraryName = conf[
"libname"]
49 for par,val
in conf.items():
50 if par==
"thresholds" and val
in L1CaloMonitorCfgHelper.hanThresholdConfigs:
51 for thresh,vals
in L1CaloMonitorCfgHelper.hanThresholdConfigs[val].
items():
52 if thresh
not in dqAlgo.ThresholdsNames:
54 dqAlgo.ThresholdsNames += [thresh]
55 elif par
not in [
"name",
"libname",
"thresholds"]+dqAlgo.ParametersNames:
57 dqAlgo.ParametersNames += [par]
64 db.create_obj(
"DQShape",
"L1CaloShapeDeveloper")
65 db.create_obj(
"DQLayout",
"L1CaloLayoutDeveloper")
66 db.create_obj(
"DQRegion",
"L1CaloRegionDeveloper")
67 dqLayout = db.get_dal(
"DQLayout",
"L1CaloLayoutDeveloper")
68 dqLayout.DefaultChildrenShape = db.get_dal(
"DQShape",
"L1CaloShapeDeveloper")
69 db.update_dal(dqLayout)
70 dqRegion = db.get_dal(
"DQRegion",
"L1CaloRegionDeveloper")
71 dqRegion.Description =
"L1Calo Monitoring Development Folder"
72 dqRegion.Label =
"Developer"
73 dqRegion.DQLayout = dqLayout
74 dqRegion.DQSummaryMaker = db.get_dal(
"DQSummaryMaker",
"WorstCaseSummary")
76 for histPath,value
in L1CaloMonitorCfgHelper.xmlConfigs.items():
77 if "algorithm" not in value.keys():
continue
79 name =
"_".
join(histPath.split(
"/"))
80 db.create_obj(
"DQParameter",name)
81 dqPar = db.get_dal(
"DQParameter",name)
82 dqPar.InputDataSource = [
"Histogramming.l1calo-athenaHLT-Phase1./"+histPath]
83 dqPar.Description = value[
"description"]
85 if value[
"algorithm"]
in L1CaloMonitorCfgHelper.hanAlgConfigs:
86 algConf = L1CaloMonitorCfgHelper.hanAlgConfigs[value[
"algorithm"]]
87 dqPar.DQAlgorithm = db.get_dal(
"DQAlgorithm",algConf[
"name"])
88 for par,val
in algConf.items():
89 if par
in dqPar.DQAlgorithm.ParametersNames:
90 dqPar.Parameters += [f
"{par}={val}"]
91 if "thresholds" in algConf:
92 for thresh,vals
in L1CaloMonitorCfgHelper.hanThresholdConfigs[algConf[
"thresholds"]].
items():
93 dqPar.GreenThresholds += [f
"{thresh}={vals['warning']}"]
94 dqPar.RedThresholds += [f
"{thresh}={vals['error']}"]
96 dqPar.DQAlgorithm = db.get_dal(
"DQAlgorithm",value[
"algorithm"])
98 dqRegion.DQParameters += [dqPar]
101 db.update_dal(dqRegion)
102 db.commit(
"Autogenerated")
◆ defineDQAlgorithm()
def LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.defineDQAlgorithm |
( |
|
self, |
|
|
|
name, |
|
|
|
hanConfig, |
|
|
|
thresholdConfig = None |
|
) |
| |
:param name: name of algorithm
:param hanConfig: dict of algo properties
:param thresholdConfig: dict of thresholds, keys in form of ParName.level
:return:
Definition at line 219 of file LVL1CaloMonitoringConfig.py.
219 def defineDQAlgorithm(self,name,hanConfig,thresholdConfig=None):
223 :param name: name of algorithm
224 :param hanConfig: dict of algo properties
225 :param thresholdConfig: dict of thresholds, keys in form of ParName.level
232 if thresholdConfig
is not None:
233 hanConfig[
"thresholds"] = f
"{name}Thresholds"
235 for parName,limVals
in thresholdConfig.items():
236 if len(limVals) != 2:
237 raise Exception(
"must specify two limits: warning and error")
238 if parName
not in threshDict: threshDict[parName] = {}
239 threshDict[parName][
"warning"] = limVals[0]
240 threshDict[parName][
"error"] = limVals[1]
242 for threshName,thresh
in self.hanThresholdConfigs.
items():
243 if str(thresh)==
str(threshDict):
245 hanConfig[
"thresholds"] = threshName
247 if threshDict
is not None: self.hanThresholdConfigs[hanConfig[
"thresholds"]] = threshDict
248 self.hanAlgConfigs[name] = hanConfig
◆ defineHistogram()
def LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.defineHistogram |
( |
|
self, |
|
|
* |
args, |
|
|
|
fillGroup = None , |
|
|
|
hanConfig = {} , |
|
|
|
paths = [] , |
|
|
** |
kwargs |
|
) |
| |
:param path:
:param fillGroup:
:param args:
:param kwargs:
:return:
Definition at line 253 of file LVL1CaloMonitoringConfig.py.
253 def defineHistogram(self,*args,fillGroup=None,hanConfig={},paths=[],**kwargs):
263 hanConfig = dict(hanConfig)
268 self.defineHistogram(*args,fillGroup=fillGroup,hanConfig=hanConfig,paths=[],path=path,**kwargs)
271 argsCopy =
list(args)
272 if ";" not in args[0]:
273 argsCopy[0] +=
";h_" + argsCopy[0].
replace(
":",
"_")
275 if kwargs.get(
"path",
None)
is None:
277 kwargs[
"path"] =
"Developer/" + self.alg.name
278 elif kwargs[
"path"][-1] ==
'/':
279 kwargs[
"path"] = kwargs[
"path"][:-1]
281 splitPath = kwargs[
"path"].
split(
"/")
282 if splitPath[0]
not in [
"Shifter",
"Expert",
"Developer"]:
283 raise Exception(
"Path of histogram invalid, does not start with one of the allowed audiences (Shifter,Expert,Developer)")
286 if splitPath[0]==
"Shifter" and self.dqEnv ==
'tier0':
290 if splitPath[0] !=
"Developer" and splitPath[-1] !=
"detail" and (
"algorithm" not in hanConfig):
292 if "description" not in hanConfig:
293 raise Exception(
"Must specify a hanConfig for a Shifter or Expert (non-detail) histogram")
295 hanConfig[
"algorithm"] =
"GatherData"
296 elif "algorithm" in hanConfig
and hanConfig[
"algorithm"]
not in self.hanAlgConfigs
and hanConfig[
"algorithm"]
not in [
"All_Bins_Filled",
"Histogram_Effective_Empty",
"Histogram_Empty",
"Histogram_Not_Empty",
"No_OverFlows",
"No_UnderFlows"]:
298 raise Exception(f
'DQ Algorithm {hanConfig["algorithm"]} for histogram {args[0]} not defined. Please use defineDQAlgorithm method to define it')
301 if fillGroup
is None: fillGroup = self.alg.name +
"_fillGroup"
302 if fillGroup
not in self.fillGroups:
303 self.fillGroups[fillGroup] = self.helper.addGroup(self.alg,fillGroup,topPath=
"L1Calo")
306 if "merge" not in kwargs
and kwargs.get(
"type",
"") !=
"TEfficiency":
307 kwargs[
"merge"] =
"merge"
309 histName = argsCopy[0].
split(
";")[-1]
312 if splitPath[0] ==
"Expert":
313 linkUrl = self.HELPURL +
"#" +
"".
join(splitPath[1:]+[histName])
314 linkUrl = f
"<a href=\"{linkUrl}\">Help</a>"
315 if "description" not in hanConfig: hanConfig[
"description"] = linkUrl
316 else: hanConfig[
"description"] +=
" - " + linkUrl
319 if splitPath[0] ==
"Expert" or splitPath[0] ==
"Developer":
320 if "description" in hanConfig
and hanConfig[
"description"]==
"":
321 del hanConfig[
"description"]
322 splitPathWithHist = splitPath + [histName]
323 x = L1CaloMonitorCfgHelper.hanConfigs
324 for i,p
in enumerate(splitPathWithHist):
325 key = (
"dir " if i!=len(splitPathWithHist)-1
else "hist ") + p
329 hanConfig[
"output"] =
"/".
join([
"L1Calo"]+splitPath)
331 elif splitPath[0] ==
"Shifter":
332 L1CaloMonitorCfgHelper.xmlConfigs[
"/".
join([
"L1Calo"]+splitPath+[histName])] = {}
333 L1CaloMonitorCfgHelper.xmlConfigs[
"/".
join([
"L1Calo"]+splitPath+[histName])].update(hanConfig)
◆ defineTree()
def LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.defineTree |
( |
|
self, |
|
|
* |
args, |
|
|
|
fillGroup = None , |
|
|
** |
kwargs |
|
) |
| |
Definition at line 337 of file LVL1CaloMonitoringConfig.py.
337 def defineTree(self,*args,fillGroup=None,**kwargs):
339 if ";" not in args[0]:
340 raise Exception(
"Must specify a tree name using ';name' suffix")
341 treeName = args[0].
split(
";")[-1]
344 raise Exception(
"Should not have comma in list of branch names and types")
346 if kwargs.get(
"path",
None)
is None:
348 kwargs[
"path"] =
"Developer/" + self.alg.name
351 splitPath = kwargs[
"path"].
split(
"/")
352 if splitPath[0]
not in [
"Developer"]:
353 raise Exception(
"Path of tree invalid, must be in the audience=Developer directory")
356 if fillGroup
is None: fillGroup = self.alg.name +
"_fillGroup"
357 if fillGroup
not in self.fillGroups:
358 self.fillGroups[fillGroup] = self.helper.addGroup(self.alg,fillGroup,topPath=
"L1Calo")
363 histName =
"h_" + treeName +
"_entries"
364 argsCopy =
list(args)
365 argsCopy[0] = argsCopy[0].
replace(
";"+treeName,
";"+histName)
366 kwargsCopy = dict(kwargs)
367 kwargsCopy[
"title"] = f
"Number of Entries in {treeName} TTree" +
";" +
";".
join(kwargsCopy.get(
"title",
"").
split(
";")[1:])
368 kwargsCopy[
"opt"] = [
'kCanRebin',
'kAddBinsDynamically',
'kAlwaysCreate']
369 kwargsCopy[
"merge"] =
"merge"
370 is2d = (kwargsCopy[
"title"].
count(
";")>1)
371 self.defineHistogram(argsCopy[0],type=
"TH2I" if is2d
else "TH1I",xbins=1,xmin=0,xmax=1,ybins=1
if is2d
else None,ymin=0,ymax=1,fillGroup=fillGroup,**kwargsCopy)
372 if not any([x
in self.dqEnv
for x
in [
'tier0',
'online']]):
373 out = self.fillGroups[fillGroup].
defineTree(*args,**kwargs)
◆ printHanConfig()
def LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.printHanConfig |
( |
|
filename = "collisions_run.config" | ) |
|
|
static |
Definition at line 106 of file LVL1CaloMonitoringConfig.py.
106 def printHanConfig(filename="collisions_run.config"):
107 L1CaloMonitorCfgHelper.createXmls()
108 from contextlib
import redirect_stdout
109 from PathResolver
import PathResolver
111 with open(filename,
'w')
as f:
114 with open(header,
'r')
as fh:
115 for line
in fh: f.write(line)
116 with redirect_stdout(f):
126 def printConf(d,prefix=""):
127 for key,value
in d.items():
128 if type(value)==dict:
129 print(prefix,key,
"{")
130 if(key==
"dir detail" or key==
"dir Developer"):
131 print(prefix+
" algorithm = GatherData")
132 if key.startswith(
"dir ")
and any([x.startswith(
"hist ")
for x
in value.keys()]):
134 for childKey,childVal
in value.items():
135 if childKey.startswith(
"hist ")
and "output" in childVal:
136 print(prefix+
" output = "+childVal[
"output"])
138 printConf(value,prefix +
" ")
142 if key ==
"output": outputs.add(value)
143 else:
print(prefix,key,
"=",value)
147 print(
"dir L1Calo {")
148 printConf(L1CaloMonitorCfgHelper.hanConfigs,
" ")
151 print(
"output top_level {")
152 def printOutputs(d,prefix=""):
153 for key,value
in d.items():
154 if(key.startswith(
"hist ")):
156 elif type(value)==dict:
157 print(prefix,key.replace(
"dir ",
"output "),
"{")
158 if key==
"dir Developer":
print(prefix,
" algorithm = L1Calo_AlwaysUndefinedSummary")
159 printOutputs(value,prefix +
" ")
161 print(
" output L1Calo {")
162 printOutputs(L1CaloMonitorCfgHelper.hanConfigs,
" ")
168 algorithm AnyNonZeroBinIsError {
169 # Use this algo if want error on any non-zero bin content
170 libname = libdqm_summaries.so
171 name = Bins_NotEqual_Threshold
173 thresholds = th_AnyBinIsError
175 algorithm L1Calo_AlwaysUndefinedSummary {
176 libname = libdqm_summaries.so
177 name = AlwaysUndefinedSummary
180 for algName,algProps
in L1CaloMonitorCfgHelper.hanAlgConfigs.items():
181 print(f
"algorithm {algName} {{")
182 for propName,propVal
in algProps.items():
183 print(f
" {propName} = {propVal}")
187 thresholds th_AnyBinIsError {
194 for threshName,threshProps
in L1CaloMonitorCfgHelper.hanThresholdConfigs.items():
195 print(f
"thresholds {threshName} {{")
196 for parName,parLims
in threshProps.items():
197 print(f
" limits {parName} {{")
198 for limName,limVal
in parLims.items():
199 print(f
" {limName} = {limVal}")
◆ result()
def LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.result |
( |
|
self | ) |
|
◆ alg
LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.alg |
◆ dqEnv
LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.dqEnv |
◆ fillGroups
LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.fillGroups |
◆ hanAlgConfigs
LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.hanAlgConfigs |
|
static |
◆ hanConfigs
LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.hanConfigs |
|
static |
◆ hanThresholdConfigs
LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.hanThresholdConfigs |
|
static |
◆ helper
LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.helper |
◆ HELPURL
LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.HELPURL |
|
static |
◆ SIGNATURES
LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.SIGNATURES |
|
static |
◆ xmlConfigs
LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.xmlConfigs |
|
static |
The documentation for this class was generated from the following file:
std::string replace(std::string s, const std::string &s2, const std::string &s3)
static std::string FindCalibFile(const std::string &logical_file_name)
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
void print(char *figname, TCanvas *c1)
std::string join(const std::vector< std::string > &v, const char c=',')
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.