]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSClusterFinderSSD.cxx
Mother volume ITSV corrected
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinderSSD.cxx
index 12c0d23e4a3d765a317acccd833ef22a20f1e28c..8c9cedbb1d289c27427b5795c555f2e8ba8478b5 100644 (file)
 Adding rekonstruction facilities
 Piotr Krzysztof Skowronski 
 December 1999.
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
 */
 
 /*
@@ -27,9 +32,22 @@ Automatic combination routines improved (traps)
 
 */
 
+#include <iostream.h>
+
+
 #include "AliRun.h"
+#include "AliITS.h"
+#include "AliITSdigit.h"
+#include "AliITSRawCluster.h"
+#include "AliITSRecPoint.h"
+#include "AliITSMapA1.h"
 #include "AliITSClusterFinderSSD.h"
+#include "AliITSclusterSSD.h"
+#include "AliITSpackageSSD.h"
+#include "AliITSsegmentation.h"
+
+const Bool_t AliITSClusterFinderSSD::fgkSIDEP=kTRUE;
+const Bool_t AliITSClusterFinderSSD::fgkSIDEN=kFALSE;
 
 const Int_t debug=0;
 
@@ -44,11 +62,14 @@ ClassImp(AliITSClusterFinderSSD)
 
 AliITSClusterFinderSSD::AliITSClusterFinderSSD(AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp)   
 {
+//Standard constructor
 
     fSegmentation=seg;
     fDigits=digits;
     fRecPoints=recp;
     
+    fMap = new AliITSMapA1(fSegmentation,fDigits);  
+  
     fITS=(AliITS*)gAlice->GetModule("ITS");
     
     fClusterP =  new TClonesArray ("AliITSclusterSSD",200);    
@@ -78,36 +99,43 @@ AliITSClusterFinderSSD::AliITSClusterFinderSSD(AliITSsegmentation *seg, TClonesA
     fTanP=TMath::Tan(StereoP);
     fTanN=TMath::Tan(StereoN);
 
+    fPNsignalRatio=7./8.;         // warning: hard-wired number
+
 }
 
 //-------------------------------------------------------
 AliITSClusterFinderSSD::~AliITSClusterFinderSSD() {
-   
+// Default destructor   
+
     delete fClusterP;
     delete fClusterN;        
     delete fPackages;        
     delete fDigitsIndexP;        
     delete fDigitsIndexN; 
+    
+    delete fMap;
+
 }
 
 //-------------------------------------------------------
 void AliITSClusterFinderSSD::InitReconstruction()
 {
+// initialization of the cluster finder
 
   register Int_t i; //iterator
 
-  for(i=0;i<fNClusterP;i++)
+  for (i=0;i<fNClusterP;i++)
     {
       fClusterP->RemoveAt(i);
     }
   fNClusterP  =0;
-  for(i=0;i<fNClusterN;i++)
+  for (i=0;i<fNClusterN;i++)
     {
       fClusterN->RemoveAt(i);
     }
   fNClusterN=0;
 
-  for(i=0;i<fNPackages;i++)
+  for (i=0;i<fNPackages;i++)
     {
       fPackages->RemoveAt(i);
     }
@@ -128,13 +156,6 @@ void AliITSClusterFinderSSD::InitReconstruction()
 //---------------------------------------------
 void AliITSClusterFinderSSD::FindRawClusters() 
 {
-
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
 // This function findes out all clusters belonging to one module
 // 1. Zeroes all space after previous module reconstruction
 // 2. Finds all neighbouring digits
@@ -144,6 +165,7 @@ void AliITSClusterFinderSSD::FindRawClusters()
 // 5. Creates clusters 
 
   InitReconstruction();  //ad. 1
+  fMap->FillMap();
   FillDigitsIndex();
   SortDigits();
   FindNeighbouringDigits(); //ad. 2
@@ -152,23 +174,20 @@ void AliITSClusterFinderSSD::FindRawClusters()
   ConsumeClusters();
   PackagesToPoints();   //ad. 5
   ReconstructNotConsumedClusters();
+  
+  fMap->ClearMap();
 }
 
 
 //-------------------------------------------------
 void AliITSClusterFinderSSD::FindNeighbouringDigits()
 {
+//If there are any digits on this side, create 1st Cluster,
+// add to it this digit, and increment number of clusters
 
 
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
  register Int_t i;
 
-    //If there are any digits on this side, create 1st Cluster,
-    // add to it this digit, and increment number of clusters
 
  if ((fNDigitsP>0 )  && (fNDigitsN > 0 )) {     
 
@@ -185,7 +204,7 @@ void AliITSClusterFinderSSD::FindNeighbouringDigits()
    dnumber = 1;
    dbuffer[0]=lDigitsIndexP[0];
    //If next digit is a neighbour of previous, adds to last cluster this digit
-   for(i=1; i<fNDigitsP; i++) {
+   for (i=1; i<fNDigitsP; i++) {
      //reads new digit
      currentstripNo = ((AliITSdigitSSD*)lDigits[lDigitsIndexP[i]])->
                                                             GetStripNumber(); 
@@ -194,12 +213,12 @@ void AliITSClusterFinderSSD::FindNeighbouringDigits()
            ==  (currentstripNo-1) ) dbuffer[dnumber++]=lDigitsIndexP[i];
      else  { 
        //create a new one side cluster
-       new(lClusterP[fNClusterP++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,SIDEP); 
+       new(lClusterP[fNClusterP++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,fgkSIDEP); 
        dbuffer[0]=lDigitsIndexP[i];
        dnumber = 1;
      }
    } // end loop over fNDigitsP
-   new(lClusterP[fNClusterP++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,SIDEP);
+   new(lClusterP[fNClusterP++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,fgkSIDEP);
 
 
    //process N side 
@@ -207,18 +226,18 @@ void AliITSClusterFinderSSD::FindNeighbouringDigits()
    dnumber = 1;
    dbuffer[0]=lDigitsIndexN[0];
    //If next digit is a neighbour of previous, adds to last cluster this digit
-   for(i=1; i<fNDigitsN; i++) { 
+   for (i=1; i<fNDigitsN; i++) { 
      currentstripNo = ((AliITSdigitSSD*)(lDigits[lDigitsIndexN[i]]))->
                                                             GetStripNumber();
      if ( (((AliITSdigitSSD*)lDigits[lDigitsIndexN[i-1]])->GetStripNumber()) 
            == (currentstripNo-1) ) dbuffer[dnumber++]=lDigitsIndexN[i];
      else {
-       new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,SIDEN);
+       new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,fgkSIDEN);
        dbuffer[0]=lDigitsIndexN[i];
        dnumber = 1;
      }
    } // end loop over fNDigitsN
-   new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,SIDEN);
+   new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,fgkSIDEN);
    delete [] dbuffer; 
  
  } // end condition on  NDigits 
@@ -231,12 +250,9 @@ void AliITSClusterFinderSSD::FindNeighbouringDigits()
 
 void AliITSClusterFinderSSD::SeparateOverlappedClusters()
 {
-//************************************************
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
+// overlapped clusters separation
 
-  register Int_t i,j; //iterator
+  register Int_t i; //iterator
 
   Float_t  factor=0.75;            // How many percent must be lower signal 
                                    // on the middle one digit
@@ -253,12 +269,12 @@ void AliITSClusterFinderSSD::SeparateOverlappedClusters()
 
   splitlist = new TArrayI(300);
 
-  for(i=0;i<initPsize;i++)
+  for (i=0;i<initPsize;i++)
   {
     if (( ((AliITSclusterSSD*)(*fClusterP)[i])->GetNumOfDigits())==1) continue;
     if (( ((AliITSclusterSSD*)(*fClusterP)[i])->GetNumOfDigits())==2) continue;
         Int_t nj=(((AliITSclusterSSD*)(*fClusterP)[i])->GetNumOfDigits()-1);
-        for(j=1; j<nj; j++)
+        for (Int_t j=1; j<nj; j++)
           {
             signal1=((AliITSclusterSSD*)(*fClusterP)[i])->GetDigitSignal(j);
             signal0=((AliITSclusterSSD*)(*fClusterP)[i])->GetDigitSignal(j-1);
@@ -270,17 +286,17 @@ void AliITSClusterFinderSSD::SeparateOverlappedClusters()
             }
          } // end loop over number of digits
           //split this cluster if necessary
-          if(numerofsplits>0) SplitCluster(splitlist,numerofsplits,i,SIDEP); 
-         numerofsplits=0;
+          if(numerofsplits>0) SplitCluster(splitlist,numerofsplits,i,fgkSIDEP);
+         numerofsplits=0;
 
          //in signed places (splitlist)
   } // end loop over clusters on Pside
 
-  for(i=0;i<initNsize;i++) {
+  for (i=0;i<initNsize;i++) {
     if (( ((AliITSclusterSSD*)(*fClusterN)[i])->GetNumOfDigits())==1) continue;
     if (( ((AliITSclusterSSD*)(*fClusterN)[i])->GetNumOfDigits())==2) continue;
        Int_t nj=(((AliITSclusterSSD*)(*fClusterN)[i])->GetNumOfDigits()-1);
-       for(j=1; j<nj; j++)
+       for (Int_t j=1; j<nj; j++)
           {
             signal1=((AliITSclusterSSD*)(*fClusterN)[i])->GetDigitSignal(j);
             signal0=((AliITSclusterSSD*)(*fClusterN)[i])->GetDigitSignal(j-1);
@@ -290,7 +306,7 @@ void AliITSClusterFinderSSD::SeparateOverlappedClusters()
                (*splitlist)[numerofsplits++]=j;  
           } // end loop over number of digits 
           //split this cluster into more clusters
-          if(numerofsplits>0) SplitCluster(splitlist,numerofsplits,i,SIDEN);
+          if(numerofsplits>0) SplitCluster(splitlist,numerofsplits,i,fgkSIDEN);
          numerofsplits=0;                                                              //in signed places (splitlist)
   } // end loop over clusters on Nside
 
@@ -300,12 +316,6 @@ void AliITSClusterFinderSSD::SeparateOverlappedClusters()
 //-------------------------------------------------------
 void AliITSClusterFinderSSD::SplitCluster(TArrayI *list, Int_t nsplits, Int_t index, Bool_t side)
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
   //This function splits one side cluster into more clusters
   //number of splits is defined by "nsplits"
   //Place of splits are defined in the TArray "list" 
@@ -325,7 +335,7 @@ void AliITSClusterFinderSSD::SplitCluster(TArrayI *list, Int_t nsplits, Int_t in
   // side true means P side
   if (side) {
      curentcluster =((AliITSclusterSSD*)((*fClusterP)[index])) ;
-     for(i = nsplits; i>0 ;i--) {  
+     for (i = nsplits; i>0 ;i--) {  
          NN=curentcluster->SplitCluster((*list)[(i-1)],tmpdigits);
          new ((*fClusterP)[fNClusterP]) AliITSclusterSSD(NN,tmpdigits,fDigits,side);
         ( (AliITSclusterSSD*)((*fClusterP)[fNClusterP]) )->
@@ -340,7 +350,7 @@ void AliITSClusterFinderSSD::SplitCluster(TArrayI *list, Int_t nsplits, Int_t in
      } // end loop over nplits
   } else {
      curentcluster =((AliITSclusterSSD*)((*fClusterN)[index]));
-     for(i = nsplits; i>0 ;i--) {  
+     for (i = nsplits; i>0 ;i--) {  
          NN=curentcluster->SplitCluster((*list)[(i-1)],tmpdigits);
         new ((*fClusterN)[fNClusterN]) AliITSclusterSSD(NN,tmpdigits,fDigits,side);
         ((AliITSclusterSSD*)((*fClusterN)[fNClusterN]))->
@@ -360,11 +370,8 @@ void AliITSClusterFinderSSD::SplitCluster(TArrayI *list, Int_t nsplits, Int_t in
 //-------------------------------------------------
 Int_t AliITSClusterFinderSSD::SortDigitsP(Int_t start, Int_t end)
 {
+// sort digits on the P side
 
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
   
   Int_t right;
   Int_t left;
@@ -394,11 +401,7 @@ Int_t AliITSClusterFinderSSD::SortDigitsP(Int_t start, Int_t end)
 
 Int_t AliITSClusterFinderSSD::SortDigitsN(Int_t start, Int_t end)
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
+// sort digits on the N side
 
   Int_t right;
   Int_t left;
@@ -426,14 +429,7 @@ Int_t AliITSClusterFinderSSD::SortDigitsN(Int_t start, Int_t end)
 //------------------------------------------------
 void AliITSClusterFinderSSD::FillDigitsIndex()
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
  //Fill the indexes of the clusters belonging to a given ITS module
- //Created by Piotr K. Skowronski, August 7 1999
 
  Int_t PNs=0, NNs=0;
  Int_t tmp,bit,k;
@@ -449,14 +445,14 @@ void AliITSClusterFinderSSD::FillDigitsIndex()
  
  AliITSdigitSSD *dig; 
  
- for(i = 0 ; i< N; i++ ) {
+ for ( i = 0 ; i< N; i++ ) {
       dig=(AliITSdigitSSD*)fDigits->UncheckedAt(i);
       if(dig->IsSideP()) { 
            bit=1;
            tmp=dig->GetStripNumber();
           // I find this totally unnecessary - it's just a 
           // CPU consuming double check
-           for(k=0;k<PNs;k++)
+           for( k=0;k<PNs;k++)
             {
              if (tmp==PSidx[k])
               {
@@ -473,7 +469,7 @@ void AliITSClusterFinderSSD::FillDigitsIndex()
          bit=1;
          tmp=dig->GetStripNumber();
         // same as above
-         for(k=0;k<NNs;k++)
+         for( k=0;k<NNs;k++)
           {
            if (tmp==NSidx[k])
             {
@@ -489,6 +485,8 @@ void AliITSClusterFinderSSD::FillDigitsIndex()
       }
  }
    
+ delete [] PSidx;
+ delete [] NSidx;
 
  if (debug) cout<<"Digits :  P = "<<fNDigitsP<<"   N = "<<fNDigitsN<<endl;
 
@@ -499,21 +497,15 @@ void AliITSClusterFinderSSD::FillDigitsIndex()
 
 void AliITSClusterFinderSSD::SortDigits()
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
-
+// sort digits
 
   Int_t i;
   if(fNDigitsP>1) 
-  for(i=0;i<fNDigitsP-1;i++)
+  for (i=0;i<fNDigitsP-1;i++)
   if (SortDigitsP(0,(fNDigitsP-1-i))==0) break;
 
   if(fNDigitsN>1) 
-    for(i=0;i<fNDigitsN-1;i++)
+    for (i=0;i<fNDigitsN-1;i++)
   if(SortDigitsN(0,(fNDigitsN-1-i))==0) break;
 }
 
@@ -522,19 +514,14 @@ void AliITSClusterFinderSSD::SortDigits()
 //----------------------------------------------
 void AliITSClusterFinderSSD::FillClIndexArrays(Int_t* arrayP, Int_t *arrayN)
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
+// fill cluster index array
 
   register Int_t i;
-  for(i=0; i<fNClusterP;i++)
+  for (i=0; i<fNClusterP;i++)
     {
       arrayP[i]=i;
     }
-  for(i=0; i<fNClusterN;i++)
+  for (i=0; i<fNClusterN;i++)
     {
       arrayN[i]=i;
     }
@@ -544,21 +531,16 @@ void AliITSClusterFinderSSD::FillClIndexArrays(Int_t* arrayP, Int_t *arrayN)
 //------------------------------------------------------
 void AliITSClusterFinderSSD::SortClusters(Int_t* arrayP, Int_t *arrayN)
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
+// sort clusters
 
   Int_t i;
   if(fNClusterP>1) 
-    for(i=0;i<fNClusterP-1;i++)
+    for (i=0;i<fNClusterP-1;i++)
       if (SortClustersP(0,(fNClusterP-1),arrayP)==0)  break;
     
     
   if(fNClusterN>1) 
-    for(i=0;i<fNClusterN-1;i++)
+    for (i=0;i<fNClusterN-1;i++)
       if (SortClustersN(0,(fNClusterN-1),arrayN)==0)  break;
 
 }
@@ -568,12 +550,7 @@ void AliITSClusterFinderSSD::SortClusters(Int_t* arrayP, Int_t *arrayN)
 //---------------------------------------------------
 Int_t AliITSClusterFinderSSD::SortClustersP(Int_t start, Int_t end, Int_t *array)
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
+//Sort P side clusters
 
 
   Int_t right;
@@ -603,12 +580,9 @@ Int_t AliITSClusterFinderSSD::SortClustersP(Int_t start, Int_t end, Int_t *array
 //-------------------------------------------------------
 Int_t AliITSClusterFinderSSD::SortClustersN(Int_t start, Int_t end, Int_t *array)
 {
+//Sort N side clusters
 
 
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
   Int_t right;
   Int_t left;
   
@@ -636,13 +610,7 @@ Int_t AliITSClusterFinderSSD::SortClustersN(Int_t start, Int_t end, Int_t *array
 //-------------------------------------------------------
 void AliITSClusterFinderSSD::ClustersToPackages()
 {  
-
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-  
+// fill packages   
     
   Int_t *oneSclP = new Int_t[fNClusterP]; //I want to have sorted 1 S clusters
   Int_t *oneSclN = new Int_t[fNClusterN]; //I can not sort it in TClonesArray
@@ -652,7 +620,7 @@ void AliITSClusterFinderSSD::ClustersToPackages()
                                           // MB: well, that's not true that one
                                           //cannot sort objects in TClonesArray
   
-  Int_t i,k;    //iterator
+  register Int_t i;    //iterator
   AliITSpackageSSD *currentpkg;
   AliITSclusterSSD *currentP;
   AliITSclusterSSD *currentN;
@@ -678,7 +646,8 @@ void AliITSClusterFinderSSD::ClustersToPackages()
   currentpkg = (AliITSpackageSSD*)((*fPackages)[0]);
   
   //main loop on sorted P side clusters 
-  for(i=0;i<fNClusterP;i++) {  
+  Int_t k;
+  for (i=0;i<fNClusterP;i++) {  
       //Take new P side cluster
       currentP = GetPSideCluster(oneSclP[i]);
       currentN = GetNSideCluster(oneSclN[lastNclIndex]);
@@ -706,7 +675,7 @@ void AliITSClusterFinderSSD::ClustersToPackages()
          }
           tmplastNclIndex=lastNclIndex;  
          //Check if next N side clusters crosses with it too
-          for(k=1;k<fSFF+1;k++) {
+          for (Int_t k=1;k<fSFF+1;k++) {
              //check if we are not out of array 
               if ((tmplastNclIndex+k)<fNClusterN) {
                   fcurrN = GetNSideCluster( oneSclN[tmplastNclIndex+k] );
@@ -759,7 +728,7 @@ void AliITSClusterFinderSSD::ClustersToPackages()
                     currentpkg->AddPSideCluster(oneSclP[i]);          
                     //Check, if next N side clusters crosses with it too
                     tmplastNclIndex=lastNclIndex;
-                    for(k=1;k<fSFF+1;k++) {
+                    for (Int_t k=1;k<fSFF+1;k++) {
                       //Check if we are not out of array
                       if ((tmplastNclIndex+k)<fNClusterN) {
                          fcurrN = GetNSideCluster(oneSclN[tmplastNclIndex+k]);
@@ -803,6 +772,7 @@ void AliITSClusterFinderSSD::ClustersToPackages()
 //-----------------------------------------------
 void AliITSClusterFinderSSD::PackagesToPoints()
 {
+// find recpoints from packages
  
  register Int_t i;
  AliITSpackageSSD *currentpkg;
@@ -811,7 +781,7 @@ void AliITSClusterFinderSSD::PackagesToPoints()
  Int_t clusterIndex;
  Bool_t clusterSide;
 
- for(i=0;i<fNPackages;i++) {
+ for (i=0;i<fNPackages;i++) {
     //get pointer to next package
     currentpkg = (AliITSpackageSSD*)((*fPackages)[i]); 
     NumNcl = currentpkg->GetNumOfClustersN();
@@ -880,8 +850,24 @@ void AliITSClusterFinderSSD::PackagesToPoints()
 void AliITSClusterFinderSSD::
 ResolveClusterWithOneCross(AliITSpackageSSD *currentpkg, Int_t clusterIndex, Bool_t clSide)
 {
+// resolve clusters with one cross
+/*
+
+ie:
+    \    /  
+     \  /   
+      \/ 
+      /\ 
+     /  \
+    /    \  
+   /      \
+  /        \
+ /          \
+*/
+
+
 
-   if (clSide == SIDEP) ResolvePClusterWithOneCross(currentpkg,clusterIndex);
+   if (clSide == fgkSIDEP) ResolvePClusterWithOneCross(currentpkg,clusterIndex);
    else  ResolveNClusterWithOneCross(currentpkg,clusterIndex);
 
 }
@@ -891,7 +877,7 @@ ResolveClusterWithOneCross(AliITSpackageSSD *currentpkg, Int_t clusterIndex, Boo
 void AliITSClusterFinderSSD::
 ResolvePClusterWithOneCross(AliITSpackageSSD *pkg, Int_t clusterIndex)
 {
-
+// resolve clusters with one cross on P side
 /*
 There is cluster (side P) which crosses with only one cluster on the other 
 side (N)
@@ -944,23 +930,23 @@ ie:
   ns = clusterN->GetTotalSignal();
   posClusterN = GetClusterZ(clusterN);
   posErrorClusterN = clusterN->GetPositionError();
-  pkg->DelCluster(clusterIndex,SIDEP);
-  sigClusterN = ps/PNsignalRatio;
+  pkg->DelCluster(clusterIndex,fgkSIDEP);
+  sigClusterN = ps/fPNsignalRatio;
   // there is no sonse to check how signal ratio is far from perfect 
   // matching line if the if below it is true
   if (ns < sigClusterN) {
       sigClusterN=ns;
-      if (debug) cout<<"n1 < p1/PNsignalRatio";
+      if (debug) cout<<"n1 < p1/fPNsignalRatio";
       if (debug) cout<<"Attempting to del cluster N "<<clusterIdx<<" ... \n";
-      pkg->DelClusterOI(clusterIdx,SIDEN);
+      pkg->DelClusterOI(clusterIdx,fgkSIDEN);
   } else {
       //Let's see how signal ratio is far from perfect matching line
       Chicomb = DistToPML(ps,ns);
       if (debug) cout<<"Chic "<<Chicomb<<"\n";
-      if (Chicomb > falpha2) {
+      if (Chicomb > fAlpha2) {
          //it is near, so we can risk throwing this cluster away too
         if (debug) cout<<"Attempting to del cluster N "<<clusterIdx<<"...\n"; 
-         pkg->DelClusterOI(clusterIdx,SIDEN);
+         pkg->DelClusterOI(clusterIdx,fgkSIDEN);
       } else {
          clusterN->CutTotalSignal(sigClusterN);
         if (debug) cout <<"Signal cut  |||||||||||||\n";
@@ -978,6 +964,8 @@ ie:
 void AliITSClusterFinderSSD::
 ResolveNClusterWithOneCross(AliITSpackageSSD *pkg, Int_t clusterIndex)
 {
+// resolve clusters with one cross on N side
+
 
   AliITSclusterSSD * clusterP;
   AliITSclusterSSD * clusterN;
@@ -1013,23 +1001,23 @@ ResolveNClusterWithOneCross(AliITSpackageSSD *pkg, Int_t clusterIndex)
   ps = clusterP->GetTotalSignal();
   posClusterP = GetClusterZ(clusterP);
   posErrorClusterP = clusterP->GetPositionError();
-  pkg->DelCluster(clusterIndex,SIDEN);
-  sigClusterP=ns*PNsignalRatio;
+  pkg->DelCluster(clusterIndex,fgkSIDEN);
+  sigClusterP=ns*fPNsignalRatio;
   // there is no sonse to check how signal ratio is far from perfect 
   // matching line if the if below it is true
   if (ps < sigClusterP) {
       sigClusterP = ps;
-      if (debug) cout<<"ps < ns*PNsignalRatio";
+      if (debug) cout<<"ps < ns*fPNsignalRatio";
       if (debug) cout<<"Attempting to del cluster P "<<clusterIdx<<" ... \n";
-      pkg->DelClusterOI(clusterIdx,SIDEP);
+      pkg->DelClusterOI(clusterIdx,fgkSIDEP);
   } else {
       //Let's see how signal ratio is far from perfect matching line
        Chicomb = DistToPML(ps,ns);
        if (debug) cout<<"Chic "<<Chicomb<<"\n";
-       if (Chicomb > falpha2) {
+       if (Chicomb > fAlpha2) {
           //it is near, so we can risk frowing this cluster away too
           if (debug) cout<<"Attempting to del cluster P "<<clusterIdx<<"...\n";
-         pkg->DelClusterOI(clusterIdx,SIDEP);
+         pkg->DelClusterOI(clusterIdx,fgkSIDEP);
        } else {
           clusterN->CutTotalSignal(sigClusterP);
          if (debug) cout <<"Signal cut  ------------\n";
@@ -1050,6 +1038,8 @@ ResolveNClusterWithOneCross(AliITSpackageSSD *pkg, Int_t clusterIndex)
 Bool_t AliITSClusterFinderSSD::
 ResolvePackageBestCombin(AliITSpackageSSD *pkg)
 {
+//find best combination
+
   if (debug) cout<<"NumNcl==NumPcl ("<<pkg->GetNumOfClustersN()
       <<"=="<<pkg->GetNumOfClustersP()<<"); Generating combinations ... \n";
 
@@ -1060,9 +1050,9 @@ ResolvePackageBestCombin(AliITSpackageSSD *pkg)
   Int_t Ncombin; //Number of combinations
   Int_t itera;   //iterator
   Int_t sizet=1;   //size of array to allocate 
+
   Int_t NP = pkg->GetNumOfClustersP();
-  for(itera =2; itera <= NP ;itera ++) {
+  for (itera =2; itera <= NP ;itera ++) {
      sizet=sizet*itera;
      if (sizet > 10000) {
        sizet=10000;
@@ -1070,9 +1060,9 @@ ResolvePackageBestCombin(AliITSpackageSSD *pkg)
      }
   }
 
-  Int_t **combin = new Int_t*[sizet]; //2D array to keep combinations in
+  Int_t** combin = new Int_t*[sizet]; //2D array to keep combinations in
 
-  for(itera =0; itera <sizet;itera++) {
+  for (itera =0; itera <sizet;itera++) {
    combin[itera] = new Int_t[NP+1];
   }
      
@@ -1086,7 +1076,7 @@ ResolvePackageBestCombin(AliITSpackageSSD *pkg)
   Int_t bc = GetBestComb(combin,Ncombin,NP,pkg); 
   if (debug) cout<<"  bc "<<bc <<"\n";
               
-  for(itera =0; itera < NP; itera ++) {
+  for (itera =0; itera < NP; itera ++) {
       clusterP = pkg->GetPSideCluster(itera);
       //carefully here
       //becase AliITSclusterSSD::GetCross returns index in 
@@ -1095,7 +1085,7 @@ ResolvePackageBestCombin(AliITSpackageSSD *pkg)
       CreateNewRecPoint(clusterP, clusterN, 0.75);
   } 
 
-  for(itera =0; itera <sizet;itera++) {
+  for (itera =0; itera <sizet;itera++) {
      delete [](combin[itera]);
   }
   delete [] combin;  
@@ -1108,6 +1098,7 @@ ResolvePackageBestCombin(AliITSpackageSSD *pkg)
 void AliITSClusterFinderSSD::
 ResolveOneBestMatchingPoint(AliITSpackageSSD *pkg)
 {
+// find best matching point
 
  Int_t ni, pi;
 
@@ -1140,9 +1131,9 @@ ResolveOneBestMatchingPoint(AliITSpackageSSD *pkg)
               }          
  
  
- pkg->DelClusterOI(pi, SIDEP);
- pkg->DelClusterOI(ni, SIDEN);
+ pkg->DelClusterOI(pi, fgkSIDEP);
+ pkg->DelClusterOI(ni, fgkSIDEN);
+
  if (split) {
    if (debug) cout<<"spltting package ...\n";
    new ((*fPackages)[fNPackages]) AliITSpackageSSD(fClusterP,fClusterN);
@@ -1156,6 +1147,7 @@ ResolveOneBestMatchingPoint(AliITSpackageSSD *pkg)
 //--------------------------------------------------
 void  AliITSClusterFinderSSD::ResolveSimplePackage(AliITSpackageSSD *pkg)
 {
+// resolve simple package
 
   AliITSclusterSSD * clusterP;
   AliITSclusterSSD * clusterN;
@@ -1172,7 +1164,7 @@ void  AliITSClusterFinderSSD::ResolveSimplePackage(AliITSpackageSSD *pkg)
 
 //--------------------------------------------------
 void AliITSClusterFinderSSD:: ResolvePackageWithOnePSideCluster(AliITSpackageSSD *pkg) {
-
+// resolve P side clusters from packages
 
 /*
  \   \   \  /
@@ -1222,12 +1214,12 @@ void AliITSClusterFinderSSD:: ResolvePackageWithOnePSideCluster(AliITSpackageSSD
  XPerr = clusterP->GetPositionError();
  p1err = clusterP->GetTotalSignalError();
    
- for(k=0;k<NN;k++) {
+ for (k=0;k<NN;k++) {
     SN[k]    = pkg->GetNSideCluster(k)->GetTotalSignal();
     SNerr[k] = pkg->GetNSideCluster(k)->GetTotalSignalError();
     sumsig   += SN[k];
  }
- for(k=0;k<NN;k++) {
+ for (k=0;k<NN;k++) {
     clusterN = pkg->GetNSideCluster(k);
     SP[k]= p1*SN[k]/sumsig;
     SPerr[k] = p1err*SN[k]/sumsig;
@@ -1237,12 +1229,20 @@ void AliITSClusterFinderSSD:: ResolvePackageWithOnePSideCluster(AliITSpackageSSD
 
  }
 
+ delete [] XN;
+ delete [] XNerr;
+ delete [] SP;
+ delete [] SN;
+ delete [] SPerr;
+ delete [] SNerr;
+
+
 }
 
 
 //---------------------------------------------------------
 void AliITSClusterFinderSSD::ResolvePackageWithOneNSideCluster(AliITSpackageSSD *pkg) {
-
+// resolve N side clusters from packages
 
 /*
     \    /   /   /
@@ -1287,13 +1287,13 @@ void AliITSClusterFinderSSD::ResolvePackageWithOneNSideCluster(AliITSpackageSSD
  
  n1err=clusterN->GetTotalSignalError();
    
- for(k=0;k<NP;k++) {
+ for (k=0;k<NP;k++) {
     SP[k] = pkg->GetPSideCluster(k)->GetTotalSignal();
     sumsig += SP[k];
     SPerr[k] = pkg->GetPSideCluster(k)->GetTotalSignalError();
  }
 
- for(k=0;k<NP;k++) {
+ for (k=0;k<NP;k++) {
     clusterP = pkg->GetPSideCluster(k);
     SN[k]= n1*SP[k]/sumsig;
     XP[k]=GetClusterZ(clusterP);
@@ -1302,6 +1302,12 @@ void AliITSClusterFinderSSD::ResolvePackageWithOneNSideCluster(AliITSpackageSSD
     CreateNewRecPoint(XP[k],XPerr[k], XN,XNerr, SP[k]+SN[k], SPerr[k]+SNerr[k],clusterP, clusterN, 1.0);
   }
   
+ delete [] XP;
+ delete [] XPerr;
+ delete [] SP;
+ delete [] SN;
+ delete [] SPerr;
+ delete [] SNerr;
                
 }
 
@@ -1312,6 +1318,7 @@ void AliITSClusterFinderSSD::ResolvePackageWithOneNSideCluster(AliITSpackageSSD
 void AliITSClusterFinderSSD::
 ResolveTwoForTwoPackage(AliITSpackageSSD *pkg)
 {
+// resolve 2x2 packages
 
   AliITSclusterSSD *clusterP1 = pkg->GetPSideCluster(0);
   AliITSclusterSSD *clusterP2 = pkg->GetPSideCluster(1);
@@ -1404,7 +1411,7 @@ ResolveTwoForTwoPackage(AliITSpackageSSD *pkg)
      /*Keep only better combinantion              */
      /*********************************************/
            
-     if (D12 > (falpha3*17.8768)) {
+     if (D12 > (fAlpha3*17.8768)) {
        if (debug) cout<<"decided to take only one pair \n";
        Chicomb1 = DistToPML(p1sig,n1sig) + DistToPML(p2sig,n2sig);
        Chicomb2 = DistToPML(p2sig,n1sig) + DistToPML(p1sig,n2sig);
@@ -1424,7 +1431,7 @@ ResolveTwoForTwoPackage(AliITSpackageSSD *pkg)
          CreateNewRecPoint(ZposP1,0, ZposN2,0, p1sig+n2sig, p1sigErr+n2sigErr, clusterP1, clusterN2, 0.75);   
          CreateNewRecPoint(ZposP2,0, ZposN1,0, p2sig+n1sig, p2sigErr+n1sigErr, clusterP2, clusterN1, 0.75);    
        } //end second combinantion
-       //if (D12 > falpha3*17.8768)
+       //if (D12 > fAlpha3*17.8768)
        //keep all combinations
      } else {
         if (debug) cout<<"We decide to take all points\n";
@@ -1439,12 +1446,12 @@ ResolveTwoForTwoPackage(AliITSpackageSSD *pkg)
     Chicomb1 = DistToPML(p1sig,n1sig) + DistToPML(p2sig,n2sig);
     if (debug) cout<<"\nhere can be reconstructed 3 points: chicomb = "<<Chicomb1<<"\n"; 
   
-    if (Chicomb1<falpha1) {
+    if (Chicomb1<fAlpha1) {
        if (debug) cout<<"\nWe decided to take 3rd point"; 
        if (clusterP1->GetCrossNo()==1) {
          if (debug) cout<<"...  P1 has one cross\n"; 
-         n1sig = p1sig/PNsignalRatio;
-         p2sig = n2sig*PNsignalRatio;
+         n1sig = p1sig/fPNsignalRatio;
+         p2sig = n2sig*fPNsignalRatio;
               
          clusterN1->CutTotalSignal(n1sig);
          clusterP2->CutTotalSignal(p2sig);
@@ -1457,8 +1464,8 @@ ResolveTwoForTwoPackage(AliITSpackageSSD *pkg)
        } else {
          if (debug) cout<<"...  N1 has one cross\n";
              
-         n2sig=p2sig/PNsignalRatio;
-         p1sig=n1sig*PNsignalRatio;
+         n2sig=p2sig/fPNsignalRatio;
+         p1sig=n1sig*fPNsignalRatio;
 
          clusterN2->CutTotalSignal(n2sig);
          clusterP1->CutTotalSignal(p1sig);
@@ -1488,6 +1495,7 @@ CreateNewRecPoint(Float_t P, Float_t dP, Float_t N, Float_t dN,
                   AliITSclusterSSD *clusterP, AliITSclusterSSD *clusterN,
                   Stat_t prob)
 {
+// create the recpoints
 
   const Float_t kdEdXtoQ = 2.778e+8;
   const Float_t kconv = 1.0e-4; 
@@ -1497,6 +1505,9 @@ CreateNewRecPoint(Float_t P, Float_t dP, Float_t N, Float_t dN,
 
   Float_t p=P;
   Float_t n=N;
+  Int_t stripP, stripN;
+  Int_t sigP, sigN;
+  AliITSdigitSSD *digP, *digN;
   if (GetCrossing(P,N)) {
      GetCrossingError(dP,dN);
      AliITSRawClusterSSD cnew;
@@ -1509,8 +1520,7 @@ CreateNewRecPoint(Float_t P, Float_t dP, Float_t N, Float_t dN,
         printf("multiplicity > 100 - increase the dimension of the arrays %d\n",nstripsP);
         nstripsP=100;
      }
-     Int_t i;
-     for(i=0;i<nstripsP;i++) {
+     for(int i=0;i<nstripsP;i++) {
        // check if 'clusterP->GetDigitStripNo(i)' returns the digit index
        cnew.fIndexMap[i] = clusterP->GetDigitStripNo(i); 
      } 
@@ -1518,7 +1528,7 @@ CreateNewRecPoint(Float_t P, Float_t dP, Float_t N, Float_t dN,
         printf("multiplicity > 100 - increase the dimension of the arrays %d\n",nstripsN);
         nstripsN=100;
      }
-     for(i=0;i<nstripsN;i++) {
+     for(int i=0;i<nstripsN;i++) {
        // check if 'clusterN->GetDigitStripNo(i)' returns the digit index
        cnew.fIndexMapN[i] = clusterN->GetDigitStripNo(i); 
      }
@@ -1526,6 +1536,18 @@ CreateNewRecPoint(Float_t P, Float_t dP, Float_t N, Float_t dN,
      cnew.fQErr=dSig;
      //cnew.fProbability=(float)prob; 
      fITS->AddCluster(2,&cnew);
+     fSegmentation->GetPadIxz(P,N,stripP,stripN);
+     digP = (AliITSdigitSSD*)fMap->GetHit(1,stripP);
+     digN = (AliITSdigitSSD*)fMap->GetHit(0,stripN);
+     printf("SSD: digP digN %p %p\n",digP,digN);
+     if(digP) sigP = digP->fSignal;
+     else sigP=0;
+     if(digN) sigN = digN->fSignal;
+     else sigN=0;
+     if (!digP && !digN) {
+       Error("CreateNewRecPoint","cannot find the digit!");
+       return kFALSE;
+     }
      // add the rec point info
      AliITSRecPoint rnew;
      rnew.SetX(P*kconv);
@@ -1534,7 +1556,19 @@ CreateNewRecPoint(Float_t P, Float_t dP, Float_t N, Float_t dN,
      rnew.SetdEdX(Sig/kdEdXtoQ);
      rnew.SetSigmaX2( kRMSx* kRMSx); 
      rnew.SetSigmaZ2( kRMSz* kRMSz);
-     rnew.SetProbability((float)prob);
+     //rnew.SetProbability((float)prob);
+     if(sigP > sigN) {
+        rnew.fTracks[0]=digP->fTracks[0];
+        rnew.fTracks[1]=digP->fTracks[1];
+        rnew.fTracks[2]=digP->fTracks[2];
+       //printf("sigP>sigN: %d %d %d\n",digP->fTracks[0],digP->fTracks[1],digP->fTracks[2]);
+     } else {
+        rnew.fTracks[0]=digN->fTracks[0];
+        rnew.fTracks[1]=digN->fTracks[1];
+        rnew.fTracks[2]=digN->fTracks[2];
+       //printf("sigN>sigP: %d %d %d\n",digN->fTracks[0],digN->fTracks[1],digN->fTracks[2]);
+     }
+     //printf("SSD: track1 track2 track3 X Z %d %d %d %f %f\n",rnew.fTracks[0],rnew.fTracks[1],rnew.fTracks[2],P*kconv,N*kconv);
      fITS->AddRecPoint(rnew);
      /*
      // it was
@@ -1558,6 +1592,8 @@ CreateNewRecPoint(Float_t P, Float_t dP, Float_t N, Float_t dN,
 Bool_t  AliITSClusterFinderSSD::
 CreateNewRecPoint(AliITSclusterSSD *clusterP, AliITSclusterSSD *clusterN, Stat_t prob)
 {
+// create recpoints
+
   Float_t posClusterP;  //Cluster P position in strip coordinates
   Float_t posClusterN;  //Cluster N position in strip coordinates
  
@@ -1589,6 +1625,8 @@ CreateNewRecPoint(AliITSclusterSSD *clusterP, AliITSclusterSSD *clusterN, Stat_t
 //--------------------------------------------------
 Bool_t AliITSClusterFinderSSD::IsCrossing(AliITSclusterSSD* p, AliITSclusterSSD* n)
 {
+// check for crossings
+
   Float_t x = p->GetPosition();
   Float_t y = n->GetPosition();
   return GetCrossing(x,y);
@@ -1598,11 +1636,7 @@ Bool_t AliITSClusterFinderSSD::IsCrossing(AliITSclusterSSD* p, AliITSclusterSSD*
 //----------------------------------------------
 Bool_t AliITSClusterFinderSSD::Strip2Local( Float_t stripP, Float_t stripN, Float_t &Z,Float_t &X)
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
+// convert between strip numbers and local coordinates
 
 /*
  Z = (stripN-stripP)*fFactorOne;  
@@ -1616,8 +1650,8 @@ Bool_t AliITSClusterFinderSSD::Strip2Local( Float_t stripP, Float_t stripN, Floa
  X=P;
  Z=N;
  if (debug) cout<<"P="<<stripP<<" N="<<stripN<<"   X = "<<X<<" Z = "<<Z<<"\n";
- if ((Z<2.1)&&(Z>-2.1)&&(X<3.65)&&(X>-3.65)) return true
-    else return false;  
+ if ((Z<2.1)&&(Z>-2.1)&&(X<3.65)&&(X>-3.65)) return kTRUE
+    else return kFALSE;  
 
 }
 
@@ -1625,6 +1659,7 @@ Bool_t AliITSClusterFinderSSD::Strip2Local( Float_t stripP, Float_t stripN, Floa
 //-----------------------------------------------------------
 Float_t  AliITSClusterFinderSSD::GetClusterZ(AliITSclusterSSD* clust)
 {
+// get Z coordinate of the cluster
 
   return clust->GetPosition();
 
@@ -1634,12 +1669,6 @@ Float_t  AliITSClusterFinderSSD::GetClusterZ(AliITSclusterSSD* clust)
 Int_t AliITSClusterFinderSSD::GetBestComb
 (Int_t** comb,Int_t Ncomb, Int_t Ncl, AliITSpackageSSD * pkg)
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
 //returns index of best combination in "comb"
 //comb : sets of combinations
 //       in given combination on place "n" is index of 
@@ -1660,12 +1689,11 @@ Int_t AliITSClusterFinderSSD::GetBestComb
   Float_t chi;
   Float_t ps, ns;       //signal of P cluster and N cluster
 
-  Int_t i,j;
-  for(i=0;i<Ncomb;i++)
+  for (Int_t i=0;i<Ncomb;i++)
     {
       chi=0;
       
-      for(j=0;j<Ncl;j++)
+      for (Int_t j=0;j<Ncl;j++)
       {
         ps = pkg->GetPSideCluster(j)->GetTotalSignal();  //carrefully here, different functions
         ns = GetNSideCluster(comb[i][j])->GetTotalSignal(); 
@@ -1689,11 +1717,7 @@ Int_t AliITSClusterFinderSSD::GetBestComb
 void AliITSClusterFinderSSD::GetBestMatchingPoint
 (Int_t & ip, Int_t & in, AliITSpackageSSD* pkg )
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
+// find the best matching point
  
   if (debug) pkg->PrintClusters();
  
@@ -1708,8 +1732,7 @@ void AliITSClusterFinderSSD::GetBestMatchingPoint
        
   bestchi=DistToPML(  pkg->GetPSideCluster(0)->GetTotalSignal(),
                   pkg->GetNSideCluster(0)->GetTotalSignal()  );
-  Int_t i,j;
-  for(i = 0; i< pkg->GetNumOfClustersP(); i++)
+  for (Int_t i = 0; i< pkg->GetNumOfClustersP(); i++)
     {
       
       p =  pkg->GetPSideClusterIdx(i);   
@@ -1717,7 +1740,7 @@ void AliITSClusterFinderSSD::GetBestMatchingPoint
       nc=curPcl->GetCrossNo();
       ps=curPcl->GetTotalSignal();
       
-      for(j = 0; j< nc; j++)
+      for (Int_t j = 0; j< nc; j++)
         {
          n=curPcl->GetCross(j);
          curNcl= GetNSideCluster(n);
@@ -1739,11 +1762,7 @@ void AliITSClusterFinderSSD::GetBestMatchingPoint
 //------------------------------------------------------
 void  AliITSClusterFinderSSD::CalcStepFactor(Float_t Psteo, Float_t Nsteo )
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
+// calculate the step factor for matching clusters
 
 
   // 95 is the pitch, 4000 - dimension along z ?
@@ -1764,12 +1783,9 @@ void  AliITSClusterFinderSSD::CalcStepFactor(Float_t Psteo, Float_t Nsteo )
 //-----------------------------------------------------------
 AliITSclusterSSD* AliITSClusterFinderSSD::GetPSideCluster(Int_t idx)
 {
+// get P side clusters
 
 
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
-
 
 
   if((idx<0)||(idx>=fNClusterP))
@@ -1786,11 +1802,7 @@ AliITSclusterSSD* AliITSClusterFinderSSD::GetPSideCluster(Int_t idx)
 //-------------------------------------------------------
 AliITSclusterSSD* AliITSClusterFinderSSD::GetNSideCluster(Int_t idx)
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
+// get N side clusters
 
   if((idx<0)||(idx>=fNClusterN))
     {
@@ -1806,11 +1818,7 @@ AliITSclusterSSD* AliITSClusterFinderSSD::GetNSideCluster(Int_t idx)
 //--------------------------------------------------------
 AliITSclusterSSD* AliITSClusterFinderSSD::GetCluster(Int_t idx, Bool_t side)
 {
-
-
-//Piotr Krzysztof Skowronski
-//Warsaw University of Technology
-//skowron@if.pw.edu.pl
+// Get cluster
 
   return (side) ? GetPSideCluster(idx) : GetNSideCluster(idx);
 }
@@ -1819,9 +1827,9 @@ AliITSclusterSSD* AliITSClusterFinderSSD::GetCluster(Int_t idx, Bool_t side)
 //--------------------------------------------------------
 void AliITSClusterFinderSSD::ConsumeClusters()
 {
+// remove clusters from the list of unmatched clusters
 
- Int_t i;
- for(i=0;i<fNPackages;i++)
+ for ( Int_t i=0;i<fNPackages;i++)
   {
     ((AliITSpackageSSD*)((*fPackages)[i]))->ConsumeClusters();
   }
@@ -1832,6 +1840,8 @@ void AliITSClusterFinderSSD::ConsumeClusters()
 //--------------------------------------------------------
 void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
 {
+// reconstruct remaining non-crossing clusters
+
   Int_t i;
   AliITSclusterSSD *cluster;
   Float_t pos;
@@ -1847,7 +1857,9 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
   const Float_t kRMSx = 20.0*kconv; // microns->cm ITS TDR Table 1.3
   const Float_t kRMSz = 830.0*kconv; // microns->cm ITS TDR Table 1.3
   
-  for(i=0;i<fNClusterP;i++)
+  Int_t stripP,stripN;
+  AliITSdigitSSD *dig;
+  for (i=0;i<fNClusterP;i++)
     {
       //printf("P side cluster: cluster number %d\n",i);
       cluster = GetPSideCluster(i);
@@ -1857,7 +1869,7 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
             {
               sig = cluster->GetTotalSignal();
               
-              sig += sig/PNsignalRatio;
+              sig += sig/fPNsignalRatio;
               
               sigerr = cluster->GetTotalSignalError();
               x1 = -Dx/2 + pos *fPitch;
@@ -1866,6 +1878,10 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
               x2 = pos;
               z2 = 1;
               GetCrossing (x2,z2);
+             fSegmentation->GetPadIxz((x1+x2)/2,(z1+z2)/2,stripP,stripN);
+             dig = (AliITSdigitSSD*)fMap->GetHit(1,stripP);
+             if (!dig) printf("SSD: check the digit!  dig %p\n",dig);
+             if(!dig) continue;
              AliITSRawClusterSSD cnew;
              Int_t nstripsP=cluster->GetNumOfDigits();
              cnew.fMultiplicity=nstripsP;
@@ -1875,8 +1891,7 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
                printf("multiplicity > 100 - increase the dimension of the arrays %d\n",nstripsP);
                nstripsP=100;
              }
-              Int_t k;
-             for(k=0;k<nstripsP;k++) {
+             for(int k=0;k<nstripsP;k++) {
                // check if 'clusterP->GetDigitStripNo(i)' returns 
                // the digit index and not smth else
                cnew.fIndexMap[k] = cluster->GetDigitStripNo(k); 
@@ -1893,7 +1908,12 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
               rnew.SetdEdX(sig/kdEdXtoQ);
              rnew.SetSigmaX2( kRMSx* kRMSx);
              rnew.SetSigmaZ2( kRMSz* kRMSz);
-              rnew.SetProbability(0.75);
+              //rnew.SetProbability(0.75);
+             rnew.fTracks[0]=dig->fTracks[0];
+             rnew.fTracks[1]=dig->fTracks[1];
+             rnew.fTracks[2]=dig->fTracks[2];
+             //printf("digP: %d %d %d\n",dig->fTracks[0],dig->fTracks[1],dig->fTracks[2]);
+             //printf("SSD - P : track1 track2 track3  X Z %d %d %d %f %f\n",rnew.fTracks[0],rnew.fTracks[1],rnew.fTracks[2],kconv*(x1+x2)/2,kconv*(z1+z2)/2);
               fITS->AddRecPoint(rnew);
              /*
               fPointsM->AddLast( (TObject*) 
@@ -1906,9 +1926,9 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
         }
     }
 
-  for(i=0;i<fNClusterN;i++)
+  for (i=0;i<fNClusterN;i++)
     {
-      // printf("N side cluster: cluster number %d\n",i);
+      //printf("N side cluster: cluster number %d\n",i);
       cluster = GetNSideCluster(i);
       if (!cluster->IsConsumed())
         {
@@ -1916,7 +1936,7 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
             {
               sig = cluster->GetTotalSignal();
               
-              sig += sig*PNsignalRatio;
+              sig += sig*fPNsignalRatio;
               
               sigerr = cluster->GetTotalSignalError();
               
@@ -1927,6 +1947,10 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
               z2 = pos;
               
               GetCrossing (x2,z2);
+             fSegmentation->GetPadIxz((x1+x2)/2,(z1+z2)/2,stripP,stripN);
+             dig = (AliITSdigitSSD*)fMap->GetHit(0,stripN);
+             if (!dig) printf("SSD: check the digit! dig %p\n",dig);
+             if(!dig) continue;
              AliITSRawClusterSSD cnew;
              Int_t nstripsN=cluster->GetNumOfDigits();
              cnew.fMultiplicity=0;
@@ -1936,8 +1960,7 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
                printf("multiplicity > 100 - increase the dimension of the arrays %d\n",nstripsN);
                nstripsN=100;
              }
-              Int_t k;
-             for(k=0;k<nstripsN;k++) {
+             for(int k=0;k<nstripsN;k++) {
                // check if 'clusterP->GetDigitStripNo(i)' returns 
                // the digit index and not smth else
                cnew.fIndexMapN[k] = cluster->GetDigitStripNo(k); 
@@ -1946,7 +1969,6 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
              cnew.fQErr=sigerr;
              //cnew.fProbability=0.75; 
              fITS->AddCluster(2,&cnew);
-             // add the rec point info
              AliITSRecPoint rnew;
               rnew.SetX(kconv*(x1+x2)/2);
               rnew.SetZ(kconv*(z1+z2)/2);
@@ -1954,7 +1976,12 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
               rnew.SetdEdX(sig/kdEdXtoQ);
              rnew.SetSigmaX2( kRMSx* kRMSx);
              rnew.SetSigmaZ2( kRMSz* kRMSz);
-              rnew.SetProbability(0.75);
+              //rnew.SetProbability(0.75);
+             rnew.fTracks[0]=dig->fTracks[0];
+             rnew.fTracks[1]=dig->fTracks[1];
+             rnew.fTracks[2]=dig->fTracks[2];
+             //printf("digN: %d %d %d\n",dig->fTracks[0],dig->fTracks[1],dig->fTracks[2]);
+             //printf("SSD -N : track1 track2 track3  X Z %d %d %d %f %f\n",rnew.fTracks[0],rnew.fTracks[1],rnew.fTracks[2],kconv*(x1+x2)/2,kconv*(z1+z2)/2);
               fITS->AddRecPoint(rnew);
              /*
               fPointsM->AddLast( (TObject*) 
@@ -1975,6 +2002,7 @@ void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
 
 Bool_t AliITSClusterFinderSSD::GetCrossing (Float_t &P, Float_t &N) 
 { 
+// get crossing 
 
    Float_t Dx = fSegmentation->Dx();
    Float_t Dz = fSegmentation->Dz();
@@ -2011,6 +2039,8 @@ Bool_t AliITSClusterFinderSSD::GetCrossing (Float_t &P, Float_t &N)
 
 void AliITSClusterFinderSSD::GetCrossingError(Float_t& dP, Float_t& dN)
 {
+// get crossing error
+
   Float_t dz, dx;
   
   dz = TMath::Abs(( dP + dN )*fPitch/(fTanP + fTanN) );
@@ -2020,5 +2050,3 @@ void AliITSClusterFinderSSD::GetCrossingError(Float_t& dP, Float_t& dN)
   dN = dz;
   dP = dx;
 }
-
-