]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTriggerSegmentation.cxx
Reducing number of overlaps with SHIELD module (Gines)
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerSegmentation.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 //*********************************************************
19 // Segmentation classe for trigger chambers.
20 // The present version is a bit messy because, although the
21 // x,y positions are local, most of the methods use global 
22 // strip numbering. The conversion is made via GetPadLoc2Glo.
23 // To be improved in the future.
24 //*********************************************************
25
26 #include <TArrayI.h>
27 #include <TArrayF.h>
28 #include "AliMUONTriggerSegmentation.h"
29 #include "AliLog.h"
30
31 //___________________________________________
32 ClassImp(AliMUONTriggerSegmentation)
33
34 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation() 
35   : AliMUONVGeometryDESegmentation(),
36     fBending(0),
37     fId(0),
38     fNsec(7),
39     fNDiv(0),
40     fDpxD(0),
41     fDpyD(0), 
42     fDpx(0),
43     fDpy(0),
44     fNpx(999999),
45     fNpy(999999),
46     fWireD(0.25),
47     fXhit(0.),
48     fYhit(0.),
49     fIx(0),
50     fIy(0),
51     fX(0.),
52     fY(0.),
53     fIxmin(0),
54     fIxmax(0),
55     fIymin(0),
56     fIymax(0),
57 // add to St345SlatSegmentation
58     fLineNumber(0),
59     fRpcHalfXsize(0),
60     fRpcHalfYsize(0)
61 {
62 // add to St345SlatSegmentation
63   for (Int_t i=0; i<7; i++) {
64       fNstrip[i]=0;
65       fStripYsize[i]=0.;   
66       fStripXsize[i]=0.;  
67       fModuleXmin[i]=0.;
68       fModuleXmax[i]=0.;  
69       fModuleYmin[i]=0.;  
70   }
71 }
72
73
74 //___________________________________________
75 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending) 
76   : AliMUONVGeometryDESegmentation(),
77     fBending(bending),
78     fId(0),
79     fDpx(0),
80     fDpy(0),
81     fNpx(999999),
82     fNpy(999999),
83     fWireD(0.25),
84     fXhit(0.),
85     fYhit(0.),
86     fIx(0),
87     fIy(0),
88     fX(0.),
89     fY(0.),
90     fIxmin(0),
91     fIxmax(0),
92     fIymin(0),
93     fIymax(0),
94 // add to St345SlatSegmentation
95     fLineNumber(0),
96     fRpcHalfXsize(0),
97     fRpcHalfYsize(0)
98 {
99   // Non default constructor
100   fNsec = 7;  // 4 sector densities at most per slat 
101   fNDiv = new TArrayI(fNsec);      
102   fDpxD = new TArrayF(fNsec);      
103   fDpyD = new TArrayF(fNsec);      
104   (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;     
105   (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;       
106   (*fDpyD)[0]=(*fDpyD)[1]=(*fDpyD)[2]=(*fDpyD)[3]=0;       
107 // add to St345SlatSegmentation
108   for (Int_t i=0; i<7; i++) {
109       fNstrip[i]=0;
110       fStripYsize[i]=0.;   
111       fStripXsize[i]=0.;  
112       fModuleXmin[i]=0.;
113       fModuleXmax[i]=0.;  
114       fModuleYmin[i]=0.;  
115   }
116 }
117
118 //----------------------------------------------------------------------
119 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(const AliMUONTriggerSegmentation& rhs) : AliMUONVGeometryDESegmentation(rhs)
120 {
121   AliFatal("Not implemented.");
122 }
123 //----------------------------------------------------------------------
124 AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation() 
125 {
126   // Destructor
127   if (fNDiv) delete fNDiv;
128   if (fDpxD) delete fDpxD;
129   if (fDpyD) delete fDpyD;
130 }
131 //----------------------------------------------------------------------
132 AliMUONTriggerSegmentation& AliMUONTriggerSegmentation::operator=(const AliMUONTriggerSegmentation& rhs)
133 {
134 // Protected assignement operator
135   if (this == &rhs) return *this;
136   AliFatal("Not implemented.");
137   return *this;  
138 }
139 //----------------------------------------------------------------------
140 Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ixGlo)
141 {
142 // returns column number (from 0 to 6) in which the (global) module 
143 // ixGlo is sitting (could return 7 if ixGlow=isec)
144     return TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10-1;
145 }
146 //----------------------------------------------------------------------
147 Bool_t AliMUONTriggerSegmentation::HasPad(Int_t ix, Int_t iy)
148 {
149 // check if steping outside the limits (iy=1,2... iyGlo=0,1...)
150     Bool_t hasPad = true;    
151     Int_t ixGlo = 0;
152     Int_t iyGlo = 0; 
153     GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
154     if (iyGlo>=fNstrip[ModuleColNum(ixGlo)]) hasPad = false;
155     return hasPad;    
156 }
157 //____________________________________________________________________________
158 Float_t AliMUONTriggerSegmentation::Dpx(Int_t isec) const
159 {
160 // return x-strip width in sector isec
161     Float_t size = (isec<8) ? fStripXsize[isec-1] : fStripXsize[isec-2]/2.;
162     return size;
163 }
164 //____________________________________________________________________________
165 Float_t AliMUONTriggerSegmentation::Dpy(Int_t  isec) const
166 {
167 // return y-strip width in sector isec
168     Float_t size = (isec<8) ? fStripYsize[isec-1] : fStripYsize[isec-2];
169     return size;
170 }
171 //----------------------------------------------------------------------------
172 void AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ixLoc, Int_t iyLoc, 
173                                                Int_t &ixGlo, Int_t &iyGlo)
174 {    
175 // converts ixLoc & iyLoc into ixGlo & iyGLo (module,strip number)
176     ixGlo = 0; // see AliMUONTriggerConstants::fgkModuleI
177     iyGlo = 0; // from 0 to (fNtrip-1) in module   
178     if (fBending) { 
179         ixGlo = 10*fLineNumber + ixLoc;
180         iyGlo = iyLoc - 1;
181     } else if (!fBending) {     
182         Int_t iCountStrip = 0;  
183         for (Int_t iModule=0; iModule<fNsec; iModule++) {               
184             for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
185                 if ((ixLoc-1)==iCountStrip) {
186                     ixGlo = 10*fLineNumber + iModule + 1;
187                     iyGlo = iStrip;
188                 }
189                 iCountStrip++;
190             }
191         }
192     }
193 //    printf(" in GetPadLoc2Glo ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",ixLoc,iyLoc,ixGlo,iyGlo);
194     
195 }
196 //----------------------------------------------------------------------------
197 void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y) 
198 {
199     Int_t ixGlo = 0;
200     Int_t iyGlo = 0;    
201     GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
202 //    ix = ixGlo;
203 //    iy = iyGlo;
204     
205 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
206     x = 0.;
207     y = 0.;
208     Int_t iModule = ModuleColNum(ixGlo); // find column number (0-6)
209     if (fBending) {
210         if (iModule==0) {
211             x =  fStripXsize[iModule]/ 2.;
212         } else {        
213         x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
214         }
215         y =  fModuleYmin[iModule] + 
216             iyGlo*fStripYsize[iModule] + fStripYsize[iModule]/2.;
217     } else if (!fBending) {
218         if (ModuleColNum(ixGlo)==6 && iyGlo>7) {
219             x = fModuleXmin[iModule] + 8*fStripXsize[iModule] +
220                 (iyGlo-8)*fStripXsize[iModule]/2. + fStripXsize[iModule]/4.;
221         } else {            
222             x = fModuleXmin[iModule] + 
223                 iyGlo*fStripXsize[iModule] + fStripXsize[iModule]/2.;
224         }
225         y =  fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
226     }    
227     x = x - fRpcHalfXsize;
228     y = y - fRpcHalfYsize;
229
230 //    printf(" in GetPadC iModule ixGlo iyGlo ix iy x y %i %i %i %i %i %f %f \n",iModule,ixGlo,iyGlo,ix,iy,x,y);
231 }
232
233 //_____________________________________________________________________________
234 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy) 
235 {
236 //  Returns pad coordinates (ix,iy) for given real coordinates (x,y)
237
238     x = x + fRpcHalfXsize;
239     y = y + fRpcHalfYsize;
240 // find module number    
241     Int_t modNum=0;    
242     for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
243         if ( x > fModuleXmin[iModule] && x < fModuleXmax[iModule] ) {
244             ix = 10*fLineNumber + iModule + 1;
245             modNum = iModule;       
246         }
247     }
248
249 // find strip number 
250     Float_t yMin = 0.;    
251     Float_t yMax = fModuleYmin[modNum];
252     Float_t xMin = 0.;
253     Float_t xMax = fModuleXmin[modNum];
254     if (ix!=0) {
255         for (Int_t iStrip=0; iStrip<fNstrip[modNum]; iStrip++) {
256             if (fBending) {
257                 yMin = yMax;
258                 yMax = yMin + fStripYsize[modNum];
259                 if (y > yMin && y < yMax) iy = iStrip;
260             } else if (!fBending) {
261                 xMin = xMax;
262                 xMax = xMin + fStripXsize[modNum];
263                 if (x > xMin && x < xMax) iy = iStrip;
264             }
265         } // loop on strips
266     } // if ix!=0
267 //    printf("in GetPadI ix iy x y %i %i %f %f \n",ix,iy,x,y);
268 }
269 //-------------------------------------------------------------------------
270 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
271 {
272   GetPadI(x, y, ix, iy);
273 }
274 //____________________________________________________________________________
275 void AliMUONTriggerSegmentation::SetPadSize(Float_t p1, Float_t p2)
276 {
277 //  Sets the padsize 
278     fDpx=p1;
279     fDpy=p2;
280 }
281 //-------------------------------------------------------------------------
282 void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
283     fLineNumber = iLineNumber;    
284 }
285 //-------------------------------------------------------------------------
286 void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
287 {
288   //
289   // Sets virtual pad coordinates, needed for evaluating pad response 
290   // outside the tracking program 
291   GetPadC(ix,iy,fX,fY);
292   fSector=Sector(ix,iy);
293 }
294 //---------------------------------------------------------------------------
295 void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
296 {
297   // Set current hit 
298   //
299   fXhit = x;
300   fYhit = y;
301 }
302 //----------------------------------------------------------------------------
303 void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
304 {
305   SetHit(xhit, yhit);
306 }
307
308 //--------------------------------------------------------------------------
309 Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy) 
310 {
311 // determine segmentation zone from pad coordinates (from 1 to 8)
312     Int_t ixGlo = 0;
313     Int_t iyGlo = 0;    
314     GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);    
315     if (!fBending && ModuleColNum(ixGlo)==6 && iyGlo>7) {
316         return 8; // sector 8: diff. strip width within same module
317     } else {
318         return ModuleColNum(ixGlo)+1;
319     }
320 }
321
322 //-----------------------------------------------------------------------------
323 void AliMUONTriggerSegmentation::
324 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2) 
325 {
326 /*
327 // need to return (only) x4 = dist. betwwen the hit and the closest border of
328 // the current strip
329     Int_t ix,iy;
330     Float_t xstrip,ystrip;
331     GetPadI(fXhit,fYhit,ix,iy);  
332     GetPadC(ix,iy,xstrip,ystrip);  
333     x1=fYhit;        // hit y position
334     x2=ystrip;       // y coordinate of the main strip
335     x3=fY;           // current strip real y coordinate  
336     
337     // find the position of the 2 borders of the current strip
338     Float_t ymin = ystrip - fStripXsize[ModuleColNum(ixGlo)
339
340 fYofxsmin[ModuleNumber(fIx)][fIy];
341     Float_t ymax = fYofxsmax[ModuleNumber(fIx)][fIy];
342     
343     // dist. between the hit and the closest border of the current strip
344     x4 = (TMath::Abs(ymax-x1) > TMath::Abs(ymin-x1)) ? 
345         TMath::Abs(ymin-x1):TMath::Abs(ymax-x1);
346 */
347   //  Returns integration limits for current pad
348   //
349   x1=fXhit-fX-Dpx(fSector)/2.;
350   x2=x1+Dpx(fSector);
351   y1=fYhit-fY-Dpy(fSector)/2.;
352   y2=y1+Dpy(fSector);    
353   //    printf("\n Integration Limits %f %f %f %f %d %f", x1, x2, y1, y2, fSector, Dpx(fSector));
354 }
355
356
357 //-----------------------------------------------------------------------------
358 void AliMUONTriggerSegmentation::
359 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]) 
360 {
361   // Returns list of next neighbours for given Pad (iX, iY)
362   Int_t i=0;
363   //  step right
364   if (iX+1 <= fNpx) {
365     Xlist[i]=iX+1;
366     Ylist[i++]=iY;
367   }
368   //  step left    
369   if (iX-1 > 0) {
370     Xlist[i]=iX-1;
371     Ylist[i++]=iY;
372   } 
373   Int_t sector = Sector(iX,iY);
374   //  step up
375   if (iY+1 <= fNpyS[sector]) {
376     Xlist[i]=iX;
377     Ylist[i++]=iY+1;
378   }
379   //  step down    
380   if (iY-1 > 0) {
381     Xlist[i]=iX;
382     Ylist[i++]=iY-1;
383   }
384   *Nlist=i;
385 }
386
387 //--------------------------------------------------------------------------
388 void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
389                                       Int_t nStrip[7],
390                                       Float_t stripYsize[7],
391                                       Float_t stripXsize[7],
392                                       Float_t offset)
393 {
394 //    printf(" fBending: %d \n",fBending);
395     
396     Int_t nStripMax = 0;
397     if (fBending) nStripMax = nStrip[0];
398     
399     for (Int_t i=0; i<7; i++) {
400         fNstrip[i]=nStrip[i];
401         fStripYsize[i]=stripYsize[i];
402         fStripXsize[i]=stripXsize[i];
403         fModuleYmin[0]=0.;
404     }
405 // take care of offset in Y in chamber 5, first module
406     fModuleYmin[0] = offset;
407     
408     Float_t tmp = 0.;  
409     Int_t npad = 0;  // number of pad in x and y
410     for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules        
411         fModuleXmin[iModule] = tmp;      
412         npad = npad + fNstrip[iModule];
413         if (fBending) {
414             fModuleXmax[iModule] = 
415                 fModuleXmin[iModule] + fStripXsize[iModule];
416         } else if (!fBending) {
417             if (iModule<6) {
418                 fModuleXmax[iModule] = 
419                     fModuleXmin[iModule] + 
420                     fStripXsize[iModule]*fNstrip[iModule];
421             } else if (iModule==6) { 
422                 fModuleXmax[iModule] = 
423                     fModuleXmin[iModule] + 
424                     (fStripXsize[iModule]*fNstrip[iModule]/2) +
425                     (fStripXsize[iModule]/2.*fNstrip[iModule]/2);
426             }     
427         }
428         tmp = fModuleXmax[iModule];      
429         
430 // calculate nStripMax in x & y
431         if (fBending) {
432             if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
433         } else if (!fBending) {
434             for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
435         }
436     } // loop on modules
437
438 // associate nStripMax
439 //    fNpx = (fBending) ? fNsec : nStripMax;
440 //    fNpy = (fBending) ? nStripMax : 1;
441     fNpx = 124; // tot num of modules (like with old segmentation)
442     fNpy = 64; // max number of y strips within one module
443
444 // calculate half size in x & y (to shift local coordinate ref. system)
445   fRpcHalfXsize = 0;
446   fRpcHalfYsize = 0;  
447   if (fBending) {
448       for (Int_t iModule=0; iModule<fNsec; iModule++)  
449           fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];      
450       fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
451   } else if (!fBending) {
452       fRpcHalfXsize = fModuleXmax[6];
453       fRpcHalfYsize = fStripYsize[1];
454   }
455   fRpcHalfXsize = fRpcHalfXsize / 2.;
456   fRpcHalfYsize = fRpcHalfYsize / 2.;  
457
458 /*
459   printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
460          fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
461
462   for (Int_t iModule=0; iModule<fNsec; iModule++) {
463       printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
464              iModule,fModuleXmin[iModule],fModuleXmax[iModule],
465              fModuleYmin[iModule],
466              fStripXsize[iModule],fStripYsize[iModule]);
467              }
468
469   for (Int_t iModule=0; iModule<fNsec; iModule++) {
470       printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
471              iModule,fNstrip[iModule],
472              fStripXsize[iModule],fStripYsize[iModule]);
473   }
474 */
475
476   
477
478 //  printf("npad = %i",npad);  
479
480   fId = detectionElementId;
481 }
482
483
484
485
486
487
488