1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //**********************************************************************
19 // 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 //**********************************************************************
25 #include "AliMUONTriggerSegmentation.h"
28 //___________________________________________
29 ClassImp(AliMUONTriggerSegmentation)
31 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation()
32 : AliMUONVGeometryDESegmentation(),
44 // add to St345SlatSegmentation
49 // add to St345SlatSegmentation
50 for (Int_t i=0; i<7; i++) {
61 //___________________________________________
62 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending)
63 : AliMUONVGeometryDESegmentation(),
74 // add to St345SlatSegmentation
79 // Non default constructor
81 // add to St345SlatSegmentation
82 for (Int_t i=0; i<7; i++) {
92 //----------------------------------------------------------------------
93 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(const AliMUONTriggerSegmentation& rhs) : AliMUONVGeometryDESegmentation(rhs)
95 AliFatal("Not implemented.");
97 //----------------------------------------------------------------------
98 AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation()
103 //----------------------------------------------------------------------
104 AliMUONTriggerSegmentation& AliMUONTriggerSegmentation::operator=(const AliMUONTriggerSegmentation& rhs)
106 // Protected assignement operator
107 if (this == &rhs) return *this;
108 AliFatal("Not implemented.");
111 //----------------------------------------------------------------------
112 Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ix)
114 // returns column number (from 0 to 6) in which the (global) module
115 // ix is sitting (could return 7 if ix=isec)
116 return TMath::Abs(ix)-Int_t(TMath::Abs(ix)/10)*10-1;
118 //----------------------------------------------------------------------
119 Bool_t AliMUONTriggerSegmentation::HasPad(Int_t ix, Int_t iy)
121 // check if steping outside the limits (iy=1,2... iy=0,1...)
122 Bool_t hasPad = true;
125 GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
126 if (iyGlo>=fNstrip[ModuleColNum(ixGlo)]) hasPad = false;
129 //____________________________________________________________________________
130 Float_t AliMUONTriggerSegmentation::Dpx(Int_t isec) const
132 // return x-strip width in sector isec
133 Float_t size = (isec<8) ? fStripXsize[isec-1] : fStripXsize[isec-2]/2.;
136 //____________________________________________________________________________
137 Float_t AliMUONTriggerSegmentation::Dpy(Int_t isec) const
139 // return y-strip width in sector isec
140 Float_t size = (isec<8) ? fStripYsize[isec-1] : fStripYsize[isec-2];
143 //----------------------------------------------------------------------------
144 void AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ixLoc, Int_t iyLoc,
145 Int_t &ixGlo, Int_t &iyGlo)
147 // converts ixLoc & iyLoc into ixGlo & iyGLo (module,strip number)
148 ixGlo = 0; // see AliMUONTriggerConstants::fgkModuleI
149 iyGlo = 0; // from 0 to (fNtrip-1) in module
151 ixGlo = 10*fLineNumber + ixLoc;
153 } else if (!fBending) {
154 Int_t iCountStrip = 0;
155 for (Int_t iModule=0; iModule<fNsec; iModule++) {
156 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
157 if ((ixLoc-1)==iCountStrip) {
158 ixGlo = 10*fLineNumber + iModule + 1;
165 // printf(" in GetPadLoc2Glo fbending ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",fBending,ixLoc,iyLoc,ixGlo,iyGlo);
168 //----------------------------------------------------------------------------
169 void AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
170 Int_t &ixLoc, Int_t &iyLoc)
172 // converts ixGlo & iyGlo into ixLoc & iyLoc
176 ixLoc = ModuleColNum(ixGlo) + 1;
178 } else if (!fBending) {
179 Int_t iCountStrip = 1;
180 for (Int_t iModule=0; iModule<fNsec; iModule++) {
181 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
182 if ((iModule==ModuleColNum(ixGlo))&&(iStrip==iyGlo)) {
190 // printf(" in GetPadGlo2Loc fBending ixGlo iyGlo ixLoc iyLoc %i %i %i %i %i \n",fBending,ixGlo,iyGlo,ixLoc,iyLoc);
193 //----------------------------------------------------------------------------
194 void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
196 // Returns local real coordinates (x,y) for local pad coordinates (ix,iy)
200 Int_t iModule = ModuleColNum(ix); // find column number (0-6)
203 x = fStripXsize[iModule]/ 2.;
205 x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
207 y = fModuleYmin[iModule] +
208 iy*fStripYsize[iModule] + fStripYsize[iModule]/2.;
209 } else if (!fBending) {
210 if (ModuleColNum(ix)==6 && iy>7) {
211 x = fModuleXmin[iModule] + 8*fStripXsize[iModule] +
212 (iy-8)*fStripXsize[iModule]/2. + fStripXsize[iModule]/4.;
214 x = fModuleXmin[iModule] +
215 iy*fStripXsize[iModule] + fStripXsize[iModule]/2.;
217 y = fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
219 x = x - fRpcHalfXsize;
220 y = y - fRpcHalfYsize;
222 // printf(" in GetPadC fBending ix iy x y %i %i %i %f %f \n",fBending,ix,iy,x,y);
225 //_____________________________________________________________________________
226 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
228 // Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
229 x = x + fRpcHalfXsize;
230 y = y + fRpcHalfYsize;
231 // find module number
233 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
234 if ( x > fModuleXmin[iModule] && x < fModuleXmax[iModule] ) {
235 ix = 10*fLineNumber + iModule + 1;
242 Float_t yMax = fModuleYmin[modNum];
244 Float_t xMax = fModuleXmin[modNum];
246 for (Int_t iStrip=0; iStrip<fNstrip[modNum]; iStrip++) {
249 yMax = yMin + fStripYsize[modNum];
250 if (y > yMin && y < yMax) iy = iStrip;
251 } else if (!fBending) {
253 if (modNum==6 && iStrip>7) {
254 xMax = xMin + fStripXsize[modNum]/2.;
256 xMax = xMin + fStripXsize[modNum];
258 if (x > xMin && x < xMax) iy = iStrip;
262 // printf("in GetPadI fBending x y ix iy %i %f %f %i %i \n",fBending,x,y,ix,iy);
264 //-------------------------------------------------------------------------
265 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
267 GetPadI(x, y, ix, iy);
270 //-------------------------------------------------------------------------
271 void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
272 fLineNumber = iLineNumber;
274 //-------------------------------------------------------------------------
275 void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
277 // Sets virtual pad coordinates, needed for evaluating pad response
278 // outside the tracking program
279 GetPadC(ix,iy,fX,fY);
280 fIx = ix; // used in IntegrationLimits
282 fSector=Sector(ix,iy);
284 //---------------------------------------------------------------------------
285 void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
291 //----------------------------------------------------------------------------
292 void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
297 //--------------------------------------------------------------------------
298 Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
300 // determine segmentation zone from pad coordinates (from 1 to 8)
301 if (!fBending && ModuleColNum(ix)==6 && iy>7) {
302 return 8; // sector 8: diff. strip width within same module
304 return ModuleColNum(ix)+1;
308 //-----------------------------------------------------------------------------
309 void AliMUONTriggerSegmentation::
310 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& x3, Float_t& x4)
312 // need to return (only) x4 = dist. betwwen the hit and the closest border of
316 Float_t xstrip,ystrip;
317 GetPadI(fXhit,fYhit,ix,iy);
318 GetPadC(ix,iy,xstrip,ystrip);
319 x1= (fBending) ? fYhit : fXhit; // hit y (bending) / x (!bending) position
320 x2= (fBending) ? ystrip : xstrip; // y or x coord. of the main strip
321 x3= (fBending) ? fY : fX; // current strip real y or x coord.
322 Int_t modNum = ModuleColNum(fIx);
324 // find the position of the 2 borders of the current strip
328 min = x3 - fStripYsize[modNum]/2.;
329 max = x3 + fStripYsize[modNum]/2.;
331 if (modNum==6 && fIy>7) { // equivalent to fSector == 8
332 min = x3 - fStripXsize[modNum]/4.;
333 max = x3 + fStripXsize[modNum]/4.;
335 min = x3 - fStripXsize[modNum]/2.;
336 max = x3 + fStripXsize[modNum]/2.;
338 // dist. between the hit and the closest border of the current strip
339 x4 = (TMath::Abs(max-x1) > TMath::Abs(min-x1)) ?
340 TMath::Abs(min-x1):TMath::Abs(max-x1);
341 // printf("fBending x1 x3 min max x4 %i %f %f %f %f %f\n",fBending,x1,x3,min,max,x4);
345 //-----------------------------------------------------------------------------
346 void AliMUONTriggerSegmentation::
347 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
349 //-----------------BENDING-----------------------------------------
350 // Returns list of 10 next neighbours for given X strip (ix, iy)
351 // neighbour number 4 in the list -
352 // neighbour number 3 in the list |
353 // neighbour number 2 in the list |_ Upper part
354 // neighbour number 1 in the list |
355 // neighbour number 0 in the list -
357 // neighbour number 5 in the list -
358 // neighbour number 6 in the list | _ Lower part
359 // neighbour number 7 in the list |
360 // neighbour number 8 in the list |
361 // neighbour number 9 in the list -
363 //-----------------NON-BENDING-------------------------------------
364 // Returns list of 10 next neighbours for given Y strip (ix, iy)
365 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
366 // \_______/ \_______/
369 Int_t absiX = TMath::Abs(iX);
370 Int_t modNum = ModuleColNum(absiX); // from 0 to 6
371 Int_t nStrip = fNstrip[modNum];
374 Int_t iCandidateUp, iCandidateDo;
378 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
381 for (Int_t i=0; i<5; i++) {
383 iCandidateUp = iY + (i + 1);
384 iCandidateDo = iY - (i + 1);
385 if (iCandidateUp < nStrip) {
387 Ylist[i] = iCandidateUp;
389 if (iCandidateDo >= 0) {
391 Ylist[j] = iCandidateDo;
396 } else { // non-bending
398 Int_t iCandidateLeft, iCandidateRight;
399 Int_t iNewCandidateRight=0;
400 Int_t iNewCandidateLeft=0;
401 // first strip number on the right of the left module
402 if ( modNum!=0 && absiX!=52 )
403 iNewCandidateLeft = fNstrip[modNum-1]-1;
407 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
411 for (Int_t i=0; i<5; i++) {
413 iCandidateRight = iY + (i + 1);
414 iCandidateLeft = iY - (i + 1);
415 if (iCandidateRight < nStrip) { // strip in same module
417 Ylist[i] = iCandidateRight;
418 } else if (modNum!=6) { // need to scan the module on the right
420 Ylist[i] = iNewCandidateRight;
421 iNewCandidateRight++;
424 if (iCandidateLeft >=0 ) { // strip in same module
426 Ylist[j] = iCandidateLeft;
427 } else if ( iNewCandidateLeft !=0) {
429 Ylist[j] = iNewCandidateLeft;
434 if (iX<0) { // left side of chamber
435 for (Int_t i=0; i<10; i++) {
436 if (Xlist[i]!=0) Xlist[i]=-Xlist[i];
443 // for (Int_t i=0; i<10; i++) {
444 // printf("AliMUONTriggerSegmentation LOC fBending i ix iy = %i %i %i %i \n",fBending,i,Xlist[i],Ylist[i]);
448 //--------------------------------------------------------------------------
449 void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
451 Float_t stripYsize[7],
452 Float_t stripXsize[7],
455 // printf(" fBending: %d \n",fBending);
458 if (fBending) nStripMax = nStrip[0];
460 for (Int_t i=0; i<7; i++) {
461 fNstrip[i]=nStrip[i];
462 fStripYsize[i]=stripYsize[i];
463 fStripXsize[i]=stripXsize[i];
466 // take care of offset in Y in chamber 5, first module
467 fModuleYmin[0] = offset;
470 Int_t npad = 0; // number of pad in x and y
471 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
472 fModuleXmin[iModule] = tmp;
473 npad = npad + fNstrip[iModule];
475 fModuleXmax[iModule] =
476 fModuleXmin[iModule] + fStripXsize[iModule];
477 } else if (!fBending) {
479 fModuleXmax[iModule] =
480 fModuleXmin[iModule] +
481 fStripXsize[iModule]*fNstrip[iModule];
482 } else if (iModule==6) {
483 fModuleXmax[iModule] =
484 fModuleXmin[iModule] +
485 (fStripXsize[iModule]*fNstrip[iModule]/2) +
486 (fStripXsize[iModule]/2.*fNstrip[iModule]/2);
489 tmp = fModuleXmax[iModule];
491 // calculate nStripMax in x & y
493 if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
494 } else if (!fBending) {
495 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
499 // associate nStripMax
500 // fNpx = (fBending) ? fNsec : nStripMax;
501 // fNpy = (fBending) ? nStripMax : 1;
502 fNpx = 124; // tot num of modules (like with old segmentation)
503 fNpy = 64; // max number of y strips within one module
505 // calculate half size in x & y (to shift local coordinate ref. system)
509 for (Int_t iModule=0; iModule<fNsec; iModule++)
510 fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];
511 fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
512 } else if (!fBending) {
513 fRpcHalfXsize = fModuleXmax[6];
514 fRpcHalfYsize = fStripYsize[1];
516 fRpcHalfXsize = fRpcHalfXsize / 2.;
517 fRpcHalfYsize = fRpcHalfYsize / 2.;
520 printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
521 fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
523 for (Int_t iModule=0; iModule<fNsec; iModule++) {
524 printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
525 iModule,fModuleXmin[iModule],fModuleXmax[iModule],
526 fModuleYmin[iModule],
527 fStripXsize[iModule],fStripYsize[iModule]);
530 for (Int_t iModule=0; iModule<fNsec; iModule++) {
531 printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
532 iModule,fNstrip[iModule],
533 fStripXsize[iModule],fStripYsize[iModule]);
537 fId = detectionElementId;