def create_combined_ntuple_spectrum(data_path, half_life, bkgnd_name, save_path): """ Creates both mc and reco spectra from directory containing background ntuples, dumping the results as a spectrum object in a hdf5 file. Args: data_path (str): Path to directory containing the ntuples to be evaluated half_life (float): Half-life of isotope bkgnd_name (str): Name of the background being processed save_path (str): Path to a directory where the hdf5 files will be dumped Returns: None """ file_list = os.listdir(data_path) for idx, fname in enumerate(file_list): file_path = "%s/%s" % (data_path, fname) if idx == 0: mc_spec = fill_spectrum.fill_mc_ntuple_spectrum(file_path, half_life, spectrumname = "%s_mc" % bkgnd_name) reco_spec = fill_spectrum.fill_reco_ntuple_spectrum(file_path, half_life, spectrumname = "%s_reco" % bkgnd_name) else: mc_spec = fill_spectrum.fill_mc_ntuple_spectrum(file_path, half_life, spectrum = mc_spec) reco_spec = fill_spectrum.fill_reco_ntuple_spectrum(file_path, half_life, spectrum = reco_spec) # Plot plot_spectrum(mc_spec) plot_spectrum(reco_spec) # Dump to file store.dump("%s%s_mc.hdf5" % (save_path, bkgnd_name), mc_spec) store.dump("%s%s_reco.hdf5" % (save_path, bkgnd_name), reco_spec)
def read_and_dump_ntuple(fname, half_life, spectrum_name, save_path): """ Creates both mc and reco spectra from ntuple files, dumping the results as a spectrum object in a hdf5 file Args: fname (str): The file to be evaluated half_life (float): Half-life of isotope spectrum_name (str): Name to be applied to the spectrum save_path (str): Path to a directory where the hdf5 files will be dumped Returns: None """ mc_spec = fill_spectrum.fill_mc_ntuple_spectrum(fname, half_life, spectrumname="%s_mc" % (spectrum_name)) reco_spec = fill_spectrum.fill_reco_ntuple_spectrum( fname, half_life, spectrumname="%s_reco" % (spectrum_name)) # Plot plot_spectrum(mc_spec) plot_spectrum(reco_spec) # Dump to file store.dump("%s/%s_mc.hdf5" % (save_path, spectrum_name), mc_spec) store.dump("%s/%s_reco.hdf5" % (save_path, spectrum_name), reco_spec)
def read_and_dump_ntuple(fname, half_life, spectrum_name, save_path): """ Creates both mc and reco spectra from ntuple files, dumping the results as a spectrum object in a hdf5 file. Args: fname (str): The file to be evaluated half_life (float): Half-life of isotope spectrum_name (str): Name to be applied to the spectrum save_path (str): Path to a directory where the hdf5 files will be dumped Returns: None """ mc_spec = fill_spectrum.fill_mc_ntuple_spectrum( fname, half_life, spectrumname="%s_mc" % (spectrum_name)) reco_spec = fill_spectrum.fill_reco_ntuple_spectrum( fname, half_life, spectrumname="%s_reco" % (spectrum_name)) truth_spec = fill_spectrum.fill_truth_ntuple_spectrum( fname, half_life, spectrumname="%s_truth" % (spectrum_name)) # Plot plot_spectrum(mc_spec) plot_spectrum(reco_spec) plot_spectrum(truth_spec) # Dump to file store.dump("%s/%s_mc.hdf5" % (save_path, spectrum_name), mc_spec) store.dump("%s/%s_reco.hdf5" % (save_path, spectrum_name), reco_spec) store.dump("%s/%s_truth.hdf5" % (save_path, spectrum_name), truth_spec)
def create_combined_ntuple_spectrum(data_path, half_life, bkgnd_name, save_path): """ Creates mc, truth and reco spectra from directory containing background ntuples, dumping the results as a spectrum object in an hdf5 file. Args: data_path (str): Path to directory containing the ntuples to be evaluated. half_life (float): Half-life of isotope. bkgnd_name (str): Name of the background being processed. save_path (str): Path to a directory where the hdf5 files will be dumped. """ file_list = os.listdir(data_path) for idx, fname in enumerate(file_list): file_path = "%s/%s" % (data_path, fname) if idx == 0: mc_spec = fill_spectrum.fill_mc_ntuple_spectrum( file_path, half_life, spectrumname="%s_mc" % bkgnd_name) reco_spec = fill_spectrum.fill_reco_ntuple_spectrum( file_path, half_life, spectrumname="%s_reco" % bkgnd_name) truth_spec = fill_spectrum.fill_truth_ntuple_spectrum( file_path, half_life, spectrumname="%s_truth" % bkgnd_name) else: mc_spec = fill_spectrum.fill_mc_ntuple_spectrum(file_path, half_life, spectrum=mc_spec) reco_spec = fill_spectrum.fill_reco_ntuple_spectrum( file_path, half_life, spectrum=reco_spec) truth_spec = fill_spectrum.fill_truth_ntuple_spectrum( file_path, half_life, spectrum=truth_spec) # Plot plot_spectrum(mc_spec) plot_spectrum(reco_spec) plot_spectrum(truth_spec) # Dump to file store.dump("%s%s_mc.hdf5" % (save_path, bkgnd_name), mc_spec) store.dump("%s%s_reco.hdf5" % (save_path, bkgnd_name), reco_spec) store.dump("%s%s_truth.hdf5" % (save_path, bkgnd_name), truth_spec)