]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSClusterFinderSDD.cxx
Further fixes to the par file generation
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinderSDD.cxx
index 89fb081f1dcfc9009961471ffff7e1470b456ca7..17a5a17d94b69a4d6e4c1dcab32d2eb6a3a12cdc 100644 (file)
  **************************************************************************/
 /*
   $Id$
-  $Log$
-  Revision 1.37  2004/06/10 21:00:24  nilsen
-  Modifications associated with remerging the Ba/Sa and Dubna pixel simulations,
-  some cleaning of general code (including coding convensions), and adding some
-  protections associated with SetDefaults/SetDefaultSimulations which should help
-  with the Test beam simulations. Details below. The default SPD simulation for
-  the general ITS runs/geometry is still the Ba/Sa, but for the Test beam
-  geometries this has been changed to the merged versions.
-  File: AliITS.cxx                         Modified
-  File: AliITS.h                           Modified
-        In lined many one-two line functions. Added some protection to
-        SetDefaults(), SetDefaultSimulation(), and SetDefaultClusterFinders(),
-        such that they should now even work when only one detector type has
-        been defined (as it should be for the test beams...). Some mostly
-        cosmetic issues associated with getting branch names for digits. And
-        Generally some cleaning up of the code.
-  File: AliITSClusterFinder.cxx            Modified
-  File: AliITSClusterFinder.h              Modified
-        Did some additional consolidation of data into the base class, added
-        TClonesArray *fClusters, a fDebug, and fModule variables. Otherwise
-        some cosmetic and coding conversion changes.
-  File: AliITSClusterFinderSDD.cxx         Modified
-  File: AliITSClusterFinderSDD.h           Modified
-        Changes to be consistent with the modified base class, and cosmetic
-        and coding conversion changes.
-  File: AliITSClusterFinderSPD.cxx         Modified
-  File: AliITSClusterFinderSPD.h           Modified
-        Changes to be consistent with the modified base class, and cosmetic
-        and coding conversion changes.
-  File: AliITSClusterFinderSPDdubna.h       Removed
-  File: AliITSClusterFinderSPDdubna.cxx     Removed
-        Since we have ClusterFinderSPD and V2 and this version isn't being
-        maintained, it is being retired.
-  File: AliITSClusterFinderSSD.cxx         Modified
-  File: AliITSClusterFinderSSD.h           Modified
-        Changes to be consistent with the modified base class, and cosmetic
-        and coding conversion changes.
-  File: AliITSDetType.cxx                  Modified
-  File: AliITSDetType.h                    Modified
-        Added a new class variable to indicate what the detector type is
-        AliITSDetector fDetType;  values of kSPD, kSDD, kSSD, .... Otherwise
-        cosmetic and Coding convention changes.
-  File: AliITSLoader.cxx                   Modified
-  File: AliITSLoader.h                     Modified
-        Some changes which are not complete. The idea is to be able to get,
-        simply via one call, a specific hit, Sdigit, digit, RecPoint,...
-        without all of the usual over head of initializing TClonesArrays setting
-        branch addresses and the like. Work is far form ready.
-  File: AliITSdcsSSD.cxx                   Modified
-        Some nearly cosmetic changes necessary due to changes to response and
-        segmentation class'.
-  File: AliITSgeom.h                       Modified
-        In the definition of AliITSDetector type, added kND=-1, no detector
-        defined. Expect to use it later(?).
-  File: AliITSresponse.h                   Modified
-        Basically cosmetic. Mostly changing Float_t to Double_t.
-  File: AliITSresponseSDD.cxx              Modified
-  File: AliITSresponseSDD.h                Modified
-        Basically the cosmetic and Float_t to Double_t
-  File: AliITSresponseSPD.cxx              Modified
-  File: AliITSresponseSPD.h                Modified
-        Mostly Float_t to Double_t and added in the IsPixelDead function for
-        the dubna version (otherwise the merging had been done).
-  File: AliITSresponseSPDdubna.h           Removed
-  File: AliITSresponseSPDdubna.cxx         Removed
-        We should be able to remove this class now. AliITSresponseSPD is now
-        used for both the Bari-Salerno and the dubna models.
-  File: AliITSresponseSSD.cxx              Modified
-  File: AliITSresponseSSD.h                Modified
-        Float_t to Double_t changes.
-  File: AliITSsegmentation.h               Modified
-        Made LocaltoDet return a Bool_t. Now if the x,z location is outside
-        of the volume, it returns kFALSE. see below.
-  File: AliITSsegmentationSDD.cxx          Modified
-  File: AliITSsegmentationSDD.h            Modified
-        Made LocaltoDet return a Bool_t. Now if the x,z location is outside
-        of the volume, it returns kFALSE.
-  File: AliITSsegmentationSPD.cxx          Modified
-  File: AliITSsegmentationSPD.h            Modified
-        Made LocaltoDet return a Bool_t. Now if the x,z location is outside
-        of the volume, it returns kFALSE.
-  File: AliITSsegmentationSSD.cxx          Modified
-  File: AliITSsegmentationSSD.h            Modified
-        Made LocaltoDet return a Bool_t. Now if the x,z location is outside
-        of the volume, it returns kFALSE. see below.
-  File: AliITSsimulation.cxx               Modified
-  File: AliITSsimulation.h                 Modified
-        Added fDebug variable, new Constructor for use below. Cosmetic and
-        coding convention changes
-  File: AliITSsimulationSDD.cxx            Modified
-  File: AliITSsimulationSDD.h              Modified
-        Added new Constructor, removed redundant variables and Cosmetic and
-        coding convention changes.
-  File: AliITSsimulationSPD.cxx            Modified
-  File: AliITSsimulationSPD.h              Modified
-        Removed some dead code, made changes as needed by the changes above
-        (response and segmentation classes...). a few cosmetic and coding
-        convention changes.
-  File: AliITSsimulationSPDdubna.cxx       Modified
-  File: AliITSsimulationSPDdubna.h         Modified
-        New merged version, implemented new and old coupling with switch,
-        coding convention and similar changes. (found 1 bugs, missing
-        ! in front of if(mod-LineSegmentL(....,).
-  File: AliITSsimulationSSD.cxx            Modified
-  File: AliITSsimulationSSD.h              Modified
-        removed redundant variables with base class. Fixed for coding
-        convention and other cosmetic changes.
-  File: AliITSvSDD03.cxx                   Modified
-  File: AliITSvSPD02.cxx                   Modified
-  File: AliITSvSSD03.cxx                   Modified
-        These two have their private versions of SetDefaults and
-        SetDefaultSimulation which have been similarly protected as in AliITS.cxx
-  File: ITSLinkDef.h                       Modified
-  File: libITS.pkg                         Modified
-        Versions which include v11 geometry and other private changes
-
-  Revision 1.36  2004/01/27 16:12:03  masera
-  Coding conventions for AliITSdigitXXX classes and AliITSTrackerV1
-
-  Revision 1.35  2003/11/10 16:33:50  masera
-  Changes to obey our coding conventions
-
-  Revision 1.34  2003/09/11 13:48:52  masera
-  Data members of AliITSdigit classes defined as protected (They were public)
-
-  Revision 1.33  2003/07/21 14:20:51  masera
-  Fix to track labes in SDD Rec-points
-
-  Revision 1.31.2.1  2003/07/16 13:18:04  masera
-  Proper fix to track labels associated to SDD rec-points
-
-  Revision 1.31  2003/05/19 14:44:41  masera
-  Fix to track labels associated to SDD rec-points
-
-  Revision 1.30  2003/03/03 16:34:35  masera
-  Corrections to comply with coding conventions
-
-  Revision 1.29  2002/10/25 18:54:22  barbera
-  Various improvements and updates from B.S.Nilsen and T. Virgili
-
-  Revision 1.28  2002/10/22 14:45:29  alibrary
-  Introducing Riostream.h
-
-  Revision 1.27  2002/10/14 14:57:00  hristov
-  Merging the VirtualMC branch to the main development branch (HEAD)
-
-  Revision 1.23.4.2  2002/10/14 13:14:07  hristov
-  Updating VirtualMC to v3-09-02
-
-  Revision 1.26  2002/09/09 17:23:28  nilsen
-  Minor changes in support of changes to AliITSdigitS?D class'.
-
-  Revision 1.25  2002/05/10 22:29:40  nilsen
-  Change my Massimo Masera in the default constructor to bring things into
-  compliance.
-
-  Revision 1.24  2002/04/24 22:02:31  nilsen
-  New SDigits and Digits routines, and related changes,  (including new
-  noise values).
-
  */
 /////////////////////////////////////////////////////////////////////////// 
 //  Cluster finder                                                       //
 //  for Silicon                                                          //
 //  Drift Detector                                                       //
 ////////////////////////////////////////////////////////////////////////// 
-#include <Riostream.h>
 
-#include <TMath.h>
-#include <math.h>
 
 #include "AliITSClusterFinderSDD.h"
 #include "AliITSMapA1.h"
-#include "AliITS.h"
-#include "AliITSdigitSDD.h"
 #include "AliITSRawClusterSDD.h"
 #include "AliITSRecPoint.h"
+#include "AliITSdigitSDD.h"
+#include "AliITSDetTypeRec.h"
+#include "AliITSCalibrationSDD.h"
 #include "AliITSsegmentationSDD.h"
-#include "AliITSresponseSDD.h"
-#include "AliRun.h"
+#include "AliITSgeom.h"
+#include "AliLog.h"
 
 ClassImp(AliITSClusterFinderSDD)
 
@@ -212,11 +50,10 @@ fMaxNCells(0){
     // default constructor
 }
 //______________________________________________________________________
-AliITSClusterFinderSDD::AliITSClusterFinderSDD(AliITSsegmentation *seg,
-                                               AliITSresponse *response,
+AliITSClusterFinderSDD::AliITSClusterFinderSDD(AliITSDetTypeRec* dettyp,
                                                TClonesArray *digits,
                                                TClonesArray *recp):
-AliITSClusterFinder(seg,response),
+AliITSClusterFinder(dettyp),
 fNclusters(0),
 fDAnode(0.0),
 fDTime(0.0),
@@ -230,12 +67,10 @@ fMaxNCells(0){
 
     SetDigits(digits);
     SetClusters(recp);
-    SetCutAmplitude();
+    SetCutAmplitude(fDetTypeRec->GetITSgeom()->GetStartSDD());
     SetDAnode();
     SetDTime();
-    SetMinPeak((Int_t)(((AliITSresponseSDD*)GetResp())->
-                       GetNoiseAfterElectronics()*5));
-    //    SetMinPeak();
+    SetMinPeak((Int_t)((AliITSCalibrationSDD*)GetResp(fDetTypeRec->GetITSgeom()->GetStartSDD()))->GetNoiseAfterElectronics(0)*5);
     SetMinNCells();
     SetMaxNCells();
     SetTimeCorr();
@@ -243,13 +78,24 @@ fMaxNCells(0){
     SetMap(new AliITSMapA1(GetSeg(),Digits(),fCutAmplitude));
 }
 //______________________________________________________________________
-void AliITSClusterFinderSDD::SetCutAmplitude(Double_t nsigma){
+void AliITSClusterFinderSDD::SetCutAmplitude(Int_t mod,Double_t nsigma){
     // set the signal threshold for cluster finder
-    Double_t baseline,noise,noiseAfterEl;
+    Double_t baseline,noiseAfterEl;
 
-    GetResp()->GetNoiseParam(noise,baseline);
-    noiseAfterEl = ((AliITSresponseSDD*)GetResp())->GetNoiseAfterElectronics();
-    fCutAmplitude = (Int_t)((baseline + nsigma*noiseAfterEl));
+    AliITSresponseSDD* res  = (AliITSresponseSDD*)((AliITSCalibrationSDD*)GetResp(mod))->GetResponse();
+    const char *option=res->ZeroSuppOption();
+    Int_t nanodes = GetResp(mod)->Wings()*GetResp(mod)->Channels()*GetResp(mod)->Chips();
+    fCutAmplitude.Set(nanodes);
+    for(Int_t ian=0;ian<nanodes;ian++){
+      noiseAfterEl = ((AliITSCalibrationSDD*)GetResp(mod))->GetNoiseAfterElectronics(ian);
+      if(strstr(option,"ZS")){ 
+       fCutAmplitude[ian] = (Int_t)(nsigma*noiseAfterEl);
+      }
+      else{
+       baseline=GetResp(mod)->GetBaseline(ian);
+       fCutAmplitude[ian] = (Int_t)((baseline + nsigma*noiseAfterEl));
+      } 
+    }
 }
 //______________________________________________________________________
 void AliITSClusterFinderSDD::Find1DClusters(){
@@ -262,17 +108,14 @@ void AliITSClusterFinderSDD::Find1DClusters(){
     Int_t dummy          = 0;
     Double_t fTimeStep    = GetSeg()->Dpx(dummy);
     Double_t fSddLength   = GetSeg()->Dx();
-    Double_t fDriftSpeed  = GetResp()->DriftSpeed();  
-    Double_t anodePitch   = GetSeg()->Dpz(dummy);
+    AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
+    AliITSresponseSDD* res  = (AliITSresponseSDD*)((AliITSCalibrationSDD*)GetResp(fModule))->GetResponse();
+    const char *option=res->ZeroSuppOption();
 
     // map the signal
     Map()->ClearMap();
-    Map()->SetThreshold(fCutAmplitude);
-    Map()->FillMap();
-  
-    Double_t noise;
-    Double_t baseline;
-    GetResp()->GetNoiseParam(noise,baseline);
+    Map()->SetThresholdArr(fCutAmplitude);
+    Map()->FillMap2();
   
     Int_t nofFoundClusters = 0;
     Int_t i;
@@ -295,7 +138,7 @@ void AliITSClusterFinderSDD::Find1DClusters(){
         } // anodes
 
         for(k=0;k<fNofAnodes;k++) {
-            if(GetDebug(5)) cout<<"Anode: "<<k+1<<", Wing: "<<j+1<< endl;
+            AliDebug(5,Form("Anode: %d, Wing: %d",k+1,j+1));
             idx = j*fNofAnodes+k;
             Int_t imax  = 0;
             Int_t imaxd = 0;
@@ -315,7 +158,7 @@ void AliITSClusterFinderSDD::Find1DClusters(){
                     if(id>=fMaxNofSamples) break;
                     fadc=(float)Map()->GetSignal(idx,id);
                     if(fadc > fadcmax) { fadcmax = fadc; imax = id;}
-                    if(fadc > (float)fCutAmplitude)lthrt++; 
+                    if(fadc > (float)fCutAmplitude[idx])lthrt++; 
                     if(dfadc[k][id] > dfadcmax) {
                         dfadcmax = dfadc[k][id];
                         imaxd    = id;
@@ -337,7 +180,7 @@ void AliITSClusterFinderSDD::Find1DClusters(){
                         if(tstart+ij > 255) { tstop = 255; break; }
                         fadc=(float)Map()->GetSignal(idx,tstart+ij);
                         if((dfadc[k][tstart+ij] < dfadcmin) && 
-                           (fadc > fCutAmplitude)) {
+                           (fadc > fCutAmplitude[idx])) {
                             tstop = tstart+ij+5;
                             if(tstop > 255) tstop = 255;
                             dfadcmin = dfadc[k][it+ij];
@@ -350,12 +193,14 @@ void AliITSClusterFinderSDD::Find1DClusters(){
                     Int_t   clusterMult   = 0;
                     Double_t clusterPeakAmplitude = 0.;
                     Int_t its,peakpos     = -1;
-                    Double_t n, baseline;
-                    GetResp()->GetNoiseParam(n,baseline);
-                    for(its=tstart; its<=tstop; its++) {
+                                  
+                   for(its=tstart; its<=tstop; its++) {
                         fadc=(float)Map()->GetSignal(idx,its);
-                        if(fadc>baseline) fadc -= baseline;
-                        else fadc = 0.;
+                       if(!(strstr(option,"ZS"))){
+                         Double_t baseline=GetResp(fModule)->GetBaseline(idx);
+                         if(fadc>baseline) fadc -= baseline;
+                         else fadc = 0.;
+                       }
                         clusterCharge += fadc;
                         // as a matter of fact we should take the peak
                         // pos before FFT
@@ -377,10 +222,9 @@ void AliITSClusterFinderSDD::Find1DClusters(){
                             //ns
                         } // end if
                     } // end for its
-
-                    Double_t clusteranodePath = (clusterAnode - fNofAnodes/2)*
-                                                 anodePitch;
-                    Double_t clusterDriftPath = clusterTime*fDriftSpeed;
+                   Float_t theAnode=clusterAnode+j*fNofAnodes;
+                    Double_t clusteranodePath = GetSeg()->GetLocalZFromAnode(theAnode);
+                   Double_t clusterDriftPath = (Double_t)cal->GetDriftPath(clusterTime,clusteranodePath);
                     clusterDriftPath = fSddLength-clusterDriftPath;
                     if(clusterCharge <= 0.) break;
                     AliITSRawClusterSDD clust(j+1,//i
@@ -392,7 +236,7 @@ void AliITSClusterFinderSDD::Find1DClusters(){
                                               clusteranodePath, //f
                                               clusterMult, //i
                                               0,0,0,0,0,0,0);//7*i
-                    fITS->AddCluster(1,&clust);
+                   fDetTypeRec->AddCluster(1,&clust);
                     it = tstop;
                 } // ilcl
                 it++;
@@ -415,20 +259,19 @@ void AliITSClusterFinderSDD::Find1DClustersE(){
     Int_t dummy=0;
     Double_t fTimeStep = GetSeg()->Dpx( dummy );
     Double_t fSddLength = GetSeg()->Dx();
-    Double_t fDriftSpeed = GetResp()->DriftSpeed();
-    Double_t anodePitch = GetSeg()->Dpz( dummy );
-    Double_t n, baseline;
-    GetResp()->GetNoiseParam( n, baseline );
-    // map the signal
+    AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
     Map()->ClearMap();
-    Map()->SetThreshold( fCutAmplitude );
-    Map()->FillMap();
-    
+    Map()->SetThresholdArr( fCutAmplitude );
+    Map()->FillMap2();
+
+    AliITSresponseSDD* res  = (AliITSresponseSDD*)cal->GetResponse();
+    const char *option=res->ZeroSuppOption();
+
     Int_t nClu = 0;
     //        cout << "Search  cluster... "<< endl;
     for( Int_t j=0; j<2; j++ ){
         for( Int_t k=0; k<fNofAnodes; k++ ){
-            Int_t idx = j*fNofAnodes+k;
+            Int_t idx = j*fNofAnodes+k;            
             Bool_t on = kFALSE;
             Int_t start = 0;
             Int_t nTsteps = 0;
@@ -454,8 +297,11 @@ void AliITSClusterFinderSDD::Find1DClustersE(){
                         nTsteps = 0;
                     } // end if on...
                     nTsteps++ ;
-                    if( fadc > baseline ) fadc -= baseline;
-                    else fadc=0.;
+                   if(!(strstr(option,"ZS"))){
+                     Double_t baseline=GetResp(fModule)->GetBaseline(idx);
+                     if( fadc > baseline ) fadc -= baseline;
+                     else fadc=0.;
+                   }
                     charge += fadc;
                     time += fadc*l;
                     if( fadc > fmax ){ 
@@ -477,16 +323,17 @@ void AliITSClusterFinderSDD::Find1DClustersE(){
                             time /= (charge/fTimeStep);   // ns
                                 // time = lmax*fTimeStep;   // ns
                             if( time > fTimeCorr ) time -= fTimeCorr;   // ns
-                            Double_t anodePath =(anode-fNofAnodes/2)*anodePitch;
-                            Double_t driftPath = time*fDriftSpeed;
+                           Float_t theAnode=anode+j*fNofAnodes;
+                            Double_t anodePath =GetSeg()->GetLocalZFromAnode(theAnode);
+                           Double_t driftPath = (Double_t)cal->GetDriftPath(time,anode);
                             driftPath = fSddLength-driftPath;
                             AliITSRawClusterSDD clust(j+1,anode,time,charge,
                                                       fmax, peakpos,0.,0.,
                                                       driftPath,anodePath,
                                                       nTsteps,start,stop,
                                                       start, stop, 1, k, k );
-                            fITS->AddCluster( 1, &clust );
-                            if(GetDebug(5)) clust.PrintInfo();
+                           fDetTypeRec->AddCluster( 1, &clust );
+                            if(AliDebugLevel()>=5) clust.PrintInfo();
                             nClu++;
                         } // end if nTsteps
                         on = kFALSE;
@@ -495,7 +342,7 @@ void AliITSClusterFinderSDD::Find1DClustersE(){
             } // samples
         } // anodes
     } // wings
-    if(GetDebug(3)) cout << "# Rawclusters " << nClu << endl;         
+    AliDebug(3,Form("# Rawclusters %d",nClu));         
     return; 
 }
 //_______________________________________________________________________
@@ -579,7 +426,7 @@ void AliITSClusterFinderSDD::PeakFunc( Int_t xdim, Int_t zdim, Double_t *par,
     //                 par[i+2] = zpos
     //                 par[i+3] = tau
     //                 par[i+4] = sigma.
-    Int_t electronics = GetResp()->Electronics(); // 1 = PASCAL, 2 = OLA
+    Int_t electronics = GetResp(fModule)->GetElectronics(); // 1 = PASCAL, 2 = OLA
     const Int_t knParam = 5;
     Int_t npeak = (Int_t)par[0];
 
@@ -646,8 +493,8 @@ void AliITSClusterFinderSDD::Minim( Int_t xdim, Int_t zdim, Double_t *param,
         delta = steprm[k];
         d1 = delta;
         // ENSURE THAT STEP SIZE IS SENSIBLY LARGER THAN MACHINE ROUND OFF
-        if( fabs( p1 ) > 1.0E-6 ) 
-            if ( fabs( delta/p1 ) < 1.0E-4 ) delta = p1/1000;
+        if( TMath::Abs( p1 ) > 1.0E-6 ) 
+            if ( TMath::Abs( delta/p1 ) < 1.0E-4 ) delta = p1/1000;
             else  delta = (Double_t)1.0E-4;
         //  EVALUATE CHI-SQUARED AT FIRST TWO SEARCH POINTS
         PeakFunc( xdim, zdim, param, speFit );
@@ -684,10 +531,10 @@ void AliITSClusterFinderSDD::Minim( Int_t xdim, Int_t zdim, Double_t *param,
                 if( param[k] <= 20 ) param[k] = fMinPeak;
                 break;
             case 1 :
-                if( fabs( param[k] - prm0[k] ) > 1.5 ) param[k] = prm0[k];
+                if( TMath::Abs( param[k] - prm0[k] ) > 1.5 ) param[k] = prm0[k];
                 break;
             case 2 :
-                if( fabs( param[k] - prm0[k] ) > 1. ) param[k] = prm0[k];
+                if( TMath::Abs( param[k] - prm0[k] ) > 1. ) param[k] = prm0[k];
                 break;
             case 3 :
                 if( param[k] < .5 ) param[k] = .5;        
@@ -714,8 +561,8 @@ void AliITSClusterFinderSDD::Minim( Int_t xdim, Int_t zdim, Double_t *param,
         //--IN CASE OF NEARLY EQUAL CHI-SQUARED AND TOO SMALL STEP SIZE PREVENT
         //   ERRONEOUS EVALUATION OF PARABOLA MINIMUM
         //---NEXT TWO LINES CAN BE OMITTED FOR HIGHER PRECISION MACHINES
-        //dp = (Double_t) max (fabs(p3-p2), fabs(p2-p1));
-        //if( fabs( p2-p0 ) > dp ) p0 = p2;
+        //dp = (Double_t) max (TMath::Abs(p3-p2), TMath::Abs(p2-p1));
+        //if( TMath::Abs( p2-p0 ) > dp ) p0 = p2;
         param[k] = p0;
         // Constrain paramiters
         Int_t kpos = (k-1) % knParam;
@@ -724,10 +571,10 @@ void AliITSClusterFinderSDD::Minim( Int_t xdim, Int_t zdim, Double_t *param,
             if( param[k] <= 20 ) param[k] = fMinPeak;   
             break;
         case 1 :
-            if( fabs( param[k] - prm0[k] ) > 1.5 ) param[k] = prm0[k];
+            if( TMath::Abs( param[k] - prm0[k] ) > 1.5 ) param[k] = prm0[k];
             break;
         case 2 :
-            if( fabs( param[k] - prm0[k] ) > 1. ) param[k] = prm0[k];
+            if( TMath::Abs( param[k] - prm0[k] ) > 1. ) param[k] = prm0[k];
             break;
         case 3 :
             if( param[k] < .5 ) param[k] = .5;        
@@ -790,7 +637,7 @@ Int_t AliITSClusterFinderSDD::NoLinearFit( Int_t xdim, Int_t zdim,
         iterNum++;
             chi0 = chi1;
             Minim( xdim, zdim, param, prm0, step, &chi1, spe, speFit );
-            reldif = ( chi1 > 0 ) ? ((Double_t) fabs( chi1-chi0)/chi1 ) : 0;
+            reldif = ( chi1 > 0 ) ? ((Double_t) TMath::Abs( chi1-chi0)/chi1 ) : 0;
         // EXIT conditions
         if( reldif < (float) kchilmt ){
             *chir  = (chi1>0) ? (float) TMath::Sqrt (chi1/degFree) :0;
@@ -830,7 +677,7 @@ Int_t AliITSClusterFinderSDD::NoLinearFit( Int_t xdim, Int_t zdim,
             if ((double)a < 1.0E-6) prmin = 0;
             else prmin = (float) (0.5*b/a);
             dp = 5*(tmp2-tmp0);
-            if( fabs(prmin-tmp2) > fabs(dp) ) prmin = tmp2+dp;
+            if( TMath::Abs(prmin-tmp2) > TMath::Abs(dp) ) prmin = tmp2+dp;
             param[k] = prmin;
             step[k]  = dp/10; // OPTIMIZE SEARCH STEP
         } // end for k
@@ -858,11 +705,12 @@ void AliITSClusterFinderSDD::ResolveClusters(){
     Int_t dummy=0;
     Double_t fTimeStep = GetSeg()->Dpx( dummy );
     Double_t fSddLength = GetSeg()->Dx();
-    Double_t fDriftSpeed = GetResp()->DriftSpeed();
     Double_t anodePitch = GetSeg()->Dpz( dummy );
-    Double_t n, baseline;
-    GetResp()->GetNoiseParam( n, baseline );
-    Int_t electronics = GetResp()->Electronics(); // 1 = PASCAL, 2 = OLA
+    Int_t electronics =GetResp(fModule)->GetElectronics(); // 1 = PASCAL, 2 = OLA
+    AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
+    AliITSresponseSDD* res  = (AliITSresponseSDD*)cal->GetResponse();
+    const char *option=res->ZeroSuppOption();
+    
 
     for( Int_t j=0; j<nofClusters; j++ ){ 
         // get cluster information
@@ -888,9 +736,12 @@ void AliITSClusterFinderSDD::ResolveClusters(){
         // make a local map from cluster region
         for( Int_t ianode=astart; ianode<=astop; ianode++ ){
             for( Int_t itime=tstart; itime<=tstop; itime++ ){
-                Double_t fadc = Map()->GetSignal( ianode, itime );
-                if( fadc > baseline ) fadc -= (Double_t)baseline;
-                else fadc = 0.;
+                Double_t fadc = Map()->GetSignal( ianode, itime );            
+               if(!(strstr(option,"ZS"))){
+                 Double_t baseline=GetResp(fModule)->GetBaseline(ianode);
+                 if( fadc > baseline ) fadc -= (Double_t)baseline;
+                 else fadc = 0.;
+               }
                 Int_t index = (itime-tstart+1)*zdim+(ianode-astart+1);
                 sp[index] = fadc;
             } // time loop
@@ -980,21 +831,28 @@ void AliITSClusterFinderSDD::ResolveClusters(){
                 if( peakpos < 0 ) { 
                     //Warning("ResolveClusters",
                     //        "Digit not found for cluster");
-                    //if(GetDebug(3)) clusterI.PrintInfo(); 
+                    //if(AliDebugLevel()>=3) clusterI.PrintInfo(); 
                    continue;
                 }
-                clusterI.SetPeakPos( peakpos );    
-                Double_t driftPath = fSddLength - newiTimef * fDriftSpeed;
-                Double_t sign = ( wing == 1 ) ? -1. : 1.;
-                clusterI.SetX( driftPath*sign * 0.0001 );        
-                clusterI.SetZ( anodePath * 0.0001 );
+                clusterI.SetPeakPos( peakpos ); 
+               Float_t dp = cal->GetDriftPath(newiTimef,newAnodef);
+               Float_t driftPath = fSddLength - (Double_t)dp;
+                Float_t sign = ( wing == 1 ) ? -1. : 1.;
+               Float_t xcoord = driftPath*sign * 0.0001;
+               Float_t zcoord = anodePath * 0.0001;
+               Float_t corrx=0, corrz=0;
+               cal->GetCorrections(zcoord,xcoord,corrz,corrx,GetSeg());
+               xcoord+=corrx;
+               zcoord+=corrz;
+                clusterI.SetX( xcoord );        
+                clusterI.SetZ( zcoord );
                 clusterI.SetAnode( newAnodef );
                 clusterI.SetTime( newiTimef );
                 clusterI.SetAsigma( sigma[i]*anodePitch );
                 clusterI.SetTsigma( tau[i]*fTimeStep );
                 clusterI.SetQ( integral[i] );
                 
-                fITS->AddCluster( 1, &clusterI );
+               fDetTypeRec->AddCluster( 1, &clusterI );
             } // end for i
             Clusters()->RemoveAt( j );
             delete [] par;
@@ -1035,10 +893,10 @@ void  AliITSClusterFinderSDD::GroupClusters(){
             if(clusterI->T() < fTimeStep*10) fDAnode = 1.5;  // TB 1.
             Bool_t pair = clusterI->Brother(clusterJ,fDAnode,fDTime);
             if(!pair) continue;
-            if(GetDebug(4)){
+            if(AliDebugLevel()>=4){
                 clusterI->PrintInfo();
                 clusterJ->PrintInfo();
-            } // end if GetDebug
+            } // end if AliDebugLevel
             clusterI->Add(clusterJ);
             label[j] = 1;
             Clusters()->RemoveAt(j);
@@ -1078,7 +936,7 @@ void AliITSClusterFinderSDD::SelectClusters(){
 }
 
 //______________________________________________________________________
-void AliITSClusterFinderSDD::GetRecPoints(){
+void AliITSClusterFinderSDD::GetRecPoints(AliITSCalibrationSDD* cal){
     // get rec points
   
     // get number of clusters for this module
@@ -1086,12 +944,21 @@ void AliITSClusterFinderSDD::GetRecPoints(){
     nofClusters -= fNclusters;
     const Double_t kconvGeV = 1.e-6; // GeV -> KeV
     const Double_t kconv = 1.0e-4; 
+    const Double_t kcmToMicrons = 10000.;
     const Double_t kRMSx = 38.0*kconv; // microns->cm ITS TDR Table 1.3
     const Double_t kRMSz = 28.0*kconv; // microns->cm ITS TDR Table 1.3
+    Int_t nAnodes=GetSeg()->NpzHalf();
     Int_t i;
     Int_t ix, iz, idx=-1;
     AliITSdigitSDD *dig=0;
     Int_t ndigits=NDigits();
+
+    Int_t lay,lad,det;
+    fDetTypeRec->GetITSgeom()->GetModuleId(fModule,lay,lad,det);
+    Int_t ind=(lad-1)*fDetTypeRec->GetITSgeom()->GetNdetectors(lay)+(det-1);
+    Int_t lyr=(lay-1);
+
+
     for(i=0; i<nofClusters; i++) { 
         AliITSRawClusterSDD *clusterI = (AliITSRawClusterSDD*)Cluster(i);
         if(!clusterI) Error("SDD: GetRecPoints","i clusterI ",i,clusterI);
@@ -1101,26 +968,34 @@ void AliITSClusterFinderSDD::GetRecPoints(){
         if(idx&&idx<= ndigits) dig =(AliITSdigitSDD*)GetDigit(idx);
         if(!dig) {
             // try cog
-            GetSeg()->GetPadIxz(clusterI->X(),clusterI->Z(),ix,iz);
+           Float_t xMicrons=clusterI->X()*kcmToMicrons;
+           Float_t zMicrons=clusterI->Z()*kcmToMicrons;
+           Float_t zAnode=zMicrons/GetSeg()->Dpz(0)+nAnodes/2;
+           Float_t driftSpeed=cal->GetDriftSpeedAtAnode(zAnode);           
+           Float_t driftPath=GetSeg()->Dx()-TMath::Abs(xMicrons);
+           ix=1+(Int_t)(driftPath/driftSpeed/GetSeg()->Dpx(0));
+           iz=1+(Int_t)zAnode;
+           if(xMicrons>0) iz+=nAnodes;
             dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix-1);
             // if null try neighbours
             if (!dig) dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix); 
             if (!dig) dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix+1); 
             if (!dig) printf("SDD: cannot assign the track number!\n");
         } //  end if !dig
-        AliITSRecPoint rnew;
-        rnew.SetX(clusterI->X());
-        rnew.SetZ(clusterI->Z());
-        rnew.SetQ(clusterI->Q());   // in KeV - should be ADC
-        rnew.SetdEdX(kconvGeV*clusterI->Q());
-        rnew.SetSigmaX2(kRMSx*kRMSx);
-        rnew.SetSigmaZ2(kRMSz*kRMSz);
 
-        if(dig) rnew.fTracks[0]=dig->GetTrack(0);
-        if(dig) rnew.fTracks[1]=dig->GetTrack(1);
-        if(dig) rnew.fTracks[2]=dig->GetTrack(2);
+       Int_t lab[4] = {-3141593,-3141593,-3141593,ind};
+       if (dig) {
+         lab[0] = dig->GetTrack(0);
+         lab[1] = dig->GetTrack(1);
+         lab[2] = dig->GetTrack(2);
+       }
+       Float_t hit[5] = {clusterI->X(),clusterI->Z(),kRMSx*kRMSx,kRMSz*kRMSz,clusterI->Q()};
+       Int_t info[3] = {0,0,lyr};
 
-        fITS->AddRecPoint(rnew);
+        AliITSRecPoint rnew(lab,hit,info,kTRUE);
+        rnew.SetdEdX(kconvGeV*clusterI->Q());
+
+       fDetTypeRec->AddRecPoint(rnew);        
     } // I clusters
 //    Map()->ClearMap();
 }
@@ -1129,14 +1004,22 @@ void AliITSClusterFinderSDD::FindRawClusters(Int_t mod){
     // find raw clusters
     
     SetModule(mod);
+    SetCutAmplitude(mod);
+    AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(mod);
+    Int_t nanodes=GetSeg()->Npz();
+    Int_t noise=0;
+    for(Int_t i=0;i<nanodes;i++){
+      noise+=(Int_t)cal->GetNoiseAfterElectronics(i);
+    }    
+    SetMinPeak((noise/nanodes)*5);
     Find1DClustersE();
     GroupClusters();
     SelectClusters();
     ResolveClusters();
-    GetRecPoints();
+    GetRecPoints(cal);
 }
 //_______________________________________________________________________
-void AliITSClusterFinderSDD::Print() const{
+void AliITSClusterFinderSDD::PrintStatus() const{
     // Print SDD cluster finder Parameters
 
     cout << "**************************************************" << endl;
@@ -1146,10 +1029,12 @@ void AliITSClusterFinderSDD::Print() const{
     cout << "Anode Tolerance: " << fDAnode << endl;
     cout << "Time  Tolerance: " << fDTime << endl;
     cout << "Time  correction (electronics): " << fTimeCorr << endl;
-    cout << "Cut Amplitude (threshold): " << fCutAmplitude << endl;
+    cout << "Cut Amplitude (threshold): " << fCutAmplitude[0] << endl;
     cout << "Minimum Amplitude: " << fMinPeak << endl;
     cout << "Minimum Charge: " << fMinCharge << endl;
     cout << "Minimum number of cells/clusters: " << fMinNCells << endl;
     cout << "Maximum number of cells/clusters: " << fMaxNCells << endl;
     cout << "**************************************************" << endl;
 }
+
+