Compare commits
3 commits
1eb0157ddb
...
62a65b8cbd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62a65b8cbd | ||
|
|
e5c3d0599b | ||
|
|
52dd472b04 |
3 changed files with 44 additions and 46 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
||||||
data/
|
data/
|
||||||
data/
|
sandbox.ipynb
|
||||||
|
|
|
||||||
31
bananas.py
31
bananas.py
|
|
@ -3,6 +3,7 @@
|
||||||
from seth_classes import *
|
from seth_classes import *
|
||||||
import argparse
|
import argparse
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(prog='bananas.py')
|
parser = argparse.ArgumentParser(prog='bananas.py')
|
||||||
parser.add_argument('filepath')
|
parser.add_argument('filepath')
|
||||||
|
|
@ -15,24 +16,24 @@ v = args.verbose
|
||||||
test = ReadSeth(fp, v)
|
test = ReadSeth(fp, v)
|
||||||
upper = {}
|
upper = {}
|
||||||
lower = {}
|
lower = {}
|
||||||
|
for i in range(1,21):
|
||||||
|
upper.setdefault(i, 0)
|
||||||
|
lower.setdefault(i, 0)
|
||||||
for event in test:
|
for event in test:
|
||||||
if (not event.upper_td) or (not event.lower_td):
|
if event.upper_td:
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if event.upper_td[0] in upper:
|
|
||||||
upper[event.upper_td[0]] += 1
|
upper[event.upper_td[0]] += 1
|
||||||
if event.lower_td[0] in lower:
|
elif event.lower_td:
|
||||||
lower[event.lower_td[0]] += 1
|
lower[event.lower_td[0]] += 1
|
||||||
else:
|
else:
|
||||||
lower.setdefault(event.lower_td[0], 1)
|
pass
|
||||||
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)
|
|
||||||
|
|
||||||
plt.bar(upper.keys(), upper.values())
|
|
||||||
plt.xlabel('Detector')
|
fig, (ax1, ax2) = plt.subplots(2,1)
|
||||||
plt.ylabel('Counts')
|
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()
|
plt.show()
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
#! /usr/bin/python3
|
#! /usr/bin/python3
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
import pandas as pd
|
|
||||||
|
|
||||||
|
|
||||||
class ReadSeth:
|
class ReadSeth:
|
||||||
def __init__(self, filename, verbose = False):
|
def __init__(self, filename, verbose = False):
|
||||||
self.verbose = verbose
|
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
|
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)
|
self.partial.append(line)
|
||||||
else:
|
else:
|
||||||
self.complete.append(self.partial)
|
temp = self.partial.copy()
|
||||||
self.partial = []
|
self.partial = []
|
||||||
self.partial.append(line)
|
self.partial.append(line)
|
||||||
|
self.complete.append(temp)
|
||||||
|
|
||||||
|
|
||||||
class SethEvent:
|
class SethEvent:
|
||||||
|
|
@ -85,31 +82,31 @@ class SethEvent:
|
||||||
self.HETB = 0
|
self.HETB = 0
|
||||||
self.BGOD = [0, 0, 0]
|
self.BGOD = [0, 0, 0]
|
||||||
self.lower_td = ()
|
self.lower_td = ()
|
||||||
for detector in event:
|
for line in event:
|
||||||
detector[ch] = int(detector[ch])
|
line[ch] = int(line[ch])
|
||||||
if detector[sl] == 0: # slice 0
|
if line[sl] == 0: # slice 0
|
||||||
if detector[ch] == 11: # dorn channel 11
|
if line[ch] == 11: # dorn channel 11
|
||||||
self.HETB = detector[9]
|
self.HETB = line[9]
|
||||||
if detector[ch] == 3:
|
if line[ch] == 3:
|
||||||
self.BGOD[0] = detector[9]
|
self.BGOD[0] = line[9]
|
||||||
if detector[ch] == 12:
|
if line[ch] == 12:
|
||||||
self.BGOD[1] = detector[9]
|
self.BGOD[1] = line[9]
|
||||||
if detector[ch] == 20:
|
if line[ch] == 20:
|
||||||
self.BGOD[2] = detector[9]
|
self.BGOD[2] = line[9]
|
||||||
if int(detector[ch]) not in [3,11,12,20] and abs(detector[ch]) < 24:
|
if int(line[ch]) not in [3,11,12,20] and abs(line[ch]) < 24:
|
||||||
self.lower_td = (diode_dictionary[detector[ch]], detector[9]) # tuple of (seth_diode, pha) for seth_diode see Jaspers thesis
|
self.lower_td = (diode_dictionary[line[ch]], line[9]) # tuple of (seth_diode, pha) for seth_diode see Jaspers thesis
|
||||||
|
|
||||||
else: # slice 1
|
else: # slice 1
|
||||||
if detector[ch] == 11: # dorn channel 11 is
|
if line[ch] == 11: # dorn channel 11 is
|
||||||
self.HETA = detector[9]
|
self.HETA = line[9]
|
||||||
if detector[ch] == 3:
|
if line[ch] == 3:
|
||||||
self.BGOB[0] = detector[9]
|
self.BGOB[0] = line[9]
|
||||||
if detector[ch] == 12:
|
if line[ch] == 12:
|
||||||
self.BGOB[1] = detector[9]
|
self.BGOB[1] = line[9]
|
||||||
if detector[ch] == 20:
|
if line[ch] == 20:
|
||||||
self.BGOB[2] = detector[9]
|
self.BGOB[2] = line[9]
|
||||||
if detector[ch] not in [3,11,12,20] and abs(detector[ch]) < 24:
|
if line[ch] not in [3,11,12,20] and abs(line[ch]) < 24:
|
||||||
self.upper_td = (diode_dictionary[detector[ch]], detector[9]) # tuple of (seth_diode, pha) for seth_diode see Jaspers thesis
|
self.upper_td = (diode_dictionary[line[ch]], line[9]) # tuple of (seth_diode, pha) for seth_diode see Jaspers thesis
|
||||||
|
|
||||||
def get_event(self):
|
def get_event(self):
|
||||||
return self._event
|
return self._event
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue