Index: fact/tools/rootmacros/PulseTemplates/pixel.C
===================================================================
--- fact/tools/rootmacros/PulseTemplates/pixel.C	(revision 13597)
+++ fact/tools/rootmacros/PulseTemplates/pixel.C	(revision 13603)
@@ -34,4 +34,8 @@
     hPixelMedian = new TH1F*[mMaxPulseOrder];
     hPixelMean  = new TH1F*[mMaxPulseOrder];
+
+    hPixelEdgeMax  = new TH1F*[mMaxPulseOrder];
+    hPixelEdgeMedian = new TH1F*[mMaxPulseOrder];
+    hPixelEdgeMean  = new TH1F*[mMaxPulseOrder];
 
     hList           = new TObjArray;
@@ -381,4 +385,76 @@
 //----------------------------------------------------------------------------
 
+void
+Pixel::BookEdgeTemplateHistos()
+{
+    if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
+    for (int order = 0; order < mMaxPulseOrder; order++)
+    {
+        if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMax", order) << endl;
+        hPixelEdgeMax[order]=new TH1F(
+                    HistoName("hPixelEdgeMax", order),
+                    HistoTitle("Maximum value of each slice in overlay plot of", order),
+                    mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
+                    (-1*mPixelOverlayXaxisLeft)-0.5,
+                    mPixelOverlayXaxisRight-0.5
+                    );
+
+        hPixelEdgeMax[order]->SetAxisRange(
+                    mBSLMean - 5,
+                    (mGainMean*(order+1)) + 10,
+                    "Y");
+        hPixelEdgeMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
+        hPixelEdgeMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
+        //hMaxProfile->SetBit(TH2F::kCanRebin);
+        hPixelEdgeMax[order]->SetStats(mStats);
+        hList->Add( hPixelEdgeMax[order] );
+
+//------------------------------------------------------------------------
+
+        if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMean", order) << endl;
+        hPixelEdgeMean[order] = new TH1F(
+                    HistoName("hPixelEdgeMean", order),
+                    HistoTitle("Mean value of each slice in overlay plot of", order),
+                    mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
+                    (-1*mPixelOverlayXaxisLeft)-0.5,
+                    mPixelOverlayXaxisRight-0.5
+                    );
+        hPixelEdgeMean[order]->SetLineColor(kBlue);
+        hPixelEdgeMean[order]->SetAxisRange(
+                    mBSLMean - 5,
+                    (mGainMean*(order+1)) + 10,
+                    "Y");
+        hPixelEdgeMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
+        hPixelEdgeMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
+        hPixelEdgeMean[order]->SetStats(mStats);
+        hList->Add( hPixelEdgeMean[order] );
+
+ //------------------------------------------------------------------------
+
+        if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMedian", order) << endl;
+        hPixelEdgeMedian[order] = new TH1F(
+                    HistoName("hPixelEdgeMedian", order),
+                    HistoTitle("Median value of each slice in overlay plot of", order),
+                    mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
+                    (-1*mPixelOverlayXaxisLeft)-0.5,                 //xlow
+                    mPixelOverlayXaxisRight-0.5                     //xup
+                    );
+        hPixelEdgeMedian[order]->SetLineColor(kRed);
+        hPixelEdgeMedian[order]->SetAxisRange(
+                    mBSLMean - 5,
+                    (mGainMean*(order+1)) + 10,
+                    "Y");
+        hPixelEdgeMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
+        hPixelEdgeMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
+        //hMaxProfile->SetBit(TH2F::kCanRebin);
+        hPixelEdgeMedian[order]->SetStats(mStats);
+        hList->Add( hPixelEdgeMedian[order] );
+
+    }
+    if (mVerbosityLevel > 2) cout << "...done" << endl;
+}
+//end of BookEdgeTemplateHistos
+//----------------------------------------------------------------------------
+
 
 void
@@ -461,4 +537,27 @@
         pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
         hPixelMean[pulse_order]->Draw();
+
+    }
+}
+// end of DrawTemplateHistograms
+//----------------------------------------------------------------------------
+
+void
+Pixel::DrawEdgeTemplateHistograms(
+        TCanvas**    pixelCanvas,
+        int*        histoFrameNr
+        )
+{
+    if (mVerbosityLevel > 2) cout << endl << "...drawing Template histograms" ;
+    for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
+    {
+        pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
+        hPixelEdgeMax[pulse_order]->Draw();
+
+        pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
+        hPixelEdgeMedian[pulse_order]->Draw();
+
+        pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
+        hPixelEdgeMean[pulse_order]->Draw();
 
     }
@@ -551,5 +650,5 @@
                                           << "\t\t...deleting hRisingEdgeToMax"
                                           << mChid << "_" << order ;
-//            delete hRisingEdgeToMax[order];
+            delete hRisingEdgeToMax[order];
         }
 
@@ -560,5 +659,5 @@
                                           << mChid << "_" << order ;
 
-//            delete hPosOfMax[order];
+            delete hPosOfMax[order];
         }
 
@@ -568,5 +667,6 @@
     if (mOptions.Contains("S"))
     {
-        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hSlopeRisingEdge";
+        if (mVerbosityLevel > 3)
+            cout << endl << "\t\t...deleting hSlopeRisingEdge";
         delete[] hSlopeRisingEdge;
         hSlopeRisingEdge = NULL;
@@ -575,5 +675,6 @@
     if (mOptions.Contains("R"))
     {
-        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hRisingEdgeToMax";
+        if (mVerbosityLevel > 3)
+            cout << endl << "\t\t...deleting hRisingEdgeToMax";
         delete[] hRisingEdgeToMax;
         hRisingEdgeToMax = NULL;
@@ -582,5 +683,6 @@
     if (mOptions.Contains("M"))
     {
-        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPosOfMax";
+        if (mVerbosityLevel > 3)
+            cout << endl << "\t\t...deleting hPosOfMax";
         delete[] hPosOfMax;
         hPosOfMax = NULL;
@@ -636,4 +738,54 @@
     delete[] hPixelMean;
     hPixelMean = NULL;
+}
+// end of DeleteTemplateHistos
+//----------------------------------------------------------------------------
+
+void
+Pixel::DeleteEdgeTemplateHistos()
+{
+    if (mVerbosityLevel > 2)
+    {
+        cout << endl
+             << "\t...delete current template histograms of Pixel# " << mChid;
+    }
+    for (int order = 0;
+         order < mMaxPulseOrder;
+         order ++)
+    {
+        if (mVerbosityLevel > 3)
+        cout << endl << "\t\t...deleting hPixelEdgeMax"
+                                      << mChid << "_" << order
+                                      << " hPixelEdgeMax[order] adr " << hPixelEdgeMax[order]
+                                      << " hPixelEdgeMax adr " << hPixelEdgeMax
+                                         ;
+
+        delete hPixelEdgeMax[order];
+        hPixelEdgeMax[order] = NULL;
+
+        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian"
+                                      << mChid << "_" << order ;
+        delete hPixelEdgeMedian[order];
+        hPixelEdgeMedian[order] = NULL;
+
+        if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean"
+                                      << mChid << "_" << order ;
+        delete hPixelEdgeMean[order];
+        hPixelEdgeMean[order] = NULL;
+
+    }
+    if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
+
+    if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMax";
+    delete[] hPixelEdgeMax;
+    hPixelEdgeMax = NULL;
+
+    if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian";
+    delete[] hPixelEdgeMedian;
+    hPixelEdgeMedian = NULL;
+
+    if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean";
+    delete[] hPixelEdgeMean;
+    hPixelEdgeMean = NULL;
 }
 // end of DeleteTemplateHistos
