Index: /fact/tools/rootmacros/PulseTemplates/templateextractors.C
===================================================================
--- /fact/tools/rootmacros/PulseTemplates/templateextractors.C	(revision 14061)
+++ /fact/tools/rootmacros/PulseTemplates/templateextractors.C	(revision 14062)
@@ -429,2 +429,147 @@
     return 0;
 }
+
+void
+FitMaxPropabilityPuls(
+        TH1F*       hMaximumTemp,
+        int         verbosityLevel
+        )
+    {
+      if (verbosityLevel > 2) cout << "...fit Landau in histograms" ;
+      if (verbosityLevel > 2) cout << "\t...calculating Landaufit" ;
+      hMaximumTemp->Fit("landau", "", "", -50, 250);
+      if (verbosityLevel > 2) cout << "...done" << endl;
+    }
+
+void
+FitFallingEdge(
+        TString         name,
+        TH1F*           histo,
+        double          xMin,
+        double          xMax,
+        double*         parameters
+        )
+{
+    TF1* polExpFit = new TF1(name, PolExp, xMin, xMax, 3 );
+    polExpFit->SetParNames("Pol0", "Slope", "Shift");
+    polExpFit->SetLineColor(kRed);
+    histo->Fit(polExpFit, "RWM");
+    polExpFit->GetParameters(parameters);
+}
+
+void
+FitRisingEdge(
+        TString         name,
+        TH1F*           histo,
+        double          xMin,
+        double          xMax,
+        double*         parameters
+        )
+{
+    TF1* polExpFit = new TF1(name, NegPolExp, xMin, xMax, 3 );
+    polExpFit->SetParNames("Pol0", "Slope", "Shift");
+    polExpFit->SetLineColor(kRed);
+    histo->Fit(polExpFit, "RWM");
+    polExpFit->GetParameters(parameters);
+}
+
+double
+NegPolExp(
+        double*         x,
+        double*         par
+        )
+{
+    return par[0]+(-1)*TMath::Exp(par[1]+par[2]*x[0]);
+}
+
+double
+PolExp(
+        double*         x,
+        double*         par
+        )
+{
+    return par[0]+TMath::Exp(par[1]+par[2]*x[0]);
+}
+
+double
+ChargeDiode(
+        double*         time,
+        double*         chargeVoltage,
+        double*         impedance,
+        double*         capacity,
+        )
+{
+    return chargeVoltage*(1 - TMath::Exp(time/(impedance*capacity)));
+}
+
+double
+UnChargeDiode(
+        double*         time,
+        double*         chargeVoltage,
+        double*         impedance,
+        double*         capacity,
+        )
+{
+    return chargeVoltage*(TMath::Exp(time/(impedance*capacity)));
+}
+
+double
+template_function(
+        double*         input_x,
+        double*         par)
+{
+    double returnval = 0.0;
+
+    // I introduce a few names
+   // double shift = par[0];
+    double bsl = par[0];
+    double beginOfRisingEdge = par[1];
+    double p0RisingEdge = par[6];
+    double p1RisingEdge = par[7];
+    double p2RisingEdge = par[8];
+    double p3RisingEdge = par[9];
+    double endOfRisingEdge = par[2];
+//    double pOFallingEdge = par[3];
+//    double expPar1FallingEdge = par[4];
+//    double expPar1FallingEdge = par[5];
+    /*
+    bool couted_once = false;
+    if not couted_once
+    {
+        couted_once = true;
+        cout << "shift:" << shift << endl;
+        cout << "bsl:" << bsl << endl;
+        cout << "expars:" << endl;
+        cout << "\t factor:" << exppar[0] << endl;
+        cout << "\t tau:" << exppar[1] << endl;
+        cout << "\t t0:" << exppar[2] << endl;
+        cout << "pol3pars:" << endl;
+        cout << "p[0] + x p[1] + x^2 p[2] + x^3 p[3]" << endl;
+        cout << pol3par[0] << "\t" << pol3par[1] << "\t" << pol3par[2] << "\t" << pol3par[3] << endl;
+        cout << "ranges:" << endl;
+        cout << "begin of pol3: " << range[0] << endl;
+        cout << "begin of exp:  " << range[1] << endl;
+    }
+    */
+    double x = input_x[0];
+
+    // the baseline is added everywhere.
+    returnval += bsl;
+
+    if ( (x > beginOfRisingEdge) && (x <= endOfRisingEdge) )
+    {
+        // from this point on the pol3 is added
+        returnval += p0RisingEdge;
+        returnval += p1RisingEdge * x;
+        returnval += p2RisingEdge * x*x;
+        returnval += p3RisingEdge * x*x*x;
+    }
+    else if ( x > endOfRisingEdge )
+    {
+        // from this point on the exp-func is added
+//        returnval += exppar[0] * TMath::Exp( exppar[1] * ( x - exppar[2] ) );
+        returnval += PolExp(input_x, par+3);
+    }
+
+    return returnval;
+}
Index: /fact/tools/rootmacros/PulseTemplates/templateextractors.h
===================================================================
--- /fact/tools/rootmacros/PulseTemplates/templateextractors.h	(revision 14061)
+++ /fact/tools/rootmacros/PulseTemplates/templateextractors.h	(revision 14062)
@@ -8,4 +8,5 @@
 #include <TH1I.h>
 #include <TH1F.h>
+#include <TF1.h>
 #include <TString.h>
 #include <TSystem.h>
@@ -87,4 +88,62 @@
         );
 
+void
+FitMaxPropabilityPuls(
+        TH1F*           hMaximumTemp,
+        int             verbosityLevel
+        );
+
+double
+PolExp(
+        double*         x,
+        double*         par
+        );
+
+void
+FitFallingEdge(
+        TString         name,
+        TH1F*           histo,
+        double          xMin,
+        double          xMax,
+        double*         parameters
+        );
+
+double
+template_function(
+        double*         input_x,
+        double*         par);
+
+double
+NegPolExp(
+        double*         x,
+        double*         par
+        );
+
+void
+FitRisingEdge(
+        TString         name,
+        TH1F*           histo,
+        double          xMin,
+        double          xMax,
+        double*         parameters
+        );
+
+double
+ChargeDiode(
+        double*         time,
+        double*         chargeVoltage,
+        double*         impedance,
+        double*         capacity,
+        );
+
+double
+UnChargeDiode(
+        double*         time,
+        double*         chargeVoltage,
+        double*         impedance,
+        double*         capacity,
+        );
+
+
 #endif // TEMPLATEEXTRACTORS_H
 
