#!/usr/bin/python # # Dominik Neise, Werner Lustermann # TU Dortmund, ETH Zurich # import numpy as np import matplotlib.pyplot as plt import * from fir_filter class GlobalMaxFinder(object): """ Pulse Extractor Finds the global maximum in the given window. (Best used with filtered data) """ def __init__(self, range=(30,250) , name = 'GlobalMaxFinder'): """ initialize search Window """ self.min = range[0] self.max = range[1] self.name = name def __call__(self, data): time = np.argmax( data[ : , self.min:self.max ], 1) amplitude = np.max( data[ : , self.min:self.max], 1) return amplitude, time def __str__(self): s = self.name + '\n' s += 'window:\n' s += '(min,max) = (' + self.min + ',' + self.max + ')\n' return s class FixedWindowIntegrator(object): """ Integrates in a given intergration window """ def __init__(self, range=(55,105) , name = 'FixedWindowIntegrator'): """ initialize integration Window """ self.min = range[0] self.max = range[1] self.name = name def __call__(self, data): integral = np.empty( data.shape[0] ) for pixel in range( data.shape[0] ): integral[pixel] = data[pixel, self.min:self.max].sum() return integtral def __str__(self): s = self.name + '\n' s += 'window:\n' s += '(min,max) = (' + self.min + ',' + self.max + ')\n' return s class ZeroXing(object): """ Finds zero crossings in given data (should be used on CFD output for peak finding) returns list of lists of time_of_zero_crossing """ def __init__(self, slope=1, name = 'ZeroXing'): if (slope >= 0): self.slope = 1 # search for rising edge crossing else if (slope < 0): self.slope = -1 # search for falling edge crossing self.name = name def __call__(self, data): all_hits = [] for pix_data in data hits = [] for i in range( data.shape[1] ): if ( slope > 0 ): if ( pix_data[i] > 0 ): continue else: if ( pix_data[i] < 0): continue if ( pix_data[i] * pix_data[i+1] <= 0 ): time = (pix_data[i+1]*i-pix_data[i]*(i+1)) hits.append(time) all_hits.append(hits) return all_hits def __str__(self): s = self.name + '\n' if (self.slope == 1): s += 'search for rising edge crossing.\n' else: s += 'search for falling edge crossing.\n' return s