Suming Half the Weights in a 1D Histogram

I’m trying to sum the weights of a 1D histogram from the lowest x-axis value to the middle x-axis value (in this case the position of an energy deposit from the centre of a chamber). Is there a way to define the interval in which GetSumOfWeights() is ran over. My code is listed below. Thanks.

tree = myfile.Get(‘nEXOevents’)
xpos = ROOT.std.vector(‘float’)()
ypos = ROOT.std.vector(‘float’)()
zpos = ROOT.std.vector(‘float’)()
energy = ROOT.std.vector(‘float’)()

tree.SetBranchAddress(‘Zpos’, zpos)

evtno = 1

xposlist = [ for i in range(xpos.size())]
yposlist = [ for i in range(ypos.size())]
zposlist = [ for i in range(zpos.size())]

h1z = ROOT.TH1F(‘’,‘Energy Deposit in the z-axis from a 2e event’,100,min(zposlist)-1,max(zposlist)+1)

for i in range(xpos.size()):

minz = min(zposlist)
maxz = max(zposlist)
halfz = (minz + maxz) /2

ROOT Version: 6.24.06
Platform: Windows 11
Compiler: JupyterHub

h1z.Integral(1, h1z.FindFixBin(halfz))

1 Like