Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4722)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4723)
@@ -20,5 +20,5 @@
                                                  -*-*- END OF LINE -*-*-
 
-  2004/08/24 : Wolfgang Wittek
+  2004/08/24 : Thomas Bretz
 
    * Makefile:
@@ -74,4 +74,22 @@
    * msignal/MExtractTimeHighestIntegral.[h,cc]:
      - added ReadEnv
+
+   * mcalib/MCalibrationRelTimeCalc.cc:
+     - do not write to a log file if logging is not enabled
+     - replaced some arrays by TArrays
+
+   * mjobs/JobsLinkDef.h, mjobs/Makefile:
+     - added MJCalibrateSignal
+
+   * mjobs/MJCalibrateSignal.[h,cc]:
+     - added
+
+   * msignal/MExtractFixedWindow.[h,cc], msignal/MExtractFixedWindowPeakSearch.[h,cc],
+     msignal/MExtractSlidingWindow.[h,cc], msignal/MExtractTime.[h,cc],
+     msignal/MExtractTimeAndCharge.[h,cc], msignal/MExtractTimeHighestIntegral.[h,cc]
+     msignal/MExtractor.[h,cc]:
+     - added Print
+     - added ReadEnv
+     - changed version number to 1
 
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 4722)
+++ trunk/MagicSoft/Mars/NEWS	(revision 4723)
@@ -8,4 +8,7 @@
      more): showlog
 
+   - added new program to display an MStatusArray of plots (stored with
+     MStatusDisplay) from a file: showplot
+
    - Added support for Sequences (MSequence). Sequences are blocks of run
      files containing the same calibration and belonging to the same 
@@ -31,4 +34,7 @@
    - added a cleaning which takes signal height _and_ arrival time into
      account: probability cleaning (for more details see MImgCleanStd)
+
+   - added program doing the calibration and the signal extraction
+     and signal calibration: callisto
 
 
Index: trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- trunk/MagicSoft/Mars/callisto.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/callisto.cc	(revision 4723)
@@ -16,4 +16,5 @@
 #include "MJPedestal.h"
 #include "MJCalibration.h"
+#include "MJCalibrateSignal.h"
 
 using namespace std;
@@ -40,9 +41,12 @@
     gLog << all << endl;
     gLog << "Sorry the usage is:" << endl;
-    gLog << " callisto [options] sequence.txt" << endl << endl;
+    gLog << " callisto [-c] [-y] [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 << " Operation Modes:" << endl;
+    gLog << "   -c                        Calculate the calibration constants" << endl;
+    gLog << "   -y                        Extract and calibrate signal" << endl << endl;
     gLog << " Options:" << endl;
     gLog.Usage();
@@ -50,5 +54,10 @@
     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 << "                             [default=standard path in datacenter]" << endl;
+    gLog << "   --iny=path                Path where to search for the calibration files" << endl;
+    gLog << "                             [default=local path or output path of Mode-C]" << endl;
+    gLog << "   --out=path                Path to write the all results to [def=local path]" << endl;
+    gLog << "   --outc=path               Path to write Mode-C result to   [def=local path]" << endl;
+    gLog << "   --outy=path               Path to write Mode-Y result to   [def=local path]" << endl;
     gLog << "   --printseq                Print Sequence information" << endl;
     gLog << "   --printfiles              Print Files taken from Sequence" << endl;
@@ -92,7 +101,31 @@
     const Bool_t  kPrintOnly  = arg.HasOnlyAndRemove("--printonly");
     const Bool_t  kOverwrite  = arg.HasOnlyAndRemove("-f");
+    const TString kInpathY    = arg.GetStringAndRemove("--iny=",  "");
+          TString kInpath     = arg.GetStringAndRemove("--in=",  "");
     const TString kOutpath    = arg.GetStringAndRemove("--out=", "");
-    const TString kInpath     = arg.GetStringAndRemove("--in=",  "");
-
+          TString kOutpathC   = arg.GetStringAndRemove("--outc=", "");
+          TString kOutpathY   = arg.GetStringAndRemove("--outy=", "");
+
+    const Bool_t  kModeC      = arg.HasOnlyAndRemove("-c");
+    const Bool_t  kModeY      = arg.HasOnlyAndRemove("-y");
+
+    if (!kModeC && !kModeY)
+    {
+        gLog << err << "Neither calibration (-c) nor signal extraction (-y) mode specified!" << endl;
+        return 0;
+    }
+
+    if (!kOutpath.IsNull())
+    {
+        if (!kOutpathC.IsNull() || !kOutpathY.IsNull())
+        {
+            gLog << err << "You cannot use --out= and --outc= or --outy= together!" << endl;
+            return 0;
+        }
+        if (kOutpathC.IsNull())
+            kOutpathC = kOutpath;
+        if (kOutpathY.IsNull())
+            kOutpathY = kOutpath;
+    }
     if (arg.GetNumOptions()>0)
     {
@@ -116,5 +149,5 @@
     if (gROOT->IsBatch() || !gClient)
     {
-        gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
+        gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
         return 1;
     }
@@ -164,40 +197,66 @@
     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;
+    if (kModeC)
+    {
+        MJPedestal job1("MJPedestal1");
+        job1.SetSequence(&seq);
+        job1.SetEnv(kConfig);
+        job1.SetDisplay(d);;
+        job1.SetInputPath(kInpath);
+        job1.SetOutputPath(kOutpathC);
+        job1.SetOverwrite(kOverwrite);
+
+        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("MJCalibration");
+        job2.SetSequence(&seq);
+        job2.SetEnv(kConfig);
+        job2.SetDisplay(d);;
+        job2.SetBadPixels(job1.GetBadPixels());
+        job2.SetInputPath(kInpath);
+        job2.SetOutputPath(kOutpathC);
+        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;
+        }
+    }
+
+    if (kModeY)
+    {
+        d->Reset();
+
+        MJCalibrateSignal job("MJCalibrateSignal");
+        job.SetDisplay(d);;
+        job.SetInputPath(kInpath); // Where to search for data files
+        job.SetOutputPath(kOutpathY);
+        job.SetOverwrite(kOverwrite);
+        // Where to search for calibration files
+        if (!job.ProcessFile(seq, kConfig, kModeC ? kOutpathC : kInpathY))
+            return -1;
+
+        if (!job.GetDisplay())
+        {
+            gLog << warn << "Display closed by user... execution aborted." << endl << endl;
+            return 1;
+        }
     }
 
Index: trunk/MagicSoft/Mars/callisto.rc
===================================================================
--- trunk/MagicSoft/Mars/callisto.rc	(revision 4722)
+++ trunk/MagicSoft/Mars/callisto.rc	(revision 4723)
@@ -1,91 +1,51 @@
-#############################################################################
-#
+# ==========================================================================
+#############################################################################
+# ==========================================================================
+#                              General
+# ==========================================================================
+#############################################################################
+# ==========================================================================
+
+# -------------------------------------------------------------------------
 # 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
 
-#############################################################################
-#
+# ==========================================================================
+#############################################################################
+# ==========================================================================
+#                             Calibration
+# ==========================================================================
+#############################################################################
+# ==========================================================================
+
+# -------------------------------------------------------------------------
 # 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: .
-
-#############################################################################
-#
+# -------------------------------------------------------------------------
+#MJPedestal1.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)
-#
-#############################################################################
+# 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
+# datacenter is used. (overwrites command line options)
+# -------------------------------------------------------------------------
+#MJPedestal1.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
@@ -103,55 +63,139 @@
 #MJCalibration.UsePINDiode: No
 
-#############################################################################
-#
+# -------------------------------------------------------------------------
+# 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.
+# -------------------------------------------------------------------------
+#MJCalibration.ExtractPedestal: MPedCalcPedRun 
+#MJCalibration.ExtractPedestal.HiGainFirst:       0
+#MJCalibration.ExtractPedestal.HiGainLast:       29
+#MJCalibration.ExtractPedestal.LoGainFirst:       0
+#MJCalibration.ExtractPedestal.LoGainLast:       14
+#MJCalibration.ExtractPedestal.HiGainWindowSize: 14
+#MJCalibration.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.
+# -------------------------------------------------------------------------
+MJCalibration.ExtractPedestal: MPedCalcFromLoGain
+MJCalibration.ExtractPedestal.PedestalUpdate:   no
+#MJCalibration.ExtractPedestal.HiGainFirst:       0
+#MJCalibration.ExtractPedestal.HiGainLast:       11
+#MJCalibration.ExtractPedestal.LoGainFirst:       1
+#MJCalibration.ExtractPedestal.LoGainLast:       14
+#MJCalibration.ExtractPedestal.HiGainWindowSize: 12
+#MJCalibration.ExtractPedestal.LoGainWindowSize: 14
+#MJCalibration.ExtractPedestal.MaxHiGainVar:     40
+
+# -------------------------------------------------------------------------
+# Configure MJPedestal
+# -------------------------------------------------------------------------
+# Maximum number of event processed in the loop
+#MJPedestal1.MaxEvents: 1000
+# Allow to overwrite existing files with the output file
+#MJPedestal1.AllowOverwrite: No
+# Use data runs from the sequence instead of calibration runs
+#MJPedestal1.UseData: 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
-
-#############################################################################
-#
+# -------------------------------------------------------------------------
+MJCalibration.ExtractSignal: MExtractFixedWindowPeakSearch
+#MJCalibration.ExtractSignal.HiGainFirst:       2
+#MJCalibration.ExtractSignal.HiGainLast:       14
+#MJCalibration.ExtractSignal.LoGainFirst:       2
+#MJCalibration.ExtractSignal.LoGainLast:       14
+#MJCalibration.ExtractSignal.HiGainWindowSize:  6
+#MJCalibration.ExtractSignal.LoGainWindowSize:  6
+#MJCalibration.ExtractSignal.PeakSearchWindow:  4
+#MJCalibration.ExtractSignal.OffsetFromWindow:  1
+#MJCalibration.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
-
-#############################################################################
-#
+# -------------------------------------------------------------------------
+MJCalibration.ExtractTime: MExtractTimeHighestIntegral
+#MJCalibration.ExtractTime.HiGainFirst:       0
+#MJCalibration.ExtractTime.HiGainLast:       14
+#MJCalibration.ExtractTime.LoGainFirst:       3
+#MJCalibration.ExtractTime.LoGainLast:       14
+#MJCalibration.ExtractTime.WindowSizeHiGain:  6
+#MJCalibration.ExtractTime.WindowSizeLoGain:  6
+#MJCalibration.ExtractTime.OffsetLoGain:    1.51
+
+# -------------------------------------------------------------------------
 # 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
+# -------------------------------------------------------------------------
+#MJCalibration.MCalibrationChargeCalc.ChargeLimit:        2.5
+#MJCalibration.MCalibrationChargeCalc.ChargeErrLimit:     0
+#MJCalibration.MCalibrationChargeCalc.ChargeRelErrLimit:  1
+#MJCalibration.MCalibrationChargeCalc.Debug:              no
+
+#MJCalibration.MCalibrationChargeCalc.FFactorErrLimit:    4.5
+#MJCalibration.MCalibrationChargeCalc.LambdaErrLimit:     0.2
+#MJCalibration.MCalibrationChargeCalc.LambdaCheckLimit:   0.5
+#MJCalibration.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
+# -------------------------------------------------------------------------
+#MJCalibration.MHCalibrationChargeCam.Debug:        no
+
+
+ 
+# ==========================================================================
+#############################################################################
+# ==========================================================================
+#                            Signal extraction
+# ==========================================================================
+#############################################################################
+# ==========================================================================
+
+# -------------------------------------------------------------------------
+# Use a OutputPath if you want to write the results to a file
+# -------------------------------------------------------------------------
+#MJCalibrateSignal.OutputPath: .
+
+MJPedestal2.UseData:   Yes
+MJPedestal2.MaxEvents: 750
+
+MJPedestal2.ExtractPedestal: MPedCalcFromLoGain
+MJPedestal2.ExtractPedestal.PedestalUpdate:   yes
+MJPedestal2.ExtractPedestal.NumEventsDump:   500
+
+# -------------------------------------------------------------------------
+# Setup pedestal extraktor for running through data
+# -------------------------------------------------------------------------
+MJCalibrateSignal.MPedCalcFromLoGain: MPedCalcFromLoGain
+MJCalibrateSignal.MPedCalcFromLoGain.PedestalUpdate:   yes
+MJCalibrateSignal.MPedCalcFromLoGain.NumEventsDump:   500
+#MJCalibrateSignal.ExtractPedestal.HiGainFirst:       0
+#MJCalibrateSignal.ExtractPedestal.HiGainLast:       11
+#MJCalibrateSignal.ExtractPedestal.LoGainFirst:       1
+#MJCalibrateSignal.ExtractPedestal.LoGainLast:       14
+#MJCalibrateSignal.ExtractPedestal.HiGainWindowSize: 12
+#MJCalibrateSignal.ExtractPedestal.LoGainWindowSize: 14
+#MJCalibrateSignal.ExtractPedestal.MaxHiGainVar:     40
+
+# -------------------------------------------------------------------------
+# Setup calibration of data
+# -------------------------------------------------------------------------
+MJCalibrateSignal.MCalibrateData.PedestalFlag: Event
+MJCalibrateSignal.MCalibrateData.CalibrationMode: Default
+
+# -------------------------------------------------------------------------
+# Setup level for determining of bad pixels
+# -------------------------------------------------------------------------
+# MJCalibrateSignal.MBadPixelsCalc.PedestalLevel: 3.0
+MJCalibrateSignal.MBadPixelsTreat.NumMinNeighbors:  2
+MJCalibrateSignal.MBadPixelsTreat.UseInterpolation: yes
+MJCalibrateSignal.MBadPixelsTreat.ProcessPedestal:  yes
+#MJCalibrateSignal.MBadPixelsTreat.UseCentralPixel:  no
+#MJCalibrateSignal.MBadPixelsTreat.HardTreatment:    no
Index: trunk/MagicSoft/Mars/mbase/MTaskEnv.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskEnv.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/mbase/MTaskEnv.cc	(revision 4723)
@@ -165,4 +165,5 @@
 Bool_t MTaskEnv::ReInit(MParList *list)
 {
+    *fLog << fTask->ClassName() << " - " << flush;
     return fTask->ReInit(list);
 }
@@ -187,4 +188,5 @@
 Int_t MTaskEnv::PostProcess()
 {
+    *fLog << fTask->ClassName() << " - " << flush;
     return fTask->CallPostProcess();
 }
Index: trunk/MagicSoft/Mars/mbase/MTaskEnv.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskEnv.h	(revision 4722)
+++ trunk/MagicSoft/Mars/mbase/MTaskEnv.h	(revision 4723)
@@ -36,4 +36,6 @@
     void SetDefault(const char *def);
 
+    MTask *GetTask() { return fTask; }
+
     ClassDef(MTaskEnv, 0) // Task which can be setup from an environment file
 };
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc	(revision 4723)
@@ -96,5 +96,5 @@
   SetRelTimeResolutionLimit();
   SetOutputPath();
-  SetOutputFile();
+  SetOutputFile("");
  
   Clear();
@@ -233,7 +233,11 @@
   // Re-direct the output to an ascii-file from now on:
   //
-  MLog asciilog;
-  asciilog.SetOutputFile(GetOutputFile(),kTRUE);
-  SetLogStream(&asciilog);
+  MLog *asciilog = fOutputFile.IsNull() ? 0 : new MLog;
+  if (asciilog)
+  {
+      asciilog->SetOutputFile(GetOutputFile(),kTRUE);
+      SetLogStream(asciilog);
+  }
+
   //
   // Finalize calibration statistics
@@ -254,5 +258,9 @@
                     "Pixels with unsuccesful Gauss fit to the times:   ");
 
-  SetLogStream(&gLog);
+  if (asciilog)
+  {
+      SetLogStream(&gLog);
+      delete asciilog;
+  }
 
   return kTRUE;
@@ -277,17 +285,10 @@
   const UInt_t nareas   = fGeom->GetNumAreas();
 
-  Float_t lowlim       [nareas];
-  Float_t upplim       [nareas];
-  Float_t areasum      [nareas];
+  TArrayF lowlim       (nareas);
+  TArrayF upplim       (nareas);
+  TArrayF areasum      (nareas);
   //  Float_t areasum2     [nareas];
-  Int_t   numareavalid [nareas];
-  Int_t   useunreliable[nareas];
-
-  memset(lowlim        ,0, nareas   * sizeof(Float_t));
-  memset(upplim        ,0, nareas   * sizeof(Float_t));
-  memset(areasum       ,0, nareas   * sizeof(Float_t));
-  //  memset(areasum2      ,0, nareas   * sizeof(Float_t));
-  memset(numareavalid  ,0, nareas   * sizeof(Int_t  ));
-  memset(useunreliable ,0, nareas   * sizeof(Int_t  ));
+  TArrayI numareavalid (nareas);
+  TArrayI useunreliable(nareas);
 
   //
@@ -312,5 +313,5 @@
       useunreliable[aidx] = 1;
 
-  memset(numareavalid  ,0, nareas   * sizeof(Int_t  ));
+  numareavalid.Reset();
   //
   // First loop: Get mean time resolution the RMS
Index: trunk/MagicSoft/Mars/merpp.cc
===================================================================
--- trunk/MagicSoft/Mars/merpp.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/merpp.cc	(revision 4723)
@@ -58,35 +58,34 @@
 static void Usage()
 {
+    //                1         2         3         4         5         6         7         8
+    //       12345678901234567890123456789012345678901234567890123456789012345678901234567890
     gLog << all << endl;
     gLog << "Sorry the usage is:" << endl;
-    gLog << " merpp [-h] [-?] [-a] [-vn] [-cn] [-u, -f]" << endl;
-    gLog << "       inputfile[.rep,[.raw],[.txt]] [outputfile[.root]]" << endl << endl;
+    gLog << " merpp [options] inputfile[.rep,[.raw],[.txt]] [outputfile[.root]]" << endl << endl;
     gLog << " Arguments:" << endl;
-    gLog << "   inputfile.raw:  Magic DAQ binary file." << endl;
-    gLog << "   inputfile.rep:  Magic Central Control report file." << endl;
-    gLog << "   inputfile.txt:  Magic DC currents file." << endl;
-    gLog << "   ouputfile.root: Merpped root file." << endl << endl;
+    gLog << "   inputfile.raw             Magic DAQ binary file." << endl;
+    gLog << "   inputfile.rep             Magic Central Control report file." << endl;
+    gLog << "   inputfile.txt             Magic DC currents file." << endl;
+    gLog << "   ouputfile.root            Merpped root file." << endl << endl;
     gLog << " Options:" << endl;
-    gLog << "   -c#                Compression level #=1..9 [default=2]" << endl;
-    gLog << "   -v#                Verbosity level # [default=2]" << endl;
-    gLog << "   -u, --update       Update file" << endl;
-    gLog << "   -a, --no-colors    Do not use Ansii color codes" << endl;
-    gLog << "   -f                 Force overwrite of an existing file" << endl;
-    gLog << "   --debug[=n]        Enable root debugging (Default: gDebug=1)" << endl;
-    gLog << "   -?, -h, --help     This help" << endl << endl;
+    gLog.Usage();
+    gLog << "   -?, -h, --help            This help" << endl << endl;
+    gLog << " File Options:" << endl;
+    gLog << "   -c#                       Compression level #=1..9 [default=2]" << endl;
+    gLog << "   -f                        Force overwrite of an existing file" << endl << endl;
     gLog << " Raw Data Options:" << endl;
-    gLog << "   -ff                Force merpp to ignore broken events" << endl;
-    gLog << "   --interleave=#     Process only each i-th event [default=1]" << endl << endl;
+    gLog << "   -ff                       Force merpp to ignore broken events" << endl;
+    gLog << "   --interleave=#            Process only each i-th event [default=1]" << endl << endl;
 //    gLog << "   --sql=mysql://user:password@url  Insert run into database" << endl << endl;
     gLog << " Report File Options:" << endl;
-    gLog << "   --start=date/time  Start event time" << endl;
-    gLog << "   --stop=date/time   Stop  event time" << endl;
-    gLog << "   --run=#            Only data corresponding to this run number" << endl;
-    gLog << "                      (from RUN-REPORT)" << endl;
-    gLog << "   --runfile=#        Allow only run-control files" << endl;
-    gLog << "                      (from .rep header)" << endl;
-    gLog << "   --sumfile          Check for an all night summary file" << endl;
-    gLog << "                      (from .rep header)" << endl;
-    gLog << "   --allfiles         Don't check file type <default>" << endl << endl;
+    gLog << "   --start=date/time         Start event time" << endl;
+    gLog << "   --stop=date/time          Stop  event time" << endl;
+    gLog << "   --run=#                   Only data corresponding to this run number" << endl;
+    gLog << "                             (from RUN-REPORT)" << endl;
+    gLog << "   --runfile=#               Allow only run-control files" << endl;
+    gLog << "                             (from .rep header)" << endl;
+    gLog << "   --sumfile                 Check for an all night summary file" << endl;
+    gLog << "                             (from .rep header)" << endl;
+    gLog << "   --allfiles                Don't check file type <default>" << endl << endl;
     gLog << " REMARK: - At the moment you can process a .raw _or_ a .rep file, only!" << endl;
     gLog << "         - 'date/time' has the format 'yyyy-mm-dd/hh:mm:ss.mmm'" << endl << endl;
@@ -128,9 +127,11 @@
     gLog.Setup(arg);
 
-    const Int_t kComprlvl = arg.HasOption("-c") ? arg.GetIntAndRemove("-c") : 2;
-    Bool_t kUpdate = arg.HasOnlyAndRemove("--update") || arg.HasOnlyAndRemove("-u");
-    const Bool_t kInterleave = arg.HasOption("--interleave=") ? arg.GetIntAndRemove("--interleave=") : 1;
-    const Bool_t kForce = arg.HasOnlyAndRemove("-f");
-    const Bool_t kForceProc = arg.HasOnlyAndRemove("-ff");
+    const Int_t  kComprlvl   = arg.GetIntAndRemove("-c", 2);
+    const Bool_t kInterleave = arg.GetIntAndRemove("--interleave=", 1);
+    const Bool_t kForce      = arg.HasOnlyAndRemove("-f");
+    const Bool_t kForceProc  = arg.HasOnlyAndRemove("-ff");
+    const Int_t  kRunNumber  = arg.GetIntAndRemove("--run=", -1);
+          Int_t  kRunFile    = arg.GetIntAndRemove("--runfile=", -1);
+          Bool_t kUpdate     = arg.HasOnlyAndRemove("--update") || arg.HasOnlyAndRemove("-u");
 
     MTime kTimeStart;
@@ -141,8 +142,6 @@
         kTimeStop = AnalyseTime(arg.GetStringAndRemove("--stop="));
 
-    const Int_t   kRunNumber   = arg.HasOption("--run=") ? arg.GetIntAndRemove("--run=") : -1;
 //    const TString kSqlDataBase(arg.GetStringAndRemove("--sql="));
 
-    Int_t kRunFile = arg.HasOption("--runfile=") ? arg.GetIntAndRemove("--runfile=") : -1;
     if (arg.HasOnlyAndRemove("--sumfile"))
         kRunFile = 0;
Index: trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h	(revision 4722)
+++ trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h	(revision 4723)
@@ -9,5 +9,5 @@
 #pragma link C++ class MJPedestal+;
 #pragma link C++ class MJCalibration+;
-//#pragma link C++ class MJCalibrateSignal+;
+#pragma link C++ class MJCalibrateSignal+;
 #pragma link C++ class MJExtractSignal+;
 #pragma link C++ class MJExtractCalibTest+;
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 4723)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 4723)
@@ -0,0 +1,366 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MJCalibrateSignal
+//
+// This class is reading the output written by callisto. It calibrates
+// signal and time.
+//
+// The signal and time extractors are read from the callisto-output. In
+// pricipal you could overwrite these default using the resource file,
+// but this is NOT recommended!
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MJCalibrateSignal.h"
+
+#include <TEnv.h>
+#include <TFile.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MSequence.h"
+#include "MDirIter.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MJPedestal.h"
+#include "MStatusDisplay.h"
+
+#include "MHCamEvent.h"
+#include "MPedestalCam.h"
+#include "MBadPixelsCam.h"
+#include "MCalibrationQECam.h"
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationRelTimeCam.h"
+
+#include "MReadMarsFile.h"
+#include "MGeomApply.h"
+#include "MPedCalcFromLoGain.h"
+#include "MExtractor.h"
+#include "MTaskEnv.h"
+#include "MCalibrateData.h"
+#include "MCalibrateRelTimes.h"
+#include "MBadPixelsMerge.h"
+#include "MBadPixelsCalc.h"
+#include "MBadPixelsTreat.h"
+#include "MFillH.h"
+#include "MWriteRootFile.h"
+
+ClassImp(MJCalibrateSignal);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets fRuns to 0, fExtractor to NULL, fDataCheck to kFALSE
+//
+MJCalibrateSignal::MJCalibrateSignal(const char *name, const char *title) 
+    : fOverwrite(kFALSE), fMaxEvents(0)
+{
+    fName  = name  ? name  : "MJCalibrateSignal";
+    fTitle = title ? title : "Tool to calibrate data";
+}
+
+MJCalibrateSignal::~MJCalibrateSignal()
+{
+}
+
+Bool_t MJCalibrateSignal::WriteResult(const MSequence &seq)
+{
+    if (fOutputPath.IsNull())
+        return kTRUE;
+
+    const TString oname = Form("%s/calped%06d.root", (const char*)fOutputPath, seq.GetSequence());
+
+    *fLog << inf << "Writing to file: " << oname << endl;
+
+    TFile file(oname, "RECREATE");
+
+    *fLog << inf << " - MStatusDisplay..." << flush;
+    if (fDisplay && fDisplay->Write()<=0)
+    {
+        *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
+        return kFALSE;
+    }
+    *fLog << inf << "ok." << endl;
+
+    return kTRUE;
+}
+
+void MJCalibrateSignal::SetOutputPath(const char *path)
+{
+    fOutputPath = path;
+    if (fOutputPath.EndsWith("/"))
+        fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
+}
+void MJCalibrateSignal::SetInputPath(const char *path)
+{
+    fInputPath = path;
+    if (fInputPath.EndsWith("/"))
+        fInputPath = fInputPath(0, fInputPath.Length()-1);
+}
+
+void MJCalibrateSignal::CheckEnv(const char *env)
+{
+    TEnv e(env);
+
+    TString e1 = e.GetValue("MJCalibrateSignal.OutputPath", "");
+    if (!e1.IsNull())
+    {
+        e1.ReplaceAll("\015", "");
+        SetOutputPath(e1);
+    }
+
+    fMaxEvents = e.GetValue("MJCalibrateSignal.MaxEvents", fMaxEvents);
+}
+
+Bool_t MJCalibrateSignal::ReadCalibration(const MSequence &seq, const char *path,
+                                          MCalibrationCam &calcam,
+                                          MCalibrationCam &qecam,
+                                          MCalibrationCam &tmcam,
+                                          MBadPixelsCam &badpix, MTask* &ext1, MTask* &ext2) const
+{
+    TString inpath(path);
+    if (inpath.EndsWith("/"))
+        inpath = inpath(0, inpath.Length()-1);
+
+    const TString fname = Form("%s/calib%06d.root", inpath.Data(), seq.GetSequence());
+
+    TFile file(fname, "READ");
+    if (!file.IsOpen())
+    {
+        *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
+        return kFALSE;
+    }
+
+    if (calcam.Read("MCalibrationChargeCam")<=0)
+    {
+        *fLog << err << dbginf << "ERROR - Unable to read MCalibrationChargeCam from file " << fname << endl;
+        return kFALSE;
+    }
+    if (qecam.Read("MCalibrationQECam")<=0)
+    {
+        *fLog << err << dbginf << "ERROR - Unable to read MCalibrationQECam from file " << fname << endl;
+        return kFALSE;
+    }
+    if (tmcam.Read("MCalibrationRelTimeCam")<=0)
+    {
+        *fLog << err << dbginf << "ERROR - Unable to read MCalibrationRelTimeCam from file " << fname << endl;
+        return kFALSE;
+    }
+    if (badpix.Read("MBadPixelsCam")<=0)
+    {
+        *fLog << err << dbginf << "ERROR - Unable to read MBadPixelsCam from file " << fname << endl;
+        return kFALSE;
+    }
+
+    TObject *o = file.Get("ExtractSignal");
+    if (!o)
+    {
+        *fLog << err << dbginf << "ERROR - Unable to read ExtractSignal from file " << fname << endl;
+        return kFALSE;
+    }
+    if (!o->InheritsFrom(MExtractor::Class()))
+    {
+        *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
+        return kFALSE;
+    }
+    ext1 = (MTask*)o->Clone();
+
+    o = file.Get("ExtractTime");
+    if (!o)
+    {
+        *fLog << err << dbginf << "ERROR - Unable to read ExtractTime from file " << fname << endl;
+        return kFALSE;
+    }
+    if (!o->InheritsFrom(MExtractor::Class()))
+    {
+        *fLog << err << dbginf << "ERROR - ExtractTime read from " << fname << " doesn't inherit from MExtractor!" << endl;
+        return kFALSE;
+    }
+    ext2 = (MTask*)o->Clone();
+
+    return kTRUE;
+}
+
+Bool_t MJCalibrateSignal::ProcessFile(const MSequence &seq, const char *env, const char *path)
+{
+    *fLog << inf;
+    fLog->Separator(GetDescriptor());
+    *fLog << "Calculate calibrated data from runs ";
+    *fLog << seq.GetName() << endl;
+    *fLog << endl;
+
+    CheckEnv(env);
+
+    // -------------------------------------------------------------------------------
+
+    MJPedestal job1;
+    job1.SetSequence(&seq);
+    job1.SetDisplay(fDisplay);;
+    job1.SetEnv(env);
+
+    if (!job1.ProcessFile())
+        return kFALSE;
+
+    // --------------------------------------------------------------------------------
+
+    MDirIter iter;
+    if (seq.SetupDatRuns(iter, fInputPath)==0)
+    {
+            *fLog << err << "ERROR - No input files of sequence found!" << endl;
+            return kFALSE;
+    }
+
+    // Read File
+    MCalibrationChargeCam  calcam;
+    MCalibrationQECam      qecam;
+    MCalibrationRelTimeCam tmcam;
+    MBadPixelsCam          badpix;
+
+    MTask *extractor1=0;
+    MTask *extractor2=0;
+
+    if (!ReadCalibration(seq, path, calcam, qecam, tmcam, badpix, extractor1, extractor2))
+        return kFALSE;
+
+    *fLog << all;
+    *fLog << "Extractors read from file" << endl;
+    *fLog << "=========================" << endl;
+    extractor1->Print();
+    *fLog << endl;
+    extractor2->Print();
+    *fLog << endl;
+
+    // This is necessary for the case in which it is not in the files
+    MBadPixelsCam badcam;
+
+    // Setup Parlist
+    MParList plist;
+    plist.AddToList(this); // take care of fDisplay!
+    plist.AddToList(&calcam);
+    plist.AddToList(&qecam);     
+    plist.AddToList(&tmcam);
+    plist.AddToList(&badcam);
+    plist.AddToList(&job1.GetPedestalCam());
+
+    // Setup Tasklist
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+    read.AddFiles(iter);
+    //read.AddFiles(fnamein);
+
+    MGeomApply             apply; // Only necessary to craete geometry
+    MBadPixelsMerge        merge(&badpix);
+    MPedCalcFromLoGain     pedlo;
+    //MExtractSlidingWindow  extsignal;
+    MTaskEnv taskenv1("ExtractSignal");
+    taskenv1.SetDefault(extractor1);
+    //MExtractTimeFastSpline exttime;
+    MTaskEnv taskenv2("ExtractTime");
+    taskenv2.SetDefault(extractor2);
+    MCalibrateData         calib;
+    MCalibrateRelTimes     caltm;
+    MBadPixelsCalc         bpcal;
+    MBadPixelsTreat        treat;
+
+    MHCamEvent evt0("PedestalFLG");
+    MHCamEvent evt1("Extra'd");
+    MHCamEvent evt2("PedPhot");
+    MHCamEvent evt3("Interp'd");
+    MHCamEvent evt4("Unsuitable");
+    MHCamEvent evt5("Times");
+    evt0.SetType(0);
+    evt1.SetType(0);
+    evt2.SetType(0);
+    evt3.SetType(0);
+    evt4.SetType(2);
+    evt5.SetType(0);
+    MFillH fill0(&evt0, "MPedestalCam",        "FillPedestalFLG");
+    MFillH fill1(&evt1, "MExtractedSignalCam", "FillExtracted");
+    MFillH fill2(&evt2, "MPedPhotCam",         "FillPedPhot");
+    MFillH fill3(&evt3, "MCerPhotEvt",         "FillInterpolated");
+    MFillH fill4(&evt4, "MBadPixelsCam",       "FillUnsuitable");
+    MFillH fill5(&evt5, "MArrivalTime",        "FillTimes");
+
+    MWriteRootFile write(2, Form("%s{s/_D_/_Y_}", fOutputPath.Data()), fOverwrite);
+    write.AddContainer("MCerPhotEvt",    "Events");
+    write.AddContainer("MPedPhotCam",    "Events");
+    write.AddContainer("MTime",          "Events");
+    write.AddContainer("MRawEvtHeader",  "Events");
+    write.AddContainer("MArrivalTime",   "Events");
+    write.AddContainer("MRawRunHeader",  "RunHeaders");
+    write.AddContainer("MBadPixelsCam",  "RunHeaders");
+    write.AddContainer("MGeomCam",       "RunHeaders");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&apply);
+    tlist.AddToList(&merge);
+    tlist.AddToList(&pedlo);
+    tlist.AddToList(&fill0);
+    tlist.AddToList(&taskenv1);
+    tlist.AddToList(&taskenv2);
+    tlist.AddToList(&fill1);
+    tlist.AddToList(&calib);
+    tlist.AddToList(&caltm);
+    tlist.AddToList(&fill2);
+    tlist.AddToList(&bpcal);
+    tlist.AddToList(&treat);
+    tlist.AddToList(&fill3);
+    tlist.AddToList(&fill4);
+    tlist.AddToList(&fill5);
+    tlist.AddToList(&write);
+
+    // Create and setup the eventloop
+    MEvtLoop evtloop(fName);
+    evtloop.SetParList(&plist);
+    evtloop.SetDisplay(fDisplay);
+    evtloop.SetLogStream(fLog);
+    evtloop.ReadEnv(env);
+
+    // Execute first analysis
+    if (!evtloop.Eventloop(fMaxEvents))
+    {
+        *fLog << err << GetDescriptor() << ": Failed." << endl;
+        return kFALSE;
+    }
+
+    tlist.PrintStatistics();
+
+    if (!WriteResult(seq))
+        return kFALSE;
+
+    *fLog << all << GetDescriptor() << ": Done." << endl;
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h	(revision 4723)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h	(revision 4723)
@@ -0,0 +1,51 @@
+#ifndef MARS_MJCalibrateSignal
+#define MARS_MJCalibrateSignal
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TEnv;
+
+class MTask;
+class MParList;
+class MSequence;
+class MBadPixelsCam;
+class MCalibrationCam;
+class MCalibrationQECam;
+class MCalibrationRelTimeCam;
+class MCalibrationChargeCam;
+
+class MJCalibrateSignal : public MParContainer
+{
+private:
+    TString fOutputPath;        // Directory to write signal*.root file to
+    TString fInputPath;         // Directory to read  calib*.root file from
+
+    Bool_t fOverwrite;          // Allow overwriting files
+    Int_t  fMaxEvents;          // Maximum number of events
+
+    void   CheckEnv(const char *env);
+    Bool_t WriteResult(const MSequence &seq);
+    Bool_t ReadCalibration(const MSequence &seq, const char *path, MCalibrationCam &calcam,
+                           MCalibrationCam &qecam, MCalibrationCam &tmcam,
+                           MBadPixelsCam &badpix, MTask* &ext1, MTask* &ext2) const;
+
+public:
+    MJCalibrateSignal(const char *name=NULL, const char *title=NULL);
+    ~MJCalibrateSignal();
+
+    Bool_t ProcessFile(const MSequence &seq, const char *env, const char *path=0);
+
+    void SetOutputPath(const char *path=".");
+    void SetInputPath(const char *path=".");
+    void SetMaxEvents(Int_t max) { fMaxEvents = max; }
+
+    void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
+
+    MStatusDisplay *GetDisplay() { return fDisplay; }
+
+    ClassDef(MJCalibrateSignal, 0) // Tool to create a pedestal file (MPedestalCam)
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4723)
@@ -1266,5 +1266,5 @@
         return;
 
-    TString e1 = fEnv->GetValue("MJCalibration.OutputPath", "");
+    TString e1 = fEnv->GetValue(Form("%s.OutputPath", fName.Data()), "");
     if (!e1.IsNull())
     {
@@ -1273,10 +1273,10 @@
     }
 
-    TString col = fEnv->GetValue("MJCalibration.Color", "");
+    TString col = fEnv->GetValue(Form("%s.Color", fName.Data()), "");
     if (!col.IsNull())
     {
     }
 
-    TString dis = fEnv->GetValue("MJCalibration.Display", "");
+    TString dis = fEnv->GetValue(Form("%s.Display", fName.Data()), "");
     if (dis.BeginsWith("Full", TString::kIgnoreCase))
         SetFullDisplay();
@@ -1286,12 +1286,12 @@
         SetNormalDisplay();
 
-    SetRelTimeCalibration(fEnv->GetValue("MJCalibration.RelTimeCalibration", fRelTimes));
-    SetDataCheck(fEnv->GetValue("MJCalibration.Datacheck", fDataCheck));
-    SetDebug(fEnv->GetValue("MJCalibration.Debug", fDebug));
-    SetUseBlindPixel(fEnv->GetValue("MJCalibration.UseBlindPixel", IsUseBlindPixel()));
-    SetUsePINDiode(fEnv->GetValue("MJCalibration.UsePINDiode", IsUsePINDiode()));
-
-    SetOverwrite(fEnv->GetValue("MJPedestal.AllowOverwrite", fOverwrite));
-    SetInputPath(fEnv->GetValue("MJPedestal.InputPath", fInputPath));
+    SetRelTimeCalibration(fEnv->GetValue(Form("%s.RelTimeCalibration", fName.Data()), fRelTimes));
+    SetDataCheck(fEnv->GetValue(Form("%s.Datacheck", fName.Data()), fDataCheck));
+    SetDebug(fEnv->GetValue(Form("%s.Debug", fName.Data()), fDebug));
+    SetUseBlindPixel(fEnv->GetValue(Form("%s.UseBlindPixel", fName.Data()), IsUseBlindPixel()));
+    SetUsePINDiode(fEnv->GetValue(Form("%s.UsePINDiode", fName.Data()), IsUsePINDiode()));
+
+    SetOverwrite(fEnv->GetValue(Form("%s.AllowOverwrite", fName.Data()), fOverwrite));
+    SetInputPath(fEnv->GetValue(Form("%s.InputPath", fName.Data()), fInputPath));
 }
 
@@ -1426,4 +1426,5 @@
     MTaskList tlist;
     plist.AddToList(&tlist);
+    plist.AddToList(this); // take care of fDisplay!
 
     MReadMarsFile read("Events");
@@ -1495,8 +1496,8 @@
     calcalc.SetPulserColor(fColor);
 
-    MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
-    MFillH fillbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel");
-    MFillH fillcam("MHCalibrationChargeCam",      "MExtractedSignalCam");
-    MFillH filltme("MHCalibrationRelTimeCam",     "MArrivalTimeCam");
+    MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode",   "FillPINDiode");
+    MFillH fillbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
+    MFillH fillcam("MHCalibrationChargeCam",      "MExtractedSignalCam",        "FillChargeCam");
+    MFillH filltme("MHCalibrationRelTimeCam",     "MArrivalTimeCam",            "FillRelTime");
     fillpin.SetNameTab("PINDiode");
     fillbnd.SetNameTab("BlindPix");
@@ -1566,4 +1567,10 @@
         evtloop.ReadEnv(*fEnv);
 
+    //if (!WriteEventloop(evtloop))
+    //    return kFALSE;
+
+    if (!WriteTasks(taskenv.GetTask(), taskenv2.GetTask()))
+        return kFALSE;
+
     // Execute first analysis
     if (!evtloop.Eventloop())
@@ -1580,4 +1587,7 @@
     // the display. No idea where this comes from...
     //
+    // FIND THE REASON! THE NEXT CHANGE SOMEBODY DOES MIGHT RESULT
+    // IN __YOUR__ WORKAROUN NOT WORKING IF IT IS NOT CLEANLY DONE!
+    /*
     if (fDisplay)
     {
@@ -1607,5 +1617,5 @@
         }
     }
-    
+*/
     DisplayResult(plist);
 
@@ -1613,5 +1623,5 @@
         return kFALSE;
 
-    *fLog << inf << GetDescriptor() << ": Done." << endl;
+    *fLog << all << GetDescriptor() << ": Done." << endl;
 
     return kTRUE;
@@ -1716,4 +1726,59 @@
 }
 
+Bool_t MJCalibration::WriteEventloop(MEvtLoop &evtloop) const
+{
+    if (fOutputPath.IsNull())
+        return kTRUE;
+
+    const TString oname(GetOutputFile());
+
+    *fLog << inf << "Writing to file: " << oname << endl;
+
+    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;
+    }
+
+    if (evtloop.Write(fName)<=0)
+    {
+        *fLog << err << "Unable to write MEvtloop to " << oname << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const
+{
+    if (fOutputPath.IsNull())
+        return kTRUE;
+
+    const TString oname(GetOutputFile());
+
+    *fLog << inf << "Writing to file: " << oname << endl;
+
+    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;
+    }
+
+    if (t1->Write()<=0)
+    {
+        *fLog << err << "Unable to write " << t1->GetName() << " to " << oname << endl;
+        return kFALSE;
+    }
+    if (t2->Write()<=0)
+    {
+        *fLog << err << "Unable to write " << t2->GetName() << " to " << oname << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -1736,5 +1801,5 @@
     *fLog << inf << "Writing to file: " << oname << endl;
 
-    TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
+    TFile file(oname, "UPDATE", "File created by MJCalibration", 9);
     if (!file.IsOpen())
     {
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 4722)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 4723)
@@ -22,4 +22,5 @@
 
 class TEnv;
+class MTask;
 class MRunIter;
 class MSequence;
@@ -28,4 +29,5 @@
 class MExtractor;
 class MExtractTime;
+class MEvtLoop;
 
 class MExtractBlindPixel;
@@ -56,4 +58,5 @@
 
   TString fOutputPath;                                 // Path to the output files
+  TString fInputPath;                                  // Path to get the data files from
   
   TEnv           *fEnv;                                // Input setup-file
@@ -89,8 +92,10 @@
   
   Byte_t fDevices;                                     // Bit-field for used devices for calibration
-  
+
+  // Combine these options into a single bit-files (TestBit/SetBit, etc)
   Bool_t fRelTimes;                                    // Flag if relative times have to be calibrated
   Bool_t fDataCheck;                                   // Flag if the data check is run on raw data
   Bool_t fDebug;                                       // Flag if debug option is passed onto cal. classes
+  Bool_t fOverwrite;                                   // Allow to overwite existing files
   
   void   DisplayResult        ( MParList &plist );
@@ -102,4 +107,6 @@
   
   Bool_t WriteResult();
+  Bool_t WriteEventloop(MEvtLoop &evtloop) const;
+  Bool_t WriteTasks(MTask *t1, MTask *t2) const;
   void   CheckEnv();
   
@@ -134,4 +141,6 @@
   void SetSequence(MSequence *seq) { fSequence=seq; }
   void SetOutputPath(const char *path=".");
+  void SetInputPath(const char *path=".");
+  void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
   
   // Displays
@@ -156,4 +165,6 @@
   Bool_t ProcessFile(MPedestalCam &pedcam);
   Bool_t Process(MPedestalCam &pedcam);
+
+  MStatusDisplay *GetDisplay() { return fDisplay; }
   
   ClassDef(MJCalibration, 0) // Tool to run a calibration per pulser colour and intensity
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4723)
@@ -440,7 +440,6 @@
 
 }
-
-
-Bool_t MJPedestal::WriteResult()
+/*
+Bool_t MJPedestal::WriteEventloop(MEvtLoop &evtloop) const
 {
     if (fOutputPath.IsNull())
@@ -452,4 +451,29 @@
 
     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 (evtloop.Write(fName)<=0)
+    {
+        *fLog << err << "Unable to write MEvtloop to " << oname << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+*/
+Bool_t MJPedestal::WriteResult()
+{
+    if (fOutputPath.IsNull())
+        return kTRUE;
+
+    const TString oname(GetOutputFile());
+
+    *fLog << inf << "Writing to file: " << oname << endl;
+
+    TFile file(oname, "UPDATE", "File created by MJPedestal", 9);
     if (!file.IsOpen())
     {
@@ -527,5 +551,5 @@
         return;
 
-    TString e1 = fEnv->GetValue("MJPedestal.OutputPath", "");
+    TString e1 = fEnv->GetValue(Form("%s.OutputPath", fName.Data()), "");
     if (!e1.IsNull())
     {
@@ -534,8 +558,8 @@
     }
 
-    SetMaxEvents(fEnv->GetValue("MJPedestal.MaxEvents", fMaxEvents));
-    SetOverwrite(fEnv->GetValue("MJPedestal.AllowOverwrite", fOverwrite));
-
-    fUseData = fEnv->GetValue("MJPedestal.UseData", fUseData);
+    SetMaxEvents(fEnv->GetValue(Form("%s.MaxEvents", fName.Data()), fMaxEvents));
+    SetOverwrite(fEnv->GetValue(Form("%s.AllowOverwrite", fName.Data()), fOverwrite));
+
+    fUseData = fEnv->GetValue(Form("%s.UseData", fName.Data()), fUseData);
 }
 
@@ -570,4 +594,5 @@
     MTaskList tlist;
     plist.AddToList(&tlist);
+    plist.AddToList(this); // take care of fDisplay!
 
     MReadMarsFile read("Events");
@@ -640,4 +665,7 @@
         evtloop.ReadEnv(*fEnv);
 
+    //    if (!WriteEventloop(evtloop))
+    //        return kFALSE;
+
     // Execute first analysis
     if (!evtloop.Eventloop(fMaxEvents))
@@ -654,5 +682,5 @@
         return kFALSE;
 
-    *fLog << inf << GetDescriptor() << ": Done." << endl;
+    *fLog << all << GetDescriptor() << ": Done." << endl;
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4722)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4723)
@@ -17,4 +17,5 @@
 class TH1D;
 class MExtractor;
+class MEvtLoop;
 
 class MJPedestal : public MParContainer
@@ -39,4 +40,5 @@
     
     TString fOutputPath;        // Directory where the F0-files get stored
+    TString fInputPath;         // Directory from which to read the data files
 
     TEnv       *fEnv;           // Input setup-file
@@ -55,4 +57,5 @@
     Bool_t fDataCheck;          // Flag if the data check is run on raw data
     Bool_t fUseData;            // Use data-runs from sequence instead of pedestal runs
+    Bool_t fOverwrite;          // Allow to overwite existing files
 
     Int_t fMaxEvents;           // Maximum number of events
@@ -60,4 +63,5 @@
     Bool_t ReadPedestalCam();
     Bool_t WriteResult();
+    //Bool_t WriteEventloop(MEvtLoop &evtloop) const;
 
     void   DisplayResult(MParList &plist);
@@ -86,5 +90,7 @@
     void SetSequence(const MSequence *seq, Bool_t usedata=kFALSE) { fSequence = seq; }
     void SetOutputPath(const char *path=".");
+    void SetInputPath(const char *path=".");
     void SetEnv(const char *env);
+    void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
     void SetMaxEvents(Int_t max) { fMaxEvents = max; }
 
@@ -94,4 +100,6 @@
     void SetNormalDisplay()    { fDisplayType = kNormalDisplay;    }
 
+    MStatusDisplay *GetDisplay() { return fDisplay; }
+
     ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
 };
Index: trunk/MagicSoft/Mars/mjobs/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mjobs/Makefile	(revision 4722)
+++ trunk/MagicSoft/Mars/mjobs/Makefile	(revision 4723)
@@ -28,4 +28,5 @@
 	   MJPedestal.cc \
            MJCalibration.cc \
+           MJCalibrateSignal.cc \
            MJExtractSignal.cc \
            MJExtractCalibTest.cc
Index: trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.cc	(revision 4723)
@@ -282,2 +282,9 @@
   out << ");" << endl;
 }
+
+void MExtractFixedWindow::Print(Option_t *o) const
+{
+    *fLog << all;
+    *fLog << GetDescriptor() << ":" << endl;
+    MExtractor::Print(o);
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.h	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.h	(revision 4723)
@@ -33,6 +33,8 @@
 
   void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+
+  void Print(Option_t *o="") const;
   
-  ClassDef(MExtractFixedWindow, 0) // Signal Extractor for a fixed extraction window
+  ClassDef(MExtractFixedWindow, 1) // Signal Extractor for a fixed extraction window
 };
 
Index: trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.cc	(revision 4723)
@@ -520,2 +520,13 @@
     return rc;
 }
+
+void MExtractFixedWindowPeakSearch::Print(Option_t *o) const
+{
+    *fLog << all;
+    *fLog << GetDescriptor() << ":" << endl;
+    *fLog << " Windows: Hi-Gain=" << (int)fHiGainWindowSize << "  Lo-Gain=" << (int)fLoGainWindowSize;
+    *fLog << "  Peak-Search=" << (int)fPeakSearchWindowSize << endl;
+    *fLog << " Offset From Window: " << (int)fOffsetFromWindow << endl;
+    *fLog << " Lo-Gain peak Shift: " << (int)fLoGainPeakShift << endl;
+    MExtractor::Print(o);
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.h	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.h	(revision 4723)
@@ -45,6 +45,8 @@
 
     void SetLoGainPeakShift(Byte_t shift=fgLoGainPeakShift) { fLoGainPeakShift = shift; }
-    
-    ClassDef(MExtractFixedWindowPeakSearch, 0) // Signal Extractor for fixed size trigger-corrected extraction window 
+
+    void Print(Option_t *o="") const;
+
+    ClassDef(MExtractFixedWindowPeakSearch, 1) // Signal Extractor for fixed size trigger-corrected extraction window
 };
 
Index: trunk/MagicSoft/Mars/msignal/MExtractSlidingWindow.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractSlidingWindow.h	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractSlidingWindow.h	(revision 4723)
@@ -32,5 +32,5 @@
                      Byte_t windowl=fgLoGainWindowSize);
 
-  ClassDef(MExtractSlidingWindow, 0) // Signal Extractor for sliding extraction window
+  ClassDef(MExtractSlidingWindow, 1) // Signal Extractor for sliding extraction window
 };
 
Index: trunk/MagicSoft/Mars/msignal/MExtractTime.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTime.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractTime.cc	(revision 4723)
@@ -69,5 +69,7 @@
 
 using namespace std;
+
 const Float_t MExtractTime::fgOffsetLoGain = 1.51;   // 5 ns
+
 // --------------------------------------------------------------------------
 //
@@ -83,5 +85,5 @@
 //
 MExtractTime::MExtractTime(const char *name, const char *title)
-  : fArrTime(NULL), fNamePedContainer("MPedestalCam")
+  : fArrTime(NULL)
 {
 
@@ -108,5 +110,4 @@
 Int_t MExtractTime::PreProcess(MParList *pList)
 {
-
   fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
   if (!fRawEvt)
@@ -129,5 +130,5 @@
   
 
-  fPedestals = (MPedestalCam*)pList->FindObject( AddSerialNumber(fNamePedContainer), "MPedestalCam");
+  fPedestals = (MPedestalCam*)pList->FindObject( AddSerialNumber(fNamePedestalCam), "MPedestalCam");
   if (!fPedestals)
     {
@@ -214,2 +215,30 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// In addition to the resources of the base-class MExtractor:
+//   MJPedestal.MExtractor.OffsetLoGain: 1.51
+//
+Int_t MExtractTime::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Bool_t rc = kFALSE;
+
+    if (IsEnvDefined(env, prefix, "OffsetLoGain", print))
+    {
+        fOffsetLoGain = GetEnvValue(env, prefix, "OffsetLoGain", fOffsetLoGain);
+        rc = kTRUE;
+    }
+
+    rc = MExtractor::ReadEnv(env, prefix, print) ? kTRUE : rc;
+
+    return rc;
+}
+
+void MExtractTime::Print(Option_t *o) const
+{
+    *fLog << all;
+    if (IsA()==MExtractTime::Class())
+        *fLog << GetDescriptor() << ":" << endl;
+    *fLog << " Offset Lo-Gain=" << fOffsetLoGain << endl;
+    MExtractor::Print(o);
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractTime.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTime.h	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractTime.h	(revision 4723)
@@ -8,21 +8,19 @@
 class MPedestalPix;
 class MArrivalTimeCam;
+
 class MExtractTime : public MExtractor
 {
-  
+private:
   static const Float_t fgOffsetLoGain;  // Default for fOffsetLoGain (now set to 1.51 (= 5ns)
 
+  Int_t  PreProcess(MParList *pList);
+  Bool_t ReInit(MParList *pList);
+  Int_t  Process();
+
 protected:
+  Float_t fOffsetLoGain;     // Offset of the low-gain signal w.r.t. the High-Gain slices
 
-  Float_t fOffsetLoGain;                // Offset of the low-gain signal w.r.t. the High-Gain slices 
-
-  MArrivalTimeCam *fArrTime;            // Container with the photons arrival times
-  TString fNamePedContainer; // name of the 'MPedestalCam' container
+  MArrivalTimeCam *fArrTime; //! Container with the photons arrival times
   
-
-  virtual Int_t PreProcess(MParList *pList);
-  virtual Bool_t ReInit(MParList *pList);
-  virtual Int_t Process();
-
   virtual void FindTimeHiGain(Byte_t *firstused, Float_t &time, Float_t &dtime,
                               Byte_t &sat, const MPedestalPix &ped) const;
@@ -30,17 +28,15 @@
                               Byte_t &sat, const MPedestalPix &ped) const;
 
+  Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
+
 public:
-
   MExtractTime(const char *name=NULL, const char *title=NULL);
 
   void SetOffsetLoGain( const Float_t f=fgOffsetLoGain) { fOffsetLoGain = f; }
-  void SetNamePedContainer(const char *name)    { fNamePedContainer = name; }
 
- 
-  ClassDef(MExtractTime, 0)   // Arrival Time Extractor Base Class
+  void Print(Option_t *o) const;
+
+  ClassDef(MExtractTime, 1)   // Arrival Time Extractor Base Class
 };
 
 #endif
-
-
-
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeAndCharge.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeAndCharge.h	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeAndCharge.h	(revision 4723)
@@ -9,10 +9,10 @@
 class MExtractTimeAndCharge : public MExtractTime
 {
+private:
+  Int_t  PreProcess(MParList *pList);
+  Bool_t ReInit(MParList *pList);
+  Int_t  Process();
+
 protected:
-
-  virtual Int_t PreProcess(MParList *pList);
-  virtual Bool_t ReInit(MParList *pList);
-  virtual Int_t Process();
-
   virtual void FindTimeAndChargeHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Float_t &dsum,
                                        Float_t &time, Float_t &dtime,
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeFastSpline.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeFastSpline.h	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeFastSpline.h	(revision 4723)
@@ -7,7 +7,8 @@
 
 class MPedestalPix;
+
 class MExtractTimeFastSpline : public MExtractTime
 {
-
+private:
   static const Byte_t  fgHiGainFirst;    // Default for fHiGainFirst  (now set to: 2)
   static const Byte_t  fgHiGainLast;     // Default for fHiGainLast   (now set to: 14)
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.cc	(revision 4723)
@@ -324,6 +324,14 @@
         SetWindowSize(hw, lw);
 
-    rc = MExtractor::ReadEnv(env, prefix, print) ? kTRUE : rc;
+    rc = MExtractTime::ReadEnv(env, prefix, print) ? kTRUE : rc;
 
     return rc;
 }
+
+void MExtractTimeHighestIntegral::Print(Option_t *o) const
+{
+    *fLog << all;
+    *fLog << GetDescriptor() << ":" << endl;
+    *fLog << " Windows: Hi-Gain=" << (int)fHiGainWindowSize << "  Lo-Gain=" << (int)fLoGainWindowSize << endl;
+    MExtractTime::Print(o);
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.h	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeHighestIntegral.h	(revision 4723)
@@ -9,5 +9,4 @@
 {
 private:
-
   static const Byte_t fgHiGainFirst;
   static const Byte_t fgHiGainLast;
@@ -34,5 +33,7 @@
                      Byte_t windowl=fgLoGainWindowSize);
 
-  ClassDef(MExtractTimeHighestIntegral, 0) // Task to Extract the Arrival Times As the mean time of the fWindowSize time slices
+  void Print(Option_t *o="") const;
+
+  ClassDef(MExtractTimeHighestIntegral, 1) // Task to Extract the Arrival Times As the mean time of the fWindowSize time slices
 };
 
Index: trunk/MagicSoft/Mars/msignal/MExtractTimeSpline.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractTimeSpline.h	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractTimeSpline.h	(revision 4723)
@@ -7,7 +7,8 @@
 
 class MPedestalPix;
+
 class MExtractTimeSpline : public MExtractTime
 {
-
+private:
   static const Byte_t fgHiGainFirst;
   static const Byte_t fgHiGainLast;
Index: trunk/MagicSoft/Mars/msignal/MExtractor.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 4723)
@@ -42,4 +42,14 @@
 //   setup file. For more information see ReadEnv and MEvtLoop::ReadEnv
 //
+//
+// IMPORTANT: For all classes you derive from MExtractor make sure that:
+//    - Print() is correctly implemented
+//    - Clone() works
+//    - Class Version number != 0 and the I/O works PERFECTLY
+//    - only data members which are necessary for the setup (not the ones
+//      created in PreProcess and Process) are written
+//    - the version number is maintained!
+//
+//
 // Input Containers:
 //   MRawEvtData
@@ -75,5 +85,6 @@
 
 const Byte_t  MExtractor::fgSaturationLimit  = 254;
-const TString MExtractor::fgNamePedContainer = "MPedestalCam";
+const TString MExtractor::fgNamePedestalCam = "MPedestalCam";
+
 // --------------------------------------------------------------------------
 //
@@ -84,5 +95,5 @@
 // - all variables to 0
 // - fSaturationLimit to fgSaturationLimit
-// - fNamePedContainer to fgNamePedContainer
+// - fNamePedestalCam to fgNamePedestalCam
 //
 // Call:
@@ -98,5 +109,5 @@
     AddToBranchList("MRawEvtData.*");
 
-    SetNamePedContainer();
+    SetNamePedestalCam();
     SetRange();
     SetSaturationLimit();
@@ -141,14 +152,14 @@
     
 
+    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedestalCam), "MPedestalCam");
+    if (!fPedestals)
+    {
+        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+        return kFALSE;
+    }
+
     fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
     if (!fSignals)
         return kFALSE;
-
-    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedContainer), "MPedestalCam");
-    if (!fPedestals)
-    {
-        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
-        return kFALSE;
-    }
 
     return kTRUE;
@@ -363,2 +374,14 @@
     return rc;
 }
+
+void MExtractor::Print(Option_t *o) const
+{
+    *fLog << all;
+
+    if (IsA()==MExtractor::Class())
+        *fLog << GetDescriptor() << ":" << endl;
+
+    *fLog << " Hi Gain Range:  " << (int)fHiGainFirst << " " << (int)fHiGainLast << endl;
+    *fLog << " Lo Gain Range:  " << (int)fLoGainFirst << " " << (int)fLoGainLast << endl;
+    *fLog << " Saturation Lim: " << (int)fSaturationLimit << endl;
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractor.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractor.h	(revision 4722)
+++ trunk/MagicSoft/Mars/msignal/MExtractor.h	(revision 4723)
@@ -25,8 +25,8 @@
 
   static const Byte_t  fgSaturationLimit;  //! Default for fSaturationLimit (now set to: 254)
-  static const TString fgNamePedContainer; //! "MPedestalCam"
+  static const TString fgNamePedestalCam; //! "MPedestalCam"
   
   MPedestalCam        *fPedestals;         //! Pedestals of all pixels in the camera
-  MExtractedSignalCam *fSignals;           //  Extracted signal of all pixels in the camera
+  MExtractedSignalCam *fSignals;           //! Extracted signal of all pixels in the camera
                                        
   MRawEvtData         *fRawEvt;            //! Raw event data (time slices)
@@ -47,5 +47,5 @@
                                            
   Byte_t   fSaturationLimit;               // Highest FADC slice value until being declared saturated
-  TString  fNamePedContainer;              // Name of the 'MPedestalCam' container
+  TString  fNamePedestalCam;              // Name of the 'MPedestalCam' container
   
   virtual void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const { }
@@ -59,5 +59,4 @@
 
 public:
-
   MExtractor(const char *name=NULL, const char *title=NULL);
   
@@ -72,7 +71,9 @@
 
   void SetSaturationLimit  ( Byte_t       lim=fgSaturationLimit        ) { fSaturationLimit  = lim;  }
-  void SetNamePedContainer ( const char *name=fgNamePedContainer.Data()) { fNamePedContainer = name; }
-  
-  ClassDef(MExtractor, 0) // Signal Extractor Base Class
+  void SetNamePedestalCam ( const char *name=fgNamePedestalCam.Data()) { fNamePedestalCam = name; }
+
+  void Print(Option_t *o="") const;
+
+  ClassDef(MExtractor, 1) // Signal Extractor Base Class
 };
 
