]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSegmentationTriggerY.cxx
Code revision:
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationTriggerY.cxx
index c96efd44157967cbfd94899a5f0687fc409fee4f..92e8e8a36cc010a8679232c24b4596c80e9f4fae 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.1.2.1  2000/06/09 21:51:58  morsch
-Code from AliMUONSegResTriggerY.cxx
+/* $Id$ */
 
-*/
-
-/*
-Old Log:
-Revision 1.1.2.4  2000/05/05 10:17:04  morsch
-Y strip numerotation changed (CP)
-
-Revision 1.1.2.3  2000/04/26 12:33:40  morsch
-Minor changes in some methods (CP)
-
-Revision 1.1.2.2  2000/02/20 07:49:50  morsch
-Bugs in Dpx, Dpy and ISector methods corrected (P.C.)
-
-Revision 1.1.2.1  2000/02/17 14:34:57  morsch
-Draft version from P. Crochet
-
-*/
+#include <TMath.h>
 
 #include "AliMUONSegmentationTriggerY.h"
-#include "TMath.h"
-#include "TRandom.h"
-#include "TArc.h"
-#include "AliMUONChamber.h"
-#include <iostream.h> 
+#include "AliMUONTriggerConstants.h"
+#include "AliMUON.h"
+#include "AliRun.h"
+
 ClassImp(AliMUONSegmentationTriggerY)
 
-void AliMUONSegmentationTriggerY::Init(AliMUONChamber* Chamber)
+//------------------------------------------------------------------
+AliMUONSegmentationTriggerY::AliMUONSegmentationTriggerY()
+  : AliMUONSegmentationTrigger()
+{
+// Constructor
+}
+
+//------------------------------------------------------------------
+void AliMUONSegmentationTriggerY::Init(Int_t chamber)
 {
-  cout << "Initialize Trigger Chamber Geometry Y " << "\n";    
-  AliMUONSegmentationTrigger::Init(Chamber);
+// intialize Y segmentation 
+  AliMUON *pMUON  = (AliMUON *) gAlice->GetModule("MUON");
+  if(pMUON->GetDebug()>1) printf("%s: Initialize Trigger Chamber Geometry Y\n",ClassName());
+  AliMUONSegmentationTrigger::Init(chamber);
     
 // calculate x & y position of Y strips
-  for (Int_t imodule=0; imodule<fgNmodule; imodule++) {    
-    Float_t width=StripSizeY(fgNum[imodule]);
-    for (Int_t istrip=0; istrip<fgNstripy[imodule]; istrip++){
+  Int_t nModule=AliMUONTriggerConstants::Nmodule();  
+  for (Int_t imodule=0; imodule<nModule; imodule++) {    
+    Float_t width=StripSizeY(AliMUONTriggerConstants::ModuleId(imodule));
+    Int_t nStrip=AliMUONTriggerConstants::NstripY(imodule);    
+    for (Int_t istrip=0; istrip<nStrip; istrip++){
       if (imodule<63) {
-       fXofysmin[imodule][istrip]=(fgXcmin[imodule]+width*(istrip))*fZscale;
-       fXofysmax[imodule][istrip]=(fgXcmin[imodule]+width*(istrip+1))*fZscale;
+       fXofysmin[imodule][istrip]=
+           (AliMUONTriggerConstants::XcMin(imodule)+width*(istrip))*fZscale;
+       fXofysmax[imodule][istrip]=
+           (AliMUONTriggerConstants::XcMin(imodule)+width*(istrip+1))*fZscale;
       } else { 
        fXofysmin[imodule][istrip]=-1.*fXofysmax[imodule-63][istrip];
        fXofysmax[imodule][istrip]=-1.*fXofysmin[imodule-63][istrip];
       }      
-      fYofysmin[imodule][istrip] = fgYcmin[imodule]*fZscale;
-      fYofysmax[imodule][istrip] = fgYcmax[imodule]*fZscale;
+      fYofysmin[imodule][istrip] = fYcmin[imodule]*fZscale;
+      fYofysmax[imodule][istrip] = fYcmax[imodule]*fZscale;
     }
   }
 
 }
 
 //------------------------------------------------------------------
-void AliMUONSegmentationTriggerY::GetPadIxy(Float_t x,Float_t y,Int_t &ix,Int_t &iy){
+void AliMUONSegmentationTriggerY::GetPadI(Float_t x,Float_t y,Int_t &ix,Int_t &iy) 
+{
 //  Returns pad coordinates (ix,iy) for given real coordinates (x,y)
 //  x,y = real coordinates; ix = module number , iy = strip number
 
   ix = 0;    
   iy = 0;
-  for (Int_t imodule=0; imodule<fgNmodule; imodule++) {
-    for (Int_t istrip=0; istrip<fgNstripy[imodule]; istrip++){
+  Int_t nModule=AliMUONTriggerConstants::Nmodule();
+  for (Int_t imodule=0; imodule<nModule; imodule++) {
+      Int_t nStrip=AliMUONTriggerConstants::NstripY(imodule);      
+    for (Int_t istrip=0; istrip<nStrip; istrip++){
       if (x>fXofysmin[imodule][istrip]&&x<fXofysmax[imodule][istrip]&&
          y>fYofysmin[imodule][istrip]&&y<fYofysmax[imodule][istrip]){
-       ix = fgNum[imodule];
+       ix = AliMUONTriggerConstants::ModuleId(imodule);
        iy = istrip;
       }
     }
@@ -86,13 +83,15 @@ void AliMUONSegmentationTriggerY::GetPadIxy(Float_t x,Float_t y,Int_t &ix,Int_t
 }
 
 //------------------------------------------------------------------
-void AliMUONSegmentationTriggerY::GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y){
+void AliMUONSegmentationTriggerY::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
+{
 //  Returns real coordinates (x,y) for given pad coordinates (ix,iy)
 //  ix = module number , iy = strip number;  x,y = center of strip
   x = 0.;    
   y = 0.;
-  for (Int_t imodule=0; imodule<fgNmodule; imodule++) {
-    if (fgNum[imodule]==ix){
+  Int_t nModule=AliMUONTriggerConstants::Nmodule();
+  for (Int_t imodule=0; imodule<nModule; imodule++) {
+    if (AliMUONTriggerConstants::ModuleId(imodule)==ix){
       x=fXofysmin[imodule][iy]+(fXofysmax[imodule][iy]-fXofysmin[imodule][iy])/2.;
       y=fYofysmin[imodule][iy]+(fYofysmax[imodule][iy]-fYofysmin[imodule][iy])/2.;
     }
@@ -110,42 +109,60 @@ void AliMUONSegmentationTriggerY::SetPadSize(Float_t p1, Float_t p2)
 
 //------------------------------------------------------------------
 void AliMUONSegmentationTriggerY::
-Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[2], Int_t Ylist[2]){
-// Returns list of next neighbours for given Pad (ix, iy)  
-  Int_t absiX=TMath::Abs(iX); 
-  *Nlist = 0;
+Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]){
+// 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  
+// Note : should not be used to return a list of neighbours larger than 16 !
+
+  Int_t absiX = TMath::Abs(iX); 
+  Int_t numModule = ModuleNumber(absiX);   // module number Id.
+  Int_t nStrip = AliMUONTriggerConstants::NstripY(numModule); //numb of strips
+  Int_t iCandidateLeft, iCandidateRight;
+  Int_t iNewCandidateRight=0; 
+  Int_t iNewCandidateLeft=0;
+// first strip number on the right of the left module  
+  if ( (absiX-(Int_t(absiX/10))*10)!=1 && absiX!=52 ) 
+    iNewCandidateLeft = 
+      AliMUONTriggerConstants::NstripY(ModuleNumber(absiX-1))-1;
+  Int_t j;
   
-  if (absiX!=0) {                         
-    Int_t numModule=ModuleNumber(absiX);
-    
-    if (iY==fgNstripy[numModule]-1) {                      // strip right 
-      if (absiX%10!=7) {
-       *Nlist=1;
-       Xlist[0]=absiX+1;
-       Ylist[0]=0;
-      } 
-    } else {
-      *Nlist=1;
-      Xlist[0]=absiX;
-      Ylist[0]=iY+1;
-    }
-    
-    if (iY==0) {                                            // strip left 
-      if (absiX%10!=1&&absiX!=52) {
-       *Nlist=*Nlist+1;
-       Xlist[*Nlist-1]=absiX-1;
-       Ylist[*Nlist-1]=fgNstripy[numModule-1]-1;
-      } 
-    } else {
-      *Nlist=*Nlist+1;
-      Xlist[*Nlist-1]=absiX;
-      Ylist[*Nlist-1]=iY-1;
+  *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 ((absiX+1)%10!=8) {   // 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<*Nlist; i++) {Xlist[i]=-Xlist[i];}
+      for (Int_t i=0; i<10; i++) { 
+       if (Xlist[i]!=0) Xlist[i]=-Xlist[i]; 
+      }
     }
-  }     
+    
+  } // iY < nStrip    
 }
 
 //------------------------------------------------------------------   
@@ -153,27 +170,29 @@ void AliMUONSegmentationTriggerY::SetPad(Int_t ix, Int_t iy)
 {
   // Sets virtual pad coordinates, needed for evaluating pad response 
   // outside the tracking program 
-  GetPadCxy(ix,iy,fx,fy);
-  GetPadIxy(fx,fy,fix,fiy);
+  GetPadC(ix,iy,fX,fY);
+  GetPadI(fX,fY,fIx,fIy);
   fSector=Sector(ix,iy);    
 }
 
 //------------------------------------------------------------------   
-Int_t AliMUONSegmentationTriggerY::ISector()
+Int_t AliMUONSegmentationTriggerY::ISector() 
 { return fSector;}
 
 //------------------------------------------------------------------   
+
 Int_t AliMUONSegmentationTriggerY::Ix()
-{ return fix;}
+{ return fIx;}
 
 //------------------------------------------------------------------   
+
 Int_t AliMUONSegmentationTriggerY::Iy()
-{ return fiy;}
+{ return fIy;}
 
 //------------------------------------------------------------------
-Float_t AliMUONSegmentationTriggerY::Dpx(Int_t isec)
-{ // returns x size of y strips for sector isec
-
+Float_t AliMUONSegmentationTriggerY::Dpx(Int_t isec) const
+{ 
+// returns x size of y strips for sector isec
   if (isec==1) {
     return 2.125*fZscale;
   } else if (isec==2) {
@@ -188,10 +207,9 @@ Float_t AliMUONSegmentationTriggerY::Dpx(Int_t isec)
 }
 
 //------------------------------------------------------------------
-Float_t AliMUONSegmentationTriggerY::Dpy(Int_t isec)
-{ // returns y size of y strips for sector isec
-    // cout << " In AliMUONSegmentationTriggerX::Dpx" << "\n";  
-
+Float_t AliMUONSegmentationTriggerY::Dpy(Int_t isec) const
+{ 
+// returns y size of y strips for sector isec
   if (isec==1) {
     return 68.0*fZscale;
   } else if (isec==2) {
@@ -205,21 +223,32 @@ Float_t AliMUONSegmentationTriggerY::Dpy(Int_t isec)
   } else {
     return 0.;
   }
-
+}
+//------------------------------------------------------------------   
+void AliMUONSegmentationTriggerY::GetPadI(Float_t x, Float_t y, Float_t /*z*/, Int_t &ix, Int_t &iy) 
+{
+  GetPadI(x, y, ix, iy);
 }
 
 //------------------------------------------------------------------   
 void AliMUONSegmentationTriggerY::SetHit(Float_t xhit, Float_t yhit)
-{ AliMUONSegmentationTrigger::SetHit(xhit,yhit);}
-
+{ 
+// set hits during diintegration
+  AliMUONSegmentationTrigger::SetHit(xhit,yhit);
+}
+//------------------------------------------------------------------   
+void AliMUONSegmentationTriggerY::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
+{
+  SetHit(xhit, yhit);
+}
 //------------------------------------------------------------------   
-Int_t AliMUONSegmentationTriggerY::Sector(Int_t ix, Int_t iy)
+Int_t AliMUONSegmentationTriggerY::Sector(Int_t ix, Int_t /*iy*/)
 {
 // Returns sector number for given module
 // 
   Int_t absix=TMath::Abs(ix);
   Int_t iwidth=Int_t(StripSizeY(absix));
-    
+
   if (absix==52) {
     return 1;
   } else if (absix==41||absix==61) {
@@ -235,17 +264,26 @@ Int_t AliMUONSegmentationTriggerY::Sector(Int_t ix, Int_t iy)
 
 //------------------------------------------------------------------   
 void AliMUONSegmentationTriggerY::
-IntegrationLimits(Float_t& x1, Float_t& x2, Float_t& x3, Float_t& width
+IntegrationLimits(Float_t& x1, Float_t& x2, Float_t& x3, Float_t& x4
 { 
 // returns quantities needed to evaluate neighbour strip response
   Int_t ix,iy;
   Float_t xstrip,ystrip;
-  GetPadIxy(fxhit,fyhit,ix,iy);  
-  GetPadCxy(ix,iy,xstrip,ystrip);  
-  x1=fxhit;        // hit x position
+  GetPadI(fXhit,fYhit,ix,iy);  
+  GetPadC(ix,iy,xstrip,ystrip);  
+  x1=fXhit;        // hit x position
   x2=xstrip;       // x coordinate of the main strip
-  x3=fx;           // current strip real x coordinate  
-  width=StripSizeY(ix);   // width of the main strip 
+  x3=fX;           // current strip real x coordinate  
+  //  width=StripSizeY(ix);   // width of the main strip 
+
+  // find the position of the 2 borders of the current strip
+  Float_t xmin = fXofysmin[ModuleNumber(fIx)][fIy];
+  Float_t xmax = fXofysmax[ModuleNumber(fIx)][fIy];
+
+  // dist. between the hit and the closest border of the current strip
+  x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ? 
+    TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);    
+
 }