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.8 2000/12/21 22:12:41 morsch
19 Clean-up of coding rule violations,
21 Revision 1.7 2000/11/08 13:01:40 morsch
22 Chamber half-planes of stations 3-5 at different z-positions.
24 Revision 1.6 2000/11/06 09:20:43 morsch
25 AliMUON delegates part of BuildGeometry() to AliMUONSegmentation using the
26 Draw() method. This avoids code and parameter replication.
28 Revision 1.5 2000/10/23 13:37:40 morsch
29 Correct z-position of slat planes.
31 Revision 1.4 2000/10/22 16:55:43 morsch
32 Use only x-symmetry in global to local transformations and delegation.
34 Revision 1.3 2000/10/18 11:42:06 morsch
35 - AliMUONRawCluster contains z-position.
36 - Some clean-up of useless print statements during initialisations.
38 Revision 1.2 2000/10/09 14:06:18 morsch
39 Some type cast problems of type (TMath::Sign((Float_t)1.,x)) corrected (P.H.)
41 Revision 1.1 2000/10/06 09:00:47 morsch
42 Segmentation class for chambers built out of slats.
46 #include "AliMUONSegmentationSlat.h"
47 #include "AliMUONSegmentationSlatModule.h"
49 #include "AliMUONChamber.h"
51 #include "TObjArray.h"
56 #include <TGeometry.h>
59 //___________________________________________
60 ClassImp(AliMUONSegmentationSlat)
62 AliMUONSegmentationSlat::AliMUONSegmentationSlat()
64 // Default constructor
66 fNDiv = new TArrayI(4);
69 AliMUONSegmentationSlat::~AliMUONSegmentationSlat(){
70 //PH Delete TObjArrays
77 void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
79 // Sets the pad (strip) size
85 Float_t AliMUONSegmentationSlat::GetAnod(Float_t xhit) const
87 // Returns for a hit position xhit the position of the nearest anode wire
88 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
92 Float_t AliMUONSegmentationSlat::Dpx(Int_t isec) const
95 // Returns x-pad size for given sector isec
96 // isec = 100*islat+iregion
101 return Slat(islat)->Dpx(iregion);
104 Float_t AliMUONSegmentationSlat::Dpy(Int_t isec) const
107 // Returns y-pad (strip) size for given sector isec
111 void AliMUONSegmentationSlat::SetPadDivision(Int_t ndiv[4])
114 // Defines the pad size perp. to the anode wire (y) for different sectors.
115 // Pad sizes are defined as integral fractions ndiv of a basis pad size
118 for (Int_t i=0; i<4; i++) {
123 void AliMUONSegmentationSlat::GlobalToLocal(
124 Float_t x, Float_t y, Float_t z, Int_t &islat, Float_t &xlocal, Float_t &ylocal)
127 // Perform local to global transformation for space coordinates
132 // Transform According to slat plane z-position: negative side is shifted down
133 // positive side is shifted up
134 // by half the overlap
135 zlocal = z-fChamber->Z();
136 zlocal = (x>0) ? zlocal-2.*fDz : zlocal+2.*fDz;
137 // Set the signs for the symmetry transformation and transform to first quadrant
139 Float_t xabs=TMath::Abs(x);
141 Int_t ifirst = (zlocal < Float_t(0))? 0:1;
144 for (i=ifirst; i<fNSlats; i+=2) {
146 if ((y >= fYPosition[i]) && (y < fYPosition[i]+fSlatY)) break;
150 // Transform to local coordinate system
153 ylocal = y -fYPosition[index];
154 xlocal = xabs-fXPosition[index];
156 if (i >= fNSlats) {islat = -1; x=-1; y = -1;}
159 void AliMUONSegmentationSlat::GlobalToLocal(
160 Int_t ix, Int_t iy, Int_t &islat, Int_t &ixlocal, Int_t &iylocal)
163 // Perform global to local transformation for pad coordinates
171 // Find slat number (index) and iylocal
172 for (Int_t i=0; i<fNSlats; i++) {
173 iytemp-=Slat(i)->Npy();
176 if (iytemp <= 0) break;
181 ixlocal=TMath::Abs(ix);
185 void AliMUONSegmentationSlat::
186 LocalToGlobal(Int_t islat, Float_t xlocal, Float_t ylocal, Float_t &x, Float_t &y, Float_t &z)
188 // Transform from local to global space coordinates
190 // upper plane (y>0) even slat number is shifted down
191 // upper plane (y>0) odd slat number is shifted up
192 // lower plane (y<0) even slat number is shifted up
193 // lower plane (y<0) odd slat number is shifted down
196 x = (xlocal+fXPosition[islat])*fSym;
197 y=(ylocal+fYPosition[islat]);
199 z = (TMath::Even(islat)) ? -fDz : fDz ;
200 z = (x>0) ? z+2.*fDz : z-2.*fDz ;
206 void AliMUONSegmentationSlat::LocalToGlobal(
207 Int_t islat, Int_t ixlocal, Int_t iylocal, Int_t &ix, Int_t &iy)
209 // Transform from local to global pad coordinates
215 // Find slat number (index) and iylocal
216 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
223 void AliMUONSegmentationSlat::SetSymmetry(Int_t ix)
225 // Set set signs for symmetry transformation
226 fSym=TMath::Sign(1,ix);
229 void AliMUONSegmentationSlat::SetSymmetry(Float_t x)
231 // Set set signs for symmetry transformation
232 fSym=Int_t (TMath::Sign((Float_t)1.,x));
235 void AliMUONSegmentationSlat::
236 GetPadI(Float_t x, Float_t y, Float_t z, Int_t &ix, Int_t &iy)
238 // Returns pad coordinates for given set of space coordinates
241 Float_t xlocal, ylocal;
243 GlobalToLocal(x,y,z,islat,xlocal,ylocal);
248 Slat(islat)->GetPadI(xlocal, ylocal, ix, iy);
249 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
251 ix=ix*Int_t(TMath::Sign((Float_t)1.,x));
255 void AliMUONSegmentationSlat::
256 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
258 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
260 Int_t islat, ixlocal, iylocal;
262 // Delegation of transforamtion to slat
263 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
264 Slat(islat)->GetPadC(ixlocal, iylocal, x, y);
266 x+=fXPosition[islat];
267 y+=fYPosition[islat];
269 // Symmetry transformation of half planes
270 x=x*TMath::Sign(1,ix);
273 z = (TMath::Even(islat)) ? -fDz : fDz ;
274 z = (x>0) ? z+2.*fDz : z-2.*fDz ;
278 Int_t AliMUONSegmentationSlat::ISector()
280 // Returns current sector during tracking
283 iregion = fCurrentSlat->ISector();
284 return 100*fSlatIndex+iregion;
287 Int_t AliMUONSegmentationSlat::Sector(Int_t ix, Int_t iy)
289 // Returns sector for pad coordiantes (ix,iy)
290 Int_t ixlocal, iylocal, iregion, islat;
292 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
294 iregion = Slat(islat)->Sector(ixlocal, iylocal);
295 return 100*islat+iregion;
299 void AliMUONSegmentationSlat::SetPad(Int_t ix, Int_t iy)
302 // Sets virtual pad coordinates, needed for evaluating pad response
303 // outside the tracking program
304 Int_t islat, ixlocal, iylocal;
308 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
310 fCurrentSlat=Slat(islat);
311 fCurrentSlat->SetPad(ixlocal, iylocal);
314 void AliMUONSegmentationSlat::SetHit(Float_t xhit, Float_t yhit, Float_t zhit)
316 // Sets current hit coordinates
318 Float_t xlocal, ylocal;
323 GlobalToLocal(xhit,yhit,zhit,islat,xlocal,ylocal);
325 if (islat < 0) printf("\n SetHit: %d", islat);
327 fCurrentSlat=Slat(islat);
328 fCurrentSlat->SetHit(xlocal, ylocal);
332 void AliMUONSegmentationSlat::
333 FirstPad(Float_t xhit, Float_t yhit, Float_t zhit, Float_t dx, Float_t dy)
335 // Initialises iteration over pads for charge distribution algorithm
341 Float_t xlocal, ylocal;
342 GlobalToLocal(xhit, yhit, zhit, islat, xlocal, ylocal);
344 fCurrentSlat=Slat(islat);
345 fCurrentSlat->FirstPad(xlocal, ylocal, dx, dy);
350 void AliMUONSegmentationSlat::NextPad()
352 // Stepper for the iteration over pads
354 fCurrentSlat->NextPad();
358 Int_t AliMUONSegmentationSlat::MorePads()
359 // Stopping condition for the iterator over pads
361 // Are there more pads in the integration region
363 return fCurrentSlat->MorePads();
366 void AliMUONSegmentationSlat::
367 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
369 // Returns integration limits for current pad
372 fCurrentSlat->IntegrationLimits(x1, x2, y1, y2);
376 void AliMUONSegmentationSlat::
377 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
379 // Returns list of neighbours of pad with coordinates iX, iY
381 Int_t i, xListLocal[10], yListLocal[10], iXlocal, iYlocal, islat;
385 GlobalToLocal(iX, iY, islat, iXlocal, iYlocal);
387 Slat(islat)->Neighbours(iXlocal, iYlocal, Nlist, xListLocal, yListLocal);
389 for (i=0; i<*Nlist; i++) LocalToGlobal(islat, xListLocal[i], yListLocal[i], Xlist[i], Ylist[i]);
394 Int_t AliMUONSegmentationSlat::Ix()
396 // Return current pad coordinate ix during stepping
398 ixl=fCurrentSlat->Ix();
399 iyl=fCurrentSlat->Iy();
401 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
404 GlobalToLocal(ix, iy, isc, ixc, iyc);
405 Slat(isc)->GetPadC(ixc,iyc,xc,yc);
410 Int_t AliMUONSegmentationSlat::Iy()
412 // Return current pad coordinate iy during stepping
414 ixl=fCurrentSlat->Ix();
415 iyl=fCurrentSlat->Iy();
416 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
422 // Signal Generation Condition during Stepping
423 Int_t AliMUONSegmentationSlat::SigGenCond(Float_t x, Float_t y, Float_t z)
426 // True if signal generation condition fullfilled
427 Float_t xlocal, ylocal;
429 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
430 return Slat(islat)->SigGenCond(xlocal, ylocal, z);
433 // Initialise signal generation at coord (x,y,z)
434 void AliMUONSegmentationSlat::SigGenInit(Float_t x, Float_t y, Float_t z)
436 // Initialize the signal generation condition
438 Float_t xlocal, ylocal;
441 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
442 Slat(islat)->SigGenInit(xlocal, ylocal, z);
447 void AliMUONSegmentationSlat::Init(Int_t chamber)
450 // Initialize slat modules of quadrant +/+
451 // The other three quadrants are handled through symmetry transformations
453 printf("\n Initialise Segmentation Slat \n");
456 // Initialize Slat modules
460 for (i=0; i<4; i++) ndiv[i]=(*fNDiv)[i];
465 for (i=0; i<15; i++) fSlatX[i]=0.;
467 // Initialize array of slats
468 fSlats = new TObjArray(fNSlats);
469 // Maximum number of strips (pads) in x and y
472 // for each slat in the quadrant (+,+)
473 for (islat=0; islat<fNSlats; islat++) {
474 (*fSlats)[islat] = CreateSlatModule();
476 AliMUONSegmentationSlatModule *slat = Slat(islat);
481 slat->SetPadSize(fDpx, fDpy);
482 // Forward wire pitch
483 slat->SetDAnod(fWireD);
484 // Foward segmentation
485 slat->SetPadDivision(ndiv);
486 slat->SetPcbBoards(fPcb[islat]);
487 // Initialize slat module
489 // y-position of slat module relative to the first (closest to the beam)
490 fYPosition[islat]= fYPosOrigin+islat*(fSlatY-2.*fShift);
493 if (slat->Npx() > fNpx) fNpx=slat->Npx();
495 for (isec=0; isec< 4; isec++)
497 fSlatX[islat]+=40.*fPcb[islat][isec];
501 // Set parent chamber number
502 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
503 fChamber=&(pMUON->Chamber(chamber));
511 void AliMUONSegmentationSlat::SetNPCBperSector(Int_t *npcb)
513 // PCB distribution for station 4 (6 rows with 1+3 segmentation regions)
514 for (Int_t islat=0; islat<fNSlats; islat++){
515 fPcb[islat][0] = *(npcb + 4 * islat);
516 fPcb[islat][1] = *(npcb + 4 * islat + 1);
517 fPcb[islat][2] = *(npcb + 4 * islat + 2);
518 fPcb[islat][3] = *(npcb + 4 * islat + 3);
523 void AliMUONSegmentationSlat::SetSlatXPositions(Float_t *xpos)
525 // Set x-positions of Slats
526 for (Int_t islat=0; islat<fNSlats; islat++) fXPosition[islat]=xpos[islat];
529 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::Slat(Int_t index) const
530 { return ((AliMUONSegmentationSlatModule*) (*fSlats)[index]);}
533 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::
536 // Factory method for slat module
537 return new AliMUONSegmentationSlatModule();
541 void AliMUONSegmentationSlat::Draw(const char* opt) const
543 // Draw method for event display
545 if (!strcmp(opt,"eventdisplay")) {
546 const int kColorMUON1 = kYellow;
547 const int kColorMUON2 = kBlue;
549 // Drawing Routines for example for Event Display
552 char nameChamber[9], nameSlat[9], nameNode[9];
555 // Number of modules per slat
556 for (i=0; i<fNSlats; i++) {
558 for (j=0; j<4; j++) npcb[i]+=fPcb[i][j];
561 TNode* top=gAlice->GetGeometry()->GetNode("alice");
562 sprintf(nameChamber,"C_MUON%d",fId+1);
563 new TBRIK(nameChamber,"Mother","void",340,340,5.);
565 sprintf(nameNode,"MUON%d",100+fId+1);
566 TNode* node = new TNode(nameNode,"Chambernode",nameChamber,0,0,fChamber->Z(),"");
568 node->SetLineColor(kBlack);
569 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
570 (pMUON->Nodes())->Add(node);
574 for (j=0; j<fNSlats; j++)
576 sprintf(nameSlat,"SLAT%d",100*fId+1+j);
577 Float_t dx = 20.*npcb[j];
579 new TBRIK(nameSlat,"Slat Module","void",dx,20.,0.25);
581 color = TMath::Even(j) ? kColorMUON1 : kColorMUON2;
583 sprintf(nameNode,"SLAT%d",100*fId+1+j);
585 new TNode(nameNode,"Slat Module",nameSlat, dx+fXPosition[j],fYPosition[j]+dy,0,"");
586 nodeSlat->SetLineColor(color);
588 sprintf(nameNode,"SLAT%d",100*fId+1+j+fNSlats);
590 new TNode(nameNode,"Slat Module",nameSlat,-dx-fXPosition[j],fYPosition[j]+dy,0,"");
591 nodeSlat->SetLineColor(color);