Index: trunk/FACT++/spectrum/display.C
===================================================================
--- trunk/FACT++/spectrum/display.C	(revision 19902)
+++ trunk/FACT++/spectrum/display.C	(revision 19904)
@@ -32,5 +32,6 @@
     fx.SetLineColor(kBlack);
 
-    TF1 f0("f0", "0", 0, 90);
+    TF1 f0("f0", "[0]", 0, 90);
+    f0.SetParameter(0, 0);
     f0.SetLineStyle(kDashed);
     f0.SetLineColor(kBlack);
@@ -211,10 +212,19 @@
 
     // --------------------------------
+    f0.SetLineColor(kRed);
+    // --------------------------------
 
     c = new TCanvas("Integral Spectrum", "Integral Spectrum");
-    c->SetLogy();
+    c->Divide(2,2);
+    c->cd(4);
+    gPad->SetLogy();
     file.GetObject("Data/Energy/Differential/IntegratedSpectrum", h1);
     h1->SetLineColor(kGray);
     h1->SetMarkerColor(kGray);
+    if (h1->GetMinimum()<=0)
+    {
+        h1->SetMinimum(h1->GetMinimum(0)*0.1);
+        cout << "WARNING: Integral Spectrum contains negative flux points!\n" << endl;
+    }
     h1->DrawCopy("P");
     file.GetObject("Data/Energy/Integral/Spectrum", h1);
@@ -238,9 +248,41 @@
     //h1->DrawCopy("P same");
 
+    c->cd(1);
+    gPad->SetGridx();
+    file.GetObject("Data/Energy/Integral/SigmaFlux", h1);
+    h1->SetMaximum(5);
+    h1->SetMarkerStyle(kFullDotLarge);
+    h1->DrawCopy("P");
+    f0.SetParameter(0, 1);
+    f0.DrawCopy("same");
+
+    c->cd(3);
+    gPad->SetGridx();
+    file.GetObject("Data/Energy/Integral/BackgroundI", h1);
+    h1->Scale(5);
+    h1->SetMaximum(30);
+    h1->SetLineColor(kRed);
+    h1->DrawCopy("P");
+    file.GetObject("Data/Energy/Integral/SignalI", h1);
+    h1->DrawCopy("P same");
+    file.GetObject("Data/Energy/Integral/ExcessI", h1);
+    h1->SetLineColor(kBlue);
+    h1->DrawCopy("P same");
+
+    f0.SetParameter(0, 10);
+    f0.DrawCopy("same");
+
     // --------------------------------
 
     c = new TCanvas("Differential Spectrum", "Differential Spectrum");
-    c->SetLogy();
+    c->Divide(2,2);
+    c->cd(4);
+    gPad->SetLogy();
     file.GetObject("Data/Energy/Differential/Spectrum", h1);
+    if (h1->GetMinimum()<=0)
+    {
+        h1->SetMinimum(h1->GetMinimum(0)*0.1);
+        cout << "WARNING: Differential Spectrum contains negative flux points!\n" << endl;
+    }
     h1->DrawCopy("P");
 
@@ -261,3 +303,28 @@
     //h1->SetMarkerStyle(22);
     //h1->DrawCopy("P same");
+
+    c->cd(1);
+    gPad->SetGridx();
+    file.GetObject("Data/Energy/Differential/SigmaFlux", h1);
+    h1->SetMaximum(5);
+    h1->SetMarkerStyle(kFullDotLarge);
+    h1->DrawCopy("P");
+    f0.SetParameter(0, 1);
+    f0.DrawCopy("same");
+
+    c->cd(3);
+    gPad->SetGridx();
+    file.GetObject("Data/Energy/Differential/Background", h1);
+    h1->Scale(5);
+    h1->SetMaximum(30);
+    h1->SetLineColor(kRed);
+    h1->DrawCopy("P");
+    file.GetObject("Data/Energy/Differential/Signal", h1);
+    h1->DrawCopy("P same");
+    file.GetObject("Data/Energy/Differential/Excess", h1);
+    h1->SetLineColor(kBlue);
+    h1->DrawCopy("P same");
+
+    f0.SetParameter(0, 10);
+    f0.DrawCopy("same");
 }
Index: trunk/FACT++/spectrum/spectrum.sql
===================================================================
--- trunk/FACT++/spectrum/spectrum.sql	(revision 19902)
+++ trunk/FACT++/spectrum/spectrum.sql	(revision 19904)
@@ -74,53 +74,59 @@
       %106:join2
 ),
+Flux AS
+(
+   SELECT -- Return final result
+      *,
+
+      -- Differetial Spectrum
+
+      SimExcess/SimFluxW  AS  Efficiency,
+
+      Excess/SimExcess/Width/AreaTime  AS  ExcessRatio,
+         1/SQRT(
+             + POW(ErrExcess    / Excess,    2)
+             + POW(ErrSimExcess / SimExcess, 2)
+         )  AS  SigmaExcessRatio,
+
+
+      Excess/SimExcess*SimFluxW/Width/AreaTime  AS  Flux,
+         1/SQRT(
+             + POW(ErrExcess    / Excess,    2)
+             + POW(ErrSimExcess / SimExcess, 2)
+             + POW(ErrSimFluxW  / SimFluxW,  2)
+         )  AS  SigmaFlux,
+
+      -- Integral Spectrum
+
+      SimExcessI/SimFluxI  AS  EfficiencyI,
+
+      ExcessI/SimExcessI/AreaTime  AS  ExcessRatioI,
+         1/SQRT(
+             + POW(ErrExcessI    / ExcessI,    2)
+             + POW(ErrSimExcessI / SimExcessI, 2)
+         )  AS  SigmaExcessRatioI,
+
+
+      ExcessI/SimExcessI*SimFluxI/AreaTime  AS  FluxI,
+         1/SQRT(
+             + POW(ErrExcessI    / ExcessI,    2)
+             + POW(ErrSimExcessI / SimExcessI, 2)
+             + POW(ErrSimFluxI   / SimFluxI,   2)
+         )  AS  SigmaFluxI
+
+   FROM
+      CombinedData
+),
 Spectrum AS
 (
-SELECT -- Return final result
-   *,
+   SELECT -- Return final result
+      *,
 
-   -- Differetial Spectrum
-
-   SimExcess/SimFluxW  AS  Efficiency,
-
-   Excess/SimExcess/Width/AreaTime  AS  ExcessRatio,
-   Excess/SimExcess/Width/AreaTime
-      * SQRT(
-          + POW(ErrExcess    / Excess,    2)
-          + POW(ErrSimExcess / SimExcess, 2)
-        )  AS  ErrExcessRatio,
-
-
-   Excess/SimExcess*SimFluxW/Width/AreaTime  AS  Flux,
-   Excess/SimExcess*SimFluxW/Width/AreaTime
-      * SQRT(
-          + POW(ErrExcess    / Excess,    2)
-          + POW(ErrSimExcess / SimExcess, 2)
-          + POW(ErrSimFluxW  / SimFluxW,  2)
-        )  AS  ErrFlux,
-
-   -- Integral Spectrum
-
-   SimExcessI/SimFluxI  AS  EfficiencyI,
-
-   ExcessI/SimExcessI/AreaTime  AS  ExcessRatioI,
-   ExcessI/SimExcessI/AreaTime
-      * SQRT(
-          + POW(ErrExcessI    / ExcessI,    2)
-          + POW(ErrSimExcessI / SimExcessI, 2)
-        )  AS  ErrExcessRatioI,
-
-
-   ExcessI/SimExcessI*SimFluxI/AreaTime  AS  FluxI,
-   ExcessI/SimExcessI*SimFluxI/AreaTime
-      * SQRT(
-          + POW(ErrExcessI    / ExcessI,    2)
-          + POW(ErrSimExcessI / SimExcessI, 2)
-          + POW(ErrSimFluxI   / SimFluxI,   2)
-        )  AS  ErrFluxI
-
-FROM
-   CombinedData
-WHERE
-   Excess>0
+      ExcessRatio /SigmaExcessRatio   AS  ErrExcessRatio,
+      ExcessRatioI/SigmaExcessRatioI  AS  ErrExcessRatioI,
+      ABS(Flux)   /SigmaFlux          AS  ErrFlux,
+      ABS(FluxI)  /SigmaFluxI         AS  ErrFluxI
+   FROM
+      Flux
 )
 SELECT
