]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerSegmentation.cxx
Updated for replacement of AliMpReader with AliMpSectorReader
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerSegmentation.cxx
CommitLineData
0a11496e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
d173a061 18//**********************************************************************
38aedc99 19// Segmentation classe for trigger chambers.
d173a061 20// In the present version the method use global strip coordinates except
21// HasPad. The conversion is made via GetPadLoc2Glo.
38aedc99 22// To be improved in the future.
d173a061 23//**********************************************************************
0a11496e 24
0a11496e 25#include "AliMUONTriggerSegmentation.h"
26#include "AliLog.h"
27
28//___________________________________________
29ClassImp(AliMUONTriggerSegmentation)
30
a713db22 31AliMUONTriggerSegmentation::AliMUONTriggerSegmentation()
32 : AliMUONVGeometryDESegmentation(),
33 fBending(0),
79b4ba23 34 fId(0),
38aedc99 35 fNsec(7),
79b4ba23 36 fNpx(999999),
37 fNpy(999999),
79b4ba23 38 fXhit(0.),
39 fYhit(0.),
40 fIx(0),
41 fIy(0),
42 fX(0.),
43 fY(0.),
79b4ba23 44// add to St345SlatSegmentation
45 fLineNumber(0),
46 fRpcHalfXsize(0),
47 fRpcHalfYsize(0)
a713db22 48{
79b4ba23 49// add to St345SlatSegmentation
50 for (Int_t i=0; i<7; i++) {
51 fNstrip[i]=0;
52 fStripYsize[i]=0.;
53 fStripXsize[i]=0.;
54 fModuleXmin[i]=0.;
55 fModuleXmax[i]=0.;
56 fModuleYmin[i]=0.;
57 }
a713db22 58}
79b4ba23 59
60
a713db22 61//___________________________________________
0a11496e 62AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending)
63 : AliMUONVGeometryDESegmentation(),
79b4ba23 64 fBending(bending),
65 fId(0),
79b4ba23 66 fNpx(999999),
67 fNpy(999999),
79b4ba23 68 fXhit(0.),
69 fYhit(0.),
70 fIx(0),
71 fIy(0),
72 fX(0.),
73 fY(0.),
79b4ba23 74// add to St345SlatSegmentation
75 fLineNumber(0),
76 fRpcHalfXsize(0),
77 fRpcHalfYsize(0)
0a11496e 78{
79 // Non default constructor
d173a061 80 fNsec = 7;
79b4ba23 81// add to St345SlatSegmentation
82 for (Int_t i=0; i<7; i++) {
83 fNstrip[i]=0;
84 fStripYsize[i]=0.;
85 fStripXsize[i]=0.;
86 fModuleXmin[i]=0.;
87 fModuleXmax[i]=0.;
88 fModuleYmin[i]=0.;
89 }
0a11496e 90}
79b4ba23 91
0a11496e 92//----------------------------------------------------------------------
93AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(const AliMUONTriggerSegmentation& rhs) : AliMUONVGeometryDESegmentation(rhs)
94{
95 AliFatal("Not implemented.");
96}
97//----------------------------------------------------------------------
98AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation()
99{
100 // Destructor
d173a061 101 ;
0a11496e 102}
103//----------------------------------------------------------------------
104AliMUONTriggerSegmentation& AliMUONTriggerSegmentation::operator=(const AliMUONTriggerSegmentation& rhs)
105{
79b4ba23 106// Protected assignement operator
0a11496e 107 if (this == &rhs) return *this;
108 AliFatal("Not implemented.");
109 return *this;
110}
79b4ba23 111//----------------------------------------------------------------------
d173a061 112Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ix)
38aedc99 113{
114// returns column number (from 0 to 6) in which the (global) module
d173a061 115// ix is sitting (could return 7 if ix=isec)
116 return TMath::Abs(ix)-Int_t(TMath::Abs(ix)/10)*10-1;
38aedc99 117}
118//----------------------------------------------------------------------
79b4ba23 119Bool_t AliMUONTriggerSegmentation::HasPad(Int_t ix, Int_t iy)
120{
d173a061 121// check if steping outside the limits (iy=1,2... iy=0,1...)
38aedc99 122 Bool_t hasPad = true;
79b4ba23 123 Int_t ixGlo = 0;
38aedc99 124 Int_t iyGlo = 0;
125 GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
126 if (iyGlo>=fNstrip[ModuleColNum(ixGlo)]) hasPad = false;
79b4ba23 127 return hasPad;
128}
0a11496e 129//____________________________________________________________________________
130Float_t AliMUONTriggerSegmentation::Dpx(Int_t isec) const
131{
38aedc99 132// return x-strip width in sector isec
133 Float_t size = (isec<8) ? fStripXsize[isec-1] : fStripXsize[isec-2]/2.;
134 return size;
0a11496e 135}
136//____________________________________________________________________________
137Float_t AliMUONTriggerSegmentation::Dpy(Int_t isec) const
138{
38aedc99 139// return y-strip width in sector isec
140 Float_t size = (isec<8) ? fStripYsize[isec-1] : fStripYsize[isec-2];
141 return size;
0a11496e 142}
143//----------------------------------------------------------------------------
144void AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ixLoc, Int_t iyLoc,
145 Int_t &ixGlo, Int_t &iyGlo)
146{
79b4ba23 147// converts ixLoc & iyLoc into ixGlo & iyGLo (module,strip number)
38aedc99 148 ixGlo = 0; // see AliMUONTriggerConstants::fgkModuleI
149 iyGlo = 0; // from 0 to (fNtrip-1) in module
0a11496e 150 if (fBending) {
38aedc99 151 ixGlo = 10*fLineNumber + ixLoc;
0a11496e 152 iyGlo = iyLoc - 1;
153 } else if (!fBending) {
154 Int_t iCountStrip = 0;
38aedc99 155 for (Int_t iModule=0; iModule<fNsec; iModule++) {
0a11496e 156 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
157 if ((ixLoc-1)==iCountStrip) {
38aedc99 158 ixGlo = 10*fLineNumber + iModule + 1;
0a11496e 159 iyGlo = iStrip;
160 }
161 iCountStrip++;
162 }
163 }
164 }
d173a061 165// printf(" in GetPadLoc2Glo fbending ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",fBending,ixLoc,iyLoc,ixGlo,iyGlo);
0a11496e 166}
d173a061 167
168//----------------------------------------------------------------------------
169void AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
170 Int_t &ixLoc, Int_t &iyLoc)
171{
172// converts ixGlo & iyGlo into ixLoc & iyLoc
173 ixLoc = 0;
174 iyLoc = 0;
175 if (fBending) {
176 ixLoc = ModuleColNum(ixGlo) + 1;
177 iyLoc = iyGlo + 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)) {
183 ixLoc = 1;
184 iyLoc = iCountStrip;
185 }
186 iCountStrip++;
187 }
188 }
189 }
190// printf(" in GetPadGlo2Loc fBending ixGlo iyGlo ixLoc iyLoc %i %i %i %i %i \n",fBending,ixGlo,iyGlo,ixLoc,iyLoc);
191}
192
0a11496e 193//----------------------------------------------------------------------------
194void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
195{
d173a061 196// Returns local real coordinates (x,y) for local pad coordinates (ix,iy)
197
0a11496e 198 x = 0.;
199 y = 0.;
d173a061 200 Int_t iModule = ModuleColNum(ix); // find column number (0-6)
0a11496e 201 if (fBending) {
202 if (iModule==0) {
38aedc99 203 x = fStripXsize[iModule]/ 2.;
0a11496e 204 } else {
38aedc99 205 x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
206 }
79b4ba23 207 y = fModuleYmin[iModule] +
d173a061 208 iy*fStripYsize[iModule] + fStripYsize[iModule]/2.;
0a11496e 209 } else if (!fBending) {
d173a061 210 if (ModuleColNum(ix)==6 && iy>7) {
38aedc99 211 x = fModuleXmin[iModule] + 8*fStripXsize[iModule] +
d173a061 212 (iy-8)*fStripXsize[iModule]/2. + fStripXsize[iModule]/4.;
79b4ba23 213 } else {
214 x = fModuleXmin[iModule] +
d173a061 215 iy*fStripXsize[iModule] + fStripXsize[iModule]/2.;
79b4ba23 216 }
38aedc99 217 y = fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
0a11496e 218 }
219 x = x - fRpcHalfXsize;
220 y = y - fRpcHalfYsize;
221
d173a061 222// printf(" in GetPadC fBending ix iy x y %i %i %i %f %f \n",fBending,ix,iy,x,y);
0a11496e 223}
224
225//_____________________________________________________________________________
226void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
227{
d173a061 228// Returns global pad coordinates (ix,iy) for local real coordinates (x,y)
0a11496e 229 x = x + fRpcHalfXsize;
230 y = y + fRpcHalfYsize;
231// find module number
232 Int_t modNum=0;
38aedc99 233 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
0a11496e 234 if ( x > fModuleXmin[iModule] && x < fModuleXmax[iModule] ) {
8ceced0c 235 ix = 10*fLineNumber + iModule + 1;
0a11496e 236 modNum = iModule;
237 }
238 }
239
240// find strip number
241 Float_t yMin = 0.;
242 Float_t yMax = fModuleYmin[modNum];
243 Float_t xMin = 0.;
244 Float_t xMax = fModuleXmin[modNum];
245 if (ix!=0) {
246 for (Int_t iStrip=0; iStrip<fNstrip[modNum]; iStrip++) {
247 if (fBending) {
248 yMin = yMax;
249 yMax = yMin + fStripYsize[modNum];
250 if (y > yMin && y < yMax) iy = iStrip;
38aedc99 251 } else if (!fBending) {
0a11496e 252 xMin = xMax;
7743b3a9 253 if (modNum==6 && iStrip>7) {
254 xMax = xMin + fStripXsize[modNum]/2.;
255 } else {
256 xMax = xMin + fStripXsize[modNum];
257 }
0a11496e 258 if (x > xMin && x < xMax) iy = iStrip;
7743b3a9 259 } //
0a11496e 260 } // loop on strips
261 } // if ix!=0
d173a061 262// printf("in GetPadI fBending x y ix iy %i %f %f %i %i \n",fBending,x,y,ix,iy);
0a11496e 263}
264//-------------------------------------------------------------------------
265void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
266{
267 GetPadI(x, y, ix, iy);
268}
d173a061 269
0a11496e 270//-------------------------------------------------------------------------
271void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
272 fLineNumber = iLineNumber;
273}
274//-------------------------------------------------------------------------
0a11496e 275void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
276{
0a11496e 277 // Sets virtual pad coordinates, needed for evaluating pad response
278 // outside the tracking program
279 GetPadC(ix,iy,fX,fY);
d173a061 280 fIx = ix; // used in IntegrationLimits
281 fIy = iy;
0a11496e 282 fSector=Sector(ix,iy);
283}
284//---------------------------------------------------------------------------
285void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
286{
287 // Set current hit
0a11496e 288 fXhit = x;
289 fYhit = y;
0a11496e 290}
291//----------------------------------------------------------------------------
292void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
293{
294 SetHit(xhit, yhit);
295}
296
297//--------------------------------------------------------------------------
79b4ba23 298Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
0a11496e 299{
38aedc99 300// determine segmentation zone from pad coordinates (from 1 to 8)
d173a061 301 if (!fBending && ModuleColNum(ix)==6 && iy>7) {
38aedc99 302 return 8; // sector 8: diff. strip width within same module
79b4ba23 303 } else {
d173a061 304 return ModuleColNum(ix)+1;
38aedc99 305 }
0a11496e 306}
79b4ba23 307
0a11496e 308//-----------------------------------------------------------------------------
309void AliMUONTriggerSegmentation::
d173a061 310IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& x3, Float_t& x4)
0a11496e 311{
38aedc99 312// need to return (only) x4 = dist. betwwen the hit and the closest border of
313// the current strip
d173a061 314
38aedc99 315 Int_t ix,iy;
316 Float_t xstrip,ystrip;
d173a061 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);
38aedc99 323
d173a061 324 // find the position of the 2 borders of the current strip
325 Float_t min = 0.;
326 Float_t max = 0.;
327 if (fBending) {
328 min = x3 - fStripYsize[modNum]/2.;
329 max = x3 + fStripYsize[modNum]/2.;
330 } else {
331 if (modNum==6 && fIy>7) { // equivalent to fSector == 8
332 min = x3 - fStripXsize[modNum]/4.;
333 max = x3 + fStripXsize[modNum]/4.;
334 } else
335 min = x3 - fStripXsize[modNum]/2.;
336 max = x3 + fStripXsize[modNum]/2.;
337 }
38aedc99 338 // dist. between the hit and the closest border of the current strip
d173a061 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);
0a11496e 342}
38aedc99 343
344
0a11496e 345//-----------------------------------------------------------------------------
346void AliMUONTriggerSegmentation::
347Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
348{
d173a061 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 -
356// X strip (ix, iy)
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 -
362
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// \_______/ \_______/
367// left right
368
369 Int_t absiX = TMath::Abs(iX);
370 Int_t modNum = ModuleColNum(absiX); // from 0 to 6
371 Int_t nStrip = fNstrip[modNum];
372
373 if (fBending) {
374 Int_t iCandidateUp, iCandidateDo;
375 Int_t j;
376
377 *Nlist = 10;
378 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
379
380 if (iY < nStrip) {
381 for (Int_t i=0; i<5; i++) {
382 j = i + 5;
383 iCandidateUp = iY + (i + 1);
384 iCandidateDo = iY - (i + 1);
385 if (iCandidateUp < nStrip) {
386 Xlist[i] = iX;
387 Ylist[i] = iCandidateUp;
388 }
389 if (iCandidateDo >= 0) {
390 Xlist[j] = iX;
391 Ylist[j] = iCandidateDo;
392 }
393 }
394 } // iY < nStrip
395
396 } else { // non-bending
397
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;
404 Int_t j;
405
406 *Nlist = 10;
407 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
408
409 if (iY < nStrip) {
410
411 for (Int_t i=0; i<5; i++) {
412 j = i + 5;
413 iCandidateRight = iY + (i + 1);
414 iCandidateLeft = iY - (i + 1);
415 if (iCandidateRight < nStrip) { // strip in same module
416 Xlist[i] = absiX;
417 Ylist[i] = iCandidateRight;
418 } else if (modNum!=6) { // need to scan the module on the right
419 Xlist[i] = absiX+1;
420 Ylist[i] = iNewCandidateRight;
421 iNewCandidateRight++;
422 }
423
424 if (iCandidateLeft >=0 ) { // strip in same module
425 Xlist[j] = absiX;
426 Ylist[j] = iCandidateLeft;
427 } else if ( iNewCandidateLeft !=0) {
428 Xlist[j] = absiX-1;
429 Ylist[j] = iNewCandidateLeft;
430 iNewCandidateLeft--;
431 }
432 }
433
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];
437 }
438 }
439
440 } // iY < nStrip
441 } // non-bending
442
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]);
445// }
0a11496e 446}
447
448//--------------------------------------------------------------------------
449void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
0a11496e 450 Int_t nStrip[7],
451 Float_t stripYsize[7],
452 Float_t stripXsize[7],
453 Float_t offset)
454{
79b4ba23 455// printf(" fBending: %d \n",fBending);
456
457 Int_t nStripMax = 0;
458 if (fBending) nStripMax = nStrip[0];
459
460 for (Int_t i=0; i<7; i++) {
461 fNstrip[i]=nStrip[i];
462 fStripYsize[i]=stripYsize[i];
463 fStripXsize[i]=stripXsize[i];
464 fModuleYmin[0]=0.;
465 }
0a11496e 466// take care of offset in Y in chamber 5, first module
79b4ba23 467 fModuleYmin[0] = offset;
468
469 Float_t tmp = 0.;
470 Int_t npad = 0; // number of pad in x and y
38aedc99 471 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
79b4ba23 472 fModuleXmin[iModule] = tmp;
473 npad = npad + fNstrip[iModule];
474 if (fBending) {
475 fModuleXmax[iModule] =
476 fModuleXmin[iModule] + fStripXsize[iModule];
477 } else if (!fBending) {
478 if (iModule<6) {
479 fModuleXmax[iModule] =
38aedc99 480 fModuleXmin[iModule] +
481 fStripXsize[iModule]*fNstrip[iModule];
79b4ba23 482 } else if (iModule==6) {
483 fModuleXmax[iModule] =
484 fModuleXmin[iModule] +
485 (fStripXsize[iModule]*fNstrip[iModule]/2) +
486 (fStripXsize[iModule]/2.*fNstrip[iModule]/2);
487 }
488 }
489 tmp = fModuleXmax[iModule];
490
491// calculate nStripMax in x & y
492 if (fBending) {
493 if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
494 } else if (!fBending) {
495 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
496 }
497 } // loop on modules
0a11496e 498
499// associate nStripMax
7743b3a9 500// fNpx = (fBending) ? fNsec : nStripMax;
501// fNpy = (fBending) ? nStripMax : 1;
8ceced0c 502 fNpx = 124; // tot num of modules (like with old segmentation)
503 fNpy = 64; // max number of y strips within one module
504
38aedc99 505// calculate half size in x & y (to shift local coordinate ref. system)
0a11496e 506 fRpcHalfXsize = 0;
507 fRpcHalfYsize = 0;
508 if (fBending) {
38aedc99 509 for (Int_t iModule=0; iModule<fNsec; iModule++)
0a11496e 510 fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];
511 fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
512 } else if (!fBending) {
513 fRpcHalfXsize = fModuleXmax[6];
514 fRpcHalfYsize = fStripYsize[1];
515 }
516 fRpcHalfXsize = fRpcHalfXsize / 2.;
517 fRpcHalfYsize = fRpcHalfYsize / 2.;
518
519/*
520 printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
521 fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
522
38aedc99 523 for (Int_t iModule=0; iModule<fNsec; iModule++) {
79b4ba23 524 printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
0a11496e 525 iModule,fModuleXmin[iModule],fModuleXmax[iModule],
79b4ba23 526 fModuleYmin[iModule],
0a11496e 527 fStripXsize[iModule],fStripYsize[iModule]);
528 }
79b4ba23 529
38aedc99 530 for (Int_t iModule=0; iModule<fNsec; iModule++) {
79b4ba23 531 printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
532 iModule,fNstrip[iModule],
533 fStripXsize[iModule],fStripYsize[iModule]);
534 }
535*/
536
0a11496e 537 fId = detectionElementId;
538}
539
540
541
542
543
544
545