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