From 7ec5b1c372ad5885d62a7b746e485167e15a3f17 Mon Sep 17 00:00:00 2001 From: Stefan Reck <stefan.reck@fau.de> Date: Fri, 5 Apr 2019 15:36:06 +0200 Subject: [PATCH] Added mc info extractor for real data, time gets corrected for McHits automatically if McHits are in blob. --- orcasong_plag/core.py | 3 ++- orcasong_plag/mc_info_types.py | 16 ++++++++++++++++ orcasong_plag/modules.py | 16 ++++------------ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/orcasong_plag/core.py b/orcasong_plag/core.py index 2f8275a..fd0d4f5 100644 --- a/orcasong_plag/core.py +++ b/orcasong_plag/core.py @@ -28,8 +28,9 @@ class FileBinner: n_memory_observer : int, optional Print memory usage every n blobs. do_time_preproc : bool - Do time preprocessing, i.e. add t0 to real data, subtract time + Do time preprocessing, i.e. add t0 only to real data, and subtract time of first triggered hit. + Will also be done for McHits if they are in the blob. chunksize : int Chunksize (along axis_0) used for saving the output to a .h5 file. complib : str diff --git a/orcasong_plag/mc_info_types.py b/orcasong_plag/mc_info_types.py index 7385f85..adcd6fe 100644 --- a/orcasong_plag/mc_info_types.py +++ b/orcasong_plag/mc_info_types.py @@ -20,12 +20,28 @@ def get_mc_info_extr(mc_info_extr): if mc_info_extr == "mupage": mc_info_extr = get_mupage_mc + elif mc_info_extr == "event_and_run_id": + mc_info_extr = get_event_and_run_id + else: raise ValueError("Unknown mc_info_type " + mc_info_extr) return mc_info_extr +def get_event_and_run_id(blob): + """ + Get event id and run id from event info. + E.g. for the 2017 one line real data. + """ + event_id = blob['EventInfo'].event_id[0] + run_id = blob["EventInfo"].run_id + + track = {'event_id': event_id, + 'run_id': run_id, } + return track + + def get_mupage_mc(blob): """ For mupage muon simulations. diff --git a/orcasong_plag/modules.py b/orcasong_plag/modules.py index bf089f0..6361aa7 100644 --- a/orcasong_plag/modules.py +++ b/orcasong_plag/modules.py @@ -43,20 +43,12 @@ class TimePreproc(kp.Module): Time hits and mchits will be shifted by the time of the first triggered hit. - Attributes - ---------- - correct_hits : bool - If true, will correct time of the hits. - correct_mchits : bool - If true, will correct the time of the McHits. - """ - def configure(self): - self.correct_hits = self.get('correct_hits', default=True) - self.correct_mchits = self.get('correct_mchits', default=True) - def process(self, blob): - blob = time_preproc(blob, self.correct_hits, self.correct_mchits) + correct_mchits = "McHits" in blob + blob = time_preproc(blob, + correct_hits=True, + correct_mchits=correct_mchits) return blob -- GitLab