Compare commits

..

No commits in common. "62a65b8cbde1fc4087c5f7f5621fb9f4d70a5301" and "1eb0157ddb1bb38dec35d7b7d6a9d8617b4a1d71" have entirely different histories.

3 changed files with 46 additions and 44 deletions

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
data/
sandbox.ipynb
data/

View file

@ -3,7 +3,6 @@
from seth_classes import *
import argparse
import matplotlib.pyplot as plt
import numpy as np
parser = argparse.ArgumentParser(prog='bananas.py')
parser.add_argument('filepath')
@ -16,24 +15,24 @@ v = args.verbose
test = ReadSeth(fp, v)
upper = {}
lower = {}
for i in range(1,21):
upper.setdefault(i, 0)
lower.setdefault(i, 0)
for event in test:
if event.upper_td:
upper[event.upper_td[0]] += 1
elif event.lower_td:
lower[event.lower_td[0]] += 1
else:
if (not event.upper_td) or (not event.lower_td):
pass
else:
if event.upper_td[0] in upper:
upper[event.upper_td[0]] += 1
if event.lower_td[0] in lower:
lower[event.lower_td[0]] += 1
else:
lower.setdefault(event.lower_td[0], 1)
else:
upper.setdefault(event.upper_td[0], 1)
if event.lower_td[0] in lower:
lower[event.lower_td[0]] += 1
else:
lower.setdefault(event.lower_td[0], 1)
fig, (ax1, ax2) = plt.subplots(2,1)
ax1.bar(upper.keys(), upper.values(), label='upper diodes', tick_label=[str(num) for num in range(1,21)])
ax2.bar(lower.keys(), lower.values(), label='lower diodes', tick_label=[str(num) for num in range(1,21)])
ax1.set_xlabel('Upper Trigger Diode')
ax2.set_xlabel('Lower Trigger Diode')
ax1.set_ylabel('Total Counts')
ax2.set_ylabel('Total Counts')
fig.suptitle(f'Total counts of trigger diodes {fp.split("/")[-1]}')
plt.bar(upper.keys(), upper.values())
plt.xlabel('Detector')
plt.ylabel('Counts')
plt.show()

View file

@ -1,5 +1,9 @@
#! /usr/bin/python3
import numpy as np
import pandas as pd
class ReadSeth:
def __init__(self, filename, verbose = False):
self.verbose = verbose
@ -38,10 +42,9 @@ class ReadSeth:
if not self.partial or line[0] <= self.partial[0][0] + time_window: # if list is empty or new line is not older than 5 ticks relative to first line in event
self.partial.append(line)
else:
temp = self.partial.copy()
self.complete.append(self.partial)
self.partial = []
self.partial.append(line)
self.complete.append(temp)
class SethEvent:
@ -82,31 +85,31 @@ class SethEvent:
self.HETB = 0
self.BGOD = [0, 0, 0]
self.lower_td = ()
for line in event:
line[ch] = int(line[ch])
if line[sl] == 0: # slice 0
if line[ch] == 11: # dorn channel 11
self.HETB = line[9]
if line[ch] == 3:
self.BGOD[0] = line[9]
if line[ch] == 12:
self.BGOD[1] = line[9]
if line[ch] == 20:
self.BGOD[2] = line[9]
if int(line[ch]) not in [3,11,12,20] and abs(line[ch]) < 24:
self.lower_td = (diode_dictionary[line[ch]], line[9]) # tuple of (seth_diode, pha) for seth_diode see Jaspers thesis
for detector in event:
detector[ch] = int(detector[ch])
if detector[sl] == 0: # slice 0
if detector[ch] == 11: # dorn channel 11
self.HETB = detector[9]
if detector[ch] == 3:
self.BGOD[0] = detector[9]
if detector[ch] == 12:
self.BGOD[1] = detector[9]
if detector[ch] == 20:
self.BGOD[2] = detector[9]
if int(detector[ch]) not in [3,11,12,20] and abs(detector[ch]) < 24:
self.lower_td = (diode_dictionary[detector[ch]], detector[9]) # tuple of (seth_diode, pha) for seth_diode see Jaspers thesis
else: # slice 1
if line[ch] == 11: # dorn channel 11 is
self.HETA = line[9]
if line[ch] == 3:
self.BGOB[0] = line[9]
if line[ch] == 12:
self.BGOB[1] = line[9]
if line[ch] == 20:
self.BGOB[2] = line[9]
if line[ch] not in [3,11,12,20] and abs(line[ch]) < 24:
self.upper_td = (diode_dictionary[line[ch]], line[9]) # tuple of (seth_diode, pha) for seth_diode see Jaspers thesis
if detector[ch] == 11: # dorn channel 11 is
self.HETA = detector[9]
if detector[ch] == 3:
self.BGOB[0] = detector[9]
if detector[ch] == 12:
self.BGOB[1] = detector[9]
if detector[ch] == 20:
self.BGOB[2] = detector[9]
if detector[ch] not in [3,11,12,20] and abs(detector[ch]) < 24:
self.upper_td = (diode_dictionary[detector[ch]], detector[9]) # tuple of (seth_diode, pha) for seth_diode see Jaspers thesis
def get_event(self):
return self._event