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(),
47 // add to St345SlatSegmentation
52 /// Default constructor
54 // add to St345SlatSegmentation
55 for (Int_t i=0; i<7; i++) {
64 AliDebug(1, Form("default (empty) ctor this = %p", this));
68 //___________________________________________
69 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending)
70 : AliMUONVGeometryDESegmentation(),
83 // add to St345SlatSegmentation
88 /// Standard constructor
90 // add to St345SlatSegmentation
91 for (Int_t i=0; i<7; i++) {
100 AliDebug(1, Form("ctor this = %p", this) );
103 //----------------------------------------------------------------------
104 AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation()
108 AliDebug(1, Form("dtor this = %p", this) );
110 //----------------------------------------------------------------------
111 Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ix)
113 /// returns column number (from 0 to 6) in which the (global) module
114 /// 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...)
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
135 Float_t size = (isec<8) ? fStripXsize[isec-1] : fStripXsize[isec-2]/2.;
138 //____________________________________________________________________________
139 Float_t AliMUONTriggerSegmentation::Dpy(Int_t isec) const
141 /// return y-strip width in sector isec
143 Float_t size = (isec<8) ? fStripYsize[isec-1] : fStripYsize[isec-2];
146 //----------------------------------------------------------------------------
147 void AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ixLoc, Int_t iyLoc,
148 Int_t &ixGlo, Int_t &iyGlo)
150 /// converts ixLoc & iyLoc into ixGlo & iyGLo (module,strip number)
153 iyGlo = 0; // from 0 to (fNtrip-1) in module
155 ixGlo = 10*fLineNumber + ixLoc;
157 } else if (!fBending) {
158 Int_t iCountStrip = 0;
159 for (Int_t iModule=0; iModule<fNsec; iModule++) {
160 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
161 if ((ixLoc-1)==iCountStrip) {
162 ixGlo = 10*fLineNumber + iModule + 1;
169 // printf(" in GetPadLoc2Glo fbending ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",fBending,ixLoc,iyLoc,ixGlo,iyGlo);
172 //----------------------------------------------------------------------------
173 void AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
174 Int_t &ixLoc, Int_t &iyLoc)
176 /// converts ixGlo & iyGlo into ixLoc & iyLoc
181 ixLoc = ModuleColNum(ixGlo) + 1;
183 } else if (!fBending) {
184 Int_t iCountStrip = 1;
185 for (Int_t iModule=0; iModule<fNsec; iModule++) {
186 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
187 if ((iModule==ModuleColNum(ixGlo))&&(iStrip==iyGlo)) {
195 // printf(" in GetPadGlo2Loc fBending ixGlo iyGlo ixLoc iyLoc %i %i %i %i %i \n",fBending,ixGlo,iyGlo,ixLoc,iyLoc);
198 //----------------------------------------------------------------------------
199 void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
201 /// Returns local real coordinates (x,y) for local pad coordinates (ix,iy)
205 Int_t iModule = ModuleColNum(ix); // find column number (0-6)
208 x = fStripXsize[iModule]/ 2.;
210 x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
212 y = fModuleYmin[iModule] +
213 iy*fStripYsize[iModule] + fStripYsize[iModule]/2.;
214 } else if (!fBending) {
215 if (ModuleColNum(ix)==6 && iy>7) {
216 x = fModuleXmin[iModule] + 8*fStripXsize[iModule] +
217 (iy-8)*fStripXsize[iModule]/2. + fStripXsize[iModule]/4.;
219 x = fModuleXmin[iModule] +
220 iy*fStripXsize[iModule] + fStripXsize[iModule]/2.;
222 y = fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
224 x = x - fRpcHalfXsize;
225 y = y - fRpcHalfYsize;
227 // printf(" in GetPadC fBending ix iy x y %i %i %i %f %f \n",fBending,ix,iy,x,y);
230 //_____________________________________________________________________________
231 void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
233 /// 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 /// Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
278 GetPadI(x, y, ix, iy);
281 //-------------------------------------------------------------------------
282 void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
285 fLineNumber = iLineNumber;
287 //-------------------------------------------------------------------------
288 void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
290 /// Sets virtual pad coordinates, needed for evaluating pad response
291 /// outside the tracking program
293 GetPadC(ix,iy,fX,fY);
294 fIx = ix; // used in IntegrationLimits
296 fSector=Sector(ix,iy);
298 //---------------------------------------------------------------------------
299 void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
306 //----------------------------------------------------------------------------
307 void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
314 //--------------------------------------------------------------------------
315 Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
317 /// determine segmentation zone from pad coordinates (from 1 to 8)
319 if (!fBending && ModuleColNum(ix)==6 && iy>7) {
320 return 8; // sector 8: diff. strip width within same module
322 return ModuleColNum(ix)+1;
326 //-----------------------------------------------------------------------------
327 void AliMUONTriggerSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,
328 Float_t& x3, Float_t& x4)
330 /// need to return (only) x4 = dist. betwwen the hit and the closest border of
331 /// the current strip
334 Float_t xstrip,ystrip;
335 GetPadI(fXhit,fYhit,ix,iy);
336 GetPadC(ix,iy,xstrip,ystrip);
337 AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
338 fXhit,fYhit,xstrip,ystrip));
339 x1= (fBending) ? fYhit : fXhit; // hit y (bending) / x (!bending) position
340 x2= (fBending) ? ystrip : xstrip; // y or x coord. of the main strip
341 x3= (fBending) ? fY : fX; // current strip real y or x coord.
342 Int_t modNum = ModuleColNum(fIx);
344 // find the position of the 2 borders of the current strip
348 min = x3 - fStripYsize[modNum]/2.;
349 max = x3 + fStripYsize[modNum]/2.;
351 if (modNum==6 && fIy>7) { // equivalent to fSector == 8
352 min = x3 - fStripXsize[modNum]/4.;
353 max = x3 + fStripXsize[modNum]/4.;
355 min = x3 - fStripXsize[modNum]/2.;
356 max = x3 + fStripXsize[modNum]/2.;
358 // dist. between the hit and the closest border of the current strip
359 x4 = (TMath::Abs(max-x1) > TMath::Abs(min-x1)) ?
360 TMath::Abs(min-x1):TMath::Abs(max-x1);
362 AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
363 fBending,x1,x2,x3,x4,min,max));
367 //-----------------------------------------------------------------------------
368 void AliMUONTriggerSegmentation::
369 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
372 ///-----------------BENDING-----------------------------------------
373 /// Returns list of 10 next neighbours for given X strip (ix, iy)
374 /// neighbour number 4 in the list -
375 /// neighbour number 3 in the list |
376 /// neighbour number 2 in the list |_ Upper part
377 /// neighbour number 1 in the list |
378 /// neighbour number 0 in the list -
380 /// neighbour number 5 in the list -
381 /// neighbour number 6 in the list | _ Lower part
382 /// neighbour number 7 in the list |
383 /// neighbour number 8 in the list |
384 /// neighbour number 9 in the list -
386 ///-----------------NON-BENDING-------------------------------------
387 /// Returns list of 10 next neighbours for given Y strip (ix, iy)
388 /// neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
389 /// \\_______/ \\_______/
392 Int_t absiX = TMath::Abs(iX);
393 Int_t modNum = ModuleColNum(absiX); // from 0 to 6
394 Int_t nStrip = fNstrip[modNum];
397 Int_t iCandidateUp, iCandidateDo;
401 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
404 for (Int_t i=0; i<5; i++) {
406 iCandidateUp = iY + (i + 1);
407 iCandidateDo = iY - (i + 1);
408 if (iCandidateUp < nStrip) {
410 Ylist[i] = iCandidateUp;
412 if (iCandidateDo >= 0) {
414 Ylist[j] = iCandidateDo;
419 } else { // non-bending
421 Int_t iCandidateLeft, iCandidateRight;
422 Int_t iNewCandidateRight=0;
423 Int_t iNewCandidateLeft=0;
424 // first strip number on the right of the left module
425 if ( modNum!=0 && absiX!=52 )
426 iNewCandidateLeft = fNstrip[modNum-1]-1;
430 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
434 for (Int_t i=0; i<5; i++) {
436 iCandidateRight = iY + (i + 1);
437 iCandidateLeft = iY - (i + 1);
438 if (iCandidateRight < nStrip) { // strip in same module
440 Ylist[i] = iCandidateRight;
441 } else if (modNum!=6) { // need to scan the module on the right
443 Ylist[i] = iNewCandidateRight;
444 iNewCandidateRight++;
447 if (iCandidateLeft >=0 ) { // strip in same module
449 Ylist[j] = iCandidateLeft;
450 } else if ( iNewCandidateLeft !=0) {
452 Ylist[j] = iNewCandidateLeft;
457 if (iX<0) { // left side of chamber
458 for (Int_t i=0; i<10; i++) {
459 if (Xlist[i]!=0) Xlist[i]=-Xlist[i];
466 // for (Int_t i=0; i<10; i++) {
467 // printf("AliMUONTriggerSegmentation LOC fBending i ix iy = %i %i %i %i \n",fBending,i,Xlist[i],Ylist[i]);
471 //--------------------------------------------------------------------------
472 void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
474 Float_t stripYsize[7],
475 Float_t stripXsize[7],
480 // printf(" fBending: %d \n",fBending);
483 if (fBending) nStripMax = nStrip[0];
485 for (Int_t i=0; i<7; i++) {
486 fNstrip[i]=nStrip[i];
487 fStripYsize[i]=stripYsize[i];
488 fStripXsize[i]=stripXsize[i];
491 // take care of offset in Y in chamber 5, first module
492 fModuleYmin[0] = offset;
495 Int_t npad = 0; // number of pad in x and y
496 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
497 fModuleXmin[iModule] = tmp;
498 npad = npad + fNstrip[iModule];
500 fModuleXmax[iModule] =
501 fModuleXmin[iModule] + fStripXsize[iModule];
502 } else if (!fBending) {
504 fModuleXmax[iModule] =
505 fModuleXmin[iModule] +
506 fStripXsize[iModule]*fNstrip[iModule];
507 } else if (iModule==6) {
508 fModuleXmax[iModule] =
509 fModuleXmin[iModule] +
510 (fStripXsize[iModule]*fNstrip[iModule]/2) +
511 (fStripXsize[iModule]/2.*fNstrip[iModule]/2);
514 tmp = fModuleXmax[iModule];
516 // calculate nStripMax in x & y
518 if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
519 } else if (!fBending) {
520 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
524 // associate nStripMax
525 // fNpx = (fBending) ? fNsec : nStripMax;
526 // fNpy = (fBending) ? nStripMax : 1;
527 fNpx = 124; // tot num of modules (like with old segmentation)
528 fNpy = 64; // max number of y strips within one module
530 // calculate half size in x & y (to shift local coordinate ref. system)
534 for (Int_t iModule=0; iModule<fNsec; iModule++)
535 fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];
536 fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
537 } else if (!fBending) {
538 fRpcHalfXsize = fModuleXmax[6];
539 fRpcHalfYsize = fStripYsize[1];
541 fRpcHalfXsize = fRpcHalfXsize / 2.;
542 fRpcHalfYsize = fRpcHalfYsize / 2.;
545 printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
546 fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
548 for (Int_t iModule=0; iModule<fNsec; iModule++) {
549 printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
550 iModule,fModuleXmin[iModule],fModuleXmax[iModule],
551 fModuleYmin[iModule],
552 fStripXsize[iModule],fStripYsize[iModule]);
555 for (Int_t iModule=0; iModule<fNsec; iModule++) {
556 printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
557 iModule,fNstrip[iModule],
558 fStripXsize[iModule],fStripYsize[iModule]);
562 fId = detectionElementId;
565 //_____________________________________________________________________________
567 AliMUONTriggerSegmentation::Print(Option_t*) const
571 cout << "fId=" << fId << " fBending=" << fBending << " fNsec="
572 << fNsec << " Nx,Ny=" << fNpx << "," << fNpy
573 << " LineNumber=" << fLineNumber
574 << " fRpcHalfSize(X,Y)=" << fRpcHalfXsize << "," << fRpcHalfYsize
577 for (Int_t iModule=0; iModule<fNsec; iModule++)
579 cout << "Module " << iModule
580 << " xmin,xmax=" << fModuleXmin[iModule]
581 << "," << fModuleXmax[iModule]
582 << " ymin=" << fModuleYmin[iModule]
583 << " StripSize(X,Y)=(" << fStripXsize[iModule] << ","
584 << fStripYsize[iModule] << ")"