May 2018
Summer on campus. Entire family swimming in the fountain.
I need to take sums over ranges in time and energy. The challenge is that I can't simply provide an input energy, because that may not correspond to a bin edge. I need to select the energies that correspond to time bin edges.
In [1]:
import os
import sys
import matplotlib.pyplot as plt
import numpy as np
import imageio
In [2]:
import pandas as pd
In [3]:
import seaborn as sns
sns.set(style='ticks')
In [4]:
sys.path.append('../scripts/')
In [5]:
import bicorr as bicorr
import bicorr_plot as bicorr_plot
In [6]:
%load_ext autoreload
%autoreload 2
In [7]:
help(bicorr.convert_energy_to_time)
Let's look at the distribution of detector distances. This is stored in an excel file meas_info > detector_distances.xlsx
.
In [8]:
os.listdir('../meas_info/')
Out[8]:
In [7]:
det_distance_df = pd.read_excel('../meas_info/detector_distances.xlsx')
det_distance_df.head()
Out[7]:
Look at a distibution of the detector distances.
In [8]:
plt.figure(figsize=(4,3))
plt.hist(det_distance_df['Distance (cm)'])
plt.xlabel('Distance (cm)')
plt.ylabel('Number of detectors')
plt.title('Detector-FC distance distribution')
sns.despine(right=False)
plt.show()
Yikes, so my first observation is that the distances are not centered around 100! They are, in fact, all greater than 100. So I think even just changing the default distance in bicorr.convert_time_to_energy
would improve things.
I'm going to use pandas.DataFrame.describe
to spit out some metrics: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.describe.html
In [9]:
det_distance_df.describe()['Distance (cm)']
Out[9]:
In [33]:
bicorr_plot.histogram_metrics(np.asarray(det_distance_df['Distance (cm)']),'Distance (cm)','Relative number of detectors')
I don't know where this error is coming from, so I will just continue on...
One nice thing about this distribution is that there are not really any "extremes." The
Look at 25 ns, which is right in the middle of the neutron distribution.
In [12]:
t = 25
print(bicorr.convert_time_to_energy(t,distance=1))
print(bicorr.convert_time_to_energy(t,distance=1.05522))
print(bicorr.convert_time_to_energy(t,distance=1.05522)/bicorr.convert_time_to_energy(t,distance=1))
So the 5.5% change in distance translates to an 11% change in energy for a 25 ns time of flight.
In [13]:
t = 50
print(bicorr.convert_time_to_energy(t,distance=1))
print(bicorr.convert_time_to_energy(t,distance=1.05522))
print(bicorr.convert_time_to_energy(t,distance=1.05522)/bicorr.convert_time_to_energy(t,distance=1))
Again, an 11% change in energy for a 50 ns time of flight. This is equal to 1.05522^2.
In [14]:
1.05522**2
Out[14]:
There we go. So whatever the ratio of distances is, the energy calculations will be off by that amount squared.
This really makes me think we need to go back to the original cced files, calculate the energies for each interaction, and then remake the bicorr_hist_master
from that. This will be a lot of work.
In [19]:
det_distance_df.head()
Out[19]:
In [30]:
t = 25
energies = [bicorr.convert_time_to_energy(t,distance=dist) for dist in det_distance_df['Distance (cm)']/100]
bicorr_plot.histogram_metrics(energies, xlabel='Energy (MeV)', ylabel='Counts')
In [31]:
pd.DataFrame([bicorr.convert_time_to_energy(t,distance=dist) for dist in det_distance_df['Distance (cm)']/100]).describe()
Out[31]:
In [27]:
t = 50
energies = [bicorr.convert_time_to_energy(t,distance=dist) for dist in det_distance_df['Distance (cm)']/100]
bicorr_plot.histogram_metrics(energies, xlabel='Energy (MeV)', ylabel='Counts')
In [29]:
pd.DataFrame([bicorr.convert_time_to_energy(t,distance=dist) for dist in det_distance_df['Distance (cm)']/100]).describe()
Out[29]:
In [ ]:
In [15]:
dt_bin_edges = np.arange(0,200,2)
print(dt_bin_edges)
In [17]:
energy_bin_edges = np.asarray(np.insert([bicorr.convert_time_to_energy(t) for t in dt_bin_edges[1:]],0,10000))
print(energy_bin_edges)
In [18]:
plt.figure(figsize=(4,3))
plt.plot(dt_bin_edges,energy_bin_edges,'.-k',linewidth=.5)
plt.axvline(15,color='r')
plt.axvline(150,color='r')
plt.yscale('log')
plt.xlabel('time bin edge (ns)')
plt.ylabel('energy bin edge (MeV)')
sns.despine(right=False)
plt.show()
Look at dt_bin_edges
-> energy_bin_edges
. How different are the edges for the extreme distances?
Evaluate how much would have to go into updating the analysis to incorporate this.
bhp
together across pairs. Would have to define energy bin edges for all of them, and then time and energy bhp
distributions would be different for each.
In [ ]: