]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSegmentationTriggerY.cxx
properly take care of chamber edges in GetPadI
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationTriggerY.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 #include <TMath.h>
19
20 #include "AliMUONSegmentationTriggerY.h"
21 #include "AliMUONTriggerConstants.h"
22 #include "AliMUON.h"
23 #include "AliRun.h"
24 #include "AliLog.h"
25
26 ClassImp(AliMUONSegmentationTriggerY)
27
28 //------------------------------------------------------------------
29 AliMUONSegmentationTriggerY::AliMUONSegmentationTriggerY()
30   : AliMUONSegmentationTrigger()
31 {
32 // Constructor
33 }
34
35 //------------------------------------------------------------------
36 void AliMUONSegmentationTriggerY::Init(Int_t chamber)
37 {
38 // intialize Y segmentation 
39   AliDebug(2,"Initialize Trigger Chamber Geometry Y");
40   AliMUONSegmentationTrigger::Init(chamber);  
41
42 // calculate x & y position of Y strips
43   Int_t nModule=AliMUONTriggerConstants::Nmodule();  
44   for (Int_t imodule=0; imodule<nModule; imodule++) { 
45       Int_t moduleId=AliMUONTriggerConstants::ModuleId(imodule);      
46       Int_t nStrip=AliMUONTriggerConstants::NstripY(imodule);
47       for (Int_t istrip=0; istrip<nStrip; istrip++){
48           Float_t width=StripSizeY(moduleId,istrip);
49
50           if (imodule<63) {
51               if (moduleId-10*Int_t(moduleId/10.)==7&&istrip>7) {
52                   fXofysmin[imodule][istrip]=
53                       ( AliMUONTriggerConstants::XcMin(imodule)+
54                         (width*2.)*8 + width*(istrip-8) )*fZscale;
55                   fXofysmax[imodule][istrip]=
56                       ( AliMUONTriggerConstants::XcMin(imodule)+
57                         (width*2.)*8 + width*(istrip-7) )*fZscale;
58               } else {        
59                   fXofysmin[imodule][istrip]=
60                       (AliMUONTriggerConstants::XcMin(imodule)
61                        +width*(istrip))*fZscale;
62                   fXofysmax[imodule][istrip]=
63                       (AliMUONTriggerConstants::XcMin(imodule)
64                        +width*(istrip+1))*fZscale;
65                   
66               }
67               
68           } else {      
69               fXofysmin[imodule][istrip]=-1.*fXofysmax[imodule-63][istrip];
70               fXofysmax[imodule][istrip]=-1.*fXofysmin[imodule-63][istrip];
71           }      
72           fYofysmin[imodule][istrip] = fYcmin[imodule]*fZscale;
73           fYofysmax[imodule][istrip] = fYcmax[imodule]*fZscale;
74       }
75   }  
76 /*
77           if (TMath::Abs(AliMUONTriggerConstants::ModuleId(imodule))==11) {
78               printf("module Id istrip fXofxsmin fXofxsmax fYofxsmin fYofxsmax %d %d %f %f %f %f \n",
79                      AliMUONTriggerConstants::ModuleId(imodule),
80                      istrip,
81                      fXofysmin[imodule][istrip],
82                      fXofysmax[imodule][istrip],
83                      fYofysmin[imodule][istrip],
84                      fYofysmax[imodule][istrip]);
85           }
86 */
87
88 }
89
90
91 //------------------------------------------------------------------
92 void AliMUONSegmentationTriggerY::GetPadI(Float_t x,Float_t y,Int_t &ix,Int_t &iy) 
93 {
94 //  Returns pad coordinates (ix,iy) for given real coordinates (x,y)
95 //  x,y = real coordinates; ix = module number , iy = strip number
96
97   ix = 0;    
98   iy = 0;
99   Int_t nModule=AliMUONTriggerConstants::Nmodule();
100   for (Int_t imodule=0; imodule<nModule; imodule++) {
101       Int_t nStrip=AliMUONTriggerConstants::NstripY(imodule);      
102     for (Int_t istrip=0; istrip<nStrip; istrip++){
103       if (x>fXofysmin[imodule][istrip]&&x<fXofysmax[imodule][istrip]&&
104           y>fYofysmin[imodule][istrip]&&y<fYofysmax[imodule][istrip]){
105         ix = AliMUONTriggerConstants::ModuleId(imodule);
106         iy = istrip;
107       }
108     }
109   }
110 }
111
112 //------------------------------------------------------------------
113 void AliMUONSegmentationTriggerY::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
114 {
115 //  Returns real coordinates (x,y) for given pad coordinates (ix,iy)
116 //  ix = module number , iy = strip number;  x,y = center of strip
117   x = 0.;    
118   y = 0.;
119   Int_t nModule=AliMUONTriggerConstants::Nmodule();
120   for (Int_t imodule=0; imodule<nModule; imodule++) {
121     if (AliMUONTriggerConstants::ModuleId(imodule)==ix){
122       x=fXofysmin[imodule][iy]+(fXofysmax[imodule][iy]-fXofysmin[imodule][iy])/2.;
123       y=fYofysmin[imodule][iy]+(fYofysmax[imodule][iy]-fYofysmin[imodule][iy])/2.;
124     }
125   }
126 }
127
128 //------------------------------------------------------------------
129 void AliMUONSegmentationTriggerY::SetPadSize(Float_t p1, Float_t p2)
130 {
131 //  Sets the padsize 
132 //  
133   fDpx=p1;
134   fDpy=p2;
135 }
136
137 //------------------------------------------------------------------
138 void AliMUONSegmentationTriggerY::
139 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]){
140 // Returns list of 10 next neighbours for given Y strip (ix, iy)  
141 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
142 //                  \_______/                    \_______/
143 //                    left                         right  
144 // Note : should not be used to return a list of neighbours larger than 16 !
145
146   Int_t absiX = TMath::Abs(iX); 
147   Int_t numModule = ModuleNumber(absiX);   // module number Id.
148   Int_t nStrip = AliMUONTriggerConstants::NstripY(numModule); //numb of strips
149   Int_t iCandidateLeft, iCandidateRight;
150   Int_t iNewCandidateRight=0; 
151   Int_t iNewCandidateLeft=0;
152 // first strip number on the right of the left module  
153   if ( (absiX-(Int_t(absiX/10))*10)!=1 && absiX!=52 ) 
154     iNewCandidateLeft = 
155       AliMUONTriggerConstants::NstripY(ModuleNumber(absiX-1))-1;
156   Int_t j;
157   
158   *Nlist = 10;
159   for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
160
161   if (iY < nStrip) {
162
163     for (Int_t i=0; i<5; i++) {
164       j = i + 5;
165       iCandidateRight = iY + (i + 1);
166       iCandidateLeft  = iY - (i + 1);
167       if (iCandidateRight < nStrip) { // strip in same module  
168         Xlist[i] = absiX;
169         Ylist[i] = iCandidateRight;  
170       } else if ((absiX+1)%10!=8) {   // need to scan the module on the right
171         Xlist[i] = absiX+1;
172         Ylist[i] = iNewCandidateRight;  
173         iNewCandidateRight++;
174       }
175       
176       if (iCandidateLeft >=0 ) { // strip in same module
177         Xlist[j] = absiX;
178         Ylist[j] = iCandidateLeft;  
179       } else if ( iNewCandidateLeft !=0) {
180         Xlist[j] = absiX-1;
181         Ylist[j] = iNewCandidateLeft;  
182         iNewCandidateLeft--;
183       }
184     }
185     
186     if (iX<0) {                                  // left side of chamber 
187       for (Int_t i=0; i<10; i++) { 
188         if (Xlist[i]!=0) Xlist[i]=-Xlist[i]; 
189       }
190     }
191     
192   } // iY < nStrip    
193 }
194
195 //------------------------------------------------------------------   
196 void AliMUONSegmentationTriggerY::SetPad(Int_t ix, Int_t iy)
197 {
198   // Sets virtual pad coordinates, needed for evaluating pad response 
199   // outside the tracking program 
200   GetPadC(ix,iy,fX,fY);
201   GetPadI(fX,fY,fIx,fIy);
202   fSector=Sector(ix,iy);    
203 }
204
205 //------------------------------------------------------------------   
206 Int_t AliMUONSegmentationTriggerY::ISector() 
207 { return fSector;}
208
209 //------------------------------------------------------------------   
210
211 Int_t AliMUONSegmentationTriggerY::Ix()
212 { return fIx;}
213
214 //------------------------------------------------------------------   
215
216 Int_t AliMUONSegmentationTriggerY::Iy()
217 { return fIy;}
218
219 //------------------------------------------------------------------
220 Float_t AliMUONSegmentationTriggerY::Dpx(Int_t isec) const
221
222 // returns x size of y strips for sector isec
223   if (isec==1) {
224     return AliMUONTriggerConstants::StripWidth(1)*fZscale;
225   } else if (isec==2) {
226     return AliMUONTriggerConstants::StripWidth(1)*fZscale;
227   } else if (isec==3) {
228     return AliMUONTriggerConstants::StripWidth(1)*fZscale;
229   } else if (isec==4) {
230     return AliMUONTriggerConstants::StripWidth(2)*fZscale;
231   } else {
232     return 0.;  
233   }       
234 }
235
236 //------------------------------------------------------------------
237 Float_t AliMUONSegmentationTriggerY::Dpy(Int_t isec) const
238
239 // returns y size of y strips for sector isec
240   if (isec==1) {
241     return AliMUONTriggerConstants::StripLength(3)*fZscale;
242   } else if (isec==2) {
243     return AliMUONTriggerConstants::StripLength(2)*fZscale;
244   } else if (isec==3) {
245     return AliMUONTriggerConstants::StripLength(3)*fZscale;
246   } else if (isec==4) {
247     return AliMUONTriggerConstants::StripLength(3)*fZscale;
248   } else if (isec==5) {
249     return AliMUONTriggerConstants::StripLength(3)*fZscale;
250   } else {
251     return 0.;
252   }
253 }
254 //------------------------------------------------------------------   
255 void AliMUONSegmentationTriggerY::GetPadI(Float_t x, Float_t y, Float_t /*z*/, Int_t &ix, Int_t &iy) 
256 {
257   GetPadI(x, y, ix, iy);
258 }
259
260 //------------------------------------------------------------------   
261 void AliMUONSegmentationTriggerY::SetHit(Float_t xhit, Float_t yhit)
262
263 // set hits during diintegration
264   AliMUONSegmentationTrigger::SetHit(xhit,yhit);
265 }
266 //------------------------------------------------------------------   
267 void AliMUONSegmentationTriggerY::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
268 {
269   SetHit(xhit, yhit);
270 }
271 //------------------------------------------------------------------   
272 Int_t AliMUONSegmentationTriggerY::Sector(Int_t ix, Int_t iy)
273 {
274 // Returns sector number for given module
275 // 
276   Int_t absix=TMath::Abs(ix);
277   Int_t iwidth=Int_t(StripSizeY(absix,iy));
278
279   if (absix==52) {
280     return 1;
281   } else if (absix==41||absix==61) {
282     return 2;
283   } else if (iwidth==2) {
284     return 3;
285   } else if (iwidth==4) {
286     return 4;
287   } else {
288     return 0;
289   }      
290
291 }
292
293 //------------------------------------------------------------------   
294 void AliMUONSegmentationTriggerY::
295 IntegrationLimits(Float_t& x1, Float_t& x2, Float_t& x3, Float_t& x4) 
296
297 // returns quantities needed to evaluate neighbour strip response
298   Int_t ix,iy;
299   Float_t xstrip,ystrip;
300   GetPadI(fXhit,fYhit,ix,iy);  
301   GetPadC(ix,iy,xstrip,ystrip);  
302   x1=fXhit;        // hit x position
303   x2=xstrip;       // x coordinate of the main strip
304   x3=fX;           // current strip real x coordinate  
305   //  width=StripSizeY(ix);   // width of the main strip 
306
307   // find the position of the 2 borders of the current strip
308   Float_t xmin = fXofysmin[ModuleNumber(fIx)][fIy];
309   Float_t xmax = fXofysmax[ModuleNumber(fIx)][fIy];
310
311   // dist. between the hit and the closest border of the current strip
312   x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ? 
313     TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);    
314
315 }
316
317
318
319