Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 8714)
+++ trunk/MagicSoft/Mars/NEWS	(revision 8716)
@@ -7,4 +7,12 @@
      Also the old values seemed not exactly the PulsePos used for 
      teh check.
+
+   - general: Resource file now allow an Include-Resource, i.e. you can
+     read a resource file with default settings, include it in your
+     resource file and overwrite the settings in your file. More than
+     one include file is allowed. Inclusions can be iterative.
+        Include: mydefaults.rc yourdefaults.rc
+     The resources in the first file have higher priority than the
+     second file.
 
    - general: Now the output files (calib*.root, etc) also contain the
@@ -105,4 +113,12 @@
      analysis in star might not work as perfect as expected as long
      as old files read in.
+
+   - callisto: The callibration constants of earlier updates got lost
+     somehow. All constants have been updated.
+
+   - star: The PSF is now determined from the profile of the ArcWidth
+     instead of arcwidth/radius. The old way gave to much weight
+     to the bins with low statistics. The reference lines have been
+     updated.
 
    - star: For speed reasons events suitable for the muon analysis 
Index: trunk/MagicSoft/Mars/mbase/MEnv.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEnv.cc	(revision 8714)
+++ trunk/MagicSoft/Mars/mbase/MEnv.cc	(revision 8716)
@@ -31,4 +31,14 @@
 // PrintUntouched()
 //
+// A new special resource is available. With the resource "Include"
+// you can include resources from other files, for example
+//
+//   Include: file1.rc file2.rc
+//
+// Including can be done recursively. Resources from the included files
+// have lower priority. This allows to write a resource file with your
+// default resources which then can be included in other files overwriting
+// some of the resources.
+//
 //////////////////////////////////////////////////////////////////////////////
 #include "MEnv.h"
@@ -58,10 +68,13 @@
     fChecked.SetOwner();
 
+    // If TEnv::TEnv has not set fRcName
     if (!IsValid())
         return;
 
+    // ExpandPathName (not done by TEnv::TEnv) and read again
     TString fname(name);
     gSystem->ExpandPathName(fname);
 
+    // Is file accessible
     if (gSystem->AccessPathName(fname, kFileExists))
         fname = "";
@@ -69,6 +82,99 @@
     SetRcName(fname);
 
-    if (GetEntries()<=0 && !fname.IsNull() && fname!=name)
-        ReadFile(fname, kEnvLocal);;
+    // No file found
+    if (fname.IsNull())
+        return;
+
+    // File has been already processed, but ReadInclude is part of a
+    // derived function, i.e. not yet executed.
+    if (GetEntries()>0 || fname==name)
+    {
+        if (ReadInclude()<0)
+            SetRcName("");
+        return;
+    }
+
+    // File not yet processed. Reread file.
+    if (ReadFile(fname, kEnvLocal)<0)
+        SetRcName("");
+}
+
+//---------------------------------------------------------------------------
+//
+// Process an Include directive and read the corresponding contents
+//
+Int_t MEnv::ReadInclude()
+{
+    // Check for "Include" resource
+    const TString incl = GetValue("Include", "");
+    if (incl.IsNull())
+        return 0;
+
+    // Tokenize the array into single files divided by a whitespace
+    TObjArray *arr = incl.Tokenize(" ");
+
+    // We have to rebuild the Include array from scratch to get the
+    // correct sorting for a possible rereading.
+    SetValue("Include", "");
+
+    // FIXME: Make sure that recursions don't crash the system!
+
+    for (int i=0; i<arr->GetEntries(); i++)
+    {
+        // Get file name to include
+        const char *fenv = (*arr)[i]->GetName();
+
+        // Read included file and check if its valid
+        const MEnv env(fenv);
+        if (!env.IsValid())
+        {
+            delete arr;
+            return -1;
+        }
+
+        // Add file name before its childs
+        SetValue("+Include", fenv);
+
+        // If it is valid add entries from include without overwriting,
+        // i.e. the included resources have lower priority
+        AddEnv(env, kFALSE);
+
+        // Get a possible child include from env
+        const TString incl2 = const_cast<MEnv&>(env).GetValue("Include", "");
+        if (!incl2.IsNull())
+            SetValue("+Include", incl2);
+    }
+
+    delete arr;
+
+    // Get final compiled resource
+    TString inc = GetValue("Include", "");
+
+    // Remove obsolete whitespaces for convinience
+    inc.ReplaceAll("  ", " ");
+    inc = inc.Strip(TString::kBoth);
+
+    // Set final resource, now as kEnvLocal (previously set as kEnvChnaged)
+    SetValue("Include", inc, kEnvLocal);
+
+    // FIXME: Remove douplets in the correct order
+
+    return 0;
+}
+
+//---------------------------------------------------------------------------
+//
+// Read and parse the resource file for a certain level.
+// Returns -1 on case of error, 0 in case of success.
+//
+// Check for an include directive
+//
+Int_t MEnv::ReadFile(const char *fname, EEnvLevel level)
+{
+    // First read the file via TEnv
+    if (TEnv::ReadFile(fname, level)<0)
+        return -1;
+
+    return ReadInclude();
 }
 
Index: trunk/MagicSoft/Mars/mbase/MEnv.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEnv.h	(revision 8714)
+++ trunk/MagicSoft/Mars/mbase/MEnv.h	(revision 8716)
@@ -22,4 +22,5 @@
 
     TString Compile(TString str, const char *post) const;
+    Int_t   ReadInclude();
 
 public:
@@ -67,4 +68,6 @@
     void        AddEnv(const TEnv &env, Bool_t overwrite=kTRUE);
 
+    Int_t       ReadFile(const char *fname, EEnvLevel level);
+
     void        PrintEnv(EEnvLevel level = kEnvAll) const;
     void        Print(Option_t *option) const { TEnv::Print(option); }
