]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSClusterFinder.cxx
Fix for copy/paste error
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinder.cxx
index 308596d43acb702560d59be7d67f0d93ac1d1b42..de400891a834622a5e8d7c903ed076883c34d19a 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-//
-// Base Class used to find
-// the reconstructed points for ITS
-// See also AliITSClusterFinderSPD, AliITSClusterFinderSDD, 
-// AliITSClusterFinderSDD
-//
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// Base Class used to find                                                //
+// the reconstructed points for ITS                                       //
+// See also AliITSClusterFinderSPD, AliITSClusterFinderSDD,               //
+// AliITSClusterFinderSDD  AliITSClusterFinderV2                          //
+////////////////////////////////////////////////////////////////////////////
 
+#include "AliRun.h"
 #include "AliITSClusterFinder.h"
-#include "AliITSdigitSPD.h"
-#include "AliITSdigitSDD.h"
-#include "AliITSdigitSSD.h"
+#include "AliITSRecPoint.h"
+#include "AliITSdigit.h"
+#include "AliITSDetTypeRec.h"
 #include "AliITSMap.h"
-#include "AliRun.h"
-#include "AliITS.h"
+#include "AliITSgeomTGeo.h"
+#include <TParticle.h>
+#include "AliMC.h"
 
 ClassImp(AliITSClusterFinder)
 
+extern AliRun *gAlice;
+
 //----------------------------------------------------------------------
 AliITSClusterFinder::AliITSClusterFinder():
 TObject(),
-fDebug(0),
 fModule(0),
 fDigits(0),
 fNdigits(0),
-fResponse(0),
-fSegmentation(0),
+fDetTypeRec(0),
 fClusters(0),
-fNRawClusters(0),
 fMap(0),
-fNperMax(0),
-fDeclusterFlag(0),
-fClusterSize(0),
-fNPeaks(-1){
+fNPeaks(-1),
+fNModules(AliITSgeomTGeo::GetNModules()),
+fEvent(0),
+fZmin(0),
+fZmax(0),
+fXmin(0),
+fXmax(0){
     // default cluster finder
     // Input:
     //   none.
@@ -54,22 +59,22 @@ fNPeaks(-1){
     //   A default constructed AliITSCulsterFinder
 }
 //----------------------------------------------------------------------
-AliITSClusterFinder::AliITSClusterFinder(AliITSsegmentation *seg, 
-                                         AliITSresponse *res):
+AliITSClusterFinder::AliITSClusterFinder(AliITSDetTypeRec* dettyp):
 TObject(),
-fDebug(0),
 fModule(0),
 fDigits(0),
 fNdigits(0),
-fResponse(res),
-fSegmentation(seg),
+fDetTypeRec(dettyp),
 fClusters(0),
-fNRawClusters(0),
 fMap(0),
-fNperMax(0),
-fDeclusterFlag(0),
-fClusterSize(0),
-fNPeaks(-1){
+fNPeaks(-1),
+fNModules(AliITSgeomTGeo::GetNModules()),
+fEvent(0),
+fZmin(0),
+fZmax(0),
+fXmin(0),
+fXmax(0){
+    // default cluster finder
     // Standard constructor for cluster finder
     // Input:
     //   AliITSsegmentation *seg  The segmentation class to be used
@@ -79,28 +84,25 @@ fNPeaks(-1){
     // Return:
     //   A Standard constructed AliITSCulsterFinder
 
-    SetNperMax();
-    SetClusterSize();
-    SetDeclusterFlag();
 }
 //----------------------------------------------------------------------
-AliITSClusterFinder::AliITSClusterFinder(AliITSsegmentation *seg, 
-                                         AliITSresponse *response, 
-                                         TClonesArray *digits):
+AliITSClusterFinder::AliITSClusterFinder(AliITSDetTypeRec* dettyp,
+                                        TClonesArray *digits):
 TObject(),
-fDebug(0),
 fModule(0),
 fDigits(digits),
 fNdigits(0),
-fResponse(response),
-fSegmentation(seg),
+fDetTypeRec(dettyp),
 fClusters(0),
-fNRawClusters(0),
 fMap(0),
-fNperMax(0),
-fDeclusterFlag(0),
-fClusterSize(0),
-fNPeaks(-1){
+fNPeaks(-1),
+fNModules(AliITSgeomTGeo::GetNModules()),
+fEvent(0),
+fZmin(0),
+fZmax(0),
+fXmin(0),
+fXmax(0){
+    // default cluster finder
     // Standard + cluster finder constructor
     // Input:
     //   AliITSsegmentation *seg  The segmentation class to be used
@@ -112,10 +114,39 @@ fNPeaks(-1){
     //   A Standard constructed AliITSCulsterFinder
 
     fNdigits = fDigits->GetEntriesFast();
-    SetNperMax();
-    SetClusterSize();
-    SetDeclusterFlag();
 }
+
+//______________________________________________________________________
+AliITSClusterFinder::AliITSClusterFinder(const AliITSClusterFinder &source) : 
+  TObject(source),
+  fModule(source.fModule),
+  fDigits(),
+  fNdigits(source.fNdigits),
+  fDetTypeRec(),
+  fClusters(),
+  fMap(),
+  fNPeaks(source.fNPeaks),
+  fNModules(source.fNModules),
+  fEvent(source.fEvent),
+  fZmin(source.fZmin),
+  fZmax(source.fZmax),
+  fXmin(source.fXmin),
+  fXmax(source.fXmax) 
+{
+  // Copy constructor
+  // Copies are not allowed. The method is protected to avoid misuse.
+  AliError("Copy constructor not allowed\n");
+}
+
+
+//______________________________________________________________________
+//AliITSClusterFinder& AliITSClusterFinder::operator=(const AliITSClusterFinder& /* source */){
+  // Assignment operator
+  // Assignment is not allowed. The method is protected to avoid misuse.
+//  Fatal("= operator","Assignment operator not allowed\n");
+//  return *this;
+//}
+
 //----------------------------------------------------------------------
 AliITSClusterFinder::~AliITSClusterFinder(){
     // destructor cluster finder
@@ -128,187 +159,29 @@ AliITSClusterFinder::~AliITSClusterFinder(){
 
     if(fMap) {delete fMap;}
     // Zero local pointers. Other classes own these pointers.
-    fSegmentation = 0;
-    fResponse     = 0;
     fMap          = 0;
     fDigits       = 0;
     fNdigits      = 0;
-    fNRawClusters = 0;
-    fNperMax      = 0;
-    fDeclusterFlag= 0;
-    fClusterSize  = 0;
     fNPeaks       = 0;
-}
-//__________________________________________________________________________
-AliITSClusterFinder::AliITSClusterFinder(const AliITSClusterFinder &source) :
-    TObject(source){
-    //     Copy Constructor
-    // Input:
-    //   AliITSClusterFinder &source  The class which will become a copy of 
-    //                                this class
-    // Output:
-    //   none.
-    // Return:
-    //   A copy of this class
+    fDetTypeRec   = 0;
 
-    if(&source == this) return;
-    *this = source;
-    return;
 }
-//______________________________________________________________________
-AliITSClusterFinder& AliITSClusterFinder::operator=(const AliITSClusterFinder 
-                                                    &source) {
-    //    Assignment operator
-    // Input:
-    //   AliITSClusterFinder &source  The class which will become a copy of 
-    //                                this class
-    // Output:
-    //   none.
-    // Return:
-    //   A copy of this class
-
-    if(&source == this) return *this;
-    this->fDigits = source.fDigits;
-    this->fNdigits = source.fNdigits;
-    this->fResponse = source.fResponse;
-    this->fSegmentation = source.fSegmentation;
-    this->fNRawClusters = source.fNRawClusters;
-    this->fMap = source.fMap;
-    this->fNperMax = source.fNperMax;
-    this->fDeclusterFlag = source.fDeclusterFlag;
-    this->fClusterSize = source.fClusterSize;
-    this->fNPeaks = source.fNPeaks;
-    return *this;
+//__________________________________________________________________________
+void AliITSClusterFinder::InitGeometry(){
+ //
+ // Initialisation of ITS geometry
+ //
+  Int_t mmax=AliITSgeomTGeo::GetNModules();
+  for (Int_t m=0; m<mmax; m++) {
+    Int_t lay,lad,det; AliITSgeomTGeo::GetModuleId(m,lay,lad,det);
+    fNdet[m] = (lad-1)*AliITSgeomTGeo::GetNDetectors(lay) + (det-1);
+    fNlayer[m] = lay-1;
+  }
 }
-//----------------------------------------------------------------------
-void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c){
-    // Add a raw cluster copy to the list
-    // Input:
-    //   Int_t       branch  The branch to which the cluster is to be added to
-    //   AliITSRawCluster *c The cluster to be added to the array of clusters
-    // Output:
-    //   none.
-    // Return:
-    //   none.
 
-    AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
-    iTS->AddCluster(branch,c); 
-    fNRawClusters++;
-}
-//----------------------------------------------------------------------
-void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c, 
-                                    AliITSRecPoint &rp){
-    // Add a raw cluster copy to the list and the RecPoint
-    // Input:
-    //   Int_t       branch  The branch to which the cluster is to be added to
-    //   AliITSRawCluster *c The cluster to be added to the array of clusters
-    //   AliITSRecPoint  &rp The RecPoint to be added to the array of RecPoints
-    // Output:
-    //   none.
-    // Return:
-    //   none.
 
-    AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
-    iTS->AddCluster(branch,c); 
-    fNRawClusters++;
-    iTS->AddRecPoint(rp); 
-}
-//______________________________________________________________________
-void AliITSClusterFinder::FindRawClusters(Int_t module){
-    // Default Cluster finder.
-    // Input:
-    //   Int_t module   Module number for which culster are to be found.
-    // Output:
-    //   none.
-    // Return:
-    //   none.
-    const Int_t kelms = 10;
-    Int_t ndigits = fDigits->GetEntriesFast();
-    TObjArray *digs = new TObjArray(ndigits);
-    TObjArray *clusts = new TObjArray(ndigits); // max # cluster
-    TObjArray *clust0=0; // A spacific cluster of digits
-    TObjArray *clust1=0; // A spacific cluster of digits
-    AliITSdigit *dig=0; // locat pointer to a digit
-    Int_t i=0,nc=0,j[4],k,k2=0;
-
-    // Copy all digits for this module into a local TObjArray.
-    for(i=0;i<ndigits;i++) digs->AddAt(new AliITSdigit(*(GetDigit(i))),i);
-    digs->Sort();
-    // First digit is a cluster.
-    i  = 0;
-    nc = 0;
-    clusts->AddAt(new TObjArray(kelms),nc);
-    clust0 = (TObjArray*)(clusts->At(nc));
-    clust0->AddAtFree(digs->At(i)); // move owner ship from digs to clusts
-    nc++;
-    for(i=1;i<ndigits;i++){
-        if(IsNeighbor(digs,i,j)){
-            dig = (AliITSdigit*)(digs->At(j[0]));
-            // Add to existing cluster. Find which cluster this digis 
-            for(k=0;k<nc;k++){
-                clust0 = ((TObjArray*)(clusts->At(k)));
-                if(clust0->IndexOf(dig)>=0) break;
-            } // end for k
-            if(k>=nc){
-                Fatal("FindRawClusters","Digit not found as expected");
-            } // end if
-            if(j[1]>=0){
-                dig = (AliITSdigit*)(digs->At(j[1]));
-                // Add to existing cluster. Find which cluster this digis 
-                for(k2=0;k2<nc;k2++){
-                    clust1 = ((TObjArray*)(clusts->At(k2)));
-                    if(clust1->IndexOf(dig)>=0) break;
-                } // end for k2
-                if(k2>=nc){
-                    Fatal("FindRawClusters","Digit not found as expected");
-                } // end if
-            } // end if j[1]>=0
-            // Found cluster with neighboring digits add this one to it.
-            if(clust0==clust1){ // same cluster
-                clust0->AddAtFree(digs->At(i));
-                clust0 = 0; // finished with cluster. zero for safty
-                clust1 = 0; // finished wit hcluster. zero for safty
-            }else{ // two different clusters which need to be merged.
-                clust0->AddAtFree(digs->At(i)); // Add digit to this cluster.
-                for(k=0;k<clust1->GetEntriesFast();k++){
-                    // move clust1 into clust0
-                    //move digit to this cluster
-                    clust0->AddAtFree(clust1->At(k));
-                    clust1->AddAt(0,k); // zero this one
-                } // end for k
-                delete clust1;
-                clusts->AddAt(0,k2); // zero array of clusters element clust1
-                clust0 = 0; // finished with cluster. zero for safty
-                clust1 = 0; // finished wit hcluster. zero for safty
-            } // end if clust0==clust1
-        }else{// New cluster
-            clusts->AddAt(new TObjArray(kelms),nc);
-            clust0 = ((TObjArray*)(clusts->At(nc)));
-            // move owner ship from digs to clusts
-            clust0->AddAtFree(digs->At(i));
-            clust0 = 0; // finished with cluster. zero for safty
-            nc++;
-        } // End if IsNeighbor
-    } // end for i
-    // There are now nc clusters in clusts. Each element of clust is an
-    // array of digits which are clustered together.
-
-    // For each cluster call detector specific CreateRecPoints
-    for(i=0;i<nc;i++) CreateRecPoints((TObjArray*)(clusts->At(i)),module);
-
-    // clean up at the end.
-    for(i=0;i<nc;i++){ 
-        clust0 =(TObjArray*)(clusts->At(i));
-        // Digits deleted below, so zero this TObjArray
-        for(k=0;k<clust0->GetEntriesFast();k++) clust0->AddAt(0,k);
-        delete clust0; // Delete this TObjArray
-        clusts->AddAt(0,i); // Contents deleted above, so zero it.
-    } // end for i
-    delete clusts; // Delete this TObjArray/
-    // Delete the digits then the TObjArray which containted them.
-    for(i=0;i<ndigits;i++) delete ((AliITSdigit*)(digs->At(i)));
-    delete digs;
-}
+
+
 //______________________________________________________________________
 Bool_t AliITSClusterFinder::IsNeighbor(TObjArray *digs,Int_t i,Int_t n[])const{
     // Locagical function which checks to see if digit i has a neighbor.
@@ -354,7 +227,7 @@ Bool_t AliITSClusterFinder::IsNeighbor(TObjArray *digs,Int_t i,Int_t n[])const{
 }
 
 //______________________________________________________________________
-void AliITSClusterFinder::Print(ostream *os){
+void AliITSClusterFinder::Print(ostream *os) const{
     //Standard output format for this class
     // Inputs:
     //    ostream *os   Output stream
@@ -363,17 +236,12 @@ void AliITSClusterFinder::Print(ostream *os){
     // Return:
     //    none.
 
-    *os << fDebug<<",";
     *os << fModule<<",";
     *os << fNdigits<<",";
-    *os << fNRawClusters<<",";
-    *os << fNperMax<<",";
-    *os << fDeclusterFlag<<",";
-    *os << fClusterSize<<",";
     *os << fNPeaks<<endl;
 }
 //______________________________________________________________________
-void AliITSClusterFinder::Read(istream *is){
+void AliITSClusterFinder::Read(istream *is)  {
     //Standard input for this class
     // Inputs:
     //    istream *is   Input stream
@@ -382,13 +250,8 @@ void AliITSClusterFinder::Read(istream *is){
     // Return:
     //    none.
 
-    *is >> fDebug;
     *is >> fModule;
     *is >> fNdigits;
-    *is >> fNRawClusters;
-    *is >> fNperMax;
-    *is >> fDeclusterFlag;
-    *is >> fClusterSize;
     *is >> fNPeaks;
 }
 //______________________________________________________________________
@@ -419,3 +282,212 @@ istream &operator>>(istream &is,AliITSClusterFinder &source){
     source.Read(&is);
     return is;
 }
+//______________________________________________________________________
+void AliITSClusterFinder::CheckLabels2(Int_t lab[10]) {
+  //------------------------------------------------------------
+  // Tries to find mother's labels
+  //------------------------------------------------------------
+  AliRunLoader *rl = AliRunLoader::Instance();
+  if(!rl) return;
+  TTree *trK=(TTree*)rl->TreeK();
+
+  if(trK){
+    Int_t nlabels =0; 
+    for (Int_t i=0;i<10;i++) if (lab[i]>=0) nlabels++;
+    if(nlabels == 0) return; // In case of no labels just exit
+
+
+    Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
+
+    for (Int_t i=0;i<10;i++){
+      Int_t label = lab[i];
+      if (label>=0 && label<ntracks) {
+       TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
+
+       if (part->P() < 0.02) {
+         Int_t m=part->GetFirstMother();
+         if (m<0) {    
+           continue;
+         }
+         if (part->GetStatusCode()>0) {
+           continue;
+         }
+         lab[i]=m;       
+       }
+       else
+         if (part->P() < 0.12 && nlabels>3) {
+           lab[i]=-2;
+           nlabels--;
+         } 
+      }
+      else{
+       if ( (label>ntracks||label <0) && nlabels>3) {
+         lab[i]=-2;
+         nlabels--;
+       } 
+      }
+    }  
+    if (nlabels>3){
+      for (Int_t i=0;i<10;i++){
+       if (nlabels>3){
+         Int_t label = lab[i];
+         if (label>=0 && label<ntracks) {
+           TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
+           if (part->P() < 0.1) {
+             lab[i]=-2;
+             nlabels--;
+           }
+         }
+       }
+      }
+    }
+
+    //compress labels -- if multi-times the same
+    Int_t lab2[10];
+    for (Int_t i=0;i<10;i++) lab2[i]=-2;
+    for (Int_t i=0;i<10  ;i++){
+      if (lab[i]<0) continue;
+      for (Int_t j=0;j<10 &&lab2[j]!=lab[i];j++){
+       if (lab2[j]<0) {
+         lab2[j]= lab[i];
+         break;
+       }
+      }
+    }
+    for (Int_t j=0;j<10;j++) lab[j]=lab2[j];
+  
+  }
+}
+
+//______________________________________________________________________
+void AliITSClusterFinder::AddLabel(Int_t lab[10], Int_t label) {
+  //add label to the cluster
+  AliRunLoader *rl = AliRunLoader::Instance();
+  TTree *trK=(TTree*)rl->TreeK();
+  if(trK){
+    if(label<0) return; // In case of no label just exit
+
+    Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
+    if (label>ntracks) return;
+    for (Int_t i=0;i<10;i++){
+      //    if (label<0) break;
+      if (lab[i]==label) break;
+      if (lab[i]<0) {
+       lab[i]= label;
+       break;
+      }
+    }
+  }
+}
+
+
+//______________________________________________________________________
+void AliITSClusterFinder:: 
+FindCluster(Int_t k,Int_t maxz,AliBin *bins,Int_t &n,Int_t *idx) {
+  //------------------------------------------------------------
+  // returns an array of indices of digits belonging to the cluster
+  // (needed when the segmentation is not regular) 
+  //------------------------------------------------------------
+  if (n<200) idx[n++]=bins[k].GetIndex();
+  bins[k].Use();
+
+  if (bins[k-maxz].IsNotUsed()) FindCluster(k-maxz,maxz,bins,n,idx);
+  if (bins[k-1   ].IsNotUsed()) FindCluster(k-1   ,maxz,bins,n,idx);
+  if (bins[k+maxz].IsNotUsed()) FindCluster(k+maxz,maxz,bins,n,idx);
+  if (bins[k+1   ].IsNotUsed()) FindCluster(k+1   ,maxz,bins,n,idx);
+  /*
+  if (bins[k-maxz-1].IsNotUsed()) FindCluster(k-maxz-1,maxz,bins,n,idx);
+  if (bins[k-maxz+1].IsNotUsed()) FindCluster(k-maxz+1,maxz,bins,n,idx);
+  if (bins[k+maxz-1].IsNotUsed()) FindCluster(k+maxz-1,maxz,bins,n,idx);
+  if (bins[k+maxz+1].IsNotUsed()) FindCluster(k+maxz+1,maxz,bins,n,idx);
+  */
+}
+
+//______________________________________________________________________
+Bool_t AliITSClusterFinder::IsMaximum(Int_t k,Int_t max,const AliBin *bins) {
+  //------------------------------------------------------------
+  //is this a local maximum ?
+  //------------------------------------------------------------
+  UShort_t q=bins[k].GetQ();
+  if (q==1023) return kFALSE;
+  if (bins[k-max].GetQ() > q) return kFALSE;
+  if (bins[k-1  ].GetQ() > q) return kFALSE; 
+  if (bins[k+max].GetQ() > q) return kFALSE; 
+  if (bins[k+1  ].GetQ() > q) return kFALSE; 
+  if (bins[k-max-1].GetQ() > q) return kFALSE;
+  if (bins[k+max-1].GetQ() > q) return kFALSE; 
+  if (bins[k+max+1].GetQ() > q) return kFALSE; 
+  if (bins[k-max+1].GetQ() > q) return kFALSE;
+  return kTRUE; 
+}
+
+//______________________________________________________________________
+void AliITSClusterFinder::
+FindPeaks(Int_t k,Int_t max,AliBin *b,Int_t *idx,UInt_t *msk,Int_t& n) {
+  //------------------------------------------------------------
+  //find local maxima
+  //------------------------------------------------------------
+  if (n<31)
+  if (IsMaximum(k,max,b)) {
+    idx[n]=k; msk[n]=(2<<n);
+    n++;
+  }
+  b[k].SetMask(0);
+  if (b[k-max].GetMask()&1) FindPeaks(k-max,max,b,idx,msk,n);
+  if (b[k-1  ].GetMask()&1) FindPeaks(k-1  ,max,b,idx,msk,n);
+  if (b[k+max].GetMask()&1) FindPeaks(k+max,max,b,idx,msk,n);
+  if (b[k+1  ].GetMask()&1) FindPeaks(k+1  ,max,b,idx,msk,n);
+}
+
+//______________________________________________________________________
+void AliITSClusterFinder::
+MarkPeak(Int_t k, Int_t max, AliBin *bins, UInt_t m) {
+  //------------------------------------------------------------
+  //mark this peak
+  //------------------------------------------------------------
+  UShort_t q=bins[k].GetQ();
+
+  bins[k].SetMask(bins[k].GetMask()|m); 
+
+  if (bins[k-max].GetQ() <= q)
+     if ((bins[k-max].GetMask()&m) == 0) MarkPeak(k-max,max,bins,m);
+  if (bins[k-1  ].GetQ() <= q)
+     if ((bins[k-1  ].GetMask()&m) == 0) MarkPeak(k-1  ,max,bins,m);
+  if (bins[k+max].GetQ() <= q)
+     if ((bins[k+max].GetMask()&m) == 0) MarkPeak(k+max,max,bins,m);
+  if (bins[k+1  ].GetQ() <= q)
+     if ((bins[k+1  ].GetMask()&m) == 0) MarkPeak(k+1  ,max,bins,m);
+}
+
+//______________________________________________________________________
+void AliITSClusterFinder::
+MakeCluster(Int_t k,Int_t max,AliBin *bins,UInt_t m,AliITSRecPoint &c) {
+  //------------------------------------------------------------
+  //make cluster using digits of this peak
+  //------------------------------------------------------------
+  Float_t q=(Float_t)bins[k].GetQ();
+  Int_t i=k/max, j=k-i*max;
+  if(c.GetQ()<0.01){ // first entry in cluster
+    fXmin=i;
+    fXmax=i;
+    fZmin=j;
+    fZmax=j;
+  }else{  // check cluster extension
+    if(i<fXmin) fXmin=i;
+    if(i>fXmax) fXmax=i;
+    if(j<fZmin) fZmin=j;
+    if(j>fZmax) fZmax=j;
+  }
+  c.SetQ(c.GetQ()+q);
+  c.SetY(c.GetY()+i*q);
+  c.SetZ(c.GetZ()+j*q);
+  c.SetSigmaY2(c.GetSigmaY2()+i*i*q);
+  c.SetSigmaZ2(c.GetSigmaZ2()+j*j*q);
+
+  bins[k].SetMask(0xFFFFFFFE);
+  
+  if (bins[k-max].GetMask() == m) MakeCluster(k-max,max,bins,m,c);
+  if (bins[k-1  ].GetMask() == m) MakeCluster(k-1  ,max,bins,m,c);
+  if (bins[k+max].GetMask() == m) MakeCluster(k+max,max,bins,m,c);
+  if (bins[k+1  ].GetMask() == m) MakeCluster(k+1  ,max,bins,m,c);
+}