aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2021-01-04 13:03:03 -0600
committertlatorre <tlatorre@uchicago.edu>2021-01-04 13:03:03 -0600
commit3d13f8f409d412c6d2aa3447b81e29a1a3d7b2a7 (patch)
tree7c4a216353b7a149c25148a8b2435d20ca07b196
parent64e5d47398a428ae7eca9e3c1251b9d9a35a823d (diff)
downloadsddm-3d13f8f409d412c6d2aa3447b81e29a1a3d7b2a7.tar.gz
sddm-3d13f8f409d412c6d2aa3447b81e29a1a3d7b2a7.tar.bz2
sddm-3d13f8f409d412c6d2aa3447b81e29a1a3d7b2a7.zip
get rid of nhit_thresh
-rwxr-xr-xutils/chi27
-rwxr-xr-xutils/dc5
-rwxr-xr-xutils/dm-search7
-rwxr-xr-xutils/plot-dc5
-rwxr-xr-xutils/plot-michels5
-rwxr-xr-xutils/plot-muons3
-rw-r--r--utils/sddm/plot_energy.py5
7 files changed, 14 insertions, 23 deletions
diff --git a/utils/chi2 b/utils/chi2
index f32208a..1edc0fd 100755
--- a/utils/chi2
+++ b/utils/chi2
@@ -487,7 +487,6 @@ if __name__ == '__main__':
parser.add_argument("--save", action='store_true', default=False, help="save corner plots for backgrounds")
parser.add_argument("--mc", nargs='+', required=True, help="atmospheric MC files")
parser.add_argument("--muon-mc", nargs='+', required=True, help="muon MC files")
- parser.add_argument("--nhit-thresh", type=int, default=None, help="nhit threshold to apply to events before processing (should only be used for testing to speed things up)")
parser.add_argument("--steps", type=int, default=1000, help="number of steps in the MCMC chain")
parser.add_argument("--multinomial-prob-size", type=int, default=10000, help="number of p values to compute")
parser.add_argument("--coverage", type=int, default=0, help="plot p value coverage")
@@ -513,7 +512,7 @@ if __name__ == '__main__':
evs = []
for run, df in rhdr.groupby('run'):
- evs.append(get_events(df.filename.values, merge_fits=True, nhit_thresh=args.nhit_thresh))
+ evs.append(get_events(df.filename.values, merge_fits=True))
ev = pd.concat(evs).reset_index()
ev = correct_energy_bias(ev)
@@ -524,14 +523,14 @@ if __name__ == '__main__':
# and otherwise the GTIDs will clash
ev_mcs = []
for filename in args.mc:
- ev_mcs.append(get_events([filename], merge_fits=True, nhit_thresh=args.nhit_thresh, mc=True))
+ ev_mcs.append(get_events([filename], merge_fits=True, mc=True))
ev_mc = pd.concat([ev_mc for ev_mc in ev_mcs if len(ev_mc) > 0]).reset_index()
if (~rhdr.run.isin(ev_mc.run)).any():
print_warning("Error! The following runs have no Monte Carlo: %s" % \
np.unique(rhdr.run[~rhdr.run.isin(ev_mc.run)].values))
- muon_mc = get_events(args.muon_mc, merge_fits=True, nhit_thresh=args.nhit_thresh, mc=True)
+ muon_mc = get_events(args.muon_mc, merge_fits=True, mc=True)
weights = pd.concat([read_hdf(filename, "weights") for filename in args.weights],ignore_index=True)
# The next two things we have to do are reweight the Monte Carlo data since
diff --git a/utils/dc b/utils/dc
index 23aae1e..39ca008 100755
--- a/utils/dc
+++ b/utils/dc
@@ -263,7 +263,6 @@ if __name__ == '__main__':
parser.add_argument("--steps", type=int, default=100000, help="number of steps in the MCMC chain")
parser.add_argument("--save", action="store_true", default=False, help="save plots")
parser.add_argument("--mc", nargs='+', required=True, help="atmospheric MC files")
- parser.add_argument("--nhit-thresh", type=int, default=None, help="nhit threshold to apply to events before processing (should only be used for testing to speed things up)")
parser.add_argument("--run-list", default=None, help="run list")
args = parser.parse_args()
@@ -280,7 +279,7 @@ if __name__ == '__main__':
# Loop over runs to prevent using too much memory
evs = []
for run, df in rhdr.groupby('run'):
- evs.append(get_events(df.filename.values, merge_fits=True, nhit_thresh=args.nhit_thresh))
+ evs.append(get_events(df.filename.values, merge_fits=True))
ev = pd.concat(evs)
ev = ev[ev.prompt]
@@ -322,7 +321,7 @@ if __name__ == '__main__':
# and otherwise the GTIDs will clash
ev_mcs = []
for filename in args.mc:
- ev_mcs.append(get_events([filename], merge_fits=True, nhit_thresh=args.nhit_thresh, mc=True))
+ ev_mcs.append(get_events([filename], merge_fits=True, mc=True))
ev_mc = pd.concat(ev_mcs)
ev_mc = ev_mc[ev_mc.prompt]
diff --git a/utils/dm-search b/utils/dm-search
index d5d3ec7..533d2f7 100755
--- a/utils/dm-search
+++ b/utils/dm-search
@@ -544,7 +544,6 @@ if __name__ == '__main__':
parser.add_argument("--save", action='store_true', default=False, help="save corner plots for backgrounds")
parser.add_argument("--mc", nargs='+', required=True, help="atmospheric MC files")
parser.add_argument("--muon-mc", nargs='+', required=True, help="muon MC files")
- parser.add_argument("--nhit-thresh", type=int, default=None, help="nhit threshold to apply to events before processing (should only be used for testing to speed things up)")
parser.add_argument("--steps", type=int, default=1000, help="number of steps in the MCMC chain")
parser.add_argument("--pull", type=int, default=0, help="plot pull plots")
parser.add_argument("--weights", nargs='+', required=True, help="GENIE reweight HDF5 files")
@@ -571,7 +570,7 @@ if __name__ == '__main__':
# Loop over runs to prevent using too much memory
evs = []
for run, df in rhdr.groupby('run'):
- evs.append(get_events(df.filename.values, merge_fits=True, nhit_thresh=args.nhit_thresh))
+ evs.append(get_events(df.filename.values, merge_fits=True))
ev = pd.concat(evs).reset_index()
livetime = 0.0
@@ -603,14 +602,14 @@ if __name__ == '__main__':
# and otherwise the GTIDs will clash
ev_mcs = []
for filename in args.mc:
- ev_mcs.append(get_events([filename], merge_fits=True, nhit_thresh=args.nhit_thresh, mc=True))
+ ev_mcs.append(get_events([filename], merge_fits=True, mc=True))
ev_mc = pd.concat([ev_mc for ev_mc in ev_mcs if len(ev_mc) > 0]).reset_index()
if (~rhdr.run.isin(ev_mc.run)).any():
print_warning("Error! The following runs have no Monte Carlo: %s" % \
np.unique(rhdr.run[~rhdr.run.isin(ev_mc.run)].values))
- muon_mc = get_events(args.muon_mc, merge_fits=True, nhit_thresh=args.nhit_thresh, mc=True)
+ muon_mc = get_events(args.muon_mc, merge_fits=True, mc=True)
weights = pd.concat([read_hdf(filename, "weights") for filename in args.weights],ignore_index=True)
# Add the "flux_weight" column to the ev_mc data since I stupidly simulated
diff --git a/utils/plot-dc b/utils/plot-dc
index e20d5cc..89de2a9 100755
--- a/utils/plot-dc
+++ b/utils/plot-dc
@@ -108,7 +108,6 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser("plot fit results")
parser.add_argument("filenames", nargs='+', help="input files")
parser.add_argument("--save", action='store_true', default=False, help="save corner plots for backgrounds")
- parser.add_argument("--nhit-thresh", type=int, default=None, help="nhit threshold to apply to events before processing (should only be used for testing to speed things up)")
args = parser.parse_args()
setup_matplotlib(args.save)
@@ -122,9 +121,9 @@ if __name__ == '__main__':
if len(data_filenames):
rhdr = pd.concat([read_hdf(filename, "rhdr").assign(filename=filename) for filename in data_filenames],ignore_index=True)
for run, df in rhdr.groupby('run'):
- evs.append(get_events(df.filename.values, merge_fits=True, nhit_thresh=args.nhit_thresh))
+ evs.append(get_events(df.filename.values, merge_fits=True))
if len(mc_filenames):
- evs.append(get_events(mc_filenames, merge_fits=True, nhit_thresh=args.nhit_thresh))
+ evs.append(get_events(mc_filenames, merge_fits=True))
ev = pd.concat(evs)
ev = ev[ev.prompt & ~np.isnan(ev.fmin)]
diff --git a/utils/plot-michels b/utils/plot-michels
index e0e4dd7..300562a 100755
--- a/utils/plot-michels
+++ b/utils/plot-michels
@@ -96,7 +96,6 @@ if __name__ == '__main__':
parser.add_argument("filenames", nargs='+', help="input files")
parser.add_argument("--save", action='store_true', default=False, help="save corner plots for backgrounds")
parser.add_argument("--mc", nargs='+', required=True, help="atmospheric MC files")
- parser.add_argument("--nhit-thresh", type=int, default=None, help="nhit threshold to apply to events before processing (should only be used for testing to speed things up)")
parser.add_argument("--print-nll", action='store_true', default=False, help="print nll values")
parser.add_argument("--steps", type=int, default=1000, help="number of steps in the MCMC chain")
parser.add_argument("--walkers", type=int, default=100, help="number of walkers")
@@ -110,7 +109,7 @@ if __name__ == '__main__':
evs = []
rhdr = pd.concat([read_hdf(filename, "rhdr").assign(filename=filename) for filename in args.filenames],ignore_index=True)
for run, df in rhdr.groupby('run'):
- evs.append(get_events(df.filename.values, merge_fits=True, nhit_thresh=args.nhit_thresh))
+ evs.append(get_events(df.filename.values, merge_fits=True))
ev = pd.concat(evs)
ev = correct_energy_bias(ev)
@@ -120,7 +119,7 @@ if __name__ == '__main__':
# and otherwise the GTIDs will clash
ev_mcs = []
for filename in args.mc:
- ev_mcs.append(get_events([filename], merge_fits=True, nhit_thresh=args.nhit_thresh, mc=True))
+ ev_mcs.append(get_events([filename], merge_fits=True, mc=True))
ev_mc = pd.concat(ev_mcs)
ev_mc = correct_energy_bias(ev_mc)
diff --git a/utils/plot-muons b/utils/plot-muons
index a37f223..532400a 100755
--- a/utils/plot-muons
+++ b/utils/plot-muons
@@ -81,7 +81,6 @@ if __name__ == '__main__':
parser.add_argument("filenames", nargs='+', help="input files")
parser.add_argument("--save", action='store_true', default=False, help="save corner plots for backgrounds")
parser.add_argument("--mc", nargs='+', required=True, help="atmospheric MC files")
- parser.add_argument("--nhit-thresh", type=int, default=None, help="nhit threshold to apply to events before processing (should only be used for testing to speed things up)")
args = parser.parse_args()
setup_matplotlib(args.save)
@@ -92,7 +91,7 @@ if __name__ == '__main__':
evs = []
rhdr = pd.concat([read_hdf(filename, "rhdr").assign(filename=filename) for filename in args.filenames],ignore_index=True)
for run, df in rhdr.groupby('run'):
- evs.append(get_events(df.filename.values, merge_fits=True, nhit_thresh=args.nhit_thresh))
+ evs.append(get_events(df.filename.values, merge_fits=True))
ev = pd.concat(evs)
ev = correct_energy_bias(ev)
ev_mc = get_events(args.mc, merge_fits=True, mc=True)
diff --git a/utils/sddm/plot_energy.py b/utils/sddm/plot_energy.py
index f81df67..651064b 100644
--- a/utils/sddm/plot_energy.py
+++ b/utils/sddm/plot_energy.py
@@ -481,7 +481,7 @@ def burst_cut(ev):
burst.loc[burst] &= np.concatenate(([True],np.diff(ev[burst].gtr.values) > BURST_WINDOW))
return ev.groupby(burst.cumsum()).filter(lambda ev: len(ev[ev.prompt_50]) <= BURST_MAX_EVENTS).reset_index(drop=True)
-def get_events(filenames, merge_fits=False, nhit_thresh=None, mc=False):
+def get_events(filenames, merge_fits=False, mc=False):
h = hashlib.sha1()
for filename in filenames:
@@ -514,9 +514,6 @@ def get_events(filenames, merge_fits=False, nhit_thresh=None, mc=False):
del fits['time']
del fits['t0']
- if nhit_thresh is not None:
- ev = ev[ev.nhit_cal >= nhit_thresh]
-
if len(ev) == 0:
if merge_fits:
return ev