ATLAS Good Run List (GRL) 读取器和实用工具
项目描述
关于
goodruns提供了ATLAS Good Run List (GRL) 读取器/写入器的Python实现,以及一组有用的命令行工具。
要求
goodruns需要至少Python 2.5。与标准ATLAS GoodRunsLists包不同,goodruns不需要ROOT进行XML处理,除非您正在从或写入ROOT文件(见下文)。为了更快地读取/写入XML,goodruns将可选地使用lxml(如果已安装)。如果您希望将GRL转换为YAML格式,请安装PyYAML。
安装
使用pip安装goodruns的最新发布版本
pip install --user goodruns
省略--user以进行系统级安装(需要root权限)。如果使用--user并且它尚未存在于您的${PATH}中,请将其添加到${HOME}/.local/bin(将其放在您的.bashrc中)
export PATH=${HOME}/.local/bin${PATH:+:$PATH}
要升级现有安装,请在上面的pip命令中添加-U选项。
用法
使用goodruns的示例
from goodruns import GRL grl = GRL('grl.xml') # or: grl = GRL('http://atlasdqm.web.cern.ch/atlasdqm/grlgen/path/to/grl.xml') # or (if '/path/to/grl' is a ROOT.TObjString in data.root): grl = GRL('data.root:/path/to/grl') # check if the GRL contains the lumiblock 231 in run 186356: if (186356, 231) in grl: # do something pass
GRL会自动优化(合并并排序lumiblocks)
>>> from goodruns import GRL >>> a = GRL() >>> a.insert(1, (1,4)) >>> a.insert(1, (7,10)) >>> a --------------- RUN: 1 LUMIBLOCKS: 1 - 4 7 - 10 >>> a.insert(1, (6,7)) >>> a --------------- RUN: 1 LUMIBLOCKS: 1 - 4 6 - 10 >>> a.insert(1, (5,5)) >>> a --------------- RUN: 1 LUMIBLOCKS: 1 - 10
命令行工具
goodruns 还提供了一系列命令行工具,用于组合、操作和检查 GRL。如上所述,GRL 可能是 XML 文件、URL 或 ROOT 文件。
grl diff
使用 grl diff 确定包含在 A.xml 中但不在 B.xml 中的运行/光子块。
grl diff A.xml B.xml
换句话说,从 A.xml 中减去 B.xml。所有命令行工具都会打印到 stdout。将 stdout 重定向到文件以保存结果
grl diff A.xml B.xml > C.xml
您可以向 grl diff 提供多个 GRL
grl diff A.xml B.xml C.xml D.xml > E.xml
结果为 GRL E=((A-B)-C)-D)。这相当于
grl diff A.xml B.xml | grl diff C.xml | grl diff D.xml > E.xml
一个命令的输出可以被管道传输到 goodruns 中的其他任何命令。
grl and, grl or, grl xor
这些脚本实现了 GRL 的逻辑组合。逻辑 AND
grl and A.xml B.xml > C.xml
OR
grl or A.xml B.xml > C.xml
和 XOR(异或)
grl xor A.xml B.xml > C.xml
再次强调,这些命令可以任意组合
grl and A.xml B.xml | grl or C.xml | grl xor D.xml > E.xml
并且任何 GRL 参数也可以是 ROOT 文件或 URL
grl and data.root:/path/to/grl http://atlasdqm.web.cern.ch/path/to/grl.xml
grl clip
使用 grl clip 在起始运行/光子块和结束运行/光子块之间截断 GRL
grl clip --help usage: grl clip [-h] [-o OUTPUT] [-f FORMAT] [--startrun STARTRUN] [--startlb STARTLB] [--endrun ENDRUN] [--endlb ENDLB] [grl] positional arguments: grl optional arguments: -h, --help show this help message and exit -o OUTPUT, --output OUTPUT Output filename (optional) -f FORMAT, --format FORMAT Output format: xml, yml, txt, py, cut --startrun STARTRUN Start run --startlb STARTLB Start lumiblock --endrun ENDRUN End run --endlb ENDLB End lumiblock
grl convert
grl convert 可以将 GRL 从 XML 格式转换为 YAML
grl convert -f yml A.xml 186178: - !!python/tuple [125, 156] - !!python/tuple [158, 161] 186179: - !!python/tuple [382, 388] - !!python/tuple [390, 390] - !!python/tuple [396, 396] - !!python/tuple [398, 415] - !!python/tuple [417, 431] - !!python/tuple [433, 453] - !!python/tuple [455, 469] - !!python/tuple [471, 474] - !!python/tuple [476, 479] 186180: - !!python/tuple [114, 116] - !!python/tuple [118, 124] - !!python/tuple [126, 140] - !!python/tuple [144, 149] - !!python/tuple [151, 170] - !!python/tuple [173, 176] ...
或纯文本
grl convert -f txt A.xml --------------- RUN: 186178 LUMIBLOCKS: 125 - 156 158 - 161 --------------- RUN: 186179 LUMIBLOCKS: 382 - 388 390 396 398 - 415 417 - 431 433 - 453 455 - 469 471 - 474 476 - 479 --------------- RUN: 186180 LUMIBLOCKS: 114 - 116 118 - 124 126 - 140 144 - 149 151 - 170 173 - 176 ...
grl convert 还可以将 GRL 转换为 Python 代码(列表的元组字典)或(作为笑话)ROOT TCut 表达式。
grl runs
grl runs 仅简单地打印出 GRL 中包含的运行号,每行一个
grl runs A.xml 186178 186179 186180 ...
快速打印出 URL 中包含的运行号
grl runs http://atlasdqm.web.cern.ch/path/to/grl.xml
grl find
grl find 打印包含运行号和光子块号(如果有的话)的 GRL。光子块号是可选的,如果未设置,则打印包含运行的所有 GRL。例如,您可以使用以下命令确定哪个 ROOT 文件包含运行 215643 和光子块 400
grl find --path Lumi/tau --pattern "*.root*" --run 215643 --lb 400 globbed*path*
项目详情
goodruns-2.8.1.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | bb277fe7cb51c7a180715c0868ae9db83a8e6f6c5c31db4cb4b922a31fc50d58 |
|
MD5 | 5265a92f937ada9012ebc4dbfbbde00b |
|
BLAKE2b-256 | 8693684a692e5bb3b6cd9add987c6fee4118eade79c67392559243ed2c0cceb9 |