Index: trunk/MagicSoft/Mars/mjobs/MDataSet.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 8750)
+++ trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 8780)
@@ -31,5 +31,5 @@
 //  Such an input file looks like:
 //
-//     crab.seq:
+//     crab.txt:
 //     ---------
 //       AnalysisNumber: 1
@@ -37,5 +37,5 @@
 //       Name: SecondCrab
 //
-//       SequencesOn: 35222 35229
+//       SequencesOn:  35222 35229
 //       SequencesOff: 36817
 //
@@ -49,4 +49,6 @@
 //       Sequence00036817.Dir: /data2/wuerzburg/Crab-Analyse/images/036817
 //
+//       Sequence00036817.Exclude: 36818 36819
+//
 //       WobbleMode: No
 //       MonteCarlo: No
@@ -55,60 +57,78 @@
 //       Catalog: /magic/datacenter/setup/magic_favorites_dc.edb
 //
+//
+// Reading the file is based on TEnv. For more details see also
+// the class reference of TEnv.
+//
+//
 // AnalysisNumber: The analysis number is an artifical number used to name
-// the output files automatically if the names are not overwritten in the
-// corresponding programs.
+//  the output files automatically if the names are not overwritten in the
+//  corresponding programs.
 //
 // SequencePath: In case it is not specified the datacenter default path is
-// used. If it is given it is the place at which the sequence files
-// are searched, if not overwritten by either a program command line
-// option (aka. a argument to the constructor) or a resource for
-// an individual sequence file. Note, that the four digits high-level
-// directories to sort the sequences are added to the given path.
+//  used. If it is given it is the place at which the sequence files
+//  are searched, if not overwritten by either a program command line
+//  option (aka. a argument to the constructor) or a resource for
+//  an individual sequence file. Note, that the four digits high-level
+//  directories to sort the sequences are added to the given path.
 //
 // DataPath: In case it is not specified the datacenter default path is
-// used. If it is given it is the place at which the data files
-// are searched, if not overwritten by either a program command line
-// option (aka. a argument to the constructor) or a resource for
-// an individual data path.  Note, that the four digits high-level
-// directories to sort the sequences are added to the given path.
+//  used. If it is given it is the place at which the data files
+//  are searched, if not overwritten by either a program command line
+//  option (aka. a argument to the constructor) or a resource for
+//  an individual data path.  Note, that the four digits high-level
+//  directories to sort the sequences are added to the given path.
 //
 // SequencesOn/Off: The sequence number are used to concatenate the filenames
-// of the sequences using the file structure used in the datacenter. Each
-// sequence can be added to the on and off data at the same time but only
-// once.
-//
-// If you have different file names you can overwrite the default file names
-// using Sequence%08d.File (make sure you have 8 digits!)
-//
-// In standard coditions (datacenter file system) paths are concatenated
-// by using the information in the sequence files (date, etc). You can
-// overwrite the directories in which the sequence-files (eg I-files) are
-// stored using Sequence%08d.Dir (make sure you have 8 digits!)
+//  of the sequences using the file structure used in the datacenter. Each
+//  sequence can be added to the on and off data at the same time but only
+//  once.
+//
+//  If you have different file names you can overwrite the default file names
+//  using Sequence%08d.File (make sure you have 8 digits!)
+//
+//  If the file name is given as "-", e.g.
+//       Sequence00035222.File: -
+//  the current dataset file is read as sequence file. In this case all
+//  resources defined for a sequence file should be prefixed by
+//  "Sequence%08d."; if not prefixed the default without the prefix
+//  is looked up. Be aware that the "Sequence" resource for sequence-files
+//  (for more details see MSequence) is ignored and the already defined
+//  number is used instead and thus should be identical to the sequence
+//  number - which normally is not necessary.
+//
+//  In standard coditions (datacenter file system) paths are concatenated
+//  by using the information in the sequence files (date, etc). You can
+//  overwrite the directories in which the sequence-files (eg I-files) are
+//  stored using Sequence%08d.Dir (make sure you have 8 digits!)
+//
+//  Using the resource Sequence%08d.Exclude you can exclude a list of
+//  runs from a sequence.
 //
 // 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.
+//  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.
+//  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
+//  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.
+//  containing the observed sky positions.
 //
 // SourceName: The source name, as defined in the catalog, of the object
-// the data corresponds to.
+//  the data corresponds to.
 //
 // Name: A name is stored for your convinience
@@ -261,6 +281,9 @@
     for (int i=0; i<num.GetSize(); i++)
     {
-        TString name = GetEnvValue2(env, prefix, Form("Sequence%08d.File", num[i]), "");
-        TString dir  = GetEnvValue2(env, prefix, Form("Sequence%08d.Dir",  num[i]), "");
+        const TString seqid = Form("Sequence%08d", num[i]);
+
+        TString name = GetEnvValue2(env, prefix, Form("%s.File",    seqid.Data()), "");
+        TString dir  = GetEnvValue2(env, prefix, Form("%s.Dir",     seqid.Data()), "");
+        TString excl = GetEnvValue2(env, prefix, Form("%s.Exclude", seqid.Data()), "");
 
         // Set default sequence file and dir name
@@ -270,6 +293,10 @@
             dir = Form("%s%04d/%08d", data.Data(), num[i]/10000, num[i]);
 
+        // Check if sequence information is contained in Dataset file
+        const Bool_t useds = name=="-";
+
         // FIXME: The sequence number from the sequence file is assigned!!!
-        MSequence *seq = new MSequence(name, dir);
+        MSequence *seq = new MSequence(useds?fName:name, dir, num[i]);
+        seq->ExcludeRuns(excl);
 
         if (seq->IsValid() && seq->GetSequence()!=(UInt_t)num[i])
@@ -436,4 +463,25 @@
 
     gLog << "#  " << access << " " << seq.GetFileName() << " <" << seq.GetDataPath() << ">" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Helper to print a seqeunce in Print()
+//
+void MDataSet::PrintSeq(const MSequence &seq) const
+{
+    const Bool_t useds = seq.GetFileName()==fName;
+
+    gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".File:   " << (useds?"-":seq.GetFileName()) << endl;
+    gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".Dir:    " << seq.GetDataPath() << endl;
+    if (!useds && seq.GetNumExclRuns()>0)
+        gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".Exclude: " << seq.GetExcludedRuns() << endl;
+
+    if (useds)
+    {
+        gLog << endl;
+        seq.Print("prefixed");
+        gLog << endl << "# ---" << endl;
+    }
 }
 
@@ -478,19 +526,15 @@
         gLog << endl;
 
+    // FIXME: If file==fName --> print Sequence0000.content
+
     TIter NextOn(&fSequencesOn);
     TIter NextOff(&fSequencesOff);
     MSequence *seq=0;
     while ((seq=(MSequence*)NextOn()))
-    {
-        gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".File: " << seq->GetFileName() << endl;
-        gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".Dir:  " << seq->GetDataPath() << endl;
-    }
+        PrintSeq(*seq);
     if (fSequencesOff.GetEntries()>0)
         gLog << endl;
     while ((seq=(MSequence*)NextOff()))
-    {
-        gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".File: " << seq->GetFileName() << endl;
-        gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".Dir:  " << seq->GetDataPath() << endl;
-    }
+        PrintSeq(*seq);
 
     if (TString(o).Contains("files", TString::kIgnoreCase))
Index: trunk/MagicSoft/Mars/mjobs/MDataSet.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MDataSet.h	(revision 8750)
+++ trunk/MagicSoft/Mars/mjobs/MDataSet.h	(revision 8780)
@@ -46,4 +46,5 @@
     Bool_t GetWobbleMode(const TEnv &env, const TString &prefix) const;
     static void PrintFile(const MSequence &obj);
+    void PrintSeq(const MSequence &seq) const;
 
     // Directory and file handling
@@ -138,4 +139,7 @@
     const TList &GetSequencesOff() const { return fSequencesOff; }
 
+    const TArrayI &GetSequencesNumOn() const  { return fNumSequencesOn; }
+    const TArrayI &GetSequencesNumOff() const { return fNumSequencesOff; }
+
     Bool_t AddFiles(MRead &read) const;
     Bool_t AddFilesOn(MRead &read) const;
Index: trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 8750)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 8780)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 8/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2004
+!   Copyright: MAGIC Software Development, 2004-2007
 !
 !
@@ -28,10 +28,13 @@
 //
 //  This class describes a sequence. For sequences see:
-//    http://magic.astro.uni-wuerzburg.de/mars/db/queryseq.html
+//    http://db.astro.uni-wuerzburg.de
 //
 //  A sequence is a collection of runs which should be used together.
 //  Any run can be contained only once.
 //
-//  Here is an example how a file describing a sequence could look like:
+//  Here is an example how a file describing a sequence could look like.
+//
+//  Reading the file is based on TEnv. For more details see also
+//  the class reference of TEnv.
 //
 // ===========================================================================
@@ -40,55 +43,52 @@
 //  ------------
 //
-//   # Sequence number (identifier)
+//   # Sequence number (identifier) - necessary if the path
+//   # contains the sequence number, e.g. image files
 //   Sequence:     31015
-//   # Observation Period (used to get the path-names)
+//
+//   # Observation Period (not needed)
 //   Period:       18
-//   # Date of sunrise of the observation night
+//
+//   # Date of sunrise of the observation night - necessary if the path
+//   # contains the date, e.g. raw data
 //   Night:        2004-06-24
 //
-//   # Start time of the sequence (first data run)
+//   # Start time of the sequence (first data run, not needed)
 //   Start:        2004-06-24 03:12:42
-//   # Run number of last data run in sequence
+//
+//   # Run number of last data run in sequence (not needed)
 //   LastRun:      31032
-//   # Project name of data-runs of sequence
+//
+//   # Project name of data-runs of sequence (not needed)
 //   Project:      3EG2033+41
-//   # Source name of all runs of sequence
+//
+//   # Source name of all runs of sequence (not needed)
 //   Source:       3EG2033+41
-//   # Trigger table of data-runs of sequence
+//
+//   # Trigger table of data-runs of sequence (not needed)
 //   TriggerTable: L1_4NN:L2_DEFAULT
-//   # HV Setting table of data-runs of sequence
+//
+//   # HV Setting table of data-runs of sequence (not needed)
 //   HvSettings:   HVSettings_FF36q
-//   # Total number of data-events in sequence
+//
+//   # Total number of data-events in sequence (not needed)
 //   NumEvents:    250914
 //
-//   # List of all runs of this sequence
+//   # Whether this is MC data or not (necessary in case of MCs if
+//   # default paths should be used)
+//   MonteCarlo: Yes
+//
+//   # List of all runs of this sequence (not needed)
 //   Runs: 31015 31016 31017 31018 31019 31020 31021 31022 31023 31024 31025 31026 31027 31028 31029 31030 31031 31032
 //
-//   # List of all calibration runs of this sequence
+//   # List of all calibration runs of this sequence (necessary if accessed)
 //   CalRuns: 31015 31016 31017
-//   # List of pedestal runs belonging to the calibration runs of this sequence
+//   # List of pedestal runs belonging to the calibration runs of this sequence (necessary if accessed)
 //   PedRuns: 31018
-//   # List of all data runs belonging to this sequence
+//   # List of all data runs belonging to this sequence (necessary)
 //   DatRuns: 31019 31020 31022 31023 31024 31025 31027 31028 31030 31032
 //
-//   # List of run types of all runs
-//   31015: C
-//   31016: C
-//   31017: C
-//   31018: P
-//   31019: D
-//   31020: D
-//   31021: P
-//   31022: D
-//   31023: D
-//   31024: D
-//   31025: D
-//   31026: P
-//   31027: D
-//   31028: D
-//   31029: P
-//   31030: D
-//   31031: P
-//   31032: D
+//   # Just for fun ;-) (not needed, but helpful)
+//   Comment: This is a template for a sequence file
 //
 // ===========================================================================
@@ -125,4 +125,7 @@
 //  Class Version 3:
 //   + fComment
+//
+//  Class Version 4:
+//   + fExclRuns
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -253,6 +256,13 @@
         d += '/';
 
+    Int_t excluded = 0;
     for (int i=0; i<arr.GetSize(); i++)
     {
+        if (IsExcluded(arr[i]))
+        {
+            excluded++;
+            continue;
+        }
+
         // R. DeLosReyes and T. Bretz
         // Changes to read the DAQ numbering format. Changes takes place
@@ -325,6 +335,9 @@
     }
 
+    // n0: The previous contents of the iter
+    // n1: The number of files which have been added to the iter
+    // n2: The number of files which should have been added from the array
     const Int_t n1 = iter.GetNumEntries()-n0;
-    const Int_t n2 = arr.GetSize();
+    const Int_t n2 = arr.GetSize()-excluded;
     if (n1==0)
     {
@@ -386,7 +399,7 @@
 //}
 
-MSequence::LightCondition_t MSequence::ReadLightCondition(TEnv &env) const
-{
-    TString str = env.GetValue("LightConditions", "n/a");
+MSequence::LightCondition_t MSequence::ReadLightCondition(TEnv &env, const char *prefix) const
+{
+    TString str = GetEnvValue2(env, prefix, "LightConditions", "n/a");
     if (!str.CompareTo("n/a", TString::kIgnoreCase))
         return kNA;
@@ -410,5 +423,5 @@
 // Read the file fname as setup file for the sequence.
 //
-MSequence::MSequence(const char *fname, const char *path)
+MSequence::MSequence(const char *fname, const char *path, UInt_t seq)
 {
     fName  = fname;
@@ -431,36 +444,40 @@
     MEnv env(fName);
 
-    fSequence  = env.GetValue("Sequence", -1);
+    fSequence = (UInt_t)env.GetValue("Sequence", (Int_t)seq);
     if (rc1 || rc2)
         fSequence = (UInt_t)-1;
 
-    fLastRun   = env.GetValue("LastRun",   -1);
-    fNumEvents = env.GetValue("NumEvents", -1);
-    fPeriod    = env.GetValue("Period",    -1);
-
-    fLightCondition = ReadLightCondition(env);
+    const TString prefix = Form("Sequence%08d", fSequence);
+
+    fLastRun   = GetEnvValue2(env, prefix, "LastRun",   -1);
+    fNumEvents = GetEnvValue2(env, prefix, "NumEvents", -1);
+    fPeriod    = GetEnvValue2(env, prefix, "Period",    -1);
+
+    fLightCondition = ReadLightCondition(env, prefix);
 
     TString str;
-    str = env.GetValue("Start", "");
+    str = GetEnvValue2(env, prefix, "Start", "");
     fStart.SetSqlDateTime(str);
-    str = env.GetValue("Night", "");
+    str = GetEnvValue2(env, prefix, "Night", "");
     str += " 00:00:00";
     fNight.SetSqlDateTime(str);
 
-    fProject      = env.GetValue("Project", "");
-    fSource       = env.GetValue("Source", "");
-    fTriggerTable = env.GetValue("TriggerTable", "");
-    fHvSettings   = env.GetValue("HvSettings", "");
-    fMonteCarlo   = env.GetValue("MonteCarlo", kFALSE);
-    fComment      = env.GetValue("Comment",    "");
-
-    str = env.GetValue("Runs", "");
+    fProject      = GetEnvValue2(env, prefix, "Project", "");
+    fSource       = GetEnvValue2(env, prefix, "Source", "");
+    fTriggerTable = GetEnvValue2(env, prefix, "TriggerTable", "");
+    fHvSettings   = GetEnvValue2(env, prefix, "HvSettings", "");
+    fMonteCarlo   = GetEnvValue2(env, prefix, "MonteCarlo", kFALSE);
+    fComment      = GetEnvValue2(env, prefix, "Comment",    "");
+
+    str = GetEnvValue2(env, prefix, "Runs", "");
     Split(str, fRuns);
-    str = env.GetValue("CalRuns", "");
+    str = GetEnvValue2(env, prefix, "CalRuns", "");
     Split(str, fCalRuns);
-    str = env.GetValue("PedRuns", "");
+    str = GetEnvValue2(env, prefix, "PedRuns", "");
     Split(str, fPedRuns);
-    str = env.GetValue("DatRuns", "");
+    str = GetEnvValue2(env, prefix, "DatRuns", "");
     Split(str, fDatRuns);
+    str = GetEnvValue2(env, prefix, "Exclude", "");
+    Split(str, fExclRuns);
 
   //  GetFileNames(env, fRuns);
@@ -470,12 +487,12 @@
 
     // Dummies:
-    env.GetValue("ZdMin", 0);
-    env.GetValue("ZdMax", 0);
-    env.GetValue("L1TriggerTable", 0);
-    env.GetValue("L2TriggerTable", 0);
-
-    if (env.GetNumUntouched()>0)
-    {
-        gLog << warn << "WARNING - At least one resource in the dataset-file has not been touched!" << endl;
+    env.Touch("ZdMin");
+    env.Touch("ZdMax");
+    env.Touch("L1TriggerTable");
+    env.Touch("L2TriggerTable");
+
+    if (seq<0 && env.GetNumUntouched()>0)
+    {
+        gLog << warn << "WARNING - At least one resource in the sequence-file has not been touched!" << endl;
         env.PrintUntouched();
     }
@@ -492,5 +509,4 @@
 }
 
-
 // --------------------------------------------------------------------------
 //
@@ -499,8 +515,10 @@
 void MSequence::Print(Option_t *o) const
 {
+    const TString pre = TString(o).Contains("prefixed") ? Form("Sequence%08d.", fSequence) : "";
+
     gLog << all;
     if (!IsValid())
     {
-        gLog << "Sequence: " << fFileName << " <invalid>" << endl;
+        gLog << pre << "Sequence: " << fFileName << " <invalid>" << endl;
         return;
     }
@@ -508,10 +526,11 @@
     gLog << "# Name: " << GetName() << endl;
     gLog << endl;
-    gLog << "Sequence:       " << fSequence << endl;
+    if (pre.IsNull())
+        gLog << "Sequence:       " << fSequence << endl;
     if (fMonteCarlo)
-        gLog << "MonteCarlo:     Yes" << endl;
-    gLog << "Period:         " << fPeriod << endl;
-    gLog << "Night:          " << fNight << endl << endl;
-    gLog << "LightCondition: ";
+        gLog << pre << "MonteCarlo:     Yes" << endl;
+    gLog << pre <<"Period:         " << fPeriod << endl;
+    gLog << pre << "Night:          " << fNight << endl << endl;
+    gLog << pre << "LightCondition: ";
     switch (fLightCondition)
     {
@@ -522,33 +541,50 @@
     case kDay:      gLog << "Day" << endl;     break;
     }
-    gLog << "Start:          " << fStart << endl;
-    gLog << "LastRun:        " << fLastRun << endl;
-    gLog << "NumEvents:      " << fNumEvents << endl;
-    gLog << "Project:        " << fProject << endl;
-    gLog << "Source:         " << fSource << endl;
-    gLog << "TriggerTable:   " << fTriggerTable << endl;
-    gLog << "HvSettings:     " << fHvSettings << endl << endl;
-    gLog << "Runs:";
-    for (int i=0; i<fRuns.GetSize(); i++)
-        gLog << " " << fRuns[i];
-    gLog << endl;
-    gLog << "CalRuns:";
-    for (int i=0; i<fCalRuns.GetSize(); i++)
-        gLog << " " << fCalRuns[i];
-    gLog << endl;
-    gLog << "PedRuns:";
-    for (int i=0; i<fPedRuns.GetSize(); i++)
-        gLog << " " << fPedRuns[i];
-    gLog << endl;
-    gLog << "DatRuns:";
-    for (int i=0; i<fDatRuns.GetSize(); i++)
-        gLog << " " << fDatRuns[i];
-    gLog << endl;
-
+    gLog << pre << "Start:          " << fStart << endl;
+    gLog << pre << "LastRun:        " << fLastRun << endl;
+    gLog << pre << "NumEvents:      " << fNumEvents << endl;
+    gLog << pre << "Project:        " << fProject << endl;
+    gLog << pre << "Source:         " << fSource << endl;
+    gLog << pre << "TriggerTable:   " << fTriggerTable << endl;
+    gLog << pre << "HvSettings:     " << fHvSettings << endl << endl;
+    if (fRuns.GetSize()>0)
+    {
+        gLog << pre << "Runs:";
+        for (int i=0; i<fRuns.GetSize(); i++)
+            gLog << " " << fRuns[i];
+        gLog << endl;
+    }
+    if (fCalRuns.GetSize()>0)
+    {
+        gLog << pre << "CalRuns:";
+        for (int i=0; i<fCalRuns.GetSize(); i++)
+            gLog << " " << fCalRuns[i];
+        gLog << endl;
+    }
+    if (fPedRuns.GetSize()>0)
+    {
+        gLog << pre << "PedRuns:";
+        for (int i=0; i<fPedRuns.GetSize(); i++)
+            gLog << " " << fPedRuns[i];
+        gLog << endl;
+    }
+    if (fDatRuns.GetSize()>0)
+    {
+        gLog << pre << "DatRuns:";
+        for (int i=0; i<fDatRuns.GetSize(); i++)
+            gLog << " " << fDatRuns[i];
+        gLog << endl;
+    }
+    if (fExclRuns.GetSize()>0)
+    {
+        gLog << pre << "Exclude:";
+        for (int i=0; i<fExclRuns.GetSize(); i++)
+            gLog << " " << fExclRuns[i];
+        gLog << endl;
+    }
     if (!fDataPath.IsNull())
-        gLog << endl << "DataPath: " << fDataPath << endl;
-
-    gLog << endl << "Comment: " << fComment << endl;
-
+        gLog << endl << pre << "DataPath: " << fDataPath << endl;
+
+    gLog << endl << pre << "Comment: " << fComment << endl;
 }
 
@@ -562,4 +598,6 @@
 // Return the number of files added.
 //
+// Runs which are in fExlRuns are ignored.
+//
 UInt_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, Bool_t raw) const
 {
@@ -576,4 +614,6 @@
 // Return the number of files added.
 //
+// Runs which are in fExlRuns are ignored.
+//
 UInt_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, Bool_t raw) const
 {
@@ -590,4 +630,6 @@
 // Return the number of files added.
 //
+// Runs which are in fExlRuns are ignored.
+//
 UInt_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, Bool_t raw) const
 {
@@ -604,4 +646,6 @@
 // Return the number of files added.
 //
+// Runs which are in fExlRuns are ignored.
+//
 UInt_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, Bool_t raw) const
 {
@@ -618,4 +662,6 @@
 // Return the number of files added.
 //
+// Runs which are in fExlRuns are ignored.
+//
 UInt_t MSequence::SetupDatRuns(MDirIter &iter, FileType_t type, const char *path) const
 {
@@ -653,7 +699,88 @@
         fRuns[nall+i] = first+i;
         if (runs)
-            (*runs)[nrun+i]  = first+i;
+            (*runs)[nrun+i] = first+i;
     }
     return add;
+}
+
+Bool_t MSequence::IsContained(const TArrayI &arr, UInt_t run) const
+{
+    for (int i=0; i<arr.GetSize(); i++)
+        if (run==(UInt_t)arr[i])
+            return kTRUE;
+    return kFALSE;
+}
+
+/*
+// --------------------------------------------------------------------------
+//
+// Check if num is found in arr. If it is found remove it. Copy all
+// following entries one back and decrease the array size by 1.
+//
+void MSequence::ExcludeRun(TArrayI &arr, UInt_t num)
+{
+    UInt_t *ptr = (UInt_t*)arr.GetArray();
+
+    Int_t i = 0;
+    for (i=0; i<arr.GetSize(); i++)
+        if (ptr[i]==num)
+            break;
+
+    if (i==arr.GetSize())
+        return;
+
+    for (; i<arr.GetSize()-1; i++)
+        ptr[i] = ptr[i+1];
+
+    arr.Set(arr.GetSize()-1);
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Exclude this run (i.e. add it to fExclRuns)
+//
+void MSequence::ExcludeRun(UInt_t num)
+{
+    /*
+     ExcludeRun(fRuns,    num);
+     ExcludeRun(fCalRuns, num);
+     ExcludeRun(fPedRuns, num);
+     ExcludeRun(fDatRuns, num);
+     */
+
+    if (IsExcluded(num))
+        return;
+
+    // set new entry
+    const Int_t n = fExclRuns.GetSize();
+    fExclRuns.Set(n+1);
+    fExclRuns[n] = num;
+
+    MJob::SortArray(fExclRuns);
+}
+
+// --------------------------------------------------------------------------
+//
+// Exclude all runs which are found in the list, e.g. "100 102 105"
+//
+void MSequence::ExcludeRuns(TString runs)
+{
+    TArrayI data;
+    Split(runs, data);
+
+    for (int i=0; i<data.GetSize(); i++)
+        ExcludeRun(data[i]);
+}
+
+const TString MSequence::GetExcludedRuns() const
+{
+    TString rc;
+    for (int i=0; i<fExclRuns.GetSize(); i++)
+    {
+        rc += fExclRuns[i];
+        rc += " ";
+    }
+    return rc(0, rc.Length()-1);
 }
 
@@ -698,2 +825,3 @@
     return kFALSE;
 }
+
Index: trunk/MagicSoft/Mars/mjobs/MSequence.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 8750)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 8780)
@@ -52,4 +52,6 @@
     TArrayI fDatRuns;
 
+    TArrayI fExclRuns;
+
     Bool_t fMonteCarlo;
 
@@ -58,5 +60,6 @@
     void Split(TString &runs, TArrayI &data) const;
     //void GetFileNames(TEnv &env, const TArrayI &arr);
-    LightCondition_t ReadLightCondition(TEnv &env) const;
+
+    LightCondition_t ReadLightCondition(TEnv &env, const char *prefix) const;
 
     const char *GetFileName(UInt_t num);
@@ -65,9 +68,11 @@
     UInt_t SetupRuns(MDirIter &iter, const TArrayI &arr, FileType_t type, const char *path=0) const;
     UInt_t AddRuns(UInt_t first, UInt_t last, TArrayI *runs);
+    void   ExcludeRun(TArrayI &arr, UInt_t num);
+    Bool_t IsContained(const TArrayI &arr, UInt_t num) const;
 
 public:
     MSequence() : fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
         fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fMonteCarlo(kFALSE) { }
-    MSequence(const char *fname, const char *path="");
+    MSequence(const char *fname, const char *path="", UInt_t id=(UInt_t)-1);
     MSequence(const MSequence &s) : fSequence(s.fSequence), fStart(s.fStart),
         fLastRun(s.fLastRun), fNumEvents(s.fNumEvents), fPeriod(s.fPeriod),
@@ -88,4 +93,6 @@
     Bool_t IsValid() const { return fSequence!=(UInt_t)-1; }
     Bool_t IsMonteCarlo() const { return fMonteCarlo; }
+    Bool_t IsExcluded(UInt_t run) const { return IsContained(fExclRuns, run); }
+    Bool_t IsContained(UInt_t run) const { return IsContained(fCalRuns, run) || IsContained(fPedRuns, run) || IsContained(fDatRuns, run); }
 
     void SetMonteCarlo(Bool_t ismc=kTRUE) { fMonteCarlo=ismc; }
@@ -102,9 +109,11 @@
     UInt_t SetupCalRuns(MDirIter &iter, FileType_t type, const char *path=0);
    */
+
     // Getter
-    UInt_t GetNumAllRuns() const { return fRuns.GetSize(); }
-    UInt_t GetNumDatRuns() const { return fDatRuns.GetSize(); }
-    UInt_t GetNumPedRuns() const { return fPedRuns.GetSize(); }
-    UInt_t GetNumCalRuns() const { return fCalRuns.GetSize(); }
+//    UInt_t GetNumAllRuns() const { return fRuns.GetSize(); }
+//    UInt_t GetNumDatRuns() const { return fDatRuns.GetSize(); }
+//    UInt_t GetNumPedRuns() const { return fPedRuns.GetSize(); }
+//    UInt_t GetNumCalRuns() const { return fCalRuns.GetSize(); }
+    UInt_t GetNumExclRuns() const { return fExclRuns.GetSize(); }
 
     UInt_t GetSequence() const { return fSequence; }
@@ -117,7 +126,8 @@
     const UInt_t GetFirstCalRun() const { return fCalRuns[0]; }
     const UInt_t GetLastCalRun() const { return fCalRuns[fCalRuns.GetSize()-1]; }
-    const TArrayI &GetPedRuns() const { return fPedRuns; } 
-    const TArrayI &GetCalRuns() const { return fCalRuns; } 
-    const TArrayI &GetDatRuns() const { return fDatRuns; } 
+//    const TArrayI &GetDatRuns() const { return fDatRuns; }
+//    const TArrayI &GetPedRuns() const { return fPedRuns; }
+//    const TArrayI &GetCalRuns() const { return fCalRuns; }
+    const TArrayI &GetExclRuns() const { return fExclRuns; }
 
     const MTime &GetStart() const { return fStart; }
@@ -129,4 +139,6 @@
     const TString &GetFileName() const { return fFileName; }
     const TString &GetDataPath() const { return fDataPath; }
+
+    const TString GetExcludedRuns() const;
 
     // Setter
@@ -143,7 +155,10 @@
     UInt_t AddDatRuns(UInt_t num) { return AddDatRuns(num, num); }
 
+    void ExcludeRun(UInt_t num);
+    void ExcludeRuns(TString runs);
+
     static Bool_t InflatePath(TString &seq, Bool_t ismc=kFALSE);
 
-    ClassDef(MSequence, 3)
+    ClassDef(MSequence, 4)
 };
 
