import tables import sys my_file=tables.open_file(sys.argv[1]) import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np print('Loading ctime') ctime = my_file.root.FlasherShiftedPulses.cols.time[:] print('Loading charge') charge = my_file.root.FlasherShiftedPulses.cols.charge[:] print('Loading rstr') rstr = my_file.root.FlasherShiftedPulses.cols.string[:] print('Loading rdom') rdom = my_file.root.FlasherShiftedPulses.cols.om[:] print('Computing cut') cut = (charge[:]>0)&(rstr[:]==73)&(rdom[:]==23) #you can adapt this to whatever receiver you want print('Getting N flashers') n_flashers = len(my_file.root.FlasherInfo) print('Making figure') plt.figure() # this normalizes the charge to the number of flashers, so you can compare data to simulation # or compare different runs print('Normalizing charge') weightvec = charge[cut] / n_flashers # this saves the histogram contents as an array which you can then use to make calculations # such as total charge, etc. print('Making histogram') h,edges = np.histogram(ctime[cut],weights=weightvec,bins=100,range=[0,1000]) print('Plotting histogram') plt.hist(ctime[cut],weights=charge[cut],bins=100,range=[0,1000],alpha=0.5,color='red') print('Saving figure') plt.xlim(0,1000) plt.xlabel('time (ns)') plt.savefig('flasher_plot.png')