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

More docs.

parent edd6d2ea
No related branches found
No related tags found
No related merge requests found
......@@ -6,16 +6,22 @@ in the h5 files.
import numpy as np
def get_mc_info_extr(mc_info_type):
def get_mc_info_extr(mc_info_extr):
"""
Get an existing mc info extractor function.
Attributes
----------
mc_info_extr : function
Function to extract the info. Takes the blob as input, outputs
a dict with the desired mc_infos.
"""
if mc_info_type == "mupage":
if mc_info_extr == "mupage":
mc_info_extr = get_mupage_mc
else:
raise ValueError("Unknown mc_info_type " + mc_info_type)
raise ValueError("Unknown mc_info_type " + mc_info_extr)
return mc_info_extr
......@@ -24,6 +30,8 @@ def get_mupage_mc(blob):
"""
For mupage muon simulations.
e.g. mcv5.1_r3.mupage_10G.km3_AAv1.jterbr00002800.5103.root.h5
Parameters
----------
blob : dict
......
......@@ -9,6 +9,15 @@ import numpy as np
class McInfoMaker(kp.Module):
"""
Get the desired mc_info from the blob.
Attributes
----------
mc_info_extr : function
Function to extract the info. Takes the blob as input, outputs
a dict with the desired mc_infos.
store_as : str
Store the mcinfo with this name in the blob.
"""
def configure(self):
self.mc_info_extr = self.require('mc_info_extr')
......@@ -34,6 +43,13 @@ 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)
......@@ -76,6 +92,15 @@ def time_preproc(blob, correct_hits=True, correct_mchits=True):
class ImageMaker(kp.Module):
"""
Make a n-d histogram from the blob.
Attributes
----------
bin_edges_list : List
List with the names of the fields to bin, and the respective bin edges,
including the left- and right-most bin edge.
store_as : str
Store the images with this name in the blob.
"""
def configure(self):
self.bin_edges_list = self.require('bin_edges_list')
......
......@@ -14,6 +14,8 @@ import numpy as np
import km3pipe as kp
import matplotlib.pyplot as plt
from orcasong_plag.modules import time_preproc
class FieldPlotter:
"""
......@@ -337,51 +339,6 @@ class FieldPlotter:
return "<FieldPlotter: {}>".format(self.files)
class TimePreproc(kp.Module):
"""
Preprocess the time in the blob.
t0 will be added to the time for real data, but not simulations.
Time hits and mchits will be shifted by the time of the first triggered hit.
"""
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)
return blob
def time_preproc(blob, correct_hits=True, correct_mchits=True):
"""
Preprocess the time in the blob.
t0 will be added to the time for real data, but not simulations.
Time hits and mchits will be shifted by the time of the first triggered hit.
"""
hits_time = blob["Hits"].time
if "McHits" not in blob:
# add t0 only for real data, not sims
hits_t0 = blob["Hits"].t0
hits_time = np.add(hits_time, hits_t0)
hits_triggered = blob["Hits"].triggered
t_first_trigger = np.min(hits_time[hits_triggered == 1])
if correct_hits:
blob["Hits"].time = np.subtract(hits_time, t_first_trigger)
if correct_mchits:
mchits_time = blob["McHits"].time
blob["McHits"].time = np.subtract(mchits_time, t_first_trigger)
return blob
class TimePlotter(FieldPlotter):
"""
For plotting the time.
......
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