1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.3 2000/10/18 11:42:06 morsch
19 - AliMUONRawCluster contains z-position.
20 - Some clean-up of useless print statements during initialisations.
22 Revision 1.2 2000/10/09 14:06:18 morsch
23 Some type cast problems of type (TMath::Sign((Float_t)1.,x)) corrected (P.H.)
25 Revision 1.1 2000/10/06 09:00:47 morsch
26 Segmentation class for chambers built out of slats.
30 #include "AliMUONSegmentationSlat.h"
31 #include "AliMUONSegmentationSlatModule.h"
33 #include "AliMUONChamber.h"
35 #include "TObjArray.h"
40 //___________________________________________
41 ClassImp(AliMUONSegmentationSlat)
43 AliMUONSegmentationSlat::AliMUONSegmentationSlat()
45 // Default constructor
47 fNDiv = new TArrayI(4);
50 void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
52 // Sets the pad (strip) size
58 Float_t AliMUONSegmentationSlat::GetAnod(Float_t xhit) const
60 // Returns for a hit position xhit the position of the nearest anode wire
61 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
65 Float_t AliMUONSegmentationSlat::Dpx(Int_t isec) const
68 // Returns x-pad size for given sector isec
69 // isec = 100*islat+iregion
74 return Slat(islat)->Dpx(iregion);
77 Float_t AliMUONSegmentationSlat::Dpy(Int_t isec) const
80 // Returns y-pad (strip) size for given sector isec
84 void AliMUONSegmentationSlat::SetPadDivision(Int_t ndiv[4])
87 // Defines the pad size perp. to the anode wire (y) for different sectors.
88 // Pad sizes are defined as integral fractions ndiv of a basis pad size
91 for (Int_t i=0; i<4; i++) {
96 void AliMUONSegmentationSlat::GlobalToLocal(
97 Float_t x, Float_t y, Float_t z, Int_t &islat, Float_t &xlocal, Float_t &ylocal)
100 // Perform local to global transformation for space coordinates
105 // Transform According to slat plane z-position: negative side is shifted down
106 // positive side is shifted up
107 // by half the overlap
108 zlocal = z-fChamber->Z();
109 // Set the signs for the symmetry transformation and transform to first quadrant
111 Float_t xabs=TMath::Abs(x);
113 Int_t ifirst = (zlocal < Float_t(0))? 0:1;
116 for (i=ifirst; i<fNSlats; i+=2) {
118 if ((y >= fYPosition[i]) && (y < fYPosition[i]+fSlatY)) break;
122 // Transform to local coordinate system
125 ylocal = y -fYPosition[index];
126 xlocal = xabs-fXPosition[index];
128 if (i >= fNSlats) {islat = -1; x=-1; y = -1;}
131 void AliMUONSegmentationSlat::GlobalToLocal(
132 Int_t ix, Int_t iy, Int_t &islat, Int_t &ixlocal, Int_t &iylocal)
135 // Perform global to local transformation for pad coordinates
143 // Find slat number (index) and iylocal
144 for (Int_t i=0; i<fNSlats; i++) {
145 iytemp-=Slat(i)->Npy();
148 if (iytemp <= 0) break;
153 ixlocal=TMath::Abs(ix);
157 void AliMUONSegmentationSlat::
158 LocalToGlobal(Int_t islat, Float_t xlocal, Float_t ylocal, Float_t &x, Float_t &y, Float_t &z)
160 // Transform from local to global space coordinates
162 // upper plane (y>0) even slat number is shifted down
163 // upper plane (y>0) odd slat number is shifted up
164 // lower plane (y<0) even slat number is shifted up
165 // lower plane (y<0) odd slat number is shifted down
168 x = (xlocal+fXPosition[islat])*fSym;
169 y=(ylocal+fYPosition[islat]);
171 z = (TMath::Even(islat)) ? -fDz : fDz ;
176 void AliMUONSegmentationSlat::LocalToGlobal(
177 Int_t islat, Int_t ixlocal, Int_t iylocal, Int_t &ix, Int_t &iy)
179 // Transform from local to global pad coordinates
185 // Find slat number (index) and iylocal
186 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
193 void AliMUONSegmentationSlat::SetSymmetry(Int_t ix)
195 // Set set signs for symmetry transformation
196 fSym=TMath::Sign(1,ix);
199 void AliMUONSegmentationSlat::SetSymmetry(Float_t x)
201 // Set set signs for symmetry transformation
202 fSym=Int_t (TMath::Sign((Float_t)1.,x));
205 void AliMUONSegmentationSlat::
206 GetPadI(Float_t x, Float_t y, Float_t z, Int_t &ix, Int_t &iy)
208 // Returns pad coordinates for given set of space coordinates
211 Float_t xlocal, ylocal;
213 GlobalToLocal(x,y,z,islat,xlocal,ylocal);
218 Slat(islat)->GetPadI(xlocal, ylocal, ix, iy);
219 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
221 ix=ix*Int_t(TMath::Sign((Float_t)1.,x));
225 void AliMUONSegmentationSlat::
226 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
228 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
230 Int_t islat, ixlocal, iylocal;
232 // Delegation of transforamtion to slat
233 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
234 Slat(islat)->GetPadC(ixlocal, iylocal, x, y);
236 x+=fXPosition[islat];
237 y+=fYPosition[islat];
239 // Symmetry transformation of half planes
240 x=x*TMath::Sign(1,ix);
243 z = (TMath::Even(islat)) ? -fDz : fDz ;
247 Int_t AliMUONSegmentationSlat::ISector()
249 // Returns current sector during tracking
252 iregion = fCurrentSlat->ISector();
253 return 100*fSlatIndex+iregion;
256 Int_t AliMUONSegmentationSlat::Sector(Int_t ix, Int_t iy)
258 Int_t ixlocal, iylocal, iregion, islat;
260 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
262 iregion = Slat(islat)->Sector(ixlocal, iylocal);
263 return 100*islat+iregion;
267 void AliMUONSegmentationSlat::SetPad(Int_t ix, Int_t iy)
270 // Sets virtual pad coordinates, needed for evaluating pad response
271 // outside the tracking program
272 Int_t islat, ixlocal, iylocal;
276 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
278 fCurrentSlat=Slat(islat);
279 fCurrentSlat->SetPad(ixlocal, iylocal);
282 void AliMUONSegmentationSlat::SetHit(Float_t xhit, Float_t yhit, Float_t zhit)
284 // Sets current hit coordinates
286 Float_t xlocal, ylocal;
291 GlobalToLocal(xhit,yhit,zhit,islat,xlocal,ylocal);
293 if (islat < 0) printf("\n SetHit: %d", islat);
295 fCurrentSlat=Slat(islat);
296 fCurrentSlat->SetHit(xlocal, ylocal);
300 void AliMUONSegmentationSlat::
301 FirstPad(Float_t xhit, Float_t yhit, Float_t zhit, Float_t dx, Float_t dy)
303 // Initialises iteration over pads for charge distribution algorithm
309 Float_t xlocal, ylocal;
310 GlobalToLocal(xhit, yhit, zhit, islat, xlocal, ylocal);
312 fCurrentSlat=Slat(islat);
313 fCurrentSlat->FirstPad(xlocal, ylocal, dx, dy);
318 void AliMUONSegmentationSlat::NextPad()
320 // Stepper for the iteration over pads
322 fCurrentSlat->NextPad();
326 Int_t AliMUONSegmentationSlat::MorePads()
327 // Stopping condition for the iterator over pads
329 // Are there more pads in the integration region
331 return fCurrentSlat->MorePads();
334 void AliMUONSegmentationSlat::
335 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
337 // Returns integration limits for current pad
340 fCurrentSlat->IntegrationLimits(x1, x2, y1, y2);
344 void AliMUONSegmentationSlat::
345 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
347 // Returns list of neighbours of pad with coordinates iX, iY
349 Int_t i, xListLocal[10], yListLocal[10], iXlocal, iYlocal, islat;
353 GlobalToLocal(iX, iY, islat, iXlocal, iYlocal);
355 Slat(islat)->Neighbours(iXlocal, iYlocal, Nlist, xListLocal, yListLocal);
357 for (i=0; i<*Nlist; i++) LocalToGlobal(islat, xListLocal[i], yListLocal[i], Xlist[i], Ylist[i]);
362 Int_t AliMUONSegmentationSlat::Ix()
364 // Return current pad coordinate ix during stepping
366 ixl=fCurrentSlat->Ix();
367 iyl=fCurrentSlat->Iy();
369 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
372 GlobalToLocal(ix, iy, isc, ixc, iyc);
373 Slat(isc)->GetPadC(ixc,iyc,xc,yc);
378 Int_t AliMUONSegmentationSlat::Iy()
380 // Return current pad coordinate iy during stepping
382 ixl=fCurrentSlat->Ix();
383 iyl=fCurrentSlat->Iy();
384 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
390 // Signal Generation Condition during Stepping
391 Int_t AliMUONSegmentationSlat::SigGenCond(Float_t x, Float_t y, Float_t z)
394 // True if signal generation condition fullfilled
395 Float_t xlocal, ylocal;
397 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
398 return Slat(islat)->SigGenCond(xlocal, ylocal, z);
401 // Initialise signal generation at coord (x,y,z)
402 void AliMUONSegmentationSlat::SigGenInit(Float_t x, Float_t y, Float_t z)
404 // Initialize the signal generation condition
406 Float_t xlocal, ylocal;
409 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
410 Slat(islat)->SigGenInit(xlocal, ylocal, z);
415 void AliMUONSegmentationSlat::Init(Int_t chamber)
418 // Initialize slat modules of quadrant +/+
419 // The other three quadrants are handled through symmetry transformations
421 printf("\n Initialise Segmentation Slat \n");
424 // Initialize Slat modules
428 for (i=0; i<4; i++) ndiv[i]=(*fNDiv)[i];
429 // Half distance between slat planes
433 for (i=0; i<15; i++) fSlatX[i]=0.;
435 // Initialize array of slats
436 fSlats = new TObjArray(fNSlats);
437 // Maximum number of strips (pads) in x and y
440 // for each slat in the quadrant (+,+)
441 for (islat=0; islat<fNSlats; islat++) {
442 (*fSlats)[islat] = CreateSlatModule();
444 AliMUONSegmentationSlatModule *slat = Slat(islat);
449 slat->SetPadSize(fDpx, fDpy);
450 // Forward wire pitch
451 slat->SetDAnod(fWireD);
452 // Foward segmentation
453 slat->SetPadDivision(ndiv);
454 slat->SetPcbBoards(fPcb[islat]);
455 // Initialize slat module
457 // y-position of slat module relative to the first (closest to the beam)
458 fYPosition[islat]= fYPosOrigin+islat*(fSlatY-2.*fShift);
461 if (slat->Npx() > fNpx) fNpx=slat->Npx();
463 for (isec=0; isec< 4; isec++)
465 fSlatX[islat]+=40.*fPcb[islat][isec];
469 // Set parent chamber number
470 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
471 fChamber=&(pMUON->Chamber(chamber));
478 void AliMUONSegmentationSlat::SetNPCBperSector(Int_t *npcb)
480 // PCB distribution for station 4 (6 rows with 1+3 segmentation regions)
481 for (Int_t islat=0; islat<fNSlats; islat++){
482 fPcb[islat][0] = *(npcb + 4 * islat);
483 fPcb[islat][1] = *(npcb + 4 * islat + 1);
484 fPcb[islat][2] = *(npcb + 4 * islat + 2);
485 fPcb[islat][3] = *(npcb + 4 * islat + 3);
490 void AliMUONSegmentationSlat::SetSlatXPositions(Float_t *xpos)
492 // Set x-positions of Slats
493 for (Int_t islat=0; islat<fNSlats; islat++) fXPosition[islat]=xpos[islat];
496 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::Slat(Int_t index) const
497 { return ((AliMUONSegmentationSlatModule*) (*fSlats)[index]);}
500 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::
503 // Factory method for slat module
504 return new AliMUONSegmentationSlatModule();