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"
27 #include "Riostream.h"
29 //___________________________________________
30 ClassImp(AliMUONTriggerSegmentation)
32 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation()
33 : AliMUONVGeometryDESegmentation(),
45 // add to St345SlatSegmentation
50 // add to St345SlatSegmentation
51 for (Int_t i=0; i<7; i++) {
62 //___________________________________________
63 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending)
64 : AliMUONVGeometryDESegmentation(),
75 // add to St345SlatSegmentation
80 // Non default constructor
82 // add to St345SlatSegmentation
83 for (Int_t i=0; i<7; i++) {
93 //----------------------------------------------------------------------
94 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(const AliMUONTriggerSegmentation& rhs) : AliMUONVGeometryDESegmentation(rhs)
96 AliFatal("Not implemented.");
98 //----------------------------------------------------------------------
99 AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation()
104 //----------------------------------------------------------------------
105 AliMUONTriggerSegmentation& AliMUONTriggerSegmentation::operator=(const AliMUONTriggerSegmentation& rhs)
107 // Protected assignement operator
108 if (this == &rhs) return *this;
109 AliFatal("Not implemented.");
112 //----------------------------------------------------------------------
113 Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ix)
115 // returns column number (from 0 to 6) in which the (global) module
116 // ix is sitting (could return 7 if ix=isec)
117 return TMath::Abs(ix)-Int_t(TMath::Abs(ix)/10)*10-1;
119 //----------------------------------------------------------------------
120 Bool_t AliMUONTriggerSegmentation::HasPad(Int_t ix, Int_t iy)
122 // check if steping outside the limits (iy=1,2... iy=0,1...)
123 Bool_t hasPad = true;
126 GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
127 if (iyGlo>=fNstrip[ModuleColNum(ixGlo)]) hasPad = false;
130 //____________________________________________________________________________
131 Float_t AliMUONTriggerSegmentation::Dpx(Int_t isec) const
133 // return x-strip width in sector isec
134 Float_t size = (isec<8) ? fStripXsize[isec-1] : fStripXsize[isec-2]/2.;
137 //____________________________________________________________________________
138 Float_t AliMUONTriggerSegmentation::Dpy(Int_t isec) const
140 // return y-strip width in sector isec
141 Float_t size = (isec<8) ? fStripYsize[isec-1] : fStripYsize[isec-2];
144 //----------------------------------------------------------------------------
145 void AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ixLoc, Int_t iyLoc,
146 Int_t &ixGlo, Int_t &iyGlo)
148 // converts ixLoc & iyLoc into ixGlo & iyGLo (module,strip number)
149 ixGlo = 0; // see AliMUONTriggerConstants::fgkModuleI
150 iyGlo = 0; // from 0 to (fNtrip-1) in module
152 ixGlo = 10*fLineNumber + ixLoc;
154 } else if (!fBending) {
155 Int_t iCountStrip = 0;
156 for (Int_t iModule=0; iModule<fNsec; iModule++) {
157 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
158 if ((ixLoc-1)==iCountStrip) {
159 ixGlo = 10*fLineNumber + iModule + 1;
166 // printf(" in GetPadLoc2Glo fbending ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",fBending,ixLoc,iyLoc,ixGlo,iyGlo);
169 //----------------------------------------------------------------------------
170 void AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
171 Int_t &ixLoc, Int_t &iyLoc)
173 // converts ixGlo & iyGlo into ixLoc & iyLoc
177 ixLoc = ModuleColNum(ixGlo) + 1;
179 } else if (!fBending) {
180 Int_t iCountStrip = 1;
181 for (Int_t iModule=0; iModule<fNsec; iModule++) {
182 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
183 if ((iModule==ModuleColNum(ixGlo))&&(iStrip==iyGlo)) {
191 // printf(" in GetPadGlo2Loc fBending ixGlo iyGlo ixLoc iyLoc %i %i %i %i %i \n",fBending,ixGlo,iyGlo,ixLoc,iyLoc);
194 //----------------------------------------------------------------------------
195 void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
197 // Returns local real coordinates (x,y) for local pad coordinates (ix,iy)
201 Int_t iModule = ModuleColNum(ix); // find column number (0-6)
204 x = fStripXsize[iModule]/ 2.;
206 x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
208 y = fModuleYmin[iModule] +
209 iy*fStripYsize[iModule] + fStripYsize[iModule]/2.;
210 } else if (!fBending) {
211 if (ModuleColNum(ix)==6 && iy>7) {
212 x = fModuleXmin[iModule] + 8*fStripXsize[iModule] +
213 (iy-8)*fStripXsize[iModule]/2. + fStripXsize[iModule]/4.;
215 x = fModuleXmin[iModule] +
216 iy*fStripXsize[iModule] + fStripXsize[iModule]/2.;
218 y = fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
220 x = x - fRpcHalfXsize;
221 y = y - fRpcHalfYsize;
223 // printf(" in GetPadC fBending ix iy x y %i %i %i %f %f \n",fBending,ix,iy,x,y);
226 //_____________________________________________________________________________
227 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
229 // Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
233 x = x + fRpcHalfXsize;
234 y = y + fRpcHalfYsize;
235 // find module number
237 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
238 if ( x > fModuleXmin[iModule] && x < fModuleXmax[iModule] ) {
239 ix = 10*fLineNumber + iModule + 1;
246 Float_t yMax = fModuleYmin[modNum];
248 Float_t xMax = fModuleXmin[modNum];
250 for (Int_t iStrip=0; iStrip<fNstrip[modNum]; iStrip++) {
253 yMax = yMin + fStripYsize[modNum];
254 if (y > yMin && y < yMax) iy = iStrip;
255 } else if (!fBending) {
257 if (modNum==6 && iStrip>7) {
258 xMax = xMin + fStripXsize[modNum]/2.;
260 xMax = xMin + fStripXsize[modNum];
262 if (x > xMin && x < xMax) iy = iStrip;
266 // printf("in GetPadI fBending x y ix iy %i %f %f %i %i \n",fBending,x,y,ix,iy);
268 //-------------------------------------------------------------------------
269 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
271 GetPadI(x, y, ix, iy);
274 //-------------------------------------------------------------------------
275 void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
276 fLineNumber = iLineNumber;
278 //-------------------------------------------------------------------------
279 void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
281 // Sets virtual pad coordinates, needed for evaluating pad response
282 // outside the tracking program
283 GetPadC(ix,iy,fX,fY);
284 fIx = ix; // used in IntegrationLimits
286 fSector=Sector(ix,iy);
288 //---------------------------------------------------------------------------
289 void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
295 //----------------------------------------------------------------------------
296 void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
301 //--------------------------------------------------------------------------
302 Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
304 // determine segmentation zone from pad coordinates (from 1 to 8)
305 if (!fBending && ModuleColNum(ix)==6 && iy>7) {
306 return 8; // sector 8: diff. strip width within same module
308 return ModuleColNum(ix)+1;
312 //-----------------------------------------------------------------------------
313 void AliMUONTriggerSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,
314 Float_t& x3, Float_t& x4)
316 // need to return (only) x4 = dist. betwwen the hit and the closest border of
320 Float_t xstrip,ystrip;
321 GetPadI(fXhit,fYhit,ix,iy);
322 GetPadC(ix,iy,xstrip,ystrip);
323 AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
324 fXhit,fYhit,xstrip,ystrip));
325 x1= (fBending) ? fYhit : fXhit; // hit y (bending) / x (!bending) position
326 x2= (fBending) ? ystrip : xstrip; // y or x coord. of the main strip
327 x3= (fBending) ? fY : fX; // current strip real y or x coord.
328 Int_t modNum = ModuleColNum(fIx);
330 // find the position of the 2 borders of the current strip
334 min = x3 - fStripYsize[modNum]/2.;
335 max = x3 + fStripYsize[modNum]/2.;
337 if (modNum==6 && fIy>7) { // equivalent to fSector == 8
338 min = x3 - fStripXsize[modNum]/4.;
339 max = x3 + fStripXsize[modNum]/4.;
341 min = x3 - fStripXsize[modNum]/2.;
342 max = x3 + fStripXsize[modNum]/2.;
344 // dist. between the hit and the closest border of the current strip
345 x4 = (TMath::Abs(max-x1) > TMath::Abs(min-x1)) ?
346 TMath::Abs(min-x1):TMath::Abs(max-x1);
348 AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
349 fBending,x1,x2,x3,x4,min,max));
353 //-----------------------------------------------------------------------------
354 void AliMUONTriggerSegmentation::
355 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
357 //-----------------BENDING-----------------------------------------
358 // Returns list of 10 next neighbours for given X strip (ix, iy)
359 // neighbour number 4 in the list -
360 // neighbour number 3 in the list |
361 // neighbour number 2 in the list |_ Upper part
362 // neighbour number 1 in the list |
363 // neighbour number 0 in the list -
365 // neighbour number 5 in the list -
366 // neighbour number 6 in the list | _ Lower part
367 // neighbour number 7 in the list |
368 // neighbour number 8 in the list |
369 // neighbour number 9 in the list -
371 //-----------------NON-BENDING-------------------------------------
372 // Returns list of 10 next neighbours for given Y strip (ix, iy)
373 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
374 // \_______/ \_______/
377 Int_t absiX = TMath::Abs(iX);
378 Int_t modNum = ModuleColNum(absiX); // from 0 to 6
379 Int_t nStrip = fNstrip[modNum];
382 Int_t iCandidateUp, iCandidateDo;
386 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
389 for (Int_t i=0; i<5; i++) {
391 iCandidateUp = iY + (i + 1);
392 iCandidateDo = iY - (i + 1);
393 if (iCandidateUp < nStrip) {
395 Ylist[i] = iCandidateUp;
397 if (iCandidateDo >= 0) {
399 Ylist[j] = iCandidateDo;
404 } else { // non-bending
406 Int_t iCandidateLeft, iCandidateRight;
407 Int_t iNewCandidateRight=0;
408 Int_t iNewCandidateLeft=0;
409 // first strip number on the right of the left module
410 if ( modNum!=0 && absiX!=52 )
411 iNewCandidateLeft = fNstrip[modNum-1]-1;
415 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
419 for (Int_t i=0; i<5; i++) {
421 iCandidateRight = iY + (i + 1);
422 iCandidateLeft = iY - (i + 1);
423 if (iCandidateRight < nStrip) { // strip in same module
425 Ylist[i] = iCandidateRight;
426 } else if (modNum!=6) { // need to scan the module on the right
428 Ylist[i] = iNewCandidateRight;
429 iNewCandidateRight++;
432 if (iCandidateLeft >=0 ) { // strip in same module
434 Ylist[j] = iCandidateLeft;
435 } else if ( iNewCandidateLeft !=0) {
437 Ylist[j] = iNewCandidateLeft;
442 if (iX<0) { // left side of chamber
443 for (Int_t i=0; i<10; i++) {
444 if (Xlist[i]!=0) Xlist[i]=-Xlist[i];
451 // for (Int_t i=0; i<10; i++) {
452 // printf("AliMUONTriggerSegmentation LOC fBending i ix iy = %i %i %i %i \n",fBending,i,Xlist[i],Ylist[i]);
456 //--------------------------------------------------------------------------
457 void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
459 Float_t stripYsize[7],
460 Float_t stripXsize[7],
463 // printf(" fBending: %d \n",fBending);
466 if (fBending) nStripMax = nStrip[0];
468 for (Int_t i=0; i<7; i++) {
469 fNstrip[i]=nStrip[i];
470 fStripYsize[i]=stripYsize[i];
471 fStripXsize[i]=stripXsize[i];
474 // take care of offset in Y in chamber 5, first module
475 fModuleYmin[0] = offset;
478 Int_t npad = 0; // number of pad in x and y
479 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
480 fModuleXmin[iModule] = tmp;
481 npad = npad + fNstrip[iModule];
483 fModuleXmax[iModule] =
484 fModuleXmin[iModule] + fStripXsize[iModule];
485 } else if (!fBending) {
487 fModuleXmax[iModule] =
488 fModuleXmin[iModule] +
489 fStripXsize[iModule]*fNstrip[iModule];
490 } else if (iModule==6) {
491 fModuleXmax[iModule] =
492 fModuleXmin[iModule] +
493 (fStripXsize[iModule]*fNstrip[iModule]/2) +
494 (fStripXsize[iModule]/2.*fNstrip[iModule]/2);
497 tmp = fModuleXmax[iModule];
499 // calculate nStripMax in x & y
501 if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
502 } else if (!fBending) {
503 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
507 // associate nStripMax
508 // fNpx = (fBending) ? fNsec : nStripMax;
509 // fNpy = (fBending) ? nStripMax : 1;
510 fNpx = 124; // tot num of modules (like with old segmentation)
511 fNpy = 64; // max number of y strips within one module
513 // calculate half size in x & y (to shift local coordinate ref. system)
517 for (Int_t iModule=0; iModule<fNsec; iModule++)
518 fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];
519 fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
520 } else if (!fBending) {
521 fRpcHalfXsize = fModuleXmax[6];
522 fRpcHalfYsize = fStripYsize[1];
524 fRpcHalfXsize = fRpcHalfXsize / 2.;
525 fRpcHalfYsize = fRpcHalfYsize / 2.;
528 printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
529 fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
531 for (Int_t iModule=0; iModule<fNsec; iModule++) {
532 printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
533 iModule,fModuleXmin[iModule],fModuleXmax[iModule],
534 fModuleYmin[iModule],
535 fStripXsize[iModule],fStripYsize[iModule]);
538 for (Int_t iModule=0; iModule<fNsec; iModule++) {
539 printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
540 iModule,fNstrip[iModule],
541 fStripXsize[iModule],fStripYsize[iModule]);
545 fId = detectionElementId;
548 //_____________________________________________________________________________
550 AliMUONTriggerSegmentation::Print(Option_t*) const
552 cout << "fId=" << fId << " fBending=" << fBending << " fNsec="
553 << fNsec << " Nx,Ny=" << fNpx << "," << fNpy
554 << " LineNumber=" << fLineNumber
555 << " fRpcHalfSize(X,Y)=" << fRpcHalfXsize << "," << fRpcHalfYsize
558 for (Int_t iModule=0; iModule<fNsec; iModule++)
560 cout << "Module " << iModule
561 << " xmin,xmax=" << fModuleXmin[iModule]
562 << "," << fModuleXmax[iModule]
563 << " ymin=" << fModuleYmin[iModule]
564 << " StripSize(X,Y)=(" << fStripXsize[iModule] << ","
565 << fStripYsize[iModule] << ")"