]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerSegmentation.cxx
More inline functions available to the user (B.Hippolyte)
[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
230// printf(" in GetPadC iModule ixloc iyloc ix iy x y %i %i %i %i %i %f %f \n",iModule,ixLoc,iyLoc,ix,iy,x,y);
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] ) {
38aedc99 244 ix = 10*fLineNumber + iModule;
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;
262 xMax = xMin + fStripXsize[modNum];
263 if (x > xMin && x < xMax) iy = iStrip;
264 }
265 } // loop on strips
266 } // if ix!=0
267// printf("in GetPadI ix iy x y %i %i %f %f \n",ix,iy,x,y);
268}
269//-------------------------------------------------------------------------
270void AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
271{
272 GetPadI(x, y, ix, iy);
273}
274//____________________________________________________________________________
275void AliMUONTriggerSegmentation::SetPadSize(Float_t p1, Float_t p2)
276{
79b4ba23 277// Sets the padsize
278 fDpx=p1;
279 fDpy=p2;
0a11496e 280}
281//-------------------------------------------------------------------------
282void AliMUONTriggerSegmentation::SetLineNumber(Int_t iLineNumber){
283 fLineNumber = iLineNumber;
284}
285//-------------------------------------------------------------------------
0a11496e 286void AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
287{
288 //
289 // Sets virtual pad coordinates, needed for evaluating pad response
290 // outside the tracking program
291 GetPadC(ix,iy,fX,fY);
292 fSector=Sector(ix,iy);
293}
294//---------------------------------------------------------------------------
295void AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
296{
297 // Set current hit
298 //
299 fXhit = x;
300 fYhit = y;
0a11496e 301}
302//----------------------------------------------------------------------------
303void AliMUONTriggerSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
304{
305 SetHit(xhit, yhit);
306}
307
308//--------------------------------------------------------------------------
79b4ba23 309Int_t AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
0a11496e 310{
38aedc99 311// determine segmentation zone from pad coordinates (from 1 to 8)
79b4ba23 312 Int_t ixGlo = 0;
313 Int_t iyGlo = 0;
38aedc99 314 GetPadLoc2Glo(ix, iy, ixGlo, iyGlo);
315 if (!fBending && ModuleColNum(ixGlo)==6 && iyGlo>7) {
316 return 8; // sector 8: diff. strip width within same module
79b4ba23 317 } else {
38aedc99 318 return ModuleColNum(ixGlo)+1;
319 }
0a11496e 320}
79b4ba23 321
0a11496e 322//-----------------------------------------------------------------------------
323void AliMUONTriggerSegmentation::
324IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
325{
38aedc99 326/*
327// need to return (only) x4 = dist. betwwen the hit and the closest border of
328// the current strip
329 Int_t ix,iy;
330 Float_t xstrip,ystrip;
331 GetPadI(fXhit,fYhit,ix,iy);
332 GetPadC(ix,iy,xstrip,ystrip);
333 x1=fYhit; // hit y position
334 x2=ystrip; // y coordinate of the main strip
335 x3=fY; // current strip real y coordinate
336
337 // find the position of the 2 borders of the current strip
338 Float_t ymin = ystrip - fStripXsize[ModuleColNum(ixGlo)
339
340fYofxsmin[ModuleNumber(fIx)][fIy];
341 Float_t ymax = fYofxsmax[ModuleNumber(fIx)][fIy];
342
343 // dist. between the hit and the closest border of the current strip
344 x4 = (TMath::Abs(ymax-x1) > TMath::Abs(ymin-x1)) ?
345 TMath::Abs(ymin-x1):TMath::Abs(ymax-x1);
346*/
0a11496e 347 // Returns integration limits for current pad
348 //
349 x1=fXhit-fX-Dpx(fSector)/2.;
350 x2=x1+Dpx(fSector);
351 y1=fYhit-fY-Dpy(fSector)/2.;
352 y2=y1+Dpy(fSector);
353 // printf("\n Integration Limits %f %f %f %f %d %f", x1, x2, y1, y2, fSector, Dpx(fSector));
0a11496e 354}
38aedc99 355
356
0a11496e 357//-----------------------------------------------------------------------------
358void AliMUONTriggerSegmentation::
359Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
360{
361 // Returns list of next neighbours for given Pad (iX, iY)
362 Int_t i=0;
363 // step right
364 if (iX+1 <= fNpx) {
365 Xlist[i]=iX+1;
366 Ylist[i++]=iY;
367 }
368 // step left
369 if (iX-1 > 0) {
370 Xlist[i]=iX-1;
371 Ylist[i++]=iY;
372 }
373 Int_t sector = Sector(iX,iY);
374 // step up
375 if (iY+1 <= fNpyS[sector]) {
376 Xlist[i]=iX;
377 Ylist[i++]=iY+1;
378 }
379 // step down
380 if (iY-1 > 0) {
381 Xlist[i]=iX;
382 Ylist[i++]=iY-1;
383 }
384 *Nlist=i;
385}
386
387//--------------------------------------------------------------------------
388void AliMUONTriggerSegmentation::Init(Int_t detectionElementId,
0a11496e 389 Int_t nStrip[7],
390 Float_t stripYsize[7],
391 Float_t stripXsize[7],
392 Float_t offset)
393{
79b4ba23 394// printf(" fBending: %d \n",fBending);
395
396 Int_t nStripMax = 0;
397 if (fBending) nStripMax = nStrip[0];
398
399 for (Int_t i=0; i<7; i++) {
400 fNstrip[i]=nStrip[i];
401 fStripYsize[i]=stripYsize[i];
402 fStripXsize[i]=stripXsize[i];
403 fModuleYmin[0]=0.;
404 }
0a11496e 405// take care of offset in Y in chamber 5, first module
79b4ba23 406 fModuleYmin[0] = offset;
407
408 Float_t tmp = 0.;
409 Int_t npad = 0; // number of pad in x and y
38aedc99 410 for (Int_t iModule=0; iModule<fNsec; iModule++) { // modules
79b4ba23 411 fModuleXmin[iModule] = tmp;
412 npad = npad + fNstrip[iModule];
413 if (fBending) {
414 fModuleXmax[iModule] =
415 fModuleXmin[iModule] + fStripXsize[iModule];
416 } else if (!fBending) {
417 if (iModule<6) {
418 fModuleXmax[iModule] =
38aedc99 419 fModuleXmin[iModule] +
420 fStripXsize[iModule]*fNstrip[iModule];
79b4ba23 421 } else if (iModule==6) {
422 fModuleXmax[iModule] =
423 fModuleXmin[iModule] +
424 (fStripXsize[iModule]*fNstrip[iModule]/2) +
425 (fStripXsize[iModule]/2.*fNstrip[iModule]/2);
426 }
427 }
428 tmp = fModuleXmax[iModule];
429
430// calculate nStripMax in x & y
431 if (fBending) {
432 if (fNstrip[iModule] > nStripMax) nStripMax = fNstrip[iModule];
433 } else if (!fBending) {
434 for (Int_t iStrip=0; iStrip<fNstrip[iModule]; iStrip++) nStripMax++;
435 }
436 } // loop on modules
0a11496e 437
438// associate nStripMax
38aedc99 439 fNpx = (fBending) ? fNsec : nStripMax;
440 fNpy = (fBending) ? nStripMax : 1;
441
442// calculate half size in x & y (to shift local coordinate ref. system)
0a11496e 443 fRpcHalfXsize = 0;
444 fRpcHalfYsize = 0;
445 if (fBending) {
38aedc99 446 for (Int_t iModule=0; iModule<fNsec; iModule++)
0a11496e 447 fRpcHalfXsize = fRpcHalfXsize + fStripXsize[iModule];
448 fRpcHalfYsize = fNstrip[1] * fStripYsize[1];
449 } else if (!fBending) {
450 fRpcHalfXsize = fModuleXmax[6];
451 fRpcHalfYsize = fStripYsize[1];
452 }
453 fRpcHalfXsize = fRpcHalfXsize / 2.;
454 fRpcHalfYsize = fRpcHalfYsize / 2.;
455
456/*
457 printf(" fNpx fNpy fRpcHalfXsize fRpcHalfYsize = %i %i %f %f \n",
458 fNpx,fNpy,fRpcHalfXsize,fRpcHalfYsize);
459
38aedc99 460 for (Int_t iModule=0; iModule<fNsec; iModule++) {
79b4ba23 461 printf(" iModule fModuleXmin fModuleXmax fModuleYmin fStripXsize fStripYsize %i %f %f %f %f %f\n",
0a11496e 462 iModule,fModuleXmin[iModule],fModuleXmax[iModule],
79b4ba23 463 fModuleYmin[iModule],
0a11496e 464 fStripXsize[iModule],fStripYsize[iModule]);
465 }
79b4ba23 466
38aedc99 467 for (Int_t iModule=0; iModule<fNsec; iModule++) {
79b4ba23 468 printf(" iModule fNstrip fStripXsize fStripYsize %i %i %f %f \n",
469 iModule,fNstrip[iModule],
470 fStripXsize[iModule],fStripYsize[iModule]);
471 }
472*/
473
474
475
0a11496e 476// printf("npad = %i",npad);
477
478 fId = detectionElementId;
479}
480
481
482
483
484
485
486