Index: trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 3305)
+++ trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 3306)
@@ -71,13 +71,4 @@
 #pragma link C++ class MPedestalWorkaround+;
 
-#pragma link C++ class MExtractedSignalCam+;
-#pragma link C++ class MExtractedSignalPix+;
-#pragma link C++ class MExtractSignal+;
-#pragma link C++ class MExtractSignal2+;
-
-#pragma link C++ class MArrivalTime+;
-#pragma link C++ class MArrivalTimeCalc+;
-#pragma link C++ class MArrivalTimeCalc2+;
-
 #pragma link C++ class MSourcePosfromStarPos+;
 #pragma link C++ class MMcCalibrationUpdate+;
Index: trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc	(revision 3305)
+++ 	(revision )
@@ -1,104 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Sebastian Raducci, 12/2003 <mailto:raducci@fisica.uniud.it>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// MArrivalTime
-//
-// Times are calculated using the TSpline5 Root Class
-// 
-/////////////////////////////////////////////////////////////////////////////
-#include "MArrivalTime.h"
-
-#include "MGeomCam.h"
-#include "MGeomPix.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MRawEvtPixelIter.h"
-#include "MRawEvtData.h"
-
-ClassImp(MArrivalTime);
-
-using namespace std;
-
-
-// --------------------------------------------------------------------------
-//
-// Creates an object containing the arrival time for each pixel in the event
-//
-MArrivalTime::MArrivalTime(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MArrivalTime";
-    fTitle = title ? title : "Photons arrival times Information";
-}
-
-// -------------------------------------------------------------------------
-//
-// Sets every pixel arrival time to -1
-//
-void MArrivalTime::Reset()
-{
-    fData.Reset(-1);
-}
-
-void MArrivalTime::InitSize(Int_t i)
-{
-    fData.Set(i);
-}
-
-// -------------------------------------------------------------------------
-// 
-// Set the arrival time in one pixel
-//
-void MArrivalTime::SetTime(const Int_t i, const Float_t t)
-{
-    fData[i] = t;
-}
-      
-// --------------------------------------------------------------------------
-//
-// Returns the arrival time value
-//
-Bool_t MArrivalTime::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
-{
-    if (idx<0 || idx>=fData.GetSize())
-        return kFALSE;
-
-    switch (type)
-    {
-    case 0:
-    case 1:
-        val = fData[idx];
-        break;
-    }
-
-    return kTRUE;
-}
-
-void MArrivalTime::DrawPixelContent(Int_t num) const
-{
-    *fLog << warn << "MArrivalTime::DrawPixelContent - not available." << endl;
-}
Index: trunk/MagicSoft/Mars/manalysis/MArrivalTime.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MArrivalTime.h	(revision 3305)
+++ 	(revision )
@@ -1,47 +1,0 @@
-#ifndef MARS_MArrivalTime
-#define MARS_MArrivalTime
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-#ifndef MARS_MCamEvent
-#include "MCamEvent.h"
-#endif
-
-#ifndef ROOT_TArrayF
-#include <TArrayF.h>
-#endif
-#ifndef ROOT_TArrayS
-#include <TArrayS.h>
-#endif
-
-class MRawEvtData;
-
-class MArrivalTime : public MParContainer, public MCamEvent
-{
- private:
-    TArrayF fData;  // Stores the arrival times
-
-public:
-
-    MArrivalTime(const char *name=NULL, const char *title=NULL);
-    ~MArrivalTime() { }
-
-    void   Reset();
-    void   InitSize(Int_t i);
-
-    UInt_t GetSize() const { return fData.GetSize(); }
-
-    void SetTime(const Int_t i, const Float_t time);
-    
-    const TArrayF &GetData() const { return fData; }
-
-    Double_t operator[](int i) { return fData[i]; }
-
-    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
-    void DrawPixelContent(Int_t num) const;
-
-    ClassDef(MArrivalTime, 0)    // class for an event containing the arrival times
-};
-
-#endif
Index: trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc	(revision 3305)
+++ 	(revision )
@@ -1,187 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Sebastian Raducci 12/2003 <mailto:raducci@fisica.uniud.it>
-!
-!   Copyright: MAGIC Software Development, 2002-2004
-!
-!
-\* ======================================================================== */
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//   MArrivalTimeCalc
-//
-//   This is a task that calculates the arrival times of photons. 
-//   It returns the absolute maximum of the spline that interpolates
-//   the FADC slices 
-//
-// Input Containers:
-//   MRawEvtData
-//
-// Output Containers:
-//   MArrivalTime
-//   MRawEvtData
-//
-//////////////////////////////////////////////////////////////////////////////
-#include "MArrivalTimeCalc.h"
-
-#include "MCubicSpline.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-
-#include "MGeomCam.h"
-#include "MArrivalTime.h"
-#include "MRawEvtData.h"      
-#include "MRawEvtPixelIter.h"
-
-ClassImp(MArrivalTimeCalc);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// Default constructor.
-//
-// 
-MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title) 
-{
-
-    fName  = name  ? name  : "MArrivalTimeCalc";
-    fTitle = title ? title : "Calculate photons arrival time";
-
-}
-
-// --------------------------------------------------------------------------
-//
-// The PreProcess searches for the following input containers:
-//  - MRawEvtData
-//  - MArrivalTime
-//
-// The following output containers are also searched and created if
-// they were not found:
-//  - MArrivalTime
-//
-
-Int_t MArrivalTimeCalc::PreProcess(MParList *pList)
-{
-
-
-    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
-    if (!fRawEvt)
-    {
-        *fLog << err << "MRawEvtData not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fArrTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
-    if (!fArrTime)
-        return kFALSE;
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// The ReInit searches for the following input containers:
-//  - MGeomCam
-//
-Bool_t MArrivalTimeCalc::ReInit(MParList *pList)
-{
-    MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
-    if (!cam)
-    {
-        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
-        return kFALSE;
-    }
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Evaluation of the mean arrival times (spline interpolation)
-// per pixel and store them in the MArrivalTime container.
-//
-Int_t MArrivalTimeCalc::Process()
-{
-
-  MRawEvtPixelIter pixel(fRawEvt);
-  
-  while (pixel.Next())
-    {
-      
-      const UInt_t idx = pixel.GetPixelId();
-      Float_t time = 0.;
-
-
-      //
-      // If pixel is saturated we use LoGains
-      //
-      if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
-        {
-          
-          const Short_t nslices = fRawEvt->GetNumLoGainSamples();
-          time = Calc(pixel.GetLoGainSamples(),nslices);
-        }
-      
-
-      //
-      // Use HiGains
-      //
-      else if (pixel.HasLoGain())
-        {
-          
-          const Short_t nslices = fRawEvt->GetNumHiGainSamples();
-          time = Calc(pixel.GetHiGainSamples(),nslices);
-        }
-      
-      //
-      // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
-      //
-      fArrTime->SetTime(idx,time);
-      
-    }
-    
-  fArrTime->SetReadyToSave();
-  
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Calculates the arrival time for each pixel 
-// Possible Methods 
-// Case 1: MCubicSpline (3rd order spline)
-//
-Float_t MArrivalTimeCalc::Calc(const Byte_t *fadcSamples, const Short_t nslices)
-{
-
-  //
-  // Initialize the spline
-  //
-    MCubicSpline *spline = new MCubicSpline(fadcSamples);  
-
-  //
-  // Now find the maximum  
-  //
-   return (Float_t)spline->EvalAbMax();
-}
-
Index: trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h	(revision 3305)
+++ 	(revision )
@@ -1,34 +1,0 @@
-#ifndef MARS_MArrivalTimeCalc
-#define MARS_MArrivalTimeCalc
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-class MRawEvtData;
-class MRawRunHeader;
-class MArrivalTime;
-
-class MArrivalTimeCalc : public MTask
-{
-
-    MRawEvtData    *fRawEvt;     // raw event data (time slices)
-    MRawRunHeader  *fRunHeader;  // RunHeader information
-
-    MArrivalTime   *fArrTime;    // Container with the photons arrival times
-
-    Int_t PreProcess(MParList *pList);
-    Bool_t ReInit(MParList *pList);
-    Int_t Process();
-    Int_t PostProcess() {return kTRUE;}
-
-    Float_t Calc(const Byte_t *fadcSamples, const Short_t nslices);
- 
-public:
-    MArrivalTimeCalc(const char *name=NULL, const char *title=NULL);
-    ~MArrivalTimeCalc(){}
- 
-    ClassDef(MArrivalTimeCalc, 0)   // Task to calculate Arrival Times from raw data
-};
-
-#endif
Index: trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc2.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc2.cc	(revision 3305)
+++ 	(revision )
@@ -1,259 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
-!              Hendrik Bartko, 02/2004 <mailto:hbartko@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//   MArrivalTimeCalc2
-//
-//  Calculates the arrival time as the mean time of the fWindowSize time slices
-//  which have the highest integral content.
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-#include "MArrivalTimeCalc2.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-
-#include "MRawEvtData.h"
-#include "MRawEvtPixelIter.h"
-
-#include "MPedestalCam.h"
-#include "MPedestalPix.h"
-
-#include "MArrivalTimeCam.h"
-#include "MArrivalTimePix.h"
-
-
-ClassImp(MArrivalTimeCalc2);
-
-using namespace std;
-
-const Byte_t MArrivalTimeCalc2::fgSaturationLimit = 254;
-const Byte_t MArrivalTimeCalc2::fgFirst  =  0;
-const Byte_t MArrivalTimeCalc2::fgLast   = 14;
-const Byte_t MArrivalTimeCalc2::fgWindowSize = 6;
-
-// --------------------------------------------------------------------------
-//
-// Default constructor. 
-//
-MArrivalTimeCalc2::MArrivalTimeCalc2(const char *name, const char *title)
-  : fSaturationLimit(fgSaturationLimit)
-{
-
-    fName  = name  ? name  : "MArrivalTimeCalc2";
-    fTitle = title ? title : "Task to extract the signal from the FADC slices";
-
-    AddToBranchList("MRawEvtData.*");
-
-    SetRange();
-}
-
-void MArrivalTimeCalc2::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast, Byte_t windowsize)
-{
-    fNumHiGainSamples = hilast-hifirst+1;
-    fNumLoGainSamples = lolast-lofirst+1;
-
-    fHiGainFirst = hifirst;
-    fLoGainFirst = lofirst;
-
-    fWindowSize = windowsize & ~1;
-
-    if (fWindowSize != windowsize)
-      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size has to be even, set to: " << int(fWindowSize) << " samples " << endl;
-
-    if (fWindowSize<2) 
-    {
-      fWindowSize = 2;
-      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to two samples" << endl;
-    }
-
-    if (fWindowSize > fNumHiGainSamples)
-    {
-      fWindowSize = fNumLoGainSamples & ~1;
-      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
-    }
-
-    if (fWindowSize > fNumLoGainSamples)
-    {
-      fWindowSize = fNumLoGainSamples & ~1;
-      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
-    }
-
-    fWindowSizeSqrt = TMath::Sqrt((Float_t)fWindowSize);
-}
-
-// --------------------------------------------------------------------------
-//
-// The PreProcess searches for the following input containers:
-//  - MRawEvtData
-//  - MPedestalCam
-//
-// The following output containers are also searched and created if
-// they were not found:
-//
-//  - MExtractedSignalCam
-//
-Int_t MArrivalTimeCalc2::PreProcess(MParList *pList)
-{
-    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
-    if (!fRawEvt)
-    {
-        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
-    if (!fPedestals)
-    {
-        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
-        return kFALSE;
-    }
-
-    fArrivalTime = (MArrivalTimeCam*)pList->FindCreateObj(AddSerialNumber("MArrivalTimeCam"));
-    if (!fArrivalTime)
-        return kFALSE;
-
-    return kTRUE;
-}
-
-void MArrivalTimeCalc2::FindSignalTime(Byte_t *ptr, Byte_t size, Float_t &time, Float_t &deltatime, Int_t &sat, Float_t pedes, Float_t pedrms) const
-{
-    const Byte_t *end = ptr + size;
-
-    Int_t sum=0;    // integral content of the actual window
-    Int_t max = 0;  // highest integral content of all windows
-
-    //
-    // Calculate the sum of the first fWindowSize slices
-    //
-    sat = 0;
-    Byte_t *p = ptr;
-
-    while (p<ptr+fWindowSize)
-    {
-        sum += *p;
-        if (*p++ >= fSaturationLimit)
-            sat++;
-    }
-
-    //
-    // Check for saturation in all other slices
-    //
-    while (p<end)
-        if (*p++ >= fSaturationLimit)
-            sat++;
-
-    //
-    // Calculate the i-th sum as
-    //    sum_i+1 = sum_i + slice[i+8] - slice[i]
-    // This is fast and accurate (because we are using int's)
-    //
-    max=sum;
-    Byte_t *ptrmax=ptr;  // pointer to the first slice of the maximum window
-
-    for (p=ptr; p+fWindowSize<end; p++)
-    {
-        sum += *(p+fWindowSize) - *p;
-		
-	if (sum>max)
-	{
-	  max = sum;
-	  ptrmax = p;
-	}
-    }
-
-    // now calculate the time for the maximum window
-    Int_t timesignalsum = 0;
-    Int_t timesquaredsum =0;
-    Int_t timesum =0;
-
-    for (p=ptrmax; p < ptrmax + fWindowSize; p++)
-    {
-        timesignalsum += *p*(p-ptr);
-        timesum += p-ptr;
-        timesquaredsum  += (p-ptr)*(p-ptr);
-    }
-
-    const Float_t pedsubsum = max - fWindowSize*pedes;
-    const Float_t pedsubtimesignalsum = timesignalsum - timesum*pedes;
-
-    time      = pedsubsum != 0 ? pedsubtimesignalsum / pedsubsum : 1;
-    deltatime = pedsubsum != 0 ? pedrms / pedsubsum * sqrt(timesquaredsum - fWindowSize*time) : 1;
-}
-
-// --------------------------------------------------------------------------
-//
-//  Calculates the arrival time as the mean time of the fWindowSize time slices
-//  which have the highest integral content.
-//
-Int_t MArrivalTimeCalc2::Process()
-{
-    MRawEvtPixelIter pixel(fRawEvt);
-
-    Int_t sat=0;
-    while (pixel.Next())
-    {
-        //
-        // Find signal in hi- and lo-gain
-        //
-        Float_t timehi, timelo, deltatimehi, deltatimelo;
-        Int_t sathi, satlo;
-
-	//
-        // Take correspodning pedestal
-        //
-        const Int_t pixid = pixel.GetPixelId();
-
-	const MPedestalPix  &ped = (*fPedestals)[pixid];
-
-	MArrivalTimePix &pix = (*fArrivalTime)[pixid];
-
-	const Float_t pedes  = ped.GetPedestal();
-	const Float_t pedrms = ped.GetPedestalRms();
-
-	FindSignalTime(pixel.GetHiGainSamples()+fHiGainFirst, fNumHiGainSamples, timehi, deltatimehi, sathi, pedes, pedrms);
-        FindSignalTime(pixel.GetLoGainSamples()+fLoGainFirst, fNumLoGainSamples, timelo, deltatimelo, satlo, pedes, pedrms);
-
-        if (satlo)
-            sat++;
-
-        pix.SetArrivalTime(timehi, deltatimehi, timelo, deltatimelo);
-	pix.SetGainSaturation(sathi, sathi, satlo);
-    }
-
-    fArrivalTime->SetReadyToSave();
-
-    //
-    // Print a warning if event has saturationg lo-gains
-    //
-    if (sat)
-        *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels." << endl;
-
-    return kTRUE;
-}
Index: trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc2.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc2.h	(revision 3305)
+++ 	(revision )
@@ -1,58 +1,0 @@
-#ifndef MARS_MArrivalTimeCalc2
-#define MARS_MArrivalTimeCalc2
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-class MRawEvtData;
-class MRawRunHeader;
-
-class MPedestalCam;
-class MArrivalTimeCam;
-
-class MArrivalTimeCalc2 : public MTask
-{
-private:
-    static const Byte_t fgSaturationLimit;
-    static const Byte_t fgFirst;
-    static const Byte_t fgLast;
-    static const Byte_t fgWindowSize;
-
-    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
-
-    MRawEvtData         *fRawEvt;       // raw event data (time slices)
-    MRawRunHeader       *fRunHeader;    // RunHeader information
-
-    
-    MArrivalTimeCam        *fArrivalTime;  // Arrival Time of FADC sample
-     
-  
-    Byte_t  fHiGainFirst;       // First hi gain to be used
-    Byte_t  fLoGainFirst;       // First lo gain to be used
-
-    Byte_t  fNumHiGainSamples;  // Number of hi gain to be used
-    Byte_t  fNumLoGainSamples;  // Number of lo gain to be used
-
-    Byte_t  fWindowSize;            // Number of gains in window
-    Float_t fWindowSizeSqrt;        // Sqaure root of number of gains in window
-
-    Byte_t  fSaturationLimit;
-
-    void   FindSignalTime(Byte_t *ptr, Byte_t size, Float_t &time,  Float_t &deltatime, Int_t &sat, Float_t pedes, Float_t pedrms) const;
-
-    Int_t  PreProcess(MParList *pList);
-    Int_t  Process();
-
-public:
-    MArrivalTimeCalc2(const char *name=NULL, const char *title=NULL);
-
-    void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast, Byte_t lofirst=fgFirst, Byte_t lolast=fgLast, Byte_t windowsize=fgWindowSize);
-    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
-
-    ClassDef(MArrivalTimeCalc2, 0) // Calculates the arrival time as the mean time of the fWindowSize time slices
-};
-
-#endif
-
-
Index: trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc	(revision 3305)
+++ 	(revision )
@@ -1,233 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Markus Gaug, 09/2003 <mailto:markus@ifae.es>
-!              Thomas Bretz, 01/2004 
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//   MExtractSignal
-//
-//////////////////////////////////////////////////////////////////////////////
-#include "MExtractSignal.h"
-
-#include <fstream>
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-
-#include "MRawEvtData.h"
-#include "MRawEvtPixelIter.h"
-
-#include "MPedestalCam.h"
-#include "MPedestalPix.h"
-
-#include "MExtractedSignalCam.h"
-#include "MExtractedSignalPix.h"
-
-ClassImp(MExtractSignal);
-
-using namespace std;
-
-const Byte_t MExtractSignal::fgSaturationLimit = 254;
-const Byte_t MExtractSignal::fgFirst =  3;
-const Byte_t MExtractSignal::fgLast  = 10;
-
-// --------------------------------------------------------------------------
-//
-// Default constructor. 
-//
-MExtractSignal::MExtractSignal(const char *name, const char *title)
-    : fSaturationLimit(fgSaturationLimit)
-{
-
-    fName  = name  ? name  : "MExtractSignal";
-    fTitle = title ? title : "Task to extract the signal from the FADC slices";
-
-    AddToBranchList("MRawEvtData.*");
-
-    SetRange();
-}
-
-void MExtractSignal::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
-{
-
-    fNumHiGainSamples = hilast-hifirst+1;
-    fNumLoGainSamples = lolast-lofirst+1;
-
-    fHiGainFirst = hifirst;
-    fLoGainFirst = lofirst;
-
-    fSqrtHiGainSamples = TMath::Sqrt((Float_t)fNumHiGainSamples);
-    fSqrtLoGainSamples = TMath::Sqrt((Float_t)fNumLoGainSamples);
-}
-
-// --------------------------------------------------------------------------
-//
-// The PreProcess searches for the following input containers:
-//  - MRawEvtData
-//  - MPedestalCam
-//
-// The following output containers are also searched and created if
-// they were not found:
-//
-//  - MExtractedSignalCam
-//
-Int_t MExtractSignal::PreProcess(MParList *pList)
-{
-    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
-    if (!fRawEvt)
-    {
-        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
-        return kFALSE;
-    }
-
-
-    fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
-    if (!fSignals)
-        return kFALSE;
-
-    fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainFirst+fNumHiGainSamples-1,
-                                fLoGainFirst, fLoGainFirst+fNumLoGainSamples-1);
-
-    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
-
-    if (!fPedestals)
-    {
-        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
-        return kFALSE;
-    }
-
-    return kTRUE;
-}
-
-void MExtractSignal::FindSignal(Byte_t *ptr, Int_t size, Int_t &sum, Byte_t &sat) const
-{
-
-  Byte_t *end = ptr + size;
-  
-  sum = 0;
-  sat = 0;
-  
-  while (ptr<end)
-    {
-      sum += *ptr;
-      
-      if (*ptr++ >= fSaturationLimit)
-        sat++;
-    }
-}
-
-// --------------------------------------------------------------------------
-//
-// Calculate the integral of the FADC time slices and store them as a new
-// pixel in the MExtractedSignalCam container.
-//
-Int_t MExtractSignal::Process()
-{
-
-    MRawEvtPixelIter pixel(fRawEvt);
-    fSignals->Clear();
-
-    UInt_t  sat=0;
-    TString satpixels;
-
-    while (pixel.Next())
-    {
-        Int_t sumhi, sumlo;
-        Byte_t sathi, satlo;
-
-        FindSignal(pixel.GetHiGainSamples()+fHiGainFirst-1, fNumHiGainSamples, sumhi, sathi);
-        FindSignal(pixel.GetLoGainSamples()+fLoGainFirst-1, fNumLoGainSamples, sumlo, satlo);
-
-        if (satlo)
-        {
-            sat++;
-            satpixels += Form(" %d", pixel.GetPixelId());
-        }
-        
-
-        const Int_t pixid = pixel.GetPixelId();
-
-        const MPedestalPix  &ped = (*fPedestals)[pixid]; 
-	MExtractedSignalPix &pix = (*fSignals)[pixid];
-
-        const Float_t pedes  = ped.GetPedestal();
-        const Float_t pedrms = ped.GetPedestalRms();
-
-        
-	pix.SetExtractedSignal(sumhi - pedes*fNumHiGainSamples, pedrms*fSqrtHiGainSamples,
-                               sumlo - pedes*fNumLoGainSamples, pedrms*fSqrtLoGainSamples);
-
-	pix.SetGainSaturation(sathi, sathi, satlo);
-
-    } /* while (pixel.Next()) */
-
-    if (sat)
-        *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels with Index:" << satpixels << endl;
-
-    fSignals->SetReadyToSave();
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Implementation of SavePrimitive. Used to write the call to a constructor
-// to a macro. In the original root implementation it is used to write
-// gui elements to a macro-file.
-//
-void MExtractSignal::StreamPrimitive(ofstream &out) const
-{
-    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
-    out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
-
-    if (fSaturationLimit!=fgSaturationLimit)
-    {
-        out << "   " << GetUniqueName() << ".SetSaturationLimit(";
-        out << (int)fSaturationLimit << ");" << endl;
-    }
-
-    const Bool_t arg4 = fNumLoGainSamples+fLoGainFirst-1 != fgLast;
-    const Bool_t arg3 = arg4 || fLoGainFirst != fgFirst;
-    const Bool_t arg2 = arg3 || fNumHiGainSamples+fHiGainFirst-1 != fgLast;
-    const Bool_t arg1 = arg2 || fHiGainFirst != fgFirst;
-
-    if (!arg1)
-        return;
-
-    out << "   " << GetUniqueName() << ".SetRange(";
-    out << (int)fLoGainFirst;
-    if (arg2)
-    {
-        out << ", " << (int)(fNumHiGainSamples+fHiGainFirst-1);
-        if (arg3)
-        {
-            out << ", " << (int)fLoGainFirst;
-            if (arg4)
-                out << ", " << (int)(fNumLoGainSamples+fLoGainFirst-1);
-        }
-    }
-    out << ");" << endl;
-}
Index: trunk/MagicSoft/Mars/manalysis/MExtractSignal.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractSignal.h	(revision 3305)
+++ 	(revision )
@@ -1,62 +1,0 @@
-#ifndef MARS_MExtractSignal
-#define MARS_MExtractSignal
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MExtractSignal                                                          //
-//                                                                         //
-// Integrates the time slices of the all pixels of a calibration event     //
-// and substract the pedestal value                                        //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-class MRawEvtData;
-class MRawRunHeader;
-
-class MPedestalCam;
-class MExtractedSignalCam;
-
-class MExtractSignal : public MTask
-{
-private:
-    static const Byte_t fgSaturationLimit;
-    static const Byte_t fgFirst;
-    static const Byte_t fgLast;
-
-    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
-    MExtractedSignalCam *fSignals;      // Extracted signal of all pixels in the camera
-
-    MRawEvtData         *fRawEvt;       // raw event data (time slices)
-    MRawRunHeader       *fRunHeader;    // RunHeader information
-
-    Byte_t  fHiGainFirst;
-    Byte_t  fLoGainFirst;
-
-    Byte_t  fNumHiGainSamples;
-    Byte_t  fNumLoGainSamples;
-
-    Float_t fSqrtHiGainSamples;
-    Float_t fSqrtLoGainSamples;
-
-    Byte_t  fSaturationLimit;
-
-    void   FindSignal(Byte_t *ptr, Int_t size, Int_t &sum, Byte_t &sat) const;
-
-    Int_t  PreProcess(MParList *pList);
-    Int_t  Process();
-    void   StreamPrimitive(ofstream &out) const;
-
-public:
-    MExtractSignal(const char *name=NULL, const char *title=NULL);
-
-    void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast, Byte_t lofirst=fgFirst, Byte_t lolast=fgLast);
-    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
-
-    ClassDef(MExtractSignal, 0) // Task to fill the Extracted Signal Containers from raw data
-};
-
-#endif
Index: trunk/MagicSoft/Mars/manalysis/MExtractSignal2.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractSignal2.cc	(revision 3305)
+++ 	(revision )
@@ -1,250 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
-!              Hendrik Bartko, 01/2004 <mailto:hbartko@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//   MExtractSignal2
-//
-//  Calculate the signal as the fWindowSize time slices which have the highest
-// integral contents.
-//
-// 
-//
-//////////////////////////////////////////////////////////////////////////////
-#include "MExtractSignal2.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-
-#include "MRawEvtData.h"
-#include "MRawEvtPixelIter.h"
-
-#include "MPedestalCam.h"
-#include "MPedestalPix.h"
-
-#include "MExtractedSignalCam.h"
-#include "MExtractedSignalPix.h"
-
-//#include "MArrivalTime.h"
-
-ClassImp(MExtractSignal2);
-
-using namespace std;
-
-const Byte_t MExtractSignal2::fgSaturationLimit = 254;
-const Byte_t MExtractSignal2::fgFirst  =  0;
-const Byte_t MExtractSignal2::fgLast   = 14;
-const Byte_t MExtractSignal2::fgWindowSize = 6;
-
-// --------------------------------------------------------------------------
-//
-// Default constructor. 
-//
-MExtractSignal2::MExtractSignal2(const char *name, const char *title)
-  : fSaturationLimit(fgSaturationLimit)
-{
-
-    fName  = name  ? name  : "MExtractSignal2";
-    fTitle = title ? title : "Task to extract the signal from the FADC slices";
-
-    AddToBranchList("MRawEvtData.*");
-
-    SetRange();
-}
-
-void MExtractSignal2::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast, Byte_t windowsize)
-{
-
-    fNumHiGainSamples = hilast-hifirst+1;
-    fNumLoGainSamples = lolast-lofirst+1;
-
-    fHiGainFirst = hifirst;
-    fLoGainFirst = lofirst;
-
-   
-    fWindowSize = windowsize & ~1;
-
-    if (fWindowSize != windowsize)
-      *fLog << warn << "MExtractSignal2::SetRange - window size has to be even, set to: " << int(fWindowSize) << " samples " << endl;
-    
-    if (fWindowSize<2) 
-    {
-      fWindowSize = 2;
-      *fLog << warn << "MExtractSignal2::SetRange - window size set to two samples" << endl;
-    }
-
-    if (fWindowSize > fNumHiGainSamples)
-    {
-      fWindowSize = fNumLoGainSamples & ~1;
-      *fLog << warn << "MExtractSignal2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
-    }
-    
-    if (fWindowSize > fNumLoGainSamples)
-    {
-      fWindowSize = fNumLoGainSamples & ~1;
-      *fLog << warn << "MExtractSignal2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
-    }
-
-    fWindowSizeSqrt = TMath::Sqrt((Float_t)fWindowSize);
-
-}
-
-
-
-// --------------------------------------------------------------------------
-//
-// The PreProcess searches for the following input containers:
-//  - MRawEvtData
-//  - MPedestalCam
-//
-// The following output containers are also searched and created if
-// they were not found:
-//
-//  - MExtractedSignalCam
-//
-Int_t MExtractSignal2::PreProcess(MParList *pList)
-{
-    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
-    if (!fRawEvt)
-    {
-        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
-        return kFALSE;
-    }
-
-
-    fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
-    if (!fSignals)
-        return kFALSE;
-
-    fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainFirst+fNumHiGainSamples-1,
-                                fLoGainFirst, fLoGainFirst+fNumLoGainSamples-1);
-
-    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
-    if (!fPedestals)
-    {
-        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
-        return kFALSE;
-    }
-/*
-    fArrivalTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
-    if (!fArrivalTime)
-        return kFALSE;
- */
-    return kTRUE;
-}
-
-void MExtractSignal2::FindSignal(Byte_t *ptr, Byte_t size, Int_t &max, Int_t &sat) const
-{
-    const Byte_t *end = ptr + size;
-
-    Int_t sum=0;
-
-    //
-    // Calculate the sum of the first fWindowSize slices
-    //
-    sat = 0;
-    Byte_t *p = ptr;
-    while (p<ptr+fWindowSize)
-    {
-        sum += *p;
-        if (*p++ >= fSaturationLimit)
-            sat++;
-    }
-
-    //
-    // Check for saturation in all other slices
-    //
-    while (p<end)
-        if (*p++ >= fSaturationLimit)
-            sat++;
-
-    //
-    // Calculate the i-th sum as
-    //    sum_i+1 = sum_i + slice[i+8] - slice[i]
-    // This is fast and accurate (because we are using int's)
-    //
-    max=sum;
-    for (p=ptr; p+fWindowSize<end; p++)
-    {
-        sum += *(p+fWindowSize) - *p;
-        if (sum>max)
-            max = sum;
-    }
-}
-
-// --------------------------------------------------------------------------
-//
-// Calculate the integral of the FADC of fWindowSize time slices which have the
-// highest signal
-//
-Int_t MExtractSignal2::Process()
-{
-    MRawEvtPixelIter pixel(fRawEvt);
-    fSignals->Clear();
-
-    Int_t sat=0;
-    while (pixel.Next())
-    {
-        //
-        // Find signal in hi- and lo-gain
-        //
-        Int_t sumhi, sumlo, sathi, satlo;
-        FindSignal(pixel.GetHiGainSamples()+fHiGainFirst, fNumHiGainSamples, sumhi, sathi);
-        FindSignal(pixel.GetLoGainSamples()+fLoGainFirst, fNumLoGainSamples, sumlo, satlo);
-        if (satlo)
-            sat++;
-
-        //
-        // Take correspodning pedestal
-        //
-        const Int_t pixid = pixel.GetPixelId();
-
-        const MPedestalPix  &ped = (*fPedestals)[pixid];
-        MExtractedSignalPix &pix = (*fSignals)[pixid];
-
-        const Float_t pedes  = ped.GetPedestal();
-        const Float_t pedrms = ped.GetPedestalRms();
-
-        //
-        // Set extracted signal with pedestal substracted
-        //
-        pix.SetExtractedSignal(sumhi - pedes*fWindowSize, pedrms*fWindowSizeSqrt,
-                               sumlo - pedes*fWindowSize, pedrms*fWindowSizeSqrt);
-
-        pix.SetGainSaturation(sathi, sathi, satlo);
-    } /* while (pixel.Next()) */
-
-    //
-    // Print a warning if evant has saturationg lo-gains
-    //
-    if (sat)
-        *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels." << endl;
-
-    fSignals->SetReadyToSave();
-
-    return kTRUE;
-}
Index: trunk/MagicSoft/Mars/manalysis/MExtractSignal2.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractSignal2.h	(revision 3305)
+++ 	(revision )
@@ -1,58 +1,0 @@
-#ifndef MARS_MExtractSignal2
-#define MARS_MExtractSignal2
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-class MRawEvtData;
-class MRawRunHeader;
-
-class MPedestalCam;
-class MExtractedSignalCam;
-//class MArrivalTime;
-
-class MExtractSignal2 : public MTask
-{
-private:
-    static const Byte_t fgSaturationLimit;
-    static const Byte_t fgFirst;
-    static const Byte_t fgLast;
-    static const Byte_t fgWindowSize;
-
-    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
-    MExtractedSignalCam *fSignals;      // Extracted signal of all pixels in the camera
-
-    MRawEvtData         *fRawEvt;       // raw event data (time slices)
-    MRawRunHeader       *fRunHeader;    // RunHeader information
-
-    /*
-     MArrivalTime        *fArrivalTime;  // Arrival Time of FADC sample
-     */
-  
-    Byte_t  fHiGainFirst;       // First hi gain to be used
-    Byte_t  fLoGainFirst;       // First lo gain to be used
-
-    Byte_t  fNumHiGainSamples;  // Number of hi gain to be used
-    Byte_t  fNumLoGainSamples;  // Number of lo gain to be used
-
-    Byte_t  fWindowSize;            // Number of gains in window
-    Float_t fWindowSizeSqrt;        // Sqaure root of number of gains in window
-
-    Byte_t  fSaturationLimit;
-
-    void   FindSignal(Byte_t *ptr, Byte_t size, Int_t &max, Int_t &sat) const;
-
-    Int_t  PreProcess(MParList *pList);
-    Int_t  Process();
-
-public:
-    MExtractSignal2(const char *name=NULL, const char *title=NULL);
-
-    void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast, Byte_t lofirst=fgFirst, Byte_t lolast=fgLast, Byte_t window_size=fgWindowSize);
-    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
-
-    ClassDef(MExtractSignal2, 0) // Extracted Signal as highest integral content
-};
-
-#endif
Index: trunk/MagicSoft/Mars/manalysis/MExtractedSignalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractedSignalCam.cc	(revision 3305)
+++ 	(revision )
@@ -1,162 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Markus Gaug  12/2003 <mailto:markus@ifae.es>
-!   Author(s): Thomas Bretz 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// MExtractedSignalCam
-//
-// Hold the Extracted Signal information for all pixels in the camera
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MExtractedSignalCam.h"
-
-#include <TClonesArray.h>
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MExtractedSignalPix.h"
-
-ClassImp(MExtractedSignalCam);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// Default constructor. Creates a MExtractedSignalPix object for each pixel
-//
-MExtractedSignalCam::MExtractedSignalCam(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MExtractedSignalCam";
-    fTitle = title ? title : "Storage container for all Extracted Signal Information in the camera";
-
-    fArray = new TClonesArray("MExtractedSignalPix", 1);
-}
-
-// --------------------------------------------------------------------------
-//
-// Delete the array conatining the pixel pedest information
-//
-MExtractedSignalCam::~MExtractedSignalCam()
-{
-    delete fArray;
-}
-
-// --------------------------------------------------------------------------
-//
-// Distribute logging stream to all childs
-//
-void MExtractedSignalCam::SetLogStream(MLog *lg)
-{
-    fArray->ForEach(MParContainer, SetLogStream)(lg);
-    MParContainer::SetLogStream(lg);
-}
-
-// --------------------------------------------------------------------------
-//
-// Set the size of the camera
-//
-void MExtractedSignalCam::InitSize(const UInt_t i)
-{
-    fArray->ExpandCreate(i);
-}
-
-// --------------------------------------------------------------------------
-//
-// Get the size of the MExtractedSignalCam
-//
-Int_t MExtractedSignalCam::GetSize() const
-{
-    return fArray->GetEntriesFast();
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th pixel (pixel index)
-//
-MExtractedSignalPix &MExtractedSignalCam::operator[](Int_t i)
-{
-    return *static_cast<MExtractedSignalPix*>(fArray->UncheckedAt(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th pixel (pixel index)
-//
-const MExtractedSignalPix &MExtractedSignalCam::operator[](Int_t i) const
-{
-    return *static_cast<MExtractedSignalPix*>(fArray->UncheckedAt(i));
-}
-
-void MExtractedSignalCam::Clear(Option_t *o)
-{
-    fArray->ForEach(TObject, Clear)();
-}
-
-void MExtractedSignalCam::Print(Option_t *o) const
-{
-    *fLog << all << GetDescriptor() << ":" << endl;
-    int idx = -1;
-
-    TIter Next(fArray);
-    MExtractedSignalPix *pix;
-    while ((pix=(MExtractedSignalPix*)Next()))
-    {
-        idx++;
-
-        if (!pix->IsValid())
-            continue;
-
-        *fLog << idx << ": ";
-	pix->Print();
-    }
-}
-
-Bool_t MExtractedSignalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
-{
-    switch (type)
-    {
-    case 0:
-        val = (*this)[idx].GetExtractedSignalHiGain();
-        break;
-    case 1:
-        val = (*this)[idx].GetExtractedSignalHiGainError();
-        break;
-    case 2:
-        val = (*this)[idx].GetExtractedSignalLoGain();
-        break;
-    case 3:
-        val = (*this)[idx].GetExtractedSignalLoGainError();
-        break;
-    default:
-	return kFALSE;
-    }
-    return val>=0;
-}
-
-void MExtractedSignalCam::DrawPixelContent(Int_t num) const
-{
-    *fLog << warn << "MExtractedSignaCam::DrawPixelContent - not available." << endl;
-}
Index: trunk/MagicSoft/Mars/manalysis/MExtractedSignalCam.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractedSignalCam.h	(revision 3305)
+++ 	(revision )
@@ -1,67 +1,0 @@
-#ifndef MARS_MExtractedSignalCam
-#define MARS_MExtractedSignalCam
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-#ifndef MARS_MCamEvent
-#include "MCamEvent.h"
-#endif
-
-class TClonesArray;
-class MExtractedSignalPix;
-
-class MExtractedSignalCam : public MParContainer, public MCamEvent
-{
-private:
-    TClonesArray *fArray; //-> FIXME: Change TClonesArray away from a pointer?
-
-    Byte_t fFirstUsedSliceHiGain;
-    Byte_t fFirstUsedSliceLoGain;
-
-    Byte_t fLastUsedSliceHiGain;
-    Byte_t fLastUsedSliceLoGain;
-
-public:
-
-    MExtractedSignalCam(const char *name=NULL, const char *title=NULL);
-    ~MExtractedSignalCam();
-
-    void Print(Option_t *o="") const;
-    void Clear(Option_t *o="");
-    void SetLogStream(MLog *lg);
-
-    void InitSize(const UInt_t i);
-    Int_t GetSize() const;
-
-    Byte_t GetNumUsedFADCSlices() const       { return fLastUsedSliceHiGain-fFirstUsedSliceHiGain+1; }
-    Byte_t GetNumUsedHiGainFADCSlices() const { return fLastUsedSliceHiGain-fFirstUsedSliceHiGain+1; }
-    Byte_t GetNumUsedLoGainFADCSlices() const { return fLastUsedSliceLoGain-fFirstUsedSliceLoGain+1; }
-
-    Byte_t GetFirstUsedSliceHiGain() const    { return fFirstUsedSliceHiGain; }
-    Byte_t GetLastUsedSliceHiGain() const     { return fLastUsedSliceHiGain; }
-
-    Byte_t GetFirstUsedSliceLoGain() const    { return fFirstUsedSliceLoGain; }
-    Byte_t GetLastUsedSliceLoGain() const     { return fLastUsedSliceLoGain; }
-
-    void   SetUsedFADCSlices(Byte_t firsth, Byte_t lasth, 
-                             Byte_t firstl, Byte_t lastl)
-    {
-      fFirstUsedSliceHiGain    = firsth;
-      fLastUsedSliceHiGain     = lasth;
-      fFirstUsedSliceLoGain    = firstl;
-      fLastUsedSliceLoGain     = lastl;
-    }
-
-    MExtractedSignalPix &operator[](Int_t i);
-    const MExtractedSignalPix &operator[](Int_t i) const;
-
-    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
-    void DrawPixelContent(Int_t num) const;
-
-    ClassDef(MExtractedSignalCam, 0)	// Storage Container for extracted signals in the camera
-};
-
-#endif
-
Index: trunk/MagicSoft/Mars/manalysis/MExtractedSignalPix.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractedSignalPix.cc	(revision 3305)
+++ 	(revision )
@@ -1,120 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Markus Gaug  12/2003 <mailto:markus@ifae.es>
-!   Author(s): Thomas Bretz 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// MExtractedSignalPix
-//
-// This is the storage container to hold informations about the pedestal
-// (offset) value of one Pixel (PMT).
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MExtractedSignalPix.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-ClassImp(MExtractedSignalPix);
-
-using namespace std;
-
-static const Float_t gkSignalInitializer = 99999.9;
-
-// ------------------------------------------------------------------------
-//
-// MExtractedSignalPix holds the extracted signal (HiGain and LoGain) 
-// of the FADC slices and its error. 
-//
-// Additionally, the number of saturated HiGain and LoGain Slices are stored. 
-// 
-// Default values for the extracted signals are: 99999.9 
-//
-MExtractedSignalPix::MExtractedSignalPix(const char* name, const char* title)
-  : fExtractedSignalHiGain(gkSignalInitializer),
-    fExtractedSignalHiGainError(gkSignalInitializer),
-    fExtractedSignalLoGain(gkSignalInitializer),
-    fExtractedSignalLoGainError(gkSignalInitializer),
-    fLoGainUsed(kFALSE),
-    fNumHiGainSaturated(0),
-    fNumLoGainSaturated(0)
-{
-  fName  = name  ? name  : "MExtractedSignalPix";
-  fTitle = title ? title : "Container of the Extracted Signals";
-}
-
-// ------------------------------------------------------------------------
-//
-// Invalidate values
-//
-void MExtractedSignalPix::Clear(Option_t *o)
-{
-  fExtractedSignalHiGain      = gkSignalInitializer;
-  fExtractedSignalHiGainError = gkSignalInitializer;
-  fExtractedSignalLoGain      = gkSignalInitializer;
-  fExtractedSignalLoGainError = gkSignalInitializer;
-  
-  fLoGainUsed = kFALSE;
-
-  fNumHiGainSaturated = 0;
-  fNumLoGainSaturated = 0;
-}
-
-void MExtractedSignalPix::SetExtractedSignal(Float_t sig, Float_t sigerr)   
-{
-  fExtractedSignalHiGain      = sig; 
-  fExtractedSignalHiGainError = sigerr;
-}
-
-void MExtractedSignalPix::SetExtractedSignal(Float_t sighi, Float_t sighierr,
-                                             Float_t siglo, Float_t sigloerr)   
-{
-  fExtractedSignalHiGain = sighi;
-  fExtractedSignalHiGainError = sighierr;
-  fExtractedSignalLoGain = siglo;
-  fExtractedSignalLoGainError = sigloerr;
-}
-
-Bool_t MExtractedSignalPix::IsValid() const
-{
-    return fExtractedSignalHiGain >= 0. || fExtractedSignalHiGainError >= 0.;
-}
-
-void MExtractedSignalPix::SetGainSaturation(Bool_t sat, Byte_t higain, Byte_t logain) 
-{
-
-  fLoGainUsed = sat; 
-  fNumHiGainSaturated = higain; 
-  fNumLoGainSaturated = logain;
-}
-
-void MExtractedSignalPix::Print(Option_t *o) const
-{
-    *fLog << " Signal: " << fExtractedSignalHiGain
-        << " +- " << fExtractedSignalHiGainError
-        << " LoGain? " << fLoGainUsed
-        << " Nr. Sat. Hi Gain: " <<  fNumHiGainSaturated
-        << " Nr. Sat. Lo Gain: " <<  fNumLoGainSaturated
-        << endl;
-}
Index: trunk/MagicSoft/Mars/manalysis/MExtractedSignalPix.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractedSignalPix.h	(revision 3305)
+++ 	(revision )
@@ -1,47 +1,0 @@
-#ifndef MARS_MExtractedSignalPix
-#define MARS_MExtractedSignalPix
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-class MExtractedSignalPix : public MParContainer
-{
-private:
-  Float_t fExtractedSignalHiGain;      // mean value of the extracted signal
-  Float_t fExtractedSignalHiGainError; // error of the mean value of the extracted signal
-  Float_t fExtractedSignalLoGain;      // mean value of the extracted signal
-  Float_t fExtractedSignalLoGainError; // error of the mean value of the extracted signal
-
-  Bool_t fLoGainUsed;
-  Byte_t fNumHiGainSaturated;
-  Byte_t fNumLoGainSaturated;
-
-public:
-    MExtractedSignalPix(const char* name=NULL, const char* title=NULL);
-
-    void Clear(Option_t *o="");
-    void Print(Option_t *o="") const;
-
-    // Setter
-    void SetExtractedSignal(Float_t sig, Float_t sigerr);
-    void SetExtractedSignal(Float_t sighi, Float_t sighierr,Float_t siglo, Float_t sigloerr);
-    void SetGainSaturation(Bool_t sat, Byte_t higain, Byte_t logain);
-
-    // Getter
-    Float_t GetExtractedSignalHiGain()      const { return fExtractedSignalHiGain; }
-    Float_t GetExtractedSignalHiGainError() const { return fExtractedSignalHiGainError; }
-
-    Float_t GetExtractedSignalLoGain()      const { return fExtractedSignalLoGain; }
-    Float_t GetExtractedSignalLoGainError() const { return fExtractedSignalLoGainError; }
-
-    Byte_t GetNumHiGainSaturated()          const { return fNumHiGainSaturated; }
-    Byte_t GetNumLoGainSaturated()          const { return fNumLoGainSaturated; }
-
-    Bool_t IsLoGainUsed() const { return fLoGainUsed; }
-    Bool_t IsValid() const;   
-
-    ClassDef(MExtractedSignalPix, 0)	// Storage Container for Extracted Signal information of one pixel
-};
-
-#endif
Index: trunk/MagicSoft/Mars/manalysis/Makefile
===================================================================
--- trunk/MagicSoft/Mars/manalysis/Makefile	(revision 3305)
+++ trunk/MagicSoft/Mars/manalysis/Makefile	(revision 3306)
@@ -81,11 +81,4 @@
            MPad.cc  \
            MPedestalWorkaround.cc \
-           MExtractedSignalCam.cc \
-           MExtractedSignalPix.cc \
-           MExtractSignal.cc \
-           MExtractSignal2.cc \
-           MArrivalTime.cc \
-           MArrivalTimeCalc.cc \
-           MArrivalTimeCalc2.cc \
            MSourcePosfromStarPos.cc \
            MMcCalibrationUpdate.cc
Index: trunk/MagicSoft/Mars/mcalib/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mcalib/Makefile	(revision 3305)
+++ trunk/MagicSoft/Mars/mcalib/Makefile	(revision 3306)
@@ -23,5 +23,5 @@
 #
 INCLUDES = -I. -I../mbase -I../mhbase -I../mgui -I../mgeom -I../manalysis \
-	   -I../mraw -I../mtools -I../mmc -I../mimage
+	   -I../mraw -I../mtools -I../mmc -I../mimage -I../msignal
 
 # mhbase:    MBinning MH 
Index: trunk/MagicSoft/Mars/mfilter/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mfilter/Makefile	(revision 3305)
+++ trunk/MagicSoft/Mars/mfilter/Makefile	(revision 3306)
@@ -22,5 +22,5 @@
 INCLUDES = -I. -I../mbase -I../mraw -I../mmc -I../mdata -I../manalysis \
            -I../mfileio  -I../mgeom -I../mimage -I../mhbase -I../mmain \
-           -I../mgui
+           -I../mgui -I../msignal
 
 # @code 
Index: trunk/MagicSoft/Mars/mjobs/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mjobs/Makefile	(revision 3305)
+++ trunk/MagicSoft/Mars/mjobs/Makefile	(revision 3306)
@@ -24,5 +24,5 @@
 INCLUDES = -I. -I../mbase -I../mgui -I../mgeom -I../mdata -I../mhbase \
 	   -I../mfileio -I../mfilter -I../manalysis -I../mhist -I../mcalib \
-           -I../mbadpixels
+           -I../mbadpixels -I../msignal
 
 #manalysis: MChisqEval (MParameters)
Index: trunk/MagicSoft/Mars/mmain/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mmain/Makefile	(revision 3305)
+++ trunk/MagicSoft/Mars/mmain/Makefile	(revision 3306)
@@ -25,5 +25,5 @@
 	   -I../mgui -I../mgeom -I../mhbase -I../mhist -I../mmontecarlo   \
            -I../mfileio -I../mimage -I../mhistmc -I../mgbase -I../mfilter \
-           -I../mdata
+           -I../mdata -I../msignal
 
 #------------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/msignal/MArrivalTime.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MArrivalTime.cc	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MArrivalTime.cc	(revision 3306)
@@ -0,0 +1,104 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Sebastian Raducci, 12/2003 <mailto:raducci@fisica.uniud.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MArrivalTime
+//
+// Times are calculated using the TSpline5 Root Class
+// 
+/////////////////////////////////////////////////////////////////////////////
+#include "MArrivalTime.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawEvtPixelIter.h"
+#include "MRawEvtData.h"
+
+ClassImp(MArrivalTime);
+
+using namespace std;
+
+
+// --------------------------------------------------------------------------
+//
+// Creates an object containing the arrival time for each pixel in the event
+//
+MArrivalTime::MArrivalTime(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MArrivalTime";
+    fTitle = title ? title : "Photons arrival times Information";
+}
+
+// -------------------------------------------------------------------------
+//
+// Sets every pixel arrival time to -1
+//
+void MArrivalTime::Reset()
+{
+    fData.Reset(-1);
+}
+
+void MArrivalTime::InitSize(Int_t i)
+{
+    fData.Set(i);
+}
+
+// -------------------------------------------------------------------------
+// 
+// Set the arrival time in one pixel
+//
+void MArrivalTime::SetTime(const Int_t i, const Float_t t)
+{
+    fData[i] = t;
+}
+      
+// --------------------------------------------------------------------------
+//
+// Returns the arrival time value
+//
+Bool_t MArrivalTime::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+    if (idx<0 || idx>=fData.GetSize())
+        return kFALSE;
+
+    switch (type)
+    {
+    case 0:
+    case 1:
+        val = fData[idx];
+        break;
+    }
+
+    return kTRUE;
+}
+
+void MArrivalTime::DrawPixelContent(Int_t num) const
+{
+    *fLog << warn << "MArrivalTime::DrawPixelContent - not available." << endl;
+}
Index: trunk/MagicSoft/Mars/msignal/MArrivalTime.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MArrivalTime.h	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MArrivalTime.h	(revision 3306)
@@ -0,0 +1,47 @@
+#ifndef MARS_MArrivalTime
+#define MARS_MArrivalTime
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class MRawEvtData;
+
+class MArrivalTime : public MParContainer, public MCamEvent
+{
+ private:
+    TArrayF fData;  // Stores the arrival times
+
+public:
+
+    MArrivalTime(const char *name=NULL, const char *title=NULL);
+    ~MArrivalTime() { }
+
+    void   Reset();
+    void   InitSize(Int_t i);
+
+    UInt_t GetSize() const { return fData.GetSize(); }
+
+    void SetTime(const Int_t i, const Float_t time);
+    
+    const TArrayF &GetData() const { return fData; }
+
+    Double_t operator[](int i) { return fData[i]; }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void DrawPixelContent(Int_t num) const;
+
+    ClassDef(MArrivalTime, 0)    // class for an event containing the arrival times
+};
+
+#endif
Index: trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc.cc	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc.cc	(revision 3306)
@@ -0,0 +1,187 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Sebastian Raducci 12/2003 <mailto:raducci@fisica.uniud.it>
+!
+!   Copyright: MAGIC Software Development, 2002-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MArrivalTimeCalc
+//
+//   This is a task that calculates the arrival times of photons. 
+//   It returns the absolute maximum of the spline that interpolates
+//   the FADC slices 
+//
+// Input Containers:
+//   MRawEvtData
+//
+// Output Containers:
+//   MArrivalTime
+//   MRawEvtData
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MArrivalTimeCalc.h"
+
+#include "MCubicSpline.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MArrivalTime.h"
+#include "MRawEvtData.h"      
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MArrivalTimeCalc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+// 
+MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title) 
+{
+
+    fName  = name  ? name  : "MArrivalTimeCalc";
+    fTitle = title ? title : "Calculate photons arrival time";
+
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MArrivalTime
+//
+// The following output containers are also searched and created if
+// they were not found:
+//  - MArrivalTime
+//
+
+Int_t MArrivalTimeCalc::PreProcess(MParList *pList)
+{
+
+
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+    {
+        *fLog << err << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fArrTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
+    if (!fArrTime)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The ReInit searches for the following input containers:
+//  - MGeomCam
+//
+Bool_t MArrivalTimeCalc::ReInit(MParList *pList)
+{
+    MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!cam)
+    {
+        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Evaluation of the mean arrival times (spline interpolation)
+// per pixel and store them in the MArrivalTime container.
+//
+Int_t MArrivalTimeCalc::Process()
+{
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  
+  while (pixel.Next())
+    {
+      
+      const UInt_t idx = pixel.GetPixelId();
+      Float_t time = 0.;
+
+
+      //
+      // If pixel is saturated we use LoGains
+      //
+      if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
+        {
+          
+          const Short_t nslices = fRawEvt->GetNumLoGainSamples();
+          time = Calc(pixel.GetLoGainSamples(),nslices);
+        }
+      
+
+      //
+      // Use HiGains
+      //
+      else if (pixel.HasLoGain())
+        {
+          
+          const Short_t nslices = fRawEvt->GetNumHiGainSamples();
+          time = Calc(pixel.GetHiGainSamples(),nslices);
+        }
+      
+      //
+      // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
+      //
+      fArrTime->SetTime(idx,time);
+      
+    }
+    
+  fArrTime->SetReadyToSave();
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates the arrival time for each pixel 
+// Possible Methods 
+// Case 1: MCubicSpline (3rd order spline)
+//
+Float_t MArrivalTimeCalc::Calc(const Byte_t *fadcSamples, const Short_t nslices)
+{
+
+  //
+  // Initialize the spline
+  //
+    MCubicSpline *spline = new MCubicSpline(fadcSamples);  
+
+  //
+  // Now find the maximum  
+  //
+   return (Float_t)spline->EvalAbMax();
+}
+
Index: trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc.h	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc.h	(revision 3306)
@@ -0,0 +1,34 @@
+#ifndef MARS_MArrivalTimeCalc
+#define MARS_MArrivalTimeCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+class MArrivalTime;
+
+class MArrivalTimeCalc : public MTask
+{
+
+    MRawEvtData    *fRawEvt;     // raw event data (time slices)
+    MRawRunHeader  *fRunHeader;  // RunHeader information
+
+    MArrivalTime   *fArrTime;    // Container with the photons arrival times
+
+    Int_t PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess() {return kTRUE;}
+
+    Float_t Calc(const Byte_t *fadcSamples, const Short_t nslices);
+ 
+public:
+    MArrivalTimeCalc(const char *name=NULL, const char *title=NULL);
+    ~MArrivalTimeCalc(){}
+ 
+    ClassDef(MArrivalTimeCalc, 0)   // Task to calculate Arrival Times from raw data
+};
+
+#endif
Index: trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc2.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc2.cc	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc2.cc	(revision 3306)
@@ -0,0 +1,259 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Hendrik Bartko, 02/2004 <mailto:hbartko@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MArrivalTimeCalc2
+//
+//  Calculates the arrival time as the mean time of the fWindowSize time slices
+//  which have the highest integral content.
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MArrivalTimeCalc2.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimePix.h"
+
+
+ClassImp(MArrivalTimeCalc2);
+
+using namespace std;
+
+const Byte_t MArrivalTimeCalc2::fgSaturationLimit = 254;
+const Byte_t MArrivalTimeCalc2::fgFirst  =  0;
+const Byte_t MArrivalTimeCalc2::fgLast   = 14;
+const Byte_t MArrivalTimeCalc2::fgWindowSize = 6;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MArrivalTimeCalc2::MArrivalTimeCalc2(const char *name, const char *title)
+  : fSaturationLimit(fgSaturationLimit)
+{
+
+    fName  = name  ? name  : "MArrivalTimeCalc2";
+    fTitle = title ? title : "Task to extract the signal from the FADC slices";
+
+    AddToBranchList("MRawEvtData.*");
+
+    SetRange();
+}
+
+void MArrivalTimeCalc2::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast, Byte_t windowsize)
+{
+    fNumHiGainSamples = hilast-hifirst+1;
+    fNumLoGainSamples = lolast-lofirst+1;
+
+    fHiGainFirst = hifirst;
+    fLoGainFirst = lofirst;
+
+    fWindowSize = windowsize & ~1;
+
+    if (fWindowSize != windowsize)
+      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size has to be even, set to: " << int(fWindowSize) << " samples " << endl;
+
+    if (fWindowSize<2) 
+    {
+      fWindowSize = 2;
+      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to two samples" << endl;
+    }
+
+    if (fWindowSize > fNumHiGainSamples)
+    {
+      fWindowSize = fNumLoGainSamples & ~1;
+      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
+    }
+
+    if (fWindowSize > fNumLoGainSamples)
+    {
+      fWindowSize = fNumLoGainSamples & ~1;
+      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
+    }
+
+    fWindowSizeSqrt = TMath::Sqrt((Float_t)fWindowSize);
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedSignalCam
+//
+Int_t MArrivalTimeCalc2::PreProcess(MParList *pList)
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+    {
+        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (!fPedestals)
+    {
+        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+        return kFALSE;
+    }
+
+    fArrivalTime = (MArrivalTimeCam*)pList->FindCreateObj(AddSerialNumber("MArrivalTimeCam"));
+    if (!fArrivalTime)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+void MArrivalTimeCalc2::FindSignalTime(Byte_t *ptr, Byte_t size, Float_t &time, Float_t &deltatime, Int_t &sat, Float_t pedes, Float_t pedrms) const
+{
+    const Byte_t *end = ptr + size;
+
+    Int_t sum=0;    // integral content of the actual window
+    Int_t max = 0;  // highest integral content of all windows
+
+    //
+    // Calculate the sum of the first fWindowSize slices
+    //
+    sat = 0;
+    Byte_t *p = ptr;
+
+    while (p<ptr+fWindowSize)
+    {
+        sum += *p;
+        if (*p++ >= fSaturationLimit)
+            sat++;
+    }
+
+    //
+    // Check for saturation in all other slices
+    //
+    while (p<end)
+        if (*p++ >= fSaturationLimit)
+            sat++;
+
+    //
+    // Calculate the i-th sum as
+    //    sum_i+1 = sum_i + slice[i+8] - slice[i]
+    // This is fast and accurate (because we are using int's)
+    //
+    max=sum;
+    Byte_t *ptrmax=ptr;  // pointer to the first slice of the maximum window
+
+    for (p=ptr; p+fWindowSize<end; p++)
+    {
+        sum += *(p+fWindowSize) - *p;
+		
+	if (sum>max)
+	{
+	  max = sum;
+	  ptrmax = p;
+	}
+    }
+
+    // now calculate the time for the maximum window
+    Int_t timesignalsum = 0;
+    Int_t timesquaredsum =0;
+    Int_t timesum =0;
+
+    for (p=ptrmax; p < ptrmax + fWindowSize; p++)
+    {
+        timesignalsum += *p*(p-ptr);
+        timesum += p-ptr;
+        timesquaredsum  += (p-ptr)*(p-ptr);
+    }
+
+    const Float_t pedsubsum = max - fWindowSize*pedes;
+    const Float_t pedsubtimesignalsum = timesignalsum - timesum*pedes;
+
+    time      = pedsubsum != 0 ? pedsubtimesignalsum / pedsubsum : 1;
+    deltatime = pedsubsum != 0 ? pedrms / pedsubsum * sqrt(timesquaredsum - fWindowSize*time) : 1;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculates the arrival time as the mean time of the fWindowSize time slices
+//  which have the highest integral content.
+//
+Int_t MArrivalTimeCalc2::Process()
+{
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    Int_t sat=0;
+    while (pixel.Next())
+    {
+        //
+        // Find signal in hi- and lo-gain
+        //
+        Float_t timehi, timelo, deltatimehi, deltatimelo;
+        Int_t sathi, satlo;
+
+	//
+        // Take correspodning pedestal
+        //
+        const Int_t pixid = pixel.GetPixelId();
+
+	const MPedestalPix  &ped = (*fPedestals)[pixid];
+
+	MArrivalTimePix &pix = (*fArrivalTime)[pixid];
+
+	const Float_t pedes  = ped.GetPedestal();
+	const Float_t pedrms = ped.GetPedestalRms();
+
+	FindSignalTime(pixel.GetHiGainSamples()+fHiGainFirst, fNumHiGainSamples, timehi, deltatimehi, sathi, pedes, pedrms);
+        FindSignalTime(pixel.GetLoGainSamples()+fLoGainFirst, fNumLoGainSamples, timelo, deltatimelo, satlo, pedes, pedrms);
+
+        if (satlo)
+            sat++;
+
+        pix.SetArrivalTime(timehi, deltatimehi, timelo, deltatimelo);
+	pix.SetGainSaturation(sathi, sathi, satlo);
+    }
+
+    fArrivalTime->SetReadyToSave();
+
+    //
+    // Print a warning if event has saturationg lo-gains
+    //
+    if (sat)
+        *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels." << endl;
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc2.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc2.h	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc2.h	(revision 3306)
@@ -0,0 +1,58 @@
+#ifndef MARS_MArrivalTimeCalc2
+#define MARS_MArrivalTimeCalc2
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+
+class MPedestalCam;
+class MArrivalTimeCam;
+
+class MArrivalTimeCalc2 : public MTask
+{
+private:
+    static const Byte_t fgSaturationLimit;
+    static const Byte_t fgFirst;
+    static const Byte_t fgLast;
+    static const Byte_t fgWindowSize;
+
+    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
+
+    MRawEvtData         *fRawEvt;       // raw event data (time slices)
+    MRawRunHeader       *fRunHeader;    // RunHeader information
+
+    
+    MArrivalTimeCam        *fArrivalTime;  // Arrival Time of FADC sample
+     
+  
+    Byte_t  fHiGainFirst;       // First hi gain to be used
+    Byte_t  fLoGainFirst;       // First lo gain to be used
+
+    Byte_t  fNumHiGainSamples;  // Number of hi gain to be used
+    Byte_t  fNumLoGainSamples;  // Number of lo gain to be used
+
+    Byte_t  fWindowSize;            // Number of gains in window
+    Float_t fWindowSizeSqrt;        // Sqaure root of number of gains in window
+
+    Byte_t  fSaturationLimit;
+
+    void   FindSignalTime(Byte_t *ptr, Byte_t size, Float_t &time,  Float_t &deltatime, Int_t &sat, Float_t pedes, Float_t pedrms) const;
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+
+public:
+    MArrivalTimeCalc2(const char *name=NULL, const char *title=NULL);
+
+    void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast, Byte_t lofirst=fgFirst, Byte_t lolast=fgLast, Byte_t windowsize=fgWindowSize);
+    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
+
+    ClassDef(MArrivalTimeCalc2, 0) // Calculates the arrival time as the mean time of the fWindowSize time slices
+};
+
+#endif
+
+
Index: trunk/MagicSoft/Mars/msignal/MExtractSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractSignal.cc	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MExtractSignal.cc	(revision 3306)
@@ -0,0 +1,233 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Markus Gaug, 09/2003 <mailto:markus@ifae.es>
+!              Thomas Bretz, 01/2004 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractSignal
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractSignal.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+ClassImp(MExtractSignal);
+
+using namespace std;
+
+const Byte_t MExtractSignal::fgSaturationLimit = 254;
+const Byte_t MExtractSignal::fgFirst =  3;
+const Byte_t MExtractSignal::fgLast  = 10;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MExtractSignal::MExtractSignal(const char *name, const char *title)
+    : fSaturationLimit(fgSaturationLimit)
+{
+
+    fName  = name  ? name  : "MExtractSignal";
+    fTitle = title ? title : "Task to extract the signal from the FADC slices";
+
+    AddToBranchList("MRawEvtData.*");
+
+    SetRange();
+}
+
+void MExtractSignal::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+    fNumHiGainSamples = hilast-hifirst+1;
+    fNumLoGainSamples = lolast-lofirst+1;
+
+    fHiGainFirst = hifirst;
+    fLoGainFirst = lofirst;
+
+    fSqrtHiGainSamples = TMath::Sqrt((Float_t)fNumHiGainSamples);
+    fSqrtLoGainSamples = TMath::Sqrt((Float_t)fNumLoGainSamples);
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedSignalCam
+//
+Int_t MExtractSignal::PreProcess(MParList *pList)
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+    {
+        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
+    if (!fSignals)
+        return kFALSE;
+
+    fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainFirst+fNumHiGainSamples-1,
+                                fLoGainFirst, fLoGainFirst+fNumLoGainSamples-1);
+
+    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+
+    if (!fPedestals)
+    {
+        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+void MExtractSignal::FindSignal(Byte_t *ptr, Int_t size, Int_t &sum, Byte_t &sat) const
+{
+
+  Byte_t *end = ptr + size;
+  
+  sum = 0;
+  sat = 0;
+  
+  while (ptr<end)
+    {
+      sum += *ptr;
+      
+      if (*ptr++ >= fSaturationLimit)
+        sat++;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MExtractedSignalCam container.
+//
+Int_t MExtractSignal::Process()
+{
+
+    MRawEvtPixelIter pixel(fRawEvt);
+    fSignals->Clear();
+
+    UInt_t  sat=0;
+    TString satpixels;
+
+    while (pixel.Next())
+    {
+        Int_t sumhi, sumlo;
+        Byte_t sathi, satlo;
+
+        FindSignal(pixel.GetHiGainSamples()+fHiGainFirst-1, fNumHiGainSamples, sumhi, sathi);
+        FindSignal(pixel.GetLoGainSamples()+fLoGainFirst-1, fNumLoGainSamples, sumlo, satlo);
+
+        if (satlo)
+        {
+            sat++;
+            satpixels += Form(" %d", pixel.GetPixelId());
+        }
+        
+
+        const Int_t pixid = pixel.GetPixelId();
+
+        const MPedestalPix  &ped = (*fPedestals)[pixid]; 
+	MExtractedSignalPix &pix = (*fSignals)[pixid];
+
+        const Float_t pedes  = ped.GetPedestal();
+        const Float_t pedrms = ped.GetPedestalRms();
+
+        
+	pix.SetExtractedSignal(sumhi - pedes*fNumHiGainSamples, pedrms*fSqrtHiGainSamples,
+                               sumlo - pedes*fNumLoGainSamples, pedrms*fSqrtLoGainSamples);
+
+	pix.SetGainSaturation(sathi, sathi, satlo);
+
+    } /* while (pixel.Next()) */
+
+    if (sat)
+        *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels with Index:" << satpixels << endl;
+
+    fSignals->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MExtractSignal::StreamPrimitive(ofstream &out) const
+{
+    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
+    out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
+
+    if (fSaturationLimit!=fgSaturationLimit)
+    {
+        out << "   " << GetUniqueName() << ".SetSaturationLimit(";
+        out << (int)fSaturationLimit << ");" << endl;
+    }
+
+    const Bool_t arg4 = fNumLoGainSamples+fLoGainFirst-1 != fgLast;
+    const Bool_t arg3 = arg4 || fLoGainFirst != fgFirst;
+    const Bool_t arg2 = arg3 || fNumHiGainSamples+fHiGainFirst-1 != fgLast;
+    const Bool_t arg1 = arg2 || fHiGainFirst != fgFirst;
+
+    if (!arg1)
+        return;
+
+    out << "   " << GetUniqueName() << ".SetRange(";
+    out << (int)fLoGainFirst;
+    if (arg2)
+    {
+        out << ", " << (int)(fNumHiGainSamples+fHiGainFirst-1);
+        if (arg3)
+        {
+            out << ", " << (int)fLoGainFirst;
+            if (arg4)
+                out << ", " << (int)(fNumLoGainSamples+fLoGainFirst-1);
+        }
+    }
+    out << ");" << endl;
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractSignal.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractSignal.h	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MExtractSignal.h	(revision 3306)
@@ -0,0 +1,62 @@
+#ifndef MARS_MExtractSignal
+#define MARS_MExtractSignal
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MExtractSignal                                                          //
+//                                                                         //
+// Integrates the time slices of the all pixels of a calibration event     //
+// and substract the pedestal value                                        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+
+class MPedestalCam;
+class MExtractedSignalCam;
+
+class MExtractSignal : public MTask
+{
+private:
+    static const Byte_t fgSaturationLimit;
+    static const Byte_t fgFirst;
+    static const Byte_t fgLast;
+
+    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
+    MExtractedSignalCam *fSignals;      // Extracted signal of all pixels in the camera
+
+    MRawEvtData         *fRawEvt;       // raw event data (time slices)
+    MRawRunHeader       *fRunHeader;    // RunHeader information
+
+    Byte_t  fHiGainFirst;
+    Byte_t  fLoGainFirst;
+
+    Byte_t  fNumHiGainSamples;
+    Byte_t  fNumLoGainSamples;
+
+    Float_t fSqrtHiGainSamples;
+    Float_t fSqrtLoGainSamples;
+
+    Byte_t  fSaturationLimit;
+
+    void   FindSignal(Byte_t *ptr, Int_t size, Int_t &sum, Byte_t &sat) const;
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+    void   StreamPrimitive(ofstream &out) const;
+
+public:
+    MExtractSignal(const char *name=NULL, const char *title=NULL);
+
+    void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast, Byte_t lofirst=fgFirst, Byte_t lolast=fgLast);
+    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
+
+    ClassDef(MExtractSignal, 0) // Task to fill the Extracted Signal Containers from raw data
+};
+
+#endif
Index: trunk/MagicSoft/Mars/msignal/MExtractSignal2.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractSignal2.cc	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MExtractSignal2.cc	(revision 3306)
@@ -0,0 +1,250 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Hendrik Bartko, 01/2004 <mailto:hbartko@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractSignal2
+//
+//  Calculate the signal as the fWindowSize time slices which have the highest
+// integral contents.
+//
+// 
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractSignal2.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+//#include "MArrivalTime.h"
+
+ClassImp(MExtractSignal2);
+
+using namespace std;
+
+const Byte_t MExtractSignal2::fgSaturationLimit = 254;
+const Byte_t MExtractSignal2::fgFirst  =  0;
+const Byte_t MExtractSignal2::fgLast   = 14;
+const Byte_t MExtractSignal2::fgWindowSize = 6;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MExtractSignal2::MExtractSignal2(const char *name, const char *title)
+  : fSaturationLimit(fgSaturationLimit)
+{
+
+    fName  = name  ? name  : "MExtractSignal2";
+    fTitle = title ? title : "Task to extract the signal from the FADC slices";
+
+    AddToBranchList("MRawEvtData.*");
+
+    SetRange();
+}
+
+void MExtractSignal2::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast, Byte_t windowsize)
+{
+
+    fNumHiGainSamples = hilast-hifirst+1;
+    fNumLoGainSamples = lolast-lofirst+1;
+
+    fHiGainFirst = hifirst;
+    fLoGainFirst = lofirst;
+
+   
+    fWindowSize = windowsize & ~1;
+
+    if (fWindowSize != windowsize)
+      *fLog << warn << "MExtractSignal2::SetRange - window size has to be even, set to: " << int(fWindowSize) << " samples " << endl;
+    
+    if (fWindowSize<2) 
+    {
+      fWindowSize = 2;
+      *fLog << warn << "MExtractSignal2::SetRange - window size set to two samples" << endl;
+    }
+
+    if (fWindowSize > fNumHiGainSamples)
+    {
+      fWindowSize = fNumLoGainSamples & ~1;
+      *fLog << warn << "MExtractSignal2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
+    }
+    
+    if (fWindowSize > fNumLoGainSamples)
+    {
+      fWindowSize = fNumLoGainSamples & ~1;
+      *fLog << warn << "MExtractSignal2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
+    }
+
+    fWindowSizeSqrt = TMath::Sqrt((Float_t)fWindowSize);
+
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedSignalCam
+//
+Int_t MExtractSignal2::PreProcess(MParList *pList)
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+    {
+        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
+    if (!fSignals)
+        return kFALSE;
+
+    fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainFirst+fNumHiGainSamples-1,
+                                fLoGainFirst, fLoGainFirst+fNumLoGainSamples-1);
+
+    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (!fPedestals)
+    {
+        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+        return kFALSE;
+    }
+/*
+    fArrivalTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
+    if (!fArrivalTime)
+        return kFALSE;
+ */
+    return kTRUE;
+}
+
+void MExtractSignal2::FindSignal(Byte_t *ptr, Byte_t size, Int_t &max, Int_t &sat) const
+{
+    const Byte_t *end = ptr + size;
+
+    Int_t sum=0;
+
+    //
+    // Calculate the sum of the first fWindowSize slices
+    //
+    sat = 0;
+    Byte_t *p = ptr;
+    while (p<ptr+fWindowSize)
+    {
+        sum += *p;
+        if (*p++ >= fSaturationLimit)
+            sat++;
+    }
+
+    //
+    // Check for saturation in all other slices
+    //
+    while (p<end)
+        if (*p++ >= fSaturationLimit)
+            sat++;
+
+    //
+    // Calculate the i-th sum as
+    //    sum_i+1 = sum_i + slice[i+8] - slice[i]
+    // This is fast and accurate (because we are using int's)
+    //
+    max=sum;
+    for (p=ptr; p+fWindowSize<end; p++)
+    {
+        sum += *(p+fWindowSize) - *p;
+        if (sum>max)
+            max = sum;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC of fWindowSize time slices which have the
+// highest signal
+//
+Int_t MExtractSignal2::Process()
+{
+    MRawEvtPixelIter pixel(fRawEvt);
+    fSignals->Clear();
+
+    Int_t sat=0;
+    while (pixel.Next())
+    {
+        //
+        // Find signal in hi- and lo-gain
+        //
+        Int_t sumhi, sumlo, sathi, satlo;
+        FindSignal(pixel.GetHiGainSamples()+fHiGainFirst, fNumHiGainSamples, sumhi, sathi);
+        FindSignal(pixel.GetLoGainSamples()+fLoGainFirst, fNumLoGainSamples, sumlo, satlo);
+        if (satlo)
+            sat++;
+
+        //
+        // Take correspodning pedestal
+        //
+        const Int_t pixid = pixel.GetPixelId();
+
+        const MPedestalPix  &ped = (*fPedestals)[pixid];
+        MExtractedSignalPix &pix = (*fSignals)[pixid];
+
+        const Float_t pedes  = ped.GetPedestal();
+        const Float_t pedrms = ped.GetPedestalRms();
+
+        //
+        // Set extracted signal with pedestal substracted
+        //
+        pix.SetExtractedSignal(sumhi - pedes*fWindowSize, pedrms*fWindowSizeSqrt,
+                               sumlo - pedes*fWindowSize, pedrms*fWindowSizeSqrt);
+
+        pix.SetGainSaturation(sathi, sathi, satlo);
+    } /* while (pixel.Next()) */
+
+    //
+    // Print a warning if evant has saturationg lo-gains
+    //
+    if (sat)
+        *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels." << endl;
+
+    fSignals->SetReadyToSave();
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractSignal2.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractSignal2.h	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MExtractSignal2.h	(revision 3306)
@@ -0,0 +1,58 @@
+#ifndef MARS_MExtractSignal2
+#define MARS_MExtractSignal2
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+
+class MPedestalCam;
+class MExtractedSignalCam;
+//class MArrivalTime;
+
+class MExtractSignal2 : public MTask
+{
+private:
+    static const Byte_t fgSaturationLimit;
+    static const Byte_t fgFirst;
+    static const Byte_t fgLast;
+    static const Byte_t fgWindowSize;
+
+    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
+    MExtractedSignalCam *fSignals;      // Extracted signal of all pixels in the camera
+
+    MRawEvtData         *fRawEvt;       // raw event data (time slices)
+    MRawRunHeader       *fRunHeader;    // RunHeader information
+
+    /*
+     MArrivalTime        *fArrivalTime;  // Arrival Time of FADC sample
+     */
+  
+    Byte_t  fHiGainFirst;       // First hi gain to be used
+    Byte_t  fLoGainFirst;       // First lo gain to be used
+
+    Byte_t  fNumHiGainSamples;  // Number of hi gain to be used
+    Byte_t  fNumLoGainSamples;  // Number of lo gain to be used
+
+    Byte_t  fWindowSize;            // Number of gains in window
+    Float_t fWindowSizeSqrt;        // Sqaure root of number of gains in window
+
+    Byte_t  fSaturationLimit;
+
+    void   FindSignal(Byte_t *ptr, Byte_t size, Int_t &max, Int_t &sat) const;
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+
+public:
+    MExtractSignal2(const char *name=NULL, const char *title=NULL);
+
+    void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast, Byte_t lofirst=fgFirst, Byte_t lolast=fgLast, Byte_t window_size=fgWindowSize);
+    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
+
+    ClassDef(MExtractSignal2, 0) // Extracted Signal as highest integral content
+};
+
+#endif
Index: trunk/MagicSoft/Mars/msignal/MExtractedSignalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractedSignalCam.cc	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MExtractedSignalCam.cc	(revision 3306)
@@ -0,0 +1,162 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Markus Gaug  12/2003 <mailto:markus@ifae.es>
+!   Author(s): Thomas Bretz 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MExtractedSignalCam
+//
+// Hold the Extracted Signal information for all pixels in the camera
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MExtractedSignalCam.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MExtractedSignalPix.h"
+
+ClassImp(MExtractedSignalCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Creates a MExtractedSignalPix object for each pixel
+//
+MExtractedSignalCam::MExtractedSignalCam(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MExtractedSignalCam";
+    fTitle = title ? title : "Storage container for all Extracted Signal Information in the camera";
+
+    fArray = new TClonesArray("MExtractedSignalPix", 1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the array conatining the pixel pedest information
+//
+MExtractedSignalCam::~MExtractedSignalCam()
+{
+    delete fArray;
+}
+
+// --------------------------------------------------------------------------
+//
+// Distribute logging stream to all childs
+//
+void MExtractedSignalCam::SetLogStream(MLog *lg)
+{
+    fArray->ForEach(MParContainer, SetLogStream)(lg);
+    MParContainer::SetLogStream(lg);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the size of the camera
+//
+void MExtractedSignalCam::InitSize(const UInt_t i)
+{
+    fArray->ExpandCreate(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the size of the MExtractedSignalCam
+//
+Int_t MExtractedSignalCam::GetSize() const
+{
+    return fArray->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel index)
+//
+MExtractedSignalPix &MExtractedSignalCam::operator[](Int_t i)
+{
+    return *static_cast<MExtractedSignalPix*>(fArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel index)
+//
+const MExtractedSignalPix &MExtractedSignalCam::operator[](Int_t i) const
+{
+    return *static_cast<MExtractedSignalPix*>(fArray->UncheckedAt(i));
+}
+
+void MExtractedSignalCam::Clear(Option_t *o)
+{
+    fArray->ForEach(TObject, Clear)();
+}
+
+void MExtractedSignalCam::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << ":" << endl;
+    int idx = -1;
+
+    TIter Next(fArray);
+    MExtractedSignalPix *pix;
+    while ((pix=(MExtractedSignalPix*)Next()))
+    {
+        idx++;
+
+        if (!pix->IsValid())
+            continue;
+
+        *fLog << idx << ": ";
+	pix->Print();
+    }
+}
+
+Bool_t MExtractedSignalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+    switch (type)
+    {
+    case 0:
+        val = (*this)[idx].GetExtractedSignalHiGain();
+        break;
+    case 1:
+        val = (*this)[idx].GetExtractedSignalHiGainError();
+        break;
+    case 2:
+        val = (*this)[idx].GetExtractedSignalLoGain();
+        break;
+    case 3:
+        val = (*this)[idx].GetExtractedSignalLoGainError();
+        break;
+    default:
+	return kFALSE;
+    }
+    return val>=0;
+}
+
+void MExtractedSignalCam::DrawPixelContent(Int_t num) const
+{
+    *fLog << warn << "MExtractedSignaCam::DrawPixelContent - not available." << endl;
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractedSignalCam.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractedSignalCam.h	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MExtractedSignalCam.h	(revision 3306)
@@ -0,0 +1,67 @@
+#ifndef MARS_MExtractedSignalCam
+#define MARS_MExtractedSignalCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+class TClonesArray;
+class MExtractedSignalPix;
+
+class MExtractedSignalCam : public MParContainer, public MCamEvent
+{
+private:
+    TClonesArray *fArray; //-> FIXME: Change TClonesArray away from a pointer?
+
+    Byte_t fFirstUsedSliceHiGain;
+    Byte_t fFirstUsedSliceLoGain;
+
+    Byte_t fLastUsedSliceHiGain;
+    Byte_t fLastUsedSliceLoGain;
+
+public:
+
+    MExtractedSignalCam(const char *name=NULL, const char *title=NULL);
+    ~MExtractedSignalCam();
+
+    void Print(Option_t *o="") const;
+    void Clear(Option_t *o="");
+    void SetLogStream(MLog *lg);
+
+    void InitSize(const UInt_t i);
+    Int_t GetSize() const;
+
+    Byte_t GetNumUsedFADCSlices() const       { return fLastUsedSliceHiGain-fFirstUsedSliceHiGain+1; }
+    Byte_t GetNumUsedHiGainFADCSlices() const { return fLastUsedSliceHiGain-fFirstUsedSliceHiGain+1; }
+    Byte_t GetNumUsedLoGainFADCSlices() const { return fLastUsedSliceLoGain-fFirstUsedSliceLoGain+1; }
+
+    Byte_t GetFirstUsedSliceHiGain() const    { return fFirstUsedSliceHiGain; }
+    Byte_t GetLastUsedSliceHiGain() const     { return fLastUsedSliceHiGain; }
+
+    Byte_t GetFirstUsedSliceLoGain() const    { return fFirstUsedSliceLoGain; }
+    Byte_t GetLastUsedSliceLoGain() const     { return fLastUsedSliceLoGain; }
+
+    void   SetUsedFADCSlices(Byte_t firsth, Byte_t lasth, 
+                             Byte_t firstl, Byte_t lastl)
+    {
+      fFirstUsedSliceHiGain    = firsth;
+      fLastUsedSliceHiGain     = lasth;
+      fFirstUsedSliceLoGain    = firstl;
+      fLastUsedSliceLoGain     = lastl;
+    }
+
+    MExtractedSignalPix &operator[](Int_t i);
+    const MExtractedSignalPix &operator[](Int_t i) const;
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void DrawPixelContent(Int_t num) const;
+
+    ClassDef(MExtractedSignalCam, 0)	// Storage Container for extracted signals in the camera
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/msignal/MExtractedSignalPix.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractedSignalPix.cc	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MExtractedSignalPix.cc	(revision 3306)
@@ -0,0 +1,120 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Markus Gaug  12/2003 <mailto:markus@ifae.es>
+!   Author(s): Thomas Bretz 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MExtractedSignalPix
+//
+// This is the storage container to hold informations about the pedestal
+// (offset) value of one Pixel (PMT).
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MExtractedSignalPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MExtractedSignalPix);
+
+using namespace std;
+
+static const Float_t gkSignalInitializer = 99999.9;
+
+// ------------------------------------------------------------------------
+//
+// MExtractedSignalPix holds the extracted signal (HiGain and LoGain) 
+// of the FADC slices and its error. 
+//
+// Additionally, the number of saturated HiGain and LoGain Slices are stored. 
+// 
+// Default values for the extracted signals are: 99999.9 
+//
+MExtractedSignalPix::MExtractedSignalPix(const char* name, const char* title)
+  : fExtractedSignalHiGain(gkSignalInitializer),
+    fExtractedSignalHiGainError(gkSignalInitializer),
+    fExtractedSignalLoGain(gkSignalInitializer),
+    fExtractedSignalLoGainError(gkSignalInitializer),
+    fLoGainUsed(kFALSE),
+    fNumHiGainSaturated(0),
+    fNumLoGainSaturated(0)
+{
+  fName  = name  ? name  : "MExtractedSignalPix";
+  fTitle = title ? title : "Container of the Extracted Signals";
+}
+
+// ------------------------------------------------------------------------
+//
+// Invalidate values
+//
+void MExtractedSignalPix::Clear(Option_t *o)
+{
+  fExtractedSignalHiGain      = gkSignalInitializer;
+  fExtractedSignalHiGainError = gkSignalInitializer;
+  fExtractedSignalLoGain      = gkSignalInitializer;
+  fExtractedSignalLoGainError = gkSignalInitializer;
+  
+  fLoGainUsed = kFALSE;
+
+  fNumHiGainSaturated = 0;
+  fNumLoGainSaturated = 0;
+}
+
+void MExtractedSignalPix::SetExtractedSignal(Float_t sig, Float_t sigerr)   
+{
+  fExtractedSignalHiGain      = sig; 
+  fExtractedSignalHiGainError = sigerr;
+}
+
+void MExtractedSignalPix::SetExtractedSignal(Float_t sighi, Float_t sighierr,
+                                             Float_t siglo, Float_t sigloerr)   
+{
+  fExtractedSignalHiGain = sighi;
+  fExtractedSignalHiGainError = sighierr;
+  fExtractedSignalLoGain = siglo;
+  fExtractedSignalLoGainError = sigloerr;
+}
+
+Bool_t MExtractedSignalPix::IsValid() const
+{
+    return fExtractedSignalHiGain >= 0. || fExtractedSignalHiGainError >= 0.;
+}
+
+void MExtractedSignalPix::SetGainSaturation(Bool_t sat, Byte_t higain, Byte_t logain) 
+{
+
+  fLoGainUsed = sat; 
+  fNumHiGainSaturated = higain; 
+  fNumLoGainSaturated = logain;
+}
+
+void MExtractedSignalPix::Print(Option_t *o) const
+{
+    *fLog << " Signal: " << fExtractedSignalHiGain
+        << " +- " << fExtractedSignalHiGainError
+        << " LoGain? " << fLoGainUsed
+        << " Nr. Sat. Hi Gain: " <<  fNumHiGainSaturated
+        << " Nr. Sat. Lo Gain: " <<  fNumLoGainSaturated
+        << endl;
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractedSignalPix.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractedSignalPix.h	(revision 3306)
+++ trunk/MagicSoft/Mars/msignal/MExtractedSignalPix.h	(revision 3306)
@@ -0,0 +1,47 @@
+#ifndef MARS_MExtractedSignalPix
+#define MARS_MExtractedSignalPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MExtractedSignalPix : public MParContainer
+{
+private:
+  Float_t fExtractedSignalHiGain;      // mean value of the extracted signal
+  Float_t fExtractedSignalHiGainError; // error of the mean value of the extracted signal
+  Float_t fExtractedSignalLoGain;      // mean value of the extracted signal
+  Float_t fExtractedSignalLoGainError; // error of the mean value of the extracted signal
+
+  Bool_t fLoGainUsed;
+  Byte_t fNumHiGainSaturated;
+  Byte_t fNumLoGainSaturated;
+
+public:
+    MExtractedSignalPix(const char* name=NULL, const char* title=NULL);
+
+    void Clear(Option_t *o="");
+    void Print(Option_t *o="") const;
+
+    // Setter
+    void SetExtractedSignal(Float_t sig, Float_t sigerr);
+    void SetExtractedSignal(Float_t sighi, Float_t sighierr,Float_t siglo, Float_t sigloerr);
+    void SetGainSaturation(Bool_t sat, Byte_t higain, Byte_t logain);
+
+    // Getter
+    Float_t GetExtractedSignalHiGain()      const { return fExtractedSignalHiGain; }
+    Float_t GetExtractedSignalHiGainError() const { return fExtractedSignalHiGainError; }
+
+    Float_t GetExtractedSignalLoGain()      const { return fExtractedSignalLoGain; }
+    Float_t GetExtractedSignalLoGainError() const { return fExtractedSignalLoGainError; }
+
+    Byte_t GetNumHiGainSaturated()          const { return fNumHiGainSaturated; }
+    Byte_t GetNumLoGainSaturated()          const { return fNumLoGainSaturated; }
+
+    Bool_t IsLoGainUsed() const { return fLoGainUsed; }
+    Bool_t IsValid() const;   
+
+    ClassDef(MExtractedSignalPix, 0)	// Storage Container for Extracted Signal information of one pixel
+};
+
+#endif
Index: trunk/MagicSoft/Mars/msignal/Makefile
===================================================================
--- trunk/MagicSoft/Mars/msignal/Makefile	(revision 3305)
+++ trunk/MagicSoft/Mars/msignal/Makefile	(revision 3306)
@@ -33,5 +33,12 @@
 .SUFFIXES: .c .cc .cxx .h .hxx .o 
 
-SRCFILES = MArrivalTimeCam.cc \
+SRCFILES = MExtractedSignalCam.cc \
+           MExtractedSignalPix.cc \
+           MExtractSignal.cc \
+           MExtractSignal2.cc \
+           MArrivalTime.cc \
+           MArrivalTimeCalc.cc \
+           MArrivalTimeCalc2.cc \
+           MArrivalTimeCam.cc \
 	   MArrivalTimePix.cc
 
Index: trunk/MagicSoft/Mars/msignal/SignalLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/SignalLinkDef.h	(revision 3305)
+++ trunk/MagicSoft/Mars/msignal/SignalLinkDef.h	(revision 3306)
@@ -5,6 +5,16 @@
 #pragma link off all functions;
 
+#pragma link C++ class MExtractedSignalCam+;
+#pragma link C++ class MExtractedSignalPix+;
+#pragma link C++ class MExtractSignal+;
+#pragma link C++ class MExtractSignal2+;
+
 #pragma link C++ class MArrivalTimeCam;
 #pragma link C++ class MArrivalTimePix;
+#pragma link C++ class MArrivalTime+;
+#pragma link C++ class MArrivalTimeCalc+;
+#pragma link C++ class MArrivalTimeCalc2+;
+
+
 
 #endif
