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++) {
60 AliDebug(1, Form("default (empty) ctor this = %p", this));
64 //___________________________________________
65 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending)
66 : AliMUONVGeometryDESegmentation(),
77 // add to St345SlatSegmentation
82 // Non default constructor
84 // add to St345SlatSegmentation
85 for (Int_t i=0; i<7; i++) {
94 AliDebug(1, Form("ctor this = %p", this) );
97 //----------------------------------------------------------------------
98 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(const AliMUONTriggerSegmentation& rhs) : AliMUONVGeometryDESegmentation(rhs)
100 AliFatal("Not implemented.");
102 //----------------------------------------------------------------------
103 AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation()
107 AliDebug(1, Form("dtor this = %p", this) );
109 //----------------------------------------------------------------------
110 AliMUONTriggerSegmentation& AliMUONTriggerSegmentation::operator=(const AliMUONTriggerSegmentation& rhs)
112 // Protected assignement operator
113 if (this == &rhs) return *this;
114 AliFatal("Not implemented.");
117 //----------------------------------------------------------------------
118 Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ix)
120 // returns column number (from 0 to 6) in which the (global) module
121 // ix is sitting (could return 7 if ix=isec)
122 return TMath::Abs(ix)-Int_t(TMath::Abs(ix)/10)*10-1;
124 //----------------------------------------------------------------------
125 Bool_t AliMUONTriggerSegmentation::HasPad(Int_t ix, Int_t iy)
127 // check if steping outside the limits (iy=1,2... iy=0,1...)
128 Bool_t hasPad = true;
131 GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
132 if (iyGlo>=fNstrip[ModuleColNum(ixGlo)]) hasPad = false;
135 //____________________________________________________________________________
136 Float_t AliMUONTriggerSegmentation::Dpx(Int_t isec) const
138 // return x-strip width in sector isec
139 Float_t size = (isec<8) ? fStripXsize[isec-1] : fStripXsize[isec-2]/2.;
142 //____________________________________________________________________________
143 Float_t AliMUONTriggerSegmentation::Dpy(Int_t isec) const
145 // return y-strip width in sector isec
146 Float_t size = (isec<8) ? fStripYsize[isec-1] : fStripYsize[isec-2];
149 //----------------------------------------------------------------------------
150 void AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ixLoc, Int_t iyLoc,
151 Int_t &ixGlo, Int_t &iyGlo)
153 // converts ixLoc & iyLoc into ixGlo & iyGLo (module,strip number)
154 ixGlo = 0; // see AliMUONTriggerConstants::fgkModuleI
155 iyGlo = 0; // from 0 to (fNtrip-1) in module
157 ixGlo = 10*fLineNumber + ixLoc;
159 } else if (!fBending) {
160 Int_t iCountStrip = 0;
161 for (Int_t iModule=0; iModule<fNsec; iModule++) {
162 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
163 if ((ixLoc-1)==iCountStrip) {
164 ixGlo = 10*fLineNumber + iModule + 1;
171 // printf(" in GetPadLoc2Glo fbending ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",fBending,ixLoc,iyLoc,ixGlo,iyGlo);
174 //----------------------------------------------------------------------------
175 void AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
176 Int_t &ixLoc, Int_t &iyLoc)
178 // converts ixGlo & iyGlo into ixLoc & iyLoc
182 ixLoc = ModuleColNum(ixGlo) + 1;
184 } else if (!fBending) {
185 Int_t iCountStrip = 1;
186 for (Int_t iModule=0; iModule<fNsec; iModule++) {
187 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
188 if ((iModule==ModuleColNum(ixGlo))&&(iStrip==iyGlo)) {
196 // printf(" in GetPadGlo2Loc fBending ixGlo iyGlo ixLoc iyLoc %i %i %i %i %i \n",fBending,ixGlo,iyGlo,ixLoc,iyLoc);
199 //----------------------------------------------------------------------------
200 void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
202 // Returns local real coordinates (x,y) for local pad coordinates (ix,iy)
206 Int_t iModule = ModuleColNum(ix); // find column number (0-6)
209 x = fStripXsize[iModule]/ 2.;
211 x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
213 y = fModuleYmin[iModule] +
214 iy*fStripYsize[iModule] + fStripYsize[iModule]/2.;
215 } else if (!fBending) {
216 if (ModuleColNum(ix)==6 && iy>7) {
217 x = fModuleXmin[iModule] + 8*fStripXsize[iModule] +
218 (iy-8)*fStripXsize[iModule]/2. + fStripXsize[iModule]/4.;
220 x = fModuleXmin[iModule] +
221 iy*fStripXsize[iModule] + fStripXsize[iModule]/2.;
223 y = fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
225 x = x - fRpcHalfXsize;
226 y = y - fRpcHalfYsize;
228 // printf(" in GetPadC fBending ix iy x y %i %i %i %f %f \n",fBending,ix,iy,x,y);
231 //_____________________________________________________________________________
232 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
234 // Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
238 x = x + fRpcHalfXsize;
239 y = y + fRpcHalfYsize;
240 // find module number
242 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
243 if ( x > fModuleXmin[iModule] && x < fModuleXmax[iModule] ) {
244 ix = 10*fLineNumber + iModule + 1;
251 Float_t yMax = fModuleYmin[modNum];
253 Float_t xMax = fModuleXmin[modNum];
255 for (Int_t iStrip=0; iStrip<fNstrip[modNum]; iStrip++) {
258 yMax = yMin + fStripYsize[modNum];
259 if (y > yMin && y < yMax) iy = iStrip;
260 } else if (!fBending) {
262 if (modNum==6 && iStrip>7) {
263 xMax = xMin + fStripXsize[modNum]/2.;
265 xMax = xMin + fStripXsize[modNum];
267 if (x > xMin && x < xMax) iy = iStrip;
271 // printf("in GetPadI fBending x y ix iy %i %f %f %i %i \n",fBending,x,y,ix,iy);
273 //-------------------------------------------------------------------------
274 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
276 GetPadI(x, y, ix, iy);
279 //-------------------------------------------------------------------------
280 void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
281 fLineNumber = iLineNumber;
283 //-------------------------------------------------------------------------
284 void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
286 // Sets virtual pad coordinates, needed for evaluating pad response
287 // outside the tracking program
288 GetPadC(ix,iy,fX,fY);
289 fIx = ix; // used in IntegrationLimits
291 fSector=Sector(ix,iy);
293 //---------------------------------------------------------------------------
294 void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
300 //----------------------------------------------------------------------------
301 void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
306 //--------------------------------------------------------------------------
307 Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
309 // determine segmentation zone from pad coordinates (from 1 to 8)
310 if (!fBending && ModuleColNum(ix)==6 && iy>7) {
311 return 8; // sector 8: diff. strip width within same module
313 return ModuleColNum(ix)+1;
317 //-----------------------------------------------------------------------------
318 void AliMUONTriggerSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,
319 Float_t& x3, Float_t& x4)
321 // need to return (only) x4 = dist. betwwen the hit and the closest border of
325 Float_t xstrip,ystrip;
326 GetPadI(fXhit,fYhit,ix,iy);
327 GetPadC(ix,iy,xstrip,ystrip);
328 AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
329 fXhit,fYhit,xstrip,ystrip));
330 x1= (fBending) ? fYhit : fXhit; // hit y (bending) / x (!bending) position
331 x2= (fBending) ? ystrip : xstrip; // y or x coord. of the main strip
332 x3= (fBending) ? fY : fX; // current strip real y or x coord.
333 Int_t modNum = ModuleColNum(fIx);
335 // find the position of the 2 borders of the current strip
339 min = x3 - fStripYsize[modNum]/2.;
340 max = x3 + fStripYsize[modNum]/2.;
342 if (modNum==6 && fIy>7) { // equivalent to fSector == 8
343 min = x3 - fStripXsize[modNum]/4.;
344 max = x3 + fStripXsize[modNum]/4.;
346 min = x3 - fStripXsize[modNum]/2.;
347 max = x3 + fStripXsize[modNum]/2.;
349 // dist. between the hit and the closest border of the current strip
350 x4 = (TMath::Abs(max-x1) > TMath::Abs(min-x1)) ?
351 TMath::Abs(min-x1):TMath::Abs(max-x1);
353 AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
354 fBending,x1,x2,x3,x4,min,max));
358 //-----------------------------------------------------------------------------
359 void AliMUONTriggerSegmentation::
360 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
362 //-----------------BENDING-----------------------------------------
363 // Returns list of 10 next neighbours for given X strip (ix, iy)
364 // neighbour number 4 in the list -
365 // neighbour number 3 in the list |
366 // neighbour number 2 in the list |_ Upper part
367 // neighbour number 1 in the list |
368 // neighbour number 0 in the list -
370 // neighbour number 5 in the list -
371 // neighbour number 6 in the list | _ Lower part
372 // neighbour number 7 in the list |
373 // neighbour number 8 in the list |
374 // neighbour number 9 in the list -
376 //-----------------NON-BENDING-------------------------------------
377 // Returns list of 10 next neighbours for given Y strip (ix, iy)
378 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
379 // \_______/ \_______/
382 Int_t absiX = TMath::Abs(iX);
383 Int_t modNum = ModuleColNum(absiX); // from 0 to 6
384 Int_t nStrip = fNstrip[modNum];
387 Int_t iCandidateUp, iCandidateDo;
391 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
394 for (Int_t i=0; i<5; i++) {
396 iCandidateUp = iY + (i + 1);
397 iCandidateDo = iY - (i + 1);
398 if (iCandidateUp < nStrip) {
400 Ylist[i] = iCandidateUp;
402 if (iCandidateDo >= 0) {
404 Ylist[j] = iCandidateDo;
409 } else { // non-bending
411 Int_t iCandidateLeft, iCandidateRight;
412 Int_t iNewCandidateRight=0;
413 Int_t iNewCandidateLeft=0;
414 // first strip number on the right of the left module
415 if ( modNum!=0 && absiX!=52 )
416 iNewCandidateLeft = fNstrip[modNum-1]-1;
420 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
424 for (Int_t i=0; i<5; i++) {
426 iCandidateRight = iY + (i + 1);
427 iCandidateLeft = iY - (i + 1);
428 if (iCandidateRight < nStrip) { // strip in same module
430 Ylist[i] = iCandidateRight;
431 } else if (modNum!=6) { // need to scan the module on the right
433 Ylist[i] = iNewCandidateRight;
434 iNewCandidateRight++;
437 if (iCandidateLeft >=0 ) { // strip in same module
439 Ylist[j] = iCandidateLeft;
440 } else if ( iNewCandidateLeft !=0) {
442 Ylist[j] = iNewCandidateLeft;
447 if (iX<0) { // left side of chamber
448 for (Int_t i=0; i<10; i++) {
449 if (Xlist[i]!=0) Xlist[i]=-Xlist[i];
456 // for (Int_t i=0; i<10; i++) {
457 // printf("AliMUONTriggerSegmentation LOC fBending i ix iy = %i %i %i %i \n",fBending,i,Xlist[i],Ylist[i]);
461 //--------------------------------------------------------------------------
462 void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
464 Float_t stripYsize[7],
465 Float_t stripXsize[7],
468 // printf(" fBending: %d \n",fBending);
471 if (fBending) nStripMax = nStrip[0];
473 for (Int_t i=0; i<7; i++) {
474 fNstrip[i]=nStrip[i];
475 fStripYsize[i]=stripYsize[i];
476 fStripXsize[i]=stripXsize[i];
479 // take care of offset in Y in chamber 5, first module
480 fModuleYmin[0] = offset;
483 Int_t npad = 0; // number of pad in x and y
484 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
485 fModuleXmin[iModule] = tmp;
486 npad = npad + fNstrip[iModule];
488 fModuleXmax[iModule] =
489 fModuleXmin[iModule] + fStripXsize[iModule];
490 } else if (!fBending) {
492 fModuleXmax[iModule] =
493 fModuleXmin[iModule] +
494 fStripXsize[iModule]*fNstrip[iModule];
495 } else if (iModule==6) {
496 fModuleXmax[iModule] =
497 fModuleXmin[iModule] +
498 (fStripXsize[iModule]*fNstrip[iModule]/2) +
499 (fStripXsize[iModule]/2.*fNstrip[iModule]/2);
502 tmp = fModuleXmax[iModule];
504 // calculate nStripMax in x & y
506 if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
507 } else if (!fBending) {
508 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
512 // associate nStripMax
513 // fNpx = (fBending) ? fNsec : nStripMax;
514 // fNpy = (fBending) ? nStripMax : 1;
515 fNpx = 124; // tot num of modules (like with old segmentation)
516 fNpy = 64; // max number of y strips within one module
518 // calculate half size in x & y (to shift local coordinate ref. system)
522 for (Int_t iModule=0; iModule<fNsec; iModule++)
523 fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];
524 fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
525 } else if (!fBending) {
526 fRpcHalfXsize = fModuleXmax[6];
527 fRpcHalfYsize = fStripYsize[1];
529 fRpcHalfXsize = fRpcHalfXsize / 2.;
530 fRpcHalfYsize = fRpcHalfYsize / 2.;
533 printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
534 fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
536 for (Int_t iModule=0; iModule<fNsec; iModule++) {
537 printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
538 iModule,fModuleXmin[iModule],fModuleXmax[iModule],
539 fModuleYmin[iModule],
540 fStripXsize[iModule],fStripYsize[iModule]);
543 for (Int_t iModule=0; iModule<fNsec; iModule++) {
544 printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
545 iModule,fNstrip[iModule],
546 fStripXsize[iModule],fStripYsize[iModule]);
550 fId = detectionElementId;
553 //_____________________________________________________________________________
555 AliMUONTriggerSegmentation::Print(Option_t*) const
557 cout << "fId=" << fId << " fBending=" << fBending << " fNsec="
558 << fNsec << " Nx,Ny=" << fNpx << "," << fNpy
559 << " LineNumber=" << fLineNumber
560 << " fRpcHalfSize(X,Y)=" << fRpcHalfXsize << "," << fRpcHalfYsize
563 for (Int_t iModule=0; iModule<fNsec; iModule++)
565 cout << "Module " << iModule
566 << " xmin,xmax=" << fModuleXmin[iModule]
567 << "," << fModuleXmax[iModule]
568 << " ymin=" << fModuleYmin[iModule]
569 << " StripSize(X,Y)=(" << fStripXsize[iModule] << ","
570 << fStripYsize[iModule] << ")"