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 **************************************************************************/
19 #include <TObjArray.h>
23 #include <TGeometry.h>
25 #include "AliMUONSegmentationSlat.h"
26 #include "AliMUONSegmentationSlatModule.h"
28 #include "AliMUONChamber.h"
30 #include "AliMUONConstants.h"
32 //___________________________________________
33 ClassImp(AliMUONSegmentationSlat)
35 AliMUONSegmentationSlat::AliMUONSegmentationSlat()
38 // Default constructor
45 AliMUONSegmentationSlat::AliMUONSegmentationSlat(Int_t /*nsec*/)
48 // Non default constructor
50 fNDiv = new TArrayI(4);
55 AliMUONSegmentationSlat::AliMUONSegmentationSlat(const AliMUONSegmentationSlat& rhs)
56 : AliSegmentation(rhs)
58 // Protected copy constructor
60 AliFatal("Not implemented.");
63 AliMUONSegmentationSlat::~AliMUONSegmentationSlat(){
64 //PH Delete TObjArrays
76 //----------------------------------------------------------------------
77 AliMUONSegmentationSlat&
78 AliMUONSegmentationSlat::operator=(const AliMUONSegmentationSlat& rhs)
80 // Protected assignement operator
82 if (this == &rhs) return *this;
84 AliFatal("Not implemented.");
89 //-----------------------------------------------------------
90 void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
92 // Sets the pad (strip) size
98 //-----------------------------------------------------------
99 Float_t AliMUONSegmentationSlat::GetAnod(Float_t xhit) const
101 // Returns for a hit position xhit the position of the nearest anode wire
102 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
106 //-----------------------------------------------------------
107 void AliMUONSegmentationSlat::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/, Int_t *Nparallel, Int_t *Offset)
112 //-----------------------------------------------------------
113 void AliMUONSegmentationSlat::GiveTestPoints(Int_t & /*n*/, Float_t */*x*/, Float_t */*y*/) const
116 //-----------------------------------------------------------
117 Float_t AliMUONSegmentationSlat::Distance2AndOffset(Int_t /*iX*/, Int_t /*iY*/, Float_t /*X*/, Float_t /*Y*/, Int_t * /*dummy*/)
122 //-----------------------------------------------------------
123 Float_t AliMUONSegmentationSlat::Dpx(Int_t isec) const
126 // Returns x-pad size for given sector isec
127 // isec = 100*islat+iregion
129 Int_t islat, iregion;
132 return Slat(islat)->Dpx(iregion);
135 Float_t AliMUONSegmentationSlat::Dpy(Int_t /*isec*/) const
138 // Returns y-pad (strip) size for given sector isec
142 void AliMUONSegmentationSlat::SetPadDivision(Int_t ndiv[4])
145 // Defines the pad size perp. to the anode wire (y) for different sectors.
146 // Pad sizes are defined as integral fractions ndiv of a basis pad size
149 for (Int_t i = 0; i < 4; i++) {
150 (*fNDiv)[i] = ndiv[i];
154 void AliMUONSegmentationSlat::GlobalToLocal(
155 Float_t x, Float_t y, Float_t z, Int_t &islat, Float_t &xlocal, Float_t &ylocal)
158 // Perform local to global transformation for space coordinates
165 // Transform According to slat plane z-position: negative side is shifted down
166 // positive side is shifted up
167 // by half the overlap
168 zlocal = z-fChamber->Z();
170 // zlocal = (x>0) ? zlocal-2.*fDz : zlocal+2.*fDz;
171 // zlocal = (x>0) ? zlocal+2.*fDz : zlocal-2.*fDz; //Change?
176 // Set the signs for the symmetry transformation and transform to first quadrant
178 Float_t xabs = TMath::Abs(x);
182 for (i = 0; i < fNSlats; i++) { //Loop on all slats (longuer but more secure)
184 if ((y >= fYPosition[i]-eps) && (y <= fYPosition[i]+fSlatY+eps)) break;
188 // Transform to local coordinate system
191 if (index >= fNSlats || index < 0 ) {
197 xlocal = xabs - fXPosition[index];
198 ylocal = y - fYPosition[index];
201 //_________________________________________________
202 void AliMUONSegmentationSlat::GlobalToLocal(
203 Int_t ix, Int_t iy, Int_t &islat, Int_t &ixlocal, Int_t &iylocal) const
206 // Perform global to local transformation for pad coordinates
214 // Find slat number (index) and iylocal
215 for (Int_t i=0; i<fNSlats; i++) {
216 iytemp-=Slat(i)->Npy();
218 if (iytemp <= 0) break;
222 ixlocal=TMath::Abs(ix);
226 //_________________________________________________
227 void AliMUONSegmentationSlat::
228 LocalToGlobal(Int_t islat, Float_t xlocal, Float_t ylocal, Float_t &x, Float_t &y, Float_t &z) const
230 // Transform from local to global space coordinates
232 // upper plane (y>0) even slat number is shifted down
233 // upper plane (y>0) odd slat number is shifted up
234 // lower plane (y<0) even slat number is shifted up
235 // lower plane (y<0) odd slat number is shifted down
238 x = (xlocal + fXPosition[islat])*fSym;
239 y = (ylocal + fYPosition[islat]);
241 // z = (TMath::Even(islat)) ? fDz : -fDz ; //Change for new referential
242 // z = (x>0) ? z+2.*fDz : z-2.*fDz ;
246 z = (TMath::Even(islat)) ? -fDzSlat : fDzSlat ; //Change for new referential
247 z = (x>0) ? -z + fDzCh : z - fDzCh;
252 //_________________________________________________
253 void AliMUONSegmentationSlat::LocalToGlobal (
254 Int_t islat, Int_t ixlocal, Int_t iylocal, Int_t &ix, Int_t &iy) const
256 // Transform from local to global pad coordinates
262 // Find slat number (index) and iylocal
263 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
269 //_________________________________________________
270 void AliMUONSegmentationSlat::SetSymmetry(Int_t ix)
272 // Set set signs for symmetry transformation
273 fSym = TMath::Sign(1,ix);
276 //_________________________________________________
277 void AliMUONSegmentationSlat::SetSymmetry(Float_t x)
279 // Set set signs for symmetry transformation
280 fSym = Int_t (TMath::Sign((Float_t)1.,x));
283 //_________________________________________________
284 void AliMUONSegmentationSlat::
285 GetPadI(Float_t x, Float_t y, Float_t z, Int_t &ix, Int_t &iy)
287 // Returns pad coordinates for given set of space coordinates
290 Float_t xlocal, ylocal;
292 GlobalToLocal(x,y,z,islat,xlocal,ylocal);
298 Slat(islat)->GetPadI(xlocal, ylocal, ix, iy);
299 for (i = 0; i < islat; i++) iy += Slat(islat)->Npy();
301 ix = ix*Int_t(TMath::Sign((Float_t)1.,x));
304 //_________________________________________________
305 void AliMUONSegmentationSlat::
306 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
308 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
310 Int_t islat, ixlocal, iylocal;
312 // Delegation of transforamtion to slat
313 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
314 Slat(islat)->GetPadC(ixlocal, iylocal, x, y);
316 x += fXPosition[islat];
317 y += fYPosition[islat];
319 // Symmetry transformation of half planes
320 x = x * TMath::Sign(1,ix);
323 z = (TMath::Even(islat)) ? -fDzSlat : fDzSlat ; //Change for new referential
324 z = (x>0) ? -z + fDzCh : z - fDzCh;
328 //_________________________________________________
329 Int_t AliMUONSegmentationSlat::ISector()
331 // Returns current sector during tracking
334 iregion = fCurrentSlat->ISector();
335 return 100*fSlatIndex+iregion;
338 //_________________________________________________
339 Int_t AliMUONSegmentationSlat::Sector(Int_t ix, Int_t iy)
341 // Returns sector for pad coordiantes (ix,iy)
342 Int_t ixlocal, iylocal, iregion, islat;
344 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
346 iregion = Slat(islat)->Sector(ixlocal, iylocal);
347 return 100*islat+iregion;
350 //_________________________________________________
351 void AliMUONSegmentationSlat::SetPad(Int_t ix, Int_t iy)
354 // Sets virtual pad coordinates, needed for evaluating pad response
355 // outside the tracking program
356 Int_t islat, ixlocal, iylocal;
360 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
362 fCurrentSlat=Slat(islat);
363 fCurrentSlat->SetPad(ixlocal, iylocal);
366 //_________________________________________________
367 void AliMUONSegmentationSlat::SetHit(Float_t xhit, Float_t yhit, Float_t zhit)
369 // Sets current hit coordinates
371 Float_t xlocal, ylocal;
376 GlobalToLocal(xhit,yhit,zhit,islat,xlocal,ylocal);
378 if (islat < 0) printf("\n SetHit: %d", islat);
380 fCurrentSlat=Slat(islat);
381 fCurrentSlat->SetHit(xlocal, ylocal);
384 //_________________________________________________
385 void AliMUONSegmentationSlat::
386 FirstPad(Float_t xhit, Float_t yhit, Float_t zhit, Float_t dx, Float_t dy)
388 // Initialises iteration over pads for charge distribution algorithm
393 Float_t xlocal, ylocal;
394 GlobalToLocal(xhit, yhit, zhit, islat, xlocal, ylocal);
397 fCurrentSlat=Slat(islat);
398 fCurrentSlat->FirstPad(xlocal, ylocal, dx, dy);
403 //_________________________________________________
404 void AliMUONSegmentationSlat::NextPad()
406 // Stepper for the iteration over pads
408 fCurrentSlat->NextPad();
411 //_________________________________________________
412 Int_t AliMUONSegmentationSlat::MorePads()
413 // Stopping condition for the iterator over pads
415 // Are there more pads in the integration region
417 return fCurrentSlat->MorePads();
420 //_________________________________________________
421 void AliMUONSegmentationSlat::
422 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
424 // Returns integration limits for current pad
427 fCurrentSlat->IntegrationLimits(x1, x2, y1, y2);
431 //_________________________________________________
432 void AliMUONSegmentationSlat::
433 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
435 // Returns list of neighbours of pad with coordinates iX, iY
437 Int_t i, xListLocal[10], yListLocal[10], iXlocal, iYlocal, islat;
441 GlobalToLocal(iX, iY, islat, iXlocal, iYlocal);
443 Slat(islat)->Neighbours(iXlocal, iYlocal, Nlist, xListLocal, yListLocal);
445 for (i=0; i<*Nlist; i++) LocalToGlobal(islat, xListLocal[i], yListLocal[i], Xlist[i], Ylist[i]);
449 //_________________________________________________
450 Int_t AliMUONSegmentationSlat::Ix()
452 // Return current pad coordinate ix during stepping
454 ixl=fCurrentSlat->Ix();
455 iyl=fCurrentSlat->Iy();
456 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
460 GlobalToLocal(ix, iy, isc, ixc, iyc);
462 Slat(isc)->GetPadC(ixc,iyc,xc,yc);
466 //_________________________________________________
467 Int_t AliMUONSegmentationSlat::Iy()
469 // Return current pad coordinate iy during stepping
471 ixl=fCurrentSlat->Ix();
472 iyl=fCurrentSlat->Iy();
473 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
477 //_________________________________________________
478 Int_t AliMUONSegmentationSlat::SigGenCond(Float_t x, Float_t y, Float_t z)
480 // Signal Generation Condition during Stepping
482 // True if signal generation condition fullfilled
483 Float_t xlocal, ylocal;
485 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
486 return Slat(islat)->SigGenCond(xlocal, ylocal, z);
489 //_________________________________________________
490 void AliMUONSegmentationSlat::SigGenInit(Float_t x, Float_t y, Float_t z)
493 // Initialize the signal generation condition
495 Float_t xlocal, ylocal;
498 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
499 Slat(islat)->SigGenInit(xlocal, ylocal, z);
502 //_________________________________________________
503 void AliMUONSegmentationSlat::Init(Int_t chamber)
506 // Initialize slat modules of quadrant +/+
507 // The other three quadrants are handled through symmetry transformations
509 //printf("\n Initialise Segmentation Slat \n");
512 // Initialize Slat modules
516 for (i=0; i<4; i++) ndiv[i]=(*fNDiv)[i];
520 for (i=0; i<15; i++) fSlatX[i]=0.;
522 // shifts in z direction
523 fDzSlat = AliMUONConstants::DzSlat();
524 fDzCh = AliMUONConstants::DzCh();
526 // Initialize array of slats
527 fSlats = new TObjArray(fNSlats);
528 // Maximum number of strips (pads) in x and y
531 // for each slat in the quadrant (+,+)
532 for (islat=0; islat<fNSlats; islat++) {
533 fSlats->AddAt(CreateSlatModule(),islat);
535 AliMUONSegmentationSlatModule *slat = Slat(islat);
540 slat->SetPadSize(fDpx, fDpy);
541 // Forward wire pitch
542 slat->SetDAnod(fWireD);
543 // Foward segmentation
544 slat->SetPadDivision(ndiv);
545 slat->SetPcbBoards(fPcb[islat]);
546 // Initialize slat module
548 // y-position of slat module relative to the first (closest to the beam)
549 // fYPosition[islat]= fYPosOrigin+islat*(fSlatY-2.*fShift);
552 if (slat->Npx() > fNpx) fNpx=slat->Npx();
554 for (isec=0; isec< 4; isec++)
556 fSlatX[islat]+=40.*fPcb[islat][isec];
560 // Set parent chamber number
561 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
562 fChamber=&(pMUON->Chamber(chamber));
566 //_________________________________________________
567 void AliMUONSegmentationSlat::SetNPCBperSector(Int_t *npcb)
569 // PCB distribution for station 4 (6 rows with 1+3 segmentation regions)
570 for (Int_t islat=0; islat<fNSlats; islat++){
571 fPcb[islat][0] = *(npcb + 4 * islat);
572 fPcb[islat][1] = *(npcb + 4 * islat + 1);
573 fPcb[islat][2] = *(npcb + 4 * islat + 2);
574 fPcb[islat][3] = *(npcb + 4 * islat + 3);
578 //_________________________________________________
579 void AliMUONSegmentationSlat::SetSlatXPositions(Float_t *xpos)
581 // Set x-positions of Slats
582 for (Int_t islat=0; islat<fNSlats; islat++) fXPosition[islat]=xpos[islat];
585 //_________________________________________________
586 void AliMUONSegmentationSlat::SetSlatYPositions(Float_t *ypos)
588 // Set y-positions of Slats
589 for (Int_t islat=0; islat<fNSlats; islat++) fYPosition[islat]=ypos[islat];
592 //_________________________________________________
593 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::Slat(Int_t index) const
594 //PH { return ((AliMUONSegmentationSlatModule*) (*fSlats)[index]);}
596 return ((AliMUONSegmentationSlatModule*) fSlats->At(index));
599 //_________________________________________________
600 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::
601 CreateSlatModule() const
603 // Factory method for slat module
604 return new AliMUONSegmentationSlatModule(4);
607 //_________________________________________________
608 void AliMUONSegmentationSlat::Draw(const char* opt)
610 // Draw method for event display
612 if (!strcmp(opt,"eventdisplay")) {
613 const int kColorMUON1 = kYellow;
614 const int kColorMUON2 = kBlue;
616 // Drawing Routines for example for Event Display
619 char nameChamber[9], nameSlat[9], nameNode[9];
622 // Number of modules per slat
623 for (i = 0; i < fNSlats; i++) {
625 for (j = 0; j < 4; j++) npcb[i] += fPcb[i][j];
628 TNode* top=gAlice->GetGeometry()->GetNode("alice");
629 sprintf(nameChamber,"C_MUON%d",fId+1);
630 new TBRIK(nameChamber,"Mother","void",340,340,5.);
632 sprintf(nameNode,"MUON%d",100+fId+1);
633 TNode* node = new TNode(nameNode,"Chambernode",nameChamber,0,0,fChamber->Z(),"");
635 node->SetLineColor(kBlack);
636 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
637 (pMUON->Nodes())->Add(node);
641 for (j = 0; j < fNSlats; j++) {
642 sprintf(nameSlat,"SLAT%d",100*fId+1+j);
643 Float_t dx = 20.*npcb[j];
645 new TBRIK(nameSlat,"Slat Module","void",dx,20.,0.25);
647 color = TMath::Even(j) ? kColorMUON1 : kColorMUON2;
649 sprintf(nameNode,"SLAT%d",100*fId+1+j);
651 new TNode(nameNode,"Slat Module",nameSlat, dx+fXPosition[j],fYPosition[j]+dy,0,"");
652 nodeSlat->SetLineColor(color);
654 sprintf(nameNode,"SLAT%d",100*fId+1+j+fNSlats);
656 new TNode(nameNode,"Slat Module",nameSlat,-dx-fXPosition[j],fYPosition[j]+dy,0,"");
657 nodeSlat->SetLineColor(color);