added examples, moved implementation to new file

This commit is contained in:
Erik Frojdh
2023-05-30 16:08:32 +02:00
parent 6aa6673696
commit ae6aa5b58d
7 changed files with 416 additions and 179 deletions

23
examples/hist.py Normal file
View File

@@ -0,0 +1,23 @@
import os, sys
from pathlib import Path
import boost_histogram as bh
import matplotlib.pyplot as plt
from creader import ClusterFileReader
try:
base = Path(os.environ['MOENCH_DATA'])
except:
print('MOENCH_DATA has to be defined to run examples')
sys.exit(1)
fname = "Moench_LGAD_SIM_Nov22/moenchLGAD202211/clustW17new/beam_En800eV_-40deg_300V_10us_d0_f5_0.clust"
r = ClusterFileReader((base/fname).as_posix())
cl = r.read(10000)
hist1 = bh.Histogram(bh.axis.Regular(40, -2, 2**14))
hist1.fill(cl['data'].flat)
fig, ax = plt.subplots()
ax.bar(hist1.axes[0].centers, hist1.values(), width=hist1.axes[0].widths)
ax.set_yscale('log')
plt.show()