Index: trunk/FACT++/src/spectrum.cc
===================================================================
--- trunk/FACT++/src/spectrum.cc	(revision 19886)
+++ trunk/FACT++/src/spectrum.cc	(revision 19887)
@@ -46,5 +46,5 @@
         const double stp = (max-min)/cnt;
 
-        for (int i=0; i<=cnt; i++)
+        for (size_t i=0; i<=cnt; i++)
             emplace(min+i*stp);
     }
@@ -363,5 +363,5 @@
 
     const auto vec = bins.vec();
-    for (int i=1; i<vec.size()-2; i++)
+    for (size_t i=1; i<vec.size()-2; i++)
         query1 << "  ( " << i << ", " << vec[i-1] << ", " << vec[i] << " ),\n";
     query1 << "  ( " << vec.size()-2 << ", " << vec[vec.size()-2] << ", " << vec[vec.size()-1] << " )\n";
@@ -376,7 +376,28 @@
 // ----------------------------- ROOT Histogram -----------------------------
 
+/*
+A bit of hackery, so just sharing for fun.
+
+   #define with(T, ...) ([&]{ T ${}; __VA_ARGS__; return $; }())
+
+And use it like:
+
+   MyFunction(with(Params,
+      $.Name = "Foo Bar",
+      $.Age  = 18
+   ));
+
+which expands to:
+
+   MyFunction(([&] {
+      Params ${};
+    $.Name = "Foo Bar", $.Age = 18;
+    return $;
+   }()));
+*/
 struct Histogram
 {
     // A workaround to be able to set a default also in C++11
+    /*
     template<typename T, T def>
     struct Value
@@ -386,5 +407,5 @@
         Value(const T &_t) : t(_t) { }
         operator T() const { return t; }
-    };
+    };*/
 
     string  name;
@@ -401,5 +422,6 @@
     string  axisy;
     string  axisz;
-    Value<bool,true> stats;
+    bool    stats;
+    //Value<bool,true> stats;
 };
 
@@ -468,5 +490,5 @@
         const uint32_t x = row["X"];
         const double   v = row["V"];
-        if (x>h->GetNbinsX()+1)
+        if (x>uint32_t(h->GetNbinsX()+1))
             continue;
 
@@ -474,5 +496,5 @@
         {
             const uint32_t y = row["Y"];
-            if (y>h->GetNbinsY()+1)
+            if (y>uint32_t(h->GetNbinsY()+1))
                 continue;
 
@@ -487,5 +509,5 @@
                 h->SetBinError(x, double(row["E"]));
             }
-            catch (const mysqlpp::BadFieldName &e)
+            catch (const mysqlpp::BadFieldName &)
             {
             }
@@ -548,5 +570,4 @@
 int main(int argc, const char* argv[])
 {
-
     Time start;
 
@@ -1051,39 +1072,52 @@
 
     WriteHistogram(connection, {
-             .dir      = "Zd",
              .name     = "OnTime",
              .title    = "Effective on time",
+             .dir      = "Zd",
              .binningx = binning_theta,
+             .binningy = {},
              .table    = "ThetaHist",
              .x        = ".theta",
+             .y        = "",
              .v        = "OnTime",
+             .err      = "",
              .axisx    = "Zenith Distance #theta [#circ]",
-             .axisy    = "Eff. on time [s]"
-         });
-
-    WriteHistogram(connection, {
-             .dir      = "Zd",
+             .axisy    = "Eff. on time [s]",
+             .axisz    = "",
+             .stats    = true
+         });
+
+    WriteHistogram(connection, {
              .name     = "CountN",
              .title    = "Simulated Zenith Distance",
+             .dir      = "Zd",
              .binningx = binning_theta,
+             .binningy = {},
              .table    = "ThetaHist",
              .x        = ".theta",
+             .y        = "",
              .v        = "CountN",
              .err      = "ErrCountN",
              .axisx    = "Zenith Distance #theta [#circ]",
-             .axisy    = "Counts"
-         });
-
-    WriteHistogram(connection, {
-             .dir      = "Zd",
+             .axisy    = "Counts",
+             .axisz    = "",
+             .stats    = true
+         });
+
+    WriteHistogram(connection, {
              .name     = "ZdWeight",
              .title    = "Zenith Distance Weight",
+             .dir      = "Zd",
              .binningx = binning_theta,
+             .binningy = {},
              .table    = "ThetaHist",
              .x        = ".theta",
+             .y        = "",
              .v        = "ZdWeight",
              .err      = "ErrZdWeight",
              .axisx    = "Zenith Distance #theta [#circ]",
-             .axisy    = "Weight [s]"
+             .axisy    = "Weight [s]",
+             .axisz    = "",
+             .stats    = true
          });
 
@@ -1523,10 +1557,14 @@
              .dir      = "Eest/Measurement",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "Signal",
              .err      = "ErrSignal",
              .axisx    = "Energy lg(E_{est}/GeV)",
-             .axisy    = "Counts"
+             .axisy    = "Counts",
+             .axisz    = "",
+             .stats    = true
          });
 
@@ -1536,10 +1574,14 @@
              .dir      = "Eest/Measurement",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "Background",
              .err      = "ErrBackground",
              .axisx    = "Energy lg(E_{est}/GeV)",
-             .axisy    = "Counts"
+             .axisy    = "Count",
+             .axisz    = "",
+             .stats    = true
          });
 
@@ -1549,10 +1591,14 @@
              .dir      = "Eest/Measurement",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "Excess",
              .err      = "ErrExcess",
              .axisx    = "Energy lg(E_{est}/GeV)",
-             .axisy    = "Signal - Background (Counts)"
+             .axisy    = "Signal - Background (Counts)",
+             .axisz    = "",
+             .stats    = true
          });
 
@@ -1562,10 +1608,14 @@
              .dir      = "Eest/Simulation/Weighted",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "SignalW",
              .err      = "ErrSignalW",
              .axisx    = "Energy lg(E_{est}/GeV)",
-             .axisy    = "Weighted"
+             .axisy    = "Weighted",
+             .axisz    = "",
+             .stats    = true
          });
 
@@ -1575,10 +1625,14 @@
              .dir      = "Eest/Simulation/Weighted",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "BackgroundW",
              .err      = "ErrBackgroundW",
              .axisx    = "Energy lg(E_{est}/GeV)",
-             .axisy    = "Weighted"
+             .axisy    = "Weighted",
+             .axisz    = "",
+             .stats    = true
          });
 
@@ -1588,10 +1642,14 @@
              .dir      = "Eest/Simulation/Weighted",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "ExcessW",
              .err      = "ErrExcessW",
              .axisx    = "Energy lg(E_{est}/GeV)",
-             .axisy    = "Signal - Background (Weighted)"
+             .axisy    = "Signal - Background (Weighted)",
+             .axisz    = "",
+             .stats    = true
          });
 
@@ -1601,62 +1659,82 @@
              .dir      = "Eest/Measurement",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "Significance",
+             .err      = "",
              .axisx    = "Energy lg(E_{est}/GeV)",
-             .axisy    = "Li/Ma Significance"
-         });
-
-    WriteHistogram(connection, {
-             .dir      = "Eest",
+             .axisy    = "Li/Ma Significance",
+             .axisz    = "",
+             .stats    = true
+         });
+
+    WriteHistogram(connection, {
              .name     = "Bias",
              .title    = "Energy Bias",
+             .dir      = "Eest",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "Bias",
              .err      = "Resolution",
              .axisx    = "Energy lg(E_{sim}/GeV)",
              .axisy    = "lg(E_{est}/E_{sim})",
+             .axisz    = "",
              .stats    = false
          });
 
     WriteHistogram(connection, {
-             .dir      = "Eest",
              .name     = "Resolution",
              .title    = "Energy Resolution",
+             .dir      = "Eest",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "Resolution",
+             .err      = "",
              .axisx    = "Energy lg(E_{sim}/GeV)",
              .axisy    = "#sigma(lg(E_{est}/E_{sim}))",
+             .axisz    = "",
              .stats    = false
          });
 
     WriteHistogram(connection, {
-             .dir      = "Eest/Efficiency",
              .name     = "EfficiencyN",
              .title    = "Efficiency (Counts)",
+             .dir      = "Eest/Efficiency",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "EfficiencyN",
              .err      = "ErrEfficiencyN",
              .axisx    = "Energy lg(E_{sim}/GeV)",
-             .axisy    = "Efficiency"
-         });
-
-    WriteHistogram(connection, {
-             .dir      = "Eest/Efficiency",
+             .axisy    = "Efficiency",
+             .axisz    = "",
+             .stats    = true
+         });
+
+    WriteHistogram(connection, {
              .name     = "EfficiencyW",
              .title    = "Efficiency (Weighted)",
+             .dir      = "Eest/Efficiency",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = ".",
              .v        = "EfficiencyW",
              .err      = "ErrEfficiencyW",
              .axisx    = "Energy lg(E_{sim}/GeV)",
-             .axisy    = "Efficiency"
+             .axisy    = "Efficiency",
+             .axisz    = "",
+             .stats    = true
          });
 
@@ -1664,11 +1742,15 @@
              .name     = "Spectrum",
              .title    = "Differential Energy Spectrum",
+             .dir      = "",
              .binningx = binning_eest,
+             .binningy = {},
              .table    = "Spectrum",
              .x        = ".energy",
+             .y        = "",
              .v        = "Flux",
              .err      = "ErrFlux",
              .axisx    = "Energy lg(E/GeV)",
              .axisy    = "dN/dE [cm^{-2} s^{-1} TeV^{-1}]",
+             .axisz    = "",
              .stats    = false
          });
@@ -1797,10 +1879,14 @@
              .dir      = "Esim/Simulation/Weighted",
              .binningx = binning_esim,
+             .binningy = {},
              .table    = "Threshold",
              .x        = ".energy",
+             .y        = "",
              .v        = "ThresholdW",
              .err      = "ErrThresholdW",
              .axisx    = "Energy lg(E_{sim}/GeV)",
-             .axisy    = "Weighted Counts"
+             .axisy    = "Weighted Counts",
+             .axisz    = "",
+             .stats    = true
          });
 
@@ -1810,10 +1896,14 @@
              .dir      = "Esim/Simulation/Counts",
              .binningx = binning_esim,
+             .binningy = {},
              .table    = "Threshold",
              .x        = ".energy",
+             .y        = "",
              .v        = "ThresholdN",
              .err      = "ErrThresholdN",
              .axisx    = "Energy lg(E_{sim}/GeV)",
-             .axisy    = "Counts"
+             .axisy    = "Counts",
+             .axisz    = "",
+             .stats    = true
          });
 
@@ -1821,38 +1911,49 @@
              .name     = "SimSpectrumW",
              .title    = "Weighted Simulated Excess Spectrum",
+             .dir      = "Esim/Simulation/Weighted",
              .binningx = binning_esim,
-             .dir      = "Esim/Simulation/Weighted",
+             .binningy = {},
              .table    = "Threshold",
              .x        = ".energy",
+             .y        = "",
              .v        = "Flux",
              .err      = "ErrFlux",
              .axisx    = "Energy lg(E_{sim}/GeV)",
-             .axisy    = "dN/dE [cm^{-2} s^{-1} TeV^{-1}]"
-         });
-
-    WriteHistogram(connection, {
-             .dir      = "Esim",
+             .axisy    = "dN/dE [cm^{-2} s^{-1} TeV^{-1}]",
+             .axisz    = "",
+             .stats    = true
+         });
+
+    WriteHistogram(connection, {
              .name     = "Bias",
              .title    = "Energy Bias",
+             .dir      = "Esim",
              .binningx = binning_esim,
+             .binningy = {},
              .table    = "Threshold",
              .x        = ".energy",
+             .y        = "",
              .v        = "Bias",
              .err      = "Resolution",
              .axisx    = "Energy lg(E_{sim}/GeV)",
              .axisy    = "lg(E_{est}/E_{sim})",
+             .axisz    = "",
              .stats    = false
          });
 
     WriteHistogram(connection, {
-             .dir      = "Esim",
              .name     = "Resolution",
              .title    = "Energy Resolution",
+             .dir      = "Esim",
              .binningx = binning_esim,
+             .binningy = {},
              .table    = "Threshold",
              .x        = ".energy",
+             .y        = "",
              .v        = "Resolution",
+             .err      = "",
              .axisx    = "Energy lg(E_{sim}/GeV)",
              .axisy    = "#sigma(lg(E_{est}/E_{sim}))",
+             .axisz    = "",
              .stats    = false
          });
@@ -1912,4 +2013,5 @@
              .name     = "MigrationN",
              .title    = "Energy Migration",
+             .dir      = "",
              .binningx = binning_esim,
              .binningy = binning_eest,
@@ -1918,4 +2020,5 @@
              .y        = ".energyest",
              .v        = "MigrationN",
+             .err      = "",
              .axisx    = "Energy lg(E_{sim}/GeV)",
              .axisy    = "Energy lg(E_{est}/GeV)",
@@ -1927,4 +2030,5 @@
              .name     = "MigrationW",
              .title    = "Energy Migration",
+             .dir      = "",
              .binningx = binning_esim,
              .binningy = binning_eest,
@@ -1933,4 +2037,5 @@
              .y        = ".energyest",
              .v        = "MigrationW",
+             .err      = "",
              .axisx    = "Energy lg(E_{sim}/GeV)",
              .axisy    = "Energy lg(E_{est}/GeV)",
