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.14 2001/08/30 09:52:12 hristov
19 The operator[] is replaced by At() or AddAt() in case of TObjArray.
21 Revision 1.13 2001/07/20 10:03:14 morsch
22 Changes needed to work with Root 3.01 (substitute lhs [] operator). (Jiri Chudoba)
24 Revision 1.12 2001/05/16 14:57:17 alibrary
25 New files for folders and Stack
27 Revision 1.11 2001/01/26 21:25:48 morsch
28 Empty default constructors and.
30 Revision 1.10 2001/01/23 18:58:19 hristov
31 Initialisation of some pointers
33 Revision 1.9 2001/01/17 20:53:40 hristov
34 Destructors corrected to avoid memory leaks
36 Revision 1.8 2000/12/21 22:12:41 morsch
37 Clean-up of coding rule violations,
39 Revision 1.7 2000/11/08 13:01:40 morsch
40 Chamber half-planes of stations 3-5 at different z-positions.
42 Revision 1.6 2000/11/06 09:20:43 morsch
43 AliMUON delegates part of BuildGeometry() to AliMUONSegmentation using the
44 Draw() method. This avoids code and parameter replication.
46 Revision 1.5 2000/10/23 13:37:40 morsch
47 Correct z-position of slat planes.
49 Revision 1.4 2000/10/22 16:55:43 morsch
50 Use only x-symmetry in global to local transformations and delegation.
52 Revision 1.3 2000/10/18 11:42:06 morsch
53 - AliMUONRawCluster contains z-position.
54 - Some clean-up of useless print statements during initialisations.
56 Revision 1.2 2000/10/09 14:06:18 morsch
57 Some type cast problems of type (TMath::Sign((Float_t)1.,x)) corrected (P.H.)
59 Revision 1.1 2000/10/06 09:00:47 morsch
60 Segmentation class for chambers built out of slats.
64 #include "AliMUONSegmentationSlat.h"
65 #include "AliMUONSegmentationSlatModule.h"
67 #include "AliMUONChamber.h"
69 #include "TObjArray.h"
74 #include <TGeometry.h>
77 //___________________________________________
78 ClassImp(AliMUONSegmentationSlat)
80 AliMUONSegmentationSlat::AliMUONSegmentationSlat()
82 // Default constructor
89 AliMUONSegmentationSlat::AliMUONSegmentationSlat(Int_t nsec)
91 // Non default constructor
93 fNDiv = new TArrayI(4);
98 AliMUONSegmentationSlat::~AliMUONSegmentationSlat(){
99 //PH Delete TObjArrays
111 void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
113 // Sets the pad (strip) size
119 Float_t AliMUONSegmentationSlat::GetAnod(Float_t xhit) const
121 // Returns for a hit position xhit the position of the nearest anode wire
122 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
126 Float_t AliMUONSegmentationSlat::Dpx(Int_t isec) const
129 // Returns x-pad size for given sector isec
130 // isec = 100*islat+iregion
132 Int_t islat, iregion;
135 return Slat(islat)->Dpx(iregion);
138 Float_t AliMUONSegmentationSlat::Dpy(Int_t isec) const
141 // Returns y-pad (strip) size for given sector isec
145 void AliMUONSegmentationSlat::SetPadDivision(Int_t ndiv[4])
148 // Defines the pad size perp. to the anode wire (y) for different sectors.
149 // Pad sizes are defined as integral fractions ndiv of a basis pad size
152 for (Int_t i=0; i<4; i++) {
157 void AliMUONSegmentationSlat::GlobalToLocal(
158 Float_t x, Float_t y, Float_t z, Int_t &islat, Float_t &xlocal, Float_t &ylocal)
161 // Perform local to global transformation for space coordinates
166 // Transform According to slat plane z-position: negative side is shifted down
167 // positive side is shifted up
168 // by half the overlap
169 zlocal = z-fChamber->Z();
170 zlocal = (x>0) ? zlocal-2.*fDz : zlocal+2.*fDz;
171 // Set the signs for the symmetry transformation and transform to first quadrant
173 Float_t xabs=TMath::Abs(x);
175 Int_t ifirst = (zlocal < Float_t(0))? 0:1;
178 for (i=ifirst; i<fNSlats; i+=2) {
180 if ((y >= fYPosition[i]) && (y < fYPosition[i]+fSlatY)) break;
184 // Transform to local coordinate system
187 ylocal = y -fYPosition[index];
188 xlocal = xabs-fXPosition[index];
190 if (i >= fNSlats) {islat = -1; x=-1; y = -1;}
193 void AliMUONSegmentationSlat::GlobalToLocal(
194 Int_t ix, Int_t iy, Int_t &islat, Int_t &ixlocal, Int_t &iylocal)
197 // Perform global to local transformation for pad coordinates
205 // Find slat number (index) and iylocal
206 for (Int_t i=0; i<fNSlats; i++) {
207 iytemp-=Slat(i)->Npy();
210 if (iytemp <= 0) break;
215 ixlocal=TMath::Abs(ix);
219 void AliMUONSegmentationSlat::
220 LocalToGlobal(Int_t islat, Float_t xlocal, Float_t ylocal, Float_t &x, Float_t &y, Float_t &z)
222 // Transform from local to global space coordinates
224 // upper plane (y>0) even slat number is shifted down
225 // upper plane (y>0) odd slat number is shifted up
226 // lower plane (y<0) even slat number is shifted up
227 // lower plane (y<0) odd slat number is shifted down
230 x = (xlocal+fXPosition[islat])*fSym;
231 y=(ylocal+fYPosition[islat]);
233 z = (TMath::Even(islat)) ? -fDz : fDz ;
234 z = (x>0) ? z+2.*fDz : z-2.*fDz ;
240 void AliMUONSegmentationSlat::LocalToGlobal(
241 Int_t islat, Int_t ixlocal, Int_t iylocal, Int_t &ix, Int_t &iy)
243 // Transform from local to global pad coordinates
249 // Find slat number (index) and iylocal
250 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
257 void AliMUONSegmentationSlat::SetSymmetry(Int_t ix)
259 // Set set signs for symmetry transformation
260 fSym=TMath::Sign(1,ix);
263 void AliMUONSegmentationSlat::SetSymmetry(Float_t x)
265 // Set set signs for symmetry transformation
266 fSym=Int_t (TMath::Sign((Float_t)1.,x));
269 void AliMUONSegmentationSlat::
270 GetPadI(Float_t x, Float_t y, Float_t z, Int_t &ix, Int_t &iy)
272 // Returns pad coordinates for given set of space coordinates
275 Float_t xlocal, ylocal;
277 GlobalToLocal(x,y,z,islat,xlocal,ylocal);
282 Slat(islat)->GetPadI(xlocal, ylocal, ix, iy);
283 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
285 ix=ix*Int_t(TMath::Sign((Float_t)1.,x));
289 void AliMUONSegmentationSlat::
290 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
292 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
294 Int_t islat, ixlocal, iylocal;
296 // Delegation of transforamtion to slat
297 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
298 Slat(islat)->GetPadC(ixlocal, iylocal, x, y);
300 x+=fXPosition[islat];
301 y+=fYPosition[islat];
303 // Symmetry transformation of half planes
304 x=x*TMath::Sign(1,ix);
307 z = (TMath::Even(islat)) ? -fDz : fDz ;
308 z = (x>0) ? z+2.*fDz : z-2.*fDz ;
312 Int_t AliMUONSegmentationSlat::ISector()
314 // Returns current sector during tracking
317 iregion = fCurrentSlat->ISector();
318 return 100*fSlatIndex+iregion;
321 Int_t AliMUONSegmentationSlat::Sector(Int_t ix, Int_t iy)
323 // Returns sector for pad coordiantes (ix,iy)
324 Int_t ixlocal, iylocal, iregion, islat;
326 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
328 iregion = Slat(islat)->Sector(ixlocal, iylocal);
329 return 100*islat+iregion;
333 void AliMUONSegmentationSlat::SetPad(Int_t ix, Int_t iy)
336 // Sets virtual pad coordinates, needed for evaluating pad response
337 // outside the tracking program
338 Int_t islat, ixlocal, iylocal;
342 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
344 fCurrentSlat=Slat(islat);
345 fCurrentSlat->SetPad(ixlocal, iylocal);
348 void AliMUONSegmentationSlat::SetHit(Float_t xhit, Float_t yhit, Float_t zhit)
350 // Sets current hit coordinates
352 Float_t xlocal, ylocal;
357 GlobalToLocal(xhit,yhit,zhit,islat,xlocal,ylocal);
359 if (islat < 0) printf("\n SetHit: %d", islat);
361 fCurrentSlat=Slat(islat);
362 fCurrentSlat->SetHit(xlocal, ylocal);
366 void AliMUONSegmentationSlat::
367 FirstPad(Float_t xhit, Float_t yhit, Float_t zhit, Float_t dx, Float_t dy)
369 // Initialises iteration over pads for charge distribution algorithm
375 Float_t xlocal, ylocal;
376 GlobalToLocal(xhit, yhit, zhit, islat, xlocal, ylocal);
378 fCurrentSlat=Slat(islat);
379 fCurrentSlat->FirstPad(xlocal, ylocal, dx, dy);
384 void AliMUONSegmentationSlat::NextPad()
386 // Stepper for the iteration over pads
388 fCurrentSlat->NextPad();
392 Int_t AliMUONSegmentationSlat::MorePads()
393 // Stopping condition for the iterator over pads
395 // Are there more pads in the integration region
397 return fCurrentSlat->MorePads();
400 void AliMUONSegmentationSlat::
401 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
403 // Returns integration limits for current pad
406 fCurrentSlat->IntegrationLimits(x1, x2, y1, y2);
410 void AliMUONSegmentationSlat::
411 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
413 // Returns list of neighbours of pad with coordinates iX, iY
415 Int_t i, xListLocal[10], yListLocal[10], iXlocal, iYlocal, islat;
419 GlobalToLocal(iX, iY, islat, iXlocal, iYlocal);
421 Slat(islat)->Neighbours(iXlocal, iYlocal, Nlist, xListLocal, yListLocal);
423 for (i=0; i<*Nlist; i++) LocalToGlobal(islat, xListLocal[i], yListLocal[i], Xlist[i], Ylist[i]);
428 Int_t AliMUONSegmentationSlat::Ix()
430 // Return current pad coordinate ix during stepping
432 ixl=fCurrentSlat->Ix();
433 iyl=fCurrentSlat->Iy();
435 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
438 GlobalToLocal(ix, iy, isc, ixc, iyc);
439 Slat(isc)->GetPadC(ixc,iyc,xc,yc);
444 Int_t AliMUONSegmentationSlat::Iy()
446 // Return current pad coordinate iy during stepping
448 ixl=fCurrentSlat->Ix();
449 iyl=fCurrentSlat->Iy();
450 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
456 // Signal Generation Condition during Stepping
457 Int_t AliMUONSegmentationSlat::SigGenCond(Float_t x, Float_t y, Float_t z)
460 // True if signal generation condition fullfilled
461 Float_t xlocal, ylocal;
463 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
464 return Slat(islat)->SigGenCond(xlocal, ylocal, z);
467 // Initialise signal generation at coord (x,y,z)
468 void AliMUONSegmentationSlat::SigGenInit(Float_t x, Float_t y, Float_t z)
470 // Initialize the signal generation condition
472 Float_t xlocal, ylocal;
475 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
476 Slat(islat)->SigGenInit(xlocal, ylocal, z);
481 void AliMUONSegmentationSlat::Init(Int_t chamber)
484 // Initialize slat modules of quadrant +/+
485 // The other three quadrants are handled through symmetry transformations
487 //printf("\n Initialise Segmentation Slat \n");
490 // Initialize Slat modules
494 for (i=0; i<4; i++) ndiv[i]=(*fNDiv)[i];
499 for (i=0; i<15; i++) fSlatX[i]=0.;
501 // Initialize array of slats
502 fSlats = new TObjArray(fNSlats);
503 // Maximum number of strips (pads) in x and y
506 // for each slat in the quadrant (+,+)
507 for (islat=0; islat<fNSlats; islat++) {
508 fSlats->AddAt(CreateSlatModule(),islat);
510 AliMUONSegmentationSlatModule *slat = Slat(islat);
515 slat->SetPadSize(fDpx, fDpy);
516 // Forward wire pitch
517 slat->SetDAnod(fWireD);
518 // Foward segmentation
519 slat->SetPadDivision(ndiv);
520 slat->SetPcbBoards(fPcb[islat]);
521 // Initialize slat module
523 // y-position of slat module relative to the first (closest to the beam)
524 fYPosition[islat]= fYPosOrigin+islat*(fSlatY-2.*fShift);
527 if (slat->Npx() > fNpx) fNpx=slat->Npx();
529 for (isec=0; isec< 4; isec++)
531 fSlatX[islat]+=40.*fPcb[islat][isec];
535 // Set parent chamber number
536 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
537 fChamber=&(pMUON->Chamber(chamber));
545 void AliMUONSegmentationSlat::SetNPCBperSector(Int_t *npcb)
547 // PCB distribution for station 4 (6 rows with 1+3 segmentation regions)
548 for (Int_t islat=0; islat<fNSlats; islat++){
549 fPcb[islat][0] = *(npcb + 4 * islat);
550 fPcb[islat][1] = *(npcb + 4 * islat + 1);
551 fPcb[islat][2] = *(npcb + 4 * islat + 2);
552 fPcb[islat][3] = *(npcb + 4 * islat + 3);
557 void AliMUONSegmentationSlat::SetSlatXPositions(Float_t *xpos)
559 // Set x-positions of Slats
560 for (Int_t islat=0; islat<fNSlats; islat++) fXPosition[islat]=xpos[islat];
563 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::Slat(Int_t index) const
564 //PH { return ((AliMUONSegmentationSlatModule*) (*fSlats)[index]);}
565 { return ((AliMUONSegmentationSlatModule*) fSlats->At(index));}
568 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::
571 // Factory method for slat module
572 return new AliMUONSegmentationSlatModule(4);
576 void AliMUONSegmentationSlat::Draw(const char* opt) const
578 // Draw method for event display
580 if (!strcmp(opt,"eventdisplay")) {
581 const int kColorMUON1 = kYellow;
582 const int kColorMUON2 = kBlue;
584 // Drawing Routines for example for Event Display
587 char nameChamber[9], nameSlat[9], nameNode[9];
590 // Number of modules per slat
591 for (i=0; i<fNSlats; i++) {
593 for (j=0; j<4; j++) npcb[i]+=fPcb[i][j];
596 TNode* top=gAlice->GetGeometry()->GetNode("alice");
597 sprintf(nameChamber,"C_MUON%d",fId+1);
598 new TBRIK(nameChamber,"Mother","void",340,340,5.);
600 sprintf(nameNode,"MUON%d",100+fId+1);
601 TNode* node = new TNode(nameNode,"Chambernode",nameChamber,0,0,fChamber->Z(),"");
603 node->SetLineColor(kBlack);
604 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
605 (pMUON->Nodes())->Add(node);
609 for (j=0; j<fNSlats; j++)
611 sprintf(nameSlat,"SLAT%d",100*fId+1+j);
612 Float_t dx = 20.*npcb[j];
614 new TBRIK(nameSlat,"Slat Module","void",dx,20.,0.25);
616 color = TMath::Even(j) ? kColorMUON1 : kColorMUON2;
618 sprintf(nameNode,"SLAT%d",100*fId+1+j);
620 new TNode(nameNode,"Slat Module",nameSlat, dx+fXPosition[j],fYPosition[j]+dy,0,"");
621 nodeSlat->SetLineColor(color);
623 sprintf(nameNode,"SLAT%d",100*fId+1+j+fNSlats);
625 new TNode(nameNode,"Slat Module",nameSlat,-dx-fXPosition[j],fYPosition[j]+dy,0,"");
626 nodeSlat->SetLineColor(color);