Index: fact/tools/pyscripts/pyfact/pyfact.py
===================================================================
--- fact/tools/pyscripts/pyfact/pyfact.py	(revision 12815)
+++ fact/tools/pyscripts/pyfact/pyfact.py	(revision 12816)
@@ -6,4 +6,5 @@
 from ctypes import *
 import numpy as np
+import scipy.signal as spsi
 
 # get the ROOT stuff + my shared libs
@@ -58,8 +59,10 @@
         # allocate the data memories
         self.evNum = c_ulong()
+        self.trigType = c_ushort()
         self.Data  = np.zeros( self.NPIX * self.NROI, np.int16 ) 
         self.startCells = np.zeros( self.NPIX, np.int16 )
         # set the pointers to the data++
         df.SetPtrAddress( 'EventNum', self.evNum )
+        df.SetPtrAddress( 'TriggerType', self.trigType )
         df.SetPtrAddress( 'StartCellData', self.startCells ) # DRS readout start cell
         df.SetPtrAddress( 'Data', self.Data ) # this is what you would expect
@@ -100,4 +103,7 @@
         self.df.GetNextRow()
         self.calibrate_drsAmplitude()
+        self.smoothData = None
+        self.maxPos = None
+        self.maxAmp = None
 
         
@@ -129,5 +135,80 @@
     
         # print 'acalData ', self.acalData[0:2,0:20]
-
+        
+    def filterSlidingAverage( self , windowSize = 4):
+        """ sliding average filter
+        using:
+            self.acalData
+        filling array:
+            self.smoothData
+        """
+        #scipy.signal.lfilter(b, a, x, axis=-1, zi=None)
+        smoothData = self.acalData.copy()
+        b = np.ones( windowSize )
+        a = np.zeros( windowSize )
+        a[0] = len(b)
+        smoothData[:,:] = spsi.lfilter(b, a, smoothData[:,:])
+
+        self.smoothData = smoothData
+        
+    def filterCFD( self, length=10, ratio=0.75):
+        """ constant fraction filter
+        using:
+            self.smoothData
+        filling array:
+            self.cfdData
+        """
+        if self.smoothData == None:
+            print 'error pyfact.filterCFD was called without prior call to filterSlidingAverage'
+            print ' variable self.smoothData is needed '
+            pass
+        cfdData = self.smoothData.copy()
+        b = np.zeros( length )
+        a = np.zeros( length )
+        b[0] = -1. * ratio
+        b[length-1] = 1.
+        a[0] = 1.
+        cfdData[:,:] = spsi.lfilter(b, a, cfdData[:,:])
+        
+        self.cfdData = cfdData
+    
+    def findPeak (self, min=30, max=250):
+        """ find maximum in search window
+        using: 
+            self.smoothData
+        filling arrays:
+            self.maxPos
+            self.maxAmp
+        """
+        if self.smoothData == None:
+            print 'error pyfact.findPeakMax was called without prior call to filterSlidingAverage'
+            print ' variable self.smoothData is needed '
+            pass
+        maxPos = np.argmax( self.smoothData[:,min:max] , 1)
+        maxAmp = np.max( self.smoothData[:,min:max] , 1)
+        self.maxPos = maxPos
+        self.maxAmp = maxAmp
+
+    def sumAroundPeak (self, left=13, right=23):
+        """ integrate signal in gate around Peak
+        using:
+            self.maxPos
+            self.acalData
+        filling array:
+            self.integral
+        """
+        if self.maxPos == None:
+            print 'error pyfact.sumAroundPeak was called without prior call of findPeak'
+            print ' variable self.maxPos is needed'
+            pass
+        
+        sums = np.empty( self.NPIX )
+        for pixel in range( self.NPIX ):
+            min = self.maxPos[pixel]-left
+            max = self.maxPos[pixel]+right
+            sums[pixel] = self.acalData[pixel,min:max].sum()
+        
+        self.integral = sums
+        
     def ReadBaseline( self, file, bsl_hist = 'bsl_sum/hplt_mean' ):
         """
