Index: fact/tools/rootmacros/PulseTemplates/csv.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/csv.C	(revision 14480)
+++ fact/tools/rootmacros/PulseTemplates/csv.C	(revision 14534)
@@ -17,4 +17,5 @@
     mSuffix     = suffix;
     mVerbLevel  = verbLevel;
+    mSeparator  = ";";
 
     BuildPath();
@@ -39,8 +40,8 @@
     if (!mSuffix.IsNull()){
 
-        if (mSuffix = -1)
+        if (mSuffix.Contains("-1"))
             mSuffix = "AllPixel";
 
-        mSuffix.Append("_");
+        mSuffix.Prepend("_");
         mPath.Append(mSuffix);
     }
@@ -55,5 +56,5 @@
 
 bool
-Csv::WritePixelToCsv(
+Csv::WritePointSetToCsv(
         Pixel*          pixel,
         TString         overlayMethod,
@@ -67,7 +68,7 @@
     }
 
-    WritePointsetExplain();
-
-    WritePointSetToCsv(
+    WritePointSetHeader();
+
+    WritePointSet(
             pixel,
             overlayMethod,
@@ -88,4 +89,5 @@
     TH1F*  Median_histo     = NULL;
     TH1F*  Mean_histo       = NULL;
+    int overlayPos          = 0;
 
     if (overlayMethod.Contains("Maximum"))
@@ -94,4 +96,5 @@
         Median_histo    = pixel->hPixelMedian[order];
         Mean_histo      = pixel->hPixelMean[order];
+        overlayPos      = 1;
     }
     else if (overlayMethod.Contains("Edge"))
@@ -100,9 +103,10 @@
         Median_histo    = pixel->hPixelMedian[order];
         Mean_histo      = pixel->hPixelMean[order];
+        overlayPos      = 2;
     }
     else
     {
         cout << endl << "Unknown Overlay Method-->aborting" << endl;
-        return 1;
+        return ;
     }
 
@@ -117,92 +121,125 @@
     if (mVerbLevel > 2) cout << "...number of bins " << nbins << endl;
 
+    //fill coulums
+    for (int TimeSlice=1;TimeSlice<=nbins;TimeSlice++)
+    {
+        mCsvFile << TimeSlice << mSeparator ;
+        mCsvFile << pixel->mChid << mSeparator ;
+        mCsvFile << order << mSeparator ;
+        mCsvFile << overlayPos << mSeparator ;
+        mCsvFile.precision(8);
+        mCsvFile << Max_histo->GetBinContent(TimeSlice) << mSeparator;
+        mCsvFile << Mean_histo->GetBinContent(TimeSlice) << mSeparator;
+        mCsvFile << Median_histo->GetBinContent(TimeSlice) << endl;
+        mCsvFile.precision(mPrecision);
+    }
+
+    return ;
+}
+
+void
+Csv::WritePointSetHeader()
+{
+    mCsvFile << "### point-set of a single photon pulse template"
+             << endl
+             << "### Slice's Amplitude determined by calculating the "
+             << endl
+             << "### value of maximum propability of slice -> AmplitudeMax "
+             << endl
+             << "### mean of slice -> AmplitudeMean "
+             << endl
+             << "### median of slice -> AmplitudeMedian "
+             << endl
+             << "### for each slice"
+             << endl
+             << "### "
+             << endl
+             << "### OverlayMethods (1) at Maximum, (2) at rising Edge" << endl;
+
     //name coulums header
-    mCsvFile << "pixel [CHid]"          << ",";
-    mCsvFile << "OverlayPosition"       << ",";
-    mCsvFile << "AmplitudeMax [mV]"     << ",";
-    mCsvFile << "AmplitudeMean [mV]"    << ",";
+    mCsvFile << "TimeSlice [a.u.]"          << mSeparator;
+    mCsvFile << "pixel [CHid]"          << mSeparator;
+    mCsvFile << "Pulseorder [PhE]"          << mSeparator;
+    mCsvFile << "OverlayPosition"       << mSeparator;
+    mCsvFile << "AmplitudeMax [mV]"     << mSeparator;
+    mCsvFile << "AmplitudeMean [mV]"    << mSeparator;
     mCsvFile << "AmplitudeMedian [mV]";
     mCsvFile << endl;
-
-    //fill coulums
-    for (int TimeSlice=1;TimeSlice<=nbins;TimeSlice++)
-    {
-        mCsvFile << pixel->mChid << "," ;
-        mCsvFile << overlayMethod << "," ;
-        mCsvFile << TimeSlice << "," ;
-        mCsvFile << Max_histo->GetBinContent(TimeSlice) << ",";
-        mCsvFile << Mean_histo->GetBinContent(TimeSlice) << ",";
-        mCsvFile << Median_histo->GetBinContent(TimeSlice) << endl;
-    }
-    return 0;
-}
-
-void
-Csv::WritePointSetExplain()
-{
-    mCsvFile << "### point-set of a single photon pulse template"
-             << endl;
-             << "### Slice's Amplitude determined by calculating the "
-             << endl
-             << "### value of maximum propability of slice -> AmplitudeMax "
-             << endl
-             << "### mean of slice -> AmplitudeMean "
-             << endl
-             << "### median of slice -> AmplitudeMedian "
-             << endl
-             << "### for each slice"
-             << endl
-             << "### " << endl;
-}
-
+}
+
+void
+Csv::WritePulseAttributesHeader()
+{
+    //name coulums header
+    mCsvFile << "pixel [CHid]"      << mSeparator;
+    mCsvFile << "OverlayPosition"   << mSeparator;
+    mCsvFile << "ModelName"         << mSeparator ;
+    mCsvFile << "Bsl"               << mSeparator;
+    mCsvFile << "BslErr"            << mSeparator;
+    mCsvFile << "Height"            << mSeparator ;
+    mCsvFile << "HeightErr"         << mSeparator ;
+    mCsvFile << "T0"                << mSeparator ;
+    mCsvFile << "T0Err"             << mSeparator ;
+    mCsvFile << "T1"                << mSeparator ;
+    mCsvFile << "T1Err"             << mSeparator ;
+    mCsvFile << "Tau1"              << mSeparator ;
+    mCsvFile << "Tau1Err"           << mSeparator ;
+    mCsvFile << "Tau2"              << mSeparator ;
+    mCsvFile << "Tau2Err"           << mSeparator ;
+    mCsvFile << "Integral"          << mSeparator ;
+    mCsvFile << "IntegralErr"       << mSeparator ;
+    mCsvFile << "Amplitude"         << mSeparator ;
+    mCsvFile << "AmplitudeErr"      << mSeparator ;
+    mCsvFile << "Phe"               << mSeparator ;
+    mCsvFile << "PheErr"            << mSeparator ;
+    mCsvFile << "Order"             << mSeparator ;
+    mCsvFile << "Type"              << mSeparator ;
+    mCsvFile << "FitProb"           << mSeparator ;
+    mCsvFile << "FitNCalls"         << mSeparator ;
+    mCsvFile << "FitNdf"            << mSeparator ;
+    mCsvFile << "Chi2"                     ;
+    mCsvFile << endl;
+}
 void
 Csv::WritePulseAttributes(
         Pixel*          pixel,
         Pulse*          pulse,
-        TString         overlayMethod
+        TString         overlayMethod,
+        int             order
         )
 {
-    //name coulums header
-    mCsvFile << "pixel [CHid]"      << ",";
-    mCsvFile << "OverlayPosition"   << ",";
-    mCsvFile << "ModelName"         << "," ;
-    mCsvFile << "Bsl"               << ",";
-    mCsvFile << "Height"            << "," ;
-    mCsvFile << "T0"                << "," ;
-    mCsvFile << "T1"                << "," ;
-    mCsvFile << "Tau1"              << "," ;
-    mCsvFile << "Tau2"              << "," ;
-    mCsvFile << "Integral"          << "," ;
-    mCsvFile << "Amplitude"         << "," ;
-    mCsvFile << "PhE"               << "," ;
-    mCsvFile << "Type"              << "," ;
-    mCsvFile << "FitProb"           << "," ;
-    mCsvFile << "FitNCalls"         << "," ;
-    mCsvFile << "FitNdf"            << "," ;
-    mCsvFile << "Chi2"                     ;
+    //fill coulums
+    mCsvFile << pixel->mChid << mSeparator ;
+    mCsvFile << overlayMethod << mSeparator ;
+    mCsvFile << pulse->GetName() << mSeparator ;
+    mCsvFile.precision(12);
+    mCsvFile << pulse->GetBsl() << mSeparator ;
+    mCsvFile << pulse->GetBslErr() << mSeparator ;
+    mCsvFile << pulse->GetHeight() << mSeparator ;
+    mCsvFile << pulse->GetHeightErr() << mSeparator ;
+    mCsvFile.precision(12);
+    mCsvFile << pulse->GetT0() << mSeparator ;
+    mCsvFile << pulse->GetT0Err() << mSeparator ;
+    mCsvFile << pulse->GetT1() << mSeparator ;
+    mCsvFile << pulse->GetT1Err() << mSeparator ;
+    mCsvFile << pulse->GetTau1() << mSeparator ;
+    mCsvFile << pulse->GetTau1Err() << mSeparator ;
+    mCsvFile << pulse->GetTau2() << mSeparator ;
+    mCsvFile << pulse->GetTau2Err() << mSeparator ;
+    mCsvFile.precision(8);
+    mCsvFile << pulse->GetIntegral() << mSeparator ;
+    mCsvFile << pulse->GetAmplitude() << mSeparator ;
+    mCsvFile.precision(2);
+    mCsvFile << pulse->GetPhE() << mSeparator ;
+    mCsvFile << pulse->GetPhEErr() << mSeparator ;
+    mCsvFile << order << mSeparator ;
+    mCsvFile << pulse->GetType() << mSeparator ;
+    mCsvFile << pulse->GetFitProb() << mSeparator ;
+    mCsvFile.precision(12);
+    mCsvFile << pulse->GetFitNCalls() << mSeparator ;
+    mCsvFile << pulse->GetFitNdf() << mSeparator ;
+    mCsvFile << pulse->GetChi2() << mSeparator ;
     mCsvFile << endl;
-
-    //fill coulums
-    for (int TimeSlice=1;TimeSlice<=nbins;TimeSlice++)
-    {
-        mCsvFile << pixel->mChid << "," ;
-        mCsvFile << overlayMethod << "," ;
-        mCsvFile << pulse->GetName() << "," ;
-        mCsvFile << pulse->GetBsl() << "," ;
-        mCsvFile << pulse->GetHeight() << "," ;
-        mCsvFile << pulse->GetT0() << "," ;
-        mCsvFile << pulse->GetT1() << "," ;
-        mCsvFile << pulse->GetTau1() << "," ;
-        mCsvFile << pulse->GetTau2() << "," ;
-        mCsvFile << pulse->GetIntegral() << "," ;
-        mCsvFile << pulse->GetAmplitude() << "," ;
-        mCsvFile << pulse->GetPhE() << "," ;
-        mCsvFile << pulse->GetType() << "," ;
-        mCsvFile << pulse->GetFitProb() << "," ;
-        mCsvFile << pulse->GetFitNCalls() << "," ;
-        mCsvFile << pulse->GetFitNdf() << "," ;
-        mCsvFile << pulse->GetChi2() << "," ;
-        mCsvFile << endl;
-    }
+    mCsvFile.precision(mPrecision);
 }
 
@@ -211,4 +248,5 @@
     if (mVerbLevel > 2) cout << "...opening csv file" << endl;
     mCsvFile.open( mPath );
+    mPrecision = mCsvFile.precision();
 }
 
@@ -223,10 +261,10 @@
 // ===========================================================================
 
-void
+TString
 Csv::GetFilename(){
     return mFilename;
 }
 
-void
+TString
 Csv::GetPath(){
     return mPath;
