Skip to content

Instantly share code, notes, and snippets.

@jmduarte
Last active July 25, 2023 21:39
Show Gist options
  • Save jmduarte/502ef4e63478e1574d1682eb8979e154 to your computer and use it in GitHub Desktop.
Save jmduarte/502ef4e63478e1574d1682eb8979e154 to your computer and use it in GitHub Desktop.
MetEfficVal
def MetEfficVal(EVal_bins):
inFileName = args.inFileName
inFile = r.TFile.Open(inFileName, 'READ')
tree = inFile.Get('ntuple0/objects')
ver = inFile.Get('ntuple0/objects/vz')
eventNum = tree.GetEntries()
met_values = []
tree.GetEntry(0)
ver = tree.pup
for a in range(eventNum):
tree.GetEntry(a)
if len(ver) > 1:
tmpTLVPx = ver[0][0].Px()
tmpTLVPy = ver[0][0].Py()
for b in range(1, len(ver)):
tmpTLVPx = tmpTLVPx + ver[b][0].Px()
tmpTLVPy = tmpTLVPy + ver[b][0].Py()
vectorsum = np.sqrt(tmpTLVPx**2 + tmpTLVPy**2)
met_values.append(vectorsum)
met_values = np.array(met_values)
num = np.digitize(met_values, EVal_bins)
return (num / eventNum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment