Index: fact/tools/rootmacros/PulseTemplates/templateextractors.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/templateextractors.C	(revision 14081)
+++ fact/tools/rootmacros/PulseTemplates/templateextractors.C	(revision 14477)
@@ -1,7 +1,7 @@
 #include <iostream>
 #include <fstream>
+#include <stdlib.h>
 
 #include "templateextractors.h"
-#include <stdlib.h>
 
 using namespace std;
@@ -15,29 +15,34 @@
         )
 {
-    if (verbosityLevel > 2) cout << endl
-                                 << "...calculating slieces value of max. propability"
-                                 << endl;
-
-    float   max_value_of_slice  = 0;
-    TH1D*   hTempHisto          = NULL;
-    int     nbins               = inputHisto->GetXaxis()->GetNbins();
-
-    if (verbosityLevel > 2) cout << "...generating projections" << endl;
-
-    for (Int_t TimeSlice = 1; TimeSlice <= nbins; TimeSlice++)
-    {
-        if (verbosityLevel > 2) cout << "...Timeslice: " << TimeSlice;
-
-        //put maximumvalue of every Y-projection of every timeslice into vector
-        hTempHisto          = inputHisto->ProjectionY( "", TimeSlice,TimeSlice);
-        max_value_of_slice  = hTempHisto->GetBinCenter( hTempHisto->GetMaximumBin() );
-
-        if (verbosityLevel > 2) cout << " with max value "
-                                     << max_value_of_slice << endl;
-
-        outputHisto->SetBinContent(TimeSlice, max_value_of_slice );
-    }
-
-    if (verbosityLevel > 2) cout << "\t...done" << endl;
+    if (verbosityLevel > 2)
+        cout << endl
+             << "...calculating slieces value of max. propability"
+             << endl;
+
+    float   sliceMax    = 0;
+    TH1D*   hTemp       = NULL;
+    int     nbins       = inputHisto->GetXaxis()->GetNbins();
+
+    if (verbosityLevel > 2)
+        cout << "...generating projections" << endl;
+
+    for (Int_t slice = 1; slice <= nbins; slice++)
+    {
+        if (verbosityLevel > 2)
+            cout << "...slice: " << slice;
+
+    //put maximumvalue of every Y-projection of every slice into vector
+        hTemp       = inputHisto->ProjectionY( "", slice,slice);
+        sliceMax    = hTemp->GetBinCenter( hTemp->GetMaximumBin() );
+
+        if (verbosityLevel > 2)
+            cout << " with max value "
+                 << sliceMax << endl;
+
+        outputHisto->SetBinContent(slice, sliceMax );
+    }
+
+    if (verbosityLevel > 2)
+        cout << "\t...done" << endl;
 }
 // end of CalcMaxPropabilityOfSlice
@@ -442,186 +447,136 @@
     }
 
-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;
-}
-
-double
-PulseFunction(
-        double*         time,
-        double*         baseline,
-        double*         risingChargeVoltage,
-        double*         risingImpedance,
-        double*         risingCapacity,
-        double*         fallingChargeVoltage,
-        double*         fallingImpedance,
-        double*         fallingCapacity
-        )
-{
-    double returnValue  = 0.0;
-    returnValue         += baseline;
-    returnValue         +=  ChargeDiode(
-                                    time,
-                                    risingChargeVoltage,
-                                    risingImpedance,
-                                    risingCapacity);
-    returnValue         +=  UnChargeDiode(
-                                    time,
-                                    fallingChargeVoltage,
-                                    fallingImpedance,
-                                    fallingCapacity);
-    return returnValue;
-}
-
-void
-FitPulse(
-        TString         name,
-        TH1F*           histo,
-        double          xMin,
-        double          xMax,
-        double*         parameters
-        )
-{
-    TF1* pulseFunction = new TF1(name, PulseFunction, xMin, xMax, 7 );
-    pulseFunction->SetParNames(
-                "Baseline",
-                "Charge-Voltage of rising Edge",
-                "Impedance for rising Edge",
-                "Capacity for rising Edge",
-                "Charge-Voltage of falling Edge",
-                "Impedance for falling Edge",
-                "Capacity for falling Edge"
-                );
-    pulseFunction->SetLineColor(kRed);
-    histo->Fit(pulseFunction, "RWM");
-    pulseFunction->GetParameters(parameters);
-    return 0;
-}
+//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(kGreen);
+//    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, "+RWWM");
+//    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*         timeConstant
+//        )
+//{
+//   return chargeVoltage[0]+TMath::Exp(chargeVoltage[1]+timeConstant[2]*time[0]);
+////    return chargeVoltage[0] * (TMath::Exp(time[0]/timeConstant[0]));
+//}
+
+//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;
+//}
