Index: /fact/tools/pyscripts/pyfact/fir_filter.py
===================================================================
--- /fact/tools/pyscripts/pyfact/fir_filter.py	(revision 12947)
+++ /fact/tools/pyscripts/pyfact/fir_filter.py	(revision 12947)
@@ -0,0 +1,183 @@
+#!/usr/bin/python
+#
+# Dominik Neise, Werner Lustermann
+# TU Dortmund, ETH Zurich
+#
+import numpy as np
+from scipy import signal
+import matplotlib.pyplot as plt
+
+class FirFilter(object):
+    """ finite impulse response filter 
+    
+    """
+    
+    def __init__(self, b, a, name = 'general FIR filter'):
+        """ initialize filter coefficients
+        
+        """
+        
+        self.a = a
+        self.b = b
+        self.name = name
+        
+    def __call__(self, data):
+        return signal.lfilter(self.b, self.a, data)
+
+    def __str__(self):
+        s = self.name + '\n'
+        s += 'filter, coefficients:\n'
+        s += 'nominator ' + str(self.b) + '\n'
+        s += 'denominator ' + str(self.a)
+        return s
+        
+class SlidingAverage(FirFilter):
+    """ data smoothing in the time domain with a sliding average
+    
+    """
+    
+    def __init__(self, length=8):
+        """ initialize the object
+        length:  lenght of the averaging window
+    
+        """
+
+        b = np.ones(length)
+        a = len(b)
+        FirFilter.__init__(self, b, a, 'sliding average')
+            
+
+class CFD(FirFilter):
+    """ Constant Fraction Discriminator """
+    def __init__(self, length = 10., ratio = 0.75):
+        
+        b = np.zeros(length)
+        a = np.zeros(length)
+
+        b[0] = -1. * ratio
+        b[length-1] = 1.
+        a[0] = 1.
+        FirFilter.__init__(self, b, a, 'constant fraction discriminator')
+
+
+class RemoveSignal(FirFilter):
+    """ estimator to identify DRS4 spikes
+    
+    """
+    
+    def __init__(self):
+        """ initialize the object """
+        
+        b = np.array((-0.5, 1., -0.5)) 
+        a = 1.
+        FirFilter.__init__(self, b, a, 'remove signal')       
+
+
+def _test_SlidingAverage():
+    """ test the sliding average function
+    use a step function as input
+
+    """
+    npoints = 100
+    safilter = SlidingAverage(8)
+    signal = np.zeros(npoints)
+    signal[10:50] += 20.
+
+    # add noise to the signal
+    sigma = 1.5
+    signal += np.random.randn(npoints) * sigma
+    
+    print safilter
+    #print 'signal in:  ', signal
+    #print 'signal out: ', rsfilter(signal)
+    x=range(npoints)
+    plt.plot(x, signal, 'b', label='original')
+    plt.plot(x, safilter(signal), 'r', label='filtered')
+    plt.title(safilter.name)
+    plt.xlabel('sample')
+    plt.legend()
+    plt.grid(True)
+    plt.show()
+
+
+def _test_CFD():
+    """ test the remove signal function
+    
+    """
+    
+    filt = CFD(8, 0.6)
+
+    npoints = 100
+    signal = np.ones(npoints) * 10.
+    signal[20:30] += np.linspace(0., 100., 10)
+    signal[30:90] += np.linspace(100., 0., 60)
+    # add noise to the signal
+    sigma = 1.5
+    signal += np.random.randn(npoints) * sigma
+    
+    print filt
+    #print 'signal in:  ', signal
+    #print 'signal out: ', rsfilter(signal)
+    x=range(npoints)
+    plt.plot(x, signal, 'b.', label='original')
+    plt.plot(x, filt(signal), 'r.', label='filtered')
+    plt.title(filt.name)
+    plt.xlabel('sample')
+    plt.legend()
+    plt.grid(True)
+    plt.show()
+
+
+def _test_RemoveSignal():
+    """ test the remove signal function
+    
+    """
+    
+    rsfilter = RemoveSignal()
+
+    npoints = 100
+    signal = np.ones(npoints) * 10.
+    signal[10:20] += np.linspace(0., 100., 10)
+    signal[20:80] += np.linspace(100., 0., 60)
+    # add noise to the signal
+    sigma = 3.
+    signal += np.random.randn(npoints) * sigma
+    
+    print rsfilter
+    #print 'signal in:  ', signal
+    #print 'signal out: ', rsfilter(signal)
+    x=range(npoints)
+    plt.plot(x, signal, 'b.', label='original')
+    plt.plot(x, rsfilter(signal), 'r.', label='filtered')
+    plt.title(rsfilter.name)
+    plt.xlabel('sample')
+    plt.legend()
+    plt.grid(True)
+    plt.show()
+
+def _test(filter_type, sig, noise_sigma = 1.):
+    
+    filt = filter_type
+    samples = len(sig)
+    # add noise to the signal
+    sig += np.random.randn(samples) * noise_sigma
+    
+    print filt
+    x=range(samples)
+    plt.plot(x, sig, 'b.', label='original')
+    plt.plot(x, filt(sig), 'r.', label='filtered')
+    plt.title(filt.name)
+    plt.xlabel('sample')
+    plt.legend()
+    plt.grid(True)
+    plt.show()
+    
+
+if __name__ == '__main__':
+    """ test the class """
+    
+    _test_SlidingAverage()
+    _test_RemoveSignal()
+    _test_CFD()
+    tsig = np.ones(100)
+    _test(filter_type=SlidingAverage(8), sig=tsig, noise_sigma=3.) 
Index: /fact/tools/pyscripts/pyfact/pyfact.py
===================================================================
--- /fact/tools/pyscripts/pyfact/pyfact.py	(revision 12946)
+++ /fact/tools/pyscripts/pyfact/pyfact.py	(revision 12947)
@@ -257,5 +257,5 @@
     
     def __init__( self, specifier = ['012', '023', '2011', '11', '24'],
-                 rpath = '/scratch_nfs/bsl/',
+                 rpath = '/scratch_nfs/res/bsl/',
                  zipped = True):
         """
Index: /fact/tools/pyscripts/pyfact/pyfact_rename.py
===================================================================
--- /fact/tools/pyscripts/pyfact/pyfact_rename.py	(revision 12946)
+++ /fact/tools/pyscripts/pyfact/pyfact_rename.py	(revision 12947)
@@ -77,5 +77,5 @@
 
         # set the pointers to the data++
-        data_file.SetPtrAddress('Event ID', self.event_id)
+        data_file.SetPtrAddress('EventNum', self.event_id)
         data_file.SetPtrAddress('TriggerType', self.trigger_type)
         data_file.SetPtrAddress('StartCellData', self.start_cells) 
