Compare commits
2 commits
9dbe44c19a
...
ca7358e95a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca7358e95a | ||
|
|
afec9ea818 |
4 changed files with 226 additions and 51 deletions
112
BB-chaos.py
112
BB-chaos.py
|
|
@ -30,13 +30,13 @@ particles = {
|
||||||
'z': 1
|
'z': 1
|
||||||
},
|
},
|
||||||
'Helium': {
|
'Helium': {
|
||||||
'E0_min': 10, # MeV
|
'E0_min': 100, # MeV
|
||||||
'E0_max': 5000, # MeV
|
'E0_max': 5000, # MeV
|
||||||
'm0': 6.644657e-27,
|
'm0': 6.644657e-27,
|
||||||
'z': 2
|
'z': 2
|
||||||
},
|
},
|
||||||
'Muon': {
|
'Muon': {
|
||||||
'E0_min': 10, # MeV
|
'E0_min': 1 , # MeV
|
||||||
'E0_max': 5000, # MeV
|
'E0_max': 5000, # MeV
|
||||||
'm0': 1.883531627e-28,
|
'm0': 1.883531627e-28,
|
||||||
'z': 1
|
'z': 1
|
||||||
|
|
@ -100,6 +100,22 @@ materials = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
materials = {
|
||||||
|
'Si': {
|
||||||
|
'ne': (2.336e3 / (28.085e-3)) * 14.0 * N_A, # Elektronendichte in Si
|
||||||
|
'I': 173 * e, # Ionisierungsenergie in Silizium in J
|
||||||
|
'd': 300e-6 # Dicke in m (300um)
|
||||||
|
},
|
||||||
|
'BGO': {
|
||||||
|
# Elektronendichte in BGO berechnen (gewichteter Durchschnitt)
|
||||||
|
'ne': (4 * (9.78e3 / (208.98e-3)) * 83 * N_A + 3 * (5.323e3 / (72.63e-3)) * 32 * N_A + 12 * (1.429e3 / (16.00e-3)) * 8 * N_A) / (4 + 3 + 12),
|
||||||
|
# Ionisierungsenergie in BGO (gewichteter Durchschnitt)
|
||||||
|
'I': (4 * 250 * e + 3 * 290 * e + 12 * 150 * e) / (4 + 3 + 12),
|
||||||
|
# Dicke in m (2cm)
|
||||||
|
'd': 2e-2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# #Output the parameters for each material
|
# #Output the parameters for each material
|
||||||
# print("Materials and their parameters:\n")
|
# print("Materials and their parameters:\n")
|
||||||
# for material, params in materials.items():
|
# for material, params in materials.items():
|
||||||
|
|
@ -162,6 +178,11 @@ def plot_Eloss_E():
|
||||||
'BGO': '-' # Linienstil für BGO (nun geändert)
|
'BGO': '-' # Linienstil für BGO (nun geändert)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linestyles = {
|
||||||
|
'Si': '-', # Linienstil für Si
|
||||||
|
'BGO': ':' # Linienstil für BGO (nun geändert)
|
||||||
|
}
|
||||||
|
|
||||||
colors = {
|
colors = {
|
||||||
'Proton': 'red',
|
'Proton': 'red',
|
||||||
'Helium': 'green',
|
'Helium': 'green',
|
||||||
|
|
@ -181,7 +202,8 @@ def plot_Eloss_E():
|
||||||
E = np.linspace(particle_params['E0_min'], particle_params['E0_max'], 100000) * 1e6 * e # Umrechnung in Joule
|
E = np.linspace(particle_params['E0_min'], particle_params['E0_max'], 100000) * 1e6 * e # Umrechnung in Joule
|
||||||
dEdx = bethebloch(E, particle_params['m0'], particle_params['z'], params['ne'], params['I'])
|
dEdx = bethebloch(E, particle_params['m0'], particle_params['z'], params['ne'], params['I'])
|
||||||
dEdx_cm = dEdx / (1e6 * e) * 1e-2 # eV/m to MeV/cm
|
dEdx_cm = dEdx / (1e6 * e) * 1e-2 # eV/m to MeV/cm
|
||||||
linewidth = 1.5 if material != 'BGO' else 3
|
#linewidth = 1.5 if material != 'BGO' else 3
|
||||||
|
linewidth = 2
|
||||||
plt.plot(E / (1e6 * e), dEdx_cm, color=colors[name], linestyle=linestyles[material], linewidth=linewidth)
|
plt.plot(E / (1e6 * e), dEdx_cm, color=colors[name], linestyle=linestyles[material], linewidth=linewidth)
|
||||||
|
|
||||||
if f'{name}' not in legend_particle_labels:
|
if f'{name}' not in legend_particle_labels:
|
||||||
|
|
@ -193,11 +215,11 @@ def plot_Eloss_E():
|
||||||
|
|
||||||
plt.xscale('log')
|
plt.xscale('log')
|
||||||
plt.yscale('log')
|
plt.yscale('log')
|
||||||
plt.xlabel('kinetic energy E [MeV]')
|
plt.xlabel('kinetic energy E [MeV]',fontsize=15)
|
||||||
plt.ylabel('Stopping Power in MeV/cm')
|
plt.ylabel('stopping power in MeV/cm',fontsize=15)
|
||||||
plt.title('Energy loss in Si, BGO, Bi, Ge, and O')
|
plt.title('Energy loss in Si, BGO, Bi, Ge, and O')
|
||||||
legend_particle = plt.legend(handles=legend_particle_handles, labels=legend_particle_labels, loc='upper center', title="Particles", frameon=True, fontsize=12*1.5)
|
legend_particle = plt.legend(handles=legend_particle_handles, labels=legend_particle_labels, loc='lower left', title="Particles", frameon=True, fontsize=15, title_fontsize=15)
|
||||||
legend_material = plt.legend(handles=legend_material_handles, labels=legend_material_labels, loc='lower left', title="Materials", frameon=True, fontsize=12*1.5)
|
legend_material = plt.legend(handles=legend_material_handles, labels=legend_material_labels, loc='upper right', title="Materials", frameon=True, fontsize=15, title_fontsize=15)
|
||||||
plt.gca().add_artist(legend_particle)
|
plt.gca().add_artist(legend_particle)
|
||||||
plt.gca().add_artist(legend_particle)
|
plt.gca().add_artist(legend_particle)
|
||||||
|
|
||||||
|
|
@ -217,21 +239,25 @@ def plot_Eloss_E():
|
||||||
E = particle_params['m0'] * c**2 * (gam - 1) # Berechnung der kinetischen Energie aus gamma
|
E = particle_params['m0'] * c**2 * (gam - 1) # Berechnung der kinetischen Energie aus gamma
|
||||||
dEdx = bethebloch(E, particle_params['m0'], particle_params['z'], params['ne'], params['I']) # Energieverlust pro Distanz
|
dEdx = bethebloch(E, particle_params['m0'], particle_params['z'], params['ne'], params['I']) # Energieverlust pro Distanz
|
||||||
dEdx_cm = dEdx / (1e6 * e) * 1e-2 # Umrechnung von eV/m in MeV/cm
|
dEdx_cm = dEdx / (1e6 * e) * 1e-2 # Umrechnung von eV/m in MeV/cm
|
||||||
linewidth = 1.5 if material != 'BGO' else 3
|
#linewidth = 1.5 if material != 'BGO' else 3
|
||||||
plt.plot(beta_gamma, dEdx_cm, color=colors[name], linestyle=linestyles[material], linewidth=linewidth)
|
linewidth = 2
|
||||||
|
f=1
|
||||||
|
if name == 'Muon': f = 0.8
|
||||||
|
plt.plot(beta_gamma, dEdx_cm, color=colors[name], linestyle=linestyles[material], linewidth=f*linewidth)
|
||||||
|
|
||||||
# Plot-Einstellungen für den zweiten Plot
|
# Plot-Einstellungen für den zweiten Plot
|
||||||
plt.xscale('log')
|
plt.xscale('log')
|
||||||
plt.yscale('log')
|
plt.yscale('log')
|
||||||
plt.xlabel(r'$\beta \cdot \gamma$')
|
plt.xlabel(r'$\beta \cdot \gamma$',fontsize=15)
|
||||||
plt.ylabel('Stopping Power in MeV/cm')
|
plt.ylabel('stopping power in MeV/cm',fontsize=15)
|
||||||
plt.title('Energy loss in Si, BGO, Bi, Ge, and O (βγ)')
|
plt.title('Energy loss in Si, BGO, Bi, Ge, and O (βγ)')
|
||||||
legend_particle = plt.legend(handles=legend_particle_handles, labels=legend_particle_labels, loc='upper center', title="Particles", frameon=True, fontsize=12*1.5)
|
legend_particle = plt.legend(handles=legend_particle_handles, labels=legend_particle_labels, loc='lower left', title="Particles", frameon=True, fontsize=15, title_fontsize=15)
|
||||||
legend_material = plt.legend(handles=legend_material_handles, labels=legend_material_labels, loc='upper right', title="Materials", frameon=True, fontsize=12*1.5)
|
legend_material = plt.legend(handles=legend_material_handles, labels=legend_material_labels, loc='upper right', title="Materials", frameon=True, fontsize=15, title_fontsize=15)
|
||||||
plt.gca().add_artist(legend_particle)
|
plt.gca().add_artist(legend_particle)
|
||||||
plt.gca().add_artist(legend_material)
|
plt.gca().add_artist(legend_material)
|
||||||
plt.grid(True, which="both", ls="--", lw=0.5)
|
plt.grid(True, which="both", ls="--", lw=0.5)
|
||||||
|
|
||||||
|
plt.tight_layout(rect=[0, 0, 0.95, 1])
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -253,7 +279,7 @@ def plot_only_Si():
|
||||||
plt.xscale('log')
|
plt.xscale('log')
|
||||||
plt.yscale('log')
|
plt.yscale('log')
|
||||||
plt.xlabel('kinetic energy E [MeV]')
|
plt.xlabel('kinetic energy E [MeV]')
|
||||||
plt.ylabel('Stopping Power in MeV/cm')
|
plt.ylabel('stopping power in MeV/cm')
|
||||||
plt.title('Energy loss in silicon')
|
plt.title('Energy loss in silicon')
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.grid(True, which="both", ls="--", lw=0.5)
|
plt.grid(True, which="both", ls="--", lw=0.5)
|
||||||
|
|
@ -278,11 +304,12 @@ def plot_only_Si():
|
||||||
plt.xscale('log')
|
plt.xscale('log')
|
||||||
plt.yscale('log')
|
plt.yscale('log')
|
||||||
plt.xlabel(r'$\beta \cdot \gamma$')
|
plt.xlabel(r'$\beta \cdot \gamma$')
|
||||||
plt.ylabel('Stopping Power in MeV/cm')
|
plt.ylabel('stopping power in MeV/cm')
|
||||||
plt.title('Energy loss in silicon (βγ)')
|
plt.title('Energy loss in silicon (βγ)')
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.grid(True, which="both", ls="--", lw=0.5)
|
plt.grid(True, which="both", ls="--", lw=0.5)
|
||||||
|
|
||||||
|
plt.tight_layout(rect=[0, 0, 0.95, 1])
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -291,7 +318,7 @@ def plot_only_Si():
|
||||||
def calculate_CHAOS(params):
|
def calculate_CHAOS(params):
|
||||||
#E0s = np.linspace(params['E0_min'], params['E0_max'], 1000)
|
#E0s = np.linspace(params['E0_min'], params['E0_max'], 1000)
|
||||||
E0s = np.logspace(np.log10(params['E0_min']), np.log10(params['E0_max']), 1000)
|
E0s = np.logspace(np.log10(params['E0_min']), np.log10(params['E0_max']), 1000)
|
||||||
dx = 1e-7
|
dx = 1e-9
|
||||||
results = []
|
results = []
|
||||||
Si_data = materials['Si']
|
Si_data = materials['Si']
|
||||||
BGO_data = materials['BGO']
|
BGO_data = materials['BGO']
|
||||||
|
|
@ -308,36 +335,39 @@ def calculate_CHAOS(params):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
results_p = calculate_CHAOS(particles['Proton'])
|
# results_p = calculate_CHAOS(particles['Proton'])
|
||||||
results_h = calculate_CHAOS(particles['Helium'])
|
# results_h = calculate_CHAOS(particles['Helium'])
|
||||||
results_mu = calculate_CHAOS(particles['Muon'])
|
# results_mu = calculate_CHAOS(particles['Muon'])
|
||||||
|
|
||||||
def format_frame(results, particle_name):
|
# def format_frame(results, particle_name):
|
||||||
df = pd.DataFrame(results, columns=["E0", "EA", "EC", "ED", "EE", "E_rest"])
|
# df = pd.DataFrame(results, columns=["E0", "EA", "EC", "ED", "EE", "E_rest"])
|
||||||
df = df.round(3)
|
# df = df.round(3)
|
||||||
df.to_csv(f'hists_sim/BB-{particle_name}.histlog', sep=' ')
|
# df.to_csv(f'hists_sim/BB-{particle_name}.histlog', sep=' ')
|
||||||
return df
|
# return df
|
||||||
|
|
||||||
frame_p = format_frame(results_p, 'Proton')
|
# frame_p = format_frame(results_p, 'Proton')
|
||||||
frame_h = format_frame(results_h, 'Helium')
|
# frame_h = format_frame(results_h, 'Helium')
|
||||||
frame_mu = format_frame(results_mu, 'Muon')
|
# frame_mu = format_frame(results_mu, 'Muon')
|
||||||
|
|
||||||
print(frame_p)
|
# print(frame_p)
|
||||||
print(frame_h)
|
# print(frame_h)
|
||||||
print(frame_mu)
|
# print(frame_mu)
|
||||||
|
|
||||||
plt.plot(frame_p["ED"], frame_p["EC"], 'x', label="proton")
|
# plt.plot(frame_p["ED"], frame_p["EC"], 'x', label="proton")
|
||||||
plt.plot(frame_h["ED"], frame_h["EC"], 'x', label="helium")
|
# plt.plot(frame_h["ED"], frame_h["EC"], 'x', label="helium")
|
||||||
plt.plot(frame_mu["ED"], frame_mu["EC"], 'x', label="muon")
|
# plt.plot(frame_mu["ED"], frame_mu["EC"], 'x', label="muon")
|
||||||
|
|
||||||
|
# plt.xlabel('Energieverlust im BGO (MeV)')
|
||||||
|
# #plt.ylabel('Verhältnis der Energieverluste (E_si2 / E_si1)')
|
||||||
|
# plt.ylabel('Energieverluste in (A)')
|
||||||
|
# plt.title('Energieverluste von Teilchen in Detektoren')
|
||||||
|
# plt.yscale('log')
|
||||||
|
# plt.ylim(0.01, 100)
|
||||||
|
# plt.legend()
|
||||||
|
# plt.show()
|
||||||
|
|
||||||
|
plot_Eloss_E()
|
||||||
|
|
||||||
plt.xlabel('Energieverlust im BGO (MeV)')
|
|
||||||
#plt.ylabel('Verhältnis der Energieverluste (E_si2 / E_si1)')
|
|
||||||
plt.ylabel('Energieverluste in (A)')
|
|
||||||
plt.title('Energieverluste von Teilchen in Detektoren')
|
|
||||||
plt.yscale('log')
|
|
||||||
plt.ylim(0.01, 100)
|
|
||||||
plt.legend()
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,9 @@ if args.lim:
|
||||||
if args.xray:
|
if args.xray:
|
||||||
nameadd = nameadd + '_xray'
|
nameadd = nameadd + '_xray'
|
||||||
|
|
||||||
if args.res: nameadd=nameadd+"_res"+str(args.res[0])
|
if args.res:
|
||||||
|
if float(args.res[0]) > 1.0: nameadd=nameadd+"_res"+str(int(args.res[0]))
|
||||||
|
else: nameadd=nameadd+"_res0"+str(int(float(args.res[0])*10))
|
||||||
if args.equal: nameadd = nameadd + '_equal'
|
if args.equal: nameadd = nameadd + '_equal'
|
||||||
|
|
||||||
global axes
|
global axes
|
||||||
|
|
@ -431,7 +433,7 @@ def generate_hist_D_MeV_log():
|
||||||
def generate_hist_xlog():
|
def generate_hist_xlog():
|
||||||
minX = 1
|
minX = 1
|
||||||
maxX = 3500
|
maxX = 3500
|
||||||
maxX = 10000
|
maxX = 100000
|
||||||
resX = 1000*resV
|
resX = 1000*resV
|
||||||
bin_x = int((maxX-minX)/resX)
|
bin_x = int((maxX-minX)/resX)
|
||||||
edges_x = np.logspace(np.log10(minX), np.log10(maxX), bin_x)
|
edges_x = np.logspace(np.log10(minX), np.log10(maxX), bin_x)
|
||||||
|
|
@ -452,7 +454,7 @@ def generate_hist_xlog():
|
||||||
if l[0] == 'H':
|
if l[0] == 'H':
|
||||||
timestamp = int(l[1])
|
timestamp = int(l[1])
|
||||||
T = get_T(float(l[8]))
|
T = get_T(float(l[8]))
|
||||||
if l[0] == 'EI' and len(l)>3*18 and conditions(l,T,args) and isMask_other(l,T,mask):
|
if l[0] == 'EI' and len(l)>3*18 and conditions(l,T,args):# and isMask_other(l,T,mask):
|
||||||
for i,chan in enumerate(chans):
|
for i,chan in enumerate(chans):
|
||||||
#b = value_HL(l,chan,u)
|
#b = value_HL(l,chan,u)
|
||||||
x_expr, x_op, x_next_op, x_next_channel = parse_channel_expression(chan)
|
x_expr, x_op, x_next_op, x_next_channel = parse_channel_expression(chan)
|
||||||
|
|
|
||||||
141
Ecalib.py
Normal file
141
Ecalib.py
Normal file
|
|
@ -0,0 +1,141 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Created on Tue Feb 25 14:02:18 2025
|
||||||
|
|
||||||
|
Energy calibration for CHAOS
|
||||||
|
|
||||||
|
@author: ava
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
|
from scipy import special
|
||||||
|
from scipy import constants
|
||||||
|
from scipy.optimize import curve_fit
|
||||||
|
import os.path
|
||||||
|
from fit_functions import lan
|
||||||
|
from fit_functions import mips
|
||||||
|
|
||||||
|
keV = True
|
||||||
|
factor = 1/0.00362
|
||||||
|
plt.figure(figsize=(17,10))
|
||||||
|
|
||||||
|
fchaos = 'histograms/chaos_sd_floata_cut-AC_ch-a.1dhistlog'
|
||||||
|
fproton = 'histograms/protona_cut-AC_ch-a.1dhistlog'
|
||||||
|
fmuon = 'histograms/mua_cut-AC_ch-a.1dhistlog'
|
||||||
|
fe = 'histograms/e-a_cut-AC_ch-a.1dhistlog'
|
||||||
|
fhe = 'histograms/hea_cut-AC_ch-a.1dhistlog'
|
||||||
|
|
||||||
|
# fchaos = 'histograms/chaos_sd_floata_cut-AC_res05_ch-a.1dhistlog'
|
||||||
|
# fproton = 'histograms/protona_cut-AC_res05_ch-a.1dhistlog'
|
||||||
|
# fmuon = 'histograms/mua_cut-AC_res05_ch-a.1dhistlog'
|
||||||
|
# fe = 'histograms/e-a_cut-AC_res05_ch-a.1dhistlog'
|
||||||
|
#fhe = 'histograms/hea_cut-AC_res05_ch-a.1dhistlog'
|
||||||
|
|
||||||
|
data_chaos = pd.read_csv(fchaos, sep = '\s+', skiprows=0)
|
||||||
|
data_p = pd.read_csv(fproton, sep = '\s+', skiprows=0)
|
||||||
|
data_m = pd.read_csv(fmuon, sep = '\s+', skiprows=0)
|
||||||
|
data_e = pd.read_csv(fe, sep = '\s+', skiprows=0)
|
||||||
|
data_h = pd.read_csv(fhe, sep = '\s+', skiprows=0)
|
||||||
|
|
||||||
|
datas = [data_chaos,data_p, data_m, data_e, data_h]
|
||||||
|
names = ["fligt","proton","muon","electron","helium"]
|
||||||
|
|
||||||
|
ch = pd.read_csv(fchaos, sep=' ', nrows=0)
|
||||||
|
energy = ch.columns[0]
|
||||||
|
resV = data_chaos[energy][1]-data_chaos[energy][0]
|
||||||
|
|
||||||
|
# channels = ['A1','A2','C1','C2']
|
||||||
|
|
||||||
|
# for ch in channels:
|
||||||
|
# plt.step(data_chaos[energy], np.multiply(data_chaos[ch], resV),label = ch, lw = 2)
|
||||||
|
# plt.step(data_p[energy], np.multiply(data_p[ch], resV),label = str(ch)+'(P)', lw = 2)
|
||||||
|
|
||||||
|
|
||||||
|
# for i in range (0,len(datas)):
|
||||||
|
# plt.step(datas[i][energy], np.add(datas[i]['A1'],datas[i]['A2']),label = names[i]+'-A', lw = 2)
|
||||||
|
# plt.step(datas[i][energy], np.add(datas[i]['C1'],datas[i]['C2']),label = names[i]+'-C', lw = 2)
|
||||||
|
# i=0
|
||||||
|
# plt.step(datas[i][energy], np.add(datas[i]['A1'],datas[i]['A2']),label = names[i]+'-A', lw = 2)
|
||||||
|
# plt.step(datas[i][energy], np.add(datas[i]['C1'],datas[i]['C2']),label = names[i]+'-C', lw = 2)
|
||||||
|
|
||||||
|
|
||||||
|
[80000, 85, 10, 700, 24000000]
|
||||||
|
# plt.plot(data_chaos[energy][a:b], lan(data_chaos[energy], *[200000, 85, 10, 14000, 200])[a:b], 'r--')
|
||||||
|
# plt.plot(data_chaos[energy][a:b], lan(data_chaos[energy], *[180000, 85, 10, 14000, 200])[a:b], 'b--')
|
||||||
|
# plt.plot(data_chaos[energy][a:b], lan(data_chaos[energy], *[160000, 85, 10, 14000, 200])[a:b], 'k--')
|
||||||
|
|
||||||
|
#AC chaos proton muon
|
||||||
|
startparams=[[2000, 91, 14, 180, 1000],[60000, 83, 9, 11000, 600],[154000, 85, 9, 16000, 170],[120000, 85, 8, 5000, 200],[]]
|
||||||
|
a = [86,88,87,87]
|
||||||
|
b = [124,129,120,127]
|
||||||
|
a = [2*86,2*88,2*87,2*87]
|
||||||
|
b = [2*124,2*129,2*120,2*127]
|
||||||
|
|
||||||
|
for i in []:
|
||||||
|
ydata=np.add(datas[i]['A1'],datas[i]['A2'])
|
||||||
|
plt.step(datas[i][energy], ydata,label = names[i]+'-A', lw = 2)
|
||||||
|
sig = np.power(ydata+1, 0.5)
|
||||||
|
par, cov = curve_fit(lan, datas[i][energy][a[i]:b[i]], ydata[a[i]:b[i]], startparams[i], sigma = sig[a[i]:b[i]], absolute_sigma=True)
|
||||||
|
print(par)
|
||||||
|
plt.plot(data_chaos[energy][a[i]:b[i]], lan(data_chaos[energy], *par)[a[i]:b[i]], 'k--')
|
||||||
|
|
||||||
|
ydata=np.add(datas[i]['C1'],datas[i]['C2'])
|
||||||
|
plt.step(datas[i][energy], ydata,label = names[i]+'-C', lw = 2)
|
||||||
|
sig = np.power(ydata+1, 0.5)
|
||||||
|
par, cov = curve_fit(lan, datas[i][energy][a[i]:b[i]], ydata[a[i]:b[i]], startparams[i], sigma = sig[a[i]:b[i]], absolute_sigma=True)
|
||||||
|
print(par)
|
||||||
|
plt.plot(data_chaos[energy][a[i]:b[i]], lan(data_chaos[energy], *par)[a[i]:b[i]], 'g--')
|
||||||
|
|
||||||
|
# i=3
|
||||||
|
# plt.step(datas[i][energy], np.add(datas[i]['A1'],datas[i]['A2']),label = names[i]+'-A', lw = 2)
|
||||||
|
# plt.step(datas[i][energy], np.add(datas[i]['C1'],datas[i]['C2']),label = names[i]+'-C', lw = 2)
|
||||||
|
|
||||||
|
################# BGO ###################
|
||||||
|
a=150
|
||||||
|
b=160
|
||||||
|
i=0
|
||||||
|
plt.vlines(datas[i][energy][a],0,100000,colors='red')
|
||||||
|
plt.vlines(datas[i][energy][b],0,100000,colors='blue')
|
||||||
|
#D chaos proton muon electron
|
||||||
|
startparams=[[2000, 91, 14, 180, 1000],[60000, 83, 9, 11000, 600],[154000, 85, 9, 16000, 170],[120000, 85, 8, 5000, 200],[]]
|
||||||
|
a = [95,103,103,0, 134]
|
||||||
|
b = [122,140,124,0,127]
|
||||||
|
c = 126
|
||||||
|
d = 150
|
||||||
|
|
||||||
|
|
||||||
|
for i in [0,1,2,3,4]:
|
||||||
|
ydata=np.add(datas[i]['D1'],datas[i]['D2'])
|
||||||
|
plt.step(datas[i][energy], ydata,label = names[i]+'-D', lw = 2)
|
||||||
|
#sig = np.power(ydata+1, 0.5)
|
||||||
|
#par, cov = curve_fit(lan, datas[i][energy][a[i]:b[i]], ydata[a[i]:b[i]], startparams[i], sigma = sig[a[i]:b[i]], absolute_sigma=True)
|
||||||
|
#print(par)
|
||||||
|
#plt.plot(data_chaos[energy][a[i]:b[i]], lan(data_chaos[energy], *par)[a[i]:b[i]], 'k--')
|
||||||
|
|
||||||
|
fs = 24
|
||||||
|
ylab = 'counts'
|
||||||
|
xlab = 'signal in ' + energy
|
||||||
|
plt.yscale('log')
|
||||||
|
plt.xscale('log')
|
||||||
|
|
||||||
|
plt.ylabel(ylab, fontsize=fs + 5)
|
||||||
|
plt.xlabel(xlab, fontsize=fs + 5)
|
||||||
|
|
||||||
|
plt.xticks(fontsize=fs)
|
||||||
|
plt.yticks(fontsize=fs)
|
||||||
|
plt.tick_params(axis='both', size=7, width=1.5)
|
||||||
|
|
||||||
|
plt.xlim(10, 100000)
|
||||||
|
plt.ylim(0.9, 200000)
|
||||||
|
|
||||||
|
plt.legend(fontsize=fs-1, loc="upper right",ncol=1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
plt.show()
|
||||||
|
|
||||||
14
xplot.py
14
xplot.py
|
|
@ -91,7 +91,7 @@ def do_1dhist():
|
||||||
if not Itime==None:
|
if not Itime==None:
|
||||||
plt.step(data[energy], np.multiply(data[ch], f*3600/resV/Itime),label=ch, lw=2)
|
plt.step(data[energy], np.multiply(data[ch], f*3600/resV/Itime),label=ch, lw=2)
|
||||||
else:
|
else:
|
||||||
plt.step(data[energy], data[ch], label=ch)
|
plt.step(data[energy], data[ch]/resV, label=ch)
|
||||||
|
|
||||||
#limits = args.limits if args.limits else [-100, 10000, 0.1, 100000]
|
#limits = args.limits if args.limits else [-100, 10000, 0.1, 100000]
|
||||||
limits = args.limits if args.limits else [0, 100, 10, 10000]
|
limits = args.limits if args.limits else [0, 100, 10, 10000]
|
||||||
|
|
@ -114,7 +114,7 @@ def do_1dhist():
|
||||||
#plt.axvline(x=43, color='black', linestyle='--', linewidth=2, label='43 mV')
|
#plt.axvline(x=43, color='black', linestyle='--', linewidth=2, label='43 mV')
|
||||||
|
|
||||||
|
|
||||||
plot_layout(title, energy, limits,None,None,None)
|
plot_layout(title, energy, limits,None,None,None,None)
|
||||||
|
|
||||||
|
|
||||||
save_or_show_plot(channels)
|
save_or_show_plot(channels)
|
||||||
|
|
@ -148,7 +148,7 @@ def do_1dhist_morefiles(files):
|
||||||
|
|
||||||
title = args.title if args.title else f'Histplot: {", ".join([f.split("/")[-1] for f in files])}'
|
title = args.title if args.title else f'Histplot: {", ".join([f.split("/")[-1] for f in files])}'
|
||||||
|
|
||||||
plot_layout(title, energy, limits,None,None,None)
|
plot_layout(title, energy, limits,None,None,None,None)
|
||||||
|
|
||||||
save_or_show_plot(channels)
|
save_or_show_plot(channels)
|
||||||
|
|
||||||
|
|
@ -333,7 +333,7 @@ def do_2dhist():
|
||||||
xx = np.linspace(limits[0], limits[1], 10000)
|
xx = np.linspace(limits[0], limits[1], 10000)
|
||||||
plt.plot(xx, xx, color='black', linewidth=0.5)
|
plt.plot(xx, xx, color='black', linewidth=0.5)
|
||||||
|
|
||||||
plot_layout(tit,energy, limits,xlab,ylab,cbar)
|
plot_layout(tit,energy, limits,xlab,ylab,cbar,None)
|
||||||
|
|
||||||
save_or_show_plot([])
|
save_or_show_plot([])
|
||||||
|
|
||||||
|
|
@ -360,7 +360,7 @@ def read_Itime(file, end):
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
def plot_layout(title, energy, limits, x, y, cbar):
|
def plot_layout(title, energy, limits, x, y, cbar, Itime):
|
||||||
fs = 15
|
fs = 15
|
||||||
fs = 24
|
fs = 24
|
||||||
|
|
||||||
|
|
@ -370,6 +370,8 @@ def plot_layout(title, energy, limits, x, y, cbar):
|
||||||
add = '$_{Si}$'
|
add = '$_{Si}$'
|
||||||
add = ""
|
add = ""
|
||||||
ylab = 'counts / h / ' + energy + add
|
ylab = 'counts / h / ' + energy + add
|
||||||
|
if Itime == None:
|
||||||
|
ylab = 'counts / ' + energy + add
|
||||||
xlab = 'signal in ' + energy + add
|
xlab = 'signal in ' + energy + add
|
||||||
plt.yscale('log')
|
plt.yscale('log')
|
||||||
|
|
||||||
|
|
@ -411,7 +413,7 @@ def plot_layout(title, energy, limits, x, y, cbar):
|
||||||
cbar.ax.tick_params(labelsize=fs)
|
cbar.ax.tick_params(labelsize=fs)
|
||||||
|
|
||||||
if plt.gca().get_legend_handles_labels()[0]: # Gibt eine Liste von Künstlern (Handles) und Labels zurück
|
if plt.gca().get_legend_handles_labels()[0]: # Gibt eine Liste von Künstlern (Handles) und Labels zurück
|
||||||
plt.legend(fontsize=fs-1, loc="upper right",ncol=4)
|
plt.legend(fontsize=fs-1, loc="upper right",ncol=1)
|
||||||
#plt.legend(fontsize=fs+5, loc="upper right")
|
#plt.legend(fontsize=fs+5, loc="upper right")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue