]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONClusterFinderVS.cxx
Cosmetics (Chrsitian)
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterFinderVS.cxx
index 5819b861e62d62a149d3bf5a55c2c018e52809d2..0418dd5a9b4f724982e9f10043d5e7be1a0d7a98 100644 (file)
 
 /* $Id$ */
 
+#include <TMinuit.h> 
+#include <TF1.h>
+#include <TMinuit.h> 
+#include <Riostream.h>
+
 #include "AliMUONClusterFinderVS.h"
 #include "AliMUONDigit.h"
 #include "AliMUONRawCluster.h"
 #include "AliSegmentation.h"
-#include "AliMUONResponse.h"
+#include "AliMUONGeometrySegmentation.h"
+#include "AliMUONMathieson.h"
 #include "AliMUONClusterInput.h"
 #include "AliMUONHitMapA1.h"
-#include "AliRun.h"
-#include "AliMUON.h"
-
-#include <TTree.h>
-#include <TCanvas.h>
-#include <TH1.h>
-#include <TPad.h>
-#include <TGraph.h> 
-#include <TPostScript.h> 
-#include <TMinuit.h> 
-#include <TF1.h>
-
-#include <stdio.h>
-#include <Riostream.h>
+#include "AliLog.h"
 
 //_____________________________________________________________________
 // This function is minimized in the double-Mathieson fit
@@ -47,9 +40,11 @@ void fcnCombiS2(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t if
 ClassImp(AliMUONClusterFinderVS)
 
 AliMUONClusterFinderVS::AliMUONClusterFinderVS()
+  : TObject()
 {
 // Default constructor
     fInput=AliMUONClusterInput::Instance();
+//     cout <<  " TYPE" << fSegmentationType << endl;
     fHitMap[0] = 0;
     fHitMap[1] = 0;
     fTrack[0]=fTrack[1]=-1;
@@ -57,6 +52,9 @@ AliMUONClusterFinderVS::AliMUONClusterFinderVS()
     fGhostChi2Cut = 1e6; // nothing done by default
     fSeg[0]    = 0;
     fSeg[1]    = 0;
+    fSeg2[0]    = 0;
+    fSeg2[1]    = 0;
+
     for(Int_t i=0; i<100; i++) {
       for (Int_t j=0; j<2; j++) {
         fDig[i][j] = 0;
@@ -64,8 +62,6 @@ AliMUONClusterFinderVS::AliMUONClusterFinderVS()
     } 
     fRawClusters = new TClonesArray("AliMUONRawCluster",1000);
     fNRawClusters = 0;
-
-
 }
  //____________________________________________________________________________
 AliMUONClusterFinderVS::~AliMUONClusterFinderVS()
@@ -80,8 +76,9 @@ AliMUONClusterFinderVS::~AliMUONClusterFinderVS()
 
 AliMUONClusterFinderVS::AliMUONClusterFinderVS(const AliMUONClusterFinderVS & clusterFinder):TObject(clusterFinder)
 {
-// Dummy copy Constructor
-    ;
+// Protected copy constructor
+
+  AliFatal("Not implemented.");
 }
 //____________________________________________________________________________
 void AliMUONClusterFinderVS::ResetRawClusters()
@@ -104,8 +101,8 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 
     fInput->SetCluster(c);
 
-    fMul[0]=c->fMultiplicity[0];
-    fMul[1]=c->fMultiplicity[1];
+    fMul[0]=c->GetMultiplicity(0);
+    fMul[1]=c->GetMultiplicity(1);
 
 //
 //  dump digit information into arrays
@@ -114,20 +111,25 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
     Float_t qtot;
     
     for (cath=0; cath<2; cath++) {
-       qtot=0;
-       for (i=0; i<fMul[cath]; i++)
-       {
-           // pointer to digit
-           fDig[i][cath]=fInput->Digit(cath, c->fIndexMap[i][cath]);
-           // pad coordinates
-           fIx[i][cath]= fDig[i][cath]->PadX();
-           fIy[i][cath]= fDig[i][cath]->PadY();
-           // pad charge
-           fQ[i][cath] = fDig[i][cath]->Signal();
-           // pad centre coordinates
-           fSeg[cath]->
-               GetPadC(fIx[i][cath], fIy[i][cath], fX[i][cath], fY[i][cath], fZ[i][cath]);
-       } // loop over cluster digits
+      qtot=0;
+
+      for (i=0; i<fMul[cath]; i++) {
+       // pointer to digit
+       fDig[i][cath]=fInput->Digit(cath, c->GetIndex(i, cath));
+       // pad coordinates
+       fIx[i][cath]= fDig[i][cath]->PadX();
+       fIy[i][cath]= fDig[i][cath]->PadY();
+       // pad charge
+       fQ[i][cath] = fDig[i][cath]->Signal();
+       // pad centre coordinates
+       if (fSegmentationType == 1)
+         fSeg[cath]->
+           GetPadC(fIx[i][cath], fIy[i][cath], fX[i][cath], fY[i][cath], fZ[i][cath]);
+       else
+         fSeg2[cath]->
+           GetPadC(fInput->DetElemId(), fIx[i][cath], fIy[i][cath], fX[i][cath], fY[i][cath], fZ[i][cath]);
+      } // loop over cluster digits
+
     }  // loop over cathodes
 
 
@@ -146,46 +148,48 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 
        // One local maximum on cathodes 1 and 2 (X->cathode 2, Y->cathode 1)
        if (fNLocal[0]==1 &&  fNLocal[1]==1) {
-           fXInit[0]=c->fX[1];
-           fYInit[0]=c->fY[0];
+           fXInit[0]=c->GetX(1);
+           fYInit[0]=c->GetY(0);
            // One local maximum on cathode 1 (X,Y->cathode 1)
        } else if (fNLocal[0]==1) {
-           fXInit[0]=c->fX[0];
-           fYInit[0]=c->fY[0];
+           fXInit[0]=c->GetX(0);
+           fYInit[0]=c->GetY(0);
            // One local maximum on cathode 2  (X,Y->cathode 2)
        } else {
-           fXInit[0]=c->fX[1];
-           fYInit[0]=c->fY[1];
+           fXInit[0]=c->GetX(1);
+           fYInit[0]=c->GetY(1);
        }
-       if (fDebugLevel)
-           fprintf(stderr,"\n cas (1) CombiSingleMathiesonFit(c)\n");
+       AliDebug(1,"cas (1) CombiSingleMathiesonFit(c)");
        chi2=CombiSingleMathiesonFit(c);
 //     Int_t ndf = fgNbins[0]+fgNbins[1]-2;
 //     Float_t prob = TMath::Prob(Double_t(chi2),ndf);
 //     prob1->Fill(prob);
 //     chi2_1->Fill(chi2);
        oldchi2=chi2;
-       if (fDebugLevel)
-           fprintf(stderr," chi2 %f ",chi2);
+       AliDebug(1,Form(" chi2 %f ",chi2));        
 
-       c->fX[0]=fXFit[0];
-       c->fY[0]=fYFit[0];
+       c->SetX(0, fXFit[0]);
+       c->SetY(0, fYFit[0]);
 
-       c->fX[1]=fXFit[0];
-       c->fY[1]=fYFit[0];
-       c->fChi2[0]=chi2;
-       c->fChi2[1]=chi2;
+       c->SetX(1,fXFit[0]);
+       c->SetY(1,fYFit[0]);
+       c->SetChi2(0,chi2);
+       c->SetChi2(1,chi2);
         // Force on anod
-       c->fX[0]=fSeg[0]->GetAnod(c->fX[0]);
-       c->fX[1]=fSeg[1]->GetAnod(c->fX[1]);
+       if (fSegmentationType == 1) {
+         c->SetX(0, fSeg[0]->GetAnod(c->GetX(0)));
+         c->SetX(1, fSeg[1]->GetAnod(c->GetX(1)));
+       } else {
+         c->SetX(0, fSeg2[0]->GetAnod(fInput->DetElemId(), c->GetX(0)));
+         c->SetX(1, fSeg2[1]->GetAnod(fInput->DetElemId(), c->GetX(1)));
+       }
        
 // If reasonable chi^2 add result to the list of rawclusters
        if (chi2 < 0.3) {
            AddRawCluster(*c);
 // If not try combined double Mathieson Fit
        } else {
-         if (fDebugLevel)
-           fprintf(stderr," MAUVAIS CHI2 !!!\n");
+               AliDebug(1," MAUVAIS CHI2 !!!\n");
            if (fNLocal[0]==1 &&  fNLocal[1]==1) {
                fXInit[0]=fX[fIndLocal[0][1]][1];
                fYInit[0]=fY[fIndLocal[0][0]][0];
@@ -206,8 +210,7 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 //  Initial value for charge ratios
            fQrInit[0]=0.5;
            fQrInit[1]=0.5;
-           if (fDebugLevel)
-           fprintf(stderr,"\n cas (1) CombiDoubleMathiesonFit(c)\n");
+           AliDebug(1,"\n cas (1) CombiDoubleMathiesonFit(c)\n");
            chi2=CombiDoubleMathiesonFit(c);
 //         Int_t ndf = fgNbins[0]+fgNbins[1]-6;
 //         Float_t prob = TMath::Prob(chi2,ndf);
@@ -215,16 +218,13 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 //         chi2_2->Fill(chi2);
            
 // Was this any better ??
-           if (fDebugLevel)
-             fprintf(stderr," Old and new chi2 %f %f ", oldchi2, chi2);
+           AliDebug(1,Form(" Old and new chi2 %f %f ", oldchi2, chi2));
            if (fFitStat!=0 && chi2>0 && (2.*chi2 < oldchi2)) {
-             if (fDebugLevel)
-               fprintf(stderr," Split\n");
+             AliDebug(1,"Split");
                // Split cluster into two according to fit result
                Split(c);
            } else {
-             if (fDebugLevel)
-               fprintf(stderr," Don't Split\n");
+             AliDebug(1,"Do not Split");
                // Don't split
                AddRawCluster(*c);
            }
@@ -278,15 +278,24 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
        for (ico=0; ico<4; ico++) {
            accepted[ico]=kFALSE;
 // cathode one: x-coordinate
-           isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]);
-           dpx=fSeg[0]->Dpx(isec)/2.;
+           if (fSegmentationType == 1) {
+             isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]);
+             dpx=fSeg[0]->Dpx(isec)/2.;
+           } else {
+             isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
+             dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
+           }
            dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
 // cathode two: y-coordinate
-           isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]);
-           dpy=fSeg[1]->Dpy(isec)/2.;
+           if (fSegmentationType == 1) {
+             isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]);
+             dpy=fSeg[1]->Dpy(isec)/2.;
+           } else {
+             isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
+             dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
+           }
            dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
-           if (fDebugLevel>1) 
-               printf("\n %i %f %f %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy, dx, dpx );
+           AliDebug(2,Form("\n %i %f %f %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy, dx, dpx ));
            if ((dx <= dpx) && (dy <= dpy+eps)) {
                // consistent
                accepted[ico]=kTRUE;
@@ -297,8 +306,7 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
                accepted[ico]=kFALSE;
            }
        }
-       if (fDebugLevel)
-         printf("\n iacc= %d:\n", iacc);
+       AliDebug(1,Form("\n iacc= %d:\n", iacc));
        if (iacc == 3) {
            if (accepted[0] && accepted[1]) {
                if (dr[0] >= dr[1]) {
@@ -333,15 +341,13 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
        }
        
        
-       if (fDebugLevel) {
-         printf("\n iacc= %d:\n", iacc);
-           if (iacc==2) {
-               fprintf(stderr,"\n iacc=2: No problem ! \n");
-           } else if (iacc==4) {
-               fprintf(stderr,"\n iacc=4: Ok, but ghost problem !!! \n");
-           } else if (iacc==0) {
-               fprintf(stderr,"\n iacc=0: I don't know what to do with this !!!!!!!!! \n");
-           }
+       AliDebug(1,Form("\n iacc= %d:\n", iacc));
+       if (iacc==2) {
+               AliDebug(1,"\n iacc=2: No problem ! \n");
+       } else if (iacc==4) {
+               AliDebug(1,"\n iacc=4: Ok, but ghost problem !!! \n");
+       } else if (iacc==0) {
+               AliDebug(1,"\n iacc=0: I don't know what to do with this !!!!!!!!! \n");
        }
 
 //  Initial value for charge ratios
@@ -365,39 +371,37 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 // 1 maximum is initialised with the maximum of the combination found (X->cathode 2, Y->cathode 1)
 // 1 maximum is initialised with the other maximum of the first cathode  
            if (accepted[0]){
-               fprintf(stderr,"ico=0\n");
+               AliDebug(1,"ico=0");
                fXInit[0]=xm[0][1];
                fYInit[0]=ym[0][0];
                fXInit[1]=xm[3][0];
                fYInit[1]=ym[3][0];
            } else if (accepted[1]){
-               fprintf(stderr,"ico=1\n");
+               AliDebug(1,"ico=1");
                fXInit[0]=xm[1][1];
                fYInit[0]=ym[1][0];
                fXInit[1]=xm[2][0];
                fYInit[1]=ym[2][0];
            } else if (accepted[2]){
-               fprintf(stderr,"ico=2\n");
+               AliDebug(1,"ico=2");
                fXInit[0]=xm[2][1];
                fYInit[0]=ym[2][0];
                fXInit[1]=xm[1][0];
                fYInit[1]=ym[1][0];
            } else if (accepted[3]){
-               fprintf(stderr,"ico=3\n");
+               AliDebug(1,"ico=3");
                fXInit[0]=xm[3][1];
                fYInit[0]=ym[3][0];
                fXInit[1]=xm[0][0];
                fYInit[1]=ym[0][0];
            }
-           if (fDebugLevel)
-               fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
+               AliDebug(1,"cas (2) CombiDoubleMathiesonFit(c)");
            chi2=CombiDoubleMathiesonFit(c);
 //         Int_t ndf = fgNbins[0]+fgNbins[1]-6;
 //         Float_t prob = TMath::Prob(chi2,ndf);
 //         prob2->Fill(prob);
 //         chi2_2->Fill(chi2);
-           if (fDebugLevel)
-               fprintf(stderr," chi2 %f\n",chi2);
+           AliDebug(1,Form(" chi2 %f\n",chi2));
 
 // If reasonable chi^2 add result to the list of rawclusters
            if (chi2<10) {
@@ -407,39 +411,37 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 // 1 maximum is initialised with the maximum of the combination found (X->cathode 2, Y->cathode 1)
 // 1 maximum is initialised with the other maximum of the second cathode  
                if (accepted[0]){
-                   fprintf(stderr,"ico=0\n");
+                       AliDebug(1,"ico=0");
                    fXInit[0]=xm[0][1];
                    fYInit[0]=ym[0][0];
                    fXInit[1]=xm[3][1];
                    fYInit[1]=ym[3][1];
                } else if (accepted[1]){
-                   fprintf(stderr,"ico=1\n");
+                       AliDebug(1,"ico=1");
                    fXInit[0]=xm[1][1];
                    fYInit[0]=ym[1][0];
                    fXInit[1]=xm[2][1];
                    fYInit[1]=ym[2][1];
                } else if (accepted[2]){
-                   fprintf(stderr,"ico=2\n");
+                       AliDebug(1,"ico=2");
                    fXInit[0]=xm[2][1];
                    fYInit[0]=ym[2][0];
                    fXInit[1]=xm[1][1];
                    fYInit[1]=ym[1][1];
                } else if (accepted[3]){
-                   fprintf(stderr,"ico=3\n");
+                       AliDebug(1,"ico=3");
                    fXInit[0]=xm[3][1];
                    fYInit[0]=ym[3][0];
                    fXInit[1]=xm[0][1];
                    fYInit[1]=ym[0][1];
                }
-               if (fDebugLevel)
-                   fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
+               AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
                chi2=CombiDoubleMathiesonFit(c);
 //             Int_t ndf = fgNbins[0]+fgNbins[1]-6;
 //             Float_t prob = TMath::Prob(chi2,ndf);
 //             prob2->Fill(prob);
 //             chi2_2->Fill(chi2);
-               if (fDebugLevel)
-                   fprintf(stderr," chi2 %f\n",chi2);
+               AliDebug(1,Form(" chi2 %f\n",chi2));
 
 // If reasonable chi^2 add result to the list of rawclusters
                if (chi2<10) {
@@ -451,20 +453,23 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
                            AliMUONRawCluster cnew;
                            Int_t cath;    
                            for (cath=0; cath<2; cath++) {
-                               cnew.fX[cath]=Float_t(xm[ico][1]);
-                               cnew.fY[cath]=Float_t(ym[ico][0]);
-                               cnew.fZ[cath]=fZPlane;
+                               cnew.SetX(cath, Float_t(xm[ico][1]));
+                               cnew.SetY(cath, Float_t(ym[ico][0]));
+                               cnew.SetZ(cath, fZPlane);
                                
-                               cnew.fMultiplicity[cath]=c->fMultiplicity[cath];
+                               cnew.SetMultiplicity(cath,c->GetMultiplicity(cath));
                                for (i=0; i<fMul[cath]; i++) {
-                                   cnew.fIndexMap[i][cath]=c->fIndexMap[i][cath];
+                                 cnew.SetIndex(i, cath, c->GetIndex(i,cath));
+                                 if (fSegmentationType == 1) 
                                    fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]);
+                                 else 
+                                   fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
                                }
-                               fprintf(stderr,"\nRawCluster %d cath %d\n",ico,cath);
-                               fprintf(stderr,"mult_av %d\n",c->fMultiplicity[cath]);
+                               AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
+                               AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
                                FillCluster(&cnew,cath);
                            } 
-                           cnew.fClusterType=cnew.PhysicsContribution();
+                           cnew.SetClusterType(cnew.PhysicsContribution());
                            AddRawCluster(cnew);
                            fNPeaks++;
                        }
@@ -478,7 +483,7 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
        if (iacc==2) {
 // Was the same maximum taken twice
            if ((accepted[0]&&accepted[1]) || (accepted[2]&&accepted[3])) {
-               fprintf(stderr,"\n Maximum taken twice !!!\n");
+               AliDebug(1,"\n Maximum taken twice !!!\n");
 
 // Have a try !! with that
                if (accepted[0]&&accepted[3]) {
@@ -492,8 +497,7 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
                    fXInit[1]=xm[3][1];
                    fYInit[1]=ym[3][0];
                }
-               if (fDebugLevel)
-                   fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
+               AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
                chi2=CombiDoubleMathiesonFit(c);
 //                 Int_t ndf = fgNbins[0]+fgNbins[1]-6;
 //                 Float_t prob = TMath::Prob(chi2,ndf);
@@ -514,15 +518,13 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
                    fXInit[1]=xm[2][1];
                    fYInit[1]=ym[2][0];
                }
-               if (fDebugLevel)
-                   fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
+               AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
                chi2=CombiDoubleMathiesonFit(c);
 //                 Int_t ndf = fgNbins[0]+fgNbins[1]-6;
 //                 Float_t prob = TMath::Prob(chi2,ndf);
 //                 prob2->Fill(prob);
 //                 chi2_2->Fill(chi2);
-               if (fDebugLevel)
-                   fprintf(stderr," chi2 %f\n",chi2);
+               AliDebug(1,Form(" chi2 %f\n",chi2));
                Split(c);
            }
            
@@ -537,15 +539,13 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
            fYInit[0]=ym[0][0];
            fXInit[1]=xm[3][1];
            fYInit[1]=ym[3][0];
-           if (fDebugLevel)
-               fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
+           AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
            chi2=CombiDoubleMathiesonFit(c);
 //             Int_t ndf = fgNbins[0]+fgNbins[1]-6;
 //             Float_t prob = TMath::Prob(chi2,ndf);
 //             prob2->Fill(prob);
 //             chi2_2->Fill(chi2);
-           if (fDebugLevel)
-               fprintf(stderr," chi2 %f\n",chi2);
+           AliDebug(1,Form(" chi2 %f\n",chi2));
            // store results of fit and postpone decision
            Double_t sXFit[2],sYFit[2],sQrFit[2];
            Float_t sChi2[2];
@@ -559,35 +559,33 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
            fYInit[0]=ym[1][0];
            fXInit[1]=xm[2][1];
            fYInit[1]=ym[2][0];
-           if (fDebugLevel)
-               fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
+           AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
            chi2=CombiDoubleMathiesonFit(c);
 //             ndf = fgNbins[0]+fgNbins[1]-6;
 //             prob = TMath::Prob(chi2,ndf);
 //             prob2->Fill(prob);
 //             chi2_2->Fill(chi2);
-           if (fDebugLevel)
-               fprintf(stderr," chi2 %f\n",chi2);
+           AliDebug(1,Form(" chi2 %f\n",chi2));
            // We have all informations to perform the decision
            // Compute the chi2 for the 2 possibilities
            Float_t chi2fi,chi2si,chi2f,chi2s;
 
            chi2f = (TMath::Log(fInput->TotalCharge(0)*fQrFit[0]
                  /  (fInput->TotalCharge(1)*fQrFit[1]) )
-                 / fInput->Response()->ChargeCorrel() );
+                 / fInput->ChargeCorrel() );
            chi2f *=chi2f;
            chi2fi = (TMath::Log(fInput->TotalCharge(0)*(1-fQrFit[0])
                  /  (fInput->TotalCharge(1)*(1-fQrFit[1])) )
-                 / fInput->Response()->ChargeCorrel() );
+                 / fInput->ChargeCorrel() );
            chi2f += chi2fi*chi2fi;
 
            chi2s = (TMath::Log(fInput->TotalCharge(0)*sQrFit[0]
                  /  (fInput->TotalCharge(1)*sQrFit[1]) )
-                 / fInput->Response()->ChargeCorrel() );
+                 / fInput->ChargeCorrel() );
            chi2s *=chi2s;
            chi2si = (TMath::Log(fInput->TotalCharge(0)*(1-sQrFit[0])
                  /  (fInput->TotalCharge(1)*(1-sQrFit[1])) )
-                 / fInput->Response()->ChargeCorrel() );
+                 / fInput->ChargeCorrel() );
            chi2s += chi2si*chi2si;
 
            // usefull to store the charge matching chi2 in the cluster
@@ -595,10 +593,10 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
            // fChi2[1]=sChi2[0]=chi2s;
 
            if (chi2f<=fGhostChi2Cut && chi2s<=fGhostChi2Cut)
-               c->fGhost=1;
+               c->SetGhost(1);
            if   (chi2f>fGhostChi2Cut && chi2s>fGhostChi2Cut) {
                // we keep the ghost
-               c->fGhost=2;
+               c->SetGhost(2);
                chi2s=-1;
                chi2f=-1;
            }
@@ -614,7 +612,7 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
                }
                Split(c);
            }
-           c->fGhost=0;
+           c->SetGhost(0);
        }
 
     } else if (fNLocal[0]==2 &&  fNLocal[1]==1) {
@@ -657,14 +655,23 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 
        for (ico=0; ico<2; ico++) {
            accepted[ico]=kFALSE;
-           isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]);
-           dpx=fSeg[0]->Dpx(isec)/2.;
+           if (fSegmentationType == 1) {
+             isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]);
+             dpx=fSeg[0]->Dpx(isec)/2.;
+           } else {
+             isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
+             dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
+           }
            dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
-           isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]);
-           dpy=fSeg[1]->Dpy(isec)/2.;
+           if (fSegmentationType == 1) {
+             isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]);
+             dpy=fSeg[1]->Dpy(isec)/2.;
+           } else {
+             isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
+             dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
+           }
            dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
-           if (fDebugLevel>1)
-               printf("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy );
+           AliDebug(2,Form("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy ));
            if ((dx <= dpx) && (dy <= dpy+eps)) {
                // consistent
                accepted[ico]=kTRUE;
@@ -711,8 +718,7 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 //         Float_t prob = TMath::Prob(chi2,ndf);
 //         prob2->Fill(prob);
 //         chi2_2->Fill(chi21);
-           if (fDebugLevel)
-               fprintf(stderr," chi2 %f\n",chi21);
+           AliDebug(1,Form(" chi2 %f\n",chi21));
            if (chi21<10) Split(c);
        } else if (accepted[1]) {
            fXInit[0]=xm[1][1];
@@ -724,8 +730,7 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 //         Float_t prob = TMath::Prob(chi2,ndf);
 //         prob2->Fill(prob);
 //         chi2_2->Fill(chi22);
-           if (fDebugLevel)
-               fprintf(stderr," chi2 %f\n",chi22);
+           AliDebug(1,Form(" chi2 %f\n",chi22));
            if (chi22<10) Split(c);
        }
 
@@ -736,19 +741,24 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
                    AliMUONRawCluster cnew;
                    Int_t cath;    
                    for (cath=0; cath<2; cath++) {
-                       cnew.fX[cath]=Float_t(xm[ico][1]);
-                       cnew.fY[cath]=Float_t(ym[ico][0]);
-                       cnew.fZ[cath]=fZPlane;
-                       cnew.fMultiplicity[cath]=c->fMultiplicity[cath];
+                       cnew.SetX(cath, Float_t(xm[ico][1]));
+                       cnew.SetY(cath, Float_t(ym[ico][0]));
+                       cnew.SetZ(cath, fZPlane);
+                       cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
                        for (i=0; i<fMul[cath]; i++) {
-                           cnew.fIndexMap[i][cath]=c->fIndexMap[i][cath];
-                           fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]);
+                           cnew.SetIndex(i, cath, c->GetIndex(i, cath));
+                           if (fSegmentationType == 1) 
+                             fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]);
+                           else
+                             fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
+
                        }
-                       fprintf(stderr,"\nRawCluster %d cath %d\n",ico,cath);
-                       fprintf(stderr,"mult_av %d\n",c->fMultiplicity[cath]);
+                       AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
+                       AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
+                       
                        FillCluster(&cnew,cath);
                    } 
-                   cnew.fClusterType=cnew.PhysicsContribution();
+                   cnew.SetClusterType(cnew.PhysicsContribution());
                    AddRawCluster(cnew);
                    fNPeaks++;
                }
@@ -794,18 +804,27 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
        
        for (ico=0; ico<2; ico++) {
            accepted[ico]=kFALSE;
-           isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]);
-           dpx=fSeg[0]->Dpx(isec)/2.;
+           if (fSegmentationType == 1) {
+             isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]);
+             dpx=fSeg[0]->Dpx(isec)/2.;
+           } else {
+             isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
+             dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
+           }
            dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
-           isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]);
-           dpy=fSeg[1]->Dpy(isec)/2.;
+           if (fSegmentationType == 1) {
+             isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]);
+             dpy=fSeg[1]->Dpy(isec)/2.;
+           } else {
+             isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
+             dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
+           }
            dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
-           if (fDebugLevel>0)
-               printf("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy );
+           AliDebug(1,Form("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy ));
            if ((dx <= dpx) && (dy <= dpy+eps)) {
                // consistent
                accepted[ico]=kTRUE;
-               fprintf(stderr,"ico %d\n",ico);
+               AliDebug(1,Form("ico %d\n",ico));
                iacc++;
            } else {
                // reject
@@ -849,8 +868,7 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 //         Float_t prob = TMath::Prob(chi2,ndf);
 //         prob2->Fill(prob);
 //         chi2_2->Fill(chi21);
-           if (fDebugLevel)
-               fprintf(stderr," chi2 %f\n",chi21);
+           AliDebug(1,Form(" chi2 %f\n",chi21));
            if (chi21<10) Split(c);
        } else if (accepted[1]) {
            fXInit[0]=xm[1][0];
@@ -862,8 +880,7 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 //         Float_t prob = TMath::Prob(chi2,ndf);
 //         prob2->Fill(prob);
 //         chi2_2->Fill(chi22);
-           if (fDebugLevel)
-               fprintf(stderr," chi2 %f\n",chi22);
+           AliDebug(1,Form(" chi2 %f\n",chi22));
            if (chi22<10) Split(c);
        }
 
@@ -874,19 +891,22 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
                    AliMUONRawCluster cnew;
                    Int_t cath;    
                    for (cath=0; cath<2; cath++) {
-                       cnew.fX[cath]=Float_t(xm[ico][1]);
-                       cnew.fY[cath]=Float_t(ym[ico][0]);
-                       cnew.fZ[cath]=fZPlane;
-                       cnew.fMultiplicity[cath]=c->fMultiplicity[cath];
+                       cnew.SetX(cath, Float_t(xm[ico][1]));
+                       cnew.SetY(cath, Float_t(ym[ico][0]));
+                       cnew.SetZ(cath, fZPlane);
+                       cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
                        for (i=0; i<fMul[cath]; i++) {
-                           cnew.fIndexMap[i][cath]=c->fIndexMap[i][cath];
-                           fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]);
+                           cnew.SetIndex(i, cath, c->GetIndex(i, cath));
+                           if (fSegmentationType == 1) 
+                             fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]);
+                           else 
+                             fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
                        }
-                       fprintf(stderr,"\nRawCluster %d cath %d\n",ico,cath);
-                       fprintf(stderr,"mult_av %d\n",c->fMultiplicity[cath]);
+                       AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
+                       AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
                        FillCluster(&cnew,cath);
                    } 
-                   cnew.fClusterType=cnew.PhysicsContribution();
+                   cnew.SetClusterType(cnew.PhysicsContribution());
                    AddRawCluster(cnew);
                    fNPeaks++;
                }
@@ -929,38 +949,46 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
        }
        
        Int_t nIco = ico;
-       if (fDebugLevel)
-           fprintf(stderr,"nIco %d\n",nIco);
+       AliDebug(1,Form("nIco %d\n",nIco));
        for (ico=0; ico<nIco; ico++) {
-           if (fDebugLevel)
-               fprintf(stderr,"ico = %d\n",ico);
-           isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]);
-           dpx=fSeg[0]->Dpx(isec)/2.;
+           AliDebug(1,Form("ico = %d\n",ico));
+           if (fSegmentationType == 1) {
+             isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]);
+             dpx=fSeg[0]->Dpx(isec)/2.;
+           } else {
+             isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
+             dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
+           } 
            dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
-           isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]);
-           dpy=fSeg[1]->Dpy(isec)/2.;
-           dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
-           if (fDebugLevel) {
-               fprintf(stderr,"dx %f dpx %f dy %f dpy %f\n",dx,dpx,dy,dpy);
-               fprintf(stderr,"  X %f Y %f\n",xm[ico][1],ym[ico][0]);
+           if (fSegmentationType == 1) {
+             isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]);
+             dpy=fSeg[1]->Dpy(isec)/2.;
+           } else {
+             isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
+             dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
            }
+           dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
+               AliDebug(1,Form("dx %f dpx %f dy %f dpy %f\n",dx,dpx,dy,dpy));
+               AliDebug(1,Form("  X %f Y %f\n",xm[ico][1],ym[ico][0]));
            if ((dx <= dpx) && (dy <= dpy)) {
-               if (fDebugLevel)
-                   fprintf(stderr,"ok\n");
+                       AliDebug(1,"ok\n");
                Int_t cath;    
                AliMUONRawCluster cnew;
                for (cath=0; cath<2; cath++) {
-                   cnew.fX[cath]=Float_t(xm[ico][1]);
-                   cnew.fY[cath]=Float_t(ym[ico][0]);
-                   cnew.fZ[cath]=fZPlane;
-                   cnew.fMultiplicity[cath]=c->fMultiplicity[cath];
+                   cnew.SetX(cath, Float_t(xm[ico][1]));
+                   cnew.SetY(cath, Float_t(ym[ico][0]));
+                   cnew.SetZ(cath, fZPlane);
+                   cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
                    for (i=0; i<fMul[cath]; i++) {
-                       cnew.fIndexMap[i][cath]=c->fIndexMap[i][cath];
-                       fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]);
+                       cnew.SetIndex(i, cath, c->GetIndex(i, cath));
+                       if (fSegmentationType == 1) 
+                         fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]);
+                       else 
+                         fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
                    }
                    FillCluster(&cnew,cath);
                } 
-               cnew.fClusterType=cnew.PhysicsContribution();
+               cnew.SetClusterType(cnew.PhysicsContribution());
                AddRawCluster(cnew);
                fNPeaks++;
            }
@@ -975,8 +1003,7 @@ void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
 void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
 {
 // Find all local maxima of a cluster
-    if (fDebugLevel)
-       printf("\n Find Local maxima  !");
+    AliDebug(1,"\n Find Local maxima  !");
     
     AliMUONDigit* digt;
     
@@ -996,52 +1023,69 @@ void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
 //  number of next neighbours and arrays to store them 
     Int_t nn;
     Int_t x[10], y[10];
-// loop over cathodes
+    // loop over cathodes
     for (cath=0; cath<2; cath++) {
-// loop over cluster digits
-       for (i=0; i<fMul[cath]; i++) {
-// get neighbours for that digit and assume that it is local maximum       
-           fSeg[cath]->Neighbours(fIx[i][cath], fIy[i][cath], &nn, x, y);
-           isLocal[i][cath]=kTRUE;
-           Int_t isec= fSeg[cath]->Sector(fIx[i][cath], fIy[i][cath]);
-           Float_t a0 = fSeg[cath]->Dpx(isec)*fSeg[cath]->Dpy(isec);
-// loop over next neighbours, if at least one neighbour has higher charger assumption
-// digit is not local maximum 
-           for (j=0; j<nn; j++) {
-               if (fHitMap[cath]->TestHit(x[j], y[j])==kEmpty) continue;
-               digt=(AliMUONDigit*) fHitMap[cath]->GetHit(x[j], y[j]);
-               isec=fSeg[cath]->Sector(x[j], y[j]);
-               Float_t a1 = fSeg[cath]->Dpx(isec)*fSeg[cath]->Dpy(isec);
-               if (digt->Signal()/a1 > fQ[i][cath]/a0) {
+      // loop over cluster digits
+      for (i=0; i<fMul[cath]; i++) {
+       // get neighbours for that digit and assume that it is local maximum
+       Int_t isec;
+       Float_t a0;
+
+       if (fSegmentationType == 1)         
+         fSeg[cath]->Neighbours(fIx[i][cath], fIy[i][cath], &nn, x, y);
+       else 
+         fSeg2[cath]->Neighbours(fInput->DetElemId(), fIx[i][cath], fIy[i][cath], &nn, x, y);
+         
+       isLocal[i][cath]=kTRUE;
+
+       if (fSegmentationType == 1) {
+         isec = fSeg[cath]->Sector(fIx[i][cath], fIy[i][cath]);
+         a0   = fSeg[cath]->Dpx(isec)*fSeg[cath]->Dpy(isec);
+       } else {
+         isec = fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
+         a0   = fSeg2[cath]->Dpx(fInput->DetElemId(), isec)*fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
+       }
+       // loop over next neighbours, if at least one neighbour has higher charger assumption
+       // digit is not local maximum 
+       for (j=0; j<nn; j++) {
+         if (fHitMap[cath]->TestHit(x[j], y[j])==kEmpty) continue;
+         digt=(AliMUONDigit*) fHitMap[cath]->GetHit(x[j], y[j]);
+         Float_t a1;
+         if (fSegmentationType == 1) {
+           isec=fSeg[cath]->Sector(x[j], y[j]);
+           a1 = fSeg[cath]->Dpx(isec)*fSeg[cath]->Dpy(isec);
+         } else {
+           isec=fSeg2[cath]->Sector(fInput->DetElemId(), x[j], y[j]);
+           a1 = fSeg2[cath]->Dpx(fInput->DetElemId(),isec)*fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
+         }
+         if (digt->Signal()/a1 > fQ[i][cath]/a0) {
+           isLocal[i][cath]=kFALSE;
+           break;
+           //
+           // handle special case of neighbouring pads with equal signal
+         } else if (digt->Signal() == fQ[i][cath]) {
+           if (fNLocal[cath]>0) {
+             for (Int_t k=0; k<fNLocal[cath]; k++) {
+               if (x[j]==fIx[fIndLocal[k][cath]][cath] 
+                   && y[j]==fIy[fIndLocal[k][cath]][cath])
+                 {
                    isLocal[i][cath]=kFALSE;
-                   break;
-//
-// handle special case of neighbouring pads with equal signal
-               } else if (digt->Signal() == fQ[i][cath]) {
-                   if (fNLocal[cath]>0) {
-                       for (Int_t k=0; k<fNLocal[cath]; k++) {
-                           if (x[j]==fIx[fIndLocal[k][cath]][cath] 
-                               && y[j]==fIy[fIndLocal[k][cath]][cath])
-                           {
-                               isLocal[i][cath]=kFALSE;
-                           } 
-                       } // loop over local maxima
-                   } // are there already local maxima
-               } // same charge ? 
-           } // loop over next neighbours
-           if (isLocal[i][cath]) {
-               fIndLocal[fNLocal[cath]][cath]=i;
-               fNLocal[cath]++;
-           } 
-       } // loop over all digits
+                 } 
+             } // loop over local maxima
+           } // are there already local maxima
+         } // same charge ? 
+       } // loop over next neighbours
+       if (isLocal[i][cath]) {
+         fIndLocal[fNLocal[cath]][cath]=i;
+         fNLocal[cath]++;
+       } 
+      } // loop over all digits
     } // loop over cathodes
 
-    if (fDebugLevel) {
-       printf("\n Found %d %d %d %d local Maxima\n",
-              fNLocal[0], fNLocal[1], fMul[0], fMul[1]);
-       fprintf(stderr,"\n Cathode 1 local Maxima %d Multiplicite %d\n",fNLocal[0], fMul[0]);
-       fprintf(stderr," Cathode 2 local Maxima %d Multiplicite %d\n",fNLocal[1], fMul[1]);
-    }
+    AliDebug(1,Form("\n Found %d %d %d %d local Maxima\n",
+              fNLocal[0], fNLocal[1], fMul[0], fMul[1]));
+       AliDebug(1,Form("\n Cathode 1 local Maxima %d Multiplicite %d\n",fNLocal[0], fMul[0]));
+       AliDebug(1,Form(" Cathode 2 local Maxima %d Multiplicite %d\n",fNLocal[1], fMul[1]));
     Int_t ix, iy, isec;
     Float_t dpx, dpy;
     
@@ -1057,9 +1101,15 @@ void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
        cath1=1;
        
        for (i=0; i<fMul[cath]; i++) {
+         if (fSegmentationType == 1) {
            isec=fSeg[cath]->Sector(fIx[i][cath],fIy[i][cath]);
            dpy=fSeg[cath]->Dpy(isec);
            dpx=fSeg[cath]->Dpx(isec);
+         } else {
+           isec=fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath],fIy[i][cath]);
+           dpy=fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
+           dpx=fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
+         }
            if (isLocal[i][cath]) continue;
 // Pad position should be consistent with position of local maxima on the opposite cathode
            if ((TMath::Abs(fX[i][cath]-fX[fIndLocal[0][cath1]][cath1]) > dpx/2.) && 
@@ -1071,25 +1121,41 @@ void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
 // compare signal to that on the two neighbours on the left and on the right
 // iNN counts the number of neighbours with signal, it should be 1 or 2
            Int_t iNN=0;
+           if (fSegmentationType == 1) {
+
+             for (fSeg[cath]->FirstPad(fX[i][cath], fY[i][cath], fZPlane, 0., dpy);
+                  fSeg[cath]->MorePads();
+                  fSeg[cath]->NextPad())
+               {
+                 ix = fSeg[cath]->Ix();
+                 iy = fSeg[cath]->Iy();
+                 // skip the current pad
+                 if (iy == fIy[i][cath]) continue;
+               
+                 if (fHitMap[cath]->TestHit(ix, iy)!=kEmpty) {
+                   iNN++;
+                   digt=(AliMUONDigit*) fHitMap[cath]->GetHit(ix,iy);
+                   if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE;
+                 }
+               } // Loop over pad neighbours in y
+           } else {
 
-           for (fSeg[cath]
-                    ->FirstPad(fX[i][cath], fY[i][cath], fZPlane, 0., dpy);
-                fSeg[cath]
-                    ->MorePads();
-                fSeg[cath]
-                    ->NextPad())
-           {
-               ix = fSeg[cath]->Ix();
-               iy = fSeg[cath]->Iy();
-               // skip the current pad
-               if (iy == fIy[i][cath]) continue;
+             for (fSeg2[cath]->FirstPad(fInput->DetElemId(), fX[i][cath], fY[i][cath], fZPlane, 0., dpy);
+                  fSeg2[cath]->MorePads(fInput->DetElemId());
+                  fSeg2[cath]->NextPad(fInput->DetElemId()))
+               {
+                 ix = fSeg2[cath]->Ix();
+                 iy = fSeg2[cath]->Iy();
+                 // skip the current pad
+                 if (iy == fIy[i][cath]) continue;
                
-               if (fHitMap[cath]->TestHit(ix, iy)!=kEmpty) {
+                 if (fHitMap[cath]->TestHit(ix, iy)!=kEmpty) {
                    iNN++;
                    digt=(AliMUONDigit*) fHitMap[cath]->GetHit(ix,iy);
                    if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE;
-               }
-           } // Loop over pad neighbours in y
+                 }
+               } // Loop over pad neighbours in y
+           }
            if (isLocal[i][cath] && iNN>0) {
                fIndLocal[fNLocal[cath]][cath]=i;
                fNLocal[cath]++;
@@ -1097,14 +1163,10 @@ void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
        } // loop over all digits
 // if one additional maximum has been found we are happy 
 // if more maxima have been found restore the previous situation
-       if (fDebugLevel) {
-           fprintf(stderr,
-                   "\n New search gives %d local maxima for cathode 1 \n",
-                   fNLocal[0]);
-           fprintf(stderr,
-                   "                  %d local maxima for cathode 2 \n",
-                   fNLocal[1]);
-       }
+       AliDebug(1,Form("\n New search gives %d local maxima for cathode 1 \n",
+                   fNLocal[0]));
+       AliDebug(1,Form("                  %d local maxima for cathode 2 \n",
+                   fNLocal[1]));
        if (fNLocal[cath]>2) {
            fNLocal[cath]=iback;
        }
@@ -1123,9 +1185,16 @@ void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
 //
 //  Loop over cluster digits
        for (i=0; i<fMul[cath]; i++) {
+         if (fSegmentationType == 1) {
            isec=fSeg[cath]->Sector(fIx[i][cath],fIy[i][cath]);
            dpx=fSeg[cath]->Dpx(isec);
            dpy=fSeg[cath]->Dpy(isec);
+         } else {
+           isec=fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath],fIy[i][cath]);
+           dpx=fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
+           dpy=fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
+         }
+       
            if (isLocal[i][cath]) continue;
 // Pad position should be consistent with position of local maxima on the opposite cathode
            if ((TMath::Abs(fY[i][cath]-fY[fIndLocal[0][cath1]][cath1]) > dpy/2.+eps) && 
@@ -1139,26 +1208,43 @@ void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
 
 // iNN counts the number of neighbours with signal, it should be 1 or 2
            Int_t iNN=0;
-           for (fSeg[cath]
-                    ->FirstPad(fX[i][cath], fY[i][cath], fZPlane, dpx, 0.);
-                fSeg[cath]
-                    ->MorePads();
-                fSeg[cath]
-                    ->NextPad())
-           {
-
-               ix = fSeg[cath]->Ix();
-               iy = fSeg[cath]->Iy();
-
-               // skip the current pad
-               if (ix == fIx[i][cath]) continue;
+           if (fSegmentationType == 1) {
+             for (fSeg[cath]->FirstPad(fX[i][cath], fY[i][cath], fZPlane, dpx, 0.);
+                  fSeg[cath]->MorePads();
+                  fSeg[cath]->NextPad())
+               {
+
+                 ix = fSeg[cath]->Ix();
+                 iy = fSeg[cath]->Iy();
+
+                 // skip the current pad
+                 if (ix == fIx[i][cath]) continue;
                
-               if (fHitMap[cath]->TestHit(ix, iy)!=kEmpty) {
+                 if (fHitMap[cath]->TestHit(ix, iy)!=kEmpty) {
                    iNN++;
                    digt=(AliMUONDigit*) fHitMap[cath]->GetHit(ix,iy);
                    if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE;
-               }
-           } // Loop over pad neighbours in x
+                 }
+               } // Loop over pad neighbours in x
+           } else {
+             for (fSeg2[cath]->FirstPad(fInput->DetElemId(), fX[i][cath], fY[i][cath], fZPlane, dpx, 0.);
+                  fSeg2[cath]->MorePads(fInput->DetElemId());
+                  fSeg2[cath]->NextPad(fInput->DetElemId()))
+               {
+
+                 ix = fSeg2[cath]->Ix();
+                 iy = fSeg2[cath]->Iy();
+
+                 // skip the current pad
+                 if (ix == fIx[i][cath]) continue;
+               
+                 if (fHitMap[cath]->TestHit(ix, iy)!=kEmpty) {
+                   iNN++;
+                   digt=(AliMUONDigit*) fHitMap[cath]->GetHit(ix,iy);
+                   if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE;
+                 }
+               } // Loop over pad neighbours in x
+           }
            if (isLocal[i][cath] && iNN>0) {
                fIndLocal[fNLocal[cath]][cath]=i;
                fNLocal[cath]++;
@@ -1166,11 +1252,9 @@ void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
        } // loop over all digits
 // if one additional maximum has been found we are happy 
 // if more maxima have been found restore the previous situation
-       if (fDebugLevel) {
-           fprintf(stderr,"\n New search gives %d local maxima for cathode 1 \n",fNLocal[0]);
-           fprintf(stderr,"\n                  %d local maxima for cathode 2 \n",fNLocal[1]);
-           printf("\n New search gives %d %d \n",fNLocal[0],fNLocal[1]);
-       }
+       AliDebug(1,Form("\n New search gives %d local maxima for cathode 1 \n",fNLocal[0]));
+       AliDebug(1,Form("\n                  %d local maxima for cathode 2 \n",fNLocal[1]));
+       AliDebug(1,Form("\n New search gives %d %d \n",fNLocal[0],fNLocal[1]));
        if (fNLocal[cath]>2) {
            fNLocal[cath]=iback;
        }
@@ -1188,75 +1272,93 @@ void  AliMUONClusterFinderVS::FillCluster(AliMUONRawCluster* c, Int_t flag, Int_
     Int_t  ix, iy;
     
     if (cath==1) {
-       c->fPeakSignal[cath]=c->fPeakSignal[0]; 
+       c->SetPeakSignal(cath,c->GetPeakSignal(0));     
     } else {
-       c->fPeakSignal[cath]=0;
+       c->SetPeakSignal(cath,0);
     }
     
     
     if (flag) {
-       c->fX[cath]=0;
-       c->fY[cath]=0;
-       c->fQ[cath]=0;
+       c->SetX(cath,0.);
+       c->SetY(cath,0.);
+       c->SetCharge(cath,0);
     }
 
-    if (fDebugLevel)
-       fprintf(stderr,"\n fPeakSignal %d\n",c->fPeakSignal[cath]);
-    for (Int_t i=0; i<c->fMultiplicity[cath]; i++)
+    AliDebug(1,Form("\n fPeakSignal %d\n",c->GetPeakSignal(cath)));
+    for (Int_t i=0; i<c->GetMultiplicity(cath); i++)
     {
-       dig= fInput->Digit(cath,c->fIndexMap[i][cath]);
-       ix=dig->PadX()+c->fOffsetMap[i][cath];
+       dig= fInput->Digit(cath,c->GetIndex(i,cath));
+       ix=dig->PadX()+c->GetOffset(i,cath);
        iy=dig->PadY();
        Int_t q=dig->Signal();
-       if (!flag) q=Int_t(q*c->fContMap[i][cath]);
+       if (!flag) q=Int_t(q*c->GetContrib(i,cath));
 //     fprintf(stderr,"q %d c->fPeakSignal[ %d ] %d\n",q,cath,c->fPeakSignal[cath]);
        if (dig->Physics() >= dig->Signal()) {
-           c->fPhysicsMap[i]=2;
+           c->SetPhysics(i,2);
        } else if (dig->Physics() == 0) {
-           c->fPhysicsMap[i]=0;
-       } else  c->fPhysicsMap[i]=1;
+           c->SetPhysics(i,0);
+       } else  c->SetPhysics(i,1);
 //
 // 
-       if (fDebugLevel>1)
-           fprintf(stderr,"q %d c->fPeakSignal[cath] %d\n",q,c->fPeakSignal[cath]);
+       AliDebug(2,Form("q %d c->fPeakSignal[cath] %d\n",q,c->GetPeakSignal(cath)));
 // peak signal and track list
-       if (q>c->fPeakSignal[cath]) {
-           c->fPeakSignal[cath]=q;
-           c->fTracks[0]=dig->Hit();
-           c->fTracks[1]=dig->Track(0);
-           c->fTracks[2]=dig->Track(1);
+       if (q>c->GetPeakSignal(cath)) {
+           c->SetPeakSignal(cath, q);
+           c->SetTrack(0,dig->Hit());
+           c->SetTrack(1,dig->Track(0));
+           c->SetTrack(2,dig->Track(1));
 //         fprintf(stderr," c->fTracks[0] %d c->fTracks[1] %d\n",dig->fHit,dig->fTracks[0]);
        }
 //
        if (flag) {
+         if (fSegmentationType == 1) 
            fSeg[cath]->GetPadC(ix, iy, x, y, z);
-           c->fX[cath] += q*x;
-           c->fY[cath] += q*y;
-           c->fQ[cath] += q;
+         else
+           fSeg2[cath]->GetPadC(fInput->DetElemId(), ix, iy, x, y, z);
+       
+           c->AddX(cath, q*x);
+           c->AddY(cath, q*y);
+           c->AddCharge(cath, q);
        }
     } // loop over digits
-    if (fDebugLevel)
-       fprintf(stderr," fin du cluster c\n");
+    AliDebug(1," fin du cluster c\n");
 
 
     if (flag) {
-       c->fX[cath]/=c->fQ[cath];
+       c->SetX(cath, c->GetX(cath)/c->GetCharge(cath));
 // Force on anod
-       c->fX[cath]=fSeg[cath]->GetAnod(c->fX[cath]);
-       c->fY[cath]/=c->fQ[cath]; 
+       if (fSegmentationType == 1) 
+         c->SetX(cath, fSeg[cath]->GetAnod(c->GetX(cath)));
+       else
+         c->SetX(cath, fSeg2[cath]->GetAnod(fInput->DetElemId(), c->GetX(cath)));
+       c->SetY(cath, c->GetY(cath)/c->GetCharge(cath)); 
 //
 //  apply correction to the coordinate along the anode wire
 //
-       x=c->fX[cath];   
-       y=c->fY[cath];
-       fSeg[cath]->GetPadI(x, y, fZPlane, ix, iy);
-       fSeg[cath]->GetPadC(ix, iy, x, y, z);
-       Int_t isec=fSeg[cath]->Sector(ix,iy);
-       TF1* cogCorr = fSeg[cath]->CorrFunc(isec-1);
+       x=c->GetX(cath);   
+       y=c->GetY(cath);
+       TF1* cogCorr;
+       Int_t isec;
+       if (fSegmentationType == 1) {
+         fSeg[cath]->GetPadI(x, y, fZPlane, ix, iy);
+         fSeg[cath]->GetPadC(ix, iy, x, y, z);
+         isec=fSeg[cath]->Sector(ix,iy);
+         cogCorr = fSeg[cath]->CorrFunc(isec-1);
+       } else {
+         fSeg2[cath]->GetPadI(fInput->DetElemId(), x, y, fZPlane, ix, iy);
+         fSeg2[cath]->GetPadC(fInput->DetElemId(), ix, iy, x, y, z);
+         isec=fSeg2[cath]->Sector(fInput->DetElemId(), ix,iy);
+         cogCorr = fSeg2[cath]->CorrFunc(fInput->DetElemId(), isec-1);
+       }
        
        if (cogCorr) {
-           Float_t yOnPad=(c->fY[cath]-y)/fSeg[cath]->Dpy(isec);
-           c->fY[cath]=c->fY[cath]-cogCorr->Eval(yOnPad, 0, 0);
+         Float_t yOnPad;
+         if (fSegmentationType == 1) 
+           yOnPad=(c->GetY(cath)-y)/fSeg[cath]->Dpy(isec);
+         else 
+           yOnPad=(c->GetY(cath)-y)/fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
+
+         c->SetY(cath, c->GetY(cath)-cogCorr->Eval(yOnPad, 0, 0));
        }
     }
 }
@@ -1277,41 +1379,45 @@ void  AliMUONClusterFinderVS::FillCluster(AliMUONRawCluster* c, Int_t cath)
     Float_t xpad, ypad, zpad;
     Float_t dx, dy, dr;
 
-    for (Int_t i=0; i<c->fMultiplicity[cath]; i++)
+    for (Int_t i=0; i<c->GetMultiplicity(cath); i++)
     {
-       dig = fInput->Digit(cath,c->fIndexMap[i][cath]);
-       fSeg[cath]->
-       GetPadC(dig->PadX(),dig->PadY(),xpad,ypad, zpad);
-       if (fDebugLevel)
-           fprintf(stderr,"x %f y %f cx %f cy %f\n",xpad,ypad,c->fX[0],c->fY[0]);
-       dx = xpad - c->fX[0];
-       dy = ypad - c->fY[0];
+       dig = fInput->Digit(cath,c->GetIndex(i,cath));
+       if (fSegmentationType == 1) 
+         fSeg[cath]->
+           GetPadC(dig->PadX(),dig->PadY(),xpad,ypad, zpad);
+       else
+         fSeg2[cath]->
+           GetPadC(fInput->DetElemId(),dig->PadX(),dig->PadY(),xpad,ypad, zpad);
+       AliDebug(1,Form("x %f y %f cx %f cy %f\n",xpad,ypad,c->GetX(0),c->GetY(0)));
+       dx = xpad - c->GetX(0);
+       dy = ypad - c->GetY(0);
        dr = TMath::Sqrt(dx*dx+dy*dy);
 
        if (dr < dr0) {
            dr0 = dr;
-           if (fDebugLevel)
-               fprintf(stderr," dr %f\n",dr);
+           AliDebug(1,Form(" dr %f\n",dr));
            Int_t q=dig->Signal();
            if (dig->Physics() >= dig->Signal()) {
-               c->fPhysicsMap[i]=2;
+               c->SetPhysics(i,2);
            } else if (dig->Physics() == 0) {
-               c->fPhysicsMap[i]=0;
-           } else  c->fPhysicsMap[i]=1;
-           c->fPeakSignal[cath]=q;
-           c->fTracks[0]=dig->Hit();
-           c->fTracks[1]=dig->Track(0);
-           c->fTracks[2]=dig->Track(1);
-           if (fDebugLevel)
-               fprintf(stderr," c->fTracks[0] %d c->fTracks[1] %d\n",dig->Hit(),
-                   dig->Track(0));
+               c->SetPhysics(i,0);
+           } else  c->SetPhysics(i,1);
+           c->SetPeakSignal(cath,q);
+           c->SetTrack(0,dig->Hit());
+           c->SetTrack(1,dig->Track(0));
+           c->SetTrack(2,dig->Track(1));
+           AliDebug(1,Form(" c->fTracks[0] %d c->fTracks[1] %d\n",dig->Hit(),
+                   dig->Track(0)));
        }
 //
     } // loop over digits
 
 //  apply correction to the coordinate along the anode wire
 // Force on anod
-    c->fX[cath]=fSeg[cath]->GetAnod(c->fX[cath]);
+    if (fSegmentationType == 1) 
+      c->SetX(cath,fSeg[cath]->GetAnod(c->GetX(cath)));
+    else
+      c->SetX(cath,fSeg2[cath]->GetAnod(fInput->DetElemId(), c->GetX(cath)));
 }
 
 void  AliMUONClusterFinderVS::FindCluster(Int_t i, Int_t j, Int_t cath, AliMUONRawCluster &c){
@@ -1330,36 +1436,36 @@ void  AliMUONClusterFinderVS::FindCluster(Int_t i, Int_t j, Int_t cath, AliMUONR
     Int_t theX=dig->PadX();
     Int_t theY=dig->PadY(); 
    
-    if (q > TMath::Abs(c.fPeakSignal[0]) && q > TMath::Abs(c.fPeakSignal[1])) {
-       c.fPeakSignal[cath]=q;
-       c.fTracks[0]=dig->Hit();
-       c.fTracks[1]=dig->Track(0);
-       c.fTracks[2]=dig->Track(1);
+    if (q > TMath::Abs(c.GetPeakSignal(0)) && q > TMath::Abs(c.GetPeakSignal(1))) {
+       c.SetPeakSignal(cath,q);
+       c.SetTrack(0,dig->Hit());
+       c.SetTrack(1,dig->Track(0));
+       c.SetTrack(2,dig->Track(1));
     }
 
 //
 //  Make sure that list of digits is ordered 
 // 
-    Int_t mu=c.fMultiplicity[cath];
-    c.fIndexMap[mu][cath]=idx;
+    Int_t mu=c.GetMultiplicity(cath);
+    c.SetIndex(mu, cath, idx);
     
     if (dig->Physics() >= dig->Signal()) {
-        c.fPhysicsMap[mu]=2;
+        c.SetPhysics(mu,2);
     } else if (dig->Physics() == 0) {
-        c.fPhysicsMap[mu]=0;
-    } else  c.fPhysicsMap[mu]=1;
+        c.SetPhysics(mu,0);
+    } else  c.SetPhysics(mu,1);
 
     
     if (mu > 0) {
        for (Int_t ind = mu-1; ind >= 0; ind--) {
-           Int_t ist=(c.fIndexMap)[ind][cath];
+           Int_t ist=c.GetIndex(ind,cath);
            Int_t ql=fInput->Digit(cath, ist)->Signal();
            Int_t ix=fInput->Digit(cath, ist)->PadX();
            Int_t iy=fInput->Digit(cath, ist)->PadY();
            
            if (q>ql || (q==ql && theX > ix && theY < iy)) {
-               c.fIndexMap[ind][cath]=idx;
-               c.fIndexMap[ind+1][cath]=ist;
+               c.SetIndex(ind, cath, idx);
+               c.SetIndex(ind+1, cath, ist);
            } else {
                
                break;
@@ -1367,19 +1473,21 @@ void  AliMUONClusterFinderVS::FindCluster(Int_t i, Int_t j, Int_t cath, AliMUONR
        }
     }
 
-    c.fMultiplicity[cath]++;
-    if (c.fMultiplicity[cath] >= 50 ) {
-       printf("FindCluster - multiplicity >50  %d \n",c.fMultiplicity[0]);
-       c.fMultiplicity[cath]=49;
+    c.SetMultiplicity(cath, c.GetMultiplicity(cath)+1);
+    if (c.GetMultiplicity(cath) >= 50 ) {
+      AliDebug(1,Form("FindCluster - multiplicity >50  %d \n",c.GetMultiplicity(0)));
+       c.SetMultiplicity(cath, 49);
     }
 
 // Prepare center of gravity calculation
     Float_t x, y, z;
-    fSeg[cath]->GetPadC(i, j, x, y, z);
-    
-    c.fX[cath] += q*x;
-    c.fY[cath] += q*y;
-    c.fQ[cath] += q;
+    if (fSegmentationType == 1) 
+      fSeg[cath]->GetPadC(i, j, x, y, z);
+    else
+      fSeg2[cath]->GetPadC(fInput->DetElemId(), i, j, x, y, z);
+    c.AddX(cath,q*x);
+    c.AddY(cath,q*y);
+    c.AddCharge(cath,q);
 //
 // Flag hit as "taken"  
     fHitMap[cath]->FlagHit(i,j);
@@ -1391,14 +1499,16 @@ void  AliMUONClusterFinderVS::FindCluster(Int_t i, Int_t j, Int_t cath, AliMUONR
     ix=iy=0;
     Int_t nn;
     Int_t xList[10], yList[10];
-    fSeg[cath]->Neighbours(i,j,&nn,xList,yList);
+    if (fSegmentationType == 1) 
+      fSeg[cath]->Neighbours(i,j,&nn,xList,yList);
+    else 
+      fSeg2[cath]->Neighbours(fInput->DetElemId(), i,j,&nn,xList,yList);
     for (Int_t in=0; in<nn; in++) {
        ix=xList[in];
        iy=yList[in];
        
        if (fHitMap[cath]->TestHit(ix,iy)==kUnused) {
-           if (fDebugLevel>1)
-               printf("\n Neighbours %d %d %d", cath, ix, iy);
+           AliDebug(2,Form("\n Neighbours %d %d %d", cath, ix, iy));
            FindCluster(ix, iy, cath, c);
        }
        
@@ -1408,42 +1518,86 @@ void  AliMUONClusterFinderVS::FindCluster(Int_t i, Int_t j, Int_t cath, AliMUONR
     
 //  Neighbours on opposite cathode 
 //  Take into account that several pads can overlap with the present pad
-    Int_t isec=fSeg[cath]->Sector(i,j);    
+    Int_t isec;
+    if (fSegmentationType == 1) 
+      isec=fSeg[cath]->Sector(i,j);    
+    else
+      isec=fSeg2[cath]->Sector(fInput->DetElemId(), i,j);    
+
     Int_t iop;
     Float_t dx, dy;
 
-    if (cath==0) {
+    if (fSegmentationType == 1) {
+      if (cath==0) {
        iop = 1;
        dx  = (fSeg[cath]->Dpx(isec))/2.;
        dy  = 0.;
-    } else {
+      } else {
        iop = 0;
        dx  = 0.;
        dy  = (fSeg[cath]->Dpy(isec))/2;
-    }
-// loop over pad neighbours on opposite cathode
-    for (fSeg[iop]->FirstPad(x, y, fZPlane, dx, dy);
-        fSeg[iop]->MorePads();
-        fSeg[iop]->NextPad())
-    {
+      }
+   
+
+    
+      // loop over pad neighbours on opposite cathode
+      for (fSeg[iop]->FirstPad(x, y, fZPlane, dx, dy);
+          fSeg[iop]->MorePads();
+          fSeg[iop]->NextPad())
+       {
        
-       ix = fSeg[iop]->Ix(); iy = fSeg[iop]->Iy();
-       if (fDebugLevel > 1)
-           printf("\n ix, iy: %f %f %f %d %d %d", x,y,z,ix, iy, fSector);
-       if (fHitMap[iop]->TestHit(ix,iy)==kUnused){
+         ix = fSeg[iop]->Ix(); iy = fSeg[iop]->Iy();
+         AliDebug(2,Form("\n ix, iy: %f %f %f %d %d %d", x,y,z,ix, iy, fSector));
+         if (fHitMap[iop]->TestHit(ix,iy)==kUnused){
            iXopp[nOpp]=ix;
            iYopp[nOpp++]=iy;
-           if (fDebugLevel > 1)
-               printf("\n Opposite %d %d %d", iop, ix, iy);
-       }
+           AliDebug(2,Form("\n Opposite %d %d %d", iop, ix, iy));
+         }
        
-    } // Loop over pad neighbours
-//  This had to go outside the loop since recursive calls inside the iterator are not possible
-//
-    Int_t jopp;
-    for (jopp=0; jopp<nOpp; jopp++) {
+       } // Loop over pad neighbours
+      //  This had to go outside the loop since recursive calls inside the iterator are not possible
+      //
+      Int_t jopp;
+      for (jopp=0; jopp<nOpp; jopp++) {
+       if (fHitMap[iop]->TestHit(iXopp[jopp],iYopp[jopp]) == kUnused) 
+         FindCluster(iXopp[jopp], iYopp[jopp], iop, c);
+      }
+    } else {
+
+      if (cath==0) {
+       iop = 1;
+       dx  = (fSeg2[cath]->Dpx(fInput->DetElemId(), isec))/2.;
+       dy  = 0.;
+      } else {
+       iop = 0;
+       dx  = 0.;
+       dy  = (fSeg2[cath]->Dpy(fInput->DetElemId(), isec))/2;
+      }
+   
+
+    
+      // loop over pad neighbours on opposite cathode
+      for (fSeg2[iop]->FirstPad(fInput->DetElemId(), x, y, fZPlane, dx, dy);
+          fSeg2[iop]->MorePads(fInput->DetElemId());
+          fSeg2[iop]->NextPad(fInput->DetElemId()))
+       {
+       
+         ix = fSeg2[iop]->Ix(); iy = fSeg2[iop]->Iy();
+         AliDebug(2,Form("\n ix, iy: %f %f %f %d %d %d", x,y,z,ix, iy, fSector));
+         if (fHitMap[iop]->TestHit(ix,iy)==kUnused){
+           iXopp[nOpp]=ix;
+           iYopp[nOpp++]=iy;
+           AliDebug(2,Form("\n Opposite %d %d %d", iop, ix, iy));
+         }
+       
+       } // Loop over pad neighbours
+      //  This had to go outside the loop since recursive calls inside the iterator are not possible
+      //
+      Int_t jopp;
+      for (jopp=0; jopp<nOpp; jopp++) {
        if (fHitMap[iop]->TestHit(iXopp[jopp],iYopp[jopp]) == kUnused) 
-           FindCluster(iXopp[jopp], iYopp[jopp], iop, c);
+         FindCluster(iXopp[jopp], iYopp[jopp], iop, c);
+      }
     }
 }
 
@@ -1460,12 +1614,22 @@ void AliMUONClusterFinderVS::FindRawClusters()
 //  Return if no input datad available
     if (!fInput->NDigits(0) && !fInput->NDigits(1)) return;
 
-    fSeg[0] = fInput->Segmentation(0);
-    fSeg[1] = fInput->Segmentation(1);
+    fSegmentationType = fInput->GetSegmentationType();
+
+    if (fSegmentationType == 1) {
+      fSeg[0] = fInput->Segmentation(0);
+      fSeg[1] = fInput->Segmentation(1);
 
-    fHitMap[0]  = new AliMUONHitMapA1(fSeg[0], fInput->Digits(0));
-    fHitMap[1]  = new AliMUONHitMapA1(fSeg[1], fInput->Digits(1));
+      fHitMap[0]  = new AliMUONHitMapA1(fSeg[0], fInput->Digits(0));
+      fHitMap[1]  = new AliMUONHitMapA1(fSeg[1], fInput->Digits(1));
 
+    } else {
+      fSeg2[0] = fInput->Segmentation2(0);
+      fSeg2[1] = fInput->Segmentation2(1);
+
+      fHitMap[0]  = new AliMUONHitMapA1(fInput->DetElemId(), fSeg2[0], fInput->Digits(0));
+      fHitMap[1]  = new AliMUONHitMapA1(fInput->DetElemId(), fSeg2[1], fInput->Digits(1));
+    }
  
     AliMUONDigit *dig;
 
@@ -1477,76 +1641,89 @@ void AliMUONClusterFinderVS::FindRawClusters()
 //
 //  Outer Loop over Cathodes
     for (cath=0; cath<2; cath++) {
+
        for (ndig=0; ndig<fInput->NDigits(cath); ndig++) {
            dig = fInput->Digit(cath, ndig);
-           Int_t i=dig->PadX();
-           Int_t j=dig->PadY();
-           if (fHitMap[cath]->TestHit(i,j)==kUsed ||fHitMap[0]->TestHit(i,j)==kEmpty) {
+           Int_t padx = dig->PadX();
+           Int_t pady = dig->PadY();
+           if (fHitMap[cath]->TestHit(padx,pady)==kUsed ||fHitMap[0]->TestHit(padx,pady)==kEmpty) {
                nskip++;
                continue;
            }
-           if (fDebugLevel)
-               fprintf(stderr,"\n CATHODE %d CLUSTER %d\n",cath,ncls);
-           AliMUONRawCluster c;
-           c.fMultiplicity[0]=0;
-           c.fMultiplicity[1]=0;
-           c.fPeakSignal[cath]=dig->Signal();
-           c.fTracks[0]=dig->Hit();
-           c.fTracks[1]=dig->Track(0);
-           c.fTracks[2]=dig->Track(1);
+           AliDebug(1,Form("\n CATHODE %d CLUSTER %d\n",cath,ncls));
+           AliMUONRawCluster clus;
+           clus.SetMultiplicity(0, 0);
+           clus.SetMultiplicity(1, 0);
+           clus.SetPeakSignal(cath,dig->Signal());
+           clus.SetTrack(0, dig->Hit());
+           clus.SetTrack(1, dig->Track(0));
+           clus.SetTrack(2, dig->Track(1));
+
+           AliDebug(1,Form("idDE %d Padx %d Pady %d", fInput->DetElemId(), padx, pady));
+
            // tag the beginning of cluster list in a raw cluster
-           c.fNcluster[0]=-1;
+           clus.SetNcluster(0,-1);
            Float_t xcu, ycu;
-           fSeg[cath]->GetPadC(i,j,xcu, ycu, fZPlane);
-           fSector= fSeg[cath]->Sector(i,j)/100;
-           if (fDebugLevel)
-               printf("\n New Seed %d %d ", i,j);
-       
+           if (fSegmentationType == 1) {
+             fSeg[cath]->GetPadC(padx,pady, xcu, ycu, fZPlane);
+             fSector= fSeg[cath]->Sector(padx,pady)/100;
+           } else {
+             fSeg2[cath]->GetPadC(fInput->DetElemId(), padx, pady, xcu, ycu, fZPlane);
+             fSector= fSeg2[cath]->Sector(fInput->DetElemId(), padx, pady)/100;
+           }
+
+
             
-           FindCluster(i,j,cath,c);
+           FindCluster(padx,pady,cath,clus);
 //          ^^^^^^^^^^^^^^^^^^^^^^^^
            // center of gravity
-           if (c.fX[0]!=0.) c.fX[0] /= c.fQ[0];
-// Force on anod
-           c.fX[0]=fSeg[0]->GetAnod(c.fX[0]);
-           if (c.fY[0]!=0.) c.fY[0] /= c.fQ[0];
+           if (clus.GetX(0)!=0.) clus.SetX(0, clus.GetX(0)/clus.GetCharge(0)); // clus.fX[0] /= clus.fQ[0];
+
+           // Force on anod
+           if (fSegmentationType == 1) 
+             clus.SetX(0,fSeg[0]->GetAnod(clus.GetX(0)));
+           else 
+             clus.SetX(0,fSeg2[0]->GetAnod(fInput->DetElemId(), clus.GetX(0)));
+           if (clus.GetY(0)!=0.) clus.SetY(0, clus.GetY(0)/clus.GetCharge(0)); // clus.fY[0] /= clus.fQ[0];
            
-           if(c.fQ[1]!=0.) c.fX[1] /= c.fQ[1];
+           if(clus.GetCharge(1)!=0.) clus.SetX(1, clus.GetX(1)/clus.GetCharge(1));  // clus.fX[1] /= clus.fQ[1];
                                        
           // Force on anod
-           c.fX[1]=fSeg[0]->GetAnod(c.fX[1]);
-            if(c.fQ[1]!=0.) c.fY[1] /= c.fQ[1];
+           if (fSegmentationType == 1) 
+             clus.SetX(1, fSeg[0]->GetAnod(clus.GetX(1)));
+           else 
+             clus.SetX(1, fSeg2[0]->GetAnod(fInput->DetElemId(),clus.GetX(1)));
+           if(clus.GetCharge(1)!=0.) clus.SetY(1, clus.GetY(1)/clus.GetCharge(1));// clus.fY[1] /= clus.fQ[1];
            
-           c.fZ[0] = fZPlane;
-           c.fZ[1] = fZPlane;      
-
-           if (fDebugLevel) {
-               fprintf(stderr,"\n Cathode 1 multiplicite %d X(CG) %f Y(CG) %f\n",
-                       c.fMultiplicity[0],c.fX[0],c.fY[0]);
-               fprintf(stderr," Cathode 2 multiplicite %d X(CG) %f Y(CG) %f\n",
-                       c.fMultiplicity[1],c.fX[1],c.fY[1]);
-           }
+           clus.SetZ(0, fZPlane);
+           clus.SetZ(1, fZPlane);          
+
+               AliDebug(1,Form("\n Cathode 1 multiplicite %d X(CG) %f Y(CG) %f\n",
+                       clus.GetMultiplicity(0),clus.GetX(0),clus.GetY(0)));
+               AliDebug(1,Form(" Cathode 2 multiplicite %d X(CG) %f Y(CG) %f\n",
+                       clus.GetMultiplicity(1),clus.GetX(1),clus.GetY(1)));
 //      Analyse cluster and decluster if necessary
 //     
        ncls++;
-       c.fNcluster[1]=fNRawClusters;
-       c.fClusterType=c.PhysicsContribution();
+       clus.SetNcluster(1,fNRawClusters);
+       clus.SetClusterType(clus.PhysicsContribution());
 
        fNPeaks=0;
 //
 //
-       Decluster(&c);
+       Decluster(&clus);
 //
 //      reset Cluster object
        { // begin local scope
-           for (int k=0;k<c.fMultiplicity[0];k++) c.fIndexMap[k][0]=0;
+           for (int k=0;k<clus.GetMultiplicity(0);k++) clus.SetIndex(k, 0, 0);
        } // end local scope
 
        { // begin local scope
-           for (int k=0;k<c.fMultiplicity[1];k++) c.fIndexMap[k][1]=0;
+           for (int k=0;k<clus.GetMultiplicity(1);k++) clus.SetIndex(k, 1, 0);
        } // end local scope
        
-       c.fMultiplicity[0]=c.fMultiplicity[0]=0;
+       clus.SetMultiplicity(0,0);
+       clus.SetMultiplicity(1,0);
 
        
        } // end loop ndig
@@ -1570,21 +1747,34 @@ Float_t AliMUONClusterFinderVS::SingleMathiesonFit(AliMUONRawCluster *c, Int_t c
     clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
 // Set starting values 
     static Double_t vstart[2];
-    vstart[0]=c->fX[1];
-    vstart[1]=c->fY[0];
+    vstart[0]=c->GetX(1);
+    vstart[1]=c->GetY(0);
     
     
 // lower and upper limits
     static Double_t lower[2], upper[2];
-    Int_t ix,iy;
-    fSeg[cath]->GetPadI(c->fX[cath], c->fY[cath], fZPlane, ix, iy);
-    Int_t isec=fSeg[cath]->Sector(ix, iy);
-    lower[0]=vstart[0]-fSeg[cath]->Dpx(isec)/2;
-    lower[1]=vstart[1]-fSeg[cath]->Dpy(isec)/2;
+    Int_t ix,iy, isec;
+    if (fSegmentationType == 1) {
+      fSeg[cath]->GetPadI(c->GetX(cath), c->GetY(cath), fZPlane, ix, iy);
+      isec=fSeg[cath]->Sector(ix, iy);
+
+      lower[0]=vstart[0]-fSeg[cath]->Dpx(isec)/2;
+      lower[1]=vstart[1]-fSeg[cath]->Dpy(isec)/2;
     
-    upper[0]=lower[0]+fSeg[cath]->Dpx(isec);
-    upper[1]=lower[1]+fSeg[cath]->Dpy(isec);
+      upper[0]=lower[0]+fSeg[cath]->Dpx(isec);
+      upper[1]=lower[1]+fSeg[cath]->Dpy(isec);
+
+    } else {
+      fSeg2[cath]->GetPadI(fInput->DetElemId(), c->GetX(cath), c->GetY(cath), fZPlane, ix, iy);
+      isec=fSeg2[cath]->Sector(fInput->DetElemId(), ix, iy);
+
+      lower[0]=vstart[0]-fSeg2[cath]->Dpx(fInput->DetElemId(), isec)/2;
+      lower[1]=vstart[1]-fSeg2[cath]->Dpy(fInput->DetElemId(), isec)/2;
     
+      upper[0]=lower[0]+fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
+      upper[1]=lower[1]+fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
+    }
+
 // step sizes
     static Double_t step[2]={0.0005, 0.0005};
     
@@ -1636,46 +1826,80 @@ Float_t AliMUONClusterFinderVS::CombiSingleMathiesonFit(AliMUONRawCluster * /*c*
 // lower and upper limits
     static Float_t lower[2], upper[2];
     Int_t ix,iy,isec;
-    fSeg[0]->GetPadI(fXInit[0], fYInit[0], fZPlane, ix, iy);
-    isec=fSeg[0]->Sector(ix, iy);
-    Float_t dpy=fSeg[0]->Dpy(isec);
-    fSeg[1]->GetPadI(fXInit[0], fYInit[0], fZPlane, ix, iy);
-    isec=fSeg[1]->Sector(ix, iy);
-    Float_t dpx=fSeg[1]->Dpx(isec);
+    Float_t dpy, dpx;
 
+    if (fSegmentationType == 1) {
+      fSeg[0]->GetPadI(fXInit[0], fYInit[0], fZPlane, ix, iy);
+      isec=fSeg[0]->Sector(ix, iy);
+      dpy=fSeg[0]->Dpy(isec);
+      fSeg[1]->GetPadI(fXInit[0], fYInit[0], fZPlane, ix, iy);
+      isec=fSeg[1]->Sector(ix, iy);
+      dpx=fSeg[1]->Dpx(isec);
+
+    } else {
+      fSeg2[0]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
+      isec=fSeg2[0]->Sector(fInput->DetElemId(), ix, iy);
+      dpy=fSeg2[0]->Dpy(fInput->DetElemId(), isec);
+      fSeg2[1]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
+      isec=fSeg2[1]->Sector(fInput->DetElemId(), ix, iy);
+      dpx=fSeg2[1]->Dpx(fInput->DetElemId(), isec);
+
+    }
     Int_t icount;
     Float_t xdum, ydum, zdum;
 
 //  Find save upper and lower limits    
     
     icount = 0;
-    
-    for (fSeg[1]->FirstPad(fXInit[0], fYInit[0], fZPlane, dpx, 0.); 
-        fSeg[1]->MorePads(); fSeg[1]->NextPad())
-    {
-       ix=fSeg[1]->Ix(); iy=fSeg[1]->Iy();
-       fSeg[1]->GetPadC(ix,iy, upper[0], ydum, zdum);  
-       if (icount ==0) lower[0]=upper[0];
-       icount++;
+    if (fSegmentationType == 1) {
+      for (fSeg[1]->FirstPad(fXInit[0], fYInit[0], fZPlane, dpx, 0.); 
+          fSeg[1]->MorePads(); 
+          fSeg[1]->NextPad())
+       {
+         ix=fSeg[1]->Ix(); iy=fSeg[1]->Iy();
+         fSeg[1]->GetPadC(ix,iy, upper[0], ydum, zdum);        
+         if (icount ==0) lower[0]=upper[0];
+         icount++;
+       }
+    } else {
+      for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, dpx, 0.); 
+          fSeg2[1]->MorePads(fInput->DetElemId()); 
+          fSeg2[1]->NextPad(fInput->DetElemId()))
+       {
+         ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
+         fSeg2[1]->GetPadC(fInput->DetElemId(), ix,iy, upper[0], ydum, zdum);  
+         if (icount ==0) lower[0]=upper[0];
+         icount++;
+       }
     }
-
     if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;}
        
     icount=0;
-    if (fDebugLevel)
-       printf("\n single y %f %f", fXInit[0], fYInit[0]);
+    AliDebug(1,Form("\n single y %f %f", fXInit[0], fYInit[0]));
     
-    for (fSeg[0]->FirstPad(fXInit[0], fYInit[0], fZPlane, 0., dpy); 
-        fSeg[0]->MorePads(); fSeg[0]->NextPad())
-    {
-       ix=fSeg[0]->Ix(); iy=fSeg[0]->Iy();
-       fSeg[0]->GetPadC(ix,iy,xdum,upper[1],zdum);     
-       if (icount ==0) lower[1]=upper[1];
-       icount++;
-       if (fDebugLevel)
-           printf("\n upper lower %d %f %f", icount, upper[1], lower[1]);
+    if (fSegmentationType == 1) {
+      for (fSeg[0]->FirstPad(fXInit[0], fYInit[0], fZPlane, 0., dpy); 
+          fSeg[0]->MorePads(); 
+          fSeg[0]->NextPad())
+       {
+         ix=fSeg[0]->Ix(); iy=fSeg[0]->Iy();
+         fSeg[0]->GetPadC(ix,iy,xdum,upper[1],zdum);   
+         if (icount ==0) lower[1]=upper[1];
+         icount++;
+         AliDebug(1,Form("\n upper lower %d %f %f", icount, upper[1], lower[1]));
+       }
+    } else {
+      for (fSeg2[0]->FirstPad(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, 0., dpy); 
+          fSeg2[0]->MorePads(fInput->DetElemId()); 
+          fSeg2[0]->NextPad(fInput->DetElemId()))
+       {
+         ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
+         fSeg2[0]->GetPadC(fInput->DetElemId(), ix,iy,xdum,upper[1],zdum);     
+         if (icount ==0) lower[1]=upper[1];
+         icount++;
+         AliDebug(1,Form("\n upper lower %d %f %f", icount, upper[1], lower[1]));
+       }
     }
-    
     if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;}
 
 // step sizes
@@ -1734,20 +1958,42 @@ Bool_t AliMUONClusterFinderVS::DoubleMathiesonFit(AliMUONRawCluster * /*c*/, Int
        Float_t(fQ[fIndLocal[0][cath]][cath]+fQ[fIndLocal[1][cath]][cath]);
 // lower and upper limits
     static Float_t lower[5], upper[5];
-    Int_t isec=fSeg[cath]->Sector(fIx[fIndLocal[0][cath]][cath], fIy[fIndLocal[0][cath]][cath]);
-    lower[0]=vstart[0]-fSeg[cath]->Dpx(isec);
-    lower[1]=vstart[1]-fSeg[cath]->Dpy(isec);
+    Int_t isec;
+
+    if (fSegmentationType == 1) {
+      isec=fSeg[cath]->Sector(fIx[fIndLocal[0][cath]][cath], fIy[fIndLocal[0][cath]][cath]);
+      lower[0]=vstart[0]-fSeg[cath]->Dpx(isec);
+      lower[1]=vstart[1]-fSeg[cath]->Dpy(isec);
+    
+      upper[0]=lower[0]+2.*fSeg[cath]->Dpx(isec);
+      upper[1]=lower[1]+2.*fSeg[cath]->Dpy(isec);
     
-    upper[0]=lower[0]+2.*fSeg[cath]->Dpx(isec);
-    upper[1]=lower[1]+2.*fSeg[cath]->Dpy(isec);
+      isec=fSeg[cath]->Sector(fIx[fIndLocal[1][cath]][cath], fIy[fIndLocal[1][cath]][cath]);
+      lower[2]=vstart[2]-fSeg[cath]->Dpx(isec)/2;
+      lower[3]=vstart[3]-fSeg[cath]->Dpy(isec)/2;
     
-    isec=fSeg[cath]->Sector(fIx[fIndLocal[1][cath]][cath], fIy[fIndLocal[1][cath]][cath]);
-    lower[2]=vstart[2]-fSeg[cath]->Dpx(isec)/2;
-    lower[3]=vstart[3]-fSeg[cath]->Dpy(isec)/2;
+      upper[2]=lower[2]+fSeg[cath]->Dpx(isec);
+      upper[3]=lower[3]+fSeg[cath]->Dpy(isec);
+
+    } else {
+      isec=fSeg2[cath]->Sector(fInput->DetElemId(),fIx[fIndLocal[0][cath]][cath], 
+                              fIy[fIndLocal[0][cath]][cath]);
+      lower[0]=vstart[0]-fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
+      lower[1]=vstart[1]-fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
+    
+      upper[0]=lower[0]+2.*fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
+      upper[1]=lower[1]+2.*fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
     
-    upper[2]=lower[2]+fSeg[cath]->Dpx(isec);
-    upper[3]=lower[3]+fSeg[cath]->Dpy(isec);
+      isec=fSeg2[cath]->Sector(fInput->DetElemId(),fIx[fIndLocal[1][cath]][cath], 
+                             fIy[fIndLocal[1][cath]][cath]);
+      lower[2]=vstart[2]-fSeg2[cath]->Dpx(fInput->DetElemId(),isec)/2;
+      lower[3]=vstart[3]-fSeg2[cath]->Dpy(fInput->DetElemId(),isec)/2;
     
+      upper[2]=lower[2]+fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
+      upper[1]=lower[1]+2.*fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
+
+    }
+
     lower[4]=0.;
     upper[4]=1.;
 // step sizes
@@ -1809,7 +2055,7 @@ Float_t AliMUONClusterFinderVS::CombiDoubleMathiesonFit(AliMUONRawCluster * /*c*
     static Float_t lower[6], upper[6];
     Int_t ix,iy,isec;
     Float_t dpx, dpy;
-    
+  if (fSegmentationType == 1) {
     fSeg[1]->GetPadI(fXInit[0], fYInit[0], fZPlane, ix, iy);
     isec=fSeg[1]->Sector(ix, iy);
     dpx=fSeg[1]->Dpx(isec);
@@ -1818,85 +2064,174 @@ Float_t AliMUONClusterFinderVS::CombiDoubleMathiesonFit(AliMUONRawCluster * /*c*
     isec=fSeg[0]->Sector(ix, iy);
     dpy=fSeg[0]->Dpy(isec);
 
+  } else {
+    fSeg2[1]->GetPadI(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, ix, iy);
+    isec=fSeg2[1]->Sector(fInput->DetElemId(),ix, iy);
+    dpx=fSeg2[1]->Dpx(fInput->DetElemId(), isec);
+
+    fSeg2[0]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
+    isec=fSeg2[0]->Sector(fInput->DetElemId(), ix, iy);
+    dpy=fSeg2[0]->Dpy(fInput->DetElemId(), isec);
+
+  }
 
     Int_t icount;
     Float_t xdum, ydum, zdum;
-    if (fDebugLevel)
-       printf("\n Cluster Finder: %f %f %f %f  ", fXInit[0], fXInit[1],fYInit[0], fYInit[1] );
-    
-//  Find save upper and lower limits    
-    icount = 0;
+    AliDebug(1,Form("\n Cluster Finder: %f %f %f %f  ", fXInit[0], fXInit[1],fYInit[0], fYInit[1] ));
+
+    if (fSegmentationType == 1) {
+      //  Find save upper and lower limits    
+      icount = 0;
     
-    for (fSeg[1]->FirstPad(fXInit[0], fYInit[0], fZPlane, dpx, 0.); 
-        fSeg[1]->MorePads(); fSeg[1]->NextPad())
-    {
-       ix=fSeg[1]->Ix(); iy=fSeg[1]->Iy();
-//     if (fHitMap[1]->TestHit(ix, iy) == kEmpty) continue;
-       fSeg[1]->GetPadC(ix,iy,upper[0],ydum,zdum);     
-       if (icount ==0) lower[0]=upper[0];
-       icount++;
-    }
-    if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;}    
-//    vstart[0] = 0.5*(lower[0]+upper[0]);
+      for (fSeg[1]->FirstPad(fXInit[0], fYInit[0], fZPlane, dpx, 0.); 
+          fSeg[1]->MorePads(); 
+          fSeg[1]->NextPad())
+       {
+         ix=fSeg[1]->Ix(); iy=fSeg[1]->Iy();
+         //    if (fHitMap[1]->TestHit(ix, iy) == kEmpty) continue;
+         fSeg[1]->GetPadC(ix,iy,upper[0],ydum,zdum);   
+         if (icount ==0) lower[0]=upper[0];
+         icount++;
+       }
+      if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;}    
+      //    vstart[0] = 0.5*(lower[0]+upper[0]);
 
     
-    icount=0;
+      icount=0;
     
-    for (fSeg[0]->FirstPad(fXInit[0], fYInit[0], fZPlane, 0., dpy); 
-        fSeg[0]->MorePads(); fSeg[0]->NextPad())
-    {
-       ix=fSeg[0]->Ix(); iy=fSeg[0]->Iy();
-//     if (fHitMap[0]->TestHit(ix, iy) == kEmpty) continue;
-       fSeg[0]->GetPadC(ix,iy,xdum,upper[1],zdum);     
-       if (icount ==0) lower[1]=upper[1];
-       icount++;
-    }
+      for (fSeg[0]->FirstPad(fXInit[0], fYInit[0], fZPlane, 0., dpy); 
+          fSeg[0]->MorePads(); 
+          fSeg[0]->NextPad())
+       {
+         ix=fSeg[0]->Ix(); iy=fSeg[0]->Iy();
+         //    if (fHitMap[0]->TestHit(ix, iy) == kEmpty) continue;
+         fSeg[0]->GetPadC(ix,iy,xdum,upper[1],zdum);   
+         if (icount ==0) lower[1]=upper[1];
+         icount++;
+       }
     
-    if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;}    
-//     vstart[1] = 0.5*(lower[1]+upper[1]);
+      if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;}    
+      //     vstart[1] = 0.5*(lower[1]+upper[1]);
 
 
-    fSeg[1]->GetPadI(fXInit[1], fYInit[1], fZPlane, ix, iy);
-    isec=fSeg[1]->Sector(ix, iy);
-    dpx=fSeg[1]->Dpx(isec);
-    fSeg[0]->GetPadI(fXInit[1], fYInit[1], fZPlane, ix, iy);
-    isec=fSeg[0]->Sector(ix, iy);
-    dpy=fSeg[0]->Dpy(isec);
+      fSeg[1]->GetPadI(fXInit[1], fYInit[1], fZPlane, ix, iy);
+      isec=fSeg[1]->Sector(ix, iy);
+      dpx=fSeg[1]->Dpx(isec);
+      fSeg[0]->GetPadI(fXInit[1], fYInit[1], fZPlane, ix, iy);
+      isec=fSeg[0]->Sector(ix, iy);
+      dpy=fSeg[0]->Dpy(isec);
 
 
-//  Find save upper and lower limits    
+      //  Find save upper and lower limits    
 
-    icount=0;
+      icount=0;
     
-    for (fSeg[1]->FirstPad(fXInit[1], fYInit[1], fZPlane, dpx, 0); 
-        fSeg[1]->MorePads(); fSeg[1]->NextPad())
-    {
-       ix=fSeg[1]->Ix(); iy=fSeg[1]->Iy();
-//     if (fHitMap[1]->TestHit(ix, iy) == kEmpty) continue;
-       fSeg[1]->GetPadC(ix,iy,upper[2],ydum,zdum);     
-       if (icount ==0) lower[2]=upper[2];
-       icount++;
-    }
-    if (lower[2]>upper[2]) {xdum=lower[2]; lower[2]=upper[2]; upper[2]=xdum;}    
-    //    vstart[2] = 0.5*(lower[2]+upper[2]);
+      for (fSeg[1]->FirstPad(fXInit[1], fYInit[1], fZPlane, dpx, 0); 
+          fSeg[1]->MorePads(); fSeg[1]->NextPad())
+       {
+         ix=fSeg[1]->Ix(); iy=fSeg[1]->Iy();
+         //    if (fHitMap[1]->TestHit(ix, iy) == kEmpty) continue;
+         fSeg[1]->GetPadC(ix,iy,upper[2],ydum,zdum);   
+         if (icount ==0) lower[2]=upper[2];
+         icount++;
+       }
+      if (lower[2]>upper[2]) {xdum=lower[2]; lower[2]=upper[2]; upper[2]=xdum;}    
+      //    vstart[2] = 0.5*(lower[2]+upper[2]);
 
-    icount=0;
+      icount=0;
     
-    for (fSeg[0]->FirstPad(fXInit[1], fYInit[1], fZPlane, 0, dpy); 
-        fSeg[0]-> MorePads(); fSeg[0]->NextPad())
-    {
-       ix=fSeg[0]->Ix(); iy=fSeg[0]->Iy();
-//     if (fHitMap[0]->TestHit(ix, iy) != kEmpty) continue;
+      for (fSeg[0]->FirstPad(fXInit[1], fYInit[1], fZPlane, 0, dpy); 
+          fSeg[0]-> MorePads(); fSeg[0]->NextPad())
+       {
+         ix=fSeg[0]->Ix(); iy=fSeg[0]->Iy();
+         //    if (fHitMap[0]->TestHit(ix, iy) != kEmpty) continue;
        
-       fSeg[0]->GetPadC(ix,iy,xdum,upper[3],zdum);     
-       if (icount ==0) lower[3]=upper[3];
-       icount++;
+         fSeg[0]->GetPadC(ix,iy,xdum,upper[3],zdum);   
+         if (icount ==0) lower[3]=upper[3];
+         icount++;
 
-    }
-    if (lower[3]>upper[3]) {xdum=lower[3]; lower[3]=upper[3]; upper[3]=xdum;}    
+       }
+      if (lower[3]>upper[3]) {xdum=lower[3]; lower[3]=upper[3]; upper[3]=xdum;}    
     
-//     vstart[3] = 0.5*(lower[3]+upper[3]);
+      //     vstart[3] = 0.5*(lower[3]+upper[3]);
+    } else {
+
+    //  Find save upper and lower limits    
+      icount = 0;
     
+      for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, dpx, 0.); 
+          fSeg2[1]->MorePads(fInput->DetElemId()); 
+          fSeg2[1]->NextPad(fInput->DetElemId()))
+       {
+         ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
+         //    if (fHitMap[1]->TestHit(ix, iy) == kEmpty) continue;
+         fSeg2[1]->GetPadC(fInput->DetElemId(),ix,iy,upper[0],ydum,zdum);      
+         if (icount ==0) lower[0]=upper[0];
+         icount++;
+       }
+      if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;}    
+      //    vstart[0] = 0.5*(lower[0]+upper[0]);
+
+    
+      icount=0;
+    
+      for (fSeg2[0]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, 0., dpy); 
+          fSeg2[0]->MorePads(fInput->DetElemId()); 
+          fSeg2[0]->NextPad(fInput->DetElemId()))
+       {
+         ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
+         //    if (fHitMap[0]->TestHit(ix, iy) == kEmpty) continue;
+         fSeg2[0]->GetPadC(fInput->DetElemId(),ix,iy,xdum,upper[1],zdum);      
+         if (icount ==0) lower[1]=upper[1];
+         icount++;
+       }
+    
+      if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;}    
+      //     vstart[1] = 0.5*(lower[1]+upper[1]);
+
+
+      fSeg2[1]->GetPadI(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, ix, iy);
+      isec=fSeg2[1]->Sector(fInput->DetElemId(),ix, iy);
+      dpx=fSeg2[1]->Dpx(fInput->DetElemId(),isec);
+      fSeg2[0]->GetPadI(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, ix, iy);
+      isec=fSeg2[0]->Sector(fInput->DetElemId(),ix, iy);
+      dpy=fSeg2[0]->Dpy(fInput->DetElemId(),isec);
+
+
+      //  Find save upper and lower limits    
+
+      icount=0;
+    
+      for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, dpx, 0); 
+          fSeg2[1]->MorePads(fInput->DetElemId()); 
+          fSeg2[1]->NextPad(fInput->DetElemId()))
+       {
+         ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
+         //    if (fHitMap[1]->TestHit(ix, iy) == kEmpty) continue;
+         fSeg2[1]->GetPadC(fInput->DetElemId(),ix,iy,upper[2],ydum,zdum);      
+         if (icount ==0) lower[2]=upper[2];
+         icount++;
+       }
+      if (lower[2]>upper[2]) {xdum=lower[2]; lower[2]=upper[2]; upper[2]=xdum;}    
+      //    vstart[2] = 0.5*(lower[2]+upper[2]);
+
+      icount=0;
+    
+      for (fSeg2[0]->FirstPad(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, 0, dpy); 
+          fSeg2[0]-> MorePads(fInput->DetElemId()); 
+          fSeg2[0]->NextPad(fInput->DetElemId()))
+       {
+         ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
+         //    if (fHitMap[0]->TestHit(ix, iy) != kEmpty) continue;
+       
+         fSeg2[0]->GetPadC(fInput->DetElemId(),ix,iy,xdum,upper[3],zdum);      
+         if (icount ==0) lower[3]=upper[3];
+         icount++;
+
+       }
+      if (lower[3]>upper[3]) {xdum=lower[3]; lower[3]=upper[3]; upper[3]=xdum;}  
+    }
     lower[4]=0.;
     upper[4]=1.;
     lower[5]=0.;
@@ -1948,46 +2283,80 @@ void AliMUONClusterFinderVS::Split(AliMUONRawCluster* c)
     AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
     for (j=0; j<2; j++) {
        AliMUONRawCluster cnew;
-       cnew.fGhost=c->fGhost;
+       cnew.SetGhost(c->GetGhost());
        for (cath=0; cath<2; cath++) {
-           cnew.fChi2[cath]=fChi2[0];
+           cnew.SetChi2(cath,fChi2[0]);
            // ?? why not cnew.fChi2[cath]=fChi2[cath];
            
            if (fNPeaks == 0) {
-               cnew.fNcluster[0]=-1;
-               cnew.fNcluster[1]=fNRawClusters;
+               cnew.SetNcluster(0,-1);
+               cnew.SetNcluster(1,fNRawClusters);
            } else {
-               cnew.fNcluster[0]=fNPeaks;
-               cnew.fNcluster[1]=0;
+               cnew.SetNcluster(0,fNPeaks);
+               cnew.SetNcluster(1,0);
            }
-           cnew.fMultiplicity[cath]=0;
-           cnew.fX[cath]=Float_t(fXFit[j]);
-           cnew.fY[cath]=Float_t(fYFit[j]);
-           cnew.fZ[cath]=fZPlane;
+           cnew.SetMultiplicity(cath,0);
+           cnew.SetX(cath, Float_t(fXFit[j]));
+           cnew.SetY(cath, Float_t(fYFit[j]));
+           cnew.SetZ(cath, fZPlane);
            if (j==0) {
-               cnew.fQ[cath]=Int_t(clusterInput.TotalCharge(cath)*fQrFit[cath]);
+               cnew.SetCharge(cath, Int_t(clusterInput.TotalCharge(cath)*fQrFit[cath]));
            } else {
-               cnew.fQ[cath]=Int_t(clusterInput.TotalCharge(cath)*(1-fQrFit[cath]));
+               cnew.SetCharge(cath, Int_t(clusterInput.TotalCharge(cath)*(1-fQrFit[cath])));
            }
-           fSeg[cath]->SetHit(fXFit[j],fYFit[j],fZPlane);
+           if (fSegmentationType == 1) 
+             fSeg[cath]->SetHit(fXFit[j],fYFit[j],fZPlane);
+           else 
+             fSeg2[cath]->SetHit(fInput->DetElemId(), fXFit[j],fYFit[j],fZPlane);
+
            for (i=0; i<fMul[cath]; i++) {
-               cnew.fIndexMap[cnew.fMultiplicity[cath]][cath]=
-                   c->fIndexMap[i][cath];
-               fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]);
-               Float_t q1=fInput->Response()->IntXY(fSeg[cath]);
-               cnew.fContMap[i][cath]
-                   =(q1*Float_t(cnew.fQ[cath]))/Float_t(fQ[i][cath]);
-               cnew.fMultiplicity[cath]++;
+             Float_t q1;
+               cnew.SetIndex(cnew.GetMultiplicity(cath), cath, c->GetIndex(i,cath));
+               if (fSegmentationType == 1) {
+                 fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]);
+                 q1 = fInput->Mathieson()->IntXY(fSeg[cath]);
+               } else {
+                 fSeg2[cath]->SetPad(fInput->DetElemId(),fIx[i][cath], fIy[i][cath]);
+                 q1 = fInput->Mathieson()->IntXY(fInput->DetElemId(),fSeg2[cath]);
+               }
+               cnew.SetContrib(i, cath, q1*Float_t(cnew.GetCharge(cath))/Float_t(fQ[i][cath]));
+               cnew.SetMultiplicity(cath, cnew.GetMultiplicity(cath)+1 );
            }
            FillCluster(&cnew,0,cath);
        } // cathode loop
        
-       cnew.fClusterType=cnew.PhysicsContribution();
-       if (cnew.fQ[0]>0 && cnew.fQ[1]>0) AddRawCluster(cnew);
+       cnew.SetClusterType(cnew.PhysicsContribution());
+       if (cnew.GetCharge(0)>0 && cnew.GetCharge(1)>0) AddRawCluster(cnew);
        fNPeaks++;
     }
 }
+void AliMUONClusterFinderVS::AddRawCluster(const AliMUONRawCluster& c)
+{
+  //
+  // Add a raw cluster copy to the list
+  //
+
+//     AliMUON *pMUON=(AliMUON*)gAlice->GetModule("MUON");
+//     pMUON->GetMUONData()->AddRawCluster(fInput->Chamber(),c); 
+//     fNRawClusters++;
+
+  
+    TClonesArray &lrawcl = *fRawClusters;
+    new(lrawcl[fNRawClusters++]) AliMUONRawCluster(c);
+    AliDebug(1,Form("\nfNRawClusters %d\n",fNRawClusters));
+}
+
+AliMUONClusterFinderVS& AliMUONClusterFinderVS
+::operator = (const AliMUONClusterFinderVS& rhs)
+{
+// Protected assignement operator
 
+  if (this == &rhs) return *this;
+
+  AliFatal("Not implemented.");
+    
+  return *this;  
+}
 
 //
 // Minimisation functions
@@ -2077,47 +2446,3 @@ void fcnCombiS2(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par
     }
     f=chisq;
 }
-
-void AliMUONClusterFinderVS::AddRawCluster(const AliMUONRawCluster& c)
-{
-  //
-  // Add a raw cluster copy to the list
-  //
-
-//     AliMUON *pMUON=(AliMUON*)gAlice->GetModule("MUON");
-//     pMUON->GetMUONData()->AddRawCluster(fInput->Chamber(),c); 
-//     fNRawClusters++;
-
-  
-    TClonesArray &lrawcl = *fRawClusters;
-    new(lrawcl[fNRawClusters++]) AliMUONRawCluster(c);
-    if (fDebugLevel)
-       fprintf(stderr,"\nfNRawClusters %d\n",fNRawClusters);
-}
-
-Bool_t AliMUONClusterFinderVS::TestTrack(Int_t t) {
-// Test if track was user selected
-    if (fTrack[0]==-1 || fTrack[1]==-1) {
-       return kTRUE;
-    } else if (t==fTrack[0] || t==fTrack[1]) {
-       return kTRUE;
-    } else {
-       return kFALSE;
-    }
-}
-
-AliMUONClusterFinderVS& AliMUONClusterFinderVS
-::operator = (const AliMUONClusterFinderVS& /*rhs*/)
-{
-// Dummy assignment operator
-    return *this;
-}
-
-
-
-
-
-
-
-
-