Index: trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C	(revision 9197)
+++ trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C	(revision 9213)
@@ -345,5 +345,5 @@
         query += ", fL1TriggerTableKEY, fL2TriggerTableKEY,"
             " fHvSettingsKEY, fDiscriminatorThresholdTableKEY,"
-            " fTriggerDelayTableKEY, fObservationModeKEY "
+            " fTriggerDelayTableKEY, fObservationModeKEY, fSumTriggerFlagKEY "
             " FROM RunData WHERE fRunTypeKEY=2 AND ";
         query += where;
@@ -355,5 +355,5 @@
 
         row = res->Next();
-        if (!row || res->GetFieldCount()!=8)
+        if (!row || res->GetFieldCount()!=9)
         {
             cout << "ERROR - No result from query: " << query << endl;
@@ -383,4 +383,5 @@
         query1 += Form(" fLightConditionsKEY=%s,",             light.Data());
         query1 += Form(" fObservationModeKEY=%s, ",            (*row)[7]);
+        query1 += Form(" fSumTriggerFlagKEY=%s, ",             (*row)[8]);
         query1 += "fManuallyChangedKEY=1";
 
Index: trunk/MagicSoft/Mars/datacenter/macros/filldotrun.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/filldotrun.C	(revision 9197)
+++ trunk/MagicSoft/Mars/datacenter/macros/filldotrun.C	(revision 9213)
@@ -87,5 +87,4 @@
 using namespace std;
 
-
 Int_t insert(MSQLMagic &serv, Bool_t dummy, TString filename)
 {
@@ -96,7 +95,14 @@
         return -1;
     }
+    //read the file a second time for the check for number of columns
+    ifstream fin2(filename);
 
     TString strng;
+    TString strng2;
+    TObjArray *array = new TObjArray();
+    Int_t check=0;
+
     strng.ReadLine(fin);
+    strng2.ReadLine(fin2);
     if (strng!=TString("[CC Plain Run Summary File]"))
     {
@@ -108,4 +114,5 @@
 
     strng.ReadLine(fin);
+    strng2.ReadLine(fin2);
     TRegexp reg("[0-9][0-9][0-9][0-9][0-9][0-9]-[0-9]");
     TString arehucas = strng(reg);
@@ -135,4 +142,5 @@
     {
         strng.ReadLine(fin);
+        strng2.ReadLine(fin2);
         if (!strng.BeginsWith("Telescope M"))
         {
@@ -145,4 +153,5 @@
     {
         strng.ReadLine(fin);
+        strng2.ReadLine(fin2);
         if (strng[0]!='#')
         {
@@ -157,4 +166,39 @@
     while (1)
     {
+        // ===== Check for number of columns in file =====
+        // different arehucas versions provide a different number of columns:
+        // 200405050 - 200405140: 18 columns
+        // 200405180 - 200407270: 35 columns
+        // 200411130 - 200510250: 43 columns
+        // 200603300 - 200802200: 52 columns
+        // 200805190 - 200809120: 54 columns
+        // > 200812040:           55 columns
+        //
+
+        strng2.ReadLine(fin2);
+        //fill an array with the values separated by ' '
+        array=strng2.Tokenize(" ");
+        check=array->GetEntries();
+        cout << check << endl;
+        //check the number of columns for the different versions, if there is an empty line (check=0), do nothing
+        if (check != 0)
+        {
+            if ((version <= 200405140 && check != 18) ||
+                (version >  200405140 && version <= 200407270 && check != 35) ||
+                (version >  200407270 && version <= 200510250 && check != 43) ||
+                (version >  200510250 && version <= 200802200 && check != 52) ||
+                (version >  200802200 && version <= 200809120 && check != 54) ||
+                (version >  200809120 && check != 55))
+            {
+                strng.ReadLine(fin);
+                cout << "ERROR - Number of columns doesn't match number of required columns." << endl;
+                array->Delete();
+                continue;
+            }
+        }
+        array->Delete();
+
+
+        // ========== Col 1: Telescope Number =========
         Int_t telnumber = 1; // FIXME: "NULL"?
         if (version >=200805190)
@@ -181,5 +225,5 @@
         }
 
-        // ========== Col 1: Run Number =========
+        // ========== Col 2: Run Number =========
         //Reading the line
         //and converting some strings to ints/floats
@@ -200,4 +244,5 @@
         }
 
+        // ========== Col 3: Subrun Number ========= starting with version 200805190
         Int_t filenumber = 0; // FIXME: "NULL"?
         if (version >=200805190)
@@ -217,5 +262,5 @@
         }
 
-        // ========== Col 2: Run Type =========
+        // ========== Col 4: Run Type =========
         strng.ReadToDelim(fin, ' ');
         if (strng.Contains("???"))
@@ -232,5 +277,5 @@
         //cout << runtype << " ";
 
-        // ========== Col 3,4: Start Time =========
+        // ========== Col 5,6: Start Time =========
         TString startdate, starttime;
         startdate.ReadToDelim(fin, ' ');
@@ -238,5 +283,5 @@
         //cout << startdate << " " << starttime << " ";
 
-        // ========== Col 5,6: Stop Time =========
+        // ========== Col 7,8: Stop Time =========
         TString stopdate, stoptime;
         stopdate.ReadToDelim(fin, ' ');
@@ -253,5 +298,5 @@
             stoptime="00:00:00";
 
-        // ========== Col 7: Source Name =========
+        // ========== Col 9: Source Name =========
         strng.ReadToDelim(fin, ' ');
         if (strng.Contains("???"))
@@ -266,5 +311,5 @@
         //cout << sourcekey << " ";
 
-        // ========== Col 8,9: Local source position =========
+        // ========== Col 10,11: Local source position =========
         strng.ReadToDelim(fin, ' ');
         Float_t zd = atof(strng.Data());
@@ -275,5 +320,5 @@
         //cout << zd << " " << az << " ";
 
-        // ========== Col 10: Number of Events =========
+        // ========== Col 12: Number of Events =========
         strng.ReadToDelim(fin, ' ');
         Int_t evtno = atoi(strng.Data());
@@ -281,5 +326,5 @@
         //cout << evtno << " ";
 
-        // ========== Col 11: Project Name =========
+        // ========== Col 13: Project Name =========
         strng.ReadToDelim(fin, ' ');
         if (strng.Contains("???"))
@@ -294,6 +339,6 @@
         //cout << projkey << " ";
 
-        // ========== Col 12: Trigger Table Name =========
-        // starting from version 200411130: Col 12,13: Trigger Table Name =========
+        // ========== Col 14: Trigger Table Name =========
+        // starting from version 200411130: Col 14,15: Trigger Table Name =========
         strng.ReadToDelim(fin, ' ');
         if (strng.Contains("???"))
@@ -401,5 +446,5 @@
         }
 
-        // ========== Col 13-15: TrigRate, L2 UnPresc Rate, L2 Presc Rate ==========
+        // ========== Col 16-18: TrigRate, L2 UnPresc Rate, L2 Presc Rate ==========
         strng.ReadToDelim(fin, ' ');
         Float_t trigrate = atof(strng.Data());
@@ -411,5 +456,5 @@
         Float_t l2prrate = atof(strng.Data());
 
-        // ========== Col 16,17: DaqRate, Storage Rate ==========
+        // ========== Col 19,20: DaqRate, Storage Rate ==========
         strng.ReadToDelim(fin, ' ');
         Float_t daqrate = atof(strng.Data());
@@ -418,5 +463,5 @@
         Float_t storerate = atof(strng.Data());
 
-        // ========== Col 18: HV table =========
+        // ========== Col 21: HV table =========
         if (version==200405050 || version==200405140)
             strng.ReadToDelim(fin, '\n');
@@ -443,5 +488,5 @@
         if (version>=200411130)
         {
-            // ========== Col 19-35: DC and HV-values, mjd =========
+            // ========== Col 22-38: DC and HV-values, mjd =========
             for (int i=0 ; i<17 ; i++)
             {
@@ -449,5 +494,5 @@
             }
 
-            // ========== Col 36: test-flag =========
+            // ========== Col 39: test-flag =========
             strng.ReadToDelim(fin, ' ');
             if (strng.Contains("???"))
@@ -461,5 +506,5 @@
             }
 
-            // ========== Col 37: light conditions =========
+            // ========== Col 40: light conditions =========
             strng.ReadToDelim(fin, ' ');
             if (strng.Contains("???"))
@@ -473,5 +518,5 @@
             }
 
-            // ========== Col 38: discriminator threshold table =========
+            // ========== Col 41: discriminator threshold table =========
             strng.ReadToDelim(fin, ' ');
             if (strng.Contains("???"))
@@ -485,5 +530,5 @@
             }
 
-            // ========== Col 39: trigger delay table =========
+            // ========== Col 42: trigger delay table =========
             strng.ReadToDelim(fin, ' ');
             if (strng.Contains("???"))
@@ -497,9 +542,9 @@
             }
 
-            // ========== Col 40,41: Telescope RA and Dec sent to drive =========
-            strng.ReadToDelim(fin, ' ');
-            strng.ReadToDelim(fin, ' ');
-
-            // ========== Col 42: Calibration Script =========
+            // ========== Col 43,44: Telescope RA and Dec sent to drive =========
+            strng.ReadToDelim(fin, ' ');
+            strng.ReadToDelim(fin, ' ');
+
+            // ========== Col 45: Calibration Script =========
             if (version>=200411130 && version<=200510250)
                 strng.ReadToDelim(fin, '\n');
@@ -521,5 +566,5 @@
         if (version>=200603300)
         {
-            // ========== Col 43: Observation Mode =========
+            // ========== Col 46: Observation Mode =========
             strng.ReadToDelim(fin, ' ');
             if (strng.Contains("???"))
@@ -533,5 +578,5 @@
             }
 
-            // ========== Col 44-51: Source RA and Dec, DT's and IPR =========
+            // ========== Col 47-54: Source RA and Dec, DT's and IPR =========
             for (int i=0 ; i<7 ; i++)
             {
@@ -547,5 +592,5 @@
         if (version>=200812040)
         {
-            // ========= Col 52: SumTrigger flag =========
+            // ========= Col 55: SumTrigger flag =========
             strng.ReadToDelim(fin, '\n');
             if (strng.Contains("???"))
