Index: fact/tools/rootmacros/PulseTemplates/templateextractors.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/templateextractors.C	(revision 13652)
+++ fact/tools/rootmacros/PulseTemplates/templateextractors.C	(revision 13785)
@@ -4,4 +4,5 @@
 #include "templateextractors.h"
 #include <stdlib.h>
+
 using namespace std;
 
@@ -262,8 +263,8 @@
                                  << " Overlay"
                                  << endl;
-    TH2F*   hInputHistoArray        = NULL;
-    TH1F*   hOutputMaxHistoArray    = NULL;
-    TH1F*   hOutputMeanHistoArray   = NULL;
-    TH1F*   hOutputMedianHistoArray = NULL;
+    TH2F*   hInputHisto             = NULL;
+    TH1F*   hOutputMaxHisto         = NULL;
+    TH1F*   hOutputMeanHisto        = NULL;
+    TH1F*   hOutputMedianHisto      = NULL;
     TH1*    hTempHisto              = NULL;
     float   max_prop                = 0;
@@ -274,34 +275,35 @@
     {
         cout << "...setting pointers to histogramm arrays ";
+        cout << " for " << overlayType << "Overlay" << endl;
     }
     if (overlayType.Contains("Edge"))
     {
-        hInputHistoArray        = CurrentPixel->hEdgeOverlay[pulse_order];
+        hInputHisto        = (CurrentPixel->hEdgeOverlay[pulse_order]);
 
         //Maximum Propability of Slices
-        hOutputMaxHistoArray    = CurrentPixel->hPixelEdgeMax[pulse_order];
+        hOutputMaxHisto    = (CurrentPixel->hPixelEdgeMax[pulse_order]);
 
         //Mean of Slices
-        hOutputMeanHistoArray   = CurrentPixel->hPixelEdgeMean[pulse_order];
+        hOutputMeanHisto   = (CurrentPixel->hPixelEdgeMean[pulse_order]);
 
         //Median of Slices
-        hOutputMedianHistoArray = CurrentPixel->hPixelEdgeMedian[pulse_order];
+        hOutputMedianHisto = (CurrentPixel->hPixelEdgeMedian[pulse_order]);
     }
     else if (overlayType.Contains("Maximum"))
     {
-        hInputHistoArray        = CurrentPixel->hMaxOverlay[pulse_order];
+        hInputHisto        = (CurrentPixel->hMaxOverlay[pulse_order]);
 
         //Maximum Propability of Slices
-        hOutputMaxHistoArray    = CurrentPixel->hPixelMax[pulse_order];
+        hOutputMaxHisto    = (CurrentPixel->hPixelMax[pulse_order]);
 
         //Mean of Slices
-        hOutputMeanHistoArray   = CurrentPixel->hPixelMean[pulse_order];
+        hOutputMeanHisto   = (CurrentPixel->hPixelMean[pulse_order]);
 
         //Median of Slices
-        hOutputMedianHistoArray = CurrentPixel->hPixelMedian[pulse_order];
+        hOutputMedianHisto = (CurrentPixel->hPixelMedian[pulse_order]);
     }
     else
     {
-        cout << endl << "Unknown Overlay Method-->aborting" << endl;
+        cout << endl << overlayType << "Unknown Overlay Method-->aborting" << endl;
         return;
     }
@@ -311,15 +313,9 @@
     }
 
-    if (verbosityLevel > 2) cout << "\t...calculation of "
-                                 << "pulse order " << pulse_order << endl;
-
-    cout << "################ " << endl;
-    //  vector max_value_of to number of timeslices in Overlay Spectra
-    cout << "### " << hInputHistoArray;
-    cout << "################ " << endl;
-
-//    int nbins = hInputHistoArray->GetXaxis()->GetNbins();
-//    cout << "###" << nbins << endl;
-
+    if (verbosityLevel > 2)
+    {
+        cout << "\t...calculation of "
+             << "pulse order " << pulse_order << endl;
+    }
 
 //    if (verbosityLevel > 2) cout << "\t...# slices processed " << nbins << endl;
@@ -328,5 +324,5 @@
     {
 
-        hTempHisto  = hInputHistoArray->ProjectionY("",TimeSlice,TimeSlice);
+        hTempHisto  = hInputHisto->ProjectionY("",TimeSlice,TimeSlice);
 
         if (verbosityLevel > 3)
@@ -346,12 +342,12 @@
 
         if (verbosityLevel > 4) cout << "\t\t\t\t MaxProb of Slice " << TimeSlice << ": " << max_prop << endl;
-        hOutputMaxHistoArray->SetBinContent(TimeSlice, max_prop );
+        hOutputMaxHisto->SetBinContent(TimeSlice, max_prop );
 
         if (verbosityLevel > 4) cout << "\t\t\t\t Mean of Slice " << TimeSlice << ": " << mean << endl;
-        hOutputMeanHistoArray->SetBinContent(TimeSlice, mean );
+        hOutputMeanHisto->SetBinContent(TimeSlice, mean );
 
         if (verbosityLevel > 4) cout << "\t\t\t\t Median of Slice " << TimeSlice << ": " << median << endl;
-        hOutputMedianHistoArray->SetBinContent(TimeSlice, median );
-//            delete h1;
+        hOutputMedianHisto->SetBinContent(TimeSlice, median );
+        delete hTempHisto;
 
     }//Loop over Timeslices
@@ -369,21 +365,25 @@
         )
 {
+//    TSystem this_system();
+//    this_system.cd(path);
+//    cout << this_system.pwd();
+//    this_system.mkdir("CSV");
     path = CurrentPixel->CsvFileName( path, overlayMethod, order);
 
-    TH1F**  Max_histo_array    = NULL;
-    TH1F**  Median_histo_array    = NULL;
-    TH1F**  Mean_histo_array    = NULL;
+    TH1F*  Max_histo    = NULL;
+    TH1F*  Median_histo    = NULL;
+    TH1F*  Mean_histo    = NULL;
 
     if (overlayMethod.Contains("Maximum"))
     {
-            Max_histo_array = CurrentPixel->hPixelMax;
-            Median_histo_array = CurrentPixel->hPixelMedian;
-            Mean_histo_array = CurrentPixel->hPixelMean;
+        Max_histo = CurrentPixel->hPixelMax[order];
+            Median_histo = CurrentPixel->hPixelMedian[order];
+            Mean_histo = CurrentPixel->hPixelMean[order];
     }
     else if (overlayMethod.Contains("Edge"))
     {
-        Max_histo_array = CurrentPixel->hPixelMax;
-        Median_histo_array = CurrentPixel->hPixelMedian;
-        Mean_histo_array = CurrentPixel->hPixelMean;
+        Max_histo = CurrentPixel->hPixelMax[order];
+        Median_histo = CurrentPixel->hPixelMedian[order];
+        Mean_histo = CurrentPixel->hPixelMean[order];
     }
     else
@@ -394,5 +394,5 @@
 
 
-    Int_t nbins = Max_histo_array[order]->GetXaxis()->GetNbins();
+    Int_t nbins = Max_histo->GetXaxis()->GetNbins();
 
     if (verbosityLevel > 0)
@@ -421,7 +421,7 @@
     {
         out << TimeSlice << "," ;
-        out << Max_histo_array[order]->GetBinContent(TimeSlice) << ",";
-        out << Mean_histo_array[order]->GetBinContent(TimeSlice) << ",";
-        out << Median_histo_array[order]->GetBinContent(TimeSlice) << endl;
+        out << Max_histo->GetBinContent(TimeSlice) << ",";
+        out << Mean_histo->GetBinContent(TimeSlice) << ",";
+        out << Median_histo->GetBinContent(TimeSlice) << endl;
     }
     out.close();
