]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerSegmentation.cxx
New TGeo features allow us to avoid the use of MANY.
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerSegmentation.cxx
index 12435a1e36157229b084a15e6c48c34cf662e433..695710185a46d1e93d27c61f4f8ce61cf28018df 100644 (file)
 
 /* $Id$ */
 
+//**********************************************************************
+// Segmentation classe for trigger chambers.
+// In the present version the method use global strip coordinates except
+// HasPad. The conversion is made via GetPadLoc2Glo.
+// To be improved in the future.
+//**********************************************************************
 
-#include <TArrayI.h>
-#include <TArrayF.h>
 #include "AliMUONTriggerSegmentation.h"
 #include "AliLog.h"
+#include "Riostream.h"
 
 //___________________________________________
 ClassImp(AliMUONTriggerSegmentation)
@@ -28,25 +33,15 @@ AliMUONTriggerSegmentation::AliMUONTriggerSegmentation()
   : AliMUONVGeometryDESegmentation(),
     fBending(0),
     fId(0),
-    fNsec(0),
-    fNDiv(0),
-    fDpxD(0),
-    fDpyD(0), 
-    fDpx(0),
-    fDpy(0),
+    fNsec(7),
     fNpx(999999),
     fNpy(999999),
-    fWireD(0.25),
     fXhit(0.),
     fYhit(0.),
     fIx(0),
     fIy(0),
     fX(0.),
     fY(0.),
-    fIxmin(0),
-    fIxmax(0),
-    fIymin(0),
-    fIymax(0),
 // add to St345SlatSegmentation
     fLineNumber(0),
     fRpcHalfXsize(0),
@@ -61,6 +56,8 @@ AliMUONTriggerSegmentation::AliMUONTriggerSegmentation()
       fModuleXmax[i]=0.;  
       fModuleYmin[i]=0.;  
   }
+
+  AliDebug(1, Form("default (empty) ctor this = %p", this));
 }
 
 
@@ -69,34 +66,21 @@ AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending)
   : AliMUONVGeometryDESegmentation(),
     fBending(bending),
     fId(0),
-    fDpx(0),
-    fDpy(0),
     fNpx(999999),
     fNpy(999999),
-    fWireD(0.25),
     fXhit(0.),
     fYhit(0.),
     fIx(0),
     fIy(0),
     fX(0.),
     fY(0.),
-    fIxmin(0),
-    fIxmax(0),
-    fIymin(0),
-    fIymax(0),
 // add to St345SlatSegmentation
     fLineNumber(0),
     fRpcHalfXsize(0),
     fRpcHalfYsize(0)
 {
   // Non default constructor
-  fNsec = 4;  // 4 sector densities at most per slat 
-  fNDiv = new TArrayI(fNsec);      
-  fDpxD = new TArrayF(fNsec);      
-  fDpyD = new TArrayF(fNsec);      
-  (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;     
-  (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;       
-  (*fDpyD)[0]=(*fDpyD)[1]=(*fDpyD)[2]=(*fDpyD)[3]=0;       
+  fNsec = 7;  
 // add to St345SlatSegmentation
   for (Int_t i=0; i<7; i++) {
       fNstrip[i]=0;
@@ -106,6 +90,8 @@ AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending)
       fModuleXmax[i]=0.;  
       fModuleYmin[i]=0.;  
   }
+
+  AliDebug(1, Form("ctor this = %p", this) ); 
 }
 
 //----------------------------------------------------------------------
@@ -117,10 +103,8 @@ AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(const AliMUONTriggerSegme
 AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation() 
 {
   // Destructor
-/*  if (fNDiv) delete fNDiv;
-  if (fDpxD) delete fDpxD;
-  if (fDpyD) delete fDpyD;
-*/
+
+  AliDebug(1, Form("dtor this = %p", this) ); 
 }
 //----------------------------------------------------------------------
 AliMUONTriggerSegmentation& AliMUONTriggerSegmentation::operator=(const AliMUONTriggerSegmentation& rhs)
@@ -131,126 +115,133 @@ AliMUONTriggerSegmentation& AliMUONTriggerSegmentation::operator=(const AliMUONT
   return *this;  
 }
 //----------------------------------------------------------------------
+Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ix)
+{
+// returns column number (from 0 to 6) in which the (global) module 
+// ix is sitting (could return 7 if ix=isec)
+    return TMath::Abs(ix)-Int_t(TMath::Abs(ix)/10)*10-1;
+}
+//----------------------------------------------------------------------
 Bool_t AliMUONTriggerSegmentation::HasPad(Int_t ix, Int_t iy)
 {
-// check if steping outside the limits
-    Bool_t hasPad=true;    
-    Int_t ixLoc = ix;
-    Int_t iyLoc = iy;    
+// check if steping outside the limits (iy=1,2... iy=0,1...)
+    Bool_t hasPad = true;    
     Int_t ixGlo = 0;
-    Int_t iyGlo = 0;    
-    GetPadLoc2Glo(ixLoc, iyLoc, ixGlo, iyGlo);
-    Int_t iModule = TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10 - 1;    
-    if ((iy-1)>=fNstrip[iModule]) hasPad = false;
+    Int_t iyGlo = 0; 
+    GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
+    if (iyGlo>=fNstrip[ModuleColNum(ixGlo)]) hasPad = false;
     return hasPad;    
 }
 //____________________________________________________________________________
 Float_t AliMUONTriggerSegmentation::Dpx(Int_t isec) const
 {
-// Return x-strip width
-    Float_t size = 0.;    
-    Int_t iModule = TMath::Abs(isec)-Int_t(TMath::Abs(isec)/10)*10 - 1;    
-//    printf ("iModule = %i\n",iModule);    
-
-    if (iModule<7) {   
-       size = fStripXsize[iModule];    
-    } else if (iModule==7) {
-       size = fStripXsize[iModule-1]/2;        
-    }    
-    return size;    
+// return x-strip width in sector isec
+    Float_t size = (isec<8) ? fStripXsize[isec-1] : fStripXsize[isec-2]/2.;
+    return size;
 }
 //____________________________________________________________________________
 Float_t AliMUONTriggerSegmentation::Dpy(Int_t  isec) const
 {
-// Return y-strip width
-    Float_t size = 0.;    
-    Int_t iModule = TMath::Abs(isec)-Int_t(TMath::Abs(isec)/10)*10 - 1;
-    if (iModule<7) {   
-       size = fStripYsize[iModule];    
-    } else if (iModule==7) {
-       size = fStripYsize[iModule-1];  
-    } 
-    return size;    
+// return y-strip width in sector isec
+    Float_t size = (isec<8) ? fStripYsize[isec-1] : fStripYsize[isec-2];
+    return size;
 }
 //----------------------------------------------------------------------------
 void AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ixLoc, Int_t iyLoc, 
                                               Int_t &ixGlo, Int_t &iyGlo)
 {    
 // converts ixLoc & iyLoc into ixGlo & iyGLo (module,strip number)
-    ixGlo = 0;
-    iyGlo = 0;    
+    ixGlo = 0; // see AliMUONTriggerConstants::fgkModuleI
+    iyGlo = 0; // from 0 to (fNtrip-1) in module   
     if (fBending) { 
-       ixGlo = (10 * fLineNumber) + ixLoc;
+       ixGlo = 10*fLineNumber + ixLoc;
        iyGlo = iyLoc - 1;
     } else if (!fBending) {    
        Int_t iCountStrip = 0;  
-       for (Int_t iModule=0; iModule<7; iModule++) {           
+       for (Int_t iModule=0; iModule<fNsec; iModule++) {               
            for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
                if ((ixLoc-1)==iCountStrip) {
-                   ixGlo = (10 * fLineNumber) + iModule + 1;
+                   ixGlo = 10*fLineNumber + iModule + 1;
                    iyGlo = iStrip;
                }
                iCountStrip++;
            }
        }
     }
-//    printf(" in GetPadLoc2Glo ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",ixLoc,iyLoc,ixGlo,iyGlo);
-    
+//    printf(" in GetPadLoc2Glo fbending ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",fBending,ixLoc,iyLoc,ixGlo,iyGlo);
 }
+
+//----------------------------------------------------------------------------
+void AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo, 
+                                              Int_t &ixLoc, Int_t &iyLoc)
+{    
+// converts ixGlo & iyGlo into ixLoc & iyLoc 
+    ixLoc = 0; 
+    iyLoc = 0; 
+    if (fBending) { 
+       ixLoc = ModuleColNum(ixGlo) + 1;
+       iyLoc = iyGlo + 1;
+    } else if (!fBending) {    
+       Int_t iCountStrip = 1;  
+       for (Int_t iModule=0; iModule<fNsec; iModule++) {               
+           for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
+               if ((iModule==ModuleColNum(ixGlo))&&(iStrip==iyGlo)) {
+                   iyLoc = 1;              
+                   ixLoc = iCountStrip;
+               }               
+               iCountStrip++;
+           }
+       }
+    }    
+//    printf(" in GetPadGlo2Loc fBending ixGlo iyGlo ixLoc iyLoc %i %i %i %i %i \n",fBending,ixGlo,iyGlo,ixLoc,iyLoc);
+}
+
 //----------------------------------------------------------------------------
 void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y) 
 {
-    Int_t ixLoc = ix;
-    Int_t iyLoc = iy;    
-    Int_t ixGlo = 0;
-    Int_t iyGlo = 0;    
-    GetPadLoc2Glo(ixLoc, iyLoc, ixGlo, iyGlo);
-    ix = ixGlo;
-    iy = iyGlo;
-    
-// Returns real coordinates (x,y) for given pad coordinates (ix,iy)
+// Returns local real coordinates (x,y) for local pad coordinates (ix,iy)
+
     x = 0.;
     y = 0.;
-// find module number    
-    Int_t iModule = TMath::Abs(ix)-Int_t(TMath::Abs(ix)/10)*10 - 1;
+    Int_t iModule = ModuleColNum(ix); // find column number (0-6)
     if (fBending) {
        if (iModule==0) {
-           x = (fModuleXmax[iModule] - fModuleXmin[iModule]) / 2.;
+           x =  fStripXsize[iModule]/ 2.;
        } else {        
-       x = fModuleXmax[iModule-1] +
-           (fModuleXmax[iModule] - fModuleXmin[iModule]) / 2.;
-       }       
+       x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
+       }
        y =  fModuleYmin[iModule] + 
-           (iy * fStripYsize[iModule]) + fStripYsize[iModule]/2.;
+           iy*fStripYsize[iModule] + fStripYsize[iModule]/2.;
     } else if (!fBending) {
-       if (TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10==7 && iyGlo>7) {
-           x = fModuleXmin[iModule] + 7 * fStripXsize[iModule] +
-               ( (iy -8)* fStripXsize[iModule]/2.) + fStripXsize[iModule]/4.;
-           y =  fModuleYmin[iModule] + fStripYsize[iModule] / 2.;      
+       if (ModuleColNum(ix)==6 && iy>7) {
+           x = fModuleXmin[iModule] + 8*fStripXsize[iModule] +
+               (iy-8)*fStripXsize[iModule]/2. + fStripXsize[iModule]/4.;
        } else {            
            x = fModuleXmin[iModule] + 
-               (iy * fStripXsize[iModule]) + fStripXsize[iModule]/2.;
-           y =  fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
+               iy*fStripXsize[iModule] + fStripXsize[iModule]/2.;
        }
+       y =  fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
     }    
     x = x - fRpcHalfXsize;
     y = y - fRpcHalfYsize;
 
-//    printf(" in GetPadC iModule ixloc iyloc ix iy x y %i %i %i %i %i %f %f \n",iModule,ixLoc,iyLoc,ix,iy,x,y);
+//    printf(" in GetPadC fBending ix iy x y %i %i %i %f %f \n",fBending,ix,iy,x,y);
 }
 
 //_____________________________________________________________________________
 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy) 
 {
-//  Returns pad coordinates (ix,iy) for given real coordinates (x,y)
+//  Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
+    ix = -1;
+    iy = -1;
 
     x = x + fRpcHalfXsize;
     y = y + fRpcHalfYsize;
 // find module number    
     Int_t modNum=0;    
-    for (Int_t iModule=0; iModule<7; iModule++) { // modules
+    for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
        if ( x > fModuleXmin[iModule] && x < fModuleXmax[iModule] ) {
-           ix = (10 * fLineNumber) + iModule;
+           ix = 10*fLineNumber + iModule + 1;
            modNum = iModule;       
        }
     }
@@ -266,57 +257,43 @@ void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t
                yMin = yMax;
                yMax = yMin + fStripYsize[modNum];
                if (y > yMin && y < yMax) iy = iStrip;
-           } else {
+           } else if (!fBending) {
                xMin = xMax;
-               xMax = xMin + fStripXsize[modNum];
+               if (modNum==6 && iStrip>7) {
+                   xMax = xMin + fStripXsize[modNum]/2.;
+               } else {                    
+                   xMax = xMin + fStripXsize[modNum];
+               }               
                if (x > xMin && x < xMax) iy = iStrip;
-           }
+           } //
        } // loop on strips
     } // if ix!=0
-//    printf("in GetPadI ix iy x y %i %i %f %f \n",ix,iy,x,y);
+//    printf("in GetPadI fBending x y ix iy %i %f %f %i %i \n",fBending,x,y,ix,iy);
 }
 //-------------------------------------------------------------------------
 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
 {
   GetPadI(x, y, ix, iy);
 }
-//____________________________________________________________________________
-void AliMUONTriggerSegmentation::SetPadSize(Float_t p1, Float_t p2)
-{
-//  Sets the padsize 
-    fDpx=p1;
-    fDpy=p2;
-}
+
 //-------------------------------------------------------------------------
 void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
     fLineNumber = iLineNumber;    
 }
 //-------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::SetNstrip(Int_t nStrip[7]){
-    for (Int_t i=0; i<7; i++) fNstrip[i]=nStrip[i];
-}
-//-------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::SetStripYsize(Float_t stripYsize[7]){
-    for (Int_t i=0; i<7; i++) fStripYsize[i]=stripYsize[i];
-}
-//-------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::SetStripXsize(Float_t stripXsize[7]){
-    for (Int_t i=0; i<7; i++) fStripXsize[i]=stripXsize[i];
-}
-//-------------------------------------------------------------------------
 void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
 {
-  //
   // Sets virtual pad coordinates, needed for evaluating pad response 
   // outside the tracking program 
   GetPadC(ix,iy,fX,fY);
+  fIx = ix; // used in IntegrationLimits
+  fIy = iy;    
   fSector=Sector(ix,iy);
 }
 //---------------------------------------------------------------------------
 void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
 {
   // Set current hit 
-  //
   fXhit = x;
   fYhit = y;
 }
@@ -329,61 +306,156 @@ void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zh
 //--------------------------------------------------------------------------
 Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy) 
 {
-  // Determine segmentation zone from pad coordinates
-    Int_t ixLoc = ix;
-    Int_t iyLoc = iy;    
-    Int_t ixGlo = 0;
-    Int_t iyGlo = 0;    
-    GetPadLoc2Glo(ixLoc, iyLoc, ixGlo, iyGlo);    
-    if (!fBending && 
-       TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10==7 && iyGlo>7) {
-       return ixGlo + 1; // different strip width within same module    
+// determine segmentation zone from pad coordinates (from 1 to 8)
+    if (!fBending && ModuleColNum(ix)==6 && iy>7) {
+       return 8; // sector 8: diff. strip width within same module
     } else {
-       return ixGlo;
-    }  
+       return ModuleColNum(ix)+1;
+    }
 }
 
 //-----------------------------------------------------------------------------
-void AliMUONTriggerSegmentation::
-IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2
+void AliMUONTriggerSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,
+                                                   Float_t& x3, Float_t& x4
 {
-  //  Returns integration limits for current pad
-  //
-  x1=fXhit-fX-Dpx(fSector)/2.;
-  x2=x1+Dpx(fSector);
-  y1=fYhit-fY-Dpy(fSector)/2.;
-  y2=y1+Dpy(fSector);    
-  //    printf("\n Integration Limits %f %f %f %f %d %f", x1, x2, y1, y2, fSector, Dpx(fSector));
-
+// need to return (only) x4 = dist. betwwen the hit and the closest border of
+// the current strip
+
+    Int_t ix,iy;
+    Float_t xstrip,ystrip;
+    GetPadI(fXhit,fYhit,ix,iy);
+    GetPadC(ix,iy,xstrip,ystrip);
+    AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
+                    fXhit,fYhit,xstrip,ystrip));
+    x1= (fBending) ? fYhit : fXhit;  // hit y (bending) / x (!bending) position
+    x2= (fBending) ? ystrip : xstrip; // y or x coord. of the main strip
+    x3= (fBending) ? fY : fX;          // current strip real y or x coord.
+    Int_t modNum = ModuleColNum(fIx);
+
+    // find the position of the 2 borders of the current strip
+    Float_t min = 0.;
+    Float_t max = 0.;    
+    if (fBending) {
+       min = x3 - fStripYsize[modNum]/2.;
+       max = x3 + fStripYsize[modNum]/2.;      
+    } else {
+       if (modNum==6 && fIy>7) { // equivalent to fSector == 8
+           min = x3 - fStripXsize[modNum]/4.;
+           max = x3 + fStripXsize[modNum]/4.;  
+       } else 
+           min = x3 - fStripXsize[modNum]/2.;
+           max = x3 + fStripXsize[modNum]/2.;          
+    }    
+    // dist. between the hit and the closest border of the current strip
+    x4 = (TMath::Abs(max-x1) > TMath::Abs(min-x1)) ? 
+      TMath::Abs(min-x1):TMath::Abs(max-x1);
+  
+    AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
+                    fBending,x1,x2,x3,x4,min,max));
 }
+
+
 //-----------------------------------------------------------------------------
 void AliMUONTriggerSegmentation::
 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]) 
 {
-  // Returns list of next neighbours for given Pad (iX, iY)
-  Int_t i=0;
-  //  step right
-  if (iX+1 <= fNpx) {
-    Xlist[i]=iX+1;
-    Ylist[i++]=iY;
-  }
-  //  step left    
-  if (iX-1 > 0) {
-    Xlist[i]=iX-1;
-    Ylist[i++]=iY;
-  } 
-  Int_t sector = Sector(iX,iY);
-  //  step up
-  if (iY+1 <= fNpyS[sector]) {
-    Xlist[i]=iX;
-    Ylist[i++]=iY+1;
-  }
-  //  step down    
-  if (iY-1 > 0) {
-    Xlist[i]=iX;
-    Ylist[i++]=iY-1;
-  }
-  *Nlist=i;
+//-----------------BENDING-----------------------------------------
+// Returns list of 10 next neighbours for given X strip (ix, iy)  
+// neighbour number 4 in the list -                     
+// neighbour number 3 in the list  |                    
+// neighbour number 2 in the list  |_ Upper part             
+// neighbour number 1 in the list  |            
+// neighbour number 0 in the list -           
+//      X strip (ix, iy) 
+// neighbour number 5 in the list -       
+// neighbour number 6 in the list  | _ Lower part
+// neighbour number 7 in the list  |
+// neighbour number 8 in the list  | 
+// neighbour number 9 in the list -
+
+//-----------------NON-BENDING-------------------------------------
+// Returns list of 10 next neighbours for given Y strip (ix, iy)  
+// neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
+//                  \_______/                    \_______/
+//                    left                         right
+
+    Int_t absiX = TMath::Abs(iX); 
+    Int_t modNum = ModuleColNum(absiX); // from 0 to 6
+    Int_t nStrip = fNstrip[modNum];    
+    
+    if (fBending) {
+       Int_t iCandidateUp, iCandidateDo;
+       Int_t j;
+       
+       *Nlist = 10;
+       for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
+       
+       if (iY < nStrip) {          
+           for (Int_t i=0; i<5; i++) {
+               j = i + 5;
+               iCandidateUp = iY + (i + 1);
+               iCandidateDo = iY - (i + 1);
+               if (iCandidateUp < nStrip) { 
+                   Xlist[i] = iX;
+                   Ylist[i] = iCandidateUp;  
+               }
+               if (iCandidateDo >= 0) { 
+                   Xlist[j] = iX;
+                   Ylist[j] = iCandidateDo;  
+               }
+           }       
+       } // iY < nStrip        
+
+    } else { // non-bending
+        
+      Int_t iCandidateLeft, iCandidateRight;
+      Int_t iNewCandidateRight=0; 
+      Int_t iNewCandidateLeft=0;
+// first strip number on the right of the left module  
+      if ( modNum!=0 && absiX!=52 ) 
+         iNewCandidateLeft = fNstrip[modNum-1]-1;
+      Int_t j;
+      
+      *Nlist = 10;
+      for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
+      
+      if (iY < nStrip) {
+         
+         for (Int_t i=0; i<5; i++) {
+             j = i + 5;
+             iCandidateRight = iY + (i + 1);
+             iCandidateLeft  = iY - (i + 1);
+             if (iCandidateRight < nStrip) { // strip in same module  
+                 Xlist[i] = absiX;
+                 Ylist[i] = iCandidateRight;  
+             } else if (modNum!=6) {   // need to scan the module on the right
+                 Xlist[i] = absiX+1;
+                 Ylist[i] = iNewCandidateRight;  
+                 iNewCandidateRight++;
+             }
+             
+             if (iCandidateLeft >=0 ) { // strip in same module
+                 Xlist[j] = absiX;
+                 Ylist[j] = iCandidateLeft;  
+             } else if ( iNewCandidateLeft !=0) {
+                 Xlist[j] = absiX-1;
+                 Ylist[j] = iNewCandidateLeft;  
+                 iNewCandidateLeft--;
+             }
+         }
+         
+         if (iX<0) {                                  // left side of chamber 
+             for (Int_t i=0; i<10; i++) { 
+                 if (Xlist[i]!=0) Xlist[i]=-Xlist[i]; 
+             }
+         }
+         
+      } // iY < nStrip
+    } // non-bending
+
+//    for (Int_t i=0; i<10; i++) {
+//     printf("AliMUONTriggerSegmentation LOC fBending i ix iy = %i %i %i %i \n",fBending,i,Xlist[i],Ylist[i]);
+//   }
 }
 
 //--------------------------------------------------------------------------
@@ -409,7 +481,7 @@ void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
     
     Float_t tmp = 0.;  
     Int_t npad = 0;  // number of pad in x and y
-    for (Int_t iModule=0; iModule<7; iModule++) { // modules   
+    for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules       
        fModuleXmin[iModule] = tmp;      
        npad = npad + fNstrip[iModule];
        if (fBending) {
@@ -418,7 +490,8 @@ void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
        } else if (!fBending) {
            if (iModule<6) {
                fModuleXmax[iModule] = 
-                   fModuleXmin[iModule] + fStripXsize[iModule]*fNstrip[iModule];
+                   fModuleXmin[iModule] + 
+                   fStripXsize[iModule]*fNstrip[iModule];
            } else if (iModule==6) { 
                fModuleXmax[iModule] = 
                    fModuleXmin[iModule] + 
@@ -435,22 +508,18 @@ void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
            for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
        }
     } // loop on modules
-    
 
 // associate nStripMax
-  if (fBending) {
-      fNpx = 7;
-      fNpy = nStripMax;      
-  } else if (!fBending) {
-      fNpx = nStripMax;
-      fNpy = 1;      
-  }  
+//   fNpx = (fBending) ? fNsec : nStripMax;
+//   fNpy = (fBending) ? nStripMax : 1;
+    fNpx = 124; // tot num of modules (like with old segmentation)
+    fNpy = 64; // max number of y strips within one module
 
-// calculate half size in x & y (to shift the local coordinate ref. system)
+// calculate half size in x & y (to shift local coordinate ref. system)
   fRpcHalfXsize = 0;
   fRpcHalfYsize = 0;  
   if (fBending) {
-      for (Int_t iModule=0; iModule<7; iModule++)  
+      for (Int_t iModule=0; iModule<fNsec; iModule++)  
          fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];      
       fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
   } else if (!fBending) {
@@ -463,31 +532,45 @@ void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
 /*
   printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
         fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
-*/
 
-/*
-  for (Int_t iModule=0; iModule<7; iModule++) {
+  for (Int_t iModule=0; iModule<fNsec; iModule++) {
       printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
             iModule,fModuleXmin[iModule],fModuleXmax[iModule],
             fModuleYmin[iModule],
             fStripXsize[iModule],fStripYsize[iModule]);
             }
 
-  for (Int_t iModule=0; iModule<7; iModule++) {
+  for (Int_t iModule=0; iModule<fNsec; iModule++) {
       printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
             iModule,fNstrip[iModule],
             fStripXsize[iModule],fStripYsize[iModule]);
   }
 */
 
-  
-
-//  printf("npad = %i",npad);  
-
   fId = detectionElementId;
 }
 
-
+//_____________________________________________________________________________
+void
+AliMUONTriggerSegmentation::Print(Option_t*) const
+{
+  cout << "fId=" << fId << " fBending=" << fBending << " fNsec=" 
+  << fNsec << " Nx,Ny=" << fNpx << "," << fNpy 
+  << " LineNumber=" << fLineNumber 
+  << " fRpcHalfSize(X,Y)=" << fRpcHalfXsize << "," << fRpcHalfYsize
+  << endl;
+  
+  for (Int_t iModule=0; iModule<fNsec; iModule++) 
+  { 
+    cout << "Module " << iModule 
+    << " xmin,xmax=" << fModuleXmin[iModule] 
+    << "," << fModuleXmax[iModule] 
+    << " ymin=" << fModuleYmin[iModule]
+    << " StripSize(X,Y)=(" << fStripXsize[iModule] << ","
+    << fStripYsize[iModule] << ")"
+    << endl;
+  }                    
+}