]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSClusterFinderV2SSD.cxx
For Pythia with tune don't switch off MI in ConfigHeavyFlavor
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinderV2SSD.cxx
index 8291f4279f9c09fc0d388b2c7e6926c52992cf2a..3e46291731ad4b1e7bec1676309c3f2240b28f3b 100644 (file)
 //            Implementation of the ITS clusterer V2 class                //
 //                                                                        //
 //          Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch            //
-//          Revised: Enrico Fragiacomo, enrico.fragiacomo@ts.infn.it      //
-//          Revised 23/06/08: Marco Bregant
+//          Last revision: 13-05-09 Enrico Fragiacomo                     //
+//                                  enrico.fragiacomo@ts.infn.it          //
 //                                                                        //
 ///////////////////////////////////////////////////////////////////////////
 
 #include <Riostream.h>
-
+#include "AliLog.h"
 
 #include "AliITSClusterFinderV2SSD.h"
 #include "AliITSRecPoint.h"
@@ -41,6 +41,8 @@
 
 Short_t *AliITSClusterFinderV2SSD::fgPairs = 0x0;
 Int_t    AliITSClusterFinderV2SSD::fgPairsSize = 0;
+const Float_t  AliITSClusterFinderV2SSD::fgkThreshold = 5.;
+
 const Float_t AliITSClusterFinderV2SSD::fgkCosmic2008StripShifts[16][9] = 
   {{-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35},  // DDL 512
    {-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35},  // DDL 513
@@ -97,10 +99,14 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
   //------------------------------------------------------------
   // Actual SSD cluster finder
   //------------------------------------------------------------
+  Int_t smaxall=alldigits->GetEntriesFast();
+  if (smaxall==0) return;
 
-  static AliITSRecoParam *repa = NULL;
-  
-  
+
+  //---------------------------------------
+  // load recoparam and calibration
+  // 
+  static AliITSRecoParam *repa = NULL;  
   if(!repa){
     repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
     if(!repa){
@@ -111,42 +117,86 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
 
   AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)GetResp(fModule);
   Float_t gain=0;
+  Float_t noise=0;
+  //---------------------------------------
 
-  Int_t smaxall=alldigits->GetEntriesFast();
-  if (smaxall==0) return;
-  //  TObjArray *digits = new TObjArray;
+
+  //------------------------------------
+  // fill the digits array with zero-suppression condition
+  // Signal is converted in KeV
+  //
   TObjArray digits;
   for (Int_t i=0;i<smaxall; i++){
     AliITSdigitSSD *d=(AliITSdigitSSD*)alldigits->UncheckedAt(i);
 
+    if(d->IsSideP()) noise = cal->GetNoiseP(d->GetStripNumber());  
+    else noise = cal->GetNoiseN(d->GetStripNumber());
+    if (d->GetSignal()<3.*noise) continue;
+
     if(d->IsSideP()) gain = cal->GetGainP(d->GetStripNumber());  
     else gain = cal->GetGainN(d->GetStripNumber());
 
-    Float_t q=gain*d->GetSignal(); // calibration brings mip peaks around 120 (in ADC units)
+    Float_t q=gain*d->GetSignal(); //
     q=cal->ADCToKeV(q); // converts the charge in KeV from ADC units
     d->SetSignal(Int_t(q));
 
-    if (d->GetSignal()<3) continue;
     digits.AddLast(d);
   }
   Int_t smax = digits.GetEntriesFast();
   if (smax==0) return;
+  //------------------------------------
+
   
   const Int_t kMax=1000;
   Int_t np=0, nn=0; 
   Ali1Dcluster pos[kMax], neg[kMax];
   Float_t y=0., q=0., qmax=0.; 
-  Int_t lab[4]={-2,-2,-2,-2};
+  Int_t lab[4]={-2,-2,-2,-2};  
+  Bool_t flag5 = 0;
   
+  /*
+  cout<<"-----------------------------"<<endl;
+  cout<<"this is module "<<fModule;
+  cout<<endl;
+  cout<<endl;
+  */
+
+  //--------------------------------------------------------
+  // start 1D-clustering from the first digit in the digits array
+  //
   AliITSdigitSSD *d=(AliITSdigitSSD*)digits.UncheckedAt(0);
   q += d->GetSignal();
   y += d->GetCoord2()*d->GetSignal();
   qmax=d->GetSignal();
   lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
+  
+  if(d->IsSideP()) {
+    noise = cal->GetNoiseP(d->GetStripNumber());  
+    gain = cal->GetGainP(d->GetStripNumber());
+  }
+  else {
+    noise = cal->GetNoiseN(d->GetStripNumber());
+    gain = cal->GetGainN(d->GetStripNumber());
+  }  
+  noise*=gain;
+  noise=cal->ADCToKeV(noise); // converts noise in KeV from ADC units
+
+  if(qmax>fgkThreshold*noise) flag5=1; // seed for the cluster
+
+  /*
+  cout<<d->GetSignal()<<" "<<noise<<" "<<flag5<<" "<<
+    d->GetCoord1()<<" "<<d->GetCoord2()<<endl;
+  */
+
   Int_t curr=d->GetCoord2();
   Int_t flag=d->GetCoord1();
+
+  // Note: the first side which will be processed is supposed to be the 
+  // P-side which is neg
   Int_t *n=&nn;
   Ali1Dcluster *c=neg;
+  if(flag) {n=&np; c=pos;} // in case we have only Nstrips (P was bad!)
+
   Int_t nd=1;
   Int_t milab[10];
   for (Int_t ilab=0;ilab<10;ilab++){
@@ -154,10 +204,21 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
   }
   milab[0]=d->GetTrack(0); milab[1]=d->GetTrack(1); milab[2]=d->GetTrack(2);
 
+
+  //----------------------------------------------------------
+  // search for neighboring digits
+  //
   for (Int_t s=1; s<smax; s++) {
       d=(AliITSdigitSSD*)digits.UncheckedAt(s);      
       Int_t strip=d->GetCoord2();
-      if ((strip-curr) > 1 || flag!=d->GetCoord1()) {
+
+      // if digits is not a neighbour or side did not change 
+      // and at least one of the previous digits met the seed condition
+      // then creates a new 1D cluster
+      if ( ( ((strip-curr) > 1) || (flag!=d->GetCoord1()) ) ) {
+
+       if(flag5) {
+         //cout<<"here1"<<endl;
          c[*n].SetY(y/q);
          c[*n].SetQ(q);
          c[*n].SetNd(nd);
@@ -165,7 +226,8 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
          c[*n].SetLabels(milab);
 
         if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
-          
+          // Note: fUseUnfoldingInClusterFinderSSD=kFALSE by default in RecoParam
+
           //Split suspiciously big cluster
           if (nd>4&&nd<25) {
             c[*n].SetY(y/q-0.25*nd);
@@ -188,20 +250,48 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
           Error("FindClustersSSD","Too many 1D clusters !");
           return;
          }
+
+       } // flag5 set
+
+        // reset everything
          y=q=qmax=0.;
          nd=0;
+        flag5=0;
          lab[0]=lab[1]=lab[2]=-2;
-        //
-        for (Int_t ilab=0;ilab<10;ilab++){
-          milab[ilab]=-2;
-        }
-        //
-         if (flag!=d->GetCoord1()) { n=&np; c=pos; }
-      }
+        for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
+
+        // if side changed from P to N, switch to pos 1D clusters
+        // (if for some reason the side changed from N to P then do the opposite)
+         if (flag!=d->GetCoord1()) 
+          { if(!flag) {n=&np; c=pos;} else {n=&nn; c=neg;} }
+
+      } // end create new 1D cluster from previous neighboring digits
+
+      // continues adding digits to the previous cluster 
+      // or start a new one 
       flag=d->GetCoord1();
       q += d->GetSignal();
       y += d->GetCoord2()*d->GetSignal();
       nd++;
+
+      if(d->IsSideP()) {
+       noise = cal->GetNoiseP(d->GetStripNumber());  
+       gain = cal->GetGainP(d->GetStripNumber());
+      }
+      else {
+       noise = cal->GetNoiseN(d->GetStripNumber());
+       gain = cal->GetGainN(d->GetStripNumber());
+      }
+      noise*=gain;
+      noise=cal->ADCToKeV(noise); // converts the charge in KeV from ADC units
+
+      if(d->GetSignal()>fgkThreshold*noise) flag5=1;
+
+      /*
+  cout<<d->GetSignal()<<" "<<noise<<" "<<flag5<<" "<<
+    d->GetCoord1()<<" "<<d->GetCoord2()<<endl;
+      */
+
       if (d->GetSignal()>qmax) {
          qmax=d->GetSignal();
          lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
@@ -210,37 +300,59 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
        if (d->GetTrack(ilab)>=0) AddLabel(milab, (d->GetTrack(ilab))); 
       }
       curr=strip;
-  }
-  c[*n].SetY(y/q);
-  c[*n].SetQ(q);
-  c[*n].SetNd(nd);
-  c[*n].SetLabels(lab);
 
-  if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
+
+  } // loop over digits, no more digits in the digits array
+
+
+  // add the last 1D cluster 
+  if(flag5) {
+
+    // cout<<"here2"<<endl;
+
+    c[*n].SetY(y/q);
+    c[*n].SetQ(q);
+    c[*n].SetNd(nd);
+    c[*n].SetLabels(lab);
     
-    //Split suspiciously big cluster
-    if (nd>4 && nd<25) {
-      c[*n].SetY(y/q-0.25*nd);
-      c[*n].SetQ(0.5*q);
-      (*n)++;
-      if (*n==kMax) {
-        Error("FindClustersSSD","Too many 1D clusters !");
-        return;
+    if(repa->GetUseUnfoldingInClusterFinderSSD()==kTRUE) {
+      
+      //Split suspiciously big cluster
+      if (nd>4 && nd<25) {
+       c[*n].SetY(y/q-0.25*nd);
+       c[*n].SetQ(0.5*q);
+       (*n)++;
+       if (*n==kMax) {
+         Error("FindClustersSSD","Too many 1D clusters !");
+         return;
+       }
+       c[*n].SetY(y/q+0.25*nd);
+       c[*n].SetQ(0.5*q);
+       c[*n].SetNd(nd);
+       c[*n].SetLabels(lab);
       }
-      c[*n].SetY(y/q+0.25*nd);
-      c[*n].SetQ(0.5*q);
-      c[*n].SetNd(nd);
-      c[*n].SetLabels(lab);
+    } // unfolding is on
+    
+    (*n)++;
+    if (*n==kMax) {
+      Error("FindClustersSSD","Too many 1D clusters !");
+      return;
     }
-  } // unfolding is on
-  
-  (*n)++;
-  if (*n==kMax) {
-     Error("FindClustersSSD","Too many 1D clusters !");
-     return;
-  }
 
+  } // if flag5 last 1D cluster added
+
+
+  //------------------------------------------------------
+  // call FindClustersSSD to pair neg and pos 1D clusters 
+  // and create recpoints from the crosses
+  // Note1: neg are Pside and pos are Nside!!
+  // Note2: if there are no Pside digits nn=0 (bad strips!!) (same for Nside)
+  //
+  //  cout<<nn<<" Pside and "<<np<<" Nside clusters"<<endl;
   FindClustersSSD(neg, nn, pos, np);
+  //
+  //-----------------------------------------------------
+
 }
 
 
@@ -347,6 +459,7 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
       cal = (AliITSCalibrationSSD*)GetResp(iModule);
 
       Bool_t first = 0;
+      Bool_t flag5 = 0;
       
       /*
       for(Int_t istrip=0; istrip<768; istrip++) { // P-side
@@ -381,6 +494,7 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
        if (signal!=65535) {
          gain = cal->GetGainP(istrip);
          signal = (Int_t) ( signal * gain ); // signal is corrected for gain
+         if(signal>fgkThreshold*noise) flag5=1;
          signal = (Int_t) cal->ADCToKeV( signal ); // signal is  converted in KeV 
          
          q += signal;    // add digit to current cluster
@@ -391,7 +505,7 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
        
        else if(first) {
          
-         if ( ( (nDigits==1) && ( (q==0) || (q>5*oldnoise)) ) || (nDigits>1) ) {
+         if ( (nDigits>0) && flag5 ) {
            
            Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
 
@@ -426,6 +540,7 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
          y = q = 0.;
          nDigits = 0;
          first=0;
+         flag5=0;
        }
        
       } // loop over strip on P-side
@@ -433,7 +548,7 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
       // if last strip does have signal
       if(first) {
        
-         if ( ( (nDigits==1) && ( (q==0) || (q>5*oldnoise)) ) || (nDigits>1) ) {
+         if ( (nDigits>0) && flag5 ) {
          
          Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
 
@@ -468,6 +583,7 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
        y = q = 0.;
        nDigits = 0;
        first=0;
+       flag5=0;
       }
       
       /*
@@ -505,6 +621,7 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
        if (signal!=65535) {
          gain = cal->GetGainN(strip);
          signal = (Int_t) ( signal * gain); // signal is corrected for gain
+         if(signal>fgkThreshold*noise) flag5=1;
          signal = (Int_t) cal->ADCToKeV( signal ); // signal is  converted in KeV 
          
          // add digit to current cluster
@@ -516,7 +633,7 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
 
        else if(first) {
          
-         if ( ( (nDigits==1) && ( (q==0) || (q>5*oldnoise)) ) || (nDigits>1) ) {
+         if ( (nDigits>0) && flag5 ) {
            
            Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
 
@@ -549,13 +666,14 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
          y = q = 0.;
          nDigits = 0;
          first=0;        
+       flag5=0;
        }
        
       } // loop over strips on N-side
 
       if(first) {
        
-         if ( ( (nDigits==1) && ( (q==0) || (q>5*oldnoise)) ) || (nDigits>1) ) {
+         if ( (nDigits>0) && flag5 ) {
          
          Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
          
@@ -590,6 +708,7 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input,
        y = q = 0.;
        nDigits = 0;
        first=0;          
+       flag5=0;
       }
       
       // create recpoints
@@ -625,6 +744,18 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
 
   const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
 
+  //---------------------------------------
+  // load recoparam
+  // 
+  static AliITSRecoParam *repa = NULL;  
+  if(!repa){
+    repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
+    if(!repa){
+      repa = AliITSRecoParam::GetHighFluxParam();
+      AliWarning("Using default AliITSRecoParam class");
+    }
+  }
+
   TClonesArray &cl=*clusters;
   
   AliITSsegmentationSSD *seg = dynamic_cast<AliITSsegmentationSSD*>(fDetTypeRec->GetSegmentationModel(2));
@@ -671,19 +802,26 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
 
       Float_t xt, zt;
       seg->GetPadCxz(yn, yp, xt, zt);
+      //cout<<yn<<" "<<yp<<" "<<xt<<" "<<zt<<endl;
       
-      if (TMath::Abs(xt)<hwSSD+0.01)
-      if (TMath::Abs(zt)<hlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
-       negativepair[i*10+cnegative[i]] =j;  //index
-       positivepair[j*10+cpositive[j]] =i;
-       cnegative[i]++;  //counters
-       cpositive[j]++; 
-       fgPairs[i*nn+j]=100;
+      if (TMath::Abs(xt)<hwSSD)
+      if (TMath::Abs(zt)<hlSSD) {
+       Int_t in = i*10+cnegative[i];
+       Int_t ip = j*10+cpositive[j];
+       if ((in < 10*np) && (ip < 10*nn)) {
+         negativepair[in] =j;  //index
+         positivepair[ip] =i;
+         cnegative[i]++;  //counters
+         cpositive[j]++;       
+         fgPairs[i*nn+j]=100;
+       }
+       else
+         AliError(Form("Index out of range: ip=%d, in=%d",ip,in));
       }
     }
   }
 
-  //
+  /* //
   // try to recover points out of but close to the module boundaries 
   //
   for (Int_t i=0; i<np; i++) {
@@ -703,30 +841,28 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
        // tag 1Dcluster (eventually will produce low quality recpoint)
        if (cnegative[i]==0) pos[i].SetNd(100);  // not available pair
        if (cpositive[j]==0) neg[j].SetNd(100);  // not available pair
-       negativepair[i*10+cnegative[i]] =j;  //index
-       positivepair[j*10+cpositive[j]] =i;
-       cnegative[i]++;  //counters
-       cpositive[j]++; 
-       fgPairs[i*nn+j]=100;
+       Int_t in = i*10+cnegative[i];
+       Int_t ip = j*10+cpositive[j];
+       if ((in < 10*np) && (ip < 10*nn)) {
+         negativepair[in] =j;  //index
+         positivepair[ip] =i;
+         cnegative[i]++;  //counters
+         cpositive[j]++;       
+         fgPairs[i*nn+j]=100;
+       }
+       else
+         AliError(Form("Index out of range: ip=%d, in=%d",ip,in));
       }
     }
   }
+  */
 
   //
-  Float_t lp[5];
+  Float_t lp[6];
   Int_t milab[10];
   Double_t ratio;
   
 
-  static AliITSRecoParam *repa = NULL;
-  if(!repa){
-    repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
-    if(!repa){
-      repa = AliITSRecoParam::GetHighFluxParam();
-      AliWarning("Using default AliITSRecoParam class");
-    }
-  }
-
   if(repa->GetUseChargeMatchingInClusterFinderSSD()==kTRUE) {
 
 
@@ -750,6 +886,7 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
        }
 
        ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
+       //cout<<"ratio="<<ratio<<endl;
 
        // charge matching (note that if posQ or negQ is 0 -> ratio=1 and the following condition is met
        if (TMath::Abs(ratio)>0.2) continue; // note: 0.2=3xsigma_ratio calculated in cosmics tests
@@ -764,7 +901,7 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
 
        
        qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
-       if( (pos[ip].GetQ()==0)||(neg[ip].GetQ()==0)) qbest*=2; // in case of bad strips on one side keep all charge from the other one
+       if( (pos[ip].GetQ()==0)||(neg[j].GetQ()==0)) qbest*=2; // in case of bad strips on one side keep all charge from the other one
        
        {
          Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
@@ -772,9 +909,6 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
          lp[0]=trk[1];
          lp[1]=trk[2];
        }
-       lp[2]=0.0025*0.0025;  //SigmaY2
-       lp[3]=0.110*0.110;  //SigmaZ2
-       
        lp[4]=qbest;        //Q
        for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
        for (Int_t ilab=0;ilab<3;ilab++){
@@ -785,6 +919,29 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
        CheckLabels2(milab);
        milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
        Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
+
+       lp[2]=4.968e-06;     // 0.00223*0.00223;  //SigmaY2
+       lp[3]=0.012;         // 0.110*0.110;  //SigmaZ2
+       // out-of-diagonal element of covariance matrix
+       if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
+       else if ( (info[0]>1) && (info[1]>1) ) { 
+         lp[2]=2.63e-06;    // 0.0016*0.0016;  //SigmaY2
+         lp[3]=0.0065;      // 0.08*0.08;   //SigmaZ2
+         lp[5]=-6.48e-05;
+       }
+       else {
+         lp[2]=4.80e-06;      // 0.00219*0.00219
+         lp[3]=0.0093;        // 0.0964*0.0964;
+         if (info[0]==1) {
+           lp[5]=-0.00014;
+         }
+         else { 
+           lp[2]=2.79e-06;    // 0.0017*0.0017; 
+           lp[3]=0.00935;     // 0.967*0.967;
+           lp[5]=-4.32e-05;
+         }
+       }
+
        AliITSRecPoint * cl2;
        
        if(clusters){  // Note clusters != 0 when method is called for rawdata
@@ -802,7 +959,7 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
          }
 
          if(pos[ip].GetQ()==0) cl2->SetType(3);
-         if(neg[ip].GetQ()==0) cl2->SetType(4);
+         if(neg[j].GetQ()==0) cl2->SetType(4);
 
          cused1[ip]++;
          cused2[j]++;
@@ -822,7 +979,7 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
          }
 
          if(pos[ip].GetQ()==0) cl2->SetType(3);
-         if(neg[ip].GetQ()==0) cl2->SetType(4);
+         if(neg[j].GetQ()==0) cl2->SetType(4);
 
          cused1[ip]++;
          cused2[j]++;
@@ -844,7 +1001,11 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
        if (ip2==ip) ip2 =  positivepair[10*in+1];
        Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ();
        
-       if ( (TMath::Abs(pcharge-neg[in].GetQ())<30) && (pcharge!=0) ) { // 
+
+
+       ratio = (pcharge-neg[in].GetQ())/(pcharge+neg[in].GetQ());
+       if ( (TMath::Abs(ratio)<0.2) && (pcharge!=0) ) {
+         //if ( (TMath::Abs(pcharge-neg[in].GetQ())<30) && (pcharge!=0) ) { // 
          
          //
          // add first pair
@@ -864,9 +1025,6 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
            lp[0]=trk[1];
            lp[1]=trk[2];
            
-           lp[2]=0.0025*0.0025;  //SigmaY2
-           lp[3]=0.110*0.110;  //SigmaZ2
-           
            lp[4]=qbest;        //Q
            for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
            for (Int_t ilab=0;ilab<3;ilab++){
@@ -879,7 +1037,29 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
            milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det
            Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
            
-           AliITSRecPoint * cl2;
+       lp[2]=4.968e-06;     // 0.00223*0.00223;  //SigmaY2
+       lp[3]=0.012;         // 0.110*0.110;  //SigmaZ2
+       // out-of-diagonal element of covariance matrix
+       if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
+       else if ( (info[0]>1) && (info[1]>1) ) { 
+         lp[2]=2.63e-06;    // 0.0016*0.0016;  //SigmaY2
+         lp[3]=0.0065;      // 0.08*0.08;   //SigmaZ2
+         lp[5]=-6.48e-05;
+       }
+       else {
+         lp[2]=4.80e-06;      // 0.00219*0.00219
+         lp[3]=0.0093;        // 0.0964*0.0964;
+         if (info[0]==1) {
+           lp[5]=-0.00014;
+         }
+         else { 
+           lp[2]=2.79e-06;    // 0.0017*0.0017; 
+           lp[3]=0.00935;     // 0.967*0.967;
+           lp[5]=-4.32e-05;
+         }
+       }
+
+       AliITSRecPoint * cl2;
            if(clusters){
              
              cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
@@ -928,9 +1108,6 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
            lp[0]=trk[1];
            lp[1]=trk[2];
            
-           lp[2]=0.0025*0.0025;  //SigmaY2
-           lp[3]=0.110*0.110;  //SigmaZ2
-           
            lp[4]=qbest;        //Q
            for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
            for (Int_t ilab=0;ilab<3;ilab++){
@@ -943,6 +1120,28 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
            milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det
            Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
            
+       lp[2]=4.968e-06;     // 0.00223*0.00223;  //SigmaY2
+       lp[3]=0.012;         // 0.110*0.110;  //SigmaZ2
+       // out-of-diagonal element of covariance matrix
+       if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
+       else if ( (info[0]>1) && (info[1]>1) ) { 
+         lp[2]=2.63e-06;    // 0.0016*0.0016;  //SigmaY2
+         lp[3]=0.0065;      // 0.08*0.08;   //SigmaZ2
+         lp[5]=-6.48e-05;
+       }
+       else {
+         lp[2]=4.80e-06;      // 0.00219*0.00219
+         lp[3]=0.0093;        // 0.0964*0.0964;
+         if (info[0]==1) {
+           lp[5]=-0.00014;
+         }
+         else { 
+           lp[2]=2.79e-06;    // 0.0017*0.0017; 
+           lp[3]=0.00935;     // 0.967*0.967;
+           lp[5]=-4.32e-05;
+         }
+       }
+
            AliITSRecPoint * cl2;
            if(clusters){
              cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
@@ -993,9 +1192,16 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
        Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ();
        //
        
+
+       ratio = (pcharge-pos[ip].GetQ())/(pcharge+pos[ip].GetQ());
+       if ( (TMath::Abs(ratio)<0.2) && (pcharge!=0) ) {
+
+         /*
        if ( (TMath::Abs(pcharge-pos[ip].GetQ())<30) &&  // charge matching 
             (pcharge!=0) ) { // reject combinations of bad strips
-         
+         */
+
+
          //
          // add first pair
          //    if (!(cused1[ip]||cused2[jn])){
@@ -1017,8 +1223,6 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
              lp[0]=trk[1];
              lp[1]=trk[2];
           }
-         lp[2]=0.0025*0.0025;  //SigmaY2
-         lp[3]=0.110*0.110;  //SigmaZ2
          
          lp[4]=qbest;        //Q
          for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
@@ -1032,6 +1236,28 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
          milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det
          Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]};
 
+       lp[2]=4.968e-06;     // 0.00223*0.00223;  //SigmaY2
+       lp[3]=0.012;         // 0.110*0.110;  //SigmaZ2
+       // out-of-diagonal element of covariance matrix
+       if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
+       else if ( (info[0]>1) && (info[1]>1) ) { 
+         lp[2]=2.63e-06;    // 0.0016*0.0016;  //SigmaY2
+         lp[3]=0.0065;      // 0.08*0.08;   //SigmaZ2
+         lp[5]=-6.48e-05;
+       }
+       else {
+         lp[2]=4.80e-06;      // 0.00219*0.00219
+         lp[3]=0.0093;        // 0.0964*0.0964;
+         if (info[0]==1) {
+           lp[5]=-0.00014;
+         }
+         else { 
+           lp[2]=2.79e-06;    // 0.0017*0.0017; 
+           lp[3]=0.00935;     // 0.967*0.967;
+           lp[5]=-4.32e-05;
+         }
+       }
+
          AliITSRecPoint * cl2;
          if(clusters){
            cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
@@ -1080,9 +1306,7 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
           lp[0]=trk[1];
           lp[1]=trk[2];
           }
-         lp[2]=0.0025*0.0025;  //SigmaY2
-         lp[3]=0.110*0.110;  //SigmaZ2
-         
+
          lp[4]=qbest;        //Q
          for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
          for (Int_t ilab=0;ilab<3;ilab++){
@@ -1094,6 +1318,29 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
          ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ());
          milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det
          Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fModule]};
+
+       lp[2]=4.968e-06;     // 0.00223*0.00223;  //SigmaY2
+       lp[3]=0.012;         // 0.110*0.110;  //SigmaZ2
+       // out-of-diagonal element of covariance matrix
+       if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
+       else if ( (info[0]>1) && (info[1]>1) ) { 
+         lp[2]=2.63e-06;    // 0.0016*0.0016;  //SigmaY2
+         lp[3]=0.0065;      // 0.08*0.08;   //SigmaZ2
+         lp[5]=-6.48e-05;
+       }
+       else {
+         lp[2]=4.80e-06;      // 0.00219*0.00219
+         lp[3]=0.0093;        // 0.0964*0.0964;
+         if (info[0]==1) {
+           lp[5]=-0.00014;
+         }
+         else { 
+           lp[2]=2.79e-06;    // 0.0017*0.0017; 
+           lp[3]=0.00935;     // 0.967*0.967;
+           lp[5]=-4.32e-05;
+         }
+       }
+
          AliITSRecPoint * cl2;
          if(clusters){
            cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
@@ -1135,10 +1382,156 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
   
     
     for (Int_t ip=0;ip<np;ip++){
+
+      if(cused1[ip]) continue;
+
+
       Float_t xbest=1000,zbest=1000,qbest=0;
       //
       // 2x2 clusters
       //
+      if ( (cnegative[ip]==2) && cpositive[negativepair[10*ip]]==2){ 
+       Float_t minchargediff =4.;
+       Float_t minchargeratio =0.2;
+
+       Int_t j=-1;
+       for (Int_t di=0;di<cnegative[ip];di++){
+         Int_t   jc = negativepair[ip*10+di];
+         Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
+         ratio = (pos[ip].GetQ()-neg[jc].GetQ())/(pos[ip].GetQ()+neg[jc].GetQ()); 
+         //if (TMath::Abs(chargedif)<minchargediff){
+         if (TMath::Abs(ratio)<0.2){
+           j =jc;
+           minchargediff = TMath::Abs(chargedif);
+           minchargeratio = TMath::Abs(ratio);
+         }
+       }
+       if (j<0) continue;  // not proper cluster      
+       
+
+       Int_t count =0;
+       for (Int_t di=0;di<cnegative[ip];di++){
+         Int_t   jc = negativepair[ip*10+di];
+         Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
+         if (TMath::Abs(chargedif)<minchargediff+3.) count++;
+       }
+       if (count>1) continue;  // more than one "proper" cluster for positive
+       //
+       
+       count =0;
+       for (Int_t dj=0;dj<cpositive[j];dj++){
+         Int_t   ic  = positivepair[j*10+dj];
+         Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
+         if (TMath::Abs(chargedif)<minchargediff+3.) count++;
+       }
+       if (count>1) continue;  // more than one "proper" cluster for negative
+       
+       Int_t jp = 0;
+       
+       count =0;
+       for (Int_t dj=0;dj<cnegative[jp];dj++){
+         Int_t   ic = positivepair[jp*10+dj];
+         Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
+         if (TMath::Abs(chargedif)<minchargediff+4.) count++;
+       }
+       if (count>1) continue;   
+       if (fgPairs[ip*nn+j]<100) continue;
+       //
+       
+
+
+       //almost gold clusters
+       Float_t yp=pos[ip].GetY(); 
+       Float_t yn=neg[j].GetY();      
+       Float_t xt, zt;
+       seg->GetPadCxz(yn, yp, xt, zt); 
+       xbest=xt; zbest=zt; 
+       qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
+       {
+         Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.};
+         mT2L->MasterToLocal(loc,trk);
+         lp[0]=trk[1];
+         lp[1]=trk[2];
+       }
+       lp[4]=qbest;        //Q
+       for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
+       for (Int_t ilab=0;ilab<3;ilab++){
+         milab[ilab] = pos[ip].GetLabel(ilab);
+         milab[ilab+3] = neg[j].GetLabel(ilab);
+       }
+       //
+       CheckLabels2(milab);
+        if ((neg[j].GetQ()==0)&&(pos[ip].GetQ()==0)) continue; // reject crosses of bad strips!!
+       ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
+       milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
+       Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
+
+       lp[2]=4.968e-06;     // 0.00223*0.00223;  //SigmaY2
+       lp[3]=0.012;         // 0.110*0.110;  //SigmaZ2
+       // out-of-diagonal element of covariance matrix
+       if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
+       else if ( (info[0]>1) && (info[1]>1) ) { 
+         lp[2]=2.63e-06;    // 0.0016*0.0016;  //SigmaY2
+         lp[3]=0.0065;      // 0.08*0.08;   //SigmaZ2
+         lp[5]=-6.48e-05;
+       }
+       else {
+         lp[2]=4.80e-06;      // 0.00219*0.00219
+         lp[3]=0.0093;        // 0.0964*0.0964;
+         if (info[0]==1) {
+           lp[5]=-0.00014;
+         }
+         else { 
+           lp[2]=2.79e-06;    // 0.0017*0.0017; 
+           lp[3]=0.00935;     // 0.967*0.967;
+           lp[5]=-4.32e-05;
+         }
+       }
+
+       AliITSRecPoint * cl2;
+       if(clusters){
+         cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
+                 
+         cl2->SetChargeRatio(ratio);           
+         cl2->SetType(10);
+         fgPairs[ip*nn+j]=10;
+         if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
+           cl2->SetType(11);
+           fgPairs[ip*nn+j]=11;
+         }
+         cused1[ip]++;
+         cused2[j]++;      
+       }
+       else{
+         cl2 = new AliITSRecPoint(milab,lp,info);
+         cl2->SetChargeRatio(ratio);           
+         cl2->SetType(10);
+         fgPairs[ip*nn+j]=10;
+         if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
+           cl2->SetType(11);
+           fgPairs[ip*nn+j]=11;
+         }
+         cused1[ip]++;
+         cused2[j]++;      
+         
+         fDetTypeRec->AddRecPoint(*cl2);
+       }      
+       ncl++;
+       
+      } // 2X2
+    } // loop over Pside 1Dclusters
+
+
+
+    for (Int_t ip=0;ip<np;ip++){
+
+      if(cused1[ip]) continue;
+
+
+      Float_t xbest=1000,zbest=1000,qbest=0;
+      //
+      // manyxmany clusters
+      //
       if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){ 
        Float_t minchargediff =4.;
        Int_t j=-1;
@@ -1199,8 +1592,6 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
          lp[0]=trk[1];
          lp[1]=trk[2];
        }
-       lp[2]=0.0025*0.0025;  //SigmaY2
-       lp[3]=0.110*0.110;  //SigmaZ2   
        lp[4]=qbest;        //Q
        for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
        for (Int_t ilab=0;ilab<3;ilab++){
@@ -1213,16 +1604,39 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
        ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
        milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
        Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
+
+       lp[2]=4.968e-06;     // 0.00223*0.00223;  //SigmaY2
+       lp[3]=0.012;         // 0.110*0.110;  //SigmaZ2
+       // out-of-diagonal element of covariance matrix
+       if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
+       else if ( (info[0]>1) && (info[1]>1) ) { 
+         lp[2]=2.63e-06;    // 0.0016*0.0016;  //SigmaY2
+         lp[3]=0.0065;      // 0.08*0.08;   //SigmaZ2
+         lp[5]=-6.48e-05;
+       }
+       else {
+         lp[2]=4.80e-06;      // 0.00219*0.00219
+         lp[3]=0.0093;        // 0.0964*0.0964;
+         if (info[0]==1) {
+           lp[5]=-0.00014;
+         }
+         else { 
+           lp[2]=2.79e-06;    // 0.0017*0.0017; 
+           lp[3]=0.00935;     // 0.967*0.967;
+           lp[5]=-4.32e-05;
+         }
+       }
+
        AliITSRecPoint * cl2;
        if(clusters){
          cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
                  
          cl2->SetChargeRatio(ratio);           
-         cl2->SetType(10);
-         fgPairs[ip*nn+j]=10;
+         cl2->SetType(12);
+         fgPairs[ip*nn+j]=12;
          if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
-           cl2->SetType(11);
-           fgPairs[ip*nn+j]=11;
+           cl2->SetType(13);
+           fgPairs[ip*nn+j]=13;
          }
          cused1[ip]++;
          cused2[j]++;      
@@ -1230,11 +1644,11 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
        else{
          cl2 = new AliITSRecPoint(milab,lp,info);
          cl2->SetChargeRatio(ratio);           
-         cl2->SetType(10);
-         fgPairs[ip*nn+j]=10;
+         cl2->SetType(12);
+         fgPairs[ip*nn+j]=12;
          if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
-           cl2->SetType(11);
-           fgPairs[ip*nn+j]=11;
+           cl2->SetType(13);
+           fgPairs[ip*nn+j]=13;
          }
          cused1[ip]++;
          cused2[j]++;      
@@ -1246,7 +1660,6 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
       } // manyXmany
     } // loop over Pside 1Dclusters
     
-    
   } // use charge matching
   
   
@@ -1271,8 +1684,8 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
       Float_t xt, zt;
       seg->GetPadCxz(yn, yp, xt, zt);
       
-      if (TMath::Abs(xt)<hwSSD+0.01)
-      if (TMath::Abs(zt)<hlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
+      if (TMath::Abs(xt)<hwSSD)
+      if (TMath::Abs(zt)<hlSSD) {
        xbest=xt; zbest=zt; 
 
         qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
@@ -1283,9 +1696,6 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
         lp[0]=trk[1];
         lp[1]=trk[2];
         }
-        lp[2]=0.0025*0.0025;  //SigmaY2
-        lp[3]=0.110*0.110;  //SigmaZ2
-
         lp[4]=qbest;        //Q
        for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
        for (Int_t ilab=0;ilab<3;ilab++){
@@ -1296,6 +1706,29 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
        CheckLabels2(milab);
        milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
        Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
+
+       lp[2]=4.968e-06;     // 0.00223*0.00223;  //SigmaY2
+       lp[3]=0.012;         // 0.110*0.110;  //SigmaZ2
+       // out-of-diagonal element of covariance matrix
+       if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012;
+       else if ( (info[0]>1) && (info[1]>1) ) { 
+         lp[2]=2.63e-06;    // 0.0016*0.0016;  //SigmaY2
+         lp[3]=0.0065;      // 0.08*0.08;   //SigmaZ2
+         lp[5]=-6.48e-05;
+       }
+       else {
+         lp[2]=4.80e-06;      // 0.00219*0.00219
+         lp[3]=0.0093;        // 0.0964*0.0964;
+         if (info[0]==1) {
+           lp[5]=-0.00014;
+         }
+         else { 
+           lp[2]=2.79e-06;    // 0.0017*0.0017; 
+           lp[3]=0.00935;     // 0.967*0.967;
+           lp[5]=-4.32e-05;
+         }
+       }
+
        AliITSRecPoint * cl2;
        if(clusters){
          cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
@@ -1321,6 +1754,250 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
       }
     }
   }
+
+
+
+  if(repa->GetUseBadChannelsInClusterFinderSSD()==kTRUE) {
+    
+    //---------------------------------------------------------
+    // recover crosses of good 1D clusters with bad strips on the other side
+    // Note1: at first iteration skip modules with a bad side (or almost), (would produce too many fake!) 
+    // Note2: for modules with a bad side see below 
+    
+    AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)GetResp(fModule);
+    Int_t countPbad=0, countNbad=0;
+    for(Int_t ib=0; ib<768; ib++) {
+      if(cal->IsPChannelBad(ib)) countPbad++;
+      if(cal->IsNChannelBad(ib)) countNbad++;
+    }
+    //  AliInfo(Form("module %d has %d P- and %d N-bad strips",fModule,countPbad,countNbad));
+    
+    if( (countPbad<100) && (countNbad<100) ) { // no bad side!!
+      
+      for (Int_t i=0; i<np; i++) { // loop over Nside 1Dclusters with no crosses
+       if(cnegative[i]) continue; // if intersecting Pside clusters continue;
+       
+       //      for(Int_t ib=0; ib<768; ib++) { // loop over all Pstrips
+       for(Int_t ib=15; ib<753; ib++) { // loop over all Pstrips
+         
+         if(cal->IsPChannelBad(ib)) { // check if strips is bad
+           Float_t yN=pos[i].GetY();   
+           Float_t xt, zt;
+           seg->GetPadCxz(1.*ib, yN, xt, zt);  
+           
+           //----------
+           // bad Pstrip is crossing the Nside 1Dcluster -> create recpoint
+           // 
+           if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
+             Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
+             mT2L->MasterToLocal(loc,trk);
+             lp[0]=trk[1];
+             lp[1]=trk[2];        
+             lp[4]=pos[i].GetQ(); //Q
+             for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
+             for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = pos[i].GetLabel(ilab);       
+             CheckLabels2(milab);
+             milab[3]=( (i<<10) << 10 ) + idet; // pos|neg|det
+             Int_t info[3] = {pos[i].GetNd(),0,fNlayer[fModule]};
+             
+             lp[2]=4.968e-06;     // 0.00223*0.00223;  //SigmaY2
+             lp[3]=0.012;         // 0.110*0.110;  //SigmaZ2
+             lp[5]=-0.00012; // out-of-diagonal element of covariance matrix
+             if (info[0]>1) {
+               lp[2]=4.80e-06;
+               lp[3]=0.0093;
+               lp[5]=0.00014;
+             }
+                     
+             AliITSRecPoint * cl2;
+             if(clusters){
+               cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);          
+               cl2->SetChargeRatio(1.);
+             cl2->SetType(50);   
+             }
+             else{
+               cl2 = new AliITSRecPoint(milab,lp,info);
+               cl2->SetChargeRatio(1.);
+               cl2->SetType(50);
+               fDetTypeRec->AddRecPoint(*cl2);
+             }
+             ncl++;
+           } // cross is within the detector
+           //
+           //--------------
+           
+         } // bad Pstrip
+         
+       } // end loop over Pstrips
+       
+      } // end loop over Nside 1D clusters
+      
+      for (Int_t j=0; j<nn; j++) { // loop over Pside 1D clusters with no crosses
+       if(cpositive[j]) continue;
+       
+       //      for(Int_t ib=0; ib<768; ib++) { // loop over all Nside strips
+       for(Int_t ib=15; ib<753; ib++) { // loop over all Nside strips
+         
+         if(cal->IsNChannelBad(ib)) { // check if strip is bad
+           Float_t yP=neg[j].GetY();   
+           Float_t xt, zt;
+           seg->GetPadCxz(yP, 1.*ib, xt, zt);  
+           
+           //----------
+           // bad Nstrip is crossing the Pside 1Dcluster -> create recpoint
+           // 
+           if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
+             Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
+             mT2L->MasterToLocal(loc,trk);
+             lp[0]=trk[1];
+             lp[1]=trk[2];        
+             lp[4]=neg[j].GetQ(); //Q
+             for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
+             for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = neg[j].GetLabel(ilab);       
+             CheckLabels2(milab);
+             milab[3]=( j << 10 ) + idet; // pos|neg|det
+             Int_t info[3]={0,(Int_t)neg[j].GetNd(),fNlayer[fModule]};
+             
+             lp[2]=4.968e-06;     // 0.00223*0.00223;  //SigmaY2
+             lp[3]=0.012;         // 0.110*0.110;  //SigmaZ2
+             lp[5]=-0.00012; // out-of-diagonal element of covariance matrix
+             if (info[0]>1) {
+               lp[2]=2.79e-06;
+               lp[3]=0.00935;
+               lp[5]=-4.32e-05;
+             }
+             
+             AliITSRecPoint * cl2;
+             if(clusters){
+               cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);          
+               cl2->SetChargeRatio(1.);
+               cl2->SetType(60);         
+             }
+             else{
+               cl2 = new AliITSRecPoint(milab,lp,info);
+               cl2->SetChargeRatio(1.);
+               cl2->SetType(60);
+               fDetTypeRec->AddRecPoint(*cl2);
+             }
+             ncl++;
+           } // cross is within the detector
+           //
+           //--------------
+           
+         } // bad Nstrip
+       } // end loop over Nstrips
+      } // end loop over Pside 1D clusters
+      
+    } // no bad sides 
+    
+    //---------------------------------------------------------
+    
+    else if( (countPbad>700) && (countNbad<100) ) { // bad Pside!!
+      
+      for (Int_t i=0; i<np; i++) { // loop over Nside 1Dclusters with no crosses
+       if(cnegative[i]) continue; // if intersecting Pside clusters continue;
+       
+       Float_t xt, zt;
+       Float_t yN=pos[i].GetY();       
+       Float_t yP=0.;
+       if (seg->GetLayer()==5) yP = yN + (7.6/1.9);
+       else yP = yN - (7.6/1.9);
+       seg->GetPadCxz(yP, yN, xt, zt); 
+       
+       if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
+         Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
+         mT2L->MasterToLocal(loc,trk);
+         lp[0]=trk[1];
+         lp[1]=trk[2];        
+         lp[4]=pos[i].GetQ(); //Q
+         for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
+         for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = pos[i].GetLabel(ilab);   
+         CheckLabels2(milab);
+         milab[3]=( (i<<10) << 10 ) + idet; // pos|neg|det
+         Int_t info[3] = {(Int_t)pos[i].GetNd(),0,fNlayer[fModule]};
+         
+         lp[2]=0.00098;    // 0.031*0.031;  //SigmaY2
+         lp[3]=1.329;      // 1.15*1.15;  //SigmaZ2
+         lp[5]=-0.0359;
+         if(info[0]>1) lp[2]=0.00097;
+
+         AliITSRecPoint * cl2;
+         if(clusters){
+           cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);      
+           cl2->SetChargeRatio(1.);
+           cl2->SetType(70);     
+         }
+         else{
+           cl2 = new AliITSRecPoint(milab,lp,info);
+           cl2->SetChargeRatio(1.);
+           cl2->SetType(70);
+           fDetTypeRec->AddRecPoint(*cl2);
+         }
+         ncl++;
+       } // cross is within the detector
+       //
+       //--------------
+       
+      } // end loop over Nside 1D clusters
+      
+    } // bad Pside module
+    
+    else if( (countNbad>700) && (countPbad<100) ) { // bad Nside!!
+      
+      for (Int_t j=0; j<nn; j++) { // loop over Pside 1D clusters with no crosses
+       if(cpositive[j]) continue;
+       
+       Float_t xt, zt;
+       Float_t yP=neg[j].GetY();       
+       Float_t yN=0.;
+       if (seg->GetLayer()==5) yN = yP - (7.6/1.9);
+       else yN = yP + (7.6/1.9);
+       seg->GetPadCxz(yP, yN, xt, zt); 
+       
+       if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) {
+         Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.};
+         mT2L->MasterToLocal(loc,trk);
+         lp[0]=trk[1];
+         lp[1]=trk[2];        
+         lp[4]=neg[j].GetQ(); //Q
+         for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
+         for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = neg[j].GetLabel(ilab);   
+         CheckLabels2(milab);
+         milab[3]=( j << 10 ) + idet; // pos|neg|det
+         Int_t info[3] = {0,(Int_t)neg[j].GetNd(),fNlayer[fModule]};
+         
+         lp[2]=7.27e-05;   // 0.0085*0.0085;  //SigmaY2
+         lp[3]=1.33;       // 1.15*1.15;  //SigmaZ2
+         lp[5]=0.00931;
+         if(info[1]>1) lp[2]=6.91e-05;
+         
+         AliITSRecPoint * cl2;
+         if(clusters){
+           cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);      
+           cl2->SetChargeRatio(1.);
+           cl2->SetType(80);     
+         }
+         else{
+           cl2 = new AliITSRecPoint(milab,lp,info);
+           cl2->SetChargeRatio(1.);
+           cl2->SetType(80);
+           fDetTypeRec->AddRecPoint(*cl2);
+         }
+         ncl++;
+       } // cross is within the detector
+       //
+       //--------------
+       
+      } // end loop over Pside 1D clusters
+      
+    } // bad Nside module
+    
+    //---------------------------------------------------------
+    
+  } // use bad channels
+    
+  //cout<<ncl<<" clusters for this module"<<endl;
+
   delete [] cnegative;
   delete [] cused1;
   delete [] negativepair;
@@ -1329,3 +2006,4 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
   delete [] positivepair;
 
 }
+