Index: trunk/MagicSoft/Mars/mjobs/MDataSet.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 8669)
+++ trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 8674)
@@ -274,4 +274,15 @@
 }
 
+//---------------------------------------------------------------------------
+//
+// Make sure that the name used for writing doesn't contain a full path
+//
+const char *MDataSet::GetName() const
+{
+    const char *pos = strrchr(GetRcName(), '/');
+    return pos>0 ? pos+1 : GetRcName();
+}
+
+
 // --------------------------------------------------------------------------
 //
@@ -299,4 +310,7 @@
         return;
     }
+    gLog << "# Path: " << GetRcName() << endl;
+    gLog << "# Name: " << GetName() << endl;
+    gLog << endl;
     gLog << "AnalysisNumber: " << fNumAnalysis << endl << endl;
 
Index: trunk/MagicSoft/Mars/mjobs/MDataSet.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MDataSet.h	(revision 8669)
+++ trunk/MagicSoft/Mars/mjobs/MDataSet.h	(revision 8674)
@@ -67,4 +67,7 @@
     MDataSet(Int_t num=(UInt_t)-1) : fNumAnalysis(num) { }
     MDataSet(const char *fname, TString sequences="", TString data="");
+
+    const char *GetName() const;
+    const char *GetRcName() const { return fName; }
 
     void Copy(TObject &obj) const
@@ -153,5 +156,6 @@
 
     // TObject
-    void Print(Option_t *o="") const; //*MENU*
+    void Print(Option_t *o) const;
+    void Print() const { Print(); } //*MENU*
 
     ClassDef(MDataSet, 2)
Index: trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 8669)
+++ trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 8674)
@@ -47,4 +47,6 @@
 #include "MLogManip.h"
 
+#include "MDirIter.h"
+
 #include "MStatusArray.h"
 #include "MStatusDisplay.h"
@@ -88,5 +90,6 @@
     : fCutQ(0), fCut0(0),fCut1(0), fCut2(0), fCut3(0), fCutS(0),
     fEstimateEnergy(0), fCalcHadronness(0), fRefill(kFALSE),
-    fSimpleMode(kTRUE), fRawMc(kFALSE), fNoThetaWeights(kFALSE)
+    /*fSimpleMode(kTRUE),*/ fForceTheta(kFALSE),
+    fRawMc(kFALSE), fNoThetaWeights(kFALSE)
 {
     fName  = name  ? name  : "MJSpectrum";
@@ -291,20 +294,29 @@
 
     *fLog << inf << "Using weights: " << w << endl;
-    *fLog << "Please stand by, this may take a while..." << flush;
+    *fLog << "Please stand by, this may take a while..." << endl;
 
     if (fDisplay)
-        fDisplay->SetStatusLine1("Compiling MC distribution...");
+        fDisplay->SetStatusLine1("Getting maximum impact...");
 
     // Create chain
-    TChain chain("OriginalMC");
+    *fLog << "Getting files... " << flush;
+    TChain chain("RunHeaders");
     if (!set.AddFilesOn(chain))
         return kFALSE;
+    *fLog << "done. " << endl;
+
+    *fLog << "Getting maximum impact... " << flush;
+    const Double_t impactmax = chain.GetMaximum("MMcRunHeader.fImpactMax");
+    *fLog << "found " << impactmax/100 << "m" << endl;
+
+    *fLog << "Getting files... " << flush;
+    MDirIter iter;
+    if (!set.AddFilesOn(iter))
+        return kFALSE;
+    *fLog << "done. " << endl;
 
     // Prepare histogram
     h.Reset();
     h.Sumw2();
-
-    // Fill histogram from chain
-    h.SetDirectory(gROOT);
     if (h.InheritsFrom(TH2::Class()))
     {
@@ -312,6 +324,5 @@
         h.SetXTitle("\\Theta [\\circ]");
         h.SetYTitle("E [GeV]");
-        h.SetZTitle("Counts");
-        chain.Draw("MMcEvtBasic.fEnergy:MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaEMC", w, "goff");
+        h.SetZTitle(Form("Counts normalized to r=%.0fm", impactmax/100));
     }
     else
@@ -319,10 +330,78 @@
         h.SetNameTitle("ThetaMC", "Event-Distribution vs Theta for MC (produced)");
         h.SetXTitle("\\Theta [\\circ]");
-        h.SetYTitle("Counts");
-        chain.Draw("MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaMC", w, "goff");
+        h.SetYTitle(Form("Counts normalized to r=%.0fm", impactmax/100));
     }
     h.SetDirectory(0);
 
-    *fLog << "done." << endl;
+    const TString cont = h.InheritsFrom(TH2::Class()) ?
+        "MMcEvtBasic.fEnergy:MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaEMC" :
+        "MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaMC";
+
+    if (fDisplay)
+        fDisplay->SetStatusLine1("Reading OriginalMC");
+
+    TH1 *hfill = (TH1*)h.Clone(h.InheritsFrom(TH2::Class())?"ThetaEMC":"ThetaMC");
+    hfill->SetDirectory(0);
+
+    TString fname;
+    while (1)
+    {
+        fname = iter.Next();
+        if (fname.IsNull())
+            break;
+
+        TFile file(fname);
+        if (file.IsZombie())
+        {
+            *fLog << err << "ERROR - Couldn't open file " << fname << endl;
+            return kFALSE;
+        }
+
+        TTree *rh = dynamic_cast<TTree*>(file.Get("RunHeaders"));
+        if (!rh)
+        {
+            *fLog << err << "ERROR - File " << fname << " doesn't contain tree RunHeaders." << endl;
+            return kFALSE;
+        }
+
+        if (rh->GetEntries()!=1)
+        {
+            *fLog << err << "ERROR - RunHeaders of " << fname << " doesn't contain exactly one entry." << endl;
+            return kFALSE;
+        }
+
+        TTree *t = dynamic_cast<TTree*>(file.Get("OriginalMC"));
+        if (!t)
+        {
+            *fLog << err << "ERROR - File " << fname << " doesn't contain tree OriginalMC." << endl;
+            return kFALSE;
+        }
+
+        *fLog << inf << "Reading OriginalMC of " << fname << endl;
+
+        if (t->GetEntries()==0)
+        {
+            *fLog << warn << "WARNING - OriginalMC of " << fname << " empty." << endl;
+            continue;
+        }
+
+        // Why does it crash if closed within loop (no update?)
+        //if (fDisplay)
+        //    fDisplay->SetStatusLine2(fname);
+
+        // Normalize by deviding through production area
+        const Double_t impact  = rh->GetMaximum("MMcRunHeader.fImpactMax");
+        const Double_t scale   = impactmax/impact;
+        const TString  weights = Form("%.16e*(%s)", scale*scale, w.Data());
+
+        // Fill histogram from tree
+        hfill->SetDirectory(&file);
+        t->Draw(cont, weights, "goff");
+        hfill->SetDirectory(0);
+        h.Add(hfill);
+    }
+    delete hfill;
+
+    *fLog << "Total number of events from file: " << h.GetEntries() << endl;
     if (fDisplay)
         fDisplay->SetStatusLine2("done.");
@@ -333,5 +412,5 @@
     *fLog << err << "ERROR - Histogram with original MC distribution empty..." << endl;
 
-    return h.GetEntries()>0;
+    return kFALSE;
 }
 
@@ -412,6 +491,7 @@
     {
         *fLog << err;
-        *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos doesn't overlap";
-        *fLog << "        with the the Zenith Angle distribution of your observation.";
+        *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos doesn't overlap" << endl;
+        *fLog << "        with the Zenith Angle distribution of your observation." << endl;
+        *fLog << "        Maybe the energy binning is not defined or wrong." << endl;
         theta->SetLineColor(kRed);
         return kFALSE;;
@@ -424,5 +504,6 @@
 
     // Compare both histograms
-    const Double_t prob = proj.Chi2Test(theta, "");
+    *fLog << inf << "Comparing theta distributions for data and MCs." << endl;
+    const Double_t prob = proj.Chi2Test(theta, "P");
     if (prob==1)
         return kTRUE;
@@ -431,25 +512,26 @@
     {
         *fLog << inf;
-        *fLog << "The Zenith Angle distribution of your Monte Carlos fits well";
-        *fLog << "with the the Zenith Angle distribution of your observation.";
+        *fLog << "The Zenith Angle distribution of your Monte Carlos fits well" << endl;
+        *fLog << "with the Zenith Angle distribution of your observation." << endl;
+        *fLog << "The probability for identical Theta distributions is " << prob << endl;
         return kTRUE;
     }
 
-    // <0.01: passen gar nicht
-    // ==1: passen perfekt
-    // >0.99: passer sehr gut
-
     if (prob<0.01)
     {
         *fLog << err;
-        *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos does not fit";
-        *fLog << "        with the the Zenith Angle distribution of your observation.";
+        *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos does not fit" << endl;
+        *fLog << "        with the Zenith Angle distribution of your observation." << endl;
+        *fLog << "        The probability for identical Theta distributions is " << prob << endl;
+        if (!fForceTheta)
+            *fLog << "        To force processing use --force-theta (with care!)" << endl;
         theta->SetLineColor(kRed);
-        return kFALSE;
+        return fForceTheta;
     }
 
     *fLog << warn;
-    *fLog << "WARNING - The Zenith Angle distribution of your Monte Carlos doesn't fits well";
-    *fLog << "          with the the Zenith Angle distribution of your observation.";
+    *fLog << "WARNING - The Zenith Angle distribution of your Monte Carlos doesn't fits well" << endl;
+    *fLog << "          with the Zenith Angle distribution of your observation." << endl;
+    *fLog << "          The probability for identical Theta distributions is " << prob << endl;
     return kTRUE;
 }
@@ -1167,5 +1249,5 @@
     TH2D hist;
     MH3 mh1("MMcEvtBasic.fTelescopeTheta*kRad2Deg", "MMcEvtBasic.fEnergy");
-    if (fSimpleMode)
+    //if (fSimpleMode)
     {
         // Now we read the MC distribution as produced by corsika again
@@ -1189,5 +1271,5 @@
                 }
         }
-    }
+    }/*
     else
     {
@@ -1198,7 +1280,7 @@
             return kFALSE;
         weight.SetNameMcEvt();
-    }
-
-    if (!DisplayResult(fSimpleMode ? hist : (TH2D&)mh1.GetHist()))
+    }*/
+
+    if (!DisplayResult(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/))
         return kFALSE;
 
@@ -1245,6 +1327,6 @@
     MHCollectionArea area0("TriggerArea");
     MHCollectionArea area1;
-    area0.SetHistAll(fSimpleMode ? hist : (TH2D&)mh1.GetHist());
-    area1.SetHistAll(fSimpleMode ? hist : (TH2D&)mh1.GetHist());
+    area0.SetHistAll(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/);
+    area1.SetHistAll(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/);
 
     MHEnergyEst      hest;
@@ -1400,4 +1482,8 @@
     TObjArray cont;
     cont.Add((TObject*)GetEnv());
+    cont.Add(&area0);
+    cont.Add(&area1);
+    cont.Add(&hest);
+    cont.Add(const_cast<TEnv*>(GetEnv()));
 
     if (fDisplay)
Index: trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 8669)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 8674)
@@ -478,4 +478,15 @@
 }
 
+//---------------------------------------------------------------------------
+//
+// Make sure that the name used for writing doesn't contain a full path
+//
+const char *MSequence::GetName() const
+{
+    const char *pos = strrchr(GetRcName(), '/');
+    return pos>0 ? pos+1 : GetRcName();
+}
+
+
 // --------------------------------------------------------------------------
 //
@@ -490,4 +501,7 @@
         return;
     }
+    gLog << "# Path: " << GetRcName() << endl;
+    gLog << "# Name: " << GetName() << endl;
+    gLog << endl;
     gLog << "Sequence:       " << fSequence << endl;
     if (fMonteCarlo)
Index: trunk/MagicSoft/Mars/mjobs/MSequence.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 8669)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 8674)
@@ -78,5 +78,9 @@
 
     // TObject
-    void Print(Option_t *o="") const; //*MENU*
+    void Print(Option_t *o) const;
+    void Print() const { Print(); } //*MENU*
+
+    const char *GetName() const;
+    const char *GetRcName() const { return fName; }
 
     // Genaral interface
