Index: fact/tools/rootmacros/PulseTemplates/templateextractors.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/templateextractors.C	(revision 14742)
+++ fact/tools/rootmacros/PulseTemplates/templateextractors.C	(revision 14751)
@@ -184,5 +184,5 @@
 void CalculateErrorsWithBootstrapping(TH1* inputHisto, int numIt, double* par, double* parErr)
 {
-    cout << "...calculating errors of " << inputHisto->GetName() << endl;
+//    cout << "...calculating errors of " << inputHisto->GetName() << endl;
     Sample  sample;
     double  Mean[numIt];
@@ -192,29 +192,53 @@
     double  parameterErr[3];
 
+//    TCanvas test_canvas;
+//    test_canvas.Divide(2,1);
+//    test_canvas.cd(1);
+//    inputHisto->Draw();
     for (int i = 0; i < numIt; i++)
     {
-        TH1D    tempHisto(
-                    "tempHisto",
-                    "tempHisto",
-                    inputHisto->GetNbinsX(),
-                    inputHisto->GetXaxis()->GetFirst(),
-                    inputHisto->GetXaxis()->GetLast()
-                    );
-
-        sample.BootstrapTH1(inputHisto, &tempHisto);
-
-        Mean[i]     = tempHisto.GetMean();
-        Median[i]   = MedianOfH1 ( &tempHisto );
-
-        Max[i]      = tempHisto.GetBinCenter( tempHisto.GetMaximumBin() );
+//        test_canvas.cd(2);
+        TH1* tempHisto = (TH1*)inputHisto->Clone("tempHisto");
+//                    "",
+//                    "",
+//                    inputHisto->GetNbinsX(),
+//                    inputHisto->GetXaxis()->GetBinLowEdge(  inputHisto->GetXaxis()->GetFirst() ),
+//                    inputHisto->GetXaxis()->GetBinUpEdge(   inputHisto->GetXaxis()->GetLast() )
+//                    );
+        tempHisto->Reset();
+        sample.BootstrapTH1(inputHisto, tempHisto);
+
+        Mean[i]     = tempHisto->GetMean();
+        Median[i]   = MedianOfH1 ( tempHisto );
+
+        Max[i]      = tempHisto->GetBinCenter( tempHisto->GetMaximumBin() );
 
         //improved determination of maximum
 //        TF1 gaus("fgaus", "gaus", Max[i]-10, Max[i]+10);
-//        tempHisto.Fit("fgaus", "WWQRN0");
+//        tempHisto->Fit("fgaus", "WWQRN0");
 //        Max[i]      = gaus.GetParameter(1);
 
 
-        sample.SetSeed(sample.GetSeed() + 1);
-
+//        sample.SetSeed(sample.GetSeed() + 1);
+
+        /*
+        //Process gui events asynchronously during input
+        tempHisto->Draw();
+        test_canvas.Modified();
+        test_canvas.Update();
+        cout << endl;
+        TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
+        timer.TurnOn();
+        TString input = Getline("Type 'q' to exit, <return> to go on: ");
+        timer.TurnOff();
+        if (input=="q\n")
+        {
+            return;
+        }
+        */
+
+
+
+        delete tempHisto;
     }
 
@@ -585,5 +609,5 @@
 
         //calculate Errors with bootstrapping
-        CalculateErrorsWithBootstrapping(hTempHisto, 100, slMean, slError);
+        CalculateErrorsWithBootstrapping(hTempHisto, 10, slMean, slError);
 
         if (verbosityLevel > 3)
@@ -594,4 +618,5 @@
         //Get maximum of slice's distribution
         max_prop    = hTempHisto->GetBinCenter( hTempHisto->GetMaximumBin() );
+//                max_prop    = slMean[0];
 
         //improve result by< fitting gaussian to slices distribution
@@ -610,5 +635,6 @@
         }
         median      = MedianOfH1(hTempHisto);
-        median_err    = slError[1]; //error from bootstraping
+//        median      = slMean[1];
+        median_err  = slError[1]; //error from bootstraping
 
         if (verbosityLevel > 3) cout << "\t\t...calculating Mean of slice " << slice << endl;
@@ -616,4 +642,5 @@
 
         mean        = hTempHisto->GetMean();
+//        mean        = slMean[2];
         mean_err    = hTempHisto->GetRMS(); //RMS of slice
 //        mean_err    = slError[2];         //error from bootstraping
@@ -640,4 +667,34 @@
 //            verbosityLevel
 //            );
+//    hOutputMaxHisto->GetXaxis()->SetLimits(
+//                0,
+//                300
+//                );
+
+//    hOutputMeanHisto->GetXaxis()->SetLimits(
+//                0,
+//                300
+//                );
+
+//    hOutputMedianHisto->GetXaxis()->SetLimits(
+//                0,
+//                300
+//                );
+
+    ShiftStartOfHistoInXTo(
+            hOutputMaxHisto,
+            0
+            );
+
+    ShiftStartOfHistoInXTo(
+            hOutputMeanHisto,
+            0
+            );
+
+    ShiftStartOfHistoInXTo(
+            hOutputMedianHisto,
+            0
+            );
+
 }
 // end of PlotMaxPropabilityPulse
@@ -864,2 +921,27 @@
 //    return returnval;
 //}
+
+
+void
+ShiftHistoInX(
+        TH1*                histo,
+        float               shift
+        )
+{
+    histo->GetXaxis()->SetLimits(
+        histo->GetXaxis()->GetBinLowEdge( histo->GetXaxis()->GetFirst() ) + shift,
+        histo->GetXaxis()->GetBinUpEdge(  histo->GetXaxis()->GetLast() )  + shift
+                              );
+}
+
+void
+ShiftStartOfHistoInXTo(
+        TH1*                histo,
+        float               value
+        )
+{
+    float min = histo->GetXaxis()->GetBinLowEdge( histo->GetXaxis()->GetFirst() );
+    float shift = value - min;
+
+    ShiftHistoInX( histo, shift);
+}
