Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4721)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4722)
@@ -72,5 +72,5 @@
      - for consistency renamed fWindowSize* to f*WindowSize
 
-   * msignal/MExtractFixedWindowPeakSearch.[h,cc]:
+   * msignal/MExtractTimeHighestIntegral.[h,cc]:
      - added ReadEnv
 
Index: trunk/MagicSoft/Mars/Makefile
===================================================================
--- trunk/MagicSoft/Mars/Makefile	(revision 4721)
+++ trunk/MagicSoft/Mars/Makefile	(revision 4722)
@@ -21,5 +21,5 @@
 
 #PROGRAMS = readraw merpp mars test mona status
-PROGRAMS = readdaq readraw merpp star status mars mona showlog
+PROGRAMS = readdaq readraw merpp mars mona showlog callisto showplot
 SOLIB    = libmars.so
 CINT     = M
Index: trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- trunk/MagicSoft/Mars/callisto.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/callisto.cc	(revision 4722)
@@ -0,0 +1,210 @@
+#include <TROOT.h>
+#include <TClass.h>
+#include <TGClient.h>
+#include <TApplication.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MArgs.h"
+#include "MArray.h"
+#include "MDirIter.h"
+
+#include "MStatusDisplay.h"
+
+#include "MSequence.h"
+#include "MJPedestal.h"
+#include "MJCalibration.h"
+
+using namespace std;
+
+static void StartUpMessage()
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "========================================================" << endl;
+    gLog << "                 Callisto - MARS V" << MARSVER         << endl;
+    gLog << "    MARS -- CALibrate LIght Signals and Time Offsets"  << endl;
+    gLog << "               Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "                  Using ROOT v" << ROOTVER             << endl;
+    gLog << "========================================================" << endl;
+    gLog << endl;
+}
+
+static void Usage()
+{
+    //                1         2         3         4         5         6         7         8
+    //       12345678901234567890123456789012345678901234567890123456789012345678901234567890
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << " callisto [options] sequence.txt" << endl << endl;
+    gLog << " Arguments:" << endl;
+    gLog << "   sequence.txt:             An ascii file defining a sequence of runs" << endl;
+    gLog << " Root Options:" << endl;
+    gLog << "   -b                        Batch mode (no graphical output to screen)" << endl<<endl;
+    gLog << " Options:" << endl;
+    gLog.Usage();
+    gLog << endl;
+    gLog << "   -f                        Force overwrite of existing files" << endl;
+    gLog << "   --in=path                 Path where to search for the data files" << endl;
+    gLog << "   --out=path                Path where to write the result to" << endl;
+    gLog << "   --printseq                Print Sequence information" << endl;
+    gLog << "   --printfiles              Print Files taken from Sequence" << endl;
+    gLog << "   --printonly               Do not excute anything except print" << endl;
+    gLog << "   --config=callisto.rc      Resource file [default=callistop.rc]" << endl;
+    gLog << endl;
+    gLog << "   -?, -h, --help            This help" << endl << endl;
+    gLog << " Setup of the two jobs run by callisto (MJPedestal and MJCalibration)" << endl;
+    gLog << " can be done with the resource file. See MJPedestal and MJCalibration" << endl;
+    gLog << " especially CheckEnv() for more details.   Command line options might" << endl;
+    gLog << " be overwritten by the resource file." << endl << endl;
+    gLog << "Description:" << endl;
+    gLog << " callisto will calculate pedestals  from  pedestal-files defined in a" << endl;
+    gLog << " sequence-file.  This pedestals are used to calculate the calibration" << endl;
+    gLog << " contants. These constants are stored in a so called calibration-file" << endl;
+    gLog << " together with some datacheck plots  which can be viewed using either" << endl;
+    gLog << " showplot or MStatusDisplay in the interpreter." << endl;
+    gLog << endl;
+}
+
+int main(int argc, char **argv)
+{
+    StartUpMessage();
+
+    //
+    // Evaluate arguments
+    //
+    MArgs arg(argc, argv);
+
+    if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+        Usage();
+        return -1;
+    }
+
+    gLog.Setup(arg);
+
+    const TString kConfig     = arg.GetStringAndRemove("--config=", "callisto.rc");
+    const Bool_t  kPrintSeq   = arg.HasOnlyAndRemove("--printseq");
+    const Bool_t  kPrintFiles = arg.HasOnlyAndRemove("--printfiles");
+    const Bool_t  kPrintOnly  = arg.HasOnlyAndRemove("--printonly");
+    const Bool_t  kOverwrite  = arg.HasOnlyAndRemove("-f");
+    const TString kOutpath    = arg.GetStringAndRemove("--out=", "");
+    const TString kInpath     = arg.GetStringAndRemove("--in=",  "");
+
+    if (arg.GetNumOptions()>0)
+    {
+        gLog << warn << "WARNING - Unknown commandline options..." << endl;
+        arg.Print("options");
+        gLog << endl;
+    }
+
+    //
+    // check for the right usage of the program
+    //
+    if (arg.GetNumArguments()!=1)
+    {
+        Usage();
+        return -1;
+    }
+
+    const TString kSequence = arg.GetArgumentStr(0);
+
+    TApplication app("Callisto", &argc, argv);
+    if (gROOT->IsBatch() || !gClient)
+    {
+        gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
+        return 1;
+    }
+
+    MSequence seq(kSequence);
+    if (kPrintSeq)
+    {
+        gLog << all;
+        gLog.Separator(kSequence);
+        seq.Print();
+        gLog << endl;
+    }
+    if (!seq.IsValid())
+    {
+        gLog << err << "Sequence invalid!" << endl << endl;
+        return -1;
+    }
+
+    if (kPrintFiles)
+    {
+        MDirIter Next1, Next2;
+        seq.SetupPedRuns(Next1, kInpath);
+        seq.SetupDatRuns(Next2, kInpath);
+
+        gLog << all;
+        gLog.Separator("Pedestal Files");
+        Next1.Print("all");
+        gLog << endl;
+        gLog.Separator("Data Files");
+        Next2.Print("all");
+        gLog << endl;
+    }
+
+    if (kPrintOnly)
+        return 0;
+
+    MArray::Class()->IgnoreTObjectStreamer();
+    MParContainer::Class()->IgnoreTObjectStreamer();
+
+    //
+    // Update frequency by default = 1Hz
+    //
+    MStatusDisplay *d = new MStatusDisplay;
+
+    // From now on each 'Exit' means: Terminate the application
+    d->SetBit(MStatusDisplay::kExitLoopOnExit);
+    d->SetTitle(kSequence);
+
+    MJPedestal job1;
+    job1.SetSequence(&seq);
+    job1.SetEnv(kConfig);
+    job1.SetDisplay(d);;
+    job1.SetOutputPath(kOutpath);
+
+    if (!job1.ProcessFile())
+    {
+        gLog << err << "Calculation of pedestal failed." << endl << endl;
+        return -1;
+    }
+
+    if (!job1.GetDisplay())
+    {
+        gLog << warn << "Display closed by user... execution aborted." << endl << endl;
+        return 1;
+    }
+
+    MJCalibration job2;
+    job2.SetSequence(&seq);
+    job2.SetEnv(kConfig);
+    job2.SetDisplay(d);;
+    job2.SetBadPixels(job1.GetBadPixels());
+    job2.SetOutputPath(kOutpath);
+    job2.SetOverwrite(kOverwrite);
+
+    if (!job2.ProcessFile(job1.GetPedestalCam()))
+    {
+        gLog << err << "Calculation of calibration failed." << endl << endl;
+        return -1;
+    }
+
+    if (!job2.GetDisplay())
+    {
+        gLog << warn << "Display closed by user... execution aborted." << endl << endl;
+        return 1;
+    }
+
+    // From now on each 'Close' means: Terminate the application
+    d->SetBit(MStatusDisplay::kExitLoopOnClose);
+
+    // Wait until the user decides to exit the application
+    app.Run(kFALSE);
+    return 0;
+}
Index: trunk/MagicSoft/Mars/callisto.rc
===================================================================
--- trunk/MagicSoft/Mars/callisto.rc	(revision 4722)
+++ trunk/MagicSoft/Mars/callisto.rc	(revision 4722)
@@ -0,0 +1,157 @@
+#############################################################################
+#
+# Use this if you want to setup the logging stream for the jobs
+# (overwrites command line options)
+#
+#############################################################################
+#MLog.VerbosityLevel: 2
+#MLog.DebugLevel:     1
+#MLog.NoColors:       yes
+
+#############################################################################
+#
+# Use this if you want to write the MJPedestal output somewhere
+# If you don't want it, it is written to the calibration output anyhow.
+#
+#############################################################################
+#MJPedestal.OutputPath: .
+
+#############################################################################
+#
+# Use this to define where the calibration output is stored. The filename
+# is created from the sequence number. If nothing is specified '.' is
+# assumed.
+# (overwrites command line options)
+#
+#############################################################################
+#MJCalibration.OutputPath: calped
+
+#############################################################################
+#
+# Use this to define where the program should search for the pedestal
+# and calibration files defined in the sequence. To use the local
+# directory use '.' If nothing is specified the default path in the
+# datacenter is used.
+# (overwrites command line options)
+#
+#############################################################################
+#MJPedestal.InputPath:    calped
+#MJCalibration.InputPath: calped
+
+#############################################################################
+#
+# You can choose the pedestal extraction algorithm/task. To use
+# MPedCalcPedRun use the lines below. Be carefull, a pedestal file
+# could be (if no pedestal file available) a data-file, too.
+#
+#############################################################################
+#ExtractPedestal: MPedCalcPedRun 
+#ExtractPedestal.HiGainFirst:       0
+#ExtractPedestal.HiGainLast:       29
+#ExtractPedestal.LoGainFirst:       0
+#ExtractPedestal.LoGainLast:       14
+#ExtractPedestal.HiGainWindowSize: 14
+#ExtractPedestal.LoGainWindowSize:  0
+
+#############################################################################
+#
+# You can choose the pedestal extraction algorithm/task. To use
+# MPedCalcFromLoGain use the lines below. Be carefull, a pedestal file
+# could be (if no pedestal file available) a data-file, too.
+#
+#############################################################################
+ExtractPedestal: MPedCalcFromLoGain
+ExtractPedestal.PedestalUpdate:   no
+#ExtractPedestal.HiGainFirst:       0
+#ExtractPedestal.HiGainLast:       11
+#ExtractPedestal.LoGainFirst:       1
+#ExtractPedestal.LoGainLast:       14
+#ExtractPedestal.HiGainWindowSize: 12
+#ExtractPedestal.LoGainWindowSize: 14
+#ExtractPedestal.MaxHiGainVar:     40
+
+#############################################################################
+#
+# Configure MJPedestal
+#
+#############################################################################
+# Maximum number of event processed in the loop
+#MJPedestal.MaxEvents: 1000
+# Allow to overwrite existing files with the output file
+#MJPedestal.AllowOverwrite: No
+# Use data runs from the sequence instead of calibration runs
+#MJPedestal.UseData: No
+
+#############################################################################
+#
+# Configure MJCalibration
+#
+#############################################################################
+# Switch on relative time calibration
+MJCalibration.RelTimeCalibration: Yes
+# Set color to be used
+#MJCalibration.Color:
+# Type of displayed plots
+#MJCalibration.Display: Full,DataCheck,Normal
+# Used for data-check (eg. raw files are read)
+#MJCalibration.Datacheck: No
+# Write additinal debug output
+#MJCalibration.Debug: No
+# Use blind pixel
+#MJCalibration.UseBlindPixel: No
+# Use pin diode
+#MJCalibration.UsePINDiode: No
+
+#############################################################################
+#
+# Use this if you want to change the signal extractor for the calibration
+# and automatically the data extraction
+#
+#############################################################################
+ExtractSignal: MExtractFixedWindowPeakSearch
+#ExtractSignal.HiGainFirst:       2
+#ExtractSignal.HiGainLast:       14
+#ExtractSignal.LoGainFirst:       2
+#ExtractSignal.LoGainLast:       14
+#ExtractSignal.HiGainWindowSize:  6
+#ExtractSignal.LoGainWindowSize:  6
+#ExtractSignal.PeakSearchWindow:  4
+#ExtractSignal.OffsetFromWindow:  1
+#ExtractSignal.LoGainPeakShift:   0
+
+#############################################################################
+#
+# Use this if you want to change the time extractor for the calibration
+# and automatically the data extraction
+#
+#############################################################################
+ExtractTime: MExtractTimeHighestIntegral
+#ExtractTime.HiGainFirst:       0
+#ExtractTime.HiGainLast:       14
+#ExtractTime.LoGainFirst:       3
+#ExtractTime.LoGainLast:       14
+#ExtractTime.WindowSizeHiGain:  6
+#ExtractTime.WindowSizeLoGain:  6
+
+#############################################################################
+#
+# Use this to change the behaviour of the calibration
+#
+#############################################################################
+#MCalibrationChargeCalc.ChargeLimit:        2.5
+#MCalibrationChargeCalc.ChargeErrLimit:     0
+#MCalibrationChargeCalc.ChargeRelErrLimit:  1
+#MCalibrationChargeCalc.Debug:              no
+
+#MCalibrationChargeCalc.FFactorErrLimit:    4.5
+#MCalibrationChargeCalc.LambdaErrLimit:     0.2
+#MCalibrationChargeCalc.LambdaCheckLimit:   0.5
+#MCalibrationChargeCalc.PheErrLimit:        3.5
+#//MCalibrationChargeCalc.PulserColor       ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;   }
+
+#############################################################################
+#
+# Use this to change the behaviour of the calibration
+#
+#############################################################################
+#MHCalibrationChargeCam.Debug:        no
Index: trunk/MagicSoft/Mars/mbase/MArgs.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MArgs.cc	(revision 4721)
+++ trunk/MagicSoft/Mars/mbase/MArgs.cc	(revision 4722)
@@ -231,4 +231,37 @@
 // --------------------------------------------------------------------------
 //
+// Returns GetIntAndRemove. If HasOption returns kFALSE def is returned.
+//
+Int_t MArgs::GetIntAndRemove(const TString name, Int_t def)
+{
+    if (!HasOption(name))
+        return def;
+    return GetIntAndRemove(name);
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns GetFloatAndRemove. If HasOption returns kFALSE def is returned.
+//
+Double_t MArgs::GetFloatAndRemove(const TString name, Double_t def)
+{
+    if (!HasOption(name))
+        return def;
+    return GetFloatAndRemove(name);
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns GetStringAndRemove. If HasOption returns kFALSE def is returned.
+//
+TString MArgs::GetStringAndRemove(const TString name, const TString def)
+{
+    if (!HasOption(name))
+        return def;
+    return GetStringAndRemove(name);
+}
+
+// --------------------------------------------------------------------------
+//
 // Return the TString corresponding to the i-th argument.
 // This is ment for enumerations like
Index: trunk/MagicSoft/Mars/mbase/MArgs.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MArgs.h	(revision 4721)
+++ trunk/MagicSoft/Mars/mbase/MArgs.h	(revision 4722)
@@ -43,4 +43,8 @@
     TString  GetStringAndRemove(const TString name);
 
+    Int_t    GetIntAndRemove(const TString name, Int_t def);
+    Double_t GetFloatAndRemove(const TString name, Double_t def);
+    TString  GetStringAndRemove(const TString name, const TString def);
+
     Bool_t   Has(const TString name) const;
     Bool_t   HasOnly(const TString name) const;
Index: trunk/MagicSoft/Mars/mbase/MDirIter.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MDirIter.cc	(revision 4721)
+++ trunk/MagicSoft/Mars/mbase/MDirIter.cc	(revision 4722)
@@ -151,4 +151,16 @@
 // --------------------------------------------------------------------------
 //
+// Adds all entries from iter to this object
+//
+void MDirIter::Add(const MDirIter &iter)
+{
+    TIter Next(&iter.fList);
+    TObject *o=0;
+    while ((o=Next()))
+        fList.Add(o->Clone());
+}
+
+// --------------------------------------------------------------------------
+//
 //  Return the pointer to the current directory. If the pointer is NULL
 //  a new directory is opened. If no new directory can be opened NULL is
Index: trunk/MagicSoft/Mars/mbase/MDirIter.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MDirIter.h	(revision 4721)
+++ trunk/MagicSoft/Mars/mbase/MDirIter.h	(revision 4722)
@@ -49,4 +49,5 @@
 
     Int_t AddDirectory(const char *dir, const char *filter="", Int_t recursive=0);
+    void  Add(const MDirIter &iter);
     void  Reset();
 
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 4721)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 4722)
@@ -964,5 +964,15 @@
 Bool_t MEvtLoop::ReadEnv(const char *config)
 {
-    return config ? ReadEnv(TEnv(config)) : kTRUE;
+    if (!config)
+        return kTRUE;
+
+    const Bool_t fileexist = !gSystem->AccessPathName(config, kFileExists);
+    if (!fileexist)
+    {
+        *fLog << warn << "WARNING - resource file '" << config << "' not found... no resources applied." << endl;
+        return kFALSE;
+    }
+
+    return ReadEnv(TEnv(config));
 }
 
Index: trunk/MagicSoft/Mars/mbase/MLog.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 4721)
+++ trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 4722)
@@ -512,4 +512,17 @@
 // --------------------------------------------------------------------------
 //
+// Print usage information setup in Setup()
+//
+void MLog::Usage()
+{
+    //                 1         2         3         4         5         6         7         8
+    //        12345678901234567890123456789012345678901234567890123456789012345678901234567890
+    *this << "   -v#                       Verbosity level # [default=2]" << endl;
+    *this << "   -a, --no-colors           Do not use Ansii color codes" << endl;
+    *this << "   --debug[=n]               Enable root debugging [default: gDebug=1]" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
 // Setup MLog and global debug output from command line arguments.
 //
Index: trunk/MagicSoft/Mars/mbase/MLog.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLog.h	(revision 4721)
+++ trunk/MagicSoft/Mars/mbase/MLog.h	(revision 4722)
@@ -185,4 +185,5 @@
 
     void Setup(MArgs &arg);
+    void Usage();
 
     void ReadEnv(const TEnv &env, TString prefix="", Bool_t print=kFALSE);
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4721)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4722)
@@ -186,5 +186,5 @@
     : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fTimeExtractor(NULL),
       fColor(MCalibrationCam::kNONE), fDisplayType(kNormalDisplay),
-      fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE)
+      fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE), fOverwrite(kFALSE)
 {
 
@@ -1247,4 +1247,18 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// MJCalibration allows to setup several option by a resource file:
+//   MJCalibration.OutputPath: path
+//   MJCalibration.InputPath: path
+//   MJCalibration.Display: full, datacheck, normal
+//   MJCalibration.RelTimeCalibration: yes,no
+//   MJCalibration.Datacheck: yes,no
+//   MJCalibration.Debug: yes,no
+//   MJCalibration.UseBlindPixel: yes,no
+//   MJCalibration.UsePINDiode: yes,no
+//
+// For more details see the class description and the corresponding Getters
+// 
 void MJCalibration::CheckEnv()
 {
@@ -1277,4 +1291,7 @@
     SetUseBlindPixel(fEnv->GetValue("MJCalibration.UseBlindPixel", IsUseBlindPixel()));
     SetUsePINDiode(fEnv->GetValue("MJCalibration.UsePINDiode", IsUsePINDiode()));
+
+    SetOverwrite(fEnv->GetValue("MJPedestal.AllowOverwrite", fOverwrite));
+    SetInputPath(fEnv->GetValue("MJPedestal.InputPath", fInputPath));
 }
 
@@ -1415,5 +1432,11 @@
     MDirIter iter;
     if (fSequence)
-        fSequence->SetupCalRuns(iter);
+    {
+        if (fSequence->SetupCalRuns(iter, fInputPath)==0)
+        {
+            *fLog << err << "ERROR - No input files of sequence found!" << endl;
+            return kFALSE;
+        }
+    }
 
     if (fDataCheck)
@@ -1666,4 +1689,15 @@
 // --------------------------------------------------------------------------
 //
+// Set the path from which the sequence files are read
+// 
+void MJCalibration::SetInputPath(const char *path)
+{
+    fInputPath = path;
+    if (fInputPath.EndsWith("/"))
+        fInputPath = fInputPath(0, fInputPath.Length()-1);
+}
+
+// --------------------------------------------------------------------------
+//
 // Set the useage of the Blind Pixel device 
 // 
@@ -1702,5 +1736,10 @@
     *fLog << inf << "Writing to file: " << oname << endl;
 
-    TFile file(oname, "RECREATE");
+    TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
+    if (!file.IsOpen())
+    {
+        *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
+        return kFALSE;
+    }
 
     *fLog << inf << " - MStatusDisplay..." << flush;
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4721)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4722)
@@ -91,5 +91,5 @@
 MJPedestal::MJPedestal(const char *name, const char *title) 
     : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
-      fDataCheck(kFALSE), fUseData(kFALSE), fMaxEvents(0)
+      fDataCheck(kFALSE), fUseData(kFALSE), fOverwrite(kFALSE), fMaxEvents(0)
 {
     fName  = name  ? name  : "MJPedestal";
@@ -451,5 +451,10 @@
     *fLog << inf << "Writing to file: " << oname << endl;
 
-    TFile file(oname, "RECREATE");
+    TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJPedestal", 9);
+    if (!file.IsOpen())
+    {
+        *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
+        return kFALSE;
+    }
 
     if (fDisplay && fDisplay->Write()<=0)
@@ -481,4 +486,15 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Set the path from which the sequence files are read
+// 
+void MJPedestal::SetInputPath(const char *path)
+{
+    fInputPath = path;
+    if (fInputPath.EndsWith("/"))
+        fInputPath = fInputPath(0, fInputPath.Length()-1);
+}
+
 void MJPedestal::SetEnv(const char *env)
 {
@@ -496,4 +512,14 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// MJPedestsl allows to setup several option by a resource file:
+//   MJPedestal.OutputPath: path
+//   MJPedestal.MaxEvents: 1000
+//   MJPedestal.AllowOverwrite: yes, no
+//   MJPedestal.UseData: yes, no (use DatRuns from sequence instead of PedRuns)
+//
+// For more details see the class description and the corresponding Getters
+// 
 void MJPedestal::CheckEnv()
 {
@@ -508,6 +534,8 @@
     }
 
-    fMaxEvents = fEnv->GetValue("MJPedestal.MaxEvents", fMaxEvents);
-    fUseData   = fEnv->GetValue("MJPedestal.UseData",   fUseData);
+    SetMaxEvents(fEnv->GetValue("MJPedestal.MaxEvents", fMaxEvents));
+    SetOverwrite(fEnv->GetValue("MJPedestal.AllowOverwrite", fOverwrite));
+
+    fUseData = fEnv->GetValue("MJPedestal.UseData", fUseData);
 }
 
@@ -548,5 +576,12 @@
     MDirIter iter;
     if (fSequence)
-        fUseData ? fSequence->SetupDatRuns(iter) : fSequence->SetupPedRuns(iter);
+    {
+        const Int_t n = fUseData ? fSequence->SetupDatRuns(iter, fInputPath) : fSequence->SetupPedRuns(iter, fInputPath);
+        if (n==0)
+        {
+            *fLog << err << "ERROR - No input files of sequence found!" << endl;
+            return kFALSE;
+        }
+    }
 
     if (fDataCheck)
Index: trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 4721)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 4722)
@@ -27,4 +27,9 @@
 //  MSequence
 //
+//  This class describes a sequence. For sequences see:
+//    http://magic.astro.uni-wuerzburg.de/mars/db/queryseq.html
+//
+//  A sequence is a collection of runs which should be used together.
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MSequence.h"
@@ -34,4 +39,5 @@
 #include <TEnv.h>
 #include <TRegexp.h>
+#include <TSystem.h> // TSystem::ExpandPath
 
 #include "MLog.h"
@@ -44,4 +50,8 @@
 using namespace std;
 
+// --------------------------------------------------------------------------
+//
+// Copy the run numbers from the TString runs into the TArrayI data
+//
 void MSequence::Split(TString &runs, TArrayI &data) const
 {
@@ -63,14 +73,16 @@
 }
 
-void MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const
+Int_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const
 {
     TString d(path);
 
     // Setup path
-    if (!path)
+    if (d.IsNull())
     {
         d  = Form("/data/MAGIC/Period%03d/rootdata/", fPeriod);
         d += fNight.GetStringFmt("%Y_%m_%d");
     }
+
+    Int_t num = 0;
 
     for (int i=0; i<arr.GetSize(); i++)
@@ -83,8 +95,13 @@
 
         // Add Path/File to TIter
-        iter.AddDirectory(d, n, 0);
-    }
-}
-
+        num += iter.AddDirectory(d, n, 0);
+    }
+    return num;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the file fname as setup file for the sequence.
+//
 MSequence::MSequence(const char *fname)
 {
@@ -96,8 +113,8 @@
     TString str;
 
-    fSequence  = env.GetValue("Sequence", -1);
-    fLastRun   = env.GetValue("LastRun", -1);
+    fSequence  = env.GetValue("Sequence",  -1);
+    fLastRun   = env.GetValue("LastRun",   -1);
     fNumEvents = env.GetValue("NumEvents", -1);
-    fPeriod    = env.GetValue("Period", -1);
+    fPeriod    = env.GetValue("Period",    -1);
 
     str = env.GetValue("Start", "");
@@ -122,7 +139,16 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Print the contents of the sequence
+//
 void MSequence::Print(Option_t *o) const
 {
     gLog << all;
+    if (!IsValid())
+    {
+        gLog << "Sequence: " << fName << " <invalid>" << endl;
+        return;
+    }
     gLog << "Sequence:     " << fSequence << endl;
     gLog << "Period:       " << fPeriod << endl;
@@ -153,21 +179,49 @@
 }
 
-void MSequence::SetupPedRuns(MDirIter &iter, const char *path) const
-{
-    SetupRuns(iter, fPedRuns, path);
-}
-
-void MSequence::SetupDatRuns(MDirIter &iter, const char *path) const
-{
-    SetupRuns(iter, fDatRuns, path);
-}
-
-void MSequence::SetupAllRuns(MDirIter &iter, const char *path) const
-{
-    SetupRuns(iter, fRuns, path);
-}
-
-void MSequence::SetupCalRuns(MDirIter &iter, const char *path) const
-{
-    SetupRuns(iter, fCalRuns, path);
-}
+// --------------------------------------------------------------------------
+//
+// Add all ped runs from the sequence to MDirIter.
+// If path==0 the standard path of the data-center is assumed.
+// If you have the runs locally use path="."
+// Return the number of files added.
+//
+Int_t MSequence::SetupPedRuns(MDirIter &iter, const char *path) const
+{
+    return SetupRuns(iter, fPedRuns, path);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add all data runs from the sequence to MDirIter.
+// If path==0 the standard path of the data-center is assumed.
+// If you have the runs locally use path="."
+// Return the number of files added.
+//
+Int_t MSequence::SetupDatRuns(MDirIter &iter, const char *path) const
+{
+    return SetupRuns(iter, fDatRuns, path);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add all runs from the sequence to MDirIter.
+// If path==0 the standard path of the data-center is assumed.
+// If you have the runs locally use path="."
+// Return the number of files added.
+//
+Int_t MSequence::SetupAllRuns(MDirIter &iter, const char *path) const
+{
+    return SetupRuns(iter, fRuns, path);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add all calibration runs from the sequence to MDirIter.
+// If path==0 the standard path of the data-center is assumed.
+// If you have the runs locally use path="."
+// Return the number of files added.
+//
+Int_t MSequence::SetupCalRuns(MDirIter &iter, const char *path) const
+{
+    return SetupRuns(iter, fCalRuns, path);
+}
Index: trunk/MagicSoft/Mars/mjobs/MSequence.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 4721)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 4722)
@@ -36,5 +36,5 @@
 
     void Split(TString &runs, TArrayI &data) const;
-    void SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const;
+    Int_t SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const;
 
 public:
@@ -45,8 +45,8 @@
     Bool_t IsValid() const { return fSequence!=(UInt_t)-1; }
 
-    void SetupPedRuns(MDirIter &iter, const char *path=0) const;
-    void SetupDatRuns(MDirIter &iter, const char *path=0) const;
-    void SetupAllRuns(MDirIter &iter, const char *path=0) const;
-    void SetupCalRuns(MDirIter &iter, const char *path=0) const;
+    Int_t SetupPedRuns(MDirIter &iter, const char *path=0) const;
+    Int_t SetupDatRuns(MDirIter &iter, const char *path=0) const;
+    Int_t SetupAllRuns(MDirIter &iter, const char *path=0) const;
+    Int_t SetupCalRuns(MDirIter &iter, const char *path=0) const;
 
     // Getter
Index: trunk/MagicSoft/Mars/mmain/MEventDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MEventDisplay.cc	(revision 4721)
+++ trunk/MagicSoft/Mars/mmain/MEventDisplay.cc	(revision 4722)
@@ -248,4 +248,5 @@
     fEvtLoop->SetOwner();
     fEvtLoop->SetParList(plist);
+    fEvtLoop->ReadEnv("mars.rc");
 
     MHEvent *evt01 = new MHEvent(MHEvent::kEvtSignalRaw);
@@ -254,5 +255,6 @@
     MHEvent *evt04 = new MHEvent(MHEvent::kEvtPedestalRMS);
     MHEvent *evt05 = new MHEvent(MHEvent::kEvtRelativeSignal);
-    MHEvent *evt06 = new MHEvent(MHEvent::kEvtCleaningLevels);
+    MHEvent *evt06a= new MHEvent(MHEvent::kEvtCleaningData);
+    MHEvent *evt06b= new MHEvent(MHEvent::kEvtCleaningLevels);
     MHEvent *evt07 = new MHEvent(MHEvent::kEvtIdxMax);
     MHEvent *evt08 = new MHEvent(MHEvent::kEvtArrTime);
@@ -265,5 +267,6 @@
     evt04->SetName("PedRMS");
     evt05->SetName("Signal/PedRMS");
-    evt06->SetName("CleanLevels");
+    evt06a->SetName("CleanData");
+    evt06b->SetName("CleanLevels");
     evt07->SetName("Max Slice Idx");
     evt08->SetName("Arrival Time");
@@ -277,5 +280,6 @@
     plist->AddToList(evt04);
     plist->AddToList(evt05);
-    plist->AddToList(evt06);
+    plist->AddToList(evt06a);
+    plist->AddToList(evt06b);
     plist->AddToList(evt07);
     plist->AddToList(evt08);
@@ -290,5 +294,6 @@
     MFillH             *fill04 = new MFillH(evt04, "MPedPhotCam", "MFillH04");
     MFillH             *fill05 = new MFillH(evt05, "MCameraData", "MFillH05");
-    MFillH             *fill06 = new MFillH(evt06, "MCameraData", "MFillH06");
+    MFillH             *fill06a= new MFillH(evt06a, "MCameraData", "MFillH06");
+    MFillH             *fill06b= new MFillH(evt06b, "MCameraData", "MFillH06");
 //    MBlindPixelCalc   *blind = new MBlindPixelCalc;
     MHillasCalc        *hcalc  = new MHillasCalc;
@@ -357,5 +362,6 @@
     tlist->AddToList(fill04);
     tlist->AddToList(fill05);
-    tlist->AddToList(fill06);
+    tlist->AddToList(fill06a);
+    tlist->AddToList(fill06b);
 //    tlist->AddToList(blind);
     tlist->AddToList(hcalc);
Index: trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.cc	(revision 4721)
+++ trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.cc	(revision 4722)
@@ -1,25 +1,26 @@
 /* ======================================================================== *\
-   !
-   ! *
-   ! * 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): Abelardo Moralejo,04/2004 <mailto:moralejo@pd.infn.it>
-   !              Markus Gaug      ,04/2004 <mailto:markus@ifae.es>
-   !   Copyright: MAGIC Software Development, 2000-2004
-   !
-   !
-   \* ======================================================================== */
+!
+! *
+! * 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): Abelardo Moralejo, 04/2004 <mailto:moralejo@pd.infn.it>
+!   Author(s): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
 
 //////////////////////////////////////////////////////////////////////////////
@@ -55,5 +56,5 @@
 //   fLoGainWindowSize     = fgLoGainWindowSize     = 6
 //   fPeakSearchWindowSize = fgPeakSearchWindowSize = 4
-//   fLowGainPeakShift     = fgLowGainPeakShift     = 0
+//   fLoGainPeakShift      = fgLoGainPeakShift      = 0
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -84,5 +85,5 @@
 const Byte_t MExtractFixedWindowPeakSearch::fgPeakSearchWindowSize = 4;
 const Byte_t MExtractFixedWindowPeakSearch::fgOffsetFromWindow     = 1;
-const Byte_t MExtractFixedWindowPeakSearch::fgLowGainPeakShift     = 0;
+const Byte_t MExtractFixedWindowPeakSearch::fgLoGainPeakShift      = 0;
 // --------------------------------------------------------------------------
 //
@@ -90,8 +91,8 @@
 //
 // Sets:
-// - fWindowSizeHiGain to fgWindowSizeHiGain
-// - fWindowSizeLoGain to fgWindowSizeLoGain
+// - fHiGainWindowSize to fgHiGainWindowSize
+// - fLoGainWindowSize to fgLoGainWindowSize
 // - fPeakSearchWindowSize to fgPeakSearchWindowSize
-// - fLowGainPeakShift to fgLowGainPeakShift
+// - fLoGainPeakShift to fgLoGainPeakShift
 //
 // Calls: 
@@ -100,8 +101,8 @@
 //
 MExtractFixedWindowPeakSearch::MExtractFixedWindowPeakSearch(const char *name, const char *title)
-    : fWindowSizeHiGain(fgHiGainWindowSize), 
-      fWindowSizeLoGain(fgLoGainWindowSize),
+    : fHiGainWindowSize(fgHiGainWindowSize), 
+      fLoGainWindowSize(fgLoGainWindowSize),
       fPeakSearchWindowSize(fgPeakSearchWindowSize),
-      fLowGainPeakShift(fgLowGainPeakShift)
+      fLoGainPeakShift(fgLoGainPeakShift)
 {
 
@@ -119,5 +120,5 @@
 // Calls:
 // - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
-// - SetWindows(fWindowSizeHiGain,fWindowSizeLoGain,fPeakSearchWindowSize);
+// - SetWindows(fHiGainWindowSize,fLoGainWindowSize,fPeakSearchWindowSize);
 //
 void MExtractFixedWindowPeakSearch::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
@@ -129,5 +130,5 @@
   // Redo the checks if the window is still inside the ranges
   //
-  SetWindows(fWindowSizeHiGain,fWindowSizeLoGain,fPeakSearchWindowSize);
+  SetWindows(fHiGainWindowSize,fLoGainWindowSize,fPeakSearchWindowSize);
   
 }
@@ -141,6 +142,6 @@
 // 
 // Sets:
-// - fNumHiGainSamples to: (Float_t)fWindowSizeHiGain
-// - fNumLoGainSamples to: (Float_t)fWindowSizeLoGain
+// - fNumHiGainSamples to: (Float_t)fHiGainWindowSize
+// - fNumLoGainSamples to: (Float_t)fLoGainWindowSize
 // - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
 // - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)  
@@ -149,15 +150,15 @@
 {
 
-  fWindowSizeHiGain     = windowh & ~1;
-  fWindowSizeLoGain     = windowl & ~1;
+  fHiGainWindowSize     = windowh & ~1;
+  fLoGainWindowSize     = windowl & ~1;
   fPeakSearchWindowSize = peaksearchwindow & ~1;
 
-  if (fWindowSizeHiGain != windowh)
+  if (fHiGainWindowSize != windowh)
     *fLog << warn << GetDescriptor() << ": Hi Gain window size has to be even, set to: " 
-          << int(fWindowSizeHiGain) << " samples " << endl;
-  
-  if (fWindowSizeLoGain != windowl)
+          << int(fHiGainWindowSize) << " samples " << endl;
+  
+  if (fLoGainWindowSize != windowl)
     *fLog << warn << GetDescriptor() << ": Lo Gain window size has to be even, set to: " 
-          << int(fWindowSizeLoGain) << " samples " << endl;
+          << int(fLoGainWindowSize) << " samples " << endl;
     
   if (fPeakSearchWindowSize != peaksearchwindow)
@@ -168,34 +169,34 @@
   const Byte_t availlorange = (fLoGainLast-fLoGainFirst+1) & ~1;
 
-  if (fWindowSizeHiGain > availhirange)
+  if (fHiGainWindowSize > availhirange)
     {
       *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",(int)fWindowSizeHiGain,
+            << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",(int)fHiGainWindowSize,
                     " is bigger than available range: [",(int)fHiGainFirst,",",(int)fHiGainLast,"]") << endl;
       *fLog << warn << GetDescriptor() 
             << ": Will set window size to: " << (int)availhirange << endl;
-      fWindowSizeHiGain = availhirange;
-    }
-  
-  
-  if (fWindowSizeLoGain > availlorange)
+      fHiGainWindowSize = availhirange;
+    }
+  
+  
+  if (fLoGainWindowSize > availlorange)
     {
       *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fWindowSizeLoGain,
+            << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fLoGainWindowSize,
                     " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
       *fLog << warn << GetDescriptor() 
             << ": Will set window size to: " << (int)availlorange << endl;
-      fWindowSizeLoGain = availlorange;
-    }
-  
-  if (fWindowSizeHiGain<2) 
-    {
-      fWindowSizeHiGain = 2;
+      fLoGainWindowSize = availlorange;
+    }
+  
+  if (fHiGainWindowSize<2) 
+    {
+      fHiGainWindowSize = 2;
       *fLog << warn << GetDescriptor() << ": Hi Gain window size set to two samples" << endl;
     }
   
-  if (fWindowSizeLoGain<2) 
-    {
-      fWindowSizeLoGain = 2;
+  if (fLoGainWindowSize<2) 
+    {
+      fLoGainWindowSize = 2;
       *fLog << warn << GetDescriptor() << ": Lo Gain window size set to two samples" << endl;
     }
@@ -208,6 +209,6 @@
     }
 
-  fNumHiGainSamples = (Float_t)fWindowSizeHiGain;
-  fNumLoGainSamples = (Float_t)fWindowSizeLoGain;
+  fNumHiGainSamples = (Float_t)fHiGainWindowSize;
+  fNumLoGainSamples = (Float_t)fLoGainWindowSize;
 
   fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
@@ -295,5 +296,5 @@
 // FindSignalHiGain:
 //
-// - Loop from ptr to (ptr+fWindowSizeHiGain)
+// - Loop from ptr to (ptr+fHiGainWindowSize)
 // - Sum up contents of *ptr
 // - If *ptr is greater than fSaturationLimit, raise sat by 1
@@ -302,5 +303,5 @@
 {
 
-  Byte_t *end = ptr + fWindowSizeHiGain-fHiLoLast;
+  Byte_t *end = ptr + fHiGainWindowSize-fHiLoLast;
 
   Int_t summ = 0;
@@ -316,5 +317,5 @@
 
   //
-  // If part of the "low-Gain" slices are used, 
+  // If part of the "lo-Gain" slices are used,
   // repeat steps one and two for the logain part until fHiLoLast
   //
@@ -337,5 +338,5 @@
 // FindSignalLoGain:
 //
-// - Loop from ptr to (ptr+fWindowSizeLoGain)
+// - Loop from ptr to (ptr+fLoGainWindowSize)
 // - Sum up contents of *ptr
 // - If *ptr is greater than fSaturationLimit, raise sat by 1
@@ -349,5 +350,5 @@
   Int_t summ = 0;
 
-  while (p<ptr+fWindowSizeLoGain)
+  while (p<ptr+fLoGainWindowSize)
     {
       summ += *p;
@@ -400,15 +401,15 @@
 
 
-  loGainFirst = ( hiGainFirst+fLowGainPeakShift > fLoGainFirst ) ? 
-      hiGainFirst+fLowGainPeakShift : fLoGainFirst;
+  loGainFirst = ( hiGainFirst+fLoGainPeakShift > fLoGainFirst ) ?
+      hiGainFirst+fLoGainPeakShift : fLoGainFirst;
 
   // Make sure we will not integrate beyond the hi gain limit:
-  if (hiGainFirst+fWindowSizeHiGain > pixel.GetNumHiGainSamples())
-    fHiLoLast = hiGainFirst+fWindowSizeHiGain - pixel.GetNumHiGainSamples();
-  //    hiGainFirst = pixel.GetNumHiGainSamples()-fWindowSizeHiGain;
+  if (hiGainFirst+fHiGainWindowSize > pixel.GetNumHiGainSamples())
+    fHiLoLast = hiGainFirst+fHiGainWindowSize - pixel.GetNumHiGainSamples();
+  //    hiGainFirst = pixel.GetNumHiGainSamples()-fHiGainWindowSize;
 
   // Make sure we will not integrate beyond the lo gain limit:
-  if (loGainFirst+fWindowSizeLoGain > pixel.GetNumLoGainSamples())
-    loGainFirst = pixel.GetNumLoGainSamples()-fWindowSizeLoGain;
+  if (loGainFirst+fLoGainWindowSize > pixel.GetNumLoGainSamples())
+    loGainFirst = pixel.GetNumLoGainSamples()-fLoGainWindowSize;
 
   pixel.Reset();
@@ -465,2 +466,56 @@
   return kTRUE;
 }
+
+// --------------------------------------------------------------------------
+//
+// In addition to the resources of the base-class MExtractor:
+//   MJPedestal.MExtractor.WindowSizeHiGain: 6
+//   MJPedestal.MExtractor.WindowSizeLoGain: 6
+//   MJPedestal.MExtractor.PeakSearchWindow: 4
+//   MJPedestal.MExtractor.OffsetFromWindow: 1
+//   MJPedestal.MExtractor.LoGainPeakShift:  0
+//
+Int_t MExtractFixedWindowPeakSearch::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Byte_t hw = fHiGainWindowSize;
+    Byte_t lw = fLoGainWindowSize;
+    Byte_t pw = fPeakSearchWindowSize;
+
+    Bool_t rc = kFALSE;
+
+    if (IsEnvDefined(env, prefix, "PeakSearchWindow", print))
+    {
+        pw = GetEnvValue(env, prefix, "PeakSearchWindow", pw);
+        rc = kTRUE;
+    }
+    if (IsEnvDefined(env, prefix, "HiGainWindowSize", print))
+    {
+        hw = GetEnvValue(env, prefix, "HiGainWindowSize", hw);
+        rc = kTRUE;
+    }
+    if (IsEnvDefined(env, prefix, "LoGainWindowSize", print))
+    {
+        lw = GetEnvValue(env, prefix, "LoGainWindowSize", lw);
+        rc = kTRUE;
+    }
+
+    if (rc)
+        SetWindows(hw, lw, pw);
+
+
+    if (IsEnvDefined(env, prefix, "OffsetFromWindow", print))
+    {
+        SetOffsetFromWindow(GetEnvValue(env, prefix, "OffsetFromWindow", fOffsetFromWindow));
+        rc = kTRUE;
+    }
+
+    if (IsEnvDefined(env, prefix, "LoGainPeakShift", print))
+    {
+        SetLoGainPeakShift(GetEnvValue(env, prefix, "LoGainPeakShift", fLoGainPeakShift));
+        rc = kTRUE;
+    }
+
+    rc = MExtractor::ReadEnv(env, prefix, print) ? kTRUE : rc;
+
+    return rc;
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.h	(revision 4721)
+++ trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.h	(revision 4722)
@@ -18,11 +18,11 @@
   static const Byte_t fgPeakSearchWindowSize; // Default for fPeakSearchWindowSize (now set to: 4)
   static const Byte_t fgOffsetFromWindow;     // Default for fOffsetFromWindow (now set to: 1)
-  static const Byte_t fgLowGainPeakShift;     // Default for fLowGainPeakShift (now set to: 0)
+  static const Byte_t fgLoGainPeakShift;      // Default for fLowGainPeakShift (now set to: 0)
 
-  Byte_t  fWindowSizeHiGain;     // Number of Hi Gain slices in window
-  Byte_t  fWindowSizeLoGain;     // Number of Lo Gain slices in window
+  Byte_t  fHiGainWindowSize;     // Number of Hi Gain slices in window
+  Byte_t  fLoGainWindowSize;     // Number of Lo Gain slices in window
   Byte_t  fPeakSearchWindowSize; // Size of FADC window in the search for the highest peak of all pixels.
   Byte_t  fOffsetFromWindow;     // Number of slices to start extraction before search window
-  Byte_t  fLowGainPeakShift;     // Shift of the low gain pulse with respect to the high gain pulse, in slices: it is 0 if the low gain is delayed with respect to HG by 15 slices.
+  Byte_t  fLoGainPeakShift;      // Shift of the low gain pulse with respect to the high gain pulse, in slices: it is 0 if the low gain is delayed with respect to HG by 15 slices.
 
   void   FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const;
@@ -31,6 +31,7 @@
   void   FindPeak(Byte_t *ptr, Byte_t window, Byte_t &startslice, Int_t &signal, Int_t &sat) const;
 
-  Bool_t  ReInit(MParList *pList);
+  Bool_t ReInit(MParList *pList);
   Int_t  Process();
+  Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
   
 public:
@@ -43,5 +44,5 @@
     void SetOffsetFromWindow(Byte_t offset=fgOffsetFromWindow)  {  fOffsetFromWindow = offset; }
 
-    void SetLowGainPeakShift(Byte_t shift=fgLowGainPeakShift) { fLowGainPeakShift = shift; }
+    void SetLoGainPeakShift(Byte_t shift=fgLoGainPeakShift) { fLoGainPeakShift = shift; }
     
     ClassDef(MExtractFixedWindowPeakSearch, 0) // Signal Extractor for fixed size trigger-corrected extraction window 
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.cc	(revision 4721)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.cc	(revision 4722)
@@ -17,5 +17,5 @@
 !
 !   Author(s): Thomas Bretz, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
-!              Hendrik Bartko, 02/2004 <mailto:hbartko@mppmu.mpg.de>
+!   Author(s): Hendrik Bartko, 02/2004 <mailto:hbartko@mppmu.mpg.de>
 !
 !   Copyright: MAGIC Software Development, 2000-2004
@@ -297,2 +297,33 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// In addition to the resources of the base-class MExtractor:
+//   MJPedestal.MExtractor.WindowSizeHiGain: 6
+//   MJPedestal.MExtractor.WindowSizeLoGain: 6
+//
+Int_t MExtractTimeHighestIntegral::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Byte_t hw = fHiGainWindowSize;
+    Byte_t lw = fLoGainWindowSize;
+
+    Bool_t rc = kFALSE;
+
+    if (IsEnvDefined(env, prefix, "HiGainWindowSize", print))
+    {
+        hw = GetEnvValue(env, prefix, "HiGainWindowSize", hw);
+        rc = kTRUE;
+    }
+    if (IsEnvDefined(env, prefix, "LoGainWindowSize", print))
+    {
+        lw = GetEnvValue(env, prefix, "LoGainWindowSize", lw);
+        rc = kTRUE;
+    }
+
+    if (rc)
+        SetWindowSize(hw, lw);
+
+    rc = MExtractor::ReadEnv(env, prefix, print) ? kTRUE : rc;
+
+    return rc;
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.h	(revision 4721)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.h	(revision 4722)
@@ -24,4 +24,6 @@
   void FindTimeHiGain(Byte_t *first, Float_t &time, Float_t &dtime, Byte_t &sat, const MPedestalPix &ped) const;
   void FindTimeLoGain(Byte_t *first, Float_t &time, Float_t &dtime, Byte_t &sat, const MPedestalPix &ped) const;
+
+  Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
   
 public:
Index: trunk/MagicSoft/Mars/showplot.cc
===================================================================
--- trunk/MagicSoft/Mars/showplot.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/showplot.cc	(revision 4722)
@@ -0,0 +1,86 @@
+#include <TROOT.h>
+#include <TClass.h>
+#include <TGClient.h>
+#include <TApplication.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MArgs.h"
+
+#include "MStatusDisplay.h"
+
+using namespace std;
+
+static void StartUpMessage()
+{
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << endl;
+    gLog << "showplot --- Mars V" << MARSVER << " compiled on <" << __DATE__ << "> using ROOT v" << ROOTVER << endl;
+    gLog << endl;
+}
+
+static void Usage()
+{
+    //                1         2         3         4         5         6         7         8
+    //       12345678901234567890123456789012345678901234567890123456789012345678901234567890
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << " showplot filename" << endl << endl;
+    gLog << "Description:" << endl;
+    gLog << " Use showplot to display a MStatusArray in an MStatusDisplay." << endl;
+    gLog << " MStatusArrays are typically written by programs showing data" << endl;
+    gLog << " check plots, like callisto." << endl;
+    gLog << endl;
+}
+
+int main(int argc, char **argv)
+{
+    StartUpMessage();
+
+    //
+    // Evaluate arguments
+    //
+    MArgs arg(argc, argv);
+
+    if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // check for the right usage of the program
+    //
+    if (arg.GetNumArguments()!=1)
+    {
+        Usage();
+        return -1;
+    }
+
+    const TString kInput = arg.GetArgumentStr(0);
+
+    TApplication app("Callisto", &argc, argv);
+    if (gROOT->IsBatch() || !gClient)
+    {
+        gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
+        return 1;
+    }
+
+    //
+    // Update frequency by default = 1Hz
+    //
+    MStatusDisplay *d = new MStatusDisplay;
+
+    // From now on each 'Exit' means: Terminate the application
+    d->SetTitle(kInput);
+    d->Open(kInput);
+
+    // From now on each 'Close' means: Terminate the application
+    d->SetBit(MStatusDisplay::kExitLoopOnClose);
+
+    // Wait until the user decides to exit the application
+    app.Run(kFALSE);
+    return 0;
+}
