|
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 116 of file LVL1CaloMonitoringConfig.py.
116 def __init__(self, flags, algClassOrObj = None, name = None, *args, **kwargs):
118 Create the configuration helper.
121 flags -- the configuration flag object
122 algClassOrObj -- the name you want to assign the family of algorithms
124 from AthenaMonitoring
import AthMonitorCfgHelper
125 self.helper = AthMonitorCfgHelper(flags,name)
126 self.alg = self.helper.addAlgorithm(algClassOrObj,name,*args, **kwargs)
if algClassOrObj
is not None else None
128 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 130 of file LVL1CaloMonitoringConfig.py.
130 def defineDQAlgorithm(self,name,hanConfig,thresholdConfig=None):
134 :param name: name of algorithm
135 :param hanConfig: dict of algo properties
136 :param thresholdConfig: dict of thresholds, keys in form of ParName.level
143 if thresholdConfig
is not None:
144 hanConfig[
"thresholds"] = f
"{name}Thresholds"
146 for parName,limVals
in thresholdConfig.items():
147 if len(limVals) != 2:
148 raise Exception(
"must specify two limits: warning and error")
149 if parName
not in threshDict: threshDict[parName] = {}
150 threshDict[parName][
"warning"] = limVals[0]
151 threshDict[parName][
"error"] = limVals[1]
153 for threshName,thresh
in self.hanThresholdConfigs.
items():
154 if str(thresh)==
str(threshDict):
156 hanConfig[
"thresholds"] = threshName
158 if threshDict
is not None: self.hanThresholdConfigs[hanConfig[
"thresholds"]] = threshDict
159 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 164 of file LVL1CaloMonitoringConfig.py.
164 def defineHistogram(self,*args,fillGroup=None,hanConfig={},paths=[],**kwargs):
174 hanConfig = dict(hanConfig)
179 self.defineHistogram(*args,fillGroup=fillGroup,hanConfig=hanConfig,paths=[],path=path,**kwargs)
182 argsCopy =
list(args)
183 if ";" not in args[0]:
184 argsCopy[0] +=
";h_" + argsCopy[0].
replace(
":",
"_")
186 if kwargs.get(
"path",
None)
is None:
188 kwargs[
"path"] =
"Developer/" + self.alg.name
189 elif kwargs[
"path"][-1] ==
'/':
190 kwargs[
"path"] = kwargs[
"path"][:-1]
192 splitPath = kwargs[
"path"].
split(
"/")
193 if splitPath[0]
not in [
"Shifter",
"Expert",
"Developer"]:
194 raise Exception(
"Path of histogram invalid, does not start with one of the allowed audiences (Shifter,Expert,Developer)")
197 if splitPath[0] !=
"Developer" and splitPath[-1] !=
"detail" and (
"algorithm" not in hanConfig):
199 if "description" not in hanConfig:
200 raise Exception(
"Must specify a hanConfig for a Shifter or Expert (non-detail) histogram")
202 hanConfig[
"algorithm"] =
"GatherData"
205 if fillGroup
is None: fillGroup = self.alg.name +
"_fillGroup"
206 if fillGroup
not in self.fillGroups:
207 self.fillGroups[fillGroup] = self.helper.addGroup(self.alg,fillGroup,topPath=
"L1Calo")
209 if "merge" not in kwargs
and kwargs.get(
"type",
"") !=
"TEfficiency":
210 kwargs[
"merge"] =
"merge"
212 histName = argsCopy[0].
split(
";")[-1]
215 if splitPath[0] ==
"Expert":
216 linkUrl = self.HELPURL +
"#" +
"".
join(splitPath[1:]+[histName])
217 linkUrl = f
"<a href=\"{linkUrl}\">Help</a>"
218 if "description" not in hanConfig: hanConfig[
"description"] = linkUrl
219 else: hanConfig[
"description"] +=
" - " + linkUrl
222 if splitPath[0] ==
"Expert":
223 splitPathWithHist = splitPath + [histName]
224 x = L1CaloMonitorCfgHelper.hanConfigs
225 for i,p
in enumerate(splitPathWithHist):
226 key = (
"dir " if i!=len(splitPathWithHist)-1
else "hist ") + p
230 hanConfig[
"output"] =
"/".
join([
"L1Calo"]+splitPath)
◆ defineTree()
def LVL1CaloMonitoringConfig.L1CaloMonitorCfgHelper.defineTree |
( |
|
self, |
|
|
* |
args, |
|
|
|
fillGroup = None , |
|
|
** |
kwargs |
|
) |
| |
Definition at line 235 of file LVL1CaloMonitoringConfig.py.
235 def defineTree(self,*args,fillGroup=None,**kwargs):
237 if ";" not in args[0]:
238 raise Exception(
"Must specify a tree name using ';name' suffix")
239 treeName = args[0].
split(
";")[-1]
242 raise Exception(
"Should not have comma in list of branch names and types")
244 if kwargs.get(
"path",
None)
is None:
246 kwargs[
"path"] =
"Developer/" + self.alg.name
249 splitPath = kwargs[
"path"].
split(
"/")
250 if splitPath[0]
not in [
"Developer"]:
251 raise Exception(
"Path of tree invalid, must be in the audience=Developer directory")
254 if fillGroup
is None: fillGroup = self.alg.name +
"_fillGroup"
255 if fillGroup
not in self.fillGroups:
256 self.fillGroups[fillGroup] = self.helper.addGroup(self.alg,fillGroup,topPath=
"L1Calo")
261 histName =
"h_" + treeName +
"_entries"
262 argsCopy =
list(args)
263 argsCopy[0] = argsCopy[0].
replace(
";"+treeName,
";"+histName)
264 kwargsCopy = dict(kwargs)
265 kwargsCopy[
"title"] = f
"Number of Entries in {treeName} TTree" +
";" +
";".
join(kwargsCopy.get(
"title",
"").
split(
";")[1:])
266 kwargsCopy[
"opt"] = [
'kCanRebin',
'kAddBinsDynamically']
267 kwargsCopy[
"merge"] =
"merge"
268 is2d = (kwargsCopy[
"title"].
count(
";")>1)
269 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)
270 if not any([x
in self.dqEnv
for x
in [
'tier0',
'online']]):
271 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 from PathResolver
import PathResolver
27 with open(filename,
'w')
as f:
30 with open(header,
'r')
as fh:
31 for line
in fh: f.write(line)
32 with redirect_stdout(f):
42 def printConf(d,prefix=""):
43 for key,value
in d.items():
46 if(key==
"dir detail" or key==
"dir Developer"):
47 print(prefix+
" algorithm = GatherData")
48 if key.startswith(
"dir ")
and any([x.startswith(
"hist ")
for x
in value.keys()]):
50 for childKey,childVal
in value.items():
51 if childKey.startswith(
"hist ")
and "output" in childVal:
52 print(prefix+
" output = "+childVal[
"output"])
54 printConf(value,prefix +
" ")
58 if key ==
"output": outputs.add(value)
59 else:
print(prefix,key,
"=",value)
64 printConf(L1CaloMonitorCfgHelper.hanConfigs,
" ")
67 print(
"output top_level {")
68 def printOutputs(d,prefix=""):
69 for key,value
in d.items():
70 if(key.startswith(
"hist ")):
72 elif type(value)==dict:
73 print(prefix,key.replace(
"dir ",
"output "),
"{")
74 printOutputs(value,prefix +
" ")
76 print(
" output L1Calo {")
77 printOutputs(L1CaloMonitorCfgHelper.hanConfigs,
" ")
83 algorithm AnyNonZeroBinIsError {
84 # Use this algo if want error on any non-zero bin content
85 libname = libdqm_summaries.so
86 name = Bins_NotEqual_Threshold
88 thresholds = th_AnyBinIsError
91 for algName,algProps
in L1CaloMonitorCfgHelper.hanAlgConfigs.items():
92 print(f
"algorithm {algName} {{")
93 for propName,propVal
in algProps.items():
94 print(f
" {propName} = {propVal}")
98 thresholds th_AnyBinIsError {
105 for threshName,threshProps
in L1CaloMonitorCfgHelper.hanThresholdConfigs.items():
106 print(f
"thresholds {threshName} {{")
107 for parName,parLims
in threshProps.items():
108 print(f
" limits {parName} {{")
109 for limName,limVal
in parLims.items():
110 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:
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.
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.
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)