FastJet与Numpy的接口
pyjet的Python项目详细描述
pyjet允许您使用FastJet执行jet集群 在NumPy数组上。默认情况下,pyjet只依赖于 numpy和内部使用了fastjet的独立fjcore版本。接口 代码是用Cython编写的,然后被编译 C++,所以它很快。记住,如果你使用pyjet,那么你使用的是fastjet 并应引用所列的论文here。
开始
pyjet提供了cluster()函数,该函数接受一个numpy数组作为输入 并返回一个ClusterSequence,从中可以访问喷气机:
frompyjetimportclusterfrompyjet.testdataimportget_eventvectors=get_event()sequence=cluster(vectors,R=1.0,p=-1)jets=sequence.inclusive_jets()# list of PseudoJetsexclusivejets=sequence.exclusive_jets(3)# Find the cluster history when there are 3 jets
输入数组vectors的前四个字段必须是:
np.dtype([('pT','f8'),('eta','f8'),('phi','f8'),('mass','f8')])
或者如果cluster(..., ep=True):
np.dtype([('E','f8'),('px','f8'),('py','f8'),('pz','f8')])
注意,输入数组的字段名不需要与“pt”、“eta”、“phi”匹配, “质量”等。Pyjet只假设前四个字段是这些数量。 此数组还可以有任何类型的附加字段。其他字段将 然后成为PseudoJet对象的属性。
请参阅examples到 开始:
独立安装
只需使用内置的FastJet源代码:
pip install --user pyjet
你很好去!
获取example.py并运行它:
curl -O https://raw.githubusercontent.com/scikit-hep/pyjet/master/examples/example.py python example.py jet# pT eta phi mass #constit. 1 983.280 -0.868 2.905 36.457 34 2 901.745 0.221 -0.252 51.850 34 3 67.994 -1.194 -0.200 11.984 32 4 12.465 0.433 0.673 5.461 13 5 6.568 -2.629 1.133 2.099 9 6 6.498 -1.828 -2.248 3.309 6 The 6th jet has the following constituents: PseudoJet(pt=0.096, eta=-2.166, phi=-2.271, mass=0.000) PseudoJet(pt=2.200, eta=-1.747, phi=-1.972, mass=0.140) PseudoJet(pt=1.713, eta=-2.037, phi=-2.469, mass=0.940) PseudoJet(pt=0.263, eta=-1.682, phi=-2.564, mass=0.140) PseudoJet(pt=1.478, eta=-1.738, phi=-2.343, mass=0.940) PseudoJet(pt=0.894, eta=-1.527, phi=-2.250, mass=0.140) Get the constituents as an array (pT, eta, phi, mass): [( 0.09551261, -2.16560157, -2.27109083, 4.89091390e-06) ( 2.19975694, -1.74672746, -1.97178728, 1.39570000e-01) ( 1.71301882, -2.03656511, -2.46861524, 9.39570000e-01) ( 0.26339374, -1.68243005, -2.56397904, 1.39570000e-01) ( 1.47781519, -1.7378898 , -2.34304346, 9.39570000e-01) ( 0.89353864, -1.52729244, -2.24973202, 1.39570000e-01)] or (E, px, py, pz): [( 0.42190436, -0.06155242, -0.07303395, -0.41095089) ( 6.50193926, -0.85863306, -2.02526044, -6.11692764) ( 6.74203628, -1.33952806, -1.06775374, -6.45273802) ( 0.74600384, -0.22066287, -0.1438199 , -0.68386087) ( 4.43164941, -1.0311407 , -1.05862485, -4.07096881) ( 2.15920027, -0.56111108, -0.69538886, -1.96067711)] Reclustering the constituents of the hardest jet with the kt algorithm [PseudoJet(pt=983.280, eta=-0.868, phi=2.905, mass=36.457)] Go back in the clustering sequence to when there were two jets PseudoJet(pt=946.493, eta=-0.870, phi=2.908, mass=20.117) PseudoJet(pt=36.921, eta=-0.800, phi=2.821, mass=4.119) Ask how many jets there are with a given dcut There are 9 jets with a dcut of 0.5 Get the jets with the given dcut 1 PseudoJet(pt=308.478, eta=-0.865, phi=2.908, mass=2.119) 2 PseudoJet(pt=256.731, eta=-0.868, phi=2.906, mass=0.140) 3 PseudoJet(pt=142.326, eta=-0.886, phi=2.912, mass=0.829) 4 PseudoJet(pt=135.971, eta=-0.870, phi=2.910, mass=0.140) 5 PseudoJet(pt=91.084, eta=-0.864, phi=2.899, mass=1.530) 6 PseudoJet(pt=30.970, eta=-0.831, phi=2.822, mass=2.124) 7 PseudoJet(pt=7.123, eta=-0.954, phi=2.939, mass=1.017) 8 PseudoJet(pt=5.951, eta=-0.626, phi=2.818, mass=0.748) 9 PseudoJet(pt=4.829, eta=-0.812, phi=3.037, mass=0.384)
使用外部FastJet安装
利用完整的fastjet库和优化的o(nlnn)kt和 反kt算法您可以首先构建和安装fastjet,然后安装 带有--external-fastjet标志的pyjet。在建造FastJet之前 需要安装CGAL和GMP。
在基于debian的系统(ubuntu)上:
sudo apt-get install libcgal-dev libcgal11v5 libgmp-dev libgmp10
在基于RPM的系统(Fedora)上:
sudo dnf install gmp.x86_64 gmp-devel.x86_64 CGAL.x86_64 CGAL-devel.x86_64
在Mac OS上:
brew install cgal gmp wget
然后运行pyjet的install-fastjet.sh脚本:
curl -O https://raw.githubusercontent.com/scikit-hep/pyjet/master/install-fastjet.sh chmod +x install-fastjet.sh sudo ./install-fastjet.sh
现在安装pyjet如下:
pip install --user pyjet --install-option="--external-fastjet"
pyjet现在将在您的系统上使用外部fastjet安装。
关于单位的说明
这个包裹对特定的单位漠不关心,这些单位仅仅是“传播的” 通过密码。我们建议按照定义使用HEP装置 在hepunits package的units模块中。
值得注意的是,方位角phi用弧度表示。 从圆周率到圆周率不等。