]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSt345SlatSegmentation.cxx
Removing unused enum member to avoid warnings with gcc 3.2.3
[u/mrichter/AliRoot.git] / MUON / AliMUONSt345SlatSegmentation.cxx
CommitLineData
cc4dcfb0 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
5398f946 18/// \class AliMUONSt345SlatSegmentation
19/// \brief Segmentation classes for slat modules
20///
21/// This class works with local coordinates
22/// of the slats via the class AliMUONGeometrySegmentation
23/// This class contains the size of the slats and the
24/// and the differents PCB densities.
25/// (from old AliMUONSegmentationSlatModule)
26///
27/// Add electronics mapping - Christian, Subatech, Mai 05
28///
29/// \author Gines Martinez, Subatech, Nov04
cc4dcfb0 30
31#include <TArrayI.h>
32#include <TArrayF.h>
33#include "AliMUONSt345SlatSegmentation.h"
34#include "AliLog.h"
35
5398f946 36/// \cond CLASSIMP
cc4dcfb0 37ClassImp(AliMUONSt345SlatSegmentation)
5398f946 38/// \endcond
cc4dcfb0 39
a713db22 40AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation()
f1501d74 41 : AliMUONVGeometryDESegmentation(),
a713db22 42 fBending(0),
43 fId(0),
6b9de626 44 fNsec(0),
45 fNDiv(0),
46 fDpxD(0),
47 fDpyD(0),
a713db22 48 fDpx(0),
49 fDpy(0),
50 fNpx(999999),
51 fNpy(999999),
52 fWireD(0.0),
53 fXhit(0.),
54 fYhit(0.),
55 fIx(0),
56 fIy(0),
57 fX(0.),
58 fY(0.),
59 fIxmin(0),
60 fIxmax(0),
61 fIymin(0),
f1501d74 62 fIymax(0),
9db6c8d7 63 fInitDone(kFALSE)
a713db22 64{
5398f946 65/// Default constructor
f64ec237 66 AliDebug(1,Form("this=%p default (empty) ctor",this));
a713db22 67}
68
69//___________________________________________
f48459ab 70AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(Bool_t bending)
fed772f3 71 : AliMUONVGeometryDESegmentation(),
f48459ab 72 fBending(bending),
73 fId(0),
6b9de626 74 fNsec(0),
75 fNDiv(0),
76 fDpxD(0),
77 fDpyD(0),
f48459ab 78 fDpx(0),
79 fDpy(0),
80 fNpx(999999),
81 fNpy(999999),
82 fWireD(0.25),
83 fXhit(0.),
84 fYhit(0.),
85 fIx(0),
86 fIy(0),
87 fX(0.),
88 fY(0.),
89 fIxmin(0),
90 fIxmax(0),
91 fIymin(0),
f1501d74 92 fIymax(0),
9db6c8d7 93 fInitDone(kFALSE)
f1501d74 94
cc4dcfb0 95{
5398f946 96/// Standard constructor
97
cc4dcfb0 98 fNsec = 4; // 4 sector densities at most per slat
99 fNDiv = new TArrayI(fNsec);
100 fDpxD = new TArrayF(fNsec);
f48459ab 101 fDpyD = new TArrayF(fNsec);
cc4dcfb0 102 (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;
103 (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;
f1501d74 104 (*fDpyD)[0]=(*fDpyD)[1]=(*fDpyD)[2]=(*fDpyD)[3]=0;
f64ec237 105 AliDebug(1,Form("this=%p ctor for bending=%d",this,fBending));
f1501d74 106
cc4dcfb0 107}
108//----------------------------------------------------------------------
cc4dcfb0 109AliMUONSt345SlatSegmentation::~AliMUONSt345SlatSegmentation()
110{
5398f946 111/// Destructor
47d60ed9 112
113 AliDebug(1, Form("dtor this = %p", this));
114
f64ec237 115 delete fNDiv;
116 delete fDpxD;
117 delete fDpyD;
cc4dcfb0 118}
cc4dcfb0 119
120//------------------------------------------------------------------------
121Float_t AliMUONSt345SlatSegmentation::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y, Int_t * /*dummy*/)
122{
5398f946 123/// Returns the square of the distance between 1 pad
124/// labelled by its Channel numbers and a coordinate
125
cc4dcfb0 126 Float_t x,y;
127 GetPadC(iX,iY,x,y);
128 return (x-X)*(x-X) + (y-Y)*(y-Y);
129}
130//____________________________________________________________________________
131Float_t AliMUONSt345SlatSegmentation::Dpx(Int_t isec) const
132{
5398f946 133/// Return x-strip width
134
f48459ab 135 return (*fDpxD)[isec];
cc4dcfb0 136}
137
138//____________________________________________________________________________
f48459ab 139Float_t AliMUONSt345SlatSegmentation::Dpy(Int_t isec) const
cc4dcfb0 140{
5398f946 141/// Return y-strip width
142
f48459ab 143 return (*fDpyD)[isec];
cc4dcfb0 144}
145//_____________________________________________________________________________
146Float_t AliMUONSt345SlatSegmentation::GetAnod(Float_t xhit) const
147{
5398f946 148/// Returns for a hit position xhit the position of the nearest anode wire
149
f48459ab 150 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
151 return fWireD*wire;
cc4dcfb0 152}
cc4dcfb0 153
f64ec237 154//_____________________________________________________________________________
155Bool_t AliMUONSt345SlatSegmentation::HasPad(Int_t ix, Int_t iy)
156{
5398f946 157/// Return true if pas with given indices exists
d19b6003 158
f64ec237 159 if ( ix < 1 || ix > Npx() || iy < 1 || iy > Npy() )
160 {
161 return kFALSE;
162 }
163 Int_t isec = Sector(ix,iy);
164 if ( isec == -1 )
165 {
166 return kFALSE;
167 }
168 if ( iy > fNpyS[isec] )
169 {
170 return kFALSE;
171 }
172 return kTRUE;
173}
f48459ab 174
cc4dcfb0 175//--------------------------------------------------------------------------------
176void AliMUONSt345SlatSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
177{
5398f946 178/// Returns real coordinates (x,y) for given pad coordinates (ix,iy)
d19b6003 179
bd57045f 180 if (ix < 1 || ix > Npx() || iy < 1 || iy > Npy() ){
f7db2071 181 AliWarning(Form("ix %d or iy %d out of boundaries: Npx=%d and Npy=%d",ix, iy, Npx(), Npy()));
13b83a58 182 x = y= 0.;
bd57045f 183
184 } else {
185
cc4dcfb0 186 // Find sector isec
187 Int_t isec = Sector(ix,iy);
76fa1113 188 if (isec == -1) AliWarning(Form("isector = %d with ix %d, iy %d", isec, ix, iy));
f48459ab 189 if (iy > fNpyS[isec]) {
13b83a58 190 x = y = 0.;
f48459ab 191 return;
192 }
cc4dcfb0 193 if (isec>0) {
194 x = fCx[isec-1]+(ix-fNpxS[isec-1])*(*fDpxD)[isec];
195 x = x-(*fDpxD)[isec]/2;
f48459ab 196 y = Float_t(iy*(*fDpyD)[isec])-(*fDpyD)[isec]/2.- fCy; // !!!
cc4dcfb0 197 } else {
bd57045f 198 x = y = 0;
cc4dcfb0 199 }
200 }
201}
f48459ab 202
203
204//_____________________________________________________________________________
205void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
206{
5398f946 207/// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
76fa1113 208
f48459ab 209 // Find sector isec
210 Int_t isec=-1;
211 for (Int_t i=fNsec-1; i > 0; i--) {
212 if (x >= fCx[i-1]) {
213 isec=i;
13b83a58 214 if (TMath::Abs(fCx[isec] - fCx[isec-1]) <0.1 && isec > 1) isec--;
f48459ab 215 break;
216 }
217 }
f7db2071 218 if (isec == -1) AliWarning(Form("isector equal to %d with xl %f, yl %f", isec, x, y));
f48459ab 219 if (isec>0) {
220 ix= Int_t((x-fCx[isec-1])/(*fDpxD)[isec])
221 +fNpxS[isec-1]+1;
222 iy= Int_t((y+fCy)/(*fDpyD)[isec])+1;
223 } else if (isec == 0) {
224 ix= Int_t(x/(*fDpxD)[isec])+1;
225 iy= Int_t((y+fCy)/(*fDpyD)[isec])+1;
226 } else {
227 ix=0;
228 iy=0;
229 }
230}
cc4dcfb0 231//-------------------------------------------------------------------------
232void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
233{
5398f946 234/// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
d19b6003 235
cc4dcfb0 236 GetPadI(x, y, ix, iy);
237}
f1501d74 238
f1501d74 239
cc4dcfb0 240//_______________________________________________________________
241void AliMUONSt345SlatSegmentation::SetPadDivision(Int_t ndiv[4])
242{
5398f946 243/// Defines the pad size perp. to the anode wire (y) for different sectors.
244/// Pad sizes are defined as integral fractions ndiv of a basis pad size
245/// fDpx
246
f48459ab 247 for (Int_t i=0; i<4; i++) {
248 (*fNDiv)[i]=ndiv[i];
249 }
250 ndiv[0]=ndiv[1];
cc4dcfb0 251}
252//____________________________________________________________________________
253void AliMUONSt345SlatSegmentation::SetPadSize(Float_t p1, Float_t p2)
254{
5398f946 255/// Sets the padsize
256
f48459ab 257 fDpx=p1;
258 fDpy=p2;
cc4dcfb0 259}
260//_______________________________________________________________
261void AliMUONSt345SlatSegmentation::SetPcbBoards(Int_t n[4])
262{
5398f946 263/// Set PcbBoard segmentation zones for each density
264/// n[0] slat type parameter
265/// n[1] PcbBoards for highest density sector fNDiv[1] etc ...
f1501d74 266
267 fRtype = n[0];
268 n[0] = 0;
f48459ab 269 for (Int_t i=0; i<4; i++) fPcbBoards[i]=n[i];
f1501d74 270
cc4dcfb0 271}
272//-------------------------------------------------------------------------
273void AliMUONSt345SlatSegmentation::SetPad(Int_t ix, Int_t iy)
274{
5398f946 275/// Sets virtual pad coordinates, needed for evaluating pad response
276/// outside the tracking program
277
f48459ab 278 GetPadC(ix,iy,fX,fY);
279 fSector=Sector(ix,iy);
cc4dcfb0 280}
281//---------------------------------------------------------------------------
282void AliMUONSt345SlatSegmentation::SetHit(Float_t x, Float_t y)
283{
5398f946 284/// Set current hit
285
f48459ab 286 fXhit = x;
287 fYhit = y;
cc4dcfb0 288
bd57045f 289 if (x < fCx[0]) fXhit = fCx[0];
290 if (y < -fDyPCB/2.) fYhit = -fDyPCB/2.;
cc4dcfb0 291
bd57045f 292 if (x > fCx[fNsec-1]) fXhit = fCx[fNsec-1];
293 if (y > fDyPCB/2.) fYhit = fDyPCB/2.;
cc4dcfb0 294
295}
296//----------------------------------------------------------------------------
297void AliMUONSt345SlatSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
298{
5398f946 299/// Set current hit
d19b6003 300
cc4dcfb0 301 SetHit(xhit, yhit);
302}
f48459ab 303
cc4dcfb0 304//----------------------------------------------------------
305void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
306{
5398f946 307/// Initialises iteration over pads for charge distribution algorithm
308
cc4dcfb0 309 //
310 // Find the wire position (center of charge distribution)
bd57045f 311 Float_t x0a = GetAnod(xhit);
312 fXhit = x0a;
313 fYhit = yhit;
cc4dcfb0 314 //
315 // and take fNsigma*sigma around this center
bd57045f 316 Float_t x01 = x0a - dx ;
317 Float_t x02 = x0a + dx;
318 Float_t y01 = yhit - dy;
319 Float_t y02 = yhit + dy;
cc4dcfb0 320
bd57045f 321 // check the limits after adding (fNsigma*sigma)
322 if (x01 < fCx[0]) x01 = fCx[0];
323 if (y01 < -fDyPCB/2) y01 = -fDyPCB/2;
324
325 if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1]; // still ok ? (CF)
13b83a58 326 if (y02 >= fDyPCB/2.) y02 = fDyPCB/2.;
cc4dcfb0 327
328
329 Int_t isec=-1;
330 for (Int_t i=fNsec-1; i > 0; i--) {
bd57045f 331 if (x02 >= fCx[i-1]) {
332 isec=i;
13b83a58 333 if (TMath::Abs(fCx[isec] - fCx[isec-1]) < 0.1 && isec > 1) isec--;
bd57045f 334 break;
335 }
cc4dcfb0 336 }
bd57045f 337
13b83a58 338 // y02 += Dpy(isec);// why ? (CF)
cc4dcfb0 339
340 //
341 // find the pads over which the charge distributes
342 GetPadI(x01,y01,fIxmin,fIymin);
343 GetPadI(x02,y02,fIxmax,fIymax);
344
345 if (fIxmax > fNpx) fIxmax=fNpx;
346 if (fIymax > fNpyS[isec]) fIymax = fNpyS[isec];
f7db2071 347 if (fIxmin < 1) fIxmin = 1; // patch for the moment (Ch. Finck)
348 if (fIymin < 1) fIymin = 1;
cc4dcfb0 349
bd57045f 350 fXmin = x01;
351 fXmax = x02;
352 fYmin = y01;
353 fYmax = y02;
cc4dcfb0 354
355 //
356 // Set current pad to lower left corner
bd57045f 357 if (fIxmax < fIxmin) fIxmax = fIxmin;
358 if (fIymax < fIymin) fIymax = fIymin;
359 fIx = fIxmin;
360 fIy = fIymin;
cc4dcfb0 361
362 GetPadC(fIx,fIy,fX,fY);
bd57045f 363 fSector = Sector(fIx,fIy);
f64ec237 364
365 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d",
366 xhit,yhit,dx,dy,fIx,fIy));
cc4dcfb0 367}
f48459ab 368
cc4dcfb0 369//----------------------------------------------------------------------
370void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
371{
5398f946 372/// Initialises iteration over pads for charge distribution algorithm
d19b6003 373
cc4dcfb0 374 FirstPad(xhit, yhit, dx, dy);
375}
376//----------------------------------------------------------------------
377void AliMUONSt345SlatSegmentation::NextPad()
378{
5398f946 379/// Stepper for the iteration over pads
380
f48459ab 381 // Step to next pad in the integration region
382 // step from left to right
383 if (fIx != fIxmax) {
384 fIx++;
385 GetPadC(fIx,fIy,fX,fY);
386 fSector=Sector(fIx,fIy);
387 // step up
388 } else if (fIy != fIymax) {
389 fIx=fIxmin;
390 fIy++;
391 GetPadC(fIx,fIy,fX,fY);
392 fSector=Sector(fIx,fIy);
f48459ab 393 } else {
f7db2071 394 fIx=-999;
395 fIy=-999;
f48459ab 396 }
cc4dcfb0 397}
398//-------------------------------------------------------------------------
399Int_t AliMUONSt345SlatSegmentation::MorePads()
400{
5398f946 401/// Stopping condition for the iterator over pads
402
f48459ab 403 // Are there more pads in the integration region
cc4dcfb0 404
f7db2071 405 return (fIx != -999 || fIy != -999);
cc4dcfb0 406}
407//--------------------------------------------------------------------------
408Int_t AliMUONSt345SlatSegmentation::Sector(Int_t ix, Int_t iy)
409{
5398f946 410/// Determine segmentation zone from pad coordinates
411
bd57045f 412 Int_t isec = -1;
413 for (Int_t i = 0; i < fNsec; i++) {
f48459ab 414 if (ix <= fNpxS[i]) {
bd57045f 415 isec = i;
f48459ab 416 break;
cc4dcfb0 417 }
f48459ab 418 }
bd57045f 419 if (isec == -1) AliWarning(Form("Sector = %d with ix %d and iy %d, Npx %d",
420 isec, ix, iy, fNpx));
cc4dcfb0 421
f48459ab 422 return isec;
cc4dcfb0 423
424}
425//-----------------------------------------------------------------------------
426void AliMUONSt345SlatSegmentation::
427IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
428{
5398f946 429/// Returns integration limits for current pad
430
f48459ab 431 x1=fXhit-fX-Dpx(fSector)/2.;
432 x2=x1+Dpx(fSector);
433 y1=fYhit-fY-Dpy(fSector)/2.;
434 y2=y1+Dpy(fSector);
f64ec237 435
436 AliDebug(4,Form("xhit,yhit=%e,%e x,y=%e,%e, x1,x2,y1,y2=%e,%e,%e,%e",fXhit,fYhit,fX,fY,x1,x2,y1,y2));
cc4dcfb0 437
438}
439//-----------------------------------------------------------------------------
440void AliMUONSt345SlatSegmentation::
441Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
442{
5398f946 443/// Returns list of next neighbours for given Pad (iX, iY)
444
f48459ab 445 Int_t i=0;
446 // step right
447 if (iX+1 <= fNpx) {
448 Xlist[i]=iX+1;
449 Ylist[i++]=iY;
450 }
451 // step left
452 if (iX-1 > 0) {
453 Xlist[i]=iX-1;
454 Ylist[i++]=iY;
455 }
456 Int_t sector = Sector(iX,iY);
457 // step up
458 if (iY+1 <= fNpyS[sector]) {
459 Xlist[i]=iX;
460 Ylist[i++]=iY+1;
461 }
462 // step down
463 if (iY-1 > 0) {
464 Xlist[i]=iX;
465 Ylist[i++]=iY-1;
466 }
467 *Nlist=i;
cc4dcfb0 468}
f48459ab 469
cc4dcfb0 470//--------------------------------------------------------------------------
471void AliMUONSt345SlatSegmentation::Init(Int_t detectionElementId)
472{
5398f946 473/// Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
474/// These arrays help in converting from real to pad co-ordinates and
475/// vice versa
476///
477/// Segmentation is defined by rectangular modules approximating
478/// concentric circles as shown below
479
f48459ab 480 // PCB module size in cm
481 // printf("\n Initialise Segmentation SlatModule \n");
cc4dcfb0 482
f48459ab 483
a713db22 484 // printf(" fBending: %d \n",fBending);
f48459ab 485
f1501d74 486 if (fInitDone) return; // security if init is already done in AliMUONFactory
f48459ab 487 fDxPCB=40;
488 fDyPCB=40;
489
490 // Calculate padsize along x
491 (*fDpxD)[fNsec-1]=fDpx;
492 (*fDpyD)[fNsec-1]=fDpy;
493 if (fNsec > 1) {
494 for (Int_t i=fNsec-1; i>=0; i--){ // fNsec-2
495 if (!fBending) {
496 (*fDpxD)[i]=fDpx;
497 (*fDpyD)[i]=(*fDpyD)[fNsec-1]/(*fNDiv)[i];
498 } else {
cc4dcfb0 499 (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i];
f48459ab 500 (*fDpyD)[i]=fDpy;
cc4dcfb0 501 }
502 }
f48459ab 503 }
504 //
505 // fill the arrays defining the pad segmentation boundaries
506 //
507 //
508 // Loop over sectors (isec=0 for secto close to the beam pipe)
509 Float_t totalLength = 0;
510 for (Int_t isec=0; isec<4; isec++) totalLength += fPcbBoards[isec]*fDxPCB; // !!!!
511
512 fNpy = 0; // maximum number of pads in y
513 for (Int_t isec=0; isec<4; isec++) {
514 if (isec==0) {
515 fNpxS[0] = 0;
516 fNpyS[0] = 0;
517 fCx[0] = -totalLength/2;
518 } else {
13b83a58 519 fNpxS[isec] = fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]+0.5);
520 fNpyS[isec] = Int_t(fDyPCB/(*fDpyD)[isec]+0.5);
f48459ab 521 if (fNpyS[isec] >= fNpy) fNpy = fNpyS[isec];
522 fCx[isec]= fCx[isec-1] + fPcbBoards[isec]*fDxPCB;
523 }
524 } // sectors
cc4dcfb0 525
f48459ab 526 fNpx = fNpxS[3]; // maximum number of pads in x
527 fCy = fDyPCB/2.;
528 //
529 fId = detectionElementId;
f1501d74 530
f1501d74 531 fInitDone = kTRUE;
f48459ab 532}