Index: fact/tools/pyscripts/sandbox/dneise/mc_pulses_for_sabrina/gen_TH1D.py
===================================================================
--- fact/tools/pyscripts/sandbox/dneise/mc_pulses_for_sabrina/gen_TH1D.py	(revision 14180)
+++ fact/tools/pyscripts/sandbox/dneise/mc_pulses_for_sabrina/gen_TH1D.py	(revision 14198)
@@ -7,4 +7,8 @@
 import sys
 from ROOT import *
+from scipy import interpolate
+
+#from plotters import Plotter
+import matplotlib.pyplot as plt
 
 class SignalGenerator(object):
@@ -105,4 +109,38 @@
         time, maxprob, mean, median = np.loadtxt( file_name, delimiter=',', unpack=True)
         csv_data = maxprob
+        
+        # shift the input data such, that the left baseline is equal to zero
+        csv_data = csv_data - csv_data[:50].mean()
+        
+        # I want the data to be longer than they are, so I add 1000 slices left and right
+        self.csv_data = np.zeros(2000 + len(csv_data))
+        
+        for i in range(len(csv_data)):
+            self.csv_data[1000+i] = csv_data[i]
+        for i in range(1000):
+            self.csv_data[i] = csv_data[:50].mean()
+            self.csv_data[-1*i] = csv_data[-50:].mean()
+        
+        # fermi dirac distribution for weighting the input data.
+        # we do not believe the right tail is really higher than zero, so we make it go to zero.
+        weight_function = lambda x : 1. / (1 + np.exp((x - 1200.)/25.))
+        x = np.arange(0,len(self.csv_data),1)
+        weights = map(weight_function, x)
+        
+        bla = self.csv_data.copy()
+        
+        self.csv_data = weights * self.csv_data
+        
+        tck = interpolate.splrep(x, self.csv_data ,s=50)
+        tck2 = interpolate.splrep(x, bla ,s=50)
+        
+        xnew = np.arange(0,len(self.csv_data), 0.1)
+        ynew = interpolate.splev(xnew,tck,der=0)
+        ynew2 = interpolate.splev(xnew,tck2,der=0)
+
+        plt.figure()
+        plt.plot(x,self.csv_data,'.:k',xnew,ynew,'b',x, weights, '.:r', x,bla,'.:g',xnew,ynew2,'m')
+        plt.show()
+        raw_input('stop')
         
         # csv data was downshifted, I shift it up here
