Index: fact/tools/rootmacros/PulseTemplates/pulse.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/pulse.C	(revision 14479)
+++ fact/tools/rootmacros/PulseTemplates/pulse.C	(revision 14532)
@@ -124,22 +124,32 @@
 Pulse::InitMembers()
 {
-    mName           = "pulse";
-    mHisto          = NULL;
-    mModel          = NULL;
-    mOptions        = "S";
-    mBsl            = 0;
-    mHeight         = 0;
-    mT0             = 0;
-    mT1             = 0;
-    mTau1           = 0;
-    mTau2           = 0;
-    mIntegral       = 0;
-    mAmplitude      = 0;
-    mPhE            = 0;
-    mType           = 0;
-    mFitProb        = 0;
-    mFitNCalls      = 0;
-    mFitNdf         = 0;
-    mChi2           = 0;
+    mName               = "pulse";
+    mHisto              = NULL;
+    mModel              = NULL;
+    mOptions            = "S";
+    mBsl.first          = 0;
+    mHeight.first       = 0;
+    mT0.first           = 0;
+    mT1.first           = 0;
+    mTau1.first         = 0;
+    mTau2.first         = 0;
+    mIntegral.first     = 0;
+    mAmplitude.first    = 0;
+    mPhE.first          = 0;
+    mBsl.second         = 0;
+    mHeight.second      = 0;
+    mT0.second          = 0;
+    mT1.second          = 0;
+    mTau1.second        = 0;
+    mTau2.second        = 0;
+    mIntegral.second    = 0;
+    mAmplitude.second   = 0;
+    mPhE.second         = 0;
+    mOrder              = 0;
+    mType               = 0;
+    mFitProb            = 0;
+    mFitNCalls          = 0;
+    mFitNdf             = 0;
+    mChi2               = 0;
 }
 
@@ -154,5 +164,5 @@
     mFitMin = fitMin;
     mFitMax = fitMax;
-    mModel  = new TF1(fitName, shapeFunc, fitMin, fitMax, 6 );
+    mModel  = new TF1(fitName, shapeFunc, fitMin, fitMax, 7 );
 
     // ======================================================================
@@ -168,25 +178,33 @@
     bsl = bsl/30;
 
-    double stop     = mHisto->GetMaximumBin(); //pos of max
-    double height   = mHisto->GetBinContent(stop);
-    double start    = stop-10; //pos 10 slices before maximum
+    double stop         = mHisto->GetMaximumBin(); //pos of max
+    double amplitude    = mHisto->GetBinContent(stop);
+    double start        = stop-10; //pos 10 slices before maximum
+    int    phe          = amplitude/10;
     // ======================================================================
 
-    double para[] = {bsl, height, start, stop, tau, tau};
+    double para[] = {bsl, amplitude, start, stop, tau, tau, phe};
 
 
 
     mModel->SetParameters(para);
-    mModel->SetParNames("BSL", "A0", "t0", "t1", "Tau1", "Tau2");
+    mModel->SetParNames("BSL", "A0", "t0", "t1", "Tau1", "Tau2", "PhE");
     mModel->SetLineColor(kRed);
 
-    mFitResultPtr = mHisto->Fit(mModel, fitOptions);
-
-    mBsl            = mModel->GetParameter(0);
-    mHeight         = mModel->GetParameter(1);
-    mT0             = mModel->GetParameter(2);
-    mT1             = mModel->GetParameter(3);
-    mTau1           = mModel->GetParameter(4);
-    mTau2           = mModel->GetParameter(5);
+    mFitResultPtr   = mHisto->Fit(mModel, fitOptions);
+    mBsl.first      = mModel->GetParameter(0);
+    mBsl.second     = mModel->GetParError(0);
+    mHeight.first   = mModel->GetParameter(1);
+    mHeight.second  = mModel->GetParError(1);
+    mT0.first       = mModel->GetParameter(2);
+    mT0.second      = mModel->GetParError(2);
+    mT1.first       = mModel->GetParameter(3);
+    mT1.second      = mModel->GetParameter(3);
+    mTau1.first     = mModel->GetParameter(4);
+    mTau1.second    = mModel->GetParError(4);
+    mTau2.first     = mModel->GetParameter(5);
+    mTau2.second    = mModel->GetParError(5);
+    mPhE.first      = mModel->GetParameter(6);
+    mPhE.second     = mModel->GetParError(6);
 }
 
@@ -201,5 +219,5 @@
     mFitMin = fitMin;
     mFitMax = fitMax;
-    mModel  = new TF1(fitName, shapeFunc2, fitMin, fitMax, 5 );
+    mModel  = new TF1(fitName, shapeFunc2, fitMin, fitMax, 6 );
 
     // ======================================================================
@@ -218,19 +236,28 @@
     double amplitude= mHisto->GetBinContent(stop);
     double start    = stop-10; //pos 10 slices before maximum
+    int    phe      = amplitude/10;
     // ======================================================================
 
 
-    double para[] = {bsl, amplitude, start, tau, tau};
+    double para[] = {bsl, amplitude, start, tau, tau, phe};
     mModel->SetParameters(para);
-    mModel->SetParNames("BSL", "A0", "t0", "Tau1", "Tau2");
+    mModel->SetParNames("BSL", "A0", "t0", "Tau1", "Tau2", "PhE");
     mModel->SetLineColor(kBlue);
 
-    mFitResultPtr = mHisto->Fit(mModel, fitOptions);
-
-    mBsl    = mModel->GetParameter(0);
-    mHeight = mModel->GetParameter(1);
-    mT0     = mModel->GetParameter(2);
-    mTau1   = mModel->GetParameter(3);
-    mTau2   = mModel->GetParameter(4);
+    mFitResultPtr   = mHisto->Fit(mModel, fitOptions);
+    mBsl.first      = mModel->GetParameter(0);
+    mBsl.second     = mModel->GetParError(0);
+    mHeight.first   = mModel->GetParameter(1);
+    mHeight.second  = mModel->GetParError(1);
+    mT0.first       = mModel->GetParameter(2);
+    mT0.second      = mModel->GetParError(2);
+    mTau1.first     = mModel->GetParameter(3);
+    mTau1.second    = mModel->GetParError(3);
+    mTau2.first     = mModel->GetParameter(4);
+    mTau2.second    = mModel->GetParError(4);
+    mPhE.first      = mModel->GetParameter(5);
+    mPhE.second     = mModel->GetParError(5);
+
+    cout << "test" << mBsl.first << "\t +/-" << mBsl.second << endl;
 }
 
@@ -238,10 +265,10 @@
 Pulse::CalculateParameters()
 {
-    mIntegral   = mModel->Integral(mFitMin, mFitMax);
-    mAmplitude  = mModel->GetMaximum() - mBsl;
-    mFitProb    = mFitResultPtr->Prob();
-    mFitNCalls  = mFitResultPtr->NCalls();
-    mFitNdf     = mFitResultPtr->Ndf();
-    mChi2       = mFitResultPtr->Chi2();
+    mIntegral.first     = mModel->Integral(mFitMin, mFitMax);
+    mAmplitude.first    = mModel->GetMaximum() - mBsl.first;
+    mFitProb            = mFitResultPtr->Prob();
+    mFitNCalls          = mFitResultPtr->NCalls();
+    mFitNdf             = mFitResultPtr->Ndf();
+    mChi2               = mFitResultPtr->Chi2();
 }
 
@@ -251,13 +278,23 @@
 
 TString Pulse::GetName(){ return mName;}
-double  Pulse::GetBsl(){ return mBsl;}
-double  Pulse::GetHeight(){ return mHeight;}
-double  Pulse::GetT0(){ return mT0;}
-double  Pulse::GetT1(){ return mT1;}
-double  Pulse::GetTau1(){ return mTau1;}
-double  Pulse::GetTau2(){ return mTau2;}
-double  Pulse::GetIntegral(){ return mIntegral;}
-double  Pulse::GetAmplitude(){ return mAmplitude;}
-int     Pulse::GetPhe(){ return mPhE;}
+double  Pulse::GetBsl(){ return mBsl.first;}
+double  Pulse::GetHeight(){ return mHeight.first;}
+double  Pulse::GetT0(){ return mT0.first;}
+double  Pulse::GetT1(){ return mT1.first;}
+double  Pulse::GetTau1(){ return mTau1.first;}
+double  Pulse::GetTau2(){ return mTau2.first;}
+double  Pulse::GetIntegral(){ return mIntegral.first;}
+double  Pulse::GetAmplitude(){ return mAmplitude.first;}
+int     Pulse::GetPhE(){ return mPhE.first;}
+double  Pulse::GetBslErr(){ return mBsl.second;}
+double  Pulse::GetHeightErr(){ return mHeight.second;}
+double  Pulse::GetT0Err(){ return mT0.second;}
+double  Pulse::GetT1Err(){ return mT1.second;}
+double  Pulse::GetTau1Err(){ return mTau1.second;}
+double  Pulse::GetTau2Err(){ return mTau2.second;}
+double  Pulse::GetIntegralErr(){ return mIntegral.second;}
+double  Pulse::GetAmplitudeErr(){ return mAmplitude.second;}
+int     Pulse::GetPhEErr(){ return mPhE.second;}
+int     Pulse::GetOrder(){ return mOrder;}
 int     Pulse::GetType(){return mType;}
 int     Pulse::GetFitMin(){return mFitMin;}
@@ -293,7 +330,8 @@
     double start    = par[2];
 //    double rising   = par[3];
+    double stop     = par[3];
     double tau1     = par[4];
     double tau2     = par[5];
-    double stop     = par[3];
+    int    phe      = par[6];
 
     // helper variables
@@ -305,5 +343,5 @@
     returnval += Heaviside(t[0]-start)*e1;
     returnval += Heaviside(t[0]-stop)*e2;
-    returnval *= height;
+    returnval *= phe*height;
     returnval += bsl;
 //    if (t[0] > start)
@@ -362,4 +400,5 @@
     double tau1     = par[3];
     double tau2     = par[4];
+    int    phe      = par[5];
 
     // helper variables
@@ -369,5 +408,5 @@
     // calculate return value
     returnval += bsl;
-    returnval += gain*e1*e2*Heaviside(t[0]-t_0);
+    returnval += phe*gain*e1*e2*Heaviside(t[0]-t_0);
 
     return returnval;
