]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTriggerSegmentation.cxx
Removing obsolete constants.
[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 /// \class AliMUONTriggerSegmentation
19 /// \brief Segmentation classe for trigger chambers.
20 /// In the present version the method use global strip coordinates except
21 /// HasPad. The conversion is made via GetPadLoc2Glo.
22 /// To be improved in the future.
23
24 #include "AliMUONTriggerSegmentation.h"
25 #include "AliLog.h"
26 #include "Riostream.h"
27
28 /// \cond CLASSIMP
29 ClassImp(AliMUONTriggerSegmentation)
30 /// \endcond
31
32 //___________________________________________
33 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation() 
34   : AliMUONVGeometryDESegmentation(),
35     fBending(0),
36     fId(0),
37     fNsec(7),
38     fNpx(999999),
39     fNpy(999999),
40     fXhit(0.),
41     fYhit(0.),
42     fIx(0),
43     fIy(0),
44     fX(0.),
45     fY(0.),
46 // add to St345SlatSegmentation
47     fLineNumber(0),
48     fRpcHalfXsize(0),
49     fRpcHalfYsize(0)
50 {
51 /// Default constructor
52
53 // add to St345SlatSegmentation
54   for (Int_t i=0; i<7; i++) {
55       fNstrip[i]=0;
56       fStripYsize[i]=0.;   
57       fStripXsize[i]=0.;  
58       fModuleXmin[i]=0.;
59       fModuleXmax[i]=0.;  
60       fModuleYmin[i]=0.;  
61   }
62
63   AliDebug(1, Form("default (empty) ctor this = %p", this));
64 }
65
66
67 //___________________________________________
68 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending) 
69   : AliMUONVGeometryDESegmentation(),
70     fBending(bending),
71     fId(0),
72     fNpx(999999),
73     fNpy(999999),
74     fXhit(0.),
75     fYhit(0.),
76     fIx(0),
77     fIy(0),
78     fX(0.),
79     fY(0.),
80 // add to St345SlatSegmentation
81     fLineNumber(0),
82     fRpcHalfXsize(0),
83     fRpcHalfYsize(0)
84 {
85 /// Standard constructor
86
87   fNsec = 7;  
88 // add to St345SlatSegmentation
89   for (Int_t i=0; i<7; i++) {
90       fNstrip[i]=0;
91       fStripYsize[i]=0.;   
92       fStripXsize[i]=0.;  
93       fModuleXmin[i]=0.;
94       fModuleXmax[i]=0.;  
95       fModuleYmin[i]=0.;  
96   }
97
98   AliDebug(1, Form("ctor this = %p", this) ); 
99 }
100
101 //----------------------------------------------------------------------
102 AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation() 
103 {
104 /// Destructor
105
106   AliDebug(1, Form("dtor this = %p", this) ); 
107 }
108 //----------------------------------------------------------------------
109 Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ix)
110 {
111 /// returns column number (from 0 to 6) in which the (global) module 
112 /// ix is sitting (could return 7 if ix=isec)
113
114     return TMath::Abs(ix)-Int_t(TMath::Abs(ix)/10)*10-1;
115 }
116 //----------------------------------------------------------------------
117 Bool_t AliMUONTriggerSegmentation::HasPad(Int_t ix, Int_t iy)
118 {
119 /// check if steping outside the limits (iy=1,2... iy=0,1...)
120
121     Bool_t hasPad = true;    
122     Int_t ixGlo = 0;
123     Int_t iyGlo = 0; 
124     GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
125     if (iyGlo>=fNstrip[ModuleColNum(ixGlo)]) hasPad = false;
126     return hasPad;    
127 }
128 //____________________________________________________________________________
129 Float_t AliMUONTriggerSegmentation::Dpx(Int_t isec) const
130 {
131 /// return x-strip width in sector isec
132
133     Float_t size = (isec<8) ? fStripXsize[isec-1] : fStripXsize[isec-2]/2.;
134     return size;
135 }
136 //____________________________________________________________________________
137 Float_t AliMUONTriggerSegmentation::Dpy(Int_t  isec) const
138 {
139 /// return y-strip width in sector isec
140
141     Float_t size = (isec<8) ? fStripYsize[isec-1] : fStripYsize[isec-2];
142     return size;
143 }
144 //----------------------------------------------------------------------------
145 void AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ixLoc, Int_t iyLoc, 
146                                                Int_t &ixGlo, Int_t &iyGlo)
147 {    
148 /// converts ixLoc & iyLoc into ixGlo & iyGLo (module,strip number)
149
150     ixGlo = 0; // see AliMUONTriggerConstants::fgkModuleI
151     iyGlo = 0; // from 0 to (fNtrip-1) in module   
152     if (fBending) { 
153         ixGlo = 10*fLineNumber + ixLoc;
154         iyGlo = iyLoc - 1;
155     } else if (!fBending) {     
156         Int_t iCountStrip = 0;  
157         for (Int_t iModule=0; iModule<fNsec; iModule++) {               
158             for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
159                 if ((ixLoc-1)==iCountStrip) {
160                     ixGlo = 10*fLineNumber + iModule + 1;
161                     iyGlo = iStrip;
162                 }
163                 iCountStrip++;
164             }
165         }
166     }
167 //    printf(" in GetPadLoc2Glo fbending ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",fBending,ixLoc,iyLoc,ixGlo,iyGlo);
168 }
169
170 //----------------------------------------------------------------------------
171 void AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo, 
172                                                Int_t &ixLoc, Int_t &iyLoc)
173 {    
174 /// converts ixGlo & iyGlo into ixLoc & iyLoc 
175
176     ixLoc = 0; 
177     iyLoc = 0; 
178     if (fBending) { 
179         ixLoc = ModuleColNum(ixGlo) + 1;
180         iyLoc = iyGlo + 1;
181     } else if (!fBending) {     
182         Int_t iCountStrip = 1;  
183         for (Int_t iModule=0; iModule<fNsec; iModule++) {               
184             for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
185                 if ((iModule==ModuleColNum(ixGlo))&&(iStrip==iyGlo)) {
186                     iyLoc = 1;              
187                     ixLoc = iCountStrip;
188                 }               
189                 iCountStrip++;
190             }
191         }
192     }    
193 //    printf(" in GetPadGlo2Loc fBending ixGlo iyGlo ixLoc iyLoc %i %i %i %i %i \n",fBending,ixGlo,iyGlo,ixLoc,iyLoc);
194 }
195
196 //----------------------------------------------------------------------------
197 void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y) 
198 {
199 /// Returns local real coordinates (x,y) for local pad coordinates (ix,iy)
200
201     x = 0.;
202     y = 0.;
203     Int_t iModule = ModuleColNum(ix); // find column number (0-6)
204     if (fBending) {
205         if (iModule==0) {
206             x =  fStripXsize[iModule]/ 2.;
207         } else {        
208         x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
209         }
210         y =  fModuleYmin[iModule] + 
211             iy*fStripYsize[iModule] + fStripYsize[iModule]/2.;
212     } else if (!fBending) {
213         if (ModuleColNum(ix)==6 && iy>7) {
214             x = fModuleXmin[iModule] + 8*fStripXsize[iModule] +
215                 (iy-8)*fStripXsize[iModule]/2. + fStripXsize[iModule]/4.;
216         } else {            
217             x = fModuleXmin[iModule] + 
218                 iy*fStripXsize[iModule] + fStripXsize[iModule]/2.;
219         }
220         y =  fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
221     }    
222     x = x - fRpcHalfXsize;
223     y = y - fRpcHalfYsize;
224
225 //    printf(" in GetPadC fBending ix iy x y %i %i %i %f %f \n",fBending,ix,iy,x,y);
226 }
227
228 //_____________________________________________________________________________
229 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy) 
230 {
231 ///  Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
232
233     ix = -1;
234     iy = -1;
235
236     x = x + fRpcHalfXsize;
237     y = y + fRpcHalfYsize;
238 // find module number    
239     Int_t modNum=0;    
240     for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
241         if ( x > fModuleXmin[iModule] && x < fModuleXmax[iModule] ) {
242             ix = 10*fLineNumber + iModule + 1;
243             modNum = iModule;       
244         }
245     }
246
247 // find strip number 
248     Float_t yMin = 0.;    
249     Float_t yMax = fModuleYmin[modNum];
250     Float_t xMin = 0.;
251     Float_t xMax = fModuleXmin[modNum];
252     if (ix!=0) {
253         for (Int_t iStrip=0; iStrip<fNstrip[modNum]; iStrip++) {
254             if (fBending) {
255                 yMin = yMax;
256                 yMax = yMin + fStripYsize[modNum];
257                 if (y > yMin && y < yMax) iy = iStrip;
258             } else if (!fBending) {
259                 xMin = xMax;
260                 if (modNum==6 && iStrip>7) {
261                     xMax = xMin + fStripXsize[modNum]/2.;
262                 } else {                    
263                     xMax = xMin + fStripXsize[modNum];
264                 }               
265                 if (x > xMin && x < xMax) iy = iStrip;
266             } //
267         } // loop on strips
268     } // if ix!=0
269 //    printf("in GetPadI fBending x y ix iy %i %f %f %i %i \n",fBending,x,y,ix,iy);
270 }
271 //-------------------------------------------------------------------------
272 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
273 {
274 ///  Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
275
276   GetPadI(x, y, ix, iy);
277 }
278
279 //-------------------------------------------------------------------------
280 void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
281 /// Set line number
282
283     fLineNumber = iLineNumber;    
284 }
285 //-------------------------------------------------------------------------
286 void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
287 {
288 /// Sets virtual pad coordinates, needed for evaluating pad response 
289 /// outside the tracking program 
290
291   GetPadC(ix,iy,fX,fY);
292   fIx = ix; // used in IntegrationLimits
293   fIy = iy;    
294   fSector=Sector(ix,iy);
295 }
296 //---------------------------------------------------------------------------
297 void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
298 {
299 /// Set current hit 
300
301   fXhit = x;
302   fYhit = y;
303 }
304 //----------------------------------------------------------------------------
305 void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
306 {
307 /// Set current hit 
308
309   SetHit(xhit, yhit);
310 }
311
312 //--------------------------------------------------------------------------
313 Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy) 
314 {
315 /// determine segmentation zone from pad coordinates (from 1 to 8)
316
317     if (!fBending && ModuleColNum(ix)==6 && iy>7) {
318         return 8; // sector 8: diff. strip width within same module
319     } else {
320         return ModuleColNum(ix)+1;
321     }
322 }
323
324 //-----------------------------------------------------------------------------
325 void AliMUONTriggerSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,
326                                                    Float_t& x3, Float_t& x4) 
327 {
328 /// need to return (only) x4 = dist. betwwen the hit and the closest border of
329 /// the current strip
330
331     Int_t ix,iy;
332     Float_t xstrip,ystrip;
333     GetPadI(fXhit,fYhit,ix,iy);
334     GetPadC(ix,iy,xstrip,ystrip);
335     AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
336                     fXhit,fYhit,xstrip,ystrip));
337     x1= (fBending) ? fYhit : fXhit;  // hit y (bending) / x (!bending) position
338     x2= (fBending) ? ystrip : xstrip; // y or x coord. of the main strip
339     x3= (fBending) ? fY : fX;          // current strip real y or x coord.
340     Int_t modNum = ModuleColNum(fIx);
341
342     // find the position of the 2 borders of the current strip
343     Float_t min = 0.;
344     Float_t max = 0.;    
345     if (fBending) {
346         min = x3 - fStripYsize[modNum]/2.;
347         max = x3 + fStripYsize[modNum]/2.;      
348     } else {
349         if (modNum==6 && fIy>7) { // equivalent to fSector == 8
350             min = x3 - fStripXsize[modNum]/4.;
351             max = x3 + fStripXsize[modNum]/4.;  
352         } else 
353             min = x3 - fStripXsize[modNum]/2.;
354             max = x3 + fStripXsize[modNum]/2.;          
355     }    
356     // dist. between the hit and the closest border of the current strip
357     x4 = (TMath::Abs(max-x1) > TMath::Abs(min-x1)) ? 
358       TMath::Abs(min-x1):TMath::Abs(max-x1);
359   
360     AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
361                     fBending,x1,x2,x3,x4,min,max));
362 }
363
364
365 //-----------------------------------------------------------------------------
366 void AliMUONTriggerSegmentation::
367 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]) 
368 {
369 /// <pre>
370 ///-----------------BENDING-----------------------------------------
371 /// Returns list of 10 next neighbours for given X strip (ix, iy)  
372 /// neighbour number 4 in the list -                     
373 /// neighbour number 3 in the list  |                    
374 /// neighbour number 2 in the list  |_ Upper part             
375 /// neighbour number 1 in the list  |            
376 /// neighbour number 0 in the list -           
377 ///      X strip (ix, iy) 
378 /// neighbour number 5 in the list -       
379 /// neighbour number 6 in the list  | _ Lower part
380 /// neighbour number 7 in the list  |
381 /// neighbour number 8 in the list  | 
382 /// neighbour number 9 in the list -
383 ///
384 ///-----------------NON-BENDING-------------------------------------
385 /// Returns list of 10 next neighbours for given Y strip (ix, iy)  
386 /// neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
387 ///                 \\_______/                    \\_______/
388 ///                    left                         right
389
390     Int_t absiX = TMath::Abs(iX); 
391     Int_t modNum = ModuleColNum(absiX); // from 0 to 6
392     Int_t nStrip = fNstrip[modNum];    
393     
394     if (fBending) {
395         Int_t iCandidateUp, iCandidateDo;
396         Int_t j;
397         
398         *Nlist = 10;
399         for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
400         
401         if (iY < nStrip) {          
402             for (Int_t i=0; i<5; i++) {
403                 j = i + 5;
404                 iCandidateUp = iY + (i + 1);
405                 iCandidateDo = iY - (i + 1);
406                 if (iCandidateUp < nStrip) { 
407                     Xlist[i] = iX;
408                     Ylist[i] = iCandidateUp;  
409                 }
410                 if (iCandidateDo >= 0) { 
411                     Xlist[j] = iX;
412                     Ylist[j] = iCandidateDo;  
413                 }
414             }       
415         } // iY < nStrip        
416
417     } else { // non-bending
418          
419       Int_t iCandidateLeft, iCandidateRight;
420       Int_t iNewCandidateRight=0; 
421       Int_t iNewCandidateLeft=0;
422 // first strip number on the right of the left module  
423       if ( modNum!=0 && absiX!=52 ) 
424           iNewCandidateLeft = fNstrip[modNum-1]-1;
425       Int_t j;
426       
427       *Nlist = 10;
428       for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
429       
430       if (iY < nStrip) {
431           
432           for (Int_t i=0; i<5; i++) {
433               j = i + 5;
434               iCandidateRight = iY + (i + 1);
435               iCandidateLeft  = iY - (i + 1);
436               if (iCandidateRight < nStrip) { // strip in same module  
437                   Xlist[i] = absiX;
438                   Ylist[i] = iCandidateRight;  
439               } else if (modNum!=6) {   // need to scan the module on the right
440                   Xlist[i] = absiX+1;
441                   Ylist[i] = iNewCandidateRight;  
442                   iNewCandidateRight++;
443               }
444               
445               if (iCandidateLeft >=0 ) { // strip in same module
446                   Xlist[j] = absiX;
447                   Ylist[j] = iCandidateLeft;  
448               } else if ( iNewCandidateLeft !=0) {
449                   Xlist[j] = absiX-1;
450                   Ylist[j] = iNewCandidateLeft;  
451                   iNewCandidateLeft--;
452               }
453           }
454           
455           if (iX<0) {                                  // left side of chamber 
456               for (Int_t i=0; i<10; i++) { 
457                   if (Xlist[i]!=0) Xlist[i]=-Xlist[i]; 
458               }
459           }
460           
461       } // iY < nStrip
462     } // non-bending
463
464 //    for (Int_t i=0; i<10; i++) {
465 //      printf("AliMUONTriggerSegmentation LOC fBending i ix iy = %i %i %i %i \n",fBending,i,Xlist[i],Ylist[i]);
466 //   }
467 }
468
469 //--------------------------------------------------------------------------
470 void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
471                                       Int_t nStrip[7],
472                                       Float_t stripYsize[7],
473                                       Float_t stripXsize[7],
474                                       Float_t offset)
475 {
476 /// Initialize
477
478 //    printf(" fBending: %d \n",fBending);
479     
480     Int_t nStripMax = 0;
481     if (fBending) nStripMax = nStrip[0];
482     
483     for (Int_t i=0; i<7; i++) {
484         fNstrip[i]=nStrip[i];
485         fStripYsize[i]=stripYsize[i];
486         fStripXsize[i]=stripXsize[i];
487         fModuleYmin[0]=0.;
488     }
489 // take care of offset in Y in chamber 5, first module
490     fModuleYmin[0] = offset;
491     
492     Float_t tmp = 0.;  
493     Int_t npad = 0;  // number of pad in x and y
494     for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules        
495         fModuleXmin[iModule] = tmp;      
496         npad = npad + fNstrip[iModule];
497         if (fBending) {
498             fModuleXmax[iModule] = 
499                 fModuleXmin[iModule] + fStripXsize[iModule];
500         } else if (!fBending) {
501             if (iModule<6) {
502                 fModuleXmax[iModule] = 
503                     fModuleXmin[iModule] + 
504                     fStripXsize[iModule]*fNstrip[iModule];
505             } else if (iModule==6) { 
506                 fModuleXmax[iModule] = 
507                     fModuleXmin[iModule] + 
508                     (fStripXsize[iModule]*fNstrip[iModule]/2) +
509                     (fStripXsize[iModule]/2.*fNstrip[iModule]/2);
510             }     
511         }
512         tmp = fModuleXmax[iModule];      
513         
514 // calculate nStripMax in x & y
515         if (fBending) {
516             if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
517         } else if (!fBending) {
518             for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
519         }
520     } // loop on modules
521
522 // associate nStripMax
523 //   fNpx = (fBending) ? fNsec : nStripMax;
524 //   fNpy = (fBending) ? nStripMax : 1;
525     fNpx = 124; // tot num of modules (like with old segmentation)
526     fNpy = 64; // max number of y strips within one module
527
528 // calculate half size in x & y (to shift local coordinate ref. system)
529   fRpcHalfXsize = 0;
530   fRpcHalfYsize = 0;  
531   if (fBending) {
532       for (Int_t iModule=0; iModule<fNsec; iModule++)  
533           fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];      
534       fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
535   } else if (!fBending) {
536       fRpcHalfXsize = fModuleXmax[6];
537       fRpcHalfYsize = fStripYsize[1];
538   }
539   fRpcHalfXsize = fRpcHalfXsize / 2.;
540   fRpcHalfYsize = fRpcHalfYsize / 2.;  
541
542 /*
543   printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
544          fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
545
546   for (Int_t iModule=0; iModule<fNsec; iModule++) {
547       printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
548              iModule,fModuleXmin[iModule],fModuleXmax[iModule],
549              fModuleYmin[iModule],
550              fStripXsize[iModule],fStripYsize[iModule]);
551              }
552
553   for (Int_t iModule=0; iModule<fNsec; iModule++) {
554       printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
555              iModule,fNstrip[iModule],
556              fStripXsize[iModule],fStripYsize[iModule]);
557   }
558 */
559
560   fId = detectionElementId;
561 }
562
563 //_____________________________________________________________________________
564 void
565 AliMUONTriggerSegmentation::Print(Option_t*) const
566 {
567 /// Printing
568
569   cout << "fId=" << fId << " fBending=" << fBending << " fNsec=" 
570   << fNsec << " Nx,Ny=" << fNpx << "," << fNpy 
571   << " LineNumber=" << fLineNumber 
572   << " fRpcHalfSize(X,Y)=" << fRpcHalfXsize << "," << fRpcHalfYsize
573   << endl;
574   
575   for (Int_t iModule=0; iModule<fNsec; iModule++) 
576   { 
577     cout << "Module " << iModule 
578     << " xmin,xmax=" << fModuleXmin[iModule] 
579     << "," << fModuleXmax[iModule] 
580     << " ymin=" << fModuleYmin[iModule]
581     << " StripSize(X,Y)=(" << fStripXsize[iModule] << ","
582     << fStripYsize[iModule] << ")"
583     << endl;
584   }                    
585 }
586
587
588
589
590