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.5 2000/10/23 13:37:40 morsch
19 Correct z-position of slat planes.
21 Revision 1.4 2000/10/22 16:55:43 morsch
22 Use only x-symmetry in global to local transformations and delegation.
24 Revision 1.3 2000/10/18 11:42:06 morsch
25 - AliMUONRawCluster contains z-position.
26 - Some clean-up of useless print statements during initialisations.
28 Revision 1.2 2000/10/09 14:06:18 morsch
29 Some type cast problems of type (TMath::Sign((Float_t)1.,x)) corrected (P.H.)
31 Revision 1.1 2000/10/06 09:00:47 morsch
32 Segmentation class for chambers built out of slats.
36 #include "AliMUONSegmentationSlat.h"
37 #include "AliMUONSegmentationSlatModule.h"
39 #include "AliMUONChamber.h"
41 #include "TObjArray.h"
46 #include <TGeometry.h>
49 //___________________________________________
50 ClassImp(AliMUONSegmentationSlat)
52 AliMUONSegmentationSlat::AliMUONSegmentationSlat()
54 // Default constructor
56 fNDiv = new TArrayI(4);
59 void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
61 // Sets the pad (strip) size
67 Float_t AliMUONSegmentationSlat::GetAnod(Float_t xhit) const
69 // Returns for a hit position xhit the position of the nearest anode wire
70 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
74 Float_t AliMUONSegmentationSlat::Dpx(Int_t isec) const
77 // Returns x-pad size for given sector isec
78 // isec = 100*islat+iregion
83 return Slat(islat)->Dpx(iregion);
86 Float_t AliMUONSegmentationSlat::Dpy(Int_t isec) const
89 // Returns y-pad (strip) size for given sector isec
93 void AliMUONSegmentationSlat::SetPadDivision(Int_t ndiv[4])
96 // Defines the pad size perp. to the anode wire (y) for different sectors.
97 // Pad sizes are defined as integral fractions ndiv of a basis pad size
100 for (Int_t i=0; i<4; i++) {
105 void AliMUONSegmentationSlat::GlobalToLocal(
106 Float_t x, Float_t y, Float_t z, Int_t &islat, Float_t &xlocal, Float_t &ylocal)
109 // Perform local to global transformation for space coordinates
114 // Transform According to slat plane z-position: negative side is shifted down
115 // positive side is shifted up
116 // by half the overlap
117 zlocal = z-fChamber->Z();
118 // Set the signs for the symmetry transformation and transform to first quadrant
120 Float_t xabs=TMath::Abs(x);
122 Int_t ifirst = (zlocal < Float_t(0))? 0:1;
125 for (i=ifirst; i<fNSlats; i+=2) {
127 if ((y >= fYPosition[i]) && (y < fYPosition[i]+fSlatY)) break;
131 // Transform to local coordinate system
134 ylocal = y -fYPosition[index];
135 xlocal = xabs-fXPosition[index];
137 if (i >= fNSlats) {islat = -1; x=-1; y = -1;}
140 void AliMUONSegmentationSlat::GlobalToLocal(
141 Int_t ix, Int_t iy, Int_t &islat, Int_t &ixlocal, Int_t &iylocal)
144 // Perform global to local transformation for pad coordinates
152 // Find slat number (index) and iylocal
153 for (Int_t i=0; i<fNSlats; i++) {
154 iytemp-=Slat(i)->Npy();
157 if (iytemp <= 0) break;
162 ixlocal=TMath::Abs(ix);
166 void AliMUONSegmentationSlat::
167 LocalToGlobal(Int_t islat, Float_t xlocal, Float_t ylocal, Float_t &x, Float_t &y, Float_t &z)
169 // Transform from local to global space coordinates
171 // upper plane (y>0) even slat number is shifted down
172 // upper plane (y>0) odd slat number is shifted up
173 // lower plane (y<0) even slat number is shifted up
174 // lower plane (y<0) odd slat number is shifted down
177 x = (xlocal+fXPosition[islat])*fSym;
178 y=(ylocal+fYPosition[islat]);
180 z = (TMath::Even(islat)) ? -fDz : fDz ;
185 void AliMUONSegmentationSlat::LocalToGlobal(
186 Int_t islat, Int_t ixlocal, Int_t iylocal, Int_t &ix, Int_t &iy)
188 // Transform from local to global pad coordinates
194 // Find slat number (index) and iylocal
195 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
202 void AliMUONSegmentationSlat::SetSymmetry(Int_t ix)
204 // Set set signs for symmetry transformation
205 fSym=TMath::Sign(1,ix);
208 void AliMUONSegmentationSlat::SetSymmetry(Float_t x)
210 // Set set signs for symmetry transformation
211 fSym=Int_t (TMath::Sign((Float_t)1.,x));
214 void AliMUONSegmentationSlat::
215 GetPadI(Float_t x, Float_t y, Float_t z, Int_t &ix, Int_t &iy)
217 // Returns pad coordinates for given set of space coordinates
220 Float_t xlocal, ylocal;
222 GlobalToLocal(x,y,z,islat,xlocal,ylocal);
227 Slat(islat)->GetPadI(xlocal, ylocal, ix, iy);
228 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
230 ix=ix*Int_t(TMath::Sign((Float_t)1.,x));
234 void AliMUONSegmentationSlat::
235 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
237 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
239 Int_t islat, ixlocal, iylocal;
241 // Delegation of transforamtion to slat
242 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
243 Slat(islat)->GetPadC(ixlocal, iylocal, x, y);
245 x+=fXPosition[islat];
246 y+=fYPosition[islat];
248 // Symmetry transformation of half planes
249 x=x*TMath::Sign(1,ix);
252 z = (TMath::Even(islat)) ? -fDz : fDz ;
256 Int_t AliMUONSegmentationSlat::ISector()
258 // Returns current sector during tracking
261 iregion = fCurrentSlat->ISector();
262 return 100*fSlatIndex+iregion;
265 Int_t AliMUONSegmentationSlat::Sector(Int_t ix, Int_t iy)
267 Int_t ixlocal, iylocal, iregion, islat;
269 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
271 iregion = Slat(islat)->Sector(ixlocal, iylocal);
272 return 100*islat+iregion;
276 void AliMUONSegmentationSlat::SetPad(Int_t ix, Int_t iy)
279 // Sets virtual pad coordinates, needed for evaluating pad response
280 // outside the tracking program
281 Int_t islat, ixlocal, iylocal;
285 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
287 fCurrentSlat=Slat(islat);
288 fCurrentSlat->SetPad(ixlocal, iylocal);
291 void AliMUONSegmentationSlat::SetHit(Float_t xhit, Float_t yhit, Float_t zhit)
293 // Sets current hit coordinates
295 Float_t xlocal, ylocal;
300 GlobalToLocal(xhit,yhit,zhit,islat,xlocal,ylocal);
302 if (islat < 0) printf("\n SetHit: %d", islat);
304 fCurrentSlat=Slat(islat);
305 fCurrentSlat->SetHit(xlocal, ylocal);
309 void AliMUONSegmentationSlat::
310 FirstPad(Float_t xhit, Float_t yhit, Float_t zhit, Float_t dx, Float_t dy)
312 // Initialises iteration over pads for charge distribution algorithm
318 Float_t xlocal, ylocal;
319 GlobalToLocal(xhit, yhit, zhit, islat, xlocal, ylocal);
321 fCurrentSlat=Slat(islat);
322 fCurrentSlat->FirstPad(xlocal, ylocal, dx, dy);
327 void AliMUONSegmentationSlat::NextPad()
329 // Stepper for the iteration over pads
331 fCurrentSlat->NextPad();
335 Int_t AliMUONSegmentationSlat::MorePads()
336 // Stopping condition for the iterator over pads
338 // Are there more pads in the integration region
340 return fCurrentSlat->MorePads();
343 void AliMUONSegmentationSlat::
344 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
346 // Returns integration limits for current pad
349 fCurrentSlat->IntegrationLimits(x1, x2, y1, y2);
353 void AliMUONSegmentationSlat::
354 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
356 // Returns list of neighbours of pad with coordinates iX, iY
358 Int_t i, xListLocal[10], yListLocal[10], iXlocal, iYlocal, islat;
362 GlobalToLocal(iX, iY, islat, iXlocal, iYlocal);
364 Slat(islat)->Neighbours(iXlocal, iYlocal, Nlist, xListLocal, yListLocal);
366 for (i=0; i<*Nlist; i++) LocalToGlobal(islat, xListLocal[i], yListLocal[i], Xlist[i], Ylist[i]);
371 Int_t AliMUONSegmentationSlat::Ix()
373 // Return current pad coordinate ix during stepping
375 ixl=fCurrentSlat->Ix();
376 iyl=fCurrentSlat->Iy();
378 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
381 GlobalToLocal(ix, iy, isc, ixc, iyc);
382 Slat(isc)->GetPadC(ixc,iyc,xc,yc);
387 Int_t AliMUONSegmentationSlat::Iy()
389 // Return current pad coordinate iy during stepping
391 ixl=fCurrentSlat->Ix();
392 iyl=fCurrentSlat->Iy();
393 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
399 // Signal Generation Condition during Stepping
400 Int_t AliMUONSegmentationSlat::SigGenCond(Float_t x, Float_t y, Float_t z)
403 // True if signal generation condition fullfilled
404 Float_t xlocal, ylocal;
406 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
407 return Slat(islat)->SigGenCond(xlocal, ylocal, z);
410 // Initialise signal generation at coord (x,y,z)
411 void AliMUONSegmentationSlat::SigGenInit(Float_t x, Float_t y, Float_t z)
413 // Initialize the signal generation condition
415 Float_t xlocal, ylocal;
418 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
419 Slat(islat)->SigGenInit(xlocal, ylocal, z);
424 void AliMUONSegmentationSlat::Init(Int_t chamber)
427 // Initialize slat modules of quadrant +/+
428 // The other three quadrants are handled through symmetry transformations
430 printf("\n Initialise Segmentation Slat \n");
433 // Initialize Slat modules
437 for (i=0; i<4; i++) ndiv[i]=(*fNDiv)[i];
442 for (i=0; i<15; i++) fSlatX[i]=0.;
444 // Initialize array of slats
445 fSlats = new TObjArray(fNSlats);
446 // Maximum number of strips (pads) in x and y
449 // for each slat in the quadrant (+,+)
450 for (islat=0; islat<fNSlats; islat++) {
451 (*fSlats)[islat] = CreateSlatModule();
453 AliMUONSegmentationSlatModule *slat = Slat(islat);
458 slat->SetPadSize(fDpx, fDpy);
459 // Forward wire pitch
460 slat->SetDAnod(fWireD);
461 // Foward segmentation
462 slat->SetPadDivision(ndiv);
463 slat->SetPcbBoards(fPcb[islat]);
464 // Initialize slat module
466 // y-position of slat module relative to the first (closest to the beam)
467 fYPosition[islat]= fYPosOrigin+islat*(fSlatY-2.*fShift);
470 if (slat->Npx() > fNpx) fNpx=slat->Npx();
472 for (isec=0; isec< 4; isec++)
474 fSlatX[islat]+=40.*fPcb[islat][isec];
478 // Set parent chamber number
479 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
480 fChamber=&(pMUON->Chamber(chamber));
488 void AliMUONSegmentationSlat::SetNPCBperSector(Int_t *npcb)
490 // PCB distribution for station 4 (6 rows with 1+3 segmentation regions)
491 for (Int_t islat=0; islat<fNSlats; islat++){
492 fPcb[islat][0] = *(npcb + 4 * islat);
493 fPcb[islat][1] = *(npcb + 4 * islat + 1);
494 fPcb[islat][2] = *(npcb + 4 * islat + 2);
495 fPcb[islat][3] = *(npcb + 4 * islat + 3);
500 void AliMUONSegmentationSlat::SetSlatXPositions(Float_t *xpos)
502 // Set x-positions of Slats
503 for (Int_t islat=0; islat<fNSlats; islat++) fXPosition[islat]=xpos[islat];
506 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::Slat(Int_t index) const
507 { return ((AliMUONSegmentationSlatModule*) (*fSlats)[index]);}
510 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::
513 // Factory method for slat module
514 return new AliMUONSegmentationSlatModule();
518 void AliMUONSegmentationSlat::Draw(const char* opt) const
520 if (!strcmp(opt,"eventdisplay")) {
521 const int kColorMUON1 = kYellow;
522 const int kColorMUON2 = kBlue;
524 // Drawing Routines for example for Event Display
527 char nameChamber[9], nameSlat[9], nameNode[9];
530 // Number of modules per slat
531 for (i=0; i<fNSlats; i++) {
533 for (j=0; j<4; j++) npcb[i]+=fPcb[i][j];
536 TNode* top=gAlice->GetGeometry()->GetNode("alice");
537 sprintf(nameChamber,"C_MUON%d",fId+1);
538 new TBRIK(nameChamber,"Mother","void",340,340,5.);
540 sprintf(nameNode,"MUON%d",100+fId+1);
541 TNode* node = new TNode(nameNode,"Chambernode",nameChamber,0,0,fChamber->Z(),"");
543 node->SetLineColor(kBlack);
544 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
545 (pMUON->Nodes())->Add(node);
549 for (j=0; j<fNSlats; j++)
551 sprintf(nameSlat,"SLAT%d",100*fId+1+j);
552 Float_t dx = 20.*npcb[j];
554 new TBRIK(nameSlat,"Slat Module","void",dx,20.,0.25);
556 color = TMath::Even(j) ? kColorMUON1 : kColorMUON2;
558 sprintf(nameNode,"SLAT%d",100*fId+1+j);
560 new TNode(nameNode,"Slat Module",nameSlat, dx+fXPosition[j],fYPosition[j]+dy,0,"");
561 nodeSlat->SetLineColor(color);
563 sprintf(nameNode,"SLAT%d",100*fId+1+j+fNSlats);
565 new TNode(nameNode,"Slat Module",nameSlat,-dx-fXPosition[j],fYPosition[j]+dy,0,"");
566 nodeSlat->SetLineColor(color);