Last active
July 25, 2023 21:39
-
-
Save jmduarte/502ef4e63478e1574d1682eb8979e154 to your computer and use it in GitHub Desktop.
MetEfficVal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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