Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 9220)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 9221)
@@ -18,4 +18,20 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2009/01/14 Daniel Hoehne-Moench
+
+   * datacenter/scripts/sourcefile:
+     - extended errorcoding on mc run process status
+
+   * datacenter/scripts/runmccallisto, runmcstar:
+     - deleted unnecessary lines, adapted to primary structure
+
+   * datacenter/macros/fillmcsignal.C, fillmccalib.C, fillmcstar.C:
+     - added
+
+   * datacenter/scripts/fillmccallisto, fillmcstar:
+     - added
+
+
 
  2009/01/14 Thomas Bretz
Index: /trunk/MagicSoft/Mars/datacenter/macros/fillmccalib.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/macros/fillmccalib.C	(revision 9221)
+++ /trunk/MagicSoft/Mars/datacenter/macros/fillmccalib.C	(revision 9221)
@@ -0,0 +1,306 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 08/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Daniela Dorner, 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
+!   Author(s): Daniel Hoehne-Moench, 01/2009 <mailto:hoehne@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2009
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// fillmccalib.C
+// ===========
+//
+// This macro is used to read the calibration-/callisto-output files.
+// These files are automatically called calib00000.root.
+//
+// From this file the MBadPixelsCam and the MGeomCam is extracted. If
+// the geometry isn't found MGeomCamMagic is used as a default.
+// The bad pixel information and other information, extracted from the status
+// display, is inserted into the database in the table MCCalibration, which
+// stores the results from the calibration.
+// The corresponding sequence number is extracted from the filename...
+//
+// Usage:
+//  .x fillmccalib.C("/magic/montecarlo/callisto/0002/00048270/calib00028270.root", kTRUE)
+//
+// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
+// switched on and nothing will be written into the database. This is usefull
+// for tests.
+//
+// The macro can also be run without ACLiC but this is a lot slower...
+//
+// Remark: Running it from the commandline looks like this:
+//   root -q -l -b fillmccalib.C+\(\"filename\"\,kFALSE\)
+//
+// Make sure, that database and password are corretly set in a resource
+// file called sql.rc and the resource file is found.
+//
+// Returns 2 in case of failure, 1 in case of success and 0 if the connection
+// to the database is not working.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include <iostream>
+
+#include <TEnv.h>
+#include <TRegexp.h>
+
+#include <TH1.h>
+
+#include <TFile.h>
+#include <TSQLResult.h>
+#include <TSQLRow.h>
+
+#include "MSQLServer.h"
+#include "MSQLMagic.h"
+
+#include "MStatusArray.h"
+#include "MHCamera.h"
+#include "MSequence.h"
+#include "MGeomCamMagic.h"
+#include "MBadPixelsCam.h"
+
+using namespace std;
+
+int Process(MSQLMagic &serv, TString fname)
+{
+    //getting number of unsuitable, unreliable and isolated pixel
+    MBadPixelsCam badpix;
+
+    TFile file(fname, "READ");
+    if (!file.IsOpen())
+    {
+        cout << "ERROR - Could not find file " << fname << endl;
+        return 2;
+    }
+
+    if (badpix.Read("MBadPixelsCam")<=0)
+    {
+        cout << "ERROR - Reading of MBadPixelsCam failed." << endl;
+        return 2;
+    }
+
+    MGeomCamMagic def;
+
+    MGeomCam *geom = (MGeomCam*)file.Get("MGeomCam");
+    if (!geom)
+    {
+        cout << "WARNING - Reading of MGeomCam failed... using default <MGeomCamMagic>" << endl;
+        geom = &def;
+    }
+
+    cout << "Camera Geometry: " << geom->ClassName() << endl;
+
+    const Short_t unsin  = badpix.GetNumUnsuitable(MBadPixelsPix::kUnsuitableRun, geom, 0);
+    const Short_t unsout = badpix.GetNumUnsuitable(MBadPixelsPix::kUnsuitableRun, geom, 1);
+
+    const Short_t unrin  = badpix.GetNumUnsuitable(MBadPixelsPix::kUnreliableRun, geom, 0);
+    const Short_t unrout = badpix.GetNumUnsuitable(MBadPixelsPix::kUnreliableRun, geom, 1);
+
+    const Short_t isoin  = badpix.GetNumIsolated(*geom, 0);
+    const Short_t isoout = badpix.GetNumIsolated(*geom, 1);
+
+    const Short_t clumax = badpix.GetNumMaxCluster(*geom);
+
+    if (unsin<0 || unsout<0 || unrin<0 || unrout<0 || isoin<0 || isoout<0 || clumax<0)
+    {
+        cout << "ERROR - one of the pixel values < 0." << endl;
+        return 2;
+    }
+
+    //Getting values from the status display
+    MStatusArray arr;
+    if (arr.Read()<=0)
+    {
+        cout << "ERROR - could not read MStatusArray." << endl;
+        return 2;
+    }
+
+    TH1 *h;
+
+    //getting the mean and rms from the arrival time (inner cam)
+    h = (TH1*)arr.FindObjectInCanvas("HRelTimeHiGainArea0", "TH1F", "Time");
+    if (!h)
+    {
+        cout << "WARNING - Could not find histogram HRelTimeHiGainArea0." << endl;
+        return 2;
+    }
+
+    TString meaninner = Form("%5.1f", h->GetMean());
+    TString rmsinner  = Form("%6.2f", h->GetRMS());
+
+    //getting the mean and rms from the arrival time (outer cam)
+    h = (TH1*)arr.FindObjectInCanvas("HRelTimeHiGainArea1", "TH1F", "Time");
+    if (!h)
+    {
+        cout << "WARNING - Could not find histogram HRelTimeHiGainArea1." << endl;
+        return 2;
+    }
+
+    TString meanouter = Form("%5.1f", h->GetMean());
+    TString rmsouter  = Form("%6.2f", h->GetRMS());
+
+    //Getting conversion factors
+    MHCamera *c = (MHCamera*)arr.FindObjectInCanvas("TotalConvPhe", "MHCamera", "Conversion");
+    if (!c)
+    {
+        cout << "WARNING - Could not find MHCamera TotalConv." << endl;
+        return 2;
+    }
+
+    TArrayI inner(1), outer(1);
+    inner[0] = 0;
+    outer[0] = 1;
+
+    Int_t s0[] = { 1, 2, 3, 4, 5, 6 };
+
+    Stat_t meanconvi = c->GetMeanSectors(TArrayI(6, s0), inner);
+    Stat_t meanconvo = c->GetMeanSectors(TArrayI(6, s0), outer);
+    TString meanconvinner=Form("%6.3f", meanconvi);
+    TString meanconvouter=Form("%6.3f", meanconvo);
+
+    //Getting relative charge rms
+    c = (MHCamera*)arr.FindObjectInCanvas("RMSperMean", "MHCamera", "FitCharge");
+    if (!c)
+    {
+        cout << "ERROR - Could not find MHCamera RMSperMean in FitCharge." << endl;
+        return 2;
+    }
+
+    Stat_t relrmsi = c->GetMedianSectors(TArrayI(6, s0), inner);
+    Stat_t relrmso = c->GetMedianSectors(TArrayI(6, s0), outer);
+    TString relrmsinner=Form("%6.3f", relrmsi);
+    TString relrmsouter=Form("%6.3f", relrmso);
+
+    //Getting relative charge rms
+    c = (MHCamera*)arr.FindObjectInCanvas("NumPhes", "MHCamera", "FitCharge");
+    if (!c)
+    {
+        cout << "ERROR - Could not find MHCamera NumPhes in FitCharge." << endl;
+        return 2;
+    }
+
+    Stat_t numphei = c->GetMedianSectors(TArrayI(6, s0), inner);
+    Stat_t numpheo = c->GetMedianSectors(TArrayI(6, s0), outer);
+    TString numpheinner=Form("%5.1f", numphei);
+    TString numpheouter=Form("%5.1f", numpheo);
+
+    MSequence seq;
+    if (seq.Read("sequence[0-9]{8}[.]txt|MSequence")<=0)
+    {
+        cout << "ERROR - Could not find sequence in file: " << fname << endl;
+        return 2;
+    }
+    if (!seq.IsValid())
+    {
+        cout << "ERROR - Sequence read from file inavlid: " << fname << endl;
+        return 2;
+    }
+
+    //getting the ratio of calibration events used
+    h = (TH1*)arr.FindObjectInCanvas("ArrTm;avg", "MHCamera", "ArrTm");
+    if (!h)
+    {
+        cout << "ERROR - Could not find histogram ArrTime;avg." << endl;
+        return 2;
+    }
+
+    UInt_t nevts = TMath::Nint(h->GetEntries());
+
+    //Num of calibration events is 5000 for all MC C runs
+    UInt_t calevts = 5000;
+
+    Float_t ratiocalib = 100.*nevts/calevts;
+
+    TString ratiocal = Form("%.1f", ratiocalib);
+
+    cout << "Sequence " << seq.GetSequence() << endl;
+    cout << "  Unsuitable: (i/o)  " << Form("%3d %3d", (int)unsin, (int)unsout) << endl; // Unbrauchbar
+    cout << "  Unreliable: (i/o)  " << Form("%3d %3d", (int)unrin, (int)unrout) << endl; // Unzuverlaessig
+    cout << "  Isolated:   (i/o)  " << Form("%3d %3d", (int)isoin, (int)isoout) << endl; // Isolated (unbrauchbar)
+    cout << "  Max.Cluster:       " << Form("%3d", (int)clumax)                 << endl; // Max Cluster
+    cout << "  Arr Time inner:     " << meaninner << " +- " << rmsinner  << endl;
+    cout << "  Arr Time outer:     " << meanouter << " +- " << rmsouter  << endl;
+    cout << "  Mean Conv inner:     " << meanconvinner << endl;
+    cout << "  Mean Conv outer:     " << meanconvouter << endl;
+    cout << "  Rel.charge rms in:   " << relrmsinner << endl;
+    cout << "  Rel.charge rms out:  " << relrmsouter << endl;
+    cout << "  Med. num phe inner: " << numpheinner << endl;
+    cout << "  Med. num phe outer: " << numpheouter << endl;
+    cout << "  Ratio Calib Evts:   " << ratiocal << endl;
+
+    //inserting or updating the information in the database
+    TString vars =
+        Form(" fSequenceFirst=%d, "
+             " fUnsuitableInner=%d, "
+             " fUnsuitableOuter=%d, "
+             " fUnreliableInner=%d, "
+             " fUnreliableOuter=%d, "
+             " fIsolatedInner=%d, "
+             " fIsolatedOuter=%d, "
+             " fIsolatedMaxCluster=%d, "
+             " fArrTimeMeanInner=%s, "
+             " fArrTimeRmsInner=%s, "
+             " fArrTimeMeanOuter=%s, "
+             " fArrTimeRmsOuter=%s, "
+             " fConvFactorInner=%s, "
+             " fConvFactorOuter=%s, "
+             " fRatioCalEvents=%s, "
+             " fRelChargeRmsInner=%s, "
+             " fRelChargeRmsOuter=%s, "
+             " fMedNumPheInner=%s, "
+             " fMedNumPheOuter=%s ",
+             seq.GetSequence(),
+             (int)unsin, (int)unsout, (int)unrin,
+             (int)unrout, (int)isoin, (int)isoout, (int)clumax,
+             meaninner.Data(), rmsinner.Data(),
+             meanouter.Data(), rmsouter.Data(),
+             meanconvinner.Data(), meanconvouter.Data(),
+             ratiocal.Data(),
+             relrmsinner.Data(), relrmsouter.Data(),
+             numpheinner.Data(), numpheouter.Data()
+            );
+
+    TString where = Form("fSequenceFirst=%d", seq.GetSequence());
+
+    return serv.InsertUpdate("MCCalibration", vars, where) ? 1 : 2;
+}
+
+int fillmccalib(TString fname, Bool_t dummy=kTRUE)
+{
+    MSQLMagic serv("sql.rc");
+    if (!serv.IsConnected())
+    {
+        cout << "ERROR - Connection to database failed." << endl;
+        return 0;
+    }
+
+    cout << "fillmccalib" << endl;
+    cout << "---------" << endl;
+    cout << endl;
+    cout << "Connected to " << serv.GetName() << endl;
+    cout << "File: " << fname << endl;
+    cout << endl;
+
+    serv.SetIsDummy(dummy);
+
+    return Process(serv, fname);
+}
Index: /trunk/MagicSoft/Mars/datacenter/macros/fillmcsignal.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/macros/fillmcsignal.C	(revision 9221)
+++ /trunk/MagicSoft/Mars/datacenter/macros/fillmcsignal.C	(revision 9221)
@@ -0,0 +1,324 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 04/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Daniela Dorner, 04/2005 <mailto:dorner@astro.uni-wuerzburg.de>
+!   Author(s): Daniel Hoehne-Moench, 01/2009 <mailto:hoehne@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2009
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// fillmcsignal.C
+// ============
+//
+// This macro is used to read the calibration-/callisto-output files
+// signal00000.root.
+//
+// From this file the mean pedrms, the mean signal and the pulse position
+// for the inner and outer camera is extracted and inserted into the database
+// in the table MCCalibration, where the results of callisto are stored.
+// The sequence number is extracted from the filename.
+//
+// Usage:
+//   .x fillmcsignal.C("/magic/montecarlo/callisto/0002/00028270/signal00028270.root", kTRUE)
+//
+// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
+// switched on and nothing will be written into the database. This is usefull
+// for tests.
+//
+// The macro can also be run without ACLiC but this is a lot slower...
+//
+// Remark: Running it from the commandline looks like this:
+//   root -q -l -b fillmcsignal.C+\(\"filename\"\,kFALSE\) 2>&1 | tee fillsignal.log
+//
+// Make sure, that database and password are corretly set in a resource
+// file called sql.rc and the resource file is found.
+//
+// Returns 2 in case of failure, 1 in case of success and 0 if the connection
+// to the database is not working.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include <iomanip>
+
+#include <TEnv.h>
+#include <TRegexp.h>
+
+#include <TFile.h>
+#include <TGraph.h>
+#include <TSQLResult.h>
+
+#include "MSQLServer.h"
+#include "MSQLMagic.h"
+
+#include "MStatusArray.h"
+#include "MSequence.h"
+#include "MHCamera.h"
+#include "MHVsTime.h"
+
+#include "MCalibrationPulseTimeCam.h"
+#include "MCalibrationPix.h"
+
+using namespace std;
+
+int Process(MSQLMagic &serv, TString fname)
+{
+    TFile file(fname, "READ");
+    if (!file.IsOpen())
+    {
+        cout << "ERROR - Could not find file " << fname << endl;
+        return 2;
+    }
+
+    Float_t meanextpul = -1;
+    Float_t rmsextpul  = -1;
+
+    MCalibrationPulseTimeCam *pt;
+    file.GetObject("MCalibrationPulseTimeCam", pt);
+    if (pt)
+    {
+        meanextpul = pt->GetAverageArea(0).GetHiGainMean();
+        rmsextpul  = pt->GetAverageArea(0).GetHiGainRms();
+
+        meanextpul = TMath::Nint(meanextpul*100)/100.;
+        rmsextpul  = TMath::Nint(rmsextpul*100)/100.;
+    }
+
+    MStatusArray arr;
+    if (arr.Read()<=0)
+    {
+        cout << "ERROR - Reading of MStatusDisplay failed." << endl;
+        return 2;
+    }
+
+    MHCamera *cam = (MHCamera*)arr.FindObjectInCanvas("PedRMS;avg", "MHCamera", "PedRMS");
+    if (!cam)
+    {
+        cout << "WARNING - Reading of PedRMS;avg failed." << endl;
+        return 2;
+    }
+
+    MHCamera *cal = (MHCamera*)arr.FindObjectInCanvas("CalPos;avg", "MHCamera", "CalPos");
+    MHCamera *pul = (MHCamera*)arr.FindObjectInCanvas("PulsePos;avg", "MHCamera", "PulsePos");
+    if (!pul)
+    {
+        cout << "WARNING - Reading of PulsePos;avg failed." << endl;
+        return 2;
+    }
+
+    MSequence seq;
+    if (seq.Read("sequence[0-9]{8}[.]txt|MSequence")<=0)
+    {
+        cout << "ERROR - Could not find sequence in file: " << fname << endl;
+        return 2;
+    }
+    if (!seq.IsValid())
+    {
+        cout << "ERROR - Sequence read from file inavlid: " << fname << endl;
+        return 2;
+    }
+
+    Double_t medoff;
+    Double_t devoff;
+
+    Double_t medcal;
+    Double_t devcal;
+
+    TString medpuloff("NULL");
+    TString devpuloff("NULL");
+    TString medhilocal("NULL");
+    TString devhilocal("NULL");
+
+    MHCamera *hilooff = (MHCamera*)arr.FindObjectInCanvas("HiLoOff;avg", "MHCamera", "HiLoOff");
+    if (!hilooff)
+    {
+        cout << "WARNING - Reading of HiLoOff failed." << endl;
+        return 2;
+    }
+
+    MHCamera *hilocal = (MHCamera*)arr.FindObjectInCanvas("HiLoCal;avg", "MHCamera", "HiLoCal");
+    if (!hilocal)
+    {
+        cout << "WARNING - Reading of HiLoCal failed." << endl;
+        return 2;
+    }
+
+    medoff = TMath::Nint(hilooff->GetMedian()*10000)/10000.;
+    devoff = TMath::Nint(hilooff->GetDev()   *10000)/10000.;
+
+    medcal = TMath::Nint(hilocal->GetMedian()*100)/100.;
+    devcal = TMath::Nint(hilocal->GetDev()   *100)/100.;
+
+    medpuloff.Form("%7.4f", medoff);
+    devpuloff.Form("%7.4f", devoff);
+    medhilocal.Form("%6.2f", medcal);
+    devhilocal.Form("%6.2f", devcal);
+
+    TArrayI inner(1);
+    inner[0] = 0;
+
+    TArrayI outer(1);
+    outer[0] = 1;
+
+    Int_t s0[] = { 1, 2, 3, 4, 5, 6 };
+
+    Stat_t meanrmsi = cam->GetMeanSectors(TArrayI(6, s0), inner);
+    Stat_t meanrmso = cam->GetMeanSectors(TArrayI(6, s0), outer);
+
+    if (meanrmsi<0 || meanrmso<0)
+    {
+        cout << "WARNING - MeanPedRMS inner or outer < 0 " << endl;
+        cout << "MeanPedRMS inner " << meanrmsi << endl;
+        cout << "MeanPedRMS outer " << meanrmso << endl;
+        return 2;
+    }
+
+    meanrmsi = TMath::Nint(meanrmsi*100)/100.;
+    meanrmso = TMath::Nint(meanrmso*100)/100.;
+
+    cam = (MHCamera*)arr.FindObjectInCanvas("Interp'd;avg", "MHCamera", "Interp'd");
+    if (!cam)
+    {
+        cout << "WARNING - Reading of Interp'd;avg failed." << endl;
+        return 2;
+    }
+
+    Stat_t meansigi = cam->GetMeanSectors(TArrayI(6, s0), inner);
+    Stat_t meansigo = cam->GetMeanSectors(TArrayI(6, s0), outer);
+
+    if (meansigi<0 || meansigo<0)
+    {
+        cout << "WARNING - MeanInterp'd inner or outer < 0 " << endl;
+        cout << "MeanInterp'd inner " << meansigi << endl;
+        cout << "MeanInterp'd outer " << meansigo << endl;
+        return 2;
+    }
+
+    meansigi = TMath::Nint(meansigi*100)/100.;
+    meansigo = TMath::Nint(meansigo*100)/100.;
+
+    TString calpos = cal ? Form("%5.1f", cal->GetMean()) : "NULL";
+
+    Stat_t meanpul = pul->GetMean();
+    Stat_t rmspul  = pul->GetRMS();
+
+    if (meanpul<0 || rmspul<0)
+    {
+        cout << "WARNING - PulsePos'd mean or rms < 0 " << endl;
+        cout << "PulsePos'd mean " << meanpul << endl;
+        cout << "PulsePos'd rms  " << rmspul << endl;
+        return 2;
+    }
+
+    meanpul = TMath::Nint(meanpul*100)/100.;
+    rmspul  = TMath::Nint(rmspul *100)/100.;
+
+    cam = (MHCamera*)arr.FindObjectInCanvas("Unsuitable;avg", "MHCamera", "Unsuitable");
+    if (!cam)
+    {
+        cout << "WARNING - Reading of Unsuitable;avg failed." << endl;
+        return 2;
+    }
+
+    Int_t unsuitable50 = cam->GetNumBinsAboveThreshold(0.50);
+    Int_t unsuitable01 = cam->GetNumBinsAboveThreshold(0.01);
+
+    TString meanrmsinner =Form("%6.2f", meanrmsi);
+    TString meanrmsouter =Form("%6.2f", meanrmso);
+    TString meansiginner =Form("%6.2f", meansigi);
+    TString meansigouter =Form("%6.2f", meansigo);
+    TString meanpulpos   =Form("%6.2f", meanpul);
+    TString rmspulpos    =Form("%6.2f", rmspul);
+    TString meanextpulpos=Form("%6.2f", meanextpul);
+    TString rmsextpulpos =Form("%6.2f", rmsextpul);
+
+    if (meanextpul<0 && rmsextpul<0)
+    {
+        meanextpulpos = "NULL";
+        rmsextpulpos  = "NULL";
+    }
+
+    // *****************************************************
+
+    // *****************************************************
+
+
+    cout << "Sequence #" << seq.GetSequence() << endl;
+    cout << "  Mean Ped RMS inner [phe] " << meanrmsinner  << endl;
+    cout << "  Mean Ped RMS outer [phe] " << meanrmsouter  << endl;
+    cout << "  Mean Signal  inner [phe] " << meansiginner  << endl;
+    cout << "  Mean Signal  outer [phe] " << meansigouter  << endl;
+    cout << "  Mean extracted  PulsePos " << meanextpulpos << " +- " << rmsextpulpos << endl;
+    cout << "  Mean calibrated PulsePos " << meanpulpos    << " +- " << rmspulpos    << endl;
+    cout << "  Mean calib pulse pos     " << calpos << endl;
+    cout << "  Lo-Hi gain offset:       " << medpuloff    << " +- " << devpuloff    << endl;
+    cout << "  Hi/Lo gain ratio:        " << medhilocal   << " +- " << devhilocal   << endl;
+    cout << "  Unsuitable > 50%:       " << setw(6) << unsuitable50 << endl;
+    cout << "  Unsuitable >  1%:       " << setw(6) << unsuitable01 << endl;
+    cout << endl;
+
+    //build query and insert information into the database
+    // here only a update query is built, as this macro is exexuted after
+    // the macro fillmccalib.C in the script fillmccallisto
+    // and so the table MCCalibration is always updated
+    TString vars = Form(" fMeanPedRmsInner=%s,    fMeanPedRmsOuter=%s,  "
+                         " fMeanSignalInner=%s,   fMeanSignalOuter=%s,  "
+                         " fPulsePosMean=%s,      fPulsePosRms=%s,      "
+                         " fPulsePosCheckMean=%s, fPulsePosCheckRms=%s, "
+                         " fPulsePosOffMed=%s,    fPulsePosOffDev=%s,   "
+                         " fHiLoGainRatioMed=%s,  fHiLoGainRatioDev=%s, "
+                         " fUnsuitable50=%d,      fUnsuitable01=%d,     "
+                         " fPulsePosCalib=%s ",
+                         meanrmsinner.Data(),  meanrmsouter.Data(),
+                         meansiginner.Data(),  meansigouter.Data(),
+                         meanpulpos.Data(),    rmspulpos.Data(),
+                         meanextpulpos.Data(), rmsextpulpos.Data(),
+                         medpuloff.Data(),     devpuloff.Data(),
+                         medhilocal.Data(),    devhilocal.Data(),
+                         unsuitable50,         unsuitable01,
+                         calpos.Data());
+
+    TString where = Form("fSequenceFirst=%d", seq.GetSequence());
+    return serv.Update("MCCalibration", vars, where) ? 1 : 2;
+
+}
+
+int fillmcsignal(TString fname, Bool_t dummy=kTRUE)
+{
+    MSQLMagic serv("sql.rc");
+    if (!serv.IsConnected())
+    {
+        cout << "ERROR - Connection to database failed." << endl;
+        return 0;
+    }
+
+    cout << "fillmcsignal" << endl;
+    cout << "----------" << endl;
+    cout << endl;
+    cout << "Connected to " << serv.GetName() << endl;
+    cout << "File: " << fname << endl;
+    cout << endl;
+
+    serv.SetIsDummy(dummy);
+
+    //process file
+    return Process(serv, fname);
+}
Index: /trunk/MagicSoft/Mars/datacenter/macros/fillmcstar.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/macros/fillmcstar.C	(revision 9221)
+++ /trunk/MagicSoft/Mars/datacenter/macros/fillmcstar.C	(revision 9221)
@@ -0,0 +1,211 @@
+/* ======================================================================== *\
+!
+! *
+! * 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>
+!   Author(s): Daniel Hoehne-Moench, 01/2009 <mailto:hoehne@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2009
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// fillmcstar.C
+// ==========
+//
+// This macro is used to read the star-output files.
+// These files are automatically called star00000000.root.
+// From these files the number of islands and a parameter describing the
+// inhomogeneity are extracted from the status display.
+// The sequence number is extracted from the filename.
+//
+// Usage:
+//   .x fillmcstar.C("/magic/montecarlo/star/0002/00028270/star00028270.root", kTRUE)
+//
+// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
+// switched on and nothing will be written into the database. This is usefull
+// for tests.
+//
+// The macro can also be run without ACLiC but this is a lot slower...
+//
+// Remark: Running it from the commandline looks like this:
+//   root -q -l -b fillmcstar.C+\(\"filename\"\,kFALSE\)
+//
+// Make sure, that database and password are corretly set in a resource
+// file called sql.rc and the resource file is found.
+//
+// Returns 2 in case of failure, 1 in case of success and 0 if the connection
+// to the database is not working.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include <iomanip>
+
+#include <TFile.h>
+#include <TH1.h>
+#include <TH2.h>
+#include <TGraph.h>
+
+#include "MSQLMagic.h"
+
+#include "MHCamera.h"
+#include "MHMuonPar.h"
+#include "MSequence.h"
+#include "MStatusArray.h"
+#include "MBadPixelsCam.h"
+#include "MHEffectiveOnTime.h"
+
+using namespace std;
+
+bool CheckGraph(const TGraph *g)
+{
+    return g && g->GetN()>0 && !(g->GetN()==1 && g->GetX()[0]==0);
+}
+
+int Process(MSQLMagic &serv, TString fname)
+{
+    TFile file(fname, "READ");
+    if (!file.IsOpen())
+    {
+        cout << "ERROR - Could not find file " << fname << endl;
+        return 2;
+    }
+
+
+    MStatusArray arr;
+    if (arr.Read()<=0)
+    {
+        cout << "ERROR - Reading of MStatusDisplay failed." << endl;
+        return 2;
+    }
+
+    MHCamera *hevts = (MHCamera*)arr.FindObjectInCanvas("Sparkless;avg", "MHCamera", "Sparkless");
+    if (!hevts)
+    {
+        cout << "ERROR - Reading of Sparkless failed." << endl;
+        return 2;
+    }
+
+    MHCamera *hsparks = (MHCamera*)arr.FindObjectInCanvas("Sparks;avg", "MHCamera", "Sparks");
+    if (!hsparks)
+    {
+        cout << "ERROR - Reading of Sparks failed." << endl;
+        return 2;
+    }
+
+    TH2F *hcog = (TH2F*)arr.FindObjectInCanvas("Center", "TH2F", "MHHillas");
+    if (!hcog)
+    {
+        cout << "ERROR - Reading of MHHillas failed." << endl;
+        return 2;
+    }
+
+    MHMuonPar *hmuon = (MHMuonPar*)arr.FindObjectInCanvas("MHMuonPar", "MHMuonPar", "MHMuonPar");
+    if (!hmuon)
+    {
+        cout << "ERROR - Reading of MHMuon failed." << endl;
+        return 2;
+    }
+
+    Double_t val[6];
+    for (int x=1; x<hcog->GetNbinsX(); x++)
+        for (int y=1; y<hcog->GetNbinsY(); y++)
+        {
+            Stat_t px = hcog->GetXaxis()->GetBinCenter(x);
+            Stat_t py = hcog->GetYaxis()->GetBinCenter(y);
+            Int_t  i  = (TMath::Nint(3*TMath::ATan2(px,py)/TMath::Pi())+6)%6;
+            val[i] += hcog->GetBinContent(x, y);
+        }
+
+    Float_t inhom = TMath::RMS(6, val)*6/hcog->GetEntries()*100;
+    TString inhomogen = Form("%5.1f", inhom);
+
+    Int_t   num = (int)hmuon->GetEntries();
+
+    Float_t ratiodatamc = (hmuon->GetMeanSize()/7216)*100;
+    TString ratio = Form("%5.1f", ratiodatamc);
+
+    TH1 *h = (TH1*)arr.FindObjectInCanvas("Islands", "TH1F", "MHImagePar");
+    if (!h)
+    {
+        cout << "ERROR - Reading of Islands failed." << endl;
+        return 2;
+    }
+
+    TString islands = Form("%6.2f", h->GetMean());
+
+    Int_t numsparks = (int)hsparks->GetEntries();
+    Int_t numevents = (int)hevts->GetEntries();
+
+    MSequence seq;
+    if (seq.Read("sequence[0-9]{8}[.]txt|MSequence")<=0)
+    {
+        cout << "ERROR - Could not find sequence in file: " << fname << endl;
+        return 2;
+    }
+    if (!seq.IsValid())
+    {
+        cout << "ERROR - Sequence read from file inavlid: " << fname << endl;
+        return 2;
+    }
+
+    cout << "Sequence " << seq.GetSequence() << endl;
+    cout << "  Inhomogeneity            " << inhomogen << endl;
+    cout << "  Island Quality           " << islands   << endl;
+    cout << "  Muon Number              " << num       << endl;
+    cout << "  # of Events (w/o sparks) " << numevents << endl;
+    cout << "  # of Sparks              " << numsparks << endl;
+
+    TString vars = Form(" fSequenceFirst=%d, "
+                        " fMeanNumberIslands=%s,"
+                        " fMuonNumber=%d,"
+                        " fNumEvts=%d, "
+                        " fNumSparks=%d, "
+                        " fInhomogeneity=%s ",
+                        seq.GetSequence(),
+                        islands.Data(),
+                        num,
+                        numevents, numsparks,
+                        inhomogen.Data());
+
+    TString where = Form("fSequenceFirst=%d", seq.GetSequence());
+
+    return serv.InsertUpdate("MCStar", vars, where) ? 1 : 2;
+}
+
+int fillmcstar(TString fname, Bool_t dummy=kTRUE)
+{
+    MSQLMagic serv("sql.rc");
+    if (!serv.IsConnected())
+    {
+        cout << "ERROR - Connection to database failed." << endl;
+        return 0;
+    }
+
+    cout << "fillmcstar" << endl;
+    cout << "--------" << endl;
+    cout << endl;
+    cout << "Connected to " << serv.GetName() << endl;
+    cout << "File: " << fname << endl;
+    cout << endl;
+
+    serv.SetIsDummy(dummy);
+
+    return Process(serv, fname);
+}
Index: /trunk/MagicSoft/Mars/datacenter/scripts/fillmccallisto
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/scripts/fillmccallisto	(revision 9221)
+++ /trunk/MagicSoft/Mars/datacenter/scripts/fillmccallisto	(revision 9221)
@@ -0,0 +1,118 @@
+#!/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>
+#   Author(s): Daniel Hoehne-Moench  08/2009 <mailto:hoehne@astro.uni-wuerzburg.de>
+#
+#   Copyright: MAGIC Software Development, 2000-2009
+#
+#
+# ========================================================================
+#
+# This script launches the filling of the results from the calibration for 
+# all mc sequences of which the results are not yet in the database.
+#
+# After checking if the script is already running the todolist is written.
+# Then for each sequence in the todo list the calibration results are 
+# filled into the table MCCalibration in the database using the macros 
+# fillmccalib.C and fillmcsignal.C 
+# If this was successful, the status is inserted into the database using 
+# the function setstatus.
+#
+
+source `dirname $0`/sourcefile
+printprocesslog "INFO starting $0"
+program=fillmccallisto
+column=fFillCallisto
+
+set -C
+
+scriptlog=$runlogpath/$program-$datetime.log
+date >> $scriptlog 2>&1
+
+# check if the script is already running
+lockfile=$lockpath/lock-$program.txt
+checklock  >> $scriptlog 2>&1
+
+# get todo file
+gettodo  >> $scriptlog 2>&1
+
+cd $mars
+
+# fill information into the database for all sequences in the todo file
+for (( s=0 ; s < $num ; s++ ))
+do
+   sequence=${primaries[$s+$s]}
+   printprocesslog "INFO starting $program for mc sequence $sequence"
+   no=`printf %08d $sequence | cut -c 0-4`
+   no2=`printf %08d $sequence`
+   path="$mcpath/callisto/$no/$no2"
+   signalfile=$path/signal$no2.root
+   calibfile=$path/calib$no2.root
+   fillcallistologpath=$logpath/$program/$no
+   makedir $fillcallistologpath >> $scriptlog 2>&1
+   fillcaliblog=$fillcallistologpath/fillcalib-$sequence.log
+   fillsignallog=$fillcallistologpath/fillsignal-$sequence.log
+
+   echo "run $program for mc sequence $sequence" >> $scriptlog 2>&1
+   setstatus "start" >> $scriptlog 2>&1
+   echo "run fillmccalib..." >> $scriptlog 2>&1
+   printprocesslog "INFO starting fillmccalib for mc sequence $sequence"
+
+   check1=`root -q -b $macrospath/fillmccalib.C+\("\"$calibfile\""\,kFALSE\) | tee $fillcaliblog | intgrep`
+
+   case $check1 in
+      1)   echo " check1=$check1 -> everything ok -> run fillmcsignal " >> $scriptlog 2>&1 
+           printprocesslog "INFO done fillmccalib successfully for mc sequence $sequence"
+           ;;
+      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+           printprocesslog "WARN connection to DB failed"
+           check="no"
+           setstatus "stop" >> $scriptlog 2>&1
+           continue ;;
+      *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+           printprocesslog "ERROR fillmccalib failed for mc sequence $sequence"
+           com=$Ffillmccalib
+           check=$check1
+           setstatus "stop" >> $scriptlog 2>&1
+           continue ;;
+   esac
+
+   printprocesslog "INFO starting fillmcsignal for sequence $sequence"
+   check2=`root -q -b $macrospath/fillmcsignal.C+\("\"$signalfile\""\,kFALSE\) | tee $fillsignallog | intgrep`
+   case $check2 in
+      1)   echo " check2=$check2 -> everything ok " >> $scriptlog 2>&1 
+           printprocesslog "INFO done fillmcsignal successfully for mc sequence $sequence"
+           ;;
+      0)   echo " check2=$check2 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+           printprocesslog "WARN connection to DB failed"
+           check="no"
+           ;;
+      *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+           printprocesslog "ERROR fillmcsignal failed for mc sequence $sequence"
+           com=$Ffillmcsignal
+           check=$check2
+           ;;
+   esac
+   
+   setstatus "stop" >> $scriptlog 2>&1
+done
+
+finish >> $scriptlog 2>&1
+
Index: /trunk/MagicSoft/Mars/datacenter/scripts/fillmcstar
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/scripts/fillmcstar	(revision 9221)
+++ /trunk/MagicSoft/Mars/datacenter/scripts/fillmcstar	(revision 9221)
@@ -0,0 +1,93 @@
+#!/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>
+#   Author(s): Daniel Hoehne-Moench  01/2009 <mailto:hoehne@astro.uni-wuerzburg.de>
+#
+#   Copyright: MAGIC Software Development, 2000-2009
+#
+#
+# ========================================================================
+#
+# This script launches the filling of the results of star into the db 
+# for all mc sequences of which the results are not yet in the database.
+#
+# After checking if the script is already running the todolist is written. 
+# Then for each sequence in the todo list the star results are filled 
+# into the table Star in the database using the macro fillmcstar.C
+# If this was successful, the status is inserted into the database using 
+# the function setstatus.
+#
+
+source `dirname $0`/sourcefile
+printprocesslog "INFO starting $0"
+program=fillmcstar
+column=fFillStar
+
+set -C
+
+scriptlog=$runlogpath/$program-$datetime.log
+date >> $scriptlog 2>&1
+
+# check if the script is already running
+lockfile=$lockpath/lock-$program.txt
+checklock  >> $scriptlog 2>&1
+
+# get todo list
+gettodo  >> $scriptlog 2>&1
+
+cd $mars
+
+# run fillstar for sequences
+for (( s=0 ; s < $num ; s++ ))
+do
+   sequence=${primaries[$s+$s]}
+   printprocesslog "INFO starting $program for mc sequence $sequence"
+   no=`printf %08d $sequence | cut -c 0-4`
+   no2=`printf %08d $sequence`
+   path="$mcpath/star/$no/$no2"
+   starfile=$path/star$no2.root
+   fillstarlogpath=$logpath/$program/$no
+   makedir $fillstarlogpath >> $scriptlog 2>&1
+   fillstarlog=$fillstarlogpath/$program-$sequence.log
+
+   echo "run $program for mc sequence $sequence" >> $scriptlog 2>&1
+   setstatus "start" >> $scriptlog 2>&1
+
+   check2=`root -q -b $macrospath/fillmcstar.C+\("\"$starfile\""\,kFALSE\) | tee $fillstarlog | intgrep`
+   case $check2 in
+      1)   echo " check2=$check2 -> everything ok " >> $scriptlog 2>&1 
+           printprocesslog "INFO done fillmcstar successfully for mc sequence $sequence"
+           ;;
+      0)   echo " check2=$check2 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+           printprocesslog "WARN connection to DB failed"
+           check="no"
+           ;;
+      *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+           printprocesslog "ERROR fillmcstar failed for mc sequence $sequence"
+           com=$Ffillmcstar
+           check=$check2
+           ;;
+   esac
+   
+   setstatus "stop" >> $scriptlog 2>&1
+done
+
+finish >> $scriptlog 2>&1
+
Index: /trunk/MagicSoft/Mars/datacenter/scripts/runmccallisto
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/scripts/runmccallisto	(revision 9220)
+++ /trunk/MagicSoft/Mars/datacenter/scripts/runmccallisto	(revision 9221)
@@ -19,7 +19,7 @@
 #
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
-#   Author(s): Daniel Hoehne   06/2008 <mailto:hoehne@astro.uni-wuerzburg.de>
+#   Author(s): Daniel Hoehne-Moench  01/2009 <mailto:hoehne@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2008
+#   Copyright: MAGIC Software Development, 2000-2009
 #
 #
@@ -55,6 +55,6 @@
 
 # get sequence # 
-gettodo >> $scriptlog 2>&1
-sequence=$process
+gettodo "1" >> $scriptlog 2>&1
+sequence=${primaries[0]}
 
 # lock sequ for cal
@@ -73,23 +73,7 @@
 sequfile="$mcsequpath/$no/sequence$no2.txt"
 
-## stage the needed files; to be removed as soon as the correct stub file size has been determined
-#echo "staging files:" >> $scriptlog 2>&1
-#day=`grep Night $sequfile | cut -c 18-27 | sed -e "s/-/\//g"`
-#runs=`grep Runs $sequfile | cut -d: -f2`
-#i=0
-#
-#for run in ${runs[@]}
-#do
-#   files[i]=19*_${run}_[PCD]_*_E.root
-#   echo ${mcpath}/rawfiles/${day}/${files[i]} >> $scriptlog 2>&1
-#   let i++
-#done
-#
-#ssh -nx phoenix "cd ${mcpath}/rawfiles/${day}; /opt/SUNWsamfs/bin/stage ${files[@]}"
-
-
 # define callisto.rc files
 callistorcnew=$setuppath/$program/callisto.rc
-callistorcmux=$setuppath/$program/callisto_mux_new.rc
+callistorcmux=$setuppath/$program/callisto_mux.rc
 
 epoch=`grep Epoch $sequfile | cut -d: -f2 | grep Mux`
@@ -110,14 +94,4 @@
 fi
 
-# lock sequ for zipping
-#lockfile=$lockpath/calzip$sequence.txt
-# if lockfile is already existing, 1 is returned
-#if ! checklock return 1 >> $scriptlog 2>&1
-#then
-   # reset lockfile name
-#   lockfile=$lockpath/lock-$table-$column-$sequence.txt
-#   finish >> $scriptlog 2>&1
-#fi
-
 primvar=$no2
 setstatus "start" >> $scriptlog 2>&1
@@ -127,106 +101,8 @@
 check1=$?
 
-# remove lockfile for zip and reset lockfile name
-#rm -v $lockfile >> $scriptlog 2>&1
-#lockfile=$lockpath/lock-$table-$column-$sequence.txt
-
 case $check1 in
    0)   echo " check1=$check1 -> everything ok" >> $scriptlog 2>&1
         printprocesslog "INFO $program finished successfully for mc sequence $sequence"
         ;;
-        # running merpp update if calibration worked
-        # finding files, which have to be updated
-#        echo "finding files to be updated..." >> $scriptlog 2>&1
-#        calfiles=`find $outpath -name *_Y_* `
-#        if [ "$calfiles" = "" ]
-#        then 
-#           echo " no files found -> continue with next sequence" >> $scriptlog 2>&1
-#           printprocesslog "ERROR no calfiles found"
-#        fi
-#        echo " files to be updated: "$calfiles >> $scriptlog 2>&1
-#        
-#        merpplogpath=$outpath"/merpplogs"
-#        makedir $merpplogpath >> $scriptlog 2>&1
-#        
-#        printprocesslog "INFO doing merppupdate for sequence $sequence"
-#        # updated calibrated data files with the information from the cc and caco files
-#        for calfile in ${calfiles[@]}
-#        do 
-#           echo "calfile: "$calfile >> $scriptlog 2>&1
-#           # find cc and caco file
-#           # if file is missing continue with next sequence
-#           date=`date --date \`basename $calfile | cut -d_ -f1\` +%Y/%m/%d`
-#           ccpath=$subsystempath/cc/$date
-#           cacopath=$subsystempath/caco/$date
-#           runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
-#           ccfile=`find $ccpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*${runno}_[PDCS]_*_S.rep`
-#           source=`echo $ccfile | cut -d_ -f4`
-#           cacofile=`find /magic/subsystemdata/caco/$date -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
-#           if [ "$ccfile" = "" ]
-#           then
-#              echo "no ccfile found for run "$runno >> $scriptlog 2>&1
-#              printprocesslog "ERROR  ccfile $ccfile not found for $calfile"
-#              com=$Fnoccfile
-#              comadd=$runno
-#              check=0
-#              break
-#           fi
-#           if [ "$cacofile" = "" ]
-#           then 
-#              echo "cacofile with no $runno not found" >> $scriptlog 2>&1
-#              echo "finding cacofile..." >> $scriptlog 2>&1
-#              for (( i = 0; i <= 10; i++ ))
-#              do 
-#                 newrun=`echo $runno - $i | bc`
-#                 cacofile=`find $cacopath -name *$newrun*`
-#                 if [ "$cacofile" = "" ]
-#                 then
-#                    if [ $i -eq 9 ]
-#                    then
-#                       echo "no cacofile found for runno $newrun in $cacopath" >> $scriptlog 2>&1
-#                       printprocesslog "ERROR cacofile $cacofile not found for $calfile"
-#                       com=$Fnocacofile
-#                       comadd=$runno
-#                       check=0
-#                       break 2
-#                    fi
-#                    continue
-#                 else
-#                    echo "cacofile: "$cacofile >> $scriptlog 2>&1
-#                    break
-#                 fi
-#              done
-#           fi
-#           echo "./merpp -u --log=$merpplogpath/merppccupdate$runno.log --html=$merpplogpath/merppccupdate$runno.html --auto-time-stop --runfile=$runno $ccfile $calfile 2>> $scriptlog> /dev/null" >> $scriptlog 2>&1
-#           ./merpp -u --log=$merpplogpath/merppccupdate$runno.log --html=$merpplogpath/merppccupdate$runno.html --auto-time-stop --runfile=$runno $ccfile $calfile 2>> $scriptlog> /dev/null
-#           check2=$?
-#           case $check2 in
-#              0)   echo " check2=$check2 -> everything ok, merppccupdate worked -> continue" >> $scriptlog 2>&1
-#                   printprocesslog "INFO merppupdated $calfile sucessfully with $ccfile"
-#                   ;;
-#              *)   echo " check2=$check2 -> ERROR -> merppccupdate failed" >> $scriptlog 2>&1
-#                   printprocesslog "ERROR merppccupdate with file $ccfile failed for $calfile"
-#                   com=$Fmerppcc
-#                   comadd=$runno
-#                   check=$check2
-#                   break ;;
-#           esac
-#           echo "./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --html=$merpplogpath/merppcacoupdate$runno.html --auto-time $cacofile $calfile 2>> $scriptlog> /dev/null" >> $scriptlog 2>&1
-#           ./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --html=$merpplogpath/merppcacoupdate$runno.html --auto-time $cacofile $calfile 2>> $scriptlog> /dev/null
-#           check3=$?
-#           case $check3 in
-#              0)   echo " check3=$check3 -> everything ok, merppcacoupdate worked -> continue" >> $scriptlog 2>&1
-#                   printprocesslog "INFO merppupdated $calfile sucessfully with $cacofile"
-#                   ;;
-#              *)   echo " check3=$check3 -> ERROR -> merppcacoupdate failed" >> $scriptlog 2>&1
-#                   printprocesslog "ERROR merppcacoupdate with file $cacofile failed for $calfile"
-#                   com=$Fmerppcaco
-#                   comadd=$runno
-#                   check=$check3
-#                   break ;;
-#           esac
-#        done
-#	printprocesslog "INFO finished merppupdate successfully for sequence $sequence"
-#        ;;
    *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
         printprocesslog "ERROR $program failed for mc sequence $sequence (return code $check1)"
Index: /trunk/MagicSoft/Mars/datacenter/scripts/runmcstar
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/scripts/runmcstar	(revision 9220)
+++ /trunk/MagicSoft/Mars/datacenter/scripts/runmcstar	(revision 9221)
@@ -56,6 +56,6 @@
 
 # get sequence # 
-gettodo >> $scriptlog 2>&1
-sequence=$process
+gettodo "1" >> $scriptlog 2>&1
+sequence=${primaries[0]}
 
 # lock sequ
Index: /trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 9220)
+++ /trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 9221)
@@ -126,11 +126,13 @@
 Fganymed=21
 Ffillganymed=22
-#mc run process status
-Fcorsika=23
-Freflector=24
-Fcamera=25
 #again run process status
 FCompmux=26
 Fdowebplots=27
+#again mc run process status
+Fmccallisto=28
+Ffillmccalib=29
+Ffillmcsignal=30
+Fmcstar=31
+Ffillmcstar=32
 
 # setup for jobmanager:
