Index: trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C	(revision 7018)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C	(revision 7019)
@@ -104,5 +104,4 @@
 }
 
-
 int Process(MSQLServer &serv, TString fname, Bool_t dummy)
 {
@@ -235,5 +234,4 @@
     if (!ExistStr(serv, "fSequenceFirst", "MyMagic.Calibration", seq))
     {
-
         query = Form("INSERT MyMagic.Calibration SET"
                      " fSequenceFirst=%d,"
@@ -283,6 +281,4 @@
     }
 
-    cout << "q: " << query << endl;
-
     if (dummy)
         return 0;
Index: trunk/MagicSoft/Mars/datacenter/macros/fillstar.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillstar.C	(revision 7019)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillstar.C	(revision 7019)
@@ -0,0 +1,184 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 05/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Daniela Dorner, 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2005
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// fillstar.C
+// ==========
+//
+// This macro is used to read the star-output files.
+// These files are automatically called star00000.root.
+//
+// Make sure, that database and password are corretly set in a resource
+// file called sql.rc and the resource file is found.
+//
+// Returns 0 in case of failure and 1 in case of success.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include <iostream>
+
+#include <TEnv.h>
+#include <TRegexp.h>
+
+#include <TH1.h>
+#include <TProfile.h>
+#include <TFile.h>
+#include <TSQLResult.h>
+#include <TSQLRow.h>
+
+#include "MSQLServer.h"
+
+#include "MStatusArray.h"
+#include "MGeomCamMagic.h"
+#include "MBadPixelsCam.h"
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Checks whether an entry is already existing
+//
+Bool_t ExistStr(MSQLServer &serv, const char *column, const char *table, Int_t test)
+{
+    TString query(Form("SELECT %s FROM %s WHERE %s='%d'", column, table, column, test));
+    TSQLResult *res = serv.Query(query);
+    if (!res)
+        return kFALSE;
+
+    TSQLRow *row;
+
+    Bool_t rc = kFALSE;
+    while ((row=res->Next()))
+    {
+        if ((*row)[0])
+        {
+            rc = kTRUE;
+            break;
+        }
+    }
+
+    delete res;
+
+    return rc;
+}
+
+
+int Process(MSQLServer &serv, TString fname, Bool_t dummy)
+{
+    TFile file(fname, "READ");
+
+    MStatusArray arr;
+    if (arr.Read()<=0)
+    {
+        cout << "ERROR - Reading of MStatusDisplay failed." << endl;
+        return 0;
+    }
+
+    TProfile *h1 = (TProfile*)arr.FindObjectInCanvas("RingBroadening", "TProfile", "MHMuonPar");
+    if (!h1)
+    {
+        cout << "WARNING - Reading of RingBroadening failed." << endl;
+        return 0;
+    }
+
+    Float_t psf = (h1->Integral(5, 14) - 0.837)/0.0252;
+    psf = TMath::Nint(psf*10)/10.;
+    TString PSF = Form("%5.1f", psf);
+
+    TH1 *h = (TH1*)arr.FindObjectInCanvas("Islands", "TH1F", "MHImagePar");
+    if (!h)
+    {
+        cout << "WARNING - Reading of Islands failed." << endl;
+        return 0;
+    }
+
+    Float_t quality = h->GetMean();
+    quality = TMath::Nint(quality*10)/10.;
+    TString islands = Form("%5.1f", quality);
+
+    TString sequence = fname(TRegexp("star[0-9]+[.]root$"));
+    if (sequence.IsNull())
+    {
+        cout << "WARNING - Could get sequence# from filename: " << fname << endl;
+        return 0;
+    }
+
+    Int_t seq = atoi(sequence.Data()+5);
+
+    cout << "Sequence #" << seq << endl;
+    cout << "  PSF [mm]       " << Form("%5.1f", psf)     << endl;
+    cout << "  Island Quality " << Form("%5.1f", quality) << endl;
+
+    TString query;
+    if (!ExistStr(serv, "fSequenceFirst", "MyMagic.Star", seq))
+    {
+        query = Form("INSERT MyMagic.Star SET"
+                     " fSequenceFirst=%d,"
+                     " fMeanNumberIslands=%s, "
+                     " fPSF=%s ",
+                     seq, islands.Data(), PSF.Data());
+    }
+    else
+    {
+        query = Form("UPDATE MyMagic.Star SET"
+                     " fMeanNumberIslands=%s, "
+                     " fPSF=%s "
+                     " WHERE fSequenceFirst=%d ",
+                     islands.Data(), PSF.Data(), seq);
+    }
+
+    if (dummy)
+        return 0;
+
+    TSQLResult *res = serv.Query(query);
+    if (!res)
+    {
+        cout << "ERROR - Query failed: " << query << endl;
+        return 0;
+    }
+
+    return 1;
+}
+
+int fillstar(TString fname, Bool_t dummy=kTRUE)
+{
+    TEnv env("sql.rc");
+
+    MSQLServer serv(env);
+    if (!serv.IsConnected())
+    {
+        cout << "ERROR - Connection to database failed." << endl;
+        return 0;
+    }
+
+    cout << "fillstar" << endl;
+    cout << "---------" << endl;
+    cout << endl;
+    cout << "Connected to " << serv.GetName() << endl;
+    cout << "File: " << fname << endl;
+    cout << endl;
+
+    return Process(serv, fname, dummy);
+}
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillstar
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillstar	(revision 7019)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillstar	(revision 7019)
@@ -0,0 +1,162 @@
+#!/bin/sh
+#
+# ========================================================================
+#
+# *
+# * This file is part of MARS, the MAGIC Analysis and Reconstruction
+# * Software. It is distributed to you in the hope that it can be a useful
+# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+# * It is distributed WITHOUT ANY WARRANTY.
+# *
+# * Permission to use, copy, modify and distribute this software and its
+# * documentation for any purpose is hereby granted without fee,
+# * provided that the above copyright notice appear in all copies and
+# * that both that copyright notice and this permission notice appear
+# * in supporting documentation. It is provided "as is" without express
+# * or implied warranty.
+# *
+#
+#
+#   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
+#
+#   Copyright: MAGIC Software Development, 2000-2004
+#
+#
+# ========================================================================
+#
+#
+
+export ROOTSYS=/opt/root_v3.10.02
+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
+export PATH=$PATH:$ROOTSYS/bin
+
+set -C
+
+mars=/home/operator/Mars
+macrospath=$mars/datacenter/macros
+scriptspath=$mars/datacenter/scripts
+
+table=SequenceProcessStatus
+column=fFillStar
+date=NULL
+datetime=`date +%F-%H-%M-%S`
+year=`date +%Y`
+
+todofile=/magic/datacenter/lists/ToDo-$table-$column.txt
+lockpath=/magic/datacenter/locks
+logpath=/magic/datacenter/autologs
+getstatuslogpath=$logpath/getstatus/fillstar/$year
+getstatuslog=$getstatuslogpath/getstatus-fillstar-$datetime.log
+
+scriptlogpath=$logpath/run/fillstar/`date +%Y/%m/%d`
+if [ ! -d $scriptlogpath ]
+then
+  mkdir -pv $scriptlogpath 
+  if [ ! -d $scriptlogpath ]
+  then 
+     echo "could not make scriptlogpath "$scriptlogpath 
+     exit
+  fi
+fi
+
+scriptlog=$scriptlogpath/runfillstar-$datetime.log
+
+date >> $scriptlog 2>&1
+
+
+if [ ! -d $getstatuslogpath ]
+then
+  mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
+  if [ ! -d $getstatuslogpath ]
+  then 
+     echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
+     date  >> $scriptlog 2>&1
+     exit
+  fi
+fi
+
+cd $mars
+
+date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+checklock0=$?
+case $checklock0 in 
+    0)   echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
+    1)   echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
+         echo "-> fillstar is running -> exit" >> $scriptlog 2>&1
+         date  >> $scriptlog 2>&1
+         exit;;
+    *)   echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
+esac
+
+echo "getting list..." >> $scriptlog 2>&1
+check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
+
+case $check0 in 
+    1)   echo "check0=$check0 -> everthing ok -> run fillstar" >> $scriptlog 2>&1;;
+    *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+esac
+
+sequences=(`cat $todofile`)
+
+if [ "$sequences" = "" ]
+then 
+   echo "nothing to do -> exit"  >> $scriptlog 2>&1
+   rm -v $todofile >> $scriptlog 2>&1
+   rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+   date  >> $scriptlog 2>&1
+   exit
+fi
+
+echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
+
+for sequence in ${sequences[@]}
+do 
+   no=`printf %08d $sequence | cut -c 4`
+   path="/magic/data/star/"`printf %04d $no`"/"`printf %08d $sequence`
+   starfile=$path/star`printf %08d $sequence`.root
+   fillstarlogpath=$logpath/fillstar/`printf %04d $no`
+   echo "fillstarlogpath: "$fillstarlogpath >> $scriptlog 2>&1
+   if [ ! -d $fillstarlogpath ]
+   then
+     mkdir -pv $fillstarlogpath >> $scriptlog 2>&1
+     if [ ! -d $fillstarlogpath ]
+     then
+        echo "could not make fillstarlogpath $fillstarlogpath -> continue " >> $scriptlog 2>&1
+        continue
+     fi
+   fi
+   fillstarlog=$fillstarlogpath/fillstar-$sequence.log
+
+   echo "run fillstar for sequence $sequence" >> $scriptlog 2>&1
+   check2=`root -q -b $macrospath/fillstar.C+\("\"$starfile\""\,kFALSE\) | tee $fillstarlog | grep int | sed -e 's/(int)//'`
+   case $check2 in
+      1)   echo "check2=$check2 -> everthing ok " >> $scriptlog 2>&1
+           echo "-> inserting the status for fillstar for sequence $sequence into the db" >> $scriptlog 2>&1
+           setstatuslogpath=$logpath/setstatus/fillstar/`printf %04d $no`
+           if [ ! -d $setstatuslogpath ]
+           then
+             mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
+             if [ ! -d $setstatuslogpath ]
+             then
+                echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
+                continue
+             fi
+           fi
+           setstatuslog=$setstatuslogpath/setstatus-fillstar
+           check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog-$sequence.log | grep int | sed -e 's/(int)//'`
+           case $check4 in
+   	     1)   echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
+   	     *)   echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
+           esac
+   	  ;;
+      *)   echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+   esac
+done
+
+rm -v $todofile >> $scriptlog 2>&1
+rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+
+set +C
+
+date  >> $scriptlog 2>&1
+
Index: trunk/MagicSoft/Mars/datacenter/scripts/runcallisto
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runcallisto	(revision 7018)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runcallisto	(revision 7019)
@@ -43,5 +43,5 @@
 datetime=`date +%F-%H-%M-%S`
 year=`date +%Y`
-pno=8 # number of processes, i.e. number of todo-files
+pno=24 # number of processes, i.e. number of todo-files
 
 todofile=/magic/datacenter/lists/ToDo-$table-$column
Index: trunk/MagicSoft/Mars/datacenter/scripts/runstar
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runstar	(revision 7018)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runstar	(revision 7019)
@@ -42,5 +42,5 @@
 datetime=`date +%F-%H-%M-%S`
 year=`date +%Y`
-pno=8 # number of processes, i.e. number of todo-files
+pno=24 # number of processes, i.e. number of todo-files
 
 todofile=/magic/datacenter/lists/ToDo-$table-$column
@@ -91,5 +91,5 @@
 
 echo "checking if other todo-files are there" >> $scriptlog 2>&1
-if  ls $todofile-[1-9].txt >> $scriptlog 2>&1
+if  ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
 then 
    echo "other file(s) on disk " >> $scriptlog 2>&1
