]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSegmentationTriggerY.cxx
Code revision:
[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
25 ClassImp(AliMUONSegmentationTriggerY)
26
27 //------------------------------------------------------------------
28 AliMUONSegmentationTriggerY::AliMUONSegmentationTriggerY()
29   : AliMUONSegmentationTrigger()
30 {
31 // Constructor
32 }
33
34 //------------------------------------------------------------------
35 void AliMUONSegmentationTriggerY::Init(Int_t chamber)
36 {
37 // intialize Y segmentation 
38   AliMUON *pMUON  = (AliMUON *) gAlice->GetModule("MUON");
39   if(pMUON->GetDebug()>1) printf("%s: Initialize Trigger Chamber Geometry Y\n",ClassName());
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     Float_t width=StripSizeY(AliMUONTriggerConstants::ModuleId(imodule));
46     Int_t nStrip=AliMUONTriggerConstants::NstripY(imodule);    
47     for (Int_t istrip=0; istrip<nStrip; istrip++){
48       if (imodule<63) {
49         fXofysmin[imodule][istrip]=
50             (AliMUONTriggerConstants::XcMin(imodule)+width*(istrip))*fZscale;
51         fXofysmax[imodule][istrip]=
52             (AliMUONTriggerConstants::XcMin(imodule)+width*(istrip+1))*fZscale;
53       } else {  
54         fXofysmin[imodule][istrip]=-1.*fXofysmax[imodule-63][istrip];
55         fXofysmax[imodule][istrip]=-1.*fXofysmin[imodule-63][istrip];
56       }      
57       fYofysmin[imodule][istrip] = fYcmin[imodule]*fZscale;
58       fYofysmax[imodule][istrip] = fYcmax[imodule]*fZscale;
59     }
60   }
61
62 }
63
64 //------------------------------------------------------------------
65 void AliMUONSegmentationTriggerY::GetPadI(Float_t x,Float_t y,Int_t &ix,Int_t &iy) 
66 {
67 //  Returns pad coordinates (ix,iy) for given real coordinates (x,y)
68 //  x,y = real coordinates; ix = module number , iy = strip number
69
70   ix = 0;    
71   iy = 0;
72   Int_t nModule=AliMUONTriggerConstants::Nmodule();
73   for (Int_t imodule=0; imodule<nModule; imodule++) {
74       Int_t nStrip=AliMUONTriggerConstants::NstripY(imodule);      
75     for (Int_t istrip=0; istrip<nStrip; istrip++){
76       if (x>fXofysmin[imodule][istrip]&&x<fXofysmax[imodule][istrip]&&
77           y>fYofysmin[imodule][istrip]&&y<fYofysmax[imodule][istrip]){
78         ix = AliMUONTriggerConstants::ModuleId(imodule);
79         iy = istrip;
80       }
81     }
82   }
83 }
84
85 //------------------------------------------------------------------
86 void AliMUONSegmentationTriggerY::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
87 {
88 //  Returns real coordinates (x,y) for given pad coordinates (ix,iy)
89 //  ix = module number , iy = strip number;  x,y = center of strip
90   x = 0.;    
91   y = 0.;
92   Int_t nModule=AliMUONTriggerConstants::Nmodule();
93   for (Int_t imodule=0; imodule<nModule; imodule++) {
94     if (AliMUONTriggerConstants::ModuleId(imodule)==ix){
95       x=fXofysmin[imodule][iy]+(fXofysmax[imodule][iy]-fXofysmin[imodule][iy])/2.;
96       y=fYofysmin[imodule][iy]+(fYofysmax[imodule][iy]-fYofysmin[imodule][iy])/2.;
97     }
98   }
99 }
100
101 //------------------------------------------------------------------
102 void AliMUONSegmentationTriggerY::SetPadSize(Float_t p1, Float_t p2)
103 {
104 //  Sets the padsize 
105 //  
106   fDpx=p1;
107   fDpy=p2;
108 }
109
110 //------------------------------------------------------------------
111 void AliMUONSegmentationTriggerY::
112 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]){
113 // Returns list of 10 next neighbours for given Y strip (ix, iy)  
114 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
115 //                  \_______/                    \_______/
116 //                    left                         right  
117 // Note : should not be used to return a list of neighbours larger than 16 !
118
119   Int_t absiX = TMath::Abs(iX); 
120   Int_t numModule = ModuleNumber(absiX);   // module number Id.
121   Int_t nStrip = AliMUONTriggerConstants::NstripY(numModule); //numb of strips
122   Int_t iCandidateLeft, iCandidateRight;
123   Int_t iNewCandidateRight=0; 
124   Int_t iNewCandidateLeft=0;
125 // first strip number on the right of the left module  
126   if ( (absiX-(Int_t(absiX/10))*10)!=1 && absiX!=52 ) 
127     iNewCandidateLeft = 
128       AliMUONTriggerConstants::NstripY(ModuleNumber(absiX-1))-1;
129   Int_t j;
130   
131   *Nlist = 10;
132   for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
133
134   if (iY < nStrip) {
135
136     for (Int_t i=0; i<5; i++) {
137       j = i + 5;
138       iCandidateRight = iY + (i + 1);
139       iCandidateLeft  = iY - (i + 1);
140       if (iCandidateRight < nStrip) { // strip in same module  
141         Xlist[i] = absiX;
142         Ylist[i] = iCandidateRight;  
143       } else if ((absiX+1)%10!=8) {   // need to scan the module on the right
144         Xlist[i] = absiX+1;
145         Ylist[i] = iNewCandidateRight;  
146         iNewCandidateRight++;
147       }
148       
149       if (iCandidateLeft >=0 ) { // strip in same module
150         Xlist[j] = absiX;
151         Ylist[j] = iCandidateLeft;  
152       } else if ( iNewCandidateLeft !=0) {
153         Xlist[j] = absiX-1;
154         Ylist[j] = iNewCandidateLeft;  
155         iNewCandidateLeft--;
156       }
157     }
158     
159     if (iX<0) {                                  // left side of chamber 
160       for (Int_t i=0; i<10; i++) { 
161         if (Xlist[i]!=0) Xlist[i]=-Xlist[i]; 
162       }
163     }
164     
165   } // iY < nStrip    
166 }
167
168 //------------------------------------------------------------------   
169 void AliMUONSegmentationTriggerY::SetPad(Int_t ix, Int_t iy)
170 {
171   // Sets virtual pad coordinates, needed for evaluating pad response 
172   // outside the tracking program 
173   GetPadC(ix,iy,fX,fY);
174   GetPadI(fX,fY,fIx,fIy);
175   fSector=Sector(ix,iy);    
176 }
177
178 //------------------------------------------------------------------   
179 Int_t AliMUONSegmentationTriggerY::ISector() 
180 { return fSector;}
181
182 //------------------------------------------------------------------   
183
184 Int_t AliMUONSegmentationTriggerY::Ix()
185 { return fIx;}
186
187 //------------------------------------------------------------------   
188
189 Int_t AliMUONSegmentationTriggerY::Iy()
190 { return fIy;}
191
192 //------------------------------------------------------------------
193 Float_t AliMUONSegmentationTriggerY::Dpx(Int_t isec) const
194
195 // returns x size of y strips for sector isec
196   if (isec==1) {
197     return 2.125*fZscale;
198   } else if (isec==2) {
199     return 2.125*fZscale;
200   } else if (isec==3) {
201     return 2.125*fZscale;
202   } else if (isec==4) {
203     return 4.25*fZscale;
204   } else {
205     return 0.;  
206   }       
207 }
208
209 //------------------------------------------------------------------
210 Float_t AliMUONSegmentationTriggerY::Dpy(Int_t isec) const
211
212 // returns y size of y strips for sector isec
213   if (isec==1) {
214     return 68.0*fZscale;
215   } else if (isec==2) {
216     return 51.0*fZscale;
217   } else if (isec==3) {
218     return 68.0*fZscale;
219   } else if (isec==4) {
220     return 68.0*fZscale;
221   } else if (isec==5) {
222     return 68.0*fZscale;
223   } else {
224     return 0.;
225   }
226 }
227 //------------------------------------------------------------------   
228 void AliMUONSegmentationTriggerY::GetPadI(Float_t x, Float_t y, Float_t /*z*/, Int_t &ix, Int_t &iy) 
229 {
230   GetPadI(x, y, ix, iy);
231 }
232
233 //------------------------------------------------------------------   
234 void AliMUONSegmentationTriggerY::SetHit(Float_t xhit, Float_t yhit)
235
236 // set hits during diintegration
237   AliMUONSegmentationTrigger::SetHit(xhit,yhit);
238 }
239 //------------------------------------------------------------------   
240 void AliMUONSegmentationTriggerY::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
241 {
242   SetHit(xhit, yhit);
243 }
244 //------------------------------------------------------------------   
245 Int_t AliMUONSegmentationTriggerY::Sector(Int_t ix, Int_t /*iy*/)
246 {
247 // Returns sector number for given module
248 // 
249   Int_t absix=TMath::Abs(ix);
250   Int_t iwidth=Int_t(StripSizeY(absix));
251
252   if (absix==52) {
253     return 1;
254   } else if (absix==41||absix==61) {
255     return 2;
256   } else if (iwidth==2) {
257     return 3;
258   } else if (iwidth==4) {
259     return 4;
260   } else {
261     return 0;
262   }
263 }
264
265 //------------------------------------------------------------------   
266 void AliMUONSegmentationTriggerY::
267 IntegrationLimits(Float_t& x1, Float_t& x2, Float_t& x3, Float_t& x4) 
268
269 // returns quantities needed to evaluate neighbour strip response
270   Int_t ix,iy;
271   Float_t xstrip,ystrip;
272   GetPadI(fXhit,fYhit,ix,iy);  
273   GetPadC(ix,iy,xstrip,ystrip);  
274   x1=fXhit;        // hit x position
275   x2=xstrip;       // x coordinate of the main strip
276   x3=fX;           // current strip real x coordinate  
277   //  width=StripSizeY(ix);   // width of the main strip 
278
279   // find the position of the 2 borders of the current strip
280   Float_t xmin = fXofysmin[ModuleNumber(fIx)][fIy];
281   Float_t xmax = fXofysmax[ModuleNumber(fIx)][fIy];
282
283   // dist. between the hit and the closest border of the current strip
284   x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ? 
285     TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);    
286
287 }
288
289
290
291