Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/waffles/np04_analysis/time_resolution/channel_pair_ana.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@
out_root_file.mkdir(subdir_name)
out_root_file.cd(subdir_name)

t0_diff = time_alligner.com_ch.t0s - time_alligner.ref_ch.t0s
t0_diff = (time_alligner.com_ch.t0s - time_alligner.ref_ch.t0s)*16.0 # convert to ns

# --- PLOTTING ---------------------------------------------------
# t0 differences distribution ------------------------------------
x_min = np.percentile(t0_diff, 0.5)
x_max = np.percentile(t0_diff, 99.5)
h_t0_diff = TH1F("h_t0_diff", "Comparison-Reference time difference;t0 [ticks=16ns];Counts",
h_t0_diff = TH1F("h_t0_diff", "Comparison-Reference time difference;#Deltat [ns];Counts",
200, x_min, x_max)
for diff in t0_diff:
h_t0_diff.Fill(diff)
Expand Down
10 changes: 6 additions & 4 deletions src/waffles/np04_analysis/time_resolution/params.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
# Runs to be analyzed
runs : [30666]
runs : [30658]

# File.csv with an OfflineCh <-> RMS mapping for a given
# VGain and Integrators ON/OFF configuration
noise_results_file : "/eos/home-f/fegalizz/ProtoDUNE_HD/Noise_Studies/analysis/FFT_sets/OfflineCh_RMS_Config_31.csv"
# NOW USELESS! These files are in np04_utils, and the mapping is done in the code
# noise_results_file : "/eos/home-f/fegalizz/ProtoDUNE_HD/Noise_Studies/analysis/FFT_sets/OfflineCh_RMS_Config_31.csv"

# File.csv with the calibration results
calibration_file : "/eos/home-f/fegalizz/ProtoDUNE_HD/TimeResolution/analysis/TimeResolutionCalib_golden_runs.csv"
calibration_file : "/eos/home-f/fegalizz/ProtoDUNE_HD/TimeResolution/analysis/golden_runs_analysis/TimeResolutionCalib_golden_runs.csv"

# If empty, all the calibrated channels will be analyzed
channels : []

# Used only if these parametersa re not found in the calibration file
prepulse_ticks : 125
int_low : 130
int_up : 155
postpulse_ticks : 155

min_pes : 5

methods : ["amplitude", "integral", "denoise"]
methods : ["amplitude", "integral"]

relative_thrs : [0.5]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
# --- LOOP OVER RUNS --------------------------------------------
files = [raw_ana_folder+f for f in os.listdir(raw_ana_folder) if f.endswith("time_resolution.root")]
for file in files:
root_file = uproot.open(file)
print("Processing file ", file)
try:
root_file = uproot.open(file)
except:
continue
root_dirs = root_file.keys()

out_root_file_name = file.replace(raw_ana_folder, single_ana_folder).replace(".root", "_plots.root")
Expand Down
40 changes: 20 additions & 20 deletions src/waffles/np04_analysis/time_resolution/raw_single_channel_ana.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# --- IMPORTS -------------------------------------------------------
from waffles.np04_utils.utils import get_np04_daphne_to_offline_channel_dict
from waffles.np04_utils.utils import get_np04_daphne_to_offline_channel_dict, get_average_baseline_std_from_file
from waffles.np04_analysis.time_resolution.imports import *
# -------------------------------------------------------------------

Expand All @@ -20,9 +20,6 @@
params_variables = yaml.safe_load(params_stream)

runs = params_variables.get("runs")
noise_results_file = params_variables.get("noise_results_file")
noise_df = pd.read_csv(noise_results_file, sep=",")
print(noise_df.head(5))

calibration_file = params_variables.get("calibration_file")
calibration_df = pd.read_csv(calibration_file, sep=",")
Expand Down Expand Up @@ -59,7 +56,7 @@
except FileNotFoundError:
print(f"File {file} not found. Skipping.")
continue

a = tr.TimeResolution(wf_set=wfset_run)

# --- LOOP OVER CHANNELS ------------------------------------------
Expand All @@ -75,30 +72,33 @@

offline_ch = new_daphne_to_offline[daphne_ch]

if global_prepulse_ticks != 0:
try:
prepulse_ticks = int(calibration_df.loc[calibration_df['DaphneCh'] == daphne_ch, 'Prepulse ticks'].values[0])
except:
print(f"Error: prepulse_ticks not found for channel {daphne_ch} in calibration file. Using global value.")
prepulse_ticks = global_prepulse_ticks
else:
prepulse_ticks = int(calibration_df.loc[calibration_df['DaphneCh'] == daphne_ch, 'prepulse_ticks'].values[0])

if global_int_low != 0:
try:
int_low = int(calibration_df.loc[calibration_df['DaphneCh'] == daphne_ch, 'Int low'].values[0])
except:
print(f"Error: int_low not found for channel {daphne_ch} in calibration file. Using global value.")
int_low = global_int_low
else:
int_low = int(calibration_df.loc[calibration_df['DaphneCh'] == daphne_ch, 'int_low'].values[0])

if global_int_up != 0:
try:
int_up = int(calibration_df.loc[calibration_df['DaphneCh'] == daphne_ch, 'Int up'].values[0])
except:
print(f"Error: int_up not found for channel {daphne_ch} in calibration file. Using global value.")
int_up = global_int_up
else:
int_up = int(calibration_df.loc[calibration_df['DaphneCh'] == daphne_ch, 'int_up'].values[0])

if global_postpulse_ticks != 0:
try:
postpulse_ticks = int(calibration_df.loc[calibration_df['DaphneCh'] == daphne_ch, 'Postpulse ticks'].values[0])
except:
postpulse_ticks = global_postpulse_ticks
else:
postpulse_ticks = int(calibration_df.loc[calibration_df['DaphneCh'] == daphne_ch, 'postpulse_ticks'].values[0])


spe_charge = float(calibration_df.loc[calibration_df['DaphneCh'] == daphne_ch, 'Gain'].values[0])
spe_ampl = float(calibration_df.loc[calibration_df['DaphneCh'] == daphne_ch, 'SpeAmpl'].values[0])
baseline_rms = float(noise_df.loc[noise_df['OfflineCh'] == offline_ch, 'RMS'].values[0])
baseline_rms = get_average_baseline_std_from_file(run=run, daphne_channel=daphne_ch)
print(baseline_rms)


Expand Down Expand Up @@ -127,13 +127,13 @@
all_tikcs = np.array([np.arange(len(wf.adcs_float)) for wf in a.wfs[:n_pwfs] if wf.time_resolution_selection]).flatten()
counts, xedges, yedges = np.histogram2d(all_tikcs, all_wfs, bins=(len(a.wfs[0].adcs_float),h2_nbins),
range=[[0, len(a.wfs[0].adcs_float)],
[np.min(all_wfs), np.max(all_wfs)]])
[-spe_ampl*5, spe_ampl*100]])


# Histogram 2D of t0 vs pe
h2_persistence = TH2F("persistence", ";time [ticks]; Amplitude [ADC]",
len(a.wfs[0].adcs_float), 0, len(a.wfs[0].adcs_float),
h2_nbins, np.min(all_wfs), np.max(all_wfs))
h2_nbins, -spe_ampl*5, spe_ampl*100)

for i in range(len(a.wfs[0].adcs_float)):
for j in range(h2_nbins):
Expand Down