My question is about the Vector module in scikit-hep.
https://vector.readthedocs.io/en/latest/index.html
I have an awkward array of vectors and I'd like to set the mass of all of them to be a common value. For example, I can do this with a single vector object.
x = vector.obj(pt=2, eta=1.5, phi=1, energy=10)
y = x.from_rhophietatau(rho=x.rho, eta=x.eta, phi=x.phi, tau=20)
print(f"{x.mass:6.3f} {x.pt} {x.eta} {x.phi} {x.energy:6.2f}")
print(f"{y.mass:6.3f} {y.pt} {y.eta} {y.phi} {y.energy:6.2f}")
Output
8.824 2 1.5 1 10.00
20.000 2 1.5 1 20.55
But suppose I want to do this with an awkward array of vectors?
Let me start with some starter code from this previous question:
Using awkward-array with zip/unzip with two different physics objects
First, I'll get an input file
curl http://opendata.cern.ch/record/12361/files/SMHiggsToZZTo4L.root --output SMHiggsToZZTo4L.root
Then I'll make use of the code from the answer to that question:
import numpy as np
import matplotlib.pylab as plt
import uproot
import awkward as ak
import vector
vector.register_awkward()
infile = uproot.open("/tmp/SMHiggsToZZTo4L.root")
muon_branch_arrays = infile["Events"].arrays(filter_name="Muon_*")
electron_branch_arrays = infile["Events"].arrays(filter_name="Electron_*")
muons = ak.zip({
"pt": muon_branch_arrays["Muon_pt"],
"phi": muon_branch_arrays["Muon_phi"],
"eta": muon_branch_arrays["Muon_eta"],
"mass": muon_branch_arrays["Muon_mass"],
"charge": muon_branch_arrays["Muon_charge"],
}, with_name="Momentum4D")
quads = ak.combinations(muons, 4)
mu1, mu2, mu3, mu4 = ak.unzip(quads)
p4 = mu1 + mu2 + mu3 + mu4
The type of p4 is <class 'vector._backends.awkward_.MomentumArray4D'>. Is there a way to set all the masses of the p4 objects to be, for example, 125? While this is not exactly my analysis, I need to do something similar where I will then use p4 to boost the muX objects to the CM frame of p4 and look at some relative angles. But I need to set the mass of p4 to be a constant value.
Is this possible? Thanks!
Matt