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 /// \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.
24 #include "AliMUONTriggerSegmentation.h"
26 #include "Riostream.h"
29 ClassImp(AliMUONTriggerSegmentation)
32 //___________________________________________
33 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation()
34 : AliMUONVGeometryDESegmentation(),
46 // add to St345SlatSegmentation
51 /// Default constructor
53 // add to St345SlatSegmentation
54 for (Int_t i=0; i<7; i++) {
63 AliDebug(1, Form("default (empty) ctor this = %p", this));
67 //___________________________________________
68 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending)
69 : AliMUONVGeometryDESegmentation(),
80 // add to St345SlatSegmentation
85 /// Standard constructor
88 // add to St345SlatSegmentation
89 for (Int_t i=0; i<7; i++) {
98 AliDebug(1, Form("ctor this = %p", this) );
101 //----------------------------------------------------------------------
102 AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation()
106 AliDebug(1, Form("dtor this = %p", this) );
108 //----------------------------------------------------------------------
109 Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ix)
111 /// returns column number (from 0 to 6) in which the (global) module
112 /// ix is sitting (could return 7 if ix=isec)
114 return TMath::Abs(ix)-Int_t(TMath::Abs(ix)/10)*10-1;
116 //----------------------------------------------------------------------
117 Bool_t AliMUONTriggerSegmentation::HasPad(Int_t ix, Int_t iy)
119 /// check if steping outside the limits (iy=1,2... iy=0,1...)
121 Bool_t hasPad = true;
124 GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
125 if (iyGlo>=fNstrip[ModuleColNum(ixGlo)]) hasPad = false;
128 //____________________________________________________________________________
129 Float_t AliMUONTriggerSegmentation::Dpx(Int_t isec) const
131 /// 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
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)
150 ixGlo = 0; // see AliMUONTriggerConstants::fgkModuleI
151 iyGlo = 0; // from 0 to (fNtrip-1) in module
153 ixGlo = 10*fLineNumber + ixLoc;
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;
167 // printf(" in GetPadLoc2Glo fbending ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",fBending,ixLoc,iyLoc,ixGlo,iyGlo);
170 //----------------------------------------------------------------------------
171 void AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
172 Int_t &ixLoc, Int_t &iyLoc)
174 /// converts ixGlo & iyGlo into ixLoc & iyLoc
179 ixLoc = ModuleColNum(ixGlo) + 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)) {
193 // printf(" in GetPadGlo2Loc fBending ixGlo iyGlo ixLoc iyLoc %i %i %i %i %i \n",fBending,ixGlo,iyGlo,ixLoc,iyLoc);
196 //----------------------------------------------------------------------------
197 void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
199 /// Returns local real coordinates (x,y) for local pad coordinates (ix,iy)
203 Int_t iModule = ModuleColNum(ix); // find column number (0-6)
206 x = fStripXsize[iModule]/ 2.;
208 x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
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.;
217 x = fModuleXmin[iModule] +
218 iy*fStripXsize[iModule] + fStripXsize[iModule]/2.;
220 y = fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
222 x = x - fRpcHalfXsize;
223 y = y - fRpcHalfYsize;
225 // printf(" in GetPadC fBending ix iy x y %i %i %i %f %f \n",fBending,ix,iy,x,y);
228 //_____________________________________________________________________________
229 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
231 /// Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
236 x = x + fRpcHalfXsize;
237 y = y + fRpcHalfYsize;
238 // find module number
240 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
241 if ( x > fModuleXmin[iModule] && x < fModuleXmax[iModule] ) {
242 ix = 10*fLineNumber + iModule + 1;
249 Float_t yMax = fModuleYmin[modNum];
251 Float_t xMax = fModuleXmin[modNum];
253 for (Int_t iStrip=0; iStrip<fNstrip[modNum]; iStrip++) {
256 yMax = yMin + fStripYsize[modNum];
257 if (y > yMin && y < yMax) iy = iStrip;
258 } else if (!fBending) {
260 if (modNum==6 && iStrip>7) {
261 xMax = xMin + fStripXsize[modNum]/2.;
263 xMax = xMin + fStripXsize[modNum];
265 if (x > xMin && x < xMax) iy = iStrip;
269 // printf("in GetPadI fBending x y ix iy %i %f %f %i %i \n",fBending,x,y,ix,iy);
271 //-------------------------------------------------------------------------
272 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
274 /// Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
276 GetPadI(x, y, ix, iy);
279 //-------------------------------------------------------------------------
280 void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
283 fLineNumber = iLineNumber;
285 //-------------------------------------------------------------------------
286 void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
288 /// Sets virtual pad coordinates, needed for evaluating pad response
289 /// outside the tracking program
291 GetPadC(ix,iy,fX,fY);
292 fIx = ix; // used in IntegrationLimits
294 fSector=Sector(ix,iy);
296 //---------------------------------------------------------------------------
297 void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
304 //----------------------------------------------------------------------------
305 void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
312 //--------------------------------------------------------------------------
313 Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
315 /// determine segmentation zone from pad coordinates (from 1 to 8)
317 if (!fBending && ModuleColNum(ix)==6 && iy>7) {
318 return 8; // sector 8: diff. strip width within same module
320 return ModuleColNum(ix)+1;
324 //-----------------------------------------------------------------------------
325 void AliMUONTriggerSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,
326 Float_t& x3, Float_t& x4)
328 /// need to return (only) x4 = dist. betwwen the hit and the closest border of
329 /// the current strip
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);
342 // find the position of the 2 borders of the current strip
346 min = x3 - fStripYsize[modNum]/2.;
347 max = x3 + fStripYsize[modNum]/2.;
349 if (modNum==6 && fIy>7) { // equivalent to fSector == 8
350 min = x3 - fStripXsize[modNum]/4.;
351 max = x3 + fStripXsize[modNum]/4.;
353 min = x3 - fStripXsize[modNum]/2.;
354 max = x3 + fStripXsize[modNum]/2.;
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);
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));
365 //-----------------------------------------------------------------------------
366 void AliMUONTriggerSegmentation::
367 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
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 -
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 -
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 /// \\_______/ \\_______/
390 Int_t absiX = TMath::Abs(iX);
391 Int_t modNum = ModuleColNum(absiX); // from 0 to 6
392 Int_t nStrip = fNstrip[modNum];
395 Int_t iCandidateUp, iCandidateDo;
399 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
402 for (Int_t i=0; i<5; i++) {
404 iCandidateUp = iY + (i + 1);
405 iCandidateDo = iY - (i + 1);
406 if (iCandidateUp < nStrip) {
408 Ylist[i] = iCandidateUp;
410 if (iCandidateDo >= 0) {
412 Ylist[j] = iCandidateDo;
417 } else { // non-bending
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;
428 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
432 for (Int_t i=0; i<5; i++) {
434 iCandidateRight = iY + (i + 1);
435 iCandidateLeft = iY - (i + 1);
436 if (iCandidateRight < nStrip) { // strip in same module
438 Ylist[i] = iCandidateRight;
439 } else if (modNum!=6) { // need to scan the module on the right
441 Ylist[i] = iNewCandidateRight;
442 iNewCandidateRight++;
445 if (iCandidateLeft >=0 ) { // strip in same module
447 Ylist[j] = iCandidateLeft;
448 } else if ( iNewCandidateLeft !=0) {
450 Ylist[j] = iNewCandidateLeft;
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];
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]);
469 //--------------------------------------------------------------------------
470 void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
472 Float_t stripYsize[7],
473 Float_t stripXsize[7],
478 // printf(" fBending: %d \n",fBending);
481 if (fBending) nStripMax = nStrip[0];
483 for (Int_t i=0; i<7; i++) {
484 fNstrip[i]=nStrip[i];
485 fStripYsize[i]=stripYsize[i];
486 fStripXsize[i]=stripXsize[i];
489 // take care of offset in Y in chamber 5, first module
490 fModuleYmin[0] = offset;
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];
498 fModuleXmax[iModule] =
499 fModuleXmin[iModule] + fStripXsize[iModule];
500 } else if (!fBending) {
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);
512 tmp = fModuleXmax[iModule];
514 // calculate nStripMax in x & y
516 if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
517 } else if (!fBending) {
518 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
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
528 // calculate half size in x & y (to shift local coordinate ref. system)
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];
539 fRpcHalfXsize = fRpcHalfXsize / 2.;
540 fRpcHalfYsize = fRpcHalfYsize / 2.;
543 printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
544 fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
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]);
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]);
560 fId = detectionElementId;
563 //_____________________________________________________________________________
565 AliMUONTriggerSegmentation::Print(Option_t*) const
569 cout << "fId=" << fId << " fBending=" << fBending << " fNsec="
570 << fNsec << " Nx,Ny=" << fNpx << "," << fNpy
571 << " LineNumber=" << fLineNumber
572 << " fRpcHalfSize(X,Y)=" << fRpcHalfXsize << "," << fRpcHalfYsize
575 for (Int_t iModule=0; iModule<fNsec; iModule++)
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] << ")"