diff --git a/MQ/source/CMakeLists.txt b/MQ/source/CMakeLists.txt
index db521f12b989386699e5ff53f011fe505110d868..63bbfa08ee58ee4f1771bafcb0fd28a57b7c3c61 100644
--- a/MQ/source/CMakeLists.txt
+++ b/MQ/source/CMakeLists.txt
@@ -13,7 +13,6 @@ set(INCLUDE_DIRECTORIES
     ${CBMDATA_DIR}/much
     ${CBMDATA_DIR}/trd
     ${CBMDATA_DIR}/tof
-#    ${CBMDATA_DIR}/ecal
     ${CBMDATA_DIR}/psd
 )
 
diff --git a/core/data/CMakeLists.txt b/core/data/CMakeLists.txt
index 8cfe696a525415962016e5f8bc9d3bf304cfb9e5..6babfa6053faf405582127de3db115bb26161b1c 100644
--- a/core/data/CMakeLists.txt
+++ b/core/data/CMakeLists.txt
@@ -12,7 +12,6 @@ set(INCLUDE_DIRECTORIES
   ${CMAKE_CURRENT_SOURCE_DIR}/trd
   ${CMAKE_CURRENT_SOURCE_DIR}/tof
   ${CMAKE_CURRENT_SOURCE_DIR}/rich
-#  ${CMAKE_CURRENT_SOURCE_DIR}/ecal
   ${CMAKE_CURRENT_SOURCE_DIR}/psd
   ${CMAKE_CURRENT_SOURCE_DIR}/global
 )
@@ -103,16 +102,6 @@ set(SRCS
   tof/CbmTofTracklet.cxx
   tof/CbmTofTrackletParam.cxx
 
-#  ecal/CbmEcalHit.cxx
-#  ecal/CbmEcalPoint.cxx
-#  ecal/CbmEcalPointLite.cxx
-#  ecal/CbmEcalHitFastMC.cxx
-#  ecal/CbmEcalCell.cxx
-#  ecal/CbmEcalMaximum.cxx
-#  ecal/CbmEcalCluster.cxx
-#  ecal/CbmEcalRecParticle.cxx
-#  ecal/CbmEcalIdParticle.cxx
-
   psd/CbmPsdDigi.cxx
   psd/CbmPsdHit.cxx
   psd/CbmPsdPoint.cxx
@@ -124,19 +113,6 @@ set(SRCS
   global/CbmTofTrack.cxx
   global/CbmTrackParam.cxx
 
-#  beamtime/CbmAuxDigi.cxx
-#  beamtime/CbmTbEvent.cxx
-#  beamtime/fhodo/CbmFiberHodoDigi.cxx
-#  beamtime/fhodo/CbmFiberHodoCluster.cxx
-#  beamtime/fhodo/CbmFiberHodoAddress.cxx
-
-#  raw/CbmRawMessage.cxx
-#  raw/CbmSpadicRawMessage.cxx
-#  raw/CbmTrdRawMessage.cxx
-#  raw/CbmNxyterRawMessage.cxx
-#  raw/CbmNxyterRawSyncMessage.cxx
-#  raw/CbmStsxyterRawHitMessage.cxx
-#  raw/CbmTrbRawMessage.cxx
   raw/StsXyterMessage.cxx
   raw/gDpbMessv100.cxx
   raw/TimesliceMetaData.cxx
diff --git a/core/data/DataLinkDef.h b/core/data/DataLinkDef.h
index 5f3eb421722e1a640b465719e7e584edeb51b766..caed293024aeaa4a939d8fc3cb5282a9dede7e10 100644
--- a/core/data/DataLinkDef.h
+++ b/core/data/DataLinkDef.h
@@ -76,18 +76,6 @@
 #pragma link C++ class CbmTofTracklet+;
 #pragma link C++ class CbmTofTrackletParam+;
 
-/*
-#pragma link C++ class CbmEcalPoint+;
-#pragma link C++ class CbmEcalHit+;
-#pragma link C++ class CbmEcalHitFastMC+;
-#pragma link C++ class CbmEcalPointLite+;
-#pragma link C++ class CbmEcalCell+;
-#pragma link C++ class CbmEcalMaximum+;
-#pragma link C++ class CbmEcalCluster+;
-#pragma link C++ class CbmEcalRecParticle+;
-#pragma link C++ class CbmEcalIdParticle+;
-*/
-
 #pragma link C++ class CbmPsdDigi;
 #pragma link C++ class CbmPsdHit;
 #pragma link C++ class CbmPsdPoint+;
@@ -98,15 +86,6 @@
 #pragma link C++ class CbmTofTrack+;
 #pragma link C++ class CbmVertex+;
 
-/*
-#pragma link C++ class CbmRawMessage;
-#pragma link C++ class CbmSpadicRawMessage;
-#pragma link C++ class CbmTrdRawMessage;
-#pragma link C++ class CbmNxyterRawMessage;
-#pragma link C++ class CbmNxyterRawSyncMessage;
-#pragma link C++ class CbmStsxyterRawHitMessage;
-#pragma link C++ class CbmTrbRawMessage;
-*/
 #pragma link C++ class stsxyter::Message;
 #pragma link C++ class gdpbv100::Message;
 #pragma link C++ class gdpbv100::FullMessage;
diff --git a/core/data/ecal/CbmEcalCell.cxx b/core/data/ecal/CbmEcalCell.cxx
deleted file mode 100644
index 77c5a4daf97e46a838c9d2618e2caf01179f3d73..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalCell.cxx
+++ /dev/null
@@ -1,84 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalCell source file                      -----
-// -----                  Created  27/01/06  by M.Prokudin             -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalCell.cxx
- *@author Mikhail Prokudin
- **
- ** ECAL cell structure, a part of ECAL module
- **/
-
-/* $Id: CbmEcalCell.cxx,v 1.6 2006/07/19 09:33:34 prokudin Exp $ */
-
-/* History of cvs commits:
- *
- * $Log: CbmEcalCell.cxx,v $
- * Revision 1.6  2006/07/19 09:33:34  prokudin
- * Modifing for CbmEcalPhotonCalibrator
- *
- * Revision 1.5  2006/06/30 06:17:17  kharlov
- * Optimization, commenting
- *
- * Revision 1.4  2006/04/02 16:55:23  kharlov
- * Merging full and fast MC
- *
- * Revision 1.3  2006/02/03 14:53:40  kharlov
- * CbmEcalAnalysisDS.cxx
- *
- * Revision 1.2  2006/01/31 17:07:17  kharlov
- * Correction for CbmEcalv1
- *
- * Revision 1.1  2006/01/27 17:26:29  kharlov
- * First adaptation of ECAL detailed geometry to cbmroot2
- *
- */
-
-#include "CbmEcalCell.h"
-
-#include <algorithm>
-
-using std::map;
-using std::list;
-
-//-----------------------------------------------------------------------------
-Int_t CbmEcalCell::CountNeighbors(const std::list<CbmEcalCell*>& lst) const
-{
-  Int_t c=0;
-  list<CbmEcalCell*>::const_iterator p=lst.begin();
-  for(;p!=lst.end();++p)
-    if (find(fNeighbors[0].begin(), fNeighbors[0].end(), *p)!=fNeighbors[0].end())
-      ++c;
-
-  return c;
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalCell::GetClusterEnergy(Int_t code, Float_t& EcalEnergy)
-{
-  EcalEnergy=-1;
-  if (code>4||code<0)
-    return;
-  EcalEnergy=GetEnergy();
-  list<CbmEcalCell*>::const_iterator p;
-  for(p=fNeighbors[code].begin();p!=fNeighbors[code].end();++p)
-  {
-    EcalEnergy+=(*p)->GetEnergy();
-  }
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalCell::IvansProcedure(Float_t &clusterE, Float_t &ivansE, Float_t &shape)
-{
-  Float_t e;
-  GetClusterEnergy(0,e);
-  clusterE=e;
-  ivansE=0;
-  for(Int_t i=1;i<5;i++)
-  {
-    GetClusterEnergy(i,e);
-    if (e>ivansE) ivansE=e;
-  }
-  shape=ivansE/clusterE;
-}
-
diff --git a/core/data/ecal/CbmEcalCell.h b/core/data/ecal/CbmEcalCell.h
deleted file mode 100644
index aa4cde147b8506eccbeb672885e410e37105ca39..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalCell.h
+++ /dev/null
@@ -1,150 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalCell header file                      -----
-// -----                  Created  27/01/06  by M.Prokudin             -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalCell.h
- *@author Mikhail Prokudin
- **
- ** ECAL cell structure, a part of ECAL module
- **/
-
-#ifndef CBMECALCELL_H
-#define CBMECALCELL_H
-
-/* $Id: CbmEcalCell.h,v 1.9 2006/09/12 18:15:23 prokudin Exp $ */
-
-/* History of cvs commits:
- *
- * $Log: CbmEcalCell.h,v $
- * Revision 1.9  2006/09/12 18:15:23  prokudin
- * GetType moved to CbmEcalCell
- *
- * Revision 1.8  2006/07/19 11:49:39  prokudin
- * Commenting, optimizing hitproducer
- *
- * Revision 1.7  2006/07/19 09:33:34  prokudin
- * Modifing for CbmEcalPhotonCalibrator
- *
- * Revision 1.6  2006/07/13 14:46:00  prokudin
- * New version of hit producer
- *
- * Revision 1.5  2006/06/30 06:17:17  kharlov
- * Optimization, commenting
- *
- * Revision 1.4  2006/04/02 16:55:23  kharlov
- * Merging full and fast MC
- *
- * Revision 1.3  2006/02/03 14:53:40  kharlov
- * CbmEcalAnalysisDS.cxx
- *
- * Revision 1.2  2006/01/31 17:07:17  kharlov
- * Correction for CbmEcalv1
- *
- * Revision 1.1  2006/01/27 17:26:29  kharlov
- * First adaptation of ECAL detailed geometry to cbmroot2
- *
- */
-
-#include "TObject.h"
-
-#include <list>
-#include <map>
-#include <algorithm>
-
-class CbmEcalCell : public TObject
-{
-public:
-  CbmEcalCell(Int_t cellnumber, Float_t x1=0, Float_t y1=0, Float_t x2=0, Float_t y2=0, Char_t type=0, Float_t energy=0) 
-    : TObject(), fNumber(cellnumber), fX1(x1), fY1(y1), fX2(x2),
-    fY2(y2), fType(type), fEnergy(energy), fADC(-1111), fNeighbors(), fTime(-1111)
-  {};
-
-  inline Bool_t IsInside(Float_t x, Float_t y) {return x>GetX1()&&x<GetX2()&&y>GetY1()&&y<GetY2();}
-  //getters
-  inline Char_t GetType() const {return fType;}
-  inline Float_t X1() const {return fX1;}
-  inline Float_t Y1() const {return fY1;}
-  inline Float_t X2() const {return fX2;}
-  inline Float_t Y2() const {return fY2;}
-  inline Float_t GetX1() const {return fX1;}
-  inline Float_t GetY1() const {return fY1;}
-  inline Float_t GetX2() const {return fX2;}
-  inline Float_t GetY2() const {return fY2;}
-  inline Float_t GetCenterX() const {return (fX1+fX2)/2.0;}
-  inline Float_t GetCenterY() const {return (fY1+fY2)/2.0;}
-  inline Short_t ADC() const {return fADC;}
-  inline Short_t GetADC() const {return fADC;}
-
-  inline Int_t   GetCellNumber() const {return fNumber;}
-	
-  inline Float_t GetEnergy() const {return fEnergy;}
-  inline Float_t GetTotalEnergy() const {return fEnergy;}	//Dummy: better use GetEnergy
-  Float_t GetTime() const {return fTime;}
-  void SetTime(Float_t time) {fTime=time;}
-	
-  inline void GetNeighborsList(Int_t num, std::list<CbmEcalCell*> &neib) const
-  {
-    if (num<0||num>4) return;
-    neib=fNeighbors[num];
-  }
-  inline void SetNeighborsList(Int_t num, std::list<CbmEcalCell*> &neib)
-  {
-    if (num<0||num>4) return;
-    fNeighbors[num]=neib;
-  }
-  inline void SetEnergy(Float_t energy) {fEnergy=energy;}
-  inline void SetADC(Short_t adc) {fADC=adc;}
-  /** Reset all energies in cell **/
-  void ResetEnergyFast();
-  inline void AddEnergy(Float_t energy) {fEnergy+=energy;}
-	
-  // code=0 for "3x3" cluster
-  // code=1-4 for other clusters for Ivan's procedure
-  void GetClusterEnergy(Int_t code, Float_t& EcalEnergy);
-
-  /** Get 2x2 subcluster with maximum energy deposition of 3x3 cluster**/
-  void IvansProcedure(Float_t &clusterE, Float_t &ivansE, Float_t &shape);
-  void TrackIvansProcedure(Int_t /*num*/, Float_t & /*clusterE*/, Float_t & /*ivansE*/, Float_t & /*shape*/) {};
-
-  inline void SetCoord(Float_t x1, Float_t y1, Float_t x2, Float_t y2)
-    { fX1=x1; fY1=y1; fX2=x2; fY2=y2; }
-  inline void SetType(Char_t type) {fType=type;}
-  /** returns number of neighbors in lst with cell **/
-  Int_t CountNeighbors(const std::list<CbmEcalCell*>& lst) const; 
-private:
-  /**  cell number within the module **/
-  Int_t fNumber;
-  /** left edge of the cell **/
-  Float_t fX1;
-  /** bottom edge of the cell **/
-  Float_t fY1;
-  /** right edge of the cell **/
-  Float_t fX2;
-  /** upper edge of the cell **/
-  Float_t fY2;
-  /** type of cell **/
-  Char_t fType;
-  /** energy in the calorimeter cell **/
-  Float_t fEnergy;
-  /** ADC counts read **/
-  Short_t fADC;
-
-
-  /** list of neighbor cells **/
-  std::list<CbmEcalCell*> fNeighbors[5];
-
-  /** Time of cell to fire **/
-  Double_t fTime;
-
-  ClassDef(CbmEcalCell,1);
-};
-  
-inline void CbmEcalCell::ResetEnergyFast()
-{
-  fEnergy=0;
-  fADC=-1111;
-  fTime=-1111;
-}
-
-#endif
diff --git a/core/data/ecal/CbmEcalCluster.cxx b/core/data/ecal/CbmEcalCluster.cxx
deleted file mode 100644
index c405475ea23f9f00811c66b5543e696446facd60..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalCluster.cxx
+++ /dev/null
@@ -1,231 +0,0 @@
-#include "CbmEcalCluster.h"
-
-#include "CbmEcalCell.h"
-#include "CbmEcalMaximum.h"
-
-#include "TMath.h"
-
-#include <algorithm>
-#include <iostream>
-
-using namespace std;
-
-/** An empty constructor **/
-CbmEcalCluster::CbmEcalCluster()
-  : TObject(),
-    fNum(0),
-    fSize(0),
-    fMaxs(0),
-    fEnergy(0.),
-    fType(0.),
-    fMoment(0.),
-    fMomentX(0.),
-    fMomentY(0.),
-    fX(0.),
-    fY(0.),
-    fChi2(0.),
-    fCellNums(),
-    fPeakNums(),
-    fPreEnergy(),
-    fMaximums(nullptr)
-{
-}
-
-/** A standart constructor **/
-CbmEcalCluster::CbmEcalCluster(Int_t num, const std::list<CbmEcalCell*>& cluster)
-  : TObject(),
-    fNum(num),
-    fSize(0),
-    fMaxs(0),
-    fEnergy(0.),
-    fType(0.),
-    fMoment(0.),
-    fMomentX(0.),
-    fMomentY(0.),
-    fX(0.),
-    fY(0.),
-    fChi2(0.),
-    fCellNums(),
-    fPeakNums(),
-    fPreEnergy(),
-    fMaximums(nullptr)
-{
-  std::list<CbmEcalCell*> cls;
-
-  fMaximums=nullptr;
-  cls.clear();
-  list<CbmEcalCell*>::const_iterator p=cluster.begin();
-  for(;p!=cluster.end();++p)
-    cls.push_back(*p);
-  Init(cls);
-}
-
-/** A more advanced constructor. Should use this. **/
-CbmEcalCluster::CbmEcalCluster(Int_t num, const std::list<CbmEcalCell*>& cluster, const std::list<CbmEcalMaximum*>& maximums, const std::list<Double_t>& energy)
-  : TObject(),
-    fNum(num),
-    fSize(0),
-    fMaxs(0),
-    fEnergy(0.),
-    fType(0.),
-    fMoment(0.),
-    fMomentX(0.),
-    fMomentY(0.),
-    fX(0.),
-    fY(0.),
-    fChi2(0.),
-    fCellNums(),
-    fPeakNums(),
-    fPreEnergy(),
-    fMaximums(nullptr)
-{
-  if (maximums.size()!=energy.size())
-  {
-    Fatal("CbmEcalCluster","Sizes of maximums and energy lists are different.");
-    return;
-  }
-  
-  std::list<CbmEcalCell*> cls;
-  list<CbmEcalCell*>::const_iterator p=cluster.begin();
-  list<CbmEcalMaximum*>::const_iterator pm;
-  list<Double_t>::const_iterator pd;
-  Double_t e;
-  Double_t x;
-  Double_t y;
-//  Double_t r;
-  Int_t i;
-
-  fMaxs=maximums.size();
-  fEnergy=0;
-  fType=0;
-  fX=0;
-  fY=0;
-  for(;p!=cluster.end();++p)
-  {
-    cls.push_back(*p);
-    e=(*p)->GetTotalEnergy();
-    x=(*p)->GetCenterX();
-    y=(*p)->GetCenterY();
-    fX+=x*e; fY+=y*e;
-    fEnergy+=e;
-    fType+=(*p)->GetType();
-  }
-  fSize=cls.size();
-
-  cls.sort(CbmEcalClusterSortProcess());
-  cls.reverse();
-  fType/=fSize;
-  fX/=fEnergy;
-  fY/=fEnergy;
-  fChi2=-1111.0;
-
-  fCellNums.Set(fSize);
-  fPeakNums.Set(fMaxs);
-  fPreEnergy.Set(fMaxs);
-
-  fMomentX=0; fMomentY=0; fMoment=0;
-  for(p=cls.begin();p!=cls.end();++p)
-  {
-    /** Still not clear about next 3 variables **/
-    e=(*p)->GetTotalEnergy();
-    x=fX-(*p)->GetCenterX(); x*=x;
-    y=fY-(*p)->GetCenterY(); y*=y;
-    fMomentX+=x*e; fMomentY+=y*e; fMoment+=(x+y)*e;
-  }
-  fMomentX/=fEnergy; fMomentY/=fEnergy; fMoment/=fEnergy;
-
-  i=0;
-  for(p=cls.begin();p!=cls.end();++p)
-    fCellNums[i++]=(*p)->GetCellNumber();
-  i=0; pd=energy.begin();
-  fMaximums=new CbmEcalMaximum*[fMaxs];
-  for(pm=maximums.begin();pm!=maximums.end();++pm)
-  {
-    fPreEnergy[i]=(*pd); ++pd;
-    fMaximums[i]=(*pm);
-    fPeakNums[i++]=(*pm)->Cell()->GetCellNumber();
-  }
-}
-/** An virtual destructor **/
-CbmEcalCluster::~CbmEcalCluster()
-{
-  delete [] fMaximums;
-}
-
-/** An initialization **/
-void CbmEcalCluster::Init(std::list<CbmEcalCell*>& fCells)
-{
-  list<CbmEcalCell*>::const_iterator p1;
-  list<CbmEcalCell*> neib;
-  list<CbmEcalCell*> fPeaks;
-  Double_t e;
-  Double_t x;
-  Double_t y;
-  Double_t r;
-  Double_t ar=0;
-  Double_t tx=0;
-  Double_t ty=0;
-  Double_t tr=0;
-  Int_t i;
-
-  fCells.sort(CbmEcalClusterSortProcess());
-  fCells.reverse();
-  list<CbmEcalCell*>::const_iterator p=fCells.begin();
-  fEnergy=0;
-  fX=0;
-  fY=0;
-  fType=0;
-
-  fSize=fCells.size();
-  fPeaks.clear();
-  for(;p!=fCells.end();++p)
-  {
-    e=(*p)->GetTotalEnergy();
-    fEnergy+=e;
-    x=(*p)->GetCenterX(); y=(*p)->GetCenterY();
-    fX+=e*x; x*=x; tx+=e*x;
-    fY+=e*y; y*=y; ty+=e*y;
-    r=TMath::Sqrt(x+y);
-    ar+=e*r; tr+=e*(x+y);
-    fType+=(*p)->GetType();
-    neib.clear();
-    (*p)->GetNeighborsList(0, neib);
-    for(p1=neib.begin(); p1!=neib.end();++p1)
-      if ((*p1)->GetTotalEnergy()>e) break;
-    if (p1!=neib.end()) continue;
-    for(p1=neib.begin(); p1!=neib.end();++p1)
-      if (find(fPeaks.begin(), fPeaks.end(), *p1)!=fPeaks.end()) break;
-    if (p1!=neib.end()) continue;
-    fPeaks.push_back(*p);
-  }
-  fX/=fEnergy;
-  fY/=fEnergy;
-  fType/=fSize;
-  fMaxs=fPeaks.size();
-  fChi2=-1111;
-  fMomentX=0; fMomentY=0; fMoment=0;
-  for(p=fCells.begin();p!=fCells.end();++p)
-  {
-    /** Still not clear about next 3 variables **/
-    e=(*p)->GetTotalEnergy();
-    x=fX-(*p)->GetCenterX(); x*=x;
-    y=fY-(*p)->GetCenterY(); y*=y;
-    fMomentX+=x*e; fMomentY+=y*e; fMoment+=(x+y)*e;
-  }
-  fMomentX/=fEnergy; fMomentY/=fEnergy; fMoment/=fEnergy;
-  fCellNums.Set(fSize);
-  fPeakNums.Set(fMaxs);
-  fPreEnergy.Set(fMaxs);
-  i=0;
-  for(p=fCells.begin();p!=fCells.end();++p)
-    fCellNums[i++]=(*p)->GetCellNumber();
-  i=0;
-  for(p=fPeaks.begin();p!=fPeaks.end();++p)
-  {
-    fPreEnergy[i]=-1111.0;
-    fPeakNums[i++]=(*p)->GetCellNumber();
-  }
-  fMaximums=nullptr;
-}
-
-ClassImp(CbmEcalCluster)
diff --git a/core/data/ecal/CbmEcalCluster.h b/core/data/ecal/CbmEcalCluster.h
deleted file mode 100644
index 7835eb8271780d0a80c0295689bc90e0d59fc920..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalCluster.h
+++ /dev/null
@@ -1,109 +0,0 @@
-#ifndef CBMECALCLUSTER_H
-#define CBMECALCLUSTER_H
-
-#include "TObject.h"
-#include "TArrayI.h"
-#include "TArrayD.h"
-#include <list>
-
-#include "CbmEcalCell.h"
-
-class CbmEcalRecParticle;
-class CbmEcalMaximum;
-
-struct CbmEcalClusterSortProcess : public std::binary_function<CbmEcalCell*, CbmEcalCell*, Bool_t>
-{
-  inline Bool_t operator()(const CbmEcalCell* left, const CbmEcalCell* right) const
-  {
-    if (left->GetTotalEnergy()<right->GetTotalEnergy())
-      return kTRUE;
-    return kFALSE;
-  }
-};
-
-/** A temporary cluster needed for debugging of cluster finder procedure **/
-class CbmEcalCluster : public TObject
-{
-friend class CbmEcalReco;
-friend class CbmEcalReco2;
-friend class CbmEcalRecoCorr;
-friend class CbmEcalClusterFinder;
-friend class CbmEcalClusterFinderV2;
-public:
-  /** An empty constructor **/
-  CbmEcalCluster();
-  /** A standard constructor **/ 
-  CbmEcalCluster(Int_t num, const std::list<CbmEcalCell*>& cluster);
-  /** A more advanced constructor. Should use this. **/
-  CbmEcalCluster(Int_t num, const std::list<CbmEcalCell*>& cluster, const std::list<CbmEcalMaximum*>& maximums, const std::list<Double_t>& energy);
-  /** Number of cluster in event **/
-  inline Int_t Number() const {return fNum;}
-  /** Size of cluster **/
-  inline Int_t Size() const {return fSize;}
-  /** Number of maximums in cluster **/
-  inline Int_t Maxs() const {return fMaxs;}
-  /** Energy of cluster **/
-  inline Double_t Energy() const {return fEnergy;}
-  /** Average type of cells in cluster **/
-  inline Double_t Type() const {return fType;}
-  /** Second moment **/
-  inline Double_t Moment() const {return fMoment;}
-  /** Moment over X axis **/
-  inline Double_t MomentX() const {return fMomentX;}
-  /** Moment over Y axis **/
-  inline Double_t MomentY() const {return fMomentY;}
-  /** Coordinates of cluster centre of gravity **/
-  inline Double_t X() const {return fX;}
-  inline Double_t Y() const {return fY;}
-  /** \chi^2 of cluster after fitting **/
-  inline Double_t Chi2() const {return fChi2;}
-
-  /** Getters for cells and peaks **/
-  inline Int_t CellNum(Int_t i) const {return fCellNums[i];}
-  inline Int_t PeakNum(Int_t i) const {return fPeakNums[i];}
-  inline Double_t PreEnergy(Int_t i) const {return fPreEnergy[i];}
-  inline CbmEcalMaximum* Maximum(Int_t i) const {return fMaximums[i];}
-  /** An virtual destructor **/
-  virtual ~CbmEcalCluster();
-private:
-  /** An initialization **/
-  void Init(std::list<CbmEcalCell*>& cls);
-  /** Cluster number **/
-  Int_t fNum;
-  /** Cluster size in cells
-   ** A separate variable. fCells not stored **/
-  Int_t fSize;
-  /** Number of maximums in cluster **/
-  Int_t fMaxs;
-  /** Energy of cluster **/
-  Double_t fEnergy;
-  /** Type is an average of type of cells in cluster **/
-  Double_t fType;
-  /** Second moment **/
-  Double_t fMoment;
-  /** Moment over X axis **/
-  Double_t fMomentX;
-  /** Moment over Y axis **/
-  Double_t fMomentY;
-  /** Coordinates of cluster centre of gravity **/
-  Double_t fX;
-  Double_t fY;
-  /** \chi^2 after fitting **/
-  Double_t fChi2;
-  
-  /** Serial numbers of cells in cluster **/
-  TArrayI fCellNums;
-  /** Serial numbers of peaks in cluster **/
-  TArrayI fPeakNums;
-  /** An energy deposition in peak areas  (preclusters)  **/
-  TArrayD fPreEnergy;
-  /** Serial numbers of maximums in system **/
-  CbmEcalMaximum** fMaximums;		//!
-
-  CbmEcalCluster(const CbmEcalCluster&);
-  CbmEcalCluster& operator=(const CbmEcalCluster&);
-
-  ClassDef(CbmEcalCluster, 1)
-};
-
-#endif
diff --git a/core/data/ecal/CbmEcalHit.cxx b/core/data/ecal/CbmEcalHit.cxx
deleted file mode 100644
index 6cfa3a403bc4bbc5d2ef6c0ef7b23f7c8192fd8e..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalHit.cxx
+++ /dev/null
@@ -1,40 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                      CbmEcalHit source file                   -----
-// -----               Created 11/03/05  by Yu.Kharlov                 -----
-// -------------------------------------------------------------------------
-
-
-#include "CbmEcalHit.h"
-
-#include "FairLogger.h"
-
-// -----   Default constructor   -------------------------------------------
-CbmEcalHit::CbmEcalHit() 
-  : TObject(), 
-    fEnergy(0.), 
-    fPSEnergy(0.), 
-    fTime(0.), 
-    fTrackId(0), 
-    fDetectorId(0)
-{
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcalHit::~CbmEcalHit() {}
-// -------------------------------------------------------------------------
-
-
-// -----   Public method Print   -------------------------------------------
-void CbmEcalHit::Print(const Option_t* /*opt*/) const {
-  std::stringstream ss;
-  ss << "ECAL hit: cellid=" << GetDetectorId() << ", Energy=" << fEnergy;
-  ss << ", PS Energy=" << fPSEnergy;
-  if (fTrackId>0) ss << ", TrackID= " << fTrackId;
-  LOG(info) << ss.str();
-//  LOG(info) << ", x=" << GetX() << ", y=" << GetY(); 
-}
-// -------------------------------------------------------------------------
-
-ClassImp(CbmEcalHit)
diff --git a/core/data/ecal/CbmEcalHit.h b/core/data/ecal/CbmEcalHit.h
deleted file mode 100644
index c6aeb6a4da610e05ec840c417d39d5629871bf88..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalHit.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                     CbmEcalHit header file                    -----
-// -----               Created 10/03/05  by Yu.Kharlov                 -----
-// -------------------------------------------------------------------------
-
-
-/**  CbmEcalHit.h
- *@author Yu.Kharlov
- **
- ** Hits in ECAL which is an total amplitude per cell
- **/
-
-
-#ifndef CBMECALHIT_H
-#define CBMECALHIT_H
-
-#include "TObject.h"
-
-class CbmEcalHit : public TObject
-{
-public:    
- 
-
-  /** Default constructor **/
-  CbmEcalHit();
-
-  CbmEcalHit(Int_t id, Float_t energy, Float_t psenergy, Int_t trackid, Double32_t time)
-    : TObject(), fEnergy(energy), fPSEnergy(psenergy), fTime(time), fTrackId(trackid), fDetectorId(id)
-  {};
-
-  /** Destructor **/
-  virtual ~CbmEcalHit();    
-  
-  /** Output to screen **/
-  virtual void Print(const Option_t* opt ="") const;
-  
-  /** Modifiers **/
-  virtual void SetEnergy(Double32_t energy) {fEnergy=energy;}
-  virtual void SetPSEnergy(Double32_t psenergy) {fPSEnergy=psenergy;}
-  virtual void SetTime(Double32_t time) {fTime=time;}
-  virtual void SetTrackId(Int_t id) {fTrackId=id;}
-  virtual void SetDetectorId(Int_t id) {fDetectorId=id;}
-  
-  /** Accessors **/
-  virtual Double_t GetEnergy() const {return fEnergy;}
-  virtual Double_t GetPSEnergy() const {return fPSEnergy;}
-  virtual Double_t GetTime() const {return fTime;}
-  virtual Int_t GetTrackId() const {return fTrackId;}
-  virtual Int_t GetDetectorId() const {return fDetectorId;}
-  
-protected:
-
-  Double32_t fEnergy;    // hit amplitude
-  Double32_t fPSEnergy;  // hit amplitude in PS
-  Double32_t fTime;
-  Int_t fTrackId;
-  Int_t fDetectorId;
-
-  ClassDef(CbmEcalHit,1)
-};
-
-#endif //CBMRICHHIT_H
diff --git a/core/data/ecal/CbmEcalHitFastMC.cxx b/core/data/ecal/CbmEcalHitFastMC.cxx
deleted file mode 100644
index e43f9f8a37dbeffe99783f0cc6b4d83680559d01..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalHitFastMC.cxx
+++ /dev/null
@@ -1,57 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                CbmEcalHitFastMC source file                   -----
-// -----               Created 21/06/06  by Yu.Kharlov                 -----
-// -------------------------------------------------------------------------
-
-  /* $Id: CbmEcalHitFastMC.cxx,v 1.1 2006/06/22 06:55:01 kharlov Exp $ */
-
-  /* History of cvs commits:
-   *
-   * $Log: CbmEcalHitFastMC.cxx,v $
-   * Revision 1.1  2006/06/22 06:55:01  kharlov
-   * Newly added classes for Fas-MC hit producer
-   *
-   */
-
-/**  CbmEcalHitFastMC.h
- *@author Yu.Kharlov
- **
- ** ECAL hit which is a photon with the total energy and
- ** coordinate position. To be used in Fast MC.
- **/
-#include "CbmEcalHitFastMC.h"
-
-
-// -----   Default constructor   -------------------------------------------
-CbmEcalHitFastMC::CbmEcalHitFastMC() 
-  : FairHit(),
-    fAmplitude(0.)
-{
-}
-// -------------------------------------------------------------------------
-
-// -----   Constructor   -------------------------------------------
-CbmEcalHitFastMC::CbmEcalHitFastMC(Double_t x, Double_t y, Double_t E)
-  : FairHit(),
-    fAmplitude(E)
-{
-  // Fill position and energy of the hit
-  fX = x;
-  fY = y;
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcalHitFastMC::~CbmEcalHitFastMC(){}
-// -------------------------------------------------------------------------
-
-
-// -----   Public method Print   -------------------------------------------
-void CbmEcalHitFastMC::Print(const Option_t* /*opt*/) const {
-  printf("ECAL hit: (x,y)=(%f.1,%f.1) cm, Amp=%f GeV\n",
-	 fX,fY,fAmplitude);
-}
-// -------------------------------------------------------------------------
-
-ClassImp(CbmEcalHitFastMC)
diff --git a/core/data/ecal/CbmEcalHitFastMC.h b/core/data/ecal/CbmEcalHitFastMC.h
deleted file mode 100644
index f04941e8816451c297148b2d56a4c563aa1fef3d..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalHitFastMC.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// -------------------------------------------------------------------------
-// -----               CbmEcalHitFastMC header file                    -----
-// -----               Created 21/06/06  by Yu.Kharlov                 -----
-// -------------------------------------------------------------------------
-
-  /* $Id: CbmEcalHitFastMC.h,v 1.1 2006/06/22 06:55:01 kharlov Exp $ */
-
-  /* History of cvs commits:
-   *
-   * $Log: CbmEcalHitFastMC.h,v $
-   * Revision 1.1  2006/06/22 06:55:01  kharlov
-   * Newly added classes for Fas-MC hit producer
-   *
-   */
-
-/**  CbmEcalHitFastMC.h
- *@author Yu.Kharlov
- **
- ** ECAL hit which is a photon with the total energy and
- ** coordinate position. To be used in Fast MC.
- **/
-
-#ifndef CBMECALHITFASTMC_H
-#define CBMECALHITFASTMC_H
-
-#include "FairHit.h"
-
-class CbmEcalHitFastMC : public FairHit {
-
-public:    
-  
-  /** Default constructor **/
-  CbmEcalHitFastMC();
-
-  /** Constructor **/
-  CbmEcalHitFastMC(Double_t x, Double_t y, Double_t E);
-
-  /** Destructor **/
-  virtual ~CbmEcalHitFastMC();
-  
-  /** Output to screen **/
-  virtual void Print(const Option_t* opt ="") const;
-  
-  /** Modifiers **/
-  void SetAmplitude(Double_t amp) {fAmplitude = amp;}
-  
-  /** Accessors **/
-  Double_t GetAmplitude() {return fAmplitude;}
-  
-protected:
-
-  Double32_t fAmplitude;    // hit amplitude
-
-  ClassDef(CbmEcalHitFastMC,1)
-};
-
-#endif //CBMRICHHITFASTMC_H
diff --git a/core/data/ecal/CbmEcalIdParticle.cxx b/core/data/ecal/CbmEcalIdParticle.cxx
deleted file mode 100644
index 182a7f3fd50a167533c994abef21b0da159ae901..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalIdParticle.cxx
+++ /dev/null
@@ -1,108 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                   CbmEcalIdParticle source file               -----
-// -----                   Created 2009.03.13 by //Dr.Sys              -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalIdParticle.cxx
- *@author //Dr.Sys
- **
- ** Identified particle in ECAL, characterized by reconstructed 4-momentum
- **/
-
-#include "CbmEcalIdParticle.h"
-#include "CbmEcalCluster.h"
-
-#include <iostream>
-
-using namespace std;
-
-// -----   Default constructor   -------------------------------------------
-CbmEcalIdParticle::CbmEcalIdParticle() 
-  : TObject(), 
-    fX(-1111), 
-    fY(-1111), 
-    fZ(-1111), 
-    fE(-1111), 
-    fPSE(-1111), 
-    fShape(-1111), 
-    fCellNum(-1111), 
-    fTrack(-1111), 
-    fEProb(-1111), 
-    fMCTrack(-1111)
-{
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Standard constructor   ------------------------------------------
-CbmEcalIdParticle::CbmEcalIdParticle(CbmEcalCell* cell,
-                    Double_t x, Double_t y, Double_t z,
-		    Double_t e, Double_t pse, Double_t shape,
-                    Int_t tracknum, Double_t prob, Int_t mctr)
-  : TObject(),
-    fX(x), 
-    fY(y), 
-    fZ(z), 
-    fE(e), 
-    fPSE(pse), 
-    fShape(shape),
-    fCellNum(cell->GetCellNumber()), 
-    fTrack(tracknum), 
-    fEProb(prob), 
-    fMCTrack(mctr)
-{
-}
-// -------------------------------------------------------------------------
-
-// -----   Standard constructor   ------------------------------------------
-CbmEcalIdParticle::CbmEcalIdParticle(Int_t cell,
-                    Double_t x, Double_t y, Double_t z,
-		    Double_t e, Double_t pse, Double_t shape,
-                    Int_t tracknum, Double_t prob, Int_t mctr)
-  : TObject(),
-    fX(x), 
-    fY(y), 
-    fZ(z), 
-    fE(e), 
-    fPSE(pse), 
-    fShape(shape),
-    fCellNum(cell), 
-    fTrack(tracknum), 
-    fEProb(prob), 
-    fMCTrack(mctr)
-{
-}
-// -------------------------------------------------------------------------
-CbmEcalIdParticle::CbmEcalIdParticle(const CbmEcalIdParticle& obj)
-
-  : TObject(obj),
-    fX(obj.fX), 
-    fY(obj.fY), 
-    fZ(obj.fZ), 
-    fE(obj.fE), 
-    fPSE(obj.fPSE), 
-    fShape(obj.fShape),
-    fCellNum(obj.fCellNum), 
-    fTrack(obj.fTrack), 
-    fEProb(obj.fEProb), 
-    fMCTrack(obj.fMCTrack)
-{
-}
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcalIdParticle::~CbmEcalIdParticle()
-{
-  ;
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Public method Print   -------------------------------------------
-void CbmEcalIdParticle::Print(const Option_t* /*opt*/) const {
-  printf("-I- CbmEcalIdParticle: ECAL id particle :(track, E, PSE, Shape) = (%d,%f,%f,%f)\n", fTrack, fE, fPSE, fShape);
-  printf("                                        :(x, y) = (%f,%f)\n", fX, fY);
-}
-// -------------------------------------------------------------------------
-
-
-ClassImp(CbmEcalIdParticle)
diff --git a/core/data/ecal/CbmEcalIdParticle.h b/core/data/ecal/CbmEcalIdParticle.h
deleted file mode 100644
index 4f237b673499099a5b42726d68ba44f4ffb9112a..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalIdParticle.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                 CbmEcalIdParticle header file                 -----
-// -----                 Created 2009.03.13 by //Dr.Sys                -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalIdParticle.h
- *@author //Dr.Sys
- ** Identified particle in ECAL, characterized by reconstructed 4-momentum
- **/
-
-#ifndef CBMECALIDPARTICLE_H
-#define CBMECALIDPARTICLE_H
-
-#include "TObject.h"
-#include "TLorentzVector.h"
-
-
-class CbmEcalCluster;
-class CbmEcalCell;
-
-class CbmEcalIdParticle : public TObject
-{
-public:
-
-  /** Default constructor **/
-  CbmEcalIdParticle();
-
-  /** Constructor with arguments
-   *@param px,py,pz,E  4 components of LorentzVector
-   **/
-  CbmEcalIdParticle(CbmEcalCell* cell,
-                    Double_t x, Double_t y, Double_t z,
-		    Double_t e, Double_t pse, Double_t shape,
-                    Int_t tracknum, Double_t prob, Int_t mctrack=-1111); 
-
-  CbmEcalIdParticle(Int_t cell,
-                    Double_t x, Double_t y, Double_t z,
-		    Double_t e, Double_t pse, Double_t shape,
-                    Int_t tracknum, Double_t prob, Int_t mctrack=-1111); 
-  /** Copy constructor **/
-  CbmEcalIdParticle(const CbmEcalIdParticle& obj);
-
-  /** Destructor **/
-  virtual ~CbmEcalIdParticle();
-
-  /** Accessors **/
-  Double32_t E() const {return fE;}
-  Double32_t PSE() const {return fPSE;}
-  Double32_t Shape() const {return fShape;}
-  Double32_t X() const {return fX;}
-  Double32_t Y() const {return fY;}
-  Double32_t Z() const {return fZ;}
-  Double32_t EProb() const {return fEProb;}// Probability  to be an electron
-  Int_t CellNum() const {return fCellNum;}
-  virtual void Print(const Option_t* opt = "") const;
-
-  Int_t Track() const {return fTrack;}
-  Int_t MCTrack() const {return fMCTrack;}
-  void SetMCTrack(Int_t tr) {fMCTrack=tr;} 
-protected:
-  /** Reconstructed position in calorimeter **/
-  Double32_t fX;
-  Double32_t fY;		
-  Double32_t fZ;
-
-  Double32_t fE;	// E in cluster
-  Double32_t fPSE;	// Energy in PS
-  Double32_t fShape;	// 3x3 Energy/2x2 Energy
-
-  /** A seed for the photon **/
-  Int_t fCellNum;
-  /** A mother track number **/
-  Int_t fTrack;
-
-  Double32_t fEProb;	// Probability of track to be an electron
-
-  /** A mother MC track **/
-  Int_t fMCTrack;
-
-  ClassDef(CbmEcalIdParticle, 2)
-};
-
-#endif
diff --git a/core/data/ecal/CbmEcalMaximum.cxx b/core/data/ecal/CbmEcalMaximum.cxx
deleted file mode 100644
index c5e69538fbe04e501d1fa414b5afa8695192effe..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalMaximum.cxx
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "CbmEcalMaximum.h"
-
-#include "CbmEcalCell.h"
-
-#include "TMath.h"
-
-#include <list>
-
-using namespace std;
-
-CbmEcalMaximum::CbmEcalMaximum(CbmEcalCell* cell, Double_t z)
-  : TObject(), 
-    fCell(cell), 
-    fCX(0.), 
-    fCY(0.), 
-    fX(0.), 
-    fY(0.), 
-    fTanTheta(0.), 
-    fI(0), 
-    fMark(0), 
-    fRegion(0)
-{
-  Double_t me=0;
-  Double_t e;
-  Int_t i;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-
-  fCX=cell->GetCenterX();
-  fCY=cell->GetCenterY();
-  fI=1;
-  for(i=1;i<5;i++)
-  {
-    cell->GetNeighborsList(i, cells);
-    e=0;
-    for(p=cells.begin();p!=cells.end();++p)
-      e+=(*p)->GetTotalEnergy();
-    if (e>me)
-    {
-      fI=i;
-      me=e;
-    }
-  }
-  me+=cell->GetTotalEnergy();
-  fX=cell->GetTotalEnergy()*fCX;
-  fY=cell->GetTotalEnergy()*fCY;
-  cell->GetNeighborsList(fI, cells);
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    fX+=(*p)->GetTotalEnergy()*(*p)->GetCenterX();
-    fY+=(*p)->GetTotalEnergy()*(*p)->GetCenterY();
-  }
-  fX/=me; fY/=me;
-  fTanTheta=TMath::Sqrt(fX*fX+fY*fY)/z;
-  fMark=0;
-  fRegion=-1111;
-}
-
-ClassImp(CbmEcalMaximum)
diff --git a/core/data/ecal/CbmEcalMaximum.h b/core/data/ecal/CbmEcalMaximum.h
deleted file mode 100644
index 2d02dd1b2c6ee2104c97e1c89e8ea56e1a59d4ee..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalMaximum.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef CBMECALMAXIMUM_H
-#define CBMECALMAXIMUM_H
-
-#include "TObject.h"
-
-class CbmEcalCell;
-/** A calorimeter maximum. Used for unification of photon reconstruction and
- ** electron identification procedures **/
-class CbmEcalMaximum : public TObject
-{
-public:
-  /** An emtry constructor **/
-  CbmEcalMaximum() : TObject(), fCell(nullptr), fCX(0.), fCY(0.), fX(0.), fY(0.), 
-    fTanTheta(0.), fI(0), fMark(0), fRegion(0)
-    {};
-  /** Simplest constructor **/
-  CbmEcalMaximum(CbmEcalCell* cell, Double_t z);
-  /** Standard constructor **/
-  CbmEcalMaximum(CbmEcalCell* cell, Double_t cx, Double_t cy, Double_t x, Double_t y, Int_t i);
-  ~CbmEcalMaximum() {};
-
-  CbmEcalCell* Cell() const {return fCell;}
-  Double_t CX() const {return fCX;}
-  Double_t CY() const {return fCY;}
-  Double_t X() const {return fX;}
-  Double_t Y() const {return fY;}
-  Int_t I() const {return fI;}
-  Int_t Mark() const {return fMark;}
-  /** Region is used for calibration **/
-  Int_t Region() const {return fRegion;}
-  Double_t TanTheta() const {return fTanTheta;}
-
-  void SetMark(Int_t mark) {fMark=mark;}
-  void SetRegion(Int_t region) {fRegion=region;}
-  void SetTanTheta(Double_t tantheta) {fTanTheta=tantheta;}
-private:
-  CbmEcalCell* fCell;
-  /** Coordinates of cell **/
-  Double_t fCX;
-  Double_t fCY;
-  /** Coobdinates of center of mass of maximum subcluster **/
-  Double_t fX;
-  Double_t fY;
-  /** Sqrt(fX*fX+fY*fY)/Z_calorimeter**/
-  Double_t fTanTheta;
-  /** Number maximum subcluster **/
-  Int_t fI;
-  /** A mark. Used for maximum exclusion. **/
-  Int_t fMark;
-  /** A calorimeter region **/
-  Int_t fRegion;
-
-
-  CbmEcalMaximum(const CbmEcalMaximum&);
-  CbmEcalMaximum& operator=(const CbmEcalMaximum&);
-
-  ClassDef(CbmEcalMaximum, 1)
-};
-
-inline CbmEcalMaximum::CbmEcalMaximum(CbmEcalCell* cell, Double_t cx, Double_t cy, Double_t x, Double_t y, Int_t i)
-		      : TObject(), fCell(cell), fCX(cx), fCY(cy), fX(x), fY(y), 
-		      fTanTheta(0.), fI(i), fMark(0), fRegion(0)
-{
-  ;
-}
-#endif
-
diff --git a/core/data/ecal/CbmEcalPoint.cxx b/core/data/ecal/CbmEcalPoint.cxx
deleted file mode 100644
index dff6323d2b88b6cc11e21f6d3c6cdac9dfc505d0..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalPoint.cxx
+++ /dev/null
@@ -1,45 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                      CbmEcalPoint source file                 -----
-// -----                   Created 28/07/04  by V. Friese              -----
-// -------------------------------------------------------------------------
-#include "CbmEcalPoint.h"
-
-#include "FairLogger.h"
-
-#include "TVector3.h"
-
-// -----   Default constructor   -------------------------------------------
-CbmEcalPoint::CbmEcalPoint() : FairMCPoint() { }
-// -------------------------------------------------------------------------
-
-
-
-// -----   Standard constructor   ------------------------------------------
-CbmEcalPoint::CbmEcalPoint(Int_t trackID, Int_t detID, TVector3 pos, 
-			   TVector3 mom, Double_t tof, Double_t length, 
-			   Double_t eLoss)
-  : FairMCPoint(trackID, detID, pos, mom, tof, length, eLoss) { }
-// -------------------------------------------------------------------------
-
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcalPoint::~CbmEcalPoint() { }
-// -------------------------------------------------------------------------
-
-
-
-// -----   Public method Print   -------------------------------------------
-void CbmEcalPoint::Print(const Option_t* /*opt*/) const {
-  LOG(info) << "ECAL point for track " << fTrackID 
-            << " in detector " << fDetectorID;
-  LOG(info) << "    Position (" << fX << ", " << fY << ", " << fZ
-            << ") cm";
-  LOG(info) << "    Momentum (" << fPx << ", " << fPy << ", " << fPz
-            << ") GeV";
-  LOG(info) << "    Time " << fTime << " ns,  Length " << fLength 
-            << " cm,  Energy loss " << fELoss*1.0e06 << " keV";
-}
-// -------------------------------------------------------------------------
-
-
-ClassImp(CbmEcalPoint)
diff --git a/core/data/ecal/CbmEcalPoint.h b/core/data/ecal/CbmEcalPoint.h
deleted file mode 100644
index 2e2e218b3d4faa38a618eb36c0854c0e4762db22..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalPoint.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                    CbmEcalPoint header file                   -----
-// -----                 Created 28/07/04  by V. Friese                -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalPoint.h
- *@author V. Friese
- **
- ** Interception of MC track with the plane representing the ECAL.
- **/
-
-
-#ifndef CBMECALPOINT_H
-#define CBMECALPOINT_H 1
-
-
-#include "FairMCPoint.h"
-
-class TVector3;
-
-class CbmEcalPoint : public FairMCPoint
-{
-
- public:
-
-  /** Default constructor **/
-  CbmEcalPoint();
-
-
-  /** Constructor with arguments
-   *@param trackID  Index of MCTrack
-   *@param detID    Detector ID
-   *@param pos      Ccoordinates at entrance to active volume [cm]
-   *@param mom      Momentum of track at entrance [GeV]
-   *@param tof      Time since event start [ns]
-   *@param length   Track length since creation [cm]
-   *@param eLoss    Energy deposit [GeV]
-   **/
-  CbmEcalPoint(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, 
-	       Double_t tof, Double_t length, Double_t eLoss);
-
-
-  /** Copy constructor **/
-  CbmEcalPoint(const CbmEcalPoint& point):FairMCPoint(point) { *this = point; };
-
-
-  /** Destructor **/
-  virtual ~CbmEcalPoint();
-
-
-  /** Output to screen **/
-  virtual void Print(const Option_t* opt) const;
-
-  
-  ClassDef(CbmEcalPoint,1)
-
-};
-
-
-#endif
diff --git a/core/data/ecal/CbmEcalPointLite.cxx b/core/data/ecal/CbmEcalPointLite.cxx
deleted file mode 100644
index c426839f53e84e112efc5bbf139ce4b0bea222ed..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalPointLite.cxx
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "CbmEcalPointLite.h"
-
-#include "FairLogger.h"
-
-void CbmEcalPointLite::Print(const Option_t* /*opt*/) const
-{
-  LOG(info) << "CbmEcalPointLite: DetectorID=" << GetDetectorID() 
-            << ", TrackID=" << GetTrackID() 
-            << ", Eloss=" << GetEnergyLoss() 
-            << ", Time=" << GetTime();
-}
-
-ClassImp(CbmEcalPointLite)
diff --git a/core/data/ecal/CbmEcalPointLite.h b/core/data/ecal/CbmEcalPointLite.h
deleted file mode 100644
index c01282d23382905f53f4688d7bb65ff3a27db78e..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalPointLite.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// CbmEcalPointLite --- stripped MCPoint class for ECAL 
-
-#ifndef CBMECALPOINTLITE_H
-#define CBMECALPOINTLITE_H
-
-#include "FairMCPoint.h"
-
-class CbmEcalPointLite : public FairMCPoint
-{
-public:
-	//Default constuctor
-	CbmEcalPointLite()
-	  : FairMCPoint(-1111, -1111, TVector3(-1111, -1111, -1111), TVector3(-1111, -1111, -1111), -1111, -1111, -1111)
-        {} ;
-
-	CbmEcalPointLite(Int_t trackID, Int_t detID, Double32_t tof, Double32_t eloss, UInt_t EventId=0)
-	  : FairMCPoint(trackID, detID, TVector3(-1111, -1111, -1111), TVector3(-1111, -1111, -1111), tof, -1111, eloss, EventId) 
-	{} ;
-//	  : fTrackID(trackID), fDetectorID(detID), fTime(tof), fELoss(eloss) {};
-/*
-	//Getters
-	Int_t GetTrackID() const	{return fTrackID;}
-	Int_t GetDetectorID() const	{return fDetectorID;}
-	Double32_t GetTime() const	{return fTime;}
-	Double32_t GetEnergyLoss() const{return fELoss;}
-
-	//Setters
-	void SetTrackID(Int_t trackID)		{fTrackID=trackID;}
-	void SetDetectorID(Int_t detID)		{fDetectorID=detID;}
-	void SetTime(Double32_t time)		{fTime=time;}
-	void SetEnergyLoss(Double32_t eloss)	{fELoss=eloss;}
-
-	//Need implementation
-*/
-	virtual void Print(const Option_t*) const;
-
-	virtual ~CbmEcalPointLite() {};
-private:
-//	Int_t fTrackID;		//Index of track
-//	Int_t fDetectorID;	//Number of volume in calorimeter system
-//	Double32_t fTime;	//Time since interaction moment 
-//	Double32_t fELoss;	//Energy deposition in cell
-	ClassDef(CbmEcalPointLite,2)
-};
-
-#endif
-
diff --git a/core/data/ecal/CbmEcalRecParticle.cxx b/core/data/ecal/CbmEcalRecParticle.cxx
deleted file mode 100644
index 18d3afc7500b8ffe1c20bf838c92463826387a02..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalRecParticle.cxx
+++ /dev/null
@@ -1,135 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                   CbmEcalRecParticle source file              -----
-// -----                   Created 04/07/05  by Yu.Kharlov             -----
-// -------------------------------------------------------------------------
-
-  /* $Id: CbmEcalRecParticle.cxx,v 1.1 2006/06/22 14:02:17 kharlov Exp $ */
-
-  /* History of cvs commits:
-   *
-   * $Log: CbmEcalRecParticle.cxx,v $
-   * Revision 1.1  2006/06/22 14:02:17  kharlov
-   * First upload of reconstruction classes for Full MC
-   *
-   */
-
-/**  CbmEcalRecParticle.cxx
- *@author Yu.Kharlov <Y.Kharlov at gsi.de>
- **
- ** Reconstructed particle in ECAL, characterized by reconstructed 4-momentum
- **/
-
-#include "CbmEcalRecParticle.h"
-#include "CbmEcalCluster.h"
-
-#include "FairLogger.h"
-
-// -----   Default constructor   -------------------------------------------
-CbmEcalRecParticle::CbmEcalRecParticle() 
-  : TObject(),
-    fPx(0), 
-    fPy(0),
-    fPz(0), 
-    fE(0), 
-    fX(-1111), 
-    fY(-1111), 
-    fZ(-1111), 
-    fId(0), 
-    fChi2(-1111), 
-    fType(0), 
-    fClusterNum(-1111),
-    fCellNum(-1111),
-    fMCTrack(-1111),
-    fTime(-1111)
-{
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Standard constructor   ------------------------------------------
-CbmEcalRecParticle::CbmEcalRecParticle(Double_t px, Double_t py, 
-				       Double_t pz, Double_t e,
-				       Double_t x, Double_t y, Double_t z, 
-				       Int_t id, Double_t ch2, CbmEcalCluster* cluster,
-				       CbmEcalCell* cell, Int_t type)
-  : TObject(),
-    fPx(px),
-    fPy(py),
-    fPz(pz),
-    fE(e), 
-    fX(x), 
-    fY(y), 
-    fZ(z), 
-    fId(id), 
-    fChi2(ch2), 
-    fType(type), 
-    fClusterNum(cluster->Number()), 
-    fCellNum(cell->GetCellNumber()),
-    fMCTrack(-1111),
-    fTime(-1111)
-{
-}
-// -------------------------------------------------------------------------
-
-// -----   Standard constructor   ------------------------------------------
-CbmEcalRecParticle::CbmEcalRecParticle(Int_t clnum, Int_t cellnum, Double_t px, Double_t py, 
-				       Double_t pz, Double_t e,
-				       Double_t x, Double_t y, Double_t z, 
-				       Int_t id, Double_t ch2, Int_t type)
-  : TObject(), 
-    fPx(px),
-    fPy(py),
-    fPz(pz),
-    fE(e), 
-    fX(x), 
-    fY(y), 
-    fZ(z), 
-    fId(id), 
-    fChi2(ch2), 
-    fType(type), 
-    fClusterNum(clnum), 
-    fCellNum(cellnum),
-    fMCTrack(-1111),
-    fTime(-1111)
-{
-}
-// -------------------------------------------------------------------------
-CbmEcalRecParticle::CbmEcalRecParticle(const CbmEcalRecParticle& obj) 
-  : TObject(obj),
-    fPx(obj.fPx),
-    fPy(obj.fPy),
-    fPz(obj.fPz),
-    fE(obj.fE), 
-    fX(obj.fX), 
-    fY(obj.fY), 
-    fZ(obj.fZ), 
-    fId(obj.fId), 
-    fChi2(obj.fChi2), 
-    fType(obj.fType), 
-    fClusterNum(obj.fClusterNum), 
-    fCellNum(obj.fCellNum),
-    fMCTrack(obj.fMCTrack),
-    fTime(obj.fTime)
-{
-}
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcalRecParticle::~CbmEcalRecParticle()
-{
-  ;
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Public method Print   -------------------------------------------
-void CbmEcalRecParticle::Print(const Option_t* /*opt*/) const {
-  LOG(info) << "ECAL rec.particle :(px,py,pz,E) = (" 
-            << fPx << "," 
-            << fPy << "," 
-            << fPz << "," 
-            << fE << ") GeV/n";
-}
-// -------------------------------------------------------------------------
-
-
-ClassImp(CbmEcalRecParticle)
diff --git a/core/data/ecal/CbmEcalRecParticle.h b/core/data/ecal/CbmEcalRecParticle.h
deleted file mode 100644
index dd22293c018dbde932d4581864013802e9bfa3ac..0000000000000000000000000000000000000000
--- a/core/data/ecal/CbmEcalRecParticle.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/** A calorimeter reconstructed particle. Momenta and calorimeter impact point
- ** inside. Chi2 for quality control. TOF information also provided in case
- ** of time measurements with calorimeter.
- ** **/
-#ifndef CBMECALRECPARTICLE_H
-#define CBMECALRECPARTICLE_H
-
-#include "TObject.h"
-#include "TLorentzVector.h"
-
-
-class CbmEcalCluster;
-class CbmEcalCell;
-
-class CbmEcalRecParticle : public TObject
-{
-friend class CbmEcalReco;
-friend class CbmEcalReco2;
-friend class CbmEcalRecoCorr;
-public:
-
-  /** Default constructor **/
-  CbmEcalRecParticle();
-
-  /** Constructor with arguments
-   *@param px,py,pz,E  4 components of LorentzVector
-   **/
-  CbmEcalRecParticle(Double_t px, Double_t py, 
-		     Double_t pz, Double_t e,
-		     Double_t x=-1111, Double_t y=-1111, Double_t z=-1111,
-		     Int_t id=0, Double_t chi2=-1111, CbmEcalCluster* cl=nullptr,
-		     CbmEcalCell* cell=nullptr, Int_t type=0);
-
-  CbmEcalRecParticle(Int_t clnum, Int_t cellnum, Double_t px, Double_t py, 
-		     Double_t pz, Double_t e,
-		     Double_t x=-1111, Double_t y=-1111, Double_t z=-1111,
-		     Int_t id=0, Double_t chi2=-1111, Int_t type=0);
-  /** Copy constructor **/
-  CbmEcalRecParticle(const CbmEcalRecParticle& obj);
-
-  /** Destructor **/
-  virtual ~CbmEcalRecParticle();
-
-  /** Accessors **/
-  TLorentzVector GetMomentum() const {return TLorentzVector(fPx,fPy,fPz,fE);}
-  Double32_t Px() const {return fPx;}
-  Double32_t Py() const {return fPy;}
-  Double32_t Pz() const {return fPz;}
-  Double32_t E() const {return fE;}
-  Double32_t X() const {return fX;}
-  Double32_t Y() const {return fY;}
-  Double32_t Z() const {return fZ;}
-  Double_t Chi2() const {return fChi2;}
-  void SetChi2(Double_t chi2) {fChi2=chi2;}
-  Int_t ClusterNum() const {return fClusterNum;}
-  Int_t CellNum() const {return fCellNum;}
-  Int_t PdgId() const {return fId;}
-  Int_t CellType() const {return fType;}
-  Double_t TOF() const {return fTime;}
-  void SetTOF(Double32_t time) {fTime=time;}
-  /** Output to screen **/
-  virtual void Print(const Option_t* opt = "") const;
-
-  Int_t MCTrack() const {return fMCTrack;}
-  void SetMCTrack(Int_t num) {fMCTrack=num;}
-protected:
-
-  Double32_t fPx;  // px component of momentum 4-vector
-  Double32_t fPy;  // py component of momentum 4-vector
-  Double32_t fPz;  // pz component of momentum 4-vector
-  Double32_t fE;   // E  component of momentum 4-vector
-
-  /** Reconstructed position in calorimeter **/
-  Double32_t fX;
-  Double32_t fY;		
-  Double32_t fZ;
-
-  /** PdgId of the particle **/
-  Int_t fId;
-
-  /** Chi^2 of the cluster **/
-  Double_t fChi2;
-
-  /** Type of cell with maximum energy deposition**/
-  Int_t fType;
-
-  /** Reference to cluster **/
-  Int_t fClusterNum;
-  /** A seed for the photon **/
-  Int_t fCellNum;
-  /** A mother tracks number **/
-  Int_t fMCTrack;
-
-  /** TOF for calorimeter **/
-  Double32_t fTime;
-
-  ClassDef(CbmEcalRecParticle, 2)
-
-};
-
-#endif
diff --git a/ecal/CMakeLists.txt b/ecal/CMakeLists.txt
deleted file mode 100644
index c3875c9b5e60424dd46807b868896cf7a34cf9d3..0000000000000000000000000000000000000000
--- a/ecal/CMakeLists.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-# Create a library called "libEcal" which includes the source files given in
-# the array .
-# The extension is already found.  Any number of sources could be listed here.
-
-Set(INCLUDE_DIRECTORIES
-${CBMBASE_DIR}
-${CBMROOT_SOURCE_DIR}/sim/transport/base
-
-${CBMDATA_DIR}
-${CBMDATA_DIR}/sts 
-${CBMDATA_DIR}/ecal 
-${CBMDATA_DIR}/global
-
-${CBMROOT_SOURCE_DIR}/KF/Interface
-${CBMROOT_SOURCE_DIR}/KF
-
-${CBMROOT_SOURCE_DIR}/ecal
-)
-
-Include_Directories( ${INCLUDE_DIRECTORIES})
-
-Set(SYSTEM_INCLUDE_DIRECTORIES
-  ${BASE_INCLUDE_DIRECTORIES} 
-)
-
-Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
-
-set(LINK_DIRECTORIES
-${ROOT_LIBRARY_DIR}
-${FAIRROOT_LIBRARY_DIR}
-${Boost_LIBRARY_DIRS}
-)
- 
-link_directories( ${LINK_DIRECTORIES})
-
-set(SRCS
-CbmEcal.cxx CbmEcalDetailed.cxx 	
-CbmEcalHitProducer.cxx 
-CbmGeoEcalPar.cxx CbmEcalDrawer.cxx 
-CbmEcalContFact.cxx
-CbmEcalAnalysisDS.cxx CbmEcalAnalysis.cxx 
-CbmEcalModule.cxx CbmEcalStructure.cxx 
-CbmEcalHitProducerFastMC.cxx  CbmEcalCellMC.cxx
-CbmEcalReconstructionFastMC.cxx
-CbmEcalPhotonCalibrator.cxx CbmEcalShowerCalibrator.cxx 
-CbmEcalUrqmdCalibrator.cxx CbmEcalSCurveLib.cxx 
-CbmEcalSCurveLibRecord.cxx CbmEcalOShowerCalibrator.cxx 
-CbmEcalTrackExtrapolation.cxx
-CbmEcalTracking.cxx CbmEcalStructureFiller.cxx
-CbmEcalTrackExport.cxx CbmEcalStructureExport.cxx
-CbmEcalQualityCheck.cxx CbmEcalClusterFinderV2.cxx
-CbmEcalTrackImport.cxx CbmEcalCalibration.cxx
-CbmEcalParam.cxx CbmEcalMatching.cxx
-CbmEcalAnalysisPi0.cxx CbmEcalAnalysisPair.cxx CbmEcalAnalysisMaterial.cxx
-CbmEcalAnalysisNeutron.cxx CbmEcalTimeDigitizer.cxx
-CbmEcalLightMap.cxx CbmEcalDrawer2.cxx
-CbmEcalAnalysisCluster.cxx CbmEcalAnalysisUniformity.cxx
-CbmEcalAnalysisDst.cxx CbmEcalAnalysisBSh.cxx
-CbmEcalCalibrationV2.cxx CbmEcalAnalysisSimple.cxx CbmEcalIdentification.cxx
-CbmEcalMaximumLocator.cxx CbmEcalAnalysisJPsi.cxx
-CbmEcalAnalysisSShape.cxx CbmEcalAnalysisShape.cxx
-CbmEcalShLibRecord.cxx CbmEcalShLib.cxx CbmEcalShLibTable.cxx
-CbmEcalClusterFinder.cxx 
-CbmEcalReco.cxx 
-CbmEcalShLibNN.cxx
-CbmEcalAnalysisEres.cxx CbmEcalPosLib.cxx 
-CbmEcalReco2.cxx
-CbmEcalShLibCorr.cxx CbmEcalShLibCorrTable.cxx
-CbmEcalShLibCorrRecord.cxx 
-CbmEcalRecoCorr.cxx
-CbmEcalDigi.cxx CbmEcalPrepare.cxx CbmEcalAnalysisCalib.cxx
-CbmEcalInf.cxx
-)
-
-set(LINKDEF CbmEcalLinkDef.h)
-Set(LIBRARY_NAME CbmEcal)
-Set(DEPENDENCIES
-    #KF ????
-    CbmBase CbmData Base MLP ASImage Minuit2
-)
-
-GENERATE_LIBRARY()
diff --git a/ecal/CbmEcal.cxx b/ecal/CbmEcal.cxx
deleted file mode 100644
index e28ace7f31764f2f5f368026fe8e97381948c560..0000000000000000000000000000000000000000
--- a/ecal/CbmEcal.cxx
+++ /dev/null
@@ -1,1272 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                       CbmEcal source file                   -----
-// -----                  Created 04/02/05  by Yuri.Kharlov              -----
-// -------------------------------------------------------------------------
-
-/* $Id: CbmEcal.cxx,v 1.26 2006/08/30 13:16:45 prokudin Exp $ */
-
-/* History of cvs commits:
- *
- * $Log: CbmEcal.cxx,v $
- * Revision 1.26  2006/08/30 13:16:45  prokudin
- * Bug huntong
- *
- * Revision 1.25  2006/08/15 19:04:39  prokudin
- * Bug hunting
- *
- * Revision 1.24  2006/08/15 16:18:01  prokudin
- * Bug hunting
- *
- * Revision 1.23  2006/07/29 00:33:53  prokudin
- * Commenting. Bringing code to coding conventions. New way of parameter file processing
- *
- * Revision 1.22  2006/07/26 22:49:23  prokudin
- * Minor bug fixed
- *
- * Revision 1.21  2006/07/24 21:45:02  prokudin
- * Now we write information to parameter file
- *
- * Revision 1.20  2006/07/20 12:44:42  kharlov
- * Switching off TObject streamer for ECAL points and MC tracks
- *
- * Revision 1.19  2006/07/18 17:10:14  kharlov
- * Track position and momentum are put into correct place
- *
- * Revision 1.18  2006/07/18 11:41:21  prokudin
- * Corrected for MCpoints production
- *
- * Revision 1.17  2006/07/17 13:59:06  prokudin
- * fMat1 removed. At last.
- *
- * Revision 1.16  2006/07/15 18:30:09  kharlov
- * Move gMC->TrackPosition and gMC->TrackMomentum to FillWallPoint
- *
- * Revision 1.15  2006/07/14 15:09:18  prokudin
- * New functionality added
- *
- * Revision 1.14  2006/07/13 14:42:16  prokudin
- * GetCellCoord now static
- *
- * Revision 1.13  2006/07/13 10:19:25  prokudin
- * Coordinate calcalation fixed
- *
- * Revision 1.12  2006/07/12 12:04:59  prokudin
- * CbmEcalInf now singleton.
- *
- * Revision 1.11  2006/07/12 08:41:38  prokudin
- * String compare removed. Using FairVolume instead.
- *
- * Revision 1.10  2006/07/04 08:29:24  kharlov
- * Remove #include TGeant3.h
- *
- * Revision 1.9  2006/06/30 13:04:22  kharlov
- * Added a function SetSpecialPhysicsCuts()
- *
- * Revision 1.8  2006/06/30 06:17:17  kharlov
- * Optimization, commenting
- *
- * Revision 1.7  2006/06/28 14:16:00  kharlov
- * Minor polishing
- *
- * Revision 1.6  2006/06/26 14:27:15  kharlov
- * Change storing MCpoints at ECAL face, change the order of medium definition
- *
- * Revision 1.5  2006/06/12 11:59:47  kharlov
- * Passing geometry file name via the constructor argument
- *
- * Revision 1.4  2006/04/25 06:52:17  kharlov
- * Remove CbmEcalv[1,2] and leave the only class CbmEcal
- *
- * Revision 1.6  2006/04/02 16:55:23  kharlov
- * Merging full and fast MC
- *
- * Revision 1.4  2006/03/03 12:01:16  turany
- * Remove FairVolume, framework is responsible for sensitivity
- *
- * Revision 1.3  2006/01/31 17:07:17  kharlov
- * Correction for CbmEcal
- *
- * Revision 1.2  2006/01/27 17:26:30  kharlov
- * First adaptation of ECAL detailed geometry to cbmroot2
- *
- */
-
-/**  CbmEcal.cxx
- *@author Yuri Kharlov
- **
- ** Defines the active detector ECAL with geometry coded here.
- **/
-
-#include "CbmEcal.h"
-
-#include "CbmEcalPoint.h"
-#include "CbmGeoEcalPar.h"
-
-#include "FairGeoInterface.h"
-#include "FairGeoLoader.h"
-#include "FairGeoNode.h"
-#include "FairGeoRootBuilder.h"
-#include "FairRuntimeDb.h"
-#include "FairRootManager.h"
-#include "FairRun.h"
-#include "FairRunAna.h"
-#include "CbmMCTrack.h"
-#include "CbmStack.h"
-#include "FairVolume.h"
-#include "FairGeoMedium.h"
-#include "FairGeoMedia.h"
-
-#include "TClonesArray.h"
-#include "TGeoMCGeometry.h"
-#include "TGeoManager.h"
-#include "TParticle.h"
-#include "TVirtualMC.h"
-#include "TGeoBBox.h"
-#include "TGeoPgon.h"
-#include "TList.h"
-#include "TTree.h"
-
-#include <iostream>
-#include <stdlib.h>
-
-using std::cout;
-using std::endl;
-using std::cerr;
-
-//Defines for debuging
-//#define _DECAL
-//#define _DECALCELL
-#define kN kNumberOfECALSensitiveVolumes
-
-// -----   Default constructor   -------------------------------------------
-CbmEcal::CbmEcal() 
-  : FairDetector("ECAL", kTRUE, kEcal),
-    fInf(NULL),
-    fDebug(NULL),
-    fTrackID(-1),
-    fVolumeID(-1),
-    fPos(),
-    fMom(),
-    fTime(-1.),
-    fLength(-1.),
-    fELoss(-1.),
-    fPosIndex(0),
-    fEcalCollection(new TClonesArray("CbmEcalPoint")),
-    fLiteCollection(new TClonesArray("CbmEcalPointLite")),
-    fEcalSize(),
-    fEcalHole(),
-    fCellSize(0.),
-    fZEcal(0.),
-    fThicknessLead(0.),
-    fThicknessScin(0.),
-    fThicknessTyvk(0.),
-    fThicknessLayer(0.),
-    fNLayers(0),
-    fGeoScale(0.),
-    fNColumns1(0),
-    fNRows1(0),
-    fNColumns2(0),
-    fNRows2(0),
-    fThicknessPSlead(0.),
-    fThicknessPSscin(0.),
-    fEcalPSgap(0.),
-    fNColumns(0),
-    fNRows(0),
-    fVolIdMax(0),
-    fFirstNumber(0),
-    fAbsorber(""),
-    fVolArr()
-{
-  fVerboseLevel = 1;
-
-  Int_t i;
-
-  for(i=kN-1;i>-1;i--)
-    fVolArr[i]=-1111;
-}
-// -------------------------------------------------------------------------
-
-
-
-// -----   Standard constructor   ------------------------------------------
-CbmEcal::CbmEcal(const char* name, Bool_t active, const char* fileGeo)
-  : FairDetector(name, active, kEcal),
-    fInf(NULL),
-    fDebug(NULL),
-    fTrackID(-1),
-    fVolumeID(-1),
-    fPos(),
-    fMom(),
-    fTime(-1.),
-    fLength(-1.),
-    fELoss(-1.),
-    fPosIndex(0),
-    fEcalCollection(NULL),
-    fLiteCollection(NULL),
-    fEcalSize(),
-    fEcalHole(),
-    fCellSize(0.),
-    fZEcal(0.),
-    fThicknessLead(0.),
-    fThicknessScin(0.),
-    fThicknessTyvk(0.),
-    fThicknessLayer(0.),
-    fNLayers(0),
-    fGeoScale(0.),
-    fNColumns1(0),
-    fNRows1(0),
-    fNColumns2(0),
-    fNRows2(0),
-    fThicknessPSlead(0.),
-    fThicknessPSscin(0.),
-    fEcalPSgap(0.),
-    fNColumns(0),
-    fNRows(0),
-    fVolIdMax(0),
-    fFirstNumber(0),
-    fAbsorber(""),
-    fVolArr()
-{
-  /** CbmEcal constructor:
-   ** reads geometry parameters from the ascii file <fileGeo>,
-   ** creates the ECAL geometry container CbmEcalInf
-   ** and initializes basic geometry parameters needed to construct
-   ** TGeo geometry
-   **/
-
-  Int_t i;
-  printf("ECAL geometry is read from file %s\n",fileGeo);
-  fInf=CbmEcalInf::GetInstance(fileGeo);
-  fInf->DumpContainer();
-  if (fInf==NULL)
-  {
-    cerr << "Error. CbmEcal: Can't read geometry from " << fileGeo;
-    cerr << "!!!" << endl;
-  }
-  fGeoScale=1.;
-  fEcalSize[0]=fInf->GetEcalSize(0);
-  fEcalSize[1]=fInf->GetEcalSize(1);
-  fEcalSize[2]=fInf->GetEcalSize(2);
-
-  fEcalHole[0]=fInf->GetEcalHole(0);
-  fEcalHole[1]=fInf->GetEcalHole(1);
-  fEcalHole[2]=fInf->GetEcalHole(2);
-  
-  fCellSize=fInf->GetCellSize();
-  fZEcal=fInf->GetZPos();
-
-  fThicknessLead=fInf->GetLead();
-  fThicknessScin=fInf->GetScin();
-  fThicknessTyvk=fInf->GetTyveec();
-  fNLayers=fInf->GetNLayers();
-
-  fThicknessPSlead=fInf->GetPSLead();
-  fThicknessPSscin=fInf->GetPSScin();
-  fEcalPSgap=fInf->GetPSGap();
-  
-  fNColumns1 = TMath::Nint((fEcalSize[0]/2/fCellSize)*2);
-  fNRows1    = TMath::Nint(((fEcalSize[1]-fEcalHole[1])/4/fCellSize)*2);
-
-  fNColumns2 = TMath::Nint(((fEcalSize[0]-fEcalHole[0])/4/fCellSize)*2);
-  fNRows2    = TMath::Nint((fEcalHole[1]/2/fCellSize)*2);
-
-  fNColumns = TMath::Max(fNColumns1,fNColumns2);
-  fNRows    = TMath::Max(fNRows1,fNRows2);
-  fVolIdMax=fNColumns*fNRows+fNRows+(2*(4-1)+2-1)*fNColumns*fNRows;
-  fPosIndex=0;
-  fDebug="";
-  fEcalCollection=new TClonesArray("CbmEcalPoint");
-  fLiteCollection=NULL;
-  fVerboseLevel = 1;
-  fAbsorber=fInf->GetStringVariable("absorber");
-
-  fInf->AddVariable("ecalversion", "0");
-  for(i=kN-1;i>-1;i--)
-    fVolArr[i]=-1111;
-
-  if (fInf->GetFastMC()==1) return;
-  fLiteCollection=new TClonesArray("CbmEcalPointLite");
-}
-
-/** size in Mb (2^20) **/
-void CbmEcal::SetMaximumFileSize(Long64_t size)
-{
-  TTree::SetMaxTreeSize(size*1024*1024);
-}
-
-// -------------------------------------------------------------------------
-
-void CbmEcal::Initialize()
-{
-  FairDetector::Initialize();
-  FairRun* sim = FairRun::Instance();
-  FairRuntimeDb* rtdb=sim->GetRuntimeDb();
-  CbmGeoEcalPar *par=new CbmGeoEcalPar();
-  fInf->FillGeoPar(par,0);
-  rtdb->addContainer(par);
-}
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcal::~CbmEcal()
-{
-  if (fEcalCollection) {
-    fEcalCollection->Delete(); 
-    delete fEcalCollection;
-    fEcalCollection=NULL;
-  }
-  if (fLiteCollection) {
-    fLiteCollection->Delete();
-    delete fLiteCollection;
-    fLiteCollection=NULL;
-  }
-}
-// -------------------------------------------------------------------------
-
-// -----   Private method SetEcalCuts   ------------------------------------
-void CbmEcal::SetEcalCuts(Int_t medium)
-{
-  /** Set GEANT3 tracking energy cuts for selected medium **/
-  if (fInf->GetElectronCut() > 0) {
-    gMC->Gstpar(medium,"CUTGAM",fInf->GetElectronCut());
-    gMC->Gstpar(medium,"CUTELE",fInf->GetElectronCut());
-    gMC->Gstpar(medium,"BCUTE" ,fInf->GetElectronCut());
-    gMC->Gstpar(medium,"BCUTM" ,fInf->GetElectronCut());
-  }
-
-  if (fInf->GetHadronCut() > 0) {
-    gMC->Gstpar(medium,"CUTNEU",fInf->GetHadronCut());
-    gMC->Gstpar(medium,"CUTHAD",fInf->GetHadronCut());
-    gMC->Gstpar(medium,"CUTMUO",fInf->GetHadronCut());
-    gMC->Gstpar(medium,"PPCUTM",fInf->GetHadronCut());
-  }
-}
-// -------------------------------------------------------------------------
-
-void CbmEcal::FinishPrimary()
-{
-  if (fInf->GetFastMC()==1) return;
-  fFirstNumber=fLiteCollection->GetEntriesFast();
-}
-
-//_____________________________________________________________________________
-void CbmEcal::ChangeHit(CbmEcalPointLite* oldHit)
-{
-  Double_t edep = gMC->Edep();
-  Double_t el=oldHit->GetEnergyLoss();
-  Double_t ttime=gMC->TrackTime()*1.0e9;
-  oldHit->SetEnergyLoss(el+edep);
-  if(ttime<oldHit->GetTime())
-    oldHit->SetTime(ttime);
-}
-
-//_____________________________________________________________________________
-void CbmEcal::SetSpecialPhysicsCuts()
-{
-  /** Change the special tracking cuts for
-   ** two ECAL media, Scintillator and Lead
-   **/
-
-  if (fInf->GetFastMC()==1) return;
-
-  FairRun* fRun = FairRun::Instance();
-  if (strcmp(fRun->GetName(),"TGeant3") == 0) {
-    Int_t mediumID;
-    mediumID = gGeoManager->GetMedium("Scintillator")->GetId();
-    SetEcalCuts(mediumID);
-  if (fInf->GetFastMC()==1) return;
-  if (fInf->GetFastMC()==1) return;
-    mediumID = gGeoManager->GetMedium(fAbsorber)->GetId();
-    SetEcalCuts(mediumID);
-    mediumID = gGeoManager->GetMedium("Tyvek")->GetId();
-    SetEcalCuts(mediumID);
-    mediumID = gGeoManager->GetMedium("SensVacuum")->GetId();
-    SetEcalCuts(mediumID);
-  }
-}
-
-// -----   Public method ProcessHits  --------------------------------------
-Bool_t  CbmEcal::ProcessHits(FairVolume* vol)
-{
-  /** Fill MC point for sensitive ECAL volumes **/
-
-  fELoss   = gMC->Edep();
-  fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
-  fTime    = gMC->TrackTime()*1.0e09;
-  fLength  = gMC->TrackLength();
-
-  Int_t num=GetVolType(vol->getVolumeId());
-  if (num<0)
-  {
-     cout << "-I- CbmEcal: Unknown volume number: " << vol->getVolumeId() << endl;
-     return kFALSE;
-  }
-  if (num!=0) { //not a WALL
-    if (fELoss==0) return kFALSE;
-    if (!FindVolumeID(num) )
-      return kFALSE;
-    if (!FillLitePoint(num) ) return kFALSE;
-  }
-  else
-    if ( gMC->IsTrackEntering() )
-    { // WALL hit
-      FillWallPoint();
-    }
-    else
-      return kFALSE;
-
-  // Increment number of ecal points for TParticle
-
-  ((CbmStack*)gMC->GetStack())->AddPoint(kEcal, fTrackID);
-  
-  ResetParameters();
-  
-  return kTRUE;
-}
-
-/** returns type of volume **/
-Int_t CbmEcal::GetVolType(Int_t volnum)
-{
-	Int_t i;
-	for(i=kN-1;i>-1;i--) {
-	  if (fVolArr[i]==volnum) break;
-	}
-        
-	return i;
-}
-
-//-----------------------------------------------------------------------------
-Bool_t CbmEcal::FindVolumeID(Int_t volnum)
-{
-  /** Find the cell ID for the current step **/
-
-  if (volnum<1||volnum>5) return kFALSE;
-#ifdef _DECALSTEP 
-  Int_t copyNo, copyNo1;
-#endif
-  Int_t copyNo2, copyNo3, copyNo4, copyNo5, copyNo6, copyNo7;
-  
-  Int_t iColumn=0, iRow=0, iEcalBlockCopy=0, iEcalBlock=0;
-  char sEcalBlock[5];
-  
-  static Int_t nColumns = TMath::Max(fNColumns1,fNColumns2);
-  static Int_t nRows    = TMath::Max(fNRows1,fNRows2);
-  
-/*  Bool_t scinCell = strstr(gMC->CurrentVolName(),"ECALscin");
-  Bool_t leadCell = strstr(gMC->CurrentVolName(),"ECALlead");
-  Bool_t tyvkCell = strstr(gMC->CurrentVolName(),"ECALtyvk");
-  Bool_t prshCell = strstr(gMC->CurrentVolName(),"ECALPScell");
-  Bool_t PSScCell = strstr(gMC->CurrentVolName(),"ECALPSscin");*/
-/*  cout << vol->getVolumeId();
-  if (PSScCell) cout << "	PSCell";
-  if (prshCell) cout << "	PSscin";
-  if (scinCell) cout << "	scin";
-  if (tyvkCell) cout << "	tyvk";
-  if (leadCell) cout << "	lead";
-
-  if (num==2) cout << "	PSCell";
-  if (num==1) cout << "	PSscin";
-  if (num==16) cout << "	scin";
-  if (num==8) cout << "	tyvk";
-  if (num==4) cout << "	lead";
-  cout <<  endl;
-  if (!leadCell&&!scinCell&&!tyvkCell&&!prshCell&&!PSScCell) return kFALSE;*/
- 
-#ifdef _DECALSTEP
-  gMC->CurrentVolID(copyNo);
-  gMC->CurrentVolOffID(1, copyNo1); // ECALPScell || ECALtyvk
-  gMC->CurrentVolOffID(2, copyNo2); // ECAL?row || ECALlayer
-  gMC->CurrentVolOffID(3, copyNo3); // ECAL?column || ECALcell
-  gMC->CurrentVolOffID(4, copyNo4);
-#endif
-  gMC->CurrentVolOffID(4, copyNo4);
-  
-  if (volnum==2) {
-    
-    gMC->CurrentVolOffID(2, copyNo2); // ECAL?row || ECALlayer
-    gMC->CurrentVolOffID(3, copyNo3); // ECAL?column || ECALcell
-    iRow = copyNo2;
-    iColumn = copyNo3;
-    iEcalBlockCopy = copyNo4;
-    sscanf(gMC->CurrentVolOffName(4),"%4s%1d",sEcalBlock,&iEcalBlock);
-    
-  }
-  else
-    if (volnum==1) {
-      gMC->CurrentVolOffID(1, copyNo2); // ECAL?row || ECALlayer
-      gMC->CurrentVolOffID(2, copyNo3); // ECAL?column || ECALcell
-      iRow = copyNo2;
-      iColumn = copyNo3;
-      gMC->CurrentVolOffID(3, copyNo4);
-      iEcalBlockCopy = copyNo4;
-      sscanf(gMC->CurrentVolOffName(3),"%4s%1d",sEcalBlock,&iEcalBlock);
-	
-    }
-    else {
-      if (volnum==5) {
-	if (fThicknessTyvk!=0.0) {
-	  gMC->CurrentVolOffID(5, copyNo5); // ECAL? || ECAL?row
-	  gMC->CurrentVolOffID(6, copyNo6);
-	  gMC->CurrentVolOffID(7, copyNo7);
-	}
-	else {
-	  gMC->CurrentVolOffID(4, copyNo5); // ECAL? || ECAL?row
-	  gMC->CurrentVolOffID(5, copyNo6);
-	  gMC->CurrentVolOffID(6, copyNo7);
-	};
-	iRow = copyNo5;
-	iColumn = copyNo6;
-	iEcalBlockCopy = copyNo7;
-	if (fThicknessTyvk!=0.0)
-	  sscanf(gMC->CurrentVolOffName(6),"%4s%1d",sEcalBlock,&iEcalBlock);
-	else
-	  sscanf(gMC->CurrentVolOffName(5),"%4s%1d",sEcalBlock,&iEcalBlock);
-	iEcalBlock+=2; // =3 or 4 for ecalCell //BVZ
-      }
-      else
-	if (volnum==3) {
-	  gMC->CurrentVolOffID(4, copyNo4);
-	  gMC->CurrentVolOffID(5, copyNo5); // ECAL? || ECAL?row
-	  gMC->CurrentVolOffID(6, copyNo6);
-	  iRow = copyNo4;
-	  iColumn = copyNo5;
-	  iEcalBlockCopy = copyNo6;
-	  sscanf(gMC->CurrentVolOffName(5),"%4s%1d",sEcalBlock,&iEcalBlock);
-	  iEcalBlock+=2; // =3 or 4 for ecalCell //BVZ
-	}
-	else
-	  if (volnum==4) {
-	    gMC->CurrentVolOffID(3, copyNo3); // ECAL?column || ECALcell
-	    gMC->CurrentVolOffID(4, copyNo4);
-	    gMC->CurrentVolOffID(5, copyNo5); // ECAL? || ECAL?row
-	    iRow = copyNo3;
-	    iColumn = copyNo4;
-	    iEcalBlockCopy = copyNo5;
-	    sscanf(gMC->CurrentVolOffName(4),"%4s%1d",sEcalBlock,&iEcalBlock);
-	    iEcalBlock+=2; // =3 or 4 for ecalCell //BVZ
-	  }
-    }
-#ifdef _DECAL
-  if(iEcalBlock<1||iEcalBlock>4||iEcalBlockCopy<1||iEcalBlockCopy>2) //BVZ
-    cout<<"!!!!!!!!! iEcalBlock,iEcalBlockCopy = "<<iEcalBlock<<","<<iEcalBlockCopy<<endl;
-#endif
-
-  // Unique cell id
-  fVolumeID = (2*(iEcalBlock-1)+iEcalBlockCopy-1)*nColumns*nRows +
-    (iColumn-1)*nRows + iRow-1;
-
-#ifdef _DECALSTEP
-  if (volnum>2)
-    printf("Track %d, Volume %d %s in %d %s in %d %s in %d %s in %d %s in %d %s in %d %s in %d %s in %d %s\n",
-	   fTrackID,
-	   copyNo ,gMC->CurrentVolName(),
-	   copyNo1,gMC->CurrentVolOffName(1),
-	   copyNo2,gMC->CurrentVolOffName(2),
-	   copyNo3,gMC->CurrentVolOffName(3),
-	   copyNo4,gMC->CurrentVolOffName(4),
-	   copyNo5,gMC->CurrentVolOffName(5),
-	   copyNo6,gMC->CurrentVolOffName(6),
-	   copyNo7,gMC->CurrentVolOffName(7),
-	   iEcalBlock,sEcalBlock);
-  else
-    printf("Track %d, Volume %d %s in %d %s in %d %s in %d %s in %d %s in %d %s\n",
-	   fTrackID,
-	   copyNo ,gMC->CurrentVolName(),
-	   copyNo1,gMC->CurrentVolOffName(1),
-	   copyNo2,gMC->CurrentVolOffName(2),
-	   copyNo3,gMC->CurrentVolOffName(3),
-	   copyNo4,gMC->CurrentVolOffName(4),
-	   iEcalBlock,sEcalBlock);
-#endif
-#ifdef _DECALCELL
-  printf("%s in ECAL block %d, block copy %d, column %d, row %d\n",
-	 gMC->CurrentVolName(),iEcalBlock,iEcalBlockCopy,iColumn,iRow);
-#endif   
-  return kTRUE;
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcal::FillWallPoint()
-{
-  /** Fill MC points on the ECAL front wall **/
-
-  gMC->TrackPosition(fPos);
-  gMC->TrackMomentum(fMom);
-  fVolumeID = -1;
-  Double_t mass = gMC->TrackMass();
-  // Calculate kinetic energy
-  Double_t ekin = TMath::Sqrt( fMom.Px()*fMom.Px() +
-			       fMom.Py()*fMom.Py() +
-			       fMom.Pz()*fMom.Pz() +
-			       mass * mass ) - mass;
-  fELoss = ekin;
-  // Create CbmEcalPoint at the entrance of calorimeter
-  // for particles with pz>0 coming through the front wall
-  if (fMom.Pz() > 0 && fPos.Z() < fZEcal+0.01)
-    AddHit(fTrackID, fVolumeID, TVector3(fPos.X(),  fPos.Y(),  fPos.Z()),
-	   TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, 
-	   fELoss);
-  fTrackID=gMC->GetStack()->GetCurrentTrackNumber();
-}
-
-CbmEcalPointLite* CbmEcal::FindHit(Int_t VolId, Int_t TrackId)
-{
-  for(Int_t i=fFirstNumber;i<fLiteCollection->GetEntriesFast();i++)
-  {
-    CbmEcalPointLite* point=(CbmEcalPointLite*)fLiteCollection->At(i);
-    if (point->GetTrackID()==TrackId&&point->GetDetectorID()==VolId)
-      return point;
-  }
-  return NULL;
-}
-//-----------------------------------------------------------------------------
-Bool_t CbmEcal::FillLitePoint(Int_t volnum)
-{
-  /** Fill MC points inside the ECAL for non-zero deposited energy **/
-
-  //Search for input track
-  
-  static Float_t zmin=fZEcal-0.0001;
-  static Float_t zmax=fZEcal+fEcalSize[2];
-  static Float_t xecal=fEcalSize[0]/2;
-  static Float_t yecal=fEcalSize[1]/2;
-  static Float_t xhole=fEcalHole[0]/2-0.01;
-  static Float_t yhole=fEcalHole[1]/2-0.01;
-  TParticle* part=gMC->GetStack()->GetCurrentTrack();
-  fTrackID=gMC->GetStack()->GetCurrentTrackNumber();
-
-  while (part->GetFirstMother()>=0&&\
-      part->Vz()>=zmin&&part->Vz()<=zmax&& \
-      TMath::Abs(part->Vx())<=xecal&&\
-      TMath::Abs(part->Vy())<=yecal&&\
-      (TMath::Abs(part->Vx())>=xhole||TMath::Abs(part->Vy())>=yhole))
-    {
-      fTrackID=part->GetFirstMother();
-      part =((CbmStack*)gMC->GetStack())->GetParticle(fTrackID);
-    }
-#ifdef _DECAL
-  if (fTrackID<0) cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!fTrackID="<<fTrackID<<endl;
-#endif
-  CbmEcalPointLite* oldHit;
-  CbmEcalPointLite* newHit;
-  
-  if (volnum==2||volnum==5) {
-    if ((oldHit=FindHit(fVolumeID,fTrackID))!=NULL)
-      ChangeHit(oldHit);
-    else
-    {	    
-      // Create CbmEcalPoint for scintillator volumes
-      newHit = AddLiteHit(fTrackID, fVolumeID, fTime, fELoss);
-    }
-  }
-      
-  fVolumeID+=fVolIdMax;
-  if ((oldHit=FindHit(fVolumeID,fTrackID))!=NULL)
-  {
-    ChangeHit(oldHit);
-    return kTRUE;
-  }
-
-  // Create CbmEcalPoint for any ECAL volumes
-  newHit = AddLiteHit(fTrackID, fVolumeID, fTime, fELoss);
-
-  if (newHit==NULL) return kFALSE;
-  return kTRUE;
-}
-
-// -----   Public method EndOfEvent   --------------------------------------
-void CbmEcal::EndOfEvent() {
-  if (fVerboseLevel) Print();
-  fEcalCollection->Delete();
-
-  if (fInf->GetFastMC()==0)
-    fLiteCollection->Delete();
-  fPosIndex = 0;
-  fFirstNumber=0;
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method GetCollection   -----------------------------------
-TClonesArray* CbmEcal::GetCollection(Int_t iColl) const
-{
-  if (iColl == 0) return fEcalCollection;
-  if (fInf->GetFastMC()==1) return NULL;
-  if (iColl == 1) return fLiteCollection;
-  else return NULL;
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method Reset   -------------------------------------------
-void CbmEcal::Reset()
-{
-  fEcalCollection->Delete();
-  if (fInf->GetFastMC()==0)
-    fLiteCollection->Delete();
-  ResetParameters();
-  fFirstNumber=0;
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method Print   -------------------------------------------
-void CbmEcal::Print(Option_t*) const 
-{
-  Int_t nHits = fEcalCollection->GetEntriesFast();
-  Int_t nLiteHits=0;
-  Int_t i;
-
-  cout << "-I- CbmEcal: " << nHits << " points registered in this event.";
-  cout << endl;
-
-  if (fInf->GetFastMC()==0) {
-    nLiteHits = fLiteCollection->GetEntriesFast();
-    cout << "-I- CbmEcal: " << nLiteHits << " lite points registered in this event.";
-    cout << endl;
-  }
-
-  if (fVerboseLevel>1) {
-    for (i=0; i<nHits; i++) (*fEcalCollection)[i]->Print();
-    if (fInf->GetFastMC()==0)
-      for (i=0; i<nLiteHits; i++) (*fLiteCollection)[i]->Print();
-  }
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method CopyClones   --------------------------------------
-void CbmEcal::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset)
-{   
-  Int_t nEntries = cl1->GetEntriesFast();
-  Int_t i;
-  Int_t index;
-  cout << "-I- CbmEcal: " << nEntries << " entries to add." << endl;
-  TClonesArray& clref = *cl2;
-  if (cl1->GetClass()==CbmEcalPoint::Class()) {
-    CbmEcalPoint* oldpoint = NULL;
-    for (i=0; i<nEntries; i++) {
-      oldpoint = (CbmEcalPoint*) cl1->At(i);
-      index = oldpoint->GetTrackID()+offset;
-      oldpoint->SetTrackID(index);
-      new (clref[fPosIndex]) CbmEcalPoint(*oldpoint);
-      fPosIndex++;
-    }
-    cout << "-I- CbmEcal: " << cl2->GetEntriesFast() << " merged entries."
-         << endl;
-  }
-  else if (cl1->GetClass()==CbmEcalPointLite::Class()) {
-    CbmEcalPointLite* oldpoint = NULL;
-    for (i=0; i<nEntries; i++) {
-      oldpoint = (CbmEcalPointLite*) cl1->At(i);
-      index = oldpoint->GetTrackID()+offset;
-      oldpoint->SetTrackID(index);
-      new (clref[fPosIndex]) CbmEcalPointLite(*oldpoint);
-      fPosIndex++;
-    }
-    cout << "-I- CbmEcal: " << cl2->GetEntriesFast() << " merged entries."
-         << endl;
-  }
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method Register   ----------------------------------------
-void CbmEcal::Register()
-{
-  FairRootManager::Instance()->Register("EcalPoint","Ecal",fEcalCollection,kTRUE);
-  if (fInf->GetFastMC()==0)
-    FairRootManager::Instance()->Register("EcalPointLite","EcalLite",fLiteCollection,kTRUE);
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method ConstructGeometry   -------------------------------
-void CbmEcal::ConstructGeometry()
-{
-  FairGeoLoader*geoLoad = FairGeoLoader::Instance();
-  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
-  FairGeoMedia *Media =  geoFace->getMedia();
-  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
-
-  TGeoVolume *volume;
-  FairGeoMedium *CbmMedium;
-  TGeoPgon *spl;
-
-  Float_t *buf = 0;
-//  Float_t sumWeight;
-//  Int_t i;
-
-  // create SensVacuum which is defined in the media file
-
-  CbmMedium=Media->getMedium("SensVacuum");
-  if (!CbmMedium) {
-    Fatal("CbmEcal","Material SensVacuum not defined in media file.");
-  }
-  Int_t kMedSVac = geobuild->createMedium(CbmMedium);
-
-
-   // Calculate other geometry parameters
-  fCellSize       *= fGeoScale;
-  fThicknessLead  *= fGeoScale;
-  fThicknessScin  *= fGeoScale;
-  fThicknessTyvk  *= fGeoScale;
-  fThicknessLayer  = fThicknessLead + fThicknessScin + 2*fThicknessTyvk;
-  fNLayers         = TMath::Nint(fNLayers/fGeoScale);
-
-  // --------------- Container volume for the whole ECAL
-  Double_t par[10], xPos, yPos, zPos;
-  par[0] =  45; // phi_min
-  par[1] = 360; // phi range
-  par[2] =   4; // N of edges
-  par[3] =   2; // N of z-planes
-  //BVZ --> outer sensitive wall for control
-  par[4] = -(fEcalSize[2]+.01)/2; // z1
-
-  if (fEcalHole[0]<fEcalHole[1])
-    par[5]=(fEcalHole[0]-.01)/2; // r1_min
-  else
-    par[5]=(fEcalHole[1]-.01)/2; // r1_min
-
-  if (fEcalSize[0]>fEcalSize[1])
-    par[6]=fEcalSize[0]/2;             // r1_max
-  else
-    par[6]=fEcalSize[1]/2;             // r1_max
-
-  par[7] =  fEcalSize[2]/2; // z2
-  par[8] =  par[5];              // r2_min
-  par[9] =  par[6];              // r2_max
-  // This wall is created differently to satisfy 
-  // CBM framework around sensitive volumes
-
-  spl = new TGeoPgon(&par[0]);
-
-  volume = new TGeoVolume("WALL",spl,gGeoManager->GetMedium(kMedSVac));
-
-  gGeoManager->Node("WALL", 1, "cave", 0.,0.,fZEcal+fEcalSize[2]/2,0,kTRUE,buf,0);
-
-  fVolArr[0]=volume->GetNumber();
-  AddSensitiveVolume(volume);
-
-  if (fInf->GetFastMC()==1) return;
-
-  //create necessary media which are defined in the media file
-
-  CbmMedium=Media->getMedium("ECALVacuum");
-  if (!CbmMedium) {
-    Fatal("CbmEcal","Material ECALVacuum not defined in media file.");
-  }
-  Int_t kMedVac = geobuild->createMedium(CbmMedium);
-
-  CbmMedium=Media->getMedium(fAbsorber);
-  if (!CbmMedium) {
-    Fatal("CbmEcal","Material %s not defined in media file.", fAbsorber.Data());
-  }
-  Int_t kMedLead = geobuild->createMedium(CbmMedium);
-
-  CbmMedium=Media->getMedium("Scintillator");
-  if (!CbmMedium) {
-    Fatal("CbmEcal","Material Scintillator not defined in media file.");
-  }
-  Int_t kMedScin = geobuild->createMedium(CbmMedium);
-
-  CbmMedium=Media->getMedium("Tyvek");
-  if (!CbmMedium) {
-    Fatal("CbmEcal","Material Tyvek not defined in media file.");
-  }
-  Int_t kMedTyvk = geobuild->createMedium(CbmMedium);
-
-
-
-  par[4] = -fEcalSize[2]/2; // z1
-  if (fEcalHole[0]<fEcalHole[1])
-    par[5]=fEcalHole[0]/2; // r1_min
-  else
-    par[5]=fEcalHole[1]/2; // r1_min
-
-  if (fEcalSize[0]>fEcalSize[1])
-    par[6]=fEcalSize[0]/2;             // r1_max
-  else
-    par[6]=fEcalSize[1]/2;             // r1_max
-  //par[5] =  fEcalHole[0]/2; // r1_min
-  //par[6] =  fEcalSize[0]/2; // r1_max
-  par[7] = -par[4];        // z2
-  par[8] =  par[5];        // r2_min
-  par[9] =  par[6];        // r2_max
-
-  spl=new TGeoPgon(&par[0]);
-  volume=new TGeoVolume("ECAL",spl,gGeoManager->GetMedium(kMedVac));
-
-  gGeoManager->Node("ECAL", 1, "WALL", 0.,0.,0.,0,kTRUE,buf,0);
-
-  // --------------- Upper and bottom parts of ECAL
-  par[0] =  fEcalSize[0]/2;
-  par[1] = (fEcalSize[1]-fEcalHole[1])/4;
-  par[2] =  fEcalSize[2]/2;
-
-  volume = gGeoManager->Volume("ECAL1", "BOX", kMedVac, par, 3);
-  yPos = par[1] + fEcalHole[1]/2;
-  gGeoManager->Node("ECAL1", 1, "ECAL", 0.,+yPos,0.,0,kTRUE,buf,0);
-  gGeoManager->Node("ECAL1", 2, "ECAL", 0.,-yPos,0.,0,kTRUE,buf,0);
-
-  volume = gGeoManager->Division("ECAL1column","ECAL1"      ,1,-1,-par[0],fCellSize,0,"S");
-  volume = gGeoManager->Division("ECAL1row"   ,"ECAL1column",2,-1,-par[1],fCellSize,0,"S");
-  
-  fNColumns1 = TMath::Nint((par[0]/fCellSize)*2);
-  fNRows1    = TMath::Nint((par[1]/fCellSize)*2);
-
-  // --------------- Left and right parts of ECAL
-  par[0] = (fEcalSize[0]-fEcalHole[0])/4;
-  par[1] =  fEcalHole[1]/2;
-  par[2] =  fEcalSize[2]/2;
-  
-  volume = gGeoManager->Volume("ECAL2", "BOX", kMedVac, par, 3);
-  
-  xPos = par[0] + fEcalHole[0]/2;
-  gGeoManager->Node("ECAL2", 1, "ECAL", +xPos,0.,0.,0,kTRUE,buf,0);
-  gGeoManager->Node("ECAL2", 2, "ECAL", -xPos,0.,0.,0,kTRUE,buf,0);
-  
-  volume = gGeoManager->Division("ECAL2column","ECAL2"      ,1,-1,-par[0],fCellSize,0,"S");
-  volume = gGeoManager->Division("ECAL2row"   ,"ECAL2column",2,-1,-par[1],fCellSize,0,"S");
-  
-  fNColumns2 = TMath::Nint((par[0]/fCellSize)*2);
-  fNRows2    = TMath::Nint((par[1]/fCellSize)*2);
-
-  Int_t colmax=TMath::Max(fNColumns1,fNColumns2);
-  Int_t rowmax=TMath::Max(fNRows1,fNRows2);
-  Int_t fVolumeIDmax = (2*(4-1)+2-1)*colmax*rowmax +
-    colmax*rowmax + rowmax;
-#ifdef _DECAL
-  cout << "fNColumns1=" << fNColumns1 << ", fNColumns2=" << fNColumns2 << endl;
-  cout << "fNRows1=" << fNRows1 << ", fNRows2=" << fNRows2 << endl;
-  cout << "fVolumeIDmax=" <<fVolumeIDmax << ".fVolIDmax=" << fVolIdMax <<endl;
-#endif  
-  fVolIdMax=fVolumeIDmax;
-  // --------------- Preshower cell (lead + scintillator)
-  Float_t psThickness = fThicknessPSlead + fThicknessPSscin;
-  TGeoBBox *shape;
-  par[0] = fCellSize/2;
-  par[1] = fCellSize/2;
-  par[2] = psThickness/2;
-
-  if (psThickness>0)
-  {
-    volume = gGeoManager->Volume("ECALPScell", "BOX", kMedLead, par, 3);
-    fVolArr[1]=volume->GetNumber();
-    AddSensitiveVolume(volume);
-  
-    zPos = fEcalSize[2]/2 - par[2];
-    gGeoManager->Node("ECALPScell", 1, "ECAL1row", 0.,0.,-zPos,0,kTRUE,buf,0);
-    gGeoManager->Node("ECALPScell", 2, "ECAL2row", 0.,0.,-zPos,0,kTRUE,buf,0);
-
-    // Preshower Scintillator tile is a sensitive volume
-    par[2] = fThicknessPSscin/2;
-    shape = new TGeoBBox("ECALPSscin", par[0], par[1], par[2]);
-  
-    volume = new TGeoVolume("ECALPSscin",shape,gGeoManager->GetMedium(kMedScin));
-
-    fVolArr[2]=volume->GetNumber();
-    
-    //  gGeoManager->AddVolume(volume);
-  
-    zPos = psThickness/2 - par[2];
-    gGeoManager->Node("ECALPSscin", 1, "ECALPScell", 0.,0.,zPos,0,kTRUE,buf,0);
-
-    AddSensitiveVolume(volume);
-  }
-  else
-  {
-    fVolArr[2]=-1111;
-    fVolArr[1]=-1111;
-    Info("ConstructGeometry"," Constructing calorimeter without PS.");
-  }
-
-  // --------------- ECAL cell
-  par[0] = fCellSize/2;
-  par[1] = fCellSize/2;
-  par[2] = (fThicknessLayer * fNLayers)/2;
-  volume = gGeoManager->Volume("ECALcell", "BOX", 1, par, 3);
-  zPos = fEcalSize[2]/2 - par[2] - psThickness - fEcalPSgap/2;
-  gGeoManager->Node("ECALcell", 1, "ECAL1row", 0.,0.,-zPos,0,kTRUE,buf,0);
-  gGeoManager->Node("ECALcell", 2, "ECAL2row", 0.,0.,-zPos,0,kTRUE,buf,0);
-
-  // ----- One layer of the cell consisting of Pb, Sci and Tyvek
-
-  volume = gGeoManager->Division("ECALlayer" ,"ECALcell"  ,3,-1,-par[2],fThicknessLayer,0,"S");
-
-  par[2]=fThicknessTyvk+(fThicknessScin+fThicknessLead)/2;
-  shape=new TGeoBBox("ECALlead",par[0],par[1],par[2]);
-  volume = new TGeoVolume("ECALlead",shape,gGeoManager->GetMedium(kMedLead));
-
-  fVolArr[4]=volume->GetNumber();
-  
-  //gGeoManager->AddVolume(volume);
-  AddSensitiveVolume(volume);
-  
-  gGeoManager->Node("ECALlead",1,"ECALlayer",0.0,0.0,0.0,0,kTRUE,buf,0);
-  
-  if (fThicknessTyvk!=0.0) {	  
-    par[2] = fThicknessTyvk + fThicknessScin/2;
-    shape=new TGeoBBox("ECALtyvk",par[0],par[1],par[2]);
-    volume = new TGeoVolume("ECALtyvk",shape,gGeoManager->GetMedium(kMedTyvk));
-
-    fVolArr[3]=volume->GetNumber();
-    //gGeoManager->AddVolume(volume);
-    
-    zPos = fThicknessLayer/2 - par[2];
-    gGeoManager->Node("ECALtyvk",1,"ECALlead",0.0,0.0,zPos,0,kTRUE,buf,0);
-    AddSensitiveVolume(volume);
-   
-    // Scintillator tile is a sensitive volume
-    par[2] = fThicknessScin/2;
-    shape = new TGeoBBox("ECALscin", par[0], par[1], par[2]);
-    volume = new TGeoVolume("ECALscin",shape,gGeoManager->GetMedium(kMedScin));
-
-    fVolArr[5]=volume->GetNumber();
-    //gGeoManager->AddVolume(volume);
-
-    gGeoManager->Node("ECALscin", 1, "ECALtyvk", 0.,0.,0.,0,kTRUE,buf,0);
-    
-   AddSensitiveVolume(volume);
-
-  }
-  else {
-    cout << "Constructing ECAL without tyvec" << endl;
-    par[2] = fThicknessScin/2;
-    shape = new TGeoBBox("ECALscin", par[0], par[1], par[2]);
-    volume = new TGeoVolume("ECALscin",shape,gGeoManager->GetMedium(kMedScin));
-
-    fVolArr[5]=volume->GetNumber();
-    //gGeoManager->AddVolume(volume);
-    zPos = fThicknessLayer/2 - par[2];
-    gGeoManager->Node("ECALscin", 1, "ECALlead", 0.,0.,zPos,0,kTRUE,buf,0);
-    AddSensitiveVolume(volume);
-  }
-
-}
-// -------------------------------------------------------------------------
-
-// ----- Public method BeginEvnt  ------------------------------------------
-void CbmEcal::BeginEvent()
-{
-}
-// -------------------------------------------------------------------------
-
-Int_t CbmEcal::GetVolIdMaxInf()
-{
-  static CbmEcalInf* inf=NULL;
-  if (inf==NULL)
-  {
-    inf=CbmEcalInf::GetInstance(NULL);
-    if (inf==NULL)
-    {
-      cerr << "Can't get geometry information!!!" << endl;
-      return kFALSE;
-    }
-  }
-  static Double_t cellsize=inf->GetCellSize();
-  static Double_t xcalosize=inf->GetEcalSize(0);
-  static Double_t ycalosize=inf->GetEcalSize(1);
-  static Double_t xholesize=inf->GetEcalHole(0);
-  static Double_t yholesize=inf->GetEcalHole(1);
-  static Int_t NColumns1 = TMath::Nint((xcalosize/2/cellsize)*2);
-  static Int_t NRows1    = TMath::Nint(((ycalosize-yholesize)/4/cellsize)*2);
-  static Int_t NColumns2 = TMath::Nint(((xcalosize-xholesize)/4/cellsize)*2);
-  static Int_t NRows2    = TMath::Nint((yholesize/2/cellsize)*2);
-  static Int_t colmax=TMath::Max(NColumns1,NColumns2);
-  static Int_t rowmax=TMath::Max(NRows1,NRows2);
-  static Int_t VolIdMax=colmax*rowmax+rowmax+(2*(4-1)+2-1)*colmax*rowmax;
-  return VolIdMax;
-}
-
-Int_t CbmEcal::GetVolIdMax()
-{
-  static FairRunAna* ana = FairRunAna::Instance();
-  if (ana==NULL)
-  {
-    return GetVolIdMaxInf();
-  }
-  static FairRuntimeDb* rtdb=ana->GetRuntimeDb();
-  static CbmGeoEcalPar* par=(CbmGeoEcalPar*)(rtdb->getContainer("CbmGeoEcalPar"));
-  static Double_t cellsize=par->GetVariable("cellsize");
-  static Double_t xcalosize=par->GetVariable("xecalsize");
-  static Double_t ycalosize=par->GetVariable("yecalsize");
-  static Double_t xholesize=par->GetVariable("xholesize");
-  static Double_t yholesize=par->GetVariable("yholesize");
-  if (cellsize==-1111||xcalosize==-1111||ycalosize==-1111||xholesize==-1111||yholesize==-1111)
-  {
-    static Int_t here=0;
-    if (here==0)
-    {
-      cerr << endl;
-      cerr << "-W-: CbmEcal. Not enough information in";
-      cerr << " container file!" << endl;
-      cerr << "Using CbmEcalInf as information source";
-      cerr << endl;
-      here=1;
-    }
-    return GetVolIdMaxInf();
-  }
-  static Int_t NColumns1 = TMath::Nint((xcalosize/2/cellsize)*2);
-  static Int_t NRows1    = TMath::Nint(((ycalosize-yholesize)/4/cellsize)*2);
-  static Int_t NColumns2 = TMath::Nint(((xcalosize-xholesize)/4/cellsize)*2);
-  static Int_t NRows2    = TMath::Nint((yholesize/2/cellsize)*2);
-  static Int_t colmax=TMath::Max(NColumns1,NColumns2);
-  static Int_t rowmax=TMath::Max(NRows1,NRows2);
-  static Int_t VolIdMax=colmax*rowmax+rowmax+(2*(4-1)+2-1)*colmax*rowmax;
-  return VolIdMax;
-
-}
-
-// ----- Public method GetCellCoordInf ----------------------------------------
-Bool_t CbmEcal::GetCellCoordInf(Int_t fVolID, Float_t &x, Float_t &y, Int_t& tenergy)
-{
-  static CbmEcalInf* inf=NULL;
-  if (inf==NULL)
-  {
-    inf=CbmEcalInf::GetInstance(NULL);
-    if (inf==NULL)
-    {
-      cerr << "Can't get geometry information!!!" << endl;
-      return kFALSE;
-    }
-  }
-  static Double_t cellsize=inf->GetCellSize();
-  static Double_t xcalosize=inf->GetEcalSize(0);
-  static Double_t ycalosize=inf->GetEcalSize(1);
-  static Double_t xholesize=inf->GetEcalHole(0);
-  static Double_t yholesize=inf->GetEcalHole(1);
-  static Int_t NColumns1 = TMath::Nint((xcalosize/2/cellsize)*2);
-  static Int_t NRows1    = TMath::Nint(((ycalosize-yholesize)/4/cellsize)*2);
-  static Int_t NColumns2 = TMath::Nint(((xcalosize-xholesize)/4/cellsize)*2);
-  static Int_t NRows2    = TMath::Nint((yholesize/2/cellsize)*2);
-  static Int_t colmax=TMath::Max(NColumns1,NColumns2);
-  static Int_t rowmax=TMath::Max(NRows1,NRows2);
-  static Int_t VolIdMax=colmax*rowmax+rowmax+(2*(4-1)+2-1)*colmax*rowmax;
-  Int_t fVolumeID=fVolID;
-
-  Int_t irow;
-  Int_t icol;
-  Int_t iblock;
-  Int_t icopy;
-  Int_t code;
-
-  if (fVolumeID<0) return kFALSE;
-  if (fVolumeID>VolIdMax) {
-    tenergy=1;
-    fVolumeID-=VolIdMax;
-  }
-  else
-    tenergy=0;
-  irow=fVolumeID%rowmax;
-  icol=((fVolumeID-irow)/rowmax)%colmax;
-
-  code=(fVolumeID-icol*rowmax-irow)/(rowmax*colmax);
-  icopy=code%2;
-  iblock=(code-icopy)/2+1;
-
-  x=0.0;
-  y=0.0;
-
-  if (iblock%2==1) {
-    x=(icol*cellsize-xcalosize/2.0);
-    y=(irow*cellsize+yholesize/2.0);
-    if (1==icopy) y-=(ycalosize+yholesize)/2.0;
-    if (iblock>2) return kFALSE; else return kTRUE;
-  }
-  x=(icol*cellsize+xholesize/2.0);
-  y=(irow*cellsize-yholesize/2.0);
-  if (1==icopy) x-=(xcalosize+xholesize)/2.0;
-  if (iblock>2) return kFALSE; else return kTRUE;
-}
-
-Bool_t CbmEcal::GetCellCoord(Int_t fVolID, Float_t &x, Float_t &y, Int_t& tenergy)
-{
-  static FairRunAna* ana = FairRunAna::Instance();
-  if (ana==NULL)
-  {
-    return GetCellCoordInf(fVolID, x, y, tenergy);
-  }
-  static FairRuntimeDb* rtdb=ana->GetRuntimeDb();
-  static CbmGeoEcalPar* par=(CbmGeoEcalPar*)(rtdb->getContainer("CbmGeoEcalPar"));
-  static Double_t cellsize=par->GetVariable("cellsize");
-  static Double_t xcalosize=par->GetVariable("xecalsize");
-  static Double_t ycalosize=par->GetVariable("yecalsize");
-  static Double_t xholesize=par->GetVariable("xholesize");
-  static Double_t yholesize=par->GetVariable("yholesize");
-  if (cellsize==-1111||xcalosize==-1111||ycalosize==-1111||xholesize==-1111||yholesize==-1111)
-  {
-    static Int_t here=0;
-    if (here==0)
-    {
-      cerr << endl;
-      cerr << "-W-: CbmEcal. Not enough information in";
-      cerr << " container file!" << endl;
-      cerr << "Using CbmEcalInf as information source";
-      cerr << endl;
-      here=1;
-    }
-    return GetCellCoordInf(fVolID, x, y, tenergy);
-  }
-  
-  static Int_t NColumns1 = TMath::Nint((xcalosize/2/cellsize)*2);
-  static Int_t NRows1    = TMath::Nint(((ycalosize-yholesize)/4/cellsize)*2);
-  static Int_t NColumns2 = TMath::Nint(((xcalosize-xholesize)/4/cellsize)*2);
-  static Int_t NRows2    = TMath::Nint((yholesize/2/cellsize)*2);
-  static Int_t colmax=TMath::Max(NColumns1,NColumns2);
-  static Int_t rowmax=TMath::Max(NRows1,NRows2);
-  static Int_t VolIdMax=colmax*rowmax+rowmax+(2*(4-1)+2-1)*colmax*rowmax;
-  Int_t fVolumeID=fVolID;
-
-  Int_t irow;
-  Int_t icol;
-  Int_t iblock;
-  Int_t icopy;
-  Int_t code;
-
-  if (fVolumeID<0) return kFALSE;
-  if (fVolumeID>VolIdMax) {
-    tenergy=1;
-    fVolumeID-=VolIdMax;
-  }
-  else
-    tenergy=0;
-  irow=fVolumeID%rowmax;
-  icol=((fVolumeID-irow)/rowmax)%colmax;
-
-  code=(fVolumeID-icol*rowmax-irow)/(rowmax*colmax);
-  icopy=code%2;
-  iblock=(code-icopy)/2+1;
-
-  x=0.0;
-  y=0.0;
-
-  if (iblock%2==1) {
-    x=(icol*cellsize-xcalosize/2.0);
-    y=(irow*cellsize+yholesize/2.0);
-    if (1==icopy) y-=(ycalosize+yholesize)/2.0;
-    if (iblock>2) return kFALSE; else return kTRUE;
-  }
-  x=(icol*cellsize+xholesize/2.0);
-  y=(irow*cellsize-yholesize/2.0);
-  if (1==icopy) x-=(xcalosize+xholesize)/2.0;
-  if (iblock>2) return kFALSE; else return kTRUE;
-}
-
-// -------------------------------------------------------------------------
-
-// -----   Private method AddHit   -----------------------------------------    
-CbmEcalPoint* CbmEcal::AddHit(Int_t trackID, Int_t detID, TVector3 pos,         
-			      TVector3 mom, Double_t time, Double_t length,       
-			      Double_t eLoss)
-{
-  TClonesArray& clref = *fEcalCollection;
-  Int_t size = clref.GetEntriesFast();
-  return new(clref[size]) CbmEcalPoint(trackID, detID, pos, mom,
-                                      time, length, eLoss);
-}                                                                               
-// -------------------------------------------------------------------------
-
-// -----   Private method AddHit   -----------------------------------------    
-CbmEcalPointLite* CbmEcal::AddLiteHit(Int_t trackID, Int_t detID, Double32_t time, Double32_t eLoss)
-{
-  TClonesArray& clref = *fLiteCollection;
-  Int_t size = clref.GetEntriesFast();
-  return new(clref[size]) CbmEcalPointLite(trackID, detID, time, eLoss);
-}
-// -------------------------------------------------------------------------
-
-ClassImp(CbmEcal)
diff --git a/ecal/CbmEcal.h b/ecal/CbmEcal.h
deleted file mode 100644
index a75db385a7391f8cf87386acbe594efff83f79d3..0000000000000000000000000000000000000000
--- a/ecal/CbmEcal.h
+++ /dev/null
@@ -1,266 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                         CbmEcal header file                 -----
-// -----                  Created  04/02/05  by Yu.Kharlov             -----
-// -----                  Modified 11/04/05  by B.Zagreev              -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcal.h
- *@author Yuri Kharlov
- **
- ** Defines the active detector ECAL with geometry coded here.
- **/
-
-/* $Id: CbmEcal.h,v 1.12 2006/07/29 00:33:53 prokudin Exp $ */
-
-/* History of cvs commits:
- *
- * $Log: CbmEcal.h,v $
- * Revision 1.12  2006/07/29 00:33:53  prokudin
- * Commenting. Bringing code to coding conventions. New way of parameter file processing
- *
- * Revision 1.11  2006/07/24 21:45:02  prokudin
- * Now we write information to parameter file
- *
- * Revision 1.10  2006/07/17 13:59:06  prokudin
- * fMat1 removed. At last.
- *
- * Revision 1.9  2006/07/14 15:09:18  prokudin
- * New functionality added
- *
- * Revision 1.8  2006/07/13 14:42:16  prokudin
- * GetCellCoord now static
- *
- * Revision 1.7  2006/07/12 08:41:38  prokudin
- * String compare removed. Using FairVolume instead.
- *
- * Revision 1.6  2006/06/30 13:04:22  kharlov
- * Added a function SetSpecialPhysicsCuts()
- *
- * Revision 1.5  2006/06/30 06:17:17  kharlov
- * Optimization, commenting
- *
- * Revision 1.4  2006/06/12 11:59:47  kharlov
- * Passing geometry file name via the constructor argument
- *
- * Revision 1.3  2006/04/25 06:52:17  kharlov
- * Remove CbmEcalv[1,2] and leave the only class CbmEcal
- *
- * Revision 1.4  2006/04/02 16:55:23  kharlov
- * Merging full and fast MC
- *
- * Revision 1.3  2006/01/31 17:07:17  kharlov
- * Correction for CbmEcal
- *
- * Revision 1.2  2006/01/27 17:26:30  kharlov
- * First adaptation of ECAL detailed geometry to cbmroot2
- *
- */
-
-
-#ifndef CBMECALV1_H
-#define CBMECALV1_H
-
-
-#include "CbmEcalPointLite.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalInf.h"
-
-#include "FairDetector.h"
-
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-#include "TVector3.h"
-
-class CbmEcalPoint; 
-class FairVolume;
-
-#define kNumberOfECALSensitiveVolumes 6
-
-class CbmEcal : public FairDetector
-{
-
-public:
-
-  /** Default constructor **/
-  CbmEcal();
-
-
-  /** Standard constructor.
-   *@param name    detetcor name
-   *@param active  sensitivity flag
-   **/
-  CbmEcal(const char* name, Bool_t active, 
-	  const char* fileGeo="ecal_FastMC.geo");
-
-
-  /** Destructor **/
-  virtual ~CbmEcal();
-
-
-  /** Virtual method ProcessHits
-   **
-   ** Defines the action to be taken when a step is inside the
-   ** active volume. Creates CbmEcalPoints and adds them to the
-   ** collection.
-   *@param vol  Pointer to the active volume
-   **/
-  virtual Bool_t  ProcessHits(FairVolume* vol = NULL);
-
-
-  /** Virtual method Construct geometry
-   **
-   ** Constructs the ECAL geometry
-   **/
-  virtual void ConstructGeometry();
-
-  virtual void EndOfEvent();
-  virtual void BeginEvent();
-  virtual void Reset();
-  virtual void Print(Option_t* ="") const;
-  virtual void CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset);
-  virtual void Register();
-  virtual void ChangeHit(CbmEcalPointLite* oldHit=NULL);
-  virtual void FinishPrimary();
-
-  virtual void Initialize();
-
-  /** Accessor to the hit collection **/                       
-  virtual TClonesArray* GetCollection(Int_t iColl) const;
-  virtual void SetSpecialPhysicsCuts();
-  
-  /** Get maximum volume id according
-   ** to parameter container **/
-  static Int_t GetVolIdMax();
-  /** Get maximum volume id according to Inf file **/
-  static Int_t GetVolIdMaxInf();
-
-  /** Get cell coordinates according
-   ** to parameter container **/
-  static Bool_t GetCellCoord(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t& tenergy);
-  /** Get cell coordinates according to Inf file **/
-  static Bool_t GetCellCoordInf(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t& tenergy);
-  CbmEcalInf* GetInf() const {return fInf;}
-
-  /** size in Mb (2^20)**/
-  void SetMaximumFileSize(Long64_t size);  
-
-protected:
-  CbmEcalPoint* AddHit(Int_t trackID, Int_t detID, TVector3 pos,
-                       TVector3 mom, Double_t time, Double_t length,
-                       Double_t eLoss);
-  CbmEcalPointLite* AddLiteHit(Int_t trackID, Int_t detID, Double32_t time, Double32_t eLoss);
-
-private:
-  Bool_t FindVolumeID(Int_t volnum);
-  Bool_t FillLitePoint(Int_t volnum);
-  void FillWallPoint();
-  /** Private method ResetParameters
-   **
-   ** Resets the private members for the track parameters
-   **/
-  void ResetParameters();
-  void SetEcalCuts(Int_t medium);
-  CbmEcalPointLite* FindHit(Int_t VolId, Int_t TrackId);
-
-private:
-  CbmEcalInf*  fInf;	//!
-  Option_t* fDebug;	//!
-
-  /** returns type of volume **/
-  Int_t GetVolType(Int_t volnum);
-  /** Track information to be stored until the track leaves the
-      active volume. **/
-  /**  track index **/
-  Int_t          fTrackID;           //!  
-  /** volume id **/
-  Int_t          fVolumeID;          //!  
-  /** position **/
-  TLorentzVector fPos;               //!  
-  /** momentum **/
-  TLorentzVector fMom;               //!  
-  /** time **/
-  Double32_t     fTime;              //!
-  /** length **/
-  Double32_t     fLength;            //!
-  /** energy loss **/
-  Double32_t     fELoss;             //!
-  /** **/ 
-  Int_t          fPosIndex;          //!
-
-  /** MC point collection on ECAL wall **/ 
-  TClonesArray*  fEcalCollection;    //! 
-  /** MC point collection inside ECAL **/ 
-  TClonesArray*  fLiteCollection;    //! 
-  /** ECAL geometry parameters **/
-  /** x,y,z size of outer ECAL box [cm] **/
-  Float_t fEcalSize[3];	//!
-  /** x,y,z size of inner ECAL beam hole [cm] **/
-  Float_t fEcalHole[3];	//!
-  /** transverce cell size [cm] **/
-  Float_t fCellSize;	//!
-  /** Z-position of ECAL from the target [cm] **/
-  Float_t fZEcal;	//!
-  /** thickness of one lead layer [cm] **/
-  Float_t fThicknessLead;	//!
-  /** thickness of one scintillator layer [cm] **/
-  Float_t fThicknessScin;	//!
-  /** thickness of one tyvek layer [cm] **/
-  Float_t fThicknessTyvk;	//!
-  /** total thickness of one layer [cm] **/
-  Float_t fThicknessLayer;	//!
-  /** number of layers per cell **/
-  Int_t   fNLayers;	//!
-  /** scall factor for fCellSize and fThicknessLayer **/
-  Float_t fGeoScale;	//!
-  /** Number of columns in ECAL1 **/
-  Int_t   fNColumns1;	//!
-  /** Number of rows in ECAL1 **/
-  Int_t   fNRows1;	//!
-  /** Number of columns in ECAL2 **/
-  Int_t   fNColumns2;	//!
-  /** Number of rows in ECAL2 **/
-  Int_t   fNRows2;	//!
-  /** thickness of preshower lead [cm] **/
-  Float_t fThicknessPSlead;	//!
-  /** thickness of preshower scintillator [cm] **/
-  Float_t fThicknessPSscin;	//!
-  /** gap between ECAL cell and preshower [cm] **/
-  Float_t fEcalPSgap;	//!
-  /** max number of columns in ECAL1 or ECAL2 **/
-  Int_t   fNColumns;	//!
-  /** max number of rows in ECAL1 or ECAL2 **/
-  Int_t   fNRows;	//!
-  /** Max number of ECAL cells **/
-  Int_t   fVolIdMax;	//!
-  /** Number of first hit for current primary **/
-  Int_t fFirstNumber;	//!
-  /** Material of ther absorber **/
-  TString fAbsorber;	//!
-  /** Map of volumes in ECAL
-   ** fVolArr[0]==code of sensivite wall
-   ** fVolArr[1]==code of PS Lead
-   ** fVolArr[2]==code of PS Scin
-   ** fVolArr[4]==code of Lead
-   ** fVolArr[3]==code of Tyveec
-   ** fVolArr[5]==code of scintillator
-   **/
-  Int_t fVolArr[kNumberOfECALSensitiveVolumes];
-
-  CbmEcal(const CbmEcal&);
-  CbmEcal& operator=(const CbmEcal&);
-
-  ClassDef(CbmEcal,1)
-
-};
-
-inline void CbmEcal::ResetParameters()
-{
-  fTrackID = fVolumeID = 0;
-  fPos.SetXYZM(0.0, 0.0, 0.0, 0.0);
-  fMom.SetXYZM(0.0, 0.0, 0.0, 0.0);
-  fTime = fLength = fELoss = 0;
-  fPosIndex = 0;
-};
-
-
-#endif
diff --git a/ecal/CbmEcalAnalysis.cxx b/ecal/CbmEcalAnalysis.cxx
deleted file mode 100644
index 197bcd9dea76b69ed5b14c41e23e48e1b688ed03..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysis.cxx
+++ /dev/null
@@ -1,436 +0,0 @@
-#include "CbmEcalAnalysis.h"
-
-#include "CbmEcalPoint.h"
-#include "CbmEcalPointLite.h"
-#include "CbmEcalHitFastMC.h"
-#include "CbmEcalRecParticle.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "TParticle.h"
-#include "TH1F.h"
-#include "TH2F.h"
-#include "TVector3.h"
-#include "TClonesArray.h"
-
-#include <iostream>
-
-using std::cout;
-using std::endl;
-
-//------------------------------------------------------------------------------
-CbmEcalAnalysis::CbmEcalAnalysis() 
-  : FairTask(),
-    fListStack(NULL),
-    fListECALptsEdep(NULL),
-    fListECALptsWall(NULL),
-    fListECALhits(NULL),
-    fListECALrp(NULL),
-    fEvent(0),
-    fNprimary(0),
-    fKfVectorMeson(0),
-    fhPrimPabs(NULL),
-    fhPrimPt(NULL),
-    fhPrimEta(NULL),
-    fhPrimTheta(NULL),
-    fhPrimPhi(NULL),
-    fhPrimPtEta(NULL),
-    fhMcpPabs(NULL),
-    fhMcpPt(NULL),
-    fhMcpEta(NULL),
-    fhMcpTheta(NULL),
-    fhMcpPhi(NULL),
-    fhMcpPtEta(NULL),
-    fhMcpXY(NULL),
-    fhHitXY(NULL),
-    fhHitE(NULL),
-    fhRecPabs(NULL),
-    fhRecPt(NULL),
-    fhRecYrap(NULL),
-    fhRecPhi(NULL),
-    fhPtYrap(NULL),
-    fhPtYrapSignal(NULL),
-    fhPtYrapAccept(NULL),
-    fDebug("")
-{
-}
-
-//------------------------------------------------------------------------------
-CbmEcalAnalysis::CbmEcalAnalysis(const char *name, const char *title)
-  : FairTask(name),
-    fListStack(NULL),
-    fListECALptsEdep(NULL),
-    fListECALptsWall(NULL),
-    fListECALhits(NULL),
-    fListECALrp(NULL),
-    fEvent(0),
-    fNprimary(0),
-    fKfVectorMeson(443),
-    fhPrimPabs(NULL),
-    fhPrimPt(NULL),
-    fhPrimEta(NULL),
-    fhPrimTheta(NULL),
-    fhPrimPhi(NULL),
-    fhPrimPtEta(NULL),
-    fhMcpPabs(NULL),
-    fhMcpPt(NULL),
-    fhMcpEta(NULL),
-    fhMcpTheta(NULL),
-    fhMcpPhi(NULL),
-    fhMcpPtEta(NULL),
-    fhMcpXY(NULL),
-    fhHitXY(NULL),
-    fhHitE(NULL),
-    fhRecPabs(NULL),
-    fhRecPt(NULL),
-    fhRecYrap(NULL),
-    fhRecPhi(NULL),
-    fhPtYrap(NULL),
-    fhPtYrapSignal(NULL),
-    fhPtYrapAccept(NULL),
-    fDebug("")
-{
-  SetTitle(title);
-  Double_t pi = TMath::Pi();
-
-  // Primary tracks histograms
-
-  fhPrimPabs = new TH1F("hPrimPabs" ,"Momentum of primary particles",100, 0.,50.);
-  fhPrimPt   = new TH1F("hPrimPt"   ,"p_{T} of primary particles"   ,100, 0.,10.);
-  fhPrimEta  = new TH1F("hPrimEta"  ,"#eta of primary particles"    , 80,-2., 6.);
-  fhPrimTheta= new TH1F("hPrimTheta","#theta of primary particles"  ,100, 0., pi);
-  fhPrimPhi  = new TH1F("hPrimPhi"  ,"#phi of primary particles"    ,100,-pi, pi);
-  fhPrimPtEta= new TH2F("hPrimPtEta","p_{T},#eta of primary particles",100, 0.,10., 80,-2., 6.);
-
-  // MC points histograms
-
-  fhMcpPabs = new TH1F("hMcpPabs" ,"Momentum of detected particles",120, 0.,30.);
-  fhMcpPt   = new TH1F("hMcpPt"   ,"p_{T} of detected particles"   ,100, 0.,10.);
-  fhMcpEta  = new TH1F("hMcpEta"  ,"#eta of detected particles"    , 80,-2., 6.);
-  fhMcpTheta= new TH1F("hMcpTheta","#theta of detected particles"  ,100, 0., pi);
-  fhMcpPhi  = new TH1F("hMcpPhi"  ,"#phi of detected particles"    ,100,-pi, pi);
-  fhMcpPtEta= new TH2F("hMcpPtEta","p_{T},#eta of detected particles",
-		       100, 0.,10., 80,-2., 6.);
-  fhMcpXY   = new TH2F("hMcpXY","(X,Y) coordinates of MC points",
-		       300,-600,600,300,-600,600);
-
-  // Hits histograms
-
-  fhHitXY = new TH2F("hHitXY","ECAL hit (x,y)",100,-600.,600.,100,-500.,500.);
-  fhHitE  = new TH1F("hHitE" ,"ECAL hit energy",120,0.,30.);
-
-  // Reconstructed particles histograms
-
-  fhRecPabs = new TH1F("hRecPabs","Reconstructed |p|"  ,120, 0.,30.);
-  fhRecPt   = new TH1F("hRecPt"  ,"Reconstructed p_{T}",100, 0.,10.);
-  fhRecYrap = new TH1F("hRecYrap","Reconstructed y"    , 80,-2., 6.);
-  fhRecPhi  = new TH1F("hRecPhi" ,"Reconstructed #phi" ,100,-pi, pi);
-
-  // Acceptance
-
-  fhPtYrap = new TH2F("PtYrap","pt vs y of primary particles", 100,0.,6.,100,0.,5.);
-  fhPtYrapSignal = new TH2F("PtYrapSignal","pt vs y of signal particles", 100,0.,6.,100,0.,5.);
-  fhPtYrapAccept = new TH2F("PtYrapAccept","ECAL p_{T}-y acceptance",100,0.,6.,100,0.,5.);
-
-}
-
-//------------------------------------------------------------------------------
-CbmEcalAnalysis::~CbmEcalAnalysis()
-{
-
-  // Primary tracks histograms
-
-  fhPrimPabs ->Write();
-  fhPrimPt   ->Write();
-  fhPrimEta  ->Write();
-  fhPrimTheta->Write();
-  fhPrimPhi  ->Write();
-  fhPrimPtEta->Write();
-
-  // MC points histograms
-
-  fhMcpPabs ->Write();
-  fhMcpPt   ->Write();
-  fhMcpEta  ->Write();
-  fhMcpTheta->Write();
-  fhMcpPhi  ->Write();
-  fhMcpPtEta->Write();
-  fhMcpXY->Write();
-
-  // Hits histograms
-
-  fhHitXY->Write();
-  fhHitE ->Write();
-
-  // Reconstructed particles histograms
-
-  fhRecPabs ->Write();
-  fhRecPt   ->Write();
-  fhRecYrap ->Write();
-  fhRecPhi  ->Write();
-
-  //Acceptance histograms
-
-  fhPtYrap->Sumw2(); fhPtYrap->Write(); 
-  fhPtYrapSignal->Sumw2(); fhPtYrapSignal->Write();
-  fhPtYrapAccept->Divide(fhPtYrapSignal,fhPtYrap);
-  fhPtYrapAccept->Write();
-
-}
-
-//------------------------------------------------------------------------------
-InitStatus CbmEcalAnalysis::Init()
-{
-  // Activate branches with ECAL objects
-
-  FairRootManager *manager= FairRootManager::Instance();
-  
-  // all tracks
-  fListStack        = (TClonesArray*)manager->GetObject("MCTrack");
-
-  //ECAL MC points inside ECAL
-  fListECALptsEdep  = (TClonesArray*)manager->GetObject("EcalPointLite");
-
-  //ECAL MC points on entrance to ECAL
-  fListECALptsWall  = (TClonesArray*)manager->GetObject("EcalPoint");
-
-  //ECAL hits
-  fListECALhits     = (TClonesArray*)manager->GetObject("EcalHitFastMC");
-
-  //ECAL reconstructed points
-  fListECALrp       = (TClonesArray*)manager->GetObject("EcalRecParticle");
-
-  return kSUCCESS;
-}
-
-//------------------------------------------------------------------------------
-void CbmEcalAnalysis::Exec(Option_t*)
-{
-  // make ECAL analysis
-
-  printf("ECAL analysis: event %d\n",fEvent);
-
-  AnalyzePrimary();
-  AnalyzeMCPointsEdep();
-  AnalyzeMCPointsWall();
-  AnalyzeHits();
-  AnalyzeRecParticles();
-  AnalyzeAcceptanceVectorMesons();
-
-  fEvent++;
-}
-
-//------------------------------------------------------------------------------
-void CbmEcalAnalysis::AnalyzePrimary()
-{
-  // Primary track analysis
-
-  CbmMCTrack *primary;
-  fNprimary = 0;
-  TLorentzVector momentum;
-  Float_t energyTotal = 0;
-  for (Int_t iPrimary=0; iPrimary<fListStack->GetEntries(); iPrimary++) {
-    primary = (CbmMCTrack*)fListStack->At(iPrimary);
-    if (primary->GetMotherId() != -1) continue;
-    fNprimary++;
-    primary->Get4Momentum(momentum);
-    if (strstr(fDebug,"prim"))
-      printf("track %d: id=%d, p=(%f,%f,%f,%f) GeV/c, pt,y,theta=%f,%f,%f\n",
-	     iPrimary,
-	     primary->GetPdgCode(),
-	     momentum.Px(),
-	     momentum.Py(),
-	     momentum.Pz(),
-	     momentum.Energy(),
-	     momentum.Pt(),
-	     momentum.Eta(),
-	     momentum.Theta());
-    fhPrimPabs ->Fill(momentum.P());
-    fhPrimPt   ->Fill(momentum.Pt());
-    fhPrimEta  ->Fill(momentum.Eta());
-    fhPrimTheta->Fill(momentum.Theta());
-    fhPrimPhi  ->Fill(momentum.Phi());
-    fhPrimPtEta->Fill(momentum.Pt(),momentum.Eta());
-    energyTotal+=momentum.P();
-  }
-  printf("Total energy of primaries: %F GeV\n",energyTotal);
-
-  if (strstr(fDebug,"prim"))
-    printf("\tNumber of primaries: %d\n",fNprimary);
-
-  
-}
-
-//------------------------------------------------------------------------------
-void CbmEcalAnalysis::AnalyzeMCPointsEdep()
-{
-  // Monte-Carlo points inside ECAL
-
-  if (fListECALptsEdep == 0) return;
-  if (strstr(fDebug,"mcp"))
-      printf("\tNumber of ECAL MC points in ECAL: %d\n",fListECALptsEdep->GetEntries());
-
-  CbmEcalPointLite* mcPoint=NULL;
-  TVector3 xyz;
-  TLorentzVector momentum;
-
-  Float_t energyTotal = 0;
-  for (Int_t iPoint=0; iPoint<fListECALptsEdep->GetEntries(); iPoint++) {
-    mcPoint = (CbmEcalPointLite*)fListECALptsEdep->At(iPoint); // MC point
-    energyTotal+=mcPoint->GetEnergyLoss();
-  }
-  printf("Total energy in MC points: %F GeV\n",energyTotal);
-}
-
-//------------------------------------------------------------------------------
-void CbmEcalAnalysis::AnalyzeMCPointsWall()
-{
-  // Monte-Carlo points on entrance to ECAL
-
-  if (fListECALptsWall == 0) return;
-  if (strstr(fDebug,"mcp"))
-      printf("\tNumber of ECAL MC points on ECAL: %d\n",fListECALptsWall->GetEntries());
-
-  CbmEcalPoint* mcPoint=NULL;
-  TVector3 xyz;
-  TLorentzVector momentum;
-
-  for (Int_t iPoint=0; iPoint<fListECALptsWall->GetEntries(); iPoint++) {
-    mcPoint = (CbmEcalPoint*)fListECALptsWall->At(iPoint); // MC point
-    CbmMCTrack* track = (CbmMCTrack*)fListStack->At(mcPoint->GetTrackID());
-    if (track->GetPdgCode() != 22 ) continue; // not a photon!
-    mcPoint->Position(xyz);
-    fhMcpXY->Fill(xyz.X(),xyz.Y());
-
-    track->Get4Momentum(momentum);
-    if (strstr(fDebug,"mcp"))
-      printf("MC point %d: id=%d, p=(%f,%f,%f,%f) GeV/c, pt,y,theta=%f,%f,%f\n",
-	     iPoint,
-	     track->GetPdgCode(),
-	     momentum.Px(),
-	     momentum.Py(),
-	     momentum.Pz(),
-	     momentum.Energy(),
-	     momentum.Pt(),
-	     momentum.Eta(),
-	     momentum.Theta());
-    fhMcpPabs ->Fill(momentum.P());
-    fhMcpPt   ->Fill(momentum.Pt());
-    fhMcpEta  ->Fill(momentum.Eta());
-    fhMcpTheta->Fill(momentum.Theta());
-    fhMcpPhi  ->Fill(momentum.Phi());
-    fhMcpPtEta->Fill(momentum.Pt(),momentum.Eta());
-  }
-}
-
-//------------------------------------------------------------------------------
-void CbmEcalAnalysis::AnalyzeHits()
-{
-  // ECAL hit analysis for Fast MC
-
-  if (fListECALhits == 0) return;
-  if (strstr(fDebug,"hit"))
-      printf("\tNumber of ECAL hits: %d\n",fListECALhits->GetEntries());
-
-  CbmEcalHitFastMC* hit=NULL;
-
-  for (Int_t iHit=0; iHit<fListECALhits->GetEntries(); iHit++) {
-    hit = (CbmEcalHitFastMC*)fListECALhits->At(iHit);
-    fhHitXY->Fill(hit->GetX(),hit->GetY());
-    fhHitE ->Fill(hit->GetAmplitude());
-  }
-}
-
-//------------------------------------------------------------------------------
-void CbmEcalAnalysis::AnalyzeRecParticles()
-{
-  // ECAL reconstructed particle analysis
-
-  if (fListECALrp   == 0) return;
-  if (strstr(fDebug,"rp"))
-      printf("\tNumber of ECAL reconstructed particles: %d\n",fListECALrp->GetEntries());
-
-  CbmEcalRecParticle* recpart=NULL;
-
-  for (Int_t iRP=0; iRP<fListECALrp->GetEntries(); iRP++) {
-    recpart = (CbmEcalRecParticle*)fListECALrp->At(iRP);
-    TLorentzVector momentum = recpart->GetMomentum();
-    fhRecPabs->Fill(momentum.P());
-    fhRecPt  ->Fill(momentum.Pt());
-    fhRecYrap->Fill(momentum.Rapidity());
-    fhRecPhi ->Fill(momentum.Phi());
-  }
-}
-
-//------------------------------------------------------------------------------
-void CbmEcalAnalysis::AnalyzeAcceptanceElectrons()
-{
-  // Acceptance analysis
-}
-
-//------------------------------------------------------------------------------
-void CbmEcalAnalysis::AnalyzeAcceptanceVectorMesons()
-{
-  // Acceptance analysis for rho --> e+e-
-
-  if (fListStack == 0 || fListECALptsWall == 0) return;
-  if (!fListStack->GetEntries()) {
-    Fatal("AnalyzeAcceptances","No particles in stack!");
-    return;
-  }
-
-  if ( ((CbmMCTrack*)fListStack->At(0))->GetPdgCode() != fKfVectorMeson)
-    return;
-
-  // if we have the single primary charged particle in event
-
-  CbmMCTrack* primary = (CbmMCTrack*)fListStack->At(0);
-  Double_t y = primary->GetRapidity();;
-  Double_t pt = primary->GetPt();
-  fhPtYrap->Fill(y, pt);
-
-  Bool_t detected = kFALSE;
-  Int_t nDetected = 0;
-  CbmEcalPoint* mcPoint=NULL;
-  // Detected e+e- from J/psi decay
-  if (fKfVectorMeson == 443) {
-    for (Int_t iPoint=0; iPoint<fListECALptsWall->GetEntries(); iPoint++) {
-      mcPoint = (CbmEcalPoint*)fListECALptsWall->At(iPoint); // MC point
-      CbmMCTrack* track = (CbmMCTrack*)fListStack->At(mcPoint->GetTrackID());
-      if (track->GetMotherId()==0 && track->GetPdgCode() == 11) {
-	nDetected++;
-      }
-      else if (track->GetMotherId()==0 && track->GetPdgCode() == -11) {
-	nDetected++;
-      }
-    }
-    if (nDetected == 2) detected = kTRUE;
-  }
-  else if (fKfVectorMeson == 223) {
-    for (Int_t iPoint=0; iPoint<fListECALptsWall->GetEntries(); iPoint++) {
-      mcPoint = (CbmEcalPoint*)fListECALptsWall->At(iPoint); // MC point
-      CbmMCTrack* track       = (CbmMCTrack*)fListStack->At(mcPoint->GetTrackID());
-      CbmMCTrack* trackMother = (CbmMCTrack*)fListStack->At(track->GetMotherId());
-      if (track->GetMotherId()==0 && track->GetPdgCode() == 22) {
-	nDetected++;
-      }
-      else if (trackMother->GetMotherId()==   0 &&
-	       trackMother->GetPdgCode() == 111 &&
-	       track->GetPdgCode()       == 22) {
-	nDetected++;
-      }
-    }
-    if (nDetected == 3) detected = kTRUE;
-  }
-
-  if (detected) fhPtYrapSignal->Fill(y, pt);
-}
-
-//------------------------------------------------------------------------------
-void CbmEcalAnalysis::Finish()
-{}
-
-
-//------------------------------------------------------------------------------
-ClassImp(CbmEcalAnalysis)
diff --git a/ecal/CbmEcalAnalysis.h b/ecal/CbmEcalAnalysis.h
deleted file mode 100644
index cd9b00ca62d49b2e629d5582935fbd44f70077b6..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysis.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalAnalysis header file                  -----
-// -----                  Created 04/01/05                             -----
-// -----                  Yuri Kharlov                                 -----
-// -------------------------------------------------------------------------
-
-#ifndef CBMECALANALYSIS_H
-#define CBMECALANALYSIS_H
-
-#include "FairTask.h"
-#include "CbmStack.h"
-
-class CbmStack;
-class TArrayD;
-class TH1F;
-class TH2F;
-
-class CbmEcalAnalysis : public FairTask {
-
-public:
-
-  CbmEcalAnalysis();
-  CbmEcalAnalysis(const char *name, const char *title="ECAL analysis");
-  virtual ~CbmEcalAnalysis();
-
-  virtual InitStatus Init();
-  void Exec(Option_t* option);
-  void Finish();
-  void SetDebug(Option_t *debug="") {fDebug = debug;}
-  void SetVectorMeson(Int_t kfVectorMeson) {fKfVectorMeson = kfVectorMeson;}
-  void AnalyzePrimary();
-  void AnalyzeMCPointsEdep();
-  void AnalyzeMCPointsWall();
-  void AnalyzeHits();
-  void AnalyzeRecParticles();
-  void AnalyzeAcceptanceElectrons();
-  void AnalyzeAcceptanceVectorMesons();
-
-private:
-
-  TClonesArray* fListStack;      // List of particles in a stack
-  TClonesArray* fListECALptsEdep;// ECAL MC points inside ECAL
-  TClonesArray* fListECALptsWall;// ECAL MC points on entrance to ECAL
-  TClonesArray* fListECALhits;   // ECAL hits
-  TClonesArray* fListECALrp;     // ECAL rec.particles
-
-  Int_t    fEvent;     // current event number
-  Int_t    fNprimary;  // number of primary tracks
-
-  Int_t    fKfVectorMeson;  // PDG code of vector meson
-
-  // Primary particles
-
-  TH1F *fhPrimPabs;  // Abs momentum distribution of primaries
-  TH1F *fhPrimPt;    // Transverse momentum distribution of primaries
-  TH1F *fhPrimEta;   // Pseudorapidity distribution of primaries
-  TH1F *fhPrimTheta; // Polar angle distribution of primaries
-  TH1F *fhPrimPhi;   // Azimuthal angle distribution of primaries
-  TH2F *fhPrimPtEta; // Transverse momentum vs Eta of primaries
-
-  // MC points
-
-  TH1F *fhMcpPabs;   // Abs momentum distribution of detected
-  TH1F *fhMcpPt;     // Transverse momentum distribution of detected
-  TH1F *fhMcpEta;    // Pseudorapidity distribution of detected
-  TH1F *fhMcpTheta;  // Polar angle distribution of detected
-  TH1F *fhMcpPhi;    // Azimuthal angle distribution of detected
-  TH2F *fhMcpPtEta;  // Transverse momentum vs Eta of detected
-  TH2F *fhMcpXY;        // (X,Y) coordinates of MC points
-
-  // Hits
-
-  TH2F *fhHitXY;     // x,y coordinates of ECAL hits
-  TH1F *fhHitE;      // ECAL hit energy
-
-  // Reconstructed particles
-
-  TH1F *fhRecPabs;   // reconstructed absolute momentum
-  TH1F *fhRecPt;     // reconstructed pt
-  TH1F *fhRecYrap;   // reconstructed rapidity
-  TH1F *fhRecPhi;    // reconstructed azimuthal angle
-
-  // Acceptance
-
-  TH2F* fhPtYrap;       // Pt and Y rapidity of primary particles
-  TH2F* fhPtYrapSignal; // Pt and Y rapidity of signal particles
-  TH2F* fhPtYrapAccept; // acceptance
-
-  Option_t *fDebug;    //! debug flag
-
-  CbmEcalAnalysis(const CbmEcalAnalysis&);
-  CbmEcalAnalysis& operator=(const CbmEcalAnalysis&);
-
-  ClassDef(CbmEcalAnalysis,2)
-
-}; 
-
-#endif
diff --git a/ecal/CbmEcalAnalysisBSh.cxx b/ecal/CbmEcalAnalysisBSh.cxx
deleted file mode 100644
index a7493c723cc453865bcd62211340e4587d004a66..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisBSh.cxx
+++ /dev/null
@@ -1,643 +0,0 @@
-#include "CbmEcalAnalysisBSh.h"
-
-#include "FairRootManager.h"
-
-#include "CbmMCTrack.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalParam.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalCalibration.h"
-#include "CbmEcalInf.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-#include "TVector2.h"
-
-#include <iostream>
-
-using namespace std;
-
-Double_t CbmEcalAnalysisBSh::GetPL(Double_t e, Double_t theta)
-{
-// Formula 0: (([0]/sqrt(x))+[1])+([2]*x)
-  Double_t F0P0=-0.511389352836172;
-  Double_t F0P1=0.112078881354459;
-  Double_t F0P2=0.0078928249438169;                                
-  Double_t p0=F0P0/TMath::Sqrt(e)+F0P1+e*F0P2;
-// Formula 1: (([0]*log(x))+[1])+([2]*x)      
-  Double_t F1P0=-0.035601043502675;
-  Double_t F1P1=-0.208980807090046;
-  Double_t F1P2=0.000845322275601826;
-  Double_t p1=F1P0*TMath::Log(e)+F1P1+F1P2*e;
-// Formula 2: ([0]/sqrt(x))+[1]
-  Double_t F2P0=-0.000885986793426617;
-  Double_t F2P1=0.00161447557665425;
-//  Double_t F2P2=0; 
-  Double_t p2=F2P0/TMath::Sqrt(e)+F2P1;
-  Double_t res=p0+theta*p1+theta*theta*p2;
-
-  return res;
-  // For tungsten  calorimeter
-/*
-//# Formula 0: ([0]/sqrt(x))+[1]
-  Double_t F0P0=-0.430846583116232;
-  Double_t F0P1=0.121138651211173;
-  Double_t F0P2=0;
-  Double_t p0=F0P0/TMath::Sqrt(e)+F0P1;
-//# Formula 1: (([0]*log(x))+[1])+([2]*x)
-  Double_t F1P0=-0.0281906348040203;
-  Double_t F1P1=-0.157848864778439;
-  Double_t F1P2=0.00116139446600647;
-  Double_t p1=F1P0*TMath::Log(e)+F1P1+F1P2*e;
-//# Formula 2: ([0]/x)+[1]
-  Double_t F2P0=-0.000357569484705054;
-  Double_t F2P1=0.000840324598592234;
-  Double_t F2P2=0;
-  Double_t p2=F2P0/TMath::Sqrt(e)+F2P1;
-  Double_t res=p0+theta*p1+theta*theta*p2;
-  return res;
-*/
-}
-
-Double_t CbmEcalAnalysisBSh::GetPH(Double_t e, Double_t theta)
-{
-// Formula 3: ([0]/sqrt(x))+[1]
-  Double_t F3P0=0.369616901912454;
-  Double_t F3P1=0.43088175058375;
-//  Double_t F3P2=0;
-  Double_t p0=F3P0/sqrt(e)+F3P1;
-// Formula 4: pol2
-  Double_t F4P0=-0.120449496069499;
-  Double_t F4P1=-0.00896745040885047;
-  Double_t F4P2=0.000338080287821179;
-  Double_t p1=F4P0+F4P1*e+F4P2*e*e;
-// Formula 5: pol2
-  Double_t F5P0=0.00125025561523754;
-  Double_t F5P1=5.1075264956049e-05;
-  Double_t F5P2=-1.81288313960512e-06;
-  Double_t p2=F5P0+F5P1*e+F5P2*e*e;
-  Double_t res=p0+theta*p1+theta*theta*p2;
-  return res;
-  // For tungsten  calorimeter
-/*
-//# Formula 3: ([0]/x)+[1]
-  Double_t F3P0=0.169589556951151;
-  Double_t F3P1=0.391751654446709;
-  Double_t F3P2=0;
-  Double_t p0=F3P0/e+F3P1;
-//# Formula 4: pol2
-  Double_t F4P0=-0.084397709284501;
-  Double_t F4P1=-0.0069293349995729;
-  Double_t F4P2=0.000237137391972728;
-  Double_t p1=F4P0+F4P1*e+F4P2*e*e;
-//# Formula 5: pol2
-  Double_t F5P0=0.000757869675318593;
-  Double_t F5P1=4.10658831181072e-05;
-  Double_t F5P2=-1.11503261196945e-06;
-  Double_t p2=F5P0+F5P1*e+F5P2*e*e;
-  Double_t res=p0+theta*p1+theta*theta*p2;
-  return res;
-*/
-}
-
-/** A default algorithm of precluster formation **/
-void  CbmEcalAnalysisBSh::FormPreCluster(CbmEcalCell* cell)
-{
-  Int_t reg=GetRegion(cell);
-  if (fCalibration==1) reg=fCurAlgo;
-//  Int_t i;
-  Int_t j;
-  Int_t max=-1111;
-  Double_t mine;
-  Double_t maxe;
-  Double_t e;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*> cs;
-  list<CbmEcalCell*>::const_iterator p;
-  CbmEcalCell* min;
-  
-  mine=cell->GetTotalEnergy(); min=cell;
-  maxe=-1.0;
-  /** Find minimum cell **/
-  cell->GetNeighborsList(0, cells);
-  for(p=cells.begin();p!=cells.end();++p)
-    if ((*p)->GetTotalEnergy()<mine)
-    {
-      mine=(*p)->GetTotalEnergy();
-      min=(*p);
-    }
-  for(j=1;j<5;j++)
-  {
-    cell->GetNeighborsList(j, cells);
-    e=0;
-    for(p=cells.begin();p!=cells.end();++p)
-      e+=(*p)->GetTotalEnergy();
-    if (e>maxe)
-    {
-      maxe=e;
-      max=j;
-    }
-  }
-  maxe+=cell->GetTotalEnergy();
-  if (fCal)
-  { if (GetEnergy(maxe, cell)<fMinClusterE[reg]) return; }
-  else
-  { if (maxe<fMinClusterE[reg]) return; }
-  cell->GetNeighborsList(max, cells);
-  cells.push_back(cell);
-  if (find(cells.begin(), cells.end(), min)==cells.end())
-    cells.push_back(min);
-//fPreClusters.push_back(new CbmEcalPreCluster(cells, cell, min)); 
-  fE=GetEnergy(maxe, cell);
-}
-
-/** A new algorithm of precluster formation **/
-void  CbmEcalAnalysisBSh::FormPreClusterNew(CbmEcalCell* cell)
-{
-  Int_t i;
-  Double_t e2m;
-  Double_t e2=0;
-  Int_t imax=-1111;
-  list<CbmEcalCell*>::const_iterator p;
-  list<CbmEcalCell*> cells;
-  Double_t x;
-  Double_t y;
-  Double_t max=-1111;
-  Int_t reg=GetRegion(cell);
-  if (fCalibration==1) reg=fCurAlgo;
-  Int_t cCl2Size=fParI[reg];
-  Int_t ix;
-  Int_t iy;
-  CbmEcalCell* cll;
-  Double_t tx;
-  Double_t ty;
-  TVector2 pv;
-  Double_t r;
-  CbmEcalCell* cls[cCl2Size];
-  Double_t rc[cCl2Size];
-  Int_t j;
-//  Double_t phi;
-//  Double_t tp;
-//  Double_t tq;
-  Double_t e;
-
-  max=cell->GetTotalEnergy();
-  x=cell->GetCenterX()*max;
-  y=cell->GetCenterY()*max;
-
-  for(i=1;i<5;i++)
-  {
-    cell->GetNeighborsList(i, cells);
-    e2m=max;
-    for(p=cells.begin();p!=cells.end();++p)
-      e2m+=(*p)->GetTotalEnergy();
-    if (e2m>e2)
-    { 
-      e2=e2m;
-      imax=i;
-    }
-  }
-  cell->GetNeighborsList(imax, cells);
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    x+=(*p)->GetCenterX()*(*p)->GetTotalEnergy();
-    y+=(*p)->GetCenterY()*(*p)->GetTotalEnergy();
-  }
-  x/=e2; y/=e2;
-
-  for(i=0;i<cCl2Size;i++)
-  {
-    cls[i]=NULL;
-    rc[i]=-1111;
-  }
-  for(ix=-4;ix<5;ix++)
-  for(iy=-4;iy<5;iy++)
-  {
-    tx=cell->GetCenterX(); tx+=ix*(cell->X2()-cell->X1());
-    ty=cell->GetCenterY(); ty+=iy*(cell->Y2()-cell->Y1());
-    cll=fStr->GetCell(tx, ty);
-    if (cll==NULL) continue;
-    r=SolveEllipse(cll, x, y, reg);
-    for(i=0;i<cCl2Size;i++)
-      if (rc[i]<r)
-	break;
-    if (i==cCl2Size) continue;
-    for(j=cCl2Size-1;j>i;j--)
-    {
-      rc[j]=rc[j-1];
-      cls[j]=cls[j-1];
-    }
-    rc[i]=r;
-    cls[i]=cll;
-  }
-
-  e=0;
-  for(j=0;j<cCl2Size;j++)
-    e+=cls[j]->GetTotalEnergy();
-//  cout << e << "	" << GetEnergy(e, cell) << endl;
-  if (fCal)
-  { if (GetEnergy(e, cell)<fMinClusterE[reg]) return; }
-  else
-  { if (e<fMinClusterE[reg]) return; }
-  fE=GetEnergy(e, cell);
-
-//fPreClusters.push_back(new CbmEcalPreCluster(cls, cCl2Size, cell, NULL)); 
-}
-
-Double_t CbmEcalAnalysisBSh::GetEnergy(Double_t e, CbmEcalCell* cell)
-{
-  Double_t x=cell->GetCenterX();
-  Double_t y=cell->GetCenterY();
-  Double_t tantheta=TMath::Sqrt(x*x+y*y)/fInf->GetZPos();
-
-  return fCal->GetEnergy(e, tantheta, GetRegion(cell));
-}
-
-Double_t  CbmEcalAnalysisBSh::SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy, Int_t reg)
-{
-  Double_t cRx=fPar2[reg];		//48*1.6
-  Double_t cRy=fPar3[reg];
-  Int_t cSt=fIntSteps;
-  TVector2 centr(cx, cy);
-  TVector2 t(centr);
-  Double_t gm=centr.Phi();
-  Double_t sgm=TMath::Sin(gm);
-  Double_t cgm=TMath::Cos(gm);
-  Double_t x;
-//  Double_t y;
-  Double_t p=sgm*sgm/cRx+cgm*cgm/cRy;
-  Double_t q=cgm*sgm*(1.0/cRx-1.0/cRy);
-  Double_t r=cgm*cgm/cRx+sgm*sgm/cRy;
-  Double_t d;
-  Double_t ex;
-//  Double_t ey;
-  Double_t y1;
-  Double_t y2;
-  Double_t inte=0;
-  Double_t step=(cell->X2()-cell->X1())/cSt;
-  Double_t fx=step/2.0+cell->X1();
-  Int_t i;
-  
-// cout << fCurAlgo << " " << reg << " " << fPar1[reg] << " " << cRx << " " << cRy << endl;
-  t/=t.Mod(); centr+=t*TMath::Sqrt(fPar1[reg]);
-  for(i=0;i<cSt;i++)
-  {
-    x=step; x*=i; x+=fx;
-    ex=x; ex-=centr.X();
-    d=q*q*ex*ex-p*(r*ex*ex-1);
-    if (d<0) continue;
-    d=TMath::Sqrt(d);
-    y1=-q*ex/p; y2=y1;
-    y1-=d/p; y2+=d/p;
-    y1+=centr.Y(); y2+=centr.Y();
-    if (y1>cell->Y2()) continue;
-    if (y2<cell->Y1()) continue;
-    if (y1<cell->Y1()) y1=cell->Y1();
-    if (y2>cell->Y2()) y2=cell->Y2();
-    inte+=(y2-y1)*step;
-  }
-
-  return inte;
-}
-
-/** Get region number of the cell **/
-Int_t CbmEcalAnalysisBSh::GetRegion(CbmEcalCell* cls)
-{
-  Double_t x=cls->GetCenterX(); x*=x;
-  Double_t y=cls->GetCenterY(); y*=y;
-  x+=y;
-  Double_t r=TMath::Sqrt(x);
-  static Double_t z=fInf->GetZPos();
-  Double_t a=TMath::ATan2(r, z)*TMath::RadToDeg();
-  Int_t i=0;
-  for(;i<fRegions;i++)
-    if (fTheta[i]>a)
-      break;
-
-  return i;
-}
-/** Loop procedure **/
-void CbmEcalAnalysisBSh::Exec(Option_t*)
-{
-  InitTree();
-
-  Int_t i;
-  Int_t j;
-  Int_t n;
-  Int_t imax=-1111;
-//  Int_t dx;
-//  Int_t dy;
-//  Int_t ix;
-//  Int_t iy;
-  Int_t pn;
-  Int_t tri;
-  Double_t xtr;
-  Double_t ytr;
-  Double_t tre;
-  Double_t thetatr;
-  Double_t phtr;
-  Double_t pltr;
-  Double_t dptr;
-  Double_t qhtr;
-  Double_t qltr;
-  TVector3 trp;
-  TVector2 v;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*> cells2;
-  list<CbmEcalCell*>::const_iterator p;
-  list<CbmEcalCell*>::const_iterator p2;
-  Double_t e;
-//  Double_t max=-1111;
- // Double_t efull;
-  Double_t e2m;
-  Double_t e2;
-//  Double_t e3;
-  Double_t x[10000];
-  Double_t y[10000];
-  Double_t eii[10000];
-  Double_t php;
-  Double_t phq;
-  Double_t phi;
-  Int_t phn;
-  Int_t reg;
-  CbmEcalCell* clls[10000];
-  CbmEcalPoint* pt;
-//  CbmEcalCell* cl;
-//  CbmEcalCell* cll;
-  CbmMCTrack* tr;
-  
-  fStr->GetCells(cells);
- // efull=0;
-  n=0;
-  cout << "." << flush;
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    if ((*p)==NULL) continue;
-    e=(*p)->GetTotalEnergy();
-    if (e<0.001) continue;
-    (*p)->GetNeighborsList(0, cells2);
-    for(p2=cells2.begin();p2!=cells2.end();++p2)
-      if ((*p2)->GetTotalEnergy()>e)
-	break;
-    if (p2!=cells2.end())
-      continue;
-    e2=0;
-    for(i=1;i<5;i++)
-    {
-      (*p)->GetNeighborsList(i, cells2);
-      e2m=e;
-      for(p2=cells2.begin();p2!=cells2.end();++p2)
-	e2m+=(*p2)->GetTotalEnergy();
-      if (e2m>e2)
-      {
-	e2=e2m;
-	imax=i;
-      }
-    }
-    (*p)->GetNeighborsList(imax, cells2);
-    clls[n]=(*p);
-    x[n]=(*p)->GetCenterX()*e;
-    y[n]=(*p)->GetCenterY()*e;
-    for(p2=cells2.begin();p2!=cells2.end();++p2)
-    {
-      x[n]+=(*p2)->GetCenterX()*(*p2)->GetTotalEnergy();
-      y[n]+=(*p2)->GetCenterY()*(*p2)->GetTotalEnergy();
-    }
-    x[n]/=e2;
-    y[n]/=e2;
-    eii[n]/=e2;
-    n++;
-  }
-
-  pn=fMC->GetEntries();
-  for(i=0;i<pn;i++)
-  {
-    pt=(CbmEcalPoint*)fMC->At(i);
-    tri=pt->GetTrackID();
-    if (tri<0) continue;
-    tr=(CbmMCTrack*)fMCTr->At(tri);
-    if (tr==NULL) continue;
-    if (tr->GetPdgCode()!=22) continue;
-   if (tr->GetStartZ()>20) continue;
-//    cout << tri << " " << tr << " " << tr->GetPdgCode() << endl << flush;
-    pt->Momentum(trp);
-    tre=trp.Mag();
-    if (tre<0.7) continue;
-    xtr=pt->GetX();
-    ytr=pt->GetY();
-    thetatr=TMath::ATan2(TMath::Sqrt(xtr*xtr+ytr*ytr),pt->GetZ())*TMath::RadToDeg();
-    phtr=GetPH(tre, thetatr);
-    pltr=GetPL(tre, thetatr);
-    dptr=phtr-pltr;
-    phtr+=0.2*dptr;
-    pltr-=0.3*dptr;
-    qhtr=1.0;
-    qltr=-1.0;
-    phn=-1111;
-    fX=xtr;
-    fY=ytr;
-    fEMC=tre;
-    fERes=0.076*0.076/fEMC;
-    fERes+=0.014*0.014;
-    fERes=TMath::Sqrt(fERes)*fEMC;
-    fTh=TMath::ATan2(TMath::Sqrt(fX*fX+fY*fY), pt->GetZ())*TMath::RadToDeg();
-    fE=-1111;
-    for(j=0;j<n;j++)
-    {
-      v.Set(x[j], y[j]);
-      phi=-(v.Phi());
-      v.Set(xtr-x[j], ytr-y[j]);
-      v=v.Rotate(phi);
-      php=v.X(); phq=v.Y();
-      if (php>pltr&&php<phtr&&phq>qltr&&phq<qhtr)
-      {
-	if (phn<0)
-	{
-	  phn=j;
-	  continue;
-	}
-	else
-	{
-	  phn=-1112;
-	  break;
-	}
-      }
-    }
-    if (phn<0)
-    {
-      fTree->Fill();
-      continue;
-    }
-//    cout << clls[phn] << endl;
-    reg=GetRegion(clls[phn]);
-    if (fPreClusterAlgo[reg]==0)
-      FormPreCluster(clls[phn]);
-    if (fPreClusterAlgo[reg]==1)
-      FormPreClusterNew(clls[phn]);    
-    fTree->Fill();
-  }
-}
-
-
-/** Initializes tree **/
-void CbmEcalAnalysisBSh::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("ps","ps ana");
-  fTree->Branch("x", &fX, "x/D");
-  fTree->Branch("y", &fY, "y/D");
-  fTree->Branch("emc", &fEMC, "emc/D");
-  fTree->Branch("e", &fE, "e/D");
-  fTree->Branch("theta", &fTh, "theta/D");
-  fTree->Branch("eres", &fERes, "eres/D");
-}
-
-
-CbmEcalAnalysisBSh::CbmEcalAnalysisBSh()
-  : FairTask(),
-    fTree(NULL),
-    fX(0.),
-    fY(0.),
-    fEMC(0.),
-    fE(0.),
-    fTh(0.),
-    fERes(0.),
-    fCurAlgo(0),
-    fRemoveCharged(0),
-    fUseCalibration(0),
-    fRegions(0),
-    fCalibration(0),
-    fIntSteps(0),
-    fPreClusterAlgo(),
-    fMinClusterE(),
-    fMinMaxE(),
-    fTheta(),
-    fPar1(),
-    fPar2(),
-    fPar3(),
-    fParI(),
-    fMC(NULL),
-    fMCTr(NULL),
-    fStr(NULL),
-    fCal(NULL),
-    fInf(NULL)
-{
-}
-
-CbmEcalAnalysisBSh::CbmEcalAnalysisBSh(const char* name, const Int_t iVerbose, const char* cfgname)
-  : FairTask(name, iVerbose),
-    fTree(NULL),
-    fX(0.),
-    fY(0.),
-    fEMC(0.),
-    fE(0.),
-    fTh(0.),
-    fERes(0.),
-    fCurAlgo(0),
-    fRemoveCharged(0),
-    fUseCalibration(0),
-    fRegions(0),
-    fCalibration(0),
-    fIntSteps(0),
-    fPreClusterAlgo(),
-    fMinClusterE(),
-    fMinMaxE(),
-    fTheta(),
-    fPar1(),
-    fPar2(),
-    fPar3(),
-    fParI(),
-    fMC(NULL),
-    fMCTr(NULL),
-    fStr(NULL),
-    fCal(NULL),
-    fInf(NULL)
-{
-  Int_t i;
-  TString st;
-  CbmEcalParam* par=new CbmEcalParam("ClusterParam", cfgname);
-
-  fRemoveCharged=par->GetInteger("removecharged");
-  fUseCalibration=par->GetInteger("usecalibration");
-  fRegions=par->GetInteger("regions");
-  if (fRegions<0||fRegions>10)
-  {
-    Fatal("CbmEcalClusterFinderV2","Number of calorimeter regions to high.");
-    delete par;
-    return;
-  }
-  fCalibration=par->GetInteger("calibrationmode");
-
-  fIntSteps=par->GetInteger("intsteps");
-  for(i=0;i<fRegions;i++)
-  {
-    st="preclusteralgo["; st+=i; st+="]";
-    fPreClusterAlgo[i]=par->GetInteger(st);
-    st="minclustere["; st+=i; st+="]";
-    fMinClusterE[i]=par->GetDouble(st);
-    st="minmaxe["; st+=i; st+="]";
-    fMinMaxE[i]=par->GetDouble(st);
-    st="theta["; st+=i; st+="]";
-    fTheta[i]=par->GetDouble(st);
-    st="par1["; st+=i; st+="]";
-    fPar1[i]=par->GetDouble(st);
-    st="par2["; st+=i; st+="]";
-    fPar2[i]=par->GetDouble(st);
-    st="par3["; st+=i; st+="]";
-    fPar3[i]=par->GetDouble(st);
-    st="pari["; st+=i; st+="]";
-    fParI[i]=par->GetInteger(st);
-  }
-  delete par;
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisBSh::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fMCTr=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (!fMCTr)
-  {
-    Fatal("Init", "Can't find an array of MC tracks");
-    return kFATAL;
-  }
-  fMC=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (!fMC)
-  {
-    Fatal("Init", "Can't find an array of ECAL points.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fCal=(CbmEcalCalibration*)fManager->GetObject("EcalCalibration");
-  if (!fCal)
-  {
-    Fatal("Init", "Can't find EcalCalibration");
-    return kFATAL;
-  }  
-  fTree=NULL;
-  fInf=fStr->GetEcalInf();
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisBSh::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisBSh)
diff --git a/ecal/CbmEcalAnalysisBSh.h b/ecal/CbmEcalAnalysisBSh.h
deleted file mode 100644
index 635830b4d4b95fece89a140df864137b79c36c1e..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisBSh.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#ifndef CBMECALANALYSISBSH_H
-#define CBMECALANALYSISBSH_H
-
-#include "FairTask.h"
-
-class TTree;
-class TClonesArray;
-class CbmEcalStructure;
-class CbmEcalCell;
-class CbmEcalPreCluster;
-class CbmEcalCalibration;
-class CbmEcalInf;
-
-class CbmEcalAnalysisBSh : public FairTask
-{
-public:
-  CbmEcalAnalysisBSh(const char* name, const Int_t iVerbose=0, const char* cfgname="ana.cfg");
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisBSh();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisBSh() {};
-private:
-  /** Initialize a tree **/
-  void InitTree();
-  /** Get region number of the cell **/
-  Int_t GetRegion(CbmEcalCell* cls);
-
-  Double_t GetPH(Double_t e, Double_t theta);
-  Double_t GetPL(Double_t e, Double_t theta);
-  /** A default algorithm of precluster formation **/
-  void FormPreCluster(CbmEcalCell* cell);
-  /** A new algorithm of precluster formation **/
-  void FormPreClusterNew(CbmEcalCell* cell);
-  /** Find a common area of ellipse and cell**/
-  Double_t SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy, Int_t reg);
-  /** Out tree **/
-  TTree* fTree;			//!
-  Double_t GetEnergy(Double_t e, CbmEcalCell* cell);
-
-  Double_t fX;
-  Double_t fY;
-  Double_t fEMC;
-  Double_t fE;
-  Double_t fTh;
-  Double_t fERes;
-
-
-  Int_t fCurAlgo;
-
-  Int_t fRemoveCharged;
-  Int_t fUseCalibration;
-  Int_t fRegions;
-  Int_t fCalibration;
-  Int_t fIntSteps;
-  Int_t fPreClusterAlgo[10];
-  Double_t fMinClusterE[10];
-  Double_t fMinMaxE[10];
-  Double_t fTheta[10];
-  Double_t fPar1[10];
-  Double_t fPar2[10];
-  Double_t fPar3[10];
-  Int_t fParI[10];
-  /** MC tracks array **/
-  TClonesArray* fMC;		//!
-  TClonesArray* fMCTr;		//!
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;	//!
-  CbmEcalCalibration* fCal;	//!
-  CbmEcalInf* fInf;
-
-  CbmEcalAnalysisBSh(const CbmEcalAnalysisBSh&);
-  CbmEcalAnalysisBSh& operator=(const CbmEcalAnalysisBSh&);
-
-  ClassDef(CbmEcalAnalysisBSh,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisCalib.cxx b/ecal/CbmEcalAnalysisCalib.cxx
deleted file mode 100644
index 5ba1d17cbbf305b5d089255f1fd03a547c6e90be..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisCalib.cxx
+++ /dev/null
@@ -1,163 +0,0 @@
-#include "CbmEcalAnalysisCalib.h"
-
-#include "FairRootManager.h"
-#include "FairTrackParam.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalPoint.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-
-#include <iostream>
-#include <fstream>
-#include <list>
-
-using namespace std;
-
-/** Loop procedure **/
-void CbmEcalAnalysisCalib::Exec(Option_t*)
-{
-  Int_t n=fTracks->GetEntries();
-  Int_t i;
-  FairTrackParam* t;
-  CbmEcalCell* cell;
-  CbmEcalCell* mcell;
-  TVector3 m;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-//  TVector3 m1;
-
-  fEv++;
-  InitTree();
-
-  for(i=0;i<n;i++)
-  {
-    t=(FairTrackParam*)fTracks->At(i);
-    fX=t->GetX();
-    fY=t->GetY();
-    t->Momentum(m);
-    fP=m.Mag();
-    fPX=m.Px();
-    fPY=m.Py();
-    fPZ=m.Pz();
-
-//    m1=m.Unit();
-    cell=fStr->GetCell(fX, fY);
-    if (!cell) continue;
-    mcell=cell;
-    cell->GetNeighborsList(0, cells);
-    for(p=cells.begin();p!=cells.end();++p)
-      if ((*p)->GetTotalEnergy()>mcell->GetTotalEnergy())
-	mcell=(*p);
-
-    mcell->GetNeighborsList(0, cells);
-    for(p=cells.begin();p!=cells.end();++p)
-      if ((*p)->GetTotalEnergy()>mcell->GetTotalEnergy())
-	break;
-
-    if (p!=cells.end()) continue;
-
-    fCX=mcell->GetCenterX();
-    fCY=mcell->GetCenterY();
-    fCE=mcell->GetTotalEnergy();
-    fCellNum=mcell->GetCellNumber();
-    fADC=mcell->ADC();
-    fOE=0.0;
-    for(p=cells.begin();p!=cells.end();++p)
-      fOE+=(*p)->GetTotalEnergy();
-
-    fTree->Fill();
-  }
-
-}
-
-void CbmEcalAnalysisCalib::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("calib", "calib");
-  fTree->Branch("px", &fPX, "px/D");
-  fTree->Branch("py", &fPY, "py/D");
-  fTree->Branch("pz", &fPZ, "pz/D");
-  fTree->Branch("p" , &fP , "p/D");
-  fTree->Branch("x" , &fX , "x/D");
-  fTree->Branch("y" , &fY , "y/D");
-  fTree->Branch("cx", &fCX, "cx/D");
-  fTree->Branch("cy", &fCY, "cy/D");
-  fTree->Branch("ce", &fCE, "ce/D");
-  fTree->Branch("oe", &fOE, "oe/D");
-  fTree->Branch("ev", &fEv, "ev/I");
-  fTree->Branch("cn", &fCellNum, "cn/I");
-  fTree->Branch("adc", &fADC, "adc/I");
-}
-
-CbmEcalAnalysisCalib::CbmEcalAnalysisCalib(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fTree(NULL),
-    fX(0.),
-    fY(0.),
-    fCX(0.),
-    fCY(0.),
-    fP(0.),
-    fCE(0.),
-    fOE(0.),
-    fPX(0.),
-    fPY(0.),
-    fPZ(0.),
-    fEv(0),
-    fCellNum(0),
-    fADC(0),
-    fStr(NULL),
-    fTracks(NULL)
-{
-}
-
-CbmEcalAnalysisCalib::CbmEcalAnalysisCalib()
-  : FairTask(),
-    fTree(NULL),
-    fX(0.),
-    fY(0.),
-    fCX(0.),
-    fCY(0.),
-    fP(0.),
-    fCE(0.),
-    fOE(0.),
-    fPX(0.),
-    fPY(0.),
-    fPZ(0.),
-    fEv(0),
-    fCellNum(0),
-    fADC(0),
-    fStr(NULL),
-    fTracks(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisCalib::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init()", "Can't find calorimeter structure. ");
-    return kFATAL;
-  }
-  fTracks=(TClonesArray*)fManager->GetObject("EcalTrackParam");
-  if (!fTracks)
-  {
-    Fatal("Init()", "Can't find array of reconstructed tracks. ");
-    return kFATAL;
-  }
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisCalib::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisCalib)
diff --git a/ecal/CbmEcalAnalysisCalib.h b/ecal/CbmEcalAnalysisCalib.h
deleted file mode 100644
index 3af1bb08066a886da5959e70875aeeca88f74582..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisCalib.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef CBMECALANALYSISCALIB_H
-#define CBMECALANALYSISCALIB_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class TTree;
-class CbmEcalStructure;
-class TClonesArray;
-
-class CbmEcalAnalysisCalib : public FairTask
-{
-public:
-  CbmEcalAnalysisCalib(const char* name, const Int_t iVerbose);
-
-  /** Default constructor **/
-  CbmEcalAnalysisCalib();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisCalib() {};
-
-private:
-  TTree* fTree;
-  Double_t fX;
-  Double_t fY;
-  Double_t fCX;
-  Double_t fCY;
-  Double_t fP;
-  Double_t fCE;
-  Double_t fOE;
-  Double_t fPX;
-  Double_t fPY;
-  Double_t fPZ;
-  Int_t fEv;
-  Int_t fCellNum;
-  Int_t fADC;
-  void InitTree();
-  CbmEcalStructure* fStr;
-  TClonesArray* fTracks;
-
-  CbmEcalAnalysisCalib(const CbmEcalAnalysisCalib&);
-  CbmEcalAnalysisCalib operator=(const CbmEcalAnalysisCalib&);
-
-  ClassDef(CbmEcalAnalysisCalib,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisCluster.cxx b/ecal/CbmEcalAnalysisCluster.cxx
deleted file mode 100644
index 9d0343b56777b452aec0ad83b4da87e6c5437bc8..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisCluster.cxx
+++ /dev/null
@@ -1,650 +0,0 @@
-#include "CbmEcalAnalysisCluster.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalParam.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-#include "TVector2.h"
-
-#include <iostream>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::list;
-void CbmEcalAnalysisCluster::BuildCluster3(CbmEcalCell* cell, Int_t, Double_t x, Double_t y)
-{
-  const Double_t cTpSigma=TMath::Sqrt(48.0*1.6/2.0);
-  const Double_t cTqSigma=TMath::Sqrt(12.0/2.0);
-  const Int_t cDiv=10;
-  const Int_t cCl2Size=8;
-  Int_t ix;
-  Int_t iy;
-  CbmEcalCell* cll;
-  Double_t tx;
-  Double_t ty;
-  TVector2 p;
-  Double_t r;
-  Double_t r1;
-  CbmEcalCell* cls[cCl2Size];
-  Double_t rc[cCl2Size];
-  Int_t i;
-  Int_t j;
-  TVector2 ox(x, y);
-  Double_t phi=-(ox.Phi());
-  Double_t tp;
-  Double_t tq;
-  Double_t dx;
-  Double_t dy;
-  Double_t xstep;
-  Double_t ystep;
-  Int_t iix;
-  Int_t iiy;
-
-  fCE3=-1111;
-  fCSize3=-1111;
-
-  for(i=0;i<cCl2Size;i++)
-  {
-    cls[i]=NULL;
-    rc[i]=-1111;
-  }
-  fCSize3=0; fCE3=0;
-  xstep=(cell->X2()-cell->X1())/cDiv;
-  ystep=(cell->Y2()-cell->Y1())/cDiv;
-  for(ix=-4;ix<5;ix++)
-  for(iy=-4;iy<5;iy++)
-  {
-    tx=cell->GetCenterX(); tx+=ix*(cell->X2()-cell->X1());
-    ty=cell->GetCenterY(); ty+=iy*(cell->Y2()-cell->Y1());
-    cll=fStr->GetCell(tx, ty);
-    if (cll==NULL) continue;
-    p.Set(tx-x, ty-y); p=p.Rotate(phi);
-    tp=p.X()-TMath::Sqrt(3.0);
-    tq=p.Y();
-    r=0;
-    dx=cll->GetX1()+xstep/2.0;
-    for(iix=0;iix<cDiv;iix++)
-    {
-      dy=cll->GetY1()+ystep/2.0;
-      for(iiy=0;iiy<cDiv;iiy++)
-      {
-        p.Set(dx-x, dy-y); p=p.Rotate(phi);
-        tp=p.X()-TMath::Sqrt(3.0);
-        tq=p.Y();
-//	r1=TMath::Sqrt(tp*tp/cTpSigma+tq*tq/cTqSigma);
-        r1=TMath::Gaus(tp, 0.0, cTpSigma)*TMath::Gaus(tq, 0.0, cTqSigma);
-        r+=r1;
-	dy+=ystep;
-      }
-      dx+=xstep;
-    }
-    for(i=0;i<cCl2Size;i++)
-      if (rc[i]<r)
-	break;
-    if (i==cCl2Size) continue;
-    for(j=cCl2Size-1;j>i;j--)
-    {
-      rc[j]=rc[j-1];
-      cls[j]=cls[j-1];
-    }
-    rc[i]=r;
-    cls[i]=cll;
-  }
-  fCSize3=cCl2Size;
-  for(i=0;i<cCl2Size;i++)
-    fCE3+=cls[i]->GetTotalEnergy();
-}
-
-
-void CbmEcalAnalysisCluster::BuildCluster2(CbmEcalCell* cell, Int_t, Double_t x, Double_t y)
-{
-  Int_t cCl2Size=fC2ParI;
-  Int_t ix;
-  Int_t iy;
-  CbmEcalCell* cll;
-  Double_t tx;
-  Double_t ty;
-  TVector2 p;
-  Double_t r;
-  CbmEcalCell* cls[cCl2Size];
-  Double_t rc[cCl2Size];
-  Int_t i;
-  Int_t j;
-  Double_t phi=0;
-  Double_t tp;
-  Double_t tq;
-
-  fCE2=-1111;
-  fCSize2=-1111;
-
-//  cout << x << "," << y << ": " << phi << endl;
-  for(i=0;i<cCl2Size;i++)
-  {
-    cls[i]=NULL;
-    rc[i]=-1111;
-  }
-  fCSize2=0; fCE2=0;
-  for(ix=-4;ix<5;ix++)
-  for(iy=-4;iy<5;iy++)
-  {
-    tx=cell->GetCenterX(); tx+=ix*(cell->X2()-cell->X1());
-    ty=cell->GetCenterY(); ty+=iy*(cell->Y2()-cell->Y1());
-    cll=fStr->GetCell(tx, ty);
-    if (cll==NULL) continue;
-    p.Set(tx-x, ty-y); p=p.Rotate(phi);
-    // fC2Par1=3.0;
-    tp=p.X()-TMath::Sqrt(fC2Par1);
-    tq=p.Y();
-    // fC2Par2=72
-    // fC2Par3=12
-    r=TMath::Sqrt(tp*tp/fC2Par2+tq*tq/fC2Par3);
-    r=SolveEllipse(cll, x, y);
-    for(i=0;i<cCl2Size;i++)
-      if (rc[i]<r)
-	break;
-    if (i==cCl2Size) continue;
-    for(j=cCl2Size-1;j>i;j--)
-    {
-      rc[j]=rc[j-1];
-      cls[j]=cls[j-1];
-    }
-    rc[i]=r;
-    cls[i]=cll;
-  }
-  fCSize2=cCl2Size;
-  for(i=0;i<cCl2Size;i++)
-    fCE2+=cls[i]->GetTotalEnergy();
-}
-
-Double_t CbmEcalAnalysisCluster::SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy)
-{
-  Double_t cRx=fC2Par2;		//48*1.6
-  Double_t cRy=fC2Par3;
-  const Int_t cSt=100;
-  TVector2 centr(cx, cy);
-  TVector2 t(centr);
-  Double_t gm=centr.Phi();
-  Double_t sgm=TMath::Sin(gm);
-  Double_t cgm=TMath::Cos(gm);
-  Double_t x;
-//  Double_t y;
-  Double_t p=sgm*sgm/cRx+cgm*cgm/cRy;
-  Double_t q=cgm*sgm*(1.0/cRx-1.0/cRy);
-  Double_t r=cgm*cgm/cRx+sgm*sgm/cRy;
-  Double_t d;
-  Double_t ex;
-//  Double_t ey;
-  Double_t y1;
-  Double_t y2;
-  Double_t inte=0;
-  Double_t step=(cell->X2()-cell->X1())/cSt;
-  Double_t fx=step/2.0+cell->X1();
-  Int_t i;
-  
-  t/=t.Mod(); centr+=t*TMath::Sqrt(fC2Par1);
-  for(i=0;i<cSt;i++)
-  {
-    x=step; x*=i; x+=fx;
-    ex=x; ex-=centr.X();
-    d=q*q*ex*ex-p*(r*ex*ex-1);
-    if (d<0) continue;
-    d=TMath::Sqrt(d);
-    y1=-q*ex/p; y2=y1;
-    y1-=d/p; y2+=d/p;
-    y1+=centr.Y(); y2+=centr.Y();
-    if (y1>cell->Y2()) continue;
-    if (y2<cell->Y1()) continue;
-    if (y1<cell->Y1()) y1=cell->Y1();
-    if (y2>cell->Y2()) y2=cell->Y2();
-    inte+=(y2-y1)*step;
-  }
-
-  return inte;
-}
-
-/** Build a cluster information **/
-void CbmEcalAnalysisCluster::BuildCluster(CbmEcalCell* cell, Int_t, Double_t x, Double_t y)
-{
-//  static CbmEcalInf* inf=fStr->GetEcalInf();
-  CbmEcalCell* cll;
-  Int_t ix;
-  Int_t iy;
-  Double_t tx;
-  Double_t ty;
-//  Double_t t;
-  Int_t i;
-  Int_t j;
-  TVector2 ox(x, y);
-  TVector2 oy;
-  TVector2 p;
-  Double_t tp;
-  Double_t tq;
-  Double_t phi;
-  Double_t r;
-
-  ox/=ox.Mod(); oy=ox; phi=-(ox.Phi());
-  for(i=0;i<fClsSize;i++)
-  {
-    fClsP[i]=-1111;
-    fClsQ[i]=-1111;
-    fClsE[i]=-1111;
-    fClsX[i]=-1111;
-    fClsY[i]=-1111;
-    fClsSE[i]=-1111;
-    fClsN[i]=-1111;
-  }
-
-  for(ix=-5;ix<6;ix++)
-  for(iy=-5;iy<6;iy++)
-  {
-    tx=cell->GetCenterX(); tx+=ix*(cell->X2()-cell->X1());
-    ty=cell->GetCenterY(); ty+=iy*(cell->Y2()-cell->Y1());
-    cll=fStr->GetCell(tx, ty);
-    if (cll!=NULL)
-    {
-      for(i=0;i<fClsSize;i++)
-	if (fClsE[i]<cll->GetTotalEnergy())
-	  break;
-      if (i==fClsSize) continue;
-      for(j=fClsSize-1;j>i;j--)
-      {
-	fClsP[j]=fClsP[j-1];
-	fClsQ[j]=fClsQ[j-1];
-	fClsX[j]=fClsX[j-1];
-	fClsY[j]=fClsY[j-1];
-	fClsE[j]=fClsE[j-1];
-	fClsS[j]=fClsS[j-1];
-      }
-      tx=cll->GetCenterX();
-      ty=cll->GetCenterY();
-      fClsX[i]=tx;
-      fClsY[i]=ty;
-      fClsE[i]=cll->GetTotalEnergy();
-/*      p.Set(tx-x, ty-y); q=p;
-      t=p*ox;
-      p=ox; p*=t;
-      q-=p;
-*/
-//      fClsP[i]=t;
-
-      p.Set(tx-x, ty-y); p=p.Rotate(phi);
-      fClsP[i]=p.X();
-      fClsQ[i]=p.Y();
-      fClsS[i]=SolveEllipse(cll, x, y);
-//      cout << phi << ". " << p.X() << ", " << p.Y() << " : " <<  t << ", " << q.Mod() << " : " << ox.X() << ", " << ox.Y() <<  endl; 
-//      if (q*oy>0) fClsQ[i]=q.Mod(); else fClsQ[i]=-q.Mod();
-/*
-      cout << ox.X() << ", " << ox.Y() << endl;
-      cout << p.X() << ", " << p.Y() << endl;
-      cout << q.X() << ", " << q.Y() << endl;
-      cout << endl;
-*/
-    }
-  }
-
-  fClsSE[0]=fClsE[0]; fClsN[0]=0;
-  for(i=1;i<fClsSize;i++)
-  {
-    fClsSE[i]=fClsSE[i-1]+fClsE[i];
-    fClsN[i]=i;
-  }
-
-  fCSize=0; fCE=0;
-  for(ix=-4;ix<5;ix++)
-  for(iy=-4;iy<5;iy++)
-  {
-    tx=cell->GetCenterX(); tx+=ix*(cell->X2()-cell->X1());
-    ty=cell->GetCenterY(); ty+=iy*(cell->Y2()-cell->Y1());
-    cll=fStr->GetCell(tx, ty);
-    if (cll==NULL) continue;
-    p.Set(tx-x, ty-y); p=p.Rotate(phi);
-    tp=p.X()-TMath::Sqrt(3.0);
-    tq=p.Y();
-    r=TMath::Sqrt(tp*tp/48+tq*tq/12);
-    if (r>1.0) continue;
-    if (SolveEllipse(cll, x, y)/6.25<0.75) continue;
-    fCSize++;
-    fCE+=cll->GetTotalEnergy();
-  }
-}
-
-/** Loop procedure **/
-void CbmEcalAnalysisCluster::Exec(Option_t*)
-{
-  fEvent++;
-  if (fVerbose>0)
-    Info("Exec", "Event %d.", fEvent);
-  InitTree();
-
-  static CbmEcalInf* inf=fStr->GetEcalInf();
-  Int_t i;
-//  Int_t n;
-  Int_t imax=-1111;
-  Int_t dx;
-  Int_t dy;
-  Int_t ix;
-  Int_t iy;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t e;
-  Double_t x;
-  Double_t y;
-//  Double_t r;
-  Double_t max=-1111;
-  Double_t efull;
-  Double_t e2m;
-  Double_t e2;
-  Double_t e3;
-  CbmEcalPoint* pt;
-  CbmEcalCell* cl=NULL;
-  CbmEcalCell* cll;
-  
-  fStr->GetCells(cells);
-  efull=0;
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    if ((*p)==NULL) continue;
-    e=(*p)->GetTotalEnergy();
-    efull+=e;
-    if (e>max)
-    {
-      max=e;
-      cl=(*p);
-    }
-  }
-  fEMax=max;
-  fEFull=efull;
-//cells.sort(CbmEcalClusterSortProcess());
-  if (max<=0) return;
-  cl->GetNeighborsList(0, cells);
-  e3=max;
-  for(p=cells.begin();p!=cells.end();++p)
-    e3+=(*p)->GetTotalEnergy();
-  fE3=e3;
-  e2=0;
-  for(i=1;i<5;i++)
-  {
-    cl->GetNeighborsList(i, cells);
-    e2m=max;
-    for(p=cells.begin();p!=cells.end();++p)
-      e2m+=(*p)->GetTotalEnergy();
-    if (e2m>e2)
-    { 
-      e2=e2m;
-      imax=i;
-    }
-  }
-  fE2=e2;
-  
-  cl->GetNeighborsList(imax, cells);
-  fMX=cl->GetCenterX();
-  fMY=cl->GetCenterY();
-  fGX=cl->GetCenterX()*cl->GetTotalEnergy(); 
-  fGY=cl->GetCenterY()*cl->GetTotalEnergy(); 
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    fGX+=(*p)->GetCenterX()*(*p)->GetTotalEnergy();
-    fGY+=(*p)->GetCenterY()*(*p)->GetTotalEnergy();
-  }
-  fGX/=e2; fGY/=e2;
-  BuildCluster(cl, imax, fGX, fGY);
-  BuildCluster2(cl, imax, fGX, fGY);
-  BuildCluster3(cl, imax, fGX, fGY);
-  cl->GetNeighborsList(0, cells);
-  fGX2=cl->GetCenterX()*cl->GetTotalEnergy(); 
-  fGY2=cl->GetCenterY()*cl->GetTotalEnergy(); 
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    fGX2+=(*p)->GetCenterX()*(*p)->GetTotalEnergy();
-    fGY2+=(*p)->GetCenterY()*(*p)->GetTotalEnergy();
-  }
-  fGX2/=e3; fGY2/=e3;
-
-  pt=(CbmEcalPoint*)fMC->At(0);
-  fX=-1111; fY=-1111; fTheta=-1111;
-  if (pt!=NULL)
-  {
-    fX=pt->GetX();
-    fY=pt->GetY();
-    fTheta=TMath::ATan(TMath::Sqrt(fX*fX+fY*fY)/inf->GetZPos());
-    fPhi=TMath::ATan2(fY, fX);
-  }
-  fE4=0; fE5=0; fE5_2=0;
-  if (fX!=-1111)
-  {
-    if (fX>0) dx=1; else dx=0;
-    if (fY>0) dy=1; else dy=0;
-    for(ix=-2;ix<2;ix++)
-    for(iy=-2;iy<2;iy++)
-    {
-      x=cl->GetCenterX(); x+=(ix+dx)*(cl->X2()-cl->X1());
-      y=cl->GetCenterY(); y+=(iy+dy)*(cl->Y2()-cl->Y1());
-      cll=fStr->GetCell(x, y);
-      if (cll!=NULL)
-	fE4+=cll->GetTotalEnergy();
-    }
-//    if (fX>0) dx=2; else dx=0;
-//    if (fY>0) dy=2; else dy=0;
-    for(ix=-2;ix<3;ix++)
-    for(iy=-2;iy<3;iy++)
-    {
-      x=cl->GetCenterX(); x+=ix*(cl->X2()-cl->X1());
-      y=cl->GetCenterY(); y+=iy*(cl->Y2()-cl->Y1());
-      cll=fStr->GetCell(x, y);
-      if (cll!=NULL)
-	fE5+=cll->GetTotalEnergy();
-    }
-    if (fX>0) dx=2; else dx=0;
-    if (fY>0) dy=2; else dy=0;
-    for(ix=-3;ix<2;ix++)
-    for(iy=-3;iy<2;iy++)
-    {
-      x=cl->GetCenterX(); x+=(ix+dx)*(cl->X2()-cl->X1());
-      y=cl->GetCenterY(); y+=(iy+dy)*(cl->Y2()-cl->Y1());
-      cll=fStr->GetCell(x, y);
-      if (cll!=NULL)
-	fE5_2+=cll->GetTotalEnergy();
-    }
-  }
-  else
-  {
-    fE4=-1111;
-    fE5=-1111;
-    fE5_2=-1111;
-  }
-  fTree->Fill();
-}
-
-
-/** Initializes tree **/
-void CbmEcalAnalysisCluster::InitTree()
-{
-  if (fTree) return;
-  TString n;
-  fClsSize=20;
-  fClsP=new Double_t[fClsSize];
-  fClsQ=new Double_t[fClsSize];
-  fClsE=new Double_t[fClsSize];
-  fClsSE=new Double_t[fClsSize];
-  fClsX=new Double_t[fClsSize];
-  fClsY=new Double_t[fClsSize];
-  fClsS=new Double_t[fClsSize];
-  fClsN=new Int_t[fClsSize];
-  fTree=new TTree("cls","Various information about cluster");
-  fTree->Branch("ev", &fEvent, "ev/I");
-  fTree->Branch("x", &fX, "x/D");
-  fTree->Branch("y", &fY, "y/D");
-  fTree->Branch("gx", &fGX, "gx/D");
-  fTree->Branch("gy", &fGY, "gy/D");
-  fTree->Branch("gx2", &fGX2, "gx2/D");
-  fTree->Branch("gy2", &fGY2, "gy2/D");
-  fTree->Branch("mx", &fMX, "mx/D");
-  fTree->Branch("my", &fMY, "my/D");
-  fTree->Branch("z", &fZ, "z/D");
-  fTree->Branch("efull", &fEFull, "efull/D");
-  fTree->Branch("emax", &fEMax, "emax/D");
-  fTree->Branch("e2", &fE2, "e2/D");
-  fTree->Branch("e3", &fE3, "e3/D");
-  fTree->Branch("e4", &fE4, "e4/D");
-  fTree->Branch("e5", &fE5, "e5/D");
-  fTree->Branch("e5_2", &fE5_2, "e5_2/D");
-  fTree->Branch("theta", &fTheta, "theta/D");
-  fTree->Branch("phi", &fPhi, "phi/D");
-  fTree->Branch("ce", &fCE, "ce/D");
-  fTree->Branch("csize", &fCSize, "csize/I");
-  fTree->Branch("ce2", &fCE2, "ce2/D");
-  fTree->Branch("csize2", &fCSize2, "csize2/I");
-  fTree->Branch("ce3", &fCE3, "ce3/D");
-  fTree->Branch("csize3", &fCSize3, "csize3/I");
-  n="clsp["; n+=fClsSize; n+="]/D"; fTree->Branch("clsp", fClsP, n);
-  n="clsq["; n+=fClsSize; n+="]/D"; fTree->Branch("clsq", fClsQ, n);
-  n="clsx["; n+=fClsSize; n+="]/D"; fTree->Branch("clsx", fClsX, n);
-  n="clsy["; n+=fClsSize; n+="]/D"; fTree->Branch("clsy", fClsY, n);
-  n="clse["; n+=fClsSize; n+="]/D"; fTree->Branch("clse", fClsE, n);
-  n="clsse["; n+=fClsSize; n+="]/D"; fTree->Branch("clsse", fClsSE, n);
-  n="clss["; n+=fClsSize; n+="]/D"; fTree->Branch("clss", fClsS, n);
-  n="clsn["; n+=fClsSize; n+="]/I"; fTree->Branch("clsn", fClsN, n);
-}
-
-CbmEcalAnalysisCluster::CbmEcalAnalysisCluster()
-  : FairTask(),
-    fTree(NULL),
-    fEvent(0),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fEFull(0.),
-    fEMax(0.),
-    fE2(0.),
-    fE3(0.),
-    fE4(0.),
-    fE5(0.),
-    fE5_2(0.),
-    fGX(0.),
-    fGY(0.),
-    fGX2(0.),
-    fGY2(0.),
-    fMX(0.),
-    fMY(0.),
-    fTheta(0.),
-    fPhi(0.),
-    fClsSize(0),
-    fClsX(NULL),
-    fClsY(NULL),
-    fClsP(NULL),
-    fClsQ(NULL),
-    fClsE(NULL),
-    fClsSE(NULL),
-    fClsN(NULL),
-    fClsS(NULL),
-    fCSize(0),
-    fCE(0.),
-    fCE2(0.),
-    fCSize2(0),
-    fCE3(0.),
-    fCSize3(0),
-    fC2ParI(0),
-    fC2Par1(0.),
-    fC2Par2(0.),
-    fC2Par3(0.),
-    fMC(NULL),
-    fStr(NULL)
-{
-}
-
-CbmEcalAnalysisCluster::CbmEcalAnalysisCluster(const char* name, const Int_t iVerbose, const char* cfgname)
-  : FairTask(name, iVerbose),
-    fTree(NULL),
-    fEvent(0),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fEFull(0.),
-    fEMax(0.),
-    fE2(0.),
-    fE3(0.),
-    fE4(0.),
-    fE5(0.),
-    fE5_2(0.),
-    fGX(0.),
-    fGY(0.),
-    fGX2(0.),
-    fGY2(0.),
-    fMX(0.),
-    fMY(0.),
-    fTheta(0.),
-    fPhi(0.),
-    fClsSize(0),
-    fClsX(NULL),
-    fClsY(NULL),
-    fClsP(NULL),
-    fClsQ(NULL),
-    fClsE(NULL),
-    fClsSE(NULL),
-    fClsN(NULL),
-    fClsS(NULL),
-    fCSize(0),
-    fCE(0.),
-    fCE2(0.),
-    fCSize2(0),
-    fCE3(0.),
-    fCSize3(0),
-    fC2ParI(0),
-    fC2Par1(TMath::Sqrt(3)),
-    fC2Par2(48.0*1.6),
-    fC2Par3(12.),
-    fMC(NULL),
-    fStr(NULL)
-{
-  CbmEcalParam* par=new CbmEcalParam("ClusterAnalysisParam", cfgname);
-  fC2ParI=par->GetInteger("cpari");
-  fC2Par1=par->GetDouble("cpar1");
-  fC2Par2=par->GetDouble("cpar2");
-  fC2Par3=par->GetDouble("cpar3");
-  delete par;
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisCluster::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fMC=(TClonesArray*)fManager->GetObject("ECALPoint");
-  if (!fMC)
-  {
-    Fatal("Init", "Can't find an array of ECAL points.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  
-  fTree=NULL;
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisCluster::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisCluster)
diff --git a/ecal/CbmEcalAnalysisCluster.h b/ecal/CbmEcalAnalysisCluster.h
deleted file mode 100644
index 2ff465e27d8405b94c446374c2ae208682ec429a..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisCluster.h
+++ /dev/null
@@ -1,96 +0,0 @@
-#ifndef CBMECALANALYSISCLUSTER_H
-#define CBMECALANALYSISCLUSTER_H
-
-#include "FairTask.h"
-
-class TTree;
-class TClonesArray;
-class CbmEcalStructure;
-class CbmEcalCell;
-
-class CbmEcalAnalysisCluster : public FairTask
-{
-public:
-  CbmEcalAnalysisCluster(const char* name, const Int_t iVerbose=0, const char* cfgname="ana.cfg");
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisCluster();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisCluster() {};
-private:
-  /** Build a cluster information **/
-  void BuildCluster(CbmEcalCell* cell, Int_t clusters, Double_t x, Double_t y);
-  /** Build a cluster information **/
-  void BuildCluster2(CbmEcalCell* cell, Int_t cls, Double_t x, Double_t y);
-  /** Build a cluster information **/
-  void BuildCluster3(CbmEcalCell* cell, Int_t cls, Double_t x, Double_t y);
-  /** Initialize a tree **/
-  void InitTree();
-  /** Out tree **/
-  TTree* fTree;			//!
-  Double_t SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy);
-
-  /** Event number **/
-  Int_t fEvent;
-  Double_t fX;
-  Double_t fY;
-  Double_t fZ;
-  Double_t fEFull;
-  Double_t fEMax;
-  Double_t fE2;
-  Double_t fE3;
-  Double_t fE4;
-  Double_t fE5;
-  Double_t fE5_2;
-  Double_t fGX;
-  Double_t fGY;
-  Double_t fGX2;
-  Double_t fGY2;
-  Double_t fMX;
-  Double_t fMY;
-  Double_t fTheta;
-  Double_t fPhi;
-  Int_t fClsSize;
-  Double_t* fClsX;		//!
-  Double_t* fClsY;		//!
-  Double_t* fClsP;		//!
-  Double_t* fClsQ;		//!
-  Double_t* fClsE;		//!
-  Double_t* fClsSE;		//!
-  Int_t* fClsN;			//!
-  Double_t* fClsS;		//!
-  Int_t fCSize;
-  Double_t fCE;
-  Double_t fCE2;
-  Int_t fCSize2;
-  Double_t fCE3;
-  Int_t fCSize3;
-  Int_t fC2ParI;
-  Double_t fC2Par1;
-  Double_t fC2Par2;
-  Double_t fC2Par3;
-
-
-  /** MC tracks array **/
-  TClonesArray* fMC;		//!
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;	//!
-
-  CbmEcalAnalysisCluster(const CbmEcalAnalysisCluster&);
-  CbmEcalAnalysisCluster& operator=(const CbmEcalAnalysisCluster&);
-
-  ClassDef(CbmEcalAnalysisCluster,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisDS.cxx b/ecal/CbmEcalAnalysisDS.cxx
deleted file mode 100644
index 2f2b2ad09993c7c29ea2c02ecf79c5b6e4d6d1f9..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisDS.cxx
+++ /dev/null
@@ -1,482 +0,0 @@
-/* $Id: CbmEcalAnalysisDS.cxx,v 1.9 2006/09/18 07:58:04 prokudin Exp $*/
-
-/*
- * $Log: CbmEcalAnalysisDS.cxx,v $
- * Revision 1.9  2006/09/18 07:58:04  prokudin
- * First implementation of SCurve library
- *
- * Revision 1.3  2006/08/30 13:16:45  prokudin
- * Bug huntong
- *
- * Revision 1.2  2006/08/25 19:17:48  prokudin
- * Energy in cell added. Minor bug fixed.
- *
- * Revision 1.1  2006/08/17 18:16:35  prokudin
- * first version of UrqmdCalibrator
- *
- */
-
-#include "CbmEcalAnalysisDS.h"
-
-#include "CbmEcalInf.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalPointLite.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalSCurveLib.h"
-#include "CbmEcalCellMC.h"
-
-#include "FairRunAna.h"
-#include "FairRuntimeDb.h"
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TParticlePDG.h"
-#include "TDatabasePDG.h"
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::list;
-
-
-/** Loop procedure **/
-void CbmEcalAnalysisDS::Exec(Option_t*)
-{
-  list<CbmEcalPoint*>::const_iterator p;
-  fEvent++;
-  if (fVerbose>0)
-    cout << "Processing event " << fEvent << "." << endl; 
-  FillStructure();
-  InitTree();
-  FindPeaks();
-
-}
-
-
-/** Fills ECAL structure **/
-void CbmEcalAnalysisDS::FillStructure()
-{
-  CbmEcalPointLite* pt;
-  CbmMCTrack* track;
-  CbmEcalCellMC* cell;
-  Int_t ten;
-  UInt_t n;
-  Bool_t isPS;
-
-  fStr->ResetModules();
-
-  n=fLitePoints->GetEntriesFast();
-  if (fVerbose>0)
-  {
-    cout << "Number of input lite ECAL points " << n;
-    cout << "." << endl;
-  }
-  for(UInt_t j=0; j<n; j++)
-  {
-    pt=(CbmEcalPointLite*)fLitePoints->At(j);
-    cell=(CbmEcalCellMC*)fStr->GetCell(pt->GetDetectorID(), ten, isPS);
-    if (pt->GetEnergyLoss()<0)
-      cout << "Here" << pt->GetEnergyLoss() << endl;
-    if (ten!=0) continue;
-    if (isPS)
-      ; // cell->AddPSEnergy(pt->GetEnergyLoss()); preshower removed
-    else
-      cell->AddEnergy(pt->GetEnergyLoss());
-
-    track=(CbmMCTrack*)fMCTracks->At(pt->GetTrackID());
-    if (track->GetPdgCode()!=fPDGType) continue;
-    if (isPS)
-      ; // cell->AddTrackPSEnergy(pt->GetTrackID(), pt->GetEnergyLoss()); preshower removed
-    else
-      cell->AddTrackEnergy(pt->GetTrackID(), pt->GetEnergyLoss());
-  } 
-}
-
-/** Initializes tree **/
-void CbmEcalAnalysisDS::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("ECALcal","Ecal Calibration tree");
-  fTree->Branch("ev",&fEvent,"ev/I");
-  fTree->Branch("type",&fType,"type/I");
-  fTree->Branch("dtype",&fDiffType,"dtype/I");
-  fTree->Branch("mcode",&fMotherCode,"mcode/I");
-  fTree->Branch("mcx",&fMCX,"mcx/F");
-  fTree->Branch("mcy",&fMCY,"mcy/F");
-  fTree->Branch("cellx",&fCellX,"cellx/F");
-  fTree->Branch("celly",&fCellY,"celly/F");
-  fTree->Branch("maxcellx",&fMaxCellX,"maxcellx/F");
-  fTree->Branch("maxcelly",&fMaxCellY,"maxcelly/F");
-  fTree->Branch("mce",&fMCE,"mce/F");
-  fTree->Branch("mcpx",&fMCPX,"mcpx/F");
-  fTree->Branch("mcpy",&fMCPY,"mcpy/F");
-  fTree->Branch("mcpz",&fMCPZ,"mcpz/F");
-  fTree->Branch("pse",&fPSE,"pse/F");
-  fTree->Branch("e",&fE,"e/F");
-  fTree->Branch("e2",&fE2x2,"e2/F");
-  fTree->Branch("e3",&fE3x3,"e3/F");
-  fTree->Branch("te",&fTotalTrackEnergy,"te/F");
-  fTree->Branch("ereco",&fEReco,"ereco/F");
-  fTree->Branch("ax",&fAX,"ax/F");
-  fTree->Branch("ay",&fAY,"ay/F");
-  fTree->Branch("xreco",&fXReco,"xreco/F");
-  fTree->Branch("yreco",&fYReco,"yreco/F");
-  fTree->Branch("nd",&fND,"nd/F");
-  fTree->Branch("ncode",&fNCode,"ncode/I");
-}
-
-/** Populates fList with particles **/
-void CbmEcalAnalysisDS::FindPeaks()
-{
-  list<CbmEcalCell*> all;
-  list<CbmEcalCell*> neib;
-  list<CbmEcalCell*>::const_iterator pt;
-  list<CbmEcalCell*>::const_iterator pv;
-
-  fStr->GetCells(all);
-
-  for(pt=all.begin();pt!=all.end();++pt)
-  {
-    neib.clear();
-    (*pt)->GetNeighborsList(0, neib);
-    for(pv=neib.begin();pv!=neib.end();++pv)
-      if ((*pv)->GetEnergy()>(*pt)->GetEnergy()) 
-	break;
-    if (pv!=neib.end())
-      continue;
-    FillEnergies(*pt);
-  }
-}
-
-/** Returns incoming particle energy **/
-Float_t CbmEcalAnalysisDS::GetEnergy(Float_t e2, CbmEcalCell* cell)
-{
-  Int_t type=cell->GetType();
-  Float_t x=cell->GetCenterX();
-  Float_t y=cell->GetCenterY();
-  Float_t tantheta=TMath::Sqrt(x*x+y*y)/fInf->GetZPos();
-  Float_t a=fP0a[type]+fP1a[type]*tantheta;
-  Float_t b=fP0b[type]+fP1b[type]*tantheta;
-  Float_t d=TMath::Sqrt(a*a+4.0*e2*b);
-  Float_t res=(-a+d)/2.0/b;
-  return res*res;
-}
-
-/** Returns mass of particle with pdgcode **/
-Float_t __GetMass(Int_t pdgcode)
-{
-    Double_t mass=-1;
-    TParticlePDG* fParticlePDG=TDatabasePDG::Instance()->GetParticle(pdgcode);
-
-    if (fParticlePDG)
-     mass=fParticlePDG->Mass();
-
-    return mass;
-}
-
-Int_t __CalculateDiffType(CbmEcalCell* cell)
-{
-  Float_t dx=cell->GetX2()-cell->GetX1();
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-
-  cells.clear();
-  cell->GetNeighborsList(0, cells);
-  for(p=cells.begin(); p!=cells.end(); ++p)
-   if (TMath::Abs((*p)->GetX2()-(*p)->GetX1()-dx)>0.001)
-     return 1;
-
-  return 0;
-}
-
-/** Calculates ECAL response for cell **/
-void CbmEcalAnalysisDS::FillEnergies(CbmEcalCell* cell)
-{
-  Float_t en;
-  Float_t maxe;
-  Int_t type;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-
-  cells.clear();
-
-  fType=cell->GetType();
-  fDiffType=0;
-
-  cell->GetNeighborsList(0,cells);
-  fE=cell->GetEnergy();
-  en=cell->GetEnergy();
-  type=cell->GetType();
-  fAX=0; fAY=0;
-  for(p=cells.begin();p!=cells.end();++p) 
-  {
-    if (type!=(*p)->GetType())
-    {
-      fAX=-1111;
-      fAY=-1111;
-      type=-1111;
-      fDiffType=1;
-    } else
-    {
-      if (cell->GetCenterX()+0.001<(*p)->GetCenterX())
-	fAX+=(*p)->GetEnergy();
-      else
-      if (cell->GetCenterX()-0.001>(*p)->GetCenterX())
-	fAX-=(*p)->GetEnergy();
-      if (cell->GetCenterY()+0.001<(*p)->GetCenterY())
-	fAY+=(*p)->GetEnergy();
-      else
-      if (cell->GetCenterY()-0.001>(*p)->GetCenterY())
-	fAY-=(*p)->GetEnergy();
-    }
-    en+=(*p)->GetEnergy();
-  }
-  fE3x3=en;
-
-  if (fAX!=-1111)
-  {
-    fAX/=fE3x3;
-    fAY/=fE3x3;
-  }
-
-  maxe=0;
-  for(Int_t i=1;i<5;i++)
-  {
-    cell->GetNeighborsList(i,cells);
-    en=cell->GetEnergy();
-    for(p=cells.begin();p!=cells.end();++p) 
-      en+=(*p)->GetEnergy();
-    if (maxe<en)
-      maxe=en;
-  }
-  fE2x2=maxe;
-
-  fCellX=cell->GetCenterX();
-  fCellY=cell->GetCenterY();
-  
-  fPSE=0;
-
-  if (fE2x2<0.05) return; 
-  fEReco=GetEnergy(fE2x2+fPSE, cell);
-  if (fAX!=-1111)
-    fXReco=fLib->GetX(fAX, fEReco, cell);
-  else
-    fXReco=-1111;
-  if (fXReco!=-1111)
-    fXReco+=cell->GetCenterX();
-  
-  if (fAY!=-1111)
-    fYReco=fLib->GetY(fAY, fEReco, cell);
-  else
-    fYReco=-1111;
-  
-  if (fYReco!=-1111)
-    fYReco+=cell->GetCenterY();
-  if ((fYReco==-1111||fXReco==-1111)&&fXReco!=-1111)
-  {
-     cout << fXReco << "  " << fAX << "	" << fYReco << "	" << fAY << endl;
-     cout << "->" << fMCE << " " << fEReco << endl;
-  }
-  FindND();
-}
-
-/** Calculate distance to nearest track **/
-void CbmEcalAnalysisDS::FindND()
-{
-  CbmEcalPoint* pt;
-  CbmEcalPoint* mp=NULL;
-  CbmMCTrack* track;
-  TVector3 mom;
-  Float_t dx;
-  Float_t dy;
-  Float_t dist;
-  Float_t ne;
- 
-  UInt_t n;
-
-  ne=1111;
-  fND=1111;
-  n=fEcalPoints->GetEntriesFast();
-  for(UInt_t i=0;i<n;i++)
-  {
-    pt=(CbmEcalPoint*)fEcalPoints->At(i);
-    track=(CbmMCTrack*)fMCTracks->At(pt->GetTrackID());
-    //Exclude gammas, neutrons and Kl
-    if (track->GetPdgCode()!=22&&TMath::Abs(track->GetPdgCode())==11)
-      continue;
-    dx=pt->GetX()-fXReco;
-    dy=pt->GetY()-fYReco;
-    dist=TMath::Sqrt(dx*dx+dy*dy);
-    if (dist>20)
-      continue;
-    track->GetMomentum(mom);
-    if (TMath::Abs(mom.Mag()/fEReco-1)<ne)
-    {
-      ne=TMath::Abs(mom.Mag()/fEReco-1);
-      fND=dist;
-      fNCode=track->GetPdgCode();
-      mp=pt;
-    }
-  }
-  pt=mp;
-  if (fND==1111)
-  {
-    fMCE=-1111;
-    fMCX=-1111;
-    fMCY=-1111;
-    fMCPX=-1111;
-    fMCPY=-1111;
-    fMCPZ=-1111;
-    fND=-1111;
-  }
-  else
-  {
-    track=(CbmMCTrack*)fMCTracks->At(mp->GetTrackID());
-    track->GetMomentum(mom);
-    fMCE=mom.Mag();
-    fMCX=pt->GetX();
-    fMCY=pt->GetY();
-    fMCPX=mom.Px();
-    fMCPY=mom.Py();
-    fMCPZ=mom.Pz();
-  }
-  fTree->Fill();
-}
-
-/** Finds cell with more energy deposition than given **/
-CbmEcalCell* CbmEcalAnalysisDS::FindNextCell(CbmEcalCell* cell)
-{
-  CbmEcalCell* ret=cell;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-
-  cells.clear();
-
-  cell->GetNeighborsList(0,cells);
-  for(p=cells.begin();p!=cells.end();++p) 
-  {
-    if ((*p)->GetEnergy()>ret->GetEnergy())
-      ret=(*p);
-  }
-
-  return ret;
-}
-
-CbmEcalAnalysisDS::CbmEcalAnalysisDS(const char* name, const Int_t iVerbose, const char* fileGeo)
-  : FairTask(name, iVerbose), 
-    fPDGType(22), 
-    fMinEnergy(0.5), 
-    fGeoFile(fileGeo),
-    fTree(NULL),
-    fEvent(-1),
-    fMCX(0.),
-    fMCY(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fP0a(),
-    fP0b(),
-    fP1a(),
-    fP1b(),
-    fMCE(0.),
-    fMCPX(0.),
-    fMCPY(0.),
-    fMCPZ(0.),
-    fPSE(0.),
-    fE(0.),
-    fE2x2(0.),
-    fE3x3(0.),
-    fTotalTrackEnergy(0.),
-    fMaxCellX(0.),
-    fMaxCellY(0.),
-    fEReco(0.),
-    fAX(0.),
-    fAY(0.),
-    fXReco(0.),
-    fYReco(0.),
-    fND(0.),
-    fNCode(-1),
-    fMotherCode(-1),
-    fType(-1),
-    fStr(NULL),
-    fDiffType(-1),
-    fInf(NULL),
-    fList(),
-    fLib(NULL),
-    fLitePoints(NULL),
-    fEcalPoints(NULL),
-    fMCTracks(NULL)
-{
-  fTree=NULL;
-  fInf=CbmEcalInf::GetInstance(fGeoFile);
-  fLib=new CbmEcalSCurveLib(0);
-  fLib->AddFile("3x3.root");
-  fLib->AddFile("6x6.root");
-  fLib->AddFile("12x12.root");
-
-  fP0a[1]=0.002833;
-  fP0a[2]=0.003345;
-  fP0a[4]=0.003587;
-  fP0b[1]=0.08788;
-  fP0b[2]=0.08496;
-  fP0b[4]=0.07886;
-
-  fP1a[1]=0.003398;
-  fP1a[2]=0.003108;
-  fP1a[4]=0.001337;
-  fP1b[1]=-0.005302;
-  fP1b[2]=-0.005155;
-  fP1b[4]=-0.006937;
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisDS::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-
-  fLitePoints=(TClonesArray*)fManager->GetObject("EcalPointLite");
-  if (fLitePoints==NULL)
-  {
-    cerr << "There are no EcalPointLite branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fEcalPoints=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (fEcalPoints==NULL)
-  {
-    cerr << "There are no EcalPoint branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fMCTracks=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (fMCTracks==NULL)
-  {
-    cerr << "There are no MCTrack branch in the file!!!" << endl;
-    return kFATAL;
-  }
-
-  fTree=NULL;
-
-  fEvent=0;
-  fStr=new CbmEcalStructure(fInf);
-  fStr->Construct();
-
-  return kSUCCESS;
-}
-
-/** Parameter container init **/
-void CbmEcalAnalysisDS::SetParContainers()
-{
-  FairRunAna* ana=FairRunAna::Instance();
-  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
-  rtdb->getContainer("CbmGeoEcalPar");
-
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisDS::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisDS)
diff --git a/ecal/CbmEcalAnalysisDS.h b/ecal/CbmEcalAnalysisDS.h
deleted file mode 100644
index 6d3cefc18e8e33d8c896642601386665a79652e3..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisDS.h
+++ /dev/null
@@ -1,256 +0,0 @@
-// For calibrate calorimeter response for UrQMD events
-// for photons, electrons, etc.
-// by Mikhail Prokudin
-
-/* $Id: CbmEcalAnalysisDS.h,v 1.5 2006/09/18 07:58:04 prokudin Exp $ */
-
-/*
- * $Log: CbmEcalAnalysisDS.h,v $
- * Revision 1.5  2006/09/18 07:58:04  prokudin
- * First implementation of SCurve library
- *
- * Revision 1.2  2006/08/25 19:17:48  prokudin
- * Energy in cell added. Minor bug fixed.
- *
- * Revision 1.1  2006/08/17 18:16:35  prokudin
- * first version of UrqmdCalibrator
- *
- */
-
-#ifndef CBMECALANALYSISDS_H
-#define CBMECALANALYSISDS_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class CbmEcalInf;
-class CbmEcalStructure;
-class CbmEcalPoint;
-class CbmEcalCell;
-class CbmEcalSCurveLib;
-class TTree;
-class TClonesArray;
-
-
-class CbmEcalAnalysisDS : public FairTask
-{
-public:
-  CbmEcalAnalysisDS(const char* name, const Int_t iVerbose=0, const char* fileGeo="ecal_FullMC.geo");
-
-  //TString GetGeoFileName();
-
-  /** Setter and getter for type of particle to
-   ** calibrate **/
-  void SetPDGType(Int_t type=22);
-  Int_t GetPDGType() const;
-
-  /** Setter and getter for minimum energy cut **/
-  void SetMinEnergy(Float_t energy=0.5);
-  Float_t GetMinEnergy() const;
-
-private:
-  /** Fills ECAL structure **/
-  void FillStructure();
-
-  /** Initializes tree **/
-  void InitTree();
-
-  /** Finds peaks on ECAL matrix **/
-  void FindPeaks();
-
-  /** Calculates ECAL response for cell **/
-  void FillEnergies(CbmEcalCell* cell);
-
-  /** Find nearest track **/
-  void FindND();
-
-  /** Returns incoming particle energy **/
-  Float_t GetEnergy(Float_t e2, CbmEcalCell* cell);
-
-  /** Finds cell with more energy deposition than given **/
-  CbmEcalCell* FindNextCell(CbmEcalCell* cell);
-
-  /** Type of particle for calibration **/
-  Int_t fPDGType;
-
-  /** Minimum energy for particle to be considered **/
-  Float_t fMinEnergy;
-
-  /** Name of Geo file **/
-  TString fGeoFile;
-
-  /** Output tree named ECALcal **/
-  TTree* fTree;
-
-  /** Event number **/
-  Int_t fEvent;
-
-  /** MC coordinates of hit **/
-  Float_t fMCX;
-  Float_t fMCY;
-
-  /** Coordinates of cell center **/
-  Float_t fCellX;
-  Float_t fCellY;
-
-  /** Calibration **/
-  Float_t fP0a[5];
-  Float_t fP0b[5];
-  Float_t fP1a[5];
-  Float_t fP1b[5];
-  
-  /** Incoming particle momentum **/
-  Float_t fMCE;
-  Float_t fMCPX;
-  Float_t fMCPY;
-  Float_t fMCPZ;
-
-  Float_t fPSE;
-
-  Float_t fE;
-
-  /** Track energy depostion in 2x2 and 3x3 cells **/
-  Float_t fE2x2;
-  Float_t fE3x3;
-
-  /** Total energy deposited by track in calorimeter **/
-  Float_t fTotalTrackEnergy;
-  /** Coordinates of cell with maximum energy deposition for this track **/
-  Float_t fMaxCellX;
-  Float_t fMaxCellY;
-
-  /** Reconstructed energy**/
-  Float_t fEReco;
-
-  /** Assymetry **/
-  Float_t fAX;
-  Float_t fAY;
-
-  /** Reconstructed X,Y **/
-  Float_t fXReco;
-  Float_t fYReco;
-
-  /** Distance to nearest track **/
-  Float_t fND;
-  Int_t fNCode;
-
-  /** PDG code of mother particle. 0 if none. **/
-  Int_t fMotherCode;
-
-  /** Type of cell with maximum energy deposition **/
-  Int_t fType;
-
-  /** Structure container **/
-  CbmEcalStructure* fStr;
-
-  /** 1 if 3x3 cluster contains cells
-   ** with different sizes**/
-  Int_t fDiffType;
-
-  /** Structure information **/
-  CbmEcalInf* fInf;
-
-  /** List of ECAL points to process **/
-  std::list<CbmEcalCell*> fList; 
-
-  /** SCurve library **/
-  CbmEcalSCurveLib* fLib;
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisDS() 
-    : FairTask(),
-    fPDGType(0),
-    fMinEnergy(-1.),
-    fGeoFile(""),
-    fTree(NULL),
-    fEvent(-1),
-    fMCX(0.),
-    fMCY(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fP0a(),
-    fP0b(),
-    fP1a(),
-    fP1b(),
-    fMCE(0.),
-    fMCPX(0.),
-    fMCPY(0.),
-    fMCPZ(0.),
-    fPSE(0.),
-    fE(0.),
-    fE2x2(0.),
-    fE3x3(0.),
-    fTotalTrackEnergy(0.),
-    fMaxCellX(0.),
-    fMaxCellY(0.),
-    fEReco(0.),
-    fAX(0.),
-    fAY(0.),
-    fXReco(0.),
-    fYReco(0.),
-    fND(0.),
-    fNCode(-1),
-    fMotherCode(-1),
-    fType(-1),
-    fStr(NULL),
-    fDiffType(-1),
-    fInf(NULL),
-    fList(),
-    fLib(NULL),
-    fLitePoints(NULL),
-    fEcalPoints(NULL),
-    fMCTracks(NULL)
-      {};
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Parameter container init **/
-  virtual void SetParContainers();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisDS() {};
-private:
-  /** MCPoints in ECAL **/
-  TClonesArray* fLitePoints;
-  /** MCPoints in front of the ECAL **/
-  TClonesArray* fEcalPoints;
-  /** MCTracks array **/
-  TClonesArray* fMCTracks;
-
-  CbmEcalAnalysisDS(const CbmEcalAnalysisDS&);  
-  CbmEcalAnalysisDS& operator=(const CbmEcalAnalysisDS&);  
-
-  ClassDef(CbmEcalAnalysisDS,1)
-};
-
-inline void CbmEcalAnalysisDS::SetPDGType(Int_t type)
-{
-  fPDGType=type;
-}
-
-inline Int_t CbmEcalAnalysisDS::GetPDGType() const
-{
-  return fPDGType;
-}
-
-inline void CbmEcalAnalysisDS::SetMinEnergy(Float_t energy)
-{
-  fMinEnergy=energy;
-}
-
-inline Float_t CbmEcalAnalysisDS::GetMinEnergy() const
-{
-  return fMinEnergy;
-}
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisDst.cxx b/ecal/CbmEcalAnalysisDst.cxx
deleted file mode 100644
index 8b4a1d7eb8a3043c8b5d7db775c652221f391270..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisDst.cxx
+++ /dev/null
@@ -1,229 +0,0 @@
-#include "CbmEcalAnalysisDst.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "CbmEcalCell.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalStructure.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-
-#include <iostream>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::list;
-
-/** Loop procedure **/
-void CbmEcalAnalysisDst::Exec(Option_t*)
-{
-  Double_t z;
-  Double_t r;
-  CbmEcalPoint* pt;
-  Double_t px;
-  Double_t py;
-  Double_t pz;
-  Double_t e;
-  Double_t max=-1111;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  CbmEcalCell* cl=NULL;
-  Int_t imax=-1111;
-  Double_t e2=-1111;
-  Double_t e2m;
-  Int_t i;
-  TVector2 v;
-  Double_t phi;
-
-  fEvent=0;
-
-  InitTree();
-
-  pt=(CbmEcalPoint*)fPts->At(0);
-  if (pt==NULL) return;
-  fX=pt->GetX();
-  fY=pt->GetY();
-
-  px=pt->GetPx(); px*=px;
-  py=pt->GetPy(); py*=py;
-  pz=pt->GetPz(); pz*=pz;
-  fE=TMath::Sqrt(px+py+pz);
-
-  fCaloE=0;
-  fStr->GetCells(cells);
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    if ((*p)==NULL) continue;
-    e=(*p)->GetTotalEnergy();
-    fCaloE+=e;
-    if (e>max)
-    {
-      max=e;
-      cl=(*p);
-    }
-  }
-  for(i=1;i<5;i++)
-  {
-    cl->GetNeighborsList(i, cells);
-    e2m=max;
-    for(p=cells.begin();p!=cells.end();++p)
-      e2m+=(*p)->GetTotalEnergy();
-    if (e2m>e2)
-    { 
-      e2=e2m;
-      imax=i;
-    }
-  }
-  cl->GetNeighborsList(imax, cells);
-  fCX=cl->GetCenterX()*cl->GetTotalEnergy(); 
-  fCY=cl->GetCenterY()*cl->GetTotalEnergy();
-  fMX=cl->GetCenterX();
-  fMY=cl->GetCenterY();
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    fCX+=(*p)->GetCenterX()*(*p)->GetTotalEnergy();
-    fCY+=(*p)->GetCenterY()*(*p)->GetTotalEnergy();
-  }
-  fCX/=e2; fCY/=e2;
-
-  v.Set(fCX, fCY);
-  phi=-(v.Phi());
-  v.Set(fX-fCX, fY-fCY);
-  v=v.Rotate(phi);
-  fP=v.X(); fQ=v.Y();
-
-  v.Set(fX, fY);
-  phi=-(v.Phi());
-  v.Set(fX-fMX, fY-fMY);
-  v=v.Rotate(phi);
-  fMP=v.X(); fMQ=v.Y();
-
-  z=pt->GetZ();
-  fPhi=TMath::ATan2(fY, fX);
-  r=TMath::Sqrt(fX*fX+fY*fY);
-  fTheta=TMath::ATan2(r, z);
-  fCPhi=TMath::ATan2(fCY, fCX);
-  r=TMath::Sqrt(fCX*fCX+fCY*fCY);
-  fCTheta=TMath::ATan2(r, z);
-
-  fTree->Fill();
-}
-
-
-/** Initializes tree **/
-void CbmEcalAnalysisDst::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("dst","dst tree");
-  fTree->Branch("ev",&fEvent,"ev/I");
-
-  fTree->Branch("e",&fE,"e/D");
-  fTree->Branch("x",&fX,"x/D");
-  fTree->Branch("y",&fY,"y/D");
-  fTree->Branch("caloe",&fCaloE,"caloe/D");
-  fTree->Branch("cx",&fCX,"cx/D");
-  fTree->Branch("cy",&fCY,"cy/D");
-  fTree->Branch("p",&fP,"p/D");
-  fTree->Branch("q",&fQ,"q/D");
-  fTree->Branch("theta",&fTheta,"theta/D");
-  fTree->Branch("phi",&fPhi,"phi/D");
-  fTree->Branch("ctheta",&fCTheta,"ctheta/D");
-  fTree->Branch("cphi",&fCPhi,"cphi/D");
-  fTree->Branch("mx",&fMX,"mx/D");
-  fTree->Branch("my",&fMY,"my/D");
-  fTree->Branch("mp",&fMP,"mp/D");
-  fTree->Branch("mq",&fMQ,"mq/D");
-}
-
-CbmEcalAnalysisDst::CbmEcalAnalysisDst()
-  : FairTask(),
-    fTree(NULL),
-    fEntries(0),
-    fEvent(0),
-    fE(0.),
-    fX(0.),
-    fY(0.),
-    fCaloE(0.),
-    fCX(0.),
-    fCY(0.),
-    fP(0.),
-    fQ(0.),
-    fTheta(0.),
-    fPhi(0.),
-    fCTheta(0.),
-    fCPhi(0.),
-    fMX(0.),
-    fMY(0.),
-    fMP(0.),
-    fMQ(0.),
-    fPts(NULL),
-    fStr(NULL)
-{
-}
-
-
-CbmEcalAnalysisDst::CbmEcalAnalysisDst(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fTree(NULL),
-    fEntries(0),
-    fEvent(0),
-    fE(0.),
-    fX(0.),
-    fY(0.),
-    fCaloE(0.),
-    fCX(0.),
-    fCY(0.),
-    fP(0.),
-    fQ(0.),
-    fTheta(0.),
-    fPhi(0.),
-    fCTheta(0.),
-    fCPhi(0.),
-    fMX(0.),
-    fMY(0.),
-    fMP(0.),
-    fMQ(0.),
-    fPts(NULL),
-    fStr(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisDst::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fPts=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (!fPts)
-  {
-    Fatal("Init", "Can't find an array of calorimeter points.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init", "Can't find calorimeter structure in the system");
-    return kFATAL;
-  }
-  fTree=NULL;
-  fEvent=0;
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisDst::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisDst)
diff --git a/ecal/CbmEcalAnalysisDst.h b/ecal/CbmEcalAnalysisDst.h
deleted file mode 100644
index c721eec2edf391538c4d857d1e0f55cba852b2f3..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisDst.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef CBMECALANALYSISDST_H
-#define CBMECALANALYSISDST_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class TTree;
-class TClonesArray;
-class CbmEcalStructure;
-
-class CbmEcalAnalysisDst : public FairTask
-{
-public:
-  CbmEcalAnalysisDst(const char* name, const Int_t iVerbose=0);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisDst();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisDst() {};
-private:
-  /** Initialize a tree **/
-  void InitTree();
-  /** Out tree **/
-  TTree* fTree;			//!
-  /** Number of found particles in this event **/
-  Int_t fEntries;
-
-  /** Event number **/
-  Int_t fEvent;
-  /** Information about first particle **/
-  Double_t fE;
-  Double_t fX;
-  Double_t fY;
-  Double_t fCaloE;
-  Double_t fCX;
-  Double_t fCY;
-  Double_t fP;
-  Double_t fQ;
-  Double_t fTheta;
-  Double_t fPhi;
-  Double_t fCTheta;
-  Double_t fCPhi;
-  Double_t fMX;
-  Double_t fMY;
-  Double_t fMP;
-  Double_t fMQ;
-
-  /** An array of clusters **/
-  TClonesArray* fPts;
-  /** A calorimeter structure **/
-  CbmEcalStructure* fStr;
-
-  CbmEcalAnalysisDst(const CbmEcalAnalysisDst&);
-  CbmEcalAnalysisDst& operator=(const CbmEcalAnalysisDst&);
-
-  ClassDef(CbmEcalAnalysisDst,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisEres.cxx b/ecal/CbmEcalAnalysisEres.cxx
deleted file mode 100644
index 00d84c0747ed4d8290744bdf2d73ad4d5a0b372d..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisEres.cxx
+++ /dev/null
@@ -1,123 +0,0 @@
-#include "CbmEcalAnalysisEres.h"
-
-#include "CbmEcalCell.h"
-#include "CbmEcalMaximum.h"
-
-#include "FairRootManager.h"
-
-#include "TClonesArray.h"
-
-
-#include <iostream>
-#include <list>
-
-using namespace std;
-
-/** Loop procedure **/
-void CbmEcalAnalysisEres::Exec(Option_t*)
-{
-  fEv++;
-  if (fTree==NULL) InitTree();
-  CbmEcalMaximum* max=NULL;
-  CbmEcalCell* cell=NULL;
-  CbmEcalCell* min;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*> cells2;
-  list<CbmEcalCell*>::const_iterator p;
-  Int_t n=fMax->GetEntries();
-  Int_t i;
-  Double_t me=1e10;
-  for(i=0;i<n;i++)
-  {
-    max=(CbmEcalMaximum*)fMax->At(i);
-    if (max==NULL) continue;
-    cell=max->Cell();
-    if (cell->GetTotalEnergy()<0.005) continue;
-    break;
-  }
-  if (i==n)
-  {
-    Info("Exec","No suitable maximum found in event %d.", fEv);
-    return;
-  }
-  cells.clear();
-  cell->GetNeighborsList(max->I(), cells);
-  cells.push_back(cell);
-  cell->GetNeighborsList(0, cells2);
-  for(p=cells2.begin();p!=cells2.end();++p)
-    if ((*p)->GetTotalEnergy()<me)
-    {
-      min=(*p);
-      me=min->GetTotalEnergy();
-    }
-  if (find(cells.begin(), cells.end(), min)==cells.end())
-    cells.push_back(min);
-
-  fCellType=cell->GetType();
-  fE=0;
-  for(p=cells.begin();p!=cells.end();++p)
-    fE+=(*p)->GetTotalEnergy();
-  
-  fTree->Fill();
-}
-
-void CbmEcalAnalysisEres::InitTree()
-{
-  if (fTree!=NULL) return;
-
-  fTree=new TTree("eres", "Energy resolution tree for calorimeter");
-  fTree->Branch("ev", &fEv, "ev/I");
-  fTree->Branch("celltype", &fCellType, "celltype/I");
-  fTree->Branch("e", &fE, "e/D");
-}
-
-CbmEcalAnalysisEres::CbmEcalAnalysisEres()
-  : FairTask(),
-    fMax(NULL),
-    fTree(NULL),
-    fCellType(0),
-    fE(0.),
-    fEv(0)
-{
-}
-
-CbmEcalAnalysisEres::CbmEcalAnalysisEres(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fMax(NULL),
-    fTree(NULL),
-    fCellType(0),
-    fE(0.),
-    fEv(0)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisEres::Init()
-{
-  fTree=NULL;
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fMax=(TClonesArray*)fManager->GetObject("EcalMaximums");
-  if (!fMax)
-  {
-    Fatal("Init", "Can't find an calorimeter maximums.");
-    return kFATAL;
-  }
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisEres::Finish()
-{
-  fTree->Write();
-//  ofstream f(fName);
-//  f << fEv << endl;
-//  f.close();
-}
-
-ClassImp(CbmEcalAnalysisEres)
diff --git a/ecal/CbmEcalAnalysisEres.h b/ecal/CbmEcalAnalysisEres.h
deleted file mode 100644
index 849f3bcf867030b5e1ba9f0a1f7d5e35925568e1..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisEres.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef CBMECALANALYSISERES_H
-#define CBMECALANALYSISERES_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-class TClonesArray;
-class TTree;
-
-class CbmEcalAnalysisEres : public FairTask
-{
-public:
-  CbmEcalAnalysisEres(const char* name, const Int_t iVerbose);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisEres();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisEres() {};
-private:
-  void InitTree();
-  /** Array of maximums **/
-  TClonesArray* fMax;		//!
-  TTree* fTree;			//!
-  
-  Int_t fCellType;
-  Double_t fE;
-
-  Int_t fEv;
-
-  CbmEcalAnalysisEres(const CbmEcalAnalysisEres&);
-  CbmEcalAnalysisEres& operator=(const CbmEcalAnalysisEres&);
-
-  ClassDef(CbmEcalAnalysisEres,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisJPsi.cxx b/ecal/CbmEcalAnalysisJPsi.cxx
deleted file mode 100644
index a85fff9288d0a82c7ccef54c1ac33ba745b87319..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisJPsi.cxx
+++ /dev/null
@@ -1,265 +0,0 @@
-#include "CbmEcalAnalysisJPsi.h"
-
-#include "FairRootManager.h"
-#include "FairTrackParam.h"
-#include "FairLogger.h"
-
-#include "CbmEcalIdParticle.h"
-#include "CbmEcalStructure.h"
-
-#include "CbmTrackMatch.h"
-#include "CbmMCTrack.h"
-#include "CbmStsTrack.h"
-#include "CbmVertex.h"
-#include "CbmStsKFTrackFitter.h"
-
-#include "TClonesArray.h"
-#include "TTree.h"
-
-#include <iostream>
-
-using namespace std;
-
-/** Loop procedure **/
-void CbmEcalAnalysisJPsi::Exec(Option_t*)
-{
-  fEv++;
-
-  InitTree();
-  Int_t n=fStsTracks->GetEntriesFast();
-  Int_t i;
-  Int_t j;
-  CbmStsTrack* tr;
-  CbmTrackMatch* trm;
-  FairTrackParam trb;
-//  FairTrackParam* trp;
-  TVector3 p;
-  CbmMCTrack* mctr;
-  CbmMCTrack* mmctr;
-  CbmEcalIdParticle* ecalid=NULL;
-  Int_t idn=fEcalId->GetEntriesFast();
-  Int_t mid;
-
-  for(i=0;i<n;i++)
-  {
-    InitVariables();
-    tr=(CbmStsTrack*)fStsTracks->At(i);
-    if (!tr) continue;
-    if (fPrimVertex)
-      fFitter->Extrapolate(tr, fPrimVertex->GetZ(), &trb);
-    else
-      fFitter->Extrapolate(tr, 0.0, &trb);
-    trb.Momentum(p);
-    if (trb.GetQp()>0)
-      fCharge=1;
-    else
-      fCharge=-1;
-/*
-    trp=tr->GetParamLast();
-    trp->Momentum(p);
-*/
-    fPX=p.Px();
-    fPY=p.Py();
-    fPZ=p.Pz();
-    fP=p.Mag();
-    fPT=p.Pt();
-    trm=(CbmTrackMatch*)fStsTracksMatch->At(i);
-    if (trm)
-    {
-      mctr=(CbmMCTrack*)fMC->At(trm->GetMCTrackId());
-      if (mctr)
-      {
-	fMCPDG=mctr->GetPdgCode();
-	mid=mctr->GetMotherId();
-	if (mid>=0)
-	{
-	  mmctr=(CbmMCTrack*)fMC->At(mctr->GetMotherId());
-	  if (mmctr)
-	    fMotherMCPDG=mmctr->GetPdgCode();
-	}
-      }
-    }
-    for(j=0;j<idn;j++)
-    {
-      ecalid=(CbmEcalIdParticle*)fEcalId->At(j);
-      if (ecalid->Track()==i)
-	break;
-    }
-    if (j!=idn)
-    {
-      fCellType=fStr->GetHitCell(ecalid->CellNum())->GetType();
-      fEProb=ecalid->EProb();
-      fShape=ecalid->Shape();
-      fCaloE=ecalid->E()*fP;
-      fChi2=ecalid->PSE();
-      if (fEProb>0.05&&fShape>0.5)
-	fIsE=1;
-      else
-	fIsE=0;
-    }
-    fOut->Fill();
-  }
-}
-
-
-CbmEcalAnalysisJPsi::CbmEcalAnalysisJPsi()
-  : FairTask(),
-    fName(),
-    fOut(NULL),
-    fEv(0),
-    fPX(0.),
-    fPY(0.),
-    fPZ(0.),
-    fPT(0.),
-    fP(0.),
-    fEProb(0.),
-    fShape(0.),
-    fIsE(0),
-    fMCPDG(0),
-    fMotherMCPDG(0),
-    fCharge(0),
-    fCaloE(0.),
-    fChi2(0.),
-    fCellType(0),
-    fMC(NULL),
-    fStsTracks(NULL),
-    fStsTracksMatch(NULL),
-    fEcalId(NULL),
-    fPrimVertex(NULL),
-    fFitter(NULL),
-    fStr(NULL)
-{
-}
-
-
-CbmEcalAnalysisJPsi::CbmEcalAnalysisJPsi(const char* name, const Int_t iVerbose, const char* fname)
-  : FairTask(name, iVerbose),
-    fName(fname),
-    fOut(NULL),
-    fEv(0),
-    fPX(0.),
-    fPY(0.),
-    fPZ(0.),
-    fPT(0.),
-    fP(0.),
-    fEProb(0.),
-    fShape(0.),
-    fIsE(0),
-    fMCPDG(0),
-    fMotherMCPDG(0),
-    fCharge(0),
-    fCaloE(0.),
-    fChi2(0.),
-    fCellType(0),
-    fMC(NULL),
-    fStsTracks(NULL),
-    fStsTracksMatch(NULL),
-    fEcalId(NULL),
-    fPrimVertex(NULL),
-    fFitter(NULL),
-    fStr(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisJPsi::Init()
-{
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fEcalId=(TClonesArray*)io->GetObject("EcalId");
-  if (!fEcalId)
-  {
-    Fatal("Init", "Can't find array of identified particles");
-    return kFATAL;
-  }
-  fStsTracks=(TClonesArray*)io->GetObject("StsTrack");
-  if (!fStsTracks)
-  {
-    Fatal("Init()","Can't find STS tracks array");
-    return kFATAL;
-  }
-  fMC=(TClonesArray*)io->GetObject("MCTrack");
-  if (!fMC)
-  {
-    Fatal("Init", "Can't find array of MC tracks in system.");
-    return kFATAL;
-  }
-  fStsTracksMatch=(TClonesArray*)io->GetObject("StsTrackMatch");
-  if (!fStsTracksMatch)
-  {
-    Fatal("Init()","Can't find STS track matching information");
-    return kFATAL;
-  }  
-  // Get pointer to PrimaryVertex object from IOManager if it exists
-  // The old name for the object is "PrimaryVertex" the new one
-  // "PrimaryVertex." Check first for the new name
-  fPrimVertex = dynamic_cast<CbmVertex*>(io->GetObject("PrimaryVertex."));
-  if (nullptr == fPrimVertex) {
-    fPrimVertex = dynamic_cast<CbmVertex*>(io->GetObject("PrimaryVertex"));
-  }
-  if (nullptr == fPrimVertex) {
-    LOG(fatal) << "No primary vertex";
-  }
-  fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-
-  fFitter=new CbmStsKFTrackFitter();
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisJPsi::Finish()
-{
-  if (fOut)
-    fOut->Write();
-}
-
-void CbmEcalAnalysisJPsi::InitTree()
-{
-  if (fOut) return;
-
-  fOut=new TTree("ecaljpsi","None here");
-  fOut->Branch("ev", &fEv, "ev/I");
-  fOut->Branch("px", &fPX, "px/D");
-  fOut->Branch("py", &fPY, "py/D");
-  fOut->Branch("pz", &fPZ, "pz/D");
-  fOut->Branch("p", &fP, "p/D");
-  fOut->Branch("pt", &fPT, "pt/D");
-  fOut->Branch("eprob", &fEProb, "eprob/D");
-  fOut->Branch("shape", &fShape, "shape/D");
-  fOut->Branch("ise", &fIsE, "ise/I");
-  fOut->Branch("mcpdg", &fMCPDG, "mcpdg/I");
-  fOut->Branch("mmcpdg", &fMotherMCPDG, "mmcpdg/I");
-  fOut->Branch("charge", &fCharge, "charge/I");
-  fOut->Branch("caloe", &fCaloE, "caloe/D");
-  fOut->Branch("tcell", &fCellType, "tcell/I");
-  fOut->Branch("chi2", &fChi2, "chi2/D");
-}
-
-void CbmEcalAnalysisJPsi::InitVariables()
-{
-  fPX=-1111;
-  fPY=-1111;
-  fPZ=-1111;
-  fPT=-1111;
-  fP=-1111;
-  fEProb=-1111;
-  fShape=-1111;
-  fIsE=-1111;
-  fMCPDG=-1111;
-  fMotherMCPDG=-1111;
-  fCharge=-1111;
-  fCaloE=-1111;
-  fChi2=-1111;
-}
-
-ClassImp(CbmEcalAnalysisJPsi)
diff --git a/ecal/CbmEcalAnalysisJPsi.h b/ecal/CbmEcalAnalysisJPsi.h
deleted file mode 100644
index f65e53d703b9b6c260d860f1fb6a23667a3cb680..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisJPsi.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef CBMECALANALYSISJPSI_H
-#define CBMECALANALYSISJPSI_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-
-class TTree;
-class TClonesArray;
-class CbmVertex;
-class CbmStsKFTrackFitter;
-class CbmEcalStructure;
-
-class CbmEcalAnalysisJPsi : public FairTask
-{
-public:
-  CbmEcalAnalysisJPsi(const char* name, const Int_t iVerbose, const char* fname);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisJPsi();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisJPsi() {};
-private:
-  TString fName;
-
-  void InitTree();
-  void InitVariables();
-  /** Output tree **/
-  TTree* fOut;
-  /** Event number**/
-  Int_t fEv;
-  /** Momentum of the particle **/
-  Double_t fPX;
-  Double_t fPY;
-  Double_t fPZ;
-  Double_t fPT;
-  Double_t fP;
-  /** Probability of electron using only energy deposition in calorimeter **/
-  Double_t fEProb;
-  /** Shape analysis result **/
-  Double_t fShape;
-  /** Particle electron **/
-  Int_t fIsE;
-  /** MC PDG of the particle **/
-  Int_t fMCPDG;
-  /** MC PDG of mother of the particle **/
-  Int_t fMotherMCPDG;
-  /** Charge of the particle **/
-  Int_t fCharge;
-  /** Energy in calorimeter **/
-  Double_t fCaloE;
-  /** \chi^2 of the cluster **/
-  Double_t fChi2;
-  Int_t fCellType;
-
-  TClonesArray* fMC;			//!
-  TClonesArray* fStsTracks;		//!
-  TClonesArray* fStsTracksMatch;	//!
-  TClonesArray* fEcalId;		//!
-  CbmVertex* fPrimVertex;		//!
-  CbmStsKFTrackFitter* fFitter;		//!
-  CbmEcalStructure* fStr;		//!
-
-  CbmEcalAnalysisJPsi(const CbmEcalAnalysisJPsi&);
-  CbmEcalAnalysisJPsi& operator=(const CbmEcalAnalysisJPsi&);
-
-  ClassDef(CbmEcalAnalysisJPsi,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisMaterial.cxx b/ecal/CbmEcalAnalysisMaterial.cxx
deleted file mode 100644
index 8f273f4a5df5029f0fa66ede38cf352c22a6c8e7..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisMaterial.cxx
+++ /dev/null
@@ -1,138 +0,0 @@
-#include "CbmEcalAnalysisMaterial.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-#include "FairRadLenPoint.h"
-
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-
-#include <iostream>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::list;
-
-/** Loop procedure **/
-void CbmEcalAnalysisMaterial::Exec(Option_t*)
-{
-  fEvent++;
-  if (fVerbose>0)
-    Info("Exec", "Event %d.", fEvent);
-  InitTree();
-  CbmMCTrack* tr;
-  FairRadLenPoint* p;
-  Int_t i;
-  Int_t n;
-  Double_t z=600;
-  TVector3 newp;
-  TVector3 oldp(0.0, 0.0, 0.0);
-  TVector3 d;
-  if (fMC->GetEntriesFast()!=1)
-  {
-    cout << "Size of MC points arrays differs from one" << endl;
-  }
-  tr=(CbmMCTrack*)fMC->At(0);
-  fX=tr->GetPx();
-  fY=tr->GetPy();
-  fZ=tr->GetPz();
-  fX*=z/fZ;
-  fY*=z/fZ;
-  fZ*=z/fZ;
-//  if (TMath::Abs(fX)>594||TMath::Abs(fY)>474) return;
-//  if (TMath::Abs(fX)<42&&TMath::Abs(fY)<42) return;
-  n=fRadLen->GetEntriesFast();
-  fX0=0; fIntL=0;
-  for(i=0;i<n;i++)
-  {
-    p=(FairRadLenPoint*)fRadLen->At(i);
-    newp=p->GetPositionOut();
-//    cout << d.Mag() << "	" << p->GetRadLength() << "	" << newp.Z() << "	" << fX0 << endl;
-    if (newp.Z()>600) break;
-    d=newp-oldp;
-//    cout << p->GetLength() << "	" << p->GetRadLength() << "	" << fEvent << "	" <<p->GetXOut() << "	" << p->GetYOut() << "	" << p->GetZOut() << endl;
-    fX0+=d.Mag()/p->GetRadLength();
-    oldp=newp;
-  }
-  fTree->Fill();
-}
-
-
-/** Initializes tree **/
-void CbmEcalAnalysisMaterial::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("rad","Radiation lenght tree");
-  fTree->Branch("ev", &fEvent, "ev/I");
-  fTree->Branch("x", &fX, "x/D");
-  fTree->Branch("y", &fY, "Y/D");
-  fTree->Branch("z", &fZ, "z/D");
-  fTree->Branch("x0", &fX0, "x0/D");
-  fTree->Branch("intl", &fIntL, "intl/D");
-}
-
-CbmEcalAnalysisMaterial::CbmEcalAnalysisMaterial()
-  : FairTask(),
-    fTree(NULL),
-    fEvent(0),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fX0(0.),
-    fIntL(0.),
-    fMC(NULL),
-    fRadLen(NULL)
-{
-}
-
-CbmEcalAnalysisMaterial::CbmEcalAnalysisMaterial(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fTree(NULL),
-    fEvent(0),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fX0(0.),
-    fIntL(0.),
-    fMC(NULL),
-    fRadLen(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisMaterial::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fMC=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (!fMC)
-  {
-    Fatal("Init", "Can't find an array of MC tracks.");
-    return kFATAL;
-  }
-  fRadLen=(TClonesArray*)fManager->GetObject("RadLen");
-  if (!fRadLen)
-  {
-    Fatal("Init", "Can't find an array of radiation length points.");
-    return kFATAL;
-  }
-  fTree=NULL;
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisMaterial::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisMaterial)
diff --git a/ecal/CbmEcalAnalysisMaterial.h b/ecal/CbmEcalAnalysisMaterial.h
deleted file mode 100644
index 08e4a211bb1ab23f84c936b99427f6b57e2f3145..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisMaterial.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef CBMECALANALYSISMATERIAL_H
-#define CBMECALANALYSISMATERIAL_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class TTree;
-class TClonesArray;
-
-
-class CbmEcalAnalysisMaterial : public FairTask
-{
-public:
-  CbmEcalAnalysisMaterial(const char* name, const Int_t iVerbose=0);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisMaterial();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisMaterial() {};
-private:
-  /** Initialize a tree **/
-  void InitTree();
-  /** Out tree **/
-  TTree* fTree;			//!
-
-  /** Event number **/
-  Int_t fEvent;
-  /** Information particle **/
-  Double_t fX;
-  Double_t fY;
-  Double_t fZ;
-  Double_t fX0;
-  Double_t fIntL;
-
-
-  /** MC tracks array **/
-  TClonesArray* fMC;		//!
-  /** Array of radlen points**/
-  TClonesArray* fRadLen;	//!
-
-  CbmEcalAnalysisMaterial(const CbmEcalAnalysisMaterial&);
-  CbmEcalAnalysisMaterial& operator=(const CbmEcalAnalysisMaterial&);
-
-  ClassDef(CbmEcalAnalysisMaterial,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisNeutron.cxx b/ecal/CbmEcalAnalysisNeutron.cxx
deleted file mode 100644
index 738223331d30481eaaf7aa49635ebb1ecc2b9383..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisNeutron.cxx
+++ /dev/null
@@ -1,223 +0,0 @@
-#include "CbmEcalAnalysisNeutron.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "CbmEcalRecParticle.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalCluster.h"
-#include "CbmEcalStructure.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-
-#include <iostream>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::list;
-
-/** Loop procedure **/
-void CbmEcalAnalysisNeutron::Exec(Option_t*)
-{
-  Int_t i;
-  Int_t n=fReco->GetEntriesFast();
-  CbmEcalRecParticle* p;
-  CbmEcalCluster* cl;
-  CbmMCTrack* mtr;
-  Double_t dx;
-  Double_t dy;
-  Double_t cx;
-  Double_t cy;
-  Double_t r;
-  list<CbmEcalCell*>::const_iterator c;
-  list<CbmEcalCell*> neib;
-  CbmEcalCell* cell;
-  
-  fEvent++;
-  fN=0;
-  fEntries=0;
-  if (fVerbose>0)
-    Info("Exec", "Event %d.", fEvent);
-  InitTree();
-
-  for(i=0;i<n;i++)
-  {
-    p=(CbmEcalRecParticle*)fReco->At(0);
-    if (p->MCTrack()<0) continue;
-    cl=(CbmEcalCluster*)fClusters->At(p->ClusterNum());
-    fMaxs=cl->Maxs(); 
-    fM=cl->Moment();
-    fMx=cl->MomentX();
-    fMy=cl->MomentY();
-    mtr=(CbmMCTrack*)fMC->At(p->MCTrack());
-    fDiffType=0;
-    if ((Int_t)(cl->Type())!=cl->Type()) fDiffType=1;
-    fE=p->E();
-    fX=p->X();
-    fY=p->Y();
-    fPx=p->Px();
-    fPy=p->Py();
-    fPz=p->Pz();
-    fChi2=p->Chi2();
-    fCellType=p->CellType();
-    fPdg=mtr->GetPdgCode();
-
-    cell=fStr->GetHitCell(p->CellNum());
-    cx=cell->GetCenterX();
-    cy=cell->GetCenterY();
-    cell->GetNeighborsList(0, neib);
-    fM3=0; fMx3=0; fMy3=0;
-    for(c=neib.begin();c!=neib.end();++c)
-    {
-      dx=cx; dx-=(*c)->GetCenterX(); dx*=dx;
-      dy=cy; dy-=(*c)->GetCenterY(); dy*=dy;
-      r=dx+dy;
-      fM3+=r*(*c)->GetTotalEnergy();
-      fMx3+=dx*(*c)->GetTotalEnergy();
-      fMy3+=dy*(*c)->GetTotalEnergy();
-    }
-
-    fN++;
-    fTree->Fill();
-  }
-  if (fVerbose>0)
-    Info("Exec", "%d found particles in event.", fEntries);
-}
-
-
-/** Initializes tree **/
-void CbmEcalAnalysisNeutron::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("neutron","neutron tree");
-  fTree->Branch("ev",&fEvent,"ev/I");
-  fTree->Branch("n", &fN, "n/I");
-
-  fTree->Branch("e",&fE,"e/D");
-  fTree->Branch("px",&fPx,"px/D");
-  fTree->Branch("py",&fPy,"py/D");
-  fTree->Branch("pz",&fPz,"pz/D");
-  fTree->Branch("x",&fX,"x/D");
-  fTree->Branch("y",&fY,"y/D");
-  fTree->Branch("chi2",&fChi2,"chi2/D");
-  fTree->Branch("ctype",&fCellType,"ctype/I");
-  fTree->Branch("cdiff",&fDiffType,"cdiff/I");
-  fTree->Branch("pdg", &fPdg, "pdg/I");
-  fTree->Branch("cmaxs", &fMaxs, "cmaxs/I");
-  fTree->Branch("m3", &fM3, "m3/D");
-  fTree->Branch("mx3", &fMx3, "mx3/D");
-  fTree->Branch("my3", &fMy3, "my3/D");
-  fTree->Branch("m", &fM, "m/D");
-  fTree->Branch("mx", &fMx, "mx/D");
-  fTree->Branch("my", &fMy, "my/D");
-}
-
-CbmEcalAnalysisNeutron::CbmEcalAnalysisNeutron()
-  : FairTask(),
-    fTree(NULL),
-    fEntries(0),
-    fN(0),
-    fEvent(0),
-    fE(0.),
-    fPx(0.),
-    fPy(0.),
-    fPz(0.),
-    fX(0.),
-    fY(0.),
-    fCellType(0),
-    fDiffType(0),
-    fM3(0.),
-    fMx3(0.),
-    fMy3(0.),
-    fChi2(0.),
-    fM(0.),
-    fMx(0.),
-    fMy(0.),
-    fPdg(0),
-    fMaxs(0),
-    fReco(NULL),
-    fMC(NULL),
-    fClusters(NULL),
-    fStr(NULL)
-{
-}
-
-CbmEcalAnalysisNeutron::CbmEcalAnalysisNeutron(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fTree(NULL),
-    fEntries(0),
-    fN(0),
-    fEvent(0),
-    fE(0.),
-    fPx(0.),
-    fPy(0.),
-    fPz(0.),
-    fX(0.),
-    fY(0.),
-    fCellType(0),
-    fDiffType(0),
-    fM3(0.),
-    fMx3(0.),
-    fMy3(0.),
-    fChi2(0.),
-    fM(0.),
-    fMx(0.),
-    fMy(0.),
-    fPdg(0),
-    fMaxs(0),
-    fReco(NULL),
-    fMC(NULL),
-    fClusters(NULL),
-    fStr(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisNeutron::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fReco=(TClonesArray*)fManager->GetObject("EcalReco");
-  if (!fReco)
-  {
-    Fatal("Init", "Can't find an array of reco parcles.");
-    return kFATAL;
-  }
-  fMC=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (!fMC)
-  {
-    Fatal("Init", "Can't find an array of MC tracks.");
-    return kFATAL;
-  }
-  fClusters=(TClonesArray*)fManager->GetObject("EcalClusters");
-  if (!fClusters)
-  {
-    Fatal("Init", "Can't find EcalClusters");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init", "Can't find calorimeter structure in the system");
-    return kFATAL;
-  }
-  fTree=NULL;
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisNeutron::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisNeutron)
diff --git a/ecal/CbmEcalAnalysisNeutron.h b/ecal/CbmEcalAnalysisNeutron.h
deleted file mode 100644
index efc13f5cb3f8624e087c61b8530aa4031d79fe17..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisNeutron.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef CBMECALANALYSISNEUTRON_H
-#define CBMECALANALYSISNEUTRON_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class TTree;
-class TClonesArray;
-class CbmEcalStructure;
-
-class CbmEcalAnalysisNeutron : public FairTask
-{
-public:
-  CbmEcalAnalysisNeutron(const char* name, const Int_t iVerbose=0);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisNeutron();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisNeutron() {};
-private:
-  /** Initialize a tree **/
-  void InitTree();
-  /** Out tree **/
-  TTree* fTree;			//!
-  /** Number of found particles in this event **/
-  Int_t fEntries;
-  /** Number of particle in event **/
-  Int_t fN;
-
-  /** Event number **/
-  Int_t fEvent;
-  /** Information about first particle **/
-  Double_t fE;
-  Double_t fPx;
-  Double_t fPy;
-  Double_t fPz;
-  Double_t fX;
-  Double_t fY;
-  Int_t fCellType;
-  Int_t fDiffType;
-  Double_t fM3;
-  Double_t fMx3;
-  Double_t fMy3;
-  Double_t fChi2;
-  Double_t fM;
-  Double_t fMx;
-  Double_t fMy;
-  Int_t fPdg;
-  Int_t fMaxs;
-
-  /** An array of reconstructed particles **/
-  TClonesArray* fReco;
-  /** MC tracks array **/
-  TClonesArray* fMC;
-  /** An array of clusters **/
-  TClonesArray* fClusters;
-  /** A calorimeter structure **/
-  CbmEcalStructure* fStr;
-
-  CbmEcalAnalysisNeutron(const CbmEcalAnalysisNeutron&);
-  CbmEcalAnalysisNeutron& operator=(const CbmEcalAnalysisNeutron&);
-
-  ClassDef(CbmEcalAnalysisNeutron,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisPair.cxx b/ecal/CbmEcalAnalysisPair.cxx
deleted file mode 100644
index 4747715f719f3faaedab7a939d4ef176ed8d8d99..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisPair.cxx
+++ /dev/null
@@ -1,296 +0,0 @@
-#include "CbmEcalAnalysisPair.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "CbmEcalRecParticle.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalCluster.h"
-#include "CbmEcalStructure.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-
-#include <iostream>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::list;
-
-/** Loop procedure **/
-void CbmEcalAnalysisPair::Exec(Option_t*)
-{
-  Int_t i;
-  Int_t n=fReco->GetEntriesFast();
-  Int_t mcn=fMC->GetEntriesFast();
-  CbmEcalRecParticle* p1;
-  CbmEcalRecParticle* p2;
-  CbmEcalCluster* cluster;
-  CbmEcalCell* cell;
-  CbmMCTrack* tr1;
-  CbmMCTrack* tr2;
-  CbmMCTrack* mtr;
-  Double_t dx;
-  Double_t dy;
-  
-  fEvent++;
-  fEntries=0;
-  if (fVerbose>0)
-    Info("Exec", "Event %d.", fEvent);
-  InitTree();
-
-  fCellN=fClusters->GetEntriesFast();
-  p1=(CbmEcalRecParticle*)fReco->At(0);
-  if (p1)
-  {
-    fE1=p1->E();
-    fX1=p1->X();
-    fY1=p1->Y();
-    fPx1=p1->Px();
-    fPy1=p1->Py();
-    fPz1=p1->Pz();
-    fChi1=p1->Chi2();
-    fCellType1=p1->CellType();
-    cell=fStr->GetHitCell(p1->CellNum());
-    fCellX1=cell->GetCenterX();
-    fCellY1=cell->GetCenterY();
-    cluster=(CbmEcalCluster*)fClusters->At(p1->ClusterNum());
-    fCells=cluster->Size();
-    fM=cluster->Moment();
-    fMx=cluster->MomentX();
-    fMy=cluster->MomentY();
-    fEntries++;
-  }
-  fR=-1111;
-  if (n>1)
-    p2=(CbmEcalRecParticle*)fReco->At(1);
-  else
-    p2=NULL;
-
-  fE2=-1111;
-  if (p2)
-  {
-    fE2=p2->E();
-    fX2=p2->X();
-    fY2=p2->Y();
-    fPx2=p2->Px();
-    fPy2=p2->Py();
-    fPz2=p2->Pz();
-    fChi2=p2->Chi2();
-    fCellType2=p2->CellType();
-    cell=fStr->GetHitCell(p2->CellNum());
-    fCellX2=cell->GetCenterX();
-    fCellY2=cell->GetCenterY();
-    fEntries++;
-  }
-  else
-  {
-    fE2=-1111;
-    fX2=-1111;
-    fY2=-1111;
-    fPx2=-1111;
-    fPy2=-1111;
-    fPz2=-1111;
-    fChi2=-1111;
-    fCellType2=-1111;
-    fCellX2=-1111;
-    fCellY2=-1111;
-  }
-  if (mcn<2)
-    Info("Exec", "Less than 2 tracks in input!");
-  tr1=NULL;
-  tr2=NULL;
-
-  for(i=0;i<mcn;i++)
-  {
-    mtr=(CbmMCTrack*)fMC->At(i);
-    if (mtr->GetMotherId()>=0) continue;
-    if (tr1==NULL)
-    {
-      tr1=mtr;
-      continue;
-    }
-    if (tr2==NULL)
-    {
-      tr2=mtr;
-      continue;
-    }
-    Info("Exec", "More than 2 initial tracks in input!");
-  }
-
-  if (tr1!=NULL&&tr2!=NULL)
-  {
-    tr1=(CbmMCTrack*)fMC->At(0);
-    tr2=(CbmMCTrack*)fMC->At(1);
-    dx=tr1->GetStartX()-tr2->GetStartX();
-    dy=tr1->GetStartY()-tr2->GetStartY();
-    dx*=dx; dy*=dy; fR=TMath::Sqrt(dx+dy);
-  }
-
-  fTree->Fill();
-  if (fVerbose>0)
-    Info("Exec", "%d found particles in event.", fEntries);
-}
-
-
-/** Initializes tree **/
-void CbmEcalAnalysisPair::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("pair","pair tree");
-  fTree->Branch("ev",&fEvent,"ev/I");
-
-  fTree->Branch("e1",&fE1,"e1/D");
-  fTree->Branch("px1",&fPx1,"px1/D");
-  fTree->Branch("py1",&fPy1,"py1/D");
-  fTree->Branch("pz1",&fPz1,"pz1/D");
-  fTree->Branch("x1",&fX1,"x1/D");
-  fTree->Branch("y1",&fY1,"y1/D");
-  fTree->Branch("cx1",&fCellX1,"cx1/D");
-  fTree->Branch("cy1",&fCellY1,"cy1/D");
-  fTree->Branch("chi1",&fChi1,"chi1/D");
-  fTree->Branch("ctype1",&fCellType1,"ctype1/I");
-
-  fTree->Branch("e2",&fE2,"e2/D");
-  fTree->Branch("px2",&fPx2,"px2/D");
-  fTree->Branch("py2",&fPy2,"py2/D");
-  fTree->Branch("pz2",&fPz2,"pz2/D");
-  fTree->Branch("x2",&fX2,"x2/D");
-  fTree->Branch("y2",&fY2,"y2/D");
-  fTree->Branch("cx2",&fCellX2,"cx2/D");
-  fTree->Branch("cy2",&fCellY2,"cy2/D");
-  fTree->Branch("chi2",&fChi2,"chi2/D");
-  fTree->Branch("ctype2",&fCellType2,"ctype2/I");
-
-  fTree->Branch("r", &fR, "r/D");
-  fTree->Branch("cn", &fCellN, "cn/I");
-  fTree->Branch("cs", &fCells, "cs/I");
-  fTree->Branch("m", &fM, "m/D");
-  fTree->Branch("mx", &fMx, "mx/D");
-  fTree->Branch("my", &fMy, "my/D");
-}
-
-CbmEcalAnalysisPair::CbmEcalAnalysisPair()
-  : FairTask(),
-    fTree(NULL),
-    fEntries(0),
-    fEvent(0),
-    fE1(0.),
-    fPx1(0.),
-    fPy1(0.),
-    fPz1(0.),
-    fX1(0.),
-    fY1(0.),
-    fCellX1(0.),
-    fCellY1(0.),
-    fCellType1(0),
-    fChi1(0.),
-    fE2(0.),
-    fPx2(0.),
-    fPy2(0.),
-    fPz2(0.),
-    fX2(0.),
-    fY2(0.),
-    fCellX2(0.),
-    fCellY2(0.),
-    fCellType2(0),
-    fChi2(0.),
-    fR(0.),
-    fCellN(0),
-    fCells(0),
-    fM(0.),
-    fMx(0.),
-    fMy(0.),
-    fReco(NULL),
-    fMC(NULL),
-    fClusters(NULL),
-    fStr(NULL)
-{
-}
-
-CbmEcalAnalysisPair::CbmEcalAnalysisPair(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fTree(NULL),
-    fEntries(0),
-    fEvent(0),
-    fE1(0.),
-    fPx1(0.),
-    fPy1(0.),
-    fPz1(0.),
-    fX1(0.),
-    fY1(0.),
-    fCellX1(0.),
-    fCellY1(0.),
-    fCellType1(0),
-    fChi1(0.),
-    fE2(0.),
-    fPx2(0.),
-    fPy2(0.),
-    fPz2(0.),
-    fX2(0.),
-    fY2(0.),
-    fCellX2(0.),
-    fCellY2(0.),
-    fCellType2(0),
-    fChi2(0.),
-    fR(0.),
-    fCellN(0),
-    fCells(0),
-    fM(0.),
-    fMx(0.),
-    fMy(0.),
-    fReco(NULL),
-    fMC(NULL),
-    fClusters(NULL),
-    fStr(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisPair::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fReco=(TClonesArray*)fManager->GetObject("EcalReco");
-  if (!fReco)
-  {
-    Fatal("Init", "Can't find an array of reco parcles.");
-    return kFATAL;
-  }
-  fMC=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (!fMC)
-  {
-    Fatal("Init", "Can't find an array of MC tracks.");
-    return kFATAL;
-  }
-  fClusters=(TClonesArray*)fManager->GetObject("EcalClusters");
-  if (!fClusters)
-  {
-    Fatal("Init", "Can't find EcalClusters");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init", "Can't find calorimeter structure in the system");
-    return kFATAL;
-  }
-  fTree=NULL;
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisPair::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisPair)
diff --git a/ecal/CbmEcalAnalysisPair.h b/ecal/CbmEcalAnalysisPair.h
deleted file mode 100644
index 2c0bb4fc4a092768a5545a94864533e7f9efdc40..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisPair.h
+++ /dev/null
@@ -1,91 +0,0 @@
-#ifndef CBMECALANALYSISPAIR_H
-#define CBMECALANALYSISPAIR_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class TTree;
-class TClonesArray;
-class CbmEcalStructure;
-
-
-class CbmEcalAnalysisPair : public FairTask
-{
-public:
-  CbmEcalAnalysisPair(const char* name, const Int_t iVerbose=0);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisPair();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisPair() {};
-private:
-  /** Initialize a tree **/
-  void InitTree();
-  /** Out tree **/
-  TTree* fTree;			//!
-  /** Number of found particles in this event **/
-  Int_t fEntries;
-
-  /** Event number **/
-  Int_t fEvent;
-  /** Information about first particle **/
-  Double_t fE1;
-  Double_t fPx1;
-  Double_t fPy1;
-  Double_t fPz1;
-  Double_t fX1;
-  Double_t fY1;
-  Double_t fCellX1;
-  Double_t fCellY1;
-  Int_t fCellType1;
-  Double_t fChi1;
-
-  /** Information about second particle **/
-  Double_t fE2;
-  Double_t fPx2;
-  Double_t fPy2;
-  Double_t fPz2;
-  Double_t fX2;
-  Double_t fY2;
-  Double_t fCellX2;
-  Double_t fCellY2;
-  Int_t fCellType2;
-  Double_t fChi2;
-  Double_t fR;
-  Int_t fCellN;
-  Int_t fCells;
-  Double_t fM;
-  Double_t fMx;
-  Double_t fMy;
-
-
-  /** An array of reconstructed particles **/
-  TClonesArray* fReco;
-  /** MC tracks array **/
-  TClonesArray* fMC;
-  /** An array of clusters **/
-  TClonesArray* fClusters;
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;		//!
-
-  CbmEcalAnalysisPair(const CbmEcalAnalysisPair&);
-  CbmEcalAnalysisPair& operator=(const CbmEcalAnalysisPair&);
-
-  ClassDef(CbmEcalAnalysisPair,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisPi0.cxx b/ecal/CbmEcalAnalysisPi0.cxx
deleted file mode 100644
index 936b2e1030a7a8176ba51dd1a7476da99505a633..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisPi0.cxx
+++ /dev/null
@@ -1,454 +0,0 @@
-#include "CbmEcalAnalysisPi0.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-#include "FairTrackParam.h"
-
-#include "CbmEcalRecParticle.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalCluster.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalPoint.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-
-#include <iostream>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::list;
-
-/** Loop procedure **/
-void CbmEcalAnalysisPi0::Exec(Option_t*)
-{
-  Int_t i;
-  Int_t n=fMC->GetEntriesFast();
-  CbmMCTrack* mtr;
-
-  fEvent++;
-  for(i=0;i<n;i++)
-  {
-    InitTree();
-    mtr=(CbmMCTrack*)fMC->At(i);
-    // Only eta and pi0
-    if (mtr->GetPdgCode()!=111&&mtr->GetPdgCode()!=221) continue;
-    fMotherID=mtr->GetPdgCode();
-    fMX=mtr->GetStartX();
-    fMY=mtr->GetStartY();
-    fMZ=mtr->GetStartZ();
-    fMPx=mtr->GetPx();
-    fMPy=mtr->GetPy();
-    fMPz=mtr->GetPz();
-    fME=mtr->GetEnergy();
-    fMPhi=TMath::ATan2(fMPy, fMPx)*TMath::RadToDeg();
-    fMTheta=TMath::ATan2(TMath::Sqrt(fMPy*fMPy+fMPx*fMPx), fMPz)*TMath::RadToDeg();    
-    FindDaughters(i);
-    GetPoints();
-    // Only two daughter tracks
-    if (fN3==-1111)
-      GetInfo();
-     
-    fEntries++;
-    fTree->Fill();
-  }
-  if (fVerbose>0)
-    Info("Exec", "%d found particles in event.", fEntries);
-}
-
-/** Get information about MC ecal points **/
-void CbmEcalAnalysisPi0::GetPoints()
-{
-  Int_t i;
-  Int_t n=fPoints->GetEntriesFast();
-  CbmEcalPoint* pt;
-  
-  for(i=0;i<n;i++)
-  {
-    pt=(CbmEcalPoint*)fPoints->At(i);
-    if (pt->GetTrackID()==fN1)
-    {
-      fMCX1=pt->GetX();
-      fMCY1=pt->GetY();
-    }
-    if (pt->GetTrackID()==fN2)
-    {
-      fMCX2=pt->GetX();
-      fMCY2=pt->GetY();
-    }
-  }
-}
-/** Finds daughters of MC track **/
-void CbmEcalAnalysisPi0::FindDaughters(Int_t mother)
-{
-  Int_t i;
-  Int_t n=fMC->GetEntriesFast();
-  CbmMCTrack* mtr;
-
-  for(i=0;i<n;i++)
-  {
-    mtr=(CbmMCTrack*)fMC->At(i);
-    if (mtr->GetMotherId()==mother)
-    {
-      if (fN1==-1111) fN1=i; else
-      if (fN2==-1111) fN2=i; else
-      { 
-	fN3=i;
-	return;
-      }
-    }
-  }
-}
-
-/** Get information for daughter tracks **/
-void CbmEcalAnalysisPi0::GetInfo()
-{
-  CbmMCTrack* tr1=NULL;
-  if (fN1>=0)
-  {
-    tr1=(CbmMCTrack*)fMC->At(fN1);
-    fMCE1=tr1->GetEnergy(); fMCPx1=tr1->GetPx(); fMCPy1=tr1->GetPy(); fMCPz1=tr1->GetPz();
-    fPdg1=tr1->GetPdgCode();
-  }
-
-  CbmMCTrack* tr2=NULL;
-  if (fN2>=0)
-  {
-    tr2=(CbmMCTrack*)fMC->At(fN2);
-    fPdg2=tr2->GetPdgCode();
-    fMCE2=tr2->GetEnergy(); fMCPx2=tr2->GetPx(); fMCPy2=tr2->GetPy(); fMCPz2=tr2->GetPz();
-  }
-  TLorentzVector v1;
-  TLorentzVector v2;
-  TLorentzVector p;
-
-  if (fN1>=0&&fN2>=0)
-  {
-    v1.SetPxPyPzE(fMCPx1, fMCPy1, fMCPz1, fMCE1);
-    v2.SetPxPyPzE(fMCPx2, fMCPy2, fMCPz2, fMCE2);
-    p=v1; p+=v2;
-    fMCM=p.M();
-  }
-
-  CbmEcalRecParticle* p1=NULL;
-  CbmEcalRecParticle* p2=NULL;
-  CbmEcalRecParticle* rp=NULL;
-
-  Int_t n=fReco->GetEntriesFast();
-  Int_t i;
-  CbmEcalCell* cell;
-  CbmEcalCluster* cls;
- 
-  for(i=0;i<n;i++)
-  {
-    rp=(CbmEcalRecParticle*)fReco->At(i);
-
-    if (rp->MCTrack()==fN1&&fN1>=0)
-    {
-      if (p1==NULL) p1=rp;
-      else
-      {
-	Info("Exec", "Two reconstructed partiles belong to the same MC track %d.", p1->MCTrack());
-	continue;
-      }
-    }
-    if (rp->MCTrack()==fN2&&fN2>=0)
-    {
-      if (p2==NULL) p2=rp;
-      else
-      {
-	Info("Exec", "Two reconstructed partiles belong to the same MC track %d.", p2->MCTrack());
-	continue;
-      }
-    }
-  }
-  if (p1!=NULL)
-  {
-    fE1=p1->E(); fPx1=p1->Px(); fPy1=p1->Py(); fPz1=p1->Pz();
-    cls=(CbmEcalCluster*)fClusters->At(p1->ClusterNum());
-    fX1=p1->X(); fY1=p1->Y(); fChi21=cls->Chi2();
-    cell=fStr->GetHitCell(p1->CellNum());
-    fCellX1=cell->GetCenterX(); fCellY1=cell->GetCenterY();
-    fCellType1=cell->GetType();
-    v1.SetPxPyPzE(fPx1, fPy1, fPz1, fE1);
-  }
-  if (p2!=NULL)
-  {
-    fE2=p2->E(); fPx2=p2->Px(); fPy2=p2->Py(); fPz2=p2->Pz();
-    cls=(CbmEcalCluster*)fClusters->At(p2->ClusterNum());
-    fX2=p2->X(); fY2=p2->Y(); fChi22=cls->Chi2();
-    cell=fStr->GetHitCell(p2->CellNum());
-    fCellX2=cell->GetCenterX(); fCellY2=cell->GetCenterY();
-    fCellType2=cell->GetType();
-    v2.SetPxPyPzE(fPx2, fPy2, fPz2, fE2);
-  }
-  if (p1!=NULL&&p2!=NULL)
-  {
-    p=v1; p+=v2;
-    fM=p.M();
-  }
-}
-
-/** Initializes tree **/
-void CbmEcalAnalysisPi0::InitTree()
-{
-  fE1=-1111; fPx1=-1111; fPy1=-1111; fPz1=-1111; fMCE1=-1111; fMCPx1=-1111; fMCPy1=-1111; fMCPz1=-1111;
-  fX1=-1111; fY1=-1111;  fCellX1=-1111; fCellY1=-1111; fChi21=-1111; fCellType1=0; fPdg1=-1111;
-  fR1=-1111; fMCX1=-1111; fMCY1=-1111;
-
-  fE2=-1111; fPx2=-1111; fPy2=-1111; fPz2=-1111; fMCE2=-1111; fMCPx2=-1111; fMCPy2=-1111; fMCPz2=-1111;
-  fX2=-1111; fY2=-1111;  fCellX2=-1111; fCellY2=-1111; fChi22=-1111; fCellType2=0; fPdg2=-1111;
-  fR2=-1111; fMCX2=-1111; fMCY2=-1111;
-
-  fN1=-1111; fN2=-1111; fN3=-1111;
-
-  fM=-1111; fMCM=-1111;
-
-  if (fTree) return;
-  fTree=new TTree("Pi0Tree","Pi0 and eta tree");
-  fTree->Branch("ev",&fEvent,"ev/I");
-  fTree->Branch("mother",&fMotherID,"mother/I");
-  fTree->Branch("m",&fM,"m/D");
-  fTree->Branch("mtheta",&fMTheta,"mtheta/D");
-  fTree->Branch("mphi",&fMPhi,"mphi/D");
-  fTree->Branch("mx",&fMX,"mx/D");
-  fTree->Branch("my",&fMY,"my/D");
-  fTree->Branch("mz",&fMZ,"mz/D");
-  fTree->Branch("mpx",&fMPx,"mpx/D");
-  fTree->Branch("mpy",&fMPy,"mpy/D");
-  fTree->Branch("mpz",&fMPz,"mpz/D");
-  fTree->Branch("me",&fME,"me/D");
-  fTree->Branch("mcm",&fMCM,"mcm/D");
-
-  fTree->Branch("e1",&fE1,"e1/D");
-  fTree->Branch("px1",&fPx1,"px1/D");
-  fTree->Branch("py1",&fPy1,"py1/D");
-  fTree->Branch("pz1",&fPz1,"pz1/D");
-  fTree->Branch("mce1",&fMCE1,"mce1/D");
-  fTree->Branch("mcpx1",&fMCPx1,"mcpx1/D");
-  fTree->Branch("mcpy1",&fMCPy1,"mcpy1/D");
-  fTree->Branch("mcpz1",&fMCPz1,"mcpz1/D");
-  fTree->Branch("x1",&fX1,"x1/D");
-  fTree->Branch("y1",&fY1,"y1/D");
-  fTree->Branch("mcx1",&fMCX1,"mcx1/D");
-  fTree->Branch("mcy1",&fMCY1,"mcy1/D");
-  fTree->Branch("r1",&fR1,"r1/D");
-  fTree->Branch("cx1",&fCellX1,"cx1/D");
-  fTree->Branch("cy1",&fCellY1,"cy1/D");
-  fTree->Branch("chi21",&fChi21,"chi21/D");
-  fTree->Branch("ctype1",&fCellType1,"ctype1/I");
-  fTree->Branch("pdg1",&fPdg1,"pdg1/I");
-
-  fTree->Branch("e2",&fE2,"e2/D");
-  fTree->Branch("px2",&fPx2,"px2/D");
-  fTree->Branch("py2",&fPy2,"py2/D");
-  fTree->Branch("pz2",&fPz2,"pz2/D");
-  fTree->Branch("mce2",&fMCE2,"mce2/D");
-  fTree->Branch("mcpx2",&fMCPx2,"mcpx2/D");
-  fTree->Branch("mcpy2",&fMCPy2,"mcpy2/D");
-  fTree->Branch("mcpz2",&fMCPz2,"mcpz2/D");
-  fTree->Branch("x2",&fX2,"x2/D");
-  fTree->Branch("y2",&fY2,"y2/D");
-  fTree->Branch("mcx2",&fMCX2,"mcx2/D");
-  fTree->Branch("mcy2",&fMCY2,"mcy2/D");
-  fTree->Branch("r2",&fR2,"r2/D");
-  fTree->Branch("cx2",&fCellX2,"cx2/D");
-  fTree->Branch("cy2",&fCellY2,"cy2/D");
-  fTree->Branch("chi22",&fChi22,"chi22/D");
-  fTree->Branch("ctype2",&fCellType2,"ctype2/I");
-  fTree->Branch("pdg2",&fPdg2,"pdg2/I");
-}
-
-CbmEcalAnalysisPi0::CbmEcalAnalysisPi0()
-  : FairTask(),
-    fTree(NULL),
-    fEntries(0),
-    fEvent(0),
-    fE1(0.),
-    fPx1(0.),
-    fPy1(0.),
-    fPz1(0.),
-    fMCE1(0.),
-    fMCPx1(0.),
-    fMCPy1(0.),
-    fMCPz1(0.),
-    fMCX1(0.),
-    fMCY1(0.),
-    fX1(0.),
-    fY1(0.),
-    fCellX1(0.),
-    fCellY1(0.),
-    fR1(0.),
-    fChi21(0.),
-    fCellType1(0),
-    fPdg1(0),
-    fN1(0),
-    fE2(0.),
-    fPx2(0.),
-    fPy2(0.),
-    fPz2(0.),
-    fMCE2(0.),
-    fMCPx2(0.),
-    fMCPy2(0.),
-    fMCPz2(0.),
-    fMCX2(0.),
-    fMCY2(0.),
-    fX2(0.),
-    fY2(0.),
-    fCellX2(0.),
-    fCellY2(0.),
-    fR2(0.),
-    fChi22(0.),
-    fCellType2(0),
-    fPdg2(0),
-    fPdg3(0),
-    fN2(0),
-    fN3(0),
-    fM(0.),
-    fMCM(0.),
-    fMotherID(0),
-    fMX(0.),
-    fMY(0.),
-    fMZ(0.),
-    fMPx(0.),
-    fMPy(0.),
-    fMPz(0.),
-    fME(0.),
-    fMTheta(0.),
-    fMPhi(0.),
-    fReco(NULL),
-    fMC(NULL),
-    fTracks(NULL),
-    fClusters(NULL),
-    fStr(NULL),
-    fPoints(NULL)
-{
-}
-
-CbmEcalAnalysisPi0::CbmEcalAnalysisPi0(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fTree(NULL),
-    fEntries(0),
-    fEvent(0),
-    fE1(0.),
-    fPx1(0.),
-    fPy1(0.),
-    fPz1(0.),
-    fMCE1(0.),
-    fMCPx1(0.),
-    fMCPy1(0.),
-    fMCPz1(0.),
-    fMCX1(0.),
-    fMCY1(0.),
-    fX1(0.),
-    fY1(0.),
-    fCellX1(0.),
-    fCellY1(0.),
-    fR1(0.),
-    fChi21(0.),
-    fCellType1(0),
-    fPdg1(0),
-    fN1(0),
-    fE2(0.),
-    fPx2(0.),
-    fPy2(0.),
-    fPz2(0.),
-    fMCE2(0.),
-    fMCPx2(0.),
-    fMCPy2(0.),
-    fMCPz2(0.),
-    fMCX2(0.),
-    fMCY2(0.),
-    fX2(0.),
-    fY2(0.),
-    fCellX2(0.),
-    fCellY2(0.),
-    fR2(0.),
-    fChi22(0.),
-    fCellType2(0),
-    fPdg2(0),
-    fPdg3(0),
-    fN2(0),
-    fN3(0),
-    fM(0.),
-    fMCM(0.),
-    fMotherID(0),
-    fMX(0.),
-    fMY(0.),
-    fMZ(0.),
-    fMPx(0.),
-    fMPy(0.),
-    fMPz(0.),
-    fME(0.),
-    fMTheta(0.),
-    fMPhi(0.),
-    fReco(NULL),
-    fMC(NULL),
-    fTracks(NULL),
-    fClusters(NULL),
-    fStr(NULL),
-    fPoints(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisPi0::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fReco=(TClonesArray*)fManager->GetObject("EcalReco");
-  if (!fReco)
-  {
-    Fatal("Init", "Can't find an array of reco parcles.");
-    return kFATAL;
-  }
-  fMC=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (!fMC)
-  {
-    Fatal("Init", "Can't find an array of MC tracks.");
-    return kFATAL;
-  }
-  fTracks=(TClonesArray*)fManager->GetObject("EcalTrackParam");
-  if (!fTracks)
-  {
-    Fatal("Init", "Can't find array of reconstructed tracks");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init", "Can't find calorimeter structure in the system");
-    return kFATAL;
-  }
-  fClusters=(TClonesArray*)fManager->GetObject("EcalClusters");
-  if (!fClusters)
-  {
-    Fatal("Init", "Can't find array of clusters");
-    return kFATAL;
-  }
-  fPoints=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (fPoints==NULL)
-  {
-    Fatal("Init", "Can't find array of ecal points.");
-    return kFATAL; 
-  }
-  fTree=NULL;
-
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisPi0::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisPi0)
diff --git a/ecal/CbmEcalAnalysisPi0.h b/ecal/CbmEcalAnalysisPi0.h
deleted file mode 100644
index cd3393f0902699aa5908c014f2bc2e08004ef8ad..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisPi0.h
+++ /dev/null
@@ -1,128 +0,0 @@
-#ifndef CBMECALANALYSISPI0_H
-#define CBMECALANALYSISPI0_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class TTree;
-class TClonesArray;
-class CbmEcalStructure;
-
-class CbmEcalAnalysisPi0 : public FairTask
-{
-public:
-  CbmEcalAnalysisPi0(const char* name, const Int_t iVerbose=0);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisPi0();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisPi0() {};
-private:
-  /** Get information for daughter tracks **/
-  void GetInfo();
-  /** Get information about MC ecal points **/
-  void GetPoints();
-  /** Finds daughters of MC track **/
-  void FindDaughters(Int_t mother);
-  /** Initialize a tree **/
-  void InitTree();
-  /** Out tree **/
-  TTree* fTree;			//!
-  /** Number of found particles in this event **/
-  Int_t fEntries;
-
-  /** Event number **/
-  Int_t fEvent;
-  /** Information about first particle **/
-  Double_t fE1;
-  Double_t fPx1;
-  Double_t fPy1;
-  Double_t fPz1;
-  Double_t fMCE1;
-  Double_t fMCPx1;
-  Double_t fMCPy1;
-  Double_t fMCPz1;
-  Double_t fMCX1;
-  Double_t fMCY1;
-  Double_t fX1;
-  Double_t fY1;
-  Double_t fCellX1;
-  Double_t fCellY1;
-  Double_t fR1;
-  Double_t fChi21;
-  Int_t fCellType1;
-  Int_t fPdg1;
-  Int_t fN1;
-
-  /** Information about second particle **/
-  Double_t fE2;
-  Double_t fPx2;
-  Double_t fPy2;
-  Double_t fPz2;
-  Double_t fMCE2;
-  Double_t fMCPx2;
-  Double_t fMCPy2;
-  Double_t fMCPz2;
-  Double_t fMCX2;
-  Double_t fMCY2;
-  Double_t fX2;
-  Double_t fY2;
-  Double_t fCellX2;
-  Double_t fCellY2;
-  Double_t fR2;
-  Double_t fChi22;
-  Int_t fCellType2;
-  Int_t fPdg2;
-  Int_t fPdg3;
-  Int_t fN2;
-  Int_t fN3;
-
-  /** An invariant mass of pair **/
-  Double_t fM;
-  Double_t fMCM;
-  /** A pdg ID of pair mother **/
-  Int_t fMotherID;
-  Double_t fMX;
-  Double_t fMY;
-  Double_t fMZ;
-  Double_t fMPx;
-  Double_t fMPy;
-  Double_t fMPz;
-  Double_t fME;
-  Double_t fMTheta;
-  Double_t fMPhi;
-
-  /** An array of reconstructed particles **/
-  TClonesArray* fReco;			//!
-  /** MC tracks array **/
-  TClonesArray* fMC;			//!
-  /** Reconstructed tracks array **/
-  TClonesArray* fTracks;		//!
-  /** Array of found clusters **/
-  TClonesArray* fClusters;		//!
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;		//!
-  /** An array of ecal MC points **/
-  TClonesArray* fPoints;		//!
-
-  CbmEcalAnalysisPi0(const CbmEcalAnalysisPi0&);
-  CbmEcalAnalysisPi0& operator=(const CbmEcalAnalysisPi0&);
-
-  ClassDef(CbmEcalAnalysisPi0,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisRe.cxx b/ecal/CbmEcalAnalysisRe.cxx
deleted file mode 100644
index d8c4378daef49a9ee086e6f88b67aeaf07147246..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisRe.cxx
+++ /dev/null
@@ -1,99 +0,0 @@
-#include "CbmEcalAnalysisRe.h"
-
-#include "FairRootManager.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalPoint.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-
-/** Loop procedure **/
-void CbmEcalAnalysisRe::Exec(Option_t* /*option*/)
-{
-  Int_t n=fMCPoints->GetEntries();
-  Int_t x;
-  Int_t y;
-  CbmEcalCell* cell;
-  CbmEcalPoint* p;
-
-  InitTree();
-
-  if (n>0)
-  {
-    p=(CbmEcalPoint*)fMCPoints->At(0);
-    fMCX=p->GetX();
-    fMCY=p->GetY();
-  }
-  else
-  {
-    fMCX=-1111;
-    fMCY=-1111;
-  }
-  for(x=0;x<9;x++)
-  for(y=0;y<9;y++)
-  {
-    cell=fStr->GetCell(fSX+(x-2)*fD+0.001, fSY+(y-2)*fD+0.001);
-    fOut[x+y*9]=cell->GetTotalEnergy();
-    fX[x+y*9]=cell->GetX1();
-    fY[x+y*9]=cell->GetY1();
-//    cout << cell->GetX1() << " " << cell->GetX2() << endl;
-  }
-
-  fTree->Fill();
-}
-
-void CbmEcalAnalysisRe::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("re", "re");
-  fTree->Branch("d", fOut, "d[81]/D");
-  fTree->Branch("x", fX  , "x[81]/D");
-  fTree->Branch("y", fY  , "y[81]/D");
-  fTree->Branch("mcx",&fMCX, "mcx/D");
-  fTree->Branch("mcy",&fMCY, "mcy/D");
-}
-
-CbmEcalAnalysisRe::CbmEcalAnalysisRe(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose)
-{
-  fTree=NULL;
-  fS=9;
-  fD=6.0;
-  fSX=0.0;
-  fSY=120.0;
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisRe::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fMCPoints=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (!fMCPoints)
-  {
-    Fatal("Init()", "Can't find array of calorimeter MCPoints. ");
-    return kFATAL;
-  }
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisRe::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisRe)
diff --git a/ecal/CbmEcalAnalysisRe.h b/ecal/CbmEcalAnalysisRe.h
deleted file mode 100644
index 9ee5421ca3b8e8729f159dcecf79aaeb739c146a..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisRe.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef CBMECALANALYSISRE_H
-#define CBMECALANALYSISRE_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class TTree;
-class CbmEcalStructure;
-class TClonesArray;
-
-class CbmEcalAnalysisRe : public FairTask
-{
-public:
-  CbmEcalAnalysisRe(const char* name, const Int_t iVerbose);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisRe() {};
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisRe() {};
-
-  void SetD(Double_t d) {fD=d;}
-private:
-  TTree* fTree;
-  Double_t fOut[81];
-  Double_t fX[81];
-  Double_t fY[81];
-  Double_t fMCX;
-  Double_t fMCY;
-  void InitTree();
-  Int_t fS;
-  Double_t fD;
-  Double_t fSX;
-  Double_t fSY;
-  CbmEcalStructure* fStr;
-  TClonesArray* fMCPoints;
-
-  ClassDef(CbmEcalAnalysisRe,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisSShape.cxx b/ecal/CbmEcalAnalysisSShape.cxx
deleted file mode 100644
index 7481a6598c7ac46c2827e681935bf66f8024fe8b..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisSShape.cxx
+++ /dev/null
@@ -1,338 +0,0 @@
-#include "CbmEcalAnalysisSShape.h"
-
-#include "FairRootManager.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalInf.h"
-
-#include "TMath.h"
-#include "TClonesArray.h"
-#include "TTree.h"
-#include "TVector3.h"
-#include "TVector2.h"
-
-#include <iostream>
-#include <list>
-
-using namespace std;
-
-#define PAR1 0.38
-#define PAR2 30.8
-#define PAR3 12.0
-#define PARI 7
-/** Loop procedure **/
-void CbmEcalAnalysisSShape::Exec(Option_t*)
-{
-  fEv++;
-  cout << "Event " << fEv << endl;
-  InitTree();
-  InitVariables();
-
-  CbmEcalPoint* pt=(CbmEcalPoint*)fMCPoints->At(0);
-  TVector3 tp;
-  if (pt)
-  {
-    fTX=pt->GetX();
-    fTY=pt->GetY();
-    pt->Momentum(tp);
-    fTPhi=TMath::ATan2(tp.Y(), tp.X())*TMath::RadToDeg();
-    fTTheta=TMath::ATan2(tp.Z(), tp.Pt())*TMath::RadToDeg();
-  }
-
-  CbmEcalCell* cell=fStr->GetCell(fTX, fTY);
-  static CbmEcalInf* fInf=fStr->GetEcalInf();
-  Double_t d=fInf->GetModuleSize()/cell->GetType();
-  Int_t ix;
-  Int_t iy;
-  Int_t n;
-  CbmEcalCell* cl;
-  for(iy=0;iy<7;iy++)
-  for(ix=0;ix<7;ix++)
-  {
-    cl=fStr->GetCell(fTX+d*(ix-2), fTY+d*(iy-2));
-    if (!cl) continue;
-    n=ix+iy*7;
-    fX[n]=cl->GetCenterX();
-    fY[n]=cl->GetCenterY();
-    fE[n]=cl->GetTotalEnergy();
-  }
-  //TODO: cluster information
-
-
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t maxe=-1111;
-
-  fStr->GetCells(cells);
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    if (maxe<(*p)->GetTotalEnergy())
-    {
-      cell=(*p);
-      maxe=cell->GetTotalEnergy();
-    }
-  }
-  fMaxE=maxe;
-  fMaxX=cell->GetCenterX();
-  fMaxY=cell->GetCenterY();
-  FillClusterInfo(cell);
-
-  if (fTree)
-    fTree->Fill();
-}
-
-void CbmEcalAnalysisSShape::FillClusterInfo(CbmEcalCell* cell)
-{
-  Int_t i;
-  Int_t j;
-  Int_t k;
-  Double_t max=-1111;
-  Double_t e2;
-  Double_t imax=-1111;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t x;
-  Double_t y;
-  CbmEcalCell* cls[PARI];
-  Double_t rc[PARI];
-  Int_t cn[PARI];
-  Double_t r;
-  CbmEcalCell* tc;
-  TVector2 v;
-
-  for(i=1;i<5;i++)
-  {
-    cell->GetNeighborsList(i, cells);
-    e2=cell->GetTotalEnergy();
-    for(p=cells.begin();p!=cells.end();++p)
-      e2+=(*p)->GetTotalEnergy();
-    if (e2>max)
-    {
-      max=e2;
-      imax=i;
-    }
-  }
-  e2=cell->GetTotalEnergy();
-  x=e2*cell->GetCenterX();
-  y=e2*cell->GetCenterY();
-  cell->GetNeighborsList(imax, cells);
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    x+=(*p)->GetCenterX()*(*p)->GetTotalEnergy();
-    y+=(*p)->GetCenterY()*(*p)->GetTotalEnergy();    
-  }
-  x/=max;
-  y/=max;
-
-  fCX=x; fCY=y;
-  for(i=0;i<49;i++)
-  {
-    v.Set(fX[i]-x, fY[i]-y);
-    v=v.Rotate(-fTPhi*TMath::DegToRad());
-    fP[i]=v.X(); fQ[i]=v.Y();
-  }
-
-  for(i=0;i<PARI;i++)
-  {
-    cls[i]=NULL;
-    rc[i]=-1111;
-    cn[i]=-1111;
-  }
-
-  for(k=0;k<49;k++)
-  {
-    tc=fStr->GetCell(fX[k], fY[k]);
-    if (!tc) continue;
-    r=SolveEllipse(tc, x, y);
-    for(i=0;i<PARI;i++)
-      if (rc[i]<r)
-	break;
-    if (i==PARI) continue;
-    for(j=PARI-1;j>i;j--)
-    {
-      rc[j]=rc[j-1];
-      cls[j]=cls[j-1];
-      cn[j]=cn[j-1];
-    }
-    rc[i]=r;
-    cls[i]=tc;
-    cn[i]=k;
-  }
-
-  for(i=0;i<PARI;i++)
-    fCls[cn[i]]=1;
-}
-
-Double_t CbmEcalAnalysisSShape::SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy)
-{
-  Double_t cRx=PAR2;		//48*1.6
-  Double_t cRy=PAR3;
-  Int_t cSt=100;
-  TVector2 centr(cx, cy);
-  TVector2 t(centr);
-  Double_t gm=fTPhi*TMath::DegToRad();
-  Double_t sgm=TMath::Sin(gm);
-  Double_t cgm=TMath::Cos(gm);
-  Double_t x;
-//  Double_t y;
-  Double_t p=sgm*sgm/cRx+cgm*cgm/cRy;
-  Double_t q=cgm*sgm*(1.0/cRx-1.0/cRy);
-  Double_t r=cgm*cgm/cRx+sgm*sgm/cRy;
-  Double_t d;
-  Double_t ex;
-//  Double_t ey;
-  Double_t y1;
-  Double_t y2;
-  Double_t inte=0;
-  Double_t step=(cell->X2()-cell->X1())/cSt;
-  Double_t fx=step/2.0+cell->X1();
-  Int_t i;
-  
-// cout << fCurAlgo << " " << reg << " " << fPar1[reg] << " " << cRx << " " << cRy << endl;
-  t/=t.Mod(); centr+=t*TMath::Sqrt(PAR1);
-  for(i=0;i<cSt;i++)
-  {
-    x=step; x*=i; x+=fx;
-    ex=x; ex-=centr.X();
-    d=q*q*ex*ex-p*(r*ex*ex-1);
-    if (d<0) continue;
-    d=TMath::Sqrt(d);
-    y1=-q*ex/p; y2=y1;
-    y1-=d/p; y2+=d/p;
-    y1+=centr.Y(); y2+=centr.Y();
-    if (y1>cell->Y2()) continue;
-    if (y2<cell->Y1()) continue;
-    if (y1<cell->Y1()) y1=cell->Y1();
-    if (y2>cell->Y2()) y2=cell->Y2();
-    inte+=(y2-y1)*step;
-  }
-
-  return inte;
-}
-
-
-CbmEcalAnalysisSShape::CbmEcalAnalysisSShape()
-  : FairTask(),
-    fTree(NULL),
-    fE(),
-    fX(),
-    fY(),
-    fP(),
-    fQ(),
-    fCls(),
-    fMaxE(0.),
-    fMaxX(0.),
-    fMaxY(0.),
-    fTX(0.),
-    fTY(0.),
-    fCX(0.),
-    fCY(0.),
-    fTTheta(0.),
-    fTPhi(0.),
-    fEv(0),
-    fMCPoints(NULL),
-    fStr(NULL)
-{
-}
-
-
-CbmEcalAnalysisSShape::CbmEcalAnalysisSShape(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fTree(NULL),
-    fE(),
-    fX(),
-    fY(),
-    fP(),
-    fQ(),
-    fCls(),
-    fMaxE(0.),
-    fMaxX(0.),
-    fMaxY(0.),
-    fTX(0.),
-    fTY(0.),
-    fCX(0.),
-    fCY(0.),
-    fTTheta(0.),
-    fTPhi(0.),
-    fEv(0),
-    fMCPoints(NULL),
-    fStr(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisSShape::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  fMCPoints=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (fMCPoints==NULL)
-  {
-    cerr << "There are no EcalPoint branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  
-
-  fTree=NULL;
-
-  return kSUCCESS;
-}
-
-void CbmEcalAnalysisSShape::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("ssh","shower shape analysis");
-  fTree->Branch("ev", &fEv, "ev/I");
-  fTree->Branch("e", fE, "e[49]/D");
-  fTree->Branch("x", fX, "x[49]/D");
-  fTree->Branch("y", fY, "y[49]/D");
-  fTree->Branch("p", fP, "p[49]/D");
-  fTree->Branch("q", fQ, "q[49]/D");
-  fTree->Branch("cls", fCls, "cls[49]/I");
-  fTree->Branch("maxe", &fMaxE, "maxe/D");
-  fTree->Branch("maxx", &fMaxX, "maxx/D");
-  fTree->Branch("maxy", &fMaxY, "maxy/D");
-  fTree->Branch("tx", &fTX, "tx/D");
-  fTree->Branch("ty", &fTY, "ty/D");
-  fTree->Branch("cx", &fCX, "cx/D");
-  fTree->Branch("cy", &fCY, "cy/D");
-  fTree->Branch("ttheta", &fTTheta, "ttheta/D");
-  fTree->Branch("tphi", &fTPhi, "tphi/D");
-}
-
-void CbmEcalAnalysisSShape::InitVariables()
-{
-  Int_t i;
-
-  for(i=0;i<49;i++)
-  {
-    fE[i]=-1111;
-    fX[i]=-1111;
-    fY[i]=-1111;
-    fP[i]=-1111;
-    fQ[i]=-1111;
-    fCls[i]=-1111;
-  }
-  fCX=-1111;
-  fCY=-1111;
-  fTX=-1111;
-  fTY=-1111;
-  fMaxX=-1111;
-  fMaxY=-1111;
-  fMaxE=-1111;
-}
-/** Finishing routine **/
-void CbmEcalAnalysisSShape::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisSShape)
diff --git a/ecal/CbmEcalAnalysisSShape.h b/ecal/CbmEcalAnalysisSShape.h
deleted file mode 100644
index ee16798059bf0fe505009da510cf81c2dc17f388..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisSShape.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef CBMECALANALYSISSSHAPE_H
-#define CBMECALANALYSISSSHAPE_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-class TTree;
-class CbmEcalStructure;
-class TClonesArray;
-class CbmEcalCell;
-
-class CbmEcalAnalysisSShape : public FairTask
-{
-public:
-  CbmEcalAnalysisSShape(const char* name, const Int_t iVerbose);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisSShape();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisSShape() {};
-private:
-  void InitTree();
-  void InitVariables();
-  void FillClusterInfo(CbmEcalCell* cell);
-  Double_t SolveEllipse(CbmEcalCell* cell, Double_t cx,Double_t cy);
-  TTree* fTree;
-  Double_t fE[49];
-  Double_t fX[49];
-  Double_t fY[49];
-  Double_t fP[49];
-  Double_t fQ[49];
-  Int_t fCls[49];
-  Double_t fMaxE;
-  Double_t fMaxX;
-  Double_t fMaxY;
-  Double_t fTX;
-  Double_t fTY;
-  Double_t fCX;
-  Double_t fCY;
-  Double_t fTTheta;
-  Double_t fTPhi;
-  Int_t fEv;
-
-  TClonesArray* fMCPoints;		//!
-  CbmEcalStructure* fStr;		//!
-
-  CbmEcalAnalysisSShape(const CbmEcalAnalysisSShape&);
-  CbmEcalAnalysisSShape& operator=(const CbmEcalAnalysisSShape&);
-
-  ClassDef(CbmEcalAnalysisSShape,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisShape.cxx b/ecal/CbmEcalAnalysisShape.cxx
deleted file mode 100644
index 478ef1a2fef3eec62d2450e332f2c3cbf9f61b8f..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisShape.cxx
+++ /dev/null
@@ -1,233 +0,0 @@
-#include "CbmEcalAnalysisShape.h"
-
-#include "FairRootManager.h"
-
-#include "CbmMCTrack.h"
-
-#include "CbmEcalInf.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalPointLite.h"
-#include "CbmEcal.h"
-
-#include "TTree.h"
-#include "TMath.h"
-#include "TClonesArray.h"
-
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-
-Int_t CbmEcalAnalysisShape::GetNum(Double_t x, Double_t y) const
-{
-  Double_t dx=x; dx+=0.025; dx-=fDX; dx/=fStep;
-  Double_t dy=y; dy+=0.025; dy-=fDY; dy/=fStep;
-  Int_t ix=TMath::FloorNint(dx+0.00001);
-  Int_t iy=TMath::FloorNint(dy+0.00001);
-  if (fVerbose>99)
-  {
-    cout << "(x, y)=(" << x << ", " << y << "), (dx, dy)=(" << dx << ", " << dy << "), (ix, iy)=(" << ix << ", " << iy << ")" << endl; 
-  }
-  if (ix<0) return -1111;
-  if (iy<0) return -1111;
-  if (ix>=fXSize) return -1111;
-  if (iy>=fYSize) return -1111;
-  return ix+iy*fXSize;
-}
-/** Loop procedure **/
-void CbmEcalAnalysisShape::Exec(Option_t*)
-{
-  fEv++;
-//  cout << fEv << endl;
-  InitTree();
-  InitE();
-
-  Int_t i;
-  Int_t n;
-  Int_t m;
-  CbmEcalPointLite* p;
-//  Bool_t isPS;
-  Int_t ten;
-  Float_t x;
-  Float_t y;
-
-  if (fWriteEach)
-    for(i=0;i<fSize;i++)
-      fShape[i]=0.0;
-  n=fP->GetEntriesFast();
-  for(i=0;i<n;i++)
-  {
-    p=(CbmEcalPointLite*)fP->At(i);
-    if (!p) continue;
-    CbmEcal::GetCellCoord(p->GetDetectorID(), x, y, ten);
-//    isPS=CbmEcal::GetCellCoord(p->GetDetectorID(), x, y, ten);
-    if (ten!=0) continue;
-    m=GetNum(x-fStartX, y-fStartY);
-    if (m<0)
-    {
-//      cout << m << endl;
-      continue;
-    }
-    fShape[m]+=p->GetEnergyLoss();
-  }
-  if (fWriteEach)
-  {
-    for(i=0;i<fSize;i++)
-      fShapeOut[i]=fShape[i];
-    fTree->Fill();
-  }
-} 
-
-
-CbmEcalAnalysisShape::CbmEcalAnalysisShape()
-  : FairTask(),
-    fName(),
-    fE(0.),
-    fPhi(0.),
-    fTheta(0.),
-    fShape(NULL),
-    fShapeOut(NULL),
-    fXSize(30*12),
-    fYSize(30*12),
-    fSize(0),
-    fDX(-12.),
-    fDY(-12.),
-    fStep(0.1),
-    fStartX(0.),
-    fStartY(0.),
-    fWriteEach(kFALSE),
-    fEv(0),
-    fTree(NULL),
-    fInf(),
-    fMC(NULL),
-    fP(NULL),
-    fMCTracks(NULL)
-{
-}
-
-
-CbmEcalAnalysisShape::CbmEcalAnalysisShape(const char* name, const Int_t iVerbose, const char* fname)
-  : FairTask(name, iVerbose),
-    fName(fname),
-    fE(0.),
-    fPhi(0.),
-    fTheta(0.),
-    fShape(NULL),
-    fShapeOut(NULL),
-    fXSize(30*12),
-    fYSize(30*12),
-    fSize(0),
-    fDX(-12.),
-    fDY(-12.),
-    fStep(0.1),
-    fStartX(0.),
-    fStartY(0.),
-    fWriteEach(kFALSE),
-    fEv(0),
-    fTree(NULL),
-    fInf(CbmEcalInf::GetInstance(fName)),
-    fMC(NULL),
-    fP(NULL),
-    fMCTracks(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisShape::Init()
-{
-  Int_t i;
-  FairRootManager* fManager = FairRootManager::Instance();
-
-  fMC=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (!fMC)
-  {
-    Fatal("Init()", "Can't find array of calorimeter points in the system.");
-    return kFATAL;
-  }
-  fP=(TClonesArray*)fManager->GetObject("EcalPointLite");
-  if (!fP)
-  {
-    Fatal("Init()", "Can't find array of lite points in the system.");
-    return kFATAL;
-  }
-  fMCTracks=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (!fMCTracks)
-  {
-    Fatal("Init()", "Can't find array of MC tracks in the system.");
-    return kFATAL;
-  }
-  fStep=fInf->GetCellSize();
-  fXSize=30*12*(0.1+0.000001)/fStep;
-  fYSize=30*12*(0.1+0.000001)/fStep;
-  Info("Init()", "fXSize=%d, fYSize=%d", fXSize, fYSize);
-  Info("Init", "Using %f cell size", fStep);
-  fSize=fXSize*fYSize;
-  fShape=new Double_t[fSize];
-  fShapeOut=new Float_t[fSize];
-  for(i=0;i<fSize;i++)
-    fShape[i]=0.0;
-  fE=-1111;
-  fPhi=-1111;
-  fTheta=-1111;
-
-  return kSUCCESS;
-}
-
-void CbmEcalAnalysisShape::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("shape","shover shape");
-  fTree->Branch("e", &fE, "e/D");
-  fTree->Branch("phi", &fPhi, "phi/D");
-  fTree->Branch("theta", &fTheta, "theta/D");
-  fTree->Branch("dx", &fDX, "dx/D");
-  fTree->Branch("dy", &fDY, "dy/D");
-  fTree->Branch("step", &fStep, "step/D");
-  fTree->Branch("xsize", &fXSize, "xsize/I");
-  fTree->Branch("ysize", &fYSize, "ysize/I");
-  TString nm; nm="shape["; nm+=fSize; nm+="]/F";
-  fTree->Branch("shape", fShapeOut, nm);
-}
-
-void CbmEcalAnalysisShape::InitE()
-{
-  CbmEcalPoint* pt=(CbmEcalPoint*)fMC->At(0);
-  CbmMCTrack* mc=(CbmMCTrack*)fMCTracks->At(pt->GetTrackID());
-  TLorentzVector v;
-  mc->Get4Momentum(v);
-  fE=v.E();
-  fPhi=v.Phi();
-  fTheta=v.Theta();
-  fStartX=pt->GetX();
-  fStartY=pt->GetY();
- 
-  if (fVerbose>9)
-    cout << "start: (" << fStartX << ", " << fStartY << ")" << endl;
-}
-/** Finishing routine **/
-void CbmEcalAnalysisShape::Finish()
-{
-  Int_t i;
-
-  if (fTree)
-  {
-    if (!fWriteEach)
-    {
-      for(i=0;i<fSize;i++)
-      {
-	fShape[i]/=fEv;
-        fShapeOut[i]=fShape[i];
-      }
-      fTree->Fill();
-    }
-    fTree->Write();
-  }
-}
-
-CbmEcalAnalysisShape::~CbmEcalAnalysisShape()
-{
-  delete fShape;
-  delete fShapeOut;
-}
-
-ClassImp(CbmEcalAnalysisShape)
diff --git a/ecal/CbmEcalAnalysisShape.h b/ecal/CbmEcalAnalysisShape.h
deleted file mode 100644
index 4a0252e462cbabb9f54936fd9737cab46981b9b7..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisShape.h
+++ /dev/null
@@ -1,81 +0,0 @@
-#ifndef CBMECALANALYSISSHAPE_H
-#define CBMECALANALYSISSHAPE_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class TTree;
-class CbmEcalInf;
-class TClonesArray;
-
-class CbmEcalAnalysisShape: public FairTask
-{
-public:
-  CbmEcalAnalysisShape(const char* name, const Int_t iVerbose, const char* fname);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisShape();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisShape();
-/*
-  void SetE(Double_t e)  {fE=e;}
-  void SetPhi(Double_t phi)  {fPhi=phi;}
-  void SetTheta(Double_t theta)  {fTheta=theta;}
-*/
-  void SetXSize(Int_t xsize) {fXSize=xsize;}
-  void SetYSize(Int_t ysize) {fYSize=ysize;}
-  void SetDX(Double_t dx) {fDX=dx;}
-  void SetDY(Double_t dy) {fDY=dy;}
-//  void SetStartX(Double_t startx) {fStartX=startx;}
-//  void SetStartY(Double_t starty) {fStartY=starty;}
-  void SetWriteEach(Bool_t writeeach) {fWriteEach=writeeach;}
-  Int_t GetNum(Double_t x,Double_t y) const;
-private:
-  void InitTree();
-  void InitE();
-  TString fName;
-
-  Double_t fE;
-  Double_t fPhi;
-  Double_t fTheta;
-  Double_t* fShape;			//!
-  Float_t* fShapeOut;			//!
-  Int_t fXSize;
-  Int_t fYSize;
-  Int_t fSize;
-  Double_t fDX;
-  Double_t fDY;
-  Double_t fStep;
-  Double_t fStartX;
-  Double_t fStartY;
-  Bool_t fWriteEach;
-
-  Int_t fEv;
-
-  TTree* fTree;				//!
-  CbmEcalInf* fInf;			//!
-  TClonesArray* fMC;			//!
-  TClonesArray* fP;			//!
-  TClonesArray* fMCTracks;		//!
-
-  CbmEcalAnalysisShape(const CbmEcalAnalysisShape&);
-  CbmEcalAnalysisShape& operator=(const CbmEcalAnalysisShape&);
-
-  ClassDef(CbmEcalAnalysisShape,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisSimple.cxx b/ecal/CbmEcalAnalysisSimple.cxx
deleted file mode 100644
index c95e5a2d47cee7cdb415f6b4c881775d33d8fee9..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisSimple.cxx
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "CbmEcalAnalysisSimple.h"
-
-#include "FairRootManager.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalDrawer.h"
-
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-
-/** Loop procedure **/
-void CbmEcalAnalysisSimple::Exec(Option_t*)
-{
-  fEv++;
-
-  TString nm=""; nm+=fEv;
-  Int_t i=nm.Length();
-  for(;i<4;i++) nm="0"+nm;
-  nm="ec"+nm; nm+=".png";
-  fDr->InitMaximumEnergy();
-  fDr->DrawEcal();
-  fDr->GetCanvas()->SaveAs(nm);
-}
-
-
-CbmEcalAnalysisSimple::CbmEcalAnalysisSimple()
-  : FairTask(),
-    fDr(NULL),
-    fStr(NULL),
-    fName(""),
-    fEv(0)
-{
-}
-
-CbmEcalAnalysisSimple::CbmEcalAnalysisSimple(const char* name, const Int_t iVerbose, const char* fname)
-  : FairTask(name, iVerbose),
-    fDr(NULL),
-    fStr(NULL),
-    fName(fname),
-    fEv(0)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisSimple::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fDr=new CbmEcalDrawer(fStr);
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisSimple::Finish()
-{
-  ofstream f(fName);
-  f << fEv << endl;
-  f.close();
-}
-
-ClassImp(CbmEcalAnalysisSimple)
diff --git a/ecal/CbmEcalAnalysisSimple.h b/ecal/CbmEcalAnalysisSimple.h
deleted file mode 100644
index e6c9bdb756887fedb72f7921dea91d07ee563ca9..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisSimple.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef CBMECALANALYSISSIMPLE_H
-#define CBMECALANALYSISSIMPLE_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class CbmEcalDrawer;
-class CbmEcalStructure;
-
-class CbmEcalAnalysisSimple : public FairTask
-{
-public:
-  CbmEcalAnalysisSimple(const char* name, const Int_t iVerbose, const char* fname);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisSimple();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisSimple() {};
-private:
-  CbmEcalDrawer* fDr;
-  CbmEcalStructure* fStr;
-  TString fName;
-  Int_t fEv;
-
-  CbmEcalAnalysisSimple(const CbmEcalAnalysisSimple&);
-  CbmEcalAnalysisSimple& operator=(const CbmEcalAnalysisSimple&);
-
-  ClassDef(CbmEcalAnalysisSimple,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalAnalysisUniformity.cxx b/ecal/CbmEcalAnalysisUniformity.cxx
deleted file mode 100644
index a97ed2609f07db082909f76166c561a43455eaac..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisUniformity.cxx
+++ /dev/null
@@ -1,120 +0,0 @@
-#include "CbmEcalAnalysisUniformity.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "CbmEcalCell.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalCell.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-
-#include <iostream>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::list;
-
-/** Loop procedure **/
-void CbmEcalAnalysisUniformity::Exec(Option_t*)
-{
-  CbmEcalPoint* pt=(CbmEcalPoint*)fPoints->At(0);
-//  CbmEcalCell* c;
-  list<CbmEcalCell*>::const_iterator p;
-  list<CbmEcalCell*> cl;
-  if (pt==NULL) return;
-
-  InitTree();
-
-  fX=pt->GetX();
-  fY=pt->GetY();
-
-//  c=fStr->GetCell(fX, fY);
-//  fE=c->GetTotalEnergy();
-//  c->GetNeighborsList(0, cl);
-//  for(p=cl.begin();p!=cl.end();++p)
-//    fE+=(*p)->GetTotalEnergy();
-
-  fStr->GetCells(cl);
-  fE=0;
-  for(p=cl.begin();p!=cl.end();++p)
-    fE+=(*p)->GetTotalEnergy();
-    
-  fTree->Fill();
-}
-
-
-/** Initializes tree **/
-void CbmEcalAnalysisUniformity::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("uniformity","");
-  fTree->Branch("x",&fX,"x/D");
-  fTree->Branch("y",&fY,"y/D");
-  fTree->Branch("e",&fE,"e/D");
-}
-
-CbmEcalAnalysisUniformity::CbmEcalAnalysisUniformity()
-  : FairTask(),
-    fTree(NULL),
-    fEntries(0),
-    fN(0),
-    fE(0.),
-    fX(0.),
-    fY(0.),
-    fStr(NULL),
-    fPoints(NULL)
-{
-}
-
-CbmEcalAnalysisUniformity::CbmEcalAnalysisUniformity(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fTree(NULL),
-    fEntries(0),
-    fN(0),
-    fE(0.),
-    fX(0.),
-    fY(0.),
-    fStr(NULL),
-    fPoints(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalAnalysisUniformity::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init", "Can't find calorimeter structure in the system");
-    return kFATAL;
-  }
-  fPoints=(TClonesArray*)fManager->GetObject("ECALPoint");
-  if (!fPoints)
-  {
-    Fatal("Init","Can't find an array of calorimeter points.");
-    return kFATAL;
-  }
-  fTree=NULL;
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalAnalysisUniformity::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalAnalysisUniformity)
diff --git a/ecal/CbmEcalAnalysisUniformity.h b/ecal/CbmEcalAnalysisUniformity.h
deleted file mode 100644
index f258b36734ae1889a97c34a78dace01a661fb92b..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalAnalysisUniformity.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef CBMECALANALYSISUNIFORMITY_H
-#define CBMECALANALYSISUNIFORMITY_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class TTree;
-class TClonesArray;
-class CbmEcalStructure;
-
-class CbmEcalAnalysisUniformity : public FairTask
-{
-public:
-  CbmEcalAnalysisUniformity(const char* name, const Int_t iVerbose=0);
-public:
-  /** Default constructor **/
-  CbmEcalAnalysisUniformity();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalAnalysisUniformity() {};
-private:
-  /** Initialize a tree **/
-  void InitTree();
-  /** Out tree **/
-  TTree* fTree;			//!
-  /** Number of found particles in this event **/
-  Int_t fEntries;
-  /** Number of particle in event **/
-  Int_t fN;
-
-  /** Information about first particle **/
-  Double_t fE;
-  Double_t fX;
-  Double_t fY;
-
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;
-  /** An array points before the calorimeter**/
-  TClonesArray* fPoints;
-
-  CbmEcalAnalysisUniformity(const CbmEcalAnalysisUniformity&);
-  CbmEcalAnalysisUniformity& operator=(const CbmEcalAnalysisUniformity&);
-
-  ClassDef(CbmEcalAnalysisUniformity,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalCalibration.cxx b/ecal/CbmEcalCalibration.cxx
deleted file mode 100644
index 06261c63b85003722709937896a8aea2c8bba3e4..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalCalibration.cxx
+++ /dev/null
@@ -1,132 +0,0 @@
-#include "CbmEcalCalibration.h"
-
-#include "CbmEcalCell.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalParam.h"
-
-#include "FairRootManager.h"
-
-#include <list>
-#include <iostream>
-
-using namespace std;
-
-/** Standard constructor **/
-CbmEcalCalibration::CbmEcalCalibration(const char *name, const Int_t iVerbose, const  char* parname)
-  : FairTask(name, iVerbose),
-    fParName(parname),
-    fP0a(),
-    fP0b(),
-    fP1a(),
-    fP1b(),
-    fInf(NULL)
-{
-  /**TODO: Need to read parameters from a parname file! **/
-  fP0a[1]=0.003145;
-  fP0a[2]=0.003143;
-  fP0a[4]=0.003457;
-  fP0b[1]=0.08834;
-  fP0b[2]=0.08558;
-  fP0b[4]=0.07944;
-
-  fP1a[1]=0.002642;
-  fP1a[2]=0.003136;
-  fP1a[4]=0.004906;
-  fP1b[1]=-0.004985;
-  fP1b[2]=-0.005067;
-  fP1b[4]=-0.008054;
-}
-
-/** Default constructor **/
-CbmEcalCalibration::CbmEcalCalibration()
-  : FairTask(),
-    fParName(),
-    fP0a(),
-    fP0b(),
-    fP1a(),
-    fP1b(),
-    fInf(NULL)
-{
-}
-
-InitStatus CbmEcalCalibration::Init()
-{
-  Int_t i;
-  TString tmp;
-
-  CbmEcalParam* par=new CbmEcalParam("calibration", fParName);
-  for(i=1;i<5;i++)
-  {
-    tmp="p0a["; tmp+=i; tmp+="]"; fP0a[i]=par->GetDouble(tmp);
-    tmp="p0b["; tmp+=i; tmp+="]"; fP0b[i]=par->GetDouble(tmp);
-    tmp="p1a["; tmp+=i; tmp+="]"; fP1a[i]=par->GetDouble(tmp);
-    tmp="p1b["; tmp+=i; tmp+="]"; fP1b[i]=par->GetDouble(tmp);
-  }
-  delete par;
-
-  FairRootManager* io=FairRootManager::Instance();
-
-  if (!io)
-  {
-    Fatal("Init()", "Can't find FairRootManager.");
-    return kFATAL;
-  }
-  CbmEcalStructure* fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fInf=fStr->GetEcalInf();
-
-  io->Register("EcalCalibration", "ECAL", this, kFALSE);
-  return kSUCCESS;
-}
-
-/** A framework requirement **/
-void CbmEcalCalibration::Finish()
-{
-  ;
-}
-
-void CbmEcalCalibration::Exec(const Option_t*)
-{
-  ;
-}
-
-/** Get energy with standard 2x2 procedure **/
-Double_t CbmEcalCalibration::GetEnergy(const CbmEcalCell* cell)
-{
-  Double_t e2=0;
-  Int_t i;
-  list<CbmEcalCell*> tmp;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t e;
-
-  for(i=1;i<5;i++)
-  {
-    cell->GetNeighborsList(i, tmp);
-    e=cell->GetTotalEnergy();
-    for(p=tmp.begin();p!=tmp.end();++p)
-      e+=(*p)->GetTotalEnergy();
-    if (e>e2) e2=e;
-  }
-  return GetEnergy(e2, cell);
-}
-
-Double_t CbmEcalCalibration::GetEnergy(Double_t e2, const CbmEcalCell* cell) 
-{
-  Double_t x=cell->GetCenterX();
-  Double_t y=cell->GetCenterY();
-  Double_t tantheta=TMath::Sqrt(x*x+y*y)/fInf->GetZPos();
-
-  return GetEnergy(e2, tantheta, cell->GetType());  
-}
-
-CbmEcalCalibration::~CbmEcalCalibration()
-{
-  ;
-}
-
-ClassImp(CbmEcalCalibration)
diff --git a/ecal/CbmEcalCalibration.h b/ecal/CbmEcalCalibration.h
deleted file mode 100644
index 3cd53a1bec03dc278fb91515296ca95f32e7396c..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalCalibration.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/** A very simple calorimeter calibration container.
- ** Paramers now hardcoded. This is BAD. Waiting for general
- ** parameter hadlning in the framework. **/
-
-#ifndef CBMECALCALIBRATION_H
-#define CBMECALCALIBRATION_H
-
-#include "FairTask.h"
-#include "TMath.h"
-#include "TString.h"
-
-class CbmEcalCell;
-class CbmEcalInf;
-
-
-class CbmEcalCalibration : public FairTask 
-{
-public:
-  /** Standard constructor **/
-  CbmEcalCalibration(const char *name, const Int_t iVerbose, const char* parname);
-  /** Default constructor **/
-  CbmEcalCalibration();
-
-  virtual void Exec(const Option_t* option);
-  virtual InitStatus Init();
-  virtual void Finish();
-
-  /** Get energy with standart 2x2 procedure **/
-  virtual Double_t GetEnergy(const CbmEcalCell* cell);
-  virtual Double_t GetEnergy(Double_t e2, const CbmEcalCell* cell);
-  virtual Double_t GetEnergy(Double_t e2, Double_t tantheta, Int_t celltype) const;
-  /** Get calorimeter respose to photon of given energy **/
-  virtual Double_t GetE2(Double_t e, Double_t tantheta, Int_t celltype) const;
-  /** Rough estimation of energy **/
-  virtual Double_t GetERough(Double_t e) const;
-  virtual ~CbmEcalCalibration();
-  virtual TString ParName() const {return fParName;} 
-private:
-  /** Name of the parameter file **/
-  TString fParName;
-  /** Calibration **/
-  Double_t fP0a[5];		//!
-  Double_t fP0b[5];		//!
-  Double_t fP1a[5];		//!
-  Double_t fP1b[5];		//!
-
-  /** Information about the calorimeter **/
-  CbmEcalInf* fInf;		//!
-  
-  CbmEcalCalibration(const CbmEcalCalibration&);
-  CbmEcalCalibration& operator=(const CbmEcalCalibration&);
-
-  ClassDef(CbmEcalCalibration, 1)
-};
-
-inline Double_t CbmEcalCalibration::GetEnergy(Double_t e2, Double_t tantheta, Int_t celltype) const
-{
-  Double_t a=fP0a[celltype]+fP1a[celltype]*tantheta;
-  Double_t b=fP0b[celltype]+fP1b[celltype]*tantheta;
-  Double_t d=TMath::Sqrt(a*a+4.0*e2*b);
-  Double_t res=(-a+d)/2.0/b; res*=res;
-  return res;
-}
-
-/** Get calorimeter respose to photon of given energy **/
-inline Double_t CbmEcalCalibration::GetE2(Double_t e, Double_t tantheta, Int_t celltype) const
-{
-  Double_t a=fP0a[celltype]+fP1a[celltype]*tantheta;
-  Double_t b=fP0b[celltype]+fP1b[celltype]*tantheta;
-  return e*(b+a/TMath::Sqrt(e));
-}
-
-/** Rough estimation of energy **/
-inline Double_t CbmEcalCalibration::GetERough(Double_t e) const
-{
-  return e/fP0b[1];
-}
-#endif
diff --git a/ecal/CbmEcalCalibrationV2.cxx b/ecal/CbmEcalCalibrationV2.cxx
deleted file mode 100644
index 51457afc64fafa6c7fcc26e6d360b916ff9245d5..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalCalibrationV2.cxx
+++ /dev/null
@@ -1,134 +0,0 @@
-#include "CbmEcalCalibrationV2.h"
-
-#include "CbmEcalCell.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalParam.h"
-
-#include "FairRootManager.h"
-
-#include <list>
-#include <iostream>
-
-using namespace std;
-
-/** Standard constructor **/
-CbmEcalCalibrationV2::CbmEcalCalibrationV2(const char *name, const Int_t iVerbose, const  char* parname)
-  : CbmEcalCalibration(name, iVerbose, parname),
-    fParName(""),
-    fContName(""),
-    fP(NULL),
-    fMethods(0),
-    fMethodB(NULL),
-    fInf(NULL)   
-{
-}
-
-/** Default constructor **/
-CbmEcalCalibrationV2::CbmEcalCalibrationV2()
-  : CbmEcalCalibration(),
-    fParName(""),
-    fContName(""),
-    fP(NULL),
-    fMethods(0),
-    fMethodB(NULL),
-    fInf(NULL)   
-{
-}
-
-InitStatus CbmEcalCalibrationV2::Init()
-{
-  Int_t p;
-  Int_t m;
-  Int_t n;
-  TString tmp;
-
-  CbmEcalParam* par=new CbmEcalParam("calibration", ParName());
-  fMethods=par->GetInteger("methods");
-  fMethodB=new Double_t[fMethods];
-  fP=new Double_t[fMethods*9];
-  for(m=0;m<fMethods;m++)
-  {
-    tmp="methodb["; tmp+=m; tmp+="]";
-    fMethodB[m]=par->GetDouble(tmp);
-  }
-
-  for(m=0;m<fMethods;m++)
-  for(p=0;p<3;p++)
-  for(n=0;n<3;n++)
-  {
-    tmp="p"; tmp+=p; tmp+="m"; tmp+=m; tmp+="["; tmp+=n; tmp+="]";
-    fP[N(p,m,n)]=par->GetDouble(tmp);
-//    cout << tmp+"=" << par->GetDouble(tmp) << endl;
-  }
-  fContName=par->GetString("containername");
-
-  delete par;
-
-  FairRootManager* io=FairRootManager::Instance();
-
-  if (!io)
-  {
-    Fatal("Init()", "Can't find FairRootManager.");
-    return kFATAL;
-  }
-  CbmEcalStructure* fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fInf=fStr->GetEcalInf();
-
-  io->Register(fContName, "ECAL", this, kFALSE);
-  return kSUCCESS;
-}
-
-/** A framework requirement **/
-void CbmEcalCalibrationV2::Finish()
-{
-  ;
-}
-
-void CbmEcalCalibrationV2::Exec(const Option_t*)
-{
-  ;
-}
-
-/** Get energy with standard 2x2 procedure **/
-Double_t CbmEcalCalibrationV2::GetEnergy(const CbmEcalCell* cell)
-{
-  Double_t e2=0;
-  Int_t i;
-  list<CbmEcalCell*> tmp;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t e;
-
-  for(i=1;i<5;i++)
-  {
-    cell->GetNeighborsList(i, tmp);
-    e=cell->GetTotalEnergy();
-    for(p=tmp.begin();p!=tmp.end();++p)
-      e+=(*p)->GetTotalEnergy();
-    if (e>e2) e2=e;
-  }
-  return GetEnergy(e2, cell);
-}
-
-Double_t CbmEcalCalibrationV2::GetEnergy(Double_t Ecls, const CbmEcalCell* cell) 
-{
-  Double_t x=cell->GetCenterX();
-  Double_t y=cell->GetCenterY();
-  Double_t tantheta=TMath::Sqrt(x*x+y*y)/fInf->GetZPos();
-
-//  cout << "--> "<< Ecls << " " << x << " " << y << " " << tantheta << " " << GetEnergy(Ecls, tantheta, cell->GetType()) << endl;
-  return GetEnergy(Ecls, tantheta, cell->GetType());  
-}
-
-CbmEcalCalibrationV2::~CbmEcalCalibrationV2()
-{
-  delete fP;
-  delete fMethodB;
-}
-
-ClassImp(CbmEcalCalibrationV2)
diff --git a/ecal/CbmEcalCalibrationV2.h b/ecal/CbmEcalCalibrationV2.h
deleted file mode 100644
index 146e7938cded8f0d41c584a5757df5bf86e41d58..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalCalibrationV2.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/** A very simple calorimeter calibration container.
- ** Paramers now hardcoded. This is BAD. Waiting for general
- ** parameter hadlning in the framework. **/
-
-#ifndef CBMECALCALIBRATIONV2_H
-#define CBMECALCALIBRATIONV2_H
-
-#include "CbmEcalCalibration.h"
-#include "TMath.h"
-#include "TString.h"
-
-class CbmEcalCell;
-class CbmEcalInf;
-
-
-class CbmEcalCalibrationV2 : public CbmEcalCalibration
-{
-public:
-  /** Standard constructor **/
-  CbmEcalCalibrationV2(const char *name, const Int_t iVerbose, const char* parname);
-  /** Default constructor **/
-  CbmEcalCalibrationV2();
-
-  virtual void Exec(const Option_t* option);
-  virtual InitStatus Init();
-  virtual void Finish();
-
-  /** Get energy with standart 2x2 procedure **/
-  virtual Double_t GetEnergy(const CbmEcalCell* cell);
-  virtual Double_t GetEnergy(Double_t Ecls, const CbmEcalCell* cell);
-  virtual Double_t GetEnergy(Double_t Ecls, Double_t tantheta, Int_t celltype) const;
-  /** Get calorimeter respose to photon of given energy **/
-  virtual Double_t GetE2(Double_t e, Double_t tantheta, Int_t celltype) const;
-  /** Rough estimation of energy **/
-  virtual Double_t GetERough(Double_t e) const;
-  virtual ~CbmEcalCalibrationV2();
-private:
-  /** Method to use **/
-  Int_t GetMethod(Double_t m) const;
-  /** Index in parameter array**/
-  Int_t N(Int_t p, Int_t m, Int_t n) const;
-  /** Name of the parameter file **/
-  TString fParName;
-  /** Name of the container **/
-  TString fContName;
-  /** Calibration **/
-  Double_t* fP; 		//!
-  /** Number of methods **/
-  Int_t fMethods;	
-  /** Angular bounradies of method **/
-  Double_t* fMethodB;		//!
-  /** Information about the calorimeter **/
-  CbmEcalInf* fInf;		//!
-  
-  CbmEcalCalibrationV2(const CbmEcalCalibrationV2&);
-  CbmEcalCalibrationV2& operator=(const CbmEcalCalibrationV2&);
-
-  ClassDef(CbmEcalCalibrationV2, 1)
-};
-
-/** We will never have more than 5 methods in this calibration. I hope... **/
-inline Int_t CbmEcalCalibrationV2::GetMethod(Double_t m) const
-{
-  if (fMethodB[0]>m) return 0;
-  if (fMethodB[1]>m) return 1;
-  if (fMethodB[2]>m) return 2;
-  if (fMethodB[3]>m) return 3;
-  return 4;
-}
-
-inline Int_t CbmEcalCalibrationV2::N(Int_t p, Int_t m, Int_t n) const 
-  {return n+3*m+3*fMethods*p;}
-
-inline Double_t CbmEcalCalibrationV2::GetEnergy(Double_t Ecls, Double_t tantheta, Int_t celltype) const
-{
-  if (Ecls<1e-5) return 0;
-  Double_t theta=TMath::ATan(tantheta)*TMath::RadToDeg();
-  Int_t m=celltype;
-  if (m<0) GetMethod(tantheta);
-  Double_t p00=fP[N(0,m,0)];
-  Double_t p01=fP[N(0,m,1)];
-  Double_t p02=fP[N(0,m,2)];
-  Double_t p0=p00+theta*(p01+theta*p02);
-
-  Double_t p10=fP[N(1,m,0)];
-  Double_t p11=fP[N(1,m,1)];
-  Double_t p12=fP[N(1,m,2)];
-  Double_t p1=p10+theta*(p11+theta*p12);
-
-  Double_t p20=fP[N(2,m,0)];
-  Double_t p21=fP[N(2,m,1)];
-  Double_t p22=fP[N(2,m,2)];
-  Double_t p2=p20+theta*(p21+theta*p22);
-
-  Double_t res=TMath::Log(Ecls)*p0+p1+p2/Ecls;
-
-  return Ecls/res;
-}
-
-/** Get calorimeter respose to photon of given energy **/
-inline Double_t CbmEcalCalibrationV2::GetE2(Double_t, Double_t, Int_t) const
-{
-//  Double_t a=fP0a[celltype]+fP1a[celltype]*tantheta;
-//  Double_t b=fP0b[celltype]+fP1b[celltype]*tantheta;
-//  return e*(b+a/TMath::Sqrt(e));
-  return -1111;
-}
-
-/** Rough estimation of energy **/
-inline Double_t CbmEcalCalibrationV2::GetERough(Double_t) const
-{
-  return -1111;
-}
-#endif
diff --git a/ecal/CbmEcalCellMC.cxx b/ecal/CbmEcalCellMC.cxx
deleted file mode 100644
index 1ea701f7dc2f2097d07503a89731d35c38b0d567..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalCellMC.cxx
+++ /dev/null
@@ -1,78 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalCellMC source file                    -----
-// -----                  Created  18/01/12  by M.Prokudin             -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalCellMC.cxx
- *@author Mikhail Prokudin
- **
- ** ECAL cell structure, a part of ECAL module. This implementation carries an MC information 
- **/
-
-/* $Id: CbmEcalCellMC.cxx,v 1.6 2011/01/18 09:33:34 prokudin Exp $ */
-
-#include "CbmEcalCellMC.h"
-
-#include <algorithm>
-#include <iostream>
-
-using std::cout;
-using std::endl;
-using std::map;
-using std::list;
-
-//-----------------------------------------------------------------------------
-CbmEcalCellMC::CbmEcalCellMC(Int_t cellnumber, Float_t x1, Float_t y1, Float_t x2, Float_t y2, Char_t type, Float_t energy)
-  : CbmEcalCell(cellnumber, x1, y1, x2, y2, type, energy),
-    fTrackEnergy(),
-    fTrackTime()
-{
-}
-//-----------------------------------------------------------------------------
-Float_t CbmEcalCellMC::GetTrackTime(Int_t num) const
-{
-  map<Int_t, Float_t>::const_iterator p=fTrackTime.find(num);
-  if (p==fTrackTime.end()) return 0; else return p->second;
-}
-
-
-//-----------------------------------------------------------------------------
-Float_t CbmEcalCellMC::GetTrackEnergy(Int_t num) const
-{
-  map<Int_t, Float_t>::const_iterator p=fTrackEnergy.find(num);
-  if (p==fTrackEnergy.end()) return 0; else return p->second;
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalCellMC::ResetEnergy()
-{
-  ResetEnergyFast();
-  fTrackEnergy.clear();
-  fTrackTime.clear();
-}
-
-//-----------------------------------------------------------------------------
-Float_t CbmEcalCellMC::GetTrackClusterEnergy(Int_t num, Int_t code)
-{
-  if (code>4||code<0) return -1;
-  Float_t energy=GetTrackTotalEnergy(num);
-  list<CbmEcalCell*> cls; GetNeighborsList(code, cls);
-  list<CbmEcalCell*>::const_iterator p=cls.begin();
-  for(;p!=cls.end();++p)
-    energy+=((CbmEcalCellMC*)(*p))->GetTrackTotalEnergy(num);
-  return energy;
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalCellMC::TrackIvansProcedure(Int_t num, Float_t &clusterE, Float_t &ivansE, Float_t &shape)
-{
-  clusterE=GetTrackClusterEnergy(num,0);
-  ivansE=0;
-  Float_t en;
-  for(Int_t i=1;i<5;i++)
-    if ((en=GetTrackClusterEnergy(num,i))>ivansE) ivansE=en;
-  shape=ivansE/clusterE;
-}
-
-ClassImp(CbmEcalCellMC)
-
diff --git a/ecal/CbmEcalCellMC.h b/ecal/CbmEcalCellMC.h
deleted file mode 100644
index a59ecfd1a6e016a028e47244c9036e6a07b9f030..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalCellMC.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalCellMC header file                    -----
-// -----                  Created  18/01/12  by M.Prokudin             -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalCellMC.h
- *@author Mikhail Prokudin
- **
- ** ECAL cell structure, a part of ECAL module. This implementation carries an MC information
- **/
-
-#ifndef CBMECALCELLMC_H
-#define CBMECALCELLMC_H
-
-/* $Id: CbmEcalCellMC.h,v 1.9 2012/01/18 18:15:23 prokudin Exp $ */
-
-#include "CbmEcalCell.h"
-
-#include <list>
-#include <map>
-#include <algorithm>
-
-class CbmEcalCellMC : public CbmEcalCell
-{
-public:
-  CbmEcalCellMC(Int_t cellnumber, Float_t x1=0, Float_t y1=0, Float_t x2=0, Float_t y2=0, Char_t type=0, Float_t energy=0);
-
-  Float_t GetTrackEnergy(Int_t num) const;
-  Float_t GetTrackTime(Int_t num) const;
-  inline Float_t GetTrackTotalEnergy(Int_t num) const		//Dummy: better use GetEnergy
-  {
-    return GetTrackEnergy(num);
-  }
-	
-  /** Reset all energies in cell **/
-  void ResetEnergy();
-	
-  inline void SetTrackEnergy(Int_t num, Float_t energy, Float_t time=-1111)
-  {fTrackEnergy[num]=energy; fTrackTime[num]=time; }
-  inline void AddTrackEnergy(Int_t num, Float_t energy, Float_t time=-1111)
-  {
-    fTrackEnergy[num]+=energy;
-    if (time==-1111) return;
-    std::map<Int_t, Float_t>::const_iterator p=fTrackTime.find(num);
-    if (p==fTrackTime.end()) fTrackTime[num]=time;
-    else
-      if (fTrackTime[num]>time) fTrackTime[num]=time;
-  }
-  // same for tracks
-  Float_t GetTrackClusterEnergy(Int_t num, Int_t code);
-  void TrackIvansProcedure(Int_t num, Float_t &clusterE, Float_t &ivansE, Float_t &shape);
-
-  inline std::map<Int_t, Float_t>::const_iterator GetTrackEnergyBegin() const
-	 {return fTrackEnergy.begin();}
-  inline std::map<Int_t, Float_t>::const_iterator GetTrackEnergyEnd() const
-	 {return fTrackEnergy.end();}
-
-  inline std::map<Int_t, Float_t>::const_iterator GetTrackTimeBegin() const
-	 {return fTrackTime.begin();}
-  inline std::map<Int_t, Float_t>::const_iterator GetTrackTimeEnd() const
-	 {return fTrackTime.end();}
-
-private:
-  /**  map<TrackId, Energy in ECAL> **/
-  std::map<Int_t, Float_t> fTrackEnergy;
-
-  /** map<TrackId, Time in ECAL>**/
-  std::map<Int_t, Float_t> fTrackTime;
-
-  ClassDef(CbmEcalCellMC,1);
-};
-  
-
-#endif
diff --git a/ecal/CbmEcalClusterFinder.cxx b/ecal/CbmEcalClusterFinder.cxx
deleted file mode 100644
index 798b2e1230735ef9e2d2b4cce3f7073e700bac91..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalClusterFinder.cxx
+++ /dev/null
@@ -1,254 +0,0 @@
-#include "CbmEcalClusterFinder.h"
-
-#include "TClonesArray.h"
-
-#include "FairRootManager.h"
-#include "FairTrackParam.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalCluster.h"
-#include "CbmEcalParam.h"
-#include "CbmEcalCalibration.h"
-#include "CbmEcalPreCluster.h"
-#include "CbmEcalMaximum.h"
-
-#include <iostream>
-#include <list>
-
-using namespace std;
-
-/** Exec a task **/
-void CbmEcalClusterFinder::Exec(Option_t*)
-{
-  fEv++;
-
-  ClearPreClusters();
-  FormPreClusters();
-  FormClusters();
-}
-
-InitStatus CbmEcalClusterFinder::Init()
-{
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fInf=fStr->GetEcalInf();
-  fMaximums=(TClonesArray*)io->GetObject("EcalMaximums");
-  if (!fMaximums)
-  {
-    Fatal("Init", "Can't find array of calorimeter maximums in the system.");
-    return kFATAL;
-  }
-  fCal=(CbmEcalCalibration*)io->GetObject("EcalCalibration");
-  if (!fCal)
-  {
-    Fatal("Init", "Can't find EcalCalibration");
-    return kFATAL;
-  }
-
-  fClusters=new TClonesArray("CbmEcalCluster", 2000);
-  io->Register("EcalClusters", "ECAL", fClusters, IsOutputBranchPersistent("EcalCluster"));
-  fEv=0;
-  return kSUCCESS;
-}
-
-/** Finish a task **/
-void CbmEcalClusterFinder::Finish()
-{
-  ;
-}
-
-/** Destructor **/
-CbmEcalClusterFinder::~CbmEcalClusterFinder()
-{
-  if (fClusters)
-  {
-    fClusters->Delete();
-    delete fClusters;
-  }
-}
-
-/** Form a preclusters.
- ** A precluster --- a group of cells neighbor to maximum cell.
- ** A cluster is a group of preclusters with common cells. **/
-void CbmEcalClusterFinder::FormPreClusters()
-{
-  Int_t nm=fMaximums->GetEntriesFast();
-  Int_t i=0;
-  CbmEcalMaximum* max;
-  list<CbmEcalCell*> all;
-  list<CbmEcalCell*>::const_iterator p;
-  list<CbmEcalCell*> cls;
-  CbmEcalCell* cell;
-  CbmEcalCell* min=NULL;
-  Double_t e;
-  Double_t ecls;
-  CbmEcalPreCluster* precluster;
- 
-
-  for(;i<nm;i++)
-  {
-    max=(CbmEcalMaximum*)fMaximums->At(i);
-    if (max==NULL) continue;
-    /** Remove maximums matched with charged tracks **/
-    if (max->Mark()!=0) continue;
-    cell=max->Cell();
-    ecls=cell->GetTotalEnergy();
-//    cout << ecls << endl;
-    /** Remove low energy maximums **/
-    if (fCal->GetEnergy(ecls, cell)<fMinMaxE) continue;
-    cell->GetNeighborsList(0, all);
-    cell->GetNeighborsList(max->I(), cls);
-    e=1e10;
-    for(p=all.begin();p!=all.end();++p)
-      if ((*p)->GetTotalEnergy()<e)
-      {
-	e=(*p)->GetTotalEnergy(); min=(*p);
-      }
-    if (find(cls.begin(), cls.end(), min)==cls.end())
-      cls.push_back(min);
-    for(p=cls.begin();p!=cls.end();++p)
-      ecls+=(*p)->GetTotalEnergy();
-//    cout << ":" << ecls << endl;
-    /** Remove low energy clusters **/
-    if (fCal->GetEnergy(ecls, cell)<fMinClusterE) continue;
-    cls.push_back(cell);
-    precluster=new CbmEcalPreCluster(cls, cell, min);
-    fPreClusters.push_back(precluster);
-  }
-}
-
-/** Form clusters from precluster **/
-void CbmEcalClusterFinder::FormClusters()
-{
-  /** CbmEcalCluster needs a destructor call :-( **/
-  fClusters->Delete();
-  Int_t fN=0;
-  list<CbmEcalPreCluster*>::const_iterator p1=fPreClusters.begin();
-  list<CbmEcalPreCluster*>::const_iterator p2;
-  list<CbmEcalCell*> cluster;
-  list<CbmEcalCell*> minimums;
-  list<CbmEcalCell*>::const_iterator pc;
-  list<CbmEcalCell*>::const_iterator pc1;
-  UInt_t oldsize;
-  Int_t MaxSize=0;
-  Int_t Maximums=0;
-  Int_t max;
-  
-  if (fVerbose>9)
-  {
-    Info("FormClusters", "Total %d preclusters found.", (Int_t)fPreClusters.size());
-  }
-  for(;p1!=fPreClusters.end();++p1)
-  if ((*p1)->fMark==0)
-  {
-    cluster.clear(); oldsize=0;
-    minimums.clear();
-    cluster=(*p1)->fCells;
-    if ((*p1)->fMinimum!=NULL)
-      minimums.push_back((*p1)->fMinimum);
-    max=1;
-    while(cluster.size()!=oldsize)
-    {
-      oldsize=cluster.size();
-      p2=p1;
-      for(++p2;p2!=fPreClusters.end();++p2)
-      if ((*p2)->fMark==0)
-      {
-        pc=cluster.begin();
-	for(;pc!=cluster.end();++pc)
-	{
-	  if ((*p2)->fMinimum!=NULL&&(*pc)==(*p2)->fMinimum) continue;
-	  pc1=find((*p2)->fCells.begin(), (*p2)->fCells.end(), (*pc));
-	  if (pc1==(*p2)->fCells.end()) continue;
-	  pc1=find(minimums.begin(), minimums.end(), (*pc));
-	  if (pc1!=minimums.end()) continue;
-	  break;
-	}
-	if (pc!=cluster.end())
-	{
-	  (*p2)->fMark=1;
-	  pc=(*p2)->fCells.begin();
-	  for(;pc!=(*p2)->fCells.end();++pc)
-	    if (find(cluster.begin(), cluster.end(), (*pc))==cluster.end())
-	      cluster.push_back(*pc);
-	  if ((*p2)->fMinimum!=NULL&&find(minimums.begin(), minimums.end(), (*p2)->fMinimum)==minimums.end())
-	    minimums.push_back((*p2)->fMinimum);
-	  max++;
-	}
-      }
-    }
-    (*p1)->fMark=1;
-    if ((Int_t)cluster.size()>MaxSize)
-      MaxSize=cluster.size();
-    if (max>Maximums) Maximums=max;
-    CbmEcalCluster* cls=new ((*fClusters)[fN]) CbmEcalCluster(fN, cluster); fN++;
-    cls->Init(cluster);
-  }
-  if (fVerbose>0)
-  {
-    Info("FormClusters", "Total %d clusters formed.", fN);
-    Info("FormClusters", "Maximum size of cluster is %d cells.",  MaxSize);
-    Info("FormClusters", "Maximum number of photons per cluster is %d.",  Maximums);
-  }
-}
-
-/** Clear a preclusters list **/
-void CbmEcalClusterFinder::ClearPreClusters()
-{
-  list<CbmEcalPreCluster*>::const_iterator p=fPreClusters.begin();
-  for(;p!=fPreClusters.end();++p)
-    delete (*p);
-  fPreClusters.clear();
-}
-
-/** Standard constructor **/
-CbmEcalClusterFinder::CbmEcalClusterFinder(const char* name, const Int_t verbose, const char* cfg)
-  : FairTask(name, verbose),
-    fEv(0),
-    fMaximums(NULL),
-    fClusters(NULL),
-    fStr(NULL),
-    fInf(NULL),
-    fCal(NULL),
-    fPreClusters(),
-    fMinClusterE(0.),
-    fMinCellE(0.),
-    fMinMaxE(0.)   
-{
-  CbmEcalParam* par=new CbmEcalParam("ClusterParam", cfg);
- 
-  fMinClusterE=par->GetDouble("minclustere");
-  fMinMaxE=par->GetDouble("minmaxe");
-  delete par;
-}
-
-
-/** Only to comply with frame work. **/
-CbmEcalClusterFinder::CbmEcalClusterFinder()
-  : FairTask(),
-    fEv(0),
-    fMaximums(NULL),
-    fClusters(NULL),
-    fStr(NULL),
-    fInf(NULL),
-    fCal(NULL),
-    fPreClusters(),
-    fMinClusterE(0.),
-    fMinCellE(0.),
-    fMinMaxE(0.)   
-{
-}
-
-ClassImp(CbmEcalClusterFinder)
diff --git a/ecal/CbmEcalClusterFinder.h b/ecal/CbmEcalClusterFinder.h
deleted file mode 100644
index 90211059d7ba001cbafb8400d18152b6ed15b443..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalClusterFinder.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/** A simple and modern version of CbmEcalClusterFinder
- ** Produces a CbmEcalCluster. **/
-
-#ifndef CBMECALCLUSTERFINDER_H
-#define CBMECALCLUSTERFINDER_H
-
-#include "FairTask.h"
-#include <list>
-
-class TClonesArray;
-class CbmEcalStructure;
-class CbmEcalCell;
-class CbmEcalInf;
-class CbmEcalCalibration;
-class CbmEcalPreCluster;
-class CbmEcalMaximum;
-
-class CbmEcalClusterFinder: public FairTask
-{
-public:
-  /** Standard constructor **/
-  CbmEcalClusterFinder(const char* name, const Int_t verbose, const char* cfg);
-  /** Only to comply with frame work. **/
-  CbmEcalClusterFinder();
-
-  /** Destructor **/
-  virtual ~CbmEcalClusterFinder();
-
-  /** Finish a task **/
-  virtual void Finish();
-
-  /** Exec a task **/
-  virtual void Exec(Option_t* option);
-
-  /** Initialization **/
-  virtual InitStatus Init();
-private:
-  /** Form clusters from precluster **/
-  void FormClusters();
-  /** Form a preclusters **/
-  void FormPreClusters();
-  /** Clear a preclusters list **/
-  void ClearPreClusters();
-  /** Current event **/
-  Int_t fEv;
-
-  /** Array of maximums in calorimeter.
-   ** Maximums belong to charged tracks excluded. **/
-  TClonesArray* fMaximums;		//!
-  /** An array of clusters **/
-  TClonesArray* fClusters;		//!
-  /** A calorimeter structure **/
-  CbmEcalStructure* fStr;		//!
-  /** An information about calorimeter **/
-  CbmEcalInf* fInf;			//!
-  /** A calibration **/
-  CbmEcalCalibration* fCal;		//!
-
-  /** A list of preclusters
-   ** May be better use TClonesArray? **/
-  std::list<CbmEcalPreCluster*> fPreClusters;		//!
-
-  /** Minimum precluster energy **/
-  Double_t fMinClusterE;
-  /** Minimum cell energy **/
-  Double_t fMinCellE;
-  /** Minimum energy of precluster maximum for consideration **/
-  Double_t fMinMaxE;
-
-  CbmEcalClusterFinder(const CbmEcalClusterFinder&);
-  CbmEcalClusterFinder& operator=(const CbmEcalClusterFinder&);
-
-  ClassDef(CbmEcalClusterFinder, 1)
-};
-
-#endif
-
diff --git a/ecal/CbmEcalClusterFinderV2.cxx b/ecal/CbmEcalClusterFinderV2.cxx
deleted file mode 100644
index 5b78087c7db37d8016dd7236e79c53ce3dc7498a..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalClusterFinderV2.cxx
+++ /dev/null
@@ -1,573 +0,0 @@
-#include "CbmEcalClusterFinderV2.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalParam.h"
-#include "CbmEcalPreCluster.h"
-#include "CbmEcalCluster.h"
-#include "CbmEcalCalibration.h"
-#include "CbmEcalMaximum.h"
-
-#include "FairRootManager.h"
-#include "FairTrackParam.h"
-
-#include "TClonesArray.h"
-#include "TVector2.h"
-
-#include <iostream>
-
-using namespace std;
-
-/** Exec a task **/
-void CbmEcalClusterFinderV2::Exec(Option_t*)
-{
-  fEv++;
-
-  if (fCalibration)
-    if (!fTree)
-      CreateTree();
-  FormPreClusters();
-
-  if (fCalibration==0)
-    FormClusters();
-}
-
-/** Form a preclusters.
- ** A precluster --- a group of cells neighbor to maximum cell.
- ** A cluster is a group of preclusters with common cells. **/
-void CbmEcalClusterFinderV2::FormPreClusters()
-{
-  Int_t i;
-  Int_t n;
-  Int_t j;
-  CbmEcalCell* cell;
-  Double_t x;
-  Double_t y;
-  Double_t r;
-  Double_t a;
-  static Double_t z=fInf->GetZPos();
-  CbmEcalMaximum* max;
-
-  ClearPreClusters();
-  n=fMaximums->GetEntriesFast();
-  for(i=0;i<n;i++)
-  {
-    max=(CbmEcalMaximum*)fMaximums->At(i);
-    /** Don't need empty maximums **/
-    if (max==NULL) continue;
-    /** and maximums due to charged tracks **/
-    if (max->Mark()!=0) continue;
-    cell=max->Cell();
-    x=cell->GetCenterX();
-    y=cell->GetCenterY();
-    x*=x; y*=y;
-    x+=y; r=TMath::Sqrt(x);
-    a=TMath::ATan2(r, z)*TMath::RadToDeg();
-    for(j=0;j<fRegions;j++)
-      if (fTheta[j]>a)
-	break;
-//    cout << j << endl;
-    max->SetRegion(j);
-    if (fCalibration==0)
-    {
-      if (fPreClusterAlgo[j]==0)
-        FormPreCluster(max);
-      if (fPreClusterAlgo[j]==1)
-        FormPreClusterNew(max);
-    }
-    else
-    {
-      fAlgo=j;
-      fAlgoType=fPreClusterAlgo[j];
-      fX=cell->GetCenterX();
-      fY=cell->GetCenterY();
-      fThetaOut=a;
-      for(j=0;j<fRegions;j++)
-      {
-	fE[j]=-1111;
-	fCurAlgo=j;
-        if (fPreClusterAlgo[j]==0)
-          FormPreCluster(max);
-        if (fPreClusterAlgo[j]==1)
-          FormPreClusterNew(max);
-      }
-      fTree->Fill();
-    }
-  }
-}
-
-/** A default algorithm of precluster formation **/
-void CbmEcalClusterFinderV2::FormPreCluster(CbmEcalMaximum* max)
-{
-  CbmEcalCell* cell=max->Cell();
-  Int_t reg=GetRegion(cell);
-  if (fCalibration==1) reg=fCurAlgo;
-//  Int_t i;
-  Int_t j;
-  Double_t mine=cell->GetTotalEnergy();
-  Double_t maxe=-1111;
-//  Double_t e;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*> cs;
-  list<CbmEcalCell*>::const_iterator p;
-  CbmEcalCell* min;
-  
-  mine=cell->GetTotalEnergy(); min=cell;
-  /** Find minimum cell **/
-  cell->GetNeighborsList(0, cells);
-  for(p=cells.begin();p!=cells.end();++p)
-    if ((*p)->GetTotalEnergy()<mine)
-    {
-      mine=(*p)->GetTotalEnergy();
-      min=(*p);
-    }
-
-  /** Build a precluster **/
-  j=max->I(); maxe=0;
-  cell->GetNeighborsList(j, cells);
-  for(p=cells.begin();p!=cells.end();++p)
-    maxe+=(*p)->GetTotalEnergy();
-  maxe+=cell->GetTotalEnergy();
-  /** Check for calibration **/
-  if (fCal)
-  { if (fCal->GetEnergy(maxe+mine, cell)<fMinClusterE[reg]) return; }
-  else
-  {  if (maxe<fMinClusterE[reg]) return; }
-  cells.push_back(cell);
-  if (fUseMinimumCell==1)
-  {
-    if (find(cells.begin(), cells.end(), min)==cells.end())
-      cells.push_back(min);
-  }
-  if (fCalibration==0)
-  {
-    fPreClusters.push_back(new CbmEcalPreCluster(cells, max, min, mine+maxe)); 
-    return;
-  }
-  else
-  {
-    fE[fCurAlgo]=maxe;
-    return;
-  }
-}
-
-/** A new algorithm of precluster formation **/
-void CbmEcalClusterFinderV2::FormPreClusterNew(CbmEcalMaximum* maximum)
-{
-  CbmEcalCell* cell=maximum->Cell();
-  Int_t i;
-//  Double_t e2m;
-  Double_t e2=0;
-//  Int_t imax;
-  list<CbmEcalCell*>::const_iterator p;
-  list<CbmEcalCell*> cells;
-  Double_t x;
-  Double_t y;
-  Double_t max;
-  Int_t reg=GetRegion(cell);
-  if (fCalibration==1) reg=fCurAlgo;
-  Int_t cCl2Size=fParI[reg];
-  Int_t ix;
-  Int_t iy;
-  CbmEcalCell* cll;
-  Double_t tx;
-  Double_t ty;
-  TVector2 pv;
-  Double_t r;
-  CbmEcalCell* cls[cCl2Size];
-  Double_t rc[cCl2Size];
-  Int_t j;
-//  Double_t phi;
-//  Double_t tp;
-//  Double_t tq;
-  Double_t e;
-
-  max=cell->GetTotalEnergy();
-  x=cell->GetCenterX()*max;
-  y=cell->GetCenterY()*max;
-
-  e2=max;
-  cell->GetNeighborsList(maximum->I(), cells);
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    e2+=(*p)->GetTotalEnergy();
-    x+=(*p)->GetCenterX()*(*p)->GetTotalEnergy();
-    y+=(*p)->GetCenterY()*(*p)->GetTotalEnergy();
-  }
-  x/=e2; y/=e2;
-
-  for(i=0;i<cCl2Size;i++)
-  {
-    cls[i]=NULL;
-    rc[i]=-1111;
-  }
-  for(ix=-4;ix<5;ix++)
-  for(iy=-4;iy<5;iy++)
-  {
-    tx=cell->GetCenterX(); tx+=ix*(cell->X2()-cell->X1());
-    ty=cell->GetCenterY(); ty+=iy*(cell->Y2()-cell->Y1());
-    cll=fStr->GetCell(tx, ty);
-    if (cll==NULL) continue;
-    r=SolveEllipse(cll, x, y, reg);
-    for(i=0;i<cCl2Size;i++)
-      if (rc[i]<r)
-	break;
-    if (i==cCl2Size) continue;
-    for(j=cCl2Size-1;j>i;j--)
-    {
-      rc[j]=rc[j-1];
-      cls[j]=cls[j-1];
-    }
-    rc[i]=r;
-    cls[i]=cll;
-  }
-
-  e=0;
-  for(j=0;j<cCl2Size;j++)
-    e+=cls[j]->GetTotalEnergy();
-  if (fCal)
-  { if (fCal->GetEnergy(e, cell)<fMinClusterE[reg]) return; }
-  else
-  { if (e<fMinClusterE[reg]) return; }
-
-  if (fCalibration==0)
-  {
-    fPreClusters.push_back(new CbmEcalPreCluster(cls, cCl2Size, maximum, NULL, e)); 
-    return;
-  }
-  else
-  {
-    fE[fCurAlgo]=e;
-    return;
-  }
-}
-
-Double_t CbmEcalClusterFinderV2::SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy, Int_t reg)
-{
-  Double_t cRx=fPar2[reg];		//48*1.6
-  Double_t cRy=fPar3[reg];
-  Int_t cSt=fIntSteps;
-  TVector2 centr(cx, cy);
-  TVector2 t(centr);
-  Double_t gm=centr.Phi();
-  Double_t sgm=TMath::Sin(gm);
-  Double_t cgm=TMath::Cos(gm);
-  Double_t x;
-//  Double_t y;
-  Double_t p=sgm*sgm/cRx+cgm*cgm/cRy;
-  Double_t q=cgm*sgm*(1.0/cRx-1.0/cRy);
-  Double_t r=cgm*cgm/cRx+sgm*sgm/cRy;
-  Double_t d;
-  Double_t ex;
-//  Double_t ey;
-  Double_t y1;
-  Double_t y2;
-  Double_t inte=0;
-  Double_t step=(cell->X2()-cell->X1())/cSt;
-  Double_t fx=step/2.0+cell->X1();
-  Int_t i;
-  
-// cout << fCurAlgo << " " << reg << " " << fPar1[reg] << " " << cRx << " " << cRy << endl;
-  t/=t.Mod(); centr+=t*TMath::Sqrt(fPar1[reg]);
-  for(i=0;i<cSt;i++)
-  {
-    x=step; x*=i; x+=fx;
-    ex=x; ex-=centr.X();
-    d=q*q*ex*ex-p*(r*ex*ex-1);
-    if (d<0) continue;
-    d=TMath::Sqrt(d);
-    y1=-q*ex/p; y2=y1;
-    y1-=d/p; y2+=d/p;
-    y1+=centr.Y(); y2+=centr.Y();
-    if (y1>cell->Y2()) continue;
-    if (y2<cell->Y1()) continue;
-    if (y1<cell->Y1()) y1=cell->Y1();
-    if (y2>cell->Y2()) y2=cell->Y2();
-    inte+=(y2-y1)*step;
-  }
-
-  return inte;
-}
-
-/** Form clusters from precluster **/
-void CbmEcalClusterFinderV2::FormClusters()
-{
-  /** CbmEcalCluster needs a destructor call :-( **/
-  fClusters->Delete();
-  Int_t fN=0;
-  list<CbmEcalPreCluster*>::const_iterator p1=fPreClusters.begin();
-  list<CbmEcalPreCluster*>::const_iterator p2;
-  list<CbmEcalCell*> cluster;
-  list<CbmEcalCell*>::const_iterator pc;
-  list<CbmEcalCell*>::const_iterator pc1;
-  list<CbmEcalMaximum*> maximums;
-  list<Double_t> energy;
-  UInt_t oldsize;
-  Int_t MaxSize=0;
-  Int_t Maximums=0;
-  Int_t max;
-  
-  for(;p1!=fPreClusters.end();++p1)
-  if ((*p1)->fMark==0)
-  {
-    cluster.clear(); oldsize=0; maximums.clear(); energy.clear();
-    cluster=(*p1)->fCells;
-    maximums.push_back((*p1)->fMax);
-    energy.push_back((*p1)->fEnergy);
-    max=1;
-    while(cluster.size()!=oldsize)
-    {
-      oldsize=cluster.size();
-      p2=p1;
-      for(++p2;p2!=fPreClusters.end();++p2)
-      if ((*p2)->fMark==0)
-      {
-        pc=cluster.begin();
-	for(;pc!=cluster.end();++pc)
-	{
-	  if ((*p2)->fMinimum!=NULL) continue;
-	  pc1=find((*p2)->fCells.begin(), (*p2)->fCells.end(), (*pc));
-	  if (pc1==(*p2)->fCells.end()) continue;
-	  break;
-	}
-	if (pc!=cluster.end())
-	{
-	  (*p2)->fMark=1;
-	  pc=(*p2)->fCells.begin();
-	  for(;pc!=(*p2)->fCells.end();++pc)
-	    if (find(cluster.begin(), cluster.end(), (*pc))==cluster.end())
-	      cluster.push_back(*pc);
-	  maximums.push_back((*p2)->fMax);
-	  energy.push_back((*p2)->fEnergy);
-	  max++;
-	}
-      }
-    }
-    (*p1)->fMark=1;
-    if ((Int_t)cluster.size()>MaxSize)
-      MaxSize=cluster.size();
-    if (max>Maximums) Maximums=max;
-    new ((*fClusters)[fN]) CbmEcalCluster(fN, cluster, maximums, energy); fN++;
-//    CbmEcalCluster* cls=new ((*fClusters)[fN]) CbmEcalCluster(fN, cluster, maximums, energy); fN++;
- //   cls->Init(cluster);
-  }
-  if (fVerbose>0)
-  {
-    Info("FormClusters", "Total %d clusters formed.", fN);
-    Info("FormClusters", "Maximum size of cluster is %d cells.",  MaxSize);
-    Info("FormClusters", "Maximum number of photons per cluster is %d.",  Maximums);
-  }
-}
-
-/** Get region number of the cell **/
-Int_t CbmEcalClusterFinderV2::GetRegion(CbmEcalCell* cls)
-{
-  Double_t x=cls->GetCenterX(); x*=x;
-  Double_t y=cls->GetCenterY(); y*=y;
-  x+=y;
-  Double_t r=TMath::Sqrt(x);
-  static Double_t z=fInf->GetZPos();
-  Double_t a=TMath::ATan2(r, z)*TMath::RadToDeg();
-  Int_t i=0;
-  for(;i<fRegions;i++)
-    if (fTheta[i]>a)
-      break;
-
-  return i;
-}
-
-/** Initialization **/
-InitStatus CbmEcalClusterFinderV2::Init()
-{
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fInf=fStr->GetEcalInf();
-  if (fUseCalibration==1)
-  {
-    fCal=(CbmEcalCalibration*)io->GetObject("EcalCalibration");
-    if (!fCal)
-    {
-      Fatal("Init", "Can't find EcalCalibration");
-      return kFATAL;
-    }
-  }
-  else
-    fCal=NULL;
-  fMaximums=(TClonesArray*)io->GetObject("EcalMaximums");
-  if (fMaximums==NULL)
-  {
-    Fatal("Init", "Cant' find array of calorimeter maximums in the system");
-    return kFATAL;
-  }
-
-  fClusters=new TClonesArray("CbmEcalCluster", 2000);
-  io->Register("EcalClusters", "ECAL", fClusters, IsOutputBranchPersistent("EcalCluster"));
-  fEv=0;
-  return kSUCCESS;
-}
-
-/** Destructor **/
-CbmEcalClusterFinderV2::~CbmEcalClusterFinderV2()
-{
-  if (fClusters)
-  {
-    fClusters->Delete();
-    delete fClusters;
-  }
-  if (fTree)
-    delete fTree;
-}
-
-/** Only to comply with frame work. **/
-CbmEcalClusterFinderV2::CbmEcalClusterFinderV2()
-  : FairTask(),
-    fEv(0),
-    fStr(NULL),
-    fInf(NULL),
-    fCal(NULL),
-    fTracks(NULL),
-    fMaximums(NULL),
-    fClusters(NULL),
-    fPreClusters(),
-    fRemoveCharged(0),
-    fUseCalibration(0),
-    fRegions(0),
-    fPreClusterAlgo(),
-    fMinClusterE(),
-    fMinMaxE(),
-    fTheta(),
-    fCalibration(0),
-    fUseMinimumCell(0),
-    fPar1(),
-    fPar2(),
-    fPar3(),
-    fParI(),
-    fIntSteps(0),
-    fTree(NULL),
-    fE(),
-    fAlgo(0),
-    fAlgoType(0),
-    fCurAlgo(0),
-    fX(0.),
-    fY(0.),
-    fThetaOut(0.)
-{
-}
-
-/** Finish a task **/
-void CbmEcalClusterFinderV2::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-CbmEcalClusterFinderV2::CbmEcalClusterFinderV2(const char* name, const Int_t verbose, const char* cfg)
-  : FairTask(name, verbose),
-    fEv(0),
-    fStr(NULL),
-    fInf(NULL),
-    fCal(NULL),
-    fTracks(NULL),
-    fMaximums(NULL),
-    fClusters(NULL),
-    fPreClusters(),
-    fRemoveCharged(0),
-    fUseCalibration(0),
-    fRegions(0),
-    fPreClusterAlgo(),
-    fMinClusterE(),
-    fMinMaxE(),
-    fTheta(),
-    fCalibration(0),
-    fUseMinimumCell(0),
-    fPar1(),
-    fPar2(),
-    fPar3(),
-    fParI(),
-    fIntSteps(0),
-    fTree(NULL),
-    fE(),
-    fAlgo(0),
-    fAlgoType(0),
-    fCurAlgo(0),
-    fX(0.),
-    fY(0.),
-    fThetaOut(0.)
-{
-  Int_t i;
-  TString st;
-  CbmEcalParam* par=new CbmEcalParam("ClusterParam", cfg);
-
-  fUseCalibration=par->GetInteger("usecalibration");
-  fRegions=par->GetInteger("regions");
-  if (fRegions<0||fRegions>10)
-  {
-    Fatal("CbmEcalClusterFinderV2","Number of calorimeter regions to high.");
-    delete par;
-    return;
-  }
-  fCalibration=par->GetInteger("calibrationmode");
-  fUseMinimumCell=par->GetInteger("useminimumcell");
-
-  fIntSteps=par->GetInteger("intsteps");
-  for(i=0;i<fRegions;i++)
-  {
-    st="preclusteralgo["; st+=i; st+="]";
-    fPreClusterAlgo[i]=par->GetInteger(st);
-    st="minclustere["; st+=i; st+="]";
-    fMinClusterE[i]=par->GetDouble(st);
-    st="minmaxe["; st+=i; st+="]";
-    fMinMaxE[i]=par->GetDouble(st);
-    st="theta["; st+=i; st+="]";
-    fTheta[i]=par->GetDouble(st);
-    st="par1["; st+=i; st+="]";
-    fPar1[i]=par->GetDouble(st);
-    st="par2["; st+=i; st+="]";
-    fPar2[i]=par->GetDouble(st);
-    st="par3["; st+=i; st+="]";
-    fPar3[i]=par->GetDouble(st);
-    st="pari["; st+=i; st+="]";
-    fParI[i]=par->GetInteger(st);
-  }
-  delete par;
-  fTree=NULL;
-}
-
-
-/** Clear a preclusters list **/
-void CbmEcalClusterFinderV2::ClearPreClusters()
-{
-  list<CbmEcalPreCluster*>::const_iterator p=fPreClusters.begin();
-  for(;p!=fPreClusters.end();++p)
-    delete (*p);
-  fPreClusters.clear();
-}
-
-
-void CbmEcalClusterFinderV2::CreateTree()
-{
-  TString st;
-
-  fTree=new TTree("c2","Preclusters information");
-  fTree->Branch("ev", &fEv, "ev/I");
-  fTree->Branch("algo", &fAlgo, "algo/I");
-  fTree->Branch("algot", &fAlgoType, "algot/I");
-  fTree->Branch("x", &fX, "x/D");
-  fTree->Branch("y", &fY, "y/D");
-  fTree->Branch("theta", &fThetaOut, "theta/D");
-  st="e["; st+=fRegions; st+="]/D";
-  fTree->Branch("e", fE, st);
-}
-
-ClassImp(CbmEcalClusterFinderV2)
diff --git a/ecal/CbmEcalClusterFinderV2.h b/ecal/CbmEcalClusterFinderV2.h
deleted file mode 100644
index 5ebd98b88cde183ccb19c1a51114ec2fa9a84155..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalClusterFinderV2.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/** Cluster finder for calorimeter into muon option
- ** Produces a CbmEcalClusterV1. **/
-
-#ifndef CBMECALCLUSTERFINDERV2_H
-#define CBMECALCLUSTERFINDERV2_H
-
-#include "FairTask.h"
-
-#include <list>
-
-class TClonesArray;
-class CbmEcalStructure;
-class CbmEcalCell;
-class CbmEcalInf;
-class CbmEcalCalibration;
-class CbmEcalPreCluster;
-class CbmEcalMaximum;
-class TTree;
-
-class CbmEcalClusterFinderV2 : public FairTask
-{
-public:
-  /** Standard constructor **/
-  CbmEcalClusterFinderV2(const char* name, const Int_t verbose, const char* cfg);
-  /** Only to comply with frame work. **/
-  CbmEcalClusterFinderV2();
-
-  /** Destructor **/
-  virtual ~CbmEcalClusterFinderV2();
-
-  /** Finish a task **/
-  virtual void Finish();
-
-  /** Exec a task **/
-  virtual void Exec(Option_t* option);
-
-  /** Initialization **/
-  virtual InitStatus Init();
-private:
-  /** Create an output tree **/
-  void CreateTree();
-  /** Get region number of the cell **/
-  Int_t GetRegion(CbmEcalCell* cls);
-  /** Build preclusters **/
-  void FormPreClusters();
-  /** A default algorithm of precluster formation **/
-  void FormPreCluster(CbmEcalMaximum* cell);
-  /** A new algorithm of precluster formation **/
-  void FormPreClusterNew(CbmEcalMaximum* cell);
-  /** Find a common area of ellipse and cell**/
-  Double_t SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy, Int_t reg);
-
-  /** Build clusters from preclusters **/
-  void FormClusters();
-  /** Clear a preclusters list **/
-  void ClearPreClusters();
-
-  /** Current event **/
-  Int_t fEv;
-
-  /** A calorimeter structure **/
-  CbmEcalStructure* fStr;		//!
-  /** An information about calorimeter **/
-  CbmEcalInf* fInf;			//!
-  /** A calibration **/
-  CbmEcalCalibration* fCal;		//!
-  /** Tracks before the calorimeter **/
-  TClonesArray* fTracks;		//!
-  /** Array of maximums in calorimeter.
-   ** Maximums belong to charged tracks excluded. **/
-  TClonesArray* fMaximums;		//!
-  /** An array of clusters **/
-  TClonesArray* fClusters;		//!
-
-  /** A list of preclusters
-   ** May be better use TClonesArray? **/
-  std::list<CbmEcalPreCluster*> fPreClusters;		//!
-
-  /** Maximums atrributed to charged tracks should be removed? **/
-  Int_t fRemoveCharged;
-  /** Should we use calibration?
-   ** If no, than a cluster finder will be used for calibration **/
-  Int_t fUseCalibration;
-  /** Number of calorimeter regions **/
-  Int_t fRegions;
-  /** An algorithm for preclustering
-   ** 0 --- default
-   ** 1 --- new algorithm with ellipses **/
-  Int_t fPreClusterAlgo[10];
-  /** Minimum energy of precluster **/
-  Double_t fMinClusterE[10];
-  /** Minimum energy of precluster maximum for consideration **/
-  Double_t fMinMaxE[10];
-  /** Maximum theta angle for cluster algorithm **/
-  Double_t fTheta[10];
-  /** Just form preclusters and store information in tree **/
-  Int_t fCalibration;
-  /** Should we add a minimum cell to precluster? **/
-  Int_t fUseMinimumCell;
-  /** Parameters for cluster construction **/
-  Double_t fPar1[10];
-  Double_t fPar2[10];
-  Double_t fPar3[10];
-  Int_t fParI[10];
-  Int_t fIntSteps;
-  
-
-  TTree* fTree;				//!
-  Double_t fE[10];			//!
-  Int_t fAlgo;
-  Int_t fAlgoType;
-  Int_t fCurAlgo;
-  Double_t fX;
-  Double_t fY;
-  Double_t fThetaOut;
-
-  CbmEcalClusterFinderV2(const CbmEcalClusterFinderV2&);
-  CbmEcalClusterFinderV2& operator=(const CbmEcalClusterFinderV2&);
-
-  ClassDef(CbmEcalClusterFinderV2, 1)
-};
-
-#endif
-
diff --git a/ecal/CbmEcalContFact.cxx b/ecal/CbmEcalContFact.cxx
deleted file mode 100644
index 7c7afe33516465ed25d0c0087db94d4f4801d73b..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalContFact.cxx
+++ /dev/null
@@ -1,63 +0,0 @@
-//*-- AUTHOR : Denis Bertini
-//*-- Created : 20/06/2005
-
-/////////////////////////////////////////////////////////////
-//
-//  CbmEcalContFact
-//
-//  Factory for the parameter containers in libEcal
-//
-/////////////////////////////////////////////////////////////
-#include "CbmEcalContFact.h"
-
-#include "CbmGeoEcalPar.h"
-
-#include "FairRuntimeDb.h"
-#include "FairParRootFileIo.h"
-#include "FairParAsciiFileIo.h"
-
-#include <iostream>
-#include <iomanip>
-
-ClassImp(CbmEcalContFact)
-
-static CbmEcalContFact gCbmEcalContFact;
-
-CbmEcalContFact::CbmEcalContFact() {
-  // Constructor (called when the library is loaded)
-  fName="CbmEcalContFact";
-  fTitle="Factory for parameter containers in libEcal";
-  setAllContainers();
-  FairRuntimeDb::instance()->addContFactory(this);
-}
-
-void CbmEcalContFact::setAllContainers() {
-  /** Creates the Container objects with all accepted contexts and adds them to
-   *  the list of containers for the STS library.*/
-
-    FairContainer* p2= new FairContainer("CbmGeoEcalPar",
-                                          "Ecal Geometry Parameters",
-                                          "TestDefaultContext");
-    p2->addContext("TestNonDefaultContext");
-
-    containers->Add(p2);
-}
-
-FairParSet* CbmEcalContFact::createContainer(FairContainer* c) {
-  /** Calls the constructor of the corresponding parameter container.
-   * For an actual context, which is not an empty string and not the default context
-   * of this container, the name is concatinated with the context. */
-  const char* name=c->GetName();
-  FairParSet* p=0;
-  if (strcmp(name,"CbmGeoEcalPar")==0) {
-    p=new CbmGeoEcalPar(c->getConcatName().Data(),c->GetTitle(),c->getContext());
-  }
-  return p;
-}
-
-void  CbmEcalContFact::activateParIo(FairParIo*) {
-  // activates the input/output class for the parameters
-  // needed by the Ecal
-return;
-}
-
diff --git a/ecal/CbmEcalContFact.h b/ecal/CbmEcalContFact.h
deleted file mode 100644
index 04977218a5665e9ea34b3df4c39908b3c817414a..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalContFact.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef CBMECALCONTFACT_H
-#define CBMECALCONTFACT_H
-
-#include "FairContFact.h"
-
-class FairContainer;
-
-class CbmEcalContFact : public FairContFact {
-private:
-  void setAllContainers();
-public:
-  CbmEcalContFact();
-  ~CbmEcalContFact() {}
-  FairParSet* createContainer(FairContainer*);
-  void  activateParIo(FairParIo* io);
-  ClassDef( CbmEcalContFact,0) // Factory for all ECAL parameter containers
-};
-
-#endif  /* !CBMECALCONTFACT_H */
diff --git a/ecal/CbmEcalDetailed.cxx b/ecal/CbmEcalDetailed.cxx
deleted file mode 100644
index 6c5b66249c0d806189787d4807cf068a42dc3260..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalDetailed.cxx
+++ /dev/null
@@ -1,1290 +0,0 @@
-/**  CbmEcalDetailed.cxx
- *@author Mikhail Prokudin
- **
- ** Defines the active detector ECAL with geometry coded here.
- ** Layers, holes, fibers,steel tapes implemented 
- **/
-
-#include "CbmEcalDetailed.h"
-
-#include "CbmEcalPoint.h"
-#include "CbmGeoEcalPar.h"
-#include "CbmEcalLightMap.h"
-
-#include "FairGeoInterface.h"
-#include "FairGeoLoader.h"
-#include "FairGeoNode.h"
-#include "FairGeoRootBuilder.h"
-#include "FairRuntimeDb.h"
-#include "FairRootManager.h"
-#include "FairRun.h"
-#include "FairRunAna.h"
-#include "CbmMCTrack.h"
-#include "CbmStack.h"
-#include "FairVolume.h"
-#include "FairGeoMedium.h"
-#include "FairGeoMedia.h"
-
-#include "TClonesArray.h"
-#include "TGeoMCGeometry.h"
-#include "TGeoManager.h"
-#include "TParticle.h"
-#include "TVirtualMC.h"
-#include "TGeoBBox.h"
-#include "TGeoPgon.h"
-#include "TGeoTube.h"
-#include "TGeoMatrix.h"
-#include "TGeoCompositeShape.h"
-#include "TList.h"
-
-#include <iostream>
-#include <stdlib.h>
-
-using namespace std;
-
-#define kN kNumberOfECALSensitiveVolumes
-
-// -----   Default constructor   -------------------------------------------
-CbmEcalDetailed::CbmEcalDetailed() 
-  : FairDetector("ECAL", kTRUE, kEcal),
-    fInf(NULL),
-    fDebug(NULL),
-    fTrackID(-1),
-    fVolumeID(-1),
-    fPos(),
-    fMom(),
-    fTime(-1.),
-    fLength(-1.),
-    fELoss(-1.),
-    fPosIndex(0),
-    fEcalCollection(new TClonesArray("CbmEcalPoint")),
-    fLiteCollection(new TClonesArray("CbmEcalPointLite")),
-    fEcalSize(),
-    fSimpleGeo(0),
-    fXSize(0),
-    fYSize(0),
-    fDX(0.),
-    fDY(0.),
-    fCellSize(0.),
-    fModuleSize(0.),
-    fZEcal(0.),
-    fThicknessLead(0.),
-    fThicknessScin(0.),
-    fThicknessTyvk(0.),
-    fThicknessLayer(0.),
-    fThicknessSteel(0.),
-    fEdging(0.),
-    fHoleRad(0.),
-    fFiberRad(0.),
-    fXCell(),
-    fYCell(),
-    fNH(),
-    fCF(),
-    fLightMapNames(),
-    fLightMaps(),
-    fNLayers(0),
-    fModuleLenght(0.),
-    fGeoScale(0.),
-    fNColumns1(0),
-    fNRows1(0),
-    fNColumns2(0),
-    fNRows2(0),
-    fThicknessPSlead(0.),
-    fThicknessPSscin(0.),
-    fEcalPSgap(0.),
-    fNColumns(0),
-    fNRows(0),
-    fVolIdMax(0),
-    fFirstNumber(0),
-    fVolArr(),
-    fModules(),
-    fCells(),
-    fScTiles(),
-    fTileEdging(),
-    fPbTiles(),
-    fTvTiles(),
-    fHoleVol(),
-    fFiberVol(),
-    fSteelTapes(),
-    fHolePos(),
-    fModulesWithType(),
-    fRawNumber(),
-    fStructureId()
-{
-  fVerboseLevel = 1;
-
-  Int_t i;
-
-  for(i=kN-1;i>-1;i--)
-    fVolArr[i]=-1111;
-}
-// -------------------------------------------------------------------------
-
-
-
-// -----   Standard constructor   ------------------------------------------
-CbmEcalDetailed::CbmEcalDetailed(const char* name, Bool_t active, const char* fileGeo)
-  : FairDetector(name, active, kEcal),
-    fInf(NULL),
-    fDebug(NULL),
-    fTrackID(-1),
-    fVolumeID(-1),
-    fPos(),
-    fMom(),
-    fTime(-1.),
-    fLength(-1.),
-    fELoss(-1.),
-    fPosIndex(0),
-    fEcalCollection(new TClonesArray("CbmEcalPoint")),
-    fLiteCollection(new TClonesArray("CbmEcalPointLite")),
-    fEcalSize(),
-    fSimpleGeo(0),
-    fXSize(0),
-    fYSize(0),
-    fDX(0.),
-    fDY(0.),
-    fCellSize(0.),
-    fModuleSize(0.),
-    fZEcal(0.),
-    fThicknessLead(0.),
-    fThicknessScin(0.),
-    fThicknessTyvk(0.),
-    fThicknessLayer(0.),
-    fThicknessSteel(0.),
-    fEdging(0.),
-    fHoleRad(0.),
-    fFiberRad(0.),
-    fXCell(),
-    fYCell(),
-    fNH(),
-    fCF(),
-    fLightMapNames(),
-    fLightMaps(),
-    fNLayers(0),
-    fModuleLenght(0.),
-    fGeoScale(0.),
-    fNColumns1(0),
-    fNRows1(0),
-    fNColumns2(0),
-    fNRows2(0),
-    fThicknessPSlead(0.),
-    fThicknessPSscin(0.),
-    fEcalPSgap(0.),
-    fNColumns(0),
-    fNRows(0),
-    fVolIdMax(0),
-    fFirstNumber(0),
-    fVolArr(),
-    fModules(),
-    fCells(),
-    fScTiles(),
-    fTileEdging(),
-    fPbTiles(),
-    fTvTiles(),
-    fHoleVol(),
-    fFiberVol(),
-    fSteelTapes(),
-    fHolePos(),
-    fModulesWithType(),
-    fRawNumber(),
-    fStructureId()
-{
-  /** CbmEcalDetailed constructor:
-   ** reads geometry parameters from the ascii file <fileGeo>,
-   ** creates the ECAL geometry container CbmEcalInf
-   ** and initializes basic geometry parameters needed to construct
-   ** TGeo geometry
-   **/
-
-  fVerboseLevel=1;
-  Int_t i;
-  Int_t j;
-  TString nm;
-  Info("CbmEcalDetailed","Geometry is read from file %s.", fileGeo);
-  fInf=CbmEcalInf::GetInstance(fileGeo);
-  if (fInf==NULL)
-  {
-    Fatal("CbmEcalDetailed"," Can't read geometry from %s.", fileGeo);
-    return;
-  }
-  fGeoScale=1.;
-  fEcalSize[0]=fInf->GetEcalSize(0);
-  fEcalSize[1]=fInf->GetEcalSize(1);
-  fEcalSize[2]=fInf->GetEcalSize(2);
-
-  fCellSize=fInf->GetCellSize();
-  fZEcal=fInf->GetZPos();
-
-  fThicknessLead=fInf->GetLead();
-  fThicknessScin=fInf->GetScin();
-  fThicknessTyvk=fInf->GetTyveec();
-  fNLayers=fInf->GetNLayers();
-
-  fThicknessPSlead=fInf->GetPSLead();
-  fThicknessPSscin=fInf->GetPSScin();
-  fEcalPSgap=fInf->GetPSGap();
-
-  fXSize=fInf->GetXSize();
-  fYSize=fInf->GetYSize();
-  
-  fPosIndex=0;
-  fDebug="";
-
-  fHoleRad=fInf->GetVariableStrict("holeradius");
-  fFiberRad=fInf->GetVariableStrict("fiberradius");
-  fThicknessSteel=fInf->GetVariableStrict("steel");
-  fEdging=fInf->GetVariableStrict("tileedging");
-  fModuleSize=fInf->GetVariableStrict("modulesize");
-  fSimpleGeo=(Int_t)fInf->GetVariableStrict("usesimplegeo");
-  fDX=fInf->GetVariableStrict("xpos");
-  fDY=fInf->GetVariableStrict("ypos");
-
-  fInf->AddVariable("ecalversion", "1"); 
-  for(i=kN-1;i>-1;i--)
-    fVolArr[i]=-1111;
-
-
-  for(i=0;i<cMaxModuleType;i++)
-  {
-    fModules[i]=NULL;
-    fCells[i]=NULL;
-    fScTiles[i]=NULL;
-    fPbTiles[i]=NULL;
-    fTvTiles[i]=NULL;
-    fHolePos[i]=NULL;
-    fTileEdging[i]=NULL;
-    fModulesWithType[i]=0;
-    fLightMapNames[i]="";
-    fLightMaps[i]=NULL;
-  }
-  for(i=0;i<2;i++)
-  {
-    fSteelTapes[i]=NULL;
-  }
-  for(i=0;i<3;i++)
-  {
-    fHoleVol[i]=NULL;
-    fFiberVol[i]=NULL;
-  }
-  /** Counting modules **/
-  for(i=0;i<fInf->GetXSize();i++)
-  for(j=0;j<fInf->GetYSize();j++)
-    fModulesWithType[(Int_t)fInf->GetType(i,j)]++;
-
-  for(i=1;i<cMaxModuleType;i++)
-  {
-    if (fModulesWithType[i]==0) continue;
-    nm="cf["; nm+=i; nm+="]";
-    fCF[i]=(Int_t)fInf->GetVariableStrict(nm);
-    nm="nh[";nm+=i; nm+="]";
-    fNH[i]=(Int_t)fInf->GetVariableStrict(nm);
-    nm="lightmap["; nm+=i; nm+="]";
-    fLightMapNames[i]=fInf->GetStringVariable(nm);
-    fLightMaps[i]=new CbmEcalLightMap(fLightMapNames[i],nm);
-    Info("CbmEcalDetailed", "Number of modules of type %d is %d (%d channels), lightmap %s", i, fModulesWithType[i], fModulesWithType[i]*i*i, fLightMapNames[i].Data());
-    fXCell[i]=(fModuleSize-2.0*fThicknessSteel)/i-2.0*fEdging;
-    fYCell[i]=(fModuleSize-2.0*fThicknessSteel)/i-2.0*fEdging;
-    Info("CbmEcalDetailed", "Size of cell of type %d is %f cm.", i, fXCell[i]);
-  }
-}
-
-// -------------------------------------------------------------------------
-
-void CbmEcalDetailed::Initialize()
-{
-  FairDetector::Initialize();
-  FairRun* sim = FairRun::Instance();
-  FairRuntimeDb* rtdb=sim->GetRuntimeDb();
-  CbmGeoEcalPar *par=new CbmGeoEcalPar();
-//  fInf->FillGeoPar(par,0);
-  rtdb->addContainer(par);
-}
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcalDetailed::~CbmEcalDetailed()
-{
-  if (fEcalCollection) {
-    fEcalCollection->Delete(); 
-    delete fEcalCollection;
-    fEcalCollection=NULL;
-  }
-  if (fLiteCollection) {
-    fLiteCollection->Delete();
-    delete fLiteCollection;
-    fLiteCollection=NULL;
-  }
-}
-// -------------------------------------------------------------------------
-
-// -----   Private method SetEcalCuts   ------------------------------------
-void CbmEcalDetailed::SetEcalCuts(Int_t medium)
-{
-  /** Set GEANT3 tracking energy cuts for selected medium **/
-  if (fInf->GetElectronCut() > 0) {
-    gMC->Gstpar(medium,"CUTGAM",fInf->GetElectronCut());
-    gMC->Gstpar(medium,"CUTELE",fInf->GetElectronCut());
-    gMC->Gstpar(medium,"BCUTE" ,fInf->GetElectronCut());
-    gMC->Gstpar(medium,"BCUTM" ,fInf->GetElectronCut());
-  }
-
-  if (fInf->GetHadronCut() > 0) {
-    gMC->Gstpar(medium,"CUTNEU",fInf->GetHadronCut());
-    gMC->Gstpar(medium,"CUTHAD",fInf->GetHadronCut());
-    gMC->Gstpar(medium,"CUTMUO",fInf->GetHadronCut());
-    gMC->Gstpar(medium,"PPCUTM",fInf->GetHadronCut());
-  }
-  ;
-}
-// -------------------------------------------------------------------------
-
-void CbmEcalDetailed::FinishPrimary()
-{
-  fFirstNumber=fLiteCollection->GetEntriesFast();
-}
-
-//_____________________________________________________________________________
-void CbmEcalDetailed::ChangeHit(CbmEcalPointLite* oldHit)
-{
-  Double_t edep = fELoss;
-  Double_t el=oldHit->GetEnergyLoss();
-  Double_t ttime=gMC->TrackTime()*1.0e9;
-  oldHit->SetEnergyLoss(el+edep);
-  if(ttime<oldHit->GetTime())
-    oldHit->SetTime(ttime);
-}
-
-//_____________________________________________________________________________
-void CbmEcalDetailed::SetSpecialPhysicsCuts()
-{
-  /** Change the special tracking cuts for
-   ** two ECAL media, Scintillator and Lead
-   **/
-  FairRun* fRun = FairRun::Instance();
-  if (strcmp(fRun->GetName(),"TGeant3") == 0) {
-    Int_t mediumID;
-    mediumID = gGeoManager->GetMedium("Scintillator")->GetId();
-    SetEcalCuts(mediumID);
-    mediumID = gGeoManager->GetMedium("Lead")->GetId();
-    SetEcalCuts(mediumID);
-    mediumID = gGeoManager->GetMedium("Tyvek")->GetId();
-    SetEcalCuts(mediumID);
-    mediumID = gGeoManager->GetMedium("SensVacuum")->GetId();
-    SetEcalCuts(mediumID);
-    mediumID = gGeoManager->GetMedium("ECALAir")->GetId();
-    SetEcalCuts(mediumID);
-    mediumID = gGeoManager->GetMedium("ECALFiber")->GetId();
-    SetEcalCuts(mediumID);
-    mediumID = gGeoManager->GetMedium("ECALTileEdging")->GetId();
-    SetEcalCuts(mediumID);
-    mediumID = gGeoManager->GetMedium("ECALSteel")->GetId();
-    SetEcalCuts(mediumID);
-  }
-}
-
-// -----   Public method ProcessHits  --------------------------------------
-Bool_t  CbmEcalDetailed::ProcessHits(FairVolume* vol)
-{
-  /** Fill MC point for sensitive ECAL volumes **/
-  fELoss   = gMC->Edep();
-  fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
-  fTime    = gMC->TrackTime()*1.0e09;
-  fLength  = gMC->TrackLength();
-
-  if (vol->getVolumeId()==fStructureId)
-  {
-    if (gMC->IsTrackEntering())
-    {
-      FillWallPoint();
-      ((CbmStack*)gMC->GetStack())->AddPoint(kEcal, fTrackID);
-  
-      ResetParameters();
-
-      return kTRUE;
-    }
-    else
-      return kFALSE;
-  }
-  if (fELoss<=0) return kFALSE;
-
-  if (fELoss>0)
-  {
-//    Int_t i;
-//    TParticle* p=gMC->GetStack()->GetCurrentTrack();
-    Double_t x, y, z;
-    Double_t px;
-    Double_t py;
-//    Double_t dx;
-    Int_t mx;
-    Int_t my;
-    Int_t cell;
-    Int_t type;
-    Int_t cx;
-    Int_t cy;
-    gMC->TrackPosition(x, y, z);
-//    cout << "Id: " << p->GetPdgCode() << " (" << x << ", " << y << ", ";
-//    cout << z << "): ";
-//    cout << endl;
-/*
-    for(i=0;i<10;i++)
-    {
-      gMC->CurrentVolOffID(i, mx); cout << i << ":" << mx << ", ";
-    }
-    cout << endl;
-*/
-    if (fSimpleGeo==0)
-    {
-      gMC->CurrentVolOffID(3, mx); mx--;
-      gMC->CurrentVolOffID(4, my); my--;
-      gMC->CurrentVolOffID(2, cell); cell--;
-    }
-    else
-    {
-      gMC->CurrentVolOffID(2, mx); mx--;
-      gMC->CurrentVolOffID(3, my); my--;
-      gMC->CurrentVolOffID(1, cell); cell--;
-    }
-    Int_t id=(my*100+mx)*100+cell+1;
-/*   
-    Float_t rx; Float_t ry; Int_t ten;
-    GetCellCoordInf(id, rx, ry, ten); rx--; ry--;
-    type=fInf->GetType(mx, my);
-    Float_t d=fInf->GetVariableStrict("modulesize")/type;
-    if (x>rx-0.001&&x<rx+d+0.001&&y>ry-0.001&&y<ry+d+0.001) 
-    {
-//      cout << "+++ ";
-      ;
-    }
-    else
-    {
-      cout << mx << ", " << my << ", " << cell << endl;
-      cout << "--- ";
-      cout << "(" << x << ", " << y << ") : (" << rx << ", " << ry << ")" << endl; 
-    }
-*/
-    fVolumeID=id;
-    if (fSimpleGeo==0)
-    {
-      type=fInf->GetType(mx, my);
-      cx=cell%type;
-      cy=cell/type;
-      // An old version
-      // px=mx*fModuleSize-fEcalSize[0]/2.0+cx*fModuleSize/type;
-      // py=my*fModuleSize-fEcalSize[1]/2.0+cy*fModuleSize/type;
-      // With correction for steel tapes and edging
-      px=mx*fModuleSize-fEcalSize[0]/2.0+fXCell[type]*cx+(2*cx+1)*fEdging+fThicknessSteel;
-      py=my*fModuleSize-fEcalSize[1]/2.0+fYCell[type]*cy+(2*cy+1)*fEdging+fThicknessSteel;
-
-      px=(x-px)/fXCell[type];
-      py=(y-py)/fYCell[type];
-      if (px>=0&&px<1&&py>=0&&py<1)
-      {
-        fELoss*=fLightMaps[type]->Data(px-0.5, py-0.5);
-        FillLitePoint(0);
-      }
-    }
-    else
-      FillLitePoint(0);
-//    for(i=0;i<8;i++)
-//    {
-//      Int_t t;
-//      
-//      gMC->CurrentVolOffID(i, t);
-//      cout << i << ": " << gMC->CurrentVolOffName(i) << " " << t << "; ";
-//   }
-//    cout << endl;
-  }
-  ((CbmStack*)gMC->GetStack())->AddPoint(kEcal, fTrackID);
-  
-  ResetParameters();
-
-  return kTRUE;
-
-}
-
-/** returns type of volume **/
-Int_t CbmEcalDetailed::GetVolType(Int_t volnum)
-{
-	Int_t i;
-	for(i=kN-1;i>-1;i--) {
-	  if (fVolArr[i]==volnum) break;
-	}
-        
-	return i;
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalDetailed::FillWallPoint()
-{
-  /** Fill MC points on the ECAL front wall **/
-
-  gMC->TrackPosition(fPos);
-  gMC->TrackMomentum(fMom);
-  fVolumeID = -1;
-  Double_t mass = gMC->TrackMass();
-  // Calculate kinetic energy
-  Double_t ekin = TMath::Sqrt( fMom.Px()*fMom.Px() +
-			       fMom.Py()*fMom.Py() +
-			       fMom.Pz()*fMom.Pz() +
-			       mass * mass ) - mass;
-  fELoss = ekin;
-  // Create CbmEcalPoint at the entrance of calorimeter
-  // for particles with pz>0 coming through the front wall
-  if (fMom.Pz() > 0 && fPos.Z() < fZEcal+0.01)
-    AddHit(fTrackID, fVolumeID, TVector3(fPos.X(),  fPos.Y(),  fPos.Z()),
-	   TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, 
-	   fELoss);
-  fTrackID=gMC->GetStack()->GetCurrentTrackNumber();
-}
-
-CbmEcalPointLite* CbmEcalDetailed::FindHit(Int_t VolId, Int_t TrackId)
-{
-  for(Int_t i=fFirstNumber;i<fLiteCollection->GetEntriesFast();i++)
-  {
-    CbmEcalPointLite* point=(CbmEcalPointLite*)fLiteCollection->At(i);
-    if (point->GetTrackID()==TrackId&&point->GetDetectorID()==VolId)
-      return point;
-  }
-  return NULL;
-}
-//-----------------------------------------------------------------------------
-Bool_t CbmEcalDetailed::FillLitePoint(Int_t)
-{
-  /** Fill MC points inside the ECAL for non-zero deposited energy **/
-
-  //Search for input track
-  
-  static Float_t zmin=fZEcal-0.0001;
-  static Float_t zmax=fZEcal+fEcalSize[2];
-  static Float_t xecal=fEcalSize[0]/2;
-  static Float_t yecal=fEcalSize[1]/2;
-  TParticle* part=gMC->GetStack()->GetCurrentTrack();
-  fTrackID=gMC->GetStack()->GetCurrentTrackNumber();
-
-  /** Need to rewrite this part **/
-  while (part->GetFirstMother()>=0&&\
-      part->Vz()>=zmin&&part->Vz()<=zmax&& \
-      TMath::Abs(part->Vx())<=xecal&&\
-      TMath::Abs(part->Vy())<=yecal)
-    {
-      fTrackID=part->GetFirstMother();
-      part =((CbmStack*)gMC->GetStack())->GetParticle(fTrackID);
-    }
-//  if (part->Vz()>500)
-//    cout << part->Vx() << ", " << part->Vy() << ", " << part->Vz() << endl;
-#ifdef _DECAL
-  if (fTrackID<0) cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!fTrackID="<<fTrackID<<endl;
-#endif
-  CbmEcalPointLite* oldHit;
-  CbmEcalPointLite* newHit;
-  
-  if ((oldHit=FindHit(fVolumeID,fTrackID))!=NULL)
-  {
-    ChangeHit(oldHit);
-    return kTRUE;
-  }
-  else
-    // Create CbmEcalPoint for scintillator volumes
-    newHit = AddLiteHit(fTrackID, fVolumeID, fTime, fELoss);
-  
-  if (newHit==NULL) return kFALSE;
-  return kTRUE;
-}
-
-// -----   Public method EndOfEvent   --------------------------------------
-void CbmEcalDetailed::EndOfEvent() {
-  if (fVerboseLevel) Print();
-  fEcalCollection->Clear();
-
-  fLiteCollection->Clear();
-  fPosIndex = 0;
-  fFirstNumber=0;
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method GetCollection   -----------------------------------
-TClonesArray* CbmEcalDetailed::GetCollection(Int_t iColl) const
-{
-  if (iColl == 0) return fEcalCollection;
-  if (iColl == 1) return fLiteCollection;
-  else return NULL;
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method Reset   -------------------------------------------
-void CbmEcalDetailed::Reset()
-{
-  fEcalCollection->Clear();
-  fLiteCollection->Clear();
-  ResetParameters();
-  fFirstNumber=0;
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method Print   -------------------------------------------
-void CbmEcalDetailed::Print(Option_t*) const 
-{
-  Int_t nHits = fEcalCollection->GetEntriesFast();
-  Int_t nLiteHits;
-  Int_t i;
-
-  cout << "-I- CbmEcalDetailed: " << nHits << " points registered in this event.";
-  cout << endl;
-
-  nLiteHits=fLiteCollection->GetEntriesFast();
-  cout << "-I- CbmEcalDetailed: " << nLiteHits << " lite points registered in this event.";
-  cout << endl;
-
-  if (fVerboseLevel>1)
-  {
-    for (i=0;i<nHits;i++)
-      (*fEcalCollection)[i]->Print();
-    for (i=0;i<nLiteHits;i++)
-      (*fLiteCollection)[i]->Print();
-  }
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method CopyClones   --------------------------------------
-void CbmEcalDetailed::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset)
-{   
-  Int_t nEntries = cl1->GetEntriesFast();
-  Int_t i;
-  Int_t index;
-  cout << "-I- CbmEcalDetailed: " << nEntries << " entries to add." << endl;
-  TClonesArray& clref = *cl2;
-  if (cl1->GetClass()==CbmEcalPoint::Class()) {
-    CbmEcalPoint* oldpoint = NULL;
-    for (i=0; i<nEntries; i++) {
-      oldpoint = (CbmEcalPoint*) cl1->At(i);
-      index = oldpoint->GetTrackID()+offset;
-      oldpoint->SetTrackID(index);
-      new (clref[fPosIndex]) CbmEcalPoint(*oldpoint);
-      fPosIndex++;
-    }
-    cout << "-I- CbmEcalDetailed: " << cl2->GetEntriesFast() << " merged entries."
-         << endl;
-  }
-  else if (cl1->GetClass()==CbmEcalPointLite::Class()) {
-    CbmEcalPointLite* oldpoint = NULL;
-    for (i=0; i<nEntries; i++) {
-      oldpoint = (CbmEcalPointLite*) cl1->At(i);
-      index = oldpoint->GetTrackID()+offset;
-      oldpoint->SetTrackID(index);
-      new (clref[fPosIndex]) CbmEcalPointLite(*oldpoint);
-      fPosIndex++;
-    }
-    cout << "-I- CbmEcalDetailed: " << cl2->GetEntriesFast() << " merged entries."
-         << endl;
-  }
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method Register   ----------------------------------------
-void CbmEcalDetailed::Register()
-{
-  FairRootManager::Instance()->Register("EcalPoint","Ecal",fEcalCollection,kTRUE);
-  FairRootManager::Instance()->Register("EcalPointLite","EcalLite",fLiteCollection,kTRUE);
-  ;
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method ConstructGeometry   -------------------------------
-void CbmEcalDetailed::ConstructGeometry()
-{
-//  FairGeoLoader*geoLoad = FairGeoLoader::Instance();
-//  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
-//  FairGeoMedia *Media =  geoFace->getMedia();
-//  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
-
-  TGeoVolume *volume;
-  TGeoCompositeShape* top;
-  TGeoBBox* bbox;
-  TGeoTube* tube;
-//  FairGeoMedium *CbmMedium;
-//  TGeoPgon *spl;
-
-  Float_t *buf = 0;
-  Int_t i;
-  Double_t par[10];
-  Float_t y;
-  TString nm;
-  Double_t thickness=fThicknessLead+fThicknessScin+fThicknessTyvk*2;
-  Double_t moduleth=thickness*fNLayers+fThicknessPSlead+fThicknessPSscin+fEcalPSgap;
-//  Float_t sumWeight;
-//  Int_t i;
-
-  // create SensVacuum which is defined in the media file
-
-  /** Initialize all media **/
-  InitMedia();
-//TODO!!! 
-//  A temporary increase of sensitive volume size to cover up to 45 degrees of acceptance 
-  par[0]=fZEcal/2.0+0.1;
-  par[1]=fZEcal/2.0+0.1;
-  par[2]=moduleth/2.0+0.1;
-/*
-  par[0]=fEcalSize[0]/2.0+0.1;
-  par[1]=fEcalSize[1]/2.0+0.1;
-  par[2]=moduleth/2.0+0.1;
-*/
-  bbox=new TGeoBBox("ecal_bbox",par[0], par[1], par[2]);
-  if (bbox==NULL) Error("ConstructGeometry", "Can't create BBox for ECAL");
-  // 48 cm for beam pipe
-  tube=new TGeoTube("ecal_hole", 0, 48, par[2]);
-  if (tube==NULL) Error("ConstructGeometry", "Can't create hole for beam pipe in ECAL");
-  top=new TGeoCompositeShape("ecal_top", "ecal_bbox-ecal_hole");
-//  volume=gGeoManager->Volume("Ecal", "BOX",  gGeoManager->GetMedium("SensVacuum")->GetId(), par, 3);
-  volume=new TGeoVolume("Ecal", top, gGeoManager->GetMedium("SensVacuum"));
-  gGeoManager->Node("Ecal", 1, "cave", 0.0,0.0, fZEcal+par[2]-0.05, 0, kTRUE, buf, 0);
-  // An ugly way!!!
-  // Need to make a two volumes for each calorimeter arm 
-  AddSensitiveVolume(volume);
-  fStructureId=volume->GetNumber();
-
-  for(i=1;i<cMaxModuleType;i++)
-    if (fModulesWithType[i]>0)
-    {
-      if (fSimpleGeo==0)
-	ConstructModule(i);
-      else
-	ConstructModuleSimple(i);
-    }
- 
-  //TGeoVolume* vol=new TGeoVolumeAssembly("EcalStructure"); (VF) unused
-  for(i=0;i<fYSize;i++)
-  {
-//    cout << i << "	" << flush;
-    volume=ConstructRaw(i);
-    if (volume==NULL) 
-    {
-//      cout << endl;
-      continue;
-    }
-    nm=volume->GetName();
-    y=(i-fYSize/2.0+0.5)*fModuleSize;
-//    cout << volume->GetName() << flush;
-    gGeoManager->Node(nm.Data(), i+1, "EcalStructure", 0.0, y, 0.0, 0, kTRUE, buf, 0);
-//    cout << endl << flush;
-  }
-//TODO:
-//Should move the guarding volume, not structure itself
-  gGeoManager->Node("EcalStructure", 1, "Ecal", fDX, fDY, 0.0, 0, kTRUE, buf, 0);
-}
-// -------------------------------------------------------------------------
-
-// ----- Public method ConstructRaw ----------------------------------------
-TGeoVolume* CbmEcalDetailed::ConstructRaw(Int_t num)
-{
-  Int_t i;
-  list<pair<Int_t, TGeoVolume*> >::const_iterator p=fRawNumber.begin();
-  pair<Int_t, TGeoVolume*> out;
-  Float_t x;
-  Float_t* buf=NULL;
-  for(i=0;i<fXSize;i++)
-    if ((Int_t)fInf->GetType(i, num)!=0) break;
-  if (i==fXSize)
-    return NULL;
-  for(;p!=fRawNumber.end();++p)
-  {
-    for(i=0;i<fXSize;i++)
-      if (fInf->GetType(i, num)!=fInf->GetType(i, (*p).first))
-	break;
-    if (i==fXSize)
-      break;
-  }
-  if (p!=fRawNumber.end())
-    return (*p).second;
-  TString nm="ECALRaw"; nm+=num;
-  TString md;
-  TGeoVolume* vol=new TGeoVolumeAssembly(nm);
-  for(i=0;i<fXSize;i++)
-  {
-    x=(i-fXSize/2.0+0.5)*fModuleSize;
-    md="EcalModule"; md+=(Int_t)fInf->GetType(i, num);
-    gGeoManager->Node(md.Data(),i+1, nm.Data(), x, 0.0, 0.0, 0, kTRUE, buf, 0);
-  }
-
-  out.first=num;
-  out.second=vol;
-  fRawNumber.push_back(out);
-  return out.second;
-}
-// -------------------------------------------------------------------------
-
-
-// ----- Public method BeginEvent  -----------------------------------------
-void CbmEcalDetailed::BeginEvent()
-{
-  ;
-}
-// -------------------------------------------------------------------------
-
-
-// -------------------------------------------------------------------------
-
-// -----   Private method AddHit   -----------------------------------------    
-CbmEcalPoint* CbmEcalDetailed::AddHit(Int_t trackID, Int_t detID, TVector3 pos,         
-			      TVector3 mom, Double_t time, Double_t length,       
-			      Double_t eLoss)
-{
-  TClonesArray& clref = *fEcalCollection;
-  Int_t size = clref.GetEntriesFast();
-  return new(clref[size]) CbmEcalPoint(trackID, detID, pos, mom,
-                                      time, length, eLoss);
-}                                                                               
-// -------------------------------------------------------------------------
-
-// -----   Private method AddHit   -----------------------------------------    
-CbmEcalPointLite* CbmEcalDetailed::AddLiteHit(Int_t trackID, Int_t detID, Double32_t time, Double32_t eLoss)
-{
-  TClonesArray& clref = *fLiteCollection;
-  Int_t size = clref.GetEntriesFast();
-  return new(clref[size]) CbmEcalPointLite(trackID, detID, time, eLoss);
-}
-// -------------------------------------------------------------------------
-
-// -----   Private method ConstructModule ----------------------------------    
-void CbmEcalDetailed::ConstructModule(Int_t type)
-{
-  if (fModules[type]!=NULL) return;
-  ConstructCell(type);
-
-  TString nm="EcalModule"; nm+=type;
-  TString nm1;
-  TString cellname="EcalCell"; cellname+=type;
-  Int_t i;
-  Int_t j;
-  Int_t n;
-  Float_t x;
-  Float_t y;
-  Float_t* buf=NULL;
-  Double_t thickness=fThicknessLead+fThicknessScin+fThicknessTyvk*2;
-  Double_t moduleth=thickness*fNLayers;
-  // Double_t par[3]={fModuleSize/2.0, fModuleSize/2.0, moduleth/2.0};   (VF) not used
-  if (fSteelTapes[0]==NULL)
-  {
-    TGeoBBox* st1=new TGeoBBox(fThicknessSteel/2.0, fModuleSize/2.0-fThicknessSteel, moduleth/2.0);
-    nm1="EcalModuleSteelTape1_"; //nm1+=type;
-    fSteelTapes[0]=new TGeoVolume(nm1.Data(), st1, gGeoManager->GetMedium("ECALSteel"));
-  }
-  if (fSteelTapes[1]==NULL)
-  {
-    TGeoBBox* st2=new TGeoBBox(fModuleSize/2.0-fThicknessSteel, fThicknessSteel/2.0, moduleth/2.0);
-    nm1="EcalModuleSteelTape2_"; //nm1+=type;
-    fSteelTapes[1]=new TGeoVolume(nm1.Data(), st2, gGeoManager->GetMedium("ECALSteel"));
-  }
-
-
-//  TGeoVolume* modulev=new TGeoVolumeAssembly(nm);
-  //TGeoVolume* modulev=gGeoManager->Volume(nm.Data(), "BOX",  gGeoManager->GetMedium("ECALAir")->GetId(), par, 3);
-
-  //Adding cells into module
-  for(i=0;i<type;i++)
-  for(j=0;j<type;j++)
-  {
-    x=(i-type/2.0+0.5)*(fXCell[type]+2.0*fEdging);
-    y=(j-type/2.0+0.5)*(fYCell[type]+2.0*fEdging);
-    n=i+j*type+1;
-    gGeoManager->Node(cellname.Data(), n, nm.Data(), x, y, 0.0, 0, kTRUE, buf, 0);
-  }
-  nm1="EcalModuleSteelTape1_"; //nm1+=type;
-  gGeoManager->Node(nm1.Data(), 1, nm.Data(), -fThicknessSteel/2.0+fModuleSize/2.0, 0.0, 0.0, 0, kTRUE, buf, 0);
-  gGeoManager->Node(nm1.Data(), 2, nm.Data(), +fThicknessSteel/2.0-fModuleSize/2.0, 0.0, 0.0, 0, kTRUE, buf, 0);
-  nm1="EcalModuleSteelTape2_"; //nm1+=type;
-  gGeoManager->Node(nm1.Data(), 1, nm.Data(), 0.0, -fThicknessSteel/2.0+fModuleSize/2.0, 0.0, 0, kTRUE, buf, 0);
-  gGeoManager->Node(nm1.Data(), 2, nm.Data(), 0.0, +fThicknessSteel/2.0-fModuleSize/2.0, 0.0, 0, kTRUE, buf, 0);
-  fModuleLenght=moduleth;
-}
-// -------------------------------------------------------------------------
-
-// -----   Private method ConstructModuleSimple-----------------------------    
-void CbmEcalDetailed::ConstructModuleSimple(Int_t type)
-{
-  if (fModules[type]!=NULL) return;
-  ConstructCellSimple(type);
-
-  TString nm="EcalModule"; nm+=type;
-  TString nm1;
-  TString cellname="EcalCell"; cellname+=type;
-  Int_t i;
-  Int_t j;
-  Int_t n;
-  Float_t x;
-  Float_t y;
-  Float_t* buf=NULL;
-  Double_t thickness=fThicknessLead+fThicknessScin+fThicknessTyvk*2;
-  Double_t moduleth=thickness*fNLayers;
-  //Double_t par[3]={fModuleSize/2.0, fModuleSize/2.0, moduleth/2.0};  (VF) not used
-
-//  TGeoVolume* modulev=new TGeoVolumeAssembly(nm);
-  //TGeoVolume* modulev=gGeoManager->Volume(nm.Data(), "BOX",  gGeoManager->GetMedium("ECALAir")->GetId(), par, 3);
-
-  //Adding cells into module
-  for(i=0;i<type;i++)
-  for(j=0;j<type;j++)
-  {
-    x=(i-type/2.0+0.5)*(fXCell[type]);
-    y=(j-type/2.0+0.5)*(fYCell[type]);
-    n=i+j*type+1;
-    gGeoManager->Node(cellname.Data(), n, nm.Data(), x, y, 0.0, 0, kTRUE, buf, 0);
-  }
-  fModuleLenght=moduleth;
-}
-// -------------------------------------------------------------------------
-
-// -----   Private method ConstructCell ------------------------------------    
-void CbmEcalDetailed::ConstructCell(Int_t type)
-{
-  if (fCells[type]!=NULL) return;
-
-  ConstructTile(type, 0);
-  ConstructTile(type, 1);
-  if (fThicknessTyvk>0) ConstructTile(type, 2);
-
-  Double_t thickness=fThicknessLead+fThicknessScin+fThicknessTyvk*2;
-  Int_t i;
-  TString nm="EcalCell"; nm+=type;
-  TString scin="ScTile"; scin+=type; scin+="_edging";
-  TString lead="LeadTile"; lead+=type;
-  TString tyvek="TvTile"; tyvek+=type;
-  Double_t* buf=NULL;
-  Double_t moduleth=thickness*fNLayers;
-  Double_t par[3]={fXCell[type]/2.0+fEdging, fYCell[type]/2.0+fEdging, moduleth/2.0};
-//  TGeoVolume* cellv=new TGeoVolumeAssembly(nm);
-  TGeoVolume* cellv=gGeoManager->Volume(nm.Data(),"BOX", gGeoManager->GetMedium("ECALAir")->GetId(), par, 3);
-  for(i=0;i<fNLayers;i++)
-  {
-    gGeoManager->Node(scin.Data(), i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin/2.0+i*thickness, 0, kTRUE, buf, 0);
-    gGeoManager->Node(lead.Data(), i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+fThicknessTyvk+fThicknessLead/2.0, 0, kTRUE, buf, 0);
-    gGeoManager->Node(tyvek.Data(), 2*i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+1.5*fThicknessTyvk+fThicknessLead, 0, kTRUE, buf, 0);
-    gGeoManager->Node(tyvek.Data(), 2*i+2, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+0.5*fThicknessTyvk, 0, kTRUE, buf, 0);
-  }
-  fCells[type]=cellv;
-}
-// -------------------------------------------------------------------------
-
-// -----   Private method ConstructCellSimple ------------------------------    
-void CbmEcalDetailed::ConstructCellSimple(Int_t type)
-{
-  if (fCells[type]!=NULL) return;
-
-  ConstructTileSimple(type, 0);
-  ConstructTileSimple(type, 1);
-  if (fThicknessTyvk>0) ConstructTileSimple(type, 2);
-
-  Double_t thickness=fThicknessLead+fThicknessScin+fThicknessTyvk*2;
-  Int_t i;
-  TString nm="EcalCell"; nm+=type;
-  TString scin="ScTile"; scin+=type;
-  TString lead="LeadTile"; lead+=type;
-  TString tyvek="TvTile"; tyvek+=type;
-  Double_t* buf=NULL;
-  Double_t moduleth=thickness*fNLayers;
-  Double_t par[3]={fXCell[type]/2.0, fYCell[type]/2.0, moduleth/2.0};
-//  TGeoVolume* cellv=new TGeoVolumeAssembly(nm);
-  TGeoVolume* cellv=gGeoManager->Volume(nm.Data(),"BOX", gGeoManager->GetMedium("ECALAir")->GetId(), par, 3);
-  for(i=0;i<fNLayers;i++)
-  {
-    gGeoManager->Node(scin.Data(), i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin/2.0+i*thickness, 0, kTRUE, buf, 0);
-    gGeoManager->Node(lead.Data(), i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+fThicknessTyvk+fThicknessLead/2.0, 0, kTRUE, buf, 0);
-    gGeoManager->Node(tyvek.Data(), 2*i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+1.5*fThicknessTyvk+fThicknessLead, 0, kTRUE, buf, 0);
-    gGeoManager->Node(tyvek.Data(), 2*i+2, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+0.5*fThicknessTyvk, 0, kTRUE, buf, 0);
-  }
-  fCells[type]=cellv;
-}
-// -------------------------------------------------------------------------
-
-// -----   Private method InitMedium ---------------------------------------    
-Int_t CbmEcalDetailed::InitMedium(const char* name)
-{
-  static FairGeoLoader *geoLoad=FairGeoLoader::Instance();
-  static FairGeoInterface *geoFace=geoLoad->getGeoInterface();
-  static FairGeoMedia *media=geoFace->getMedia();
-  static FairGeoBuilder *geoBuild=geoLoad->getGeoBuilder();
-
-  FairGeoMedium *CbmMedium=media->getMedium(name);
-
-  if (!CbmMedium)
-  {
-    Fatal("InitMedium","Material %s not defined in media file.", name);
-    return -1111;
-  }
-  return geoBuild->createMedium(CbmMedium);
-}
-// -------------------------------------------------------------------------
-
-// -----   Private method InitMedia ----------------------------------------    
-void CbmEcalDetailed::InitMedia()
-{
-  Info("InitMedia", "Initializing media.");
-  InitMedium("SensVacuum");
-  InitMedium("ECALVacuum");
-  InitMedium("Lead");
-  InitMedium("Scintillator");
-  InitMedium("Tyvek");
-  InitMedium("ECALAir");
-  InitMedium("ECALFiber");
-  InitMedium("ECALSteel");
-  InitMedium("ECALTileEdging");
-}
-// -------------------------------------------------------------------------
-
-// -----   Private method ConstructTile ------------------------------------    
-void CbmEcalDetailed::ConstructTile(Int_t type, Int_t material)
-{
-  switch (material)
-  {
-    case 0: if (fScTiles[type]!=NULL) return; break;
-    case 1: if (fPbTiles[type]!=NULL) return; break;
-    case 2: if (fTvTiles[type]!=NULL) return; break;
-    default: Error("ConstructTile", "Can't construct a tile of type %d.", material);
-  }
-  Double_t thickness=-1111;
-  TGeoVolume* hole;
-  TGeoVolume* fiber;
-//  TGeoTranslation** tr;
-//  TGeoTranslation* tm;
-  Int_t nh=fNH[type];
-  Int_t i;
-  Int_t j=0;
-  TString nm;
-  TString nm1;
-  TString nm2;
-  TString medium;
-  Double_t x;
-  Double_t y;
-  TGeoBBox* tile;
-  TGeoVolume* tilev;
-  TGeoBBox* edging;
-  TGeoVolume* edgingv;
-  Double_t* buf=NULL;
-
-  switch (material)
-  {
-    case 0: thickness=fThicknessScin/2.0; break;
-    case 1: thickness=fThicknessLead/2.0; break;
-    case 2: thickness=fThicknessTyvk/2.0; break;
-    default: Error("ConstructTile", "Can't construct a tile of type %d.", material);
-  }
-
-  // Holes in the tiles
-  if (fHoleRad>0)
-  {
-    nm1="ECALHole_"; nm1+=material;
-    nm2="ECALFiber_"; nm2+=material;
-    if (fHoleVol[material]==NULL)
-    {
-      TGeoTube* holetube=new TGeoTube(0, fHoleRad, thickness);
-      fHoleVol[material]=new TGeoVolume(nm1.Data(), holetube,  gGeoManager->GetMedium("ECALAir"));
-    }
-    hole=fHoleVol[material];
-    if (hole==NULL) Error("ConstructTile", "Can't create hole volume");
-    // Fibers in holes 
-    if (fFiberRad>0)
-    {
-      if (fFiberVol[material]==NULL)
-      {
-        TGeoTube* fibertube=new TGeoTube(0, fFiberRad, thickness);
-        fFiberVol[material]=new TGeoVolume(nm2.Data(), fibertube,  gGeoManager->GetMedium("ECALFiber"));
-        gGeoManager->Node(nm2.Data(), 1, nm1.Data(), 0.0, 0.0, 0.0, 0, kTRUE, buf, 0);
-      }
-      fiber=fFiberVol[material];
-      if (fiber==NULL) Error("ConstructTile", "Can't create fiber volume");
-      // TODO: Cerenkoff !!!
-      //AddSensitiveVolume(fiber);
-    }
-  }
-/*
-  if (fHolePos[type]==NULL)
-  {
-    tr=new TGeoTranslation*[nh*nh];
-    for(i=0;i<nh;i++)
-    for(j=0;j<nh;j++)
-    {
-      nm="sh"; nm+=type; nm+="_"; nm+=j*nh+i;
-      x=(i-nh/2+0.5)*fXCell[type]/nh;
-      y=(j-nh/2+0.5)*fYCell[type]/nh;
-
-
-      tm=new TGeoTranslation(nm, x, y, 0);
-      gGeoManager->AddTransformation(tm);
-      tr[j*nh+i]=tm;
-    }
-    fHolePos[type]=tr;
-  }
-  tr=fHolePos[type];
-*/
-  /** Building tile **/
-  switch (material)
-  {
-    case 0: nm="ScTile"; medium="Scintillator"; break;
-    case 1: nm="LeadTile"; medium="Lead"; break;
-    case 2: nm="TvTile"; medium="Tyvek"; break;
-    default: Error("ConstructTile", "Can't construct a tile of type %d.", material);
-  }
-
-  nm+=type;
-  if (material==0)
-    tile=new TGeoBBox(fXCell[type]/2.0, fYCell[type]/2.0, thickness);
-  else
-    tile=new TGeoBBox(fXCell[type]/2.0+fEdging, fYCell[type]/2.0+fEdging, thickness);
-  tilev=new TGeoVolume(nm, tile, gGeoManager->GetMedium(medium));
-  if (fHoleRad>0)
-  {
-    nm1="ECALHole_"; nm1+=material;
-    for(i=0;i<nh;i++)
-    for(j=0;j<nh;j++)
-    {
-      x=(i-nh/2+0.5)*fXCell[type]/nh;
-      y=(j-nh/2+0.5)*fYCell[type]/nh;
-      gGeoManager->Node(nm1.Data(), j*nh+i+1, nm.Data(), x, y, 0.0, 0, kTRUE, buf, 0);
-    }
-    // clear fiber
-    if (nh%2==0&&fCF[type]!=0)
-      gGeoManager->Node(nm1.Data(), j*nh+i+1, nm.Data(), 0.0, 0.0, 0.0, 0, kTRUE, buf, 0);
-
-  }
-/*
-  if (fHoleRad>0)
-  {
-    for(i=0;i<nh;i++)
-    for(j=0;j<nh;j++)
-      tilev->AddNode(hole, j*nh+i+1, tr[j*nh+i]);
-    // Clear Fiber
-    if (nh%2==0)
-      tilev->AddNode(hole, j*nh+i+1);
-  }
-*/
-  /** Adding edging to scintillator **/
-  if (material==0)
-  {
-    AddSensitiveVolume(tilev);
-    edging=new TGeoBBox(fXCell[type]/2.0+fEdging, fYCell[type]/2.0+fEdging, thickness);
-     
-    edgingv=new TGeoVolume(nm+"_edging", edging, gGeoManager->GetMedium("ECALTileEdging"));
-    edgingv->AddNode(tilev, 1);
-    fScTiles[type]=tilev;
-    fTileEdging[type]=edgingv;
-  }
-  else
-  {
-    if (material==1) //Lead
-      fPbTiles[type]=tilev;
-    else
-      fTvTiles[type]=tilev;
-    return;
-  }
-}
-// -------------------------------------------------------------------------
-
-// -----   Private method ConstructTileSimple ------------------------------    
-void CbmEcalDetailed::ConstructTileSimple(Int_t type, Int_t material)
-{
-  switch (material)
-  {
-    case 0: if (fScTiles[type]!=NULL) return; break;
-    case 1: if (fPbTiles[type]!=NULL) return; break;
-    case 2: if (fTvTiles[type]!=NULL) return; break;
-    default: Error("ConstructTileSimple", "Can't construct a tile of type %d.", material);
-  }
-  Double_t thickness=-1111;
-//  TGeoVolume* hole;
-//  TGeoVolume* fiber;
-//  TGeoTranslation** tr;
-//  TGeoTranslation* tm;
-//  Int_t nh=fNH[type];
-//  Int_t i;
-//  Int_t j;
-  TString nm;
-  TString nm1;
-  TString nm2;
-  TString medium;
-//  Double_t x;
-//  Double_t y;
-  TGeoBBox* tile;
-  TGeoVolume* tilev;
-//  TGeoBBox* edging;
-//  TGeoVolume* edgingv;
-//  Double_t* buf=NULL;
-
-  switch (material)
-  {
-    case 0: thickness=fThicknessScin/2.0; break;
-    case 1: thickness=fThicknessLead/2.0; break;
-    case 2: thickness=fThicknessTyvk/2.0; break;
-    default: Error("ConstructTile", "Can't construct a tile of type %d.", material);
-  }
-
-  /** Building tile **/
-  switch (material)
-  {
-    case 0: nm="ScTile"; medium="Scintillator"; break;
-    case 1: nm="LeadTile"; medium="Lead"; break;
-    case 2: nm="TvTile"; medium="Tyvek"; break;
-    default: Error("ConstructTile", "Can't construct a tile of type %d.", material);
-  }
-
-  nm+=type;
-  tile=new TGeoBBox(fXCell[type]/2.0, fYCell[type]/2.0, thickness);
-  tilev=new TGeoVolume(nm, tile, gGeoManager->GetMedium(medium));
-  /** Adding edging to scintillator **/
-  if (material==0)
-  {
-    AddSensitiveVolume(tilev);
-    fScTiles[type]=tilev;
-    fTileEdging[type]=tilev;
-  }
-  else
-  {
-    if (material==1) //Lead
-      fPbTiles[type]=tilev;
-    else
-      fTvTiles[type]=tilev;
-    return;
-  }
-}
-// -------------------------------------------------------------------------
-
-// ----- Public method GetCellCoordInf ----------------------------------------
-Bool_t CbmEcalDetailed::GetCellCoordInf(Int_t fVolID, Float_t &x, Float_t &y, Int_t& tenergy)
-{
-  static CbmEcalInf* inf=NULL;
-  if (inf==NULL)
-  {
-    inf=CbmEcalInf::GetInstance(NULL);
-    if (inf==NULL)
-    {
-      cerr << "CbmEcalDetailed::GetCellCoordInf(): Can't get geometry information." << endl;
-      return kFALSE;
-    }
-  }
-  Int_t volid=fVolID;
-  Int_t cell=volid%100-1; volid=volid-cell-1; volid/=100;
-  Int_t mx=volid%100; volid-=mx; volid/=100;
-  Int_t my=volid%100; volid-=my; volid/=100;
-  Int_t type=inf->GetType(mx, my);
-  Int_t cx=cell%type;
-  Int_t cy=cell/type;
-//  cout << "->" << mx << ", " << my << ", " << cell << endl;
-  static Float_t modulesize=inf->GetVariableStrict("modulesize");
-  static Float_t xcalosize=inf->GetEcalSize(0);
-  static Float_t ycalosize=inf->GetEcalSize(1);
-  static Float_t dx=inf->GetVariableStrict("xpos");
-  static Float_t dy=inf->GetVariableStrict("ypos");
-  x=mx*modulesize-xcalosize/2.0+cx*modulesize/type+1.0; x+=dx;
-  y=my*modulesize-ycalosize/2.0+cy*modulesize/type+1.0; y+=dy;
-  tenergy=0;
-
-//  cerr << fVolID << " --- " << x << ", " << y << endl;
-  return kFALSE;
-}
-
-// ------------------------------------------------------------------------------
-
-Bool_t CbmEcalDetailed::GetCellCoord(Int_t fVolID, Float_t &x, Float_t &y, Int_t& tenergy)
-{
-  return GetCellCoordInf(fVolID, x, y, tenergy);
-}
-
-
-ClassImp(CbmEcalDetailed)
diff --git a/ecal/CbmEcalDetailed.h b/ecal/CbmEcalDetailed.h
deleted file mode 100644
index 0d8b81e9acb40c9c943f83fbbfde2a258350afa4..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalDetailed.h
+++ /dev/null
@@ -1,270 +0,0 @@
-/**  CbmEcalDetailed.h
- *@author Mikhail Prokudin
- **
- ** Defines the active detector ECAL with geometry coded here.
- **/
-
-
-#ifndef CBMECALDETAILED_H
-#define CBMECALDETAILED_H
-
-
-#include "CbmEcalPointLite.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalInf.h"
-
-#include "FairDetector.h"
-
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-#include "TVector3.h"
-
-#include <list>
-
-class CbmEcalPoint; 
-class FairVolume;
-class TGeoTranslation;
-class CbmEcalLightMap;
-
-#define kNumberOfECALSensitiveVolumes 6
-const Int_t cMaxModuleType=5;
-
-class CbmEcalDetailed : public FairDetector
-{
-
-public:
-
-  /** Default constructor **/
-  CbmEcalDetailed();
-
-
-  /** Standard constructor.
-   *@param name    detetcor name
-   *@param active  sensitivity flag
-   **/
-  CbmEcalDetailed(const char* name, Bool_t active, 
-	  const char* fileGeo="ecal_Detailed.geo");
-
-
-  /** Destructor **/
-  virtual ~CbmEcalDetailed();
-
-
-  /** Virtual method ProcessHits
-   **
-   ** Defines the action to be taken when a step is inside the
-   ** active volume. Creates CbmEcalDetailed and adds them to the
-   ** collection.
-   *@param vol  Pointer to the active volume
-   **/
-  virtual Bool_t  ProcessHits(FairVolume* vol = NULL);
-
-
-  /** Virtual method Construct geometry
-   **
-   ** Constructs the ECAL geometry
-   **/
-  virtual void ConstructGeometry();
-
-  virtual void EndOfEvent();
-  virtual void BeginEvent();
-  virtual void Reset();
-  virtual void Print(Option_t* ="") const;
-  virtual void CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset);
-  virtual void Register();
-  virtual void ChangeHit(CbmEcalPointLite* oldHit=NULL);
-  virtual void FinishPrimary();
-
-  virtual void Initialize();
-
-  /** Accessor to the hit collection **/                       
-  virtual TClonesArray* GetCollection(Int_t iColl) const;
-  virtual void SetSpecialPhysicsCuts();
-  
-  /** Get cell coordinates according
-   ** to parameter container **/
-  static Bool_t GetCellCoord(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t& tenergy);
-  /** Get cell coordinates according
-   ** to current CbmEcalInf **/
-  static Bool_t GetCellCoordInf(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t& tenergy);
-protected:
-  CbmEcalPoint* AddHit(Int_t trackID, Int_t detID, TVector3 pos,
-                       TVector3 mom, Double_t time, Double_t length,
-                       Double_t eLoss);
-  CbmEcalPointLite* AddLiteHit(Int_t trackID, Int_t detID, Double32_t time, Double32_t eLoss);
-
-private:
-  Bool_t FillLitePoint(Int_t volnum);
-  void FillWallPoint();
-  /** Private method ResetParameters
-   **
-   ** Resets the private members for the track parameters
-   **/
-  void ResetParameters();
-  void SetEcalCuts(Int_t medium);
-  CbmEcalPointLite* FindHit(Int_t VolId, Int_t TrackId);
-
-private:
-  CbmEcalInf*  fInf;			//!
-  Option_t* fDebug;			//!
-
-  /** returns type of volume **/
-  Int_t GetVolType(Int_t volnum);
-  /** Track information to be stored until the track leaves the
-      active volume. **/
-  /**  track index **/
-  Int_t          fTrackID;           	//!  
-  /** volume id **/
-  Int_t          fVolumeID;          	//!  
-  /** position **/
-  TLorentzVector fPos;               	//!  
-  /** momentum **/
-  TLorentzVector fMom;               	//!  
-  /** time **/
-  Double32_t     fTime;              	//!
-  /** length **/
-  Double32_t     fLength;            	//!
-  /** energy loss **/
-  Double32_t     fELoss;             	//!
-  /** **/ 
-  Int_t          fPosIndex;          	//!
-
-  /** MC point collection on ECAL wall **/ 
-  TClonesArray*  fEcalCollection;	//! 
-  /** MC point collection inside ECAL **/ 
-  TClonesArray*  fLiteCollection;	//! 
-  /** ECAL geometry parameters **/
-  /** x,y,z size of outer ECAL box [cm] **/
-  Float_t fEcalSize[3];			//!
-  /** Use simple geometry.
-   ** Try to be as compatible to CbmEcal in physics as possible **/
-  Int_t fSimpleGeo;			//!
-  /** Size of the ECAL in modules **/
-  Int_t fXSize;				//!
-  Int_t fYSize;				//!
-  /** Position of calorimeter center **/
-  Float_t fDX;				//!
-  Float_t fDY;				//!
-  /** transverce cell size [cm] **/
-  Float_t fCellSize;			//!
-  /** Size of calorimeter module [cm] **/
-  Float_t fModuleSize;			//!
-  /** Z-position of ECAL from the target [cm] **/
-  Float_t fZEcal;			//!
-  /** thickness of one lead layer [cm] **/
-  Float_t fThicknessLead;		//!
-  /** thickness of one scintillator layer [cm] **/
-  Float_t fThicknessScin;		//!
-  /** thickness of one tyvek layer [cm] **/
-  Float_t fThicknessTyvk;		//!
-  /** total thickness of one layer [cm] **/
-  Float_t fThicknessLayer;		//!
-  /** total thickness of steel layer [cm] **/
-  Float_t fThicknessSteel;		//!
-  /** Thickness of tile edging [cm] **/
-  Float_t fEdging;			//!
-  /** Radius of holes in the calorimeter [cm] **/
-  Float_t fHoleRad;			//!
-  /** Radius of fibers in calorimeter [cm] **/
-  Float_t fFiberRad;			//!
-  /** XY Size of cell **/
-  Float_t fXCell[cMaxModuleType];	//!
-  Float_t fYCell[cMaxModuleType];	//!
-  /** Number of holes in modules  **/
-  Int_t fNH[cMaxModuleType];		//!
-  Int_t fCF[cMaxModuleType];		//!
-  /** Names of light maps **/
-  TString fLightMapNames[cMaxModuleType];		//!
-  /** Light maps **/
-  CbmEcalLightMap* fLightMaps[cMaxModuleType];		//!
-  /** number of layers per cell **/
-  Int_t   fNLayers;			//!
-  /** Lenght of calorimeter module **/
-  Float_t fModuleLenght;		//!
-  /** scall factor for fCellSize and fThicknessLayer **/
-  Float_t fGeoScale;			//!
-  /** Number of columns in ECAL1 **/
-  Int_t   fNColumns1;			//!
-  /** Number of rows in ECAL1 **/
-  Int_t   fNRows1;			//!
-  /** Number of columns in ECAL2 **/
-  Int_t   fNColumns2;			//!
-  /** Number of rows in ECAL2 **/
-  Int_t   fNRows2;			//!
-  /** thickness of preshower lead [cm] **/
-  Float_t fThicknessPSlead;		//!
-  /** thickness of preshower scintillator [cm] **/
-  Float_t fThicknessPSscin;		//!
-  /** gap between ECAL cell and preshower [cm] **/
-  Float_t fEcalPSgap;			//!
-  /** max number of columns in ECAL1 or ECAL2 **/
-  Int_t   fNColumns;			//!
-  /** max number of rows in ECAL1 or ECAL2 **/
-  Int_t   fNRows;			//!
-  /** Max number of ECAL cells **/
-  Int_t   fVolIdMax;			//!
-  /** Number of first hit for current primary **/
-  Int_t fFirstNumber;			//!
-  /** Map of volumes in ECAL
-   ** fVolArr[0]==code of sensivite wall
-   ** fVolArr[1]==code of PS Lead
-   ** fVolArr[2]==code of PS Scin
-   ** fVolArr[4]==code of Lead
-   ** fVolArr[3]==code of Tyveec
-   ** fVolArr[5]==code of scintillator
-   **/
-  Int_t fVolArr[kNumberOfECALSensitiveVolumes];		//!
-
-  /** Construct a raw of modules **/
-  TGeoVolume* ConstructRaw(Int_t number);
-  /** Construct a module with given type **/
-  void ConstructModule(Int_t type);
-  /** Construct a cell with given type **/
-  void ConstructCell(Int_t type);
-  /** Construct a tile with given type **/
-  void ConstructTile(Int_t type, Int_t material);
-  /** Next method for simplified geometry **/
-  /** Construct a module with given type **/
-  void ConstructModuleSimple(Int_t type);
-  /** Construct a cell with given type **/
-  void ConstructCellSimple(Int_t type);
-  /** Construct a tile with given type **/
-  void ConstructTileSimple(Int_t type, Int_t material);
-  TGeoVolume* fModules[cMaxModuleType];			//! Calorimeter Modules
-  TGeoVolume* fCells[cMaxModuleType];			//! Calorimeter Cells
-  TGeoVolume* fScTiles[cMaxModuleType];			//! Pb tiles 
-  TGeoVolume* fTileEdging[cMaxModuleType];		//! Edging of scintillator tiles 
-  TGeoVolume* fPbTiles[cMaxModuleType];			//! Scintillator tiles
-  TGeoVolume* fTvTiles[cMaxModuleType];			//! Tyvek sheets
-  TGeoVolume* fHoleVol[3];				//! Hole volume
-  TGeoVolume* fFiberVol[3];				//! Fiber volume
-  TGeoVolume* fSteelTapes[2];				//! Steel tapes
-  TGeoTranslation** fHolePos[cMaxModuleType];		//! Positions of holes
-  Int_t fModulesWithType[cMaxModuleType];		//! Number of mudules with type
-  std::list<std::pair<Int_t, TGeoVolume*> > fRawNumber;	//! List of constructed raws
-
-  /** Volume ID of calorimeter structure **/
-  Int_t fStructureId;			//!
-  /** Initialize medium with given name **/
-  Int_t InitMedium(const char* name);
-  /** Initialize all calorimter media **/
-  void InitMedia();
-
-  CbmEcalDetailed(const CbmEcalDetailed&);
-  CbmEcalDetailed& operator=(const CbmEcalDetailed&);
-
-  ClassDef(CbmEcalDetailed,1)
-
-};
-
-inline void CbmEcalDetailed::ResetParameters()
-{
-  fTrackID = fVolumeID = 0;
-  fPos.SetXYZM(0.0, 0.0, 0.0, 0.0);
-  fMom.SetXYZM(0.0, 0.0, 0.0, 0.0);
-  fTime = fLength = fELoss = 0;
-  fPosIndex = 0;
-};
-
-
-#endif
diff --git a/ecal/CbmEcalDigi.cxx b/ecal/CbmEcalDigi.cxx
deleted file mode 100644
index bf54fee68aa2022c156ae803f4f0ed24cdd41cbf..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalDigi.cxx
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "CbmEcalDigi.h"
-
-#include "CbmEcalStructure.h"
-
-#include "FairRootManager.h"
-
-#include "TRandom.h"
-
-#include <iostream>
-#include <list>
-
-using namespace std;
-
-/** --- Default constructor --------------------------------------------------- **/
-CbmEcalDigi::CbmEcalDigi() 
-  : FairTask(),
-    fPedestal(80),
-    fADCMax(4096),
-    fADCNoise(0.5e-3),
-    fADCChannel(0.5e-3),
-    fStr(NULL)
-{
-}
-
-/** --- Standard constructor. Use this ---------------------------------------- **/
-CbmEcalDigi::CbmEcalDigi(const char* name, Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fPedestal(80),
-    fADCMax(4096),
-    fADCNoise(0.5e-3),
-    fADCChannel(0.5e-3),
-    fStr(NULL)
-
-{
-}
-
-/** --- Initialization of the task -------------------------------------------- **/  
-InitStatus CbmEcalDigi::Init()
-{
-  FairRootManager* manager=FairRootManager::Instance();
-  if (!manager)
-  {
-    Fatal("Init()", "Can't find IOManager.");
-    return kFATAL;
-  }
-
-  fStr=(CbmEcalStructure*)manager->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  
-  return kSUCCESS;
-}
-
-/** --- Executed task --------------------------------------------------------- **/ 
-void CbmEcalDigi::Exec(Option_t*)
-{
-  CbmEcalCell* cell;
-  list<CbmEcalCell*> cells;
-  fStr->GetCells(cells);
-  list<CbmEcalCell*>::const_iterator p=cells.begin();
-  Short_t adc;
-
-  for(;p!=cells.end();++p)
-  {
-    cell=(*p);
-    adc=((Short_t)(gRandom->Gaus(cell->GetEnergy(), fADCNoise)/fADCChannel))+fPedestal;
-    if (adc>fADCMax) adc=fADCMax;
-    cell->SetEnergy(-1111);
-    cell->SetADC(adc);
-  }
-}
-
-/** --- Finish task ----------------------------------------------------------- **/ 
-void CbmEcalDigi::Finish()
-{
-  ;
-}
-/** --- Destructor ------------------------------------------------------------ **/
-CbmEcalDigi::~CbmEcalDigi()
-{
-  ;
-}
-
-ClassImp(CbmEcalDigi)
diff --git a/ecal/CbmEcalDigi.h b/ecal/CbmEcalDigi.h
deleted file mode 100644
index b50bd5d44d1c800a59e111b3a4e7e699ede39fec..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalDigi.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// A very simple digitization scheme for Cbm Calorimeter
-// Operate over CbmEcalStructure
-
-#ifndef CBMECALDIGI_H
-#define CBMECALDIGI_H
-
-#include "FairTask.h"
-
-class CbmEcalStructure;
-
-class CbmEcalDigi : public FairTask
-{
-public:
-  /** Default constructor **/
-  CbmEcalDigi();
-  /** Standard constructor. Use this **/
-  CbmEcalDigi(const char* name, Int_t iVerbose);
-  /** Destructor **/
-  virtual ~CbmEcalDigi();
-  /** Initialization of the task **/  
-  virtual InitStatus Init();
-  /** Executed task **/ 
-  virtual void Exec(Option_t* option);
-  /** Finish task **/ 
-  virtual void Finish();
-  
-
-  void SetPedestal(Short_t ped=80) {fPedestal=ped;}
-  void SetADCMax(Short_t adcmax=4096) {fADCMax=adcmax;}
-  void SetADCNoise(Float_t adcnoise=0.5e-3) {fADCNoise=adcnoise;}
-  void SetADCChannel(Float_t adcchannel=0.5e-3) {fADCChannel=adcchannel;}
-
-  Short_t GetPedestal() const {return fPedestal;}
-  Short_t GetADCMax() const {return fADCMax;}
-  Float_t GetADCNoise() const {return fADCNoise;}
-  Float_t GetADCChannel() const {return fADCChannel;}
-private:
-  // Pedestal 
-  Short_t fPedestal;
-  // ADC maximum
-  Short_t fADCMax;
-  // ADC Noise
-  Float_t fADCNoise;
-  // ADC channel (in energy deposition in _SCINTILLATOR_)
-  Float_t fADCChannel;
-  // Calorimeter structure
-  CbmEcalStructure* fStr;	//!
-
-  CbmEcalDigi(const CbmEcalDigi&);
-  CbmEcalDigi& operator=(const CbmEcalDigi&);
-
-  ClassDef(CbmEcalDigi, 1);
-};
-
-#endif
diff --git a/ecal/CbmEcalDrawer.cxx b/ecal/CbmEcalDrawer.cxx
deleted file mode 100644
index 26977cd4fb5e26397fed1728dda4e353d1bd977e..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalDrawer.cxx
+++ /dev/null
@@ -1,286 +0,0 @@
-/* $Id: CbmEcalDrawer.cxx,v 1.3 2006/07/14 15:11:51 prokudin Exp $ */
-/* 
- * $Log: CbmEcalDrawer.cxx,v $
- * Revision 1.3  2006/07/14 15:11:51  prokudin
- * Posibility to draw ECAL according to current palette added
- *
- * Revision 1.2  2006/07/13 16:41:00  prokudin
- * Cluster draw
- */
-#include "CbmEcalDrawer.h"
-
-#include "TBox.h"
-#include "TLine.h"
-#include "TStyle.h"
-#include "TColor.h"
-
-#include <iostream>
-
-using namespace std;
-
-void CbmEcalDrawer::Init()
-{
-	fEnergyType=0;
-	fMaxEnergy=10;
-	TColor c;
-	c.SetRGB(1,1,1);
-	fFirstColor=c;
-	c.SetRGB(1,0,0);
-	fSecondColor=c;
-	fLines.clear();
-	fBoxes.clear();
-	SetLineColor(1);
-}
-
-void CbmEcalDrawer::InitMaximumEnergy()
-{
-	vector<CbmEcalModule*> stru;
-	vector<CbmEcalModule*>::const_iterator p;
-	vector<CbmEcalCell*> cellstr;
-	vector<CbmEcalCell*>::const_iterator cp;
-	Double_t energy;
-
-	fMaxEnergy=0;
-
-	fEcalStructure->GetStructure(stru);
-	for(p=stru.begin();p!=stru.end();++p)
-	if ((*p)!=NULL)
-	{
-		cellstr=(*p)->GetCells();
-		for(cp=cellstr.begin();cp!=cellstr.end();++cp)
-		{
-			energy=GetEnergy(*cp);
-			if (energy>fMaxEnergy) fMaxEnergy=energy;
-		}
-
-	}
-}
-
-CbmEcalDrawer::~CbmEcalDrawer()
-{
-	fC->Clear();
-	delete fC;
-	CleanUp();
-}
-
-void CbmEcalDrawer::CleanUp()
-{
-	TLine* line;
-	TBox* box;
-
-	list<void*>::const_iterator p;
-	for(p=fLines.begin();p!=fLines.end();++p)
-	{
-		line=(TLine*)(*p);
-		delete line;
-	}
-	for(p=fBoxes.begin();p!=fBoxes.end();++p)
-	{
-		box=(TBox*)(*p);
-		delete box;
-	}
-	fBoxes.clear();
-	fLines.clear();
-}
-
-/** Sets canvas size according to size of
- ** cluster in arr **/
-void CbmEcalDrawer::InitCanvas(TObjArray* arr)
-{
-	Float_t x1=9999;
-	Float_t x2=-9999;
-	Float_t y1=9999;
-	Float_t y2=-9999;
-	CbmEcalCell* cell;
-
-	if (arr->GetSize()<=0) return;
-	for(Int_t i=0;i<arr->GetSize();i++)
-	{
-		cell=(CbmEcalCell*)arr->At(i);
-		if (cell==NULL) continue;
-		if (cell->GetX1()<x1) x1=cell->GetX1();
-		if (cell->GetX2()>x2) x2=cell->GetX2();
-		if (cell->GetY1()<y1) y1=cell->GetY1();
-		if (cell->GetY2()>y2) y2=cell->GetY2();
-	}
-	InitCanvas((Int_t)(x2-x1)*2,(Int_t)(y2-y1)*2);
-	fCX=(Int_t)(x2-x1);
-	fCY=(Int_t)(y2-y1);
-	fCCX=-((Float_t)(x1))/((Float_t)(x2-x1));
-	fCCY=-((Float_t)(y1))/((Float_t)(y2-y1));
-}
-
-void CbmEcalDrawer::InitCanvas(Int_t x, Int_t y)
-{
-	if (fC==NULL)
-		fC=new TCanvas("ECALCanv","ECAL canvas",x,y);
-	else
-	{
-		fC->Clear();
-		delete fC;
-		fC=new TCanvas("ECALCanv","ECAL canvas",x,y);
-	}
-	fC->SetFillColor(0);
-	fC->Clear();
-}
-
-void CbmEcalDrawer::DrawEcal(Int_t type)
-{
-	vector<CbmEcalModule*> stru;
-	vector<CbmEcalModule*>::const_iterator p;
-
-	Prepare();
-	CleanUp();
-	fCCX=0.5;
-	fCCY=0.5;
-	if (fEcalStructure==NULL) return;
-	fEcalStructure->GetStructure(stru);
-	for(p=stru.begin();p!=stru.end();++p)
-		DrawModule(*p, type);
-}
-
-void CbmEcalDrawer::DrawStructure()
-{
-	vector<CbmEcalModule*> stru;
-	vector<CbmEcalModule*>::const_iterator p;
-
-	Prepare();
-	CleanUp();
-	fCCX=0.5;
-	fCCY=0.5;
-	if (fEcalStructure==NULL) return;
-	fEcalStructure->GetStructure(stru);
-	for(p=stru.begin();p!=stru.end();++p)
-		DrawModule(*p, -1);
-}
-
-void CbmEcalDrawer::Prepare()
-{
-	fCX=(Int_t)fEcalStructure->GetEcalInf()->GetEcalSize(0);
-	fCY=(Int_t)fEcalStructure->GetEcalInf()->GetEcalSize(1);
-	InitCanvas(fCX*2,fCY*2);
-}
-
-/** Draws cells from TObjArray
- ** color==-2 to draw energy deposition
- ** color==-3 to draw everything with 0 energy **/
-void CbmEcalDrawer::DrawCells(TObjArray* arr, Int_t color)
-{
-	for(Int_t i=0;i<arr->GetSize();i++)
-		DrawCell((CbmEcalCell*)arr->At(i), color);
-}
-
-void CbmEcalDrawer::DrawModule(CbmEcalModule* module, Int_t color)
-{
-	Int_t lcolor;
-
-	if (module==NULL) return;
-	if (color==-1)
-	{
-		char type=module->GetType();
-		if (type==1) lcolor=3;
-		if (type==2) lcolor=4;
-		if (type==4) lcolor=5;
-	} else lcolor=color;
-
-	vector<CbmEcalCell*> cells=module->GetCells();
-	vector<CbmEcalCell*>::const_iterator p=cells.begin();
-	for(;p!=cells.end();++p)
-		DrawCell((*p), lcolor);
-
-}
-void CbmEcalDrawer::DrawCell(CbmEcalCell* cell, Int_t color)
-{
-	Int_t lcolor;
-	TLine* line;
-        TBox* rect;
-
-	if (cell==NULL) return;
-
-	Double_t x1=((Double_t)cell->GetX1()-fEcalStructure->GetEcalInf()->GetXPos())/fCX+fCCX;
-	Double_t x2=((Double_t)cell->GetX2()-fEcalStructure->GetEcalInf()->GetXPos())/fCX+fCCX;
-	Double_t y1=((Double_t)cell->GetY1()-fEcalStructure->GetEcalInf()->GetYPos())/fCY+fCCY;
-	Double_t y2=((Double_t)cell->GetY2()-fEcalStructure->GetEcalInf()->GetYPos())/fCY+fCCY;
-
-	if (color==-2)
-	{
-		TColor c;
-		Double_t e=GetEnergy(cell);
-/*		Float_t r=fFirstColor.GetRed()  *(1.0-e/fMaxEnergy)+fSecondColor.GetRed()  *e/fMaxEnergy;
-		Float_t g=fFirstColor.GetGreen()*(1.0-e/fMaxEnergy)+fSecondColor.GetGreen()*e/fMaxEnergy;
-		Float_t b=fFirstColor.GetBlue() *(1.0-e/fMaxEnergy)+fSecondColor.GetBlue() *e/fMaxEnergy;
-		c.SetRGB(r,g,b);
-		lcolor=c.GetColor(r,g,b);
-*/
-		Int_t t=(Int_t)(e/fMaxEnergy*9);
-		if (t==9) t=1; else if (t!=0) t=20-t;
-		lcolor=t;
-//		if (e>fMaxEnergy*0.01) lcolor=1;
-	} else
-	if (color==-3)
-		lcolor=fFirstColor.GetColor(fFirstColor.GetRed(), fFirstColor.GetGreen(), fFirstColor.GetBlue());
-	else
-	if (color==-4)
-	{
-		Double_t e=GetEnergy(cell);
-		if (e==0)
-			lcolor=fFirstColor.GetColor(fFirstColor.GetRed(), fFirstColor.GetGreen(), fFirstColor.GetBlue());
-		else
-		{
-			Int_t ncolors=gStyle->GetNumberOfColors();
-			lcolor=(Int_t)(((Float_t)ncolors*e/fMaxEnergy)+0.99);
-			lcolor=gStyle->GetColorPalette(lcolor);
-		}
-	}
-	else
-		lcolor=color;
-	if (lcolor>0)
-	{
-		rect=new TBox(x1,y1,x2,y2);
-		rect->SetFillColor(lcolor);
-		rect->SetFillStyle(kSolid);
-		rect->Draw();
-		fBoxes.push_back((void*)rect);
-	}
-	if (y1>0.001)
-	{
-		line=new TLine(x1,y1,x2,y1);
-		line->SetLineColor(GetLineColor());
-		line->SetLineStyle(GetLineStyle());
-		line->SetLineWidth(GetLineWidth());
-		line->Draw();
-		fLines.push_back((void*)line);
-	}
-
-	if (x2<0.999)
-	{
-		line=new TLine(x2,y1,x2,y2);
-		line->SetLineColor(GetLineColor());
-		line->SetLineStyle(GetLineStyle());
-		line->SetLineWidth(GetLineWidth());
-		line->Draw();
-		fLines.push_back((void*)line);
-	}
-
-	if (y2<0.999)
-	{
-		line=new TLine(x2,y2,x1,y2);
-		line->SetLineColor(GetLineColor());
-		line->SetLineStyle(GetLineStyle());
-		line->SetLineWidth(GetLineWidth());
-		line->Draw();
-		fLines.push_back((void*)line);
-	}
-
-	if (x1>0.001)
-	{
-		line=new TLine(x1,y2,x1,y1);
-		line->SetLineColor(GetLineColor());
-		line->SetLineStyle(GetLineStyle());
-		line->SetLineWidth(GetLineWidth());
-		line->Draw();
-		fLines.push_back((void*)line);
-	}
-}
-
-ClassImp(CbmEcalDrawer);
diff --git a/ecal/CbmEcalDrawer.h b/ecal/CbmEcalDrawer.h
deleted file mode 100644
index 2695ac56b72e55679de3fa5e3523d4acd345dce4..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalDrawer.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* $Id: CbmEcalDrawer.h,v 1.3 2006/07/14 15:11:51 prokudin Exp $ */
-/** CbmEcalDrawer 
- ** ECAL drawer. You can draw structure or energy deposition
- ** in cells. 
- **/
-/*
- * $Log: CbmEcalDrawer.h,v $
- * Revision 1.3  2006/07/14 15:11:51  prokudin
- * Posibility to draw ECAL according to current palette added
- *
- * Revision 1.2  2006/07/13 16:41:00  prokudin
- * Cluster draw
- * */
-#ifndef CBMECALDRAWER_H
-#define CBMECALDRAWER_H
-
-#include "CbmEcalStructure.h"
-
-#include "TCanvas.h"
-#include "TColor.h"
-#include "TAttLine.h"
-#include "TObjArray.h"
-
-#include <list>
-
-class CbmEcalDrawer: public TAttLine
-{
-public:
-	/** Default constructor **/
- CbmEcalDrawer(CbmEcalStructure* ecalStructure=NULL)
-   : TAttLine(), fEcalStructure(ecalStructure), fC(NULL), fCX(0), fCY(0),
-    fCCX(0.), fCCY(0.), fMaxEnergy(0.), fFirstColor(), fSecondColor(),
-    fEnergyType(), fLines(), fBoxes()
-    {Init();};
-
-	CbmEcalStructure* GetEcalStructure() const;
-	void SetEcalStructure(CbmEcalStructure* ecalStructure);
-	/** Returns canvas with picture **/
-	TCanvas* GetCanvas() const;
-        /** Draw only structure of the ECAL **/
-	void DrawStructure();
-	/** Draw structure and energy deposition in ECAL **/
-	void DrawEcal(Int_t type=-2);
-
-	/** Color used for 0 energy**/
-	void SetFirstColor(TColor color);
-	/** Color used for maximum energy**/
-	void SetSecondColor(TColor color);
-
-	TColor GetFirstColor() const;
-	TColor GetSecondColor() const;
-
-	/** Sets maximum energy. To init it from 
-	 ** ECAL structure use
-	 ** CbmEcalDrawer::InitMaximumEnergy() **/
-	void SetMaximumEnergy(Double_t energy);
-	Double_t GetMaximumEnergy() const;
-
-	/** Inits MaxEnergy from ECAL structure. **/
-	void InitMaximumEnergy();
-
-	/** 0 --- for total energy (ECAL+PS)
-	 ** 1 --- only ECAL energy
-	 ** 2 --- only PS energy **/
-	void SetEnergyType(Int_t energytype);
-	Int_t GetEnergyType() const;
-	virtual ~CbmEcalDrawer();
-	/** Delete all lines and boxes after use**/
-	void CleanUp();
-	/** Draws module with all its cells
-	 ** color==-1 to draw ECAL structure
-	 ** color==-2 to draw energy deposition
-	 ** color==-3 to draw everything with 0 energy
-	 ** color==-4 to draw according to current palette **/
-	void DrawModule(CbmEcalModule* module, Int_t color);
-
-	/** Sets canvas size according to size of
-	 ** cluster in arr **/
-	void InitCanvas(TObjArray* arr);
-	/** Draws cells from TObjArray
-	 ** color==-2 to draw energy deposition
-	 ** color==-3 to draw everything with 0 energy 
-	 ** color==-4 to draw according to current palette **/
-	void DrawCells(TObjArray* arr, Int_t color);
-	/** Draws cell
-	 ** color==-2 to draw energy deposition
-	 ** color==-3 to draw everything with 0 energy 
-	 ** color==-4 to draw according to current palette **/
-	void DrawCell(CbmEcalCell* cell,Int_t color);
-private:
-	/** Calculates size of cavnas **/
-	void Prepare();
-	/** Creates white canvas **/
-	void InitCanvas(Int_t x, Int_t y);
-	/** Set default color, energy type and
-	 ** maximum energy**/
-	void Init();
-	/** Gets energy from cell corresponding to
-	 ** fEnergyType **/
-	Double_t GetEnergy(CbmEcalCell* cell) const;
-
-	CbmEcalStructure* fEcalStructure;
-	/** Canvas to draw **/
-	TCanvas* fC;
-	/** Size of canvas **/
-	Int_t fCX;
-	Int_t fCY;
-	/** Position of center of cluster **/
-	Float_t fCCX;
-	Float_t fCCY;
-	Double_t fMaxEnergy;
-	TColor fFirstColor;
-	TColor fSecondColor;
-	Int_t fEnergyType;
-
-	std::list<void*> fLines;
-	std::list<void*> fBoxes;
-
-	CbmEcalDrawer(const CbmEcalDrawer&);
-	CbmEcalDrawer& operator=(const CbmEcalDrawer&);
-
-	ClassDef(CbmEcalDrawer,1);
-};
-
-inline void CbmEcalDrawer::SetEnergyType(Int_t energytype)
-{
-	if (energytype<0||energytype>2) return;
-	fEnergyType=energytype;
-}
-
-inline Int_t CbmEcalDrawer::GetEnergyType() const
-{
-	return fEnergyType;
-}
-
-inline Double_t CbmEcalDrawer::GetEnergy(CbmEcalCell* cell) const
-{
-	if (fEnergyType==0) return cell->GetTotalEnergy();
-	if (fEnergyType==1) return cell->GetEnergy();
-	return 0;
-}
-
-inline TColor CbmEcalDrawer::GetFirstColor() const
-{
-	return fFirstColor;
-}
-
-inline TColor CbmEcalDrawer::GetSecondColor() const
-{
-	return fSecondColor;
-}
-
-/** First color used for 0 energy**/
-inline void CbmEcalDrawer::SetFirstColor(TColor color)
-{
-	fFirstColor=color;
-}
-
-/** First color used for maximum energy**/
-inline void CbmEcalDrawer::SetSecondColor(TColor color)
-{
-	fSecondColor=color;
-}
-
-inline Double_t CbmEcalDrawer::GetMaximumEnergy() const
-{
-	return fMaxEnergy;
-}
-
-inline void CbmEcalDrawer::SetMaximumEnergy(Double_t energy)
-{
-	fMaxEnergy=energy;
-}
-
-inline CbmEcalStructure* CbmEcalDrawer::GetEcalStructure() const
-{
-	return fEcalStructure;
-}
-
-inline void CbmEcalDrawer::SetEcalStructure(CbmEcalStructure* ecalStructure)
-{
-	fEcalStructure=ecalStructure;
-}
-
-inline TCanvas* CbmEcalDrawer::GetCanvas() const
-{
-	return fC;
-}
-
-#endif
diff --git a/ecal/CbmEcalDrawer2.cxx b/ecal/CbmEcalDrawer2.cxx
deleted file mode 100644
index ec587e9bedb99589f756bad72a79b3cd6960cdf8..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalDrawer2.cxx
+++ /dev/null
@@ -1,488 +0,0 @@
-/* $Id: CbmEcalDrawer2.cxx,v 1.3 2006/07/14 15:11:51 prokudin Exp $ */
-#include "CbmEcalDrawer2.h"
-
-#include "TH2D.h"
-#include "TCanvas.h"
-#include "TClonesArray.h"
-#include "TMarker.h"
-#include "TLine.h"
-#include "TMath.h"
-#include "TText.h"
-#include "TVector2.h"
-#include "TEllipse.h"
-
-#include "FairRootManager.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalCluster.h"
-
-#include <iostream>
-
-using namespace std;
-
-CbmEcalDrawer2::CbmEcalDrawer2()
-  : FairTask(),
-    fStr(NULL),
-    fC(NULL),
-    fOut(NULL),
-    fEvent(0),
-    fDrawOpt(""),
-    fNamePrefix(""),
-    fMCPoints(NULL),
-    fCluster(),
-    fClusterE(0.),
-    fParI(0),
-    fIntSteps(0),
-    fPar1(0.),
-    fPar2(0.),
-    fPar3(0.)
-{
-  SetDrawOpt();
-  SetNamePrefix();
-}
-	
-CbmEcalDrawer2::CbmEcalDrawer2(const char* name, const char*)
-  : FairTask(name, 0),
-    fStr(NULL),
-    fC(NULL),
-    fOut(NULL),
-    fEvent(0),
-    fDrawOpt(""),
-    fNamePrefix(""),
-    fMCPoints(NULL),
-    fCluster(),
-    fClusterE(0.),
-    fParI(7),
-    fIntSteps(100),
-    fPar1(0.38),
-    fPar2(30.8),
-    fPar3(12.0)
-
-
-{
-  SetDrawOpt();
-  SetNamePrefix();
-}
-
-InitStatus CbmEcalDrawer2::Init()
-{
-  fEvent=0;
-
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Int_t type;
-  FairRootManager* io=FairRootManager::Instance();
-  Double_t x1;
-  Double_t x2;
-  Double_t y1;
-  Double_t y2;
-  Int_t ix;
-  Int_t iy;
-  CbmEcalInf* inf;
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fMCPoints=(TClonesArray*)io->GetObject("EcalPoint");
-  if (!fMCPoints) 
-  {
-    Fatal("Init()", "Can't find calorimeter points in the system.");
-    return kFATAL;
-  }
-
-  fStr->GetCells(cells);
-  type=-1111;
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    if ((*p)==NULL) continue;
-    if ((*p)->GetType()==0) continue;
-    if (type==-1111)
-      type=(*p)->GetType();
-    else
-      if (type!=(*p)->GetType())
-	break;
-  }
-  if (p!=cells.end())
-  {
-    Fatal("Init()","Calorimeter consists of cells with different types.");
-    return kFATAL;
-  }
-  inf=fStr->GetEcalInf();
-  x1=fStr->GetX1();
-  x2=fStr->GetX2();
-  y1=fStr->GetY1();
-  y2=fStr->GetY2();
-  ix=inf->GetXSize(); ix*=type;
-  iy=inf->GetYSize(); iy*=type;
-  fOut=new TH2D("ecal","CBM calorimeter", ix, x1, x2, iy, y1, y2);
-  fOut->SetStats(kFALSE);
-//  fC=new TCanvas("c","", (x2-x1)/(y2-y1)*1000, 1000);
-  fC=new TCanvas("c","", 1000, 1000);
-  fC->SetLeftMargin(0.075);
-  fC->SetRightMargin(0.125);
-
-  return kSUCCESS;
-}
-
-void CbmEcalDrawer2::Exec(Option_t*)
-{
-  const Int_t cNCells=8;
-  fEvent++;
-  TString nm="";
-  Int_t i;
-//  Int_t n;
-  Int_t imax=-1111;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t e;
-  Double_t x;
-  Double_t y;
-  Double_t r;
-  Double_t max=-1111;
-  Double_t efull;
-  Double_t e2m;
-  Double_t e2;
-  Double_t e3;
-  CbmEcalPoint* pt;
-  CbmEcalCell* cl=NULL;
-  TMarker* mk;
-  TMarker* mk2;
-  TString cp;
-  TString st;
-  TLine* ln;
-  TLine* ln2;
-  list<TLine*> lines;
-  list<TLine*>::const_iterator pl;
-  TLine* tl;
-  CbmEcalCell* cls[cNCells];
-  TText* txt[cNCells];
-  TEllipse* el;
-  TVector2 tv;
-  TVector2 tv1;
-  Double_t theta;
-
-  fC->Clear();
-  nm+=fEvent;
-  i=nm.Length();
-  for(;i<7;i++)
-    nm="0"+nm;
-  nm=fNamePrefix+nm;
-  gPad=fC;
-
-  fStr->GetCells(cells);
-  efull=0;
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    if ((*p)==NULL) continue;
-    e=(*p)->GetTotalEnergy();
-    efull+=e;
-    x=(*p)->GetCenterX();
-    y=(*p)->GetCenterY();
-    fOut->SetBinContent(fOut->FindBin(x, y), e);
-    if (e>max)
-    {
-      max=e;
-      cl=(*p);
-    }
-  }
-  if (max<=0.02) return;
-  ConstructCluster(cl);
-  if (fClusterE<0.12) return;
-  cells.sort(CbmEcalClusterSortProcess());
-  cells.reverse(); i=0;
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    cls[i++]=(*p);
-    if (i==cNCells) break;
-  }
-  cl->GetNeighborsList(0, cells);
-//  if (max<0.1) return;
-  for(p=cells.begin();p!=cells.end();++p)
-    if ((*p)==cls[1]) break;
-//  if (p!=cells.end())
-//    return;
-
-  e3=max;
-  for(p=cells.begin();p!=cells.end();++p)
-    e3+=(*p)->GetTotalEnergy();
-  e2=0;
-  for(i=1;i<5;i++)
-  {
-    cl->GetNeighborsList(i, cells);
-    e2m=max;
-    for(p=cells.begin();p!=cells.end();++p)
-      e2m+=(*p)->GetTotalEnergy();
-    if (e2m>e2)
-    { 
-      e2=e2m;
-      imax=i;
-    }
-  }
-  cl->GetNeighborsList(imax, cells);
-  cp="E_{Full}=";
-  st=""; st+=efull; st.ReplaceAll(" ",""); st.ReplaceAll("	",""); st.Remove(6);
-  cp+=st; cp+=", E_{2x2}=";
-  st=""; st+=e2; st.ReplaceAll(" ",""); st.ReplaceAll("	",""); st.Remove(6);
-  cp+=st; cp+="(";
-  st=""; st+=e2/efull*100; st.ReplaceAll(" ",""); st.ReplaceAll("	",""); if (e2!=efull) st.Remove(2); else st.Remove(3);
-  cp+=st; cp+="%), E_{cls}=";
-  st=""; st+=fClusterE; st.ReplaceAll(" ",""); st.ReplaceAll("	",""); st.Remove(6);
-  cp+=st; cp+="(";
-  st=""; st+=fClusterE/efull*100; st.ReplaceAll(" ",""); st.ReplaceAll("	",""); if (e3!=efull) st.Remove(2); else st.Remove(3);
-
-  cp+=st; cp+="%)";
-  fOut->SetTitle(cp);
-  x=cl->GetCenterX();
-  y=cl->GetCenterY();
-  fOut->SetAxisRange(x-15, x+15, "X");
-  fOut->SetAxisRange(y-15, y+15, "Y");
-  fOut->Draw(fDrawOpt);
-//  n=fMCPoints->GetEntriesFast();
-//  for(i=0;i<n;i++)
-  { 
-    pt=(CbmEcalPoint*)fMCPoints->At(0);
-    if (pt!=NULL)
-    {
-      mk=new TMarker(pt->GetX(), pt->GetY(), kFullStar);
-      mk->SetMarkerSize(2);
-      mk->SetMarkerColor(kOrange);
-      mk->Draw();
-      x=pt->GetX();
-      y=pt->GetY();
-      r=TMath::Sqrt(x*x+y*y);
-      x/=r; y/=r;
-      ln=new TLine(pt->GetX()-x*2.0, pt->GetY()-y*2.0, pt->GetX(), pt->GetY());
-      ln->Draw();
-      ln2=new TLine(pt->GetX()+x*12.0, pt->GetY()+y*12.0, pt->GetX(), pt->GetY());
-      ln2->SetLineColor(13);
-      ln2->Draw();
-    }
-    else
-    {
-      mk=NULL;
-      ln2=NULL;
-      ln=NULL;
-    }
-  }
-  for(i=0;i<cNCells;i++)
-  {
-//    cout << cls[i]->GetTotalEnergy() << endl;
-    if (cls[i]->GetTotalEnergy()<=0.0)
-    {
-      txt[i]=NULL;
-      continue;
-    }
-    st=""; st+=i+1;
-    txt[i]=new TText(cls[i]->GetCenterX(), cls[i]->GetCenterY(), st.Data());
-    txt[i]->SetTextAlign(22);
-    txt[i]->Draw();
-  }
-
-  {
-    x=cl->GetCenterX()*cl->GetTotalEnergy(); 
-    y=cl->GetCenterY()*cl->GetTotalEnergy(); 
-
-    for(p=cells.begin();p!=cells.end();++p)
-    {
-      x+=(*p)->GetCenterX()*(*p)->GetTotalEnergy();
-      y+=(*p)->GetCenterY()*(*p)->GetTotalEnergy();
-    }
-    x/=e2;
-    y/=e2;
-    mk2=new TMarker(x, y, kOpenStar);
-    mk2->SetMarkerSize(2);
-    mk2->SetMarkerColor(kOrange);
-    mk2->Draw();
-    tv.Set(x, y); theta=tv.Phi(); tv1=tv;
-    tv1/=tv.Mod();
-    tv+=tv1*fPar1;
-    el=new TEllipse(tv.X(), tv.Y(), TMath::Sqrt(fPar2), TMath::Sqrt(fPar3), 0.0, 360.0, theta*TMath::RadToDeg());
-    el->SetFillColor(0);
-    el->SetFillStyle(0);
-    el->Draw();
-  }
-  
-  lines.clear();
-  for(p=fCluster.begin();p!=fCluster.end();++p)
-  {
-    tl=new TLine((*p)->GetX1(), (*p)->GetY1(), (*p)->GetX2(), (*p)->GetY1());
-    lines.push_back(tl);
-    tl=new TLine((*p)->GetX2(), (*p)->GetY1(), (*p)->GetX2(), (*p)->GetY2());
-    lines.push_back(tl);
-    tl=new TLine((*p)->GetX2(), (*p)->GetY2(), (*p)->GetX1(), (*p)->GetY2());
-    lines.push_back(tl);
-    tl=new TLine((*p)->GetX1(), (*p)->GetY2(), (*p)->GetX1(), (*p)->GetY1());
-    lines.push_back(tl);
-  }
-  for(pl=lines.begin();pl!=lines.end();++pl)
-  {
-    tl=*pl;
-    tl->SetLineColor(kOrange);
-    tl->SetLineWidth(3);
-    tl->Draw();
-  }
-  fC->SaveAs(nm+".png");
-  fC->SaveAs(nm+".C");
-  fC->Clear();
-  delete mk;
-  delete mk2;
-  delete ln;
-  delete ln2;
-  for(i=0;i<cNCells;i++)
-    delete txt[i];
-  delete el;
-  for(pl=lines.begin();pl!=lines.end();++pl)
-    delete (*pl);
-}
-
-void CbmEcalDrawer2::Finish()
-{
-  ;
-}
-
-CbmEcalDrawer2::~CbmEcalDrawer2()
-{
-  fC->Clear();
-  delete fC;
-  fOut->Clear();
-  delete fOut;
-}
-
-void CbmEcalDrawer2::ConstructCluster(CbmEcalCell* max)
-{
-  Int_t i;
-  Int_t j=-1111;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  CbmEcalCell* cell;
-  CbmEcalCell* cll;
-  Double_t e=1e9;
-  Int_t ix;
-  Int_t iy;
-  Double_t tx;
-  Double_t ty;
-  CbmEcalCell* cls[20];
-  Double_t rc[20];
-  Double_t r;
-  Double_t cx;
-  Double_t cy;
-  Double_t me=-1111;
-
-  fCluster.clear();
-
-  cell=max;
-  for(i=1;i<5;i++)
-  {
-    cell->GetNeighborsList(i, cells);
-    e=0;
-    for(p=cells.begin();p!=cells.end();++p)
-      e+=(*p)->GetTotalEnergy();
-    if (e>me)
-    {
-      j=i;
-      me=e;
-    }
-  }
-  me+=cell->GetTotalEnergy();
-  cx=cell->GetTotalEnergy()*cell->GetCenterX();
-  cy=cell->GetTotalEnergy()*cell->GetCenterY();
-  cell->GetNeighborsList(j, cells);
-  for(p=cells.begin();p!=cells.end();++p)
-  {
-    cx+=(*p)->GetTotalEnergy()*(*p)->GetCenterX();
-    cy+=(*p)->GetTotalEnergy()*(*p)->GetCenterY();
-  }
-  cx/=me; cy/=me;
-
-
-  cell=max; e=1e9;
-  for(i=0;i<fParI;i++)
-  {
-    cls[i]=NULL;
-    rc[i]=-1111;
-  }
-
-  for(ix=-4;ix<5;ix++)
-  for(iy=-4;iy<5;iy++)
-  {
-    tx=cell->GetCenterX(); tx+=ix*(cell->X2()-cell->X1());
-    ty=cell->GetCenterY(); ty+=iy*(cell->Y2()-cell->Y1());
-    cll=fStr->GetCell(tx, ty);
-    if (cll==NULL) continue;
-    r=SolveEllipse(cll, cx, cy);
-    for(i=0;i<fParI;i++)
-      if (rc[i]<r)
-	break;
-    if (i==fParI) continue;
-    for(j=fParI-1;j>i;j--)
-    {
-      rc[j]=rc[j-1];
-      cls[j]=cls[j-1];
-    }
-    rc[i]=r;
-    cls[i]=cll;
-  }
-  fClusterE=0;
-  for(j=0;j<fParI;j++)
-  {
-    fCluster.push_back(cls[j]);
-    fClusterE+=cls[j]->GetTotalEnergy();
-  }
-}
-
-Double_t CbmEcalDrawer2::SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy)
-{
-  Double_t cRx=fPar2;		//48*1.6
-  Double_t cRy=fPar3;
-  Int_t cSt=fIntSteps;
-  TVector2 centr(cx, cy);
-  TVector2 t(centr);
-  Double_t gm=centr.Phi();
-  Double_t sgm=TMath::Sin(gm);
-  Double_t cgm=TMath::Cos(gm);
-  Double_t x;
-//  Double_t y;
-  Double_t p=sgm*sgm/cRx+cgm*cgm/cRy;
-  Double_t q=cgm*sgm*(1.0/cRx-1.0/cRy);
-  Double_t r=cgm*cgm/cRx+sgm*sgm/cRy;
-  Double_t d;
-  Double_t ex;
-//  Double_t ey;
-  Double_t y1;
-  Double_t y2;
-  Double_t inte=0;
-  Double_t step=(cell->X2()-cell->X1())/cSt;
-  Double_t fx=step/2.0+cell->X1();
-  Int_t i;
-  
-// cout << fCurAlgo << " " << reg << " " << fPar1[reg] << " " << cRx << " " << cRy << endl;
-  t/=t.Mod(); centr+=t*TMath::Sqrt(fPar1);
-  for(i=0;i<cSt;i++)
-  {
-    x=step; x*=i; x+=fx;
-    ex=x; ex-=centr.X();
-    d=q*q*ex*ex-p*(r*ex*ex-1);
-    if (d<0) continue;
-    d=TMath::Sqrt(d);
-    y1=-q*ex/p; y2=y1;
-    y1-=d/p; y2+=d/p;
-    y1+=centr.Y(); y2+=centr.Y();
-    if (y1>cell->Y2()) continue;
-    if (y2<cell->Y1()) continue;
-    if (y1<cell->Y1()) y1=cell->Y1();
-    if (y2>cell->Y2()) y2=cell->Y2();
-    inte+=(y2-y1)*step;
-  }
-
-  return inte;
-}
-
-ClassImp(CbmEcalDrawer2);
diff --git a/ecal/CbmEcalDrawer2.h b/ecal/CbmEcalDrawer2.h
deleted file mode 100644
index 692b08effc81cb176869a3a372a1fbf843764b53..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalDrawer2.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* $Id: CbmEcalDrawer2.h,v 1.3 2006/07/14 15:11:51 prokudin Exp $ */
-/** CbmEcalDrawer2 
- ** ECAL drawer. Only for calorimeters with constant granularity
- ** Use TH2D for drawing
- **/
-#ifndef CBMECALDRAWER2_H
-#define CBMECALDRAWER2_H
-
-#include "FairTask.h"
-
-#include <list>
-
-class CbmEcalStructure;
-class TH2D;
-class TCanvas;
-class CbmEcalCell;
-
-class CbmEcalDrawer2: public FairTask
-{
-public:
-  /** Default constructor **/
-  CbmEcalDrawer2();
-  CbmEcalDrawer2(const char* name, const char* title="ECAL drawer");
-  virtual ~CbmEcalDrawer2();
-  virtual InitStatus Init();
-  virtual void Exec(Option_t* option);
-  virtual void Finish();
-  void SetDrawOpt(const char* opt="colz") {fDrawOpt=opt;}
-  void SetNamePrefix(const char* prefix="ecal") {fNamePrefix=prefix;}
-private:
-  CbmEcalStructure* fStr;			//!
-  /** Canvas to draw **/
-  TCanvas* fC;					//!
-  TH2D* fOut;					//!
-  Int_t fEvent;
-  TString fDrawOpt;
-  TString fNamePrefix;
-  TClonesArray* fMCPoints;			//!
-
-  Double_t SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy);
-  void ConstructCluster(CbmEcalCell* max);
-  std::list<CbmEcalCell*> fCluster;		//!
-  Double_t fClusterE;
-  Int_t fParI;
-  Int_t fIntSteps;
-  Double_t fPar1;
-  Double_t fPar2;
-  Double_t fPar3;
-
-  CbmEcalDrawer2(const CbmEcalDrawer2&);
-  CbmEcalDrawer2& operator=(const CbmEcalDrawer2&);
-
-  ClassDef(CbmEcalDrawer2,1);
-};
-
-#endif
diff --git a/ecal/CbmEcalHitProducer.cxx b/ecal/CbmEcalHitProducer.cxx
deleted file mode 100644
index c073b5eee7b8bb534380bba26a7196c82611250a..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalHitProducer.cxx
+++ /dev/null
@@ -1,360 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                   CbmEcalHitProducer source file              -----
-// -----               Created 11/03/05  by Yu.Kharlov                 -----
-// -------------------------------------------------------------------------
-
-/* $Id: CbmEcalHitProducer.cxx,v 1.14 2006/07/29 00:33:53 prokudin Exp $ */
-
-#include "CbmEcalHitProducer.h"
-
-#include "CbmEcal.h"
-#include "CbmEcalCellMC.h"
-#include "CbmEcalPointLite.h"
-#include "CbmEcalHit.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "TVector3.h"
-#include "TRandom.h"
-
-#include <iostream>
-#include <iomanip>
-#include <vector>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::flush;
-using std::map;
-using std::vector;
-
-// -----   Default constructor   -------------------------------------------
-CbmEcalHitProducer::CbmEcalHitProducer() 
-  : FairTask(),
-    fStr(NULL),
-    fInf(NULL),
-    fListECALpts(NULL),
-    fListUHits(NULL),
-    fListHits(NULL),
-    fHitCollection(NULL),
-    fListStack(NULL),
-    fNHits(0),
-    fEvent(0),
-    fInited(kFALSE),
-    fUseMCPoints(kFALSE),
-    fUseSummableHits(kFALSE),
-    fUseUnSummableHits(kFALSE),
-    fThreshold(0.),
-    fThresholdPS(0.),
-    fNoise(0.),
-    fNoisePS(0.),
-    fFileGeo(""),
-    fProduceSummableHits(kTRUE),
-    fStandAlone(kTRUE),
-    fEcalBinSize(-1.),
-    fPSBinSize(-1.),
-    fProduceHits(kTRUE)
-{
-}
-// -------------------------------------------------------------------------
-
-// -----   Standard constructor   -------------------------------------------
-CbmEcalHitProducer::CbmEcalHitProducer(const char *name, const Int_t iVerbose, const char* fileGeo) 
-  : FairTask(name,iVerbose),
-    fStr(NULL),
-    fInf(CbmEcalInf::GetInstance(fileGeo)),
-    fListECALpts(NULL),
-    fListUHits(NULL),
-    fListHits(NULL),
-    fHitCollection(NULL),
-    fListStack(NULL),
-    fNHits(0),
-    fEvent(0),
-    fInited(kFALSE),
-    fUseMCPoints(kFALSE),
-    fUseSummableHits(kFALSE),
-    fUseUnSummableHits(kFALSE),
-    fThreshold(0.),
-    fThresholdPS(0.),
-    fNoise(0.),
-    fNoisePS(0.),
-    fFileGeo(fileGeo),
-    fProduceSummableHits(kTRUE),
-    fStandAlone(kTRUE),
-    fEcalBinSize(-1.),
-    fPSBinSize(-1.),
-    fProduceHits(kTRUE)
-{
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcalHitProducer::~CbmEcalHitProducer()
-{
-  FairRootManager *fManager =FairRootManager::Instance();
-  fManager->Write();
-}
-// -------------------------------------------------------------------------
-
-void CbmEcalHitProducer::SetParContainers()
-{
-  ;
-}
-
-// -----   Initialization   ------------------------------------------------
-InitStatus CbmEcalHitProducer::Init()
-{
-  fInited=kTRUE;
-  FairRootManager* fManager = FairRootManager::Instance();
-
-  if (fUseMCPoints==kFALSE&&fUseSummableHits==kFALSE&&fUseUnSummableHits==kFALSE)
-  {
-    cerr << "Hit producer need some data source!!!" << endl;
-    cerr << "Use CbmEcalHitProducer::SummableHitProducer() to produce summable hits" << endl;
-    cerr << "Or CbmEcalHitProducer::UnSummableHitProducer() to produce unsummable hits." << endl;
-    return kFATAL;
-  }
-  //ECAL MC points
-  if (fUseMCPoints) 
-    fListECALpts = (TClonesArray*)fManager->GetObject("EcalPointLite");
-
-  //ECAL Summable hits
-  if (fUseSummableHits) 
-    fListHits = (TClonesArray*)fManager->GetObject("EcalSumHit");
-  
-  //ECAL UnSummable hits
-  if (fUseUnSummableHits) 
-    fListUHits = (TClonesArray*)fManager->GetObject("EcalHit");
-  
-  // all tracks
-  fListStack = (TClonesArray *)fManager->GetObject("MCTrack");
-  fHitCollection = new TClonesArray("CbmEcalHit",100);
-  if (fProduceHits)
-  {
-    if (fProduceSummableHits)
-      fManager->Register("EcalSumHit","ECAL",fHitCollection,IsOutputBranchPersistent("EcalSumHit"));
-    else
-      fManager->Register("EcalHit","ECAL",fHitCollection,IsOutputBranchPersistent("EcalHit"));
-  }
-  else
-  {
-    if (fProduceSummableHits)
-      fManager->Register("EcalSumHit","ECAL",fHitCollection,IsOutputBranchPersistent("EcalSumHit"));
-    else
-      fManager->Register("EcalHit","ECAL",fHitCollection,IsOutputBranchPersistent("EcalHit"));
-  }
-
-  if (fStandAlone)
-  {
-    fInf->CheckVariables();
-    fStr=new CbmEcalStructure(fInf);
-    fStr->Construct();
-  }
-  else
-  {
-    fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-    if (!fStr) 
-    {
-      Fatal("Init()", "Can't find calorimeter structure in the system.");
-      return kFATAL;
-    }
-    fInf=fStr->GetEcalInf();
-  }
-  
-  return kSUCCESS;
-}
-// -------------------------------------------------------------------------
-
-/** Loop over MCPoints hits and add them to cells **/
-void CbmEcalHitProducer::LoopForMCPoints()
-{
-  CbmEcalPointLite* pt=NULL;
-  CbmEcalCell* cell;
-  Int_t ten;
-  UInt_t n;
-  Bool_t isPS;
-
-  n=fListECALpts->GetEntriesFast();
-  if (fVerbose>0)
-  {
-    cout << ". Number of input MC points: ";
-    cout << n << flush;
-  }
-  if (fProduceSummableHits==kFALSE)
-    for(UInt_t j=0; j<n; j++)
-    {
-      pt = (CbmEcalPointLite*)fListECALpts->At(j);
-      cell=fStr->GetCell(pt->GetDetectorID(), ten, isPS);
-      if (ten==0)
-      {
-        if (isPS) ; // cell->AddPSEnergy(pt->GetEnergyLoss());  Preshower removed
-        else
-          cell->AddEnergy(pt->GetEnergyLoss());
-      }
-    }
-  else
-    for(UInt_t j=0; j<n; j++)
-      {
-        CbmEcalCellMC* cellmc;
-        pt = (CbmEcalPointLite*)fListECALpts->At(j);
-        cellmc=(CbmEcalCellMC*)fStr->GetCell(pt->GetDetectorID(), ten, isPS);
-        if (ten==0)
-	{
-          if (isPS) ; // cell->AddTrackPSEnergy(pt->GetTrackID(),pt->GetEnergyLoss()); Preshower removed
-            else cellmc->AddTrackEnergy(pt->GetTrackID(),pt->GetEnergyLoss());
-	}
-      } 
-}
-
-/** Loop over summable hits and add them to cells **/
-void CbmEcalHitProducer::LoopForSummableHits()
-{
-  CbmEcalHit* pt=NULL;
-  CbmEcalCell* cell;
-  Int_t n;
-
-  n=fListHits->GetEntriesFast();
-  if (fVerbose>0)
-  {
-    cout << ". Number of input summable hits: ";
-    cout << n << flush;
-  }
-  if (fProduceSummableHits==kFALSE)
-  for(Int_t j=0; j<n; j++)
-  {
-    pt = (CbmEcalHit*)fListHits->At(j);
-    cell=fStr->GetHitCell(pt->GetDetectorId());
-    cell->AddEnergy(pt->GetEnergy());
-  } else
-  for(Int_t j=0; j<n; j++)
-  {
-    CbmEcalCellMC* cellmc;
-    pt = (CbmEcalHit*)fListHits->At(j);
-    cellmc=(CbmEcalCellMC*)fStr->GetHitCell(pt->GetDetectorId());
-    cellmc->AddTrackEnergy(pt->GetTrackId(), pt->GetEnergy());
-  }
-}
-
-/** Loop over hits and add them to cells **/
-void CbmEcalHitProducer::LoopForUnSummableHits()
-{
-	CbmEcalHit* pt=NULL;
-	CbmEcalCell* cell;
-	Int_t n;
-
-	n=fListUHits->GetEntriesFast();
-	if (fVerbose>0)
-	{
-  	  cout << ". Number of input unsummable hits: ";
-          cout << n << flush;
-	}
-	for(Int_t j=0; j<n; j++)
-	{
-        	pt = (CbmEcalHit*)fListUHits->At(j);
-		cell=fStr->GetHitCell(pt->GetDetectorId());
-		cell->AddEnergy(pt->GetEnergy());
-//		cell->AddPSEnergy(pt->GetPSEnergy());
-
-	}
-}
-
-/** Adds hits to the hit collection from information
- ** from cell **/
-void CbmEcalHitProducer::CellToHits(CbmEcalCell* cell)
-{
-  Float_t energy;
-  Float_t psenergy=0;
-  Int_t ebins;
-//  Int_t psbins;
-  if (fProduceSummableHits==kFALSE)
-  {
-    if (fNoise>0)
-      energy=cell->GetEnergy()+gRandom->Gaus(0,fNoise);
-    else
-      energy=cell->GetEnergy();
-
-    if (fEcalBinSize>0)
-    {
-      ebins=(Int_t)(energy/fEcalBinSize);
-      if (energy<0) ebins--;
-      energy=ebins*fEcalBinSize;
-    }
-
-    if (energy<fThreshold) energy=0;
-    cell->SetEnergy(energy);
-    if (fProduceHits)
-    if (energy!=0||psenergy!=0)
-      AddHit(cell->GetCellNumber(),energy,psenergy, -1, cell->GetTime());
-  }
-  else
-  {
-    CbmEcalCellMC* cellmc=(CbmEcalCellMC*)cell;
-    map<Int_t, Float_t>::const_iterator p=cellmc->GetTrackEnergyBegin();
-    for(;p!=cellmc->GetTrackEnergyEnd();++p)
-    {
-      energy=p->second;
-      AddHit(cellmc->GetCellNumber(),energy,psenergy, p->first, cellmc->GetTrackTime(p->first));
-    }
-  }
-}
-// -----   Execution of Task   ---------------------------------------------
-void CbmEcalHitProducer::Exec(Option_t*)
-{
-
-  vector<CbmEcalModule*>::const_iterator p;
-  vector<CbmEcalModule*> modules;
-  CbmEcalModule* module;
-  vector<CbmEcalCell*> cells;
-
-  fEvent++;
-  if (fVerbose>0)
-    cout << "--> Event no. " << fEvent;
-
-  fHitCollection->Clear();
-  fNHits = 0;
-  UInt_t i;
-
-  if (fStandAlone)
-  {
-    fStr->ResetModules();
-    if (fUseMCPoints) LoopForMCPoints();
-    if (fUseSummableHits) LoopForSummableHits();
-    if (fUseUnSummableHits) LoopForUnSummableHits();
-  }
-
-  if (fVerbose>0)
-    cout << endl << flush;
-  fStr->GetStructure(modules);
-  for(p=modules.begin();p!=modules.end();++p)
-  {
-    module=*p;
-    if (module)
-    {
-      cells=module->GetCells();
-      for(i=0;i<cells.size();i++)
-          CellToHits(cells[i]);
-    }
-  }
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Add Hit to HitCollection   --------------------------------------
-void CbmEcalHitProducer::AddHit(Int_t cellnumber, Float_t energy, Float_t psenergy, Int_t trackID, Double32_t time)
-{
-  new((*fHitCollection)[fNHits++]) CbmEcalHit(cellnumber,energy,psenergy,trackID,time); //No time information at the moment
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Finish Task   ---------------------------------------------------
-void CbmEcalHitProducer::Finish()
-{
-  fHitCollection->Clear();
-}
-// -------------------------------------------------------------------------
-
-
-ClassImp(CbmEcalHitProducer)
diff --git a/ecal/CbmEcalHitProducer.h b/ecal/CbmEcalHitProducer.h
deleted file mode 100644
index c1b39b109c2c168a6033c5b0a1415c883991b410..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalHitProducer.h
+++ /dev/null
@@ -1,353 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalHitProducer header file               -----
-// -----                  Created 10/03/05  by Yu.Kharlov              -----
-// -------------------------------------------------------------------------
-
-
-/* $Id: CbmEcalHitProducer.h,v 1.8 2006/07/24 21:45:02 prokudin Exp $ */
-
-/**  CbmEcalHitProducer.h
- *@author Yu.Kharlov
- **
- ** Class for producing either ECAL hits
- ** or ECAL summable hits from MCPoints,
- **  Definitions:
- ** ECAL hit is total deposited energy by all track in ECAL cell
- ** ECAL summable hit is a deposited energy by each tracks in ECAL cell
- **  Use cases:
- **
- ** 1. To produce hits from MC points:
- ** CbmEcalHitProducer* hp=new CbmEcalHitProducer("EcalHitProducer");
- ** hp->SetMCPoints2Hits();
- ** fRun->AddTask(hp);
- **
- ** 2. To produce summable hits from MC points:
- ** CbmEcalHitProducer* hp=new CbmEcalHitProducer("EcalHitProducer");
- ** hp->SetMCPoints2SumHits();
- ** fRun->AddTask(hp);
- **
- ** 3. To produce hits from summable hits:
- ** CbmEcalHitProducer* hp=new CbmEcalHitProducer("EcalHitProducer");
- ** hp->SetSumHits2Hits();
- ** fRun->AddTask(hp);
- **/
-
-/* History of cvs commits:
- *
- * $Log: CbmEcalHitProducer.h,v $
- * Revision 1.8  2006/07/24 21:45:02  prokudin
- * Now we write information to parameter file
- *
- * Revision 1.7  2006/07/19 12:31:54  prokudin
- * Commenting
- *
- * Revision 1.6  2006/07/19 11:49:39  prokudin
- * Commenting, optimizing hitproducer
- *
- * Revision 1.5  2006/07/18 20:38:36  prokudin
- * MCPointsToUHits() Added. Corrected for fVerbose
- *
- * Revision 1.4  2006/07/13 14:42:45  prokudin
- * New version of hit producer
- *
- * Revision 1.3  2006/04/25 06:52:18  kharlov
- * Remove CbmEcalv[1,2] and leave the only class CbmEcal
- *
- */
-
-#ifndef CBMECALHITPRODUCER_H
-#define CBMECALHITPRODUCER_H
-
-#include "CbmEcalHit.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalStructure.h"
-
-#include "FairTask.h"
-#include "CbmStack.h"
-
-#include "TClonesArray.h"
-#include "TString.h"
-#include "TVector3.h"
-
-class CbmEcalHitProducer : public FairTask {
-
-public:
-
-  /** Default constructor **/
-  CbmEcalHitProducer();
-
-  /** Standard constructor **/
-  CbmEcalHitProducer(const char *name, const Int_t iVerbose=1, const char* fileGeo="ecal_FastMC.geo");
-
-  /** Destructor **/
-  virtual ~CbmEcalHitProducer();
-
-  /** Initialization of the task **/  
-  virtual InitStatus Init();
-
-  /** Executed task **/ 
-  virtual void Exec(Option_t* option);
-
-  /** Finish task **/ 
-  virtual void Finish();
-
-  /** Process MCPoints to summable hits (hits per individual track)
-   ** MCPoints -> Summable hits **/
-  void SetMCPoints2SumHits();
-  /** Process summable hits to hits
-   ** Summable sits -> Hits **/
-  void SetSumHits2Hits();
-  /** Process MCPoints directly to hits (hits for all tracks)
-   ** MCPoints -> Hits **/
-  void SetMCPoints2Hits();
-
-  /** Set noise for ECAL (GeV) **/
-  void SetNoise(Float_t noise);
-  /** Set noise for PS (GeV)**/
-  void SetPSNoise(Float_t noiseps);
-
-  Float_t GetNoise() const;
-  Float_t GetPSNoise() const;
-
-  /** Set threshold for ECAL (GeV)**/
-  void SetThreshold(Float_t threshold);
-  /** Set threshold for PS (GeV)**/
-  void SetPSThreshold(Float_t thresholdps);
-
-  Float_t GetThreshold() const;
-  Float_t GetPSThreshold() const;
-
-  /** Sets type of output hits. If UseHits is set, only
-   ** unsummable hits can be produced
-   ** kTRUE --- produce summable hits
-   ** kFALSE --- produce unsummable hits **/
-  void SetProduceSummableHits(Bool_t ProduceSummableHits);
-
-  /** method AddHit
-   **
-   ** Adds a EcalHit to the HitCollection
-   **/
-  //Using x and y is deprecated! Will be removed in time!
-  void AddHit(Int_t cellnumber, Float_t energy, Float_t psenergy, Int_t trackID, Double32_t time=0);
-
-  /** Set data source for hit producer.
-   ** This must be called before Init()
-   ** (No effect other case)! **/
-  void SetUseMCPoints(Bool_t UseMCPoints);
-  void SetUseSummableHits(Bool_t UseSummableHits);
-  /** Can be set kTRUE only if ProduceSummableHits false **/
-  void SetUseHits(Bool_t UseHits);
-
-  Bool_t GetUseMCPoints() const;
-  Bool_t GetUseSummableHits() const;
-  Bool_t GetUseHits() const;
- 
-  Bool_t GetProduceSummableHits() const;
-
-  /** Get/set stand alone status **/
-  inline Bool_t StandAlone() const {return fStandAlone;}
-  inline void SetStandAlone(Bool_t alone) {fStandAlone=alone;} 
-
-  /** Get/set digitizer bin sizes **/
-  inline Float_t GetEcalBinSize() const {return fEcalBinSize;}
-  inline void SetEcalBinSize(Float_t binsize) {fEcalBinSize=binsize;}
-
-  inline Float_t GetPSBinSize() const {return fPSBinSize;}
-  inline void SetPSBinSize(Float_t binsize) {fPSBinSize=binsize;}
-
-  inline Bool_t ProduceHits() const {return fProduceHits;}
-  inline void SetProduceHits(Bool_t produce) {fProduceHits=produce;} 
-protected:
-
-private:
-  /** Init parameter containers **/
-  void SetParContainers();
-  /** Loop over MCPoints **/
-  void LoopForMCPoints();
-  /** Loop over summable hits **/
-  void LoopForSummableHits();
-  /** Loop over hits **/
-  void LoopForUnSummableHits();
-  /** Gets hits from cell **/
-  void CellToHits(CbmEcalCell* cell);
-  CbmEcalStructure* fStr;
-  CbmEcalInf* fInf;		//ECAL geometry container
-
-  TClonesArray* fListECALpts;   // ECAL MC points
-  TClonesArray* fListUHits;	// ECAL hits
-  TClonesArray* fListHits;	// ECAL summable hits
-  TClonesArray* fHitCollection;	// ECAL output hits
-  TClonesArray* fListStack;     // Tracks
-  Int_t fNHits;                 // Number of hits
-  Int_t fEvent;                 //! Internal event counter
-
-  /** Is Init() already done? **/
-  Bool_t fInited;
-  /** Should we take data from MCPoints? **/
-  Bool_t fUseMCPoints;
-  /** Should we take data from summable hits? **/
-  Bool_t fUseSummableHits;
-  /** Should we take data from hits? **/
-  Bool_t fUseUnSummableHits;
-
-  /** Threshold for ECAL **/
-  Float_t fThreshold;
-  /** Threshold for PS **/
-  Float_t fThresholdPS;
-  /** Noise in ECAL **/
-  Float_t fNoise;
-  /** Noise in PS **/
-  Float_t fNoisePS;
-
-  /** Geo file to use **/
-  TString fFileGeo;
-  /** Should we produce summable hits?**/
-  Bool_t fProduceSummableHits;
-
-  /** Hit producer works in stand alone mode? **/
-  Bool_t fStandAlone;
-  /** Digitization bin size for calorimter and PS **/
-  Float_t fEcalBinSize;
-  Float_t fPSBinSize;
-  /** Should we produce hits or just modify calorimter
-   ** structure content **/
-  Bool_t fProduceHits;
-
-  CbmEcalHitProducer(const CbmEcalHitProducer&);
-  CbmEcalHitProducer& operator=(const CbmEcalHitProducer&);
-
-  ClassDef(CbmEcalHitProducer,1)
-
-};
-
-/** Process MCPoints directly to hits (hits for all tracks)
- ** MCPoints -> Hits **/
-inline void CbmEcalHitProducer::SetMCPoints2Hits()
-{
-	if (fInited) return;
-	fUseMCPoints=kTRUE;
-	fUseSummableHits=kFALSE;
-	fUseUnSummableHits=kFALSE;
-	fProduceSummableHits=kFALSE;
-}
-
-/** Process MCPoints to summable hits (hits per individual track)
- ** MCPoints -> Summable hits **/
-inline void CbmEcalHitProducer::SetMCPoints2SumHits()
-{
-	if (fInited) return;
-	fUseMCPoints=kTRUE;
-	fUseSummableHits=kFALSE;
-	fUseUnSummableHits=kFALSE;
-	fProduceSummableHits=kTRUE;
-}
-
-/** Process summable hits to hits
- ** Summable hits -> Hits **/
-inline void CbmEcalHitProducer::SetSumHits2Hits()
-{
-	if (fInited) return;
-	fUseMCPoints=kFALSE;
-	fUseSummableHits=kTRUE;
-	fUseUnSummableHits=kFALSE;
-	fProduceSummableHits=kFALSE;
-}
-
-
-/** Set noise for ECAL (GeV) **/
-inline void CbmEcalHitProducer::SetNoise(Float_t noise)
-{
-	fNoise=noise;
-}
-
-/** Set noise for PS (GeV)**/
-inline void CbmEcalHitProducer::SetPSNoise(Float_t noiseps)
-{
-	fNoisePS=noiseps;
-}
-
-inline Float_t CbmEcalHitProducer::GetNoise() const
-{
-	return fNoise;
-}
-
-inline Float_t CbmEcalHitProducer::GetPSNoise() const
-{
-	return fNoisePS;
-}
-
-/** Set threshold for ECAL (GeV)**/
-inline void CbmEcalHitProducer::SetThreshold(Float_t threshold)
-{
-	fThreshold=threshold;
-}
-/** Set threshold for PS (GeV)**/
-inline void CbmEcalHitProducer::SetPSThreshold(Float_t thresholdps)
-{
-	fThresholdPS=thresholdps;
-}
-
-inline Float_t CbmEcalHitProducer::GetThreshold() const
-{
-	return fThreshold;
-}
-
-inline Float_t CbmEcalHitProducer::GetPSThreshold() const
-{
-	return fThresholdPS;
-}
-
-inline void CbmEcalHitProducer::SetUseMCPoints(Bool_t UseMCPoints)
-{
-	if (fInited) return;
-	fUseMCPoints=UseMCPoints;
-}
-
-inline void CbmEcalHitProducer::SetUseSummableHits(Bool_t UseSummableHits)
-{
-	if (fInited) return;
-	fUseSummableHits=UseSummableHits;
-}
-
-/** Can be set only if ProduceSummableHits false **/
-inline void CbmEcalHitProducer::SetUseHits(Bool_t UseHits)
-{
-	if (fInited) return;
-	if (UseHits==kTRUE&&fProduceSummableHits==kTRUE)
-		return;
-	fUseUnSummableHits=UseHits;
-}
-
-/** Sets type of output hits. If UseHits is set, only
- ** unsummable hits can be produced
- ** kTRUE --- produce summable hits
- ** kFALSE --- produce unsummable hits **/
-inline void CbmEcalHitProducer::SetProduceSummableHits(Bool_t ProduceSummableHits)
-{
-	if (fInited) return;
-	if (fUseUnSummableHits==kTRUE&&ProduceSummableHits==kTRUE)
-		return;
-	fProduceSummableHits=ProduceSummableHits;
-}
-
-inline Bool_t CbmEcalHitProducer::GetUseMCPoints() const
-{
-	return fUseMCPoints;
-}
-
-inline Bool_t CbmEcalHitProducer::GetUseSummableHits() const
-{
-	return fUseSummableHits;
-}
-
-inline Bool_t CbmEcalHitProducer::GetUseHits() const
-{
-	return fUseUnSummableHits;
-}
-
-inline Bool_t CbmEcalHitProducer::GetProduceSummableHits() const
-{
-	return fProduceSummableHits; 
-}
-
-#endif
diff --git a/ecal/CbmEcalHitProducerFastMC.cxx b/ecal/CbmEcalHitProducerFastMC.cxx
deleted file mode 100644
index de558e206550fe24806200bf7db1fb00094ed2e8..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalHitProducerFastMC.cxx
+++ /dev/null
@@ -1,207 +0,0 @@
-// -------------------------------------------------------------------------
-// -----               CbmEcalHitProducerFastMC source file                  -----
-// -----               Created 11/07/05  by Yu.Kharlov                 -----
-// -------------------------------------------------------------------------
-
-  /* $Id: CbmEcalHitProducerFastMC.cxx,v 1.1 2006/06/22 06:55:01 kharlov Exp $ */
-
-  /* History of cvs commits:
-   *
-   * $Log: CbmEcalHitProducerFastMC.cxx,v $
-   * Revision 1.1  2006/06/22 06:55:01  kharlov
-   * Newly added classes for Fas-MC hit producer
-   *
-   */
-
-/**  CbmEcalHitProducerFastMC.cxx
- *@author Yu.Kharlov
- **
- ** Class for producing ECAL hits from MCPoints
- ** It takes a list of EcalPoints produced by CbmEcal and
- ** converts it to a list of EcalHits with smeared energy
- ** and position.
- **/
-#include "CbmEcalHitProducerFastMC.h"
-
-#include "CbmEcalPoint.h"
-#include "CbmEcalHitFastMC.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "TVector3.h"
-#include "TRandom.h"
-
-#include <iostream>
-
-using std::cout;
-using std::endl;
-
-
-// -----   Default constructor   -------------------------------------------
-CbmEcalHitProducerFastMC::CbmEcalHitProducerFastMC() 
-  : FairTask(), 
-    fA(0.),
-    fB(0.),
-    fC(0.),
-    fCellSize(0.),
-    fEThreshold(0.),
-    fRegionXm(),
-    fRegionYm(),
-    fListECALpts(NULL),
-    fHitCollection(NULL),
-    fListStack(NULL),
-    fNHits(0),
-    fEvent(0)
-{
-}
-// -------------------------------------------------------------------------
-
-// -----   Standard constructor   -------------------------------------------
-CbmEcalHitProducerFastMC::CbmEcalHitProducerFastMC(const char *name, const Int_t iVerbose) 
-  : FairTask(name,iVerbose),
-    fA(0.02),
-    fB(0.05),
-    fC(0.005),
-    fCellSize(12.),
-    fEThreshold(0.5),
-    fRegionXm(),
-    fRegionYm(),
-    fListECALpts(NULL),
-    fHitCollection(NULL),
-    fListStack(NULL),
-    fNHits(0),
-    fEvent(0)
-{
-  // Set energy resolution parameters, zone sizes, energy threshold
-  fRegionXm[0] = 5;     // ECAL hole 5x5 modules
-  fRegionYm[0] = 5;
-  fRegionXm[1] = 33;    // ECAL inner zone 33x27 modules
-  fRegionYm[1] = 27;
-  fRegionXm[2] = 57;    // ECAL middle zone 57x49 modules
-  fRegionYm[2] = 49;
-  fRegionXm[3] = 99;    // ECAL outer zone 99x79 modules
-  fRegionYm[3] = 79;
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcalHitProducerFastMC::~CbmEcalHitProducerFastMC()
-{
-  FairRootManager *fManager =FairRootManager::Instance();
-  fManager->Write();
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Initialization   ------------------------------------------------
-InitStatus CbmEcalHitProducerFastMC::Init()
-{
-  FairRootManager* fManager = FairRootManager::Instance();
-
-  // ECAL MC points
-  fListECALpts = (TClonesArray*)fManager->GetObject("EcalPoint");
-  // all tracks
-  fListStack = (TClonesArray *)fManager->GetObject("MCTrack");
-  // new list of ECAL hits
-  fHitCollection = new TClonesArray("CbmEcalHitFastMC",100);
-  fManager->Register("EcalHitFastMC","ECAL",fHitCollection,IsOutputBranchPersistent("EcalHitFastMC"));
-  return kSUCCESS;
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Execution of Task   ---------------------------------------------
-void CbmEcalHitProducerFastMC::Exec(Option_t*)
-{
-  // Convert EcalPoints for photons into hits:
-  // energy is smeared according to energy resolution,
-  // position is smeared with 3 different position resolution for each sone
-  // only photons with smeared energy are accepted
-
-  CbmEcalPoint* pt=NULL;
-
-  fEvent++;
-  printf("\n\n=====> Event no. %d\n",fEvent);
-
-  cout<<"Number of input MC points: "<<fListECALpts->GetEntries()<<endl;
-
-  fHitCollection->Clear();
-  fNHits = 0;
-
-  TVector3 posPoint;
-  Double_t x,y,E, xResolution;
-  for(Int_t j=0; j<fListECALpts->GetEntries(); j++) {
-    pt = (CbmEcalPoint*)fListECALpts->At(j);
-    pt->Position(posPoint);
-    Int_t trackID = pt->GetTrackID(); 
-    CbmMCTrack *track= (CbmMCTrack*) fListStack->At(trackID);
-    Int_t pdgCode = track->GetPdgCode();
-    E = pt->GetEnergyLoss();
-    x = posPoint.X();
-    y = posPoint.Y();
-    Int_t cellX = (Int_t)(TMath::Abs(x)/fCellSize);
-    Int_t cellY = (Int_t)(TMath::Abs(y)/fCellSize);
-    if ((cellX<=fRegionXm[0]/2&&cellY<=fRegionYm[0]/2)||cellX>fRegionXm[3]/2||cellY>fRegionYm[3]/2) continue; // in the hole
-
-    if (pdgCode == 22 || TMath::Abs(pdgCode) == 11) { // photon or e+-
-      xResolution = 0.0;
-      if      (cellX<=fRegionXm[1]/2 && cellY<=fRegionXm[1]/2) xResolution=0.3;
-      else if (cellX<=fRegionXm[2]/2 && cellY<=fRegionXm[2]/2) xResolution=0.6;
-      else if (cellX<=fRegionXm[3]/2 && cellY<=fRegionXm[3]/2) xResolution=2.0;
-      x = gRandom->Gaus(x,xResolution);
-      y = gRandom->Gaus(y,xResolution);
-      E = gRandom->Gaus(E,Eresolution(E));
-    }
-    else {                                            // hadron
-      xResolution = 0.0;
-      if      (cellX<=fRegionXm[1]/2 && cellY<=fRegionXm[1]/2) xResolution=1.0;
-      else if (cellX<=fRegionXm[2]/2 && cellY<=fRegionXm[2]/2) xResolution=2.0;
-      else if (cellX<=fRegionXm[3]/2 && cellY<=fRegionXm[3]/2) xResolution=10.0;
-      x = gRandom->Gaus(x,xResolution);
-      y = gRandom->Gaus(y,xResolution);
-      E = HadronResponse(E);
-    }
-    if (E>fEThreshold) AddHit(x,y,E);
-  }   // loop over input points
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Add Hit to HitCollection   --------------------------------------
-void CbmEcalHitProducerFastMC::AddHit(Double_t x, Double_t y, Double_t E)
-{
-  // Add this hit to the list of ECAL hits
-  new((*fHitCollection)[fNHits]) CbmEcalHitFastMC(x,y,E);
-  fNHits++;
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Finish Task   ---------------------------------------------------
-void CbmEcalHitProducerFastMC::Finish()
-{
-  fHitCollection->Clear();
-}
-// -------------------------------------------------------------------------
-
-// -----   Energy resolution  ----------------------------------------------
-Double_t CbmEcalHitProducerFastMC::Eresolution(Double_t E)
-{
-  // energy resolution vs energy
-  return TMath::Sqrt(fA*fA + fB*fB*E + fC*fC*E*E);
-}
-// -------------------------------------------------------------------------
-
-// -----   Energy deposited in ECAL by hadrons  ----------------------------
-Double_t CbmEcalHitProducerFastMC::HadronResponse(Double_t)
-{
-  // energy resolution vs energy
-  Double_t energy = 0.2;
-  return energy;
-}
-// -------------------------------------------------------------------------
-
-
-ClassImp(CbmEcalHitProducerFastMC)
diff --git a/ecal/CbmEcalHitProducerFastMC.h b/ecal/CbmEcalHitProducerFastMC.h
deleted file mode 100644
index 5b316413bbd9e8d1b2a0645706d8e8aeccd607b3..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalHitProducerFastMC.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalHitProducerFastMC header file               -----
-// -----                  Created 20/06/06  by Yu.Kharlov              -----
-// -------------------------------------------------------------------------
-
-  /* $Id: CbmEcalHitProducerFastMC.h,v 1.1 2006/06/22 06:55:01 kharlov Exp $ */
-
-  /* History of cvs commits:
-   *
-   * $Log: CbmEcalHitProducerFastMC.h,v $
-   * Revision 1.1  2006/06/22 06:55:01  kharlov
-   * Newly added classes for Fas-MC hit producer
-   *
-   */
-
-/**  CbmEcalHitProducerFastMC.h
- *@author Yu.Kharlov
- **
- ** Class for producing ECAL hits from MCPoints for Fast MC
- **/
-
-
-#ifndef CBMECALHITPRODUCERFASTMC_H
-#define CBMECALHITPRODUCERFASTMC_H
-
-#include "CbmEcalHit.h"
-
-#include "FairTask.h"
-#include "CbmStack.h"
-
-#include "TClonesArray.h"
-
-class CbmEcalHitProducerFastMC : public FairTask {
-
-public:
-
-  /** Default constructor **/
-  CbmEcalHitProducerFastMC();
-
-  /** Standard constructor **/
-  CbmEcalHitProducerFastMC(const char *name, const Int_t iVerbose=1);
-
-  /** Destructor **/
-  virtual ~CbmEcalHitProducerFastMC();
-
-  /** Initialization of the task **/  
-  virtual InitStatus Init();
-
-  /** Executed task **/ 
-  virtual void Exec(Option_t* option);
-
-  /** Finish task **/ 
-  virtual void Finish();
-
-  /** Set energy resolution **/ 
-  void SetEResolution(Double_t a, Double_t b, Double_t c) {fA=a; fB=b; fC=c;}
-
-  /** method AddHit
-   **
-   ** Adds a EcalHit to the HitCollection
-   **/
-  void AddHit(Double_t x, Double_t y, Double_t E);
-
-protected:
-
-private:
-
-  Double_t Eresolution(Double_t E);
-  Double_t HadronResponse(Double_t E);
-
-private:
-
-  // Digitization parameters
-
-  Double_t fA;                  // dE/E=a/E
-  Double_t fB;                  // dE/E=b/sqrt(E)
-  Double_t fC;                  // dE/E=c
-  Double_t fCellSize;           // supermodule size
-  Double_t fEThreshold;         // Energy threshold
-  Int_t fRegionXm[4];           // zone X-size in supermodules
-  Int_t fRegionYm[4];           // zone Y-size in supermodules
-
-  TClonesArray* fListECALpts;   // ECAL MC points
-  TClonesArray* fHitCollection; // ECAL hits
-  TClonesArray* fListStack;     // Tracks
-  Int_t fNHits;                 // Number of hits
-  Int_t fEvent;                 //! Internal event counter
-
-  CbmEcalHitProducerFastMC(const CbmEcalHitProducerFastMC&);
-  CbmEcalHitProducerFastMC& operator=(const CbmEcalHitProducerFastMC&);
-
-  ClassDef(CbmEcalHitProducerFastMC,1)
-
-};
-
-#endif
diff --git a/ecal/CbmEcalIdentification.cxx b/ecal/CbmEcalIdentification.cxx
deleted file mode 100644
index 3cc6310e884a7b50b8f3c12a3c51fccef4b06af3..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalIdentification.cxx
+++ /dev/null
@@ -1,1326 +0,0 @@
-#include "CbmEcalIdentification.h"
-
-#include "FairRootManager.h"
-#include "FairTrackParam.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalCalibration.h"
-#include "CbmEcalIdParticle.h"
-#include "CbmEcalTrackExtrapolation.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalCellMC.h"
-#include "CbmEcalParam.h"
-#include "CbmMCTrack.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalMaximum.h"
-#include "CbmEcalShLibCorr.h"
-
-#include "CbmGlobalTrack.h"
-#include "CbmStsTrack.h"
-#include "CbmTrackMatch.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TMath.h"
-#include "TFormula.h"
-#include "TVector2.h"
-#include "TFile.h"
-#include "TDirectory.h"
-#include "TMatrixD.h"
-
-#include <iostream>
-#include <map>
-
-using namespace std;
-
-/** Loop procedure **/
-void CbmEcalIdentification::Exec(Option_t*)
-{
-  fEvent++;
-  if (fTreeOut) InitTree();
-  fId->Clear();
-
-  Int_t n=fTracks->GetEntriesFast();
-  Int_t i;
-  Int_t oldn;
-  fN=0;
-  FairTrackParam* tr;
-  CbmGlobalTrack* gtr;
-  if (fVerbose>9)
-    Info("Exec", "Total %d tracks before the calorimeter", n);
-  for(i=0;i<n;i++)
-  {
-    if (fTreeOut) InitVar();
-    tr=(FairTrackParam*)fTracks->At(i);
-    if (tr==NULL) continue;
-    fExtraNum=i;
-    fTrackNum=i;
-    if (fExtra)
-    {
-      fTrackNum=fExtra->Map()[fExtraNum];
-      gtr=(CbmGlobalTrack*)fGlobal->At(fTrackNum);
-      fStsTrackNum=gtr->GetStsTrackIndex();
-    }
-    else
-      fStsTrackNum=i;
-    oldn=fN;
-    Identify(tr);
-    if (oldn!=fN&&fTreeOut)
-      WriteTree();
-  }
-//  gDirectory->Cd("../");
-//  gDirectory->ls();
-//  cout << gDirectory->GetPath() << endl;
-//  if (fTreeOut) fTree->Write();
-}
-
-/** Identify a track **/
-void CbmEcalIdentification::Identify(FairTrackParam* tr)
-{
-  CbmEcalCell* cell=NULL;
-//  CbmEcalCell* cell2;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  list<CbmEcalCell*> ocells;
-  list<CbmEcalCell*>::const_iterator op;
-  Double_t e;
-  Double_t tracke;
-  Float_t x;
-  Float_t y;
-//  Float_t dst;
-//  Float_t t;
-//  CbmEcalInf* fInf=fStr->GetEcalInf();
-  TVector3 trackmom;
-  TVector3 tv3;
-//  Double_t te;
-//  Double_t me;
-//  Double_t me1;
-  Double_t sigma;
-  Int_t i;
-//  Int_t mc;
-  Int_t nm=fMaximums->GetEntriesFast();
-  CbmEcalMaximum* mx;
-  CbmEcalMaximum* mxx=NULL;
-
-
-  tr->Momentum(trackmom);
-  fTrackP=trackmom.Mag();
-  fPhi=TMath::ATan2(trackmom.Y(), trackmom.X())*TMath::RadToDeg();
-  fTheta=TMath::ATan2(trackmom.Pt(), trackmom.Z())*TMath::RadToDeg();
-  fX=tr->GetX();
-  fY=tr->GetY();
-  fZ=tr->GetZ();
-//  Info("Identify", "Track %d (%f, %f).", fExtraNum, fX, fY);
-
-  cell=fStr->GetCell(fX, fY);
-  if (cell)
-    fCellE=GetEnergy(cell);
-  tv3=trackmom.Unit();
-  x=fX+tv3.X()*2.0;
-  y=fY+tv3.Y()*2.0;
-  cell=fStr->GetCell(x, y);
-  if (cell)
-    fCellE2=GetEnergy(cell);
-  cell=NULL;
-
-  if (fSimpleMaximumLocationAlgo==1)
-    mxx=FindMaximum(tr);
-  else
-  {
-    for(i=0;i<nm;i++)
-    {
-//    cout << fZ << " -----------------------------------------------" << endl;
-      mx=(CbmEcalMaximum*)fMaximums->At(i);
-      if (!mx) continue;
-      if (CheckMaximum(mx))
-      {
-        if (cell&&fVerbose>10)
-	  Info("Identify", "For track %d (%f, %f) more than one maximum located", fTrackNum, fX, fY);
-        cell=mx->Cell();
-        mx->SetMark(mx->Mark()+1);
-        mxx=mx;
-      }
-    }
-  }
-  if (mxx==NULL)
-  {
-    if (fTreeOut) WriteTreeLight();
-    return;
-  }
-  cell=mxx->Cell();
-//  cout << "here" << endl;
-  ConstructCluster(mxx);
-  if (fCluster.size()==0)
-  {
-    if (fTreeOut) WriteTreeLight();
-    return;
-  }
-  if (fTreeOut) ShapeAnalysis(mxx);
-  CalculateShape(mxx);
-  if (fShLib) CalculateChi2(mxx);
-  e=0;
-  for(p=fCluster.begin();p!=fCluster.end();++p)
-    e+=GetEnergy(*p);
-//  fShape=-1111
-  fE=fCal->GetEnergy(e, TMath::Tan(TMath::DegToRad()*fTheta), fRegion);
-//  cout << fE << " " << fRegion << endl;
-//  cout << e << "->" << fE << ", theta=" << fTheta << ", region=" << fRegion << endl;
-  fMaxX=cell->GetCenterX();
-  fMaxY=cell->GetCenterY();
-  //TODO: Calculate probability
-  fEProb=1;
-  tracke=trackmom.Mag();
-  fTrackP=tracke;
-//  if (fE<tracke)
-  {
-    sigma=fEResolution->Eval(tracke)*tracke;
-    fEProb*=TMath::Erfc((tracke-fE)/sigma/TMath::Sqrt(2.0));
-  }
-
-  fMCTrackNum=-1111;
-  if (fUseMC==1)
-  {
-    CbmTrackMatch* ststr=(CbmTrackMatch*)fStsTracksMatch->At(fStsTrackNum);
-    if (ststr)
-      fMCTrackNum=ststr->GetMCTrackId();
-  }
-  // Use PSE for \chi^2 storage
-  new((*fId)[fN++]) CbmEcalIdParticle(cell, fX, fY, fZ, fE/tracke, fChi2, fShape, fTrackNum, fEProb, fMCTrackNum);
-}
-
-Double_t CbmEcalIdentification::Correlation(CbmEcalCell* c1, CbmEcalCell* c2, Double_t x, Double_t y, Double_t phi, Double_t theta, Double_t e) const
-{
-  if (c1->GetType()==c2->GetType())
-    return fShLib->Correlation(c1->X1()-x, c1->Y1()-y, c2->X1()-x, c2->Y1()-y, phi, theta, e, c1);
-  if (c1->GetType()>c2->GetType())
-    return fShLib->Correlation2(c1->X1()-x, c1->Y1()-y, c2->X1()-x, c2->Y1()-y, phi, theta, e, c1->GetType());
-  else
-    return fShLib->Correlation2(c2->X1()-x, c2->Y1()-y, c1->X1()-x, c1->Y1()-y, phi, theta, e, c2->GetType());
-}
-
-/** Calculate chi2 of the cluster**/
-void CbmEcalIdentification::CalculateChi2(CbmEcalMaximum*)
-{
-  // fX, fY --- corrdinates
-  // fTheta, fPhi --- angles
-  // fTrackP --- momenta of the track
-  // fCluster --- list of cluster cell
-  Int_t s=fCluster.size();
-  TMatrixD m(s, s);
-  Int_t i=0;
-  Int_t j;
-  list<CbmEcalCell*>::const_iterator p;
-  CbmEcalCell* cls[10];
-  Double_t de[10];
-  Double_t det[10];
-
-  for(p=fCluster.begin();p!=fCluster.end();++p)
-    cls[i++]=(*p);
-
-  if (fPhi<0) fPhi+=360.0;
-//  cout << fPhi << " " << fTheta << " " << fTrackP << endl;
-  // Calculate covariance matrix
-  for(i=0;i<s;i++)
-  for(j=0;j<s;j++)
-    m[i][j]=Correlation(cls[i], cls[j], fX, fY, fPhi, fTheta, fTrackP);
-
-  //Some magic numbers: TODO?
-  for(i=0;i<s;i++)
-    if (m[i][i]<1e-8*fTrackP) m[i][i]=1e-8*fTrackP;
-
-  // Inversion
-  m.Invert(det);
-
-  // Energy difference calculation
-  for(i=0;i<s;i++)
-    de[i]=cls[i]->GetTotalEnergy()-fShLib->GetResponse(cls[i]->X1()-fX, cls[i]->Y1()-fY, fPhi, fTheta, fTrackP, cls[i]);
-
-  // Chi2 calculation
-  fChi2=0.0;
-  for(i=0;i<s;i++)
-  for(j=0;j<s;j++)
-    fChi2+=de[i]*de[j]*m[i][j];
-}
-
-/** Simple maximum location algorithm. Copy/paste from CbmEcalIdentification **/
-CbmEcalMaximum* CbmEcalIdentification::FindMaximum(FairTrackParam*)
-{
-  CbmEcalCell* cell=fStr->GetCell(fX, fY);
-  if (cell==NULL) return NULL;
-  Double_t e=cell->GetTotalEnergy();
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*> ocells;
-  list<CbmEcalCell*>::const_iterator p;
-  list<CbmEcalCell*>::const_iterator op;
-  CbmEcalCell* max=NULL;
- // Double_t x;
- // Double_t y;
- // Double_t dst;
- // Double_t t;
- 
- 
-//  Info("FindMaximum", "E=%f", e);
-  cell->GetNeighborsList(0, cells);  
-  for(p=cells.begin();p!=cells.end();++p)
-    if ((*p)->GetTotalEnergy()>e)
-      break;
-  if (p==cells.end())
-  {
-    max=cell;
-//    Info("FindMaximum", "Found cell is maximum");
-  }
-//  cell->GetNeighborsList(0, cells);
-//  e=cell->GetTotalEnergy();
-  if (max==NULL)
-  /** Check cells near given for maximums **/
-    for(p=cells.begin();p!=cells.end();++p)
-    {
- //     x=(*p)->GetCenterX()-tr->GetX();
- //     y=(*p)->GetCenterY()-tr->GetY();
- //     dst=TMath::Sqrt(x*x+y*y);
-//        if (dst>fInf->GetModuleSize()*TMath::Sqrt(2.0)+0.001) continue;
- //     x=tr->GetX(); x*=x; y=tr->GetY(); y*=y;
- //     t=TMath::Sqrt(x+y);
- //     x=(*p)->GetCenterX()-cell->GetCenterX();
- //     y=(*p)->GetCenterY()-cell->GetCenterY();
-//      if (x*tr->GetTx()/t+y*tr->GetTy()/t<TMath::Sqrt(2.0)*fInf->GetModuleSize()/cell->GetType()+0.001)
-//      if (x*tr->GetTx()/t+y*tr->GetTy()/t<-0.01&&dst>fInf->GetModuleSize()/cell->GetType()+0.001) continue;
-      (*p)->GetNeighborsList(0, ocells);
-      e=(*p)->GetTotalEnergy();
-      for(op=ocells.begin(); op!=ocells.end();++op)
-        if ((*op)->GetTotalEnergy()>e) break;
-      if (op==ocells.end())
-        if (max==NULL||max->GetTotalEnergy()<(*p)->GetTotalEnergy())
-          max=*p;
-    }
-  if (max==NULL) return NULL;
-
-  Int_t i;
-  Int_t nm=fMaximums->GetEntriesFast();
-  CbmEcalMaximum* mx=NULL;
-  for(i=0;i<nm;i++)
-  {
-    mx=(CbmEcalMaximum*)fMaximums->At(i);
-    if (!mx) continue;
-    if (mx->Cell()==max) break;
-  }
-  if (i==nm)
-  {
-//    Info("FindMaximum", "Maximum (%f,%f,%f) not found in the table", fX, fY, max->GetTotalEnergy());
-//    for(i=0;i<nm;i++)
-//    {
-//      mx=(CbmEcalMaximum*)fMaximums->At(i);
-//      if (!mx) continue;
-//      Info("FindMaximum", "Table maximum %d (%f, %f, %f) ", i, mx->X(), mx->Y(), mx->Cell()->GetTotalEnergy());
-//    }
-    return NULL;
-  }
-  mx->SetMark(mx->Mark()+1);
-
-  return mx;
-}
-/** If identification failed :-( **/
-void CbmEcalIdentification::WriteTreeLight()
-{
-  fPDG=-1111;
-  fMCPDG=-1111;
-  fMotherMCPDG=-1111;
-  fMCM=-1111;
-  if (fUseMC==1)
-  {
-    CbmTrackMatch* ststr=(CbmTrackMatch*)fStsTracksMatch->At(fStsTrackNum);
-    if (ststr)
-      fMCTrackNum=ststr->GetMCTrackId();
-  }
-  if (fUseMC&&fMCTrackNum>=0)
-  {
-    CbmMCTrack* mctr=(CbmMCTrack*)fMC->At(fMCTrackNum);
-    CbmMCTrack* mother;
-    if (mctr->GetMotherId()>=0)
-    {
-      mother=(CbmMCTrack*)fMC->At(mctr->GetMotherId());
-      fMotherMCPDG=mother->GetPdgCode();
-    }
-    fMCPDG=mctr->GetPdgCode();
-    fMCP=mctr->GetP();
-
-    CbmEcalPoint* pt=NULL;
-    CbmMCTrack* tr;
-//    CbmMCTrack* mtr;
-    Int_t n=fMCPoints->GetEntriesFast();
-    Int_t i=0;
-    Int_t j;
-    Double_t x1;
-    Double_t y1;
-    Double_t dx;
-    Double_t dy;
-    Double_t r;
-    TVector3 mom;
-
-    for(i=0;i<n;i++)
-    {
-      pt=(CbmEcalPoint*)fMCPoints->At(i);
-      if (pt->GetTrackID()==fMCTrackNum)
-	break;
-    }
-    if (i!=n)
-    {
-      fMCM=0;
-      fMCX=pt->GetX();
-      fMCY=pt->GetY();
-      dx=pt->GetX()-fX;
-      dy=pt->GetY()-fY;
-      x1=pt->GetX();
-      y1=pt->GetY();
-      fR=TMath::Sqrt(dx*dx+dy*dy);
-      pt->Momentum(mom);
-      fMCSurfE=mom.Mag();
-      fMCCircE=fMCSurfE;
-      for(j=0;j<n;j++)
-      if (j!=i)
-      {
-	pt=(CbmEcalPoint*)fMCPoints->At(j);
-	if (pt->GetTrackID()>=0)
-	  tr=(CbmMCTrack*)fMC->At(pt->GetTrackID());
-	else
-	  tr=NULL;
-	while(tr!=NULL)
-	{
-	  if (tr->GetMotherId()<0)
-	  {
-	    tr=NULL; break;
-	  }
-	  if (tr->GetMotherId()==fMCTrackNum)
-	    break;
-	  tr=(CbmMCTrack*)fMC->At(tr->GetMotherId());
-	}
-	if (tr)
-        {
-          pt->Momentum(mom);
-	  dx=x1-pt->GetX();
-	  dy=y1-pt->GetY();
-	  r=TMath::Sqrt(dx*dx+dy*dy);
-	  fMCM+=r*mom.Mag();
-          if (r<fCircRad)
-  	    fMCCircE+=mom.Mag();
-	}
-      }
-    }
-    else
-    {
-      fR=-1111;
-      fMCSurfE=-1111;
-    }
-  }
-  fTree->Fill();
-}
-/** Write information to the tree **/
-void CbmEcalIdentification::WriteTree()
-{
-  fPDG=-1111;
-  fMCPDG=-1111;
-  fMotherMCPDG=-1111;
-  fMCM=-1111;
-  if (fStsTrackNum>=0)
-  {
-    CbmStsTrack* gtr=(CbmStsTrack*)fStsTracks->At(fStsTrackNum);
-    fPDG=gtr->GetPidHypo();
-    fTrChi2=gtr->GetChiSq();
-    fTrNDF=gtr->GetNDF();
-  }
-  else
-  {
-    fPDG=-1111;
-    fTrChi2=-1111;
-  }
-  if (fMCTrackNum>=0&&fUseMC==1)
-  {
-    CbmMCTrack* mctr=(CbmMCTrack*)fMC->At(fMCTrackNum);
-    CbmMCTrack* mother;
-    if (mctr->GetMotherId()>=0)
-    {
-      mother=(CbmMCTrack*)fMC->At(mctr->GetMotherId());
-      fMotherMCPDG=mother->GetPdgCode();
-    }
-    fMCPDG=mctr->GetPdgCode();
-    fMCP=mctr->GetP();
-
-    CbmEcalPoint* pt=NULL;
-    CbmMCTrack* tr;
-//    CbmMCTrack* mtr;
-    Int_t n=fMCPoints->GetEntriesFast();
-    Int_t i=0;
-    Int_t j;
-    Double_t x1;
-    Double_t y1;
-    Double_t dx;
-    Double_t dy;
-    Double_t r;
-    TVector3 mom;
-
-    for(i=0;i<n;i++)
-    {
-      pt=(CbmEcalPoint*)fMCPoints->At(i);
-      if (pt->GetTrackID()==fMCTrackNum)
-	break;
-    }
-    if (i!=n)
-    {
-      fMCM=0;
-      fMCX=pt->GetX();
-      fMCY=pt->GetY();
-      dx=pt->GetX()-fX;
-      dy=pt->GetY()-fY;
-      x1=pt->GetX();
-      y1=pt->GetY();
-      fR=TMath::Sqrt(dx*dx+dy*dy);
-      pt->Momentum(mom);
-      fMCSurfE=mom.Mag();
-      fMCCircE=fMCSurfE;
-      for(j=0;j<n;j++)
-      if (j!=i)
-      {
-	pt=(CbmEcalPoint*)fMCPoints->At(j);
-	if (pt->GetTrackID()>=0)
-	  tr=(CbmMCTrack*)fMC->At(pt->GetTrackID());
-	else
-	  tr=NULL;
-	while(tr!=NULL)
-	{
-	  if (tr->GetMotherId()<0)
-	  {
-	    tr=NULL; break;
-	  }
-	  if (tr->GetMotherId()==fMCTrackNum)
-	    break;
-	  tr=(CbmMCTrack*)fMC->At(tr->GetMotherId());
-	}
-	if (tr)
-        {
-          pt->Momentum(mom);
-	  dx=x1-pt->GetX();
-	  dy=y1-pt->GetY();
-	  r=TMath::Sqrt(dx*dx+dy*dy);
-	  fMCM+=r*mom.Mag();
-          if (r<fCircRad)
-  	    fMCCircE+=mom.Mag();
-	}
-      }
-    }
-    else
-    {
-      fR=-1111;
-      fMCSurfE=-1111;
-    }
-  }
-  fTree->Fill();
-}
-
-/** Get energy of the cell **/
-Double_t CbmEcalIdentification::GetEnergy(CbmEcalCell* cell)
-{
-  if (fUseHack==0)
-    return cell->GetEnergy();
-
-  CbmEcalCellMC* cellmc=(CbmEcalCellMC*)cell; //This will fail if no MC info is available
-  map<Int_t, Float_t>::const_iterator q;
-  Double_t e=0;
-  CbmMCTrack* tr;
-  Int_t pdg;
-
-  for(q=cellmc->GetTrackEnergyBegin();q!=cellmc->GetTrackEnergyEnd();++q)
-  {
-    tr=(CbmMCTrack*)fMC->At((*q).first);
-    if (tr==NULL)
-    {
-      Info("GetEnergy","Can't find MC track with number %d.",(*q).first);
-      continue;
-    }
-    pdg=tr->GetPdgCode();
-    if (pdg==22||pdg==-11||pdg==11||pdg==13||pdg==-13)
-      e+=(*q).second;
-    else
-      e+=(*q).second*fHack;
-  }
-  return e;
-}
-
-/** Initializes tree **/
-void CbmEcalIdentification::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("ecalid","Identification in calorimeter");
-  fTree->Branch("ev", &fEvent, "ev/I");
-  fTree->Branch("cellx", &fCellX, "cellx/D");
-  fTree->Branch("celly", &fCellY, "celly/D");
-  fTree->Branch("maxx", &fMaxX, "maxx/D");
-  fTree->Branch("maxy", &fMaxY, "maxy/D");
-  fTree->Branch("mcx", &fMCX, "mcx/D");
-  fTree->Branch("mcy", &fMCY, "mcy/D");
-  fTree->Branch("x", &fX, "x/D");
-  fTree->Branch("y", &fY, "y/D");
-  fTree->Branch("z", &fZ, "z/D");
-  fTree->Branch("e", &fE, "e/D");
-  fTree->Branch("shape", &fShape, "shape/D");
-  fTree->Branch("eprob", &fEProb, "eprob/D");
-  fTree->Branch("n", &fN, "n/I");
-  fTree->Branch("tr", &fTrackNum, "tr/I");
-  fTree->Branch("mctr", &fMCTrackNum, "mctr/I");
-  fTree->Branch("pdg", &fPDG, "pdg/I");
-  fTree->Branch("tcell", &fCellType, "pdg/I");
-  fTree->Branch("mcpdg", &fMCPDG, "mcpdg/I");
-  fTree->Branch("mmcpdg", &fMotherMCPDG, "mmcpdg/I");
-  fTree->Branch("mcp", &fMCP, "mcp/D");
-  fTree->Branch("mcm", &fMCM, "mcm/D");
-  fTree->Branch("trp", &fTrackP, "trp/D");
-  fTree->Branch("r", &fR, "r/D");
-  fTree->Branch("mcsurfe", &fMCSurfE, "mcsurfe/D");
-  fTree->Branch("mccirce", &fMCCircE, "mccirce/D");
-  fTree->Branch("trchi2", &fTrChi2, "trchi2/D");
-  fTree->Branch("trcndf", &fTrNDF, "trndf/I");
-  fTree->Branch("emax", &fEMax, "emax/D");
-  fTree->Branch("e2", &fE2, "e2/D");
-  fTree->Branch("e3", &fE3, "e3/D");
-  fTree->Branch("ecluster", &fECluster, "ecluster/D");
-  fTree->Branch("se", fSE, "se[5]/D");
-  fTree->Branch("p2", &fP2, "p2/D");
-  fTree->Branch("q2", &fQ2, "q2/D");
-  fTree->Branch("theta", &fTheta, "theta/D");
-  fTree->Branch("celle", &fCellE, "celle/D");
-  fTree->Branch("celle2", &fCellE2, "celle2/D");
-  fTree->Branch("p", &fP, "p/D");
-  fTree->Branch("q", &fQ, "q/D");
-  fTree->Branch("angle", &fAngle, "angle/D");
-  fTree->Branch("ph", &fPH, "ph/D");
-  fTree->Branch("pl", &fPL, "pl/D");
-  fTree->Branch("pc", &fPC, "pc/D");
-  fTree->Branch("pr", &fPR, "pr/D");
-  fTree->Branch("chi2", &fChi2, "chi2/D");
-}
-
-/** Initializes tree **/
-void CbmEcalIdentification::InitVar()
-{
-  fCellX=-1111;
-  fCellY=-1111;
-  fMaxX=-1111;
-  fMaxY=-1111;
-  fX=-1111;
-  fY=-1111;
-  fZ=-1111;
-  fE=-1111;
-  fShape=-1111;
-  fEProb=-1111;
-  fTrackNum=-1111;
-  fStsTrackNum=-1111;
-  fMCTrackNum=-1111;
-  fPDG=-1111;
-  fCellType=-1111;
-  fMCPDG=-1111;
-  fMotherMCPDG=-1111;
-  fMCP=-1111;
-  fMCM=-1111;
-  fTrackP=-1111;
-  fR=-1111;
-  fMCSurfE=-1111;
-  fMCCircE=-1111;
-  fTrChi2=-1111;
-  fTrNDF=-1111;
-  fMCX=-1111;
-  fMCY=-1111;
-  fEMax=-1111;
-  fE2=-1111;
-  fECluster=-1111;
-  for(Int_t i=0;i<5;i++)
-    fSE[i]=-1111;
-  fP2=-1111;
-  fQ2=-1111;
-  fCellE=-1111;
-  fCellE2=-1111;
-  fE3=-1111;
-  fP=-1111;
-  fQ=-1111;
-  fAngle=-1111;
-  fPH=-1111;
-  fPL=-1111;
-  fPC=-1111;
-  fPR=-1111;
-  fChi2=-1111;
-}
-
-
-CbmEcalIdentification::CbmEcalIdentification()
-  : FairTask(),
-    fCfgName(""),
-    fTree(NULL),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fTheta(0.),
-    fPhi(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fMaxX(0.),
-    fMaxY(0.),
-    fMCX(0.),
-    fMCY(0.),
-    fE(0.),
-    fShape(0.),
-    fEProb(0.),
-    fExtraNum(-1111),
-    fTrackNum(-1111),
-    fStsTrackNum(-1111),
-    fTrackP(0.),
-    fMCTrackNum(0),
-    fTreeOut(0),
-    fUseMC(0),
-    fUseHack(0),
-    fHack(0.),
-    fEvent(0),
-    fCellType(0),
-    fN(0),
-    fTrChi2(0.),
-    fTrNDF(0),
-    fPDG(0),
-    fMCPDG(0),
-    fMotherMCPDG(0),
-    fMCP(0.),
-    fMCM(0.),
-    fR(0.),
-    fMCSurfE(0.),
-    fMCCircE(0.),
-    fCircRad(0.),
-    fChi2(0.),
-    fUseShLib(0),
-    fSimpleMaximumLocationAlgo(0),
-    fF(NULL),
-    fForm(),
-    fQL(0.),
-    fQH(0.),
-    fCPL(0.),
-    fCPH(0.),
-    fPH(0.),
-    fPL(0.),
-    fOldShapeAlgo(0),
-    fCluster(),
-    fRegions(0),
-    fRegion(0),
-    fThetaB(NULL),
-    fAlgo(NULL),
-    fPar1(NULL),
-    fPar2(NULL),
-    fPar3(NULL),
-    fParI(NULL),
-    fIntSteps(0),
-    fUseCellType(0),
-    fEMax(0.),
-    fE2(0.),
-    fE3(0.),
-    fECluster(0.),
-    fSE(),
-    fP2(0.),
-    fQ2(0.),
-    fCellE(0.),
-    fCellE2(0.),
-    fAngle(0.),
-    fP(0.),
-    fQ(0.),
-    fPC(0.),
-    fPR(0.),
-    fQCH(0.),
-    fQCL(0.),
-    fEResolution(NULL),
-    fId(NULL),
-    fTracks(NULL),
-    fMC(NULL),
-    fGlobal(NULL),
-    fStsTracks(NULL),
-    fStsTracksMatch(NULL),
-    fMCPoints(NULL),
-    fMaximums(NULL),
-    fCal(NULL),
-    fStr(NULL),
-    fShLib(NULL),
-    fExtra(NULL)
-{
-}
-
-
-CbmEcalIdentification::CbmEcalIdentification(const char* name, const Int_t iVerbose, const char* config)
-  : FairTask(name, iVerbose),
-    fCfgName(config),
-    fTree(NULL),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fTheta(0.),
-    fPhi(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fMaxX(0.),
-    fMaxY(0.),
-    fMCX(0.),
-    fMCY(0.),
-    fE(0.),
-    fShape(0.),
-    fEProb(0.),
-    fExtraNum(-1111),
-    fTrackNum(-1111),
-    fStsTrackNum(-1111),
-    fTrackP(0.),
-    fMCTrackNum(0),
-    fTreeOut(0),
-    fUseMC(0),
-    fUseHack(0),
-    fHack(0.),
-    fEvent(0),
-    fCellType(0),
-    fN(0),
-    fTrChi2(0.),
-    fTrNDF(0),
-    fPDG(0),
-    fMCPDG(0),
-    fMotherMCPDG(0),
-    fMCP(0.),
-    fMCM(0.),
-    fR(0.),
-    fMCSurfE(0.),
-    fMCCircE(0.),
-    fCircRad(0.),
-    fChi2(0.),
-    fUseShLib(0),
-    fSimpleMaximumLocationAlgo(0),
-    fF(NULL),
-    fForm(),
-    fQL(0.),
-    fQH(0.),
-    fCPL(0.),
-    fCPH(0.),
-    fPH(0.),
-    fPL(0.),
-    fOldShapeAlgo(0),
-    fCluster(),
-    fRegions(0),
-    fRegion(0),
-    fThetaB(NULL),
-    fAlgo(NULL),
-    fPar1(NULL),
-    fPar2(NULL),
-    fPar3(NULL),
-    fParI(NULL),
-    fIntSteps(0),
-    fUseCellType(0),
-    fEMax(0.),
-    fE2(0.),
-    fE3(0.),
-    fECluster(0.),
-    fSE(),
-    fP2(0.),
-    fQ2(0.),
-    fCellE(0.),
-    fCellE2(0.),
-    fAngle(0.),
-    fP(0.),
-    fQ(0.),
-    fPC(0.),
-    fPR(0.),
-    fQCH(0.),
-    fQCL(0.),
-    fEResolution(NULL),
-    fId(NULL),
-    fTracks(NULL),
-    fMC(NULL),
-    fGlobal(NULL),
-    fStsTracks(NULL),
-    fStsTracksMatch(NULL),
-    fMCPoints(NULL),
-    fMaximums(NULL),
-    fCal(NULL),
-    fStr(NULL),
-    fShLib(NULL),
-    fExtra(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalIdentification::Init()
-{
-  Int_t f;
-  Int_t r;
-  TString nm;
-  TString res;
-
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fTracks=(TClonesArray*)fManager->GetObject("EcalTrackParam");
-  if (!fTracks)
-  {
-    Fatal("Init", "Can't find an array of reconstructed tracks.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fCal=(CbmEcalCalibration*)fManager->GetObject("EcalECalibration");
-  if (!fCal)
-  {
-    Fatal("Init", "Can't find EcalECalibration");
-    return kFATAL;
-  }
-  fExtra=(CbmEcalTrackExtrapolation*)fManager->GetObject("EcalTrackExtrapolation");
-  if (!fExtra)
-    Info("Init", "Can't find EcalTrackParam. Will use STS tracks.");
-  else // Need an array of global tracks
-  {
-    fGlobal=(TClonesArray*)fManager->GetObject("GlobalTrack");
-    if (!fGlobal)
-    {
-      Fatal("Init()","Can't find global tracks array");
-      return kFATAL;
-    }
-  }
-  fStsTracks=(TClonesArray*)fManager->GetObject("StsTrack");
-  if (!fStsTracks)
-  {
-    Fatal("Init()","Can't find STS tracks array");
-    return kFATAL;
-  }
-  fMaximums=(TClonesArray*)fManager->GetObject("EcalMaximums");
-  if (!fMaximums)
-  {
-    Fatal("Init()","Can't find array of calorimeter maximums");
-    return kFATAL;
-  }
-  fId=new TClonesArray("CbmEcalIdParticle", 2000);
-  fManager->Register("EcalId", "ECAL", fId, IsOutputBranchPersistent("EcalId"));
-  fEvent=0;
-  CbmEcalParam* p=new CbmEcalParam("IdentificationParam", fCfgName);
-  fTreeOut=p->GetInteger("treeout");
-  fUseHack=p->GetInteger("usehacks");
-  fUseMC=p->GetInteger("usemcinfo");
-  nm=p->GetString("eresolution");
-  fOldShapeAlgo=p->GetInteger("oldshapealgo");
-  fSimpleMaximumLocationAlgo=p->GetInteger("simplemaximumlocationalgo");
-  fEResolution=new TFormula("calorimeter_energy_resolution", nm);
-  if (fUseHack>0)
-  {
-    Info("Init", "Hack option given in configuration file.");
-    fHack=p->GetDouble("hack");
-    fMC=(TClonesArray*)fManager->GetObject("MCTrack");
-    if (!fMC)
-    {
-      Fatal("Init", "Can't find array of MC tracks in system.");
-      return kFATAL;
-    }
-    fMCPoints=(TClonesArray*)fManager->GetObject("EcalPoint");
-    if (!fMCPoints)
-    {
-      Fatal("Init","Can't find array of EcalPoint in the system");
-      return kFATAL;
-    }
-  }
-  if (fUseMC)
-  {
-    fCircRad=p->GetDouble("circrad");
-/*
-    fStsTracks=(TClonesArray*)fManager->GetObject("StsTrack");
-    if (!fStsTracks)
-    {
-      Fatal("Init()","Can't find STS tracking information");
-      return kFATAL;
-    }
-*/
-    fStsTracksMatch=(TClonesArray*)fManager->GetObject("StsTrackMatch");
-    if (!fStsTracksMatch)
-    {
-      Fatal("Init()","Can't find STS track matching information");
-      return kFATAL;
-    }
-  }
-  fF=new Double_t[18];
-  for(f=0;f<6;f++)
-  {
-    nm="f"; nm+=f;
-    res=p->GetString(nm);
-    nm="dist_formula_f"; nm+=f;
-    fForm[f]=new TFormula(nm, res);
-    for(r=0;r<3;r++)
-    {
-      nm="f"; nm+=f; nm+="p"; nm+=r;
-      fF[f*3+r]=p->GetDouble(nm);
-      fForm[f]->SetParameter(r, fF[f*3+r]);
-    }
-  }
-  fUseShLib=p->GetInteger("useshlib");
-  if (fUseShLib)
-  {
-    fShLib=(CbmEcalShLibCorr*)fManager->GetObject("EcalEShLib");
-    if (!fShLib)
-    {
-      Fatal("Init()", "Can't find EcalEShLib in the system");
-      return kFATAL;
-    }
-  }
-  else
-    fShLib=NULL;
-  fQL=p->GetDouble("ql");
-  fQH=p->GetDouble("qh");
-  if (fOldShapeAlgo==0)
-  {
-    fQCL=p->GetDouble("qcl");
-    fQCH=p->GetDouble("qch");
-  }
-  fCPL=p->GetDouble("cpl");
-  fCPH=p->GetDouble("cph");
-
-  fUseCellType=p->GetInteger("usecelltype");
-  // Clustering stuff
-  fRegions=p->GetInteger("regions");
-  fIntSteps=p->GetInteger("intsteps");
-  fThetaB=new Double_t[fRegions];
-  fAlgo=new Int_t[fRegions];
-  fPar1=new Double_t[fRegions];
-  fPar2=new Double_t[fRegions];
-  fPar3=new Double_t[fRegions];
-  fParI=new Int_t[fRegions];
-  for(r=0;r<fRegions;r++)
-  {
-    nm="theta["; nm+=r; nm+="]";
-    fThetaB[r]=p->GetDouble(nm);
-
-    nm="preclusteralgo["; nm+=r; nm+="]";
-    fAlgo[r]=p->GetDouble(nm);
-    
-    if (fAlgo[r]==0) continue;
-
-    nm="par1["; nm+=r; nm+="]";
-    fPar1[r]=p->GetDouble(nm);
-
-    nm="par2["; nm+=r; nm+="]";
-    fPar2[r]=p->GetDouble(nm);
-
-    nm="par3["; nm+=r; nm+="]";
-    fPar3[r]=p->GetDouble(nm);
-
-    nm="pari["; nm+=r; nm+="]";
-    fParI[r]=p->GetInteger(nm);
-  }
-  delete p;
-
-  fTree=NULL;
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalIdentification::Finish()
-{
-//  TFile* f=new TFile("cal.root", "RECREATE");
-//  cout << gFile->GetName() << endl;
-  if (fTree)
-    fTree->Write();
-//  f->Close();
-}
-
-Double_t CbmEcalIdentification::GetPL(Double_t e, Double_t theta) const
-{
-  Double_t p0=fForm[0]->Eval(e);
-  Double_t p1=fForm[1]->Eval(e);
-  Double_t p2=fForm[2]->Eval(e);
-  return p0+theta*(p1+theta*p2);
-}
-
-Double_t CbmEcalIdentification::GetPH(Double_t e, Double_t theta) const
-{
-  Double_t p0=fForm[3]->Eval(e);
-  Double_t p1=fForm[4]->Eval(e);
-  Double_t p2=fForm[5]->Eval(e);
-  return p0+theta*(p1+theta*p2);
-}
-
-Int_t CbmEcalIdentification::CheckMaximum(CbmEcalMaximum* max)
-{
-  Double_t trpl;
-  Double_t trph;
-  Double_t trdp;
-  Double_t trp;
-  Double_t trq; 
-  Double_t dq=fQH-fQL;
-  Double_t trpm;
-  TVector2 v;
-
-  trpl=GetPL(fTrackP, fTheta); fPL=trpl;
-  trph=GetPH(fTrackP, fTheta); fPH=trph;
-  fPC=(fPL+fPH)/2.0; fPR=(fPH-fPL)/2.0;
-//  cout << "(pl.ph)=(" << trpl << ","<< trph ;
-  trdp=trph-trpl;
-  if (trdp>dq)
-  {
-    trpl-=fCPL*trdp;
-    trph+=fCPH*trdp;
-  }
-  else
-  {
-    trpm=(trph+trpl)/2.0;
-    trpl=trpm-dq/2.0;
-    trph=trpm+dq/2.0;
-  }
-
-  v.Set(fX-max->X(), fY-max->Y());
-  v=v.Rotate(-fPhi*TMath::DegToRad());
-  trp=v.X(); trq=v.Y();
-//  cout << ").(" << fX << "," << fY << "):(" << max->X() << "," << max->Y() << ")"; 
-//  cout << ".(p,q)=(" << trp << "," << trq << ").(pl.ph)=(" << trpl << ","<< trph << "):Phi=" << fPhi;
-  if (trp>trpl&&trp<trph&&trq>fQL&&trq<fQH)
-  {
-//    cout << " <---------" << endl;
-    return 1;
-  }
-
-//  cout << endl;
-  return 0;  
-}
-
-void CbmEcalIdentification::ConstructCluster(CbmEcalMaximum* max)
-{
-  Int_t i;
-  Int_t j;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  CbmEcalCell* cell;
-  CbmEcalCell* cll;
-//  Double_t e=1e9;
-  Int_t ix;
-  Int_t iy;
-  Double_t tx;
-  Double_t ty;
-  CbmEcalCell* cls[20];
-  Double_t rc[20];
-  Double_t r;
-
-  fCluster.clear();
-  cell=max->Cell();
-  if (fUseCellType==1)
-    fRegion=cell->GetType();
-  else
-  {
-    for(i=0;i<fRegions;i++)
-      if (fThetaB[i]>fTheta)
-        break;
-    fRegion=i;
-  }
-  if (fRegion>=fRegions||fRegion<0)
-  {
-    Info("ConstructCluster", "Cluster can't be constructed. Theta=%f.", fTheta);
-    return;
-  }
-  if (fAlgo[fRegion]==0)
-  {
-//    cell->GetNeighborsList(0, cells);
-    cell->GetNeighborsList(max->I(), fCluster);
-    fCluster.push_back(cell);
-//    for(p=cells.begin();p!=cells.end();++p)
-//      if ((*p)->GetTotalEnergy()<e)
-//      {
-//	cell=(*p);
-//	e=(*p)->GetTotalEnergy();
-//     }
-//    if (find(fCluster.begin(), fCluster.end(), cell)==fCluster.end())
-//      fCluster.push_back(cell);
-    return;
-  }
-
-  for(i=0;i<fParI[fRegion];i++)
-  {
-    cls[i]=NULL;
-    rc[i]=-1111;
-  }
-
-  for(ix=-4;ix<5;ix++)
-  for(iy=-4;iy<5;iy++)
-  {
-    tx=cell->GetCenterX(); tx+=ix*(cell->X2()-cell->X1());
-    ty=cell->GetCenterY(); ty+=iy*(cell->Y2()-cell->Y1());
-    cll=fStr->GetCell(tx, ty);
-    if (cll==NULL) continue;
-    r=SolveEllipse(cll, max->X(), max->Y(), fRegion);
-    for(i=0;i<fParI[fRegion];i++)
-      if (rc[i]<r)
-	break;
-    if (i==fParI[fRegion]) continue;
-    for(j=fParI[fRegion]-1;j>i;j--)
-    {
-      rc[j]=rc[j-1];
-      cls[j]=cls[j-1];
-    }
-    rc[i]=r;
-    cls[i]=cll;
-  }
-  for(j=0;j<fParI[fRegion];j++)
-    fCluster.push_back(cls[j]);
-}
-
-Double_t CbmEcalIdentification::SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy, Int_t reg)
-{
-  Double_t cRx=fPar2[reg];		//48*1.6
-  Double_t cRy=fPar3[reg];
-  Int_t cSt=fIntSteps;
-  TVector2 centr(cx, cy);
-  TVector2 t(centr);
-  Double_t gm=fPhi;
-  Double_t sgm=TMath::Sin(gm);
-  Double_t cgm=TMath::Cos(gm);
-  Double_t x;
-//  Double_t y;
-  Double_t p=sgm*sgm/cRx+cgm*cgm/cRy;
-  Double_t q=cgm*sgm*(1.0/cRx-1.0/cRy);
-  Double_t r=cgm*cgm/cRx+sgm*sgm/cRy;
-  Double_t d;
-  Double_t ex;
-//  Double_t ey;
-  Double_t y1;
-  Double_t y2;
-  Double_t inte=0;
-  Double_t step=(cell->X2()-cell->X1())/cSt;
-  Double_t fx=step/2.0+cell->X1();
-  Int_t i;
-  
-// cout << fCurAlgo << " " << reg << " " << fPar1[reg] << " " << cRx << " " << cRy << endl;
-  t/=t.Mod(); centr+=t*TMath::Sqrt(fPar1[reg]);
-  for(i=0;i<cSt;i++)
-  {
-    x=step; x*=i; x+=fx;
-    ex=x; ex-=centr.X();
-    d=q*q*ex*ex-p*(r*ex*ex-1);
-    if (d<0) continue;
-    d=TMath::Sqrt(d);
-    y1=-q*ex/p; y2=y1;
-    y1-=d/p; y2+=d/p;
-    y1+=centr.Y(); y2+=centr.Y();
-    if (y1>cell->Y2()) continue;
-    if (y2<cell->Y1()) continue;
-    if (y1<cell->Y1()) y1=cell->Y1();
-    if (y2>cell->Y2()) y2=cell->Y2();
-    inte+=(y2-y1)*step;
-  }
-
-  return inte;
-}
-
-void CbmEcalIdentification::ShapeAnalysis(CbmEcalMaximum* max)
-{
-  if (!fTreeOut) return;
-
-  CbmEcalCell* cell;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Int_t i;
-  Int_t j;
-  Double_t cp=0;
-  Double_t cq=0;
-  Double_t dp;
-  Double_t dq;
-  Double_t e;
-  TVector2 v;
-  TVector2 v1;
-  TVector2 v2;
-
-  cell=max->Cell();
-  fEMax=GetEnergy(cell);
-
-  fE2=fEMax; fE3=fEMax;
-  cell->GetNeighborsList(max->I(), cells);
-  for(p=cells.begin();p!=cells.end();++p)
-    fE2+=GetEnergy(*p);
-
-  cell->GetNeighborsList(0, cells);
-  for(p=cells.begin();p!=cells.end();++p)
-    fE3+=GetEnergy(*p);
-
-  fECluster=0;
-  for(p=fCluster.begin();p!=fCluster.end();++p)
-  {
-    //TODO: Should use GetEnergy only once
-    e=GetEnergy(*p);
-    fECluster+=e;
-    for(i=0;i<5;i++)
-      if (fSE[i]<e)
-	break;
-    if (i!=5)
-    {
-      for(j=4;j>i;j--)
-       fSE[j]=fSE[j-1];
-      fSE[i]=e;
-    }
-    v.Set((*p)->GetCenterX(), (*p)->GetCenterY());
-    v=v.Rotate(-fPhi*TMath::DegToRad());
-    cp+=v.X()*e; cq+=v.Y()*e;
-  }
-  for(i=1;i<5;i++)
-    fSE[i]+=fSE[i-1];
-
-  fP2=0; fQ2=0;
-  cp/=fECluster; cq/=fECluster;
-  for(p=fCluster.begin();p!=fCluster.end();++p)
-  {
-    e=GetEnergy(*p);
-    v.Set((*p)->GetCenterX(), (*p)->GetCenterY());
-    v=v.Rotate(-fPhi*TMath::DegToRad());
-    dp=v.X()-cp; dq=v.Y()-cq;
-    fP2=dp*dp*e; fQ2=dq*dq*e;
-  }
-  fP2/=fECluster; fQ2/=fECluster;
-
-  v1.Set(fX, fY);
-  v1=v1.Rotate(-fPhi*TMath::DegToRad());
-  v2.Set(max->X(), max->Y());
-  v2=v2.Rotate(-fPhi*TMath::DegToRad());
-  v=v2; v-=v1;
-  fP=v.X(); fQ=v.Y();
-  fAngle=v.Phi()*TMath::RadToDeg();
-  if (fAngle>180) fAngle-=360;
-}
-
-void CbmEcalIdentification::CalculateShape(CbmEcalMaximum* max)
-{
-  if (fOldShapeAlgo==1)
-  {
-    CbmEcalCell* cell=max->Cell();
-    Double_t e=cell->GetTotalEnergy();
-    list<CbmEcalCell*> cells;
-    cell->GetNeighborsList(max->I(), cells);
-    list<CbmEcalCell*>::const_iterator p=cells.begin();
-    Double_t e2=e;
-    for(;p!=cells.end();++p)
-      e2+=(*p)->GetTotalEnergy();
-
-    cell->GetNeighborsList(0, cells);
-    Double_t e3=e;
-    for(p=cells.begin();p!=cells.end();++p)
-      e3+=(*p)->GetTotalEnergy();
-    fShape=e2/e3;
-
-    return;
-  }
-  TVector2 v1(fX, fY); v1=v1.Rotate(-fPhi*TMath::DegToRad());
-  TVector2 v2(max->X(), max->Y()); v2=v2.Rotate(-fPhi*TMath::DegToRad());
-  v1-=v2;
-  fShape=0;
-//  cerr << v1.X() << ", " << v1.Y() << " : ([" << fPL << ", " << fPH << "], [" << fQCL << ", " << fQCH << "])" << endl;
-  if (v1.Y()<fQCL) return;
-  if (v1.Y()>fQCH) return;
-  if (v1.X()<fPL)  return;
-  if (v1.X()>fPH)  return;
-  fShape=1;
-}
-
-ClassImp(CbmEcalIdentification)
-
diff --git a/ecal/CbmEcalIdentification.h b/ecal/CbmEcalIdentification.h
deleted file mode 100644
index b9a66da5bed014cd2f934da0a3360e7d14bd6ce1..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalIdentification.h
+++ /dev/null
@@ -1,223 +0,0 @@
-#ifndef CBMECALIDENTIFICATION_H
-#define CBMECALIDENTIFICATION_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class TTree;
-class TClonesArray;
-class CbmEcalStructure;
-class CbmEcalCalibration;
-class CbmEcalTrackExtrapolation;
-class FairTrackParam;
-class CbmEcalCell;
-class TFormula;
-class CbmEcalMaximum;
-class CbmEcalShLibCorr;
-
-class CbmEcalIdentification : public FairTask
-{
-public:
-  CbmEcalIdentification(const char* name, const Int_t iVerbose=0, const char* config="$VMCWORKDIR/parameters/ecal/identification.cfg");
-public:
-  /** Default constructor **/
-  CbmEcalIdentification();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalIdentification() {};
-private:
-  /** Initialize a tree **/
-  void InitTree();
-  /** Init variables before writing to tree **/
-  void InitVar();
-  /** Identify a track **/
-  void Identify(FairTrackParam* tr);
-  /** Write information to the tree **/
-  void WriteTree();
-  void WriteTreeLight();
-  /** Get energy of the cell **/
-  Double_t GetEnergy(CbmEcalCell* cell);
-  /** Technical function of \chi^2 calculation**/
-  Double_t Correlation(CbmEcalCell* c1, CbmEcalCell* c2, Double_t x, Double_t y, Double_t phi, Double_t theta, Double_t e) const;  
-  /** Calculate chi2 of the cluster**/
-  void CalculateChi2(CbmEcalMaximum* mx);
-  TString fCfgName;
-  /** Out tree **/
-  TTree* fTree;			//!
-
-  /** Coordinates of a track **/
-  Double_t fX;
-  Double_t fY;
-  Double_t fZ;
-  Double_t fTheta;
-  Double_t fPhi;
-  /** Coordinates of cell hitted by track **/
-  Double_t fCellX;
-  Double_t fCellY;
-  /** Coordinates of maximum cell**/
-  Double_t fMaxX;
-  Double_t fMaxY;
-  /** MC Coordinates of the track **/
-  Double_t fMCX;
-  Double_t fMCY;
-  /** An energy and a shape of shower **/
-  Double_t fE;
-  Double_t fShape;
-  /** Probability to be an electron **/
-  Double_t fEProb;
-  /** Current extrapolation **/
-  Int_t fExtraNum;
-  /** Number of global track, produce the particle **/
-  Int_t fTrackNum;
-  /** STS  extrapolation **/
-  Int_t fStsTrackNum;
-  /** P of the track **/
-  Double_t fTrackP;
-  /** Number of MC track, produce the particle. **/
-  Int_t fMCTrackNum;
-  /** Should we dump debugging info to tree? **/
-  Int_t fTreeOut;
-  /** Use MC information to get MC track number **/
-  Int_t fUseMC;
-  /** Should we use hacks for hadrons? **/
-  Int_t fUseHack;
-  Double_t fHack;
-  /** Event number **/
-  Int_t fEvent;
-  /** Type of cell **/
-  Int_t fCellType;
-  /** Number of the id particle **/
-  Int_t fN;
-
-  /** \chi^2 of a given STS track **/
-  Double_t fTrChi2;
-  /** NDF of a given STS track **/
-  Int_t fTrNDF;
-
-  /** PDG code of the track by tracking system **/
-  Int_t fPDG;
-  /** MC PDG code **/
-  Int_t fMCPDG;
-  /** MC PDG code of mother of the track **/
-  Int_t fMotherMCPDG;
-  /** Energy of mother MC track**/
-  Double_t fMCP;
-  /** Momentum of energy distribution by particle on the calorimeter surface**/
-  Double_t fMCM;
-  /** Distance between MC and predicted impact point of the track **/
-  Double_t fR;
-  /** Energy of the electron on the calorimeter surface **/
-  Double_t fMCSurfE;
-  /** Energy in circle with radius fCircRad**/
-  Double_t fMCCircE;
-  /** Radius of circle for energy collection **/
-  Double_t fCircRad;
-
-  /** \chi^2 of the cluster **/ 
-  Double_t fChi2;
-  /** Should we use shower library?**/
-  Int_t fUseShLib;
-
-  /** Use simple maximum location algorithm **/
-  Int_t fSimpleMaximumLocationAlgo;
-  CbmEcalMaximum* FindMaximum(FairTrackParam* tr);
-  /** Array of constants for maximums location **/
-  Double_t* fF;				//!
-  TFormula* fForm[6];			//!
-  Double_t GetPL(Double_t e, Double_t theta) const;
-  Double_t GetPH(Double_t e, Double_t theta) const;
-  Double_t fQL;
-  Double_t fQH;
-  Double_t fCPL;
-  Double_t fCPH;
-  Double_t fPH;
-  Double_t fPL;
-  /** Use old algorithm for shape calculation **/
-  Int_t fOldShapeAlgo;
-  Int_t CheckMaximum(CbmEcalMaximum* max);
-
-  /** Cluster construction stuff **/
-  std::list<CbmEcalCell*> fCluster;	//!
-  Int_t fRegions;
-  Int_t fRegion;
-  Double_t* fThetaB;			//!
-  Int_t* fAlgo;				//!
-  Double_t* fPar1;			//!
-  Double_t* fPar2;			//!
-  Double_t* fPar3;			//!
-  Int_t* fParI;				//!
-  Int_t fIntSteps;
-  /** Use cell type instead of region in cluster construction **/
-  Int_t fUseCellType;
-
-  void ConstructCluster(CbmEcalMaximum* max);
-  Double_t SolveEllipse(CbmEcalCell* cell, Double_t cx, Double_t cy, Int_t reg);
-
-  /** Shower shape analysis **/
-  void ShapeAnalysis(CbmEcalMaximum* max);
-  Double_t fEMax;
-  Double_t fE2;
-  Double_t fE3;
-  Double_t fECluster;
-  Double_t fSE[5];
-  Double_t fP2;
-  Double_t fQ2;
-  Double_t fCellE;
-  Double_t fCellE2;
-  Double_t fAngle;
-  Double_t fP;
-  Double_t fQ;
-  Double_t fPC;
-  Double_t fPR;
-
-  void CalculateShape(CbmEcalMaximum* max);
-  Double_t fQCH;
-  Double_t fQCL;
-
-  /** Resolution of the calorimeter. Need to calculate probability **/
-  TFormula* fEResolution;		//!
-  /** Array of identified particles **/
-  TClonesArray* fId;
-  /** Array of reconstructed particles **/
-  TClonesArray* fTracks;
-  /** Array of MC tracks. Used only for tree output and hack procedure (if any).**/
-  TClonesArray* fMC;
-  /** Global tracks array **/
-  TClonesArray* fGlobal;
-  /** Sts tracks for energy loss information **/
-  TClonesArray* fStsTracks;
-  /** Sts info for track matching **/
-  TClonesArray* fStsTracksMatch;
-  /** MC tracking on the calorimeter surface **/
-  TClonesArray* fMCPoints;
-  /** Maximums **/
-  TClonesArray* fMaximums;
-  /** Calibration **/
-  CbmEcalCalibration* fCal;			//!
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;			//!
-  /** Shower library for chi2 calculation **/
-  CbmEcalShLibCorr* fShLib;			//!
-  /** Track extrapolation class. Need to map global track <-> track before the calorimeter **/
-  CbmEcalTrackExtrapolation* fExtra;
-
-  CbmEcalIdentification(const CbmEcalIdentification&);
-  CbmEcalIdentification& operator=(const CbmEcalIdentification&);
-
-  ClassDef(CbmEcalIdentification,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalInf.cxx b/ecal/CbmEcalInf.cxx
deleted file mode 100644
index 679a604f126e2ffd7cf8fa0b283658cac5ef0e99..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalInf.cxx
+++ /dev/null
@@ -1,550 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalStructure source file                 -----
-// -----                  Created  27/01/06  by M.Prokudin             -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalStructure.cxx
- *@author Mikhail Prokudin
- **
- ** Container of ECAL geometry parameters
- **/
-
-/* $Id: CbmEcalInf.cxx,v 1.12 2006/08/30 13:16:45 prokudin Exp $ */
-
-/* History of cvs commits:
- *
- * $Log: CbmEcalInf.cxx,v $
- * Revision 1.12  2006/08/30 13:16:45  prokudin
- * Bug huntong
- *
- * Revision 1.11  2006/07/29 00:33:53  prokudin
- * Commenting. Bringing code to coding conventions. New way of parameter file processing
- *
- * Revision 1.10  2006/07/24 21:45:02  prokudin
- * Now we write information to parameter file
- *
- * Revision 1.9  2006/07/15 18:31:10  kharlov
- * Compilation warnings and coding conventions are corrected
- *
- * Revision 1.8  2006/07/12 12:04:59  prokudin
- * CbmEcalInf now singleton.
- *
- * Revision 1.7  2006/07/10 07:43:25  kharlov
- * Conversion of cell type from string to a number
- *
- * Revision 1.6  2006/06/30 06:17:17  kharlov
- * Optimization, commenting
- *
- * Revision 1.5  2006/06/22 06:52:13  kharlov
- * Compilation warnings removed
- *
- * Revision 1.4  2006/04/02 16:55:23  kharlov
- * Merging full and fast MC
- *
- * Revision 1.2  2006/01/31 17:07:17  kharlov
- * Correction for CbmEcalv1
- *
- * Revision 1.1  2006/01/27 17:26:30  kharlov
- * First adaptation of ECAL detailed geometry to cbmroot2
- *
- */
-#include "CbmEcalInf.h"
-
-#include "CbmGeoEcalPar.h"
-
-#include "FairRunAna.h"
-#include "FairRuntimeDb.h"
-
-#include "TSystem.h"
-#include "TMap.h"
-
-#include <iostream>
-#include <fstream>
-#include <string>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::string;
-
-CbmEcalInf* CbmEcalInf::fInf=NULL;
-Int_t CbmEcalInf::fRefCount=0;
-
-
-CbmEcalInf::~CbmEcalInf()
-{
-	for(Int_t i=0;i<fEcalStr.GetSize();i++)
-		delete (TObjString*)(fEcalStr.At(i));
-	fEcalStr.Clear();
-}
-
-CbmEcalInf* CbmEcalInf::GetInstance(const char* filename)
-{
-	if (filename==NULL)
-	{
-		if (fInf!=NULL)
-			fRefCount++;
-		return fInf;
-	}
-	TString newname=gSystem->Getenv("VMCWORKDIR");
-	newname+="/geometry/";
-	newname+=filename;
-	if (fInf!=NULL)
-	{
-	  if (fInf->fFileName==newname)
-	  {
-	    fRefCount++;
-	    return fInf;
-	  }
-	  else
-	  {
-	    cerr << "CbmEcalInf: Trying create ";
-	    cerr << "instance of CbmEcalInf with";
-	    cerr << " name " << filename;
-	    cerr << ", which is different from ";
-	    cerr << fInf->fFileName << "." << endl;
-	    return NULL;
-	  }
-	}
-	fInf=new CbmEcalInf(newname);
-	//Is something wrong?
-	if (fInf->fSuccess==0)
-	{
-		delete fInf;
-		return NULL;
-	}
-	fRefCount++;
-	return fInf;
-}
-
-int cmp_nocase(const string &s, const string &s2 )
-{
-  string::const_iterator p=s.begin();
-  string::const_iterator p2=s2.begin();
-  while(p!=s.end()&&p2!=s2.end()) {
-    if (toupper(*p)!=toupper(*p2)) return (toupper(*p)<toupper(*p2))?-1:1;
-    ++p;
-    ++p2;
-  }
-  return(s2.size()==s.size())?0:(s.size()<s2.size())?-1:1; // size is unsigned
-}
-
-Double_t CbmEcalInf::GetVariableStrict(const char* key)
-{
-  TObjString* value=(TObjString*)fVariables->GetValue(key);
-  if (value==NULL)
-  {
-    cerr << "Can't find variable named \"" << key << "\"";
-    cerr << ". Exiting..." << endl;
-    Fatal("GetVariableStrict", "Can't find variable.");
-  }
-  Double_t val;
-  char* err=NULL;
-  val=strtod(value->GetString(),&err);
-  if (err[0]!='\0')
-  {
-    cerr << "Can't convert variable named \"" << key ;
-    cerr << "\" to floating point. Value is \"";
-    cerr << value->GetString() << "\"." << endl;
-    cerr << "Exiting..." << endl;
-    Fatal("GetVariableStrict", "Can't find variable.");
-  }
-  return val;
-}
-
-TString CbmEcalInf::GetStringVariable(const char* key)
-{
-  TObjString* value=(TObjString*)fVariables->GetValue(key);
-  if (value==NULL)
-  {
-    Fatal("GetStringVariable","Can't find variable named %s.", key);
-  }
-  return value->GetString();
-}
-
-
-
-Double_t CbmEcalInf::GetVariable(const char* key)
-{
-  TObjString* value=(TObjString*)fVariables->GetValue(key);
-  if (value==NULL)
-    return -1111;
-  Double_t val;
-  char* err=NULL;
-  val=strtod(value->GetString(),&err);
-  if (err[0]!='\0')
-    return -1111;
-  return val;
-}
-
-void CbmEcalInf::AddVariable(const char* key, const char* value)
-{
-  TObjString* skey=(TObjString*)fVariables->FindObject(key);
-  //Value for this key already exists!!!
-  if (skey!=NULL) return;
-  skey=new TObjString(key);
-  skey->String().ToLower();
-  TObjString* svalue=new TObjString(value);
-  fVariables->Add(skey, svalue);
-}
-//=============================================================================
-CbmEcalInf::CbmEcalInf(const char* filename)
-  : TObject(), 
-    fVariables(new TMap(200)), 
-    fEcalStr(), 
-    fXPos(0.), 
-    fYPos(0.),
-    fZPos(0.), 
-    fNLayers(0), 
-    fXSize(0), 
-    fYSize(0), 
-    fModuleSize(0.), 
-    fPSLead(0.),
-    fPSScin(0.), 
-    fPSGap(0.), 
-    fLead(0.), 
-    fScin(0.), 
-    fTyveec(0.), 
-    fThicknessLayer(0.),
-    fCellSize(0.), 
-    fEcalSize(), 
-    fEcalHole(), 
-    fECut(0.), 
-    fHCut(0.), 
-    fFastMC(-1),
-    fSuccess(1), 
-    fFileName(filename) 
-{
-  /**
-   ** Constructor reads and parses the ascii file, and fill 
-   ** the ECAL geometry container
-   **/
-  FairRunAna* ana = FairRunAna::Instance();
-  if (ana!=NULL)
-  {
-    FairRuntimeDb* rtdb=ana->GetRuntimeDb();
-    rtdb->getContainer("CbmGeoEcalPar");
-  }
-
-  std::ifstream file(filename);
-  Int_t linenum;
-//  Double_t val;
-  string buffer;
-  string message;
-  string variable;
-  string value;
-  TObjString* str=NULL;
-//  char** err=NULL;
-  char winend[2]={13, 0};
-  int ssize=-1;
-
-  if (!file) {
-    cerr << "CbmEcalInf: Can't open information file " << filename << "!" << endl;
-    cerr << "CbmEcalInf: Ecal will not be constructed correctly." << endl;
-    fSuccess=0;
-    return;
-  }
-
-  linenum=0;
-  while(getline(file,buffer)) {
-    linenum++;
-    message=buffer.substr(buffer.find_first_not_of(" 	"));	//Skiping initial spaces
-    message=message.substr(0,message.find("#"));	//Removing comments
-    // Threat windows end of strings correctly
-    message=message.substr(0,message.find(winend));
-    if (message.empty()) continue;		//This was just a comment
-    variable=message.substr(0,message.find("="));
-    if (variable=="structure") {
-      while(getline(file,buffer)) {
-	linenum++;
-	if (buffer.empty()) break;
-	message=buffer.substr(buffer.find_first_not_of(" 	"));	//Skiping initial spaces
-	message=message.substr(0,message.find("#"));	//Removing comments
-	message=message.substr(0,message.find_last_not_of(" 	")+1);	//Skiping ending spaces
-
-        // Threat windows end of strings correctly
-        message=message.substr(0,message.find(winend));
-
-	if (!message.empty()) {
-	  if (-1==ssize)
-	    ssize=message.size();
-	  else
-	    if (ssize!=(Int_t)message.size()) {
-	      cerr << "Error in ECAL structure at line " << linenum;
-	      cerr << "." << endl;
-	      cerr << "Line length differs from previous one" << endl;
-              fSuccess=0;
-	      file.close();
-	      return;
-	      
-	    }
-	  
-	  str=new TObjString(message.c_str());
-	  fEcalStr.Add(str);
-	}
-      }
-      break;
-    }
-    if (variable==message) {
-      cerr << "Syntax error: File " << filename << ".Line " << linenum << "." << endl;
-      fSuccess=0;
-      file.close();
-      return;
-    }
-    variable=variable.substr(0,variable.find_first_of(" 	"));
-    value=message.substr(message.find("=")+1);
-    value=value.substr(value.find_first_not_of(" 	"));	//Skiping initial spaces
-    value=value.substr(0,value.find_first_of(" 	"));
-/*
-    value=value.substr(0,value.find_first_not_of("1234567890-+e."));
-    val=strtod(value.c_str(),err);
-    if (err) {
-      cerr << "Syntax error after =: File " << filename << ".Line " << linenum << "." << endl;
-      fSuccess=0;
-      file.close();
-      return;
-    }
-*/
-    AddVariable(variable.c_str(), value.c_str());
-  }
-  file.close();
-  InitVariables();
-}
-
-Bool_t CbmEcalInf::ExcludeParameter(TString parname)
-{
-  if (parname.CompareTo("ecalversion")==0) return kTRUE;
-  return kFALSE;
-}
-
-void CbmEcalInf::CheckVariables()
-{
-  FairRunAna* ana = FairRunAna::Instance();
-  if (ana==NULL)
-  {
-    return;
-  }
-  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
-  CbmGeoEcalPar* par=(CbmGeoEcalPar*)(rtdb->findContainer("CbmGeoEcalPar"));
-  if (par==NULL)
-  {
-    Info("CheckVariables","No parameters container is found.");
-    return;
-  }
-  TMap* parVariables=par->GetVariables();
-  if (parVariables)
-  {
-    TObjString* key;
-    TIterator* iter=parVariables->MakeIterator();
-    while((key=(TObjString*)iter->Next())!=NULL)
-    {
-      TObjString* first=(TObjString*)parVariables->GetValue(key->String());
-      TObjString* second=(TObjString*)fVariables->GetValue(key->String());
-      if (ExcludeParameter(key->String())==kFALSE)
-      {
-        if (second==NULL)
-        {
-	  Info("CheckVariables", "Parameter %s not found in .geo file, but found in parameter file.", key->String().Data());
-        }
-	else
-        {
-          if (first->String()!=second->String())
-          {
-	    Info("CheckVariables", "Parameter %s differs in .geo file and parameter file!", key->String().Data());
-	    Info("CheckVariables", "%s=%s in parameter file.", key->String().Data(), first->String().Data());
-	    Info("CheckVariables", "%s=%s in .geo file.", key->String().Data(), second->String().Data());
-          }
-        }
-      }
-      if (ExcludeParameter(key->String())==kTRUE)
-	AddVariable(key->String().Data(), first->String().Data());
-    }
-  }
-
-  TObjArray* parEcalStr=par->GetEcalStr();
-  if (parEcalStr)
-  {
-//    TObjString* key;
-    for(Int_t i=0;i<parEcalStr->GetEntriesFast();i++)
-    {
-      TObjString* first=(TObjString*)parEcalStr->At(i);
-      TObjString* second=(TObjString*)fEcalStr.At(i);
-      if (second&&first->String()!=second->String())
-      {
-	Info("CheckVariables", "String %d in calorimeter structure differs in .geo file and in parameter file.", i);
-//	Info("CheckVariables", "%s=%s in parameter file", key->String().Data(), first->String().Data());
-//	Info("CheckVariables", "%s=%s in .geo file", key->String().Data(), second->String().Data());
-      }
-    }
-  }
-}
-
-void CbmEcalInf::InitVariables()
-{
-  TString stri;
-  TObjString* str=(TObjString*)fEcalStr.At(0);
-
-  fXPos=GetVariableStrict("xpos");
-  fYPos=GetVariableStrict("ypos");
-  fZPos=GetVariableStrict("zpos");
-  fNLayers=(Int_t)GetVariableStrict("nlayers");
-  fModuleSize=GetVariableStrict("modulesize");
-  fLead=GetVariableStrict("lead");
-  fScin=GetVariableStrict("scin");
-  fTyveec=GetVariableStrict("tyveec");
-  fPSLead=GetVariableStrict("pslead");
-  fPSScin=GetVariableStrict("psscin");
-  fPSGap=GetVariableStrict("psgap");
-  fCellSize=GetVariableStrict("cellsize");
-  fEcalSize[2]=GetVariableStrict("ecalzsize");
-  fECut=GetVariableStrict("ecut");
-  fHCut=GetVariableStrict("hcut");
-  fFastMC=(Int_t)GetVariableStrict("fastmc");
-
-  stri=""; stri+=str->GetString().Length();
-  AddVariable("xsize", stri);
-  stri=""; stri+=fEcalStr.GetLast()+1;
-  AddVariable("ysize", stri);
-
-  fXSize=(Int_t)GetVariableStrict("xsize");
-  fYSize=(Int_t)GetVariableStrict("ysize");
-  fThicknessLayer = 2.0*GetTyveec()+GetScin()+GetLead();
-  fEcalSize[0]    = GetXSize()*GetModuleSize();
-  fEcalSize[1]    = GetYSize()*GetModuleSize();
-  stri=""; stri+=fEcalSize[0];
-  AddVariable("xecalsize",stri);
-  stri=""; stri+=fEcalSize[1];
-  AddVariable("yecalsize",stri);
-
-  CalculateHoleSize();
-
-  fEcalHole[0]=GetVariableStrict("xholesize");
-  fEcalHole[1]=GetVariableStrict("yholesize");
-
-  fEcalHole[2]=fEcalSize[2];
-
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalInf::CalculateHoleSize()
-{
-  // Calculate the ECAL hole size [cm] from the number of supermodules
-  // of the type 0
-
-  Int_t i;
-  Int_t j;
-  Int_t hsx=-1;	//Coord of upper left hole angle
-  Int_t hex=-1;
-  Int_t hsy=-1;
-  Int_t hey=-1;
-  int cells; 
-  TString str;
-
-  for(i=0;i<fYSize;i++)
-    for(j=0;j<fXSize;j++) {
-      cells=GetType(j,i);
-      if (cells<0) {
-	cerr << "Warrning: Looks like an incorrect cells division: " << cells << "."<< endl;
-	cerr << "At (" << j << "," << i << ")." << endl;
-      }
-      if (!cells) {
-	if (-1==hsx) {
-	  hsx=j;
-	  hsy=i;
-	}
-	if (j<hsx) {
-	  Info("CalculateHoleSize", "Caorimeter hole is not rectangular.");
-	  AddVariable("xholesize","-1111");
-	  AddVariable("yholesize","-1111");
-//	  cout << "Error: At the moment we can describe only rect hole shapes." << endl;
-	  return;
-	}
-	if (i==hsy)
-	  hex=j;
-	if (j>hex) {
-	  Info("CalculateHoleSize", "Calorimeter hole is not rectangular.");
-	  AddVariable("xholesize","-1111");
-	  AddVariable("yholesize","-1111");
-//	  cerr << "Error: At the moment we can describe only rect hole shapes." << endl;
-	  return;
-	}
-	hey=i;
-      }
-    }
-  str=""; str+=GetModuleSize()*(hex-hsx+1);
-  AddVariable("xholesize",str);
-  str=""; str+=GetModuleSize()*(hey-hsy+1);
-  AddVariable("yholesize",str);
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalInf::DumpContainer() const
-{
-  // Print out the ECAL geometry container
-
-  if (fVariables)
-  {
-    TObjString* key;
-    TIterator* iter=fVariables->MakeIterator();
-    while((key=(TObjString*)iter->Next())!=NULL)
-    {
-      TObjString* str=(TObjString*)fVariables->GetValue(key);
-      cout << key->String() << "=" << str->String() << endl;
-    }
-  }
-  TObjString* key;
-  TIterator* iter=fEcalStr.MakeIterator();
-
-  Int_t modules=0;
-  Int_t channels=0;
-  Int_t i;
-  Int_t j;
-  Int_t m[10];
-  char stri[2]={0, 0};
-  TString st;
-  for(i=0;i<10;i++) m[i]=0;
-
-  while((key=(TObjString*)iter->Next())!=NULL)
-  {
-    st=key->String();
-    cout << key->String() << endl;
-    for(i=0;i<st.Length();i++)
-    {
-      stri[0]=st[i];
-      j=atoi(stri);
-      m[j]++;
-      if (j) modules++;
-      channels+=j*j;
-    }
-  }
-  cout << "Total modules:  " << modules << endl;
-  cout << "Total channels: " << channels << endl;
-  for(i=1;i<10;i++)
-  {
-    if (m[i]==0) continue;
-    cout << "	Type " << i << " : modules=" << m[i] << ", channels=" << m[i]*i*i << endl;
-  }
-
-}
-
-void CbmEcalInf::FillGeoPar(CbmGeoEcalPar* par,Int_t write_str) const
-{
-  TObjString* key;
-  TIterator* iter=fVariables->MakeIterator();
-  par->setChanged();
-
-  TMap* parVariables=new TMap();
-  par->SetVariables(parVariables);
-
-  while((key=(TObjString*)iter->Next())!=NULL)
-    parVariables->Add(key, fVariables->GetValue(key));
- if (write_str==1)
- {
-   iter=fEcalStr.MakeIterator();
-   TObjArray* parEcalStr=new TObjArray();
-   par->SetEcalStr(parEcalStr);
-   while((key=(TObjString*)iter->Next())!=NULL)
-     parEcalStr->Add(key);
- }
-}
- 
diff --git a/ecal/CbmEcalInf.h b/ecal/CbmEcalInf.h
deleted file mode 100644
index 5cf4d67c2c30ab378a8268b70e8526fb6a0b08e6..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalInf.h
+++ /dev/null
@@ -1,239 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalStructure header file                 -----
-// -----                  Created  27/01/06  by M.Prokudin             -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalInf.h
- *@author Mikhail Prokudin
- **
- ** Container of ECAL geometry parameters
- **/
-
-/* $Id: CbmEcalInf.h,v 1.13 2006/07/29 00:33:53 prokudin Exp $ */
-
-/* History of cvs commits:
- *
- * $Log: CbmEcalInf.h,v $
- * Revision 1.13  2006/07/29 00:33:53  prokudin
- * Commenting. Bringing code to coding conventions. New way of parameter file processing
- *
- * Revision 1.12  2006/07/24 21:45:02  prokudin
- * Now we write information to parameter file
- *
- * Revision 1.11  2006/07/12 16:26:36  prokudin
- * Corrected according to ROOT requirements
- *
- * Revision 1.10  2006/07/12 12:04:59  prokudin
- * CbmEcalInf now singleton.
- *
- * Revision 1.9  2006/07/11 13:08:43  prokudin
- * Magic number 48 removed. Using atoi instead.
- *
- * Revision 1.8  2006/07/10 14:39:38  kharlov
- * Correction for type cell
- *
- * Revision 1.7  2006/07/10 07:43:25  kharlov
- * Conversion of cell type from string to a number
- *
- * Revision 1.6  2006/06/30 06:17:17  kharlov
- * Optimization, commenting
- *
- * Revision 1.5  2006/06/22 06:52:13  kharlov
- * Compilation warnings removed
- *
- * Revision 1.4  2006/04/02 16:55:23  kharlov
- * Merging full and fast MC
- *
- * Revision 1.2  2006/01/31 17:07:17  kharlov
- * Correction for CbmEcalv1
- *
- * Revision 1.1  2006/01/27 17:26:30  kharlov
- * First adaptation of ECAL detailed geometry to cbmroot2
- *
- */
-
-#ifndef CBMECALINF_H
-#define CBMECALINF_H
-
-#include "TObjArray.h"
-#include "TString.h"
-#include "TObjString.h"
-
-#include <list>
-#include <stdlib.h>
-
-class TMap;
-class CbmGeoEcalPar;
-
-class CbmEcalInf:public TObject
-{
-public:
-  /** This is ROOT requirement **/
- CbmEcalInf() : TObject(), fVariables(NULL), fEcalStr(), fXPos(0.), fYPos(0.),
-    fZPos(0.), fNLayers(0), fXSize(0), fYSize(0), fModuleSize(0.), fPSLead(0.),
-    fPSScin(0.), fPSGap(0.), fLead(0.), fScin(0.), fTyveec(0.), fThicknessLayer(0.),
-    fCellSize(0.), fEcalSize(), fEcalHole(), fECut(0.), fHCut(0.), fFastMC(-1),
-    fSuccess(-1), fFileName("") 
-    {};
-
-  static CbmEcalInf* GetInstance(const char* filename);
-  /** Getters **/
-  inline Double_t GetXPos() const {return fXPos;} 
-  inline Double_t GetYPos() const {return fYPos;} 
-  inline Double_t GetZPos() const {return fZPos;}
-	
-  inline Double_t GetModuleSize() const {return fModuleSize;}
-  
-  inline Double_t GetPSLead()  const {return fPSLead;}
-  inline Double_t GetPSScin()  const {return fPSScin;}
-  inline Double_t GetPSGap()   const {return fPSGap; }
-
-  inline Int_t    GetNLayers() const {return fNLayers;}
-  inline Double_t GetLead()    const {return fLead;}
-  inline Double_t GetScin()    const {return fScin;}
-  inline Double_t GetTyveec()  const {return fTyveec;}
-  inline Double_t GetThicknessLayer() const {return fThicknessLayer;}
-
-  /** Size of ECAL in super modules **/
-  inline Int_t GetXSize() const {return fXSize;}
-  inline Int_t GetYSize() const {return fYSize;}
-
-  /** Geant cuts information **/
-  inline Double_t GetElectronCut() const {return fECut;}
-  inline Double_t GetHadronCut()   const {return fHCut;}
-
-  inline Double_t GetCellSize()    const {return fCellSize;}
-  inline Double_t GetEcalHole(Int_t num) const {
-    if (num>-1&&num<3) return fEcalHole[num];
-    return -1;
-  }
-  inline Double_t GetEcalSize(Int_t num) const {
-    if (num>-1&&num<3) return fEcalSize[num];
-    return -1;
-  }
-  char GetType(Int_t x, Int_t y) const; //returns type of (X,Y) supercell
-  inline Int_t GetFastMC() const {return fFastMC;}
-  void DumpContainer() const;
-  
-  void FreeInstance();
-
-  /** key must be lower case. For example, if have in
-   ** geo file AaaA=90, then you should call 
-   ** GetVariableStrict("aaaa").
-   ** If variable not found, will return -1111 **/
-  Double_t GetVariable(const char* key);
-  /** key must be lower case. For example, if have in
-   ** geo file AaaA=90, then you should call 
-   ** GetVariableStrict("aaaa").
-   ** If variable not found, will generate Fatal **/
-  Double_t GetVariableStrict(const char* key);
-  TString GetStringVariable(const char* key);
-
-  void AddVariable(const char* key, const char* value);
-  /** Writes Inf to par, if write_str==1 fEcalStr also
-   ** writen **/
-  void FillGeoPar(CbmGeoEcalPar* par, Int_t write_str) const;
-  /** If data from Parameter file differs from ours **/
-  void CheckVariables();
-protected:
-
-  /** Text file constructor **/
-  CbmEcalInf(const char* filename);	
-  void CalculateHoleSize();
-  virtual ~CbmEcalInf();
-
-  static CbmEcalInf* fInf;
-  static Int_t fRefCount;
-
-  
-private:
-  /** Init all other variables from fVariables
-   ** and fEcalStr**/
-  void InitVariables();
-  /** Ignore a parameter during comparision **/
-  Bool_t ExcludeParameter(TString parname);
-  /** A map containing all variables
-   ** This variable should be saved in parameter file **/
-  TMap* fVariables;
-  /** Structure of ECAL as array of strings
-   ** This variable should be saved in parameter file **/
-  TObjArray fEcalStr;
-  /** x-position of ECAL center [cm]	 **/
-  Double_t fXPos;
-  /** y-position of ECAL center [cm] **/
-  Double_t fYPos;
-  /** z-position of ECAL front [cm] **/
-  Double_t fZPos;
-
-  /** Number of ECAL layers **/
-  Int_t fNLayers;
-
-  /** x-size of ecal in supermodules **/
-  Int_t fXSize;
-  /** y-size of ecal in supermodules **/
-  Int_t fYSize;
-
-  /** transverse supermodule size in cm **/
-  Double_t fModuleSize;
-
-  /** Thickness of PS lead [cm] **/
-  Double_t fPSLead;
-  /** Thickness of PS scintillator [cm] **/
-  Double_t fPSScin;
-  /** Gap between PS and ECAL [cm] **/
-  Double_t fPSGap;
-
-  /**Thickness of lead in one layer [cm] **/
-  Double_t fLead;
-  /**Thickness of scintillator in one layer [cm] **/
-  Double_t fScin;
-  /**Thickness of tyvec in one layer [cm] **/
-  Double_t fTyveec;
-  /**Total thickness of layer	[cm] **/
-  Double_t fThicknessLayer;
-  /**transverse size of ECAL cell for simulation [cm] **/
-  Double_t fCellSize;
-  /**Size of ECAL container [cm] **/
-  Double_t fEcalSize[3];
-  /**Size of ECAL beam hole [cm] **/
-  Double_t fEcalHole[3];
-
-  /**Electron cut for ECAL **/
-  Double_t fECut;
-  /**Hadron cut for ECAL **/
-  Double_t fHCut;
-
-  /**Flag to run Fast (1) or Full (0) MC code **/
-  Int_t fFastMC;
-
-  /** 1 if evething Ok **/
-  Int_t fSuccess;
-
-  TString fFileName;
-
-  CbmEcalInf(const CbmEcalInf&);
-  CbmEcalInf& operator=(const CbmEcalInf&);
-
-  ClassDef(CbmEcalInf,2);
-};
-
-inline char CbmEcalInf::GetType(Int_t x, Int_t y) const
-{
-  /** Returns the type of the module with position (x,y) **/
-  if (x<0||y<0||y>fEcalStr.GetLast()) return 0;
-  TObjString* str=(TObjString*)fEcalStr.At(y);
-  if (str->GetString().Length()<x) return 0;
-  char stri[2]={str->GetString()[x],0};
-  return atoi(stri);
-}
-
-inline void CbmEcalInf::FreeInstance()
-{
-	fRefCount--;
-	if (fRefCount==0)
-	{
-		delete this;
-		fInf=NULL;
-	}
-}
-#endif
diff --git a/ecal/CbmEcalLightMap.cxx b/ecal/CbmEcalLightMap.cxx
deleted file mode 100644
index 80587a59b99c33ba932f63db0541048b68710b7d..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalLightMap.cxx
+++ /dev/null
@@ -1,153 +0,0 @@
-#include "CbmEcalLightMap.h"
-
-#include "TSystem.h"
-
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <list>
-#include <stdlib.h>
-
-using namespace std;
-
-CbmEcalLightMap::CbmEcalLightMap(const char* fname, const char* title) 
-  : TNamed(fname, title),
-    fSSide(-1111.), fS(-1111), fSize(0), fData(NULL)
-{
-  Init(fname);
-}
-
-/** Read information from file **/
-void CbmEcalLightMap::Init(const char* filename)
-{
-  TString fn=filename;
-  gSystem->ExpandPathName(fn);
-  ifstream f(fn);
-  list<Double_t> lst;
-  string buf;
-  string token;
-  string message;
-  if (!f)
-  {
-    Fatal("Init","Can't open file %s.", filename);
-    return;
-  }
-
-  while(getline(f, buf))
-  {
-    if (buf.empty()) continue;
-    if (buf.find_first_not_of(" 	")==string::npos) continue;
-    //Skipping initial spaces
-    message=buf.substr(buf.find_first_not_of(" 	"));
-    if (message.empty()) continue;
-    //Removing comments
-    message=message.substr(0,message.find("#"));
-    if (message.empty()) continue;
-    while(!message.empty())
-    {
-      token=message.substr(0,message.find_first_of(" 	"));
-      if (token.empty()) break;
-      lst.push_back(atof(token.c_str()));
-      if (token==message) break;
-      token=message.substr(message.find_first_of(" 	"));
-      if (token.empty()) break;
-      if (token.find_first_not_of(" 	")==string::npos) break;
-      message=token.substr(token.find_first_not_of(" 	"));
-    }
-  }
-  f.close();
-
-  list<Double_t>::const_iterator p=lst.begin();
-  Double_t xsize;
-  Double_t ysize;
-  Double_t sqside;
-  Double_t l;
-  Double_t x;
-  Double_t y;
-  Double_t z;
-  Double_t v;
-  Int_t n;
-  Int_t i;
-
-  xsize=(*p); ++p; ysize=(*p); ++p; sqside=(*p); ++p;
-  fS=(Int_t)((xsize+0.00001)/sqside);
-  fSize=fS*fS; fSSide=sqside/xsize;
-  fData=new Double_t[fSize];
-  for(i=0;i<fSize;i++)
-    fData[i]=-1111;
-  for(;;)
-  {
-    if (p==lst.end()) break;
-    l=(*p); ++p;
-    if (p==lst.end()) break;
-    x=(*p); ++p;
-    if (p==lst.end()) break;
-    y=(*p); ++p;
-    if (p==lst.end()) break;
-    z=(*p); ++p;
-    if (p==lst.end()) break;
-    v=(*p); ++p;
-    x/=xsize; y/=ysize;
-    n=GetNum(x ,y);
-    if (n>=fSize)
-    {
-      Info("Init","Data is not selfconsistent %f (%f, %f, %f), %d", l, x, y, z, fSize);
-    }
-    fData[n]=v;
-  }
-  lst.clear();
-  FillGaps();
-  Normalize();
-}
-
-/** Fix a light collection map **/
-void CbmEcalLightMap::FillGaps()
-{
-  Int_t i;
-  Int_t j;
-  Double_t x;
-  Double_t y;
-  Int_t n[3];
-  Double_t v;
-  Int_t d;
-
-  for(i=0;i<fSize;i++)
-  if (fData[i]<0)
-  {
-    x=(i%fS)*fSSide-0.5+fSSide/2.0;
-    y=(i/fS)*fSSide-0.5+fSSide/2.0;
-    n[0]=GetNum( x,-y);
-    n[1]=GetNum(-x, y);
-    n[2]=GetNum(-x,-y);
-    v=0; d=0;
-    for(j=0;j<3;j++)
-    if (n[j]>=0&&fData[n[j]]>=0)
-      { d++; v+=fData[n[j]]; }
-    if (d>0)
-    {
-      v/=d; fData[i]=v;
-      if (fData[n[0]]<=0) fData[n[0]]=v;
-      if (fData[n[1]]<=0) fData[n[1]]=v;
-      if (fData[n[2]]<=0) fData[n[2]]=v;
-    }
-    else
-      Info("FillGaps","No data for (%f,%f)", x, y);
-  }
-}
-
-/** Set average efficiency of light collection to 1.0 **/
-void CbmEcalLightMap::Normalize()
-{
-  Int_t i;
-  Int_t n=0;
-  Double_t v=0;
-  for(i=0;i<fSize;i++)
-    if (fData[i]>0)
-      { v+=fData[i]; n++; }
-  v/=n;
-  for(i=0;i<fSize;i++)
-    if (fData[i]>0)
-      fData[i]/=v;
-}
-
-ClassImp(CbmEcalLightMap)
diff --git a/ecal/CbmEcalLightMap.h b/ecal/CbmEcalLightMap.h
deleted file mode 100644
index 59c848c55b90be0ca9b6ad9eeb6cbf48123617e6..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalLightMap.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef CBMECALLIGHTMAP_H
-#define CBMECALLIGHTMAP_H
-
-#include "TNamed.h"
-
-class CbmEcalLightMap : public TNamed
-{
-public:
- CbmEcalLightMap() : TNamed(), fSSide(0.), fS(0), fSize(0), fData(NULL) {};
-  CbmEcalLightMap(const char* fname, const char* title="Light collection efficiency map");
-  Double_t Data(Double_t x, Double_t y)
-    {Int_t n=GetNum(x,y); if (n<0) return n; return fData[n];}
-  Int_t GetNum(Double_t x, Double_t y)
-  {
-    Double_t lx=x+0.5; 
-    Double_t ly=y+0.5;
-    if (lx<0) lx=0; 
-    if (ly<0) ly=0;
-    if (lx>1) lx=1; 
-    if (ly>1) ly=1;
-    Int_t ix=(Int_t)(lx/fSSide);
-    Int_t iy=(Int_t)(ly/fSSide);
-    return iy*fS+ix;
-  }
-  virtual ~CbmEcalLightMap() {delete fData;}
-private:
-  /** Read information from file **/
-  void Init(const char* filename);
-  /** Fix a light collection map **/
-  void FillGaps();
-  /** Set average efficiency of light collection to 1.0 **/
-  void Normalize();
-  /** Step of the light map **/
-  Double_t fSSide;		//!
-  /** Size of side of the light map in steps**/
-  Int_t fS;			//!
-  /** Size of the light map **/
-  Int_t fSize;			//!
-  /** Light collection efficiency map **/
-  Double_t* fData;		//!
-
-  CbmEcalLightMap(const CbmEcalLightMap&);
-  CbmEcalLightMap& operator=(const CbmEcalLightMap&);
-
-  ClassDef(CbmEcalLightMap, 1)
-};
-
-#endif
diff --git a/ecal/CbmEcalLinkDef.h b/ecal/CbmEcalLinkDef.h
deleted file mode 100644
index 42f4d795442998cddf949c5a4a1b553cb37c0a00..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalLinkDef.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// $Id: EcalLinkDef.h,v 1.12 2006/09/18 07:58:04 prokudin Exp $
-
-#ifdef __CINT__
-
-#pragma link off all globals;
-#pragma link off all classes;
-#pragma link off all functions;
- 
-#pragma link C++ class  CbmEcal;
-#pragma link C++ class  CbmEcalDetailed;
-#pragma link C++ class  CbmEcalCellMC+;
-#pragma link C++ class  CbmEcalModule+;
-#pragma link C++ class  CbmEcalStructure+;
-#pragma link C++ class  CbmEcalInf+;
-#pragma link C++ class  CbmGeoEcalPar;
-#pragma link C++ class  CbmEcalContFact;
-#pragma link C++ class  CbmEcalDrawer+;
-#pragma link C++ class  CbmEcalDrawer2;
-#pragma link C++ class  CbmEcalAnalysis+;
-#pragma link C++ class  CbmEcalAnalysisDS+;
-#pragma link C++ class  CbmEcalAnalysisCluster;
-#pragma link C++ class  CbmEcalHitProducer+;
-#pragma link C++ class  CbmEcalHitProducerFastMC+;
-#pragma link C++ class  CbmEcalReconstructionFastMC+;
-#pragma link C++ class  CbmEcalDrawer+;
-#pragma link C++ class  CbmEcalPhotonCalibrator+;
-#pragma link C++ class  CbmEcalShowerCalibrator+;
-#pragma link C++ class  CbmEcalOShowerCalibrator+;
-#pragma link C++ class  CbmEcalUrqmdCalibrator+;
-#pragma link C++ class  CbmEcalSCurveLib;
-#pragma link C++ class  CbmEcalSCurveLibRecord;
-#pragma link C++ class  CbmEcalTracking;
-#pragma link C++ class  CbmEcalTrackExtrapolation;
-#pragma link C++ class  CbmEcalStructureFiller;
-#pragma link C++ class  CbmEcalTrackExport;
-#pragma link C++ class  CbmEcalStructureExport;
-#pragma link C++ class  CbmEcalQualityCheck;
-#pragma link C++ class  CbmEcalClusterFinder;
-#pragma link C++ class  CbmEcalClusterFinderV2;
-#pragma link C++ class  CbmEcalTrackImport;
-#pragma link C++ class  CbmEcalCalibration;
-#pragma link C++ class  CbmEcalCalibrationV2;
-#pragma link C++ class  CbmEcalParam+;
-#pragma link C++ class  CbmEcalMatching;
-#pragma link C++ class  CbmEcalAnalysisPi0;
-#pragma link C++ class  CbmEcalAnalysisPair;
-#pragma link C++ class  CbmEcalAnalysisNeutron;
-#pragma link C++ class  CbmEcalAnalysisMaterial;
-#pragma link C++ class  CbmEcalTimeDigitizer;
-#pragma link C++ class  CbmEcalIdentification;
-#pragma link C++ class  CbmEcalLightMap;
-#pragma link C++ class  CbmEcalAnalysisUniformity;
-#pragma link C++ class  CbmEcalAnalysisSimple;
-#pragma link C++ class  CbmEcalAnalysisShape;
-#pragma link C++ class  CbmEcalAnalysisJPsi;
-#pragma link C++ class  CbmEcalAnalysisDst;
-#pragma link C++ class  CbmEcalAnalysisBSh;
-#pragma link C++ class  CbmEcalAnalysisEres;
-#pragma link C++ class  CbmEcalMaximumLocator;
-#pragma link C++ class  CbmEcalAnalysisSShape;
-#pragma link C++ class  CbmEcalShLibRecord;
-#pragma link C++ class  CbmEcalShLib;
-#pragma link C++ class  CbmEcalShLibTable;
-#pragma link C++ class  CbmEcalShLibNN;
-#pragma link C++ class  CbmEcalReco;
-#pragma link C++ class  CbmEcalPosLib;
-#pragma link C++ class  CbmEcalReco2;
-#pragma link C++ class  CbmEcalShLibCorr;
-#pragma link C++ class  CbmEcalShLibCorrTable;
-#pragma link C++ class  CbmEcalShLibCorrRecord;
-#pragma link C++ class  CbmEcalRecoCorr;
-#pragma link C++ class  CbmEcalDigi;
-#pragma link C++ class  CbmEcalPrepare;
-#pragma link C++ class  CbmEcalAnalysisCalib;
-
-#endif
diff --git a/ecal/CbmEcalMatching.cxx b/ecal/CbmEcalMatching.cxx
deleted file mode 100644
index 82f8bf78c5833576673086364364f9a6051ecc1b..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalMatching.cxx
+++ /dev/null
@@ -1,694 +0,0 @@
-#include "CbmEcalMatching.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "TClonesArray.h"
-#include "TMath.h"
-#include "TTree.h"
-
-#include "CbmEcalRecParticle.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalCluster.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalShLib.h"
-#include "CbmEcalParam.h"
-#include "CbmEcalCellMC.h"
-
-#include <iostream>
-
-using namespace std;
-
-
-/** Standard constructor **/
-CbmEcalMatching::CbmEcalMatching(const char* name, const Int_t verbose, const char* config)
-  : FairTask(name, verbose),
-    fReco(NULL),
-    fMCTracks(NULL),
-    fPoints(NULL),
-    fClusters(NULL),
-    fStr(NULL),
-    fShLib(NULL),
-    fThreshold(0.8),
-    fPhotonThr(0.95),
-    fMotherThr(1.05),
-    fEv(0),
-    fPreCluster(),
-    fClusterE(0.),
-    fE(),
-    fEpred(),
-    fEsum(0.),
-    fS(0.),
-    fP(),
-    fCell(NULL),
-    fToTree(kFALSE),
-    fTree(NULL),
-    fMCNum(0),
-    fPx(0.),
-    fPy(0.),
-    fPz(0.),
-    fRE(0.),
-    fMCPx(0.),
-    fMCPy(0.),
-    fMCPz(0.),
-    fMCE(0.),
-    fPDG(0),
-    fChi2(0.),
-    fNM(0),
-    fNC(0),
-    fConfigName(config),
-    fAlgo(0)
-{
-  CbmEcalParam* par=new CbmEcalParam("MatchingParam", config);
-
-  fThreshold=par->GetDouble("threshold");
-  if (fThreshold<0.5)
-    Warning("CbmEcalMatching","Energy threshold less than half energy deposition in cluster.");
-  fMotherThr=par->GetDouble("motherthreshold");
-  fPhotonThr=par->GetDouble("photonthreshold");
-  fAlgo=par->GetInteger("algorithm");
-  if (fVerbose>10)
-  {
-    Info("CbmEcalMatching", "Using Threshold --- %f, Mother Threshold --- %f, Photon Threshold --- %f.", fThreshold, fMotherThr, fPhotonThr);
-    switch (fAlgo)
-    {
-      case 1: Info("CbmEcalMatching", "Prefer match with photons. (Algorithm)"); break;
-      case 2: Info("CbmEcalMatching", "Using complex algorithm"); break;
-      case 3: Info("CbmEcalMatching", "Using simple algorithm"); break;
-      default: Warning("CbmEcalMatching", "Unknown algorithm");
-    }
-  }
-
-  delete par;
-}
-
-
-/** Task initialization **/
-InitStatus CbmEcalMatching::Init()
-{
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fReco=(TClonesArray*)io->GetObject("EcalReco");
-  if (!fReco)
-  {
-    Fatal("Init", "Can't find an array of reconstructed photons.");
-    return kFATAL;
-  }
-  fMCTracks=(TClonesArray*)io->GetObject("MCTrack");
-  if (!fMCTracks)
-  {
-    Fatal("Init", "Can't find array of MC tracks");
-    return kFATAL;
-  }
-  fPoints=(TClonesArray*)io->GetObject("EcalPoint");
-  if (!fPoints)
-  {
-    Fatal("Init", "Can't find array of Ecal Points");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init","Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fClusters=(TClonesArray*)io->GetObject("EcalClusters");
-  if (!fClusters)
-  {
-    Fatal("Init", "Can't find array of clusters");
-    return kFATAL;
-  }
-  fShLib=(CbmEcalShLib*)io->GetObject("EcalShLib");
-  if (!fShLib)
-  {
-    Fatal("Init", "No shower library found in system. Will continue without chi2 calculation.");
-    return kFATAL;
-  }
-
-  fEv=0; 
-  return kSUCCESS;
-}
-
-/** Exec for task **/
-void CbmEcalMatching::Exec(Option_t*)
-{
-  fEv++;
-  if (fVerbose>0)
-    Info("Exec", "Event number %d. ", fEv);
-  Int_t i;
-  Int_t n=fReco->GetEntriesFast();
-  CbmEcalRecParticle* p;
-  if (fToTree) InitTree();
-  for(i=0;i<n;i++)
-  {
-    p=(CbmEcalRecParticle*)fReco->At(i);
-    FormEpred(p);
-    if (fEsum==0)
-    {
-      if (fVerbose>0)
-	Warning("Exec", "Predicted energy for reconstructed particle %d is zero. Matching failed", i);
-      continue;
-    }
-    MatchP(p);
-/*
-    FormPreCluster(p);
-    FormE();
-    Match(p);
-*/
-  }
-}
-
-/** Get form of energy deposition of the particle **/
-void CbmEcalMatching::FormEpred(CbmEcalRecParticle* p)
-{
-  CbmEcalCluster* cluster=(CbmEcalCluster*)fClusters->At(p->ClusterNum());
-  Int_t k=0;
-  Int_t type;
-//  static Double_t module=fStr->GetEcalInf()->GetModuleSize();
-//  Double_t cellsize;
-  CbmEcalCell* cell;
-  Double_t x;
-  Double_t y;
-  Double_t cx;
-  Double_t cy;
-  Double_t r;
-  Double_t theta;
-  Double_t phi;
-  
-  fEpred.Set(cluster->Size());
-  fEsum=0;
-  for(k=0;k<cluster->Size();k++)
-  {
-    cell=fStr->GetHitCell(cluster->CellNum(k));
-    type=cell->GetType();
-//    cellsize=module/type;
-    cx=cell->GetCenterX(); x=cx;
-    cy=cell->GetCenterY(); y=cy;
-    r=TMath::Sqrt(x*x+y*y);
-    x-=p->X(); 
-    y-=p->Y();
-
-    /** TODO: should be Z of the cell**/
-    theta=TMath::ATan(r/fStr->GetEcalInf()->GetZPos());
-    theta*=TMath::RadToDeg();
-    phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-    if (cy<0) phi=360.0-phi;
-
-    fEpred[k]=fShLib->GetResponse(x, y, phi, theta, p->E(), type);
-    fEsum+=fEpred[k];
-  }
-  fS=0;
-  for(k=0;k<cluster->Size();k++)
-  {
-    cell=fStr->GetHitCell(cluster->CellNum(k));
-    fS+=fEpred[k]/fEsum*cell->GetTotalEnergy();
-  }
-/*
-  {
-    for(k=0;k<cluster->Size();k++)
-    {
-      cell=fStr->GetHitCell(cluster->CellNum(k));
-      type=cell->GetType();
-      cellsize=module/type;
-      cx=cell->GetCenterX(); x=cx;
-      cy=cell->GetCenterY(); y=cy;
-      r=TMath::Sqrt(x*x+y*y);
-      x-=p->X(); 
-      y-=p->Y();
-
-      theta=TMath::ATan(r/fStr->GetEcalInf()->GetZPos());
-      theta*=TMath::RadToDeg();
-      phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-      
-//      cerr << "(" << x << "," << y << ") " << fEpred[k] << "," << fS << endl;
-    }
-  }
-*/
-}
-
-/** Add to particle constants to track and all its mothers **/
-void CbmEcalMatching::AddTrackP(Int_t track, Double_t e, Int_t cell)
-{
-  CbmMCTrack* tr;
-  Int_t num;
-  map<Int_t, Double_t>::const_iterator i;
-
-  for(i=fP.begin(); i!=fP.end();++i)
-    if ((*i).first==track) break;
-  if (i!=fP.end())
-    fP[track]+=e*fEpred[cell]/fEsum;
-  else
-    fP[track]=e*fEpred[cell]/fEsum;
-
-  tr=(CbmMCTrack*)fMCTracks->At(track);
-  if (tr==NULL)
-  {
-    Warning("AddTrackP", "Can't find MCTrack number %d.", track);
-    return;
-  }
-  num=tr->GetMotherId();
-  if (num<0) return;
-  tr=(CbmMCTrack*)fMCTracks->At(num);
-  if (tr==NULL)
-  {
-    Warning("AddTrackP", "Can't find MCTrack number %d.", num);
-    return;
-  }
-  if (tr->GetPdgCode()==22||TMath::Abs(tr->GetPdgCode())==11)
-    AddTrackP(num, e, cell);
-}
-
-  
-/** Match MCTrack and reconstructed partile using shower shape **/
-void CbmEcalMatching::MatchP(CbmEcalRecParticle* p)
-{
-  CbmEcalCluster* cluster=(CbmEcalCluster*)fClusters->At(p->ClusterNum());
-  fP.clear();
-  Int_t k;
-  CbmEcalCellMC* cell;
-  map<Int_t, Float_t>::const_iterator q;
-  map<Int_t, Double_t>::const_iterator i;
-  pair<Int_t, Double_t> max; max.first=-1111; max.second=0;
-  pair<Int_t, Double_t> max_photon; max_photon.second=0;
-  CbmMCTrack* tr;
-  CbmEcalCluster* cls;
-
-  
-  for(k=0;k<cluster->Size();k++)
-  {
-    cell=(CbmEcalCellMC*)fStr->GetHitCell(cluster->CellNum(k));
-    for(q=cell->GetTrackEnergyBegin();q!=cell->GetTrackEnergyEnd();++q)
-    {
-//      cerr << "Energy: " << (*q).second << ", " << (*q).first << "[" << fEpred[k] << "," << fEsum << "]" << endl;
-      AddTrackP((*q).first, (*q).second, k);
-    }
-  }
-
-  switch (fAlgo)
-  {
-    case 1:MatchP1(p); break;
-    case 2:MatchP2(p); break;
-    case 3:MatchP3(p); break;
-    default: Error("MatchP", "Unknown algorithm: %d.", fAlgo);
-  }
-
-  if (!fTree) return;
-  fMCNum=p->MCTrack();
-  if (fMCNum!=-1111)
-  {
-    tr=(CbmMCTrack*)fMCTracks->At(fMCNum);
-    fPDG=tr->GetPdgCode();
-    fMCE=tr->GetEnergy();
-    fMCPx=tr->GetPx();
-    fMCPy=tr->GetPy();
-    fMCPz=tr->GetPz();
-  }
-  else
-  {
-    fPDG=0;
-    fMCE=-1111;
-    fMCPx=-1111;
-    fMCPy=-1111;
-    fMCPz=-1111;
-  }
-  fPx=p->Px();
-  fPy=p->Py();
-  fPz=p->Pz();
-  fRE=p->E();
-  cls=(CbmEcalCluster*)fClusters->At(p->ClusterNum());
-  fChi2=cls->Chi2();
-  fNM=cls->Maxs();
-  fNC=cls->Size();
-  fTree->Fill();
-}
-
-/** First realization of matching **/
-void CbmEcalMatching::MatchP1(CbmEcalRecParticle* p)
-{
-  CbmMCTrack* tr;
-  pair<Int_t, Double_t> max; max.first=-1111; max.second=0;
-  pair<Int_t, Double_t> max_photon; max_photon.second=0;
-  map<Int_t, Double_t>::const_iterator i;
-
-//  cout << "here!" << endl;
-  for(i=fP.begin(); i!=fP.end();++i)
-  {
-//    cout << (*i).second/fS << endl;
-    if ((*i).second/fS<fThreshold) continue;
-    if ((*i).second>max.second)
-      max=(*i);
-    tr=(CbmMCTrack*)fMCTracks->At((*i).first);
-    if (tr==NULL)
-    {
-      Warning("Match", "Can't find MCTrack number %d.", (*i).first);
-      return;
-    }
-    if (tr->GetPdgCode()!=22) continue;
-    if ((*i).second>max_photon.second)
-      max_photon=(*i);
-  }
-  if (max.first==-1111)
-  {
-    if (fVerbose>2) 
-      Info("MatchP1", "Matching failed for reconstructed photon (%f, %f).", p->X(), p->Y());
-    return;
-  }
-  if (max_photon.second>fPhotonThr*max.second)
-    p->SetMCTrack(max_photon.first);
-  else
-    p->SetMCTrack(max.first);
-}
-
-/** Second realization of matching **/
-void  CbmEcalMatching::MatchP2(CbmEcalRecParticle* p)
-{
-  CbmMCTrack* tr;
-  pair<Int_t, Double_t> max; max.first=-1111; max.second=0;
-  list<pair<Int_t, Double_t> > good;
-  list<pair<Int_t, Double_t> > remove;
-  list<pair<Int_t, Double_t> >::const_iterator j;
-  pair<Int_t, Double_t> max_photon; max_photon.second=0;
-  map<Int_t, Double_t>::const_iterator i;
-  Int_t oldsize=0;
-
-  good.clear();
-  //cerr << fP.size() << endl;
-  for(i=fP.begin(); i!=fP.end();++i)
-  {
-    if ((*i).second/fS<fThreshold) continue;
-    good.push_back((*i));
-  }
-  if (good.size()==0)
-  {
-    if (fVerbose>2)
-      Info("MatchP2", "Matching failed for reconstructed photon (%f, %f).", p->X(), p->Y());
-    return;
-  }
-  while(good.size()!=1)
-  {
-    remove.clear();
-    oldsize=good.size();
-    if (fVerbose>100)
-      Info("MatchP2", "Size of matching track list: %d.", (Int_t)good.size());
-    for(j=good.begin();j!=good.end();j++)
-    {
-      tr=(CbmMCTrack*)fMCTracks->At((*j).first);
-      if (tr==NULL)
-      {
-        Warning("MatchP2", "Can't find MCTrack number %d.", (*i).first);
-        return;
-      }
-      while(tr!=NULL)
-      {
-        for(i=fP.begin(); i!=fP.end();++i)
-	  if ((*i).first==tr->GetMotherId())
-	    break;
-        if (i!=fP.end())
-	{
-	  if ((*i).second>fMotherThr*(*j).second)
-	  {
-	    remove.push_back(*j);
-	    break;
-	  }
-          else
-	    remove.push_back(*i);
-	}
-	if (tr->GetMotherId()>=0)
-	  tr=(CbmMCTrack*)fMCTracks->At(tr->GetMotherId());
-	else
-	  break;
-        if (tr==NULL)
-        {
-          Warning("MatchP2", "Can't find MCTrack.");
-          return;
-        }
-	if (tr->GetPdgCode()!=22&&TMath::Abs(tr->GetPdgCode())!=11)
-	  break;
-      }
-    }
-
-    if (remove.empty())
-    {
-      if (fVerbose>2)
-      {
-	Info("MatchP2","Can't remove any from %d tracks.", (Int_t)good.size());
-	if (fVerbose>100)
-        for(j=good.begin();j!=good.end();j++)
-        {
-	  tr=(CbmMCTrack*)fMCTracks->At((*j).first);
-//	  cerr << "Good: (" << (*j).first << "[" << tr->GetPdgCode() << "," << tr->GetEnergy() <<"]"<< "," << (*j).second << ") " << p->E() << endl;
-        }
-      }
-      return;
-    }
-    if (fVerbose>100)
-    {
-      Info("MatchP2", "Size of list of tracks to remove: %d.", (Int_t)remove.size());
-      for(j=remove.begin();j!=remove.end();j++)
-      {
-	tr=(CbmMCTrack*)fMCTracks->At((*j).first);
-//	cerr << "Remove: (" << (*j).first << "[" << tr->GetPdgCode() << "," << tr->GetEnergy() << "]"<< "," << (*j).second << ")" << endl;
-      }
-      for(j=good.begin();j!=good.end();j++)
-      {
-	tr=(CbmMCTrack*)fMCTracks->At((*j).first);
-//	cerr << "Good: (" << (*j).first << "[" << tr->GetPdgCode() << "," << tr->GetEnergy() <<"]"<< "," << (*j).second << ") " << p->E() << endl;
-      }
-    }
-    for(j=remove.begin();j!=remove.end();j++)
-//      good.remove(find(good.begin(), good.end(), *j));
-      good.remove(*j);
-    if (oldsize==(Int_t)good.size())
-    {
-      if (fVerbose>2)
-	Info("MatchP2","No tracks was removed!");
-      return;
-    }
-  }
-  p->SetMCTrack((*good.begin()).first);
-}
-
-/** Third realization of matching **/
-void  CbmEcalMatching::MatchP3(CbmEcalRecParticle* p)
-{
-//  CbmMCTrack* tr;
-  pair<Int_t, Double_t> max; max.first=-1111; max.second=0;
-  map<Int_t, Double_t>::const_iterator i;
-//  Int_t n;
-
-  for(i=fP.begin(); i!=fP.end();++i)
-  {
-    if ((*i).second/fS<fThreshold) continue;
-    if ((*i).second>max.second)
-      max=(*i);
-    else
-      if ((*i).second==max.second&&(*i).first<max.first)
-	max=(*i);
-  }
-  if (max.first==-1111)
-  {
-    if (fVerbose>2) 
-      Info("MatchP1", "Matching failed for reconstructed photon (%f, %f).", p->X(), p->Y());
-    return;
-  }
-  p->SetMCTrack(max.first);
-}
-
-/** Form a precluster **/
-void CbmEcalMatching::FormPreCluster(CbmEcalRecParticle* p)
-{
-  list<CbmEcalCell*> neib;
-  CbmEcalCell* celli;
-  Int_t i;
-  CbmEcalCluster* cls=(CbmEcalCluster*)fClusters->At(p->ClusterNum());
-  CbmEcalCell* cell;
-
-  fPreCluster.clear();
-  fClusterE=0;
-  cell=fStr->GetHitCell(p->CellNum());
-  cell->GetNeighborsList(0, neib);
-  for(i=0;i<cls->Size();i++)
-  {
-    celli=fStr->GetHitCell(cls->CellNum(i));
-    if (find(neib.begin(), neib.end(), celli)!=neib.end())
-    {
-      fPreCluster.push_back(celli);
-      fClusterE+=celli->GetTotalEnergy();
-    }
-  }
-  fPreCluster.push_back(cell);
-  fClusterE+=cell->GetTotalEnergy();
-}
-
-/** Add energy to track and all its mothers **/
-void CbmEcalMatching::AddTrackE(Int_t track, Double_t e)
-{
-  CbmMCTrack* tr;
-  Int_t num;
-
-  fE[track]+=e;
-
-  tr=(CbmMCTrack*)fMCTracks->At(track);
-  if (tr==NULL)
-  {
-    Warning("AddTrackE", "Can't find MCTrack number %d.", track);
-    return;
-  }
-  num=tr->GetMotherId();
-  if (num<0) return;
-  tr=(CbmMCTrack*)fMCTracks->At(num);
-  if (tr==NULL)
-  {
-    Warning("AddTrackE", "Can't find MCTrack number %d.", num);
-    return;
-  }
-  if (tr->GetPdgCode()==22||TMath::Abs(tr->GetPdgCode())==11)
-    AddTrackE(num, e);
-}
-
-/** Form a map of energies for precluster **/
-void CbmEcalMatching::FormE()
-{
-  list<CbmEcalCell*>::const_iterator i;
-  map<Int_t, Float_t>::const_iterator p;
-  CbmEcalCellMC* cell;
-  fE.clear();
-  for(i=fPreCluster.begin();i!=fPreCluster.end();++i)
-  {
-    fCell=(*i); cell=(CbmEcalCellMC*)fCell;
-    for(p=cell->GetTrackEnergyBegin();p!=cell->GetTrackEnergyEnd();++p)
-      AddTrackE((*p).first, (*p).second);
-  }
-}
-
-/** Match MCTrack and reconstructed particle **/
-void CbmEcalMatching::Match(CbmEcalRecParticle* p)
-{
-  map<Int_t, Double_t>::const_iterator i;
-  pair<Int_t, Double_t> max; max.first=-1111; max.second=0;
-  pair<Int_t, Double_t> max_photon; max_photon.second=0;
-  CbmMCTrack* tr;
-  CbmEcalCluster* cls;
-
-  for(i=fE.begin(); i!=fE.end();++i)
-  {
-    if ((*i).second/fClusterE<fThreshold) continue;
-    if ((*i).second>max.second)
-      max=(*i);
-    tr=(CbmMCTrack*)fMCTracks->At((*i).first);
-    if (tr==NULL)
-    {
-      Warning("Match", "Can't find MCTrack number %d.", (*i).first);
-      return;
-    }
-    if (tr->GetPdgCode()!=22) continue;
-    if ((*i).second>max_photon.second)
-      max_photon=(*i);
-  }
-  if (max.first==-1111)
-  {
-    if (fVerbose>2)
-      Info("Match", "Matching failed for reconstructed photon (%f, %f).", p->X(), p->Y());
-    return;
-  }
-  if (max_photon.second>fPhotonThr*max.second)
-    p->SetMCTrack(max_photon.first);
-  else
-    p->SetMCTrack(max.first);
-  if (!fTree) return;
-  fMCNum=p->MCTrack();
-  tr=(CbmMCTrack*)fMCTracks->At(fMCNum);
-  fPx=p->Px();
-  fPy=p->Py();
-  fPz=p->Pz();
-  fRE=p->E();
-  cls=(CbmEcalCluster*)fClusters->At(p->ClusterNum());
-  fChi2=cls->Chi2();
-  fNM=cls->Maxs();
-  fNC=cls->Size();
-  fPDG=tr->GetPdgCode();
-  fMCE=tr->GetEnergy();
-  fMCPx=tr->GetPx();
-  fMCPy=tr->GetPy();
-  fMCPz=tr->GetPz();
-  fTree->Fill();
-}
-
-/** Initialization of output tree **/
-void CbmEcalMatching::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("ecal_matching","Ecal matching tree");
-  fTree->Branch("ev", &fEv, "ev/I");
-  fTree->Branch("mcn", &fMCNum, "mcn/I");
-  fTree->Branch("nm", &fNM, "nm/I");
-  fTree->Branch("nc", &fNC, "nc/I");
-  fTree->Branch("pdg", &fPDG, "PDG/I");
-  fTree->Branch("chi2", &fChi2, "chi2/D");
-  fTree->Branch("px", &fPx, "px/D");
-  fTree->Branch("py", &fPy, "py/D");
-  fTree->Branch("pz", &fPz, "pz/D");
-  fTree->Branch("e", &fRE, "e/D");
-  fTree->Branch("mcpx", &fMCPx, "mcpx/D");
-  fTree->Branch("mcpy", &fMCPy, "mcpy/D");
-  fTree->Branch("mcpz", &fMCPz, "mcpz/D");
-  fTree->Branch("mce", &fMCE, "mce/D");
-}
-
-/** Finish task **/
-void CbmEcalMatching::Finish()
-{
-  if (fTree) fTree->Write();
-}
-
-/** virtual destructor **/
-CbmEcalMatching::~CbmEcalMatching()
-{
-  ;
-}
-  
-/** Only to comply with framework **/
-CbmEcalMatching::CbmEcalMatching()
-  : FairTask(),
-    fReco(NULL),
-    fMCTracks(NULL),
-    fPoints(NULL),
-    fClusters(NULL),
-    fStr(NULL),
-    fShLib(NULL),
-    fThreshold(0.8),
-    fPhotonThr(0.95),
-    fMotherThr(1.05),
-    fEv(0),
-    fPreCluster(),
-    fClusterE(0.),
-    fE(),
-    fEpred(),
-    fEsum(0.),
-    fS(0.),
-    fP(),
-    fCell(NULL),
-    fToTree(kFALSE),
-    fTree(NULL),
-    fMCNum(0),
-    fPx(0.),
-    fPy(0.),
-    fPz(0.),
-    fRE(0.),
-    fMCPx(0.),
-    fMCPy(0.),
-    fMCPz(0.),
-    fMCE(0.),
-    fPDG(0),
-    fChi2(0.),
-    fNM(0),
-    fNC(0),
-    fConfigName(""),
-    fAlgo(0)
-{
-}
-ClassImp(CbmEcalMatching)
diff --git a/ecal/CbmEcalMatching.h b/ecal/CbmEcalMatching.h
deleted file mode 100644
index 41e4c7cdd1533513bf9e5a5d05a928859c317f3a..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalMatching.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/** Matching between MC photons and reconstructed photons **/
-
-#ifndef CBMECALMATCHING_H
-#define CBMECALMATCHING_H
-
-#include "FairTask.h"
-#include <list>
-#include <map>
-#include "TArrayD.h"
-
-class TClonesArray;
-class CbmEcalCell;
-class CbmEcalRecParticle;
-class TTree;
-class CbmEcalStructure;
-class CbmEcalShLib;
-
-class CbmEcalMatching : public FairTask
-{
-public:
-  /** Only to comply with framework **/
-  CbmEcalMatching();
-  /** Standard constructor **/
-  CbmEcalMatching(const char* name, const Int_t verbose, const char* configname);
-
-  /** Task initialization **/
-  virtual InitStatus Init();
-
-  /** Exec for task **/
-  virtual void Exec(Option_t* opt);
-  
-  /** Finish task **/
-  virtual void Finish();
-
-  /** Get/set threshold **/
-  void SetThreshold(Double_t threshold=0.8) {fThreshold=threshold;}
-  Double_t GetThreshold() const {return fThreshold;}
-  /** Get/set photon threshold **/
-  void SetPhotonThreshold(Double_t threshold=0.95) {fPhotonThr=threshold;}
-  Double_t GetPhotonThreshold() const {return fPhotonThr;}
-  /** Get/set mother threshold **/
-  void SetMotherThreshold(Double_t threshold=1.05) {fMotherThr=threshold;}
-  Double_t GetMotherThreshold() const {return fMotherThr;}
-  /** virtual destructor **/
-  ~CbmEcalMatching();
-
-  /** Set output to tree **/
-  void SetOutToTree(Bool_t totree=kFALSE) {fToTree=totree;}
-private:
-  /** Form a precluster **/
-  void FormPreCluster(CbmEcalRecParticle* p);
-  /** Form a map of energies for precluster **/
-  void FormE();
-  /** Add energy to track and all its mothers **/
-  void AddTrackE(Int_t track, Double_t e);
-  /** Match MCTrack and reconstructed particle **/
-  void Match(CbmEcalRecParticle* p);
-  /** Get form of energy deposition of the particle **/
-  void FormEpred(CbmEcalRecParticle* p);
-  /** Match MCTrack and reconstructed partile using shower shape **/
-  void MatchP(CbmEcalRecParticle* p);
-  /** First realization of matching **/
-  void MatchP1(CbmEcalRecParticle* p);
-  /** Second realization of matching **/
-  void MatchP2(CbmEcalRecParticle* p);
-  /** Third realization of matching **/
-  void MatchP3(CbmEcalRecParticle* p);
-  /** Add to particle constants to track and all its mothers **/
-  void AddTrackP(Int_t track, Double_t e, Int_t cell);
-  /** An array of reconstructed photons **/
-  TClonesArray* fReco;			//!
-  /** An array of MC tracks **/
-  TClonesArray* fMCTracks;		//!
-  /** An array of calorimeter points **/
-  TClonesArray* fPoints;		//!
-  /** An array of calorimeter clustes **/
-  TClonesArray* fClusters;		//!
-  /** Structure of the calorimeter system **/
-  CbmEcalStructure* fStr;		//!
-  /** Shower library. A new implementation **/
-  CbmEcalShLib* fShLib;			//!
-
-  /** A threshold: if energy of photon is more than threshold*Ecluster
-   ** than cluster is formed by that photon **/
-  Double_t fThreshold;
-  /** If energy of max photon > fPhotonThr*energy of any other particle will match with photon **/
-  Double_t fPhotonThr;
-  /** If energy of mother > fMotherThr*Energy_{doughtier} then use mother for cluster matching instead
-   ** of doughtier**/
-  Double_t fMotherThr;
-
-  /** An event number **/
-  Int_t fEv;
-
-  /** A precluster **/
-  std::list<CbmEcalCell*> fPreCluster;	//!
-  /** An energy of precluster **/
-  Double_t fClusterE;
-  /** An energy associated with track number **/
-  std::map<Int_t, Double_t> fE;		//!
-  /** Predicted by shower library energy in every cell of the cluster **/
-  TArrayD fEpred;
-  /** Total predicted energy depostion of the particle in the cluster **/
-  Double_t fEsum;
-  /** A cluster constant **/
-  Double_t fS;
-  /** An MC particle constant associated with track number **/
-  std::map<Int_t, Double_t> fP;		//!
-
-  /** Current cell **/
-  CbmEcalCell* fCell;			//!
-
-  /** Shoul write information to tree? **/
-  Bool_t fToTree;
-  /** An output tree **/
-  TTree* fTree;				//!
-  /** Init tree **/
-  void InitTree();
-  /** Number of corresponding MC track **/
-  Int_t fMCNum;
-  /** Reconstructed information **/
-  Double_t fPx;
-  Double_t fPy;
-  Double_t fPz;
-  Double_t fRE;
-  /** MC information **/
-  Double_t fMCPx;
-  Double_t fMCPy;
-  Double_t fMCPz;
-  Double_t fMCE;
-  Int_t fPDG;
-  /** Information about cluster **/
-  Double_t fChi2;
-  /** Number of maximums **/
-  Int_t fNM;
-  /** Number cells **/
-  Int_t fNC;
-
-  /** Name of configuration file **/
-  TString fConfigName;
-  /** Type of algorithm to use **/
-  Int_t fAlgo;
-
-  CbmEcalMatching(const CbmEcalMatching&);
-  CbmEcalMatching& operator=(const CbmEcalMatching&);
-
-  ClassDef(CbmEcalMatching, 1)
-};
-
-#endif
diff --git a/ecal/CbmEcalMaximumLocator.cxx b/ecal/CbmEcalMaximumLocator.cxx
deleted file mode 100644
index 930543a370b38cb732e0acb71e4a490f356b556d..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalMaximumLocator.cxx
+++ /dev/null
@@ -1,111 +0,0 @@
-#include "CbmEcalMaximumLocator.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalMaximum.h"
-#include "CbmEcalCell.h"
-
-#include "FairRootManager.h"
-
-#include "TClonesArray.h"
-
-#include <list>
-#include <iostream>
-
-using namespace std;
-
-CbmEcalMaximumLocator::CbmEcalMaximumLocator()
-  : FairTask(),
-    fMaximums(NULL),
-    fStr(NULL),
-    fECut(0.005),
-    fEvent(-1)
-{
-}
-
-CbmEcalMaximumLocator::CbmEcalMaximumLocator(const char* name, Int_t verbose)
-  : FairTask(name, verbose),
-    fMaximums(NULL),
-    fStr(NULL),
-    fECut(0.005),
-    fEvent(-1)
-{
-}
-
-CbmEcalMaximumLocator::~CbmEcalMaximumLocator()
-{
-  if (fMaximums)
-    delete fMaximums;
-}
-
-InitStatus CbmEcalMaximumLocator::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fMaximums=new TClonesArray("CbmEcalMaximum", 3000);
-  fManager->Register("EcalMaximums", "ECAL", fMaximums, kFALSE);
-  fEvent=0;
-  return kSUCCESS;
-}
-
-void CbmEcalMaximumLocator::Finish()
-{
-  fMaximums->Clear();
-}
-
-void CbmEcalMaximumLocator::Exec(const Option_t*)
-{
-  list<CbmEcalCell*> all;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  list<CbmEcalCell*>::const_iterator r;
-  Double_t e;
-  Double_t z=fStr->GetEcalInf()->GetZPos();
-  Double_t r1;
-  Double_t r2;
-  Double_t t;
-  Int_t n=0;
-
-  fEvent++;
-  fMaximums->Clear();
-  fStr->GetCells(all);
-  for(p=all.begin();p!=all.end();++p)
-  {
-    e=(*p)->GetTotalEnergy();
-    r1=(*p)->GetCenterX(); r1*=r1;
-    t=(*p)->GetCenterY(); t*=t;
-    r1=TMath::Sqrt(r1*r1+t*t);
-    if (e<fECut)
-      continue;
-    (*p)->GetNeighborsList(0, cells);
-    for(r=cells.begin();r!=cells.end();++r)
-    {
-      if ((*r)->GetTotalEnergy()<e) continue;
-      if ((*r)->GetTotalEnergy()==e)
-      {
-        r2=(*r)->GetCenterX(); r2*=r2;
-        t=(*r)->GetCenterY(); t*=t;
-        r2=TMath::Sqrt(r2*r2+t*t);
-	if (r1>=r2) continue;
-      }
-      break;
-    }
-    if (r!=cells.end())
-      continue;
-    new ((*fMaximums)[n++]) CbmEcalMaximum(*p, z);
-  }
-  if (fVerbose>9)
-    Info("Exec", "%d maximums found", n);
-}
-
-ClassImp(CbmEcalMaximumLocator)
diff --git a/ecal/CbmEcalMaximumLocator.h b/ecal/CbmEcalMaximumLocator.h
deleted file mode 100644
index 5f8f5963d0f0f17e4db0e2ccd67d48da4983b486..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalMaximumLocator.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef CBMECALMAXIMUMLOCATOR_H
-#define CBMECALMAXIMUMLOCATOR_H
-
-#include "FairTask.h"
-
-class TClonesArray;
-class CbmEcalStructure;
-class TClonesArray;
-
-class CbmEcalMaximumLocator : public FairTask
-{
-public: 
-  /** An empty constructor **/
-  CbmEcalMaximumLocator();
-  CbmEcalMaximumLocator(const char* name, Int_t verbose);
-  virtual void Exec(const Option_t* option);
-  virtual InitStatus Init();
-  virtual void Finish();
-  ~CbmEcalMaximumLocator();
-
-  Double_t ECut() const {return fECut;}
-  void SetECut(Double_t ecut=0.005) {fECut=ecut;}
-private:
-  /** Array of found maximums **/
-  TClonesArray* fMaximums;
-  /** A calorimeter structure **/
-  CbmEcalStructure* fStr;
-  /** energy cut on energy of maximum**/
-  Double_t fECut;
-  /** Current event **/
-  Int_t fEvent;
-
-  CbmEcalMaximumLocator(const CbmEcalMaximumLocator&);
-  CbmEcalMaximumLocator& operator=(const CbmEcalMaximumLocator&);
-
-  ClassDef(CbmEcalMaximumLocator, 1);
-};
-
-#endif
diff --git a/ecal/CbmEcalModule.cxx b/ecal/CbmEcalModule.cxx
deleted file mode 100644
index 119b8e9cb6df85a8e5baf917e2350bf7581902a0..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalModule.cxx
+++ /dev/null
@@ -1,123 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalModule source file                    -----
-// -----                  Created  27/01/06  by M.Prokudin             -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalModule.cxx
- *@author Mikhail Prokudin
- **
- ** ECAL module structure, consisting of cells
- **/
-
-/* $Id: CbmEcalModule.cxx,v 1.6 2006/09/12 18:15:23 prokudin Exp $ */
-
-/* History of cvs commits:
- *
- * $Log: CbmEcalModule.cxx,v $
- * Revision 1.6  2006/09/12 18:15:23  prokudin
- * GetType moved to CbmEcalCell
- *
- * Revision 1.5  2006/07/12 08:11:14  prokudin
- * Magic number 48 removed.
- *
- * Revision 1.4  2006/06/30 06:17:17  kharlov
- * Optimization, commenting
- *
- * Revision 1.3  2006/04/02 16:55:23  kharlov
- * Merging full and fast MC
- *
- * Revision 1.2  2006/01/31 17:07:17  kharlov
- * Correction for CbmEcalv1
- *
- * Revision 1.1  2006/01/27 17:26:30  kharlov
- * First adaptation of ECAL detailed geometry to cbmroot2
- *
- */
-
-#include "CbmEcalModule.h"
-
-#include "CbmEcalCellMC.h"
-
-#include "TMath.h"
-
-using std::list;
-using std::vector;
-
-//-----------------------------------------------------------------------------
-CbmEcalModule::CbmEcalModule(char type, Int_t cellnumber, Float_t x1, Float_t y1, Float_t x2, Float_t y2, Int_t mc, Float_t energy) 
-  : CbmEcalCell(cellnumber, x1,y1,x2,y2, type, energy), 
-    fDx(x2-x1), 
-    fDy(y2-y1),
-    fCells()
-{
-  if (GetType()<1) return;
-	
-  Int_t i;
-  Int_t j;
-  Int_t mt;
-  Int_t num;
-	
-  mt=type;
-  fCells.resize(mt*mt,NULL);
-
-  num=cellnumber/100;
-
-  if (mc==0)
-    for(i=0;i<mt;i++)
-      for(j=0;j<mt;j++)
-        fCells[i*mt+j]=new CbmEcalCell((num*10+i+1)*10+j+1, x1+j*fDx/mt, y1+i*fDy/mt, x1+(j+1)*fDx/mt, y1+(i+1)*fDy/mt, type);
-  else 
-    for(i=0;i<mt;i++)
-      for(j=0;j<mt;j++)
-        fCells[i*mt+j]=new CbmEcalCellMC((num*10+i+1)*10+j+1, x1+j*fDx/mt, y1+i*fDy/mt, x1+(j+1)*fDx/mt, y1+(i+1)*fDy/mt, type);
-}
-
-//-----------------------------------------------------------------------------
-CbmEcalCell* CbmEcalModule::Locate(Int_t x, Int_t y) const
-{
-  if (x<0||y<0||x>=GetType()||y>=GetType()) return NULL;
-  return fCells[y*GetType()+x];
-}
-
-//-----------------------------------------------------------------------------
-CbmEcalCell* CbmEcalModule::FindCell(Float_t x, Float_t y) const
-{
-  Int_t ix=(Int_t)TMath::Floor( (x-GetX1())/GetDX()*GetType() );
-  Int_t iy=(Int_t)TMath::Floor( (y-GetY1())/GetDY()*GetType() );
-  if (ix<0) ix=0; 
-  if (ix>=GetType()) ix=GetType()-1;
-  if (iy<0) iy=0; 
-  if (iy>=GetType()) iy=GetType()-1;
-  return At(ix,iy);
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalModule::AddEnergy(Float_t x, Float_t y, Float_t energy)
-{
-  CbmEcalCell* tmp=FindCell(x,y);
-  if (!tmp) return;
-  tmp->AddEnergy(energy);
-  CbmEcalCell::AddEnergy(energy);
-}
-
-//-----------------------------------------------------------------------------
-list<CbmEcalCell*> CbmEcalModule::GetCellsX(Float_t x) const 
-{
-  list<CbmEcalCell*> tmp;
-  vector<CbmEcalCell*>::const_iterator p;
-
-  for(p=fCells.begin();p!=fCells.end();++p)
-    if (x>(*p)->GetX1()&&x<(*p)->GetX2()) tmp.push_back(*p);
-  return tmp;
-}
-
-//-----------------------------------------------------------------------------
-list<CbmEcalCell*> CbmEcalModule::GetCellsY(Float_t y) const
-{
-  list<CbmEcalCell*> tmp;
-  vector<CbmEcalCell*>::const_iterator p;
-
-  for(p=fCells.begin();p!=fCells.end();++p)
-    if (y>(*p)->GetY1()&&y<(*p)->GetY2()) tmp.push_back(*p);
-  return tmp;
-}
diff --git a/ecal/CbmEcalModule.h b/ecal/CbmEcalModule.h
deleted file mode 100644
index 752377f314e22cf5759ae049b1cdd8b2e09f0963..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalModule.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalModule header file                    -----
-// -----                  Created  27/01/06  by M.Prokudin             -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalModule.h
- *@author Mikhail Prokudin
- **
- ** ECAL module structure, consisting of cells
- **/
-
-/* $Id: CbmEcalModule.h,v 1.5 2006/09/12 18:15:23 prokudin Exp $ */
-
-/* History of cvs commits:
- *
- * $Log: CbmEcalModule.h,v $
- * Revision 1.5  2006/09/12 18:15:23  prokudin
- * GetType moved to CbmEcalCell
- *
- * Revision 1.4  2006/06/30 06:17:17  kharlov
- * Optimization, commenting
- *
- * Revision 1.3  2006/04/02 16:55:23  kharlov
- * Merging full and fast MC
- *
- * Revision 1.2  2006/01/31 17:07:17  kharlov
- * Correction for CbmEcalv1
- *
- * Revision 1.1  2006/01/27 17:26:30  kharlov
- * First adaptation of ECAL detailed geometry to cbmroot2
- *
- */
-
-#ifndef CBMECALMODULE_H
-#define CBMECALMODULE_H
-
-#include "CbmEcalCell.h"
-
-#include <vector>
-#include <list>
-
-class CbmEcalModule : public CbmEcalCell
-{
-
-public:
-  // Set mc==1 to construct CbmEcalCellMC, not CbmEcalCell 
-  CbmEcalModule(char type=1, Int_t cellnumber=-1, Float_t x1=0, Float_t y1=0, Float_t x2=0, Float_t y2=0, Int_t mc=0,Float_t energy=0);
-	
-  CbmEcalCell* Locate(Int_t x, Int_t y) const;
-  
-  //Faster than Locate, but doesn't check boundaries
-  inline CbmEcalCell* At(Int_t x, Int_t y) const {return fCells[y*GetType()+x];}
-  CbmEcalCell* FindCell(Float_t x, Float_t y) const;
-  void AddEnergy(Float_t x, Float_t y, Float_t energy); 
-  inline Float_t GetEnergy(Float_t x, Float_t y) const
-  {
-    CbmEcalCell* tmp=FindCell(x,y);
-    if (tmp) return tmp->GetEnergy();
-    return -1;
-  }
-  void ResetModule();
-  
-  inline Float_t GetDX() const {return fDx;}
-  inline Float_t GetDY() const {return fDy;}
-  std::vector<CbmEcalCell*> GetCells() const {return fCells;}
-  
-  //returns cells for which X1<x<X2
-  std::list<CbmEcalCell*> GetCellsX(Float_t x) const; 
-  //returns cells for which Y1<y<Y2
-  std::list<CbmEcalCell*> GetCellsY(Float_t y) const;
-
-private:
-  /** module x-size **/
-  Float_t fDx;
-  /** module y-size **/
-  Float_t fDy;
-  /** list of cells contained in a module **/
-  std::vector<CbmEcalCell*> fCells;
-
-  ClassDef(CbmEcalModule,1);
-};
-
-inline void CbmEcalModule::ResetModule()
-{
-  ResetEnergyFast();
-  for(UInt_t i=0;i<fCells.size();i++) fCells[i]->ResetEnergyFast();
-}
-#endif
diff --git a/ecal/CbmEcalNN.cxx b/ecal/CbmEcalNN.cxx
deleted file mode 100644
index bb9b0da6a6debafe1a65bf4e202166899541d4bf..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalNN.cxx
+++ /dev/null
@@ -1,766 +0,0 @@
-#include "CbmEcalNN.h"
-
-#include "TString.h"
-#include "TRandom.h"
-#include "TMath.h"
-#include "TMatrixD.h"
-
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-  
-CbmEcalNN::CbmEcalNN(const char* str)
-  : fN(-1111), fStr(NULL), fNeurons(NULL), fWNeurons(NULL), fWSynapses(NULL),
-    fNNeurons(-1111), fNSynapses(-1111), fMS(-1111), fCurrent(NULL), fDNeurons(NULL),
-    fDeDNeurons(NULL), fDeDSynapses(NULL), fDEDNeurons(NULL), fDEDSynapses(NULL),
-    fOld(NULL),
-    fReset(50), fEta(0.1), fEpsilon(0.0), fDelta(0.0), fEtaDecay(1.0),
-    fLastAlpha(0.0), fTau(3.0)
-{
-  Int_t i;
-  Int_t n=1;
-  TString st="";
-
-  for(i=0;str[i]!=0;i++)
-  {
-    if (str[i]==':') { n++; continue; }
-    if (str[i]<48||str[i]>57)
-    {
-      cerr << "Wrong symbol in " << str << " at " << i+1 << endl; 
-      return;
-    }
-  }
-
-  fStr=new Int_t[n];
-
-  n=0; 
-  for(i=0;str[i]!=0;i++)
-  {
-    if (str[i]==':')
-    {
-      fStr[n++]=st.Atoi();
-      st=""; continue;
-    }
-    st+=str[i];
-  }
-  fStr[n++]=st.Atoi();
-  fN=n;
-
-  //Counting neurons and synapses
-  n=0;
-  for(i=0;i<fN;i++) n+=fStr[i];
-  fWNeurons=new Double_t[n];
-  fDeDNeurons=new Double_t[n];
-  fDEDNeurons=new Double_t[n];
-  fNeurons=new Double_t[n];
-  fDNeurons=new Double_t[n];
-  fNNeurons=n;
-  for(i=0;i<fNNeurons;i++) fDEDNeurons[i]=0.0;
-  n=0;
-  for(i=1;i<fN;i++) n+=fStr[i]*fStr[i-1];
-  fWSynapses=new Double_t[n];
-  fDeDSynapses=new Double_t[n];
-  fDEDSynapses=new Double_t[n];
-  fNSynapses=n;
-  for(i=0;i<fNSynapses;i++) fDEDSynapses[i]=0.0;
-
-  fMS=fNSynapses+fNNeurons;
-
-  fCurrent=new Double_t[fStr[0]+fStr[fN-1]];
-  fOld=new Double_t[fMS];
-}
-
-void CbmEcalNN::LoadWeights(const char* filename)
-{
-  char* buff=new char[100];
-  ifstream f(filename);
-  Int_t i;
-  Double_t n1;
-  Double_t n2;
-  
-  if (!f)
-  {
-    Error("LoadWeights", "Can't open file %s", filename);
-    return;
-  }
-  f.getline(buff, 100); //input normalization header
-  for(i=0;i<fStr[0];i++)
-    f >> n1 >> n2; //Skip the normalization. We do not use it!
-  f.getline(buff, 100);
-
-  f.getline(buff, 100); //output normalization header
-  for(i=0;i<fStr[fN-1];i++)
-    f >> n1 >> n2; //Skip the normalization. We do not use it!
-  f.getline(buff, 100);
-
-
-  f.getline(buff, 100); //neuron weights header
-  for(i=0;i<fNNeurons;i++)
-  {
-    f >> fWNeurons[i];
-  }
-  f.getline(buff, 100);
-
-  f.getline(buff, 100); //synapse weights header
-  for(i=0;i<fNSynapses;i++)
-  {
-    f >> fWSynapses[i];
-  }
-  f.getline(buff, 100);
-
-  f.close();
-  delete[] buff;
-}
-
-
-void CbmEcalNN::DumpWeights(const char* filename)	// In ROOT compatible format
-{
-  ofstream f(filename);
-  Int_t i;
-  f << "#input normalization" << endl;
-  for(i=0;i<fStr[0];i++)
-    f << "1 0" << endl; //Write unity normalization.
-
-  f << "#output normalization" << endl;
-  for(i=0;i<fStr[fN-1];i++)
-    f << "1 0" << endl; //Write unity normalization.
-
-  f << "#neurons weights" << endl;
-  for(i=0;i<fNNeurons;i++)
-    f << fWNeurons[i] << endl;
-
-  f << "#synapses weights" << endl;
-  for(i=0;i<fNSynapses;i++)
-    f << fWSynapses[i] << endl;
-
-  f.close();
-}
-
-void CbmEcalNN::Randomize()
-{
-  Int_t i;
-
-  for(i=0;i<fNNeurons;i++)  fWNeurons[i]=gRandom->Uniform(-0.5, 0.5);
-  for(i=0;i<fNSynapses;i++) fWSynapses[i]=gRandom->Uniform(-0.5, 0.5);
-}
-
-Double_t CbmEcalNN::Eval(Int_t idx, Double_t* input)
-{
-  Int_t i;
-  Int_t j;
-  Int_t k;
-  Int_t dn=0;
-  Int_t dn1;
-  Int_t dn2;
-  Int_t ds=0;
-  Int_t ds1;
-  Int_t ds2;
-  Int_t tmp;
-  Double_t t;
-
-  for(i=0;i<fStr[0];i++)
-    fNeurons[i]=input[i];
-
-  dn=i; dn2=0;
-  //calculate values in all layers
-  for(i=1;i<fN-1;i++)
-  {
-    dn1=dn+fStr[i];
-    ds2=fStr[i-1];
-    //For all neurons in layer
-    for(j=dn;j<dn1;j++)
-    {
-      t=fWNeurons[j];
-      ds1=ds+ds2;
-      tmp=dn2-ds;
-      //Loop over synapses
-      for(k=ds;k<ds1;k++)
-	t+=fNeurons[k+tmp]*fWSynapses[k];
-      fNeurons[j]=TMath::Exp(-t*t);
-      ds=ds1;
-    }
-    dn2=dn;
-    dn=dn1;
-  }
-
-  //Last layer threated separately
-  {
-    dn1=dn+fStr[i];
-    ds2=fStr[i-1];
-    //For all neurons in layer
-    for(j=dn;j<dn1;j++)
-    {
-      t=fWNeurons[j];
-      ds1=ds+ds2;
-      tmp=dn2-ds;
-      //Loop over synapses
-      for(k=ds;k<ds1;k++)
-	t+=fNeurons[k+tmp]*fWSynapses[k];
-      fNeurons[j]=t;
-      ds=ds1;
-    }
-  }
-
-  return fNeurons[fNNeurons+idx-fStr[fN-1]];
-}
-
-
-Double_t CbmEcalNN::EvalD(Int_t idx, Double_t* input)
-//Compute output and derivaties of neural network
-{
-  Int_t i;
-  Int_t j;
-  Int_t k;
-  Int_t dn=0;
-  Int_t dn1;
-  Int_t dn2;
-  Int_t ds=0;
-  Int_t ds1;
-  Int_t ds2;
-  Int_t tmp;
-  Double_t t;
-  Double_t t1;
-
-  for(i=0;i<fStr[0];i++)
-    fNeurons[i]=input[i];
-
-  dn=i; dn2=0;
-  //calculate values in all layers
-  for(i=1;i<fN-1;i++)
-  {
-    dn1=dn+fStr[i];
-    ds2=fStr[i-1];
-    //For all neurons in layer
-    for(j=dn;j<dn1;j++)
-    {
-      t=fWNeurons[j];
-      ds1=ds+ds2;
-      tmp=dn2-ds;
-      //Loop over synapses
-      for(k=ds;k<ds1;k++)
-	t+=fNeurons[k+tmp]*fWSynapses[k];
-      t1=TMath::Exp(-t*t);
-      fNeurons[j]=t1;
-      fDNeurons[j]=(-2.0)*t*t1;
-      ds=ds1;
-    }
-    dn2=dn;
-    dn=dn1;
-  }
-
-  //Last layer threated separately
-  {
-    dn1=dn+fStr[i];
-    ds2=fStr[i-1];
-    //For all neurons in layer
-    for(j=dn;j<dn1;j++)
-    {
-      t=fWNeurons[j];
-      ds1=ds+ds2;
-      tmp=dn2-ds;
-      //Loop over synapses
-      for(k=ds;k<ds1;k++)
-	t+=fNeurons[k+tmp]*fWSynapses[k];
-      fNeurons[j]=t;
-      fDNeurons[j]=1.0;
-      ds=ds1;
-    }
-  }
-
-  return fNeurons[fNNeurons+idx-fStr[fN-1]];
-}
-
-Double_t CbmEcalNN::GetError(Int_t n, Double_t* dta)
-// Get error for given dataset
-// n --- is number of entries
-// dta --- array of input/output pairs
-{
-  Int_t ninp=fStr[0];
-  Int_t nout=fNNeurons-fStr[fN-1];
-  Int_t n1=fStr[fN-1];
-  Int_t n2=ninp+n1;
-  Int_t i;
-  Int_t j;
-  Double_t err=0;
-  Double_t d;
-
-  for(i=0;i<n;i++)
-  {
-    Eval(0, &(dta[i*n2])); //Calculate neuron network 
-    for(j=0;j<n1;j++)
-    {
-      //chi^2 used for gaussian activation function
-      d=fNeurons[nout+j]-dta[i*n2+ninp+j]; 
-      d*=d; err+=d;
-    }
-  }
-
-  return err/2.0;
-}
-
-void CbmEcalNN::ComputeDeDs()
-{
-  Int_t i=fN-1;
-  Int_t j;
-  Int_t k;
-  Int_t dn=0;
-  Int_t dn1;
-  Int_t dn2;
-  Int_t ss;
-  Int_t ds=0;
-  Int_t ds1;
-  Int_t ds2;
-  Int_t tmp;
-  Double_t t;
-  Double_t d;
-  
-  EvalD(0, fCurrent);
-
-  dn=fNNeurons-fStr[fN-1];
-  dn2=dn-fStr[fN-2];
-  ss=ds=fNSynapses-fStr[fN-2]*fStr[fN-1];
-
-  //Last layer threated separately
-  {
-    dn1=dn+fStr[i];
-    ds2=fStr[i-1];
-    //For all neurons in layer
-    for(j=dn;j<dn1;j++)
-    {
-      fDeDNeurons[j]=fNeurons[j]-fCurrent[j-dn+fStr[0]];
-      ds1=ds+ds2;
-      tmp=dn2-ds;
-      //Loop over synapses
-      for(k=dn2;k<dn;k++)
-	fDeDSynapses[k-tmp]=fNeurons[k]*fDeDNeurons[j];
-      ds=ds1;
-    }
-  }
-
-  //Other layers
-  for(i=fN-2;i>0;i--)
-  {
-    dn1=dn; dn-=fStr[i];
-    ds=ss;
-    ds2=fStr[i+1];
-    //For all neurons in layer
-    for(j=dn;j<dn1;j++)
-    {
-      t=0;
-      ds1=ds+ds2;
-      tmp=dn1+ds-ds1;
-      //Loop over synapses
-      for(k=0;k<ds1-ds;k++)
-      {
-	t+=fWSynapses[k*fStr[i]+ds]*fDeDNeurons[k+dn1];
-      }
-
-      fDeDNeurons[j]=t*fDNeurons[j];
-      ds++;
-    }
-    ss-=fStr[i]*fStr[i-1];
-  }
-
-  dn=fNNeurons-fStr[fN-1];
-  ss=ds=fNSynapses-fStr[fN-2]*fStr[fN-1];
-  for(i=fN-2;i>0;i--)
-  {
-    dn1=dn; dn-=fStr[i];
-    dn2=dn-fStr[i-1];
-    ds=ss=ss-fStr[i]*fStr[i-1];
-    ds2=fStr[i-1];
-    //For all neurons in layer
-    for(j=dn;j<dn1;j++)
-    {
-      t=0;
-      ds1=ds+ds2;
-      tmp=dn2-ds;
-      //Loop over synapses
-      for(k=dn2;k<dn;k++)
-	fDeDSynapses[k-tmp]=fNeurons[k]*fDeDNeurons[j];
-      ds=ds1;
-    }
-  }
-
-}
-
-void CbmEcalNN::Train(Int_t epochs, Int_t n, Double_t* dta)
-//Train a neural netrork. Use BFGS algo
-{
-  Int_t ie;
-  TMatrixD bfgsh(fMS, fMS);
-  TMatrixD gamma(fMS, 1);
-  TMatrixD delta(fMS, 1);
-  Double_t* buf;
-  Double_t* dir;
-
-  buf=new Double_t[fMS];
-  dir=new Double_t[fMS];
-
-  cout << "Train: Starting error is " <<  GetError(n, dta) << endl << flush;
-
-  for(ie=0;ie<epochs;ie++)
-  {
-    SetGammaDelta(gamma, delta, buf, n, dta);
-    if (ie%fReset==0)
-    {
-      SteepestDir(dir);
-      bfgsh.UnitMatrix();
-    }
-    else
-    {
-      if (GetBFGSH(bfgsh, gamma, delta))
-      {
-	SteepestDir(dir);
-	bfgsh.UnitMatrix();
-      }
-      else
-      {
-	BFGSDir(bfgsh, dir);
-      }
-    }
-    if (DerivDir(dir)>0)
-    {
-      SteepestDir(dir);
-      bfgsh.UnitMatrix();
-    }
-    if (LineSearch(dir, buf, n, dta))
-    {
-	SteepestDir(dir);
-	bfgsh.UnitMatrix();
-	if (LineSearch(dir, buf, n, dta))
-	{
-	  Error("Train()", "Line search failed :(");
-	  ie=epochs;
-	}
-    }
-    cout << "Epoch: "<< ie << " (Root Error: " << TMath::Sqrt(GetError(n, dta)/n) << ")" << endl << flush;
-//    cout << "Epoch: " << ie << endl;
-  }
-
-  delete [] buf;
-  delete [] dir;
-  //TODO
-}
-
-Bool_t CbmEcalNN::GetBFGSH(TMatrixD& bfgsh, TMatrixD& gamma, TMatrixD& delta)
-//From ROOT:
-//Computes the hessian matrix using the BFGS update algorithm.
-//from gamma (g_{(t+1)}-g_{(t)}) and delta (w_{(t+1)}-w_{(t)}).
-//Returns true if such a direction could not be found
-//(gamma and delta are orthogonal).
-{
-  TMatrixD gd(gamma, TMatrixD::kTransposeMult, delta);
-  if (gd[0][0]==0.0) return kTRUE;
-  TMatrixD aHg(bfgsh, TMatrixD::kMult, gamma);
-  TMatrixD tmp(gamma, TMatrixD::kTransposeMult, bfgsh);
-  TMatrixD gHg(gamma, TMatrixD::kTransposeMult, aHg);
-  Double_t a=1.0/gd[0][0];
-  Double_t f=1.0+(gHg[0][0]*a);
-//  TMatrixD res(TMatrixD(delta, TMatrixD::kMult, TMatrixD(TMatrixD::kTransposed, delta)));
-  TMatrixD res(delta, TMatrixD::kMult, TMatrixD(TMatrixD::kTransposed, delta));
-  res*=f;
-  res-=(TMatrixD(delta,TMatrixD::kMult,tmp)+TMatrixD(aHg,TMatrixD::kMult,TMatrixD(TMatrixD::kTransposed, delta)));
-  res*=a;
-  bfgsh+=res;
-/*
-   Int_t i;
-   Int_t j;
-   for(i=0;i<bfgsh.GetNrows();i++)
-   {
-     for(j=0;j<bfgsh.GetNrows();j++)
-       cout << bfgsh[i][j] << " ";
-     cout << endl << flush;
-   }
-*/  
-  return kFALSE;
-}
-
-void CbmEcalNN::BFGSDir(TMatrixD& bfgsh, Double_t* dir)	//direction=Hessian estimate x dir
-{
-  Int_t i;
-  Int_t j;
-  TMatrixD dedw(fMS, 1);
-
-  for(i=0;i<fNNeurons;i++)
-    dedw[i][0]=fDEDNeurons[i];
-  j=i;
-  for(i=0;i<fNSynapses;i++)
-    dedw[j++][0]=fDEDSynapses[i];
-  TMatrixD direction(bfgsh, TMatrixD::kMult, dedw);
-   for (i=0;i<fMS;i++)
-      dir[i]=-direction[i][0];
-}
-
-void CbmEcalNN::SetGammaDelta(TMatrixD& gamma, TMatrixD& delta, Double_t* buf, Int_t n, Double_t* dta)
-{
-  Int_t i;
-  Int_t j;
-
-  for(i=0;i<fMS;i++) delta[i]=buf[i];
-  for(i=0;i<fNNeurons;i++)
-    gamma[i][0]=-fDEDNeurons[i];
-  j=i;
-  for(i=0;i<fNSynapses;i++)
-    gamma[j++][0]=-fDEDSynapses[i];
-
-  ComputeDEDs(n, dta);
-  for(i=0;i<fNNeurons;i++)
-    gamma[i][0]+=fDEDNeurons[i];
-  j=i;
-  for(i=0;i<fNSynapses;i++)
-    gamma[j++][0]+=fDEDSynapses[i];
-
-//  for(i=0;i<fNNeurons+fNSynapses;i++) cout << "gamma[" << i << "][0]" << gamma[i][0] << endl;
-}
-
-void CbmEcalNN::ComputeDEDs(Int_t n, Double_t* dta)
-//Compute summ of derivatives of the error for whole data set
-{
-  Int_t i;
-  Int_t j;
-  Int_t n2=fStr[0]+fStr[fN-1];
-
-  for(i=0;i<fNNeurons;i++)  fDEDNeurons[i]=0.0;
-  for(i=0;i<fNSynapses;i++) fDEDSynapses[i]=0.0;
-
-  for(j=0;j<n;j++)
-  {
-    fCurrent=&(dta[j*n2]);
-    ComputeDeDs();
-    for(i=0;i<fNNeurons;i++)  fDEDNeurons[i]+=fDeDNeurons[i];
-    for(i=0;i<fNSynapses;i++) fDEDSynapses[i]+=fDeDSynapses[i];
-  }
-
-  for(i=0;i<fNNeurons;i++)  fDEDNeurons[i]/=n;
-  for(i=0;i<fNSynapses;i++) fDEDSynapses[i]/=n;
-/*
-  for(i=0;i<fNSynapses;i++) cout << "fDEDSynapses[" << i << "]=" << fDEDSynapses[i] << endl;
-  for(i=0;i<fNNeurons;i++)  cout << "fDEDNeurons[" << i << "]=" << fDEDNeurons[i] << endl;
-*/
-}
-
-void CbmEcalNN::SteepestDir(Double_t * dir)
-//Steepest descent search direction
-{
-  Int_t i;
-  Int_t j;
-
-  for(i=0;i<fNNeurons;i++)
-    dir[i]=-fDEDNeurons[i];
-  j=i;
-  for(i=0;i<fNSynapses;i++)
-    dir[j++]=-fDEDSynapses[i];
-
-//  for(i=0;i<fNNeurons+fNSynapses;i++) cout << "dir[" << i << "]=" << dir[i] << endl;
-}
-
-void CbmEcalNN::TrainStochastic(Int_t epochs, Int_t n, Double_t* dta)
-//Train a neural netrork. Use BFGS algo
-{
-  Double_t* buf;
-  Int_t* idx;
-  Int_t ie;
-  Int_t i;
-  Int_t j;
-  Int_t k;
-  Int_t ninp=fStr[0];
-  Int_t nout=fNNeurons-fStr[fN-1];
-  Int_t n1=fStr[fN-1];
-  Int_t n2=ninp+n1;
-
-  buf=new Double_t[fMS];
-  idx=new Int_t[n];
-  for(i=0;i<fMS;i++) buf[i]=0.0;
-  for(i=0;i<n;i++) idx[i]=i;
-
-  cout << "TrainStochastic: Starting error is " <<  GetError(n, dta) << endl << flush;
-  for(ie=0;ie<epochs;ie++)
-  {
-    Shuffle(n, idx);
-    for(i=0;i<n;i++)
-    {
-      fCurrent=&(dta[idx[i]*n2]);
-      ComputeDeDs();
-      for(j=0;j<fNNeurons;j++)
-      {
-	buf[j]=(-fEta)*(fDelta+fDeDNeurons[j])+fEpsilon*buf[j];
-	fWNeurons[j]+=buf[j];
-      }
-      for(k=0;k<fNSynapses;k++)
-      {
-	buf[j]=(-fEta)*(fDelta+fDeDSynapses[k])+fEpsilon*buf[j];
-	fWSynapses[k]+=buf[j++];
-      }
-    }
-    fEta*=fEtaDecay;
-
-//    cout << "Epoch: "<< ie << " (Error: " <<  GetError(n, dta) << ")" << endl << flush;
-    cout << "Epoch: " << ie << endl;
-  }
-
-  delete [] buf;
-  delete [] idx;
-}
-
-void CbmEcalNN::MLP_Line(Double_t* old, Double_t* dir, Double_t dst)
-{
-  Int_t i;
-  Int_t j;
-
-  for(i=0;i<fNNeurons;i++)
-//  {
-    fWNeurons[i]=old[i]+dir[i]*dst;
-//    cout << "fWNeurons[" << i << "]=" << fWNeurons[i] << endl;
-//  }
-  for(j=0;j<fNSynapses;j++)
-  {
-    fWSynapses[j]=old[i]+dir[i]*dst;
-//    cout << "fWSynapses[" << i << "]=" << fWSynapses[j] << endl;
-    i++;
-  }
-}
-
-Bool_t CbmEcalNN::LineSearch(Double_t* dir, Double_t* buf, Int_t n, Double_t* dta)
-//Search along the line defined by direction
-{
-  Int_t i;
-  Int_t j;
-  Double_t err1;
-  Double_t err2;
-  Double_t err3;
-  Double_t a1=0.0;
-  Double_t a2=fLastAlpha;
-  Double_t a3;
-  Bool_t done=kFALSE;
-
-  //Store weights
-  for(i=0;i<fNNeurons;i++)
-    fOld[i]=fWNeurons[i];
-  for(j=0;j<fNSynapses;j++)
-    fOld[i++]=fWSynapses[j];
-  err1=GetError(n, dta);
-
-  //Add some magic!!!
-  if (a2>2.0) a2=2.0;
-  if (a2<0.01) a2=0.01;
-  a3=a2;
-  MLP_Line(fOld, dir, a2);
-  err3=err2=GetError(n, dta);
-  if (err1>err2)
-  {
-    for(i=0;i<100;i++)
-    {
-      a3*=fTau;
-      MLP_Line(fOld, dir, a3);
-      err3=GetError(n, dta);
-      if (err3>err2)
-      {
-	done=kTRUE;
-        break;
-      }
-      a1=a2; a2=a3;
-      err1=err2; err2=err3;
-    }
-    if (done==kFALSE)
-    {
-      //Set weights back
-      MLP_Line(fOld, dir, 0.0);
-      return kTRUE;
-    }
-  }
-  else
-  {
-    for(i=0;i<100;i++)
-    {
-      a2/=fTau;
-      MLP_Line(fOld, dir, a2);
-      err2=GetError(n, dta);
-      if (err1>err2)
-      {
-	done=kTRUE;
-        break;
-      }
-      a3=a2; err3=err2;
-    }
-    if (done==kFALSE)
-    {
-      MLP_Line(fOld, dir, 0.);
-      fLastAlpha = 0.05;
-      return kTRUE;
-    }
-  }
-  fLastAlpha=0.5*(a1+a3-(err3-err1)/((err3-err2)/(a3-a2)-(err2-err1)/(a2-a1)));
-  if (fLastAlpha>10000) fLastAlpha=10000;
-  MLP_Line(fOld, dir, fLastAlpha);
-  GetError(n, dta);
-
-  for(i=0;i<fNNeurons;i++)
-//  {
-    buf[i]=fWNeurons[i]-fOld[i];
-//    cout << "buf[" << i << "]=" << buf[i] << endl;
-//  }
-  for(j=0;j<fNSynapses;j++)
-  {
-    buf[i]=fWSynapses[j]-fOld[i];
-//    cout << "buf[" << i << "]=" << buf[i] << endl;
-    i++;
-  }
-
-  return kFALSE;
-}
-
-Double_t CbmEcalNN::DerivDir(Double_t* dir)
-//Scalar product between gradient and direction
-{
-  Int_t i;
-  Int_t j;
-  Double_t res=0.0;
-
-  for(i=0;i<fNNeurons;i++)
-    res+=fDEDNeurons[i]*dir[i];
-  j=i;
-  for(i=0;i<fNSynapses;i++)
-  {
-    res+=fDEDSynapses[i]*dir[j];
-    j++;
-  }
-
-//  cout << "DerivDir: " << res << endl;
-  return res;
-}
-
-void CbmEcalNN::Shuffle(Int_t n, Int_t* idx)
-//Shuffle indexes
-{
-  Int_t i;
-  Int_t j;
-  Int_t k;
-
-  for(i=0;i<n;i++)
-  {
-    j=gRandom->Integer(n);
-    k=idx[j];
-    idx[j]=idx[i];
-    idx[i]=k;
-  }
-}
-
-CbmEcalNN::~CbmEcalNN()
-{
-  delete [] fStr;
-  delete [] fWNeurons;
-  delete [] fNeurons;
-  delete [] fWSynapses;
-
-  delete [] fCurrent;
-  delete [] fDNeurons;
-  delete [] fDeDNeurons;
-  delete [] fDeDSynapses;
-  delete [] fDEDNeurons;
-  delete [] fDEDSynapses;
-  delete [] fOld;
-}
-
-ClassImp(CbmEcalNN)
diff --git a/ecal/CbmEcalNN.h b/ecal/CbmEcalNN.h
deleted file mode 100644
index 540339dabf0201e1ac43073a85104d5e742337aa..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalNN.h
+++ /dev/null
@@ -1,92 +0,0 @@
-// A fast version of multilayer perceptron.
-// Can be even faster using SIMD.
-// An activation function (Gauss) is hardcoded.
-#ifndef CBMECALNN_H
-#define CBMECALNN_H
-
-#include "TObject.h"
-#include "TMatrixD.h"
-
-class CbmEcalNN : public TObject
-{
-public:
-  CbmEcalNN(const char* str);
-  //LoadWeights and DumpWeights are compatible with ROOT format
-  void LoadWeights(const char* filename);
-  void DumpWeights(const char* filename);
-  void Randomize();	//Randomize weights. Uses gRandom
-  Double_t GetError(Int_t n, Double_t* dta); //Get error for given dataset
-  Double_t Eval(Int_t idx, Double_t* input);
-  Double_t EvalD(Int_t idx, Double_t* input); //Compute output and derivaties of neural network
-  void Train(Int_t epochs, Int_t n, Double_t* dta);	//Train a neural netrork. Use BFGS algo
-  void TrainStochastic(Int_t epochs, Int_t n, Double_t* dta);	//Train a neural netrork. Use stochastic algo
-
-  void SetReset(Int_t reset=50) {fReset=reset;}
-  Int_t GetReset() const {return fReset;}
-
-  void SetEta(Double_t eta=0.1) {fEta=eta;}
-  Double_t GetEta() const {return fEta;}
-
-  void SetEpsilon(Double_t epsilon=0.0) {fEpsilon=epsilon;}
-  Double_t GetEpsilon() const {return fEpsilon;} 
-
-  void SetDelta(Double_t delta=0.0) {fDelta=delta;}
-  Double_t GetDelta() const {return fDelta;} 
-
-  void SetEtaDecay(Double_t etadecay=1.0) {fEtaDecay=etadecay;}
-  Double_t GetEtaDecay() const {return fEtaDecay;} 
-
-  void SetTau(Double_t tau=3.0) {fTau=tau;}
-  Double_t GetTau() const {return fTau;}
-  ~CbmEcalNN();
-private:
-  CbmEcalNN()
-    : fN(-1111),
-      fStr(NULL), fNeurons(NULL), fWNeurons(NULL), fWSynapses(NULL),
-      fNNeurons(-1111), fNSynapses(-1111)
-  {};
-
-  Int_t fN;			//Number of layers
-  Int_t* fStr;			//!Structure of neural network
-  Double_t* fNeurons; 		//!Values of neurons
-  Double_t* fWNeurons; 		//!Weights of neurons
-  Double_t* fWSynapses;		//!Weights of synapses
-  Int_t fNNeurons;		//Number of neurons
-  Int_t fNSynapses;		//Number of synapses
-// Other used for training
-  void ComputeDeDs();		//Compute derivative of the error for current data
-  void ComputeDEDs(Int_t n, Double_t* dta);	//Compute summ of derivatives of the error for whole data set
-  void Shuffle(Int_t n, Int_t* idx);		//Shuffle indexes
-  void SteepestDir(Double_t* dir);		//Steepest descent search direction
-  Bool_t GetBFGSH(TMatrixD& bfgsh, TMatrixD& gamma, TMatrixD& delta);
-  Double_t DerivDir(Double_t* dir);		//Scalar product between gradient and direction
-  void MLP_Line(Double_t* old, Double_t* dir, Double_t dst);
-  void BFGSDir(TMatrixD& bfgsh, Double_t* dir);	//direction=Hessian estimate x dir
-
-  //Search along the line defined by direction
-  Bool_t LineSearch(Double_t* dir, Double_t* buf, Int_t n, Double_t* dta);
-
-  void SetGammaDelta(TMatrixD& gamma, TMatrixD& delta, Double_t* buf, Int_t n, Double_t* dta);
-
-
-  Int_t fMS;			//Size of matrixes: fNNeurons+fNSynapses
-  Double_t* fCurrent;		//!Current training set
-  Double_t* fDNeurons; 		//!Derivatives of neurons
-  Double_t* fDeDNeurons;	//!Current DeDs of neurons
-  Double_t* fDeDSynapses;	//!Current DeDs of synapses
-  Double_t* fDEDNeurons;	//!Sum of DeDs over all events for neurons
-  Double_t* fDEDSynapses;	//!Sum of DeDs over all events for synapses
-  Double_t* fOld;		//!Old weights
-
-  Int_t fReset;			//Number of epochs between of the search of new steepest descent
-  Double_t fEta;		//Used in stochastic training (0.1)
-  Double_t fEpsilon;		//Used in stochastic training (0.0)
-  Double_t fDelta;		//Used in stochastic training (0.0)
-  Double_t fEtaDecay;		//Used in stochastic training (1.0)
-  Double_t fLastAlpha;		//Used in line search
-  Double_t fTau;		//Used in line search
-  ClassDef(CbmEcalNN, 1)
-};
-
-
-#endif
diff --git a/ecal/CbmEcalOShowerCalibrator.cxx b/ecal/CbmEcalOShowerCalibrator.cxx
deleted file mode 100644
index 229036ccc248377b35f128f49925fccf85f5df35..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalOShowerCalibrator.cxx
+++ /dev/null
@@ -1,354 +0,0 @@
-#include "CbmEcalOShowerCalibrator.h"
-
-#include "CbmGeoEcalPar.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalPointLite.h"
-#include "CbmEcal.h"
-
-#include "FairRunAna.h"
-#include "FairRuntimeDb.h"
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "TClonesArray.h"
-#include "TTree.h"
-#include "TParticlePDG.h"
-#include "TDatabasePDG.h"
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::flush;
-
-CbmEcalOShowerCalibrator::CbmEcalOShowerCalibrator()
-	: FairTask(), 
-	  fZPosition(-2.),
-	  fPDGCode(22),
-	  fLowEnergy(0.1),
-	  fLitePoints(NULL),
-	  fEcalPoints(NULL),
-	  fMCTracks(NULL),
-	  fTree(NULL),
-	  fOutMCX(0.),
-	  fOutMCY(0.),
-	  fOutDX(0),
-	  fOutDY(0),
-	  fCellSize(0.),
-	  fOutMCE(0.),
-	  fOutMCPx(0.),
-	  fOutMCPy(0.),
-	  fOutMCPz(0.),
-	  fEvent(0),
-	  fLocalEnergy(NULL),
-	  fLocalPSEnergy(NULL),
-	  fLocalSize(0),
-	  fLocalL(0),
-	  fModuleSize(0.),
-	  fLocalXSize(0),
-	  fLocalYSize(0),
-	  fLocalMCX(0.),
-	  fLocalMCY(0.),
-	  fMCX(0.),
-	  fMCY(0.),
-	  fCount(0),
-	  fPar(NULL)
-{
-}
-CbmEcalOShowerCalibrator::CbmEcalOShowerCalibrator(const char* name, const Int_t iVerbose)
-	: FairTask(name, iVerbose), 
-	  fZPosition(-2.),
-	  fPDGCode(22),
-	  fLowEnergy(0.1),
-	  fLitePoints(NULL),
-	  fEcalPoints(NULL),
-	  fMCTracks(NULL),
-	  fTree(NULL),
-	  fOutMCX(0.),
-	  fOutMCY(0.),
-	  fOutDX(0),
-	  fOutDY(0),
-	  fCellSize(0.),
-	  fOutMCE(0.),
-	  fOutMCPx(0.),
-	  fOutMCPy(0.),
-	  fOutMCPz(0.),
-	  fEvent(0),
-	  fLocalEnergy(NULL),
-	  fLocalPSEnergy(NULL),
-	  fLocalSize(0),
-	  fLocalL(0),
-	  fModuleSize(0.),
-	  fLocalXSize(0),
-	  fLocalYSize(0),
-	  fLocalMCX(0.),
-	  fLocalMCY(0.),
-	  fMCX(0.),
-	  fMCY(0.),
-	  fCount(0),
-	  fPar(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalOShowerCalibrator::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-
-  fLitePoints=(TClonesArray*)fManager->GetObject("EcalPointLite");
-  if (fLitePoints==NULL)
-  {
-    cerr << "There are no EcalPointLite branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fEcalPoints=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (fEcalPoints==NULL)
-  {
-    cerr << "There are no EcalPoint branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fMCTracks=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (fMCTracks==NULL)
-  {
-    cerr << "There are no MCTrack branch in the file!!!" << endl;
-    return kFATAL;
-  }
-
-  fTree=NULL;
-
-  fCellSize=fPar->GetVariableStrict("cellsize");
-  fModuleSize=fPar->GetVariableStrict("modulesize");
-
-  //Fixing local sizes according with shower size
-  //and simulation cell size of 1mm
-  fLocalXSize=120;
-  fLocalYSize=120;
-
-  cout << "Inited for transport cell size " << fCellSize;
-  cout << ", module size " << fModuleSize << endl;
-  cout << "Size of local array: x " << fLocalXSize;
-  cout << ", y " << fLocalYSize << endl;
-
-  fLocalL=3*fLocalXSize+1; fLocalSize=fLocalL; fLocalSize*=fLocalL;
-  fLocalEnergy=new Float_t[fLocalSize];
-  fLocalPSEnergy=new Float_t[fLocalSize];
-  
-  cout << "Local array size " << fLocalSize << endl;
-  fEvent=0;
-  return kSUCCESS;
-}
-
-/** Clear fLocalEnergy and fLocalPSEnergy **/
-void CbmEcalOShowerCalibrator::ClearLocal()
-{
-  if (fVerbose>10)
-    cout << "Clearing local arrays..." << flush;
-  for(Int_t i=0;i<fLocalSize;i++)
-  {
-    fLocalEnergy[i]=0;
-    fLocalPSEnergy[i]=0;
-  }
-  if (fVerbose>10)
-    cout << " Done." << endl << flush;
-}
-
-/** Loop procedure **/
-void CbmEcalOShowerCalibrator::Exec(Option_t*)
-{
-  /** Just because now it is assured we are in
-   ** output file **/
-  if (fTree==NULL)
-    InitTree();
-
-  fEvent++;
-  if (fVerbose>0)
-    cout << "Processing event " << fEvent << "." << endl;
-  ClearLocal();
-  GetMCParameters();
-  if (fCount!=1) 
-  {
-    cerr << "Event " << fEvent << "." << endl;
-    cerr << "->Found " << fCount << " suitable events.";
-    cerr << " Can't continue with this event. Skipping event." << endl;
-    return;
-  }
-  FillLocal();
-
-  if (fVerbose>10)
-    cout << "Constructing output matrices... " << flush;
-  fTree->Fill();
-  if (fVerbose>10)
-    cout << "Done." << flush;
-}
-
-/** Fill fLocalEnergy and fLocalPSEnergy **/
-void CbmEcalOShowerCalibrator::FillLocal()
-{
-  CbmEcalPointLite* p;
-  Int_t n;
-  Bool_t isPS;
-  Float_t x;
-  Float_t y;
-  Int_t ten;
-  Int_t num;
- 
-  n=fLitePoints->GetEntriesFast();
-  if (fVerbose>10)
-    cout << "Filling local arrays... " << flush;
-  if (fVerbose>1)
-    cout << "Found " << n << " MCPoints in event." << endl;
-
-  for(Int_t i=0;i<n;i++)
-  {
-    p=(CbmEcalPointLite*)fLitePoints->At(i);
-    isPS=CbmEcal::GetCellCoord(p->GetDetectorID(),x,y,ten);
-    if (ten!=0) continue;
-//    cout << x << "	" << y << "	" << fMCX << "	" << fMCY << endl;
-    x+=fCellSize/2.0-fMCX;
-    y+=fCellSize/2.0-fMCY;
-    num=GetLocalNumber(x,y);
-    if (num==-1) continue;
-
-    if (isPS)
-      fLocalPSEnergy[num]+=p->GetEnergyLoss();
-    else
-      fLocalEnergy[num]+=p->GetEnergyLoss();
-  }
-  if (fVerbose>10)
-    cout << " Done." << endl;
-}
-
-Int_t CbmEcalOShowerCalibrator::GetLocalNumber(Float_t x, Float_t y) const 
-{
-  static Float_t dx=fCellSize;
-  static Float_t dy=fCellSize;
-  static Int_t idx=fLocalXSize;
-  static Int_t idy=fLocalYSize;
-
-  Int_t ix=(Int_t)(x/dx+0.5)+idx;
-  if (x/dx+0.5<0) ix--;
-  Int_t iy=(Int_t)(y/dy+0.5)+idy;
-  if (y/dy+0.5<0) iy--;
-
-  if (ix<0||iy<0) return -1;
-  if (ix>=fLocalL) return -1;
-  if (iy>=fLocalL) return -1;
-
-  return ix+iy*fLocalL;
-}
-
-/** Get MC parameters of incoming particle **/
-void CbmEcalOShowerCalibrator::GetMCParameters()
-{
-  CbmEcalPoint* p;
-//  CbmMCTrack* track;
-  TVector3 mom;
-  Int_t n;
-  Int_t count=0;
-  Float_t mass=-1111;
-
-  n=fEcalPoints->GetEntriesFast();
-  if (fVerbose>1)
-    cout << "Found " << n << " incoming particles in event." << endl;
-
-  for(Int_t i=0;i<n;i++)
-  {
-    p=(CbmEcalPoint*)fEcalPoints->At(i);
-//    track=(CbmMCTrack*)fMCTracks->At(p->GetTrackID());
-//    if (track->GetPdgCode()!=fPDGCode) continue;
-    p->Momentum(mom);
-    if (mom.Mag()<fLowEnergy)
-      continue;
-    count++;
-    TParticlePDG* fParticlePDG=TDatabasePDG::Instance()->GetParticle(fPDGCode);
-    if (fParticlePDG)
-      mass=fParticlePDG->Mass();
-    if (mass<0)
-    {
-      cerr << "Can't find PDG particle " << fPDGCode << "!!!";
-      cerr << endl;
-      Fatal("GetMCParameters","Can't find PDG particle %d", fPDGCode);
-    }
-    fOutMCE=TMath::Sqrt(mass*mass+mom.Mag2());
-    fOutMCPx=mom.Px();
-    fOutMCPy=mom.Py();
-    fOutMCPz=mom.Pz();
-    p->Position(mom);
-    GetMCXY(mom);
-  }
-  fCount=count;
-}
-
-/** Get MC coordinates **/
-void CbmEcalOShowerCalibrator::GetMCXY(TVector3& mom)
-{
-  static Float_t PSLead=fPar->GetVariableStrict("pslead");
-  static Float_t PSScin=fPar->GetVariableStrict("psscin");
-  static Float_t PSGap=fPar->GetVariableStrict("psgap");
-  static Float_t PSThickness=PSLead+PSScin+PSGap;
-  static Float_t ZPos=fPar->GetVariableStrict("zpos");
-
-  Float_t delta;
-
-  if (fZPosition==-2) delta=ZPos+PSThickness;
-  else
-    if (fZPosition==-1) delta=ZPos;
-    else
-      delta=fZPosition;
-  delta-=mom.Z();
-
-  fMCX=mom.X()+fOutMCPx/fOutMCPz*delta;
-  fMCY=mom.Y()+fOutMCPy/fOutMCPz*delta;
-
-  Int_t ix;
-  Int_t iy;
-
-  if (fMCX>=0)
-    ix=(Int_t)(fMCX/fCellSize);
-  else
-    ix=(Int_t)(fMCX/fCellSize)-1;
-  if (fMCY>=0)
-    iy=(Int_t)(fMCY/fCellSize);
-  else
-    iy=(Int_t)(fMCY/fCellSize)-1;
-
-
-  fLocalMCX=fMCX-(0.5+ix)*fCellSize;
-  fLocalMCY=fMCY-(0.5+iy)*fCellSize;
-}
-
-/** Parameter container init **/
-void CbmEcalOShowerCalibrator::SetParContainers()
-{
-  FairRunAna* ana=FairRunAna::Instance();
-  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
-  fPar=(CbmGeoEcalPar*)(rtdb->getContainer("CbmGeoEcalPar"));
-}
-
-void CbmEcalOShowerCalibrator::InitTree()
-{
-  TString name;
-  fTree=new TTree("ECALshower","Tree of ECAL showers");
-  fTree->Branch("mcx",&fOutMCX,"mcx/F");
-  fTree->Branch("mcy",&fOutMCY,"mcy/F");
-  fTree->Branch("dx",&fOutDX,"dx/I");
-  fTree->Branch("dy",&fOutDY,"dy/I");
-  fTree->Branch("simcellsize",&fCellSize,"simcellsize/F");
-  fTree->Branch("e",&fOutMCE,"e/F");
-  fTree->Branch("px",&fOutMCPx,"px/F");
-  fTree->Branch("py",&fOutMCPy,"py/F");
-  fTree->Branch("pz",&fOutMCPz,"pz/F");
-  fTree->Branch("ev",&fEvent,"ev/I");
-
-  name="ecale["; name+=fLocalSize; name+="]/F";
-  fTree->Branch("ecale", fLocalEnergy, name);
-  name="pse["; name+=fLocalSize; name+="]/F";
-  fTree->Branch("pse", fLocalPSEnergy, name);
-};
-
-/** Finishing routine **/
-void CbmEcalOShowerCalibrator::Finish()
-{
-  fTree->Write();
-}
-
-ClassImp(CbmEcalOShowerCalibrator)
diff --git a/ecal/CbmEcalOShowerCalibrator.h b/ecal/CbmEcalOShowerCalibrator.h
deleted file mode 100644
index ba5a037bde3cee402824171154ab25dccbd6bb96..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalOShowerCalibrator.h
+++ /dev/null
@@ -1,194 +0,0 @@
-// Creater tree for shower calibration from MCPoints files.
-// This is a source of raw information for shower library.
-// Must be exactly one particle with resonably high energy
-// (>LowEnergy) per event!
-/* $Id: CbmEcalOShowerCalibrator.h,v 1.3 2006/09/07 18:19:27 prokudin Exp $*/
-
-/*
- * $Log: CbmEcalOShowerCalibrator.h,v $
- * Revision 1.3  2006/09/07 18:19:27  prokudin
- * SCurveRun option added
- *
- * Revision 1.2  2006/08/22 22:31:42  prokudin
- * Optimization
- *
- * Revision 1.1  2006/08/15 13:06:06  prokudin
- * first release of CbmEcalOShowerCalibrator
- *
- */
-
-#ifndef CBMECALOSHOWERCALIBRATOR_H
-#define CBMECALOSHOWERCALIBRATOR_H
-
-#include "FairTask.h"
-
-#include <vector>
-
-class CbmGeoEcalPar;
-class TClonesArray;
-class TTree;
-class TVector3;
-
-class CbmEcalOShowerCalibrator : public FairTask
-{
-public:
-  /** Standart constructor **/
-  CbmEcalOShowerCalibrator(const char* name, const Int_t iVerbose=1);
-
-  void SetPDGCode(Int_t code=22);
-  Int_t GetPDGCode() const;
-
-  /** Set lowest energy to analize **/
-  void SetLowEnergy(Float_t energy=0.1);
-  Float_t GetLowEnergy() const;
-
-  /** Z position of ECAL
-   ** -1 for PS surface
-   ** -2 for ECAL surface **/
-  void SetZPosition(Float_t zpos=-2);
-  Float_t GetZPosition() const;
-
-  /** (x,y) -> local number. -1 if fails **/
-  Int_t GetLocalNumber(Float_t x, Float_t y) const;
-
-private:
-  /** Z position of ECAL
-   ** -1 for PS surface
-   ** -2 for ECAL surface **/
-  Float_t fZPosition; //=-2
-
-  /** Pdg code of particles to analize **/
-  Int_t fPDGCode; //=22
-
-  /** Lowest energy to analize **/
-  Float_t fLowEnergy; //=0.1
-
-  /** MCPoints in ECAL **/
-  TClonesArray* fLitePoints;	//!
-  /** MCPoints in front of the ECAL **/
-  TClonesArray* fEcalPoints;	//!
-  /** MCTracks array **/
-  TClonesArray* fMCTracks;	//!
-
-  /** Output tree. It called ECALshower**/
-  TTree* fTree;		//!
-
-  /** MC coordinates of impact point **/
-  Float_t fOutMCX;
-  Float_t fOutMCY;
-
-  /** Delta vs. real MC X,Y**/
-  Int_t fOutDX;
-  Int_t fOutDY;
-
-  /** Cell size in simulation. From parameter container **/
-  Float_t fCellSize;
-
-  /** MC parameters of particle **/
-  Float_t fOutMCE;
-  Float_t fOutMCPx;
-  Float_t fOutMCPy;
-  Float_t fOutMCPz;
-
-  /** Enent number**/
-  Int_t fEvent;
-
-  /** Energy in temporary cluster **/
-  Float_t* fLocalEnergy;	//!
-  Float_t* fLocalPSEnergy;	//!
-  Int_t fLocalSize;
-  Int_t fLocalL;
-
-  /** Size of ECAL module **/
-  Float_t fModuleSize;
-
-  /** X/Y sizes of local array**/
-  Int_t fLocalXSize;
-  Int_t fLocalYSize;
-
-  /** Local MC coordinates of ECAL plane hit **/
-  Float_t fLocalMCX;
-  Float_t fLocalMCY;
-
-  /** MC coordinates of ECAL plane hit **/
-  Float_t fMCX;
-  Float_t fMCY;
-
-  /** Number of found good particles **/
-  Int_t fCount;
-public:
-  /** Default constructor **/
-  CbmEcalOShowerCalibrator();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Parameter container init **/
-  virtual void SetParContainers();
-
-  /** Destructor **/
-  virtual ~CbmEcalOShowerCalibrator() {};
-private:
-  /** Inits fTree and branches **/
-  void InitTree();
-
-  /** Get MC parameters of incoming particle **/
-  void GetMCParameters();
-
-  /** Get MC coordinates **/
-  void GetMCXY(TVector3& mom);
-
-  /** Fill fLocalEnergy and fLocalPSEnergy **/
-  void FillLocal();
-
-  /** Clear fLocalEnergy and fLocalPSEnergy **/
-  void ClearLocal();
-
-  CbmGeoEcalPar* fPar;
-
-  CbmEcalOShowerCalibrator(const CbmEcalOShowerCalibrator&);
-  CbmEcalOShowerCalibrator& operator=(const CbmEcalOShowerCalibrator&);
-
-  ClassDef(CbmEcalOShowerCalibrator,1)
-
-};
-
-inline void CbmEcalOShowerCalibrator::SetPDGCode(Int_t code)
-{
-  fPDGCode=code;
-}
-
-inline Int_t CbmEcalOShowerCalibrator::GetPDGCode() const
-{
-  return fPDGCode;
-}
-
-inline void CbmEcalOShowerCalibrator::SetLowEnergy(Float_t energy)
-{
-  fLowEnergy=energy;
-}
-
-inline Float_t CbmEcalOShowerCalibrator::GetLowEnergy() const
-{
-  return fLowEnergy;
-}
-
-
-inline void CbmEcalOShowerCalibrator::SetZPosition(Float_t zpos)
-{
-  fZPosition=zpos;
-}
-
-inline Float_t CbmEcalOShowerCalibrator::GetZPosition() const
-{
-  return fZPosition;
-}
-
-#endif
-
diff --git a/ecal/CbmEcalParam.cxx b/ecal/CbmEcalParam.cxx
deleted file mode 100644
index 130249744bd858ef2bcfb2d9ac73638bbba97d32..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalParam.cxx
+++ /dev/null
@@ -1,232 +0,0 @@
-#include "CbmEcalParam.h"
-
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <stdlib.h>
-#include <TSystem.h>
-
-#include "TMap.h"
-
-using namespace std;
-
-CbmEcalParam::~CbmEcalParam()
-{
-  ;
-}
-
-int cmp_nocase(const string &s, const string &s2);
-/*
-{
-  string::const_iterator p=s.begin();
-  string::const_iterator p2=s2.begin();
-  while(p!=s.end()&&p2!=s2.end()) {
-    if (toupper(*p)!=toupper(*p2)) return (toupper(*p)<toupper(*p2))?-1:1;
-    ++p;
-    ++p2;
-  }
-  return(s2.size()==s.size())?0:(s.size()<s2.size())?-1:1; // size is unsigned
-}
-*/
-// ---------------------------------------------------------------------------
-
-TString CbmEcalParam::GetString(const char* key) const
-{
-  TObjString* value=(TObjString*)fVariables.GetValue(key);
-  if (value==NULL)
-    Fatal("GetString","Can't find variable named %s.", key);
-  return value->GetString();
-}
-
-Int_t CbmEcalParam::GetInteger(const char* key) const
-{
-  TObjString* value=(TObjString*)fVariables.GetValue(key);
-  if (value==NULL)
-    Fatal("GetInteger","Can't find variable named %s.", key);
-  Int_t val;
-  char* err=NULL;
-  val=strtol(value->GetString(),&err, 10);
-  if (err[0]!='\0')
-    Fatal("GetInteger","Can't convert variable named %s==\"%s\" to floating point number.", key, value->GetString().Data());
-  return val;
-}
-
-Double_t CbmEcalParam::GetDouble(const char* key) const
-{
-  TObjString* value=(TObjString*)fVariables.GetValue(key);
-  if (value==NULL)
-    Fatal("GetDouble","Can't find variable named %s.", key);
-  Double_t val;
-  char* err=NULL;
-  val=strtod(value->GetString(),&err);
-  if (err[0]!='\0')
-    Fatal("GetDouble","Can't convert variable named %s==\"%s\" to floating point number.", key, value->GetString().Data());
-  return val;
-}
-
-TString CbmEcalParam::GetStringSlack(const char* key) const 
-{
-  TObjString* value=(TObjString*)fVariables.GetValue(key);
-  if (value==NULL)
-  {
-    Warning("GetStringSlack","Can't find variable named %s.", key);
-    return "";
-  }
-  return value->GetString();
-}
-
-Int_t CbmEcalParam::GetIntegerSlack(const char* key) const
-{
-  TObjString* value=(TObjString*)fVariables.GetValue(key);
-  if (value==NULL)
-  {
-    Warning("GetIntegerSlack","Can't find variable named %s.", key);
-    return -1111;
-  }
-  Int_t val;
-  char* err=NULL;
-  val=strtol(value->GetString(),&err, 10);
-  if (err[0]!='\0')
-  {
-    Warning("GetIntegerSlack","Can't convert variable named %s==\"%s\" to floating point number.", key, value->GetString().Data());
-    return -1111;
-  }
-  return val;
-}
-
-Double_t CbmEcalParam::GetDoubleSlack(const char* key) const
-{
-  TObjString* value=(TObjString*)fVariables.GetValue(key);
-  if (value==NULL)
-  {
-    Warning("GetDoubleSlack","Can't find variable named %s.", key);
-    return -1111;
-  }
-  Double_t val;
-  char* err=NULL;
-  val=strtod(value->GetString(),&err);
-  if (err[0]!='\0')
-  {
-    Warning("GetDoubleSlack","Can't convert variable named %s==\"%s\" to floating point number.", key, value->GetString().Data());
-    return -1111;
-  }
-  return val;
-}
-
-void CbmEcalParam::AddVariable(const char* key, const char* value)
-{
-  TObjString* skey=(TObjString*)fVariables.FindObject(key);
-  if (skey!=NULL)
-  {
-    /** Value for this key already exists **/
-    skey->SetString(value);
-    return;
-  }
-  skey=new TObjString(key);
-  skey->String().ToLower();
-  TObjString* svalue=new TObjString(value);
-  fVariables.Add(skey, svalue);
-}
-
-//=============================================================================
-CbmEcalParam::CbmEcalParam(const char* name, const char* filename)
-  : TNamed(name, filename), 
-    fVariables(200),
-    fSuccess(0), 
-    fFileName(filename)
-{
-  TString fname=filename;
-  gSystem->ExpandPathName(fname);
-  ifstream file(fname);
-  Int_t linenum;
-  string buffer;
-  string message;
-  string variable;
-  string value;
-
-  fSuccess=1;
-  if (!file) {
-    Error("CbmEcalParam", "Can't open file %s. ", filename);
-    fSuccess=0;
-    return;
-  }
-
-  linenum=0;
-  file.exceptions(ifstream::goodbit);
-  while(getline(file,buffer))
-  {
-    linenum++;
-    if (buffer.empty()) continue;
-    if (buffer.find_first_not_of(" 	")==string::npos) continue;
-    message=buffer.substr(buffer.find_first_not_of(" 	"));	//Skipping initial spaces
-    if (message.empty()) continue;
-    message=message.substr(0,message.find("#"));	//Removing comments
-    if (message.empty()) continue;		//This was just a comment
-    variable=message.substr(0,message.find("="));
-    if (variable==message)
-    {
-      Error("CbmEcalParam","Syntax error: File %s. Line %d. ", fname.Data(), linenum);
-      fSuccess=0;
-      file.close();
-      return;
-    }
-    variable=variable.substr(0,variable.find_first_of(" 	"));
-    if (message.find("=")==string::npos)
-      Error("CbmEcalParam","Can't find value for varible %s at line %d.", variable.c_str(), linenum);
-    value=message.substr(message.find("=")+1);
-    if (value.find_first_not_of(" 	")==string::npos)
-    {
-      Info("CbmEcalParam","Value of varible %s at empty.", variable.c_str());
-      value="";
-    }
-    else
-      value=value.substr(value.find_first_not_of(" 	"));	//Skipping initial spaces
-    AddVariable(variable.c_str(), value.c_str());
-    if (file.eof()) break;
-  }
-  //file.close();
-}
-
-//-----------------------------------------------------------------------------
-
-void CbmEcalParam::DumpContainer(ostream& stream) const
-{
-  TObjString* key;
-  TIterator* iter=fVariables.MakeIterator();
-  while((key=(TObjString*)iter->Next())!=NULL)
-  {
-    TObjString* str=(TObjString*)fVariables.GetValue(key);
-    stream << key->String() << "=" << str->String() << endl;
-  }
-}
-
-void CbmEcalParam::DumpContainer() const
-{
-  DumpContainer(cout);
-}
-
-//-----------------------------------------------------------------------------
-
-Bool_t CbmEcalParam:: Differs(const CbmEcalParam* info) const
-{
-  TObjString* key;
-  TIterator* iter=fVariables.MakeIterator();
-  while((key=(TObjString*)iter->Next())!=NULL)
-  {
-    TObjString* str=(TObjString*)fVariables.GetValue(key);
-    TObjString* other=(TObjString*)info->fVariables.GetValue(key);
-    if (!other||str->String()!=other->String()) break;
-  }
-  if (!key) return kTRUE;
-
-  iter=info->fVariables.MakeIterator();
-  while((key=(TObjString*)iter->Next())!=NULL)
-  {
-    TObjString* str=(TObjString*)fVariables.GetValue(key);
-    TObjString* other=(TObjString*)info->fVariables.GetValue(key);
-    if (!other||str->String()!=other->String()) break;
-  }
-  if (!key) return kTRUE;
-  return kFALSE;
-}
-
diff --git a/ecal/CbmEcalParam.h b/ecal/CbmEcalParam.h
deleted file mode 100644
index 145364ff7286687b68a0d8a536b5d299ff45ac39..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalParam.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/** I am desperate for usable parameter handle class.
- ** So we will have it only for calorimeter. :(**/
-#ifndef CBMECALPARAM_H
-#define CBMECALPARAM_H
-
-#include "TObjArray.h"
-#include <list>
-#include "TString.h"
-#include "TObjString.h"
-#include "TNamed.h"
-#include "TMap.h"
-
-
-class CbmEcalParam : public TNamed
-{
-public:
-  /** This is ROOT requirement **/
- CbmEcalParam() : TNamed(), fVariables(), fSuccess(0), fFileName("") {};
-  /** Text file constructor **/
-  CbmEcalParam(const char* name, const char* filename);	
-  virtual ~CbmEcalParam();
-
-  void DumpContainer() const;
-  void DumpContainer(std::ostream& stream) const;
-
-  /** Various getters **/
-  /** key must be lower case. For example, if have in
-   ** configuration file AaaA=90, then you should call 
-   ** GetVariableStrict("aaaa").
-   ** If variable not found, will generate Fatal **/
-  TString GetString(const char* key) const;
-  Double_t GetDouble(const char* key) const;
-  Int_t GetInteger(const char* key) const;
-
-  void AddVariable(const char* key, const char* value);
-  Bool_t Differs(const CbmEcalParam* info) const;
-private:
-  /** A map containing all variables
-   ** This variable should be saved in parameter file **/
-  TMap fVariables;
-
-  Int_t fSuccess;
-
-  TString fFileName;
-public:
-  /** DO NOT USE THIS UNLESS YOU ARE COMPLETELY SURE.
-   ** key must be lower case. For example, if have in
-   ** configuration file AaaA=90, then you should call 
-   ** GetVariableStrict("aaaa").
-   ** If variable not found, will return -1111 **/
-  Double_t GetDoubleSlack(const char* key) const;
-  Int_t GetIntegerSlack(const char* key) const;
-  TString GetStringSlack(const char* key) const;
-
-  ClassDef(CbmEcalParam,1);
-};
-
-#endif
diff --git a/ecal/CbmEcalPhotonCalibrator.cxx b/ecal/CbmEcalPhotonCalibrator.cxx
deleted file mode 100644
index 630ff01d485d5af42688b5e06b34e3f468579f13..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalPhotonCalibrator.cxx
+++ /dev/null
@@ -1,417 +0,0 @@
-/* $Id: CbmEcalPhotonCalibrator.cxx,v 1.6 2006/07/30 13:10:35 prokudin Exp $ */
-
-#include "CbmEcalPhotonCalibrator.h"
-
-#include "CbmEcalInf.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalPointLite.h"
-#include "CbmEcalPoint.h"
-
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "TClonesArray.h"
-#include "TTree.h"
-#include "TRandom.h"
-
-#include <iostream>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::flush;
-using std::list;
-using std::vector;
-
-CbmEcalPhotonCalibrator::CbmEcalPhotonCalibrator(const char* name, const Int_t iVerbose, const char* fileGeo) 
-  : FairTask(name, iVerbose),
-    fStr(NULL),
-    fEvent(0),
-    fEnergy(0.),
-    fPDGCode(0),
-    fGeoFile(fileGeo),
-    fLitePoints(NULL),
-    fEcalPoints(NULL),
-    fMCTracks(NULL),
-    fBirthX(0.),
-    fBirthY(0.),
-    fBirthZ(0.),
-    fThreshold(0.),
-    fNoise(0.),
-    fInf(CbmEcalInf::GetInstance(fGeoFile)),
-    fTree(NULL),
-    fFullEnergy(0.),
-    fEcalEnergy(0.),
-    f2x2EcalEnergy(0.),
-    f3x3EcalEnergy(0.),
-    f5x5EcalEnergy(0.),
-    fType(0),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fE(0.),
-    fPx(0.),
-    fPy(0.),
-    fPz(0.),
-    fSteps(0),
-    fAlgo(0),
-    fLowTheta(),
-    fHighTheta(),
-    fMaxX(),
-    fMaxY()
-{
-
-}
-
-void CbmEcalPhotonCalibrator::InitArrays(UInt_t size, UInt_t start)
-{
-  fLowTheta.resize(size+1);
-  fHighTheta.resize(size+1);
-  fMaxX.resize(size+1);
-  fMaxY.resize(size+1);
-  for(UInt_t i=start;i<size+1;i++)
-  {
-    fLowTheta[i]=1111;
-    fHighTheta[i]=-1111;
-    fMaxX[i]=-1111;
-    fMaxY[i]=-1111;
-  }
-}
-
-void CbmEcalPhotonCalibrator::InitForGenerator()
-{
-  Float_t angle;
-  Char_t maxtype=0;
-  InitStructure();
-
-  CbmEcalInf* inf=fStr->GetEcalInf();
-  if (inf==NULL) 
-    return;
-
-  vector<CbmEcalModule*> modules;
-  fStr->GetStructure(modules);
-  for(UInt_t i=0;i<modules.size();i++)
-    if (modules[i]!=NULL&&modules[i]->GetType()>maxtype)
-      maxtype=modules[i]->GetType();
-
-  InitArrays(maxtype,0);
-  vector<CbmEcalCell*> cells;
-
-  for(UInt_t i=0;i<modules.size();i++)
-    if (modules[i])
-    {
-      Char_t moduleType=modules[i]->GetType();
-      if (moduleType==0) continue;
-      CbmEcalModule* module=modules[i];
-      cells=module->GetCells();
-      for(UInt_t j=0;j<cells.size();j++)
-      {
-	angle=GetAngle(cells[j]->GetX1(), cells[j]->GetY1(), inf->GetZPos());
-	if (angle<fLowTheta[moduleType])
-	  fLowTheta[moduleType]=angle;
-	if (angle>fHighTheta[moduleType])
-	  fHighTheta[moduleType]=angle;
-	angle=GetAngle(cells[j]->GetX1(), cells[j]->GetY2(), inf->GetZPos());
-	if (angle<fLowTheta[moduleType])
-	  fLowTheta[moduleType]=angle;
-	if (angle>fHighTheta[moduleType])
-	  fHighTheta[moduleType]=angle;
-	angle=GetAngle(cells[j]->GetX2(), cells[j]->GetY1(), inf->GetZPos());
-	if (angle<fLowTheta[moduleType])
-	  fLowTheta[moduleType]=angle;
-	if (angle>fHighTheta[moduleType])
-	  fHighTheta[moduleType]=angle;
-	angle=GetAngle(cells[j]->GetX2(), cells[j]->GetY2(), inf->GetZPos());
-	if (angle<fLowTheta[moduleType])
-	  fLowTheta[moduleType]=angle;
-	if (angle>fHighTheta[moduleType])
-	  fHighTheta[moduleType]=angle;
-
-	if (cells[j]->GetX2()>fMaxX[moduleType])
-	  fMaxX[moduleType]=cells[j]->GetX2();
-	if (cells[j]->GetY2()>fMaxY[moduleType])
-	  fMaxY[moduleType]=cells[j]->GetY2();
-
-      }
-    }
-
-}
-void CbmEcalPhotonCalibrator::InitStructure()
-{
-  if (CbmEcalInf::GetInstance(NULL)==NULL)
-    if (CbmEcalInf::GetInstance(fGeoFile)==NULL)
-    {
-      cerr << "Error: Can't read file " << fGeoFile << endl;
-      return;
-    }
-  fStr=new CbmEcalStructure(CbmEcalInf::GetInstance(NULL));
-  fStr->Construct();
-}
-
-Float_t CbmEcalPhotonCalibrator::GetAngle(Float_t x, Float_t y, Float_t z)
-{
-  Float_t dx=x-fBirthX;
-  Float_t dy=y-fBirthY;
-  Float_t dz=z-fBirthZ;
-  return TMath::ACos(TMath::Abs(dz)/TMath::Sqrt(dx*dx+dy*dy+dz*dz));
-
-}
-
-InitStatus CbmEcalPhotonCalibrator::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-
-  if (fInf==NULL)
-  {
-    cerr << "Can't get information from " << fGeoFile << endl;
-    return kFATAL;
-  }
-  fLitePoints=(TClonesArray*)fManager->GetObject("EcalPointLite");
-  if (fLitePoints==NULL)
-  {
-    cerr << "There are no EcalPointLite branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fEcalPoints=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (fEcalPoints==NULL)
-  {
-    cerr << "There are no EcalPoint branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fMCTracks=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (fMCTracks==NULL)
-  {
-    cerr << "There are no MCTrack branch in the file!!!" << endl;
-    return kFATAL;
-  }
-
-  fInf->CheckVariables();
-  fStr=new CbmEcalStructure(fInf);
-  fStr->Construct();
-  fEvent=0;
-
-  fTree=NULL;
-  return kSUCCESS;
-}
-
-void CbmEcalPhotonCalibrator::Exec(Option_t*)
-{
-  CbmEcalPointLite* pt=NULL;
-  CbmEcalPoint* p=NULL;
-  CbmEcalCell* cell;
-  CbmEcalCell* oldcell;
-  CbmMCTrack* track;
-  TVector3 mom;
-  UInt_t n;
-  Int_t ten;
-  Bool_t isPS;
-  UInt_t points=0;
-  Float_t EcalE=0;
-//  Float_t EcalPSE=0;
-  Float_t EcalFullE=0;
-  CbmEcalInf* inf=CbmEcalInf::GetInstance(NULL);
-  Float_t dz=inf->GetPSLead()+inf->GetPSScin()+inf->GetPSGap();
-  Float_t x;
-  Float_t y;
-//  Float_t z;
-
-  Float_t energy;
-  Float_t psenergy=0.;
-
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator pc;
-
-  fEvent++;
-  if (fTree==NULL)
-  {
-    fTree=new TTree("ECALcal","ECAL calibration tree");
-    fTree->Branch("fe",&fFullEnergy,"fe/F");
-    fTree->Branch("ecale",&fEcalEnergy,"ecale/F");
-
-    fTree->Branch("ecale2x2",&f2x2EcalEnergy,"ecale2x2/F");
-
-    fTree->Branch("ecale3x3",&f3x3EcalEnergy,"ecale3x3/F");
-
-    fTree->Branch("ecale5x5",&f5x5EcalEnergy,"ecale5x5/F");
-
-    fTree->Branch("e",&fE,"e/F");
-    fTree->Branch("px",&fPx,"px/F");
-    fTree->Branch("py",&fPy,"py/F");
-    fTree->Branch("pz",&fPz,"pz/F");
-    fTree->Branch("x",&fX,"x/F");
-    fTree->Branch("y",&fY,"y/F");
-    fTree->Branch("z",&fZ,"z/F");
-    fTree->Branch("steps",&fSteps,"steps/I");
-    fTree->Branch("type",&fType,"type/I");
-  }
-  cout << "--> Event no." << fEvent << endl;
-  
-  fStr->ResetModules();
-
-  // Filling structure
-  n=fLitePoints->GetEntriesFast();
-  cout << "Number of input MC points: " << n << flush;
-  for(UInt_t i=0;i<n;i++)
-  {
-    pt=(CbmEcalPointLite*)fLitePoints->At(i);
-    cell=fStr->GetCell(pt->GetDetectorID(), ten, isPS);
-    if (ten==0)
-    {
-//      EcalFullE+=pt->GetEnergyLoss();
-      if (isPS)
-      {
-	; 
-//	cell->AddPSEnergy(pt->GetEnergyLoss());
-//	EcalPSE+=pt->GetEnergyLoss();
-      }
-      else
-      {
-	cell->AddEnergy(pt->GetEnergyLoss());
-//	EcalE+=pt->GetEnergyLoss();
-      }
-    }
-  }
-  cells.clear();
-  fStr->GetCells(cells);
-  for(pc=cells.begin();pc!=cells.end();++pc)
-  {
-    cell=(*pc);
-    if (fNoise>0)
-      energy=cell->GetEnergy()+gRandom->Gaus(0,fNoise);
-    else
-      energy=cell->GetEnergy();
-
-    if (energy<fThreshold) energy=0;
-    cell->SetEnergy(energy);
-    EcalE+=energy;
-    EcalFullE+=energy+psenergy;
-  }
-
-  fFullEnergy=EcalFullE;
-  fEcalEnergy=EcalE;
-
-  n=fEcalPoints->GetEntriesFast();
-  cout << ". Number of incoming particles: " << n << flush;
-
-  for(UInt_t i=0;i<n;i++)
-  {
-    p=(CbmEcalPoint*)fEcalPoints->At(i);
-    track=(CbmMCTrack*)fMCTracks->At(p->GetTrackID());
-    p->Momentum(mom);
-    if (TMath::Abs(mom.Mag()-fEnergy)<fEnergy*1e-3&&track->GetPdgCode()==fPDGCode)
-    {
-      fX=p->GetX();
-      fY=p->GetY();
-      fZ=p->GetZ();
-      fPx=p->GetPx();
-      fPy=p->GetPy();
-      fPz=p->GetPz();
-      fE=fEnergy;
-      points++;
-    }
-  }
-  if (points!=1)
-  {
-    cout << endl;
-    cout << "Some thing strange. Number of";
-    cout << "suitable MC points: " << points << endl;
-    return;
-  }
-
-// z=fZ+dz;
-  x=fX+fPx/fPz*dz;
-  y=fY+fPy/fPz*dz;
-
-  cell=fStr->GetCell(x,y);
-  if (cell==NULL)
-  {
-    cout << "Error: Can't find cell with (" << x << ",";
-    cout << y << ")" << endl;
-    return;
-  }
-  fSteps=0;
-  oldcell=NULL;
-  list<CbmEcalCell*> lst;
-  list<CbmEcalCell*>::const_iterator lp=lst.begin();
-  while(oldcell!=cell)
-  {
-    oldcell=cell;
-    cell->GetNeighborsList(0,lst);
-    fSteps++;
-    for(lp=lst.begin();lp!=lst.end();++lp)
-      if ((*lp)->GetTotalEnergy()>cell->GetTotalEnergy())
-      {
-	cell=(*lp);
-      }
-  }
-
-  fType=fStr->GetModule(cell->GetCenterX(), cell->GetCenterY())->GetType();
-
-  cell->GetClusterEnergy(0,f3x3EcalEnergy);
-  f2x2EcalEnergy=0;
-  if (fAlgo==0)
-    for(Int_t j=1;j<5;j++)
-    {
-      cell->GetClusterEnergy(j,EcalE);
-      if (EcalE>f2x2EcalEnergy)
-      {
-        f2x2EcalEnergy=EcalE;
-      }
-    }
-  else
-  {
-    Double_t mine;
-    Double_t maxe;
-    CbmEcalCell* min;
-    Int_t max=-1111;
-    Int_t j;
-    Double_t e;
-
-    mine=cell->GetTotalEnergy(); min=cell;
-    maxe=-1.0;
-    cells.clear();
-    /** Find minimum cell **/
-    cell->GetNeighborsList(0, cells);
-    for(pc=cells.begin();pc!=cells.end();++pc)
-      if ((*pc)->GetTotalEnergy()<mine)
-      {
-	mine=(*pc)->GetTotalEnergy();
-	min=(*pc);
-      }
-    for(j=1;j<5;j++)
-    {
-      cell->GetNeighborsList(j, cells);
-      e=0;
-      for(pc=cells.begin();pc!=cells.end();++pc)
-	e+=(*pc)->GetTotalEnergy();
-      if (e>maxe)
-      {
-	maxe=e;
-	max=j;
-      }
-    }
-    maxe+=cell->GetTotalEnergy();
-    cell->GetNeighborsList(max, cells);
-    cells.push_back(cell);
-    if (find(cells.begin(), cells.end(), min)==cells.end())
-      cells.push_back(min);
-    for(pc=cells.begin();pc!=cells.end();++pc)
-    {
-      f2x2EcalEnergy+=(*pc)->GetEnergy();
-    }
-  }
-  cout << endl;
-  fTree->Fill();
-}
-
-void CbmEcalPhotonCalibrator::Finish()
-{
-  ;
-}
-
-CbmEcalPhotonCalibrator::~CbmEcalPhotonCalibrator()
-{
-  fTree->Write();
-}
-
-ClassImp(CbmEcalPhotonCalibrator)
diff --git a/ecal/CbmEcalPhotonCalibrator.h b/ecal/CbmEcalPhotonCalibrator.h
deleted file mode 100644
index 05212b155940afa8a4ebaac9fd23647a5cd93183..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalPhotonCalibrator.h
+++ /dev/null
@@ -1,243 +0,0 @@
-/* $Id: CbmEcalPhotonCalibrator.h,v 1.3 2006/07/30 13:10:35 prokudin Exp $ */
-/* CbmEcalPhotonCalibrator.h by Mikhail Prokudin
- * Class provides geometry information for correct
- * photon(or other particles) generation and replaces
- * hit producer, to draw all necessary histograms */
-/*
- * $Log: CbmEcalPhotonCalibrator.h,v $
- * Revision 1.3  2006/07/30 13:10:35  prokudin
- * Bug hunting
- *
- * Revision 1.2  2006/07/25 20:23:31  prokudin
- * Thresholds and noise added
- *
- * Revision 1.1  2006/07/19 09:34:45  prokudin
- * First version
- *
- */
-
-#ifndef CBMECALPHOTONCALIBRATOR_H
-#define CBMECALPHOTONCALIBRATOR_H
-
-#include "FairTask.h"
-
-#include <vector>
-
-class CbmEcalInf;
-class CbmEcalStructure;
-class TClonesArray;
-class TTree;
-
-class CbmEcalPhotonCalibrator : public FairTask
-{
-public:
-  CbmEcalPhotonCalibrator(const char* name, const Int_t iVerbose=1, const char* fileGeo="ecal_FullMC.geo");
-
-  TString GetGeoFileName();
-
-  /** Must be called before GetLowTheta, GetHighTheta,
-   ** GetMaxX, GetMaxY**/
-  void InitForGenerator();
-
-  /** Returns maximum X for cells of given type**/
-  Float_t GetMaxX(Int_t type);
-  /** Returns maximum Y for cells of given type**/
-  Float_t GetMaxY(Int_t type);
-  /** Returns a low boundary for theta **/
-  Float_t GetLowTheta(Int_t type);
-  /** Returns a high boundary for theta **/
-  Float_t GetHighTheta(Int_t type);
-
-  /** Set energy of particles to analize **/
-  void SetEnergy(Float_t energy);
-  /** Get energy of particles to analize **/
-  Float_t GetEnergy() const;
-
-  /** Set noise for ECAL (GeV) **/
-  void SetNoise(Float_t noise);
-
-  Float_t GetNoise() const;
-
-  /** Set threshold for ECAL (GeV)**/
-  void SetThreshold(Float_t threshold);
-
-  Float_t GetThreshold() const;
- 
-  /** Set PDG code of particles to analize **/
-  void SetPDGCode(Int_t code);
-  /** Get PDG code of particles to analize **/
-  Int_t GetPDGCode() const;
-
-  virtual InitStatus Init();
-  virtual void Exec(Option_t* option);
-  virtual void Finish();
-  /** Destructor must be virtual because of the virtual
-   ** methods **/
-  virtual ~CbmEcalPhotonCalibrator();
-
-  /** Set photon birth point **/
-  void SetPhotonXYZ(Float_t x=0, Float_t y=0, Float_t z=0);
-  /** Set algorithm of cluster construction **/
-  void SetAlgo(Int_t algo) {fAlgo=algo;}
-private:
-  /** Init procedure for fLowTheta, fHiTheta, fMaxX, fMaxY**/
-  void InitArrays(UInt_t size=15, UInt_t start=0);
-  void InitStructure();
-  Float_t GetAngle(Float_t x, Float_t y, Float_t z);
-  /** Structure container **/
-  CbmEcalStructure* fStr;
-  /** Event number **/
-  UInt_t fEvent;
-  /** Energy of particles to analize **/
-  Float_t fEnergy;
-  /** PDG code of particles to analize **/
-  Int_t fPDGCode;
-  /** Name of geometry container **/
-  TString fGeoFile;
-
-  /** Lite MC points **/
-  TClonesArray* fLitePoints;
-  /** ECAL MC points at the begin of the ECAL**/
-  TClonesArray* fEcalPoints;
-  /** Array of MC tracks **/
-  TClonesArray* fMCTracks;
-
-  /** X coordinate of photon birth point **/
-  Float_t fBirthX;
-  /** Y coordinate of photon birth point **/
-  Float_t fBirthY;
-  /** Z coordinate of photon birth point **/
-  Float_t fBirthZ;
-
-  /** Threshold for ECAL **/
-  Float_t fThreshold;
-  /** Noise in ECAL **/
-  Float_t fNoise;
-
-  CbmEcalInf* fInf;
-
-  /** output tree **/
-  TTree* fTree;
-
-  /** Full energy deposited in ECAL **/
-  Float_t fFullEnergy;
-  /** Energy deposited in ECAL, not in PS **/
-  Float_t fEcalEnergy;
-
-  /** Energy deposited in ECAL in 2x2 cluster **/
-  Float_t f2x2EcalEnergy;
-  /** Energy deposited in ECAL in 3x3 cluster **/
-  Float_t f3x3EcalEnergy;
-  /** Energy deposited in ECAL in 5x5 cluster **/
-  Float_t f5x5EcalEnergy;
-
-  /** Type of ECAL cells used in analysis **/
-  Int_t fType;
-  /** Coordinates of ECAL hit **/
-  Float_t fX;
-  Float_t fY;
-  Float_t fZ;
-  /** Energy and momentum of incoming particle **/
-  Float_t fE;
-  Float_t fPx;
-  Float_t fPy;
-  Float_t fPz;
-  /** Numeber of steps to find maximum cell **/
-  Int_t fSteps;
-  /** Algorithm of cluster construction **/
-  Int_t fAlgo;
-
-  std::vector<Float_t> fLowTheta;
-  std::vector<Float_t> fHighTheta;
-  std::vector<Float_t> fMaxX;
-  std::vector<Float_t> fMaxY;
-
-  CbmEcalPhotonCalibrator(const CbmEcalPhotonCalibrator&);
-  CbmEcalPhotonCalibrator& operator=(const CbmEcalPhotonCalibrator&);
-
-  ClassDef(CbmEcalPhotonCalibrator, 1)
-};
-
-/** Set energy of particles to analize **/
-inline void CbmEcalPhotonCalibrator::SetEnergy(Float_t energy)
-{
-  fEnergy=energy;
-}
-
-/** Get energy of particles to analize **/
-inline Float_t CbmEcalPhotonCalibrator::GetEnergy() const
-{
-  return fEnergy;
-}
-
-/** Set PDG code of particles to analize **/
-inline void CbmEcalPhotonCalibrator::SetPDGCode(Int_t code)
-{
-  fPDGCode=code;
-}
-
-/** Get PDG code of particles to analize **/
-inline Int_t CbmEcalPhotonCalibrator::GetPDGCode() const
-{
-  return fPDGCode;;
-}
-
-/** Returns maximum X for cells of given type**/
-inline Float_t CbmEcalPhotonCalibrator::GetMaxX(Int_t type)
-{
-  return fMaxX[type];
-}
-
-/** Returns maximum Y for cells of given type**/
-inline Float_t CbmEcalPhotonCalibrator::GetMaxY(Int_t type)
-{
-  return fMaxY[type];
-}
-
-/** Returns a low boundary for theta **/
-inline Float_t CbmEcalPhotonCalibrator::GetLowTheta(Int_t type)
-{
-  return fLowTheta[type];
-}
-
-/** Returns a high boundary for theta **/
-inline Float_t CbmEcalPhotonCalibrator::GetHighTheta(Int_t type)
-{
-  return fHighTheta[type];
-}
-
-inline TString CbmEcalPhotonCalibrator::GetGeoFileName() 
-{
-  return fGeoFile;
-}
-
-inline void CbmEcalPhotonCalibrator::SetPhotonXYZ(Float_t x, Float_t y, Float_t z)
-{
-  fBirthX=x;
-  fBirthY=y;
-  fBirthZ=z;
-}
-
-/** Set noise for ECAL (GeV) **/
-inline void CbmEcalPhotonCalibrator::SetNoise(Float_t noise)
-{
-	fNoise=noise;
-}
-
-inline Float_t CbmEcalPhotonCalibrator::GetNoise() const
-{
-	return fNoise;
-}
-
-/** Set threshold for ECAL (GeV)**/
-inline void CbmEcalPhotonCalibrator::SetThreshold(Float_t threshold)
-{
-	fThreshold=threshold;
-}
-
-inline Float_t CbmEcalPhotonCalibrator::GetThreshold() const
-{
-	return fThreshold;
-}
-
-#endif
diff --git a/ecal/CbmEcalPosLib.cxx b/ecal/CbmEcalPosLib.cxx
deleted file mode 100644
index 62166faf9629f30605b119ba614f11044c7100e0..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalPosLib.cxx
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "CbmEcalPosLib.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalParam.h"
-
-#include "FairRootManager.h"
-
-#include <iostream>
-
-using namespace std;
-
-CbmEcalPosLib::CbmEcalPosLib()
-  : FairTask(),
-    fX(0.),
-    fY(0.),
-    fParName(""),
-    fContName(""),
-    fF0P0(0.),
-    fF1P0(0.),
-    fF2P0(0.),
-    fF0P1(0.),
-    fF1P1(0.),
-    fF2P1(0.),
-    fF0P2(0.),
-    fF1P2(0.),
-    fF2P2(0.),
-    fInf(NULL)
-{
-}
-
-
-CbmEcalPosLib::CbmEcalPosLib(const char* nm, Int_t verb, const char* fname)
-  : FairTask(nm, verb),
-    fX(0.),
-    fY(0.),
-    fParName(fname),
-    fContName(""),
-    fF0P0(0.),
-    fF1P0(0.),
-    fF2P0(0.),
-    fF0P1(0.),
-    fF1P1(0.),
-    fF2P1(0.),
-    fF0P2(0.),
-    fF1P2(0.),
-    fF2P2(0.),
-    fInf(NULL)
-{
-}
-
-void CbmEcalPosLib::Exec(const Option_t*)
-{
-  ;
-}
-
-InitStatus CbmEcalPosLib::Init()
-{
-  FairRootManager* io=FairRootManager::Instance();
-  CbmEcalParam* par=new CbmEcalParam("calibration", fParName);
-
-  fF0P0=par->GetDouble("f0p0");
-  fF1P0=par->GetDouble("f1p0");
-  fF2P0=par->GetDouble("f2p0");
-  fF0P1=par->GetDouble("f0p1");
-  fF1P1=par->GetDouble("f1p1");
-  fF2P1=par->GetDouble("f2p1");
-  fF0P2=par->GetDouble("f0p2");
-  fF1P2=par->GetDouble("f1p2");
-  fF2P2=par->GetDouble("f2p2");
-
-  fContName=par->GetString("containername");
-
-  delete par;
-
-  if (!io)
-  {
-    Fatal("Init()", "Can't find FairRootManager.");
-    return kFATAL;
-  }
-  CbmEcalStructure* fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fInf=fStr->GetEcalInf();
-
-  io->Register(fContName, "ECAL", this, kFALSE);
-  return kSUCCESS;
-}
-
-void CbmEcalPosLib::GetXY(Double_t e, Double_t x, Double_t y)
-{
-  static Double_t z=fInf->GetZPos();
-  Double_t r=TMath::Sqrt(x*x+y*y);
-  Double_t theta=TMath::ATan2(r, z)*TMath::RadToDeg();
-  Double_t dr=GetDR(e, theta);
-  theta=TMath::ATan2(r+dr, z)*TMath::RadToDeg();
-  dr=GetDR(e, theta);
-  Double_t phi=TMath::ATan2(y, x);
-  fX=x; fX+=TMath::Cos(phi)*dr;
-  fY=y; fY+=TMath::Sin(phi)*dr;
-}
-
-void CbmEcalPosLib::Finish()
-{
-  ;
-}
-
-CbmEcalPosLib::~CbmEcalPosLib()
-{
-  ;
-}
-
-ClassImp(CbmEcalPosLib)
diff --git a/ecal/CbmEcalPosLib.h b/ecal/CbmEcalPosLib.h
deleted file mode 100644
index 6d2b0e3396173448502bd3162d65946ff5e87ff5..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalPosLib.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef CBMECALPOSLIB_H
-#define CBMECALPOSLIB_H
-
-#include "FairTask.h"
-
-#include "TMath.h"
-
-class CbmEcalInf;
-
-class CbmEcalPosLib : public FairTask
-{
-public:
-  CbmEcalPosLib();
-  CbmEcalPosLib(const char* nm, Int_t verb, const char* fname);
-
-  Double_t X() const {return fX;}
-  Double_t Y() const {return fY;}
-
-  virtual void Exec(const Option_t* opt);
-  virtual InitStatus Init();
-  virtual void Finish();
-
-  void GetXY(Double_t e, Double_t x, Double_t y);
-  Double_t GetDR(Double_t e, Double_t theta);
-  virtual ~CbmEcalPosLib();
-
-private:
-  /** Result of (X,Y) approximation **/
-  Double_t fX;
-  Double_t fY;
-
-  /** Name of parameter file **/
-  TString fParName;
-  /** Name of container **/
-  TString fContName;
-  /** Position library **/
-  Double_t fF0P0;
-  Double_t fF1P0;
-  Double_t fF2P0;
-  Double_t fF0P1;
-  Double_t fF1P1;
-  Double_t fF2P1;
-  Double_t fF0P2;
-  Double_t fF1P2;
-  Double_t fF2P2;
-  /** Information container of calorimeter **/
-  CbmEcalInf* fInf;		//!
-
-  CbmEcalPosLib(const CbmEcalPosLib&);
-  CbmEcalPosLib& operator=(const CbmEcalPosLib&);
-
-  ClassDef(CbmEcalPosLib, 1);
-};
-
-inline Double_t CbmEcalPosLib::GetDR(Double_t e, Double_t theta)
-{
-  Double_t f0=fF0P0+e*(fF0P1+fF0P2*e);
-  Double_t f1=fF1P0*TMath::Log(e)+fF1P1+fF1P2*e;
-  Double_t f2=fF2P0+e*(fF2P1+fF2P2*e);
-  return f0+theta*(f1+theta*f2);
-}
-#endif
diff --git a/ecal/CbmEcalPreCluster.h b/ecal/CbmEcalPreCluster.h
deleted file mode 100644
index a7ffb31fdfb58482693c0e29288c0884d12479b4..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalPreCluster.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/** A helper class for cluster finder
- ** Need refactoring. April 2011 //Dr.Sys **/
-#ifndef CBMECALPRECLUSTER_H
-#define CBMECALPRECLUSTER_H
-
-#include "CbmEcalCell.h"
-#include "CbmEcalMaximum.h"
-
-#include <list>
-//#include <iostream>
-
-class CbmEcalPreCluster
-{
-public:
-  CbmEcalPreCluster(const std::list<CbmEcalCell*> cells, CbmEcalCell* max, CbmEcalCell* min, Double_t energy=-1111.0) 
-    : fCells(cells), fMaximum(max), fMinimum(min), fEnergy(energy), fMax(NULL), fMark(0) 
-  {
-  }
-
-  CbmEcalPreCluster(const std::list<CbmEcalCell*> cells, CbmEcalMaximum* max, CbmEcalCell* min, Double_t energy=-1111.0) 
-    : fCells(cells), fMaximum(max->Cell()), fMinimum(min), fEnergy(energy), fMax(max), fMark(0) 
-  {
-//    std::cout << "list: " << fEnergy << std::endl;
-  }
-
-  CbmEcalPreCluster(CbmEcalCell** cells, Int_t size, CbmEcalCell* max, CbmEcalCell* min, Double_t energy=-1111.0)
-    : fCells(), fMaximum(max), fMinimum(min), fEnergy(energy), fMax(NULL), fMark(0) 
-  {
-    fCells.clear();
-    for(Int_t i=0;i<size;i++)
-      fCells.push_back(cells[i]);
-  }
-
-  CbmEcalPreCluster(CbmEcalCell** cells, Int_t size, CbmEcalMaximum* max, CbmEcalCell* min, Double_t energy=-1111.0)
-    : fCells(), fMaximum(max->Cell()), fMinimum(min), fEnergy(energy), fMax(max), fMark(0) 
-  {
-    fCells.clear();
-    for(Int_t i=0;i<size;i++)
-      fCells.push_back(cells[i]);
-  }
-
-  std::list<CbmEcalCell*> fCells;
-  CbmEcalCell* fMaximum;
-  CbmEcalCell* fMinimum;
-  Double_t fEnergy;
-  CbmEcalMaximum* fMax;		//!
-  Int_t fMark;
-
- private:
-  CbmEcalPreCluster(const CbmEcalPreCluster&);
-  CbmEcalPreCluster& operator=(const CbmEcalPreCluster&);
-};
-
-#endif
diff --git a/ecal/CbmEcalPrepare.cxx b/ecal/CbmEcalPrepare.cxx
deleted file mode 100644
index 4b554e67445f6fcdd33096c11fbcf47003a6abe7..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalPrepare.cxx
+++ /dev/null
@@ -1,83 +0,0 @@
-#include "CbmEcalPrepare.h"
-
-#include "CbmEcalStructure.h"
-
-#include "FairRootManager.h"
-
-#include "TRandom.h"
-
-#include <iostream>
-#include <list>
-
-using namespace std;
-
-/** --- Default constructor --------------------------------------------------- **/
-CbmEcalPrepare::CbmEcalPrepare() 
-  : FairTask(),
-    fPedestal(80),
-    fADCMax(4096),
-    fADCChannel(0.5e-3),
-    fStr(NULL)
-{
-}
-
-/** --- Standard constructor. Use this ---------------------------------------- **/
-CbmEcalPrepare::CbmEcalPrepare(const char* name, Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fPedestal(80),
-    fADCMax(4096),
-    fADCChannel(0.5e-3),
-    fStr(NULL)
-{
-}
-
-/** --- Initialization of the task -------------------------------------------- **/  
-InitStatus CbmEcalPrepare::Init()
-{
-  FairRootManager* manager=FairRootManager::Instance();
-  if (!manager)
-  {
-    Fatal("Init()", "Can't find IOManager.");
-    return kFATAL;
-  }
-
-  fStr=(CbmEcalStructure*)manager->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  
-  return kSUCCESS;
-}
-
-/** --- Executed task --------------------------------------------------------- **/ 
-void CbmEcalPrepare::Exec(Option_t*)
-{
-  CbmEcalCell* cell;
-  list<CbmEcalCell*> cells;
-  fStr->GetCells(cells);
-  list<CbmEcalCell*>::const_iterator p=cells.begin();
-  Short_t adc;
-
-  for(;p!=cells.end();++p)
-  {
-    cell=(*p);
-    adc=cell->GetADC();
-    adc-=fPedestal; if (adc<0) adc=0;
-    cell->SetEnergy(adc*fADCChannel);
-  }
-}
-
-/** --- Finish task ----------------------------------------------------------- **/ 
-void CbmEcalPrepare::Finish()
-{
-  ;
-}
-/** --- Destructor ------------------------------------------------------------ **/
-CbmEcalPrepare::~CbmEcalPrepare()
-{
-  ;
-}
-
-ClassImp(CbmEcalPrepare)
diff --git a/ecal/CbmEcalPrepare.h b/ecal/CbmEcalPrepare.h
deleted file mode 100644
index 9dbc90a552b207d6003eec99ae07ae3f83370144..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalPrepare.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Converts ADC -> energy depostion in plastic
-// Very simple realization. 
-
-#ifndef CBMECALPREPARE_H
-#define CBMECALPREPARE_H
-
-#include "FairTask.h"
-
-class CbmEcalStructure;
-
-class CbmEcalPrepare : public FairTask
-{
-public:
-  /** Default constructor **/
-  CbmEcalPrepare();
-  /** Standard constructor. Use this **/
-  CbmEcalPrepare(const char* name, Int_t iVerbose);
-  /** Destructor **/
-  virtual ~CbmEcalPrepare();
-  /** Initialization of the task **/  
-  virtual InitStatus Init();
-  /** Executed task **/ 
-  virtual void Exec(Option_t* option);
-  /** Finish task **/ 
-  virtual void Finish();
-  
-
-  void SetPedestal(Short_t ped=80) {fPedestal=ped;}
-  void SetADCMax(Short_t adcmax=4096) {fADCMax=adcmax;}
-  void SetADCChannel(Float_t adcchannel=0.5e-3) {fADCChannel=adcchannel;}
-
-  Short_t GetPedestal() const {return fPedestal;}
-  Short_t GetADCMax() const {return fADCMax;}
-  Float_t GetADCChannel() const {return fADCChannel;}
-private:
-  // Pedestal 
-  Short_t fPedestal;
-  // ADC maximum
-  Short_t fADCMax;
-  // ADC channel (in energy deposition in _SCINTILLATOR_)
-  Float_t fADCChannel;
-  // Calorimeter structure
-  CbmEcalStructure* fStr;	//!
-
-  CbmEcalPrepare(const CbmEcalPrepare&);
-  CbmEcalPrepare& operator=(const CbmEcalPrepare&);
-
-  ClassDef(CbmEcalPrepare, 1);
-};
-
-#endif
diff --git a/ecal/CbmEcalQualityCheck.cxx b/ecal/CbmEcalQualityCheck.cxx
deleted file mode 100644
index 00e700d97eb82be5a110097132ea3522c70e7025..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalQualityCheck.cxx
+++ /dev/null
@@ -1,768 +0,0 @@
-#include "CbmEcalQualityCheck.h"
-
-#include "FairRootManager.h"
-
-#include "CbmMCTrack.h"
-#include "FairTrackParam.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalRecParticle.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalShLib.h"
-#include "CbmEcalCluster.h"
-#include "CbmEcalCellMC.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TASImage.h"
-#include "TText.h"
-
-#include <stdio.h>
-
-#include <iostream>
-
-using namespace std;
-
-class CbmEcalQualityCheckItem
-{
-public:
-  CbmEcalQualityCheckItem(CbmEcalCell* cell, Float_t r, Float_t g, Float_t b)
-    : fCell(cell), fR(r), fG(g), fB(b) {};
-  CbmEcalCell* fCell;
-  Float_t fR;
-  Float_t fG;
-  Float_t fB;
-};
-
-void CbmEcalQualityCheck::Exec(Option_t*)
-{
-  Int_t i;
-  Int_t j;
-  Int_t pn=fPoints->GetEntriesFast();
-  Int_t trn=fMCTracks->GetEntriesFast();
-  Int_t rn=fReco->GetEntriesFast();
-  CbmEcalPoint* p;
-  CbmEcalPoint* po;
-  CbmMCTrack* tr;
-  CbmMCTrack* tq;
-  CbmEcalRecParticle* r=NULL;
-  CbmEcalRecParticle* rm=NULL;
-  Double_t rmin;
-  Double_t rad;
-  Double_t dx;
-  Double_t dy;
-
-  CreateTree();
-  fEventN++;
-  if (fVerbose>0)
-    Info("Exec", "Event %d.", fEventN);
-  for(i=0;i<pn;i++)
-  {
-    p=(CbmEcalPoint*)fPoints->At(i);
-    if (!p) continue;
-    tr=(CbmMCTrack*)fMCTracks->At(p->GetTrackID());
-    /** Only photons **/
-    if (tr->GetPdgCode()!=22&&TMath::Abs(tr->GetPdgCode())!=2112) continue;
-    /** ... prompt and pi0 decay photons ... **/
-    //if (tr->GetStartZ()>0.1) continue;
-    /** ... energetic enough ... **/
-    if (tr->GetEnergy()<0.5) continue;
-    /** ... from pi^0 decay ... **/
-    if (tr->GetMotherId()>=0&&tr->GetPdgCode()==22)
-    {
-      tq=(CbmMCTrack*)fMCTracks->At(tr->GetMotherId());
-      if (tq->GetPdgCode()!=111) continue;
-    }
-    for(j=0;j<trn;j++)
-    {
-      tq=(CbmMCTrack*)fMCTracks->At(j);
-      if (tq->GetMotherId()==p->GetTrackID())
-        break;
-    }
-    /** ... and without daughter tracks. **/
-    if (trn!=j) continue;
-    rmin=1e10;
-    for(j=0;j<pn;j++)
-    {
-      if (i==j) continue;
-      po=(CbmEcalPoint*)fPoints->At(j);
-      dx=po->GetX(); dx-=p->GetX(); dx*=dx;
-      dy=po->GetY(); dy-=p->GetY(); dy*=dy;
-      rad=dx; rad+=dy;
-      if (rad<rmin) rmin=rad;
-    }
-    fR=TMath::Sqrt(rmin);
-
-    fMCX=p->GetX();
-    fMCY=p->GetY();
-    fMCZ=p->GetZ();
-    fMCPX=p->GetPx();
-    fMCPY=p->GetPy();
-    fMCPZ=p->GetPz();
-    fMCE=tr->GetEnergy();
-    fMCMotherTrN=tr->GetMotherId();
-    fPdgCode=tr->GetPdgCode();
-    rmin=2e10; rm=NULL;
-    fX=-1111; fY=-1111; fZ=-1111; fE=-1111; fPX=-1111; fPY=-1111; fPZ=-1111; fChi2=-1111;
-    for(j=0;j<rn;j++)
-    {
-      r=(CbmEcalRecParticle*)fReco->At(j);
-      if (r->MCTrack()==p->GetTrackID())
-	break;
-    }
-    if (j==rn)
-    {
-      fOut->Fill();
-      continue;
-    }
-    rm=r;
-    if (rm==NULL)
-    {
-      Info("Exec", "No reconstructed photons found!");
-      continue;
-    }
-    fX=rm->X(); fY=rm->Y(); fZ=rm->Z();
-    fE=rm->E(); fPX=rm->Px(); fPY=rm->Py(); fPZ=rm->Pz();
-    fChi2=rm->Chi2();
-    fOut->Fill();
-  }
-  if (fC) DrawImage();
-}
-
-void CbmEcalQualityCheck::PutPixel(Int_t x, Int_t y, Float_t r, Float_t g, Float_t b)
-{
-  if (x<0||x>=fCX) return;
-  if (y<0||y>=fCY) return;
-  if (r<0||r>1)return;
-  if (g<0||g>1)return;
-  if (b<0||b>1)return;
-  Int_t ri=(Int_t)(255.0*r);
-  Int_t gi=(Int_t)(255.0*g);
-  Int_t bi=(Int_t)(255.0*b);
-  static char color[10];
-  sprintf(color, "#%.2X%.2X%.2X", ri, gi, bi);
-  fC->PutPixel(x, y, color);
-}
-
-void CbmEcalQualityCheck::PutPixel(Int_t x, Int_t y, const char* color)
-{
-  if (x<0||x>=fCX) return;
-  if (y<0||y>=fCY) return;
-  fC->PutPixel(x, fCY-y-1, color);
-}
-
-/** draw cell with filled color. fEdging used as egding of cell **/
-void CbmEcalQualityCheck::DrawCell(CbmEcalCell* cell, Float_t r, Float_t g, Float_t b)
-{
-  Int_t ri=(Int_t)(255.0*r);
-  Int_t gi=(Int_t)(255.0*g);
-  Int_t bi=(Int_t)(255.0*b);
-  static char color[10];
-  sprintf(color, "#%.2X%.2X%.2X", ri, gi, bi);
-  DrawCell(cell, color);
-}
-
-void CbmEcalQualityCheck::DrawCell(CbmEcalCell* cell, const char* color)
-{
-  Int_t xi1=(Int_t)((cell->X1()/fInf->GetEcalSize(0))*fCX+fCX/2.0);
-  Int_t xi2=(Int_t)((cell->X2()/fInf->GetEcalSize(0))*fCX+fCX/2.0);
-  Int_t yi1=(Int_t)((cell->Y1()/fInf->GetEcalSize(1))*fCY+fCY/2.0);
-  Int_t yi2=(Int_t)((cell->Y2()/fInf->GetEcalSize(1))*fCY+fCY/2.0);
-  for(Int_t x=xi1;x<=xi2;x++)
-    for(Int_t y=yi1;y<=yi2;y++)
-      if (x==xi1||y==yi1||x==xi2||y==yi2)
-	PutPixel(x, y, fEdging);
-      else
-	PutPixel(x, y, color);
-
-}
-
-void CbmEcalQualityCheck::DrawMark(Double_t x, Double_t y, const char* color, Int_t type)
-{
-  Int_t xi=(Int_t)((x/fInf->GetEcalSize(0))*fCX+fCX/2.0);
-  Int_t yi=(Int_t)((y/fInf->GetEcalSize(1))*fCY+fCY/2.0);
-  PutPixel(xi-1, yi-1, color);
-  PutPixel(xi  , yi-1, color);
-  PutPixel(xi+1, yi-1, color);
-  PutPixel(xi-1, yi  , color);
-  PutPixel(xi  , yi  , color);
-  PutPixel(xi+1, yi  , color);
-  PutPixel(xi-1, yi+1, color);
-  PutPixel(xi  , yi+1, color);
-  PutPixel(xi+1, yi+1, color);
-  if (type==1) return;
-  PutPixel(xi-2, yi-2, color);
-  PutPixel(xi+2, yi-2, color);
-  PutPixel(xi-2, yi+2, color);
-  PutPixel(xi+2, yi+2, color);
-  PutPixel(xi  , yi-2, color);
-  PutPixel(xi-2, yi  , color);
-  PutPixel(xi  , yi+2, color);
-  PutPixel(xi+2, yi  , color);
-  PutPixel(xi  , yi-3, color);
-  PutPixel(xi-3, yi  , color);
-  PutPixel(xi  , yi+3, color);
-  PutPixel(xi+3, yi  , color);
-}
-
-void CbmEcalQualityCheck::DrawImage()
-{
-  TString name=fNamePrefix;
-  if (fEventN<10) name+="0";
-  if (fEventN<100) name+="0";
-  if (fEventN<1000) name+="0";
-  name+=fEventN;
-  fC->FillRectangle("#000000", 0, 0, fCX, fCY);
-  fEdging="#FFFFFF";
-  DrawCells();
-  DrawMC();
-  DrawTracks();
-  DrawPhotons();
-  /** some beauty **/
-  /*
-  PutPixel((Int_t)(fCX/2.0+ 0), (Int_t)(fCY/2.0+ 0), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 0), (Int_t)(fCY/2.0+ 1), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 0), (Int_t)(fCY/2.0+ 3), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 0), (Int_t)(fCY/2.0+ 4), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 1), (Int_t)(fCY/2.0+ 2), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 2), (Int_t)(fCY/2.0+ 0), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 2), (Int_t)(fCY/2.0+ 1), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 2), (Int_t)(fCY/2.0+ 3), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 2), (Int_t)(fCY/2.0+ 4), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 4), (Int_t)(fCY/2.0+ 0), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 4), (Int_t)(fCY/2.0+ 3), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 4), (Int_t)(fCY/2.0+ 4), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 5), (Int_t)(fCY/2.0+ 0), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 5), (Int_t)(fCY/2.0+ 2), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 6), (Int_t)(fCY/2.0+ 1), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 6), (Int_t)(fCY/2.0+ 2), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 6), (Int_t)(fCY/2.0+ 3), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 6), (Int_t)(fCY/2.0+ 4), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 8), (Int_t)(fCY/2.0+ 0), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 8), (Int_t)(fCY/2.0+ 1), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 8), (Int_t)(fCY/2.0+ 2), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 8), (Int_t)(fCY/2.0+ 3), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 8), (Int_t)(fCY/2.0+ 4), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 9), (Int_t)(fCY/2.0+ 1), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+ 9), (Int_t)(fCY/2.0+ 6), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+10), (Int_t)(fCY/2.0+ 2), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+10), (Int_t)(fCY/2.0+ 6), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+11), (Int_t)(fCY/2.0+ 0), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+11), (Int_t)(fCY/2.0+ 1), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+11), (Int_t)(fCY/2.0+ 2), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+11), (Int_t)(fCY/2.0+ 3), "#FFFFFF");
-  PutPixel((Int_t)(fCX/2.0+11), (Int_t)(fCY/2.0+ 4), "#FFFFFF");
-  */
-  fC->WriteImage(name+".png", TImage::kPng);
-}
-
-void CbmEcalQualityCheck::DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2,const char* color)
-{
-  Int_t x1i=(Int_t)((x1/fInf->GetEcalSize(0))*fCX+fCX/2.0);
-  Int_t y1i=(Int_t)((y1/fInf->GetEcalSize(1))*fCY+fCY/2.0);
-  Int_t x2i=(Int_t)((x2/fInf->GetEcalSize(0))*fCX+fCX/2.0);
-  Int_t y2i=(Int_t)((y2/fInf->GetEcalSize(1))*fCY+fCY/2.0);
-  if (x1i<0) x1i=0;
-  if (x1i>=fCX) x1i=fCX-1;
-  if (x2i<0) x2i=0;
-  if (x2i>=fCX) x2i=fCX-1;
-  if (y1i<0) y1i=0;
-  if (y1i>=fCY) y1i=fCY-1;
-  if (y2i<0) y2i=0;
-  if (y2i>=fCY) y2i=fCY-1;
-  y1i=fCY-y1i-1;
-  y2i=fCY-y2i-1;
-  fC->DrawLine(x1i, y1i, x2i, y2i, color);
-}
-
-void CbmEcalQualityCheck::DrawLine(Double_t x, Double_t y, const char* color, Int_t track)
-{
-  if (track==-1111) return;
-  Int_t i=0;
-  Int_t n=fPoints->GetEntriesFast();
-  CbmEcalPoint* pt=NULL;
-
-  for(i=0;i<n;i++)
-  {
-    pt=(CbmEcalPoint*)fPoints->At(i);
-    if (pt->GetTrackID()==track) break; 
-  }
-  if (i==n) return;
-  DrawLine(x, y, pt->GetX(), pt->GetY(), color);
-}
-
-void CbmEcalQualityCheck::DrawPhotons()
-{
-  Int_t rn=fReco->GetEntriesFast();
-  CbmEcalRecParticle* r;
-  Int_t i;
-  for(i=0;i<rn;i++)
-  {
-    r=(CbmEcalRecParticle*)fReco->At(i);
-    DrawLine(r->X(), r->Y(), "#0000FF", r->MCTrack());
-    DrawMark(r->X(), r->Y(), "#0000FF", 0);
-    DrawEnergy(r->X(), r->Y(), r->E(), "#0000FF");
-    DrawChi2(r->X(), r->Y(), r->Chi2(), "#0000FF");
-  }
-}
-
-void CbmEcalQualityCheck::DrawTracks()
-{
-  FairTrackParam* tr;
-  Int_t i;
-  Int_t n=fTracks->GetEntriesFast();
-  Double_t p;
-  for(i=0;i<n;i++)
-  {
-    tr=(FairTrackParam*)fTracks->At(i);
-    p=(TMath::Abs(tr->GetQp())>1.e-4)?1./TMath::Abs(tr->GetQp()):1.e4;
-    DrawMark(tr->GetX(), tr->GetY(), "#FF0000", 0);
-    DrawEnergy(tr->GetX(), tr->GetY(), p, "#FF7777");
-  }
-}
-
-Double_t CbmEcalQualityCheck::GetP(CbmEcalPoint* p)
-{
-  Double_t px=p->GetPx();
-  Double_t py=p->GetPy();
-  Double_t pz=p->GetPz();
-
-  return TMath::Sqrt(px*px+py*py+pz*pz);
-}
-
-  /** Draw chi2 for photons **/
-void CbmEcalQualityCheck::DrawChi2(Float_t x, Float_t y, Float_t chi2, const char* color)
-{
-  char stri[30];
-  Int_t xi=(Int_t)((x/fInf->GetEcalSize(0))*fCX+fCX/2.0);
-  Int_t yi=(Int_t)((y/fInf->GetEcalSize(1))*fCY+fCY/2.0);
-  yi-=8;
-  yi=fCY-yi-1;
-  xi-=6;
-
-  if (chi2!=-1111)
-  {
-    sprintf(stri,"%.1f", chi2);
-    fC->DrawText(xi, yi, stri, 8, color, "arialbd.ttf");
-  }
-  else
-    fC->DrawText(xi, yi, "-111", 8, color, "arialbd.ttf");
-}
-
-
-void CbmEcalQualityCheck::DrawEnergy(CbmEcalPoint* p, const char* color)
-{
-  if (GetP(p)<0.01) return;
-  char stri[10];
-  Int_t x=(Int_t)((p->GetX()/fInf->GetEcalSize(0))*fCX+fCX/2.0);
-  Int_t y=(Int_t)((p->GetY()/fInf->GetEcalSize(1))*fCY+fCY/2.0);
-  y+=9;
-  y=fCY-y-1;
-  x-=6;
-
-  sprintf(stri,"%.2f", GetP(p));
-  if (stri[0]=='0')
-  {
-    x+=2;
-    stri[0]=stri[1];
-    stri[1]=stri[2];
-    stri[2]=stri[3];
-    stri[3]=stri[4];
-    stri[4]=stri[5];
-    stri[5]=stri[6];
-    stri[6]=stri[7];
-  }
-  fC->DrawText(x, y, stri, 8, color, "arialbd.ttf");
-}
-
-void CbmEcalQualityCheck::DrawEnergy(Float_t x, Float_t y, Float_t p, const char* color)
-{
-  if (p<0.01) return;
-  char stri[10];
-  Int_t xi=(Int_t)((x/fInf->GetEcalSize(0))*fCX+fCX/2.0);
-  Int_t yi=(Int_t)((y/fInf->GetEcalSize(1))*fCY+fCY/2.0);
-  yi-=2;
-  yi=fCY-yi-1;
-  xi-=6;
-
-  sprintf(stri,"%.2f", p);
-  fC->DrawText(xi, yi, stri, 8, color, "arialbd.ttf");
-}
-
-void CbmEcalQualityCheck::DrawMC()
-{
-  Int_t i;
-  Int_t pn=fPoints->GetEntriesFast();
-  CbmEcalPoint* p;
-  CbmMCTrack* tr;
-  CbmMCTrack* tq;
-
-
-  for(i=0;i<pn;i++)
-  {
-    p=(CbmEcalPoint*)fPoints->At(i);
-    if (!p) continue;
-    tr=(CbmMCTrack*)fMCTracks->At(p->GetTrackID());
-    /** Secondary gammas **/
-    if (tr->GetPdgCode()==22&&tr->GetStartZ()>=0.1)
-    {
-      DrawMark(p->GetX(), p->GetY(), "#00FF00", 1);
-      DrawEnergy(p, "#00FF00");
-      continue;
-    }
-    if (TMath::Abs(tr->GetPdgCode()==11))
-    {
-      if (tr->GetMotherId()>=0)
-      {
-	tq=(CbmMCTrack*)fMCTracks->At(tr->GetMotherId());
-	/** Secondary electrons **/
-	if (tq->GetPdgCode()==22)
-	{
-          DrawMark(p->GetX(), p->GetY(), "#FFFF00", 1);
-          DrawEnergy(p, "#FFFF00");
-          continue;
-	}
-      }
-    }
-    /** Neutrons and antineutrons **/
-    if (TMath::Abs(tr->GetPdgCode()==2112))
-    {
-      DrawMark(p->GetX(), p->GetY(), "#FF00FF", 1);
-      DrawEnergy(p, "#FF00FF");
-      continue;
-    }
-    /** others **/
-    DrawMark(p->GetX(), p->GetY(), "#FF0000", 1);
-    DrawEnergy(p, "#FF0000");
-  }
-  for(i=0;i<pn;i++)
-  {
-    p=(CbmEcalPoint*)fPoints->At(i);
-    if (!p) continue;
-    tr=(CbmMCTrack*)fMCTracks->At(p->GetTrackID());
-    if (tr->GetPdgCode()==22&&tr->GetStartZ()<0.1)
-    {
-      DrawMark(p->GetX(), p->GetY(), "#00FFFF", 1);
-      DrawEnergy(p, "#00FFFF");
-    }
-  }
-}
-
-void CbmEcalQualityCheck::DrawCells()
-{
-  list<CbmEcalQualityCheckItem*>::const_iterator p;
-  list<CbmEcalCell*> clusters;
-  list<CbmEcalCell*>::const_iterator cp;
-  CbmMCTrack* tr;
-  CbmMCTrack* tq;
-  Float_t max;
-  std::map<Int_t, Float_t>::const_iterator p1;
-  CbmEcalCellMC* c;
-  CbmEcalRecParticle* r;
-  Int_t rn=fReco->GetEntriesFast();
-  Int_t i;
-  Int_t j;
-  Float_t x;
-  Float_t y;
-  Float_t dx;
-  Float_t dy;
-  Float_t rad;
-  Float_t phi;
-
-  clusters.clear();
-
-  for(i=0;i<rn;i++)
-  {
-    r=(CbmEcalRecParticle*)fReco->At(i);
-    CbmEcalCluster* cl=(CbmEcalCluster*)fClusters->At(r->ClusterNum());
-    for(j=0;j<cl->Size();j++)
-      clusters.push_back(fStr->GetHitCell(cl->CellNum(j)));
-  }
-
-  for(p=fCells.begin();p!=fCells.end();++p)
-  {
-    c=(CbmEcalCellMC*)((*p)->fCell);
-    (*p)->fG=c->GetTotalEnergy();
-    (*p)->fR=0;
-    (*p)->fB=0;
-    for(p1=c->GetTrackEnergyBegin();p1!=c->GetTrackEnergyEnd();++p1)
-    {
-      tr=(CbmMCTrack*)fMCTracks->At(p1->first);
-      if (tr->GetPdgCode()==22)
-	(*p)->fR+=p1->second;
-      else
-      if (tr->GetMotherId()>=0)
-      {
-	tq=(CbmMCTrack*)fMCTracks->At(tr->GetMotherId());
-	if (tq->GetPdgCode()==22)
-	  (*p)->fR+=p1->second;
-      }
-    }
-    if (find(clusters.begin(), clusters.end(), c)==clusters.end())
-      continue;
-    for(i=0;i<rn;i++)
-    {
-      r=(CbmEcalRecParticle*)fReco->At(i);
-      dx=x=c->GetCenterX();
-      dy=y=c->GetCenterY();
-      dx-=r->X();
-      dy-=r->Y();
-      if (TMath::Abs(dx)>30) continue;
-      if (TMath::Abs(dy)>30) continue;
-      rad=TMath::Sqrt(x*x+y*y);
-      phi=TMath::ACos(x/rad)*TMath::RadToDeg();
-      if (y<0) phi=360-phi;
-      (*p)->fB+=fShLib->GetResponse(dx, dy, phi, TMath::ATan(rad/fInf->GetZPos())*TMath::RadToDeg(), c->GetType());
-    }
-  }
-  /** Normalization **/
-  max=0;
-  for(p=fCells.begin();p!=fCells.end();++p)
-  {
-    if (max<(*p)->fR) max=(*p)->fR;
-    if (max<(*p)->fG) max=(*p)->fG;
-    if (max<(*p)->fB) max=(*p)->fB;
-  }
-  if (max>0)
-    for(p=fCells.begin();p!=fCells.end();++p)
-    {
-      (*p)->fR/=max;
-      (*p)->fG/=max;
-      (*p)->fB/=max;
-    }
-
-  /** At the moment
-   **	B --- reconstructed energy
-   **   G --- energy deposited in cell
-   **   R --- energy deposited by photons and their e+/e- daughters **/
-  for(p=fCells.begin();p!=fCells.end();++p)
-  {
-    Float_t l=(*p)->fG; l=TMath::Sqrt(l);
-    Float_t a=0;
-    Float_t b=((*p)->fG-(*p)->fB)/((*p)->fG+(*p)->fB);
-    if ((*p)->fB==0) { b=0; } 
-    else
-    {
-      if (b<-0.7) b=-0.7;
-      if (b>0.7) b=0.7;
-    }
-    LabToRGB(l, b, a, (*p)->fR, (*p)->fG, (*p)->fB);
-  }
-  /** Drawing **/
-  fEdging="#FFFFFF";
-  for(p=fCells.begin();p!=fCells.end();++p)
-    if (find(clusters.begin(), clusters.end(), (*p)->fCell)==clusters.end())
-      DrawCell((*p)->fCell, (*p)->fR, (*p)->fG, (*p)->fB);
-  fEdging="#FF0000";
-  for(p=fCells.begin();p!=fCells.end();++p)
-    if (find(clusters.begin(), clusters.end(), (*p)->fCell)!=clusters.end())
-      DrawCell((*p)->fCell, (*p)->fR, (*p)->fG, (*p)->fB);
-}
-
-void CbmEcalQualityCheck::CreateTree()
-{
-  if (fOut) return;
-  fOut=new TTree(fOutName, "Quality control tree for calorimeter");
-  fOut->Branch("x", &fX, "x/D");
-  fOut->Branch("y", &fY, "y/D");
-  fOut->Branch("z", &fZ, "z/D");
-  fOut->Branch("px", &fPX, "px/D");
-  fOut->Branch("py", &fPY, "py/D");
-  fOut->Branch("pz", &fPZ, "pz/D");
-  fOut->Branch("mcx", &fMCX, "mcx/D");
-  fOut->Branch("mcy", &fMCY, "mcy/D");
-  fOut->Branch("mcz", &fMCZ, "mcz/D");
-  fOut->Branch("mcpx", &fMCPX, "mcpx/D");
-  fOut->Branch("mcpy", &fMCPY, "mcpy/D");
-  fOut->Branch("mcpz", &fMCPZ, "mcpz/D");
-  fOut->Branch("e", &fE, "e/D");
-  fOut->Branch("mce", &fMCE, "mce/D");
-  fOut->Branch("ev", &fEventN, "ev/I");
-  fOut->Branch("chi2", &fChi2, "chi2/D");
-  fOut->Branch("r", &fR, "r/D");
-  fOut->Branch("mcmothertrackn", &fMCMotherTrN, "mcmothertrackn/I");
-  fOut->Branch("pdg", &fPdgCode, "pdg/I");
-}
-
-/** Init **/
-InitStatus CbmEcalQualityCheck::Init()
-{
-  fEventN=0;
-
-
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fReco=(TClonesArray*)io->GetObject(fInName);
-  if (!fReco)
-  {
-    Fatal("Init", "Can't find array of reconstructed tracks named %s.", fInName.Data());
-    return kFATAL;
-  }
-  fMCTracks=(TClonesArray*)io->GetObject("MCTrack");
-  if (!fMCTracks)
-  {
-    Fatal("Init", "Can't find array of MC tracks");
-    return kFATAL;
-  }
-  fPoints=(TClonesArray*)io->GetObject("EcalPoint");
-  if (!fPoints)
-  {
-    Fatal("Init", "Can't find array of Ecal Points");
-    return kFATAL;
-  }
-  if (fNeedDraw==kFALSE) return kSUCCESS;
-  fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init", "Can't find calorimeter structure for drawing");
-    return kFATAL;
-  }
-  fTracks=(TClonesArray*)io->GetObject("EcalTrackParam");
-  if (!fTracks)
-  {
-    Fatal("Init", "Can't find array of reconstructed tracks");
-    return kFATAL;
-  }
-  fClusters=(TClonesArray*)io->GetObject("EcalClusters");
-  if (!fClusters)
-  {
-    Fatal("Init", "Can't find array of calorimeter clusters");
-    return kFATAL;
-  }
-  fInf=fStr->GetEcalInf();
-  fCX=fInf->GetXSize(); fCY=fInf->GetYSize();
-  fCX*=fCellSize*4+4; fCX+=1;
-  fCY*=fCellSize*4+4; fCY+=1;
-  fC=new TASImage(fCX, fCY);
-
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  fStr->GetCells(cells);
-  for(p=cells.begin();p!=cells.end();++p)
-    fCells.push_back(new CbmEcalQualityCheckItem((*p), 0.0, 0.0, 0.0));
-  fShLib=(CbmEcalShLib*)io->GetObject("EcalShLib");
-  if (!fShLib)
-  {
-    Fatal("Init", "No shower library found in system.");
-    return kFATAL;
-  }
-  fTxt->SetTextFont(43);
-  fTxt->SetTextSizePixels(8);
-  fTxt->SetTextAlign(21);
-  return kSUCCESS;
-}
-
-void CbmEcalQualityCheck::Finish()
-{
-  if (fOut) fOut->Write();
-}
-
-
-/** Destructor **/
-CbmEcalQualityCheck::~CbmEcalQualityCheck()
-{
-  list<CbmEcalQualityCheckItem*>::const_iterator p=fCells.begin();
-  for(;p!=fCells.end();++p)
-    delete (*p);
-  delete fTxt;
-}
-
-/** Standard constructor **/
-CbmEcalQualityCheck::CbmEcalQualityCheck(const char *name, const Int_t iVerbose)
-  : FairTask(name, iVerbose),
-    fNeedDraw(kFALSE),
-    fNamePrefix("ecal"),
-    fC(NULL),
-    fCellSize(8),
-    fCX(0),
-    fCY(0),
-    fMaxEnergyDep(0.),
-    fStr(NULL),
-    fInf(NULL),
-    fEdging(""),
-    fTxt(new TText()),
-    fShLib(NULL),
-    fCells(),
-    fMCTracks(NULL),
-    fTracks(NULL),
-    fReco(NULL),
-    fPoints(NULL),
-    fClusters(NULL),
-    fInName("EcalReco"),
-    fEventN(0),
-    fOut(NULL),
-    fOutName("EcalQC"),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fMCX(0.),
-    fMCY(0.),
-    fMCZ(0.),
-    fMCMotherTrN(0),
-    fE(0.),
-    fMCE(0.),
-    fPX(0.),
-    fPY(0.),
-    fPZ(0.),
-    fMCPX(0.),
-    fMCPY(0.),
-    fMCPZ(0.),
-    fChi2(0.),
-    fPdgCode(0),
-    fR(0.)
-{
-}
-
-/** Default constructor. Requirement of ROOT system **/
-CbmEcalQualityCheck::CbmEcalQualityCheck()
-  : FairTask(),
-    fNeedDraw(kFALSE),
-    fNamePrefix("ecal"),
-    fC(NULL),
-    fCellSize(8),
-    fCX(0),
-    fCY(0),
-    fMaxEnergyDep(0.),
-    fStr(NULL),
-    fInf(NULL),
-    fEdging(""),
-    fTxt(new TText()),
-    fShLib(NULL),
-    fCells(),
-    fMCTracks(NULL),
-    fTracks(NULL),
-    fReco(NULL),
-    fPoints(NULL),
-    fClusters(NULL),
-    fInName("EcalReco"),
-    fEventN(0),
-    fOut(NULL),
-    fOutName("EcalQC"),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fMCX(0.),
-    fMCY(0.),
-    fMCZ(0.),
-    fMCMotherTrN(0),
-    fE(0.),
-    fMCE(0.),
-    fPX(0.),
-    fPY(0.),
-    fPZ(0.),
-    fMCPX(0.),
-    fMCPY(0.),
-    fMCPZ(0.),
-    fChi2(0.),
-    fPdgCode(0),
-    fR(0.)
-{
-}
-
-ClassImp(CbmEcalQualityCheck);
diff --git a/ecal/CbmEcalQualityCheck.h b/ecal/CbmEcalQualityCheck.h
deleted file mode 100644
index bd7f077340b8f998f38b27acf32fd0bab8fa4bba..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalQualityCheck.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/** Quality check file for calorimeter reconstruction.
- ** A try to develop a tool for comparison different reconstruction
- ** procedures.
- ** Idea: Select clean MC photons (e.g. without daughter particles) 
- ** and find closest reconstructed photon. **/
-
-#ifndef CBMECALQUALITYCHECK_H
-#define CBMECALQUALITYCHECK_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <math.h>
-#include <list>
-
-class TTree;
-class TClonesArray;
-class TASImage;
-class TText;
-
-class CbmEcalStructure;
-class CbmEcalInf;
-class CbmEcalCell;
-class CbmEcalQualityCheckItem;
-class CbmEcalShLib;
-class CbmEcalPoint;
-
-class CbmEcalQualityCheck : public FairTask
-{
-public:
-  /** Default constructor. Requirement of ROOT system **/
-  CbmEcalQualityCheck();
-
-  /** Standard constructor **/
-  CbmEcalQualityCheck(const char *name, const Int_t iVerbose=1);
-
-  /** Destructor **/
-  virtual ~CbmEcalQualityCheck();
-
-  /** Draw stuff **/
-  inline void SetNeedDraw(Bool_t draw=kTRUE) {fNeedDraw=draw;}
-  inline Bool_t GetNeedDraw() const {return fNeedDraw;}
-  /** Set prefix to name of images
-   ** File will be named like: prefix0000.png **/
-  inline void SetNamePrefix(const char* prefix) {fNamePrefix=prefix;}
-  inline void SetCellSize(Int_t size) {fCellSize=size;}
-
-  /** Init **/
-  virtual InitStatus Init();
-  virtual void Exec(Option_t* option);
-  virtual void Finish();
-private:
-  /** Should all the stuff be drawed? **/
-  Bool_t fNeedDraw;
-  TString fNamePrefix;		//!
-  /** An image and its size **/
-  TASImage* fC;			//!
-  Int_t fCellSize;
-  Int_t fCX;
-  Int_t fCY;
-
-  /** Normalization **/
-  Double_t fMaxEnergyDep;
-  /** Structure and info for drawing **/
-  CbmEcalStructure* fStr;	//!
-  CbmEcalInf* fInf;		//!
-  TString fEdging;		//!
-  void PutPixel(Int_t x, Int_t y, Float_t r, Float_t g, Float_t b);
-  void PutPixel(Int_t x, Int_t y, const char* color);
-  /** type==0 for star, type==1 for square **/
-  void DrawMark(Double_t x, Double_t y, const char* color, Int_t type);
-  /** draw cell with filled color. fEdging used as egding of cell **/
-  void DrawCell(CbmEcalCell* cell, Float_t r, Float_t g, Float_t b);
-  void DrawCell(CbmEcalCell* cell, const char* color);
-
-  void DrawLine(Double_t x, Double_t y, const char* color, Int_t track);
-  void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2,const char* color);
-  /** Draw energy for given point **/
-  void DrawEnergy(CbmEcalPoint* p, const char* color);
-  void DrawEnergy(Float_t x, Float_t y, Float_t p, const char* color);
-  Double_t GetP(CbmEcalPoint* p);
-
-  /** Draw chi2 for photons **/
-  void DrawChi2(Float_t x, Float_t y, Float_t chi2, const char* color);
-
-  TText* fTxt;			//!
-  void DrawMC();
-  void DrawPhotons();
-  void DrawTracks();
-  void DrawCells();
-
-  CbmEcalShLib* fShLib;		//!
-  std::list<CbmEcalQualityCheckItem*> fCells;		//!
-  void DrawImage();
-
-  TClonesArray* fMCTracks;	//!
-  TClonesArray* fTracks;	//!
-  TClonesArray* fReco;		//!
-  TClonesArray* fPoints;	//!
-  TClonesArray* fClusters;	//!
-  TString fInName;
-  /** Event number **/
-  Int_t fEventN;
-
-  /** Output tree **/
-  TTree* fOut;			//!
-  TString fOutName;
-  void CreateTree();
-  Double_t fX;
-  Double_t fY;
-  Double_t fZ;
-  Double_t fMCX;
-  Double_t fMCY;
-  Double_t fMCZ;
-  Int_t fMCMotherTrN;
-
-  Double_t fE;
-  Double_t fMCE;
-  Double_t fPX;
-  Double_t fPY;
-  Double_t fPZ;
-  Double_t fMCPX;
-  Double_t fMCPY;
-  Double_t fMCPZ;
-  Double_t fChi2;
-  /** Pdg code. Gamma and neutron(antineutron) only **/
-  Int_t fPdgCode;
-  /** Distance between this and closest other hit in the calorimeter **/
-  Double_t fR;
-
-  CbmEcalQualityCheck(const CbmEcalQualityCheck&);
-  CbmEcalQualityCheck& operator=(const CbmEcalQualityCheck&);
-
-  ClassDef(CbmEcalQualityCheck, 1)
-};
-
-/** Convert Lab color to RGB. Formulas taken from www.easyrgb.com **
- ** L[0.0, 1.0], a[-0.5, 0.5], b[-0.5, 0.5] **/
-inline void LabToRGB(Float_t L, Float_t a, Float_t b, Float_t& R, Float_t& G, Float_t& B)
-{
-  Float_t vY=(L+0.16)/1.16;
-  Float_t vX=a/5.00+vY;
-  Float_t vZ=vY-b/2.0;
-  if (vY*vY*vY>0.008856) vY=vY*vY*vY; else vY=(vY-16.0/116.0)/7.787;
-  if (vX*vX*vX>0.008856) vX=vX*vX*vX; else vX=(vX-16.0/116.0)/7.787;
-  if (vZ*vZ*vZ>0.008856) vZ=vZ*vZ*vZ; else vZ=(vZ-16.0/116.0)/7.787;
-  vX*=0.95047; vZ*=1.08883;
-  R= vX*3.2406-vY*1.5372-vZ*0.4986;
-  G=-vX*0.9689+vY*1.8758+vZ*0.0415;
-  B= vX*0.0557-vY*0.2040+vZ*1.0570;
-  if (R>0.0031308) R=1.055*powf(R, 1.0/2.4)-0.055; else R*=12.92;
-  if (G>0.0031308) G=1.055*powf(G, 1.0/2.4)-0.055; else G*=12.92;
-  if (B>0.0031308) B=1.055*powf(B, 1.0/2.4)-0.055; else B*=12.92;
-  if (R<0.0) R=0.0;
-  if (G<0.0) G=0.0;
-  if (B<0.0) B=0.0;
-  Float_t Ln=R*0.3+G*0.6+0.1*B;
-  if (Ln>L)   { R*=L/Ln; G*=L/Ln; B*=L/Ln; }
-  if (R>1.0) { G/=R; B/=R; R=1.0; }
-  if (G>1.0) { R/=G; B/=G; G=1.0; }
-  if (B>1.0) { R/=B; G/=B; B=1.0; }
-}
-
-inline Float_t Hue_2_RGB(Float_t v1, Float_t v2, Float_t h)
-{
-  Float_t vh=h;
-  if (vh<0) vh+=1;
-  if (vh>1) vh-=1;
-  if (6*vh<1) return v1+(v2-v1)*6*vh;
-  if (2*vh<1) return v2;
-  if (3*vh<2) return (v1+(v2-v1)*(2.0/3.0-vh)*6);
-  return v1;
-}
-
-inline void HSLToRGB(Float_t h, Float_t s, Float_t l, Float_t& R, Float_t& G, Float_t& B)
-{
-  if (s==0)
-  {
-    R=G=B=l;
-    return;
-  }
-  Float_t v2;
-  Float_t v1;
-  if (l<0.5) v2=l*(1+s); else v2=(l+s)-(s*l);
-  v1=2*l-v2;
-  R=Hue_2_RGB(v1, v2, h+(1.0/3));
-  G=Hue_2_RGB(v1, v2, h);
-  B=Hue_2_RGB(v1, v2, h-(1.0/3));
-}
-#endif
-
-
diff --git a/ecal/CbmEcalReco.cxx b/ecal/CbmEcalReco.cxx
deleted file mode 100644
index 3f9cc975654cffebca7eabc41a6fadf5162bfaed..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalReco.cxx
+++ /dev/null
@@ -1,1037 +0,0 @@
-#include "CbmEcalReco.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TFormula.h"
-#include "TVector3.h"
-
-#include "FairRootManager.h"
-#include "FairTrackParam.h"
-#include "FairLogger.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalSCurveLib.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalRecParticle.h"
-#include "CbmEcalCluster.h"
-#include "CbmEcalShLib.h"
-#include "CbmEcalCalibration.h"
-#include "CbmEcalParam.h"
-#include "CbmEcalPosLib.h"
-
-#include "Minuit2/Minuit2Minimizer.h"
-
-#include <iostream>
-
-using namespace std;
-
-void FCNEcalCluster::SetCluster(CbmEcalCluster* cluster)
-{
-  fCluster=cluster;
-  SetN(fCluster->Maxs());
-  fClusterResp=fCluster->Energy();
-  fClusterEnergy=fCal->GetEnergy(fClusterResp, fStr->GetHitCell(cluster->PeakNum(0)));
-}
-
-void FCNEcalCluster::SetN(Int_t n)
-{
-//  Int_t i;
-  fN=n;
-  fNDF=fCluster->Size()-(n*3-fFixClusterEnergy);
-}
-
-//Double_t FCNEcalCluster::operator()(const vector<Double_t>& par) const
-//{
-Double_t FCNEcalCluster::DoEval(const Double_t* par) const
-{
-//  if (par.size()!=fN*3)
-//    Fatal("()", "Size of input vector is wrong (%d, should be %d)!", par.size(), fN*3);
-
-  CbmEcalCell* cell;
-//  static Double_t module=fInf->GetModuleSize();
-  Int_t type;
-  Double_t de;
-  Double_t x;
-  Double_t y;
-  Double_t theta;
-  Double_t phi;
- // Double_t cellsize;
-  Double_t cx;
-  Double_t cy;
-  Double_t r;
-  Double_t celle;
-  CbmEcalCell* cl;
- // Int_t p;
-  Int_t i;
-  Int_t k;
- // CbmEcalRecParticle* part;
- // Double_t clustere=fClusterResp;
-  Double_t clenergy;
- // Double_t sigma2;
-  Double_t cellerr;
-  Double_t epred;
- // Double_t sin4theta;
-  Double_t chi2=0;
-  Double_t e[6];
-  Double_t t;
-  Double_t emeas;
-
-
-  clenergy=fClusterEnergy;
-
-  if (fFixClusterEnergy==0)
-    for(i=0;i<fN;i++)
-      e[i]=par[3*i];
-   else
-   {
-     t=fClusterEnergy;
-     for(i=0;i<fN-1;i++)
-     {
-       e[i]=par[3*i+2]*t;
-       t-=e[i];
-       if (t<0) t=0;
-     }
-     e[i]=t;
-   }
- 
-  for(k=0;k<fCluster->Size();k++)
-  {
-    cell=fStr->GetHitCell(fCluster->CellNum(k));
-    type=cell->GetType();
- //   cellsize=module/type;
-    cellerr=0; celle=0;
-    for(i=0;i<fN;i++)
-    {
-      cl=fCells[i]; cx=cl->GetCenterX(); cy=cl->GetCenterY(); 
-      x=cell->GetCenterX(); x-=par[3*i+1-fFixClusterEnergy]; //part->X(); // x-=cx; 
-      y=cell->GetCenterY(); y-=par[3*i+2-fFixClusterEnergy]; //part->Y(); // y-=cy; 
-
-      r=TMath::Sqrt(cx*cx+cy*cy);
-
-      // TODO: should be Z of the cell**/
-      theta=TMath::ATan(r/fInf->GetZPos());
-      theta*=TMath::RadToDeg();
-      phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-      if (cy<0) phi=360.0-phi;
-
-      celle+=fShLib->GetResponse(x, y, phi, theta, e[i], type);
-//      celle+=fShLib->GetSumEThetaPhi(x, y, cellsize, part->E(), theta, phi);
-    }
-    cx=cell->GetCenterX(); cy=cell->GetCenterY();
-    r=TMath::Sqrt(cx*cx+cy*cy);
-    theta=TMath::ATan(r/fInf->GetZPos());
-
-    epred=fCal->GetEnergy(celle, cell);
-    emeas=fCal->GetEnergy(cell->GetTotalEnergy(), cell);
-    {
-      fSigma[type]->SetParameter(0, clenergy);	//Ecluster
-      fSigma[type]->SetParameter(1, emeas);		//Emeas
-      fSigma[type]->SetParameter(2, epred);		//Epred
-      fSigma[type]->SetParameter(3, theta);		//Theta
-      cellerr=fSigma[type]->Eval(0);
-      de=fCal->GetEnergy(celle, cell)-fCal->GetEnergy(cell->GetTotalEnergy(), cell);
-      de*=de; chi2+=de/cellerr;
-    }
-  }
-//  chi2/=fCluster->Size();
-  return chi2;
-}
-
-/***************************************************************************/
-
-void CbmEcalReco::Exec(Option_t*)
-{
-  Int_t i;
-  Int_t n=fClusters->GetEntriesFast();
-  CbmEcalCluster* cluster;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t chi2;
-  CbmEcalCell* cell;
-  Int_t j;
-
-  fN=0;
-  fReco->Delete();
-  if (fToTree&&fOutTree==NULL)
-    CreateTree();
-  fEventN++;
-  if (fVerbose>0) 
-    Info("Exec", "Event %d, %d clusters in event.", fEventN, n);
-  for(i=0;i<n;i++)
-  {
-    fNOld=fN;
-    cluster=(CbmEcalCluster*)fClusters->At(i);
-    if (cluster->Maxs()>fMaxPhotonsPerCluster)
-      continue;
-    for(j=0;j<cluster->Maxs();j++)
-    {
-      cell=fStr->GetHitCell(cluster->CellNum(j));
-      fPreE=cluster->PreEnergy(j);
-      if (fCal->GetEnergy(cell->GetTotalEnergy(), cell)>fMinMaxE)
-        Reco(cell, cluster);
-    }
-    chi2=CalculateChi2(cluster);
-    if (chi2>fChi2Th)
-      FitCluster(cluster);
-    if (fStoreClusterInfo)
-      WriteClusterInfo(cluster);
-    if (fOutTree)
-      FillTree();
-  }
-  if (fVerbose>1)
-    Info("Exec", "%d photons reconstructed in calorimeter.", fN);
-}
-
-/** Write a cluster info **/
-void CbmEcalReco::WriteClusterInfo(CbmEcalCluster* clstr)
-{
-  list<CbmEcalCell*>::const_iterator p;  
-  CbmEcalCell* cell;
-  CbmEcalRecParticle* part;
-  Int_t i=0;
-  Int_t j;
-  Int_t k;
-  Double_t celle;
- // Double_t cellsize;
-  Double_t e[3];
-  Double_t x;
-  Double_t y;
-  Double_t r;
-  Double_t theta;
-  Double_t phi;
-  CbmEcalCell* cl;
-  Double_t cx;
-  Double_t cy;
-  Double_t de;
-  Double_t epred;
-  Double_t emeas;
- // Double_t clenergy;
-  Double_t cellerr;
-//  static Double_t module=fInf->GetModuleSize();
-
-  fECluster=fCal->GetEnergy(clstr->Energy(), fStr->GetHitCell(clstr->PeakNum(0)));
- // clenergy=fECluster;
-  for(k=0;k<clstr->Size();k++)
-  {
-    cell=fStr->GetHitCell(clstr->CellNum(k));
-    e[i++]=cell->GetTotalEnergy();
-    if (i==3) break;
-  }
-  fCMaxs=clstr->Maxs();
-  fECls=e[0]/clstr->Energy();
-  fE2Cls=(e[0]+e[1])/clstr->Energy();
-  fE3Cls=(e[0]+e[1]+e[2])/clstr->Energy();
-  i=0;
-
-  for(k=0;k<clstr->Size();k++)
-  {
-    cell=fStr->GetHitCell(clstr->CellNum(k));
-    fTypes[i]=cell->GetType();
- //   cellsize=module/fTypes[i];
-    celle=0;
-    for(j=fNOld;j<fN;j++)
-    {
-      part=(CbmEcalRecParticle*)fReco->At(j);
-      cl=fStr->GetHitCell(part->CellNum()); cx=cl->GetCenterX(); cy=cl->GetCenterY(); 
-      x=cell->GetCenterX(); x-=part->X(); // x-=cx; 
-      y=cell->GetCenterY(); y-=part->Y(); // y-=cy; 
-
-      r=TMath::Sqrt(cx*cx+cy*cy);
-
-      // TODO: should be Z of the cell**/
-      theta=TMath::ATan(r/fInf->GetZPos());
-      theta*=TMath::RadToDeg();
-      phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-      if (cy<0) phi=360.0-phi;
-
-      celle+=fShLib->GetResponse(x, y, phi, theta, part->E(), fTypes[i]);
-    }
-    de=fCal->GetEnergy(celle, cell)-fCal->GetEnergy(cell->GetTotalEnergy(), cell);
-    cx=cell->GetCenterX(); cy=cell->GetCenterY();
-    r=TMath::Sqrt(cx*cx+cy*cy);
-    theta=TMath::ATan(r/fInf->GetZPos());
-
-    epred=fCal->GetEnergy(celle, cell);
-    emeas=fCal->GetEnergy(cell->GetTotalEnergy(), cell);
-    fSigma[fTypes[i]]->SetParameter(0, fECluster);		//Ecluster
-    fSigma[fTypes[i]]->SetParameter(1, emeas);		//Emeas
-    fSigma[fTypes[i]]->SetParameter(2, epred);		//Epred
-    fSigma[fTypes[i]]->SetParameter(3, theta);		//Theta
-    cellerr=fSigma[fTypes[i]]->Eval(0);
-    de*=de; fChi2Fit[i]=de/cellerr;
-
-    cx=cell->GetCenterX(); cy=cell->GetCenterY();
-    r=TMath::Sqrt(cx*cx+cy*cy);
-    fTheta[i]=TMath::ATan(r/fInf->GetZPos());
-    fEpred[i]=fCal->GetEnergy(celle, cell);
-    fEmeas[i]=fCal->GetEnergy(cell->GetTotalEnergy(), cell);
-    fCX[i]=cell->GetCenterX();
-    fCY[i]=cell->GetCenterY();
-    i++;
-  }
-  for(j=i;j<50;j++)
-    fTypes[j]=-1111;
-}
-
-void CbmEcalReco::FillTree()
-{
-  Int_t n=fN-fNOld;
-  CbmEcalRecParticle* p;
-  Int_t i;
-
-  for(i=0;i<n;i++)
-  {
-    p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-    fChi2=p->Chi2();
-    fEReco=p->E();
-    fXReco=p->X();
-    fYReco=p->Y();
-    fOutTree->Fill();
-  }
-
-}
-
-// Fit a given cluster. A first approximation should be available **/
-
-
-void CbmEcalReco::FitCluster(CbmEcalCluster* clstr)
-{
-  vector<CbmEcalCell*> cells(fN-fNOld);
-  Int_t i;
-  Int_t n=fN-fNOld;
-  Int_t ret;
-  Double_t oldchi2=clstr->Chi2();
-  Double_t e;
-  Double_t pe[6];
-  CbmEcalRecParticle* p;
-  TString par;
-  TVector3 tv;
-
-  if (n>6)
-  {
-    Info("FitCluster", "Give up fitting the cluster with %d maximums. ", n);
-    return;
-  }
-  
-  fFCN->SetCluster(clstr);
-  // The cluster it self  doesn't care about amplitude of maximums 
-  fFCN->SetN(n);
-
-  Int_t params=0;
-
-  fFitter->Clear();
-  fFitter->SetPrintLevel(-1);
-  fFitter->SetMaxIterations(fMaxIterations);
-  if (fFixClusterEnergy==0) {
-    for(i=0;i<n;i++) {
-      p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-      cells[i]=fStr->GetHitCell(p->CellNum());
-      par="e"; par+=i; 
-      fFitter->SetVariable(i*3   ,par.Data(), p->E(), 0.01*p->E());
-      fFitter->SetVariableLimits(i*3, p->E()*0.2, p->E()*2.0);
-      params++;
-      par="x"; par+=i; 
-      fFitter->SetVariable(i*3+1 ,par.Data(), p->X(), 0.1);
-      fFitter->SetVariableLimits(i*3+1, p->X()-24., p->X()+24.);
-      params++;
-      par="y"; par+=i; 
-      fFitter->SetVariable(i*3+2 ,par.Data(), p->Y(), 0.1);
-      fFitter->SetVariableLimits(i*3+2, p->Y()-24., p->Y()+24.);
-      params++;
-    }
-  } else {
-    e=0;
-    for(i=0;i<n;i++) {
-      p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-      pe[i]=p->E(); e+=pe[i];
-    }
-    for(i=0;i<n;i++) {
-      p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-      cells[i]=fStr->GetHitCell(p->CellNum());
-      par="x"; par+=i; 
-      fFitter->SetVariable(i*3 ,par.Data(), p->X(), 0.1);
-      fFitter->SetVariableLimits(i*3,p->X()-24., p->X()+24.);
-      params++;
-      par="y"; par+=i; 
-      fFitter->SetVariable(i*3+1 ,par.Data(), p->Y(), 0.1);
-      fFitter->SetVariableLimits(i*3+1, p->Y()-24., p->Y()+24.);
-      params++;
-      if (i!=n-1) {
-	par="n";
-	par+=i;
-	fFitter->SetVariable(i*3+2 ,par.Data(), p->E()/e, 0.005);
-	fFitter->SetVariableLimits(i*3+2, 0.0, 1.0);
-        params++;
-      }
-      e-=p->E();
-    }
-    
-  }
-
-  fFCN->SetNumParam(params);
-  fFCN->SetParticleSeeds(cells);
-
-  fFitter->SetFunction(*fFCN);
-  ret=fFitter->Minimize();
-
-  Double_t chi2=fFitter->MinValue();
-
-  if (ret!=0&&fVerbose>1) {
-    Info("FitCluster", "Minimization failed! Last chi2 %f, old chi2 %f.", chi2, oldchi2);
-  }
-
-//  cout << "chi2=" << chi2 << ", NDF=" << fFCN->NDF() << endl;
-  if (fFCN->NDF()>0) {
-    chi2/=fFCN->NDF();
-  } else {
-    chi2=-chi2;
-  }
-  clstr->fChi2=chi2;
-
-  e=fFCN->ClusterEnergy();
-
-  // get the fit parameters from Minuit
-  const double *fitResult = fFitter->X();
-
-  for(i=0;i<n;i++) {
-    p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-    p->fX=fitResult[i*3+1-fFixClusterEnergy];
-    p->fY=fitResult[i*3+2-fFixClusterEnergy];
-    LOG(debug2) << "fitResult[" << i*3+1-fFixClusterEnergy << "]: " << fitResult[i*3+1-fFixClusterEnergy];
-    LOG(debug2) << "fitResult[" << i*3+2-fFixClusterEnergy << "]: " << fitResult[i*3+2-fFixClusterEnergy];
-    if (fFixClusterEnergy) {
-      if (i!=n-1) {
-        p->fE=fitResult[i*3+2]*e;
-	LOG(debug2) << "fitResult[" << i*3+2 << "]: " << fitResult[i*3+2];
-	e-=p->fE;
-      } else {
-	p->fE=e;
-      }
-    } else {
-      p->fE=fitResult[i*3];
-	LOG(debug2) << "fitResult[" << i*3 << "]: " << fitResult[i*3];
-    }
-
-    tv.SetXYZ(p->fX, p->fY, fInf->GetZPos());
-    tv*=p->fE/tv.Mag();
-    p->fPx=tv.X();
-    p->fPy=tv.Y();
-    p->fPz=tv.Z();
-    p->fChi2=chi2;
-    TimeReco(p, clstr);
-  }
-  
-}
-
-void CbmEcalReco::TimeReco(CbmEcalRecParticle* p, CbmEcalCluster* cluster)
-{
-  Double_t time=0;
-  Double_t te=0;
-
-//  static Double_t module=fInf->GetModuleSize();
-  Double_t theta;
-  Int_t k;
-  CbmEcalCell* cell;
-  Int_t type;
- // Double_t cellsize;
-  Double_t celle;
-  Double_t celltime;
-  Double_t x;
-  Double_t y;
-  Double_t r;
-  Double_t cx;
-  Double_t cy;
-  Double_t phi;
-  CbmEcalCell* cl;
-  
-  cl=fStr->GetHitCell(p->CellNum());
-  cx=cl->GetCenterX(); cy=cl->GetCenterY(); 
-  r=TMath::Sqrt(cx*cx+cy*cy);
-  // TODO: should be Z of the cell**/
-  theta=TMath::ATan(r/fInf->GetZPos());
-  theta*=TMath::RadToDeg();
-  phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-  if (cy<0) phi=360.0-phi;
-
-  for(k=0;k<cluster->Size();k++)
-  {
-    cell=fStr->GetHitCell(cluster->CellNum(k));
-    celltime=cell->GetTime();
-    if (celltime==-1111) continue;
-    // No time information for the cell **/
-    type=cell->GetType();
- //   cellsize=module/type;
-    x=cell->GetCenterX(); x-=p->X(); // x-=cx; 
-    y=cell->GetCenterY(); y-=p->Y(); // y-=cy; 
-
-    celle=fShLib->GetResponse(x, y, phi, theta, p->E(), type);
-//    cout << "CellTime: "<< celltime << "	" << celle << "	" << cell->GetTotalEnergy() << "	" << cell->GetEnergy() << "	" << cell->GetCenterX() << "	" << cell->GetCenterY() << endl;
-    time+=celle*celltime;
-    te+=celle;
-  }
- 
-//  cout << "CellTime: " << time << endl;
-  time/=te;
-//  cout << "CellTime: " << time << endl;
-  if (time>0)
-    p->SetTOF(time);
-}
-
-// Calculate a chi2 for just reconstructed photons **/
-Double_t CbmEcalReco::CalculateChi2(CbmEcalCluster* cluster)
-{
-  if (!fShLib) return -1111;
-  
-  CbmEcalCell* cell;
-//  static Double_t module=fInf->GetModuleSize();
-  Int_t type;
-  Double_t de;
-  Double_t x;
-  Double_t y;
-  Double_t theta;
-  Double_t phi;
- // Double_t cellsize;
-  Double_t cx;
-  Double_t cy;
-  Double_t r;
-  Double_t celle;
-  CbmEcalCell* cl;
-  Int_t p;
-  Int_t i;
-  Int_t k;
-  CbmEcalRecParticle* part;
-  Double_t clustere=0;
-  Double_t clenergy;
- // Double_t sigma2;
-  Double_t cellerr;
-  Double_t epred;
- // Double_t sin4theta;
-  Double_t chi2=0;
-  Double_t emeas;
-
-
-  for(k=0;k<cluster->Size();k++)
-  {
-    cell=fStr->GetHitCell(cluster->CellNum(k));
-    clustere+=cell->GetTotalEnergy();
-  }
-  clenergy=fCal->GetEnergy(clustere, fStr->GetHitCell(cluster->PeakNum(0)));
-
-  i=0;
-  for(k=0;k<cluster->Size();k++)
-  {
-    cell=fStr->GetHitCell(cluster->CellNum(k));
-    type=cell->GetType();
- //   cellsize=module/type;
-    cellerr=0; celle=0;
-    for(p=fNOld;p<fN;p++)
-    {
-      part=(CbmEcalRecParticle*)fReco->At(p);
-      cl=fStr->GetHitCell(part->CellNum()); cx=cl->GetCenterX(); cy=cl->GetCenterY(); 
-      x=cell->GetCenterX(); x-=part->X(); // x-=cx; 
-      y=cell->GetCenterY(); y-=part->Y(); // y-=cy; 
-
-      r=TMath::Sqrt(cx*cx+cy*cy);
-
-      // TODO: should be Z of the cell**/
-      theta=TMath::ATan(r/fInf->GetZPos());
-      theta*=TMath::RadToDeg();
-      phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-      if (cy<0) phi=360.0-phi;
-//      cout << "Cell(" << cx << ", " << cy << ")" << endl; 
-      celle+=fShLib->GetResponse(x, y, phi, theta, part->E(), type);
-//      cout << "Shlib " << x << " " << y << " " << phi << " " << theta << " " << part->E() << " " << type << " : " << celle << endl;
-    }
-//    cout << "---> " << x << "	" << y << "	" << cellsize << "	" << part->E() << "	" << theta << "	" << phi << endl;
-//    cout << "-> celle " << celle << endl;
-    cx=cell->GetCenterX(); cy=cell->GetCenterY();
-    r=TMath::Sqrt(cx*cx+cy*cy);
-    theta=TMath::ATan(r/fInf->GetZPos());
-
-    epred=fCal->GetEnergy(celle, cell);
-    emeas=fCal->GetEnergy(cell->GetTotalEnergy(), cell);
-    fEfirst[i]=epred;
-//    if (epred>clenergy) epred=clenergy;
-//    if (celle>0)
-    {
-      fSigma[type]->SetParameter(0, clenergy);	//Ecluster
-      fSigma[type]->SetParameter(1, emeas);		//Emeas
-      fSigma[type]->SetParameter(2, epred);		//Epred
-      fSigma[type]->SetParameter(3, theta);		//Theta
-      cellerr=fSigma[type]->Eval(0);
-      de=fCal->GetEnergy(celle, cell)-fCal->GetEnergy(cell->GetTotalEnergy(), cell);
-//      cout << "-> celle=" << celle << "	, epred(" << celle << ")=" << epred << ", emeas(" <<cell->GetTotalEnergy() << ")=" << emeas << endl;
-//      cellerr=1;
-      de*=de; chi2+=de/cellerr;
-      fChi2First[i]=de/cellerr;
-    }
-    i++;
-  }
-  if (cluster->Size()-((fN-fNOld)*3-fFixClusterEnergy)<=0)
-  {
-    Info("CalculateChi2","NDF is %d.", cluster->Size()-((fN-fNOld)*3-fFixClusterEnergy));
-    chi2=-chi2;
-  }
-  else
-    chi2/=cluster->Size()-((fN-fNOld)*3-fFixClusterEnergy);
-  for(p=fNOld;p<fN;p++)
-  {
-    part=(CbmEcalRecParticle*)fReco->At(p);
-    part->SetChi2(chi2);
-  }
-  cluster->fChi2=chi2;
-//  cout << fNOld << "	" << fN << "	" << chi2 << endl;
-  return chi2;
-}
-
-// Get first approximation of photon parameters from maximum **/
-void CbmEcalReco::Reco(CbmEcalCell* cell, CbmEcalCluster* clstr)
-{
-  if (fLib==NULL)
-  {
-    Reco2(cell, clstr);
-    return;
-  }
-  Double_t x;
-  Double_t y;
-  Double_t z;
-  Double_t amp;
-  Double_t en;
-  Double_t maxe;
-  Double_t px;
-  Double_t py;
-  Double_t pz;
-  Int_t type;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Int_t cnum=0;
-
-  cells.clear();
-
-  fType=cell->GetType();
-  fDiffType=0;
-
-  cell->GetNeighborsList(0,cells);
-  fE=cell->GetEnergy();
-  en=cell->GetEnergy();
-  type=cell->GetType();
-  fAX=0; fAY=0;
-  for(p=cells.begin();p!=cells.end();++p) 
-  {
-    if (type!=(*p)->GetType())
-    {
-      type=-1111;
-      fDiffType=1;
-    }
-    if (cell->GetX2()+0.001<(*p)->GetCenterX())
-      fAX+=(*p)->GetEnergy();
-    else
-    if (cell->GetX1()-0.001>(*p)->GetCenterX())
-      fAX-=(*p)->GetEnergy();
-    if (cell->GetY2()+0.001<(*p)->GetCenterY())
-      fAY+=(*p)->GetEnergy();
-    else
-    if (cell->GetY1()-0.001>(*p)->GetCenterY())
-      fAY-=(*p)->GetEnergy();
-    en+=(*p)->GetEnergy();
-  }
-  fE3x3=en;
-
-  if (fAX!=-1111)
-  {
-    fAX/=fE3x3;
-    fAY/=fE3x3;
-  }
-
-  maxe=0;
-  for(Int_t i=1;i<5;i++)
-  {
-    cell->GetNeighborsList(i,cells);
-    en=cell->GetEnergy();
-    for(p=cells.begin();p!=cells.end();++p) 
-      en+=(*p)->GetEnergy();
-    if (maxe<en)
-    {
-      maxe=en;
-      cnum=i;
-    }
-  }
-  cell->GetNeighborsList(cnum, cells);
-  cells.push_back(cell);
-  fE2x2=maxe;
-
-  fCellX=cell->GetCenterX();
-  fCellY=cell->GetCenterY();
-  
-  if (fCal->GetEnergy(fE2x2, cell)<0.1) return; 
-  fEReco=fCal->GetEnergy(fE2x2, cell);
-  if (fAX!=-1111)
-    fXReco=fLib->GetX(fAX, fEReco, cell);
-  else
-    fXReco=-1111;
-  if (fXReco!=-1111)
-    fXReco+=cell->GetCenterX();
-  
-  if (fAY!=-1111)
-    fYReco=fLib->GetY(fAY, fEReco, cell);
-  else
-    fYReco=-1111;
-  
-  if (fYReco!=-1111)
-    fYReco+=cell->GetCenterY();
-  if (fXReco!=-1111)
-    x=fXReco;
-  else
-    x=cell->GetCenterX();
-  if (fYReco!=-1111)
-    y=fYReco;
-  else
-    y=cell->GetCenterY();
-  z=fInf->GetZPos();
-  amp=TMath::Sqrt(x*x+y*y+z*z);
-  px=fEReco*x/amp;
-  py=fEReco*y/amp;
-  pz=fEReco*z/amp;
-  new((*fReco)[fN++]) CbmEcalRecParticle(px, py, pz, fEReco, x, y, z, 22, -1111, clstr, cell, fType);
-}
-
-/** Get first approximation of photon parameters from maximum
- ** This version uses PosLib instead of S-curves
- ** TODO Architecture: Need a maximum, instead of cell here **/
-void CbmEcalReco::Reco2(CbmEcalCell* cell, CbmEcalCluster* clstr)
-{
-  if (fPosLib==NULL)
-    Fatal("Reco2", "No position library for reconstruction.");
-
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t px;
-  Double_t py;
-  Double_t pz;
-  Double_t amp;
-  Double_t x=-1111;
-  Double_t y=-1111;
-  Double_t z=-1111;
-  Double_t t;
-
-  t=TMath::Sqrt(x*x+y*y);
-  fEReco=fCal->GetEnergy(fPreE, t/z, fRegion);
-  z=fInf->GetZPos();
-  amp=TMath::Sqrt(x*x+y*y+z*z);
-  px=fEReco*x/amp;
-  py=fEReco*y/amp;
-  pz=fEReco*z/amp;
-  new((*fReco)[fN++]) CbmEcalRecParticle(px, py, pz, fEReco, x, y, z, 22, -1111, clstr, cell, fType);
-
-}
-void CbmEcalReco::CreateTree()
-{
-  fOutTree=new TTree("slow_reco", "Reconstruction by fitting with shower library");
-  fOutTree->Branch("ev", &fEventN, "ev/I");
-  fOutTree->Branch("type", &fType, "type/S");
-  fOutTree->Branch("difftype", &fDiffType, "difftype/S");
-  fOutTree->Branch("x", &fXReco, "x/D");
-  fOutTree->Branch("y", &fYReco, "y/D");
-  fOutTree->Branch("e", &fEReco, "e/D");
-  fOutTree->Branch("chi2", &fChi2, "chi2/D");
-  fOutTree->Branch("ecluster", &fECluster, "ecluster/D");
-  if (fStoreClusterInfo==kFALSE) return;
-  fOutTree->Branch("cls_e", &fECls, "cls_e/D");
-  fOutTree->Branch("cls_e2", &fE2Cls, "cls_e2/D");
-  fOutTree->Branch("cls_e3", &fE3Cls, "cls_e3/D");
-  fOutTree->Branch("theta", fTheta, "theta[50]/D");
-  fOutTree->Branch("ctypes", fTypes, "ctypes[50]/S");
-  fOutTree->Branch("cemeas", fEmeas, "cemeas[50]/D");
-  fOutTree->Branch("cepred", fEpred, "cepred[50]/D");
-  fOutTree->Branch("cchi2", fChi2Fit, "cchi2[50]/D");
-  fOutTree->Branch("cefirst", fEfirst, "cefirst[50]/D");
-  fOutTree->Branch("cchi2first", fChi2First, "cchi2first[50]/D");
-  fOutTree->Branch("cx", fCX, "cx[50]/D");
-  fOutTree->Branch("cy", fCY, "cy[50]/D");
-  fOutTree->Branch("cmaxs", &fCMaxs, "cmaxs/I");
-}
-
-// Default constructor. Requirement of ROOT system **/
-CbmEcalReco::CbmEcalReco() 
-  : FairTask(),
-    fN(0),
-    fNOld(0),
-    fMaximums(NULL),
-    fExcluded(NULL),
-    fEventN(0),
-    fStr(NULL),
-    fInf(NULL),
-    fLib(NULL),
-    fPosLib(NULL),
-    fShLib(NULL),
-    fCal(NULL),
-    fTracks(NULL),
-    fReco(NULL),
-    fClusters(NULL),
-    fRecoName(""),
-    fToTree(kFALSE),
-    fOutTree(NULL),
-    fStoreClusterInfo(kFALSE),
-    fType(0),
-    fDiffType(0),
-    fE(0.),
-    fE3x3(0.),
-    fE2x2(0.),
-    fEReco(0.),
-    fXReco(0.),
-    fYReco(0.),
-    fECls(0.),
-    fE2Cls(0.),
-    fE3Cls(0.),
-    fECluster(0.),
-    fAX(0.),
-    fAY(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fChi2(0.),
-    fTheta(),
-    fTypes(),
-    fEmeas(),
-    fEpred(),
-    fChi2Fit(),
-    fEfirst(),
-    fChi2First(),
-    fCX(),
-    fCY(),
-    fCMaxs(0),
-    fC(),
-    fSigma(),
-    fParNames(),
-    fSigmaFormula(),
-    fParOffset(0),
-    fChi2Th(0.),
-    fEStep(0.),
-    fCStep(0.),
-    fMaxPhotonsPerCluster(0),
-    fMaxIterations(0),
-    fFixClusterEnergy(0),
-    fFCN(NULL),
-    fFitter(NULL),
-    fMinMaxE(0.),
-    fUsePosLib(0),
-    fPreE(0.),
-    fRegion(0)
-{
-}
-
-// Standard constructor **/
-CbmEcalReco::CbmEcalReco(const char *name, const Int_t iVerbose, const char* configname)
-  : FairTask(name, iVerbose),
-    fN(0),
-    fNOld(0),
-    fMaximums(NULL),
-    fExcluded(NULL),
-    fEventN(0),
-    fStr(NULL),
-    fInf(NULL),
-    fLib(NULL),
-    fPosLib(NULL),
-    fShLib(NULL),
-    fCal(NULL),
-    fTracks(NULL),
-    fReco(NULL),
-    fClusters(NULL),
-    fRecoName("EcalReco"),
-    fToTree(kFALSE),
-    fOutTree(NULL),
-    fStoreClusterInfo(kFALSE),
-    fType(0),
-    fDiffType(0),
-    fE(0.),
-    fE3x3(0.),
-    fE2x2(0.),
-    fEReco(0.),
-    fXReco(0.),
-    fYReco(0.),
-    fECls(0.),
-    fE2Cls(0.),
-    fE3Cls(0.),
-    fECluster(0.),
-    fAX(0.),
-    fAY(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fChi2(0.),
-    fTheta(),
-    fTypes(),
-    fEmeas(),
-    fEpred(),
-    fChi2Fit(),
-    fEfirst(),
-    fChi2First(),
-    fCX(),
-    fCY(),
-    fCMaxs(0),
-    fC(),
-    fSigma(),
-    fParNames(),
-    fSigmaFormula(),
-    fParOffset(0),
-    fChi2Th(0.),
-    fEStep(0.),
-    fCStep(0.),
-    fMaxPhotonsPerCluster(0),
-    fMaxIterations(0),
-    fFixClusterEnergy(0),
-    fFCN(NULL),
-    fFitter(NULL),
-    fMinMaxE(0.),
-    fUsePosLib(0),
-    fPreE(0.),
-    fRegion(0)
-{
-  Int_t i;
-  Int_t j;
-  Int_t types;
-  Int_t consts;
-  TString nm;
-
-  fParNames[0]="Ecluster";
-  fParNames[1]="Emeas";
-  fParNames[2]="Epred";
-  fParNames[3]="Theta";
-  fParOffset=3;
-  for(i=0;i<10;i++)
-  {
-    fParNames[i+fParOffset]="c";
-    fParNames[i+fParOffset]+=i;
-  }
-
-  CbmEcalParam* par=new CbmEcalParam("RecoSlowParam", configname);
-
-  for(i=0;i<10;i++)
-    fC[i]=-1111;
-  types=par->GetInteger("types");
-  consts=par->GetInteger("consts");
-  for(j=1;j<=types;j++)
-  {
-    for(i=0;i<consts;i++)
-    {
-      nm=fParNames[i+fParOffset]; nm+="_"; nm+=j;
-      fC[i]=par->GetDouble(nm);
-    }
-    nm="sigma_"; nm+=j;
-    fSigmaFormula[j]=par->GetString(nm);
-    for(i=0;i<consts;i++)
-    {
-      nm=fParNames[i+fParOffset]; nm+="_"; nm+=j;
-      fSigmaFormula[j].ReplaceAll(fParNames[i+fParOffset], par->GetString(nm));
-    }
-
-    Info("Constructor", "Formula for sigma_%d (with constants): %s. ", j, fSigmaFormula[j].Data());
-    for(i=0;i<fParOffset;i++)
-    {
-      nm="["; nm+=i; nm+="]";
-      fSigmaFormula[j].ReplaceAll(fParNames[i], nm);
-    }
-    Info("Constructor", "Used formula: %s.", fSigmaFormula[j].Data());
-    nm="RecoSlowFormula_"; nm+=j;
-    fSigma[j]=new TFormula("RecoSimpleFormula", fSigmaFormula[j].Data());
-  }
-  fChi2Th=par->GetDouble("chi2th");
-  fEStep=par->GetDouble("estep");
-  fCStep=par->GetDouble("cstep");
-  fMaxIterations=par->GetInteger("maxiterations");
-  fFixClusterEnergy=par->GetInteger("fixclusterenergy");
-  fMaxPhotonsPerCluster=par->GetInteger("maxphotonspercluster");
-  fMinMaxE=par->GetDouble("minmaxe");
-  fUsePosLib=par->GetInteger("useposlib");
-
-  Info("Constructor", "chi2 threshold is %f, Estep is %f, and Cstep is %f.", fChi2Th, fEStep, fCStep);
-  delete par;
-}
-
-CbmEcalReco::~CbmEcalReco()
-{
-  fReco->Delete();
-  delete fReco;
-}
-
-void CbmEcalReco::Finish()
-{
-  if (fOutTree) fOutTree->Write();
-}
-
-/** Init **/
-InitStatus CbmEcalReco::Init()
-{
-  fEventN=0;
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fInf=fStr->GetEcalInf();
-  fTracks=(TClonesArray*)io->GetObject("EcalTrackParam");
-  if (!fTracks)
-  {
-    Fatal("Init", "Can't find EcalTrackParam.");
-    return kFATAL;
-  }
-  fClusters=(TClonesArray*)io->GetObject("EcalClusters");
-  if (!fClusters)
-  {
-    Fatal("Init", "Can't find EcalClusters");
-    return kFATAL;
-  }
-  fCal=(CbmEcalCalibration*)io->GetObject("EcalCalibration");
-  if (!fCal)
-  {
-    Fatal("Init", "Can't find EcalCalibration");
-    return kFATAL;
-  }
-
-  if (fUsePosLib==0)
-  {
-    fLib=(CbmEcalSCurveLib*)io->GetObject("EcalSCurveLib");
-    if (!fLib)
-    {
-      Fatal("Init", "Can't find EcalSCurveLib");
-      return kFATAL;
-    }
-    fPosLib=NULL;
-  }
-  else
-  {
-    fPosLib=(CbmEcalPosLib*)io->GetObject("EcalPosition");
-    if (!fPosLib)
-    {
-      Fatal("Init", "Can't find EcalSCurveLib");
-      return kFATAL;
-    }
-    fLib=NULL;
-  }
-
-  fShLib=(CbmEcalShLib*)io->GetObject("EcalShLib");
-  if (!fShLib)
-  {
-    Fatal("Init", "No shower library found in system. Will continue without chi2 calculation.");
-    return kFATAL;
-  }
-  fReco=new TClonesArray("CbmEcalRecParticle", 2000);
-  io->Register(fRecoName, "ECAL", fReco, IsOutputBranchPersistent(fRecoName));
-
-  fFCN=new FCNEcalCluster(fCal, fShLib, fSigma, fInf);
-  fFCN->SetEStep(fEStep);
-  fFCN->SetCStep(fCStep);
-  fFCN->SetFixClusterEnergy(fFixClusterEnergy);
-  fFCN->SetStructure(fStr);
-  fFitter=new ROOT::Minuit2::Minuit2Minimizer();
-  fFitter->SetPrintLevel(-1);
-  fFitter->SetMaxIterations(fMaxIterations);
-  return kSUCCESS;
-}
-
-ClassImp(CbmEcalReco)
diff --git a/ecal/CbmEcalReco.h b/ecal/CbmEcalReco.h
deleted file mode 100644
index a7ab07f31005c27a4c8c2e35f5f0701e6613e702..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalReco.h
+++ /dev/null
@@ -1,261 +0,0 @@
-/** Quate fast version of reconstruction. Faster fitter and shower library are welcome.
- ** Can be used for data production.
- ** The tracks array can be imported from ROOT file. (see CbmEcalTrackExport. )
- ** The output can be exported to tree. 
- ** //Dr.Sys **/
-
-#ifndef CBMECALRECO_H
-#define CBMECALRECO_H
-
-#include "FairTask.h"
-#include "TString.h"
-
-#include "Math/IFunction.h"
-#include "Minuit2/Minuit2Minimizer.h"
-
-class TChain;
-class TClonesArray;
-class TTree;
-class CbmEcalStructure;
-class CbmEcalCell;
-class CbmEcalSCurveLib;
-class CbmEcalInf;
-class CbmEcalCluster;
-class CbmEcalShLib;
-class CbmEcalCalibration;
-class CbmEcalRecParticle;
-class CbmEcalPosLib;
-class TFormula;
-
-class FCNEcalCluster: public ROOT::Math::IBaseFunctionMultiDim 
-{
-public:
-  FCNEcalCluster(CbmEcalCalibration* cal, CbmEcalShLib* shlib, TFormula** sigma, CbmEcalInf* inf)
-    : ROOT::Math::IBaseFunctionMultiDim() , fCal(cal), 
-    fShLib(shlib), fSigma(sigma), 
-    fInf(inf), fStr(NULL), fCluster(NULL), fEStep(1e-4), fCStep(1e-4), 
-    fErrorDef(1.0), fClusterEnergy(0.), fClusterResp(0.), fN(0), fCells(), 
-    fFixClusterEnergy(0), fNDF(0), fParam(0)
-    {};
-
-  CbmEcalCluster* GetCluster() const {return fCluster;}
-  void SetCluster(CbmEcalCluster* cluster);
-  void SetStructure(CbmEcalStructure* str) {fStr=str;}
-
-  void SetParticleSeeds(const std::vector<CbmEcalCell*> cells) {fCells=cells;}
-
-  /** Get/Set number of photons in cluster **/
-  void SetN(Int_t n);
-  Int_t GetN() const {return fN;}
-
-  void SetNumParam(Int_t i) {fParam=i;}
-
-  /** Get/Set various steps **/
-  void SetEStep(Double_t step) {fEStep=step;}
-  void SetCStep(Double_t step) {fCStep=step;}
-  Double_t GetEStep() const {return fEStep;}
-  Double_t GetCStep() const {return fCStep;}
-  /** NDF of current fit **/
-  Int_t NDF() const {return fNDF;}
-
-  /** The chi2 stuff **/
-  /** par[n] --- energy, par[n+1] --- x, par[n+2] --- y **/
-
-  Double_t DoEval(const Double_t* x) const;
-
-  unsigned int NDim() const
-  {
-    return fParam;
-  }
-  
-  ROOT::Math::IBaseFunctionMultiDim* Clone() const
-    {
-      return new FCNEcalCluster(fCal, fShLib, fSigma, fInf);
-    }
-
-  void SetFixClusterEnergy(Int_t fix) {fFixClusterEnergy=fix;}
-  Double_t ClusterEnergy() const {return fClusterEnergy;}
-
-
-  ~FCNEcalCluster() {};
-private:
-  /** A calibration object **/
-  CbmEcalCalibration* fCal; 		//!
-  /** A shower library **/
-  CbmEcalShLib* fShLib;			//!
-  /** A sigma formula **/
-  TFormula** fSigma;			//!
-  /** Calorimeter information **/
-  CbmEcalInf* fInf;			//!
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;		//!
-  /** Calorimeter cluster **/
-  CbmEcalCluster* fCluster;		//!
-
-  /** Steps if gradient business **/
-  Double_t fEStep;
-  Double_t fCStep;
-  /** A stuff from FCNBase **/
-  Double_t fErrorDef;
-  /** Energy of cluster **/
-  Double_t fClusterEnergy;
-  /** Response of cluster **/
-  Double_t fClusterResp;
-  /** Number of photons in cluster **/
-  Int_t fN;
-  /** Seed cells of cluster **/
-  std::vector<CbmEcalCell*> fCells;	//!
-  /** Fix sum of energies of cluster particles to energy of cluster **/
-  Int_t fFixClusterEnergy;
-  /** NDF of fit **/
-  Int_t fNDF;
-  /** Number of parameters **/
-  Int_t fParam;
-
-  FCNEcalCluster(const FCNEcalCluster&);
-  FCNEcalCluster& operator=(const FCNEcalCluster&);
-};
-
-class CbmEcalReco : public FairTask
-{
-public:
-  /** Default constructor. Requirement of ROOT system **/
-  CbmEcalReco();
-
-  /** Standard constructor **/
-  CbmEcalReco(const char *name, const Int_t iVerbose=1, const char* configname="none");
-
-  /** Destructor **/
-  virtual ~CbmEcalReco();
-
-  /** Init **/
-  virtual InitStatus Init();
-  virtual void Exec(Option_t* option);
-  virtual void Finish();
-
-  /** Tools for debugging **/
-  void SetOutToTree(Bool_t totree=kTRUE) {fToTree=totree;}
-  void SetRecoName(const char* name) {fRecoName=name;}
-  TString GetRecoName() const {return fRecoName;}
-  void SetStoreClusterInfo(Bool_t store) {fStoreClusterInfo=store;}
-private:
-  /** Reconstruct photon from maximum **/
-  void Reco(CbmEcalCell* cell, CbmEcalCluster* clstr);
-  /** Reconstruct photon from maximum. PosLib instead of S-curves **/
-  void Reco2(CbmEcalCell* cell, CbmEcalCluster* clstr);
-  /** Fit a given cluster. A first approximation should be available **/
-  void FitCluster(CbmEcalCluster* clstr);
-  /** Write a cluster info **/
-  void WriteClusterInfo(CbmEcalCluster* clstr);
-  /** Calculate a chi2 for just reconstructed photons **/
-  Double_t CalculateChi2(CbmEcalCluster* cluster);
-  /** Fit a cluster. A**/
-  Double_t FitCluster();
-  /** Reconstruct time for particle **/
-  void TimeReco(CbmEcalRecParticle* p, CbmEcalCluster* cluster);
-  /** Number of reconstructed tracks **/
-  Int_t fN;
-  Int_t fNOld;
-
-  CbmEcalCell** fMaximums;	//!
-  CbmEcalCell** fExcluded;	//!
-
-  /** Event number **/
-  Int_t fEventN;
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;	//!
-  /** An information about calorimeter **/
-  CbmEcalInf* fInf;		//!
-  /** S-curve library **/
-  CbmEcalSCurveLib* fLib;	//!
-  /** A position library **/
-  CbmEcalPosLib* fPosLib;	//!
-  /** A shower library **/
-  CbmEcalShLib* fShLib;		//!
-  /** A calibration of the calorimeter **/
-  CbmEcalCalibration* fCal;	//!
-
-  /** Array of tracks **/
-  TClonesArray* fTracks;	//!
-  /** Array of reconstructed particles **/
-  TClonesArray* fReco;		//!
-  /** Array of clusters **/
-  TClonesArray* fClusters;	//!
-  /** Name of output tree **/
-  TString fRecoName;
-
-  /** A tool, to export reconstructed particles to file. Should be moved to
-   ** a separate task in future. For debugging now. **/
-  Bool_t fToTree;
-  TTree* fOutTree;		//!
-  Bool_t fStoreClusterInfo;
-  void CreateTree();
-  void FillTree();
-  Short_t fType;
-  Short_t fDiffType;
-  Double_t fE;
-  Double_t fE3x3;
-  Double_t fE2x2;
-  Double_t fEReco;
-  Double_t fXReco;
-  Double_t fYReco;
-  Double_t fECls;
-  Double_t fE2Cls;
-  Double_t fE3Cls;
-  Double_t fECluster;
-  Double_t fAX;
-  Double_t fAY;
-  Double_t fCellX;
-  Double_t fCellY;
-  Double_t fChi2;
-  Double_t fTheta[50];
-  Short_t fTypes[50];
-  Double_t fEmeas[50];
-  Double_t fEpred[50];
-  Double_t fChi2Fit[50];
-  Double_t fEfirst[50];
-  Double_t fChi2First[50];
-  Double_t fCX[50];
-  Double_t fCY[50];
-  Int_t fCMaxs;
-
-  /** Constants used in reconstruction **/
-  Double_t fC[10];
-  /** Definition of sigma used for chi^2 calculation **/
-  TFormula* fSigma[10];		//!
-  TString fParNames[14];	//!
-  TString fSigmaFormula[10];
-  Int_t fParOffset;
-  /** A threshold for chi^2. Is chi^2<fChi2Th no fitting **/
-  Double_t fChi2Th;
-  Double_t fEStep;
-  Double_t fCStep;
-  /** Maximum number of photons per cluster for reconstruction
-   ** If cluster contains more local maximums, it rejected. **/
-  Int_t fMaxPhotonsPerCluster;
-  /** Maximum number of iterations in fitting process **/
-  Int_t fMaxIterations;
-  /** Fix sum of energies of cluster particles to energy of cluster **/
-  Int_t fFixClusterEnergy;
-  /** A chi^2 and gradient function for cluster/particles **/
-  FCNEcalCluster* fFCN;		//!
-  /** A fitter **/
-  ROOT::Minuit2::Minuit2Minimizer* fFitter;
-  /** Minimum energy of precluster maximum for consideration **/
-  Double_t fMinMaxE;
-  /** Use a position library instead of S-curves **/
-  Int_t fUsePosLib;
-
-  /** Energy deposition in precluster **/
-  Double_t fPreE;
-  /** Region **/
-  Int_t fRegion;
-
-  CbmEcalReco(const CbmEcalReco&);
-  CbmEcalReco& operator=(const CbmEcalReco&);
-
-  ClassDef(CbmEcalReco, 1)
-};
-
-#endif
-
diff --git a/ecal/CbmEcalReco2.cxx b/ecal/CbmEcalReco2.cxx
deleted file mode 100644
index 974f485246c60ac7b87759c394fc9fae462a9b11..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalReco2.cxx
+++ /dev/null
@@ -1,1050 +0,0 @@
-#include "CbmEcalReco2.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TFormula.h"
-#include "TVector3.h"
-
-#include "FairRootManager.h"
-#include "FairTrackParam.h"
-#include "FairLogger.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalSCurveLib.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalRecParticle.h"
-#include "CbmEcalCluster.h"
-#include "CbmEcalShLib.h"
-#include "CbmEcalCalibration.h"
-#include "CbmEcalParam.h"
-#include "CbmEcalPosLib.h"
-#include "CbmEcalMaximum.h"
-
-#include <iostream>
-
-using namespace std;
-
-void FCNEcalCluster2::SetCluster(CbmEcalCluster* cluster)
-{
-  CbmEcalMaximum* max;
-  Int_t i;
-  Double_t eraw=0;
-  fCluster=cluster;
-  SetN(fCluster->Maxs());
-  fClusterResp=fCluster->Energy();
-
-  fClusterEnergy=0;
-  for(i=0;i<cluster->Maxs();i++)
-  {
-    max=cluster->Maximum(i);
-    eraw+=cluster->PreEnergy(i);
-    fClusterEnergy+=fCal->GetEnergy(cluster->PreEnergy(i), max->TanTheta(), max->Region());
-  }
-  fClusterEnergy*=fClusterResp/eraw;
-}
-
-void FCNEcalCluster2::SetN(Int_t n)
-{
-//  Int_t i;
-  fN=n;
-  fNDF=fCluster->Size()-(n*3-fFixClusterEnergy);
-}
-
-// TODO: more careful estimation of cluster parameters is needed 
-Double_t FCNEcalCluster2::DoEval(const Double_t* par) const
-{
-//  if (par.size()!=fN*3)
-//    Fatal("()", "Size of input vector is wrong (%d, should be %d)!", par.size(), fN*3);
-
-  CbmEcalCell* cell;
-  CbmEcalMaximum* max=fCluster->Maximum(0);
-//  static Double_t module=fInf->GetModuleSize();
-  Int_t type;
-  Double_t de;
-  Double_t x;
-  Double_t y;
-  Double_t theta;
-  Double_t phi;
- // Double_t cellsize;
-  Double_t cx;
-  Double_t cy;
-  Double_t r;
-  Double_t celle;
-  CbmEcalCell* cl;
- // Int_t p;
-  Int_t i;
-  Int_t k;
- // CbmEcalRecParticle* part;
- // Double_t clustere=fClusterResp;
-  Double_t clenergy;
- // Double_t sigma2;
-  Double_t cellerr;
-  Double_t epred;
- // Double_t sin4theta;
-  Double_t chi2=0;
-  Double_t e[6];
-  Double_t t;
-  Double_t emeas;
-  Int_t region=max->Region();
-
-
-  clenergy=fClusterEnergy;
-
-  if (fFixClusterEnergy==0)
-    for(i=0;i<fN;i++)
-      e[i]=par[3*i];
-   else
-   {
-     t=fClusterEnergy;
-     for(i=0;i<fN-1;i++)
-     {
-       e[i]=par[3*i+2]*t;
-       t-=e[i];
-       if (t<0) t=0;
-     }
-     e[i]=t;
-   }
- 
-  for(k=0;k<fCluster->Size();k++)
-  {
-    cell=fStr->GetHitCell(fCluster->CellNum(k));
-    max=fCluster->Maximum(k);
-    type=cell->GetType();
-  //  cellsize=module/type;
-    cellerr=0; celle=0;
-    for(i=0;i<fN;i++)
-    {
-      cl=fCells[i]; cx=cl->GetCenterX(); cy=cl->GetCenterY(); 
-      x=cell->GetCenterX(); x-=par[3*i+1-fFixClusterEnergy]; //part->X(); // x-=cx; 
-      y=cell->GetCenterY(); y-=par[3*i+2-fFixClusterEnergy]; //part->Y(); // y-=cy; 
-
-      r=TMath::Sqrt(cx*cx+cy*cy);
-
-      /** TODO: should be Z of the cell**/
-      theta=TMath::ATan(r/fInf->GetZPos());
-      theta*=TMath::RadToDeg();
-      phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-      if (cy<0) phi=360.0-phi;
-
-      celle+=fShLib->GetResponse(x, y, phi, theta, e[i], type);
-//      celle+=fShLib->GetSumEThetaPhi(x, y, cellsize, part->E(), theta, phi);
-    }
-    cx=cell->GetCenterX(); cy=cell->GetCenterY();
-    r=TMath::Sqrt(cx*cx+cy*cy);
-    theta=TMath::ATan(r/fInf->GetZPos());
-
-    epred=celle*fClusterEnergy/fClusterResp;
-    emeas=cell->GetTotalEnergy()*fClusterEnergy/fClusterResp;
-//      cout << fClusterEnergy << " --- " << epred << " : " << emeas << endl;
-    {
-      fSigma[region]->SetParameter(0, clenergy);	//Ecluster
-      fSigma[region]->SetParameter(1, emeas);		//Emeas
-      fSigma[region]->SetParameter(2, epred);		//Epred
-      fSigma[region]->SetParameter(3, theta);		//Theta
-      cellerr=fSigma[region]->Eval(0);
-      de=epred-emeas;
-      de*=de; chi2+=de/cellerr;
-    }
-  }
-//  cout << endl;
-//  chi2/=fCluster->Size();
-  return chi2;
-}
-
-/***************************************************************************/
-
-void CbmEcalReco2::Exec(Option_t*)
-{
-  Int_t i;
-  Int_t n=fClusters->GetEntriesFast();
-  CbmEcalCluster* cluster;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t chi2;
-  CbmEcalCell* cell;
-  Int_t j;
-
-  fN=0;
-  fReco->Delete();
-  if (fToTree&&fOutTree==NULL)
-    CreateTree();
-  fEventN++;
-  if (fVerbose>0) 
-    Info("Exec", "Event %d, %d clusters in event.", fEventN, n);
-  for(i=0;i<n;i++)
-  {
-    fNOld=fN;
-    cluster=(CbmEcalCluster*)fClusters->At(i);
-    if (cluster->Maxs()>fMaxPhotonsPerCluster)
-      continue;
-    for(j=0;j<cluster->Maxs();j++)
-    {
-      cell=fStr->GetHitCell(cluster->CellNum(j));
-      fPreE=cluster->PreEnergy(j);
-      fCurrentMaximum=cluster->Maximum(j);
-      if (fCal->GetEnergy(cell->GetTotalEnergy(), fCurrentMaximum->TanTheta(), fCurrentMaximum->Region())>fMinMaxE)
-        Reco(fCurrentMaximum, cluster);
-    }
-    chi2=CalculateChi2(cluster);
-    if (chi2>fChi2Th)
-      FitCluster(cluster);
-    if (fStoreClusterInfo)
-      WriteClusterInfo(cluster);
-    if (fOutTree)
-      FillTree();
-  }
-  if (fVerbose>1)
-    Info("Exec", "%d photons reconstructed in calorimeter.", fN);
-}
-
-/** Write a cluster info **/
-void CbmEcalReco2::WriteClusterInfo(CbmEcalCluster* clstr)
-{
-  CbmEcalMaximum* max=clstr->Maximum(0);
-  list<CbmEcalCell*>::const_iterator p;  
-  CbmEcalCell* cell;
-  CbmEcalRecParticle* part;
-  Int_t i=0;
-  Int_t j;
-  Int_t k;
-  Double_t celle;
-//  Double_t cellsize;
-  Double_t e[3];
-  Double_t x;
-  Double_t y;
-  Double_t r;
-  Double_t theta;
-  Double_t phi;
-  CbmEcalCell* cl;
-  Double_t cx;
-  Double_t cy;
-  Double_t de;
-  Double_t epred;
-  Double_t emeas;
- // Double_t clenergy;
-  Double_t cellerr;
-//  static Double_t module=fInf->GetModuleSize();
-
-  fECluster=fCal->GetEnergy(clstr->Energy(), max->TanTheta(), max->Region());
- // clenergy=fECluster;
-  for(k=0;k<clstr->Size();k++)
-  {
-    cell=fStr->GetHitCell(clstr->CellNum(k));
-    e[i++]=cell->GetTotalEnergy();
-    if (i==3) break;
-  }
-  fCMaxs=clstr->Maxs();
-  fECls=e[0]/clstr->Energy();
-  fE2Cls=(e[0]+e[1])/clstr->Energy();
-  fE3Cls=(e[0]+e[1]+e[2])/clstr->Energy();
-  i=0;
-
-  for(k=0;k<clstr->Size();k++)
-  {
-    cell=fStr->GetHitCell(clstr->CellNum(k));
-    max=clstr->Maximum(k);
-    fTypes[i]=cell->GetType();
- //   cellsize=module/fTypes[i];
-    celle=0;
-    for(j=fNOld;j<fN;j++)
-    {
-      part=(CbmEcalRecParticle*)fReco->At(j);
-      cl=fStr->GetHitCell(part->CellNum()); cx=cl->GetCenterX(); cy=cl->GetCenterY(); 
-      x=cell->GetCenterX(); x-=part->X(); // x-=cx; 
-      y=cell->GetCenterY(); y-=part->Y(); // y-=cy; 
-
-      r=TMath::Sqrt(cx*cx+cy*cy);
-
-      /** TODO: should be Z of the cell**/
-      theta=TMath::ATan(r/fInf->GetZPos());
-      theta*=TMath::RadToDeg();
-      phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-      if (cy<0) phi=360.0-phi;
-
-      celle+=fShLib->GetResponse(x, y, phi, theta, part->E(), fTypes[i]);
-    }
-    de=fCal->GetEnergy(celle, max->TanTheta(), max->Region())-fCal->GetEnergy(cell->GetTotalEnergy(), max->TanTheta(), max->Region());
-    cx=cell->GetCenterX(); cy=cell->GetCenterY();
-    r=TMath::Sqrt(cx*cx+cy*cy);
-    theta=TMath::ATan(r/fInf->GetZPos());
-
-    epred=fCal->GetEnergy(celle, max->TanTheta(), max->Region());
-    emeas=fCal->GetEnergy(cell->GetTotalEnergy(), max->TanTheta(), max->Region());
-    fSigma[fTypes[i]]->SetParameter(0, fECluster);		//Ecluster
-    fSigma[fTypes[i]]->SetParameter(1, emeas);		//Emeas
-    fSigma[fTypes[i]]->SetParameter(2, epred);		//Epred
-    fSigma[fTypes[i]]->SetParameter(3, theta);		//Theta
-    cellerr=fSigma[fTypes[i]]->Eval(0);
-    de*=de; fChi2Fit[i]=de/cellerr;
-
-    cx=cell->GetCenterX(); cy=cell->GetCenterY();
-    r=TMath::Sqrt(cx*cx+cy*cy);
-    fTheta[i]=TMath::ATan(r/fInf->GetZPos());
-    fEpred[i]=fCal->GetEnergy(celle, max->TanTheta(), max->Region());
-    fEmeas[i]=fCal->GetEnergy(cell->GetTotalEnergy(), max->TanTheta(), max->Region());
-    fCX[i]=cell->GetCenterX();
-    fCY[i]=cell->GetCenterY();
-    i++;
-  }
-  for(j=i;j<50;j++)
-    fTypes[j]=-1111;
-}
-
-void CbmEcalReco2::FillTree()
-{
-  Int_t n=fN-fNOld;
-  CbmEcalRecParticle* p;
-  Int_t i;
-
-  for(i=0;i<n;i++)
-  {
-    p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-    fChi2=p->Chi2();
-    fEReco=p->E();
-    fXReco=p->X();
-    fYReco=p->Y();
-    fOutTree->Fill();
-  }
-
-}
-
-/** Fit a given cluster. A first approximation should be available **/
-void CbmEcalReco2::FitCluster(CbmEcalCluster* clstr)
-{
-  vector<CbmEcalCell*> cells(fN-fNOld);
-  Int_t i;
-  Int_t n=fN-fNOld;
-  Int_t ret;
-  Double_t oldchi2=clstr->Chi2();
-  Double_t e;
-  Double_t pe[6];
-  CbmEcalRecParticle* p;
-  TString par;
-  TVector3 tv;
-
-  if (n>6)
-  {
-    Info("FitCluster", "Give up fitting the cluster with %d maximums. ", n);
-    return;
-  }
-  fFCN->SetCluster(clstr);
-  /// The cluster it self  doesn't care about amplitude of maximums 
-  fFCN->SetN(n);
-
-  Int_t params=0;
-
-  fFitter->Clear();
-  fFitter->SetPrintLevel(-1);
-  fFitter->SetMaxIterations(fMaxIterations);
-  if (fFixClusterEnergy==0) {
-    for(i=0;i<n;i++) {
-      p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-      cells[i]=fStr->GetHitCell(p->CellNum());
-      par="e"; par+=i; 
-      fFitter->SetVariable(i*3   ,par.Data(), p->E(), 0.01*p->E());
-      fFitter->SetVariableLimits(i*3, p->E()*0.2, p->E()*2.0);
-      params++;
-      par="x"; par+=i; 
-      fFitter->SetVariable(i*3+1 ,par.Data(), p->X(), 0.5);
-      fFitter->SetVariableLimits(i*3+1, p->X()-6., p->X()+6.);
-      params++;
-      par="y"; par+=i; 
-      fFitter->SetVariable(i*3+2 ,par.Data(), p->Y(), 0.5);
-      fFitter->SetVariableLimits(i*3+2, p->Y()-6., p->Y()+6.);
-      params++;
-    }
-  } else {
-    e=0;
-    for(i=0;i<n;i++) {
-      p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-      pe[i]=p->E(); e+=pe[i];
-    }
-    for(i=0;i<n;i++) {
-      p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-      cells[i]=fStr->GetHitCell(p->CellNum());
-      par="x"; par+=i; 
-      fFitter->SetVariable(i*3 ,par.Data(), p->X(), 2.5);
-      fFitter->SetVariableLimits(i*3,p->X()-6., p->X()+6.);
-      params++;
-      par="y"; par+=i; 
-      fFitter->SetVariable(i*3+1 ,par.Data(), p->Y(), 2.5);
-      fFitter->SetVariableLimits(i*3+1, p->Y()-6., p->Y()+6.);
-      params++;
-      if (i!=n-1) {
-        par="n";
-	par+=i;
-	fFitter->SetVariable(i*3+2 ,par.Data(), p->E()/e, 0.5);
-	fFitter->SetVariableLimits(i*3+2, 0.0, 1.0);
-        params++;
-      }
-      e-=p->E();
-    }
-
-  }
-
-  fFCN->SetNumParam(params);
-  fFCN->SetParticleSeeds(cells);
-
-  fFitter->SetFunction(*fFCN);
-  ret=fFitter->Minimize();
-
-  Double_t chi2=fFitter->MinValue();
-
-  if (ret!=0&&fVerbose>1)
-  {
-    Info("FitCluster", "Minimization failed! Last chi2 %f, old chi2 %f.", chi2, oldchi2);
-  }
-
-//  cout << "chi2=" << chi2 << ", NDF=" << fFCN->NDF() << endl;
-  if (fFCN->NDF()>0)
-    chi2/=fFCN->NDF();
-  else
-    chi2=-chi2;
-  clstr->fChi2=chi2;
-
-
-  e=fFCN->ClusterEnergy();
-
-  // get the fit parameters from Minuit
-  const double *fitResult = fFitter->X();
-
-  for(i=0;i<n;i++) {
-    p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-    p->fX=fitResult[i*3+1-fFixClusterEnergy];
-    p->fY=fitResult[i*3+2-fFixClusterEnergy];
-    LOG(debug2) << "fitResult[" << i*3+1-fFixClusterEnergy << "]: " << fitResult[i*3+1-fFixClusterEnergy];
-    LOG(debug2) << "fitResult[" << i*3+2-fFixClusterEnergy << "]: " << fitResult[i*3+2-fFixClusterEnergy];
-    if (fFixClusterEnergy) {
-      if (i!=n-1) {
-        p->fE=fitResult[i*3+2]*e;
-	LOG(debug2) << "fitResult[" << i*3+2 << "]: " << fitResult[i*3+2];
-	e-=p->fE;
-      } else {
-	p->fE=e;
-      }
-    } else {
-      p->fE=fitResult[i*3];
-      LOG(debug2) << "fitResult[" << i*3 << "]: " << fitResult[i*3];
-    }
-
-    tv.SetXYZ(p->fX, p->fY, fInf->GetZPos());
-    tv*=p->fE/tv.Mag();
-    p->fPx=tv.X();
-    p->fPy=tv.Y();
-    p->fPz=tv.Z();
-    p->fChi2=chi2;
-    TimeReco(p, clstr);
-  }
-  
-}
-
-void CbmEcalReco2::TimeReco(CbmEcalRecParticle* p, CbmEcalCluster* cluster)
-{
-  Double_t time=0;
-  Double_t te=0;
-
-//  static Double_t module=fInf->GetModuleSize();
-  Double_t theta;
-  Int_t k;
-  CbmEcalCell* cell;
-  Int_t type;
- // Double_t cellsize;
-  Double_t celle;
-  Double_t celltime;
-  Double_t x;
-  Double_t y;
-  Double_t r;
-  Double_t cx;
-  Double_t cy;
-  Double_t phi;
-  CbmEcalCell* cl;
-  
-  cl=fStr->GetHitCell(p->CellNum());
-  cx=cl->GetCenterX(); cy=cl->GetCenterY(); 
-  r=TMath::Sqrt(cx*cx+cy*cy);
-  /** TODO: should be Z of the cell**/
-  theta=TMath::ATan(r/fInf->GetZPos());
-  theta*=TMath::RadToDeg();
-  phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-  if (cy<0) phi=360.0-phi;
-
-  for(k=0;k<cluster->Size();k++)
-  {
-    cell=fStr->GetHitCell(cluster->CellNum(k));
-    celltime=cell->GetTime();
-    if (celltime==-1111) continue;
-    /** No time information for the cell **/
-    type=cell->GetType();
- //   cellsize=module/type;
-    x=cell->GetCenterX(); x-=p->X(); // x-=cx; 
-    y=cell->GetCenterY(); y-=p->Y(); // y-=cy; 
-
-    celle=fShLib->GetResponse(x, y, phi, theta, p->E(), type);
-//    cout << "CellTime: "<< celltime << "	" << celle << "	" << cell->GetTotalEnergy() << "	" << cell->GetEnergy() << "	" << cell->GetCenterX() << "	" << cell->GetCenterY() << endl;
-    time+=celle*celltime;
-    te+=celle;
-  }
- 
-//  cout << "CellTime: " << time << endl;
-  time/=te;
-//  cout << "CellTime: " << time << endl;
-  if (time>0)
-    p->SetTOF(time);
-}
-
-/** Calculate a chi2 for just reconstructed photons **/
-Double_t CbmEcalReco2::CalculateChi2(CbmEcalCluster* cluster)
-{
-  if (!fShLib) return -1111;
- 
-  CbmEcalMaximum* max=cluster->Maximum(0);
-  CbmEcalCell* cell;
-//  static Double_t module=fInf->GetModuleSize();
-  Int_t type;
-  Double_t de;
-  Double_t x;
-  Double_t y;
-  Double_t theta;
-  Double_t phi;
- // Double_t cellsize;
-  Double_t cx;
-  Double_t cy;
-  Double_t r;
-  Double_t celle;
-  CbmEcalCell* cl;
-  Int_t p;
-  Int_t i;
-  Int_t k;
-  CbmEcalRecParticle* part;
-  Double_t clustere=0;
-  Double_t clenergy;
- // Double_t sigma2;
-  Double_t cellerr;
-  Double_t epred;
- // Double_t sin4theta;
-  Double_t chi2=0;
-  Double_t emeas;
-  Int_t region=max->Region();
-
-  clenergy=0;
-  for(i=0;i<cluster->Maxs();i++)
-  {
-    max=cluster->Maximum(i);
-    clustere+=cluster->PreEnergy(i);
-    clenergy+=fCal->GetEnergy(cluster->PreEnergy(i), max->TanTheta(), max->Region());
-  }
-  clenergy*=cluster->Energy()/clustere;
-  clustere=cluster->Energy();
-
-  i=0;
-  for(k=0;k<cluster->Size();k++)
-  {
-    cell=fStr->GetHitCell(cluster->CellNum(k));
-    max=cluster->Maximum(k);
-    type=cell->GetType();
- //   cellsize=module/type;
-    cellerr=0; celle=0;
-    for(p=fNOld;p<fN;p++)
-    {
-      part=(CbmEcalRecParticle*)fReco->At(p);
-      cl=fStr->GetHitCell(part->CellNum()); cx=cl->GetCenterX(); cy=cl->GetCenterY(); 
-      x=cell->GetCenterX(); x-=part->X(); // x-=cx; 
-      y=cell->GetCenterY(); y-=part->Y(); // y-=cy; 
-
-      r=TMath::Sqrt(cx*cx+cy*cy);
-
-      /** TODO: should be Z of the cell**/
-      theta=TMath::ATan(r/fInf->GetZPos());
-      theta*=TMath::RadToDeg();
-      phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-      if (cy<0) phi=360.0-phi;
-//      cout << "Cell(" << cx << ", " << cy << ")" << endl; 
-      celle+=fShLib->GetResponse(x, y, phi, theta, part->E(), type);
-//      cout << "Shlib " << x << " " << y << " " << phi << " " << theta << " " << part->E() << " " << type << " : " << celle << endl;
-    }
-//    cout << "---> " << x << "	" << y << "	" << cellsize << "	" << part->E() << "	" << theta << "	" << phi << endl;
-//    cout << "-> celle " << celle << endl;
-    cx=cell->GetCenterX(); cy=cell->GetCenterY();
-    r=TMath::Sqrt(cx*cx+cy*cy);
-    theta=TMath::ATan(r/fInf->GetZPos());
-
-    epred=celle*clenergy/clustere;
-    emeas=cell->GetTotalEnergy()*clenergy/clustere;
-    fEfirst[i]=epred;
-//    if (epred>clenergy) epred=clenergy;
-//    if (celle>0)
-    {
-      fSigma[region]->SetParameter(0, clenergy);	//Ecluster
-      fSigma[region]->SetParameter(1, emeas);		//Emeas
-      fSigma[region]->SetParameter(2, epred);		//Epred
-      fSigma[region]->SetParameter(3, theta);		//Theta
-      cellerr=fSigma[region]->Eval(0);
-      de=epred-emeas;
-//      cout << "-> celle=" << celle << "	, epred(" << celle << ")=" << epred << ", emeas(" <<cell->GetTotalEnergy() << ")=" << emeas << endl;
-//      cellerr=1;
-      de*=de; chi2+=de/cellerr;
-      fChi2First[i]=de/cellerr;
-    }
-    i++;
-  }
-  if (cluster->Size()-((fN-fNOld)*3-fFixClusterEnergy)<=0)
-  {
-    Info("CalculateChi2","NDF is %d.", cluster->Size()-((fN-fNOld)*3-fFixClusterEnergy));
-    chi2=-chi2;
-  }
-  else
-    chi2/=cluster->Size()-((fN-fNOld)*3-fFixClusterEnergy);
-  for(p=fNOld;p<fN;p++)
-  {
-    part=(CbmEcalRecParticle*)fReco->At(p);
-    part->SetChi2(chi2);
-  }
-  cluster->fChi2=chi2;
-//  cout << fNOld << "	" << fN << "	" << chi2 << endl;
-  return chi2;
-}
-
-/** Get first approximation of photon parameters from maximum **/
-void CbmEcalReco2::Reco(CbmEcalMaximum* max, CbmEcalCluster* clstr)
-{
-  if (fLib==NULL)
-  {
-    Reco2(max, clstr);
-    return;
-  }
-  Double_t x;
-  Double_t y;
-  Double_t amp;
-  Double_t en;
- // Double_t maxe;
-  Double_t px;
-  Double_t py;
-  Double_t pz;
-  Double_t z=fInf->GetZPos();
-  CbmEcalCell* cell=max->Cell();
-  Int_t type;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-//  Int_t cnum;
-
-  cells.clear();
-
-  fType=cell->GetType();
-  fDiffType=0;
-
-  cell->GetNeighborsList(0,cells);
-  fE=cell->GetEnergy();
-  en=cell->GetEnergy();
-  type=max->Region();
-  fAX=0; fAY=0;
-  for(p=cells.begin();p!=cells.end();++p) 
-  {
-    if (type!=(*p)->GetType())
-    {
-      type=-1111;
-      fDiffType=1;
-    }
-    if (cell->GetX2()+0.001<(*p)->GetCenterX())
-      fAX+=(*p)->GetEnergy();
-    else
-    if (cell->GetX1()-0.001>(*p)->GetCenterX())
-      fAX-=(*p)->GetEnergy();
-    if (cell->GetY2()+0.001<(*p)->GetCenterY())
-      fAY+=(*p)->GetEnergy();
-    else
-    if (cell->GetY1()-0.001>(*p)->GetCenterY())
-      fAY-=(*p)->GetEnergy();
-    en+=(*p)->GetEnergy();
-  }
-  fE3x3=en;
-
-  if (fAX!=-1111)
-  {
-    fAX/=fE3x3;
-    fAY/=fE3x3;
-  }
-
- // maxe=0;
-  cell->GetNeighborsList(max->I(),cells);
-  en=cell->GetEnergy();
-  for(p=cells.begin();p!=cells.end();++p) 
-    en+=(*p)->GetEnergy();
-  cells.push_back(cell);
-  fE2x2=en;
-
-  fCellX=cell->GetCenterX();
-  fCellY=cell->GetCenterY();
-
-  if (fCal->GetEnergy(fE2x2, max->TanTheta(), max->Region())<0.1) return; 
-  fEReco=fCal->GetEnergy(fE2x2, max->TanTheta(), max->Region());
-  if (fAX!=-1111)
-    fXReco=fLib->GetX(fAX, fEReco, cell);
-  else
-    fXReco=-1111;
-  if (fXReco!=-1111)
-    fXReco+=cell->GetCenterX();
-  
-  if (fAY!=-1111)
-    fYReco=fLib->GetY(fAY, fEReco, cell);
-  else
-    fYReco=-1111;
-  
-  if (fYReco!=-1111)
-    fYReco+=cell->GetCenterY();
-  if (fXReco!=-1111)
-    x=fXReco;
-  else
-    x=cell->GetCenterX();
-  if (fYReco!=-1111)
-    y=fYReco;
-  else
-    y=cell->GetCenterY();
-  amp=TMath::Sqrt(x*x+y*y+z*z);
-  px=fEReco*x/amp;
-  py=fEReco*y/amp;
-  pz=fEReco*z/amp;
-  new((*fReco)[fN++]) CbmEcalRecParticle(px, py, pz, fEReco, x, y, z, 22, -1111, clstr, cell, fType);
-}
-
-/** Get first approximation of photon parameters from maximum
- ** This version uses PosLib instead of S-curves
- ** TODO Architecture: Need a maximum, instead of cell here **/
-void CbmEcalReco2::Reco2(CbmEcalMaximum* max, CbmEcalCluster* clstr)
-{
-  if (fPosLib==NULL)
-    Fatal("Reco2", "No position library for reconstruction.");
-
-  CbmEcalCell* cell=max->Cell();
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t px;
-  Double_t py;
-  Double_t pz;
-  Double_t amp;
-  Double_t x=max->X();
-  Double_t y=max->Y();
-  Double_t z;
-  Double_t t;
-  
-  z=fInf->GetZPos();
-  t=TMath::Sqrt(x*x+y*y);
-  fEReco=fCal->GetEnergy(fPreE, t/z, max->Region());
-  fPosLib->GetXY(fEReco, x, y);
-  //One more iteration for better precesion
-  x=fPosLib->X(); y=fPosLib->Y();
-  fPosLib->GetXY(fEReco, x, y);
-  x=fPosLib->X(); y=fPosLib->Y();
-  t=TMath::Sqrt(x*x+y*y);
-  fEReco=fCal->GetEnergy(fPreE, t/z, max->Region());
-  amp=TMath::Sqrt(t+z*z);
-  px=fEReco*x/amp;
-  py=fEReco*y/amp;
-  pz=fEReco*z/amp;
-  new((*fReco)[fN++]) CbmEcalRecParticle(px, py, pz, fEReco, x, y, z, 22, -1111, clstr, cell, fType);
-
-}
-void CbmEcalReco2::CreateTree()
-{
-  fOutTree=new TTree("slow_reco", "Reconstruction by fitting with shower library");
-  fOutTree->Branch("ev", &fEventN, "ev/I");
-  fOutTree->Branch("type", &fType, "type/S");
-  fOutTree->Branch("difftype", &fDiffType, "difftype/S");
-  fOutTree->Branch("x", &fXReco, "x/D");
-  fOutTree->Branch("y", &fYReco, "y/D");
-  fOutTree->Branch("e", &fEReco, "e/D");
-  fOutTree->Branch("chi2", &fChi2, "chi2/D");
-  fOutTree->Branch("ecluster", &fECluster, "ecluster/D");
-  if (fStoreClusterInfo==kFALSE) return;
-  fOutTree->Branch("cls_e", &fECls, "cls_e/D");
-  fOutTree->Branch("cls_e2", &fE2Cls, "cls_e2/D");
-  fOutTree->Branch("cls_e3", &fE3Cls, "cls_e3/D");
-  fOutTree->Branch("theta", fTheta, "theta[50]/D");
-  fOutTree->Branch("ctypes", fTypes, "ctypes[50]/S");
-  fOutTree->Branch("cemeas", fEmeas, "cemeas[50]/D");
-  fOutTree->Branch("cepred", fEpred, "cepred[50]/D");
-  fOutTree->Branch("cchi2", fChi2Fit, "cchi2[50]/D");
-  fOutTree->Branch("cefirst", fEfirst, "cefirst[50]/D");
-  fOutTree->Branch("cchi2first", fChi2First, "cchi2first[50]/D");
-  fOutTree->Branch("cx", fCX, "cx[50]/D");
-  fOutTree->Branch("cy", fCY, "cy[50]/D");
-  fOutTree->Branch("cmaxs", &fCMaxs, "cmaxs/I");
-}
-
-/** Default constructor. Requirement of ROOT system **/
-CbmEcalReco2::CbmEcalReco2() 
-  : FairTask(),
-    fN(0),
-    fNOld(0),
-    fMaximums(NULL),
-    fExcluded(NULL),
-    fEventN(0),
-    fStr(NULL),
-    fInf(NULL),
-    fLib(NULL),
-    fPosLib(NULL),
-    fShLib(NULL),
-    fCal(NULL),
-    fReco(NULL),
-    fClusters(NULL),
-    fRecoName(""),
-    fToTree(kFALSE),
-    fOutTree(NULL),
-    fStoreClusterInfo(kFALSE),
-    fType(0),
-    fDiffType(0),
-    fE(0.),
-    fE3x3(0.),
-    fE2x2(0.),
-    fEReco(0.),
-    fXReco(0.),
-    fYReco(0.),
-    fECls(0.),
-    fE2Cls(0.),
-    fE3Cls(0.),
-    fECluster(0.),
-    fAX(0.),
-    fAY(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fChi2(0.),
-    fTheta(),
-    fTypes(),
-    fEmeas(),
-    fEpred(),
-    fChi2Fit(),
-    fEfirst(),
-    fChi2First(),
-    fCX(),
-    fCY(),
-    fCMaxs(0),
-    fC(),
-    fSigma(),
-    fParNames(),
-    fSigmaFormula(),
-    fParOffset(0),
-    fChi2Th(0.),
-    fEStep(0.),
-    fCStep(0.),
-    fMaxPhotonsPerCluster(0),
-    fMaxIterations(0),
-    fFixClusterEnergy(0),
-    fFCN(NULL),
-    fFitter(NULL),
-    fMinMaxE(0.),
-    fUsePosLib(0),
-    fPreE(0.),
-    fCurrentMaximum(NULL)
-{
-}
-
-/** Standard constructor **/
-CbmEcalReco2::CbmEcalReco2(const char *name, const Int_t iVerbose, const char* configname)
-  : FairTask(name, iVerbose),
-    fN(0),
-    fNOld(0),
-    fMaximums(NULL),
-    fExcluded(NULL),
-    fEventN(0),
-    fStr(NULL),
-    fInf(NULL),
-    fLib(NULL),
-    fPosLib(NULL),
-    fShLib(NULL),
-    fCal(NULL),
-    fReco(NULL),
-    fClusters(NULL),
-    fRecoName("EcalReco"),
-    fToTree(kFALSE),
-    fOutTree(NULL),
-    fStoreClusterInfo(kFALSE),
-    fType(0),
-    fDiffType(0),
-    fE(0.),
-    fE3x3(0.),
-    fE2x2(0.),
-    fEReco(0.),
-    fXReco(0.),
-    fYReco(0.),
-    fECls(0.),
-    fE2Cls(0.),
-    fE3Cls(0.),
-    fECluster(0.),
-    fAX(0.),
-    fAY(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fChi2(0.),
-    fTheta(),
-    fTypes(),
-    fEmeas(),
-    fEpred(),
-    fChi2Fit(),
-    fEfirst(),
-    fChi2First(),
-    fCX(),
-    fCY(),
-    fCMaxs(0),
-    fC(),
-    fSigma(),
-    fParNames(),
-    fSigmaFormula(),
-    fParOffset(0),
-    fChi2Th(0.),
-    fEStep(0.),
-    fCStep(0.),
-    fMaxPhotonsPerCluster(0),
-    fMaxIterations(0),
-    fFixClusterEnergy(0),
-    fFCN(NULL),
-    fFitter(NULL),
-    fMinMaxE(0.),
-    fUsePosLib(0),
-    fPreE(0.),
-    fCurrentMaximum(NULL)
-{
-  Int_t i;
-  Int_t j;
-  Int_t types;
-  Int_t consts;
-  TString nm;
-
-  fParNames[0]="Ecluster";
-  fParNames[1]="Emeas";
-  fParNames[2]="Epred";
-  fParNames[3]="Theta";
-  fParOffset=3;
-  for(i=0;i<10;i++)
-  {
-    fParNames[i+fParOffset]="c";
-    fParNames[i+fParOffset]+=i;
-  }
-
-  CbmEcalParam* par=new CbmEcalParam("RecoSlowParam", configname);
-
-  for(i=0;i<10;i++)
-    fC[i]=-1111;
-  types=par->GetInteger("types");
-  consts=par->GetInteger("consts");
-  for(j=0;j<types;j++)
-  {
-    for(i=0;i<consts;i++)
-    {
-      nm=fParNames[i+fParOffset]; nm+="_"; nm+=j;
-      fC[i]=par->GetDouble(nm);
-    }
-    nm="sigma_"; nm+=j;
-    fSigmaFormula[j]=par->GetString(nm);
-    for(i=0;i<consts;i++)
-    {
-      nm=fParNames[i+fParOffset]; nm+="_"; nm+=j;
-      fSigmaFormula[j].ReplaceAll(fParNames[i+fParOffset], par->GetString(nm));
-    }
-
-    Info("Constructor", "Formula for sigma_%d (with constants): %s. ", j, fSigmaFormula[j].Data());
-    for(i=0;i<fParOffset;i++)
-    {
-      nm="["; nm+=i; nm+="]";
-      fSigmaFormula[j].ReplaceAll(fParNames[i], nm);
-    }
-    Info("Constructor", "Used formula: %s.", fSigmaFormula[j].Data());
-    nm="RecoSlowFormula_"; nm+=j;
-    fSigma[j]=new TFormula("RecoSimpleFormula", fSigmaFormula[j].Data());
-  }
-  fChi2Th=par->GetDouble("chi2th");
-  fEStep=par->GetDouble("estep");
-  fCStep=par->GetDouble("cstep");
-  fMaxIterations=par->GetInteger("maxiterations");
-  fFixClusterEnergy=par->GetInteger("fixclusterenergy");
-  fMaxPhotonsPerCluster=par->GetInteger("maxphotonspercluster");
-  fMinMaxE=par->GetDouble("minmaxe");
-  fUsePosLib=par->GetInteger("useposlib");
-
-  Info("Constructor", "chi2 threshold is %f, Estep is %f, and Cstep is %f.", fChi2Th, fEStep, fCStep);
-
-  delete par;
-}
-
-CbmEcalReco2::~CbmEcalReco2()
-{
-  fReco->Delete();
-  delete fReco;
-}
-
-void CbmEcalReco2::Finish()
-{
-  if (fOutTree) fOutTree->Write();
-}
-
-/** Init **/
-InitStatus CbmEcalReco2::Init()
-{
-  fEventN=0;
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fInf=fStr->GetEcalInf();
-  fClusters=(TClonesArray*)io->GetObject("EcalClusters");
-  if (!fClusters)
-  {
-    Fatal("Init", "Can't find EcalClusters");
-    return kFATAL;
-  }
-  fCal=(CbmEcalCalibration*)io->GetObject("EcalCalibration");
-  if (!fCal)
-  {
-    Fatal("Init", "Can't find EcalCalibration");
-    return kFATAL;
-  }
-
-  if (fUsePosLib==0)
-  {
-    fLib=(CbmEcalSCurveLib*)io->GetObject("EcalSCurveLib");
-    if (!fLib)
-    {
-      Fatal("Init", "Can't find EcalSCurveLib");
-      return kFATAL;
-    }
-    fPosLib=NULL;
-  }
-  else
-  {
-    fPosLib=(CbmEcalPosLib*)io->GetObject("EcalPosition");
-    if (!fPosLib)
-    {
-      Fatal("Init", "Can't find EcalSCurveLib");
-      return kFATAL;
-    }
-    fLib=NULL;
-  }
-
-  fShLib=(CbmEcalShLib*)io->GetObject("EcalShLib");
-  if (!fShLib)
-  {
-    Fatal("Init", "No shower library found in system. Will continue without chi2 calculation.");
-    return kFATAL;
-  }
-  fReco=new TClonesArray("CbmEcalRecParticle", 2000);
-  io->Register(fRecoName, "ECAL", fReco, IsOutputBranchPersistent(fRecoName));
-
-  fFCN=new FCNEcalCluster2(fCal, fShLib, fSigma, fInf);
-  fFCN->SetEStep(fEStep);
-  fFCN->SetCStep(fCStep);
-  fFCN->SetFixClusterEnergy(fFixClusterEnergy);
-  fFCN->SetStructure(fStr);
-  fFitter=new ROOT::Minuit2::Minuit2Minimizer();
-  fFitter->SetPrintLevel(-1);
-  fFitter->SetMaxIterations(fMaxIterations);
-
-  return kSUCCESS;
-}
-
-ClassImp(CbmEcalReco2)
diff --git a/ecal/CbmEcalReco2.h b/ecal/CbmEcalReco2.h
deleted file mode 100644
index 791b08cc55e4ef5c89f3f720c254a360f4861ce8..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalReco2.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/** A (not so)slow version of reconstruction because of extensive
- ** Shower Library usage (ShLib implementation).
- ** This version rely on CbmEcalMaximum information for region calculation
- ** (This a little step forward concearning the architecture of code)
- ** April 2011 //Dr.Sys **/
-
-#ifndef CBMECALRECO2_H
-#define CBMECALRECO2_H
-
-#include "FairTask.h"
-#include "TString.h"
-
-#include "Minuit2/Minuit2Minimizer.h"
-#include "Math/IFunction.h"
-
-class TChain;
-class TClonesArray;
-class TTree;
-class CbmEcalStructure;
-class CbmEcalCell;
-class CbmEcalSCurveLib;
-class CbmEcalInf;
-class CbmEcalCluster;
-class CbmEcalShLib;
-class CbmEcalCalibration;
-class CbmEcalRecParticle;
-class CbmEcalPosLib;
-class CbmEcalMaximum;
-class TFormula;
-
-class FCNEcalCluster2 : public ROOT::Math::IBaseFunctionMultiDim
-{
-public:
- FCNEcalCluster2(CbmEcalCalibration* cal, CbmEcalShLib* shlib, TFormula** sigma, CbmEcalInf* inf)
-   : ROOT::Math::IBaseFunctionMultiDim(), fCal(cal), fShLib(shlib), fSigma(sigma), 
-    fInf(inf), fStr(NULL), fCluster(NULL), fEStep(1e-4), fCStep(1e-4), 
-    fErrorDef(1.0), fClusterEnergy(0.), fClusterResp(0.), fN(0), fCells(), 
-    fFixClusterEnergy(0), fNDF(0), fParam(0)
-    {};
-  
-  CbmEcalCluster* GetCluster() const {return fCluster;}
-  void SetCluster(CbmEcalCluster* cluster);
-  void SetStructure(CbmEcalStructure* str) {fStr=str;}
-
-  void SetParticleSeeds(const std::vector<CbmEcalCell*> cells) {fCells=cells;}
-
-  /** Get/Set number of photons in cluster **/
-  void SetN(Int_t n);
-  Int_t GetN() const {return fN;}
-
-  void SetNumParam(Int_t i) {fParam=i;}
-
-  /** Get/Set various steps **/
-  void SetEStep(Double_t step) {fEStep=step;}
-  void SetCStep(Double_t step) {fCStep=step;}
-  Double_t GetEStep() const {return fEStep;}
-  Double_t GetCStep() const {return fCStep;}
-  /** NDF of current fit **/
-  Int_t NDF() const {return fNDF;}
-
-  /** The chi2 stuff **/
-  /** par[n] --- energy, par[n+1] --- x, par[n+2] --- y **/
-  Double_t DoEval(const Double_t* x) const;
-
-  unsigned int NDim() const
-  {
-    return fParam;
-  }
-  
-  ROOT::Math::IBaseFunctionMultiDim* Clone() const
-    {
-      return new FCNEcalCluster2(fCal, fShLib, fSigma, fInf);
-    }
-
-  void SetFixClusterEnergy(Int_t fix) {fFixClusterEnergy=fix;}
-  Double_t ClusterEnergy() const {return fClusterEnergy;}
-
-  ~FCNEcalCluster2() {};
-private:
-  /** A calibration object **/
-  CbmEcalCalibration* fCal; 		//!
-  /** A shower library **/
-  CbmEcalShLib* fShLib;			//!
-  /** A sigma formula **/
-  TFormula** fSigma;			//!
-  /** Calorimeter information **/
-  CbmEcalInf* fInf;			//!
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;		//!
-  /** Calorimeter cluster **/
-  CbmEcalCluster* fCluster;		//!
-
-  /** Steps if gradient business **/
-  Double_t fEStep;
-  Double_t fCStep;
-  /** A stuff from FCNBase **/
-  Double_t fErrorDef;
-  /** Energy of cluster **/
-  Double_t fClusterEnergy;
-  /** Response of cluster **/
-  Double_t fClusterResp;
-  /** Number of photons in cluster **/
-  Int_t fN;
-  /** Seed cells of cluster **/
-  std::vector<CbmEcalCell*> fCells;	//!
-  /** Fix sum of energies of cluster particles to energy of cluster **/
-  Int_t fFixClusterEnergy;
-  /** NDF of fit **/
-  Int_t fNDF;
-  /** Number of parameters **/
-  Int_t fParam;
-
-  FCNEcalCluster2(const FCNEcalCluster2&);
-  FCNEcalCluster2& operator=(const FCNEcalCluster2&);
-};
-
-class CbmEcalReco2 : public FairTask
-{
-public:
-  /** Default constructor. Requirement of ROOT system **/
-  CbmEcalReco2();
-
-  /** Standard constructor **/
-  CbmEcalReco2(const char *name, const Int_t iVerbose=1, const char* configname="none");
-
-  /** Destructor **/
-  virtual ~CbmEcalReco2();
-
-  /** Init **/
-  virtual InitStatus Init();
-  virtual void Exec(Option_t* option);
-  virtual void Finish();
-
-  /** Tools for debugging **/
-  void SetOutToTree(Bool_t totree=kTRUE) {fToTree=totree;}
-  void SetRecoName(const char* name) {fRecoName=name;}
-  TString GetRecoName() const {return fRecoName;}
-  void SetStoreClusterInfo(Bool_t store) {fStoreClusterInfo=store;}
-private:
-  /** Reconstruct photon from maximum **/
-  void Reco(CbmEcalMaximum* max, CbmEcalCluster* clstr);
-  /** Reconstruct photon from maximum. PosLib instead of S-curves **/
-  void Reco2(CbmEcalMaximum* max, CbmEcalCluster* clstr);
-  /** Fit a given cluster. A first approximation should be available **/
-  void FitCluster(CbmEcalCluster* clstr);
-  /** Write a cluster info **/
-  void WriteClusterInfo(CbmEcalCluster* clstr);
-  /** Calculate a chi2 for just reconstructed photons **/
-  Double_t CalculateChi2(CbmEcalCluster* cluster);
-  /** Fit a cluster. A**/
-  Double_t FitCluster();
-  /** Reconstruct time for particle **/
-  void TimeReco(CbmEcalRecParticle* p, CbmEcalCluster* cluster);
-  /** Number of reconstructed tracks **/
-  Int_t fN;
-  Int_t fNOld;
-
-  CbmEcalCell** fMaximums;	//!
-  CbmEcalCell** fExcluded;	//!
-
-  /** Event number **/
-  Int_t fEventN;
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;	//!
-  /** An information about calorimeter **/
-  CbmEcalInf* fInf;		//!
-  /** S-curve library **/
-  CbmEcalSCurveLib* fLib;	//!
-  /** A position library **/
-  CbmEcalPosLib* fPosLib;	//!
-  /** A shower library **/
-  CbmEcalShLib* fShLib;		//!
-  /** A calibration of the calorimeter **/
-  CbmEcalCalibration* fCal;	//!
-
-  /** Array of reconstructed particles **/
-  TClonesArray* fReco;		//!
-  /** Array of clusters **/
-  TClonesArray* fClusters;	//!
-  /** Name of output tree **/
-  TString fRecoName;
-
-  /** A tool, to export reconstructed particles to file. Should be moved to
-   ** a separate task in future. For debugging now. **/
-  Bool_t fToTree;
-  TTree* fOutTree;		//!
-  Bool_t fStoreClusterInfo;
-  void CreateTree();
-  void FillTree();
-  Short_t fType;
-  Short_t fDiffType;
-  Double_t fE;
-  Double_t fE3x3;
-  Double_t fE2x2;
-  Double_t fEReco;
-  Double_t fXReco;
-  Double_t fYReco;
-  Double_t fECls;
-  Double_t fE2Cls;
-  Double_t fE3Cls;
-  Double_t fECluster;
-  Double_t fAX;
-  Double_t fAY;
-  Double_t fCellX;
-  Double_t fCellY;
-  Double_t fChi2;
-  Double_t fTheta[50];
-  Short_t fTypes[50];
-  Double_t fEmeas[50];
-  Double_t fEpred[50];
-  Double_t fChi2Fit[50];
-  Double_t fEfirst[50];
-  Double_t fChi2First[50];
-  Double_t fCX[50];
-  Double_t fCY[50];
-  Int_t fCMaxs;
-
-  /** Constants used in reconstruction **/
-  Double_t fC[10];
-  /** Definition of sigma used for chi^2 calculation **/
-  TFormula* fSigma[10];		//!
-  TString fParNames[14];	//!
-  TString fSigmaFormula[10];
-  Int_t fParOffset;
-  /** A threshold for chi^2. Is chi^2<fChi2Th no fitting **/
-  Double_t fChi2Th;
-  Double_t fEStep;
-  Double_t fCStep;
-  /** Maximum number of photons per cluster for reconstruction
-   ** If cluster contains more local maximums, it rejected. **/
-  Int_t fMaxPhotonsPerCluster;
-  /** Maximum number of iterations in fitting process **/
-  Int_t fMaxIterations;
-  /** Fix sum of energies of cluster particles to energy of cluster **/
-  Int_t fFixClusterEnergy;
-  /** A chi^2 and gradient function for cluster/particles **/
-  FCNEcalCluster2* fFCN;		//!
-  /** A fitter **/
-  ROOT::Minuit2::Minuit2Minimizer* fFitter;
-  /** Minimum energy of precluster maximum for consideration **/
-  Double_t fMinMaxE;
-  /** Use a position library instead of S-curves **/
-  Int_t fUsePosLib;
-
-  /** Energy deposition in precluster **/
-  Double_t fPreE;
-  CbmEcalMaximum* fCurrentMaximum;		//!
-
-  CbmEcalReco2(const CbmEcalReco2&);
-  CbmEcalReco2& operator=(const CbmEcalReco2&);
-
-  ClassDef(CbmEcalReco2, 1)
-};
-
-#endif
-
diff --git a/ecal/CbmEcalRecoCorr.cxx b/ecal/CbmEcalRecoCorr.cxx
deleted file mode 100644
index 7cc718d22a40488900b8639ea6eb13051e21c4c6..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalRecoCorr.cxx
+++ /dev/null
@@ -1,939 +0,0 @@
-#include "CbmEcalRecoCorr.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TVector3.h"
-
-#include "FairRootManager.h"
-#include "FairTrackParam.h"
-#include "FairLogger.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalSCurveLib.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalRecParticle.h"
-#include "CbmEcalCluster.h"
-#include "CbmEcalShLibCorr.h"
-#include "CbmEcalCalibration.h"
-#include "CbmEcalParam.h"
-#include "CbmEcalPosLib.h"
-
-#include "TMatrixD.h"
-#include "TMath.h"
-
-#include <iostream>
-
-using namespace std;
-
-void FCNEcalClusterCorr::SetCluster(CbmEcalCluster* cluster)
-{
-  Int_t i;
-
-  fCluster=cluster;
-
-  fClsCells.resize(fCluster->Size());
-  for(i=0;i<fCluster->Size();i++)
-    fClsCells[i]=fStr->GetHitCell(fCluster->CellNum(i));
-
-  SetN(fCluster->Maxs());
-  fClusterResp=fCluster->Energy();
-  fClusterEnergy=fCal->GetEnergy(fClusterResp, fStr->GetHitCell(cluster->PeakNum(0)));
-}
-
-void FCNEcalClusterCorr::SetN(Int_t n)
-{
-//  Int_t i;
-  fN=n;
-  fNDF=fCluster->Size()-(n*3-fFixClusterEnergy);
-}
-
-Double_t FCNEcalClusterCorr::Correlation(CbmEcalCell* c1, CbmEcalCell* c2, Double_t x, Double_t y, Double_t phi, Double_t theta, Double_t e) const
-{
-  if (c1->GetType()==c2->GetType())
-    return fShLib->Correlation(c1->X1()-x, c1->Y1()-y, c2->X1()-x, c2->Y1()-y, phi, theta, e, c1);
-  if (c1->GetType()>c2->GetType())
-    return fShLib->Correlation2(c1->X1()-x, c1->Y1()-y, c2->X1()-x, c2->Y1()-y, phi, theta, e, c1->GetType());
-  else
-    return fShLib->Correlation2(c2->X1()-x, c2->Y1()-y, c1->X1()-x, c1->Y1()-y, phi, theta, e, c2->GetType());
-}
-
-Double_t FCNEcalClusterCorr::DoEval(const Double_t* par) const
-{
-//  if (par.size()!=fN*3)
-//    Fatal("()", "Size of input vector is wrong (%d, should be %d)!", par.size(), fN*3);
-  Int_t s=fCluster->Size();
-  TMatrixD m(s, s);
-  Int_t i;
-  Int_t j;
-  Int_t k;
-  Double_t t;
-  Double_t det[10];
-  Double_t chi2=0;
-  Double_t de[30];
-  /** Energy and coordinates of reconstructing particle **/
-  Double_t e[6];
-  Double_t x[6];
-  Double_t y[6];
-  Double_t theta[6];
-  Double_t phi[6];
-
-  // Extract photons energy from the parameters
-  if (fFixClusterEnergy==0)
-    for(i=0;i<fN;i++)
-      e[i]=par[3*i];
-  else
-  {
-    t=fClusterEnergy;
-    for(i=0;i<fN-1;i++)
-    {
-      e[i]=par[3*i+2]*t;
-      t-=e[i];
-      if (t<0) t=0;
-    }
-    e[i]=t;
-  }
-  
-  // Extract coordinates and angles 
-  for(i=0;i<fN;i++)
-  {
-    x[i]=par[3*i+1-fFixClusterEnergy];
-    y[i]=par[3*i+2-fFixClusterEnergy];
-    t=TMath::Sqrt(x[i]*x[i]+y[i]*y[i]);
-
-    theta[i]=TMath::ATan(t/fInf->GetZPos());
-    theta[i]*=TMath::RadToDeg();
-    phi[i]=TMath::ACos(x[i]/t)*TMath::RadToDeg();
-    if (y[i]<0) phi[i]=360.0-phi[i];
-  }
-
-  // Calculate covariance matrix
-  for(i=0;i<s;i++)
-  for(j=0;j<s;j++)
-  {
-    m[i][j]=0.0;
-    for(k=0;k<fN;k++)
-    {
-      m[i][j]+=Correlation(fClsCells[i], fClsCells[j], x[k], y[k], phi[k], theta[k], e[k]);
-    }
-  }
-  //Some magic numbers: TODO?
-  for(i=0;i<s;i++)
-  {
-    if (m[i][i]<1e-8*fClusterEnergy) m[i][i]=1e-8*fClusterEnergy;
-//    if (fClsCells[i]->GetType()==2&&m[i][j]<1e-10) m[i][j]=1e-10;    
-//    if (fClsCells[i]->GetType()==4&&m[i][j]<1e-15) m[i][j]=1e-15;    
-  }
-
-  // Inversion
-  m.Invert(det);
-
-  // Energy difference calculation
-  for(i=0;i<s;i++)
-  {
-    de[i]=fClsCells[i]->GetTotalEnergy();
-    for(k=0;k<fN;k++)
-      de[i]-=fShLib->GetResponse(fClsCells[i]->X1()-x[k], fClsCells[i]->Y1()-y[k], phi[k], theta[k], e[k], fClsCells[i]);
-  }
-
-  // Chi2 calculation
-  for(i=0;i<s;i++)
-  for(j=0;j<s;j++)
-    chi2+=de[i]*de[j]*m[i][j];
-
-  return chi2;
-}
-
-/***************************************************************************/
-
-void CbmEcalRecoCorr::Exec(Option_t*)
-{
-  Int_t i;
-  Int_t n=fClusters->GetEntriesFast();
-  CbmEcalCluster* cluster;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t chi2;
-  CbmEcalCell* cell;
-  Int_t j;
-
-  fN=0;
-  fReco->Delete();
-  if (fToTree&&fOutTree==NULL)
-    CreateTree();
-  fEventN++;
-  if (fVerbose>0) 
-    Info("Exec", "Event %d, %d clusters in event.", fEventN, n);
-  for(i=0;i<n;i++)
-  {
-    fNOld=fN;
-    cluster=(CbmEcalCluster*)fClusters->At(i);
-    if (cluster->Maxs()>fMaxPhotonsPerCluster)
-      continue;
-//    cout << cluster->Maxs() << endl;
-    for(j=0;j<cluster->Maxs();j++)
-    {
-      cell=fStr->GetHitCell(cluster->CellNum(j));
-      fPreE=cluster->PreEnergy(j);
-      if (fCal->GetEnergy(cell->GetTotalEnergy(), cell)>fMinMaxE)
-        Reco(cell, cluster);
-    }
-    chi2=CalculateChi2(cluster);
-    if (chi2>fChi2Th)
-      FitCluster(cluster);
-    if (fStoreClusterInfo)
-      WriteClusterInfo(cluster);
-    if (fOutTree)
-      FillTree();
-  }
-  if (fVerbose>1)
-    Info("Exec", "%d photons reconstructed in calorimeter.", fN);
-}
-
-/** Write a cluster info **/
-void CbmEcalRecoCorr::WriteClusterInfo(CbmEcalCluster* clstr)
-{
-  list<CbmEcalCell*>::const_iterator p;  
-  CbmEcalCell* cell;
-  CbmEcalRecParticle* part;
-  Int_t i=0;
-  Int_t j;
-  Int_t k;
-  Double_t celle;
-//  Double_t cellsize;
-  Double_t e[3];
-  Double_t x=-1111;
-  Double_t y=-1111;
-  Double_t r;
-  Double_t theta;
-  Double_t phi;
-  CbmEcalCell* cl;
-  Double_t cx;
-  Double_t cy;
-  Double_t de;
-//  Double_t epred;
-//  Double_t emeas;
-//  Double_t clenergy;
-  Double_t cellerr=-1111;
-//  static Double_t module=fInf->GetModuleSize();
-
-  fECluster=fCal->GetEnergy(clstr->Energy(), fStr->GetHitCell(clstr->PeakNum(0)));
-//  clenergy=fECluster;
-  for(k=0;k<clstr->Size();k++)
-  {
-    cell=fStr->GetHitCell(clstr->CellNum(k));
-    e[i++]=cell->GetTotalEnergy();
-    if (i==3) break;
-  }
-  fCMaxs=clstr->Maxs();
-  fECls=e[0]/clstr->Energy();
-  fE2Cls=(e[0]+e[1])/clstr->Energy();
-  fE3Cls=(e[0]+e[1]+e[2])/clstr->Energy();
-  i=0;
-
-  for(k=0;k<clstr->Size();k++)
-  {
-    cell=fStr->GetHitCell(clstr->CellNum(k));
-    fTypes[i]=cell->GetType();
- //   cellsize=module/fTypes[i];
-    celle=0;
-    for(j=fNOld;j<fN;j++)
-    {
-      part=(CbmEcalRecParticle*)fReco->At(j);
-      cl=fStr->GetHitCell(part->CellNum()); cx=cl->GetCenterX(); cy=cl->GetCenterY(); 
-      x=cell->GetCenterX(); x-=part->X(); // x-=cx; 
-      y=cell->GetCenterY(); y-=part->Y(); // y-=cy; 
-
-      r=TMath::Sqrt(cx*cx+cy*cy);
-
-      /** TODO: should be Z of the cell**/
-      theta=TMath::ATan(r/fInf->GetZPos());
-      theta*=TMath::RadToDeg();
-      phi=TMath::ACos(cx/r)*TMath::RadToDeg();
-      if (cy<0) phi=360.0-phi;
-
-      celle+=fShLib->GetResponse(x, y, phi, theta, part->E(), fTypes[i]);
-    }
-    de=fCal->GetEnergy(celle, cell)-fCal->GetEnergy(cell->GetTotalEnergy(), cell);
-    cx=cell->GetCenterX(); cy=cell->GetCenterY();
-    r=TMath::Sqrt(cx*cx+cy*cy);
-    theta=TMath::ATan(r/fInf->GetZPos());
-
-//    epred=fCal->GetEnergy(celle, cell);
-//    emeas=fCal->GetEnergy(cell->GetTotalEnergy(), cell);
-    de*=de; fChi2Fit[i]=de/cellerr;
-
-    cx=cell->GetCenterX(); cy=cell->GetCenterY();
-    r=TMath::Sqrt(cx*cx+cy*cy);
-    fTheta[i]=TMath::ATan(r/fInf->GetZPos());
-    fEpred[i]=fCal->GetEnergy(celle, cell);
-    fEmeas[i]=fCal->GetEnergy(cell->GetTotalEnergy(), cell);
-    fCX[i]=cell->GetCenterX();
-    fCY[i]=cell->GetCenterY();
-    i++;
-  }
-  for(j=i;j<50;j++)
-    fTypes[j]=-1111;
-}
-
-void CbmEcalRecoCorr::FillTree()
-{
-  Int_t n=fN-fNOld;
-  CbmEcalRecParticle* p;
-  Int_t i;
-
-  for(i=0;i<n;i++)
-  {
-    p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-    fChi2=p->Chi2();
-    fEReco=p->E();
-    fXReco=p->X();
-    fYReco=p->Y();
-    fOutTree->Fill();
-  }
-
-}
-
-/** Fit a given cluster. A first approximation should be available **/
-void CbmEcalRecoCorr::FitCluster(CbmEcalCluster* clstr)
-{
-  vector<CbmEcalCell*> cells(fN-fNOld);
-  Int_t i;
-  Int_t n=fN-fNOld;
-  Int_t ret;
-  Double_t oldchi2=clstr->Chi2();
-  Double_t e;
-  Double_t pe[6];
-  CbmEcalRecParticle* p;
-  TString par;
-  TVector3 tv;
-
-  if (n>6)
-  {
-    Info("FitCluster", "Give up fitting the cluster with %d maximums. ", n);
-    return;
-  }
-
-  fFCN->SetCluster(clstr);
-  // The cluster it self  doesn't care about amplitude of maximums 
-
-  fFCN->SetN(n);
-
-  Int_t params=0;
-
-  e=0;
-  for(i=0;i<n;i++)
-  {
-    p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-    e+=p->E();
-  }
-
-  fFCN->SetClusterEnergy(e);
-  fFitter->Clear();
-  fFitter->SetPrintLevel(-1);
-  fFitter->SetMaxIterations(fMaxIterations);
-
-  if (fFixClusterEnergy==0) {
-    for(i=0;i<n;i++) {
-      p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-      cells[i]=fStr->GetHitCell(p->CellNum());
-      par="e"; par+=i; 
-      fFitter->SetVariable(i*3   ,par.Data(), p->E(), 0.01*p->E());
-      fFitter->SetVariableLimits(i*3, p->E()*0.2, p->E()*2.0);
-      params++;
-      par="x"; par+=i; 
-      fFitter->SetVariable(i*3+1 ,par.Data(), p->X(), 0.1);
-      fFitter->SetVariableLimits(i*3+1, p->X()-9., p->X()+9.);
-      params++;
-      par="y"; par+=i; 
-      fFitter->SetVariable(i*3+2 ,par.Data(), p->Y(), 0.1);
-      fFitter->SetVariableLimits(i*3+2, p->Y()-9., p->Y()+9.);
-      params++;
-    } 
-  } else {
-    e=0;
-    for(i=0;i<n;i++) {
-      p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-      pe[i]=p->E(); e+=pe[i];
-    }
-    for(i=0;i<n;i++) {
-      p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-      cells[i]=fStr->GetHitCell(p->CellNum());
-      par="x"; par+=i; 
-      fFitter->SetVariable(i*3 ,par.Data(), p->X(), 0.1);
-      fFitter->SetVariableLimits(i*3,p->X()-9., p->X()+9.);
-      params++;
-      par="y"; par+=i; 
-      fFitter->SetVariable(i*3+1 ,par.Data(), p->Y(), 0.1);
-      fFitter->SetVariableLimits(i*3+1, p->Y()-9., p->Y()+9.);
-      if (i!=n-1) {
-        par="n";
-	par+=i;
-	fFitter->SetVariable(i*3+2 ,par.Data(), p->E()/e, 0.005);
-	fFitter->SetVariableLimits(i*3+2, 0.0, 1.0);
-      }
-      e-=p->E();
-    }
-
-  }
-
-  fFCN->SetNumParam(params);
-  fFCN->SetParticleSeeds(cells);
-
-  fFitter->SetFunction(*fFCN);
-  ret=fFitter->Minimize();
-
-  Double_t chi2=fFitter->MinValue();
-
-  if (ret!=0&&fVerbose>1)
-  {
-    Info("FitCluster", "Minimization failed! Last chi2 %f, old chi2 %f.", chi2, oldchi2);
-  }
-
-//  cout << "chi2=" << chi2 << ", NDF=" << fFCN->NDF() << endl;
-  //TODO: A temporary comment
-  if (fFCN->NDF()>0)
-    chi2/=fFCN->NDF();
-  else
-    chi2=-chi2;
-
-  clstr->fChi2=chi2;
-
-
-  e=fFCN->ClusterEnergy();
-
-  // get the fit parameters from Minuit
-  const double *fitResult = fFitter->X();
-
-  for(i=0;i<n;i++) {
-    p=(CbmEcalRecParticle*)fReco->At(i+fNOld);
-    p->fX=fitResult[i*3+1-fFixClusterEnergy];
-    p->fY=fitResult[i*3+2-fFixClusterEnergy];
-    LOG(debug2) << "fitResult[" << i*3+1-fFixClusterEnergy << "]: " << fitResult[i*3+1-fFixClusterEnergy];
-    LOG(debug2) << "fitResult[" << i*3+2-fFixClusterEnergy << "]: " << fitResult[i*3+2-fFixClusterEnergy];
-    if (fFixClusterEnergy) {
-      if (i!=n-1) {
-        p->fE=fitResult[i*3+2]*e;
-	LOG(debug2) << "fitResult[" << i*3+2 << "]: " << fitResult[i*3+2];
-	e-=p->fE;
-      } else {
- 	p->fE=e;
-      }
-    } else {
-      p->fE=fitResult[i*3];
-	LOG(debug2) << "fitResult[" << i*3 << "]: " << fitResult[i*3];
-    }
-
-    tv.SetXYZ(p->fX, p->fY, fInf->GetZPos());
-    tv*=p->fE/tv.Mag();
-    p->fPx=tv.X();
-    p->fPy=tv.Y();
-    p->fPz=tv.Z();
-    p->fChi2=chi2;
-  }
-//  cout << " ----------------------------------------------------------- " << endl;
-//  if (TMath::Abs(chi2)>10)
-    CalculateChi2(clstr);
-}
-
-/** Calculate a chi2 for just reconstructed photons **/
-Double_t CbmEcalRecoCorr::CalculateChi2(CbmEcalCluster* cluster)
-{
-  if (!fShLib) return -1111;
-
-  Int_t s=cluster->Size();
-  TMatrixD m(s, s);
-  Int_t i;
-  Int_t j;
-  Int_t k;
-  Double_t t;
-  Double_t det[10];
-  Double_t chi2=0;
-  Double_t de[30];
-  /** Energy and coordinates of reconstructing particle **/
-  Double_t e[6];
-  Double_t et=0;
-  Double_t x[6];
-  Double_t y[6];
-  Double_t theta[6];
-  Double_t phi[6];
-  CbmEcalRecParticle* part;
-  vector<CbmEcalCell*> clscells(s);
-  Int_t ndf=s-((fN-fNOld)*3-fFixClusterEnergy);
-
-//  cout << "Cell codes:";
-  // Copy cluster to a vector
-  for(i=0;i<s;i++)
-  {
-    clscells[i]=fStr->GetHitCell(cluster->CellNum(i));
-//    cout << (Int_t)clscells[i]->GetType();
-  }
-//  cout << endl;
-
-  // Extract photons energy from the parameters
-  // Extract coordinates and angles 
-  for(i=0;i<fN-fNOld;i++)
-  {
-    part=(CbmEcalRecParticle*)fReco->At(i);
-    e[i]=part->E(); et+=e[i];
-    x[i]=part->X();
-    y[i]=part->Y();
-    t=TMath::Sqrt(x[i]*x[i]+y[i]*y[i]);
-
-    theta[i]=TMath::ATan(t/fInf->GetZPos());
-    theta[i]*=TMath::RadToDeg();
-    phi[i]=TMath::ACos(x[i]/t)*TMath::RadToDeg();
-    if (y[i]<0) phi[i]=360.0-phi[i];
-//    cout << "(" << x[i] << ", " << y[i] << "): " << phi[i] << " and " << theta[i] << endl;
-  }
-
-  // Calculate covariance matrix
-  for(i=0;i<s;i++)
-  for(j=0;j<s;j++)
-  {
-    m[i][j]=0.0;
-    for(k=0;k<fN-fNOld;k++)
-    {
-      m[i][j]+=fFCN->Correlation(clscells[i], clscells[j], x[k], y[k], phi[k], theta[k], e[k]);
-//      cout << "Corr(" << x[k] << "," << y[k] << ",phi:" << phi[k];
-//      cout << ",theta:" << theta[k] << ",e:" << e[k];
-//      cout << ")=" << fFCN->Correlation(clscells[i], clscells[j], x[k], y[k], phi[k], theta[k], e[k])*1e6 << ":" << i << ";" << j << endl;
-    };
-  }
-  //Some magic numbers: TODO?
-  for(i=0;i<s;i++)
-  {
-    if (m[i][i]<1e-8*et) m[i][i]=1e-8*et;
-//    if (clscells[i]->GetType()==2&&m[i][i]<1e-10) m[i][i]=1e-10;    
-//    if (clscells[i]->GetType()==4&&m[i][i]<1e-15) m[i][i]=1e-15;    
-  }
-
-  // Inversion
-//  m.Print();
-  m.Invert(det);
-//  m.Print();
-  // Energy difference calculation
-  for(i=0;i<s;i++)
-  {
-    de[i]=clscells[i]->GetTotalEnergy();
-    for(k=0;k<fN-fNOld;k++)
-    {
-      de[i]-=fShLib->GetResponse(clscells[i]->X1()-x[k], clscells[i]->Y1()-y[k], phi[k], theta[k], e[k], clscells[i]);
-//      cout << "Energy(" << x[k] << "," << y[k] << ",phi:" << phi[k] << ",theta";
-//      cout << theta[k] << ",e:" << e[k] << ")=";
-//      cout << fShLib->GetResponse(clscells[i]->X1()-x[k], clscells[i]->Y1()-y[k], phi[k], theta[k], e[k], clscells[i]) << endl;
-    }
-  }
-
-  // Chi2 calculation
-  for(i=0;i<s;i++)
-  for(j=0;j<s;j++)
-    chi2+=de[i]*de[j]*m[i][j];
-
-  return chi2/ndf;
-}
-
-/** Get first approximation of photon parameters from maximum **/
-void CbmEcalRecoCorr::Reco(CbmEcalCell* cell, CbmEcalCluster* clstr)
-{
-  if (fLib==NULL)
-  {
-    Reco2(cell, clstr);
-    return;
-  }
-  Double_t x;
-  Double_t y;
-  Double_t z;
-  Double_t amp;
-  Double_t en;
-  Double_t maxe;
-  Double_t px;
-  Double_t py;
-  Double_t pz;
-  Int_t type;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Int_t cnum=0;
-
-  cells.clear();
-
-  fType=cell->GetType();
-  fDiffType=0;
-
-  cell->GetNeighborsList(0,cells);
-  fE=cell->GetEnergy();
-  en=cell->GetEnergy();
-  type=cell->GetType();
-  fAX=0; fAY=0;
-  for(p=cells.begin();p!=cells.end();++p) 
-  {
-    if (type!=(*p)->GetType())
-    {
-      type=-1111;
-      fDiffType=1;
-    }
-    if (cell->GetX2()+0.001<(*p)->GetCenterX())
-      fAX+=(*p)->GetEnergy();
-    else
-    if (cell->GetX1()-0.001>(*p)->GetCenterX())
-      fAX-=(*p)->GetEnergy();
-    if (cell->GetY2()+0.001<(*p)->GetCenterY())
-      fAY+=(*p)->GetEnergy();
-    else
-    if (cell->GetY1()-0.001>(*p)->GetCenterY())
-      fAY-=(*p)->GetEnergy();
-    en+=(*p)->GetEnergy();
-  }
-  fE3x3=en;
-
-  if (fAX!=-1111)
-  {
-    fAX/=fE3x3;
-    fAY/=fE3x3;
-  }
-
-  maxe=0;
-  for(Int_t i=1;i<5;i++)
-  {
-    cell->GetNeighborsList(i,cells);
-    en=cell->GetEnergy();
-    for(p=cells.begin();p!=cells.end();++p) 
-      en+=(*p)->GetEnergy();
-    if (maxe<en)
-    {
-      maxe=en;
-      cnum=i;
-    }
-  }
-  cell->GetNeighborsList(cnum, cells);
-  cells.push_back(cell);
-  fE2x2=maxe;
-
-  fCellX=cell->GetCenterX();
-  fCellY=cell->GetCenterY();
-  
-  if (fCal->GetEnergy(fE2x2, cell)<0.1) return; 
-  fEReco=fCal->GetEnergy(fE2x2, cell);
-  if (fAX!=-1111)
-    fXReco=fLib->GetX(fAX, fEReco, cell);
-  else
-    fXReco=-1111;
-  if (fXReco!=-1111)
-    fXReco+=cell->GetCenterX();
-  
-  if (fAY!=-1111)
-    fYReco=fLib->GetY(fAY, fEReco, cell);
-  else
-    fYReco=-1111;
-  
-  if (fYReco!=-1111)
-    fYReco+=cell->GetCenterY();
-  if (fXReco!=-1111)
-    x=fXReco;
-  else
-    x=cell->GetCenterX();
-  if (fYReco!=-1111)
-    y=fYReco;
-  else
-    y=cell->GetCenterY();
-  z=fInf->GetZPos();
-  amp=TMath::Sqrt(x*x+y*y+z*z);
-  px=fEReco*x/amp;
-  py=fEReco*y/amp;
-  pz=fEReco*z/amp;
-//  cout << fAX << " --- " << fAY << endl;
-//  cout << fXReco << " and " << fYReco << endl;
-  new((*fReco)[fN++]) CbmEcalRecParticle(px, py, pz, fEReco, x, y, z, 22, -1111, clstr, cell, fType);
-}
-
-/** Get first approximation of photon parameters from maximum
- ** This version uses PosLib instead of S-curves
- ** TODO Architecture: Need a maximum, instead of cell here **/
-void CbmEcalRecoCorr::Reco2(CbmEcalCell* cell, CbmEcalCluster* clstr)
-{
-  if (fPosLib==NULL)
-    Fatal("Reco2", "No position library for reconstruction.");
-
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Double_t px;
-  Double_t py;
-  Double_t pz;
-  Double_t amp;
-  Double_t x=-1111;
-  Double_t y=-1111;
-  Double_t z=-1111;
-  Double_t t;
-
-  t=TMath::Sqrt(x*x+y*y);
-  fEReco=fCal->GetEnergy(fPreE, t/z, fRegion);
-  z=fInf->GetZPos();
-  amp=TMath::Sqrt(x*x+y*y+z*z);
-  px=fEReco*x/amp;
-  py=fEReco*y/amp;
-  pz=fEReco*z/amp;
-  new((*fReco)[fN++]) CbmEcalRecParticle(px, py, pz, fEReco, x, y, z, 22, -1111, clstr, cell, fType);
-
-}
-void CbmEcalRecoCorr::CreateTree()
-{
-  fOutTree=new TTree("reco_corr", "Reconstruction by fitting with shower library (correlations are in)");
-  fOutTree->Branch("ev", &fEventN, "ev/I");
-  fOutTree->Branch("type", &fType, "type/S");
-  fOutTree->Branch("difftype", &fDiffType, "difftype/S");
-  fOutTree->Branch("x", &fXReco, "x/D");
-  fOutTree->Branch("y", &fYReco, "y/D");
-  fOutTree->Branch("e", &fEReco, "e/D");
-  fOutTree->Branch("chi2", &fChi2, "chi2/D");
-  fOutTree->Branch("ecluster", &fECluster, "ecluster/D");
-  if (fStoreClusterInfo==kFALSE) return;
-  fOutTree->Branch("cls_e", &fECls, "cls_e/D");
-  fOutTree->Branch("cls_e2", &fE2Cls, "cls_e2/D");
-  fOutTree->Branch("cls_e3", &fE3Cls, "cls_e3/D");
-  fOutTree->Branch("theta", fTheta, "theta[50]/D");
-  fOutTree->Branch("ctypes", fTypes, "ctypes[50]/S");
-  fOutTree->Branch("cemeas", fEmeas, "cemeas[50]/D");
-  fOutTree->Branch("cepred", fEpred, "cepred[50]/D");
-  fOutTree->Branch("cchi2", fChi2Fit, "cchi2[50]/D");
-  fOutTree->Branch("cefirst", fEfirst, "cefirst[50]/D");
-  fOutTree->Branch("cchi2first", fChi2First, "cchi2first[50]/D");
-  fOutTree->Branch("cx", fCX, "cx[50]/D");
-  fOutTree->Branch("cy", fCY, "cy[50]/D");
-  fOutTree->Branch("cmaxs", &fCMaxs, "cmaxs/I");
-}
-
-/** Default constructor. Requirement of ROOT system **/
-CbmEcalRecoCorr::CbmEcalRecoCorr() 
-  : FairTask(),
-    fN(0),
-    fNOld(0),
-    fMaximums(NULL),
-    fExcluded(NULL),
-    fEventN(0),
-    fStr(NULL),
-    fInf(NULL),
-    fLib(NULL),
-    fPosLib(NULL),
-    fShLib(NULL),
-    fCal(NULL),
-    fTracks(NULL),
-    fReco(NULL),
-    fClusters(NULL),
-    fRecoName(""),
-    fToTree(kFALSE),
-    fOutTree(NULL),
-    fStoreClusterInfo(kFALSE),
-    fType(0),
-    fDiffType(0),
-    fE(0.),
-    fE3x3(0.),
-    fE2x2(0.),
-    fEReco(0.),
-    fXReco(0.),
-    fYReco(0.),
-    fECls(0.),
-    fE2Cls(0.),
-    fE3Cls(0.),
-    fECluster(0.),
-    fAX(0.),
-    fAY(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fChi2(0.),
-    fTheta(),
-    fTypes(),
-    fEmeas(),
-    fEpred(),
-    fChi2Fit(),
-    fEfirst(),
-    fChi2First(),
-    fCX(),
-    fCY(),
-    fCMaxs(0),
-    fChi2Th(0.),
-    fEStep(0.),
-    fCStep(0.),
-    fMaxPhotonsPerCluster(0),
-    fMaxIterations(0),
-    fFixClusterEnergy(0),
-    fFCN(NULL),
-    fFitter(NULL),
-    fMinMaxE(0.),
-    fUsePosLib(0),
-    fPreE(0.),
-    fRegion(0)
-{
-}
-
-/** Standard constructor **/
-CbmEcalRecoCorr::CbmEcalRecoCorr(const char *name, const Int_t iVerbose, const char* configname)
-  : FairTask(name, iVerbose),
-    fN(0),
-    fNOld(0),
-    fMaximums(NULL),
-    fExcluded(NULL),
-    fEventN(0),
-    fStr(NULL),
-    fInf(NULL),
-    fLib(NULL),
-    fPosLib(NULL),
-    fShLib(NULL),
-    fCal(NULL),
-    fTracks(NULL),
-    fReco(NULL),
-    fClusters(NULL),
-    fRecoName("EcalReco"),
-    fToTree(kFALSE),
-    fOutTree(NULL),
-    fStoreClusterInfo(kFALSE),
-    fType(0),
-    fDiffType(0),
-    fE(0.),
-    fE3x3(0.),
-    fE2x2(0.),
-    fEReco(0.),
-    fXReco(0.),
-    fYReco(0.),
-    fECls(0.),
-    fE2Cls(0.),
-    fE3Cls(0.),
-    fECluster(0.),
-    fAX(0.),
-    fAY(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fChi2(0.),
-    fTheta(),
-    fTypes(),
-    fEmeas(),
-    fEpred(),
-    fChi2Fit(),
-    fEfirst(),
-    fChi2First(),
-    fCX(),
-    fCY(),
-    fCMaxs(0),
-    fChi2Th(0.),
-    fEStep(0.),
-    fCStep(0.),
-    fMaxPhotonsPerCluster(0),
-    fMaxIterations(0),
-    fFixClusterEnergy(0),
-    fFCN(NULL),
-    fFitter(NULL),
-    fMinMaxE(0.),
-    fUsePosLib(0),
-    fPreE(0.),
-    fRegion(0)
-{
-//  Int_t i;
-//  Int_t j;
-//  Int_t types;
-//  Int_t consts;
-  TString nm;
-
-  CbmEcalParam* par=new CbmEcalParam("RecoSlowParam", configname);
-
-  fChi2Th=par->GetDouble("chi2th");
-  fEStep=par->GetDouble("estep");
-  fCStep=par->GetDouble("cstep");
-  fMaxIterations=par->GetInteger("maxiterations");
-  fFixClusterEnergy=par->GetInteger("fixclusterenergy");
-  fMaxPhotonsPerCluster=par->GetInteger("maxphotonspercluster");
-  fMinMaxE=par->GetDouble("minmaxe");
-  fUsePosLib=par->GetInteger("useposlib");
-
-  Info("Constructor", "chi2 threshold is %f, Estep is %f, and Cstep is %f.", fChi2Th, fEStep, fCStep);
-
-  delete par;
-}
-
-CbmEcalRecoCorr::~CbmEcalRecoCorr()
-{
-  fReco->Delete();
-  delete fReco;
-}
-
-void CbmEcalRecoCorr::Finish()
-{
-  if (fOutTree) fOutTree->Write();
-}
-
-/** Init **/
-InitStatus CbmEcalRecoCorr::Init()
-{
-  fEventN=0;
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fInf=fStr->GetEcalInf();
-  fTracks=(TClonesArray*)io->GetObject("EcalTrackParam");
-  if (!fTracks)
-  {
-    Fatal("Init", "Can't find EcalTrackParam.");
-    return kFATAL;
-  }
-  fClusters=(TClonesArray*)io->GetObject("EcalClusters");
-  if (!fClusters)
-  {
-    Fatal("Init", "Can't find EcalClusters");
-    return kFATAL;
-  }
-  fCal=(CbmEcalCalibration*)io->GetObject("EcalCalibration");
-  if (!fCal)
-  {
-    Fatal("Init", "Can't find EcalCalibration");
-    return kFATAL;
-  }
-
-  if (fUsePosLib==0)
-  {
-    fLib=(CbmEcalSCurveLib*)io->GetObject("EcalSCurveLib");
-    if (!fLib)
-    {
-      Fatal("Init", "Can't find EcalSCurveLib");
-      return kFATAL;
-    }
-    fPosLib=NULL;
-  }
-  else
-  {
-    fPosLib=(CbmEcalPosLib*)io->GetObject("EcalPosition");
-    if (!fPosLib)
-    {
-      Fatal("Init", "Can't find EcalSCurveLib");
-      return kFATAL;
-    }
-    fLib=NULL;
-  }
-
-  fShLib=(CbmEcalShLibCorr*)io->GetObject("EcalShLib");
-  if (!fShLib)
-  {
-    Fatal("Init", "No shower library found in system. Will continue without chi2 calculation.");
-    return kFATAL;
-  }
-  fReco=new TClonesArray("CbmEcalRecParticle", 2000);
-  io->Register(fRecoName, "ECAL", fReco, IsOutputBranchPersistent(fRecoName));
-
-  fFCN=new FCNEcalClusterCorr(fCal, fShLib, fInf);
-  fFCN->SetEStep(fEStep);
-  fFCN->SetCStep(fCStep);
-  fFCN->SetFixClusterEnergy(fFixClusterEnergy);
-  fFCN->SetStructure(fStr);
-  fFitter=new ROOT::Minuit2::Minuit2Minimizer();
-  fFitter->SetPrintLevel(-1);
-  fFitter->SetMaxIterations(fMaxIterations);
-
-  return kSUCCESS;
-}
-
-ClassImp(CbmEcalRecoCorr)
diff --git a/ecal/CbmEcalRecoCorr.h b/ecal/CbmEcalRecoCorr.h
deleted file mode 100644
index cf3d02d33d43af3adfd8a1f7f6546d82d08a6552..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalRecoCorr.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/** Reconstruction taking care of correlations.
- ** A special showe lib (CbmEcalShLibCorr) required
- ** Can be used for data production.
- ** The tracks array can be imported from ROOT file. (see CbmEcalTrackExport. )
- ** The output can be exported to tree. 
- ** //Dr.Sys **/
-
-#ifndef CBMECALRECOCORR_H
-#define CBMECALRECOCORR_H
-
-#include "FairTask.h"
-#include "TString.h"
-
-#include "Math/IFunction.h"
-#include "Minuit2/Minuit2Minimizer.h"
-
-class TChain;
-class TClonesArray;
-class TTree;
-class CbmEcalStructure;
-class CbmEcalCell;
-class CbmEcalSCurveLib;
-class CbmEcalInf;
-class CbmEcalCluster;
-class CbmEcalShLibCorr;
-class CbmEcalCalibration;
-class CbmEcalRecParticle;
-class CbmEcalPosLib;
-
-class FCNEcalClusterCorr : public ROOT::Math::IBaseFunctionMultiDim
-{
-public:
-  FCNEcalClusterCorr(CbmEcalCalibration* cal, CbmEcalShLibCorr* shlib, CbmEcalInf* inf)
-    : ROOT::Math::IBaseFunctionMultiDim (), fCal(cal), fShLib(shlib), fInf(inf), fStr(NULL),
-    fCluster(NULL), fEStep(1e-4), fCStep(1e-4), fErrorDef(1.0), 
-    fClusterEnergy(0.), fClusterResp(0.), fN(0), fCells(), fClsCells(),
-    fFixClusterEnergy(0), fNDF(0), fParam(0)
-    {};
-  
-  CbmEcalCluster* GetCluster() const {return fCluster;}
-  void SetCluster(CbmEcalCluster* cluster);
-  void SetClusterEnergy(Double_t en) {fClusterEnergy=en;}
-  void SetStructure(CbmEcalStructure* str) {fStr=str;}
-
-  void SetParticleSeeds(const std::vector<CbmEcalCell*> cells) {fCells=cells;}
-
-  /** Get/Set number of photons in cluster **/
-  void SetN(Int_t n);
-  Int_t GetN() const {return fN;}
-
-  void SetNumParam(Int_t i) {fParam=i;}
-
-  /** Get/Set various steps **/
-  void SetEStep(Double_t step) {fEStep=step;}
-  void SetCStep(Double_t step) {fCStep=step;}
-  Double_t GetEStep() const {return fEStep;}
-  Double_t GetCStep() const {return fCStep;}
-  /** NDF of current fit **/
-  Int_t NDF() const {return fNDF;}
-
-  /** The chi2 stuff **/
-  /** par[n] --- energy, par[n+1] --- x, par[n+2] --- y **/
-  Double_t DoEval(const Double_t* x) const;
-
-  unsigned int NDim() const
-  {
-    return fParam;
-  }
-  
-  ROOT::Math::IBaseFunctionMultiDim* Clone() const
-    {
-      return new FCNEcalClusterCorr(fCal, fShLib, fInf);
-    }
-
-  void SetFixClusterEnergy(Int_t fix) {fFixClusterEnergy=fix;}
-  Double_t ClusterEnergy() const {return fClusterEnergy;}
-  Double_t Correlation(CbmEcalCell* c1, CbmEcalCell* c2, Double_t x, Double_t y, Double_t phi, Double_t theta, Double_t e) const;
-
-  ~FCNEcalClusterCorr() {};
-private:
-  /** A calibration object **/
-  CbmEcalCalibration* fCal; 		//!
-  /** A shower library **/
-  CbmEcalShLibCorr* fShLib;			//!
-  /** Calorimeter information **/
-  CbmEcalInf* fInf;			//!
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;		//!
-  /** Calorimeter cluster **/
-  CbmEcalCluster* fCluster;		//!
-
-  /** Steps if gradient business **/
-  Double_t fEStep;
-  Double_t fCStep;
-  /** A stuff from FCNBase **/
-  Double_t fErrorDef;
-  /** Energy of cluster **/
-  Double_t fClusterEnergy;
-  /** Response of cluster **/
-  Double_t fClusterResp;
-  /** Number of photons in cluster **/
-  Int_t fN;
-  /** Seed cells of cluster **/
-  std::vector<CbmEcalCell*> fCells;	//!
-  /** All cells of the cluster **/
-  std::vector<CbmEcalCell*> fClsCells;	//!
-  /** Fix sum of energies of cluster particles to energy of cluster **/
-  Int_t fFixClusterEnergy;
-  /** NDF of fit **/
-  Int_t fNDF;
-  /** Number of parameters **/
-  Int_t fParam;
-
-  FCNEcalClusterCorr(const FCNEcalClusterCorr&);
-  FCNEcalClusterCorr& operator=(const FCNEcalClusterCorr&);
-};
-
-class CbmEcalRecoCorr : public FairTask
-{
-public:
-  /** Default constructor. Requirement of ROOT system **/
-  CbmEcalRecoCorr();
-
-  /** Standard constructor **/
-  CbmEcalRecoCorr(const char *name, const Int_t iVerbose=1, const char* configname="none");
-
-  /** Destructor **/
-  virtual ~CbmEcalRecoCorr();
-
-  /** Init **/
-  virtual InitStatus Init();
-  virtual void Exec(Option_t* option);
-  virtual void Finish();
-
-  /** Tools for debugging **/
-  void SetOutToTree(Bool_t totree=kTRUE) {fToTree=totree;}
-  void SetRecoName(const char* name) {fRecoName=name;}
-  TString GetRecoName() const {return fRecoName;}
-  void SetStoreClusterInfo(Bool_t store) {fStoreClusterInfo=store;}
-private:
-  /** Reconstruct photon from maximum **/
-  void Reco(CbmEcalCell* cell, CbmEcalCluster* clstr);
-  /** Reconstruct photon from maximum. PosLib instead of S-curves **/
-  void Reco2(CbmEcalCell* cell, CbmEcalCluster* clstr);
-  /** Fit a given cluster. A first approximation should be available **/
-  void FitCluster(CbmEcalCluster* clstr);
-  /** Write a cluster info **/
-  void WriteClusterInfo(CbmEcalCluster* clstr);
-  /** Calculate a chi2 for just reconstructed photons **/
-  Double_t CalculateChi2(CbmEcalCluster* cluster);
-  /** Fit a cluster. A**/
-  Double_t FitCluster();
-  /** Number of reconstructed tracks **/
-  Int_t fN;
-  Int_t fNOld;
-
-  CbmEcalCell** fMaximums;	//!
-  CbmEcalCell** fExcluded;	//!
-
-  /** Event number **/
-  Int_t fEventN;
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;	//!
-  /** An information about calorimeter **/
-  CbmEcalInf* fInf;		//!
-  /** S-curve library **/
-  CbmEcalSCurveLib* fLib;	//!
-  /** A position library **/
-  CbmEcalPosLib* fPosLib;	//!
-  /** A shower library **/
-  CbmEcalShLibCorr* fShLib;		//!
-  /** A calibration of the calorimeter **/
-  CbmEcalCalibration* fCal;	//!
-
-  /** Array of tracks **/
-  TClonesArray* fTracks;	//!
-  /** Array of reconstructed particles **/
-  TClonesArray* fReco;		//!
-  /** Array of clusters **/
-  TClonesArray* fClusters;	//!
-  /** Name of output tree **/
-  TString fRecoName;
-
-  /** A tool, to export reconstructed particles to file. Should be moved to
-   ** a separate task in future. For debugging now. **/
-  Bool_t fToTree;
-  TTree* fOutTree;		//!
-  Bool_t fStoreClusterInfo;
-  void CreateTree();
-  void FillTree();
-  Short_t fType;
-  Short_t fDiffType;
-  Double_t fE;
-  Double_t fE3x3;
-  Double_t fE2x2;
-  Double_t fEReco;
-  Double_t fXReco;
-  Double_t fYReco;
-  Double_t fECls;
-  Double_t fE2Cls;
-  Double_t fE3Cls;
-  Double_t fECluster;
-  Double_t fAX;
-  Double_t fAY;
-  Double_t fCellX;
-  Double_t fCellY;
-  Double_t fChi2;
-  Double_t fTheta[50];
-  Short_t fTypes[50];
-  Double_t fEmeas[50];
-  Double_t fEpred[50];
-  Double_t fChi2Fit[50];
-  Double_t fEfirst[50];
-  Double_t fChi2First[50];
-  Double_t fCX[50];
-  Double_t fCY[50];
-  Int_t fCMaxs;
-
-  /** A threshold for chi^2. Is chi^2<fChi2Th no fitting **/
-  Double_t fChi2Th;
-  Double_t fEStep;
-  Double_t fCStep;
-  /** Maximum number of photons per cluster for reconstruction
-   ** If cluster contains more local maximums, it rejected. **/
-  Int_t fMaxPhotonsPerCluster;
-  /** Maximum number of iterations in fitting process **/
-  Int_t fMaxIterations;
-  /** Fix sum of energies of cluster particles to energy of cluster **/
-  Int_t fFixClusterEnergy;
-  /** A chi^2 and gradient function for cluster/particles **/
-  FCNEcalClusterCorr* fFCN;		//!
-  /** A fitter **/
-  ROOT::Minuit2::Minuit2Minimizer* fFitter;
-  /** Minimum energy of precluster maximum for consideration **/
-  Double_t fMinMaxE;
-  /** Use a position library instead of S-curves **/
-  Int_t fUsePosLib;
-
-  /** Energy deposition in precluster **/
-  Double_t fPreE;
-  /** Region **/
-  Int_t fRegion;
-
-  CbmEcalRecoCorr(const CbmEcalRecoCorr&);
-  CbmEcalRecoCorr& operator=(const CbmEcalRecoCorr&);
-
-  ClassDef(CbmEcalRecoCorr, 1)
-};
-
-#endif
-
diff --git a/ecal/CbmEcalReconstructionFastMC.cxx b/ecal/CbmEcalReconstructionFastMC.cxx
deleted file mode 100644
index d19b895e2312dc4adfa74f28727ef93af9ffdbf0..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalReconstructionFastMC.cxx
+++ /dev/null
@@ -1,133 +0,0 @@
-// -------------------------------------------------------------------------
-// -----         CbmEcalReconstructionFastMC source file               -----
-// -----         Created 22/06/06  by Yu.Kharlov                       -----
-// -------------------------------------------------------------------------
-
-  /* $Id: CbmEcalReconstructionFastMC.cxx,v 1.1 2006/06/22 14:02:17 kharlov Exp $ */
-
-  /* History of cvs commits:
-   *
-   * $Log: CbmEcalReconstructionFastMC.cxx,v $
-   * Revision 1.1  2006/06/22 14:02:17  kharlov
-   * First upload of reconstruction classes for Full MC
-   *
-   */
-
-/**  CbmEcalReconstructionFastMC.cxx
- *@author Yu.Kharlov
- **
- ** Class for ECAL reconstruction, Fast MC version:
- ** calculate 4-momenta of reconstructed particles assuming
- ** that the particle comes from the target center
- **/
-#include "CbmEcalReconstructionFastMC.h"
-
-#include "CbmEcalRecParticle.h"
-#include "CbmEcalHitFastMC.h"
-
-#include "FairRootManager.h"
-
-#include <iostream>
-
-using std::cout;
-using std::endl;
-
-// -----   Default constructor   -------------------------------------------
-CbmEcalReconstructionFastMC::CbmEcalReconstructionFastMC() 
-  : FairTask(),
-    fListECALhits(NULL),
-    fListRecParticles(NULL),
-    fNRecParticles(0),
-    fEvent(0),
-    fZEcal(1200.)
-{
-}
-// -------------------------------------------------------------------------
-
-// -----   Standard constructor   -------------------------------------------
-CbmEcalReconstructionFastMC::CbmEcalReconstructionFastMC(const char *name, const Int_t iVerbose) 
-  : FairTask(name,iVerbose),
-    fListECALhits(NULL),
-    fListRecParticles(NULL),
-    fNRecParticles(0),
-    fEvent(0),
-    fZEcal(1200.)
-{
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcalReconstructionFastMC::~CbmEcalReconstructionFastMC()
-{
-  FairRootManager *fManager =FairRootManager::Instance();
-  fManager->Write();
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Initialization   ------------------------------------------------
-InitStatus CbmEcalReconstructionFastMC::Init()
-{
-  FairRootManager* fManager = FairRootManager::Instance();
-
-  // ECAL hits
-  fListECALhits = (TClonesArray*)fManager->GetObject("EcalHitFastMC");
-  // new list of ECAL reconstructed particles
-  fListRecParticles = new TClonesArray("CbmEcalRecParticle",100);
-  fManager->Register("EcalRecParticle","ECAL",fListRecParticles,IsOutputBranchPersistent("EcalRecParticle"));
-  return kSUCCESS;
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Execution of Task   ---------------------------------------------
-void CbmEcalReconstructionFastMC::Exec(Option_t*)
-{
-
-  fEvent++;
-  printf("\n=====> Event no. %d\n",fEvent);
-  printf("Number of input ECAL hits: %d\n",fListECALhits->GetEntries());
-
-  fListRecParticles->Clear();
-  fNRecParticles = 0;
-  CbmEcalHitFastMC *hit;
-  Double_t x,y,px,py,pz,E;
-  
-  for(Int_t j=0; j<fListECALhits->GetEntries(); j++) {
-    hit = (CbmEcalHitFastMC*)fListECALhits->At(j);
-    E = hit->GetAmplitude();
-    x = hit->GetX();
-    y = hit->GetY();
-    px = E*x/fZEcal;
-    py = E*y/fZEcal;
-    pz = TMath::Sqrt(E*E - px*px - py*py);
-    AddRecParticle(px,py,pz,E);
-  }   // loop over hits
-//   for (Int_t i=0; i<fNRecParticles; i++) {
-//     printf("Rec.particle %d\n",i);
-//     ((CbmEcalRecParticle*)fListRecParticles->At(fNRecParticles))->Print();
-//   }  
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Add Hit to HitCollection   --------------------------------------
-void CbmEcalReconstructionFastMC::AddRecParticle(Double_t px, Double_t py,
-					   Double_t pz, Double_t E)
-{
-  // Add this hit to the list of ECAL hits
-  new((*fListRecParticles)[fNRecParticles]) CbmEcalRecParticle(px,py,pz,E);
-  fNRecParticles++;
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Finish Task   ---------------------------------------------------
-void CbmEcalReconstructionFastMC::Finish()
-{
-  fListRecParticles->Clear();
-}
-// -------------------------------------------------------------------------
-
-ClassImp(CbmEcalReconstructionFastMC)
diff --git a/ecal/CbmEcalReconstructionFastMC.h b/ecal/CbmEcalReconstructionFastMC.h
deleted file mode 100644
index e5b07ff505f7a406f75c99e7c2f92d78235983e6..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalReconstructionFastMC.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// -------------------------------------------------------------------------
-// -----         CbmEcalReconstructionFastMC header file               -----
-// -----         Created 22/06/06  by Yu.Kharlov                       -----
-// -------------------------------------------------------------------------
-
-  /* $Id: CbmEcalReconstructionFastMC.h,v 1.1 2006/06/22 14:02:17 kharlov Exp $ */
-
-  /* History of cvs commits:
-   *
-   * $Log: CbmEcalReconstructionFastMC.h,v $
-   * Revision 1.1  2006/06/22 14:02:17  kharlov
-   * First upload of reconstruction classes for Full MC
-   *
-   */
-
-/**  CbmEcalReconstructionFastMC.h
- *@author Yu.Kharlov
- **
- ** Class for ECAL reconstruction, Fast MC version:
- ** calculate 4-momenta of reconstructed particles assuming
- ** that the particle comes from the target center
- **/
-
-
-#ifndef CBMECALRECONSTRUCTIONFASTMC_H
-#define CBMECALRECONSTRUCTIONFASTMC_H
-
-#include "FairTask.h"
-
-#include "TClonesArray.h"
-
-class CbmEcalReconstructionFastMC : public FairTask {
-
-public:
-
-  /** Default constructor **/
-  CbmEcalReconstructionFastMC();
-
-  /** Standard constructor **/
-  CbmEcalReconstructionFastMC(const char *name, const Int_t iVerbose=1);
-
-  /** Destructor **/
-  virtual ~CbmEcalReconstructionFastMC();
-
-  /** Initialization of the task **/  
-  virtual InitStatus Init();
-
-  /** Executed task **/ 
-  virtual void Exec(Option_t* option);
-
-  /** Finish task **/ 
-  virtual void Finish();
-
-  /** method AddHit
-   **
-   ** Adds a EcalHit to the HitCollection
-   **/
-  void AddRecParticle(Double_t px, Double_t py, Double_t pz, Double_t E);
-
-private:
-
-  TClonesArray* fListECALhits;     // ECAL hits
-  TClonesArray* fListRecParticles; // ECAL reconstructed particles
-  Int_t fNRecParticles;            // Number of reconstructed particles
-  Int_t fEvent;                    //! Internal event counter
-  Double_t fZEcal;                 // distance from target to ECAL
-
-  CbmEcalReconstructionFastMC(const CbmEcalReconstructionFastMC&);
-  CbmEcalReconstructionFastMC& operator=(const CbmEcalReconstructionFastMC&);
-
-  ClassDef(CbmEcalReconstructionFastMC,1)
-
-};
-
-#endif
diff --git a/ecal/CbmEcalSCurveLib.cxx b/ecal/CbmEcalSCurveLib.cxx
deleted file mode 100644
index a102ec2c24c49832ca21265b78b4c99c3e86a7f0..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalSCurveLib.cxx
+++ /dev/null
@@ -1,195 +0,0 @@
-/* $Id: CbmEcalSCurveLib.cxx,v 1.1 2006/09/18 07:58:04 prokudin Exp $ */
-/*
- * $Log: CbmEcalSCurveLib.cxx,v $
- * Revision 1.1  2006/09/18 07:58:04  prokudin
- * First implementation of SCurve library
- *
- */
-
-#include "CbmEcalSCurveLib.h"
-
-#include "CbmEcalInf.h"
-#include "CbmEcalCell.h"
-#include "CbmEcalSCurveLibRecord.h"
-
-#include "FairRootManager.h"
-
-#include "TMath.h"
-#include "TSystem.h"
-
-#include <iostream>
-
-using std::cerr;
-using std::endl;
-using std::list;
-
-CbmEcalSCurveLib::CbmEcalSCurveLib(const char* name, Int_t verbose) 
-  : FairTask(name, verbose), 
-    fFiles(),
-    fVerbose(verbose),
-    fModuleSize(0.),
-    fSize(10),
-    fRec(new CbmEcalSCurveLibRecord*[fSize])
-{
-  Int_t i;
-
-  for(i=0;i<fSize;i++)
-    fRec[i]=NULL;
-  fFiles.clear();
-}
-
-void CbmEcalSCurveLib::GetModuleSize()
-{
-  if (fModuleSize!=0)
-    return;
-  CbmEcalInf* inf=CbmEcalInf::GetInstance(NULL);
-  if (inf==NULL)
-  {
-    Fatal("GetModuleSize","Can't find CbmEcalInf object!");
-    return;
-  }
-  fModuleSize=inf->GetModuleSize();
-}
-
-void CbmEcalSCurveLib::AddFile(const char* file)
-{
-  fFiles.push_back(file);
-}
-
-void CbmEcalSCurveLib::Add(const char* file)
-{
-  Int_t num;
-  TString fname=file;
-  gSystem->ExpandPathName(fname);
-  CbmEcalSCurveLibRecord* rec=new CbmEcalSCurveLibRecord(fname);
-  if (rec->GetCellSize()==0)
-  {
-    delete rec;
-    return;
-  }
-  GetModuleSize();
-  if (fVerbose>9)
-    Info("AddFile", "Initing for cellsize %f.", rec->GetCellSize());
-  num=(Int_t)((fModuleSize+0.0001)/rec->GetCellSize());
-  fRec[num]=rec;
-  if (fVerbose>0)
-    Info("AddFile", "Inited for cell type %d", num);
-}
-
-InitStatus CbmEcalSCurveLib::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (fManager==NULL)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fManager->Register("EcalSCurveLib", "ECAL", this, kFALSE);
-  for(list<TString>::const_iterator p=fFiles.begin(); p!=fFiles.end();++p)
-    Add((*p).Data());
-
-  return kSUCCESS;
-}
-
-void CbmEcalSCurveLib::Exec(Option_t*)
-{
-  ;
-}
-
-void CbmEcalSCurveLib::Finish()
-{
-  ;
-}
-
-void CbmEcalSCurveLib::GetCoord(Float_t e, CbmEcalCell* cell, Float_t& x, Float_t& y) const
-{
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  Float_t ax=0;
-  Float_t ay=0;
-  Float_t en=cell->GetEnergy();
-
-  Int_t type=cell->GetType();
-  cell->GetNeighborsList(0, cells);
-  x=0; y=0;
-  for(p=cells.begin();p!=cells.end();++p) 
-  {
-    if (type!=(*p)->GetType())
-    {
-      x=-1111;
-      y=-1111;
-      return;
-    } else
-    {
-      if (cell->GetCenterX()+0.001<(*p)->GetCenterX())
-        ax+=(*p)->GetEnergy();
-      else
-      if (cell->GetCenterX()-0.001>(*p)->GetCenterX())
-        ax-=(*p)->GetEnergy();
-      if (cell->GetCenterY()+0.001<(*p)->GetCenterY())
-        ay+=(*p)->GetEnergy();
-      else
-      if (cell->GetCenterY()-0.001>(*p)->GetCenterY())
-        ay-=(*p)->GetEnergy();
-    }
-    en+=(*p)->GetEnergy();
-  }
-  ax/=en;
-  ay/=en;
-  x=GetX(ax, e, cell);
-  y=GetX(ay, e, cell);
-//  x+=cell->GetCenterX();
-//  y+=cell->GetCenterY();
-}
-Float_t CbmEcalSCurveLib::GetY(Float_t a, Float_t e, CbmEcalCell* cell) const
-{
-  if (!cell) return -1111;
-  CbmEcalInf* inf=CbmEcalInf::GetInstance(NULL);
-  if (inf==NULL) return -1111;
-  Int_t type=cell->GetType();
-  if (type>=fSize||type<=0) return -1111;
-  if (!fRec[type]) return -1111;
-
-  Float_t z=inf->GetZPos();
-  Float_t y=cell->GetCenterY();
-  Float_t theta=TMath::ATan(y/z)*TMath::RadToDeg();
-  return GetX(a, e, theta, type);
-}
-
-Float_t CbmEcalSCurveLib::GetX(Float_t a, Float_t e, CbmEcalCell* cell) const
-{
-  if (!cell) return -1111;
-  CbmEcalInf* inf=CbmEcalInf::GetInstance(NULL);
-  if (inf==NULL) return -1111;
-  Int_t type=cell->GetType();
-  if (type>=fSize||type<=0) return -1111;
-  if (!fRec[type]) return -1111;
-
-  Float_t z=inf->GetZPos();
-  Float_t x=cell->GetCenterX();
-  Float_t theta=TMath::ATan(x/z)*TMath::RadToDeg();
-  return GetX(a, e, theta, type);
-}
-
-Float_t CbmEcalSCurveLib::GetX(Float_t a, Float_t e, Float_t theta, Int_t type) const
-{
-  if (type>=fSize||type<=0) return -1111;
-  if (!fRec[type]) return -1111;
-  if (theta<0)
-  {
-    Float_t res=fRec[type]->GetX(-a,e,-theta);
-    if (res==-1111)
-      return res;
-    return -res;
-  }
-  return fRec[type]->GetX(a,e,theta);
-}
-
-CbmEcalSCurveLib::~CbmEcalSCurveLib()
-{
-  for(Int_t i=0;i<fSize;i++)
-    if (fRec[i]) delete fRec;
-  delete fRec;
-}
-
-ClassImp(CbmEcalSCurveLib)
diff --git a/ecal/CbmEcalSCurveLib.h b/ecal/CbmEcalSCurveLib.h
deleted file mode 100644
index 881b4848658fc366dace87f49eb0a044ea949a94..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalSCurveLib.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Returns X for given assymetry/energy.
-// Data taken from root files
-
-/* $Id: CbmEcalSCurveLib.h,v 1.1 2006/09/18 07:58:04 prokudin Exp $ */
-/*
- * $Log: CbmEcalSCurveLib.h,v $
- * Revision 1.1  2006/09/18 07:58:04  prokudin
- * First implementation of SCurve library
- *
- */
-
-#ifndef CBMECALSCURVELIB_H
-#define CBMECALSCURVELIB_H
-
-#include "FairTask.h"
-#include "TString.h"
-
-#include <list>
-
-class CbmEcalSCurveLibRecord;
-class CbmEcalCell;
-
-class CbmEcalSCurveLib : public FairTask
-{
-public:
-  CbmEcalSCurveLib(const char* name, Int_t verbose=0);
-  void AddFile(const char* file);
-  // a is assymetry, e --- energy of incoming particle
-  void GetCoord(Float_t e, CbmEcalCell* cell, Float_t& x, Float_t& y) const;
-  Float_t GetX(Float_t a, Float_t e, CbmEcalCell* cell) const;
-  Float_t GetY(Float_t a, Float_t e, CbmEcalCell* cell) const;
-  Float_t GetX(Float_t a, Float_t e, Float_t theta, Int_t type) const;
-  InitStatus Init();
-  void Exec(Option_t* exec);
-  void Finish();
-  virtual ~CbmEcalSCurveLib();
-
-  /** Set module size, mostly for debuging
-   ** Don't use it, ModuleSize will be inited automaticly
-   ** via CbmEcalInf container **/
-  void SetModuleSize(Float_t msize);
-private:
-  void Add(const char* file);
-
-  /** Silence compiler warnings **/
-  void Add(TTask*) {;}
-
-  std::list<TString> fFiles;
-  /** if fModuleSize==0, load it from CbmEcalInf **/
-  void GetModuleSize();
-  /** A verbose flag **/
-  Int_t fVerbose;
-  Float_t fModuleSize;
-
-  /** Size of fRec array **/
-  Int_t fSize;
-  CbmEcalSCurveLibRecord** fRec; //!
-
-  CbmEcalSCurveLib(const CbmEcalSCurveLib&);
-  CbmEcalSCurveLib& operator=(const CbmEcalSCurveLib&);
-
-  ClassDef(CbmEcalSCurveLib, 1)
-};
-
-inline void CbmEcalSCurveLib::SetModuleSize(Float_t msize)
-{
-  fModuleSize=msize;
-}
-#endif
diff --git a/ecal/CbmEcalSCurveLibRecord.cxx b/ecal/CbmEcalSCurveLibRecord.cxx
deleted file mode 100644
index 928a5439cecdaa6c5505b9af999e2a7fb1448067..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalSCurveLibRecord.cxx
+++ /dev/null
@@ -1,278 +0,0 @@
-/* $Id: CbmEcalSCurveLibRecord.cxx,v 1.1 2006/09/18 07:58:04 prokudin Exp $ */
-/*
- * $Log: CbmEcalSCurveLibRecord.cxx,v $
- * Revision 1.1  2006/09/18 07:58:04  prokudin
- * First implementation of SCurve library
- *
- */
-
-
-#include "CbmEcalSCurveLibRecord.h"
-
-#include "TFile.h"
-#include "TTree.h"
-
-#include <list>
-#include <iostream>
-#include <algorithm>
-
-using std::cerr;
-using std::endl;
-using std::list;
-
-// - implementation
-
-CbmEcalSCurveLibRecord::CbmEcalSCurveLibRecord(const char* filename)
-  : fCellSize(0),
-    fPoints(0),
-    fEnergies(0),
-    fE(NULL),
-    fThetas(),
-    fTheta(NULL),
-    fA(NULL),
-    fX(NULL),
-    fSize(0),
-    fTail(10),
-    fXL(NULL),
-    fDXL(NULL),
-    fXR(NULL),
-    fDXR(NULL)
-{
-  TFile* file;
-  TTree* tree;
-  Float_t e;
-  Float_t theta;
-  Int_t size;
-  Float_t* x;
-  Float_t  cellsize;
-  list<Float_t>::const_iterator p;
-  list<Float_t> es;
-  list<Float_t> thetas;
-  Int_t i;
-  Int_t j;
-  Int_t num;
-
-  file=new TFile(filename);
-  if (file->IsZombie())
-  {
-    cerr << "Something wrong with input file " << filename << endl;
-    return;
-  }
-  
-  tree=(TTree*)file->Get("sc");
-  if (tree==NULL)
-  {
-    cerr << "Can't find SCurve tree in " << filename << endl;
-    return;
-  }
-  if (tree->GetEntries()<1)
-  {
-    file->Close();
-    return;
-  }
-  tree->SetBranchAddress("outcellsize",&cellsize);
-  tree->SetBranchAddress("oute",&e);
-  tree->SetBranchAddress("outtheta",&theta);
-  tree->SetBranchAddress("outsize",&size);
-  tree->GetEntry(0);
-
-  fCellSize=cellsize;
-  fPoints=tree->GetEntries();
-  fSize=size;
-  x=new Float_t[size];
-
-  es.clear();
-  thetas.clear();
-  for(i=0;i<fPoints;i++)
-  {
-    tree->GetEntry(i);
-    if (find(es.begin(), es.end(), e)==es.end())
-      es.push_back(e);
-    if (find(thetas.begin(), thetas.end(), theta)==thetas.end())
-      thetas.push_back(theta);
-  }
-
-//Initializing energies and thetas lists
-
-  fE=new Float_t[es.size()];
-  fEnergies=0;
-  for(p=es.begin();p!=es.end();p++)
-   fE[fEnergies++]=(*p);
-
-  fThetas=0;
-  fTheta=new Float_t[thetas.size()];
-  for(p=thetas.begin();p!=thetas.end();p++)
-    fTheta[fThetas++]=(*p);
-
-  tree->SetBranchAddress("outx",x);
-  fX=new Float_t*[fPoints];
-  for(i=0;i<fPoints;i++)
-    fX[i]=NULL;
-  
-  for(i=0;i<fPoints;i++)
-  {
-    tree->GetEntry(i);
-    num=GetNum(e, theta);
-    if (fX[num]!=NULL)
-    {
-      cerr << "Duplicate entry for " << e << "GeV, theta ";
-      cerr << theta << ". Skipping!" << endl;
-      continue;
-    }
-    fX[num]=new Float_t[fSize];
-    for(j=0;j<fSize;j++)
-      fX[num][j]=x[j];
-  }
-
-  delete [] x;
-  file->Close();
-  delete file;
-  InitA();
-}
-
-void CbmEcalSCurveLibRecord::InitA()
-{
-  Int_t i;
-  Int_t j;
-  Float_t step=1.0/(fSize-1);
-
-  fA=new Float_t[fSize];
-  fA[0]=-0.5;
-  for(i=1;i<fSize;i++)
-    fA[i]=fA[i-1]+step;
-
-  fTail=fSize/6;
-  fXL=new Float_t[fPoints];
-  fXR=new Float_t[fPoints];
-  fDXL=new Float_t[fPoints];
-  fDXR=new Float_t[fPoints];
-  for(j=0;j<fPoints;j++)
-  {
-    fXL[j]=0;
-    fXR[j]=0;
-    fDXL[j]=0;
-    fDXR[j]=0;
-
-    for(i=0;i<fTail;i++)
-      fDXL[j]+=(fX[j][i+1]-fX[j][i])/step/fTail;
-    for(i=0;i<fTail;i++)
-      fXL[j]+=fX[j][i]-fA[i]*fDXL[j];
-    fXL[j]/=fTail;
-
-
-    for(i=fSize-fTail;i<fSize;i++)
-      fDXR[j]+=(fX[j][i]-fX[j][i-1])/step/fTail;
-    for(i=fSize-fTail;i<fSize;i++)
-      fXR[j]+=fX[j][i]-fA[i]*fDXR[j];
-    fXR[j]/=fTail;
-  }
-}
-
-
-// Performance is UGLY!
-Float_t CbmEcalSCurveLibRecord::GetX(Float_t a, Float_t e, Float_t theta) const
-{
-  Int_t i;
-  Int_t tp;
-  Int_t tn;
-  Float_t tpf;
-  Float_t tnf;
-  Int_t ep;
-  Int_t en;
-  Float_t epf;
-  Float_t enf;
-
-  Int_t xn;
-  Int_t xp;
-  Float_t xnf;
-  Float_t xpf;
-
-  if (theta<fTheta[0]||e<fE[0])
-    return -1111;
-  for(i=1;i<fThetas;i++)
-    if (fTheta[i]>theta) break;
-  if (i==fThetas)
-  {
-    if ((fTheta[fThetas-1]-theta)/theta>0.02)
-      return -1111;
-    tp=i-1;
-    tn=i;
-  } else
-  {
-    tp=i-1;
-    tn=i;
-  }
-  tpf=(fTheta[tn]-theta)/(fTheta[tn]-fTheta[tp]);
-  tnf=(theta-fTheta[tp])/(fTheta[tn]-fTheta[tp]);
-
-  for(i=1;i<fEnergies;i++)
-    if (fE[i]>e) break;
-  if (i==fEnergies)
-  { ep=i-1; en=i-1; epf=1.0; enf=0.0;}
-  else
-  { ep=i-1; en=i;
-    epf=(fE[en]-e)/(fE[en]-fE[ep]);
-    enf=(e-fE[ep])/(fE[en]-fE[ep]);
-  }
-  if (TMath::Abs(a)<=0.5)
-  {
-    for(i=1;i<fSize;i++)
-      if (fA[i]>a)
-	break;
-    xn=i;
-    xp=i-1;
-    xpf=(fX[ep*fThetas+tp][xp]*tpf+fX[ep*fThetas+tn][xp]*tnf)*epf+(fX[en*fThetas+tp][xp]*tpf+fX[en*fThetas+tn][xp]*tnf)*enf;
-    xnf=(fX[ep*fThetas+tp][xn]*tpf+fX[ep*fThetas+tn][xn]*tnf)*epf+(fX[en*fThetas+tp][xn]*tpf+fX[en*fThetas+tn][xn]*tnf)*enf;
-    return (xpf*(fA[xn]-a)+xnf*(a-fA[xp]))/(fA[xn]-fA[xp]);
-  }
-  if (a>0.5)
-  {
-    xpf=(fXR[ep*fThetas+tp]*tpf+fXR[ep*fThetas+tn]*tnf)*epf+(fXR[en*fThetas+tp]*tpf+fXR[en*fThetas+tn]*tnf)*enf;
-    xnf=(fDXR[ep*fThetas+tp]*tpf+fDXR[ep*fThetas+tn]*tnf)*epf+(fDXR[en*fThetas+tp]*tpf+fDXR[en*fThetas+tn]*tnf)*enf;
-    return xpf+xnf*a;
-  }
-  xpf=(fXL[ep*fThetas+tp]*tpf+fXL[ep*fThetas+tn]*tnf)*epf+(fXL[en*fThetas+tp]*tpf+fXL[en*fThetas+tn]*tnf)*enf;
-  xnf=(fDXL[ep*fThetas+tp]*tpf+fDXL[ep*fThetas+tn]*tnf)*epf+(fDXL[en*fThetas+tp]*tpf+fDXL[en*fThetas+tn]*tnf)*enf;
-  return xpf+xnf*a;
-}
-
-Int_t CbmEcalSCurveLibRecord::GetNum(Float_t energy, Float_t theta) const 
-{
-  Int_t i;
-  Int_t en;
-  Int_t the;
-
-  for(i=0;i<fEnergies;i++)
-    if (TMath::Abs(energy-fE[i])/fE[i]<0.001)
-      break;
-  if (i==fEnergies) return -1;
-  en=i;
-  
-  for(i=0;i<fThetas;i++)
-    if (TMath::Abs(theta-fTheta[i])<0.001)
-      break;
-  if (i==fThetas) return -1;
-  the=i;
-
-  return the+en*(fThetas);
-}
-
-
-CbmEcalSCurveLibRecord::~CbmEcalSCurveLibRecord()
-{
-  delete [] fE;
-  delete [] fXL;
-  delete [] fXR;
-  delete [] fDXL;
-  delete [] fDXR; 
-  if (fX)
-  {
-    for(Int_t i=0;i<fPoints;i++)
-      delete [] fX[i];
-    delete [] fX;
-  }
-  delete [] fTheta;
-  delete [] fA;
-}
-
-ClassImp(CbmEcalSCurveLibRecord)
diff --git a/ecal/CbmEcalSCurveLibRecord.h b/ecal/CbmEcalSCurveLibRecord.h
deleted file mode 100644
index 8221cd29c75369c2ad4f06a34cb0d87eecd50175..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalSCurveLibRecord.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Returns X for given assymetry/energy.
-// Data taken from root file
-
-/* $Id: CbmEcalSCurveLibRecord.h,v 1.1 2006/09/18 07:58:04 prokudin Exp $ */
-/*
- * $Log: CbmEcalSCurveLibRecord.h,v $
- * Revision 1.1  2006/09/18 07:58:04  prokudin
- * First implementation of SCurve library
- *
- */
-
-#ifndef CBMECALSCURVELIBRECORD_H
-#define CBMECALSCURVELIBRECORD_H
-
-#include "TObject.h"
-
-class CbmEcalSCurveLibRecord
-{
-public:
-  CbmEcalSCurveLibRecord(const char* filename);
-  //returns x coordinate for given assymetry and theta
-  //-1111 if retrival not possible
-  //e --- an incoming particle energy
-  Float_t GetX(Float_t a, Float_t e, Float_t theta) const;
-  Float_t GetCellSize() const;
-  virtual ~CbmEcalSCurveLibRecord();
-private:
-  Int_t GetNum(Float_t energy, Float_t theta) const;
-  void InitA();
-  /** CellSize **/
-  Float_t fCellSize;
-  /** Number of records **/
-  Int_t fPoints;
-  /** Number of energies **/
-  Int_t fEnergies;
-  /** List of energies **/
-  Float_t* fE;		//!
-  /** Number of thetas **/
-  Int_t fThetas;
-  /** List of thetas **/
-  Float_t* fTheta;	//!
-  /** Assymetry **/
-  Float_t* fA;		//!
-  /** Correspondig X **/
-  Float_t** fX;		//!
-  /** Number of [A,X] pairs for each record **/
-  Int_t fSize;
-
-  Int_t fTail;
-
-  Float_t* fXL;		//!
-  Float_t* fDXL;	//!
-  Float_t* fXR;		//!
-  Float_t* fDXR;	//!
-
-  CbmEcalSCurveLibRecord(const CbmEcalSCurveLibRecord&);
-  CbmEcalSCurveLibRecord& operator=(const CbmEcalSCurveLibRecord&);
-
-  ClassDef(CbmEcalSCurveLibRecord, 1)
-};
-
-inline Float_t CbmEcalSCurveLibRecord::GetCellSize() const
-{
-  return fCellSize;
-}
-
-#endif
diff --git a/ecal/CbmEcalShLib.cxx b/ecal/CbmEcalShLib.cxx
deleted file mode 100644
index 7cd0824b13ed916f674f662d0126151921579331..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLib.cxx
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "CbmEcalShLib.h"
-
-CbmEcalShLib::~CbmEcalShLib()
-{
-}
-
-ClassImp(CbmEcalShLib)
diff --git a/ecal/CbmEcalShLib.h b/ecal/CbmEcalShLib.h
deleted file mode 100644
index e32681f645d1a71485bb322b25ef8182bc97d251..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLib.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef CBMECALSHLIB_H
-#define CBMECALSHLIB_H
-
-#include "FairTask.h"
-#include "CbmEcalCell.h"
-
-class CbmEcalShLib : public FairTask
-{
-public:
-  CbmEcalShLib() : fLibName("EcalShLib") {};
-  CbmEcalShLib(const char* nm, Int_t verb) : FairTask(nm, verb), fLibName("EcalShLib") {};
-  // Response to photon with energy e, polar angle phi (rad), impact angle
-  // theta (rad). X, Y are position vs. photons impact point
-  // Cell is a size os cell in cm.
-  virtual Float_t GetResponse(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e, Int_t celltype=0)=0;
-  virtual Float_t GetResponse(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e, CbmEcalCell* cell)
-  {
-    return GetResponse(x, y, phi, theta, e, cell->GetType());
-  }
-  // Several libraries can be inside the system.
-  // Example: one for gamma reconstruction, one for identification
-  void SetLibraryName(const char* name) {fLibName=name;}
-  TString LibraryName() const {return fLibName;}
-  virtual ~CbmEcalShLib()=0;
-private:
-  TString fLibName;
-  ClassDef(CbmEcalShLib, 1);
-};
-
-#endif
diff --git a/ecal/CbmEcalShLibCorr.cxx b/ecal/CbmEcalShLibCorr.cxx
deleted file mode 100644
index 30ec8813676f03d0468aec72dcc7f5a5e3a0e114..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibCorr.cxx
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "CbmEcalShLibCorr.h"
-
-CbmEcalShLibCorr::~CbmEcalShLibCorr()
-{
-}
-
-ClassImp(CbmEcalShLibCorr)
diff --git a/ecal/CbmEcalShLibCorr.h b/ecal/CbmEcalShLibCorr.h
deleted file mode 100644
index 5900e90221366324f58046dc873df1d2f5f16230..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibCorr.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef CBMECALSHLIBCORR_H
-#define CBMECALSHLIBCORR_H
-
-#include "CbmEcalShLib.h"
-#include "CbmEcalCell.h"
-
-// Abstract class for shower library with correlations
-
-class CbmEcalShLibCorr : public CbmEcalShLib
-{
-public:
-  CbmEcalShLibCorr() {};
-  CbmEcalShLibCorr(const char* nm, Int_t verb) : CbmEcalShLib(nm, verb) {};
-  // Cell is a size of cell in cm.
-  // Correlation between cells
-  virtual Float_t Correlation(Float_t x1, Float_t y1, Float_t x2, Float_t y2, Float_t phi, Float_t theta, Float_t e, Int_t celltype=0)=0;
-  virtual Float_t Correlation(Float_t x1, Float_t y1, Float_t x2, Float_t y2, Float_t phi, Float_t theta, Float_t e, CbmEcalCell* cell)
-  {
-    return Correlation(x1, y1, x2, y2, phi, theta, e, cell->GetType());
-  }
-  // Correlation between cells with different size.
-  // x2, y2 --- coordinates of cell with 2x size
-  virtual Float_t Correlation2(Float_t x1, Float_t y1, Float_t x2, Float_t y2, Float_t phi, Float_t theta, Float_t e, Int_t celltype=0)=0;
-  virtual ~CbmEcalShLibCorr()=0;
-private:
-  ClassDef(CbmEcalShLibCorr, 1);
-};
-
-#endif
diff --git a/ecal/CbmEcalShLibCorrRecord.cxx b/ecal/CbmEcalShLibCorrRecord.cxx
deleted file mode 100644
index 1d4321a148942f2dee3e8f267407438264ceb293..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibCorrRecord.cxx
+++ /dev/null
@@ -1,373 +0,0 @@
-#include "CbmEcalShLibCorrRecord.h"
-
-#include "TFile.h"
-#include "TTree.h"
-#include "TH2D.h"
-#include "TMath.h"
-
-#include <iostream>
-
-using namespace std;
-
-CbmEcalShLibCorrRecord::CbmEcalShLibCorrRecord(const char* filename, Int_t verb)
-  : TObject(),
-    fError(0),
-    fCellSize(0.),
-    fNE(0),
-    fE(NULL),
-    fNTheta(0),
-    fTheta(NULL),
-    fNPhi(0),
-    fPhi(NULL),
-    fStep(0.),
-    iCellSize(0),
-    fEndX(0.),
-    fStartX(0.),
-    fEndY(0.),
-    fStartY(0.),
-    fNCells(0),
-    fNCells2(0),
-    fSizeData(0),
-    fSizeCorr(0),
-    fSize(0),
-    fN(0),
-    fVerbose(verb),
-    fData(NULL),
-    fCorr(NULL),
-    fX1(0.),
-    fX2(0.),
-    fY1(0.),
-    fY2(0.),
-    fCEnergy(0)
-{
-  TFile* f=new TFile(filename);
-  TTree* info;
-  TTree* data;
-//  Float_t t;
-  Int_t i;
-  Int_t j;
-  Float_t* dta;
-  Float_t* corr;
-
-  Info("CbmEcalShLibCorrRecord", "Loading %s...", filename);
-  if (f->IsZombie())
-  {
-    Fatal("CbmEcalShLibCorrRecord", "File %s not found.", filename);
-    return;
-  }
-  info=(TTree*)f->Get("info");
-  info->SetBranchAddress("startx", &fStartX);
-  info->SetBranchAddress("endx", &fEndX);
-  info->SetBranchAddress("starty", &fStartY);
-  info->SetBranchAddress("endy", &fEndY);
-  info->SetBranchAddress("ne", &fNE);
-  info->SetBranchAddress("nphi", &fNPhi);
-  info->SetBranchAddress("ntheta", &fNTheta);
-  info->SetBranchAddress("cellsize", &fCellSize);
-  info->SetBranchAddress("sizedata", &fSizeData);
-  info->SetBranchAddress("sizecorr", &fSizeCorr);
-  info->SetBranchAddress("icellsize", &iCellSize);
-  info->SetBranchAddress("step", &fStep);
-  info->SetBranchAddress("ncells", &fNCells);
-  info->GetEntry(0);
-  fNCells2=fNCells*fNCells;
-  fE=new Float_t[fNE];
-  fTheta=new Float_t[fNTheta];
-  fPhi=new Float_t[fNPhi];
-  fN=fNE*fNTheta*fNPhi;
-  fData=new Float_t*[fN];
-  fCorr=new Float_t*[fN];
-  fSize=iCellSize*iCellSize;
-  for(i=0;i<fN;i++)
-  {
-    fData[i]=new Float_t[fSizeData];
-    fCorr[i]=new Float_t[fSizeCorr];
-  }
-  dta=new Float_t[fSizeData];
-  corr=new Float_t[fSizeCorr];
-  info->SetBranchAddress("e", fE);
-  info->SetBranchAddress("phi", fPhi);
-  info->SetBranchAddress("theta", fTheta);
-  info->GetEntry(0);
-  data=(TTree*)f->Get("shlib");
-  data->SetBranchAddress("data", dta);
-  data->SetBranchAddress("corr", corr);
-  if (fN!=data->GetEntries())
-  {
-    Fatal("CbmEcalShLibCorrRecord", "Info and data trees inconsistent.");
-    return;
-  }
-  for(i=0;i<fN;i++)
-  {
-    data->GetEntry(i);
-    for(j=0;j<fSizeData;j++)
-      fData[i][j]=dta[j];
-    for(j=0;j<fSizeCorr;j++)
-      fCorr[i][j]=corr[j];
-
-  }
-
-//  delete [] dta;
-//  delete [] corr;
-  f->Close();
-
-  if (fVerbose>99)
-  {
-    cout << "Information tree read." << endl;
-    cout << "	n        = " << fN << endl;
-    cout << "	cellsize = " << fCellSize << endl;
-    cout << "	icellsize= " << iCellSize << endl;
-    cout << "	step     = " << fStep << endl;
-    cout << "	startx   = " << fStartX << endl;
-    cout << "	endx     = " << fEndX << endl;
-    cout << "	starty   = " << fStartY << endl;
-    cout << "	endy     = " << fEndY << endl;
-    cout << "	ncells   = " << fNCells << endl;
-    cout << "	sizedata = " << fSizeData << endl;
-    cout << "	sizecorr = " << fSizeCorr << endl;
-    cout << "	nphi     = " << fNPhi << " : (";
-    for(i=0;i<fNPhi;i++)
-      if (i!=0) cout << ", " << fPhi[i]; else cout << fPhi[i];
-    cout << ")" << endl; 
-    cout << "	ntheta   = " << fNTheta << " : (";
-    for(i=0;i<fNTheta;i++)
-      if (i!=0) cout << ", " << fTheta[i]; else cout << fTheta[i];
-    cout << ")" << endl; 
-    cout << "	ne       = " << fNE << " : (";
-    for(i=0;i<fNE;i++)
-      if (i!=0) cout << ", " << fE[i]; else cout << fE[i];
-    cout << ")" << endl; 
-  }
-}
-
-Float_t CbmEcalShLibCorrRecord::Energy(Float_t* data)
-{
-  Float_t x=fX1;
-  Float_t y=fY1;
-  if (x<fStartX-fStep||y<fStartY-fStep) return 0;
-  if (x>fStartX+fNCells*fCellSize||y>fStartY+fNCells*fCellSize) return 0;
-  Float_t v1=0;
-  Float_t v2=0;
-  Float_t v3=0;
-  Float_t v4=0;
-  Float_t sx=x-fStartX;
-  Float_t sy=y-fStartY;
-  Float_t dx=(sx-(((Int_t)(sx/fStep))*fStep))/fStep;
-  Float_t dy=(sy-(((Int_t)(sy/fStep))*fStep))/fStep;
-  Float_t sx2=sx+fStep;
-  Float_t sy2=sy+fStep;
-  Int_t cx=(Int_t)(sx/fCellSize);
-  Int_t cy=(Int_t)(sy/fCellSize);
-  Int_t cx2=(Int_t)(sx2/fCellSize);
-  Int_t cy2=(Int_t)(sy2/fCellSize);
-
-  sx-=cx*fCellSize;
-  sy-=cy*fCellSize;
-  sx2-=cx2*fCellSize;
-  sy2-=cy2*fCellSize;
-
-  Int_t ix=(Int_t)(sx/fStep);
-  Int_t iy=(Int_t)(sy/fStep);
-  Int_t ix2=(Int_t)(sx2/fStep);
-  Int_t iy2=(Int_t)(sy2/fStep);
-
-/*
-  cout << "(" << x << ", " << y << ") : (" << dx << ", " << dy << ")" << endl;
-  Int_t is;
-  Int_t im;
-  GetN(x, y, is, im);
-  cout << (ix+iy*iCellSize)+(cx+cy*fNCells)*fSize << " : " << im+is*fSize << endl;
-  GetN(x+fStep, y, is, im);
-  cout << (ix2+iy*iCellSize)+(cx2+cy*fNCells)*fSize << " : " << im+is*fSize << endl;
-  GetN(x, y+fStep, is, im);
-  cout << (ix+iy2*iCellSize)+(cx+cy2*fNCells)*fSize << " : " << im+is*fSize << endl;
-  GetN(x+fStep, y+fStep, is, im);
-  cout << (ix2+iy2*iCellSize)+(cx2+cy2*fNCells)*fSize << " : " << im+is*fSize << endl;
-*/
-  if (x>=fStartX&&y>=fStartY)
-    v1=data[(ix+iy*iCellSize)+(cx+cy*fNCells)*fSize];
-  if (x<fStartX+fNCells*fCellSize-fStep)
-  {
-    v2=data[(ix2+iy*iCellSize)+(cx2+cy*fNCells)*fSize];
-    if (y<fStartY+fNCells*fCellSize-fStep)
-    {
-      if (x>=fStartX) v3=data[(ix+iy2*iCellSize)+(cx+cy2*fNCells)*fSize];
-      v4=data[(ix2+iy2*iCellSize)+(cx2+cy2*fNCells)*fSize];
-    }
-  }
-  else
-  if (y<fStartY+fNCells*fCellSize-fStep&&x>=fStartX)
-    v3=data[(ix+iy2*iCellSize)+(cx+cy2*fNCells)*fSize];
-
-//  cout << v1 << ", " << v2 << ", " << v3 << ", "  << v4 << ":" << v1+dx*(v2-v1)+dy*(v3-v1+dx*(v4-v3-v2+v1)) << endl;
-//  cout << fError << endl;
-  return v1+dx*(v2-v1)+dy*(v3-v1+dx*(v4-v3-v2+v1));
-//  return (1.0-dy)*(v1+dx*(v2-v1))+dy*(v3+dx*(v4-v3));
-}
-
-Int_t CbmEcalShLibCorrRecord::CorrelationN(Float_t x1, Float_t y1, Float_t x2, Float_t y2)
-{
-  Float_t sX=fStartX+fNCells*fCellSize;
-  Float_t sY=fStartY+fNCells*fCellSize;
-  if (x1<fStartX||y1<fStartY) return -1111;
-  if (x2<fStartX||y2<fStartY) return -1111;
-  if (x1>sX||y1>sY) return -1111;
-  if (x2>sX||y2>sY) return -1111;
-  Float_t sx1=x1-fStartX;
-  Float_t sy1=y1-fStartY;
-  Int_t cx1=(Int_t)(sx1/fCellSize);
-  Int_t cy1=(Int_t)(sy1/fCellSize);
-  Int_t is1=cx1+cy1*fNCells;
-  sx1-=cx1*fCellSize;
-  sy1-=cy1*fCellSize;
-  Int_t ix1=(Int_t)(sx1/fStep);
-  Int_t iy1=(Int_t)(sy1/fStep);
-/* 11.08.22 //Dr.Sys
-  Float_t sx2=x2-fStartX;
-  Float_t sy2=y2-fStartY;
-  Int_t cx2=(Int_t)(sx2/fCellSize);
-  Int_t cy2=(Int_t)(sy2/fCellSize);
-  Int_t is2=cx2+cy2*fNCells;
-  sx2-=cx2*fCellSize;
-  sy2-=cy2*fCellSize;
-  Int_t ix2=(Int_t)(sx2/fStep);
-  Int_t iy2=(Int_t)(sy2/fStep);
-*/
-  Float_t dx=x2-x1;
-  Int_t idx=(Int_t)((dx*1.00001)/fCellSize);
-  Float_t dy=y2-y1;
-  Int_t idy=(Int_t)((dy*1.00001)/fCellSize);
-  Int_t nis2=(idx+cx1)+(idy+cy1)*fNCells;
-/*
-  if (nis2!=is2)
-  {
-    cout << "-1212:	"<< ix1 << ":" << ix2 << ", " << iy1 << ":" << iy2 << endl;
-    cout << "	" << x1 << ":" << x2 << ", " << y1 << ":" << y2 << endl;
-    cout << "	" << is1 << ":" << is2 << endl;
-    cout << "id:	" << idx << ":" << idy << "->" << nis2 << "(" << dx << ";" << dy << ")" << endl; 
-  }
-*/
-  //Wrong input data
-  if (TMath::Abs(dx-idx*fCellSize)>1e-4||TMath::Abs(dy-idy*fCellSize)>1e-4)
-  {
-//    cout << "-1112:" << (dx-idx*fCellSize) << " : " << (dy-idy*fCellSize) << endl;
-    fError=-1112;
-    return -1112;
-  }
-/* 11.08.22 //Dr.Sys
-  //Wrong input data
-  if (ix1!=ix2||iy1!=iy2)
-  {
-    cout << "-1112:	"<< ix1 << ":" << ix2 << ", " << iy1 << ":" << iy2 << endl;
-    cout << "	" << x1 << ":" << x2 << ", " << y1 << ":" << y2 << endl;
-    cout << "	" << is1 << ":" << is2 << endl;
-    fError=-1112;
-    return -1112;
-  }
-*/
-//  cout << sx1 << ", " << sy1 << endl;
-//  cout << sx2 << ", " << sy2 << endl;
-//  cout << ix1 << ", " << iy1 << ": " << is1 << ", " << is2 << endl;
-//  cout << fSize << " : " << iCellSize << " : "  << fNCells2 << endl;
-  return (ix1+iCellSize*iy1)+fSize*(is1+nis2*fNCells2);
-}
-
-
-Float_t CbmEcalShLibCorrRecord::Correlation(Float_t* corr)
-{
-  Float_t x1=fX1;
-  Float_t y1=fY1;
-  Float_t x2=fX2;
-  Float_t y2=fY2;
-  Float_t v1=0;
-  Float_t v2=0;
-  Float_t v3=0;
-  Float_t v4=0;
-
-  // TODO: Test!!!!!
-  // 1
-  Int_t n1=CorrelationN(x1, y1, x2, y2);
-  if (-1112==n1) return -1112;
-  if (-1111!=n1) v1=corr[n1];
-
-  // 2
-  Int_t n2=CorrelationN(x1+fStep+0.001, y1, x2+fStep+0.001, y2);
-  if (-1112==n2)
-  { 
-    if (-1111!=n1)
-    {
-      cerr << "n2: (" << x1 << ", " << y1 << "), (" << x2 << ", " << y2 << ")" << endl;
-      cerr << "-1112 returned. Check floating point errors." << endl;
-    }
-    return -1112;
-  }
-  if (-1111!=n2) v2=corr[n2];
-
-  // 3
-  Int_t n3=CorrelationN(x1, y1+fStep+0.001, x2, y2+fStep+0.001);
-  if (-1112==n3)
-  { 
-    if (-1111!=n2)
-    {
-      cerr << "n3: (" << x1 << ", " << y1 << "), (" << x2 << ", " << y2 << ")" << endl;
-      cerr << "-1112 returned. Check floating point errors." << endl;
-    }
-    return -1112;
-  }
-  if (-1111!=n3) v3=corr[n3];
-
-  // 4
-  Int_t n4=CorrelationN(x1+fStep+0.001, y1+fStep+0.001, x2+fStep+0.001, y2+fStep+0.001);
-  if (-1112==n4)
-  { 
-    if (-1111!=n1)
-    {
-      cerr << "n4: (" << x1 << ", " << y1 << "), (" << x2 << ", " << y2 << ")" << endl;
-      cerr << "-1112 returned. Check floating point errors." << endl;
-    }
-    return -1112;
-  }
-  if (-1111!=n4) v4=corr[n4];
-
-  Float_t dx=(x1-(((Int_t)TMath::FloorNint(x1/fStep))*fStep))/fStep;
-  Float_t dy=(y1-(((Int_t)TMath::FloorNint(y1/fStep))*fStep))/fStep;
-
-//  cout << x1 << ", " << y1 << " : " << dx << ", " << dy << endl;
-//  cout << v1 << ", " << v2 << ", " << v3 << ", "  << v4 << ":" << v1+dx*(v2-v1)+dy*(v3-v1+dx*(v4-v3-v2+v1)) << endl;
-//  cout << "->" << n1 << " : " << v1 << endl;
-//  cout << "->" << n2 << " : " << v2 << endl;
-//  cout << "->" << n3 << " : " << v3 << endl;
-//  cout << "->" << n4 << " : " << v4 << endl;
-//  cout << fError << " : " << v1+dx*(v2-v1)+dy*(v3-v1+dx*(v4-v3-v2+v1)) << endl;
-  return v1+dx*(v2-v1)+dy*(v3-v1+dx*(v4-v3-v2+v1));
-}
-
-void CbmEcalShLibCorrRecord::DrawTest(Float_t, Float_t, Float_t)
-{
-  ;
-}
-
-Float_t CbmEcalShLibCorrRecord::Energy(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e)
-{
-  fError=0;
-  fCEnergy=1;
-  fX1=x;  fY1=y;
-
-  return Get(phi, theta, e);
-}
-
-Float_t CbmEcalShLibCorrRecord::Correlation(Float_t x1, Float_t y1, Float_t x2, Float_t y2, Float_t phi, Float_t theta, Float_t e)
-{
-  fError=0;
-  fCEnergy=0;
-  fX1=x1;  fY1=y1;  fX2=x2;  fY2=y2;
-  return Get(phi, theta, e);
-}
-CbmEcalShLibCorrRecord::~CbmEcalShLibCorrRecord()
-{
-  delete [] fE;
-  delete [] fTheta;
-  delete [] fPhi;
-}
-
-ClassImp(CbmEcalShLibCorrRecord)
diff --git a/ecal/CbmEcalShLibCorrRecord.h b/ecal/CbmEcalShLibCorrRecord.h
deleted file mode 100644
index 92b92e9d70625e8b47300b33eb54e071289ffedf..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibCorrRecord.h
+++ /dev/null
@@ -1,132 +0,0 @@
-#ifndef CBMECALSHLIBCORRRECORD_H
-#define CBMECALSHLIBCORRRECORD_H
-
-#include "TObject.h"
-
-//#include <iostream>
-
-class CbmEcalShLibCorrRecord : public TObject
-{
-public:
-  CbmEcalShLibCorrRecord(const char* filename, Int_t verb=0);
-  Float_t CellSize() const {return fCellSize;}
-  Float_t Energy(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e);
-  Float_t Correlation(Float_t x1, Float_t y1, Float_t x2, Float_t y2, Float_t phi, Float_t theta, Float_t e);
-  void DrawTest(Float_t phi, Float_t theta, Float_t e);
-  virtual ~CbmEcalShLibCorrRecord();
-  Int_t fError;
-private:
-  Float_t Get(Float_t phi, Float_t theta, Float_t e);
-  Float_t GetE(Float_t phi, Float_t theta, Int_t e);
-  Float_t GetETheta(Float_t phi, Int_t theta, Int_t e);
-  Int_t GetN(Int_t phi, Int_t theta, Int_t e) { return phi+fNPhi*(theta+fNTheta*e); }
-  Float_t Energy(Float_t* data);
-  Float_t Correlation(Float_t* corr);
-  Int_t CorrelationN(Float_t x1, Float_t y1, Float_t x2, Float_t y2);
-
-
-  Float_t fCellSize;
-  Int_t fNE;
-  Float_t* fE;			//!
-
-  Int_t fNTheta;
-  Float_t* fTheta;		//!
-
-  Int_t fNPhi;
-  Float_t* fPhi;		//!
-  
-  Float_t fStep;
-  Int_t iCellSize;
-  Float_t fEndX;
-  Float_t fStartX;
-
-  Float_t fEndY;
-  Float_t fStartY;
-
-  Int_t fNCells;
-  Int_t fNCells2;
-
-  Int_t fSizeData;
-  Int_t fSizeCorr;
-
-  // iCellSize*iCellSize
-  Int_t fSize;
-
-  Int_t fN;
-
-  Int_t fVerbose;
-
-  // Response and correlation data
-  Float_t** fData;		//!
-  Float_t** fCorr;		//!
-
-  // For caching 
-  Float_t fX1;
-  Float_t fX2;
-  Float_t fY1;
-  Float_t fY2;
-  Int_t fCEnergy;
-
-  CbmEcalShLibCorrRecord(const CbmEcalShLibCorrRecord&);
-  CbmEcalShLibCorrRecord& operator=(const CbmEcalShLibCorrRecord&);
-
-  ClassDef(CbmEcalShLibCorrRecord, 1);
-};
-
-inline Float_t CbmEcalShLibCorrRecord::Get(Float_t phi, Float_t theta, Float_t e)
-{
-  Int_t i=0;
-  for(;i<fNE;i++)
-    if (fE[i]>=e)
-      break;
-//  std::cout << i << std::endl;
-  if (i==fNE) return GetE(phi, theta, fNE-1);
-  if (i==0) return GetE(phi, theta, 0);
-  Float_t t=fE[i]-fE[i-1];
-  Float_t d=(fE[i]-e)/t;
-//  std::cout << phi << " " << theta << " " << e << std::endl;
-//  std::cout << t << " " << d << std::endl;
-//  std::cout <<  GetE(phi, theta, i) << std::endl;
-//  std::cout <<  GetE(phi, theta, i-1) << std::endl;
-  return GetE(phi, theta, i)*(1.0-d)+GetE(phi, theta, i-1)*d;
-}
-
-inline Float_t CbmEcalShLibCorrRecord::GetE(Float_t phi, Float_t theta, Int_t e)
-{
-  Int_t i=0;
-  for(;i<fNTheta;i++)
-    if (fTheta[i]>=theta)
-      break;
-//  if (i==fNTheta||i==0) return 0;
-  if (i==fNTheta) return GetETheta(phi, fNTheta-1, e);
-  if (i==0) return GetETheta(phi, 0, e);
-  Float_t t=fTheta[i]-fTheta[i-1];
-  Float_t d=(fTheta[i]-theta)/t;
-//  std::cout << i << " --- " << cTheta[i] <<" "<< d << std::endl;
-  return GetETheta(phi, i, e)*(1.0-d)+GetETheta(phi, i-1, e)*d;
-}
-
-inline Float_t CbmEcalShLibCorrRecord::GetETheta(Float_t phi, Int_t theta, Int_t e)
-{
-  Float_t dphi=fPhi[1]-fPhi[0];
-  Float_t t=phi/dphi;
-  Int_t n=(Int_t)(t);
-  Float_t d=t-n;
-  Int_t n1=GetN(n, theta, e);
-  if (n==fNPhi-1)
-  {
-    if (fCEnergy)
-      return Energy(fData[n1]);
-    else
-      return Correlation(fCorr[n1]);
-  }
-  Int_t n2=GetN(n+1, theta, e);
-
-//  std::cout << "Serial numbers " << n1 << " --- " << n2 << ":" << phi << " is " << n << std::endl;
-  if (fCEnergy)
-    return Energy(fData[n1])*(1.0-d)+d*Energy(fData[n2]);
-  else
-    return Correlation(fCorr[n1])*(1.0-d)+d*Correlation(fCorr[n2]);
-}
-
-#endif
diff --git a/ecal/CbmEcalShLibCorrTable.cxx b/ecal/CbmEcalShLibCorrTable.cxx
deleted file mode 100644
index e70ff88b9a4553c5accd9e2f04e09603d9cedb07..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibCorrTable.cxx
+++ /dev/null
@@ -1,198 +0,0 @@
-#include "CbmEcalShLibCorrTable.h"
-
-#include "CbmEcalShLibCorrRecord.h"
-#include "CbmEcalInf.h"
-
-#include "FairRootManager.h"
-
-#include "TSystem.h"
-#include "TString.h"
-
-#include <iostream>
-
-using namespace std;
-
-CbmEcalShLibCorrTable::CbmEcalShLibCorrTable(const char* name, Int_t verb)
-  : CbmEcalShLibCorr(name, verb),
-    fFiles(),
-    fRec()
-{
-  Int_t i;
-
-  for(i=0;i<10;i++)
-    fRec[i]=NULL;
-}
-
-void CbmEcalShLibCorrTable::Add(const char* name)
-{
-  TString str=name;
-  CbmEcalShLibCorrRecord* rec;
-  static CbmEcalInf* inf=CbmEcalInf::GetInstance(NULL);
-  if (inf==NULL)
-  {
-    Fatal("CbmEcalShLibCorrTable", "Can't find CbmEcalInf in the system.");
-    return;
-  }
-  Double_t msize;
-  Int_t num;
-
-  gSystem->ExpandPathName(str);
-  rec=new CbmEcalShLibCorrRecord(str, fVerbose);
-  msize=inf->GetModuleSize();
-  num=(Int_t)((msize+0.001)/rec->CellSize());
-  if (num<0||num>9)
-  {
-    Fatal("CbmEcalShLibCorrTable", "Wrong cell number. CellSize is %f.", rec->CellSize());
-    return;
-  }
-  fRec[num]=rec;
-}
-
-InitStatus CbmEcalShLibCorrTable::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (fManager==NULL)
-  {
-    Fatal("Init", "Can't find IOManager in the system.");
-    return kFATAL;
-  }
-  fManager->Register(LibraryName(), "ECAL", this, kFALSE);
-  for(list<TString>::const_iterator p=fFiles.begin(); p!=fFiles.end();++p)
-    Add((*p).Data());
-
-  return kSUCCESS;
-}
-
-Float_t CbmEcalShLibCorrTable::GetResponse(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e, Int_t celltype)
-{
-//  Info("Getresponse", "Here");
-  if (fRec[celltype]==NULL)
-    return -1111;
-  static CbmEcalInf* inf=CbmEcalInf::GetInstance(NULL);
-  static Float_t msize=inf->GetModuleSize();
-  Float_t csize=msize/celltype;
-  Float_t tx=x;
-  Float_t ty=y;
-  Float_t tphi=phi;
-  Float_t t;
-  if (tphi>180.0)
-  {
-    tphi=360.0-tphi;
-    ty=-ty; ty-=csize;
-  }
-  if (tphi>90.0)
-  {
-    tphi=180.0-tphi;
-    tx=-tx; tx-=csize;
-  }
-  if (tphi>45.0)
-  {
-    tphi=90.0-tphi;
-    t=tx;
-    tx=ty;
-    ty=t;
-  }
-
-  return fRec[celltype]->Energy(tx, ty, tphi, theta, e);
-}
-
-Float_t CbmEcalShLibCorrTable::Correlation(Float_t x1, Float_t y1, Float_t x2, Float_t y2, Float_t phi, Float_t theta, Float_t e, Int_t celltype)
-{
-  if (fRec[celltype]==NULL)
-    return -1111;
-  static CbmEcalInf* inf=CbmEcalInf::GetInstance(NULL);
-  static Float_t msize=inf->GetModuleSize();
-  Float_t csize=msize/celltype;
-  Float_t tx1=x1;
-  Float_t tx2=x2;
-  Float_t ty1=y1;
-  Float_t ty2=y2;
-  Float_t tphi=phi;
-  Float_t t;
-  if (tphi>180.0)
-  {
-    tphi=360.0-tphi;
-    ty1=-ty1; ty1-=csize;
-    ty2=-ty2; ty2-=csize;
-  }
-  if (tphi>90.0)
-  {
-    tphi=180.0-tphi;
-    tx1=-tx1; tx1-=csize;
-    tx2=-tx2; tx2-=csize;
-  }
-  if (tphi>45.0)
-  {
-    tphi=90.0-tphi;
-    t=tx1; tx1=ty1; ty1=t;
-    t=tx2; tx2=ty2; ty2=t;
-  }
-
-  t=fRec[celltype]->Correlation(tx1, ty1, tx2, ty2, tphi, theta, e);
-
-//TODO!!!
-  return t;
-}
-
-
-Float_t CbmEcalShLibCorrTable::Correlation2(Float_t x1, Float_t y1, Float_t x2, Float_t y2, Float_t phi, Float_t theta, Float_t e, Int_t celltype)
-{
-  if (fRec[celltype]==NULL)
-    return -1111;
-  if (fRec[celltype/2]==NULL)
-    return -1111;
-  static CbmEcalInf* inf=CbmEcalInf::GetInstance(NULL);
-  static Float_t msize=inf->GetModuleSize();
-  Float_t csize=msize/celltype;
-  Float_t tx1=x1;
-  Float_t tx2=x2;
-  Float_t ty1=y1;
-  Float_t ty2=y2;
-  Float_t tphi=phi;
-  Float_t t;
-  Float_t d=inf->GetModuleSize()/celltype;
-  Float_t tx3=x2+d;
-  Float_t ty3=y2+d;
-  if (tphi>180.0)
-  {
-    tphi=360.0-tphi;
-    ty1=-ty1; ty1-=csize;
-    ty2=-ty2; ty2-=csize;
-    ty3=-ty3; ty3-=csize;
-  }
-  if (tphi>90.0)
-  {
-    tphi=180.0-tphi;
-    tx1=-tx1; tx1-=csize;
-    tx2=-tx2; tx2-=csize;
-    tx3=-tx3; tx3-=csize;
-  }
-  if (tphi>45.0)
-  {
-    tphi=90.0-tphi;
-    t=tx1; tx1=ty1; ty1=t;
-    t=tx2; tx2=ty2; ty2=t;
-    t=tx3; tx3=ty3; ty3=t;
-  }
-
-//  cout << "(" << x1 << "," << y1 << ");(" << x2 << "," << y2 << ")";
-//  cout << ":phi=" << phi << endl;
-//  cout << "(" << tx1 << "," << ty1 << ");(" << tx2 << "," << ty2 << ")" << endl;
-//  cout << ":" << tx3 << "," << ty3 << endl;
-  t =fRec[celltype]->Correlation(tx1, ty1, tx2, ty2, tphi, theta, e);
-  t+=fRec[celltype]->Correlation(tx1, ty1, tx3, ty2, tphi, theta, e);
-  t+=fRec[celltype]->Correlation(tx1, ty1, tx2, ty3, tphi, theta, e);
-  t+=fRec[celltype]->Correlation(tx1, ty1, tx3, ty3, tphi, theta, e);
-
-//TODO!!!
-  return t;
-}
-
-CbmEcalShLibCorrTable::~CbmEcalShLibCorrTable()
-{
-  Int_t i;
-  for(i=0;i<10;i++)
-    delete fRec[i];
-}
-
-ClassImp(CbmEcalShLibCorrTable)
diff --git a/ecal/CbmEcalShLibCorrTable.h b/ecal/CbmEcalShLibCorrTable.h
deleted file mode 100644
index cfd89df6083bf98ca8bef791029801895461bc3c..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibCorrTable.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef CBMECALSHLIBCORRTABLE_H
-#define CBMECALSHLIBCORRTABLE_H
-
-#include "CbmEcalShLibCorr.h"
-
-#include "FairTask.h"
-
-#include <list>
-
-class CbmEcalShLibCorrRecord;
-
-class CbmEcalShLibCorrTable : public CbmEcalShLibCorr
-{
-public:
-  CbmEcalShLibCorrTable(const char* name, Int_t verb);
-  void AddFile(const char* name) {fFiles.push_back(name);}
-  CbmEcalShLibCorrRecord* GetRec(Int_t i) const;
-
-  // Response to photon with energy e, polar angle phi (rad), impact angle
-  // theta (rad). X, Y are position vs. photons impact point
-  // Cell is a size os cell in cm.
-  virtual Float_t GetResponse(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e, Int_t celltype=0);
-  virtual Float_t Correlation(Float_t x1, Float_t y1, Float_t x2, Float_t y2, Float_t phi, Float_t theta, Float_t e, Int_t celltype=0);
-  virtual Float_t Correlation2(Float_t x1, Float_t y1, Float_t x2, Float_t y2, Float_t phi, Float_t theta, Float_t e, Int_t celltype=0);
-  virtual InitStatus Init();
-  void Exec(Option_t*) {};
-  void Finish() {};
-  virtual ~CbmEcalShLibCorrTable();
-private:
-  void Add(const char* name);
-
-  /** Silence compiler warnings **/
-  void Add(TTask*) {;}
-
-  std::list<TString> fFiles;
-  CbmEcalShLibCorrRecord* fRec[10];
-
-  CbmEcalShLibCorrTable(const CbmEcalShLibCorrTable&);
-  CbmEcalShLibCorrTable& operator=(const CbmEcalShLibCorrTable&);
-
-  ClassDef(CbmEcalShLibCorrTable, 1);
-};
-
-inline CbmEcalShLibCorrRecord* CbmEcalShLibCorrTable::GetRec(Int_t i) const
-{
-  if (i<0||i>9) return NULL;
-  return fRec[i];
-}
-
-#endif
diff --git a/ecal/CbmEcalShLibNN.cxx b/ecal/CbmEcalShLibNN.cxx
deleted file mode 100644
index f06190050de49abcd212f24631e08ac44c9bb53e..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibNN.cxx
+++ /dev/null
@@ -1,114 +0,0 @@
-#include "CbmEcalShLibNN.h"
-
-#include "CbmEcalInf.h"
-
-#include "FairRootManager.h"
-
-#include "TSystem.h"
-#include "TString.h"
-#include "TTree.h"
-#include "TMath.h"
-#include "TMultiLayerPerceptron.h"
-
-#include <iostream>
-
-using namespace std;
-
-CbmEcalShLibNN::CbmEcalShLibNN(const char* name, Int_t verb)
-  : CbmEcalShLib(name, verb),
-    fRec(), fTr()
-{
-  Int_t i;
-
-  for(i=0;i<10;i++)
-  {
-    fRec[i]=NULL;
-    fTr[i]=0;
-  }
-}
-
-void CbmEcalShLibNN::AddRecord(const char* name, const char* fname, Int_t celltype)
-{
-  if (celltype>9||celltype<1)
-  {
-    Fatal("CbmEcalShLibNN", "Bad celltype: %d", celltype);
-    return;
-  }
-
-  TString str=fname;
-  TTree* tr=new TTree(name, "Temporary tree. Should no be saved");
-  Float_t x;
-  Float_t y;
-  Float_t theta;
-//  Float_t e;
-  Float_t phi;
-  Float_t resp;
-  TMultiLayerPerceptron* net;
-
-  tr->Branch("x", &x, "x/F");
-  tr->Branch("y", &y, "y/F");
-  tr->Branch("e", &x, "e/F");
-  tr->Branch("theta", &theta, "theta/F");
-  tr->Branch("phi", &phi, "phi/F");
-  tr->Branch("resp", &resp, "resp/F");
-
-  gSystem->ExpandPathName(str);
-  net=new TMultiLayerPerceptron("x,y,psi,theta,e:10:25:resp", tr, "1", "", TNeuron::kGauss);
-  net->LoadWeights(str);
-
-  fRec[celltype]=net;
-  fTr[celltype]=tr;
-}
-
-InitStatus CbmEcalShLibNN::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (fManager==NULL)
-  {
-    Fatal("Init", "Can't find IOManager in the system.");
-    return kFATAL;
-  }
-  fManager->Register(LibraryName(), "ECAL", this, kFALSE);
-
-  return kSUCCESS;
-}
-
-Float_t CbmEcalShLibNN::GetResponse(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e, Int_t celltype)
-{
-//  Info("Getresponse", "Here");
-  if (fRec[celltype]==NULL)
-    return -1111;
-  Double_t tx=x;
-  Double_t ty=y;
-  Double_t tphi=phi;
-  Double_t t;
-  Double_t par[5];
-  if (tphi>180.0)
-  {
-    tphi=360.0-tphi;
-    ty=-ty;
-  }
-  if (tphi>90.0)
-  {
-    tphi=180.0-tphi;
-    tx=-tx;
-  }
-  if (tphi>45.0)
-  {
-    tphi=90.0-tphi;
-    t=tx;
-    tx=ty;
-    ty=t;
-  }
-
-  par[0]=tx; par[1]=ty; par[2]=tphi*TMath::DegToRad(); par[3]=theta*TMath::DegToRad(); par[4]=e;
-  return fRec[celltype]->Evaluate(0, par)*e;
-}
-
-CbmEcalShLibNN::~CbmEcalShLibNN()
-{
-  Int_t i;
-  for(i=0;i<10;i++)
-    delete fRec[i];
-}
-ClassImp(CbmEcalShLibNN)
diff --git a/ecal/CbmEcalShLibNN.h b/ecal/CbmEcalShLibNN.h
deleted file mode 100644
index a8e7f6f4979ddd6cbaa32f3861ce69b8158ad7bc..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibNN.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef CBMECALSHLIBNN_H
-#define CBMECALSHLIBNN_H
-
-#include "CbmEcalShLib.h"
-
-#include "FairTask.h"
-
-#include <list>
-
-class TTree;
-class TMultiLayerPerceptron;
-
-class CbmEcalShLibNN : public CbmEcalShLib
-{
-public:
-  CbmEcalShLibNN(const char* name, Int_t verb);
-  void AddRecord(const char* name, const char* fname, Int_t celltype);
-  TMultiLayerPerceptron* GetRec(Int_t i) const;
-
-  // Response to photon with energy e, polar angle phi (rad), impact angle
-  // theta (rad). X, Y are position vs. photons impact point
-  // Cell is a size os cell in cm.
-  virtual Float_t GetResponse(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e, Int_t celltype=0);
-  virtual InitStatus Init();
-  void Exec(Option_t*) {};
-  void Finish() {};
-  virtual ~CbmEcalShLibNN();
-private:
-  TMultiLayerPerceptron* fRec[10];	//!
-  TTree* fTr[10];			//!
-
-  CbmEcalShLibNN(const CbmEcalShLibNN&);
-  CbmEcalShLibNN& operator=(const CbmEcalShLibNN&);
-
-  ClassDef(CbmEcalShLibNN, 1);
-};
-
-inline TMultiLayerPerceptron* CbmEcalShLibNN::GetRec(Int_t i) const
-{
-  if (i<0||i>9) return NULL;
-  return fRec[i];
-}
-
-#endif
diff --git a/ecal/CbmEcalShLibRecord.cxx b/ecal/CbmEcalShLibRecord.cxx
deleted file mode 100644
index fe964a6d59f97bc21ec439d02f7478dd92c7072e..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibRecord.cxx
+++ /dev/null
@@ -1,136 +0,0 @@
-#include "CbmEcalShLibRecord.h"
-
-#include "TFile.h"
-#include "TTree.h"
-#include "TH2D.h"
-
-#include <iostream>
-
-using namespace std;
-
-CbmEcalShLibRecord::CbmEcalShLibRecord(const char* filename, Int_t verb)
-  : TObject(),
-    fCellSize(0.),
-    fNE(0),
-    fE(NULL),
-    fNTheta(0),
-    fTheta(NULL),
-    fNPhi(0),
-    fPhi(NULL),
-    fNX(0),
-    fStepX(0.),
-    fStartX(0.),
-    fNY(0),
-    fStepY(0.),
-    fStartY(0.),
-    fVerbose(verb),
-    fN(0),
-    fR(NULL)
-{
-  TFile* f=new TFile(filename);
-  TTree* info;
-  TTree* data;
-  Float_t t;
-  Int_t i;
-
-
-  Info("CbmEcalShLibRecord", "Loading %s...", filename);
-  if (f->IsZombie())
-  {
-    Fatal("CbmEcalShLibRecord", "File %s not found.", filename);
-    return;
-  }
-  info=(TTree*)f->Get("info");
-  info->SetBranchAddress("nx", &fNX);
-  info->SetBranchAddress("startx", &fStartX);
-  info->SetBranchAddress("stepx", &fStepX);
-  info->SetBranchAddress("ny", &fNY);
-  info->SetBranchAddress("starty", &fStartY);
-  info->SetBranchAddress("stepy", &fStepY);
-  info->SetBranchAddress("ne", &fNE);
-  info->SetBranchAddress("nphi", &fNPhi);
-  info->SetBranchAddress("ntheta", &fNTheta);
-  info->SetBranchAddress("n", &fN);
-  info->SetBranchAddress("cellsize", &fCellSize);
-  info->GetEntry(0);
-  if (fN!=fNX*fNY*fNE*fNPhi*fNTheta)
-  {
-    Fatal("CbmEcalShLibRecord", "Consistency check failed.");
-    return;
-  }
-  fE=new Float_t[fNE];
-  fTheta=new Float_t[fNTheta];
-  fPhi=new Float_t[fNPhi];
-  info->SetBranchAddress("e", fE);
-  info->SetBranchAddress("phi", fPhi);
-  info->SetBranchAddress("theta", fTheta);
-  info->GetEntry(0);
-  fR=new Float_t[fN];
-  data=(TTree*)f->Get("shlib");
-  data->SetBranchAddress("dta", &t);
-  if (fN!=data->GetEntries())
-  {
-    Fatal("CbmEcalShLibRecord", "Info and data trees inconsitant.");
-    return;
-  }
-  for(i=0;i<fN;i++)
-  {
-    data->GetEntry(i);
-    fR[i]=t;
-  }
-  f->Close();
-
-  if (fVerbose>99)
-  {
-    cout << "Information tree read." << endl;
-    cout << "	n	= " << fN << endl;
-    cout << "	cellsize= " << fCellSize << endl;
-    cout << "	nx	= " << fNX << endl;
-    cout << "	startx	= " << fStartX << endl;
-    cout << "	stepx	= " << fStepX << endl;
-    cout << "	ny	= " << fNY << endl;
-    cout << "	starty	= " << fStartY << endl;
-    cout << "	stepy	= " << fStepY << endl;
-    cout << "	nphi	= " << fNPhi << " : (";
-    for(i=0;i<fNPhi;i++)
-      if (i!=0) cout << ", " << fPhi[i]; else cout << fPhi[i];
-    cout << ")" << endl; 
-    cout << "	ntheta	= " << fNTheta << " : (";
-    for(i=0;i<fNTheta;i++)
-      if (i!=0) cout << ", " << fTheta[i]; else cout << fTheta[i];
-    cout << ")" << endl; 
-    cout << "	ne	= " << fNE << " : (";
-    for(i=0;i<fNE;i++)
-      if (i!=0) cout << ", " << fE[i]; else cout << fE[i];
-    cout << ")" << endl; 
-  }
-}
-
-void CbmEcalShLibRecord::DrawTest(Float_t phi, Float_t theta, Float_t e)
-{
-  TH2D* h;
-  Float_t x;
-  Float_t y;
-  Int_t ix;
-  Int_t iy;
-  h=new TH2D("ht","", fNX, fStartX, fStartX+fNX*fStepX, fNY, fStartY, fStartY+fStepY*fNY);
-  h->SetStats(kFALSE);
-  for(ix=0;ix<fNX;ix++)
-  for(iy=0;iy<fNX;iy++)
-  {
-    x=(ix+0.5)*fStepX+fStartX;
-    y=(iy+0.5)*fStepY+fStartY;
-    h->SetBinContent(h->FindBin(x, y), GetVal(x, y, phi, theta, e));
-  }
-  h->DrawCopy("colz");
-  delete h;
-}
-CbmEcalShLibRecord::~CbmEcalShLibRecord()
-{
-  delete fR;
-  delete fE;
-  delete fTheta;
-  delete fPhi;
-}
-
-ClassImp(CbmEcalShLibRecord)
diff --git a/ecal/CbmEcalShLibRecord.h b/ecal/CbmEcalShLibRecord.h
deleted file mode 100644
index 589bb4d5fc734be4288ea065d391ced0a3220fd1..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibRecord.h
+++ /dev/null
@@ -1,125 +0,0 @@
-#ifndef CBMECALSHLIBRECORD_H
-#define CBMECALSHLIBRECORD_H
-
-#include "TObject.h"
-
-class CbmEcalShLibRecord : public TObject
-{
-public:
-  CbmEcalShLibRecord(const char* filename, Int_t verb=0);
-  Float_t CellSize() const {return fCellSize;}
-  Float_t GetVal(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e) const;
-  void DrawTest(Float_t phi, Float_t theta, Float_t e);
-  virtual ~CbmEcalShLibRecord();
-private:
-  Float_t GetValX(Int_t x, Float_t y, Float_t phi, Float_t theta, Float_t e) const;
-  Float_t GetValXY(Int_t x, Int_t y, Float_t phi, Float_t theta, Float_t e) const;
-  Float_t GetValXYTheta(Int_t x, Int_t y, Float_t phi, Int_t theta, Float_t e) const;
-  Float_t GetValXYThetaE(Int_t x, Int_t y, Float_t phi, Int_t theta, Int_t e) const;
-
-  Float_t fCellSize;
-  Int_t fNE;
-  Float_t* fE;			//!
-
-  Int_t fNTheta;
-  Float_t* fTheta;		//!
-
-  Int_t fNPhi;
-  Float_t* fPhi;		//!
-  
-  Int_t fNX;
-  Float_t fStepX;
-  Float_t fStartX;
-
-  Int_t fNY;
-  Float_t fStepY;
-  Float_t fStartY;
-
-  Int_t fVerbose;
-
-  Int_t fN;
-  Float_t* fR;			//!
-
-  CbmEcalShLibRecord(const CbmEcalShLibRecord&);
-  CbmEcalShLibRecord& operator=(const CbmEcalShLibRecord&);
-
-  ClassDef(CbmEcalShLibRecord, 1);
-};
-
-inline Float_t CbmEcalShLibRecord::GetValXYThetaE(Int_t x, Int_t y, Float_t phi, Int_t theta, Int_t e) const
-{
-  static Float_t dphi=fPhi[1]-fPhi[0];
-//  static Float_t oldphi=-1111;
-  Float_t t=phi/dphi;
-  Int_t n=(Int_t)(t);
-  Float_t d=t-n;
-  Int_t n1=x+fNX*(y+fNY*(n+fNPhi*(theta+fNTheta*e)));
-  Int_t n2=n1+fNX*fNY;
-/*
-  if (oldphi!=phi)
-  {
-    oldphi=phi;
-    cout << phi << "	" << n << " --- " << n1 << endl;
-  }
-  cout << x << ", " << y << ", " << n << ", " << theta << ", " << e << endl;
-*/
-  return fR[n1]*(1.0-d)+fR[n2]*d;
-}
-
-inline Float_t CbmEcalShLibRecord::GetValXYTheta(Int_t x, Int_t y, Float_t phi, Int_t theta, Float_t e) const
-{
-  Int_t i=0;
-  for(;i<fNE;i++)
-    if (fE[i]>=e)
-      break;
-//  cout << i << endl;
-  if (i==fNE) return GetValXYThetaE(x, y, phi, theta, fNE-1);
-  if (i==0) return GetValXYThetaE(x, y, phi, theta, 0);
-  Float_t t=fE[i]-fE[i-1];
-  Float_t d=(fE[i]-e)/t;
-  return GetValXYThetaE(x, y, phi, theta, i)*(1.0-d)+GetValXYThetaE(x, y, phi, theta, i-1)*d;
-}
-
-inline Float_t CbmEcalShLibRecord::GetValXY(Int_t x, Int_t y, Float_t phi, Float_t theta, Float_t e) const 
-{
-  Int_t i=0;
-  for(;i<fNTheta;i++)
-    if (fTheta[i]>=theta)
-      break;
-//  if (i==fNTheta||i==0) return 0;
-  if (i==fNTheta) return GetValXYTheta(x, y, phi, fNTheta-1, e);
-  if (i==0) return GetValXYTheta(x, y, phi, 0, e);
-  Float_t t=fTheta[i]-fTheta[i-1];
-  Float_t d=(fTheta[i]-theta)/t;
-//  cout << i << " --- " << cTheta[i] <<" "<< d << endl;
-  return GetValXYTheta(x, y, phi, i, e)*(1.0-d)+GetValXYTheta(x, y, phi, i-1, e)*d;
-}
-
-inline Float_t CbmEcalShLibRecord::GetValX(Int_t x, Float_t y, Float_t phi, Float_t theta, Float_t e) const
-{
-  Float_t t=(y-fStartY)/fStepY;
-  Int_t n=(Int_t)(t);
-  if (n<0||n>=fNY) return 0;
-  Float_t d=t-n;
-  if (n+1==fNY)
-    return GetValXY(x, n, phi, theta, e)*(1.0-d);
-  else
-    return GetValXY(x, n, phi, theta, e)*(1.0-d)+d*GetValXY(x, n+1, phi, theta, e);
-}
-
-inline Float_t CbmEcalShLibRecord::GetVal(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e) const 
-{
-  Float_t t=(x-fStartX)/fStepX;
-  Int_t n=(Int_t)(t);
-  if (n<0||n>=fNX) return 0;
-  Float_t d=t-n;
-  if (n+1==fNX)
-    return GetValX(n, y, phi, theta, e)*(1.0-d);
-  else
-    return GetValX(n, y, phi, theta, e)*(1.0-d)+d*GetValX(n+1, y, phi, theta, e);
-}
-
-
-
-
-#endif
diff --git a/ecal/CbmEcalShLibTable.cxx b/ecal/CbmEcalShLibTable.cxx
deleted file mode 100644
index 13b138f01c26576ff7a9d50ceb1f5897788e8b77..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibTable.cxx
+++ /dev/null
@@ -1,102 +0,0 @@
-#include "CbmEcalShLibTable.h"
-
-#include "CbmEcalShLibRecord.h"
-#include "CbmEcalInf.h"
-
-#include "FairRootManager.h"
-
-#include "TSystem.h"
-#include "TString.h"
-
-#include <iostream>
-
-using namespace std;
-
-CbmEcalShLibTable::CbmEcalShLibTable(const char* name, Int_t verb)
-  : CbmEcalShLib(name, verb),
-    fFiles(),
-    fRec()
-{
-  Int_t i;
-
-  for(i=0;i<10;i++)
-    fRec[i]=NULL;
-}
-
-void CbmEcalShLibTable::Add(const char* name)
-{
-  TString str=name;
-  CbmEcalShLibRecord* rec;
-  static CbmEcalInf* inf=CbmEcalInf::GetInstance(NULL);
-  if (inf==NULL)
-  {
-    Fatal("CbmEcalShLibTable", "Can't find CbmEcalInf in the system.");
-    return;
-  }
-  Double_t msize;
-  Int_t num;
-
-  gSystem->ExpandPathName(str);
-  rec=new CbmEcalShLibRecord(str, fVerbose);
-  msize=inf->GetModuleSize();
-  num=(Int_t)((msize+0.001)/rec->CellSize());
-  if (num<0||num>9)
-  {
-    Fatal("CbmEcalShLibTable", "Wrong cell number. CellSize is %f.", rec->CellSize());
-    return;
-  }
-  fRec[num]=rec;
-}
-
-InitStatus CbmEcalShLibTable::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (fManager==NULL)
-  {
-    Fatal("Init", "Can't find IOManager in the system.");
-    return kFATAL;
-  }
-  fManager->Register(LibraryName(), "ECAL", this, kFALSE);
-  for(list<TString>::const_iterator p=fFiles.begin(); p!=fFiles.end();++p)
-    Add((*p).Data());
-
-  return kSUCCESS;
-}
-
-Float_t CbmEcalShLibTable::GetResponse(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e, Int_t celltype)
-{
-//  Info("Getresponse", "Here");
-  if (fRec[celltype]==NULL)
-    return -1111;
-  Float_t tx=x;
-  Float_t ty=y;
-  Float_t tphi=phi;
-  Float_t t;
-  if (tphi>180.0)
-  {
-    tphi=360.0-tphi;
-    ty=-ty;
-  }
-  if (tphi>90.0)
-  {
-    tphi=180.0-tphi;
-    tx=-tx;
-  }
-  if (tphi>45.0)
-  {
-    tphi=90.0-tphi;
-    t=tx;
-    tx=ty;
-    ty=t;
-  }
-
-  return fRec[celltype]->GetVal(tx, ty, tphi, theta, e)*e;
-}
-
-CbmEcalShLibTable::~CbmEcalShLibTable()
-{
-  Int_t i;
-  for(i=0;i<10;i++)
-    delete fRec[i];
-}
-ClassImp(CbmEcalShLibTable)
diff --git a/ecal/CbmEcalShLibTable.h b/ecal/CbmEcalShLibTable.h
deleted file mode 100644
index 51444cd7455fcda57ac3b87a08329be76e9f48dc..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShLibTable.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef CBMECALSHLIBTABLE_H
-#define CBMECALSHLIBTABLE_H
-
-#include "CbmEcalShLib.h"
-
-#include "FairTask.h"
-
-#include <list>
-
-class CbmEcalShLibRecord;
-
-class CbmEcalShLibTable : public CbmEcalShLib
-{
-public:
-  CbmEcalShLibTable(const char* name, Int_t verb);
-  void AddFile(const char* name) {fFiles.push_back(name);}
-  CbmEcalShLibRecord* GetRec(Int_t i) const;
-
-  // Response to photon with energy e, polar angle phi (rad), impact angle
-  // theta (rad). X, Y are position vs. photons impact point
-  // Cell is a size os cell in cm.
-  virtual Float_t GetResponse(Float_t x, Float_t y, Float_t phi, Float_t theta, Float_t e, Int_t celltype=0);
-  virtual InitStatus Init();
-  void Exec(Option_t*) {};
-  void Finish() {};
-  virtual ~CbmEcalShLibTable();
-private:
-  void Add(const char* name);
-
-  /** Silence compiler warnings **/
-  void Add(TTask*) {;}
-
-  std::list<TString> fFiles;
-  CbmEcalShLibRecord* fRec[10];
-
-  CbmEcalShLibTable(const CbmEcalShLibTable&);
-  CbmEcalShLibTable& operator=(const CbmEcalShLibTable&);
-
-  ClassDef(CbmEcalShLibTable, 1);
-};
-
-inline CbmEcalShLibRecord* CbmEcalShLibTable::GetRec(Int_t i) const
-{
-  if (i<0||i>9) return NULL;
-  return fRec[i];
-}
-
-#endif
diff --git a/ecal/CbmEcalShowerCalibrator.cxx b/ecal/CbmEcalShowerCalibrator.cxx
deleted file mode 100644
index fe1802714ed5e011cd989338c34be889004eff2b..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShowerCalibrator.cxx
+++ /dev/null
@@ -1,469 +0,0 @@
-#include "CbmEcalShowerCalibrator.h"
-
-#include "CbmGeoEcalPar.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalPointLite.h"
-#include "CbmEcal.h"
-
-#include "FairRunAna.h"
-#include "FairRuntimeDb.h"
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "TClonesArray.h"
-#include "TTree.h"
-#include "TDatabasePDG.h"
-#include "TParticlePDG.h"
-
-#include <iostream>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::flush;
-
-
-CbmEcalShowerCalibrator::CbmEcalShowerCalibrator()
-  : FairTask(),
-    fZPosition(-2),
-    fPDGCode(22), 
-    fLowEnergy(0.1), 
-    fOutCellSize(3.0), 
-    fSCurveRun(kFALSE),
-    fLitePoints(NULL),
-    fEcalPoints(NULL),
-    fMCTracks(NULL),
-    fTree(NULL),
-    fOutMCX(0.),
-    fOutMCY(0.),
-    fOutDX(0),
-    fOutDY(0),
-    fCellSize(0.),
-    fOutMCE(0.),
-    fOutMCPx(0.),
-    fOutMCPy(0.),
-    fOutMCPz(0.),
-    fOutEnergy(),
-    fOutPSEnergy(),
-    fEvent(0),
-    fLocalEnergy(NULL),
-    fLocalPSEnergy(NULL),
-    fLocalXArr(NULL),
-    fLocalYArr(NULL),
-    fLocalSize(0),
-    fModuleSize(0.),
-    fLocalXSize(0),
-    fLocalYSize(0),
-    fLocalMCX(0.),
-    fLocalMCY(0.),
-    fMCX(0.),
-    fMCY(0.),
-    fCount(0),
-    fPar(NULL)
-{
-}
-
-CbmEcalShowerCalibrator::CbmEcalShowerCalibrator(const char* name, const Int_t iVerbose)
-  : FairTask(name, iVerbose), 
-    fZPosition(-2),
-    fPDGCode(22), 
-    fLowEnergy(0.1), 
-    fOutCellSize(3.0), 
-    fSCurveRun(kFALSE),
-    fLitePoints(NULL),
-    fEcalPoints(NULL),
-    fMCTracks(NULL),
-    fTree(NULL),
-    fOutMCX(0.),
-    fOutMCY(0.),
-    fOutDX(0),
-    fOutDY(0),
-    fCellSize(0.),
-    fOutMCE(0.),
-    fOutMCPx(0.),
-    fOutMCPy(0.),
-    fOutMCPz(0.),
-    fOutEnergy(),
-    fOutPSEnergy(),
-    fEvent(0),
-    fLocalEnergy(NULL),
-    fLocalPSEnergy(NULL),
-    fLocalXArr(NULL),
-    fLocalYArr(NULL),
-    fLocalSize(0),
-    fModuleSize(0.),
-    fLocalXSize(0),
-    fLocalYSize(0),
-    fLocalMCX(0.),
-    fLocalMCY(0.),
-    fMCX(0.),
-    fMCY(0.),
-    fCount(0),
-    fPar(NULL)
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalShowerCalibrator::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-
-  fLitePoints=(TClonesArray*)fManager->GetObject("EcalPointLite");
-  if (fLitePoints==NULL)
-  {
-    cerr << "There are no EcalPointLite branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fEcalPoints=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (fEcalPoints==NULL)
-  {
-    cerr << "There are no EcalPoint branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fMCTracks=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (fMCTracks==NULL)
-  {
-    cerr << "There are no MCTrack branch in the file!!!" << endl;
-    return kFATAL;
-  }
-
-  fTree=NULL;
-
-  fCellSize=fPar->GetVariableStrict("cellsize");
-  fModuleSize=fPar->GetVariableStrict("modulesize");
- 
-  fLocalXSize=(Int_t)((fModuleSize+0.0001)/fCellSize);
-  fLocalYSize=(Int_t)((fModuleSize+0.0001)/fCellSize);
-
-  cout << "Inited for transport cell size " << fCellSize;
-  cout << ", module size " << fModuleSize << endl;
-  cout << "Size of local array: x " << fLocalXSize;
-  cout << ", y " << fLocalYSize << endl;
-
-  fLocalSize=(6*fLocalXSize+1)*(6*fLocalYSize+1);
-  fLocalEnergy=new Float_t[(6*fLocalXSize+1)*(6*fLocalYSize+1)];
-  fLocalPSEnergy=new Float_t[(6*fLocalXSize+1)*(6*fLocalYSize+1)];
-  fLocalXArr=new Float_t[(6*fLocalXSize+1)*(6*fLocalYSize+1)];
-  fLocalYArr=new Float_t[(6*fLocalXSize+1)*(6*fLocalYSize+1)];
-  
-  for(Int_t i=0;i<fLocalSize;i++)
-    GetLocalXY(i, fLocalXArr[i], fLocalYArr[i]);    
-
-  cout << "Local array size " << fLocalSize << endl;
-  fEvent=0;
-  return kSUCCESS;
-}
-
-/** Clear fLocalEnergy and fLocalPSEnergy **/
-void CbmEcalShowerCalibrator::ClearLocal()
-{
-  if (fVerbose>10)
-    cout << "Clearing local arrays..." << flush;
-  for(Int_t i=0;i<fLocalSize;i++)
-  {
-    fLocalEnergy[i]=0;
-    fLocalPSEnergy[i]=0;
-  }
-  if (fVerbose>10)
-    cout << " Done." << endl << flush;
-}
-
-/** Loop procedure **/
-void CbmEcalShowerCalibrator::Exec(Option_t*)
-{
-  /** Just because now it is assured we are in
-   ** output file **/
-  if (fTree==NULL)
-    InitTree();
-
-  fEvent++;
-  if (fVerbose>0)
-    cout << "Processing event " << fEvent << "." << endl;
-  ClearLocal();
-  GetMCParameters();
-  if (fCount!=1) 
-  {
-    cerr << "Event " << fEvent << "." << endl;
-    cerr << "->Found " << fCount << " suitable events.";
-    cerr << " Can't continue with this event. Skipping event." << endl;
-    return;
-  }
-  FillLocal();
-
-  static Int_t size=(Int_t)((fOutCellSize+0.001)/fCellSize);
-  static Int_t halfsize=size/2;
-  Int_t num;
-  Int_t ix;
-  Int_t iy;
-  Int_t nb;
-//  Int_t ne;
-  Int_t j;
-  Int_t jj;
-  static Int_t xsize=6*fLocalXSize+1;
-  static Int_t begin=3*fLocalXSize+3*fLocalYSize*(6*fLocalXSize+1);
-  static Int_t iidx=2*size;
-  static Int_t iidy=2*size;
-//  static Int_t idx=3*size-1;
-//  static Int_t idy=3*size-1;
-  
-  if (fVerbose>10)
-    cout << "Constructing output matrices... " << flush;
-  for(ix=0;ix<size;ix++)
-  {
-    for(iy=0;iy<size;iy++)
-    {
-      nb=begin+(-ix-iidx)+(-iy-iidy)*xsize;
-//      ne=begin+(-ix+idx)+(-iy+idy)*xsize;
-      ClearOut();
-      fOutDX=ix-halfsize;
-      fOutDY=iy-halfsize;
-      if (fSCurveRun&&fOutDY!=0) continue;
-      if (size%2==0)
-      {
-        fOutMCX=fLocalMCX+(fOutDX+0.5)*fCellSize;
-        fOutMCY=fLocalMCY+(fOutDY+0.5)*fCellSize;
-      }
-      else
-      {
-        fOutMCX=fLocalMCX+fCellSize*fOutDX;
-        fOutMCY=fLocalMCY+fCellSize*fOutDY;
-      }
-      for(Int_t nx=0;nx<5;nx++)
-      for(Int_t ny=0;ny<5;ny++)
-      {
-	num=nx+ny*5;
-	jj=nb+(ny*xsize+nx)*size;
-        for(Int_t dx=0;dx<size;dx++)
-	{
-	  j=jj+dx;
-          for(Int_t dy=0;dy<size;dy++)
-	  {
-            fOutEnergy[num]+=fLocalEnergy[j];
-            fOutPSEnergy[num]+=fLocalPSEnergy[j];
-	    j+=xsize;
-  	  }
-	}
-      }
-      fTree->Fill();
-    }
-  }
-  if (fVerbose>10)
-    cout << "Done." << flush;
-}
-
-/** Fill fLocalEnergy and fLocalPSEnergy **/
-void CbmEcalShowerCalibrator::FillLocal()
-{
-  CbmEcalPointLite* p;
-  Int_t n;
-  Bool_t isPS;
-  Float_t x;
-  Float_t y;
-  Int_t ten;
-  Int_t num;
- 
-  n=fLitePoints->GetEntriesFast();
-  if (fVerbose>10)
-    cout << "Filling local arrays... " << flush;
-  if (fVerbose>1)
-    cout << "Found " << n << " MCPoints in event." << endl;
-
-  for(Int_t i=0;i<n;i++)
-  {
-    p=(CbmEcalPointLite*)fLitePoints->At(i);
-    isPS=CbmEcal::GetCellCoord(p->GetDetectorID(),x,y,ten);
-    if (ten!=0) continue;
-    x+=fCellSize/2.0-fMCX;
-    y+=fCellSize/2.0-fMCY;
-    num=GetLocalNumber(x,y);
-    if (num==-1) continue;
-
-    if (isPS)
-      fLocalPSEnergy[num]+=p->GetEnergyLoss();
-    else
-      fLocalEnergy[num]+=p->GetEnergyLoss();
-  }
-  if (fVerbose>10)
-    cout << " Done." << endl;
-}
-
-/** local number -> (x,y) **/
-void CbmEcalShowerCalibrator::GetLocalXY(Int_t num, Float_t& x, Float_t& y) const
-{
-  static Float_t dx=fCellSize;
-  static Float_t dy=fCellSize;
-  static Int_t idx=3*fLocalXSize;
-  static Int_t idy=3*fLocalYSize;
-  static Int_t xsize=6*fLocalXSize+1;
-//  static Int_t ysize=6*fLocalYSize+1;
-
-  if (num<0||num>=fLocalSize)
-  {
-    x=-1111; y=-1111;
-    return;
-  }
-  Int_t ix=num%xsize-idx;
-  Int_t iy=num/xsize-idy;
-
-  x=(0.01+ix)*dx;
-  y=(0.01+iy)*dy;
-}
-
-Int_t CbmEcalShowerCalibrator::GetLocalNumber(Float_t x, Float_t y) const 
-{
-  static Float_t dx=fCellSize;
-  static Float_t dy=fCellSize;
-  static Int_t idx=3*fLocalXSize;
-  static Int_t idy=3*fLocalYSize;
-  static Int_t xsize=6*fLocalXSize+1;
-  static Int_t ysize=6*fLocalYSize+1;
-
-  Int_t ix=(Int_t)(x/dx+0.5)+idx;
-  if (x+dx/2<0) ix--;
-  Int_t iy=(Int_t)(y/dy+0.5)+idy;
-  if (y+dy/2<0) iy--;
-
-  if (ix<0||iy<0) return -1;
-  if (ix>=xsize) return -1;
-  if (iy>=ysize) return -1;
-
-  return ix+iy*xsize;
-}
-
-/** (x,y) -> out number. -1 is fails **/
-Int_t CbmEcalShowerCalibrator::GetOutNumber(Float_t x, Float_t y) const
-{
-  static Float_t dx=fOutCellSize;
-  static Float_t dy=fOutCellSize;
-  static Int_t idx=2;
-  static Int_t idy=2;
-  static Int_t xsize=5;
-  static Int_t ysize=5;
-
-  Int_t ix=(Int_t)(x/dx+0.5)+idx;
-  if (x+dx/2<0) ix--;
-  Int_t iy=(Int_t)(y/dy+0.5)+idy;
-  if (y+dy/2<0) iy--;
-
-  if (ix<0||iy<0) return -1;
-  if (ix>=xsize) return -1;
-  if (iy>=ysize) return -1;
-
-  return ix+iy*xsize;
-}
-
-/** Get MC parameters of incoming particle **/
-void CbmEcalShowerCalibrator::GetMCParameters()
-{
-  CbmEcalPoint* p;
-  CbmMCTrack* track;
-  TVector3 mom;
-  Int_t n;
-  Int_t count=0;
-  Float_t mass=-1111;
-
-  n=fEcalPoints->GetEntriesFast();
-  if (fVerbose>1)
-    cout << "Found " << n << " incoming particles in event." << endl;
-
-  for(Int_t i=0;i<n;i++)
-  {
-    p=(CbmEcalPoint*)fEcalPoints->At(i);
-    track=(CbmMCTrack*)fMCTracks->At(p->GetTrackID());
-    if (track->GetPdgCode()!=fPDGCode)
-      continue;
-    p->Momentum(mom);
-    if (mom.Mag()<fLowEnergy)
-      continue;
-    count++;
-    TParticlePDG* fParticlePDG=TDatabasePDG::Instance()->GetParticle(fPDGCode);
-    if (fParticlePDG)
-      mass=fParticlePDG->Mass();
-    if (mass<0)
-    {
-      cerr << "Can't find PDG particle " << fPDGCode << "!!!";
-      cerr << endl;
-      Fatal("GetMCParameters","Can't find PDG particle %d.", fPDGCode);
-      return;
-    }
-    fOutMCE=TMath::Sqrt(mass*mass+mom.Mag2());
-    fOutMCPx=mom.Px();
-    fOutMCPy=mom.Py();
-    fOutMCPz=mom.Pz();
-    p->Position(mom);
-    GetMCXY(mom);
-  }
-  fCount=count;
-}
-
-/** Get MC coordinates **/
-void CbmEcalShowerCalibrator::GetMCXY(TVector3& mom)
-{
-  static Float_t PSLead=fPar->GetVariableStrict("pslead");
-  static Float_t PSScin=fPar->GetVariableStrict("psscin");
-  static Float_t PSGap=fPar->GetVariableStrict("psgap");
-  static Float_t PSThickness=PSLead+PSScin+PSGap;
-  static Float_t ZPos=fPar->GetVariableStrict("zpos");
-
-  Float_t delta;
-
-  if (fZPosition==-2) delta=ZPos+PSThickness;
-  else
-    if (fZPosition==-1) delta=ZPos;
-    else
-      delta=fZPosition;
-  delta-=mom.Z();
-
-  fMCX=mom.X()+fOutMCPx/fOutMCPz*delta;
-  fMCY=mom.Y()+fOutMCPy/fOutMCPz*delta;
-
-  Int_t ix;
-  Int_t iy;
-
-  if (fMCX>=0)
-    ix=(Int_t)(fMCX/fCellSize);
-  else
-    ix=(Int_t)(fMCX/fCellSize)-1;
-  if (fMCY>=0)
-    iy=(Int_t)(fMCY/fCellSize);
-  else
-    iy=(Int_t)(fMCY/fCellSize)-1;
-
-
-  fLocalMCX=fMCX-(0.5+ix)*fCellSize;
-  fLocalMCY=fMCY-(0.5+iy)*fCellSize;
-}
-
-/** Parameter container init **/
-void CbmEcalShowerCalibrator::SetParContainers()
-{
-  FairRunAna* ana=FairRunAna::Instance();
-  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
-  fPar=(CbmGeoEcalPar*)(rtdb->getContainer("CbmGeoEcalPar"));
-}
-
-void CbmEcalShowerCalibrator::InitTree()
-{
-  fTree=new TTree("ECALshower","Tree of ECAL showers");
-  fTree->Branch("mcx",&fOutMCX,"mcx/F");
-  fTree->Branch("mcy",&fOutMCY,"mcy/F");
-  fTree->Branch("dx",&fOutDX,"dx/I");
-  fTree->Branch("dy",&fOutDY,"dy/I");
-  fTree->Branch("cellsize",&fOutCellSize,"cellsize/F");
-  fTree->Branch("simcellsize",&fCellSize,"simcellsize/F");
-  fTree->Branch("e",&fOutMCE,"e/F");
-  fTree->Branch("px",&fOutMCPx,"px/F");
-  fTree->Branch("py",&fOutMCPy,"py/F");
-  fTree->Branch("pz",&fOutMCPz,"pz/F");
-  fTree->Branch("ev",&fEvent,"ev/I");
-  fTree->Branch("ecale", fOutEnergy, "ecale[25]/F");
-  fTree->Branch("pse", fOutPSEnergy, "pse[25]/F");
-};
-
-/** Finishing routine **/
-void CbmEcalShowerCalibrator::Finish()
-{
-  fTree->Write();
-}
-
-ClassImp(CbmEcalShowerCalibrator)
diff --git a/ecal/CbmEcalShowerCalibrator.h b/ecal/CbmEcalShowerCalibrator.h
deleted file mode 100644
index 3dd8082d2b4307f1091b1a2c84554882d3e70119..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalShowerCalibrator.h
+++ /dev/null
@@ -1,257 +0,0 @@
-// Creater tree for shower calibration from MCPoints files.
-// This is a source of raw information for shower library.
-// Must be exactly one particle with resonably high energy
-// (>LowEnergy) per event!
-/* $Id: CbmEcalShowerCalibrator.h,v 1.3 2006/09/07 18:19:27 prokudin Exp $*/
-
-/*
- * $Log: CbmEcalShowerCalibrator.h,v $
- * Revision 1.3  2006/09/07 18:19:27  prokudin
- * SCurveRun option added
- *
- * Revision 1.2  2006/08/22 22:31:42  prokudin
- * Optimization
- *
- * Revision 1.1  2006/08/15 13:06:06  prokudin
- * first release of CbmEcalShowerCalibrator
- *
- */
-
-#ifndef CBMECALSHOWERCALIBRATOR_H
-#define CBMECALSHOWERCALIBRATOR_H
-
-#include "FairTask.h"
-
-#include <vector>
-
-class CbmGeoEcalPar;
-class TClonesArray;
-class TTree;
-class TVector3;
-
-class CbmEcalShowerCalibrator : public FairTask
-{
-public:
-  /** Standart constructor **/
-  CbmEcalShowerCalibrator(const char* name, const Int_t iVerbose=1);
-
-  /** Output cell size **/
-  void SetOutCellSize(Float_t cellsize=3.0);
-  Float_t GetOutCellSize() const;
-
-  void SetPDGCode(Int_t code=22);
-  Int_t GetPDGCode() const;
-
-  /** Set lowest energy to analize **/
-  void SetLowEnergy(Float_t energy=0.1);
-  Float_t GetLowEnergy() const;
-
-  /** if true generate only showers with dy==0 **/
-  void SetSCurveRun(Bool_t run=kTRUE);
-  Bool_t GetSCurveRun() const;
-
-  /** Z position of ECAL
-   ** -1 for PS surface
-   ** -2 for ECAL surface **/
-  void SetZPosition(Float_t zpos=-2);
-  Float_t GetZPosition() const;
-
-  /** (x,y) -> local number. -1 if fails **/
-  Int_t GetLocalNumber(Float_t x, Float_t y) const;
-
-  /** local number -> (x,y) **/
-  void GetLocalXY(Int_t num, Float_t& x, Float_t& y) const;
-
-  /** (x,y) -> out number. -1 is fails **/
-  Int_t GetOutNumber(Float_t x, Float_t y) const;
-private:
-  /** Z position of ECAL
-   ** -1 for PS surface
-   ** -2 for ECAL surface **/
-  Float_t fZPosition; //=-2
-
-  /** Pdg code of particles to analize **/
-  Int_t fPDGCode; //=22
-
-  /** Lowest energy to analize **/
-  Float_t fLowEnergy; //=0.1
-
-  /** Output cellsize. Calculated from fType**/
-  Float_t fOutCellSize; //=3.0
-
-  /** if true generate only showers with dy==0 **/
-  Bool_t fSCurveRun; //=kFALSE
-
-  /** MCPoints in ECAL **/
-  TClonesArray* fLitePoints;
-  /** MCPoints in front of the ECAL **/
-  TClonesArray* fEcalPoints;
-  /** MCTracks array **/
-  TClonesArray* fMCTracks;
-
-  /** Output tree. It called ECALshower**/
-  TTree* fTree;
-
-  /** MC coordinates of impact point **/
-  Float_t fOutMCX;
-  Float_t fOutMCY;
-
-  /** Delta vs. real MC X,Y**/
-  Int_t fOutDX;
-  Int_t fOutDY;
-
-  /** Cell size in simulation. From parameter container **/
-  Float_t fCellSize;
-
-  /** MC parameters of particle **/
-  Float_t fOutMCE;
-  Float_t fOutMCPx;
-  Float_t fOutMCPy;
-  Float_t fOutMCPz;
-
-  /** Energy in 5x5 output cluster.
-   ** If you want co change 25 to something else
-   ** please correct CbmEcalShowerCalibrator::InitTree
-   ** method **/
-  Float_t fOutEnergy[25];
-  Float_t fOutPSEnergy[25];
-
-  /** Enent number**/
-  Int_t fEvent;
-
-  /** Energy in temporary cluster **/
-  Float_t* fLocalEnergy;
-  Float_t* fLocalPSEnergy;
-  Float_t* fLocalXArr;
-  Float_t* fLocalYArr;
-  Int_t fLocalSize;
-
-  /** Size of ECAL module **/
-  Float_t fModuleSize;
-
-  /** X/Y sizes of local array**/
-  Int_t fLocalXSize;
-  Int_t fLocalYSize;
-
-  /** Local MC coordinates of ECAL plane hit **/
-  Float_t fLocalMCX;
-  Float_t fLocalMCY;
-
-  /** MC coordinates of ECAL plane hit **/
-  Float_t fMCX;
-  Float_t fMCY;
-
-  /** Number of found good particles **/
-  Int_t fCount;
-public:
-  /** Default constructor **/
-  CbmEcalShowerCalibrator();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Parameter container init **/
-  virtual void SetParContainers();
-
-  /** Destructor **/
-  virtual ~CbmEcalShowerCalibrator() {};
-private:
-  /** Inits fTree and branches **/
-  void InitTree();
-
-  /** Get MC parameters of incoming particle **/
-  void GetMCParameters();
-
-  /** Get MC coordinates **/
-  void GetMCXY(TVector3& mom);
-
-  /** Fill fLocalEnergy and fLocalPSEnergy **/
-  void FillLocal();
-
-  /** Clear fLocalEnergy and fLocalPSEnergy **/
-  void ClearLocal();
-
-  /** Clear fOutEnergy and fOutPSEnergy **/
-  void ClearOut();
-
-  CbmGeoEcalPar* fPar;
-
-  CbmEcalShowerCalibrator(const CbmEcalShowerCalibrator&);
-  CbmEcalShowerCalibrator& operator=(const CbmEcalShowerCalibrator&);
-
-  ClassDef(CbmEcalShowerCalibrator,1)
-
-};
-
-inline void CbmEcalShowerCalibrator::SetPDGCode(Int_t code)
-{
-  fPDGCode=code;
-}
-
-inline Int_t CbmEcalShowerCalibrator::GetPDGCode() const
-{
-  return fPDGCode;
-}
-
-inline void CbmEcalShowerCalibrator::SetLowEnergy(Float_t energy)
-{
-  fLowEnergy=energy;
-}
-
-inline Float_t CbmEcalShowerCalibrator::GetLowEnergy() const
-{
-  return fLowEnergy;
-}
-
-
-inline void CbmEcalShowerCalibrator::SetOutCellSize(Float_t cellsize)
-{
-  fOutCellSize=cellsize;
-}
-
-inline Float_t CbmEcalShowerCalibrator::GetOutCellSize() const
-{
-  return fOutCellSize;
-}
-
-
-inline void CbmEcalShowerCalibrator::SetZPosition(Float_t zpos)
-{
-  fZPosition=zpos;
-}
-
-inline Float_t CbmEcalShowerCalibrator::GetZPosition() const
-{
-  return fZPosition;
-}
-
-/** if true generate only showers with dy==0 **/
-inline void CbmEcalShowerCalibrator::SetSCurveRun(Bool_t run)
-{
-  fSCurveRun=run;
-}
-
-inline  Bool_t CbmEcalShowerCalibrator::GetSCurveRun() const
-{
-  return fSCurveRun;
-} 
-/** Clear fOutEnergy and fOutPSEnergy **/
-/** Only for perfomance reasons! **/
-inline void CbmEcalShowerCalibrator::ClearOut()
-{
-  for(Int_t i=0;i<25;i++)
-  {
-    fOutEnergy[i]=0;
-    fOutPSEnergy[i]=0;
-  }
-}
-
-
-#endif
-
diff --git a/ecal/CbmEcalStructure.cxx b/ecal/CbmEcalStructure.cxx
deleted file mode 100644
index eda8ab427ff7a474d563c97007ecc23007ee3c0b..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalStructure.cxx
+++ /dev/null
@@ -1,457 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalStructure source file                 -----
-// -----                  Created  27/01/06  by M.Prokudin             -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalStructure.cxx
- *@author Mikhail Prokudin
- **
- ** ECAL structure, consisting of modules
- **/
-
-/* $Id: CbmEcalStructure.cxx,v 1.11 2006/07/19 09:33:34 prokudin Exp $ */
-
-#include "CbmEcalStructure.h"
-
-#include "CbmEcal.h"
-#include "CbmEcalDetailed.h"
-#include "CbmEcalCellMC.h"
-
-#include "CbmEcalCell.h"
-
-#include <iostream>
-#include <algorithm>
-#include <cmath>
-using namespace std;
-
-class __CbmEcalCellWrapper
-{
-public:
-  CbmEcalCell* cell;
-  Char_t isPsTen;
-};
-
-CbmEcalCell* CbmEcalStructure::GetCell(Int_t volId, Int_t& ten, Bool_t& isPS)
-{
-  UInt_t i;
-  static Int_t volidmax = 0;
-  if (volidmax==0)
-  {
-    if (fEcalVersion==0) volidmax=CbmEcal::GetVolIdMax()*2;
-    if (fEcalVersion==1) volidmax=10000000;
-  }
-
-  if ((Int_t)fHash.size()<volidmax)
-  {
-    fHash.resize(volidmax);
-    for(i=0;i<fHash.size();i++)
-      fHash[i]=NULL;
-  }
-  if (volId>volidmax)
-    return NULL;
-  if (fHash[volId]==NULL)
-  {
-    Bool_t lisPS=kTRUE;
-    Int_t iten;
-    Float_t x;
-    Float_t y;
-    fHash[volId]=new __CbmEcalCellWrapper();
-    if (fEcalVersion==0)
-      lisPS=CbmEcal::GetCellCoord(volId,x,y,iten);
-    if (fEcalVersion==1)
-      lisPS=CbmEcalDetailed::GetCellCoordInf(volId, x, y, iten);
-    fHash[volId]->cell=GetCell(x+0.025,y+0.025);
-    fHash[volId]->isPsTen=iten*2;
-    // lisPS should be false. No PS for calorimeter :(
-    if (lisPS) fHash[volId]->isPsTen+=1;
-  }
-  ten=fHash[volId]->isPsTen/2;
-  isPS=fHash[volId]->isPsTen%2;
-  return fHash[volId]->cell;
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalStructure::Serialize()
-{
-  fCells.clear();
-  for(UInt_t i=0;i<fStructure.size();i++)
-  if (fStructure[i])
-  {
-    vector<CbmEcalCell*> cells=fStructure[i]->GetCells();
-    copy(cells.begin(),cells.end(), back_inserter(fCells));
-  }
-}
-
-//-----------------------------------------------------------------------------
-CbmEcalModule* CbmEcalStructure::CreateModule(char type, Int_t number, Float_t x1, Float_t y1, Float_t x2, Float_t y2)
-{
-  return new CbmEcalModule(type, number, x1, y1, x2, y2, fUseMC);
-}
-//-----------------------------------------------------------------------------
-
-CbmEcalStructure::CbmEcalStructure(CbmEcalInf* ecalinf)
-  : TNamed("CbmEcalStructure", "Calorimeter structure"), 
-    fUseMC(0),
-    fX1(0.),
-    fY1(0.),
-    fEcalInf(ecalinf),
-    fStructure(),
-    fCells(),
-    fHash(),
-    fEcalVersion(0)
-{
-  fX1=fEcalInf->GetXPos()-\
-    fEcalInf->GetModuleSize()*fEcalInf->GetXSize()/2.0;
-  fY1=fEcalInf->GetYPos()-\
-    fEcalInf->GetModuleSize()*fEcalInf->GetYSize()/2.0;
-  fEcalVersion=(Int_t)fEcalInf->GetVariable("ecalversion");
-  if (fEcalVersion<0)
-    fEcalVersion=0;
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalStructure::Construct()
-{
-  if (!fEcalInf) return;
-
-  Float_t x1=GetX1();
-  Float_t y1=GetY1();
-  Float_t x;
-  Float_t y;
-  Float_t dx;
-  Float_t dy;
-  Int_t i;
-  Int_t j;
-  Int_t k;
-  Int_t number;
-  char type;
-
-  fStructure.resize(fEcalInf->GetXSize()*fEcalInf->GetYSize(), NULL);
-	
-  dx=fEcalInf->GetModuleSize();
-  dy=fEcalInf->GetModuleSize();
-  //Creating ECAL Matrix
-  for(i=0;i<fEcalInf->GetXSize();i++)
-    for(j=0;j<fEcalInf->GetYSize();j++) {
-      type=fEcalInf->GetType(i,j);
-      if (type) {
-	x=x1+i*dx;
-	y=y1+j*dy;
-	number=(i*100+j)*100;
-	fStructure[GetNum(i,j)]=CreateModule(type,number,x,y,x+dx,y+dy);
-      }
-      else
-	fStructure[GetNum(i,j)]=NULL;
-    }
-#ifdef _DECALSTRUCT
-  cerr << "-I- CbmEcalStructure::Construct(): calorimeter matrix created." << endl;
-#endif
-  //Now ECAL matrix created
-  list<CbmEcalCell*> neib[5];
-  vector<CbmEcalCell*> cl;
-  vector<CbmEcalCell*>::const_iterator pcl;
-  
-  Int_t num;
-  //We want neighbors for EcalModules be EcalModules
-  for(i=0;i<fEcalInf->GetXSize();i++)
-    for(j=0;j<fEcalInf->GetYSize();j++)
-      if (fStructure[GetNum(i,j)]) {
-	for(k=0;k<5;k++) neib[k].clear();
-	
-	num=GetNumber(i-1,j);
-	if (-1!=num) {
-	  neib[0].push_back(fStructure[num]);
-	  neib[1].push_back(fStructure[num]);
-	  neib[4].push_back(fStructure[num]);
-	}
-			
-	num=GetNumber(i-1,j+1);
-	if (-1!=num) {
-	  neib[0].push_back(fStructure[num]);
-	  neib[4].push_back(fStructure[num]);
-	}
-	
-	num=GetNumber(i,j+1);
-	if (-1!=num) {
-	  neib[0].push_back(fStructure[num]);
-	  neib[3].push_back(fStructure[num]);
-	  neib[4].push_back(fStructure[num]);
-	}
-	
-	num=GetNumber(i+1,j+1);
-	if (-1!=num) {
-	  neib[0].push_back(fStructure[num]);
-	  neib[3].push_back(fStructure[num]);
-	}
-	
-	num=GetNumber(i+1,j);
-	if (-1!=num) {
-	  neib[0].push_back(fStructure[num]);
-	  neib[2].push_back(fStructure[num]);
-	  neib[3].push_back(fStructure[num]);
-	}
-			
-	num=GetNumber(i+1,j-1);
-	if (-1!=num) {
-	  neib[0].push_back(fStructure[num]);
-	  neib[2].push_back(fStructure[num]);
-	}
-	
-	num=GetNumber(i,j-1);
-	if (-1!=num) {
-	  neib[0].push_back(fStructure[num]);
-	  neib[1].push_back(fStructure[num]);
-	  neib[2].push_back(fStructure[num]);
-	}
-	
-	num=GetNumber(i-1,j-1);
-	if (-1!=num) {
-	  neib[0].push_back(fStructure[num]);
-	  neib[1].push_back(fStructure[num]);
-	}
-	
-	num=GetNumber(i,j);
-	for(k=0;k<5;k++)
-	  fStructure[num]->SetNeighborsList(k,neib[k]);
-	cl=fStructure[num]->GetCells();
-	for(pcl=cl.begin();pcl!=cl.end();++pcl)
-	  CreateNLists(*pcl);
-      }
-  Serialize();
-}
-
-//-----------------------------------------------------------------------------
-void _add_not_null(CbmEcalModule* mod, list<CbmEcalModule*>& lst)
-{
-  if (mod)
-    if (find(lst.begin(),lst.end(),mod)==lst.end())	
-      lst.push_back(mod);
-}
-
-//-----------------------------------------------------------------------------
-void _add_not_null(list<CbmEcalCell*> from, list<CbmEcalCell*>& where)
-{
-  list<CbmEcalCell*>::const_iterator p;
-  for(p=from.begin();p!=from.end();++p)
-    if (find(where.begin(),where.end(),(*p))==where.end())
-      //this p uniq!
-      where.push_back(*p);
-}
-
-//-----------------------------------------------------------------------------
-void _add_not_null(CbmEcalCell* cell, list<CbmEcalCell*>& lst)
-{
-  if (find(lst.begin(),lst.end(),cell)==lst.end())	
-    lst.push_back(cell);
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalStructure::CreateNLists(CbmEcalCell* cell)
-{
-  Float_t x=cell->GetCenterX();
-  Float_t y=cell->GetCenterY();
-  Float_t dx=(cell->GetX2()-cell->GetX1())/2.0;
-  Float_t dy=(cell->GetX2()-cell->GetX1())/2.0;
-  Float_t x1;
-  Float_t x2;
-  Float_t y1;
-  Float_t y2;
-  Float_t mx1=cell->GetX1();
-  Float_t mx2=cell->GetX2();
-  Float_t my1=cell->GetY1();
-  Float_t my2=cell->GetY2();
-  Float_t cx;
-  Float_t cy;
-  Float_t d=0.1;
-  Float_t dd=1e-6;
-  list<CbmEcalCell*> neib[5];
-  list<CbmEcalCell*> tl;
-  list<CbmEcalModule*> tml; 
-  list<CbmEcalModule*>::const_iterator ptml;
-  list<CbmEcalCell*>::const_iterator ptl;
-  Int_t i;
-
-  //1 - lu, 2 - ru, 3 - rd, 4 - ld
-  for(i=0;i<5;i++) neib[i].clear();
-
-  tml.clear();
-  _add_not_null(GetModule(x-2*dx,y-2*dy),tml);
-  _add_not_null(GetModule(x-2*dx,y     ),tml);
-  _add_not_null(GetModule(x-2*dx,y+2*dy),tml);
-  _add_not_null(GetModule(x     ,y-2*dy),tml);
-  _add_not_null(GetModule(x     ,y     ),tml);
-  _add_not_null(GetModule(x     ,y+2*dy),tml);
-  _add_not_null(GetModule(x+2*dx,y-2*dy),tml);
-  _add_not_null(GetModule(x+2*dx,y     ),tml);
-  _add_not_null(GetModule(x+2*dx,y+2*dy),tml);
-  if (tml.empty()) {
-    cerr << "Error during creating neighbors lists." << endl;
-    cerr << "Can't' find any modules neighbors to cell." << endl;
-    cerr << "Cell: CenterX=" << x << ", CenterY=" << y << "." << endl; 
-    return;
-  }
-  tl.empty();
-  for(ptml=tml.begin();ptml!=tml.end();++ptml) {
-    _add_not_null((*ptml)->GetCellsY(y-dy-d),tl);
-    _add_not_null((*ptml)->GetCellsY(y+dy+d),tl);
-    _add_not_null((*ptml)->GetCellsX(x-dx-d),tl);
-    _add_not_null((*ptml)->GetCellsX(x+dx+d),tl);
-  }
-  if (tl.empty()) {
-    cerr << "Error during creating neighbors lists." << endl;
-    cerr << "Can't' find any cells neighbors to cell." << endl;
-    cerr << "Cell: CenterX=" << x << ", CenterY=" << y << "." << endl; 
-    return;
-  }
-  for(ptl=tl.begin();ptl!=tl.end();++ptl) {
-    x1=(*ptl)->GetX1();
-    x2=(*ptl)->GetX2();
-    y1=(*ptl)->GetY1();
-    y2=(*ptl)->GetY2();
-    cx=(*ptl)->GetCenterX();
-    cy=(*ptl)->GetCenterY();
-    if (fabs(mx1-x2)<dd) {
-      if ((cy-y+2*dy>-dd&&cy-y-dy/2<dd)||fabs(y-dy-y1)<dd||fabs(y-dy-y2)<dd) {
-	_add_not_null((*ptl),neib[0]);
-	_add_not_null((*ptl),neib[1]);
-      }
-      if ((cy-y-2*dy<dd&&cy-y+dy/2>-dd)||fabs(y+dy-y1)<dd||fabs(y+dy-y2)<dd) {
-	_add_not_null((*ptl),neib[0]);
-	_add_not_null((*ptl),neib[4]);
-      }
-    }
-    if (fabs(my1-y2)<dd) {
-      if ((cx-x+2*dx>-dd&&cx-x-dx/2<dd)||fabs(x-dx-x1)<dd||fabs(x-dx-x2)<dd) {
-	_add_not_null((*ptl),neib[0]);
-	_add_not_null((*ptl),neib[1]);
-      }
-      if ((cx-x-2*dx<dd&&cx-x+dx/2>-dd)||fabs(x+dx-x1)<dd||fabs(x+dx-x2)<dd) {
-	_add_not_null((*ptl),neib[0]);
-	_add_not_null((*ptl),neib[2]);
-      }
-    }
-    if (fabs(mx2-x1)<dd) {
-      if ((cy-y+2*dy>-dd&&cy-y-dy/2<dd)||fabs(y-dy-y1)<dd||fabs(y-dy-y2)<dd) {
-	_add_not_null((*ptl),neib[0]);
-	_add_not_null((*ptl),neib[2]);
-      }
-      if ((cy-y-2*dy<dd&&cy-y+dy/2>-dd)||fabs(y+dy-y1)<dd||fabs(y+dy-y2)<dd) {
-	_add_not_null((*ptl),neib[0]);
-	_add_not_null((*ptl),neib[3]);
-      }
-    }
-    if (fabs(my2-y1)<dd) {
-      if ((cx-x+2*dx>-dd&&cx-x-dx/2<dd)||fabs(x-dx-x1)<dd||fabs(x-dx-x2)<dd) {
-	_add_not_null((*ptl),neib[0]);
-	_add_not_null((*ptl),neib[4]);
-      }
-      if ((cx-x-2*dx<dd&&cx-x+dx/2>-dd)||fabs(x+dx-x1)<dd||fabs(x+dx-x2)<dd) {
-	_add_not_null((*ptl),neib[0]);
-	_add_not_null((*ptl),neib[3]);
-      }
-    }
-    
-  }
-  for(i=0;i<5;i++) cell->SetNeighborsList(i,neib[i]);
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalStructure::ResetModules()
-{
-  list<CbmEcalCell*>::const_iterator p=fCells.begin();
-  if (fUseMC==0)
-  {
-    for(;p!=fCells.end();++p)
-      (*p)->ResetEnergyFast();
-  }
-  else
-  {
-    for(;p!=fCells.end();++p)
-    ((CbmEcalCellMC*)(*p))->ResetEnergy();
-  }
-}
-
-//-----------------------------------------------------------------------------
-void CbmEcalStructure::GetHitXY(const Int_t hitId, Float_t& x, Float_t& y) const
-{
-  /** Hit Id -> (x,y) **/
-
-  // Some translation from x*100+y  to y*sizex+x coding...
- 
-  Int_t mnum=hitId/100;
-  Int_t cellx = mnum/100;
-  Int_t celly = mnum%100;
-  mnum = GetNum(cellx, celly);
-  
-  // end translation
-
-  CbmEcalModule* module=fStructure[mnum];
-  CbmEcalCell* cell;
-
-  Int_t cellnum=hitId%100;
-  // change place
-  Int_t cx=cellnum%10-1;
-  Int_t cy=cellnum/10-1;
-
-  if (module==NULL||cx<0||cy<0||cx>=module->GetType()||cy>=module->GetType()) {x=0; y=0; return;}
-  cell=module->At(cx,cy);
-  x=cell->GetCenterX();
-  y=cell->GetCenterY();
-}
-
-//-----------------------------------------------------------------------------
-CbmEcalCell* CbmEcalStructure::GetHitCell(const Int_t hitId) const
-{
-  /** Hit Id -> Cell **/
- 
-  // Some translation from x*100+y  to y*sizex+x coding...
- 
-  Int_t mnum=hitId/100;
-  Int_t cellx = mnum/100;
-  Int_t celly = mnum%100;
-  mnum = GetNum(cellx, celly);
-  
-  // end translation
-
-  CbmEcalModule* module=fStructure[mnum];
-
-  Int_t cellnum=hitId%100;
-  Int_t cx=cellnum%10-1;
-  Int_t cy=cellnum/10-1;
-
-  if (module==NULL||cx<0||cy<0||cx>=module->GetType()||cy>=module->GetType()) 
-    return NULL;
-//  cout << hitId << " --- " << module->At(cx,cy)->GetCellNumber() << endl;
-  return module->At(cx,cy);
-}
-
-//-----------------------------------------------------------------------------
-
-void CbmEcalStructure::GetGlobalCellXY(const Int_t hitId, Int_t& x, Int_t& y) const
-{
-
-
-  Int_t modulenum = hitId/100;
-  Int_t cellx = modulenum/100;
-  Int_t celly = modulenum%100; 
-
-  Int_t innernum =  hitId%100;
-  Int_t iny = innernum/10;
-  Int_t inx = innernum%10;
-  Int_t msize = fEcalInf->GetType(cellx,celly);
-
-   
-  x = (cellx-1)* msize + inx;
-  y = (celly-1)* msize + iny;
-
-}
-//
-Int_t CbmEcalStructure::GetType(const Int_t hitId) const
-{
-  Int_t modulenum = hitId/100;
-  Int_t cellx = modulenum/100;
-  Int_t celly = modulenum%100; 
-
-  Int_t msize = fEcalInf->GetType(cellx,celly);
-  return msize;
-}
diff --git a/ecal/CbmEcalStructure.h b/ecal/CbmEcalStructure.h
deleted file mode 100644
index 755618d1abd8f645d8f5cf2cddd4cd404a61f869..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalStructure.h
+++ /dev/null
@@ -1,194 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                  CbmEcalStructure header file                 -----
-// -----                  Created  27/01/06  by M.Prokudin             -----
-// -------------------------------------------------------------------------
-
-/**  CbmEcalStructure.h
- *@author Mikhail Prokudin
- **
- ** ECAL structure, consisting of modules
- **/
-
-#ifndef CBMECALSTRUCTURE_H
-#define CBMECALSTRUCTURE_H
-
-/* $Id: CbmEcalStructure.h,v 1.8 2006/07/19 11:49:39 prokudin Exp $ */
-
-#include "CbmEcalInf.h"
-#include "CbmEcalModule.h"
-#include "CbmEcalCell.h"
-
-#include "TMath.h"
-#include "TNamed.h"
-
-#include <vector>
-
-#define _DECALSTRUCT
-
-class __CbmEcalCellWrapper;
-
-class CbmEcalStructure : public TNamed
-{
-public:
-  CbmEcalStructure(CbmEcalInf* ecalinf);
-  void SetUseMC(Int_t mc=0) {fUseMC=mc;}
-  Int_t GetUseMC() const {return fUseMC;}
-  void Construct();
-  Int_t GetNumber(Int_t x, Int_t y) const;
-  
-  Bool_t AddEnergy(Float_t x, Float_t y, Float_t energy, Bool_t isPS=kFALSE);
-  Float_t GetEnergy(Float_t x, Float_t y, Bool_t isPS=kFALSE) const;
-  CbmEcalCell* GetCell(Float_t x, Float_t y) const;
-  CbmEcalModule* GetModule(Float_t x, Float_t y) const;
-  Int_t GetModuleNumber(Float_t x, Float_t y) const;
-  
-  Float_t GetX1() const {return fX1;};
-  Float_t GetY1() const {return fY1;};
-  Float_t GetX2() const;
-  Float_t GetY2() const;
-  inline CbmEcalInf* GetEcalInf() const {return fEcalInf;}
-  inline void GetStructure(std::vector<CbmEcalModule*>& stru) const {stru=fStructure;}
-  inline void GetCells(std::list<CbmEcalCell*>& cells) const {cells=fCells;}
-  //Create neighbors lists
-  void CreateNLists(CbmEcalCell* cell);
-  void ResetModules();
-  
-  CbmEcalModule* CreateModule(char type, Int_t number, Float_t x1, Float_t y1, Float_t x2, Float_t y2);
-  //Some usefull procedures for hit processing
-  
-  //Converts (x,y) to hit Id
-  Int_t GetHitId(Float_t x, Float_t y) const;
-  //Hit Id -> (x,y)
-  void GetHitXY(const Int_t hitId, Float_t& x, Float_t& y) const;
-
-  // HitId -> in global cell coordinate 
-  void GetGlobalCellXY(const Int_t hitId, Int_t& x, Int_t& y) const;
-
-  // HitId -> cell type
-  Int_t GetType(const Int_t hitId) const;
-
-  CbmEcalCell* GetCell(Int_t fVolId, Int_t& ten, Bool_t& isPS);
-  //Hit It -> Cell
-  CbmEcalCell* GetHitCell(const Int_t hitId) const;
-
-private:
-  Int_t GetNum(Int_t x, Int_t y) const;
-  
-private:
-  /** Creates fCells lists **/
-  void Serialize();
-  /** Use store MC information in cells **/
-  Int_t fUseMC;
-  /** X coordibate of left bottom angle of ECAL **/
-  Float_t fX1;
-  /** Y coordibate of left bottom angle of ECAL **/
-  Float_t fY1;
-  /** ECAL geometry container **/
-  CbmEcalInf* fEcalInf;
-  /** total list of ECAL modules **/
-  std::vector<CbmEcalModule*> fStructure;
-  /** All ECAL cells **/
-  std::list<CbmEcalCell*> fCells;
-  /** MCPoint id -> ECAL cell**/
-  std::vector<__CbmEcalCellWrapper*> fHash;
-  /** Version of the calorimeter class used **/
-  Int_t fEcalVersion;
-
-  CbmEcalStructure(const CbmEcalStructure&);
-  CbmEcalStructure& operator=(const CbmEcalStructure&);
-
-  ClassDef(CbmEcalStructure,1);
-};
-
-inline CbmEcalCell* CbmEcalStructure::GetCell(Float_t x, Float_t y) const
-{
-  /** get ECAL cell by known cell center coordinate (x,y) **/
-  CbmEcalModule* module=GetModule(x,y);
-  if (module) return module->FindCell(x,y);
-  return NULL;
-}
-
-inline CbmEcalModule* CbmEcalStructure::GetModule(Float_t x, Float_t y) const
-{
-  /** get ECAL module by known module center coordinate (x,y) **/
-  Int_t num=GetModuleNumber(x,y);
-  if (-1==num) return NULL; else return fStructure[num]; 
-}
-
-inline Int_t  CbmEcalStructure::GetModuleNumber(Float_t x, Float_t y) const
-{
-  /** get ECAL module by known module center coordinate (x,y) **/
-  Int_t ix=(Int_t)TMath::Floor((x-GetX1())/fEcalInf->GetModuleSize());
-  Int_t iy=(Int_t)TMath::Floor((y-GetY1())/fEcalInf->GetModuleSize());
-  return GetNumber(ix,iy);
-}
-
-inline Int_t CbmEcalStructure::GetNumber(Int_t x, Int_t y) const
-{
-  /** get ECAL absolute module number by known module relative number (x,y)
-   ** with check for the ECAL boundaries **/
-  if (x>-1&&y>-1)
-    if (x<fEcalInf->GetXSize()&&y<fEcalInf->GetYSize())
-      return GetNum(x,y);
-  return -1;
-}
-
-inline Int_t CbmEcalStructure::GetNum(Int_t x, Int_t y) const
-{
-  /** get ECAL absolute module number by known module relative number (x,y) **/
-  return y*fEcalInf->GetXSize()+x;
-}
-
-inline Float_t CbmEcalStructure::GetX2() const
-{
-  /** get ECAL right edge coordinate in cm **/
-  return fEcalInf->GetXPos()+
-         fEcalInf->GetModuleSize()*fEcalInf->GetXSize()/2.0;
-}
-
-inline Float_t CbmEcalStructure::GetY2() const
-{
-  /** get ECAL upper edge coordinate in cm **/
-  return fEcalInf->GetYPos()+
-         fEcalInf->GetModuleSize()*fEcalInf->GetYSize()/2.0;
-}
-
-inline Bool_t CbmEcalStructure::AddEnergy(Float_t x, Float_t y, Float_t energy, Bool_t isPS)
-{
-  /** Add preshower or calorimeter energy to a cell with coordinate (x,y) **/
-  CbmEcalCell* cell=GetCell(x,y);
-  if (cell)
-  {
-    if (isPS) ; // cell->AddPSEnergy(energy); Preshower removed
-    else
-      cell->AddEnergy(energy);
-  }
-  else
-    return kFALSE;
-  return kTRUE;
-}
-
-inline Float_t CbmEcalStructure::GetEnergy(Float_t x, Float_t y, Bool_t isPS) const
-{
-  CbmEcalCell* cell=GetCell(x,y);
-  if (cell)
-  {
-    if (isPS)
-      return 0; //  return cell->GetPSEnergy(); Preshower removed
-    else
-      return cell->GetEnergy();
-  }
-  return -1111;
-}
-
-//Converts (x,y) to hit Id
-inline Int_t CbmEcalStructure::GetHitId(Float_t x, Float_t y) const
-{
-  CbmEcalCell* cell=GetCell(x,y);
-  if (cell)
-    return cell->GetCellNumber();
-  else
-    return -1111;
-}
-
-#endif
diff --git a/ecal/CbmEcalStructureExport.cxx b/ecal/CbmEcalStructureExport.cxx
deleted file mode 100644
index 5ddc98a55dc1a9d9a175fea766c7be250d8b701e..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalStructureExport.cxx
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "CbmEcalStructureExport.h"
-
-#include "FairRootManager.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalCell.h"
-
-#include "TTree.h"
-
-#include <iostream>
-#include <list>
-
-using namespace std;
-
-/** Default constructor **/
-CbmEcalStructureExport::CbmEcalStructureExport()
-  : FairTask(),
-    fVerbose(0), 
-    fEventN(0),
-    fX(0.),
-    fY(0.),
-    fE(0.),
-    fStructureOut(NULL),
-    fStr(NULL)
-{
-}
-
-/** Standerd constructor **/
-CbmEcalStructureExport::CbmEcalStructureExport(const char* name, const Int_t verbose)
-  : FairTask(name, verbose),
-    fVerbose(verbose), 
-    fEventN(0),
-    fX(0.),
-    fY(0.),
-    fE(0.),
-    fStructureOut(NULL),
-    fStr(NULL)
-{
-}
-
-/** Task initialization **/
-InitStatus CbmEcalStructureExport::Init()
-{
-  fEventN=0;
-  fStructureOut=NULL;
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init()", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStr) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  return kSUCCESS;
-}
-
-/** Exec for task **/
-void CbmEcalStructureExport::Exec(Option_t*)
-{
-  if (fStructureOut==NULL)
-  {
-    fStructureOut=new TTree("EcalStr", "Exported calorimeter structure");
-    fStructureOut->Branch("ev", &fEventN, "ev/I");
-    fStructureOut->Branch("x", &fX, "x/F");
-    fStructureOut->Branch("y", &fY, "y/F");
-    fStructureOut->Branch("e", &fE, "e/F");
-  }
- 
-  Int_t n=0;
-  Int_t t=0;
-  list<CbmEcalCell*> cells;
-  fStr->GetCells(cells);
-  list<CbmEcalCell*>::const_iterator p=cells.begin();
-  for(;p!=cells.end();++p)
-  {
-    if ((*p)->GetTotalEnergy()>0)
-    {
-      fE=(*p)->GetEnergy();
-      fX=(*p)->GetCenterX();
-      fY=(*p)->GetCenterY();
-      n++;
-      fStructureOut->Fill();
-    }
-    t++;
-  }
-  if (fVerbose>0)
-  {
-    Info("Exec()", "%d of %d cells writen to a file", n, t);
-  }
-  fEventN++;
-}
-  
-/** Finish task **/
-void CbmEcalStructureExport::Finish()
-{
-  if (fStructureOut) fStructureOut->Write();
-}
-
-/** virtual destructor **/
-CbmEcalStructureExport::~CbmEcalStructureExport()
-{
-  ;
-}
-
-ClassImp(CbmEcalStructureExport)
diff --git a/ecal/CbmEcalStructureExport.h b/ecal/CbmEcalStructureExport.h
deleted file mode 100644
index 83e206c2b3d342eace43564a23197786d4023da7..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalStructureExport.h
+++ /dev/null
@@ -1,52 +0,0 @@
-//We are going t hack the architecture to be much faster
-//Idea: we store tracks before the calorimeter and 
-//energy deposition in calorimeter. Mix all stuff with 
-//photon with known parameters and try to reconstruct it.
-#ifndef CBMECALSTRUCTUREEXPORT_H
-#define CBMECALSTRUCTUREEXPORT_H
-
-#include "FairTask.h"
-
-class TTree;
-class CbmEcalStructure;
-
-class CbmEcalStructureExport : public FairTask
-{
-public:
-  /** Default constructor **/
-  CbmEcalStructureExport();
-
-  /** Standerd constructor **/
-  CbmEcalStructureExport(const char* name, const Int_t verbose);
-
-  /** Task initialization **/
-  virtual InitStatus Init();
-
-  /** Exec for task **/
-  virtual void Exec(Option_t* opt);
-  
-  /** Finish task **/
-  virtual void Finish();
-
-  /** virtual destructor **/
-  ~CbmEcalStructureExport();
-private:
-  Int_t fVerbose;
- 
-  Int_t fEventN;
-  Float_t fX;
-  Float_t fY;
-  Float_t fE;
-
-  TTree* fStructureOut;			//!
-
-  CbmEcalStructure* fStr;		//!
-
-  CbmEcalStructureExport(const CbmEcalStructureExport&);
-  CbmEcalStructureExport& operator=(const CbmEcalStructureExport&);
-
-  ClassDef(CbmEcalStructureExport, 1)
-};
-
-#endif
-
diff --git a/ecal/CbmEcalStructureFiller.cxx b/ecal/CbmEcalStructureFiller.cxx
deleted file mode 100644
index f3c2ac9ec0867b0d1703ee360114194ba095d728..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalStructureFiller.cxx
+++ /dev/null
@@ -1,223 +0,0 @@
-#include "CbmEcalStructureFiller.h"
-#include "CbmEcalPointLite.h"
-#include "CbmEcalHit.h"
-#include "CbmEcalCellMC.h"
-
-#include "FairRootManager.h"
-
-#include "TRandom.h"
-#include "TVector3.h"
-#include "TRandom.h"
-
-#include <vector>
-#include <iostream>
-
-using namespace std;
-
-// -----   Default constructor   -------------------------------------------
-CbmEcalStructureFiller::CbmEcalStructureFiller() 
-  : FairTask(), 
-    fStr(NULL),
-    fInf(NULL),
-    fListECALpts(NULL),
-    fListUHits(NULL),
-    fListHits(NULL),
-    fEvent(0),
-    fInited(kFALSE),
-    fUseMCPoints(kFALSE),
-    fUseSummableHits(kFALSE),
-    fUseUnSummableHits(kFALSE),
-    fStoreTrackInfo(kTRUE),
-    fFileGeo("")
-{
-}
-// -------------------------------------------------------------------------
-
-// -----   Standard constructor   -------------------------------------------
-CbmEcalStructureFiller::CbmEcalStructureFiller(const char *name, const Int_t iVerbose, const char* fileGeo) 
-  : FairTask(name,iVerbose),
-    fStr(NULL),
-    fInf(CbmEcalInf::GetInstance(fileGeo)),
-    fListECALpts(NULL),
-    fListUHits(NULL),
-    fListHits(NULL),
-    fEvent(0),
-    fInited(kFALSE),
-    fUseMCPoints(kFALSE),
-    fUseSummableHits(kFALSE),
-    fUseUnSummableHits(kFALSE),
-    fStoreTrackInfo(kTRUE),
-    fFileGeo(fileGeo)
-{
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Destructor   ----------------------------------------------------
-CbmEcalStructureFiller::~CbmEcalStructureFiller()
-{
-  FairRootManager *fManager =FairRootManager::Instance();
-  fManager->Write();
-}
-// -------------------------------------------------------------------------
-
-void CbmEcalStructureFiller::SetParContainers()
-{
-  ;
-}
-
-// -----   Initialization   ------------------------------------------------
-InitStatus CbmEcalStructureFiller::Init()
-{
-  fInited=kTRUE;
-  FairRootManager* fManager = FairRootManager::Instance();
-
-  if (fUseMCPoints==kFALSE&&fUseSummableHits==kFALSE&&fUseUnSummableHits==kFALSE)
-  {
-    Warning("Init()", "No data source for structure filler! Calorimeter structure will be empty.");
-//    return kFATAL;
-  }
-  //ECAL MC points
-  if (fUseMCPoints) 
-    fListECALpts = (TClonesArray*)fManager->GetObject("EcalPointLite");
-
-  //ECAL Summable hits
-  if (fUseSummableHits) 
-    fListHits = (TClonesArray*)fManager->GetObject("EcalSumHit");
-  
-  //ECAL UnSummable hits
-  if (fUseUnSummableHits) 
-    fListUHits = (TClonesArray*)fManager->GetObject("EcalHit");
-  
-  // all MC tracks
-  //fListStack = (TClonesArray *)fManager->GetObject("MCTrack");
-  fInf->CheckVariables();
-  fStr=new CbmEcalStructure(fInf);
-  if (fStoreTrackInfo) fStr->SetUseMC(1);
-  fStr->Construct();
-  
-  fManager->Register("EcalStructure", "ECAL", fStr, kFALSE);
-  return kSUCCESS;
-}
-// -------------------------------------------------------------------------
-
-/** Loop over MCPoints hits and add them to cells **/
-void CbmEcalStructureFiller::LoopForMCPoints()
-{
-  CbmEcalPointLite* pt=NULL;
-  CbmEcalCell* cell;
-  Int_t ten;
-  UInt_t n;
-  Bool_t isPS;
-
-  n=fListECALpts->GetEntriesFast();
-  if (fVerbose>0)
-  {
-    cout << ". Number of input MC points: ";
-    cout << n << flush;
-  }
-
-  for(UInt_t j=0; j<n; j++)
-  {
-    pt=(CbmEcalPointLite*)fListECALpts->At(j);
-    cell=fStr->GetCell(pt->GetDetectorID(), ten, isPS);
-    if (ten==0)
-    {
-      if (isPS)
-	; // cell->AddPSEnergy(pt->GetEnergyLoss()); preshower removed
-      else
-	cell->AddEnergy(pt->GetEnergyLoss());
-    }
-  }
-  if (fStoreTrackInfo)
-  for(UInt_t j=0; j<n; j++)
-  {
-    pt=(CbmEcalPointLite*)fListECALpts->At(j);
-    CbmEcalCellMC* cellmc=(CbmEcalCellMC*)fStr->GetCell(pt->GetDetectorID(), ten, isPS);
-    if (ten==0)
-    {
-      if (isPS)
-	; // cell->AddTrackPSEnergy(pt->GetTrackID(),pt->GetEnergyLoss()); //preshower removed
-      else
-	cellmc->AddTrackEnergy(pt->GetTrackID(),pt->GetEnergyLoss(), pt->GetTime());
-    }
-  }
-}
-
-/** Loop over summable hits and add them to cells **/
-void CbmEcalStructureFiller::LoopForSummableHits()
-{
-  CbmEcalHit* pt=NULL;
-  CbmEcalCell* cell;
-  Int_t n;
-
-  n=fListHits->GetEntriesFast();
-  if (fVerbose>0)
-  {
-    cout << ". Number of input summable hits: ";
-    cout << n << flush;
-  }
-  for(Int_t j=0; j<n; j++)
-  {
-    pt=(CbmEcalHit*)fListHits->At(j);
-    cell=fStr->GetHitCell(pt->GetDetectorId());
-    cell->AddEnergy(pt->GetEnergy());
-  }
-  if (fStoreTrackInfo)
-  for(Int_t j=0; j<n; j++)
-  {
-    pt=(CbmEcalHit*)fListHits->At(j);
-    CbmEcalCellMC* cellmc=(CbmEcalCellMC*)fStr->GetHitCell(pt->GetDetectorId());
-    cellmc->AddTrackEnergy(pt->GetTrackId(), pt->GetEnergy(), pt->GetTime());
-  }
-}
-
-/** Loop over hits and add them to cells **/
-void CbmEcalStructureFiller::LoopForUnSummableHits()
-{
-  CbmEcalHit* pt=NULL;
-  CbmEcalCell* cell;
-  Int_t n;
-
-  n=fListUHits->GetEntriesFast();
-  if (fVerbose>0)
-  {
-    cout << ". Number of input unsummable hits: ";
-    cout << n << flush;
-  }
-  for(Int_t j=0; j<n; j++)
-  {
-    pt=(CbmEcalHit*)fListUHits->At(j);
-    cell=fStr->GetHitCell(pt->GetDetectorId());
-    cell->AddEnergy(pt->GetEnergy());
-    cell->SetTime(pt->GetTime());
-  }
-}
-
-// -----   Execution of Task   ---------------------------------------------
-void CbmEcalStructureFiller::Exec(Option_t*)
-{
-  fEvent++;
-  if (fVerbose>0)
-    cout << "--> Event no. " << fEvent;
-
-  fStr->ResetModules();
-  if (fUseMCPoints) LoopForMCPoints();
-  if (fUseSummableHits) LoopForSummableHits();
-  if (fUseUnSummableHits) LoopForUnSummableHits();
-
-  if (fVerbose>0)
-    cout << endl << flush;
-}
-// -------------------------------------------------------------------------
-
-
-// -----   Finish Task   ---------------------------------------------------
-void CbmEcalStructureFiller::Finish()
-{
-  ;
-}
-// -------------------------------------------------------------------------
-
-
-ClassImp(CbmEcalStructureFiller)
diff --git a/ecal/CbmEcalStructureFiller.h b/ecal/CbmEcalStructureFiller.h
deleted file mode 100644
index 70a9cc8ca45f059827720f322908ed8f183d53c9..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalStructureFiller.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/** Creates a CbmEcalStructure and fill it with Hits/SHits/MCPoints **/
-
-/**  CbmEcalStructureFiller.h
- *@author Yu.Kharlov
- **
- ** Class for producing either ECAL hits
- ** or ECAL summable hits from MCPoints,
- **  Definitions:
- ** ECAL hit is total deposited energy by all track in ECAL cell
- ** ECAL summable hit is a deposited energy by each tracks in ECAL cell
- **  Use cases:
- **
- ** 1. To produce hits from MC points:
- ** CbmEcalStructureFiller* hp=new CbmEcalStructureFiller("EcalHitProducer");
- ** hp->SetMCPoints2Hits();
- ** fRun->AddTask(hp);
- **
- ** 2. To produce summable hits from MC points:
- ** CbmEcalStructureFiller* hp=new CbmEcalStructureFiller("EcalHitProducer");
- ** hp->SetMCPoints2SumHits();
- ** fRun->AddTask(hp);
- **
- ** 3. To produce hits from summable hits:
- ** CbmEcalStructureFiller* hp=new CbmEcalStructureFiller("EcalHitProducer");
- ** hp->SetSumHits2Hits();
- ** fRun->AddTask(hp);
- **/
-
-#ifndef CBMECALSTRUCTUREFILLER_H
-#define CBMECALSTRUCTUREFILLER_H
-
-#include "FairTask.h"
-#include "TClonesArray.h"
-#include "CbmEcalHit.h"
-#include "CbmStack.h"
-#include "CbmEcalInf.h"
-#include "CbmEcalStructure.h"
-#include "TString.h"
-#include "TVector3.h"
-
-class CbmEcalStructureFiller : public FairTask {
-
-public:
-  /** Default constructor **/
-  CbmEcalStructureFiller();
-
-  /** Standard constructor **/
-  CbmEcalStructureFiller(const char *name, const Int_t iVerbose=1, const char* fileGeo="ecal_FullMC.geo");
-
-  /** Destructor **/
-  virtual ~CbmEcalStructureFiller();
-
-  /** Initialization of the task **/  
-  virtual InitStatus Init();
-
-  /** Executed task **/ 
-  virtual void Exec(Option_t* option);
-
-  /** Finish task **/ 
-  virtual void Finish();
-
-  /** Set data source for hit producer.
-   ** This must be called before Init()
-   ** (No effect other case)! **/
-  void SetUseMCPoints(Bool_t UseMCPoints);
-  void SetUseSummableHits(Bool_t UseSummableHits);
-  /** Can be set kTRUE only if ProduceSummableHits false **/
-  void SetUseHits(Bool_t UseHits);
-
-  CbmEcalStructure* GetStructure() const;
-  void StoreTrackInformation(Bool_t storetrackinfo=kTRUE);
-  Bool_t GetStoreTrackInformation() const;
-
-  Bool_t GetUseMCPoints() const;
-  Bool_t GetUseSummableHits() const;
-  Bool_t GetUseHits() const;
-protected:
-
-private:
-  /** Init parameter containers **/
-  void SetParContainers();
-  /** Loop over MCPoints **/
-  void LoopForMCPoints();
-  /** Loop over summable hits **/
-  void LoopForSummableHits();
-  /** Loop over hits **/
-  void LoopForUnSummableHits();
-  CbmEcalStructure* fStr;
-  CbmEcalInf* fInf;		//ECAL geometry container
-
-  TClonesArray* fListECALpts;   // ECAL MC points
-  TClonesArray* fListUHits;	// ECAL hits
-  TClonesArray* fListHits;	// ECAL summable hits
-//  TClonesArray* fListStack;     // Tracks
-  Int_t fEvent;                 //! Internal event counter
-
-  /** Is Init() already done? **/
-  Bool_t fInited;
-  /** Should we take data from MCPoints? **/
-  Bool_t fUseMCPoints;
-  /** Should we take data from summable hits? **/
-  Bool_t fUseSummableHits;
-  /** Should we take data from hits? **/
-  Bool_t fUseUnSummableHits;
-
-  /** Should we store information about tracks/energy depostion **/
-  Bool_t fStoreTrackInfo;
-  /** Geo file to use **/
-  TString fFileGeo;
-
-  CbmEcalStructureFiller(const CbmEcalStructureFiller&);
-  CbmEcalStructureFiller& operator=(const CbmEcalStructureFiller&);
-
-  ClassDef(CbmEcalStructureFiller,1)
-
-};
-
-inline void CbmEcalStructureFiller::SetUseMCPoints(Bool_t UseMCPoints)
-{
-	if (fInited) return;
-	fUseMCPoints=UseMCPoints;
-}
-
-inline void CbmEcalStructureFiller::SetUseSummableHits(Bool_t UseSummableHits)
-{
-	if (fInited) return;
-	fUseSummableHits=UseSummableHits;
-}
-
-/** Can be set only if ProduceSummableHits false **/
-inline void CbmEcalStructureFiller::SetUseHits(Bool_t UseHits)
-{
-	if (fInited) return;
-	fUseUnSummableHits=UseHits;
-}
-
-inline Bool_t CbmEcalStructureFiller::GetUseMCPoints() const
-{
-	return fUseMCPoints;
-}
-
-inline Bool_t CbmEcalStructureFiller::GetUseSummableHits() const
-{
-	return fUseSummableHits;
-}
-
-inline Bool_t CbmEcalStructureFiller::GetUseHits() const
-{
-	return fUseUnSummableHits;
-}
-
-
-inline void CbmEcalStructureFiller::StoreTrackInformation(Bool_t storetrackinfo)
-{
-  if (fInited) return;
-  fStoreTrackInfo=storetrackinfo;
-}
-
-inline Bool_t CbmEcalStructureFiller::GetStoreTrackInformation() const
-{
-  return fStoreTrackInfo;
-}
-
-inline CbmEcalStructure* CbmEcalStructureFiller::GetStructure() const
-{
-  return fStr;
-}
-
-#endif
diff --git a/ecal/CbmEcalTimeDigitizer.cxx b/ecal/CbmEcalTimeDigitizer.cxx
deleted file mode 100644
index 93236d1ba3abc1d4b28f91f5bcbd502216e7bdfe..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalTimeDigitizer.cxx
+++ /dev/null
@@ -1,166 +0,0 @@
-#include "CbmEcalTimeDigitizer.h"
-
-#include "FairRootManager.h"
-
-#include "TFormula.h"
-
-#include "CbmEcalParam.h"
-#include "CbmEcalCellMC.h"
-#include "CbmEcalStructure.h"
-#include "CbmEcalCalibration.h"
-
-#include <iostream>
-
-using namespace std;
-
-/** Loop procedure **/
-void CbmEcalTimeDigitizer::Exec(Option_t*)
-{
-  if (fVerbose>0)
-    Info("Exec", "Event %d.", ++fEvent);
-  if (fCells.size()==0)
-    fStr->GetCells(fCells);
-  list<CbmEcalCell*>::const_iterator p=fCells.begin();
-  for(;p!=fCells.end();++p)
-    CalculateTime((CbmEcalCellMC*)(*p));
-}
-
-/** Calculate time in given cell **/
-void CbmEcalTimeDigitizer::CalculateTime(CbmEcalCellMC* cell)
-{
-  std::map<Int_t, Float_t>::const_iterator p=cell->GetTrackEnergyBegin();
-  Int_t n=0;
-  Int_t i;
-  Double_t e=0;
-  for(;p!=cell->GetTrackEnergyEnd();++p)
-  {
-    Double_t time=cell->GetTrackTime(p->first);
-    if (time!=-1111)
-    {
-      fE[n]=p->second;
-      fT[n]=time;
-      n++;
-    }
-    else
-    {
-      Info("CalculateTime","Can't find time information for track %d.", p->first);
-      return;
-    }
-  }
-  TMath::Sort(n, fT, fI);
-  for(i=0;i<n;i++)
-  {
-    e+=fE[fI[i]];
-    if (fCal->GetEnergy(e, cell)>fThreshold)
-      break;
-  }
-  if (i!=n)
-  {
-    fResponse->SetParameter(2, fT[fI[i]]);
-    fResponse->SetParameter(1, fCal->GetEnergy(fE[fI[i]], cell));
-    fResponse->SetParameter(0, fCal->GetEnergy(cell->GetEnergy(), cell));
-    cell->SetTime(fResponse->Eval(0));
-  }
-  else
-  {
-//    cout << "CellTimeCalc: " << e << "	" << fCal->GetEnergy(e, cell) << "	" << cell->GetCenterX() << "	" << cell->GetCenterY() << endl;
-    cell->SetTime(-1111);
-  }
-}
-
-void CbmEcalTimeDigitizer::SetArraySize(Int_t size)
-{
-  if (fSize>size) return;
-  if (fE) delete fE;
-  if (fT) delete fT;
-  if (fI) delete fI;
-  fSize=size;
-  fE=new Double_t[fSize];
-  fT=new Double_t[fSize];
-  fI=new Int_t[fSize];
-}
-
-CbmEcalTimeDigitizer::CbmEcalTimeDigitizer()
-  : FairTask(),
-    fStr(NULL),
-    fCells(),
-    fResponse(NULL),
-    fConfigName(""),
-    fThreshold(0.),
-    fEvent(0),
-    fCal(NULL),
-    fSize(0),
-    fE(NULL),
-    fT(NULL),
-    fI(NULL)
-
-{
-}
-
-
-CbmEcalTimeDigitizer::CbmEcalTimeDigitizer(const char* name, const Int_t iVerbose, const char* config)
-  : FairTask(name, iVerbose),
-    fStr(NULL),
-    fCells(),
-    fResponse(NULL),
-    fConfigName(config),
-    fThreshold(0.),
-    fEvent(0),
-    fCal(NULL),
-    fSize(0),
-    fE(NULL),
-    fT(NULL),
-    fI(NULL)
-
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalTimeDigitizer::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-  if (!fManager)
-  {
-    Fatal("Init", "Can't find a Root Manager.");
-    return kFATAL;
-  }
-  fStr=(CbmEcalStructure*)fManager->GetObject("EcalStructure");
-  if (!fStr)
-  {
-    Fatal("Init", "Can't find calorimeter structure in the system");
-    return kFATAL;
-  }
-  fCal=(CbmEcalCalibration*)fManager->GetObject("EcalCalibration");
-  if (!fCal)
-  {
-    Fatal("Init", "Can't find EcalCalibration");
-    return kFATAL;
-  }
-
-  CbmEcalParam* par=new CbmEcalParam("EcalTimeDigitizer", fConfigName);
-  fThreshold=par->GetDouble("energythreshold");
-  TString st=par->GetString("response");
-  Info("Init","Using formula %s.", st.Data());
-  st.ReplaceAll("Ecell","[0]");
-  st.ReplaceAll("Eparticle","[1]");
-  st.ReplaceAll("Tparticle","[2]");
-  Info("Init","Using formula %s.", st.Data());
-  fResponse=new TFormula("EcalTimeDigitizerFormula", st);
-  delete par;
-
-  fEvent=0;
-  fCells.clear();
-  SetArraySize(6000);
-
-  return kSUCCESS;
-}
-
-/** Finishing routine **/
-void CbmEcalTimeDigitizer::Finish()
-{
-  if (fE) delete fE;
-  if (fT) delete fT;
-  if (fI) delete fI;
-}
-
-ClassImp(CbmEcalTimeDigitizer)
diff --git a/ecal/CbmEcalTimeDigitizer.h b/ecal/CbmEcalTimeDigitizer.h
deleted file mode 100644
index 581b52d74467fe41f6f86aa7fefafe161a74b365..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalTimeDigitizer.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef CBMECALTIMEDIGITIZER_H
-#define CBMECALTIMEDIGITIZER_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class CbmEcalStructure;
-class CbmEcalCellMC;
-class CbmEcalCell;
-class CbmEcalCalibration;
-class TFormula;
-
-class CbmEcalTimeDigitizer : public FairTask
-{
-public:
-  CbmEcalTimeDigitizer(const char* name, const Int_t iVerbose=0, const char* config="");
-public:
-  /** Default constructor **/
-  CbmEcalTimeDigitizer();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Destructor **/
-  virtual ~CbmEcalTimeDigitizer() {};
-private:
-  /** Calculate time in given cell **/
-  void CalculateTime(CbmEcalCellMC* cell);
-  /** Set size of time/energy deposition array **/
-  void SetArraySize(Int_t size);
-  /** Calorimeter structure **/
-  CbmEcalStructure* fStr;		//!
-  /** All cells in the calorimeter **/
-  std::list<CbmEcalCell*> fCells;		//!
-  /** Formuta of time response **/
-  TFormula* fResponse;			//!
-  /** Name of configuration file **/
-  TString fConfigName;			//!
-  /** Enregy threshold for the cell **/
-  Double_t fThreshold;
-  /** Event number **/
-  Int_t fEvent;
-  /** A calibration of the calorimeter **/
-  CbmEcalCalibration* fCal;		//!
-
-  /** An array of emergy deposition with time **/
-  Int_t fSize;
-  Double_t* fE;				//!
-  Double_t* fT;				//!
-  Int_t* fI;				//!
-
-  CbmEcalTimeDigitizer(const CbmEcalTimeDigitizer&);
-  CbmEcalTimeDigitizer& operator=(const CbmEcalTimeDigitizer&);
-
-  ClassDef(CbmEcalTimeDigitizer,1)
-};
-
-#endif 
-
diff --git a/ecal/CbmEcalTrackExport.cxx b/ecal/CbmEcalTrackExport.cxx
deleted file mode 100644
index 70ded51c508bd2a3b01d7a283ea8d85246348830..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalTrackExport.cxx
+++ /dev/null
@@ -1,120 +0,0 @@
-#include "CbmEcalTrackExport.h"
-
-#include "FairRootManager.h"
-#include "FairTrackParam.h"
-
-#include "TClonesArray.h"
-#include "TFile.h"
-
-#include <iostream>
-
-using namespace std;
-
-/** Default constructor **/
-CbmEcalTrackExport::CbmEcalTrackExport()
-  : FairTask(),
-    fVerbose(0), 
-    fEventN(0),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fTx(0.),
-    fTy(0.),
-    fQp(0.),
-    fTracksOut(NULL),
-    fTrackPar(NULL)
-{
-}
-
-/** Standerd constructor **/
-CbmEcalTrackExport::CbmEcalTrackExport(const char* name, const Int_t verbose)
-  : FairTask(name, verbose),
-    fVerbose(verbose), 
-    fEventN(0),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fTx(0.),
-    fTy(0.),
-    fQp(0.),
-    fTracksOut(NULL),
-    fTrackPar(NULL)
-{
-
-}
-
-/** Task initialization **/
-InitStatus CbmEcalTrackExport::Init()
-{
-  fTracksOut=NULL;
-  fEventN=0;
-
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fTrackPar=(TClonesArray*)io->GetObject("EcalTrackParam");
-  if (!fTrackPar)
-  {
-    Fatal("Init", "Can't find EcalTrackParam.");
-    return kFATAL;
-  }
-  return kSUCCESS;
-}
-
-/** Exec for task **/
-void CbmEcalTrackExport::Exec(Option_t*)
-{
-  if (fTracksOut==NULL)
-  {
-    fTracksOut=new TTree("ecaltracks","Tracks before the calorimeter");
-    fTracksOut->Branch("x", &fX, "x/F");
-    fTracksOut->Branch("y", &fY, "y/F");
-    fTracksOut->Branch("z", &fZ, "z/F");
-    fTracksOut->Branch("tx", &fTx, "tx/F");
-    fTracksOut->Branch("ty", &fTy, "ty/F");
-    fTracksOut->Branch("qp", &fQp, "qp/F");
-    fTracksOut->Branch("ev", &fEventN, "ev/I");
-  }
-  Int_t i;
-  Int_t n=fTrackPar->GetEntriesFast();
-  Int_t tr=0;
-  FairTrackParam* par;
-
-  for(i=0;i<n;i++)
-  {
-    par=(FairTrackParam*)fTrackPar->At(i);
-    if (par==NULL) continue;
-    fX=par->GetX();
-    fY=par->GetY();
-    fZ=par->GetZ();
-    fTx=par->GetTx();
-    fTy=par->GetTy();
-    fQp=par->GetQp();
-    fTracksOut->Fill();
-    tr++;
-  }
-  if (fVerbose>0)
-  {
-    Info("Exec", "%d tracks writen to disk.", tr);
-  }
-  fEventN++;
-  gFile->Write();
-}
-  
-/** Finish task **/
-void CbmEcalTrackExport::Finish()
-{
-  if (fTracksOut) fTracksOut->Write();
-}
-
-/** virtual destructor **/
-CbmEcalTrackExport::~CbmEcalTrackExport()
-{
-  ;
-}
-
-
-ClassImp(CbmEcalTrackExport)
diff --git a/ecal/CbmEcalTrackExport.h b/ecal/CbmEcalTrackExport.h
deleted file mode 100644
index 640a33510f83f3597c4112459a94a24cac6738ab..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalTrackExport.h
+++ /dev/null
@@ -1,55 +0,0 @@
-//We are going t hack the architecture to be much faster
-//Idea: we store tracks before the calorimeter and 
-//energy deposition in calorimeter. Mix all stuff with 
-//photon with known parameters and try to reconstruct it.
-#ifndef CBMECALTRACKEXPORT_H
-#define CBMECALTRACKEXPORT_H
-
-#include "FairTask.h"
-
-class TTree;
-class TClonesArray;
-
-class CbmEcalTrackExport : public FairTask
-{
-public:
-  /** Default constructor **/
-  CbmEcalTrackExport();
-
-  /** Standerd constructor **/
-  CbmEcalTrackExport(const char* name, const Int_t verbose);
-
-  /** Task initialization **/
-  virtual InitStatus Init();
-
-  /** Exec for task **/
-  virtual void Exec(Option_t* opt);
-  
-  /** Finish task **/
-  virtual void Finish();
-
-  /** virtual destructor **/
-  ~CbmEcalTrackExport();
-private:
-  Int_t fVerbose;
- 
-  Int_t fEventN;
-  Float_t fX;
-  Float_t fY;
-  Float_t fZ;
-  Float_t fTx;
-  Float_t fTy;
-  Float_t fQp;
-
-  TTree* fTracksOut;			//!
-
-  TClonesArray* fTrackPar;
-
-  CbmEcalTrackExport(const CbmEcalTrackExport&);
-  CbmEcalTrackExport& operator=(const CbmEcalTrackExport&);
-
-  ClassDef(CbmEcalTrackExport, 1)
-};
-
-#endif
-    
diff --git a/ecal/CbmEcalTrackExtrapolation.cxx b/ecal/CbmEcalTrackExtrapolation.cxx
deleted file mode 100644
index bf31e64b97252975f0ba0809a867bdfbd9d6b1b0..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalTrackExtrapolation.cxx
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "CbmEcalTrackExtrapolation.h"
-
-#include "FairRootManager.h"
-
-void CbmEcalTrackExtrapolation::Init()
-{
-  FairRootManager* ioman=FairRootManager::Instance();
-  if (!ioman)
-    Fatal("CbmEcalTrackExtrapolationKF::Init()", "Can't instantise Rootmanager");
-  ioman->Register("EcalTrackExtrapolation", "ECAL", this, kFALSE);
-  fMap=new Short_t[32000]; 
-}
-
-ClassImp(CbmEcalTrackExtrapolation)
diff --git a/ecal/CbmEcalTrackExtrapolation.h b/ecal/CbmEcalTrackExtrapolation.h
deleted file mode 100644
index 8e2eba22f0a4680a78f1577f3306a5819b975e72..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalTrackExtrapolation.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef CBMECALTRACKEXTRAPOLATION_H
-#define CBMECALTRACKEXTRAPOLATION_H
-
-#include "TNamed.h"
-
-class TClonesArray;
-class CbmGlobalTrack;
-class FairTrackParam;
-class CbmEcalStructure;
-
-class CbmEcalTrackExtrapolation : public TNamed
-{
-public:
-  CbmEcalTrackExtrapolation(Int_t verb=0): TNamed("EcalTrackExtrapolation","Tracking for calorimeter"), fVerbose(verb), fStr(NULL), fMap(NULL) {};
-  virtual ~CbmEcalTrackExtrapolation() {delete fMap;}
-  virtual void Init(); 
-  virtual void Finish() {};
-  virtual Int_t DoExtrapolate(TClonesArray* gTrackArr, TClonesArray* fTrackParam)=0;
-  /** Set verbosity level **/
-  inline void SetVerbose(Int_t verbose) {fVerbose=verbose;}
-  inline void SetStructure(CbmEcalStructure* str) {fStr=str;}
-  inline CbmEcalStructure* GetStructure() const {return fStr;}
-  inline Short_t* Map() {return fMap;} 
-protected:
-  inline Int_t Verbose() const {return fVerbose;}
-  inline CbmEcalStructure* Str() const {return fStr;}
-private:
-  Int_t fVerbose;
-  CbmEcalStructure* fStr;
-  // A map: track at calorimeter surface -> global track
-  Short_t* fMap;			//!
-
-  CbmEcalTrackExtrapolation(const CbmEcalTrackExtrapolation&);
-  CbmEcalTrackExtrapolation& operator=(const CbmEcalTrackExtrapolation&);
-
-  ClassDef(CbmEcalTrackExtrapolation, 1)
-};
-
-#endif
diff --git a/ecal/CbmEcalTrackImport.cxx b/ecal/CbmEcalTrackImport.cxx
deleted file mode 100644
index 63a80008ea21c4516ffa8a2b5935f73b38103cc7..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalTrackImport.cxx
+++ /dev/null
@@ -1,124 +0,0 @@
-#include "CbmEcalTrackImport.h"
-
-#include "FairRootManager.h"
-#include "FairTrackParam.h"
-
-#include "TClonesArray.h"
-#include "TChain.h"
-#include "TMatrixFSym.h"
-
-#include <iostream>
-
-using namespace std;
-
-/** add a root file with tracks to chain **/
-void CbmEcalTrackImport::AddFile(const char* name)
-{
-  fChain->Add(name);
-}
-
-/** Standard constructor **/
-CbmEcalTrackImport::CbmEcalTrackImport(const char* name, const Int_t verbose)
-  : FairTask(name, verbose),
-    fChain(new TChain("ecaltracks")),
-    fEventN(0),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fTx(0.),
-    fTy(0.),
-    fQp(0.),
-    fN(0),
-    fEntry(0),
-    fEv(0),
-    fTracks(NULL)
-{
-}
-
-
-/** Task initialization **/
-InitStatus CbmEcalTrackImport::Init()
-{
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fChain->SetBranchAddress("ev", &fEventN);
-  fChain->SetBranchAddress("x", &fX);
-  fChain->SetBranchAddress("y", &fY);
-  fChain->SetBranchAddress("z", &fZ);
-  fChain->SetBranchAddress("tx", &fTx);
-  fChain->SetBranchAddress("ty", &fTy);
-  fChain->SetBranchAddress("qp", &fQp);
-  fN=fChain->GetEntries();
-  if (fVerbose>0)
-    Info("Init", "%d tracks in input files.", fN);
-  if (fN==0)
-    Error("Init", "No tracks in input files");
-  fTracks=new TClonesArray("FairTrackParam", 1000);
-  io->Register("EcalTrackParam", "ECAL", fTracks, kFALSE);
-  fEv=0; fEntry=1;
-  fChain->GetEntry(0);
-  return kSUCCESS;
-}
-
-/** Exec for task **/
-void CbmEcalTrackImport::Exec(Option_t*)
-{
-  fTracks->Delete();
-
-  fEv++;
-  Int_t nTr=0;
-  TMatrixFSym mat(5);
-  if (fEntry>=fN)
-  {
-    Warning("Exec", "No tracks found in file for event %d!", fEventN);
-    return;
-  }
-  while(fEventN<fEv)
-  {
-    new ((*fTracks)[nTr++]) FairTrackParam(fX, fY, fZ, fTx, fTy, fQp, mat);
-    if (fEntry<fN)
-      fChain->GetEntry(fEntry++);
-    else
-      break;
-  }
-  if (fVerbose>0)
-    Info("Exec", "%d tracks imported.", nTr);
-}
-  
-/** Finish task **/
-void CbmEcalTrackImport::Finish()
-{
-  ;
-}
-
-/** virtual destructor **/
-CbmEcalTrackImport::~CbmEcalTrackImport()
-{
-  fTracks->Delete();
-  delete fTracks;
-}
-  
-/** Only to comply with framework **/
-CbmEcalTrackImport::CbmEcalTrackImport()
-  : FairTask(),
-    fChain(),
-    fEventN(0),
-    fX(0.),
-    fY(0.),
-    fZ(0.),
-    fTx(0.),
-    fTy(0.),
-    fQp(0.),
-    fN(0),
-    fEntry(0),
-    fEv(0),
-    fTracks(NULL)
-{
-}
-
-
-ClassImp(CbmEcalTrackImport)
diff --git a/ecal/CbmEcalTrackImport.h b/ecal/CbmEcalTrackImport.h
deleted file mode 100644
index 3df2ee9fc475ae71caba7e69726023abd38a1262..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalTrackImport.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/** A second part of hack for fast tracking **/
-
-#ifndef CBMECALTRACKIMPORT_H
-#define CBMECALTRACKIMPORT_H
-
-#include "FairTask.h"
-
-class TChain;
-class TClonesArray;
-
-class CbmEcalTrackImport : public FairTask
-{
-public:
-  /** Only to comply with framework **/
-  CbmEcalTrackImport();
-  /** Standard constructor **/
-  CbmEcalTrackImport(const char* name, const Int_t verbose);
-
-  /** Task initialization **/
-  virtual InitStatus Init();
-
-  /** Exec for task **/
-  virtual void Exec(Option_t* opt);
-  
-  /** Finish task **/
-  virtual void Finish();
-
-  /** virtual destructor **/
-  ~CbmEcalTrackImport();
-  
-  /** add a root file with tracks to chain **/
-  void AddFile(const char* name);
-private:
-  /** A chain with tracks **/
-  TChain* fChain;		//!
-  /** An event number in file **/
-  Int_t fEventN;
-  /** X coordinate of track **/
-  Float_t fX;
-  /** Y coordinate of track **/
-  Float_t fY;
-  /** Z coordinate of track **/
-  Float_t fZ;
-  /** Tx (ask tracking people for name) **/
-  Float_t fTx;
-  /** Ty (ask tracking people for name) **/
-  Float_t fTy;
-  /** Qp (ask tracking people for name) **/
-  Float_t fQp;
-  /** A number of records in file **/
-  Int_t fN;
-  /** A current entry in chain **/
-  Int_t fEntry;
-
-  /** A current event **/
-  Int_t fEv;
-  /** An output array of tracks **/
-  TClonesArray* fTracks;	//!
-
-  CbmEcalTrackImport(const CbmEcalTrackImport&);
-  CbmEcalTrackImport& operator=(const CbmEcalTrackImport&);
-
-  ClassDef(CbmEcalTrackImport, 1)
-};
-
-#endif
diff --git a/ecal/CbmEcalTracking.cxx b/ecal/CbmEcalTracking.cxx
deleted file mode 100644
index 9d759114f718c274b997a87f4296d55c3e870a07..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalTracking.cxx
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "CbmEcalTracking.h"
-
-#include "CbmEcalStructure.h"
-#include "CbmEcalTrackExtrapolation.h"
-#include "FairRootManager.h"
-
-#include "FairTrackParam.h"
-
-#include "TClonesArray.h"
-
-#include <iostream>
-
-using namespace std;
-
-/** Default constructor **/
-CbmEcalTracking::CbmEcalTracking()
-  : FairTask(), 
-    fVerbose(0), 
-    fStru(NULL), 
-    fTrE(NULL),
-    fGTArray(NULL),
-    fTrackPar(NULL)
-{
-}
-
-/** Standerd constructor **/
-CbmEcalTracking::CbmEcalTracking(const char* name, const Int_t verbose)
-  : FairTask(name, verbose), 
-    fVerbose(0), 
-    fStru(NULL), 
-    fTrE(NULL),
-    fGTArray(NULL),
-    fTrackPar(NULL)
-{
-}
-
-/** Task initialization **/
-InitStatus CbmEcalTracking::Init()
-{
-  if (!fTrE) return kFATAL; 
-  
-  FairRootManager* io=FairRootManager::Instance();
-  if (!io)
-  {
-    Fatal("Init()", "Can't find IOManager.");
-    return kFATAL;
-  }
-  fGTArray=(TClonesArray*)io->GetObject("GlobalTrack");
-  if (!fGTArray)
-  {
-    Fatal("Init()", "Can't find GlobalTrack.");
-    return kFATAL;
-  }
-  fTrackPar=new TClonesArray("FairTrackParam", 1000);
-  io->Register("EcalTrackParam", "ECAL", fTrackPar, IsOutputBranchPersistent("EcalTrackParam"));
-  fStru=(CbmEcalStructure*)io->GetObject("EcalStructure");
-  if (!fStru) 
-  {
-    Fatal("Init()", "Can't find calorimeter structure in the system.");
-    return kFATAL;
-  }
-  fTrE->SetStructure(fStru);
-  
-  fTrE->Init();
-  return kSUCCESS;
-}
-
-/** Exec for task **/
-void CbmEcalTracking::Exec(Option_t*)
-{
-  Int_t tn;
-  
-  fTrackPar->Clear();
-  tn=fTrE->DoExtrapolate(fGTArray, fTrackPar);
-  cout << "Total " << tn << " tracks before ECAL." << endl;
-/*
-  tn=fTrackPar->GetEntriesFast();
-  for(i=0;i<tn;i++)
-  {
-    par=(FairTrackParam*)fTrackPar->At(i);
-    if (!par) continue;
-    cout << "Track " << i << ":(" << par->GetX() << ", " << par->GetY();
-    cout << ", " << par->GetZ() << ")" << endl;
-  }
-*/
-}
-  
-/** Finish task **/
-void CbmEcalTracking::Finish()
-{
-  fTrE->Finish();
-}
-
-/** virtual destructor **/
-CbmEcalTracking::~CbmEcalTracking()
-{
-  fTrackPar->Delete();
-  delete fTrackPar;
-}
-
-ClassImp(CbmEcalTracking)
diff --git a/ecal/CbmEcalTracking.h b/ecal/CbmEcalTracking.h
deleted file mode 100644
index 4979ba820c2eed98caf2d786950d0e3e251ee488..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalTracking.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef CBMECALTRACKING_H
-#define CBMECALTRACKING_H
-
-#include "FairTask.h"
-
-class CbmEcalHitProducer;
-class CbmEcalStructure;
-class CbmEcalTrackExtrapolation;
-class TClonesArray;
-
-class CbmEcalTracking : public FairTask
-{
-public:
-  /** Default constructor **/
-  CbmEcalTracking();
-
-  /** Standerd constructor **/
-  CbmEcalTracking(const char* name, const Int_t verbose);
-
-  /** Get/Set track extrapolation algorithm **/
-  void SetTrackExtrapolation(CbmEcalTrackExtrapolation* e);
-  CbmEcalTrackExtrapolation* GetTrackExtrapolation() const;
-
-  /** Task initialization **/
-  virtual InitStatus Init();
-
-  /** Exec for task **/
-  virtual void Exec(Option_t* opt);
-  
-  /** Finish task **/
-  virtual void Finish();
-
-  /** virtual destructor **/
-  ~CbmEcalTracking();
-private:
-  Int_t fVerbose;
- 
-  CbmEcalStructure* fStru;
-  CbmEcalTrackExtrapolation* fTrE;
-  TClonesArray* fGTArray;
-  TClonesArray* fTrackPar;
-
-  CbmEcalTracking(const CbmEcalTracking&);
-  CbmEcalTracking& operator=(const CbmEcalTracking&);
-
-  ClassDef(CbmEcalTracking, 1)
-};
-
-/** Get/Set track extrapolation algorithm **/
-inline void CbmEcalTracking::SetTrackExtrapolation(CbmEcalTrackExtrapolation* e)
-{
-  fTrE=e;
-}
-
-inline CbmEcalTrackExtrapolation* CbmEcalTracking::GetTrackExtrapolation() const
-{
-  return fTrE;
-}
-
-#endif
-    
diff --git a/ecal/CbmEcalUrqmdCalibrator.cxx b/ecal/CbmEcalUrqmdCalibrator.cxx
deleted file mode 100644
index 207ea10f816abad98c6cae92f607a91a19dacc6a..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalUrqmdCalibrator.cxx
+++ /dev/null
@@ -1,481 +0,0 @@
-/* $Id: CbmEcalUrqmdCalibrator.cxx,v 1.3 2006/08/30 13:16:45 prokudin Exp $*/
-
-/*
- * $Log: CbmEcalUrqmdCalibrator.cxx,v $
- * Revision 1.3  2006/08/30 13:16:45  prokudin
- * Bug huntong
- *
- * Revision 1.2  2006/08/25 19:17:48  prokudin
- * Energy in cell added. Minor bug fixed.
- *
- * Revision 1.1  2006/08/17 18:16:35  prokudin
- * first version of UrqmdCalibrator
- *
- */
-
-#include "CbmEcalUrqmdCalibrator.h"
-
-#include "CbmEcalInf.h"
-#include "CbmEcalPoint.h"
-#include "CbmEcalPointLite.h"
-#include "CbmEcalStructure.h"
-
-#include "CbmEcalCellMC.h"
-
-#include "FairRunAna.h"
-#include "FairRuntimeDb.h"
-#include "FairRootManager.h"
-#include "CbmMCTrack.h"
-
-#include "TTree.h"
-#include "TClonesArray.h"
-#include "TDatabasePDG.h"
-#include "TParticlePDG.h"
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::list;
-
-/** Loop procedure **/
-void CbmEcalUrqmdCalibrator::Exec(Option_t*)
-{
-  list<CbmEcalPoint*>::const_iterator p;
-  fEvent++;
-  if (fVerbose>0)
-    cout << "Processing event " << fEvent << "." << endl; 
-  FillStructure();
-  InitTree();
-  FillList();
-
-  for(p=fList.begin(); p!=fList.end(); ++p)
-  {
-    ProcessHit(*p);
-  }
-}
-
-
-/** Fills ECAL structure **/
-void CbmEcalUrqmdCalibrator::FillStructure()
-{
-  CbmEcalPointLite* pt;
-  CbmMCTrack* track;
-  CbmEcalCellMC* cell;
-  Int_t ten;
-  UInt_t n;
-  Bool_t isPS;
-
-  fStr->ResetModules();
-
-  n=fLitePoints->GetEntriesFast();
-  if (fVerbose>0)
-  {
-    cout << "Number of input lite ECAL points " << n;
-    cout << "." << endl;
-  }
-  for(UInt_t j=0; j<n; j++)
-  {
-    pt=(CbmEcalPointLite*)fLitePoints->At(j);
-    cell=(CbmEcalCellMC*)fStr->GetCell(pt->GetDetectorID(), ten, isPS);
-    if (pt->GetEnergyLoss()<0)
-      cout << "Here" << pt->GetEnergyLoss() << endl;
-    if (ten!=0) continue;
-    if (isPS)
-      ; //     cell->AddPSEnergy(pt->GetEnergyLoss()); // No preshower
-    else
-      cell->AddEnergy(pt->GetEnergyLoss());
-
-    track=(CbmMCTrack*)fMCTracks->At(pt->GetTrackID());
-    if (track->GetPdgCode()!=fPDGType) continue;
-    if (isPS)
-      ;	//     cell->AddTrackPSEnergy(pt->GetTrackID(), pt->GetEnergyLoss()); // No preshower
-    else
-      cell->AddTrackEnergy(pt->GetTrackID(), pt->GetEnergyLoss());
-  } 
-}
-
-/** Initializes tree **/
-void CbmEcalUrqmdCalibrator::InitTree()
-{
-  if (fTree) return;
-  fTree=new TTree("ECALcal","Ecal Calibration tree");
-  fTree->Branch("ev",&fEvent,"ev/I");
-  fTree->Branch("steps",&fSteps,"steps/I");
-  fTree->Branch("type",&fType,"type/I");
-  fTree->Branch("dtype",&fDiffType,"dtype/I");
-  fTree->Branch("mcode",&fMotherCode,"mcode/I");
-  fTree->Branch("mcx",&fMCX,"mcx/F");
-  fTree->Branch("mcy",&fMCY,"mcy/F");
-  fTree->Branch("cellx",&fCellX,"cellx/F");
-  fTree->Branch("celly",&fCellY,"celly/F");
-  fTree->Branch("maxcellx",&fMaxCellX,"maxcellx/F");
-  fTree->Branch("maxcelly",&fMaxCellY,"maxcelly/F");
-  fTree->Branch("mce",&fMCE,"mce/F");
-  fTree->Branch("mcpx",&fMCPX,"mcpx/F");
-  fTree->Branch("mcpy",&fMCPY,"mcpy/F");
-  fTree->Branch("mcpz",&fMCPZ,"mcpz/F");
-  fTree->Branch("e",&fE,"e/F");
-  fTree->Branch("e2",&fE2x2,"e2/F");
-  fTree->Branch("e3",&fE3x3,"e3/F");
-  fTree->Branch("tracke2",&fTrackE2x2,"tracke2/F");
-  fTree->Branch("tracke3",&fTrackE3x3,"tracke3/F");
-  fTree->Branch("te",&fTotalTrackEnergy,"te/F");
-}
-
-/** Populates fList with particles **/
-void CbmEcalUrqmdCalibrator::FillList()
-{
-  CbmEcalPoint* pt;
-  CbmMCTrack* track;
-  TVector3 mom;
-  UInt_t n;
-
-  fList.clear();
-  
-  n=fEcalPoints->GetEntriesFast();
-  for(UInt_t i=0;i<n;i++)
-  {
-    pt=(CbmEcalPoint*)fEcalPoints->At(i);
-    track=(CbmMCTrack*)fMCTracks->At(pt->GetTrackID());
-    if (track->GetPdgCode()!=fPDGType)
-      continue;
-    track->GetMomentum(mom);
-    if (mom.Mag2()<fMinEnergy*fMinEnergy)
-      continue;
-    fList.push_back(pt);
-  }
-}
-
-
-/** Returns mass of particle with pdgcode **/
-Float_t GetMass(Int_t pdgcode)
-{
-    Double_t mass=-1;
-    TParticlePDG* fParticlePDG=TDatabasePDG::Instance()->GetParticle(pdgcode);
-
-    if (fParticlePDG)
-     mass=fParticlePDG->Mass();
-
-    return mass;
-}
-
-Int_t CalculateDiffType(CbmEcalCell* cell)
-{
-  Float_t dx=cell->GetX2()-cell->GetX1();
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-
-  cells.clear();
-  cell->GetNeighborsList(0, cells);
-  for(p=cells.begin(); p!=cells.end(); ++p)
-   if (TMath::Abs((*p)->GetX2()-(*p)->GetX1()-dx)>0.001)
-     return 1;
-
-  return 0;
-}
-
-/** Do everything for one ecal point**/
-void CbmEcalUrqmdCalibrator::ProcessHit(CbmEcalPoint* point)
-{
-  TVector3 mom;
-  TVector3 pos;
-  CbmMCTrack* track=(CbmMCTrack*)fMCTracks->At(point->GetTrackID());
-  CbmMCTrack* mother;
-  CbmEcalCell* cell;
-  CbmEcalCell* old_cell=NULL;
-  CbmEcalModule* module;
-
-
-  Float_t calo_x;
-  Float_t calo_y;
-
-//  static Float_t sPSDeltaZ=fInf->GetPSLead()+fInf->GetPSScin()/2.0;
-  static Float_t sDeltaZ=fInf->GetPSLead()+fInf->GetPSScin()+fInf->GetPSGap();
-
-  point->Momentum(mom);
-  point->Position(pos);
-
-  calo_x=pos.X()+pos.X()/pos.Z()*sDeltaZ;
-  calo_y=pos.Y()+pos.Y()/pos.Z()*sDeltaZ;
-/*
-  cout << pos.X() << " " << pos.Y() << endl;
-  pos=track->GetMomentum();
-  cout << pos.X() << " " << pos.Y() << " " << pos.Z() << endl;
-  point->Position(pos);
-*/
-
-  if (TMath::Abs(calo_x*2.0)>fInf->GetEcalSize(0))
-    return;
-  if (TMath::Abs(calo_y*2.0)>fInf->GetEcalSize(1))
-    return;
-
-  cell=fStr->GetCell(calo_x, calo_y);
-  if (cell==NULL)
-  {
-    cerr << "Can't find cell (" << calo_x << "," << calo_y;
-    cerr << ")!" << endl;
-    return;
-  }
-
-  if (track->GetMotherId()<0)
-    fMotherCode=0;
-  else
-  {
-    mother=(CbmMCTrack*)fMCTracks->At(track->GetMotherId());
-    fMotherCode=mother->GetPdgCode();
-  }
-  fSteps=0;
-  while(cell!=old_cell)
-  {
-    old_cell=cell;
-    cell=FindNextCell(cell);
-    fSteps++;
-  }
-
-  fMCX=pos.X();
-  fMCY=pos.Y();
-
-  fMCPX=mom.Px();
-  fMCPY=mom.Py();
-  fMCPZ=mom.Pz();
-//  mom=track->GetMomentum();
-  fMCE=GetMass(track->GetPdgCode());
-  fMCE=TMath::Sqrt(fMCE*fMCE+mom.Mag2());
-
-  fCellX=cell->GetCenterX();
-  fCellY=cell->GetCenterY();
-
-  module=fStr->GetModule(fCellX, fCellY);
-  fType=module->GetType();
-
-  fDiffType=CalculateDiffType(cell);
-
-  FillEnergies(cell, point->GetTrackID());
-  FillTotalEnergy(point->GetTrackID());
-
-  fTree->Fill();
-}
-
-/** Calculates ECAL response for track **/
-void CbmEcalUrqmdCalibrator::FillTotalEnergy(Int_t tracknum)
-{
-  static std::list<CbmEcalCell*> cells; 
-  if (cells.size()<100)
-  {
-    cells.clear();
-    fStr->GetCells(cells);
-  }
-  Float_t maxe=0;
-  Float_t e;
-  CbmEcalCell* cell=NULL;
-  std::list<CbmEcalCell*>::const_iterator p;
-
-  fTotalTrackEnergy=0;
-  for(p=cells.begin(); p!=cells.end();++p)
-  {
-    e=((CbmEcalCellMC*)(*p))->GetTrackEnergy(tracknum);
-    if (e>maxe)
-    {
-      cell=(*p);
-      maxe=e;
-    }
-    fTotalTrackEnergy+=e;
-  }
-  if (cell)
-  {
-    fMaxCellX=cell->GetCenterX();
-    fMaxCellY=cell->GetCenterY();
-  } 
-  else
-  {
-    fMaxCellX=0;
-    fMaxCellY=0;
-  }
-}
-
-/** Calculates ECAL response for cell **/
-void CbmEcalUrqmdCalibrator::FillEnergies(CbmEcalCell* cell, Int_t trackid)
-{
-  Float_t en;
-  Float_t tracken;
-  Float_t maxe;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-  CbmEcalCellMC* cellmc=(CbmEcalCellMC*)cell;
-
-  cells.clear();
-
-  cell->GetNeighborsList(0,cells);
-  fE=cell->GetEnergy();
-  en=cell->GetEnergy();
-  tracken=cellmc->GetTrackEnergy(trackid);;
-  for(p=cells.begin();p!=cells.end();++p) 
-  {
-    en+=(*p)->GetEnergy();
-    tracken+=((CbmEcalCellMC*)(*p))->GetTrackEnergy(trackid);
-  }
-  fE3x3=en;
-  fTrackE3x3=tracken;
-
-  maxe=0;
-  for(Int_t i=1;i<5;i++)
-  {
-    cell->GetNeighborsList(i,cells);
-    en=cell->GetEnergy();
-    for(p=cells.begin();p!=cells.end();++p) 
-      en+=(*p)->GetEnergy();
-    if (maxe<en)
-    {
-      maxe=en;
-      tracken=cellmc->GetTrackEnergy(trackid);
-      for(p=cells.begin();p!=cells.end();++p) 
-	tracken+=((CbmEcalCellMC*)(*p))->GetTrackEnergy(trackid);
-     
-    }
-  }
-  fE2x2=maxe;
-  fTrackE2x2=tracken;
-}
-
-/** Finds cell with more energy deposition than given **/
-CbmEcalCell* CbmEcalUrqmdCalibrator::FindNextCell(CbmEcalCell* cell)
-{
-  CbmEcalCell* ret=cell;
-  list<CbmEcalCell*> cells;
-  list<CbmEcalCell*>::const_iterator p;
-
-  cells.clear();
-
-  cell->GetNeighborsList(0,cells);
-  for(p=cells.begin();p!=cells.end();++p) 
-  {
-    if ((*p)->GetEnergy()>ret->GetEnergy())
-      ret=(*p);
-  }
-
-  return ret;
-}
-
-CbmEcalUrqmdCalibrator::CbmEcalUrqmdCalibrator()
-  : FairTask(),
-    fPDGType(22),
-    fMinEnergy(0.5),
-    fGeoFile(""),
-    fTree(NULL),
-    fEvent(0),
-    fSteps(0),
-    fMCX(0.),
-    fMCY(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fMCE(0.),
-    fMCPX(0.),
-    fMCPY(0.),
-    fMCPZ(0.),
-    fE(0.),
-    fE2x2(0.),
-    fE3x3(0.),
-    fTrackE2x2(0.),
-    fTrackE3x3(0.),
-    fTotalTrackEnergy(0.),
-    fMaxCellX(0.),
-    fMaxCellY(0.),
-    fMotherCode(0),
-    fType(0),
-    fStr(NULL),
-    fDiffType(0),
-    fInf(NULL),
-    fList(),
-    fLitePoints(NULL),
-    fEcalPoints(NULL),
-    fMCTracks(NULL)
-{
-}
-
-CbmEcalUrqmdCalibrator::CbmEcalUrqmdCalibrator(const char* name, const Int_t iVerbose, const char* fileGeo)
-  : FairTask(name, iVerbose), 
-    fPDGType(22),
-    fMinEnergy(0.5),
-    fGeoFile(fileGeo),
-    fTree(NULL),
-    fEvent(0),
-    fSteps(0),
-    fMCX(0.),
-    fMCY(0.),
-    fCellX(0.),
-    fCellY(0.),
-    fMCE(0.),
-    fMCPX(0.),
-    fMCPY(0.),
-    fMCPZ(0.),
-    fE(0.),
-    fE2x2(0.),
-    fE3x3(0.),
-    fTrackE2x2(0.),
-    fTrackE3x3(0.),
-    fTotalTrackEnergy(0.),
-    fMaxCellX(0.),
-    fMaxCellY(0.),
-    fMotherCode(0),
-    fType(0),
-    fStr(NULL),
-    fDiffType(0),
-    fInf(CbmEcalInf::GetInstance(fGeoFile)),
-  fList(),
-    fLitePoints(NULL),
-    fEcalPoints(NULL),
-    fMCTracks(NULL)
-
-{
-}
-
-/** Initing routine **/
-InitStatus CbmEcalUrqmdCalibrator::Init()
-{
-  FairRootManager* fManager=FairRootManager::Instance();
-
-  fLitePoints=(TClonesArray*)fManager->GetObject("EcalPointLite");
-  if (fLitePoints==NULL)
-  {
-    cerr << "There are no EcalPointLite branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fEcalPoints=(TClonesArray*)fManager->GetObject("EcalPoint");
-  if (fEcalPoints==NULL)
-  {
-    cerr << "There are no EcalPoint branch in the file!!!" << endl;
-    return kFATAL; 
-  }
-  fMCTracks=(TClonesArray*)fManager->GetObject("MCTrack");
-  if (fMCTracks==NULL)
-  {
-    cerr << "There are no MCTrack branch in the file!!!" << endl;
-    return kFATAL;
-  }
-
-  fTree=NULL;
-
-  fEvent=0;
-  fStr=new CbmEcalStructure(fInf);
-  fStr->Construct();
-
-  return kSUCCESS;
-}
-
-/** Parameter container init **/
-void CbmEcalUrqmdCalibrator::SetParContainers()
-{
-  FairRunAna* ana=FairRunAna::Instance();
-  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
-  rtdb->getContainer("CbmGeoEcalPar");
-
-}
-
-/** Finishing routine **/
-void CbmEcalUrqmdCalibrator::Finish()
-{
-  if (fTree)
-    fTree->Write();
-}
-
-ClassImp(CbmEcalUrqmdCalibrator)
diff --git a/ecal/CbmEcalUrqmdCalibrator.h b/ecal/CbmEcalUrqmdCalibrator.h
deleted file mode 100644
index 78681df7113532cc01800b3e4748251b2a564969..0000000000000000000000000000000000000000
--- a/ecal/CbmEcalUrqmdCalibrator.h
+++ /dev/null
@@ -1,189 +0,0 @@
-// For calibrate calorimeter response for UrQMD events
-// for photons, electrons, etc.
-// by Mikhail Prokudin
-
-/* $Id: CbmEcalUrqmdCalibrator.h,v 1.2 2006/08/25 19:17:48 prokudin Exp $ */
-
-/*
- * $Log: CbmEcalUrqmdCalibrator.h,v $
- * Revision 1.2  2006/08/25 19:17:48  prokudin
- * Energy in cell added. Minor bug fixed.
- *
- * Revision 1.1  2006/08/17 18:16:35  prokudin
- * first version of UrqmdCalibrator
- *
- */
-
-#ifndef CBMECALURQMDCALIBRATOR_H
-#define CBMECALURQMDCALIBRATOR_H
-
-#include "FairTask.h"
-
-#include "TString.h"
-
-#include <list>
-
-class CbmEcalInf;
-class CbmEcalStructure;
-class CbmEcalPoint;
-class CbmEcalCell;
-class TTree;
-class TClonesArray;
-
-
-class CbmEcalUrqmdCalibrator : public FairTask
-{
-public:
-  CbmEcalUrqmdCalibrator(const char* name, const Int_t iVerbose=0, const char* fileGeo="ecal_FullMC.geo");
-
-  //TString GetGeoFileName();
-
-  /** Setter and getter for type of particle to
-   ** calibrate **/
-  void SetPDGType(Int_t type=22);
-  Int_t GetPDGType() const;
-
-  /** Setter and getter for minimum energy cut **/
-  void SetMinEnergy(Float_t energy=0.5);
-  Float_t GetMinEnergy() const;
-
-private:
-  /** Fills ECAL structure **/
-  void FillStructure();
-
-  /** Initializes tree **/
-  void InitTree();
-
-  /** Populates fList with particles **/
-  void FillList();
-
-  /** Do everything for one ECAL point **/
-  void ProcessHit(CbmEcalPoint* point);
-
-  /** Calculates ECAL response for cell **/
-  void FillEnergies(CbmEcalCell* cell, Int_t trackid);
-
-  /** Calculates ECAL response for track **/
-  void FillTotalEnergy(Int_t tracknum);
-
-  /** Finds cell with more energy deposition than given **/
-  CbmEcalCell* FindNextCell(CbmEcalCell* cell);
-
-  /** Type of particle for calibration **/
-  Int_t fPDGType;
-
-  /** Minimum energy for particle to be considered **/
-  Float_t fMinEnergy;
-
-  /** Name of Geo file **/
-  TString fGeoFile;
-
-  /** Output tree named ECALcal **/
-  TTree* fTree;
-
-  /** Event number **/
-  Int_t fEvent;
-
-  /** Number of steps before maximum reached **/
-  Int_t fSteps;
-
-  /** MC coordinates of hit **/
-  Float_t fMCX;
-  Float_t fMCY;
-
-  /** Coordinates of cell center **/
-  Float_t fCellX;
-  Float_t fCellY;
-
-  /** Incoming particle momentum **/
-  Float_t fMCE;
-  Float_t fMCPX;
-  Float_t fMCPY;
-  Float_t fMCPZ;
-
-
-  Float_t fE;
-
-  /** Track energy depostion in 2x2 and 3x3 cells **/
-  Float_t fE2x2;
-  Float_t fE3x3;
-
-  Float_t fTrackE2x2;
-  Float_t fTrackE3x3;
-  /** Total energy deposited by track in calorimeter **/
-  Float_t fTotalTrackEnergy;
-  /** Coordinates of cell with maximum energy deposition for this track **/
-  Float_t fMaxCellX;
-  Float_t fMaxCellY;
-
-  /** PDG code of mother particle. 0 if none. **/
-  Int_t fMotherCode;
-
-  /** Type of cell with maximum energy deposition **/
-  Int_t fType;
-
-  /** Structure container **/
-  CbmEcalStructure* fStr;
-
-  /** 1 if 3x3 cluster contains cells
-   ** with different sizes**/
-  Int_t fDiffType;
-
-  /** Structure information **/
-  CbmEcalInf* fInf;
-
-  /** List of ECAL points to process **/
-  std::list<CbmEcalPoint*> fList; 
-public:
-  /** Default constructor **/
-  CbmEcalUrqmdCalibrator();
-
-  /** Initing routine **/
-  virtual InitStatus Init();
-
-  /** Loop procedure **/
-  virtual void Exec(Option_t* option);
-
-  /** Finishing routine **/
-  virtual void Finish();
-
-  /** Parameter container init **/
-  virtual void SetParContainers();
-
-  /** Destructor **/
-  virtual ~CbmEcalUrqmdCalibrator() {};
-private:
-  /** MCPoints in ECAL **/
-  TClonesArray* fLitePoints;
-  /** MCPoints in front of the ECAL **/
-  TClonesArray* fEcalPoints;
-  /** MCTracks array **/
-  TClonesArray* fMCTracks;
-
-  CbmEcalUrqmdCalibrator(const CbmEcalUrqmdCalibrator&);
-  CbmEcalUrqmdCalibrator& operator=(const CbmEcalUrqmdCalibrator&);
-
-  ClassDef(CbmEcalUrqmdCalibrator,1)
-};
-
-inline void CbmEcalUrqmdCalibrator::SetPDGType(Int_t type)
-{
-  fPDGType=type;
-}
-
-inline Int_t CbmEcalUrqmdCalibrator::GetPDGType() const
-{
-  return fPDGType;
-}
-
-inline void CbmEcalUrqmdCalibrator::SetMinEnergy(Float_t energy)
-{
-  fMinEnergy=energy;
-}
-
-inline Float_t CbmEcalUrqmdCalibrator::GetMinEnergy() const
-{
-  return fMinEnergy;
-}
-#endif 
-
diff --git a/ecal/CbmGeoEcalPar.cxx b/ecal/CbmGeoEcalPar.cxx
deleted file mode 100644
index d673eac9069bffd47e538a4eed169858c58a0d3a..0000000000000000000000000000000000000000
--- a/ecal/CbmGeoEcalPar.cxx
+++ /dev/null
@@ -1,118 +0,0 @@
-//*--Author: Denis Bertini
-//   modified 21/06/2005 
-
-#include "CbmGeoEcalPar.h"
-
-#include "FairParamList.h"
-
-#include "TObjArray.h"
-#include "TObjString.h"
-
-#include <iostream>
-#include <stdlib.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-
-ClassImp(CbmGeoEcalPar)
-
-/** key must be lower case. For example, if have in
- ** geo file AaaA=90, then you should call 
- ** GetVariableStrict("aaaa").
- ** If variable not found, will return -1111 **/
-Double_t CbmGeoEcalPar::GetVariable(const char* key)
-{
-  if (fVariables==NULL) return -1111;
-  TObjString* value=(TObjString*)fVariables->GetValue(key);
-  if (value==NULL)
-    return -1111;
-  Double_t val;
-  char* err=NULL;
-  val=strtod(value->GetString(),&err);
-  if (err[0]!='\0')
-    return -1111;
-  return val;
-}
-/** key must be lower case. For example, if have in
- ** geo file AaaA=90, then you should call 
- ** GetVariableStrict("aaaa").
- ** If variable not found, will generate Fatal **/
-Double_t CbmGeoEcalPar::GetVariableStrict(const char* key)
-{
-  TObjString* value=(TObjString*)fVariables->GetValue(key);
-  if (value==NULL)
-  {
-    cerr << "Can't find variable named \"" << key << "\"";
-    cerr << ". Exiting..." << endl;
-    Fatal("GetVariableStrict","Can't find variable.");
-  }
-  Double_t val;
-  char* err=NULL;
-  val=strtod(value->GetString(),&err);
-  if (err[0]!='\0')
-  {
-    cerr << "Can't convert variable named \"" << key ;
-    cerr << "\" to floating point. Value is \"";
-    cerr << value->GetString() << "\"." << endl;
-    cerr << "Exiting..." << endl;
-    Fatal("GetVariableStrict","Can't find variable.");
-  }
-  return val;
-}
-
-CbmGeoEcalPar::CbmGeoEcalPar(const char* name,const char* title,const char* context)
-  : FairParGenericSet(name,title,context), 
-    fEcalStr(NULL),
-    fVariables(NULL)
-{
-}
-
-CbmGeoEcalPar::~CbmGeoEcalPar(void) {
-}
-
-void CbmGeoEcalPar::dump()
-{
-  if (fVariables)
-  {
-    TObjString* key;
-    TIterator* iter=fVariables->MakeIterator();
-    while((key=(TObjString*)iter->Next())!=NULL)
-    {
-      TObjString* str=(TObjString*)fVariables->GetValue(key);
-      cout << key->String() << "=" << str->String() << endl;
-    }
-  }
-  if (fEcalStr)
-  {
-    TObjString* key;
-    TIterator* iter=fEcalStr->MakeIterator();
-    while((key=(TObjString*)iter->Next())!=NULL)
-    {
-      cout << key->String() << endl;
-    }
-  }
-
-}
-
-void CbmGeoEcalPar::clear(void)
-{
-  if (fEcalStr) delete fEcalStr;
-  if (fVariables) delete fVariables;
-}
-
-void CbmGeoEcalPar::putParams(FairParamList* l) {
-  if (!l) return;
-  if (fEcalStr)   l->addObject("ECAL Structure", fEcalStr);
-  if (fVariables) l->addObject("ECAL Variables", fVariables);
-}
-
-Bool_t CbmGeoEcalPar::getParams(FairParamList* l) {
-    if (!l) return kFALSE;
-    if (!l->fillObject("ECAL Structure", fEcalStr))
-      fEcalStr=NULL;
-    if (!l->fillObject("ECAL Variables", fVariables))
-      return kFALSE;
-
-  return kTRUE;
-}
diff --git a/ecal/CbmGeoEcalPar.h b/ecal/CbmGeoEcalPar.h
deleted file mode 100644
index 7db72146f5feec8731b03a74385b17d3d15a851e..0000000000000000000000000000000000000000
--- a/ecal/CbmGeoEcalPar.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* $Id: CbmGeoEcalPar.h,v 1.4 2006/07/30 13:10:35 prokudin Exp $ */
-
-/** CbmGeoEcalPar.h
- *@author Mikhail Prokudin
- **
- ** Parameter container with extended functionality
- **/
-
-/*
- * $Log: &
- */
-#ifndef CBMGEOECALPAR_H
-#define CBMGEOECALPAR_H
-
-#include "FairParGenericSet.h"
-
-#include "TMap.h" 
-
-class CbmGeoEcalPar : public FairParGenericSet {
-public:
-  virtual Bool_t Init() {return kTRUE;};
-  CbmGeoEcalPar(const char* name="CbmGeoEcalPar",
-             const char* title="Ecal Geometry Parameters",
-             const char* context="TestDefaultContext");
-  ~CbmGeoEcalPar(void);
-  void clear(void);
-  void putParams(FairParamList*);
-  void dump();
-  Bool_t getParams(FairParamList*);
-
-  TObjArray* GetEcalStr() const;
-  TMap* GetVariables() const;
-
-  void SetEcalStr(TObjArray* EcalStr);
-  void SetVariables(TMap* Variables);
-
-  /** key must be lower case. For example, if have in
-   ** geo file AaaA=90, then you should call 
-   ** GetVariableStrict("aaaa").
-   ** If variable not found, will return -1111 **/
-  Double_t GetVariable(const char* key);
-  /** key must be lower case. For example, if have in
-   ** geo file AaaA=90, then you should call 
-   ** GetVariableStrict("aaaa").
-   ** If variable not found, will generate Fatal **/
-  Double_t GetVariableStrict(const char* key);
-private:
-  /** Array of string, presents ECAL structure **/
-  TObjArray* fEcalStr;
-  /** Array of ECAL variables **/
-  TMap* fVariables;
-
-  CbmGeoEcalPar(const CbmGeoEcalPar&);
-  CbmGeoEcalPar& operator=(const CbmGeoEcalPar&);
-
-  ClassDef(CbmGeoEcalPar,1)
-};
-
-inline TObjArray* CbmGeoEcalPar::GetEcalStr() const
-{
-  return fEcalStr;
-}
-
-inline TMap* CbmGeoEcalPar::GetVariables() const
-{
-  return fVariables;
-}
-
-inline void CbmGeoEcalPar::SetEcalStr(TObjArray* EcalStr)
-{
-  fEcalStr=EcalStr;
-}
-
-inline void CbmGeoEcalPar::SetVariables(TMap* Variables)
-{
-  fVariables=Variables;
-}
-
-#endif /* !CBMGEOECALPAR_H */
diff --git a/reco/tracking/vector/CMakeLists.txt b/reco/tracking/vector/CMakeLists.txt
index 53eefcf73f915477e608e19a05da691c8332dd69..65835452ce7d0683c4051a6f51b36597d1949b62 100644
--- a/reco/tracking/vector/CMakeLists.txt
+++ b/reco/tracking/vector/CMakeLists.txt
@@ -22,7 +22,6 @@ ${CBMDATA_DIR}/rich
 ${CBMDATA_DIR}/sts 
 ${CBMDATA_DIR}/trd 
 ${CBMDATA_DIR}/tof 
-#${CBMDATA_DIR}/ecal 
 ${CBMDATA_DIR}/psd 
 
 # needed by CbmMuchFindVectors
diff --git a/sim/transport/geosetup/CMakeLists.txt b/sim/transport/geosetup/CMakeLists.txt
index 430ace22e9360785546f9b3cfcbfed999552baab..9075e5f0e3a4b3cd23de00863d4cd42eca81b862 100644
--- a/sim/transport/geosetup/CMakeLists.txt
+++ b/sim/transport/geosetup/CMakeLists.txt
@@ -62,8 +62,6 @@ ${CBMROOT_SOURCE_DIR}/rich/sim
 ${CBMROOT_SOURCE_DIR}/much/sim
 ${CBMROOT_SOURCE_DIR}/trd/sim
 ${CBMROOT_SOURCE_DIR}/tof/sim
-#${CBMDATA_DIR}/ecal
-#${CBMROOT_SOURCE_DIR}/ecal
 ${CBMROOT_SOURCE_DIR}/psd/sim
 ${CBMROOT_SOURCE_DIR}/sim/passive
 ${CBMROOT_SOURCE_DIR}/field