Index: trunk/MagicSoft/Mars/mjobs/MDataSet.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 8720)
+++ trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 8724)
@@ -35,5 +35,7 @@
 //       AnalysisNumber: 1
 //
-//       SequencesOn: 35222
+//       Name: SecondCrab
+//
+//       SequencesOn: 35222 35229
 //       SequencesOff: 36817
 //
@@ -47,5 +49,9 @@
 //       Sequence00036817.Dir: /data2/wuerzburg/Crab-Analyse/images/036817
 //
+//       WobbleMode: No
 //       MonteCarlo: No
+//
+//       SourceName: CrabNebula
+//       Catalog: /magic/datacenter/setup/magic_favorites_dc.edb
 //
 // AnalysisNumber: The analysis number is an artifical number used to name
@@ -80,7 +86,67 @@
 // stored using Sequence%08d.Dir (make sure you have 8 digits!)
 //
-//
+// WobbleMode: This is just a flag which is passed to the program
+// end eveluated (or not) by the individual program, which takes this
+// dataset as an input. For example this is necessary in ganymed to do
+// some wobble mode special setup. If no resource is given (or it is
+// set to "auto") wobble mode if set if the datset contains no off-
+// sequences.
+//
+// MonetCarlo: This is just a flag which is passed to the program
+// end eveluated (or not) by the individual program, which takes this
+// dataset as an input. For example this tells ganymed to skip some
+// parts accessing time stamps which are not available in the MCs.
+//
+// SequencePath/DataPath: This determined were the sequences and data-files
+// are stored. The priorities are as follows:
+//  0) Build in default path:          /magic/sequences   /magic/data/star
+//  1) Def.path from dataset file:       SequencePath         DataPath
+//  2) Indiv.path from dataset file:  12345.SequencePath   12345.DataPath
+//  3) Path from command line:            Argument in the constructors
+//  4) Path for an indiv. dataset:         Sequences00022555.File/Dir
+//
+// Catalog: This is the xephem-style file from the central control
+// containing the observed sky positions.
+//
+// SourceName: The source name, as defined in the catalog, of the object
+// the data corresponds to.
+//
+// Name: A name is stored for your convinience
+//
+// Comment: It is just stored.
+//
+// General Remark: MDataSet doesn't implement any action on the given
+// resources. Whether a resource is used, necessary or ignored, and
+// what will happen if you change the resource is always defined by the
+// executed macro or program.
 //
 // Resource file entries are case sensitive!
+//
+//
+// Collection of datsets
+// ---------------------
+//
+//  You can combine more than one datset in a file (if your program
+//  supports this) Such a dataset file could look like this:
+//
+//       35222.SequencesOn: 35222
+//       35222.SequencesOff: 36817
+//
+//       65778.SequencesOn: 65778
+//
+//       12345.SequencesOn: 12345
+//
+//       12345.SequencePath: /home/nobody/specialsequences
+//       65778.DataPath:     /home/nobody/specialstars
+//
+//       SequencePath: /home/nobody/defaultsequences
+//       DataPath:     /home/nobody/defaultstars
+//
+//       Sequence00035222.File: sequences/sequence035222.txt
+//       Sequence00035222.Dir:  /data2/wuerzburg/Crab-Analyse/images/035222
+//
+//       35222.WobbleMode: Off
+//       WobbleMode: On
+//
 //
 // IMPORTANT:
@@ -89,4 +155,9 @@
 //   * Sequence filenames should also have names allowing to order them
 //     in time, but it is not necessary.
+//
+//
+// ToDO:
+//   * Default paths could be moved into the global .rootrc
+//
 //
 // Class Version 2:
@@ -183,5 +254,5 @@
 // The entries are sorted by filename.
 //
-void MDataSet::ResolveSequences(TEnv &env, const TArrayI &num, TList &list) const
+void MDataSet::ResolveSequences(const TEnv &env, const TString &prefix, const TArrayI &num, TList &list) const
 {
     TString sequences = fPathSequences;
@@ -190,6 +261,6 @@
     for (int i=0; i<num.GetSize(); i++)
     {
-        TString name = env.GetValue(Form("Sequence%08d.File", num[i]), "");
-        TString dir  = env.GetValue(Form("Sequence%08d.Dir",  num[i]), "");
+        TString name = GetEnvValue2(env, prefix, Form("Sequence%08d.File", num[i]), "");
+        TString dir  = GetEnvValue2(env, prefix, Form("Sequence%08d.Dir",  num[i]), "");
 
         // Set default sequence file and dir name
@@ -213,41 +284,94 @@
 }
 
-// --------------------------------------------------------------------------
-//
-// Read the file fname as setup file for the sequence.
-//
-MDataSet::MDataSet(const char *fname, TString sequences, TString data)
-{
+Bool_t MDataSet::GetWobbleMode(const TEnv &env, const TString &prefix) const
+{
+    TString wob = GetEnvValue2(env, prefix, "WobbleMode", "auto");
+
+    wob.ToLower();
+    wob=wob.Strip(TString::kBoth);
+
+    if (wob=="auto")
+        return !HasOffSequences();
+
+    return GetEnvValue2(env, prefix, "WobbleMode", kFALSE);
+}
+
+// --------------------------------------------------------------------------
+//
+// Read a dataset from the file fname. If num is != -1 all resources are
+// prefixed with the number. This allows constrcutions like:
+//
+//   89123.SequencesOn: 1 2 3 4
+//   89130.SequencesOn: 5 6 7 8
+//
+// For one dataset:
+//
+//   89123.DataPath: /magic/data/star
+//
+// For all other datasets:
+//
+//   DataPath: /magic/data/star
+//
+// For one sequence of one datasets:
+//
+//   89123.Sequence00000002.Dir: /magic/data/star
+//
+// and therefore allows storage of several datsets in one file with
+// a defaults for non specific resources.
+//
+// sequences and data are the path to the sequences (/magic/sequences)
+// and the data (/magic/data/star) respectively. Both can be overwritten
+// be a default from the dataset file or a resource for an individual
+// sequence.
+//
+void MDataSet::Init(const char *fname, const UInt_t num, TString sequences, TString &data)
+{
+    // Store given file name as name
     fName = fname;
 
+    // Delete the stored Sequences automatically at destruction
     fSequencesOn.SetOwner();
     fSequencesOff.SetOwner();
 
+    // Determin the prefix to access this resource
+    const TString prefix = num==(UInt_t)-1 ? "" : Form("%d", num);
+
+    // Expand the file name (eg $MARS or ~ are expanded)
     TString expname(fname);
     gSystem->ExpandPathName(expname);
 
+    // Check its accessibility
     const Bool_t access = !gSystem->AccessPathName(expname, kFileExists);
     if (!access)
         gLog << err << "ERROR - Dataset file " << expname << " not accessible!" << endl;
 
+    // Open and read the file
     MEnv env(expname);
 
-    fNumAnalysis = env.GetValue("AnalysisNumber", -1);
-    fTitle       = env.GetValue("Name", expname);
-
+    // Get analysis number and name
+    fNumAnalysis = GetEnvValue2(env, prefix, "AnalysisNumber", (Int_t)num);
+    fTitle       = GetEnvValue2(env, prefix, "Name", expname);
+
+    // Get sequences from file
     TString str;
-    str = env.GetValue("SequencesOn",  "");
+    str = GetEnvValue2(env, prefix, "SequencesOn",  "");
     Split(str, fNumSequencesOn);
-    str = env.GetValue("SequencesOff", "");
+    str = GetEnvValue2(env, prefix, "SequencesOff", "");
     Split(str, fNumSequencesOff);
 
-    fNameSource   = env.GetValue("SourceName", "");
-    fCatalog      = env.GetValue("Catalog",    fgCatalog);
-    fWobbleMode   = env.GetValue("WobbleMode", kFALSE);
-    fMonteCarlo   = env.GetValue("MonteCarlo", kFALSE);
-    fComment      = env.GetValue("Comment",    "");
-
-    const TString defpathseq  = env.GetValue("SequencePath", GetDefPathSequences());
-    const TString defpathdata = env.GetValue("DataPath",     GetDefPathDataFiles());
+    // Get other resources
+    fNameSource   = GetEnvValue2(env, prefix, "SourceName", "");
+    fCatalog      = GetEnvValue2(env, prefix, "Catalog",    fgCatalog);
+    fMonteCarlo   = GetEnvValue2(env, prefix, "MonteCarlo", kFALSE);
+    fComment      = GetEnvValue2(env, prefix, "Comment",    "");
+
+    fWobbleMode   = GetWobbleMode(env, prefix); // needs the number of off sequences
+
+    fNameSource = fNameSource.Strip(TString::kBoth);
+    fCatalog    = fCatalog.Strip(TString::kBoth);
+
+    // Check for sequence and data path (GetDefPath needs the monte carlo flag)
+    const TString defpathseq  = GetEnvValue2(env, prefix, "SequencePath", GetDefPathSequences());
+    const TString defpathdata = GetEnvValue2(env, prefix, "DataPath",     GetDefPathDataFiles());
 
     SetupDefaultPath(sequences, defpathseq);
@@ -257,9 +381,7 @@
     fPathDataFiles = data;
 
-    ResolveSequences(env, fNumSequencesOn,  fSequencesOn);
-    ResolveSequences(env, fNumSequencesOff, fSequencesOff);
-
-    fNameSource = fNameSource.Strip(TString::kBoth);
-    fCatalog    = fCatalog.Strip(TString::kBoth);
+    // Resolve sequences
+    ResolveSequences(env, prefix, fNumSequencesOn,  fSequencesOn);
+    ResolveSequences(env, prefix, fNumSequencesOff, fSequencesOff);
 
     // --- Now "touch" resources which are not yet stored in MDataSet ---
@@ -272,4 +394,22 @@
         env.PrintUntouched();
     }
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor. See Read for more details.
+//
+MDataSet::MDataSet(const char *fname, TString sequences, TString data)
+{
+    Init(fname, (UInt_t)-1, sequences, data);
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor. See Read for more details.
+//
+MDataSet::MDataSet(const char *fname, Int_t num, TString sequences, TString data)
+{
+    Init(fname, num, sequences, data);
 }
 
@@ -330,5 +470,5 @@
     gLog << "Catalog: " << fCatalog << endl;
 
-    gLog << "WobbleMode: " << (fWobbleMode?"On":"Off") << endl << endl;
+    gLog << "WobbleMode: " << (fWobbleMode?"Yes":"No") << endl << endl;
     gLog << "MonteCarlo: " << (fMonteCarlo?"Yes":"No") << endl << endl;
 
Index: trunk/MagicSoft/Mars/mjobs/MDataSet.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MDataSet.h	(revision 8720)
+++ trunk/MagicSoft/Mars/mjobs/MDataSet.h	(revision 8724)
@@ -24,6 +24,6 @@
     UInt_t  fNumAnalysis;     // Analysis number (artificial)
 
-    TString fPathSequences;
-    TString fPathDataFiles;
+    TString fPathSequences;   // Default path to the sequence files
+    TString fPathDataFiles;   // Default path to the data files
 
     TArrayI fNumSequencesOn;  // number of on-sequences
@@ -41,8 +41,11 @@
     Bool_t  fMonteCarlo;      // For default paths use MC or data path
 
+    // Helper functions for constrcutors
     void Split(TString &runs, TArrayI &data) const;
-    void ResolveSequences(TEnv &env, const TArrayI &num, TList &list/*, const TString &sequences, const TString &data*/) const;
+    void ResolveSequences(const TEnv &env, const TString &prefix, const TArrayI &num, TList &list/*, const TString &sequences, const TString &data*/) const;
+    Bool_t GetWobbleMode(const TEnv &env, const TString &prefix) const;
     static void PrintFile(const MSequence &obj);
 
+    // Directory and file handling
     void ReplaceDir(TList &list, const TString &old, const TString &news) const;
     void ReplaceFile(TList &list, const TString &old, const TString &news) const;
@@ -64,7 +67,11 @@
     }
 
+    // Initialize from constrcutors
+    void Init(const char *fname, const UInt_t num, TString sequences, TString &data);
+
 public:
-    MDataSet(Int_t num=(UInt_t)-1) : fNumAnalysis(num) { }
+    MDataSet() : fNumAnalysis((UInt_t)-1) { }
     MDataSet(const char *fname, TString sequences="", TString data="");
+    MDataSet(const char *fname, Int_t num, TString sequences="", TString data="");
 
     const char *GetName() const;
@@ -98,5 +105,5 @@
 
     // Getter
-    Bool_t IsValid() const { return fNumAnalysis!=(UInt_t)-1; }
+    Bool_t IsValid() const { return fNumAnalysis!=(UInt_t)-1 && GetNumSequencesOn()>0; }
 
     UInt_t GetNumSequencesOn() const  { return fNumSequencesOn.GetSize(); }
Index: trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 8720)
+++ trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 8724)
@@ -683,5 +683,5 @@
     MRead &readoff = set.IsMonteCarlo() ? (MRead&)readoffmc : (MRead&)readoffdata;
     const Bool_t setrc = set.IsWobbleMode() ? set.AddFilesOn(readoff) : set.AddFilesOff(readoff);
-    if (!setrc && set.HasOffSequences())
+    if (!setrc && (set.HasOffSequences() || set.IsWobbleMode()))
     {
         *fLog << err << "MDataSet::AddFiles" << (set.IsWobbleMode()?"On":"Off") << " failed." << endl;
