Index: /fact/tools/rootmacros/PulseTemplates/FCalcPulseTemplate.C
===================================================================
--- /fact/tools/rootmacros/PulseTemplates/FCalcPulseTemplate.C	(revision 14780)
+++ /fact/tools/rootmacros/PulseTemplates/FCalcPulseTemplate.C	(revision 14781)
@@ -97,11 +97,13 @@
 int FCalcPulseTemplate(
     TString     InRootFileName        = "20120309_017.root",
+//    TString     InRootFileName        = "20120309_032.root",
     TString     InputPath           = "analysis/analysis/FPulseTemplate/20120309_017/Overlay/",
+//    TString     InputPath           = "analysis/analysis/FPulseTemplate/20120309_032/Overlay/",
     TString     OutputRootFileName     = "test.root",
     TString     OutPutPath          = "analysis/FPulseTemplate/20120309_017/",
     int         firstpixel          = 0,
-    int         npixel              = 10,
+    int         npixel              = 100,
     int         pixelSetSize        = 200,
-    int         maxPulseOrder       = 4,
+    int         maxPulseOrder       = 1,
 //    TString     histoOptions        = "SRM",
     bool        ProduceGraphic      = true,
@@ -261,4 +263,5 @@
     TH1D hIntegral[maxPulseOrder];
     TH1D hAmplitude[maxPulseOrder];
+    TH1D hRiseTime[maxPulseOrder];
 
     //Lopp over pulse order configure distribution histograms
@@ -300,5 +303,5 @@
         title.Append(i);
         hIntegral[i].SetNameTitle(title, title);
-        hIntegral[i].SetBins(400, (i+1)*99.5, (i+1)*499.5);
+        hIntegral[i].SetBins(500, (i+1)*-0.5, (i+1)*499.5);
 
         //Amplitude
@@ -307,5 +310,41 @@
         hAmplitude[i].SetNameTitle(title, title);
         hAmplitude[i].SetBins(400, (i+1)*4.95, (i+1)*24.95);
-    }
+
+        //hRiseTime
+        title = "hRiseTime";
+        title.Append(i);
+        hRiseTime[i].SetNameTitle(title, title);
+        hRiseTime[i].SetBins(20, -0, 10);
+    }
+
+    // Error Histograms
+
+    TH1D hMedianErrors[maxPulseOrder];
+    TH1D hMeanErrors[maxPulseOrder];
+    TH1D hMaxErrors[maxPulseOrder];
+
+    //Lopp over pulse order configure distribution histograms
+    for (int i = 0; i<maxPulseOrder; i++)
+    {
+        //hMedianErrors
+        TString title;
+        title = "hMedianErrors";
+        title.Append(i);
+        hMedianErrors[i].SetNameTitle(title, title);
+        hMedianErrors[i].SetBins(300, -0.5, 300.5);
+
+        //hMeanErrors
+        title = "hMeanErrors";
+        title.Append(i);
+        hMeanErrors[i].SetNameTitle(title, title);
+        hMeanErrors[i].SetBins(300, -0.5, 300.5);
+
+        //hMaxErrors
+        title = "hMaxErrors";
+        title.Append(i);
+        hMaxErrors[i].SetNameTitle(title, title);
+        hMaxErrors[i].SetBins(300, -0.5, 300.5);
+    }
+
 
 //-----------------------------------------------------------------------------
@@ -379,5 +418,5 @@
 
         //--------------------------------------------------------------------
-        // Loops over every Pixel of a Set of Pixels
+        // Loop over every Pixel of a Set of Pixels
         //--------------------------------------------------------------------
         for ( int pixelID = firstPixelOfSet;
@@ -492,4 +531,5 @@
                             "Maximum",
                             pulse_order,
+                            10,
                             verbosityLevel
                             );
@@ -505,4 +545,5 @@
                             "Edge",
                             pulse_order,
+                            10,
                             verbosityLevel
                             );
@@ -743,13 +784,13 @@
                 Pulse* pulseFits[6];
 
-                pulses.cd(1);
+//                pulses.cd(1);
                 Pulse maxMaxPulse("maxMaxPulse", pixel[pixelID]->hPixelMax[pulse_order], "Q", 1);
                 pulseFits[0] = &maxMaxPulse;
 
-                pulses.cd(2);
+//                pulses.cd(2);
                 Pulse maxMedianPulse("maxMedianPulse", pixel[pixelID]->hPixelMedian[pulse_order], "Q",1);
                 pulseFits[1] = &maxMedianPulse;
 
-                pulses.cd(3);
+//                pulses.cd(3);
                 Pulse maxMeanPulse("maxMeanPulse", pixel[pixelID]->hPixelMean[pulse_order], "Q",1);
                 pulseFits[2] = &maxMeanPulse;
@@ -778,4 +819,43 @@
                 }
                 //-------------------------------------
+                // Fill Error Histogramms
+                //-------------------------------------
+
+                for (int i = pixel[pixelID]->hPixelEdgeMedian[pulse_order]->GetXaxis()->GetFirst();
+                     i <= pixel[pixelID]->hPixelEdgeMedian[pulse_order]->GetXaxis()->GetLast();
+                     i++)
+                {
+
+                    hMedianErrors[pulse_order].SetBinContent(
+                                i,
+                                pixel[pixelID]->hPixelEdgeMedian[pulse_order]->GetBinError(i)
+                                );
+
+                    hMeanErrors[pulse_order].SetBinContent(
+                                i,
+                                pixel[pixelID]->hPixelEdgeMean[pulse_order]->GetBinError(i)
+                                );
+
+                    hMaxErrors[pulse_order].SetBinContent(
+                                i,
+                                pixel[pixelID]->hPixelEdgeMax[pulse_order]->GetBinError(i)
+                                );
+                }
+
+                if (ProduceGraphic && debugPixel)
+                {
+                    int current_order = 0;
+                    pulses.cd(1);
+                    hMaxErrors[current_order].Draw();
+
+                    pulses.cd(2);
+                    hMedianErrors[current_order].Draw();
+
+                    pulses.cd(3);
+                    hMeanErrors[current_order].Draw();
+                    pulses.Update();
+                }
+
+                //-------------------------------------
                 // Fill Distribution Histogramms
                 //-------------------------------------
@@ -788,7 +868,8 @@
                 hIntegral[pulse_order].Fill(    edgeMedianPulse.GetIntegral());
                 hAmplitude[pulse_order].Fill(   edgeMedianPulse.GetAmplitude());
+                hRiseTime[pulse_order].Fill(    edgeMedianPulse.GetRiseTime());
 
                 //-------------------------------------
-                // Fill Distribution Containers
+                // Fill Distribution Graphs
                 //-------------------------------------
 
@@ -901,9 +982,13 @@
                 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
                 timer.TurnOn();
-                TString input = Getline("Type 'q' to exit, <return> to go on: ");
+                TString input = Getline("Type 'q' to exit, Type 's' to exit set, <return> to go on: ");
                 timer.TurnOff();
                 if (input=="q\n")
                 {
                     return(0);
+                }
+                if (input=="s\n")
+                {
+                    break;
                 }
             }
@@ -979,4 +1064,5 @@
                     "Maximum",
                     pulse_order,
+                    10,
                     verbosityLevel
                     );
@@ -997,4 +1083,5 @@
                     "Edge",
                     pulse_order,
+                    10,
                     verbosityLevel
                     );
@@ -1113,4 +1200,6 @@
             cgpDistributions[i]->cd(7);
             hAmplitude[i].Draw();
+            cgpDistributions[i]->cd(8);
+            hRiseTime[i].Draw();
 
 
