Index: /fact/tools/rootmacros/PulseTemplates/pixel.C
===================================================================
--- /fact/tools/rootmacros/PulseTemplates/pixel.C	(revision 14062)
+++ /fact/tools/rootmacros/PulseTemplates/pixel.C	(revision 14063)
@@ -1,3 +1,5 @@
 #include <iostream>
+#include <TMath.h>
+#include <TF1.h>
 
 #include "rootfilehandler.h"
@@ -52,4 +54,10 @@
 
     hList           = new TList();
+
+    if (mOptions.Contains("C") )
+    {
+        hChi2EdgetoMax = new TH1F*[mMaxPulseOrder];
+    }
+
     if (options.Contains("L"))
     {
@@ -60,4 +68,10 @@
        BookPixelHistos();
     }
+
+    if (mOptions.Contains("C"))
+    {
+        BookDistributionHistos();
+    }
+
     BookTemplateHistos();
     BookEdgeTemplateHistos();
@@ -227,11 +241,16 @@
     {
         pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
+        hMaxOverlay[pulse_order]->Draw("COLZ");
+
+        pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
         hPixelMax[pulse_order]->Draw();
 
-        pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
+        pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
         hPixelMedian[pulse_order]->Draw();
 
-        pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
+        pixelCanvas[pulse_order]->cd( histoFrameNr[3] );
         hPixelMean[pulse_order]->Draw();
+//        hPixelMax[pulse_order]->Draw("SAME");
+//        hPixelMedian[pulse_order]->Draw("SAME");
 
     }
@@ -249,12 +268,17 @@
     for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
     {
-        pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
+        pixelCanvas[pulse_order]->cd( histoFrameNr[4] );
+        hEdgeOverlay[pulse_order]->Draw("COLZ");
+
+        pixelCanvas[pulse_order]->cd( histoFrameNr[5] );
         hPixelEdgeMax[pulse_order]->Draw();
 
-        pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
+        pixelCanvas[pulse_order]->cd( histoFrameNr[6] );
         hPixelEdgeMedian[pulse_order]->Draw();
 
-        pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
+        pixelCanvas[pulse_order]->cd( histoFrameNr[7] );
         hPixelEdgeMean[pulse_order]->Draw();
+//        hPixelEdgeMax[pulse_order]->Draw("SAME");
+//        hPixelEdgeMedian[pulse_order]->Draw("SAME");
 
     }
@@ -526,4 +550,24 @@
             }
 
+            if (mOptions.Contains("C"))
+            {
+                if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl;
+                hChi2EdgetoMax[order] = new TH1F (
+                            HistoName("hChi2EdgetoMax", order),
+                            HistoTitle("Distribution of CHI2 comparison of Edge and Max", order),
+                            600,
+                            -299,
+                            300
+                            );
+                hChi2EdgetoMax[order]->SetAxisRange(
+                                    -1,
+                                    7,
+                                    "X");
+                hChi2EdgetoMax[order]->GetXaxis()->SetTitle( "p-Value" );
+                hChi2EdgetoMax[order]->GetYaxis()->SetTitle( "counts" );
+                hChi2EdgetoMax[order]->SetStats(mStats);
+//                hList->Add( hChi2EdgetoMax[order] );
+            }
+
             if (mVerbosityLevel > 2) cout << "...done" << endl;
         }
@@ -1061,3 +1105,19 @@
 
 
-
+void
+Pixel::ShiftHistoInY(
+        TH1*                histo,
+        float               shift
+        )
+{
+    int min_bin = histo->GetXaxis()->GetFirst();
+    int max_bin = histo->GetXaxis()->GetLast();
+
+    for (int bin = min_bin; bin <= max_bin; bin++)
+    {
+        histo->AddBinContent( bin, shift);
+    }
+
+}
+
+
Index: /fact/tools/rootmacros/PulseTemplates/pixel.h
===================================================================
--- /fact/tools/rootmacros/PulseTemplates/pixel.h	(revision 14062)
+++ /fact/tools/rootmacros/PulseTemplates/pixel.h	(revision 14063)
@@ -23,4 +23,5 @@
 #include <TString.h>
 #include <TFile.h>
+
 #include "TCanvas.h"
 #include "TObjArray.h"
@@ -107,4 +108,5 @@
     void DeleteEdgeTemplateHistos();
 
+    //Histogram appeareance
     void
     MakeTH1Pretty(
@@ -161,4 +163,17 @@
     virtual TString CsvFileName(TString, TString, int );
 
+    //fit funcitons
+//    void FitFallingEdge(
+//            TString             histoType,   //Max or Edge
+//            double ,
+//            double ,
+//            TH1F*               hMaximumTemp
+//            );
+
+//    double
+//    PolExp(double* x, double* par);
+
+    //shifting
+    void ShiftHistoInY(TH1*, float);
 // ACCESS
 // INQUIRY
@@ -183,4 +198,5 @@
     TH1I**          hRisingEdgeToMax;
     TH1I**          hPosOfMax;
+    TH1F**          hChi2EdgetoMax;
 
     //Max Overlay Template Histos
