|
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 103 of file LVL1CaloMonitoringConfig.py.
103 def __init__(self, flags, algClassOrObj = None, name = None, *args, **kwargs):
105 Create the configuration helper.
108 flags -- the configuration flag object
109 algClassOrObj -- the name you want to assign the family of algorithms
111 from AthenaMonitoring
import AthMonitorCfgHelper
112 self.helper = AthMonitorCfgHelper(flags,name)
113 self.alg = self.helper.addAlgorithm(algClassOrObj,name,*args, **kwargs)
if algClassOrObj
is not None else None
115 self.dqEnv = flags.DQ.Environment
◆ 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 117 of file LVL1CaloMonitoringConfig.py.
117 def defineDQAlgorithm(self,name,hanConfig,thresholdConfig=None):
121 :param name: name of algorithm
122 :param hanConfig: dict of algo properties
123 :param thresholdConfig: dict of thresholds, keys in form of ParName.level
129 thresNum = len(self.hanThresholdConfigs)
130 if thresholdConfig
is not None:
131 hanConfig[
"thresholds"] = f
"L1CaloThreshold{thresNum}"
133 for parName,limVals
in thresholdConfig.items():
134 if len(limVals) != 2:
135 raise Exception(
"must specify two limits: warning and error")
136 if parName
not in threshDict: threshDict[parName] = {}
137 threshDict[parName][
"warning"] = limVals[0]
138 threshDict[parName][
"error"] = limVals[1]
140 for threshName,thresh
in self.hanThresholdConfigs.
items():
141 if str(thresh)==
str(threshDict):
143 hanConfig[
"thresholds"] = threshName
145 if threshDict
is not None: self.hanThresholdConfigs[hanConfig[
"thresholds"]] = threshDict
146 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 151 of file LVL1CaloMonitoringConfig.py.
151 def defineHistogram(self,*args,fillGroup=None,hanConfig={},paths=[],**kwargs):
164 self.defineHistogram(*args,fillGroup=fillGroup,hanConfig=hanConfig,paths=[],path=path,**kwargs)
167 argsCopy =
list(args)
168 if ";" not in args[0]:
169 argsCopy[0] +=
";h_" + argsCopy[0].
replace(
":",
"_")
171 if kwargs.get(
"path",
None)
is None:
173 kwargs[
"path"] =
"Developer/" + self.alg.name
174 elif kwargs[
"path"][-1] ==
'/':
175 kwargs[
"path"] = kwargs[
"path"][:-1]
177 splitPath = kwargs[
"path"].
split(
"/")
178 if splitPath[0]
not in [
"Shifter",
"Expert",
"Developer"]:
179 raise Exception(
"Path of histogram invalid, does not start with one of the allowed audiences (Shifter,Expert,Developer)")
182 if splitPath[0] !=
"Developer" and splitPath[-1] !=
"detail" and (
"algorithm" not in hanConfig):
184 if "description" not in hanConfig:
185 raise Exception(
"Must specify a hanConfig for a Shifter or Expert (non-detail) histogram")
187 hanConfig[
"algorithm"] =
"GatherData"
190 if fillGroup
is None: fillGroup = self.alg.name +
"_fillGroup"
191 if fillGroup
not in self.fillGroups:
192 self.fillGroups[fillGroup] = self.helper.addGroup(self.alg,fillGroup,topPath=
"L1Calo")
194 if "merge" not in kwargs
and kwargs.get(
"type",
"") !=
"TEfficiency":
195 kwargs[
"merge"] =
"merge"
197 histName = argsCopy[0].
split(
";")[-1]
200 if splitPath[0] ==
"Expert":
201 linkUrl = self.HELPURL +
"#" +
"".
join(splitPath[1:]+[histName])
202 linkUrl = f
"<a href=\"{linkUrl}\">Help</a>"
203 if "description" not in hanConfig: hanConfig[
"description"] = linkUrl
204 else: hanConfig[
"description"] +=
" - " + linkUrl
206 splitPathWithHist = splitPath + [histName]
207 x = L1CaloMonitorCfgHelper.hanConfigs
208 for i,p
in enumerate(splitPathWithHist):
209 key = (
"dir " if i!=len(splitPathWithHist)-1
else "hist ") + p
213 hanConfig[
"output"] =
"/".
join([
"L1Calo"]+splitPath)
◆ defineTree()
def LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.defineTree |
( |
|
self, |
|
|
* |
args, |
|
|
|
fillGroup = None , |
|
|
** |
kwargs |
|
) |
| |
Definition at line 218 of file LVL1CaloMonitoringConfig.py.
218 def defineTree(self,*args,fillGroup=None,**kwargs):
220 if ";" not in args[0]:
221 raise Exception(
"Must specify a tree name using ';name' suffix")
222 treeName = args[0].
split(
";")[-1]
225 raise Exception(
"Should not have comma in list of branch names and types")
227 if kwargs.get(
"path",
None)
is None:
229 kwargs[
"path"] =
"Developer/" + self.alg.name
232 splitPath = kwargs[
"path"].
split(
"/")
233 if splitPath[0]
not in [
"Developer"]:
234 raise Exception(
"Path of tree invalid, must be in the audience=Developer directory")
237 if fillGroup
is None: fillGroup = self.alg.name +
"_fillGroup"
238 if fillGroup
not in self.fillGroups:
239 self.fillGroups[fillGroup] = self.helper.addGroup(self.alg,fillGroup,topPath=
"L1Calo")
244 histName =
"h_" + treeName +
"_entries"
245 argsCopy =
list(args)
246 argsCopy[0] = argsCopy[0].
replace(
";"+treeName,
";"+histName)
247 kwargsCopy = dict(kwargs)
248 kwargsCopy[
"title"] = f
"Number of Entries in {treeName} TTree" +
";" +
";".
join(kwargsCopy.get(
"title",
"").
split(
";")[1:])
249 kwargsCopy[
"opt"] = [
'kCanRebin']
250 kwargsCopy[
"merge"] =
"merge"
251 is2d = (kwargsCopy[
"title"].
count(
";")>1)
252 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)
253 if not any([x
in self.dqEnv
for x
in [
'tier0',
'online']]):
254 out = self.fillGroups[fillGroup].
defineTree(*args,**kwargs)
◆ printHanConfig()
def LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.printHanConfig |
( |
|
filename = "collisions_run.config" | ) |
|
|
static |
Definition at line 23 of file LVL1CaloMonitoringConfig.py.
23 def printHanConfig(filename="collisions_run.config"):
24 from contextlib
import redirect_stdout
25 with open(filename,
'w')
as f:
26 with redirect_stdout(f):
36 def printConf(d,prefix=""):
37 for key,value
in d.items():
40 if(key==
"dir detail" or key==
"dir Developer"):
41 print(prefix+
" algorithm = GatherData")
42 printConf(value,prefix +
" ")
45 print(prefix,key,
"=",value)
47 if key ==
"output": outputs.add(value)
51 printConf(L1CaloMonitorCfgHelper.hanConfigs,
" ")
54 print(
"output top_level {")
55 def printOutputs(d,prefix=""):
56 for key,value
in d.items():
57 if(key.startswith(
"hist ")):
59 elif type(value)==dict:
60 print(prefix,key.replace(
"dir ",
"output "),
"{")
61 printOutputs(value,prefix +
" ")
63 print(
" output L1Calo {")
64 printOutputs(L1CaloMonitorCfgHelper.hanConfigs,
" ")
70 algorithm AnyNonZeroBinIsError {
71 # Use this algo if want error on any non-zero bin content
72 libname = libdqm_summaries.so
73 name = Bins_NotEqual_Threshold
75 thresholds = th_AnyBinIsError
78 for algName,algProps
in L1CaloMonitorCfgHelper.hanAlgConfigs.items():
79 print(f
"algorithm {algName} {{")
80 for propName,propVal
in algProps.items():
81 print(f
" {propName} = {propVal}")
85 thresholds th_AnyBinIsError {
92 for threshName,threshProps
in L1CaloMonitorCfgHelper.hanThresholdConfigs.items():
93 print(f
"thresholds {threshName} {{")
94 for parName,parLims
in threshProps.items():
95 print(f
" limits {parName} {{")
96 for limName,limVal
in parLims.items():
97 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 |
The documentation for this class was generated from the following file:
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.