Skip to content
Snippets Groups Projects
Commit 3acece82 authored by Stefan Reck's avatar Stefan Reck
Browse files

- change default output file name suffix from _hist to _dl

- remove correct_timeslew (this is part of kp.calib now)
- subtract t0 from mchit times for now
parent ee7c9ba0
No related branches found
No related tags found
No related merge requests found
......@@ -58,6 +58,7 @@ class BaseProcessor:
If False, throw an error instead.
mc_info_to_float64 : bool
Convert everything in the mcinfo array to float 64 (Default: True).
Hint: int dtypes can not store nan!
Attributes
----------
......@@ -86,7 +87,6 @@ class BaseProcessor:
det_file=None,
center_time=True,
add_t0=False,
correct_timeslew=False,
event_skipper=None,
chunksize=32,
keep_event_info=True,
......@@ -97,7 +97,6 @@ class BaseProcessor:
self.det_file = det_file
self.center_time = center_time
self.add_t0 = add_t0
self.correct_timeslew = correct_timeslew
self.event_skipper = event_skipper
self.chunksize = chunksize
self.keep_event_info = keep_event_info
......@@ -126,7 +125,7 @@ class BaseProcessor:
"""
if outfile is None:
outfile = os.path.join(os.getcwd(), "{}_hist.h5".format(
outfile = os.path.join(os.getcwd(), "{}_dl.h5".format(
os.path.splitext(os.path.basename(infile))[0]))
if not self.overwrite:
if os.path.isfile(outfile):
......@@ -155,7 +154,7 @@ class BaseProcessor:
for infile in infiles:
outfile = os.path.join(
outfolder,
f"{os.path.splitext(os.path.basename(infile))[0]}_hist.h5")
f"{os.path.splitext(os.path.basename(infile))[0]}_dl.h5")
outfiles.append(outfile)
self.run(infile, outfile)
return outfiles
......@@ -183,11 +182,10 @@ class BaseProcessor:
if self.det_file:
cmpts.append((modules.DetApplier, {"det_file": self.det_file}))
if any((self.center_time, self.add_t0, self.correct_timeslew)):
if any((self.center_time, self.add_t0)):
cmpts.append((modules.TimePreproc, {
"add_t0": self.add_t0,
"center_time": self.center_time,
"correct_timeslew": self.correct_timeslew}))
"center_time": self.center_time}))
return cmpts
@abstractmethod
......
......@@ -59,22 +59,15 @@ class TimePreproc(kp.Module):
----------
add_t0 : bool
If true, t0 will be added to times of hits and mchits.
correct_timeslew : bool
If true, the time slewing of hits depending on their tot
will be corrected.
center_time : bool
If true, center hit and mchit times with the time of the first
triggered hit.
subtract_t0_mchits : bool
It True, subtract t0 from the times of mchits.
"""
def configure(self):
self.add_t0 = self.get('add_t0', default=False)
self.correct_timeslew = self.get("correct_timeslew", default=False)
self.center_time = self.get('center_time', default=True)
self.subtract_t0_mchits = self.get('subtract_t0_mchits', default=False)
self._has_mchits = None
self._print_flags = set()
......@@ -82,23 +75,13 @@ class TimePreproc(kp.Module):
def process(self, blob):
if self._has_mchits is None:
self._has_mchits = "McHits" in blob
if self.add_t0:
blob = self.add_t0_time(blob)
if self.correct_timeslew:
blob = self.timeslew(blob)
if self.subtract_t0_mchits and self._has_mchits:
blob = self.subtract_t0_mctime(blob)
if self.center_time:
blob = self.center_hittime(blob)
return blob
def timeslew(self, blob):
self._print_once("Subtracting time slew of hit times")
blob["Hits"]["time"] -= km.mc.slew(blob["Hits"]["tot"])
return blob
def add_t0_time(self, blob):
self._print_once("Adding t0 to hit times")
blob["Hits"].time = np.add(blob["Hits"].time, blob["Hits"].t0)
......@@ -109,12 +92,6 @@ class TimePreproc(kp.Module):
return blob
def subtract_t0_mctime(self, blob):
self._print_once("Subtracting t0 from mchits")
blob["McHits"].time = np.subtract(
blob["McHits"].time, blob["McHits"].t0)
return blob
def center_hittime(self, blob):
hits_time = blob["Hits"].time
hits_triggered = blob["Hits"].triggered
......@@ -459,11 +436,17 @@ class DetApplier(kp.Module):
"errors with t0."
)
self._calib_checked = True
# TODO use built-in time slewing of km3pipe 9 once released
blob = self.calib.process(blob, key="Hits", outkey="Hits")
blob["Hits"] = self.calib.apply(blob["Hits"], correct_slewing=True)
if "McHits" in blob:
blob = self.calib.process(blob, key="McHits", outkey="McHits")
blob["McHits"] = self.calib.apply(blob["McHits"])
# TODO remove once https://git.km3net.de/km3py/km3pipe/-/issues/239 is solved
self.subtract_t0_mctime(blob)
return blob
def subtract_t0_mctime(self, blob):
blob["McHits"].time = np.subtract(
blob["McHits"].time, blob["McHits"].t0)
return blob
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment