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