阿特拉斯良好运行列表(GRL)阅读器和实用程序
goodruns的Python项目详细描述
关于
goodruns提供了atlas良好运行列表(grl)的实现。 python中的reader/writer和有用命令行工具的集合。
要求
goodruns至少需要python 2.5。不像标准的阿特拉斯古德伦斯 包,goodruns不依赖于xml的ROOT 正在处理,除非正在读取或写入根文件(请参阅下文)。 为了更快地读取/写入xml,如果安装了goodruns,则可以选择使用lxml。如果要将grls转换为 yaml格式。
安装
安装最新版本的goodruns pip:
pip install --user goodruns
对于系统范围的安装,省略--user(需要根权限)。 如果使用--user,并且如果 它还不存在(将其放入您的.bashrc中):
export PATH=${HOME}/.local/bin${PATH:+:$PATH}
升级现有安装,在^ {TT6}$中添加^ {TT5} $选项 上面的命令。
用法
如何使用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或根文件。
GRL差异
使用grl diff确定包含中的runs/lumiblocks的GRL 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:
提供两个以上的GRLgrl 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
一个命令的输出可以通过管道传输到任何其他命令中 祝你好运。
grl和,grl或,grl xor
这些脚本实现GRL的逻辑组合。逻辑和:
grl and A.xml B.xml > C.xml
或:
grl or A.xml B.xml > C.xml
和异或(异或):
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参数也可以是根文件或url:
grl and data.root:/path/to/grl http://atlasdqm.web.cern.ch/path/to/grl.xml
GRL夹
使用grl clip在开始运行/lumiblock和结束运行之间截断GRL 运行/lumiblock:
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转换
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代码(DICT的列表 元组)或(开玩笑)根tcut表达式。
GRL运行
grl runs只打印运行编号,每行一个,包含 在GRL内:
grl runs A.xml 186178 186179 186180 ...
从URL快速打印GRL中包含的跑步记录:
grl runs http://atlasdqm.web.cern.ch/path/to/grl.xml
GRL查找
grl find打印包含运行号和lumiblock号的GRL(如果 任何)。lumiblock编号是可选的,如果不设置所有包含 将打印跑步记录。例如,可以确定哪个根文件包含 使用以下命令运行215643和lumiblock 400:
grl find --path Lumi/tau --pattern "*.root*" --run 215643 --lb 400 globbed*path*