Index: trunk/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/Mars/mjobs/MSequence.cc	(revision 11453)
+++ trunk/Mars/mjobs/MSequence.cc	(revision 12795)
@@ -181,4 +181,12 @@
 //   + fTelescope
 //
+//  Class Version 7:
+//  ----------------
+//   + fDrsRuns
+//   + fDrsRunsSub
+//   + fDrsFiles
+//   + fDrsFilesSub
+//   + fDrsSequence
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MSequenceSQL.h"
@@ -417,4 +425,9 @@
         switch (type&kFilePaths)
         {
+        case kDrs:
+        case kFits:
+            d += "raw/";
+            d += fNight.GetStringFmt("%Y/%m/%d");
+            break;
         case kRaw:  // rawdata
         case kRoot: // mcdata
@@ -455,4 +468,21 @@
         // /magic/simulated/ceres/001/000/0001/cer123456
         return MString::Format("cer%06d", -run);
+    }
+
+    TString n;
+
+    if ((type&kRunType)==kDrsFile)
+    {
+        n += night.GetStringFmt("%Y%m%d_");
+        n += MString::Format("%03d", run);
+        n += ".drs.fits.?g?z?";
+        return n;
+    }
+    if ((type&kFileType)==kFits)
+    {
+        n += night.GetStringFmt("%Y%m%d_");
+        n += MString::Format("%03d", run);
+        n += ".fits.?g?z?";
+        return n;
     }
 
@@ -489,6 +519,4 @@
 
     // ------------- Create file name --------------
-    TString n;
-
     if (night)
         n += night.GetStringFmt("%Y%m%d_");
@@ -667,4 +695,22 @@
 }
 
+UInt_t MSequence::GetDrsFile() const
+{
+    if (fDrsRuns.GetSize()==0)
+        return fDrsFiles[0];
+
+    UInt_t rc = 0;
+    for (int i=0; i<fDrsFiles.GetSize(); i++)
+    {
+        for (int j=0; j<fPedRuns.GetSize(); j++)
+        {
+            if (fDrsFiles[i]==fPedRuns[j])
+                rc = fDrsFiles[i];
+        }
+    }
+
+    return rc;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -675,4 +721,7 @@
 TString MSequence::GetFileName(UInt_t i, const TArrayI &arr, const TArrayI &sub, FileType_t type, const char *path) const
 {
+    if (i>=(UInt_t)arr.GetSize())
+        return "";
+
     if (IsExcluded(arr[i], sub[i]))
         return "0";
@@ -693,4 +742,12 @@
     switch ((RunType_t)(type&(kRunType|kExcl)))
     {
+    case kDrsRun:
+        r = &fDrsRuns;
+        f = &fDrsRunsSub;
+        break;
+    case kDrsFile:
+        r = &fDrsFiles;
+        f = &fDrsFilesSub;
+        break;
     case kPed:
         r = &fPedRuns;
@@ -913,4 +970,5 @@
     fLastRun   = GetEnvValue2(env, prefix, "LastRun",   -1);
     fNumEvents = GetEnvValue2(env, prefix, "NumEvents", -1);
+    fDrsSequence = GetEnvValue2(env, prefix, "DrsSequence", 0);
 
     TString str;
@@ -935,5 +993,10 @@
     Split(env, prefix, "PedRuns", fPedRuns,  fPedRunsSub);
     Split(env, prefix, "DatRuns", fDatRuns,  fDatRunsSub);
+    Split(env, prefix, "DrsRuns", fDrsRuns,  fDrsRunsSub);
+    Split(env, prefix, "DrsFiles",fDrsFiles, fDrsFilesSub);
     Split(env, prefix, "Exclude", fExclRuns, fExclRunsSub);
+
+    if (fDrsRuns.GetSize()==0 && fDrsFiles.GetSize()>1)
+        gLog << warn << "WARNING - In a data sequence only one DrsFiles entry makes sense." << endl;
 
     // Dummies:
@@ -1089,4 +1152,6 @@
 //   fDatRuns
 //   fDatRunsSub
+//   fDrsRuns
+//   fDrsRunsSub
 //   fExclRuns
 //   fExclRunsSub
@@ -1104,4 +1169,5 @@
         fPedRuns     == s.fPedRuns     &&
         fDatRuns     == s.fDatRuns     &&
+        fDrsRuns     == s.fDrsRuns     &&
         fExclRuns    == s.fExclRuns    &&
 
@@ -1109,4 +1175,5 @@
         Check(fPedRunsSub,  s.fPedRunsSub) &&
         Check(fDatRunsSub,  s.fDatRunsSub) &&
+        Check(fDrsRunsSub,  s.fDrsRunsSub) &&
         Check(fExclRunsSub, s.fExclRunsSub);
 }
@@ -1397,4 +1464,6 @@
     if (fLastRun!=(UInt_t)-1)
         out << pre << "LastRun:        " << fLastRun << endl;
+    if (fDrsSequence)
+        out << pre << "DrsSequence:    " << fDrsSequence << endl;
     if (fNumEvents!=(UInt_t)-1)
         out << pre << "NumEvents:      " << fNumEvents << endl;
@@ -1416,4 +1485,6 @@
         PrintRunsClassic(out, pre, "PedRuns:  ", fPedRuns);
         PrintRunsClassic(out, pre, "DataRuns: ", fDatRuns);
+        PrintRunsClassic(out, pre, "DrsRuns:  ", fDrsRuns);
+        PrintRunsClassic(out, pre, "DrsFiles: ", fDrsFiles);
         PrintRunsClassic(out, pre, "Exclude:  ", fExclRuns);
     }
@@ -1425,9 +1496,11 @@
         // Should we add a check forbidding the same run in
         // Cal/Ped/Data? What about the Exclude?
-        /*str +=*/ PrintRuns(out, pre, "Runs:    ", fRuns,     fRunsSub);
-        str += PrintRuns(out, pre, "CalRuns: ", fCalRuns,  fCalRunsSub);
-        str += PrintRuns(out, pre, "PedRuns: ", fPedRuns,  fPedRunsSub);
-        str += PrintRuns(out, pre, "DatRuns: ", fDatRuns,  fDatRunsSub);
-        str += PrintRuns(out, pre, "Exclude: ", fExclRuns, fExclRunsSub);
+        /*str +=*/ PrintRuns(out, pre, "Runs:     ", fRuns,     fRunsSub);
+        str += PrintRuns(out, pre, "CalRuns:  ", fCalRuns,  fCalRunsSub);
+        str += PrintRuns(out, pre, "PedRuns:  ", fPedRuns,  fPedRunsSub);
+        str += PrintRuns(out, pre, "DatRuns:  ", fDatRuns,  fDatRunsSub);
+        str += PrintRuns(out, pre, "DrsRuns:  ", fDrsRuns,  fDrsRunsSub);
+        str += PrintRuns(out, pre, "DrsFiles: ", fDrsFiles, fDrsFilesSub);
+        str += PrintRuns(out, pre, "Exclude:  ", fExclRuns, fExclRunsSub);
     }
 
@@ -1442,4 +1515,7 @@
     if (!fComment.IsNull())
         out << pre << "Comment: " << fComment << endl;
+
+    if (GetDrsFile())
+        out << "# DrsFile: " << GetDrsFile() << endl;
 }
 
