Compare commits

...

3 commits

Author SHA1 Message Date
Nicolas Rohrbeck
62a65b8cbd seth_classes: add detector information for each event 2025-08-12 12:58:38 +02:00
Nicolas Rohrbeck
e5c3d0599b bananas: flesh out total count histogram 2025-08-12 12:57:41 +02:00
Nicolas Rohrbeck
52dd472b04 gitignode: add sandbox.ipynb 2025-08-12 12:57:20 +02:00
3 changed files with 44 additions and 46 deletions

2
.gitignore vendored
View file

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

View file

@ -3,6 +3,7 @@
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')
@ -15,24 +16,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 (not event.upper_td) or (not event.lower_td):
pass
else:
if event.upper_td[0] in upper:
if event.upper_td:
upper[event.upper_td[0]] += 1
if event.lower_td[0] in lower:
elif event.lower_td:
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)
pass
plt.bar(upper.keys(), upper.values())
plt.xlabel('Detector')
plt.ylabel('Counts')
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.show()

View file

@ -1,9 +1,5 @@
#! /usr/bin/python3
import numpy as np
import pandas as pd
class ReadSeth:
def __init__(self, filename, verbose = False):
self.verbose = verbose
@ -42,9 +38,10 @@ 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:
self.complete.append(self.partial)
temp = self.partial.copy()
self.partial = []
self.partial.append(line)
self.complete.append(temp)
class SethEvent:
@ -85,31 +82,31 @@ class SethEvent:
self.HETB = 0
self.BGOD = [0, 0, 0]
self.lower_td = ()
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
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
else: # slice 1
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
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
def get_event(self):
return self._event