Index: /fact/tools/marsmacros/singlepe.C
===================================================================
--- /fact/tools/marsmacros/singlepe.C	(revision 14181)
+++ /fact/tools/marsmacros/singlepe.C	(revision 14182)
@@ -736,6 +736,7 @@
     const Double_t ampl     = hSum1.GetBinContent(maxbin);
 
-
     double fwhm2 = 0;
+
+    //Calculate full width half Maximum
     for (int i=1; i<maxbin; i++)
         if (hSum1.GetBinContent(maxbin-i)+hSum1.GetBinContent(maxbin+i)<ampl*2)
@@ -744,5 +745,4 @@
             break;
         }
-
     if (fwhm2==0)
     {
@@ -750,20 +750,23 @@
     }
 
-
+    //Set fit parameters
     Double_t par[5] =
     {
         ampl, hSum1.GetBinCenter(maxbin), fwhm2*1.4, 0.1, -10
     };
-
     func2.SetParameters(par);
 
+    //calculate fit range
     const double min = par[1]-fwhm2*1.4;
     const double max = par[1]*5;
 
+    //Fit and draw spectrum
     hSum1.Fit(&func2, "NOQS", "", min, max);
     func2.DrawCopy("SAME");
+
     //-------------------END OF: fit sum spectrum-----------------------------
 
-
+    // Draw gain corrected sum specetrum
+    gROOT->SetSelectedPad(0);
     TCanvas &c12 = d->AddTab("GainHist");
     gPad->SetLogy();
@@ -771,19 +774,33 @@
     const Double_t fMaxPos  = hSum2.GetBinCenter(maxbin);
 
-    //------------------fit gausses to peaks -----------------------
-
-    UInt_t nfunc = 5;
-    TF1 **gaus = new TF1*[nfunc];
-
+    //--------fit gausses to peaks of gain corrected sum specetrum -----------
+    UInt_t nfunc    = 5;
+
+    // create array for gaus funtions to fit to peaks of spectrum
+    TF1 **gaus      = new TF1*[nfunc];
+
+    // create histo for height of Maximum amplitudes vs. pe
+    TH1D hMaxHeights("MaxHeights",      "peak heights",
+                      20,  0,   20);
+
+    // fit gauss functions to spectrum
     for (UInt_t nr = 0; nr<nfunc; nr++)
     {
-      char fname[20];
-      sprintf(fname,"gaus%d",nr);
-      gaus[nr] = new TF1(fname,"gaus",  fMaxPos*(nr+1)-0.6, fMaxPos*(nr+1)+0.6);
-        hSum2.Fit(gaus[nr], "N0QS", "", fMaxPos*(nr+1)-0.6, fMaxPos*(nr+1)+0.6);
+        char fname[20];
+        sprintf(fname,"gaus%d",nr);
+
+        //create gauss functions
+        gaus[nr] = new TF1( fname,"gaus",
+                            fMaxPos*(nr+1)-0.6,     fMaxPos*(nr+1)+0.6);
+        //fit and draw gauss functions
+        hSum2.Fit(  gaus[nr],   "N0QS",     "",
+                    fMaxPos*(nr+1)-0.6,     fMaxPos*(nr+1)+0.6);
         gaus[nr]->DrawCopy("SAME");
-//        delete gaus[nr];
-    }
-
+
+        //fill histo for height of Maximum amplitudes vs. pe
+        hMaxHeights.SetBinContent(nr, gaus[nr]->GetParameter(0));
+        delete gaus[nr];
+    }
+    delete[] gaus;
 
     //------------------fit gain corrected sum spectrum-----------------------
@@ -792,6 +809,6 @@
     const Double_t binwidth2 = hSum2.GetBinWidth(maxbin);
     const Double_t ampl2     = hSum2.GetBinContent(maxbin);
-    cout << "AMPL: " << ampl2 << endl;
-
+
+    //Calculate full width half Maximum
     fwhm2 = 0;
     for (int i=1; i<maxbin; i++)
@@ -801,5 +818,4 @@
             break;
         }
-
     if (fwhm2==0)
     {
@@ -807,13 +823,9 @@
     }
 
-
+    //Set fit parameters
     Double_t par2[5] =
     {
         ampl2, hSum2.GetBinCenter(maxbin2), fwhm2*1.4, 0.1, 0
     };
-
-        cout << "AMPL: " << ampl2 << endl;
-            cout << "maxpos: " << hSum2.GetBinCenter(maxbin2) << endl;
-                cout << "fwhm: " << fwhm2*1.4 << endl;
 
     func3.SetParameters(par2);
@@ -825,4 +837,8 @@
     func3.DrawCopy("SAME");
     //-------------------END OF: fit sum spectrum-----------------------------
+
+    TCanvas &c15 = d->AddTab("PeakHeights");
+    gPad->SetLogy();
+    hMaxHeights.DrawCopy();
 
     TCanvas &c2 = d->AddTab("Result");
