Index: unk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 3803)
+++ 	(revision )
@@ -1,167 +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, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2003
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-//  MMcPedestalCopy
-//
-//  This task looks for the ìnformation about FADC pedestals in
-//  MMcFadcHeader and translates it to the pedestal values in
-//  MPedestalCam
-//
-//  Input Containers:
-//   MMcFadcHeader
-//   [MMcRunHeader]
-//   [MRawRunHeader]
-//
-//  Output Containers:
-//   MPedestalCam
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MMcPedestalCopy.h"
-
-#include "MParList.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MPedestalPix.h"
-#include "MPedestalCam.h"
-
-#include "MRawRunHeader.h"
-#include "MMcRunHeader.hxx"
-#include "MMcFadcHeader.hxx"
-
-ClassImp(MMcPedestalCopy);
-
-using namespace std;
-
-MMcPedestalCopy::MMcPedestalCopy(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MMcPedestalCopy";
-    fTitle = title ? title : "Copy MC pedestals into MPedestal Container";
-
-    //
-    // This is not needed here using MReadMarsFile because for the
-    // RunHeader tree the auto scheme is disabled by default
-    //
-    AddToBranchList("MMcFadcHeader.fPedesMean");
-    AddToBranchList("MMcFadcHeader.fElecNoise");
-}
-
-// --------------------------------------------------------------------------
-//
-// Check for the run type. Return kTRUE if it is a MC run or if there
-// is no MC run header (old camera files) kFALSE in case of a different
-// run type
-//
-Bool_t MMcPedestalCopy::CheckRunType(MParList *pList) const
-{
-    const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
-    if (!run)
-    {
-        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
-        return kTRUE;
-    }
-
-    return run->IsMonteCarloRun();
-}
-
-
-
-// --------------------------------------------------------------------------
-//
-// Make sure that there is a MPedestalCam object in the parameter list.
-//
-Int_t  MMcPedestalCopy::PreProcess(MParList *pList)
-{
-  if ( ! pList->FindObject(AddSerialNumber("MPedestalCam")) )
-    pList->FindCreateObj(AddSerialNumber("MPedestalCam"));
-
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Check for the runtype.
-// Search for MPedestalCam and MMcFadcHeader.
-//
-Bool_t MMcPedestalCopy::ReInit(MParList *pList)
-{
-    //
-    // If it is no MC file skip this function...
-    //
-    if (!CheckRunType(pList))
-      {
-	*fLog << inf << "This is no MC file... skipping." << endl;
-        return kTRUE;
-      }
-
-    //
-    // Now check the existance of all necessary containers. This has
-    // to be done only if this is a MC file.
-    //
-    MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
-    if (!fadc)
-    {
-        *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    MPedestalCam *pedcam = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
-    if (!pedcam)
-      {
-        *fLog << err << dbginf << "Cannot create " << AddSerialNumber("MPedestalCam") <<"... Exiting." << endl;
-
-        return kFALSE;
-      }
-
-    MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
-    if (!mcrun)
-        *fLog << warn << dbginf << "MMcRunHeader not found... assuming camera<0.7" << endl;
-
-    const int num = pedcam->GetSize();
-
-    const Bool_t camver70 = mcrun && mcrun->GetCamVersion()>=70;
-
-    for (int i=0; i<num; i++)
-    {
-        MPedestalPix &pix = (*pedcam)[i];
-
-        // Here one should compute the Pedestal taking into account how
-        // the MC makes the transformation analogic-digital for the FADC.
-        // This is done only once per file -> not time critical.
-
-        const Float_t pedest = fadc->GetPedestal(i);
-        const Float_t sigma  = camver70 ? fadc->GetPedestalRmsHigh(i) : fadc->GetElecNoise(i);
-
-        pix.Set(pedest, sigma);
-
-    }
-
-    if (camver70)
-        pedcam->SetReadyToSave();
-
-    return kTRUE;
-}
Index: unk/MagicSoft/Mars/manalysis/MMcPedestalCopy.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.h	(revision 3803)
+++ 	(revision )
@@ -1,21 +1,0 @@
-#ifndef MARS_MMcPedestalCopy
-#define MARS_MMcPedestalCopy
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-class MMcPedestalCopy : public MTask
-{
-private:
-    Bool_t CheckRunType(MParList *pList) const;
-    Int_t  PreProcess(MParList *pList);
-    Bool_t ReInit(MParList *pList);
-
-public:
-    MMcPedestalCopy(const char *name=NULL, const char *title=NULL);
-
-    ClassDef(MMcPedestalCopy, 0)   // Task which copies the pedestals from the MC into the standard container
-};
-
-#endif
Index: unk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 3803)
+++ 	(revision )
@@ -1,227 +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): Oscar Blanch, 11/2001 <mailto:blanch@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2001
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-//  MMcPedestalNSBAdd
-//  -----------------
-//
-//  This Task adds the contribution of the diffuse NSB to the FADC
-//  pedestals. We assume that NSB introduces larger fluctuation but does
-//  not change the mean value.
-//  To be precise we add quadratically to the rms, which is already in
-//  MPedestalCam, the NSB contribution.
-//  The number of photons from the diffuse NSB follows a poisson
-//  distribution with expected mean value X, then its standard deviation
-//  is sqrt(X).
-//  X is the number of phe per ns so we have to convert in FADC counts per
-//  slice:
-//
-//  Y = sqrt(X * FADC_time / Number_of_slices * pixel_size)
-//      * Amp_single_phe_response
-//
-//  Input Containers:
-//   MMcFadcHeader
-//   MRawRunHeader
-//   [MMcRunHeader]
-//
-//  Output Containers:
-//   MPedestalCam
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MMcPedestalNSBAdd.h"
-
-#include "MParList.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MGeomCam.h"
-#include "MGeomPix.h"
-
-#include "MPedestalPix.h"
-#include "MPedestalCam.h"
-
-#include "MRawRunHeader.h"
-#include "MMcRunHeader.hxx"
-#include "MMcFadcHeader.hxx"
-
-ClassImp(MMcPedestalNSBAdd);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// Default constructor.
-//
-MMcPedestalNSBAdd::MMcPedestalNSBAdd(const Float_t difnsb,
-                                     const char *name, const char *title)
-    : fDnsbPixel(difnsb)
-{
-    fName  = name  ? name  : "MMcPedestalNSBAdd";
-    fTitle = title ? title : "Add diffuse NSB to the pedestal signal";
-
-    //
-    // This is not needed here using MReadMarsFile because for the
-    // RunHeader tree the auto scheme is disabled by default
-    //
-    AddToBranchList("MMcFadcHeader.fPedesMean");
-    AddToBranchList("MMcFadcHeader.fElecNoise");
-}
-
-// --------------------------------------------------------------------------
-//
-// Check for the run type. Return kTRUE if it is a MC run or if there
-// is no MC run header (old camera files) kFALSE in case of a different
-// run type
-//
-Bool_t MMcPedestalNSBAdd::CheckRunType(MParList *pList) const
-{
-    const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
-    if (!runheader)
-    {
-        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
-        return kTRUE;
-    }
-
-    return runheader->IsMonteCarloRun();
-}
-
-// --------------------------------------------------------------------------
-//
-// Check for the camera version. This class should not be used with
-// camera files >= 0.7
-//
-Bool_t MMcPedestalNSBAdd::CheckCamVersion(MParList *pList) const
-{
-    const MMcRunHeader *run = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
-    if (!run)
-        *fLog << warn << dbginf << "MMcRunHeader not found... assuming camera<0.7" << endl;
-
-    return !run || run->GetCamVersion()<70;
-}
-
-// --------------------------------------------------------------------------
-//
-// If a MMcRunHeader is available the DNSB MMcRunHeader::GetNumPheFromDNSB
-// is returned. Otherwise the user given number is used.
-//
-Float_t MMcPedestalNSBAdd::GetDnsb(MParList *pList) const
-{
-    const MMcRunHeader *mcrunheader = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
-    if (!mcrunheader && fDnsbPixel<0)
-    {
-        *fLog << err << dbginf << "Using the default argument only ";
-        *fLog << "allowed if MMcRunHeader is available... aborting." << endl;
-        return -1;
-    }
-
-    if (!mcrunheader)
-        return fDnsbPixel;
-
-    if (fDnsbPixel >= 0 && fDnsbPixel != mcrunheader->GetNumPheFromDNSB())
-    {
-        *fLog << warn << dbginf << "The MC file has been generated with diffuse nsb " << mcrunheader->GetNumPheFromDNSB();
-        *fLog <<" but you set up the diffuse NSB to " << fDnsbPixel << endl;
-
-        return fDnsbPixel;
-    }
-
-    return mcrunheader->GetNumPheFromDNSB();
-}
-
-// --------------------------------------------------------------------------
-//
-//  This function is called each time MReadTree::Notify is called, which 
-//  happens when it  changes the file to read from.
-//  Here we add the contribution from NSB to the pedestals.
-//  The ReInit searches for the following input containers:
-//   - MRawRunHeader
-//   - MMcRunHeader
-//   - MMcFacdHeader
-//   - MGeomCam
-//
-//   The following output containers are also searched and created if
-//   they were not found:
-//   - MPedestalCam
-//
-Bool_t MMcPedestalNSBAdd::ReInit(MParList *pList)
-{
-    //
-    // If it is no MC file skip this function...
-    //
-    if (!CheckRunType(pList))
-        return kTRUE;
-
-    //
-    // If it is the wrong camera version this algorithm is not needed...
-    //
-    if (!CheckCamVersion(pList))
-        return kTRUE;
-
-    //
-    // Now check the existance of all necessary containers. This has
-    // to be done only if this is a MC file and the camera version
-    // is correct.
-    //
-    MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj(AddSerialNumber("MPedestalCam"));
-    if (!pedcam)
-	return kFALSE;
-
-    MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
-    if (!fadc)
-    {
-        *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
-	return kFALSE;
-    }
-
-    MGeomCam *geom = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
-    if (!geom)
-    {
-        *fLog << err << dbginf << "MGeomCam not found... aborting." << endl;
-	return kFALSE;
-    }
-
-    const Float_t dnsbpix = GetDnsb(pList) * 50.0/15.0;
-
-    if (dnsbpix < 0)
-        return kFALSE;
-
-    const int num = pedcam->GetSize();
-
-    for (int i=0; i<num; i++)
-    {
-        MPedestalPix &pix    = (*pedcam)[i];
-
-        const Float_t pedrms = pix.GetPedestalRms();
-        const Float_t ratio  = geom->GetPixRatio(i);
-        const Float_t ampl   = fadc->GetAmplitud();
-
-	pix.SetPedestalRms(sqrt(pedrms*pedrms + dnsbpix*ampl*ampl/ratio));
-    }
-
-    pedcam->SetReadyToSave();
-
-    return kTRUE;
-}
Index: unk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.h	(revision 3803)
+++ 	(revision )
@@ -1,27 +1,0 @@
-#ifndef MARS_MMcPedestalNSBAdd
-#define MARS_MMcPedestalNSBAdd
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-class MMcPedestalNSBAdd : public MTask
-{
-private:
-    Float_t fDnsbPixel;
-
-    Bool_t CheckCamVersion(MParList *pList) const;
-    Bool_t CheckRunType(MParList *pList) const;
-
-    Float_t GetDnsb(MParList *pList) const;
-
-    Bool_t ReInit(MParList *pList);
-
-public:
-    MMcPedestalNSBAdd(const Float_t difnsb = -1.0,
-                      const char *name=NULL, const char *title=NULL);
-
-    ClassDef(MMcPedestalNSBAdd, 0)   // Task which adds the NSB fluctuations to the pedestals rms
-};
-
-#endif
Index: unk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc	(revision 3803)
+++ 	(revision )
@@ -1,389 +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): Josep Flix 04/2001 <mailto:jflix@ifae.es>
-!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
-!   Author(s): Sebastian Commichau 12/2003 
-!   Author(s): Javier Rico 01/2004 <mailto:jrico@ifae.es>
-!   Author(s): Markus Gaug 01/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-//   MPedCalcPedRun
-//
-// This task takes a pedestal run file and fills MPedestalCam during
-// the Process() with the pedestal and rms computed in an event basis.
-// In the PostProcess() MPedestalCam is finally filled with the pedestal
-// mean and rms computed in a run basis.
-// More than one run (file) can be merged
-//
-//
-// Actually, MPedCalcPedRun applies the following formula (1):
-// 
-// PedRMS = Sqrt(  (sum(x_i^2) - sum(x_i)^2/n) / n-1 / 14 )
-// 
-// where x_i is the sum of 14 FADC slices and sum means the sum over all
-// events, n is the number of events.
-// 
-// For a high number of events, this formula is equivalent to formula (2):
-// 
-// PedRMS = Sqrt(  (<x_i*x_i> - <x_i>*<x_i>) / 14  )
-// 
-// where <> is the mean over all events and x_i again the sum over the 14
-// slices.
-// 
-// If you assume statistical equivalence of all slices (say, all have equal
-// offset and are not correlated and fluctuate Gaussian), it should also be
-// equivalent to (old formula) (3):
-// 
-// PedRMS = Sqrt(  (<p_i*p_i> - <p_i>*<p_i>) ) 
-// 
-// which is the RMS per slice of a single slice (p_i) and 
-// <> the mean over the total number of measurements, i.e. n*14.
-// 
-// If we assume that at least our pairs fluctuate independently and Gaussian,
-// then we can use the actual formula (1) in order to get 
-// fluctuations of pairs by the transformation:
-// 
-// PedRMS/pair = PedRMS (form. (3)) * Sqrt(2)
-// 
-// (However, we know that our slice-to-slice fluctuations are not Gaussian
-// (and moreover asymmetric) and that they are also correlated.)
-// 
-// 
-//  Input Containers:
-//   MRawEvtData
-//
-//  Output Containers:
-//   MPedestalCam
-//
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MPedCalcPedRun.h"
-
-#include "MParList.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MRawRunHeader.h"  
-#include "MRawEvtPixelIter.h"
-#include "MRawEvtData.h"
-
-#include "MPedestalPix.h"
-#include "MPedestalCam.h"
-
-#include "MExtractedSignalPix.h"
-#include "MExtractedSignalCam.h"
-
-#include "MGeomPix.h"
-#include "MGeomCam.h"
-
-#include "MGeomCamMagic.h"
-
-ClassImp(MPedCalcPedRun);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// default constructor
-//
-MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title)
-    : fRawEvt(NULL), fPedestals(NULL)
-{
-    fName  = name  ? name  : "MPedCalcPedRun";
-    fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
-
-    AddToBranchList("fHiGainPixId");
-    AddToBranchList("fHiGainFadcSamples");
-
-    fNumHiGainSamples = 0;
-    Clear();
-}
-
-void MPedCalcPedRun::Clear(const Option_t *o)
-{
-
-  fNumSamplesTot    = 0;
-
-  fRawEvt    = NULL;
-  fPedestals = NULL;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Look for the following input containers:
-//
-//  - MRawEvtData
-// 
-// The following output containers are also searched and created if
-// they were not found:
-//
-//  - MPedestalCam
-//
-Int_t MPedCalcPedRun::PreProcess( MParList *pList )
-{
-
-  Clear();
-  
-  fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
-  if (!fRawEvt)
-    {
-      *fLog << err << "MRawEvtData not found... aborting." << endl;
-      return kFALSE;
-    }
-  
-  fGeom   =  (MGeomCam*)pList->FindObject("MGeomCam");
-  if (!fGeom)
-    {
-      *fLog << err << "MGeomCam not found... aborting." << endl;
-      return kFALSE;
-    }
-
-  fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
-  if (!fPedestals)
-    return kFALSE;
-  
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// The ReInit searches for the following input containers:
-//  - MRawRunHeader
-//
-// It also initializes the data arrays fSumx and fSumx2 
-// (only for the first read file)
-// 
-Bool_t MPedCalcPedRun::ReInit(MParList *pList)
-{
-    const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
-    if (!runheader)
-    {
-        *fLog << warn << dbginf;
-        *fLog << "Warning - cannot check file type, MRawRunHeader not found." << endl;
-    }
-    else
-      if (runheader->IsMonteCarloRun())
-        return kTRUE;
-
-    Int_t npixels  = fPedestals->GetSize();
-    Int_t areas    = fPedestals->GetAverageAreas();
-    Int_t sectors  = fPedestals->GetAverageSectors();
-
-    if (fSumx.GetSize()==0)
-    {
-	fSumx. Set(npixels);
-	fSumx2.Set(npixels);
-
-	fAreaSumx. Set(areas);
-	fAreaSumx2.Set(areas);
-	fAreaValid.Set(areas);
-
-	fSectorSumx. Set(sectors);
-	fSectorSumx2.Set(sectors);
-	fSectorValid.Set(sectors);
-
-	fSumx.Reset();
-	fSumx2.Reset();
-    }
-
-    // Calculate an even number for the hi gain samples to avoid
-    // biases due to the fluctuation in pedestal from one slice to
-    // the other one
-    fNumHiGainSamples = runheader->GetNumSamplesHiGain() & ~1;
-
-    return kTRUE;
-}
-// --------------------------------------------------------------------------
-//
-// Fill the MPedestalCam container with the signal mean and rms for the event.
-// Store the measured signal in arrays fSumx and fSumx2 so that we can 
-// calculate the overall mean and rms in the PostProcess()
-//
-Int_t MPedCalcPedRun::Process()
-{
-
-  MRawEvtPixelIter pixel(fRawEvt);
-  
-  while (pixel.Next())
-    {
-
-      const UInt_t idx    = pixel.GetPixelId();
-      const UInt_t aidx   = (*fGeom)[idx].GetAidx();
-      const UInt_t sector = (*fGeom)[idx].GetSector();      
-
-      Byte_t *ptr = pixel.GetHiGainSamples();
-      const Byte_t *end = ptr + fNumHiGainSamples;
-      
-      UInt_t sum = 0;
-      UInt_t sqr = 0;
-
-      do
-        {
-          sum += *ptr;
-          sqr += *ptr * *ptr;
-        }
-      while (++ptr != end);
-      
-      const Float_t msum = (Float_t)sum;
-	
-      //
-      // These three lines have been uncommented by Markus Gaug
-      // If anybody needs them, please contact me!!
-      //
-      //	const Float_t higainped = msum/fNumHiGainSamples;
-      //	const Float_t higainrms = TMath::Sqrt((msqr-msum*msum/fNumHiGainSamples)/(fNumHiGainSamples-1.));
-      //	(*fPedestals)[idx].Set(higainped, higainrms);
-      
-      fSumx[idx]          += msum;
-      fAreaSumx[aidx]     += msum;
-      fSectorSumx[sector] += msum;      
-      //
-      // The old version:
-      //
-      //       const Float_t msqr = (Float_t)sqr;
-      //	fSumx2[idx] += msqr;
-      //
-      // The new version:
-      //
-      const Float_t sqrsum  = msum*msum;
-      fSumx2[idx]          += sqrsum;
-      fAreaSumx2[aidx]     += sqrsum;
-      fSectorSumx2[sector] += sqrsum;      
-    }
-  
-//  fPedestals->SetReadyToSave();
-  fNumSamplesTot += fNumHiGainSamples;
-  
-  
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Compute signal mean and rms in the whole run and store it in MPedestalCam
-//
-Int_t MPedCalcPedRun::PostProcess()
-{
-
-  // Compute pedestals and rms from the whole run
-  const ULong_t n     = fNumSamplesTot;
-  const ULong_t nevts = GetNumExecutions();
-
-  MRawEvtPixelIter pixel(fRawEvt);
-  
-  while (pixel.Next())
-    {
-
-      const Int_t  pixid  = pixel.GetPixelId();
-      const UInt_t aidx   = (*fGeom)[pixid].GetAidx();
-      const UInt_t sector = (*fGeom)[pixid].GetSector();      
-      
-      fAreaValid  [aidx]++;
-      fSectorValid[sector]++;
-
-      const Float_t sum  = fSumx.At(pixid);
-      const Float_t sum2 = fSumx2.At(pixid);
-      
-      const Float_t higainped = sum/n;
-      //
-      // The old version:
-      //
-      //      const Float_t higainrms = TMath::Sqrt((sum2-sum*sum/n)/(n-1.));
-      //
-      // The new version:
-      //
-      // 1. Calculate the Variance of the sums:
-      Float_t higainVar = (sum2-sum*sum/nevts)/(nevts-1.);
-      // 2. Scale the variance to the number of slices:
-      higainVar /= (Float_t)fNumHiGainSamples;
-      // 3. Calculate the RMS from the Variance:
-      const Float_t higainrms = TMath::Sqrt(higainVar);
-
-      (*fPedestals)[pixid].Set(higainped, higainrms);
-
-    }
-
-  //
-  // Loop over the (two) area indices to get the averaged pedestal per aidx
-  //
-  for (Int_t aidx=0; aidx<fAreaValid.GetSize(); aidx++)
-    {
-      
-      const Int_t   napix = fAreaValid.At(aidx);
-      const Float_t sum   = fAreaSumx.At(aidx);
-      const Float_t sum2  = fAreaSumx2.At(aidx);
-      const ULong_t an    = napix * n;
-      const ULong_t aevts = napix * nevts;
-      
-      const Float_t higainped = sum/an;
-
-      // 1. Calculate the Variance of the sums:
-      Float_t higainVar = (sum2-sum*sum/aevts)/(aevts-1.);
-      // 2. Scale the variance to the number of slices:
-      higainVar /= (Float_t)fNumHiGainSamples;
-      // 3. Calculate the RMS from the Variance:
-      Float_t higainrms = TMath::Sqrt(higainVar);
-      // 4. Re-scale it with the square root of the number of involved pixels 
-      //    in order to be comparable to the mean of pedRMS of that area
-      higainrms *= TMath::Sqrt((Float_t)napix);
-
-      fPedestals->GetAverageArea(aidx).Set(higainped, higainrms);
-    }
-  
-  //
-  // Loop over the (six) sector indices to get the averaged pedestal per sector
-  //
-  for (Int_t sector=0; sector<fSectorValid.GetSize(); sector++)
-    {
-      
-      const Int_t   nspix = fSectorValid.At(sector);
-      const Float_t sum   = fSectorSumx.At(sector);
-      const Float_t sum2  = fSectorSumx2.At(sector);
-      const ULong_t sn    = nspix * n;
-      const ULong_t sevts = nspix * nevts;
-      
-      const Float_t higainped = sum/sn;
-
-      // 1. Calculate the Variance of the sums:
-      Float_t higainVar = (sum2-sum*sum/sevts)/(sevts-1.);
-      // 2. Scale the variance to the number of slices:
-      higainVar /= (Float_t)fNumHiGainSamples;
-      // 3. Calculate the RMS from the Variance:
-      Float_t higainrms = TMath::Sqrt(higainVar);
-      // 4. Re-scale it with the square root of the number of involved pixels 
-      //    in order to be comparable to the mean of pedRMS of that sector
-      higainrms *= TMath::Sqrt((Float_t)nspix);
-
-      fPedestals->GetAverageSector(sector).Set(higainped, higainrms);
-    }
-  
-  fPedestals->SetTotalEntries(fNumSamplesTot);
-  fPedestals->SetReadyToSave();
-
-  return kTRUE;
-}
-
-
Index: unk/MagicSoft/Mars/manalysis/MPedCalcPedRun.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.h	(revision 3803)
+++ 	(revision )
@@ -1,53 +1,0 @@
-#ifndef MARS_MPedCalcPedRun
-#define MARS_MPedCalcPedRun
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-#ifndef ROOT_TArrayF
-#include <TArrayF.h>
-#endif
-
-#ifndef ROOT_TArrayI
-#include <TArrayI.h>
-#endif
-
-class MRawEvtData;
-class MPedestalCam;
-class MGeomCam;
-class MPedCalcPedRun : public MTask
-{
-
-  Byte_t fNumHiGainSamples;
-  UInt_t fNumSamplesTot;
-  
-  MRawEvtData  *fRawEvt;     // raw event data (time slices)
-  MPedestalCam *fPedestals;  // Pedestals of all pixels in the camera
-  MGeomCam     *fGeom;       // Camera geometry
-  
-  TArrayF fSumx;         // sum of values
-  TArrayF fSumx2;        // sum of squared values
-  TArrayF fAreaSumx;     // averaged sum of values per area idx
-  TArrayF fAreaSumx2;    // averaged sum of squared values per area idx
-  TArrayI fAreaValid;    // number of valid pixel with area idx  
-  TArrayF fSectorSumx;   // averaged sum of values per sector 
-  TArrayF fSectorSumx2;  // averaged sum of squared values per sector
-  TArrayI fSectorValid;  // number of valid pixel with sector idx  
-  
-  Int_t  PreProcess ( MParList *pList );
-  Bool_t ReInit     ( MParList *pList );
-  Int_t  Process    ();
-  Int_t  PostProcess();
-  
-public:
-
-  MPedCalcPedRun(const char *name=NULL, const char *title=NULL);
-  
-  void Clear(const Option_t *o="");
-  void SetNumHiGainSamples(const Byte_t n)      { fNumHiGainSamples = n;   }
-  
-  ClassDef(MPedCalcPedRun, 0)   // Task to calculate pedestals from pedestal runs raw data
-};
-
-#endif
Index: unk/MagicSoft/Mars/manalysis/MPedPhotCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedPhotCalc.cc	(revision 3803)
+++ 	(revision )
@@ -1,202 +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): Josep Flix 1/2004 <mailto:jflix@ifae.es>
-!   Author(s): Javier Rico 1/2004 <mailto:jrico@ifae.es>
-!   Author(s): Markus Gaug 4/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-//   MPedPhotCalc
-//
-//  This is a Task class to compute, for each pixel, the signal mean and
-//  rms from a pedestal run file that has undergone the standard signal
-//  extration  and calibration procedure. The signal rms can be used as
-//  reference to compute the significance of the measured signals in the
-//  following data runs (e.g. during the image cleaning).
-//
-//  Input Containers:
-//   MCerPhotEvt
-//
-//  Output Containers:
-//   MPedPhotCam
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MPedPhotCalc.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-#include "MRawRunHeader.h"
-
-#include "MCerPhotPix.h"
-#include "MCerPhotEvt.h"
-
-#include "MPedPhotPix.h"
-#include "MPedPhotCam.h"
-
-#include "MBadPixelsPix.h"
-#include "MBadPixelsCam.h"
-
-ClassImp(MPedPhotCalc);
-
-using namespace std;
-
-//
-// Default constructor
-//
-MPedPhotCalc::MPedPhotCalc(const char *name, const char *title)
-    : fPedestals(NULL), fCerPhot(NULL), fBadPixels(NULL)
-{
-  fName  = name  ? name  : "MPedPhotCalc";
-  fTitle = title ? title : "Task to calculate pedestals in units of photons";
-}
-
-// --------------------------------------------------------------------------
-//
-// Look for the following input containers:
-//
-//  - MCerPhotEvt
-//  - MBadPixelsCam
-// 
-// The following output containers are also searched and created if
-// they were not found:
-//
-//  - MPedPhotCam
-//
-Int_t MPedPhotCalc::PreProcess( MParList *pList )
-{      
-  // Look for input container
-  fCerPhot = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
-  if (!fCerPhot)
-    {
-      *fLog << err << "MPedPhotCalc::PreProcess Error: MCerPhotEvt not found... aborting." << endl;
-      return kFALSE;
-    }
-
-
-  fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
-  if (!fBadPixels)
-    {
-      *fLog << warn << "MPedPhotCalc::PreProcess Warning: No MBadPixelsCam found." << endl;
-    }
-
-  // Create output container
-  fPedestals = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam");
-  if (!fPedestals)
-    return kFALSE;
-  
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// The ReInit searches for the following input containers:
-//  - MRawRunHeader
-//
-// It also initializes the data arrays fSumx and fSumx2 
-// (only for the first read file)
-// 
-Bool_t MPedPhotCalc::ReInit(MParList *pList)
-{
-  const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
-  if (!runheader)
-  {
-      *fLog << warn << dbginf;
-      *fLog << "Warning - cannot check file type, MRawRunHeader not found." << endl;
-  }
-  else
-      if (runheader->IsMonteCarloRun())
-          return kTRUE;
-  
-
-  // Initialize arrays
-  if(fSumx.GetSize()==0)
-  {
-      const UShort_t num = fPedestals->GetSize();
-
-      fSumx.Set(num);
-      fSumx2.Set(num);
-
-      memset(fSumx.GetArray(),  0, sizeof(Float_t)*num);
-      memset(fSumx2.GetArray(), 0, sizeof(Float_t)*num);
-  }
-
-
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Store the measured number of photons in arrays fSumx and fSumx2
-// so that we can calculate the mean and rms in the PostProcess()
-//
-Int_t MPedPhotCalc::Process()
-{
-    for(UInt_t i=0;i<fCerPhot->GetNumPixels();i++)
-    {
- 
-       const MCerPhotPix &pix = (*fCerPhot)[i];
-
-       const Float_t nphot = pix.GetNumPhotons();
-       
-       fSumx[i]  += nphot;
-       fSumx2[i] += nphot*nphot;
-    }
-
-    fPedestals->SetReadyToSave();
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Compute mean and rms of the measured charge distribution (in photons)
-//
-Int_t MPedPhotCalc::PostProcess()
-{
-    // Compute pedestals and rms from fSumx and fSumx2 arrays
-    const Int_t n    = GetNumExecutions();
-    const Int_t npix = fSumx.GetSize();
-
-    for(Int_t i=0; i<npix; i++)
-    {
-
-      if (fBadPixels)
-        {
-          const MBadPixelsPix &bad = (*fBadPixels)[i];
-          if (bad.IsBad())
-            continue;
-        }
-
-      const Float_t sum  = fSumx[i];
-      const Float_t sum2 = fSumx2[i];
-      
-      const Float_t photped = sum/n;
-      const Float_t photrms = TMath::Sqrt((sum2-sum*sum/n)/(n-1.));
-      
-      (*fPedestals)[i].Set(photped,photrms);
-    }
-
-    return kTRUE;
-}
Index: unk/MagicSoft/Mars/manalysis/MPedPhotCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedPhotCalc.h	(revision 3803)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#ifndef MARS_MPedPhotCalc
-#define MARS_MPedPhotCalc
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-#ifndef ROOT_TArrayF
-#include <TArrayF.h>
-#endif
-
-class MPedPhotCam;
-class MCerPhotEvt;
-class MBadPixelsCam;
-class MPedPhotCalc : public MTask
-{
-
-  MPedPhotCam   *fPedestals;  // Pedestals of all pixels in the camera
-  MCerPhotEvt   *fCerPhot;    // Calibrated Cherenkov events 
-  MBadPixelsCam *fBadPixels;  // Bad Pixels
-  
-  TArrayF fSumx;   // sum of values
-  TArrayF fSumx2;  // sum of squared values
-
-  Bool_t ReInit(MParList *pList);
-
-  Int_t PreProcess(MParList *pList);
-  Int_t Process();
-  Int_t PostProcess();
-  
-public:
-  MPedPhotCalc(const char *name=NULL, const char *title=NULL);
-
-  ClassDef(MPedPhotCalc, 0) //Task to calculate pedestals in units of photons
-};
-
-#endif
Index: unk/MagicSoft/Mars/manalysis/MPedPhotCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedPhotCam.cc	(revision 3803)
+++ 	(revision )
@@ -1,204 +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, 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2003
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// MPedPhotCam
-//
-// Hold the Pedestal information for all pixels in the camera (in usints
-// of photons)
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MPedPhotCam.h"
-#include "MPedPhotPix.h"
-
-#include <TClonesArray.h>
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MGeomCam.h"
-
-ClassImp(MPedPhotCam);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// Default constructor. Creates a MPedPhotPix object for each pixel
-//
-MPedPhotCam::MPedPhotCam(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MPedPhotCam";
-    fTitle = title ? title : "Storage container for all Pedestal Information in the camera (in units of photons)";
-
-    fArray = new TClonesArray("MPedPhotPix", 1);
-
-//    for (int i=0; i<577; i++)
-//        new ((*fArray)[i]) MPedPhotPix;
-}
-
-// --------------------------------------------------------------------------
-//
-// Delete the array conatining the pixel pedest information
-//
-MPedPhotCam::~MPedPhotCam()
-{
-    delete fArray;
-}
-
-// --------------------------------------------------------------------------
-//
-// Set the size of the camera
-//
-void MPedPhotCam::InitSize(const UInt_t i)
-{
-    fArray->ExpandCreate(i);
-}
-
-// --------------------------------------------------------------------------
-//
-// Get the size of the MPedPhotCam
-//
-Int_t MPedPhotCam::GetSize() const
-{
-    return fArray->GetEntriesFast();
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th pixel (pixel number)
-//
-MPedPhotPix &MPedPhotCam::operator[](Int_t i)
-{
-    return *static_cast<MPedPhotPix*>(fArray->UncheckedAt(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th pixel (pixel number)
-//
-MPedPhotPix &MPedPhotCam::operator[](Int_t i) const
-{
-    return *static_cast<MPedPhotPix*>(fArray->UncheckedAt(i));
-}
-
-/*
-// --------------------------------------------------------------------------
-//
-// Check if position i is inside bounds
-//
-Bool_t MPedPhotCam::CheckBounds(Int_t i)
-{
-    return i < fArray->GetEntriesFast();
-} 
-*/
-void MPedPhotCam::Clear(Option_t *o)
-{
-    fArray->ForEach(TObject, Clear)();
-}
-
-void MPedPhotCam::Print(Option_t *o) const
-{
-    *fLog << all << GetDescriptor() << ":" << endl;
-    int id = 0;
-
-    TIter Next(fArray);
-    MPedPhotPix *pix;
-    while ((pix=(MPedPhotPix*)Next()))
-    {
-        id++;
-
-        if (!pix->IsValid())
-            continue;
-
-        *fLog << id-1 << ": ";
-        *fLog << pix->GetMean() << " " << pix->GetRms() << endl;
-    }
-}
-/*
-Float_t MPedPhotCam::GetPedestalMin(const MGeomCam *geom) const
-{
-    if (fArray->GetEntries() <= 0)
-        return 50.;
-
-    Float_t minval = (*this)[0].GetPedestalRms();
-
-    for (Int_t i=1; i<fArray->GetEntries(); i++)
-    {
-        const MPedPhotPix &pix = (*this)[i];
-
-        Float_t testval = pix.GetPedestalRms();
-
-        if (geom)
-            testval *= geom->GetPixRatio(i);
-
-        if (testval < minval)
-            minval = testval;
-    }
-    return minval;
-}
-
-Float_t MPedPhotCam::GetPedestalMax(const MGeomCam *geom) const
-{
-    if (fArray->GetEntries() <= 0)
-        return 50.;
-
-    Float_t maxval = (*this)[0].GetPedestalRms();
-
-    for (Int_t i=1; i<fArray->GetEntries(); i++)
-    {
-        const MPedPhotPix &pix = (*this)[i];
-
-        Float_t testval = pix.GetPedestalRms();
-
-        if (geom)
-            testval *= geom->GetPixRatio(i);
-
-        if (testval > maxval)
-            maxval = testval;
-    }
-    return maxval;
-}
-*/
-Bool_t MPedPhotCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
-{
-    switch (type)
-    {
-    case 0:
-        val = (*this)[idx].GetMean();
-        break;
-    case 1:
-        val = (*this)[idx].GetRms();
-        break;
-    default:
-	return kFALSE;
-    }
-    return val>=0;
-}
-
-void MPedPhotCam::DrawPixelContent(Int_t num) const
-{
-    *fLog << warn << "MPedPhotCam::DrawPixelContent - not available." << endl;
-}
Index: unk/MagicSoft/Mars/manalysis/MPedPhotCam.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedPhotCam.h	(revision 3803)
+++ 	(revision )
@@ -1,47 +1,0 @@
-#ifndef MARS_MPedPhotCam
-#define MARS_MPedPhotCam
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-#ifndef MARS_MCamEvent
-#include "MCamEvent.h"
-#endif
-
-class TClonesArray;
-
-class MGeomCam;
-class MPedPhotPix;
-
-class MPedPhotCam : public MParContainer, public MCamEvent
-{
-private:
-    TClonesArray *fArray; // FIXME: Change TClonesArray away from a pointer?
-
-public:
-    MPedPhotCam(const char *name=NULL, const char *title=NULL);
-    ~MPedPhotCam();
-
-    void Clear(Option_t *o="");
-
-    void InitSize(const UInt_t i);
-    Int_t GetSize() const;
-
-    MPedPhotPix &operator[](Int_t i);
-    MPedPhotPix &operator[](Int_t i) const;
-
-    //    Float_t GetPedestalMin(const MGeomCam *cam) const;
-    //    Float_t GetPedestalMax(const MGeomCam *cam) const;
-
-    //    Bool_t CheckBounds(Int_t i);
-
-    void Print(Option_t *o="") 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(MPedPhotCam, 1)	// Storage Container for all pedestal information of the camera (in units of photons)
-};
-
-#endif
-
Index: unk/MagicSoft/Mars/manalysis/MPedPhotPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedPhotPix.cc	(revision 3803)
+++ 	(revision )
@@ -1,53 +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  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2001
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// MPedPhotPix
-//
-// This is the storage container to hold informations about the pedestal
-// (offset) value of one Pixel (PMT) in units of photons
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MPedPhotPix.h"
-
-#include "MLog.h"
-
-ClassImp(MPedPhotPix);
-
-MPedPhotPix::MPedPhotPix()
-{
-    Clear();
-}
-
-// ------------------------------------------------------------------------
-//
-// Invalidate values
-//
-void MPedPhotPix::Clear(Option_t *o)
-{
-    fMean = -1;
-    fRms  = -1;
-}
-
Index: unk/MagicSoft/Mars/manalysis/MPedPhotPix.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedPhotPix.h	(revision 3803)
+++ 	(revision )
@@ -1,32 +1,0 @@
-#ifndef MARS_MPedPhotPix
-#define MARS_MPedPhotPix
-
-#ifndef ROOT_TObject
-#include <TObject.h>
-#endif
-
-class MPedPhotPix : public TObject
-{
-private:
-    Float_t fMean; // [phot] mean value of pedestal (should be 0)
-    Float_t fRms;  // [phot] rms of mean
-
-public:
-    MPedPhotPix();
-
-    void Clear(Option_t *o="");
-
-    Float_t GetMean() const { return fMean; }
-    Float_t GetRms() const  { return fRms; }
-
-    //void SetMean(Float_t f) { fMean = f; }
-    void SetRms(Float_t f)  { fRms  = f; }
-    void Set(Float_t m, Float_t r) { fMean = m; fRms = r; }
-
-    Bool_t IsValid() const { return fRms>=0; }
-
-    ClassDef(MPedPhotPix, 1) // Storage Container for Pedestal information of one pixel in units of photons
-};
-
-#endif
-
Index: unk/MagicSoft/Mars/manalysis/MPedestalCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 3803)
+++ 	(revision )
@@ -1,347 +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  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
-!              Markus Gaug   02/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MPedestalCam                                                            //
-//                                                                         //
-// Hold the Pedestal information for all pixels in the camera              //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-#include "MPedestalCam.h"
-#include "MPedestalPix.h"
-
-#include <TClonesArray.h>
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-
-#include "MGeomCam.h"
-
-ClassImp(MPedestalCam);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// Default constructor. 
-//
-// Creates a TClonesArray of MPedestalPix containers, initialized to 1 entry, destinated 
-// to hold one container per pixel. Later, a call to MPedestalCam::InitSize() 
-// has to be performed (in MGeomApply). 
-//
-// Creates a TClonesArray of MPedestalPix containers, initialized to 1 entry, destinated 
-// to hold one container per pixel AREA. Later, a call to MPedestalCam::InitAreas() 
-// has to be performed (in MGeomApply). 
-//
-// Creates a TClonesArray of MPedestalPix containers, initialized to 1 entry, destinated
-// to hold one container per camera SECTOR. Later, a call to MPedestalCam::InitSectors() 
-// has to be performed (in MGeomApply). 
-//
-MPedestalCam::MPedestalCam(const char *name, const char *title) 
-    : fTotalEntries(0)
-{
-  fName  = name  ? name  : "MPedestalCam";
-  fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
-  
-  fArray            = new TClonesArray("MPedestalPix", 1);
-  fAverageAreas     = new TClonesArray("MPedestalPix", 1);
-  fAverageSectors   = new TClonesArray("MPedestalPix", 1);
-}
-
-// --------------------------------------------------------------------------
-//
-// Deletes the following TClonesArray's of MPedestalPix containers (if exist):
-// - fArray
-// - fAverageAreas
-// - fAverageSectors
-//  
-MPedestalCam::~MPedestalCam()
-{
-  delete fArray;
-  delete fAverageAreas;
-  delete fAverageSectors;
-}
-
-// --------------------------------------------------------------------------
-//
-// Set the size of the camera
-//
-void MPedestalCam::InitSize(const UInt_t i)
-{
-    fArray->ExpandCreate(i);
-}
-
-// -------------------------------------------------------------------
-//
-// Calls TClonesArray::ExpandCreate() for:
-// - fAverageAreas
-//
-void MPedestalCam::InitAverageAreas(const UInt_t i)
-{
-  fAverageAreas->ExpandCreate(i);
-}
-
-// -------------------------------------------------------------------
-//
-// Calls TClonesArray::ExpandCreate() for:
-// - fAverageSectors
-//
-void MPedestalCam::InitAverageSectors(const UInt_t i)
-{
-  fAverageSectors->ExpandCreate(i);
-}
-
-// -------------------------------------------------------------------
-//
-// Calls:
-// - InitSize()
-// - InitAverageAreas()
-// - InitAverageSectors()
-//
-void MPedestalCam::Init(const MGeomCam &geom)
-{
-  InitSize          (geom.GetNumPixels() );
-  InitAverageAreas  (geom.GetNumAreas()  );
-  InitAverageSectors(geom.GetNumSectors());
-}
-
-// --------------------------------------------------------------------------
-//
-// This function returns the current size of the TClonesArray 
-// independently if the MPedestalPix is filled with values or not.
-//
-// Get the size of the MPedestalCam
-//
-Int_t MPedestalCam::GetSize() const
-{
-    return fArray->GetEntriesFast();
-}
-
-// --------------------------------------------------------------------------
-//
-// Returns the current size of the TClonesArray fAverageAreas
-// independently if the MPedestalPix is filled with values or not.
-//
-const Int_t MPedestalCam::GetAverageAreas() const
-{
-  return fAverageAreas->GetEntriesFast();
-}
-
-// --------------------------------------------------------------------------
-//
-// Returns the current size of the TClonesArray fAverageSectors
-// independently if the MPedestalPix is filled with values or not.
-//
-const Int_t MPedestalCam::GetAverageSectors() const
-{
-  return fAverageSectors->GetEntriesFast();
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th pixel (pixel number)
-//
-MPedestalPix &MPedestalCam::operator[](Int_t i)
-{
-    return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th pixel (pixel number)
-//
-const MPedestalPix &MPedestalCam::operator[](Int_t i) const
-{
-    return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th average pixel (area number)
-//
-MPedestalPix &MPedestalCam::GetAverageArea(UInt_t i)
-{
-  return *static_cast<MPedestalPix*>(fAverageAreas->UncheckedAt(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th average pixel (area number)
-//
-const MPedestalPix &MPedestalCam::GetAverageArea(UInt_t i) const 
-{
-  return *static_cast<MPedestalPix*>(fAverageAreas->UncheckedAt(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th average pixel (sector number)
-//
-MPedestalPix &MPedestalCam::GetAverageSector(UInt_t i)
-{
-  return *static_cast<MPedestalPix*>(fAverageSectors->UncheckedAt(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th average pixel (sector number)
-//
-const MPedestalPix &MPedestalCam::GetAverageSector(UInt_t i) const 
-{
-  return *static_cast<MPedestalPix*>(fAverageSectors->UncheckedAt(i));
-}
-
-// --------------------------------------
-//
-// Calls the ForEach macro for the TClonesArray fArray with the argument Clear()
-// 
-// Loops over the fAverageAreas, calling the function Clear() for 
-// every entry in fAverageAreas
-//
-// Loops over the fAverageSectors, calling the function Clear() for 
-// every entry in fAverageSectors
-// 
-void MPedestalCam::Clear(Option_t *o)
-{
-  fArray->ForEach(TObject, Clear)();
-  
-  //
-  // another ForEach does not compile, thus have to do the loop ourselves:
-  //
-  for (Int_t i=0;i<GetAverageAreas();i++)
-    fAverageAreas[i].Clear();
-
-
-  //
-  // another ForEach does not compile, thus have to do the loop ourselves:
-  //
-  for (Int_t i=0;i<GetAverageSectors();i++)
-    fAverageSectors[i].Clear();
-  
-  fTotalEntries = 0;
-}
-
-void MPedestalCam::Print(Option_t *o) const
-{
-    *fLog << all << GetDescriptor() << ":" << endl;
-    int id = 0;
-
-    TIter Next(fArray);
-    MPedestalPix *pix;
-    while ((pix=(MPedestalPix*)Next()))
-    {
-        id++;
-
-        if (!pix->IsValid())
-            continue;
-
-        *fLog << id-1 << ": ";
-        *fLog << pix->GetPedestal() << " " << pix->GetPedestalRms() << endl;
-    }
-}
-
-Float_t MPedestalCam::GetPedestalMin(const MGeomCam *geom) const
-{
-    if (fArray->GetEntries() <= 0)
-        return 50.;
-
-    Float_t minval = (*this)[0].GetPedestalRms();
-
-    for (Int_t i=1; i<fArray->GetEntries(); i++)
-    {
-        const MPedestalPix &pix = (*this)[i];
-
-        Float_t testval = pix.GetPedestalRms();
-
-        if (geom)
-            testval *= geom->GetPixRatio(i);
-
-        if (testval < minval)
-            minval = testval;
-    }
-    return minval;
-}
-
-Float_t MPedestalCam::GetPedestalMax(const MGeomCam *geom) const
-{
-    if (fArray->GetEntries() <= 0)
-        return 50.;
-
-    Float_t maxval = (*this)[0].GetPedestalRms();
-
-    for (Int_t i=1; i<fArray->GetEntries(); i++)
-    {
-        const MPedestalPix &pix = (*this)[i];
-
-        Float_t testval = pix.GetPedestalRms();
-
-        if (geom)
-            testval *= geom->GetPixRatio(i);
-
-        if (testval > maxval)
-            maxval = testval;
-    }
-    return maxval;
-}
-
-Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
-{
-
-  if (GetSize() <= idx)
-    return kFALSE;
-
-  const Float_t ped      = (*this)[idx].GetPedestal();
-  const Float_t rms      = (*this)[idx].GetPedestalRms();
-
-  const Float_t pederr   = rms/TMath::Sqrt((Float_t)fTotalEntries);
-  const Float_t rmserr   = rms/TMath::Sqrt((Float_t)fTotalEntries)/2.;
-
-  switch (type)
-    {
-    case 0:
-      val = ped;
-      break;
-    case 1:
-      val = pederr;
-      break;
-    case 2:
-      val = rms;
-      break;
-    case 3:
-      val = rmserr;
-      break;
-    default:
-      return kFALSE;
-    }
-  return kTRUE;
-}
-
-void MPedestalCam::DrawPixelContent(Int_t idx) const
-{
-  *fLog << warn << "MPedestalCam::DrawPixelContent - not available." << endl;
-}
Index: unk/MagicSoft/Mars/manalysis/MPedestalCam.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 3803)
+++ 	(revision )
@@ -1,64 +1,0 @@
-#ifndef MARS_MPedestalCam
-#define MARS_MPedestalCam
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-#ifndef MARS_MCamEvent
-#include "MCamEvent.h"
-#endif
-
-class TClonesArray;
-
-class MGeomCam;
-class MPedestalPix;
-
-class MPedestalCam : public MParContainer, public MCamEvent
-{
-private:
-
-  TClonesArray *fArray;           //-> FIXME: Change TClonesArray away from a pointer?
-  TClonesArray *fAverageAreas;    //-> Array of MPedestalPix, one per pixel area
-  TClonesArray *fAverageSectors;  //-> Array of MPedestalPix, one per camera sector
-
-  UInt_t fTotalEntries;  // Total number of times, the Process was executed (to estimate the error of pedestal)
-
-public:
-
-  MPedestalCam(const char *name=NULL, const char *title=NULL);
-  ~MPedestalCam();
-  
-  void Clear(Option_t *o="");
-  
-  // Getters 
-        MPedestalPix &GetAverageArea   ( UInt_t i );
-  const MPedestalPix &GetAverageArea   ( UInt_t i )            const;
-  const Int_t         GetAverageAreas  ()                      const;
-        MPedestalPix &GetAverageSector ( UInt_t i );
-  const MPedestalPix &GetAverageSector ( UInt_t i )            const;
-  const Int_t         GetAverageSectors()                      const;
-  Float_t             GetPedestalMin   ( const MGeomCam *cam ) const;
-  Float_t             GetPedestalMax   ( const MGeomCam *cam ) const;
-  Int_t               GetSize          ()                      const;
-  ULong_t             GetTotalEntries  ()                      const { return fTotalEntries; }
-  
-        MPedestalPix &operator[]       ( Int_t i             );
-  const MPedestalPix &operator[]       ( Int_t i             ) const;
-
-  void  Init                           ( const MGeomCam &geom);
-  void  InitSize                       ( const UInt_t i      );
-  void  InitAverageAreas               ( const UInt_t i      );
-  void  InitAverageSectors             ( const UInt_t i      );
-
-  void Print(Option_t *o="") const;
-  
-  // Setters
-  void SetTotalEntries(const ULong_t n) { fTotalEntries = n; }
-
-  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
-  void DrawPixelContent(Int_t idx) const;
-
-  ClassDef(MPedestalCam, 1)	// Storage Container for all pedestal information of the camera
-};
-
-#endif
Index: unk/MagicSoft/Mars/manalysis/MPedestalPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 3803)
+++ 	(revision )
@@ -1,77 +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  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2001
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MPedestalPix                                                            //
-//                                                                         //
-// This is the storage container to hold informations about the pedestal   //
-// (offset) value of one Pixel (PMT).                                      //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-#include "MPedestalPix.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-ClassImp(MPedestalPix);
-
-using namespace std;
-
-MPedestalPix::MPedestalPix()
-{
-  Clear();
-}
-
-
-// ------------------------------------------------------------------------
-//
-// Invalidate values
-//
-void MPedestalPix::Clear(Option_t *o)
-{
-  fPedestal = -1.;
-  fPedestalRms = -1.;
-
-}
-
-void MPedestalPix::InitUseHists()
-{
-
-  fPedestal = 0.;
-  fPedestalRms = 0.;
-}
-
-
-void MPedestalPix::Set(Float_t m, Float_t r)
-{
-  fPedestal = m; 
-  fPedestalRms = r; 
-}
-
-Bool_t MPedestalPix::IsValid() const 
-{
- return fPedestal>=0||fPedestalRms>=0;
-}
-
Index: unk/MagicSoft/Mars/manalysis/MPedestalPix.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 3803)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#ifndef MARS_MPedestalPix
-#define MARS_MPedestalPix
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-class MPedestalPix : public MParContainer
-{
-private:
-
-  Float_t fPedestal;     // mean value of pedestal (PMT offset)
-  Float_t fPedestalRms;  // root mean square / sigma  / standard deviation of pedestal
-  
-public:
-  MPedestalPix();
-  
-  void Clear(Option_t *o="");
-  
-  // Using histograms
-  void InitUseHists();
-  
-    // Setters
-  void SetPedestal(const Float_t f)    { fPedestal = f; }
-  void SetPedestalRms(const Float_t f) { fPedestalRms = f; }
-  
-  void Set(const Float_t m, const Float_t r);
-  
-  // Getters
-  Float_t GetPedestal()    const { return fPedestal; }
-  Float_t GetPedestalRms() const { return fPedestalRms; }
-  
-  Bool_t IsValid()         const;
-
-  ClassDef(MPedestalPix, 1)	// Storage Container for Pedestal information of one pixel
-};
-
-#endif
-
Index: /trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc
===================================================================
--- /trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc	(revision 3803)
+++ /trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc	(revision 3804)
@@ -382,7 +382,6 @@
   
   fPedestals->SetTotalEntries(fNumSamplesTot);
+  fPedestals->SetReadyToSave();
 
   return kTRUE;
 }
-
-
