Index: trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 8695)
+++ trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 8701)
@@ -54,4 +54,5 @@
 // Container
 #include "MH3.h"
+#include "MHn.h"
 #include "MBinning.h"
 #include "MDataSet.h"
@@ -595,4 +596,5 @@
     // Compare both histograms
     *fLog << inf << "Comparing theta distributions for data and MCs." << endl;
+
     const Double_t prob = proj.Chi2Test(theta, "P");
     if (prob==1)
@@ -1235,4 +1237,61 @@
     line.SetLineStyle(kDashed);
     line.DrawLine(cut.GetBinLowEdge(1), 50, cut.GetBinLowEdge(cut.GetNbinsX()+1), 50);
+}
+
+void MJSpectrum::SetupHistEvtDist(MHn &hist) const
+{
+    hist.AddHist("MMcEvt.fEnergy");
+    hist.InitName("EnergyDist;EnergyEst");
+    hist.InitTitle("Unweighted event distribution (Real statistics);E [GeV];Counts;");
+
+    hist.AddHist("MPointingPos.fZd");
+    hist.InitName("ZdDist;Theta");
+    hist.InitTitle("Unweighted event distribution (Real statistics);Zd [\\circ];Counts;");
+}
+
+void MJSpectrum::SetupHistEnergyEst(MHn &hist) const
+{
+    hist.AddHist("MHillas.fSize", "log10(MEnergyEst.fVal)-log10(MMcEvt.fEnergy)");
+    hist.InitName("ResSize;Size;EnergyResidual");
+    hist.InitTitle(";S [phe];\\Delta lg E;");
+    hist.SetDrawOption("colz profx");
+
+    hist.AddHist("MPointingPos.fZd", "log10(MEnergyEst.fVal)-log10(MMcEvt.fEnergy)");
+    hist.InitName("ResTheta;Theta;EnergyResidual");
+    hist.InitTitle(";Zd [\\circ];\\Delta lg E;");
+    hist.SetDrawOption("colz profx");
+
+    hist.AddHist("MNewImagePar.fLeakage1", "log10(MEnergyEst.fVal)-log10(MMcEvt.fEnergy)");
+    hist.InitName("ResLeak;Leakage;EnergyResidual");
+    hist.InitTitle(";Leak;\\Delta lg E;");
+    hist.SetDrawOption("colz profx");
+
+    hist.AddHist("MHillasSrc.fDist*3.37e-3", "log10(MEnergyEst.fVal)-log10(MMcEvt.fEnergy)");
+    hist.InitName("ResDist;Dist;EnergyResidual");
+    hist.InitTitle(";D [\\circ];\\Delta lg E;");
+    hist.SetDrawOption("colz profx");
+}
+
+void MJSpectrum::SetupHistDisp(MHn &hist) const
+{
+    hist.AddHist("MHillas.fSize", "MHillasSrc.fDist*3.37e-3/Disp.fVal");
+    hist.InitName("ResSize;Size;Xi");
+    hist.InitTitle(";S [phe];\\Delta Xi;");
+    hist.SetDrawOption("colz profx");
+
+    hist.AddHist("MPointingPos.fZd", "MHillasSrc.fDist*3.37e-3/Disp.fVal");
+    hist.InitName("ResTheta;Theta;Xi");
+    hist.InitTitle(";Zd [\\circ];\\Delta Xi;");
+    hist.SetDrawOption("colz profx");
+
+    hist.AddHist("MNewImagePar.fLeakage1", "MHillasSrc.fDist*3.37e-3/Disp.fVal");
+    hist.InitName("ResLeak;Leakage;Xi");
+    hist.InitTitle(";Leak;\\Delta Xi;");
+    hist.SetDrawOption("colz profx");
+
+    hist.AddHist("MHillasExt.fSlopeLong*sign(MHillasSrc.fCosDeltaAlpha)/3.37e-3", "MHillasSrc.fDist*3.37e-3/Disp.fVal");
+    hist.InitName("ResSlope;Slope;Xi");
+    hist.InitTitle(";Slope;\\Delta Xi;");
+    hist.SetDrawOption("colz profx");
 }
 
@@ -1339,6 +1398,6 @@
     // MC distribution. Unfortunately this must be done manually
     // because we are multiplying column by column
-    for (int y=0; y<hist.GetNbinsY(); y++)
-        for (int x=0; x<hist.GetNbinsX(); x++)
+    for (int y=0; y<=hist.GetNbinsY()+1; y++)
+        for (int x=0; x<=hist.GetNbinsX()+1; x++)
         {
             hist.SetBinContent(x, y, hist.GetBinContent(x, y)*htheta.GetBinContent(x));
@@ -1421,8 +1480,39 @@
     fill5.SetNameTab("Threshold");
 
+/*
     MH3 henergy("MMcEvt.fEnergy");
     henergy.SetName("EventDist;EnergyEst");
     henergy.SetTitle("Unweighted event distribution (Real statistics);E [GeV];Counts;");
     henergy.Sumw2();
+    */
+
+    // ---------------------------------------------------------
+
+    MBinning binsA(50, 10, 100000, "BinningSize",           "log");
+    MBinning binsB(50, -1, 1,      "BinningEnergyResidual", "lin");
+    MBinning binsC(50,  0, 0.3,    "BinningLeakage",        "lin");
+    MBinning binsD(50,  0, 3,      "BinningXi",             "lin");
+
+    plist.AddToList(&binsA);
+    plist.AddToList(&binsB);
+    plist.AddToList(&binsC);
+    plist.AddToList(&binsD);
+
+    MHn heest("Energy", "Energy Residual (lg E_{est} - lg E_{mc})");
+    SetupHistEnergyEst(heest);
+
+    MHn hdisp("Disp", "Xi (Dist/Disp)");
+    SetupHistDisp(hdisp);
+
+    MHn henergy("EvtDist");
+    SetupHistEvtDist(henergy);
+
+    MFillH fill4b(&heest, "", "FillEnergyResidual");
+    fill4b.SetWeight();
+
+    MFillH fill4c(&hdisp, "", "FillDispResidual");
+    fill4c.SetWeight();
+
+    // ---------------------------------------------------------
 
     MH3 hsize("MHillas.fSize");
@@ -1433,4 +1523,6 @@
     plist.AddToList(&hsize);
     plist.AddToList(&bins);
+
+    // ---------------------------------------------------------
 
     MFillH fill0a(&henergy, "", "FillEventDist");
@@ -1461,4 +1553,7 @@
     fill8a.SetWeight();
 
+    // FIXME: To be done: A task checking the lower 1% after the lower
+    // energy limit!
+
     MTaskEnv taskenv0("CalcHadronness");
     taskenv0.SetDefault(fCalcHadronness);
@@ -1490,4 +1585,6 @@
     tlist2.AddToList(&fill31);
     tlist2.AddToList(&fill4);
+    tlist2.AddToList(&fill4b);
+    tlist2.AddToList(&fill4c);
     tlist2.AddToList(&fill5);
     tlist2.AddToList(&fill0a);
Index: trunk/MagicSoft/Mars/mjobs/MJSpectrum.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJSpectrum.h	(revision 8695)
+++ trunk/MagicSoft/Mars/mjobs/MJSpectrum.h	(revision 8701)
@@ -12,4 +12,5 @@
 
 class MH3;
+class MHn;
 class MTask;
 class MParList;
@@ -34,4 +35,9 @@
 
     Bool_t fForceTheta;
+
+    // Setup Histograms
+    void SetupHistEvtDist(MHn &hist) const;
+    void SetupHistEnergyEst(MHn &hist) const;
+    void SetupHistDisp(MHn &hist) const;
 
     // Read Input
