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