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.4 2000/10/22 16:55:43 morsch
19 Use only x-symmetry in global to local transformations and delegation.
21 Revision 1.3 2000/10/18 11:42:06 morsch
22 - AliMUONRawCluster contains z-position.
23 - Some clean-up of useless print statements during initialisations.
25 Revision 1.2 2000/10/09 14:06:18 morsch
26 Some type cast problems of type (TMath::Sign((Float_t)1.,x)) corrected (P.H.)
28 Revision 1.1 2000/10/06 09:00:47 morsch
29 Segmentation class for chambers built out of slats.
33 #include "AliMUONSegmentationSlat.h"
34 #include "AliMUONSegmentationSlatModule.h"
36 #include "AliMUONChamber.h"
38 #include "TObjArray.h"
43 //___________________________________________
44 ClassImp(AliMUONSegmentationSlat)
46 AliMUONSegmentationSlat::AliMUONSegmentationSlat()
48 // Default constructor
50 fNDiv = new TArrayI(4);
53 void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
55 // Sets the pad (strip) size
61 Float_t AliMUONSegmentationSlat::GetAnod(Float_t xhit) const
63 // Returns for a hit position xhit the position of the nearest anode wire
64 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
68 Float_t AliMUONSegmentationSlat::Dpx(Int_t isec) const
71 // Returns x-pad size for given sector isec
72 // isec = 100*islat+iregion
77 return Slat(islat)->Dpx(iregion);
80 Float_t AliMUONSegmentationSlat::Dpy(Int_t isec) const
83 // Returns y-pad (strip) size for given sector isec
87 void AliMUONSegmentationSlat::SetPadDivision(Int_t ndiv[4])
90 // Defines the pad size perp. to the anode wire (y) for different sectors.
91 // Pad sizes are defined as integral fractions ndiv of a basis pad size
94 for (Int_t i=0; i<4; i++) {
99 void AliMUONSegmentationSlat::GlobalToLocal(
100 Float_t x, Float_t y, Float_t z, Int_t &islat, Float_t &xlocal, Float_t &ylocal)
103 // Perform local to global transformation for space coordinates
108 // Transform According to slat plane z-position: negative side is shifted down
109 // positive side is shifted up
110 // by half the overlap
111 zlocal = z-fChamber->Z();
112 // Set the signs for the symmetry transformation and transform to first quadrant
114 Float_t xabs=TMath::Abs(x);
116 Int_t ifirst = (zlocal < Float_t(0))? 0:1;
119 for (i=ifirst; i<fNSlats; i+=2) {
121 if ((y >= fYPosition[i]) && (y < fYPosition[i]+fSlatY)) break;
125 // Transform to local coordinate system
128 ylocal = y -fYPosition[index];
129 xlocal = xabs-fXPosition[index];
131 if (i >= fNSlats) {islat = -1; x=-1; y = -1;}
134 void AliMUONSegmentationSlat::GlobalToLocal(
135 Int_t ix, Int_t iy, Int_t &islat, Int_t &ixlocal, Int_t &iylocal)
138 // Perform global to local transformation for pad coordinates
146 // Find slat number (index) and iylocal
147 for (Int_t i=0; i<fNSlats; i++) {
148 iytemp-=Slat(i)->Npy();
151 if (iytemp <= 0) break;
156 ixlocal=TMath::Abs(ix);
160 void AliMUONSegmentationSlat::
161 LocalToGlobal(Int_t islat, Float_t xlocal, Float_t ylocal, Float_t &x, Float_t &y, Float_t &z)
163 // Transform from local to global space coordinates
165 // upper plane (y>0) even slat number is shifted down
166 // upper plane (y>0) odd slat number is shifted up
167 // lower plane (y<0) even slat number is shifted up
168 // lower plane (y<0) odd slat number is shifted down
171 x = (xlocal+fXPosition[islat])*fSym;
172 y=(ylocal+fYPosition[islat]);
174 z = (TMath::Even(islat)) ? -fDz : fDz ;
179 void AliMUONSegmentationSlat::LocalToGlobal(
180 Int_t islat, Int_t ixlocal, Int_t iylocal, Int_t &ix, Int_t &iy)
182 // Transform from local to global pad coordinates
188 // Find slat number (index) and iylocal
189 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
196 void AliMUONSegmentationSlat::SetSymmetry(Int_t ix)
198 // Set set signs for symmetry transformation
199 fSym=TMath::Sign(1,ix);
202 void AliMUONSegmentationSlat::SetSymmetry(Float_t x)
204 // Set set signs for symmetry transformation
205 fSym=Int_t (TMath::Sign((Float_t)1.,x));
208 void AliMUONSegmentationSlat::
209 GetPadI(Float_t x, Float_t y, Float_t z, Int_t &ix, Int_t &iy)
211 // Returns pad coordinates for given set of space coordinates
214 Float_t xlocal, ylocal;
216 GlobalToLocal(x,y,z,islat,xlocal,ylocal);
221 Slat(islat)->GetPadI(xlocal, ylocal, ix, iy);
222 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
224 ix=ix*Int_t(TMath::Sign((Float_t)1.,x));
228 void AliMUONSegmentationSlat::
229 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
231 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
233 Int_t islat, ixlocal, iylocal;
235 // Delegation of transforamtion to slat
236 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
237 Slat(islat)->GetPadC(ixlocal, iylocal, x, y);
239 x+=fXPosition[islat];
240 y+=fYPosition[islat];
242 // Symmetry transformation of half planes
243 x=x*TMath::Sign(1,ix);
246 z = (TMath::Even(islat)) ? -fDz : fDz ;
250 Int_t AliMUONSegmentationSlat::ISector()
252 // Returns current sector during tracking
255 iregion = fCurrentSlat->ISector();
256 return 100*fSlatIndex+iregion;
259 Int_t AliMUONSegmentationSlat::Sector(Int_t ix, Int_t iy)
261 Int_t ixlocal, iylocal, iregion, islat;
263 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
265 iregion = Slat(islat)->Sector(ixlocal, iylocal);
266 return 100*islat+iregion;
270 void AliMUONSegmentationSlat::SetPad(Int_t ix, Int_t iy)
273 // Sets virtual pad coordinates, needed for evaluating pad response
274 // outside the tracking program
275 Int_t islat, ixlocal, iylocal;
279 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
281 fCurrentSlat=Slat(islat);
282 fCurrentSlat->SetPad(ixlocal, iylocal);
285 void AliMUONSegmentationSlat::SetHit(Float_t xhit, Float_t yhit, Float_t zhit)
287 // Sets current hit coordinates
289 Float_t xlocal, ylocal;
294 GlobalToLocal(xhit,yhit,zhit,islat,xlocal,ylocal);
296 if (islat < 0) printf("\n SetHit: %d", islat);
298 fCurrentSlat=Slat(islat);
299 fCurrentSlat->SetHit(xlocal, ylocal);
303 void AliMUONSegmentationSlat::
304 FirstPad(Float_t xhit, Float_t yhit, Float_t zhit, Float_t dx, Float_t dy)
306 // Initialises iteration over pads for charge distribution algorithm
312 Float_t xlocal, ylocal;
313 GlobalToLocal(xhit, yhit, zhit, islat, xlocal, ylocal);
315 fCurrentSlat=Slat(islat);
316 fCurrentSlat->FirstPad(xlocal, ylocal, dx, dy);
321 void AliMUONSegmentationSlat::NextPad()
323 // Stepper for the iteration over pads
325 fCurrentSlat->NextPad();
329 Int_t AliMUONSegmentationSlat::MorePads()
330 // Stopping condition for the iterator over pads
332 // Are there more pads in the integration region
334 return fCurrentSlat->MorePads();
337 void AliMUONSegmentationSlat::
338 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
340 // Returns integration limits for current pad
343 fCurrentSlat->IntegrationLimits(x1, x2, y1, y2);
347 void AliMUONSegmentationSlat::
348 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
350 // Returns list of neighbours of pad with coordinates iX, iY
352 Int_t i, xListLocal[10], yListLocal[10], iXlocal, iYlocal, islat;
356 GlobalToLocal(iX, iY, islat, iXlocal, iYlocal);
358 Slat(islat)->Neighbours(iXlocal, iYlocal, Nlist, xListLocal, yListLocal);
360 for (i=0; i<*Nlist; i++) LocalToGlobal(islat, xListLocal[i], yListLocal[i], Xlist[i], Ylist[i]);
365 Int_t AliMUONSegmentationSlat::Ix()
367 // Return current pad coordinate ix during stepping
369 ixl=fCurrentSlat->Ix();
370 iyl=fCurrentSlat->Iy();
372 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
375 GlobalToLocal(ix, iy, isc, ixc, iyc);
376 Slat(isc)->GetPadC(ixc,iyc,xc,yc);
381 Int_t AliMUONSegmentationSlat::Iy()
383 // Return current pad coordinate iy during stepping
385 ixl=fCurrentSlat->Ix();
386 iyl=fCurrentSlat->Iy();
387 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
393 // Signal Generation Condition during Stepping
394 Int_t AliMUONSegmentationSlat::SigGenCond(Float_t x, Float_t y, Float_t z)
397 // True if signal generation condition fullfilled
398 Float_t xlocal, ylocal;
400 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
401 return Slat(islat)->SigGenCond(xlocal, ylocal, z);
404 // Initialise signal generation at coord (x,y,z)
405 void AliMUONSegmentationSlat::SigGenInit(Float_t x, Float_t y, Float_t z)
407 // Initialize the signal generation condition
409 Float_t xlocal, ylocal;
412 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
413 Slat(islat)->SigGenInit(xlocal, ylocal, z);
418 void AliMUONSegmentationSlat::Init(Int_t chamber)
421 // Initialize slat modules of quadrant +/+
422 // The other three quadrants are handled through symmetry transformations
424 printf("\n Initialise Segmentation Slat \n");
427 // Initialize Slat modules
431 for (i=0; i<4; i++) ndiv[i]=(*fNDiv)[i];
436 for (i=0; i<15; i++) fSlatX[i]=0.;
438 // Initialize array of slats
439 fSlats = new TObjArray(fNSlats);
440 // Maximum number of strips (pads) in x and y
443 // for each slat in the quadrant (+,+)
444 for (islat=0; islat<fNSlats; islat++) {
445 (*fSlats)[islat] = CreateSlatModule();
447 AliMUONSegmentationSlatModule *slat = Slat(islat);
452 slat->SetPadSize(fDpx, fDpy);
453 // Forward wire pitch
454 slat->SetDAnod(fWireD);
455 // Foward segmentation
456 slat->SetPadDivision(ndiv);
457 slat->SetPcbBoards(fPcb[islat]);
458 // Initialize slat module
460 // y-position of slat module relative to the first (closest to the beam)
461 fYPosition[islat]= fYPosOrigin+islat*(fSlatY-2.*fShift);
464 if (slat->Npx() > fNpx) fNpx=slat->Npx();
466 for (isec=0; isec< 4; isec++)
468 fSlatX[islat]+=40.*fPcb[islat][isec];
472 // Set parent chamber number
473 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
474 fChamber=&(pMUON->Chamber(chamber));
481 void AliMUONSegmentationSlat::SetNPCBperSector(Int_t *npcb)
483 // PCB distribution for station 4 (6 rows with 1+3 segmentation regions)
484 for (Int_t islat=0; islat<fNSlats; islat++){
485 fPcb[islat][0] = *(npcb + 4 * islat);
486 fPcb[islat][1] = *(npcb + 4 * islat + 1);
487 fPcb[islat][2] = *(npcb + 4 * islat + 2);
488 fPcb[islat][3] = *(npcb + 4 * islat + 3);
493 void AliMUONSegmentationSlat::SetSlatXPositions(Float_t *xpos)
495 // Set x-positions of Slats
496 for (Int_t islat=0; islat<fNSlats; islat++) fXPosition[islat]=xpos[islat];
499 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::Slat(Int_t index) const
500 { return ((AliMUONSegmentationSlatModule*) (*fSlats)[index]);}
503 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::
506 // Factory method for slat module
507 return new AliMUONSegmentationSlatModule();