Skip to content
Snippets Groups Projects
Commit ad2f7d87 authored by Jack Christopher Hutchinson Rolph's avatar Jack Christopher Hutchinson Rolph
Browse files

Update example.py

parent c056edeb
No related branches found
No related tags found
No related merge requests found
import os
import sys
import numpy as np
......@@ -7,6 +6,24 @@ from PeakOTron import PeakOTron
from joblib import dump
import time
C_tau = lambda V, V_bd, V_0: (V - V_bd)/V_0
f_tau = lambda V, V_bd, V_0: -1/np.log((1-np.exp(C_tau(V, V_bd, V_0)*np.exp(-1)))/(1 - np.exp(C_tau(V, V_bd, V_0))))
V_bd_hmt = 51.570574 + 0.307
V_0_hmt = 2.906
tau = 21.953 ##SLOW COMPONENT OF SIPM PULSE
t_0 = 100.0 ## PRE-INTEGRATION TIME
t_gate = 104.0 ## GATE LENGTH
bin_0=-100.0 ## SELECT FIRST BIN OF SPECTRUM (CAN BE AUTOMATIC)
truncate_nsigma0_up = 2.0 ## SCAN SPECTRUM FROM Q < Q_0 - 4 sigma_0
truncate_nsigma0_do = 2.0 ## EVALUATE SPECTRUM CHI2 IN Q_0 - x*sigma_0 < Q < Q_0 + 2*sigma_0
prefit_only=False ## FIT THE WHOLE SPECTRUM
print("--------------------")
print('EXAMPLE SIPM CALIBRATION RUN')
print("--------------------")
......@@ -16,7 +33,7 @@ out_dict = {}
files_to_fit = []
## Find all histograms in directory
for root, dirs, files in os.walk("./data/hamamatsu_pcb6/Light"):
for root, dirs, files in os.walk("./data_paper/hamamatsu_pcb6/Light"):
for file in files:
......@@ -40,6 +57,9 @@ for i, (file, path) in enumerate(files_to_fit):
V = float(items[2].replace('V', '').replace('p', '.'))
f_tau_hmt = f_tau(V, V_bd_hmt, V_0_hmt)
print("\n\n")
print("===============================================================")
print("FIT {:d} - {:s}".format(i, file))
......@@ -51,18 +71,23 @@ for i, (file, path) in enumerate(files_to_fit):
data = np.loadtxt(path, skiprows=8)
## Create a PeakOTron Fit Object.
f_data = PeakOTron(verbose=True)
f_data = PeakOTron(verbose=False)
## Perform fit.
f_data.Fit(data,
tau=21.953, #SLOW PULSE COMPONENT TIME CONSTANT (ns)
t_gate=104, #GATE LENGTH (ns)
t_0 = 64, #INTEGRATION TIME BEFORE GATE (ns)
tau_R=21.953
tau=tau, #SLOW PULSE COMPONENT TIME CONSTANT (ns)
t_gate=t_gate, #GATE LENGTH (ns)
t_0 = t_0, #INTEGRATION TIME BEFORE GATE (ns)
tau_R=f_tau_hmt*tau,
bin_0 = bin_0,
truncate_nsigma0_up = truncate_nsigma0_up,
truncate_nsigma0_do = truncate_nsigma0_do
) #BINNING RULE "knuth", "freedman", "scott" - use bw= #### to override. it is still required for DCR calculation.
f_data.PlotFit(xlabel="ADC", display=False, save_directory="./Results/{0}_fit.png".format(os.path.splitext(file)[0]))
f_data.PlotFit(plot_in_bins=True, display=False, save_directory="./Results/{0}_fit.png".format(os.path.splitext(file)[0]))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment