]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerSegmentation.cxx
properly take care of chamber edges in GetPadI
[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
38aedc99 18//*********************************************************
19// Segmentation classe for trigger chambers.
20// The present version is a bit messy because, although the
21// x,y positions are local, most of the methods use global
22// strip numbering. The conversion is made via GetPadLoc2Glo.
23// To be improved in the future.
24//*********************************************************
0a11496e 25
26#include <TArrayI.h>
27#include <TArrayF.h>
28#include "AliMUONTriggerSegmentation.h"
29#include "AliLog.h"
30
31//___________________________________________
32ClassImp(AliMUONTriggerSegmentation)
33
a713db22 34AliMUONTriggerSegmentation::AliMUONTriggerSegmentation()
35 : AliMUONVGeometryDESegmentation(),
36 fBending(0),
79b4ba23 37 fId(0),
38aedc99 38 fNsec(7),
79b4ba23 39 fNDiv(0),
40 fDpxD(0),
41 fDpyD(0),
42 fDpx(0),
43 fDpy(0),
44 fNpx(999999),
45 fNpy(999999),
46 fWireD(0.25),
47 fXhit(0.),
48 fYhit(0.),
49 fIx(0),
50 fIy(0),
51 fX(0.),
52 fY(0.),
53 fIxmin(0),
54 fIxmax(0),
55 fIymin(0),
56 fIymax(0),
57// add to St345SlatSegmentation
58 fLineNumber(0),
59 fRpcHalfXsize(0),
60 fRpcHalfYsize(0)
a713db22 61{
79b4ba23 62// add to St345SlatSegmentation
63 for (Int_t i=0; i<7; i++) {
64 fNstrip[i]=0;
65 fStripYsize[i]=0.;
66 fStripXsize[i]=0.;
67 fModuleXmin[i]=0.;
68 fModuleXmax[i]=0.;
69 fModuleYmin[i]=0.;
70 }
a713db22 71}
79b4ba23 72
73
a713db22 74//___________________________________________
0a11496e 75AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(Bool_t bending)
76 : AliMUONVGeometryDESegmentation(),
79b4ba23 77 fBending(bending),
78 fId(0),
79 fDpx(0),
80 fDpy(0),
81 fNpx(999999),
82 fNpy(999999),
83 fWireD(0.25),
84 fXhit(0.),
85 fYhit(0.),
86 fIx(0),
87 fIy(0),
88 fX(0.),
89 fY(0.),
90 fIxmin(0),
91 fIxmax(0),
92 fIymin(0),
93 fIymax(0),
94// add to St345SlatSegmentation
95 fLineNumber(0),
96 fRpcHalfXsize(0),
97 fRpcHalfYsize(0)
0a11496e 98{
99 // Non default constructor
38aedc99 100 fNsec = 7; // 4 sector densities at most per slat
79b4ba23 101 fNDiv = new TArrayI(fNsec);
0a11496e 102 fDpxD = new TArrayF(fNsec);
103 fDpyD = new TArrayF(fNsec);
104 (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;
105 (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;
106 (*fDpyD)[0]=(*fDpyD)[1]=(*fDpyD)[2]=(*fDpyD)[3]=0;
79b4ba23 107// add to St345SlatSegmentation
108 for (Int_t i=0; i<7; i++) {
109 fNstrip[i]=0;
110 fStripYsize[i]=0.;
111 fStripXsize[i]=0.;
112 fModuleXmin[i]=0.;
113 fModuleXmax[i]=0.;
114 fModuleYmin[i]=0.;
115 }
0a11496e 116}
79b4ba23 117
0a11496e 118//----------------------------------------------------------------------
119AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(const AliMUONTriggerSegmentation& rhs) : AliMUONVGeometryDESegmentation(rhs)
120{
121 AliFatal("Not implemented.");
122}
123//----------------------------------------------------------------------
124AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation()
125{
126 // Destructor
66241c38 127 if (fNDiv) delete fNDiv;
0a11496e 128 if (fDpxD) delete fDpxD;
129 if (fDpyD) delete fDpyD;
0a11496e 130}
131//----------------------------------------------------------------------
132AliMUONTriggerSegmentation& AliMUONTriggerSegmentation::operator=(const AliMUONTriggerSegmentation& rhs)
133{
79b4ba23 134// Protected assignement operator
0a11496e 135 if (this == &rhs) return *this;
136 AliFatal("Not implemented.");
137 return *this;
138}
79b4ba23 139//----------------------------------------------------------------------
38aedc99 140Int_t AliMUONTriggerSegmentation::ModuleColNum(Int_t ixGlo)
141{
142// returns column number (from 0 to 6) in which the (global) module
143// ixGlo is sitting (could return 7 if ixGlow=isec)
144 return TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10-1;
145}
146//----------------------------------------------------------------------
79b4ba23 147Bool_t AliMUONTriggerSegmentation::HasPad(Int_t ix, Int_t iy)
148{
38aedc99 149// check if steping outside the limits (iy=1,2... iyGlo=0,1...)
150 Bool_t hasPad = true;
79b4ba23 151 Int_t ixGlo = 0;
38aedc99 152 Int_t iyGlo = 0;
153 GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
154 if (iyGlo>=fNstrip[ModuleColNum(ixGlo)]) hasPad = false;
79b4ba23 155 return hasPad;
156}
0a11496e 157//____________________________________________________________________________
158Float_t AliMUONTriggerSegmentation::Dpx(Int_t isec) const
159{
38aedc99 160// return x-strip width in sector isec
161 Float_t size = (isec<8) ? fStripXsize[isec-1] : fStripXsize[isec-2]/2.;
162 return size;
0a11496e 163}
164//____________________________________________________________________________
165Float_t AliMUONTriggerSegmentation::Dpy(Int_t isec) const
166{
38aedc99 167// return y-strip width in sector isec
168 Float_t size = (isec<8) ? fStripYsize[isec-1] : fStripYsize[isec-2];
169 return size;
0a11496e 170}
171//----------------------------------------------------------------------------
172void AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ixLoc, Int_t iyLoc,
173 Int_t &ixGlo, Int_t &iyGlo)
174{
79b4ba23 175// converts ixLoc & iyLoc into ixGlo & iyGLo (module,strip number)
38aedc99 176 ixGlo = 0; // see AliMUONTriggerConstants::fgkModuleI
177 iyGlo = 0; // from 0 to (fNtrip-1) in module
0a11496e 178 if (fBending) {
38aedc99 179 ixGlo = 10*fLineNumber + ixLoc;
0a11496e 180 iyGlo = iyLoc - 1;
181 } else if (!fBending) {
182 Int_t iCountStrip = 0;
38aedc99 183 for (Int_t iModule=0; iModule<fNsec; iModule++) {
0a11496e 184 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) {
185 if ((ixLoc-1)==iCountStrip) {
38aedc99 186 ixGlo = 10*fLineNumber + iModule + 1;
0a11496e 187 iyGlo = iStrip;
188 }
189 iCountStrip++;
190 }
191 }
192 }
193// printf(" in GetPadLoc2Glo ixLoc iyLoc ixGlo iyGlo %i %i %i %i \n",ixLoc,iyLoc,ixGlo,iyGlo);
194
195}
196//----------------------------------------------------------------------------
197void AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
198{
0a11496e 199 Int_t ixGlo = 0;
200 Int_t iyGlo = 0;
38aedc99 201 GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
202// ix = ixGlo;
203// iy = iyGlo;
79b4ba23 204
205// Returns real coordinates (x,y) for given pad coordinates (ix,iy)
0a11496e 206 x = 0.;
207 y = 0.;
38aedc99 208 Int_t iModule = ModuleColNum(ixGlo); // find column number (0-6)
0a11496e 209 if (fBending) {
210 if (iModule==0) {
38aedc99 211 x = fStripXsize[iModule]/ 2.;
0a11496e 212 } else {
38aedc99 213 x = fModuleXmax[iModule-1] + fStripXsize[iModule]/2.;
214 }
79b4ba23 215 y = fModuleYmin[iModule] +
38aedc99 216 iyGlo*fStripYsize[iModule] + fStripYsize[iModule]/2.;
0a11496e 217 } else if (!fBending) {
38aedc99 218 if (ModuleColNum(ixGlo)==6 && iyGlo>7) {
219 x = fModuleXmin[iModule] + 8*fStripXsize[iModule] +
220 (iyGlo-8)*fStripXsize[iModule]/2. + fStripXsize[iModule]/4.;
79b4ba23 221 } else {
222 x = fModuleXmin[iModule] +
38aedc99 223 iyGlo*fStripXsize[iModule] + fStripXsize[iModule]/2.;
79b4ba23 224 }
38aedc99 225 y = fModuleYmin[iModule] + fStripYsize[iModule] / 2.;
0a11496e 226 }
227 x = x - fRpcHalfXsize;
228 y = y - fRpcHalfYsize;
229
8ceced0c 230// printf(" in GetPadC iModule ixGlo iyGlo ix iy x y %i %i %i %i %i %f %f \n",iModule,ixGlo,iyGlo,ix,iy,x,y);
0a11496e 231}
232
233//_____________________________________________________________________________
234void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
235{
236// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
237
238 x = x + fRpcHalfXsize;
239 y = y + fRpcHalfYsize;
240// find module number
241 Int_t modNum=0;
38aedc99 242 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
0a11496e 243 if ( x > fModuleXmin[iModule] && x < fModuleXmax[iModule] ) {
8ceced0c 244 ix = 10*fLineNumber + iModule + 1;
0a11496e 245 modNum = iModule;
246 }
247 }
248
249// find strip number
250 Float_t yMin = 0.;
251 Float_t yMax = fModuleYmin[modNum];
252 Float_t xMin = 0.;
253 Float_t xMax = fModuleXmin[modNum];
254 if (ix!=0) {
255 for (Int_t iStrip=0; iStrip<fNstrip[modNum]; iStrip++) {
256 if (fBending) {
257 yMin = yMax;
258 yMax = yMin + fStripYsize[modNum];
259 if (y > yMin && y < yMax) iy = iStrip;
38aedc99 260 } else if (!fBending) {
0a11496e 261 xMin = xMax;
7743b3a9 262 if (modNum==6 && iStrip>7) {
263 xMax = xMin + fStripXsize[modNum]/2.;
264 } else {
265 xMax = xMin + fStripXsize[modNum];
266 }
0a11496e 267 if (x > xMin && x < xMax) iy = iStrip;
7743b3a9 268 } //
0a11496e 269 } // loop on strips
270 } // if ix!=0
271// printf("in GetPadI ix iy x y %i %i %f %f \n",ix,iy,x,y);
272}
273//-------------------------------------------------------------------------
274void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
275{
276 GetPadI(x, y, ix, iy);
277}
278//____________________________________________________________________________
279void AliMUONTriggerSegmentation::SetPadSize(Float_t p1, Float_t p2)
280{
79b4ba23 281// Sets the padsize
282 fDpx=p1;
283 fDpy=p2;
0a11496e 284}
285//-------------------------------------------------------------------------
286void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
287 fLineNumber = iLineNumber;
288}
289//-------------------------------------------------------------------------
0a11496e 290void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
291{
292 //
293 // Sets virtual pad coordinates, needed for evaluating pad response
294 // outside the tracking program
295 GetPadC(ix,iy,fX,fY);
296 fSector=Sector(ix,iy);
297}
298//---------------------------------------------------------------------------
299void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
300{
301 // Set current hit
302 //
303 fXhit = x;
304 fYhit = y;
0a11496e 305}
306//----------------------------------------------------------------------------
307void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
308{
309 SetHit(xhit, yhit);
310}
311
312//--------------------------------------------------------------------------
79b4ba23 313Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
0a11496e 314{
38aedc99 315// determine segmentation zone from pad coordinates (from 1 to 8)
79b4ba23 316 Int_t ixGlo = 0;
317 Int_t iyGlo = 0;
38aedc99 318 GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
319 if (!fBending && ModuleColNum(ixGlo)==6 && iyGlo>7) {
320 return 8; // sector 8: diff. strip width within same module
79b4ba23 321 } else {
38aedc99 322 return ModuleColNum(ixGlo)+1;
323 }
0a11496e 324}
79b4ba23 325
0a11496e 326//-----------------------------------------------------------------------------
327void AliMUONTriggerSegmentation::
328IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
329{
38aedc99 330/*
331// need to return (only) x4 = dist. betwwen the hit and the closest border of
332// the current strip
333 Int_t ix,iy;
334 Float_t xstrip,ystrip;
335 GetPadI(fXhit,fYhit,ix,iy);
336 GetPadC(ix,iy,xstrip,ystrip);
337 x1=fYhit; // hit y position
338 x2=ystrip; // y coordinate of the main strip
339 x3=fY; // current strip real y coordinate
340
341 // find the position of the 2 borders of the current strip
342 Float_t ymin = ystrip - fStripXsize[ModuleColNum(ixGlo)
343
344fYofxsmin[ModuleNumber(fIx)][fIy];
345 Float_t ymax = fYofxsmax[ModuleNumber(fIx)][fIy];
346
347 // dist. between the hit and the closest border of the current strip
348 x4 = (TMath::Abs(ymax-x1) > TMath::Abs(ymin-x1)) ?
349 TMath::Abs(ymin-x1):TMath::Abs(ymax-x1);
350*/
0a11496e 351 // Returns integration limits for current pad
352 //
353 x1=fXhit-fX-Dpx(fSector)/2.;
354 x2=x1+Dpx(fSector);
355 y1=fYhit-fY-Dpy(fSector)/2.;
356 y2=y1+Dpy(fSector);
357 // printf("\n Integration Limits %f %f %f %f %d %f", x1, x2, y1, y2, fSector, Dpx(fSector));
0a11496e 358}
38aedc99 359
360
0a11496e 361//-----------------------------------------------------------------------------
362void AliMUONTriggerSegmentation::
363Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
364{
365 // Returns list of next neighbours for given Pad (iX, iY)
366 Int_t i=0;
367 // step right
368 if (iX+1 <= fNpx) {
369 Xlist[i]=iX+1;
370 Ylist[i++]=iY;
371 }
372 // step left
373 if (iX-1 > 0) {
374 Xlist[i]=iX-1;
375 Ylist[i++]=iY;
376 }
377 Int_t sector = Sector(iX,iY);
378 // step up
379 if (iY+1 <= fNpyS[sector]) {
380 Xlist[i]=iX;
381 Ylist[i++]=iY+1;
382 }
383 // step down
384 if (iY-1 > 0) {
385 Xlist[i]=iX;
386 Ylist[i++]=iY-1;
387 }
388 *Nlist=i;
389}
390
391//--------------------------------------------------------------------------
392void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
0a11496e 393 Int_t nStrip[7],
394 Float_t stripYsize[7],
395 Float_t stripXsize[7],
396 Float_t offset)
397{
79b4ba23 398// printf(" fBending: %d \n",fBending);
399
400 Int_t nStripMax = 0;
401 if (fBending) nStripMax = nStrip[0];
402
403 for (Int_t i=0; i<7; i++) {
404 fNstrip[i]=nStrip[i];
405 fStripYsize[i]=stripYsize[i];
406 fStripXsize[i]=stripXsize[i];
407 fModuleYmin[0]=0.;
408 }
0a11496e 409// take care of offset in Y in chamber 5, first module
79b4ba23 410 fModuleYmin[0] = offset;
411
412 Float_t tmp = 0.;
413 Int_t npad = 0; // number of pad in x and y
38aedc99 414 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
79b4ba23 415 fModuleXmin[iModule] = tmp;
416 npad = npad + fNstrip[iModule];
417 if (fBending) {
418 fModuleXmax[iModule] =
419 fModuleXmin[iModule] + fStripXsize[iModule];
420 } else if (!fBending) {
421 if (iModule<6) {
422 fModuleXmax[iModule] =
38aedc99 423 fModuleXmin[iModule] +
424 fStripXsize[iModule]*fNstrip[iModule];
79b4ba23 425 } else if (iModule==6) {
426 fModuleXmax[iModule] =
427 fModuleXmin[iModule] +
428 (fStripXsize[iModule]*fNstrip[iModule]/2) +
429 (fStripXsize[iModule]/2.*fNstrip[iModule]/2);
430 }
431 }
432 tmp = fModuleXmax[iModule];
433
434// calculate nStripMax in x & y
435 if (fBending) {
436 if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
437 } else if (!fBending) {
438 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
439 }
440 } // loop on modules
0a11496e 441
442// associate nStripMax
7743b3a9 443// fNpx = (fBending) ? fNsec : nStripMax;
444// fNpy = (fBending) ? nStripMax : 1;
8ceced0c 445 fNpx = 124; // tot num of modules (like with old segmentation)
446 fNpy = 64; // max number of y strips within one module
447
38aedc99 448// calculate half size in x & y (to shift local coordinate ref. system)
0a11496e 449 fRpcHalfXsize = 0;
450 fRpcHalfYsize = 0;
451 if (fBending) {
38aedc99 452 for (Int_t iModule=0; iModule<fNsec; iModule++)
0a11496e 453 fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];
454 fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
455 } else if (!fBending) {
456 fRpcHalfXsize = fModuleXmax[6];
457 fRpcHalfYsize = fStripYsize[1];
458 }
459 fRpcHalfXsize = fRpcHalfXsize / 2.;
460 fRpcHalfYsize = fRpcHalfYsize / 2.;
461
462/*
463 printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
464 fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
465
38aedc99 466 for (Int_t iModule=0; iModule<fNsec; iModule++) {
79b4ba23 467 printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
0a11496e 468 iModule,fModuleXmin[iModule],fModuleXmax[iModule],
79b4ba23 469 fModuleYmin[iModule],
0a11496e 470 fStripXsize[iModule],fStripYsize[iModule]);
471 }
79b4ba23 472
38aedc99 473 for (Int_t iModule=0; iModule<fNsec; iModule++) {
79b4ba23 474 printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
475 iModule,fNstrip[iModule],
476 fStripXsize[iModule],fStripYsize[iModule]);
477 }
478*/
479
480
481
0a11496e 482// printf("npad = %i",npad);
483
484 fId = detectionElementId;
485}
486
487
488
489
490
491
492