Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 9130)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 9131)
@@ -18,4 +18,30 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2008/08/25 Daniela Dorner
+
+   * datacenter/macros/filloptical.C:
+     - added different return values in case of not matching lines
+     - added new columns (ellipticity and position angle)
+
+   * datacenter/macros/fillobjects.C, datacenter/macros/fillobjects2.C:
+     - InsertUpdate instead of Insert now
+
+   * datacenter/macros/fillobjects.C:
+     - 
+
+   * resources/TeVsources.txt, resources/good_compstars_R.txt:
+     - added new sources
+
+   * datacenter/scripts/copyscript:
+     - implemented new return values
+     - improved find for optical files
+
+   * datacenter/scripts/dbchk:
+     - adapted check for consistency between sequencefiles and content 
+       of database: now only done for sequences where the file is 
+       already written
+
+
 
  2008/08/22 Daniela Dorner
Index: /trunk/MagicSoft/Mars/datacenter/macros/filloptical.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/macros/filloptical.C	(revision 9130)
+++ /trunk/MagicSoft/Mars/datacenter/macros/filloptical.C	(revision 9131)
@@ -38,4 +38,7 @@
 // Returns 2 in case of invalid file or line in file.
 // Returns 3 in case of a missing object name in the database.
+// Returns 4 in case of a telescope line with more or less than 2 arguments
+// Returns 5 in case of a timestamp line with more or less than 4 arguments
+// Returns 6 in case of a object line with more or less than 10 arguments
 //
 ///////////////////////////////////////////////////////////////////////////
@@ -84,4 +87,6 @@
     TString skylevel;
     TString fwhm;
+    TString ellipticity;
+    TString posangle;
     TString aperturer;
     TString mag;
@@ -130,6 +135,8 @@
             if (arr->GetEntries()!=2)
             {
-                cout << "WARNING: Telescopeline with less or more than 2 arguments found " << endl;
-                return 2;
+                cout << "WARNING: Telescopeline with less or more than 2 arguments found in file " <<
+                    fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_[RV][_]?[12]?[.]instr", kFALSE)) << endl;
+                cout << "Line: " << line << endl;
+                return 4;
             }
             telescope=(*arr)[0]->GetName();
@@ -146,6 +153,8 @@
             if (arr->GetEntries()!=4)
             {
-                cout << "WARNING: Timestampline with less or more than 4 arguments found " << endl;
-                return 2;
+                cout << "WARNING: Timestampline with less or more than 4 arguments found in file " <<
+                    fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_[RV][_]?[12]?[.]instr", kFALSE)) << endl;
+                cout << "Line: " << line << endl;
+                return 5;
             }
             numexp+=1;
@@ -162,9 +171,10 @@
         else
         {
-            if (arr->GetEntries()!=8)
+            if (arr->GetEntries()!=10)
             {
-                cout << "WARNING: Objectline with less or more than 8 arguments found " << endl;
-                cout << line << endl;
-                return 2;
+                cout << "WARNING: Objectline with less or more than 10 arguments found in file " <<
+                    fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_[RV][_]?[12]?[.]instr", kFALSE)) << endl;
+                cout << "Line: " << line << endl;
+                return 6;
             }
 
@@ -197,16 +207,22 @@
             }
 
-            object    = Form("%s/%s", (*arr)[0]->GetName(),(*arr)[1]->GetName());
-            skylevel  = (*arr)[2]->GetName();
-            fwhm      = (*arr)[3]->GetName();
-            aperturer = (*arr)[4]->GetName();
-            mag       = (*arr)[5]->GetName();
-            magerr    = (*arr)[6]->GetName();
-            status    = (*arr)[7]->GetName();
+            object      = Form("%s/%s", (*arr)[0]->GetName(),(*arr)[1]->GetName());
+            skylevel    = (*arr)[2]->GetName();
+            fwhm        = (*arr)[3]->GetName();
+            ellipticity = (*arr)[4]->GetName();
+            posangle    = (*arr)[5]->GetName();
+            aperturer   = (*arr)[6]->GetName();
+            mag         = (*arr)[7]->GetName();
+            magerr      = (*arr)[8]->GetName();
+            status      = (*arr)[9]->GetName();
             //make sure that no nonsense values enter the db
             if (skylevel.Contains("-"))
                 skylevel = "NULL";
+            if (ellipticity.Contains("-"))
+                ellipticity = "NULL";
             if (fwhm.Contains("-") || !fwhm.IsFloat())
                 fwhm     = "NULL";
+            if (posangle.EndsWith("-"))
+                posangle     = "NULL";
             if (!mag.IsFloat())
                 mag      = "NULL";
@@ -221,14 +237,17 @@
             /*
             cout << numexp << "th exposure: star # " << numstars << endl;
-            cout << " timestamp: " << timestamp << endl;
-            cout << " exposure : " << exposure  << endl;
-            cout << " fitsfile : " << fitsfile  << endl;
-            cout << " object   : " << object << endl;
-            cout << " skylevel : " << skylevel  << endl;
-            cout << " fwhm     : " << fwhm      << endl;
-            cout << " aperturer: " << aperturer << endl;
-            cout << " mag      : " << mag << " +/- " << magerr << endl;
-            cout << " status   : " << status    << endl << endl;
+            cout << " timestamp  : " << timestamp   << endl;
+            cout << " exposure   : " << exposure    << endl;
+            cout << " fitsfile   : " << fitsfile    << endl;
+            cout << " object     : " << object      << endl;
+            cout << " skylevel   : " << skylevel    << endl;
+            cout << " fwhm       : " << fwhm        << endl;
+            cout << " ellipticity: " << ellipticity << endl;
+            cout << " posangle   : " << posangle    << endl;
+            cout << " aperturer  : " << aperturer   << endl;
+            cout << " mag        : " << mag << " +/- " << magerr << endl;
+            cout << " status     : " << status      << endl << endl;
             */
+
             Int_t statuskey   = serv.QueryKeyOfName("Status", status.Data());
             Int_t objectkey   = serv.QueryKeyOfName("Object", object.Data());
@@ -241,12 +260,13 @@
             query=Form("fTimeStamp='%s', fExposure=%s, fFitsFileKEY=%d, "
                        "fObjectKEY=%d, fSkyLevel=%s, fFWHM=%s, "
-                       "fApertureRadius=%s, fInstrumentalMag=%s, "
-                       "fInstrumentalMagErr=%s, fStatusKEY=%d, fCCDKEY=%d, "
-                       "fFilterKEY=%d, fTelescopeKEY=%d, fBandKEY=%d, "
-                       "fZenithDistance=%.1f ",
+                       "fEllipticity=%s, fPosAngle=%s, fApertureRadius=%s, "
+                       "fInstrumentalMag=%s, fInstrumentalMagErr=%s, "
+                       "fStatusKEY=%d, fCCDKEY=%d, fFilterKEY=%d, "
+                       "fTelescopeKEY=%d, fBandKEY=%d, fZenithDistance=%.1f ",
                        timestamp.Data(), exposure.Data(), fitsfilekey,
                        objectkey, skylevel.Data(), fwhm.Data(),
-                       aperturer.Data(), mag.Data(), magerr.Data(),
-                       statuskey, ccdkey, filterkey, telkey, bandkey, zd);
+                       ellipticity.Data(), posangle.Data(), aperturer.Data(),
+                       mag.Data(), magerr.Data(), statuskey, ccdkey,
+                       filterkey, telkey, bandkey, zd);
 
             /*
Index: /trunk/MagicSoft/Mars/datacenter/scripts/copyscript
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 9130)
+++ /trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 9131)
@@ -216,5 +216,5 @@
 #moving the files
 file=""
-opticalfiles=`find $transdir/optical -name '*.instr'`
+opticalfiles=`find $transdir/optical -regextype posix-egrep -regex '^$transdir/optical/20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_[RV][_]?[12]?[.]instr$'`
 for opticalfile in $opticalfiles
 do
@@ -243,12 +243,19 @@
          fi
          ;;
-      3) echo " checkfilloptical=$checkfilloptical - Error: position of one object is missing in the database" >> $scriptlog 2>&1 
-         printprocesslog "ERROR filloptical.C failed for $opticalfile because the position of one object is missing in the database"
-         continue
-         ;;
-      *) echo " checkfilloptical=$checkfilloptical - Error -> go on with next file" >> $scriptlog 2>&1 
-         printprocesslog "ERROR filloptical.C failed for $opticalfile"
-         continue
-         ;;
+      3) echo " checkfilloptical=$checkfilloptical - ERROR filloptical.C failed for $opticalfile: position of one object is missing in the database" >> $scriptlog 2>&1 
+         printprocesslog "ERROR filloptical.C failed for $opticalfile: position of one object is missing in the database"
+         continue ;;
+      4) echo " checkfilloptical=$checkfilloptical - ERROR filloptical.C failed for $opticalfile: telescope line with more or less than 2 arguments" >> $scriptlog 2>&1 
+         printprocesslog "ERROR filloptical.C failed for $opticalfile: telescope line with more or less than 2 arguments"
+         continue ;;
+      5) echo " checkfilloptical=$checkfilloptical - ERROR filloptical.C failed for $opticalfile: timestamp line with more or less than 4 arguments" >> $scriptlog 2>&1 
+         printprocesslog "ERROR filloptical.C failed for $opticalfile: timestamp line with more or less than 4 arguments"
+         continue ;;
+      6) echo " checkfilloptical=$checkfilloptical - ERROR filloptical.C failed for $opticalfile: object line with more or less than 8 arguments" >> $scriptlog 2>&1 
+         printprocesslog "ERROR filloptical.C failed for $opticalfile: object line with more or less than 8 arguments"
+         continue ;;
+      *) echo " checkfilloptical=$checkfilloptical - ERROR filloptical.C failed for $opticalfile -> go on with next file" >> $scriptlog 2>&1 
+         printprocesslog "ERROR filloptical.C failed for $opticalfile (returned $checkfilloptical)"
+         continue ;;
    esac
 done
Index: /trunk/MagicSoft/Mars/datacenter/scripts/dbchk
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/scripts/dbchk	(revision 9130)
+++ /trunk/MagicSoft/Mars/datacenter/scripts/dbchk	(revision 9131)
@@ -161,5 +161,5 @@
 # CHECK 2
 echo "Checking if all sequences in Sequences have a corresponding sequence files" >> $scriptlog 2>&1
-sequences=`echo SELECT fSequenceFirst FROM Sequences | mymysql`
+sequences=`echo SELECT fSequenceFirst FROM Sequences left join SequenceProcessStatus using (fSequenceFirst,fTelescopeNumber) where not isnull(fSequenceFileWritten) | mymysql`
 for sequence in $sequences
 do
Index: /trunk/MagicSoft/Mars/datacenter/tools/fillobjects.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/tools/fillobjects.C	(revision 9130)
+++ /trunk/MagicSoft/Mars/datacenter/tools/fillobjects.C	(revision 9131)
@@ -118,7 +118,8 @@
 
         query+=Form(", fObjectName='%s/%s'", (*arr)[0]->GetName(), (*arr)[1]->GetName());
+        where=Form(" fObjectName='%s/%s'", (*arr)[0]->GetName(), (*arr)[1]->GetName());
         delete arr;
 
-        if (serv.Insert("Object", query)==kFALSE)
+        if (serv.InsertUpdate("Object", query, where)==kFALSE)
             return 2;
         num +=1;
Index: /trunk/MagicSoft/Mars/datacenter/tools/fillobjects2.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/tools/fillobjects2.C	(revision 9130)
+++ /trunk/MagicSoft/Mars/datacenter/tools/fillobjects2.C	(revision 9131)
@@ -118,6 +118,7 @@
 
         query+=Form(", fObjectName='%s'", object.Data());
+        where=Form(" fObjectName='%s'", object.Data());
 
-        if (serv.Insert("Object", query)==kFALSE)
+        if (serv.InsertUpdate("Object", query, where)==kFALSE)
             return 2;
         num +=1;
Index: /trunk/MagicSoft/Mars/resources/TeVsources.txt
===================================================================
--- /trunk/MagicSoft/Mars/resources/TeVsources.txt	(revision 9130)
+++ /trunk/MagicSoft/Mars/resources/TeVsources.txt	(revision 9131)
@@ -48,2 +48,9 @@
 B3_2247+381      -     22 50 05.7   +38 24 37       -     ?
 3C_454.3         -     22 53 57.7   +16 08 54       -     ?
+--------------------------------------------------------------
+RGB_0152+017     -     01 52 39.6   +01 47 17       -     ?
+MS_0158+002      -     02 01 06.2   +00 34 00       -     ?
+4C_29_45         -     11 59 31.8   +29 14 44       -     ?
+ON_238           -     12 24 54.4   +21 22 46       -     ?
+PKS_1510-089     -     15 12 50.5   -09 05 59       -     ? 
+B2_1633+38       -     16 35 15.5   +38 08 04       -     ?
Index: /trunk/MagicSoft/Mars/resources/good_compstars_R.txt
===================================================================
--- /trunk/MagicSoft/Mars/resources/good_compstars_R.txt	(revision 9130)
+++ /trunk/MagicSoft/Mars/resources/good_compstars_R.txt	(revision 9131)
@@ -4,4 +4,5 @@
 1ES_0033+595 D  13.66 1.46  prim
 1ES_0033+595 E  13.91 0.55  -
+1ES_0033+595 F  16.67 0.87  control
 
 1ES_0120+340 A  13.13 0.50  -
@@ -10,4 +11,6 @@
 1ES_0120+340 D  14.02 0.51  -
 1ES_0120+340 E  13.55 0.56  -
+1ES_0120+340 F  16.76 0.57  -
+1ES_0120+340 G  16.43 0.45  control
 
 RGB_0136+391 A  13.13 0.60  control
@@ -16,4 +19,14 @@
 RGB_0136+391 D  14.42 0.46  -
 RGB_0136+391 E  14.84 0.51  -
+RGB_0136+391 F  16.56 0.42  -
+
+RGB_0152+017 A  14.35 0.50  control
+RGB_0152+017 B  14.22 0.50  prim
+RGB_0152+017 C  16.80 0.50  -
+RGB_0152+017 D  17.25 0.50  -
+RGB_0152+017 E  15.88 0.50  -
+
+MS_0158+002  A  12.75 0.37 prim
+MS_0158+002  B  12.76 0.54 control
 
 RGB_0214+517 A  13.85 0.51  prim
@@ -22,15 +35,13 @@
 RGB_0214+517 D  15.09 0.47  -
 RGB_0214+517 E  15.19 0.44  -
-RGB_0214+517 F1 15.55 0.50  -
-RGB_0214+517 F2 15.61 0.50  -
-RGB_0214+517 F3 15.80 0.50  -
-
-
-3C_66A       A  13.38 0.22  prim
-3C_66A       B  14.28 0.49  control
-3C_66A       C1 12.70 0.09  -
-3C_66A       C2 13.62 0.56  -
+
+3C_66A       A   13.38 0.22  prim
+3C_66A       B   14.28 0.49  control
+3C_66A       C1  12.70 0.09  -
+3C_66A       C2  13.62 0.56  -
 
 1ES_0229+200 A  13.80 0.50  prim
+1ES_0229+200 B  16.05 0.50  -
+1ES_0229+200 C  15.83 0.50  control
 
 AO_0235+164  1  12.69 0.34  -
@@ -43,4 +54,5 @@
 HB89_0317+185 A  11.55 0.31 -
 HB89_0317+185 B  13.33 0.43 prim
+HB89_0317+185 C  20.00 0.50 control
 
 1ES_0323+022 A  12.33 0.52  -
@@ -77,4 +89,5 @@
 1ES_0806+524 C5 15.32 0.30  -
 
+0836+710     A  16.59 1.01  control
 0836+710     B  14.85 0.45  -
 0836+710     C  13.53 0.38  prim
@@ -86,4 +99,10 @@
 OJ_287      C2  15.66 0.46  -
 
+S4_0954+65   C1 13.96 0.41  prim
+S4_0954+65   C2 14.12 0.49  -
+S4_0954+65   C3 14.25 0.69  -
+S4_0954+65   C4 14.43 0.92  -
+S4_0954+65   C6 15.69 0.48  control
+ 
 1ES_1011+496 A  13.40 0.47  -
 1ES_1011+496 B  15.44 0.44  control
@@ -105,4 +124,5 @@
 RGB_1117+202 A  11.90 0.38  -
 RGB_1117+202 B  12.02 0.38  -
+RGB_1117+202 C  20.00 0.50  -
 RGB_1117+202 D  14.82 0.70  -
 RGB_1117+202 E  13.56 0.42  prim
@@ -113,6 +133,4 @@
 Mkn_180      3  15.13 0.36  -
 Mkn_180      4  15.66 0.34  -
-Mkn_180      F1 15.93 0.50  -
-Mkn_180      F2 15.96 0.50  -
 
 RGB_1136+676 A  14.48 0.66  -
@@ -122,13 +140,29 @@
 RGB_1136+676 E  15.80 0.42  control
 
+4C_29_45    13  14.97 0.39  prim
+4C_29_45    14  15.53 0.36  control
+4C_29_45    15  16.30 0.3   -
+4C_29_45     1  13.01 0.38  -
+
 ON_325       B  14.59 0.37  prim
+ON_325       C1 16.21 0.29  control
 
 1ES_1218+304 A  12.06 0.41  -
 1ES_1218+304 B  13.61 0.40  prim
 1ES_1218+304 C  15.58 0.62  control
-1ES_1218+304 F1 15.59 0.50  -
 
 ON_231       A  11.72 0.36  -
+ON_231       C1 16.03 0.57  control
 ON_231       D  13.86 0.95  prim
+
+ON_238       1  13.84 0.35  prim
+ON_238       2  14.56 0.30  -
+ON_238       3  15.26 0.40  -
+ON_238       4  15.83 0.41  control
+
+3C_273       C  11.30 0.57  -
+3C_273       D  12.31 0.37  -
+3C_273       E  12.27 0.42  prim
+3C_273       G  13.16 0.40  control
 
 3C_279	     1	15.45 0.49  control
@@ -136,4 +170,5 @@
 3C_279	     3  14.53 0.37  prim
 3C_279	     4  12.57 0.43  -
+3C_279	     5  20.00 0.00  -
 3C_279	     6  12.45 0.36  -
 3C_279	     7  15.13 0.53  -
@@ -142,4 +177,5 @@
 RGB_1417+257 A  13.78 0.57  prim
 RGB_1417+257 C1 15.29 1.16  -
+RGB_1417+257 C2 16.13 0.59  control
 
 PG_1424+240  C1 13.20 0.39  prim
@@ -152,17 +188,23 @@
 1ES_1426+428 D  15.20 0.33  -
 
-1ES_1544+820 A  14.59 0.37  -
-1ES_1544+820 B  15.35 0.80  control
-1ES_1544+820 C  14.41 0.38  -
-1ES_1544+820 D  12.87 0.31  prim
-1ES_1544+820 E  14.24 0.41  -
-
-Mkn_501      1  12.11 0.50  -
+PKS_1510-089 A  14.25 0.37  prim
+PKS_1510-089 B  14.63 0.55  control
+PKS_1510-089 C  16.93 0.59  -
+PKS_1510-089 D  16.10 0.43  -
+PKS_1510-089 1  11.14 0.40  -
+PKS_1510-089 2  12.88 0.29  -
+PKS_1510-089 3  13.95 0.40  -
+PKS_1510-089 5  14.35 0.35  -
+
+B2_1633+38   A  15.48 0.35  prim
+B2_1633+38   B  15.44 0.47  control
+B2_1633+38   C  17.22 0.69  -
+
+Mkn_501      1  12.11 0.50  control
 Mkn_501      2  12.79 0.44  -
-Mkn_501      3  14.80 0.44  control
+Mkn_501      3  14.80 0.44  -
 Mkn_501      4  14.96 0.34  prim
-Mkn_501      5  15.08 0.43  prim
+Mkn_501      5  15.08 0.43  -
 Mkn_501      6  14.99 0.68  prim
-Mkn_501      F1 15.78 0.50  -
 
 H_1722+119   C1 10.94 1.04  -
