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 #include "AliMUONSegmentationSlat.h"
19 #include "AliMUONSegmentationSlatModule.h"
21 #include "AliMUONChamber.h"
23 #include "TObjArray.h"
28 #include <TGeometry.h>
29 #include <Riostream.h>
31 //___________________________________________
32 ClassImp(AliMUONSegmentationSlat)
34 AliMUONSegmentationSlat::AliMUONSegmentationSlat()
36 // Default constructor
43 AliMUONSegmentationSlat::AliMUONSegmentationSlat(Int_t /*nsec*/)
45 // Non default constructor
47 fNDiv = new TArrayI(4);
52 AliMUONSegmentationSlat::~AliMUONSegmentationSlat(){
53 //PH Delete TObjArrays
64 //-----------------------------------------------------------
65 void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
67 // Sets the pad (strip) size
72 //-----------------------------------------------------------
73 Float_t AliMUONSegmentationSlat::GetAnod(Float_t xhit) const
75 // Returns for a hit position xhit the position of the nearest anode wire
76 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
79 //-----------------------------------------------------------
80 void AliMUONSegmentationSlat::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/, Int_t *Nparallel, Int_t *Offset)
85 //-----------------------------------------------------------
86 void AliMUONSegmentationSlat::GiveTestPoints(Int_t & /*n*/, Float_t */*x*/, Float_t */*y*/) const
88 //-----------------------------------------------------------
89 Float_t AliMUONSegmentationSlat::Distance2AndOffset(Int_t /*iX*/, Int_t /*iY*/, Float_t /*X*/, Float_t /*Y*/, Int_t * /*dummy*/)
93 //-----------------------------------------------------------
94 Float_t AliMUONSegmentationSlat::Dpx(Int_t isec) const
97 // Returns x-pad size for given sector isec
98 // isec = 100*islat+iregion
100 Int_t islat, iregion;
103 return Slat(islat)->Dpx(iregion);
106 Float_t AliMUONSegmentationSlat::Dpy(Int_t /*isec*/) const
109 // Returns y-pad (strip) size for given sector isec
113 void AliMUONSegmentationSlat::SetPadDivision(Int_t ndiv[4])
116 // Defines the pad size perp. to the anode wire (y) for different sectors.
117 // Pad sizes are defined as integral fractions ndiv of a basis pad size
120 for (Int_t i=0; i<4; i++) {
125 void AliMUONSegmentationSlat::GlobalToLocal(
126 Float_t x, Float_t y, Float_t z, Int_t &islat, Float_t &xlocal, Float_t &ylocal)
129 // Perform local to global transformation for space coordinates
136 // Transform According to slat plane z-position: negative side is shifted down
137 // positive side is shifted up
138 // by half the overlap
139 zlocal = z-fChamber->Z();
141 // zlocal = (x>0) ? zlocal-2.*fDz : zlocal+2.*fDz;
142 zlocal = (x>0) ? zlocal+2.*fDz : zlocal-2.*fDz; //Change?
144 // Set the signs for the symmetry transformation and transform to first quadrant
146 Float_t xabs=TMath::Abs(x);
150 for (i=0; i<fNSlats; i+=1) { //Loop on all slats (longuer but more secure)
152 if ((y >= fYPosition[i]-eps) && (y <= fYPosition[i]+fSlatY+eps)) break;
156 // Transform to local coordinate system
159 if (index >= fNSlats || index < 0 ) {
160 islat = -1; xlocal=-1; ylocal = -1; }
162 ylocal = y -fYPosition[index];
163 xlocal = xabs-fXPosition[index];
168 void AliMUONSegmentationSlat::GlobalToLocal(
169 Int_t ix, Int_t iy, Int_t &islat, Int_t &ixlocal, Int_t &iylocal)
172 // Perform global to local transformation for pad coordinates
180 // Find slat number (index) and iylocal
181 for (Int_t i=0; i<fNSlats; i++) {
182 iytemp-=Slat(i)->Npy();
185 if (iytemp <= 0) break;
190 ixlocal=TMath::Abs(ix);
194 void AliMUONSegmentationSlat::
195 LocalToGlobal(Int_t islat, Float_t xlocal, Float_t ylocal, Float_t &x, Float_t &y, Float_t &z)
197 // Transform from local to global space coordinates
199 // upper plane (y>0) even slat number is shifted down
200 // upper plane (y>0) odd slat number is shifted up
201 // lower plane (y<0) even slat number is shifted up
202 // lower plane (y<0) odd slat number is shifted down
205 x = (xlocal+fXPosition[islat])*fSym;
206 y=(ylocal+fYPosition[islat]);
208 z = (TMath::Even(islat)) ? fDz : -fDz ; //Change for new referential
209 z = (x>0) ? z+2.*fDz : z-2.*fDz ;
215 void AliMUONSegmentationSlat::LocalToGlobal(
216 Int_t islat, Int_t ixlocal, Int_t iylocal, Int_t &ix, Int_t &iy)
218 // Transform from local to global pad coordinates
224 // Find slat number (index) and iylocal
225 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
232 void AliMUONSegmentationSlat::SetSymmetry(Int_t ix)
234 // Set set signs for symmetry transformation
235 fSym=TMath::Sign(1,ix);
238 void AliMUONSegmentationSlat::SetSymmetry(Float_t x)
240 // Set set signs for symmetry transformation
241 fSym=Int_t (TMath::Sign((Float_t)1.,x));
244 void AliMUONSegmentationSlat::
245 GetPadI(Float_t x, Float_t y, Float_t z, Int_t &ix, Int_t &iy)
247 // Returns pad coordinates for given set of space coordinates
250 Float_t xlocal, ylocal;
252 GlobalToLocal(x,y,z,islat,xlocal,ylocal);
257 Slat(islat)->GetPadI(xlocal, ylocal, ix, iy);
258 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
260 ix=ix*Int_t(TMath::Sign((Float_t)1.,x));
264 void AliMUONSegmentationSlat::
265 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
267 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
269 Int_t islat, ixlocal, iylocal;
271 // Delegation of transforamtion to slat
272 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
273 Slat(islat)->GetPadC(ixlocal, iylocal, x, y);
275 x+=fXPosition[islat];
276 y+=fYPosition[islat];
278 // Symmetry transformation of half planes
279 x=x*TMath::Sign(1,ix);
282 z = (TMath::Even(islat)) ? fDz : -fDz ; //Change for new referential
283 z = (x>0) ? z+2.*fDz : z-2.*fDz ;
287 Int_t AliMUONSegmentationSlat::ISector()
289 // Returns current sector during tracking
292 iregion = fCurrentSlat->ISector();
293 return 100*fSlatIndex+iregion;
296 Int_t AliMUONSegmentationSlat::Sector(Int_t ix, Int_t iy)
298 // Returns sector for pad coordiantes (ix,iy)
299 Int_t ixlocal, iylocal, iregion, islat;
301 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
303 iregion = Slat(islat)->Sector(ixlocal, iylocal);
304 return 100*islat+iregion;
308 void AliMUONSegmentationSlat::SetPad(Int_t ix, Int_t iy)
311 // Sets virtual pad coordinates, needed for evaluating pad response
312 // outside the tracking program
313 Int_t islat, ixlocal, iylocal;
317 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
319 fCurrentSlat=Slat(islat);
320 fCurrentSlat->SetPad(ixlocal, iylocal);
323 void AliMUONSegmentationSlat::SetHit(Float_t xhit, Float_t yhit, Float_t zhit)
325 // Sets current hit coordinates
327 Float_t xlocal, ylocal;
332 GlobalToLocal(xhit,yhit,zhit,islat,xlocal,ylocal);
334 if (islat < 0) printf("\n SetHit: %d", islat);
336 fCurrentSlat=Slat(islat);
337 fCurrentSlat->SetHit(xlocal, ylocal);
341 void AliMUONSegmentationSlat::
342 FirstPad(Float_t xhit, Float_t yhit, Float_t zhit, Float_t dx, Float_t dy)
344 // Initialises iteration over pads for charge distribution algorithm
349 Float_t xlocal, ylocal;
350 GlobalToLocal(xhit, yhit, zhit, islat, xlocal, ylocal);
353 fCurrentSlat=Slat(islat);
354 fCurrentSlat->FirstPad(xlocal, ylocal, dx, dy);
360 void AliMUONSegmentationSlat::NextPad()
362 // Stepper for the iteration over pads
364 fCurrentSlat->NextPad();
368 Int_t AliMUONSegmentationSlat::MorePads()
369 // Stopping condition for the iterator over pads
371 // Are there more pads in the integration region
373 return fCurrentSlat->MorePads();
376 void AliMUONSegmentationSlat::
377 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
379 // Returns integration limits for current pad
382 fCurrentSlat->IntegrationLimits(x1, x2, y1, y2);
386 void AliMUONSegmentationSlat::
387 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
389 // Returns list of neighbours of pad with coordinates iX, iY
391 Int_t i, xListLocal[10], yListLocal[10], iXlocal, iYlocal, islat;
395 GlobalToLocal(iX, iY, islat, iXlocal, iYlocal);
397 Slat(islat)->Neighbours(iXlocal, iYlocal, Nlist, xListLocal, yListLocal);
399 for (i=0; i<*Nlist; i++) LocalToGlobal(islat, xListLocal[i], yListLocal[i], Xlist[i], Ylist[i]);
404 Int_t AliMUONSegmentationSlat::Ix()
406 // Return current pad coordinate ix during stepping
408 ixl=fCurrentSlat->Ix();
409 iyl=fCurrentSlat->Iy();
411 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
414 GlobalToLocal(ix, iy, isc, ixc, iyc);
415 Slat(isc)->GetPadC(ixc,iyc,xc,yc);
420 Int_t AliMUONSegmentationSlat::Iy()
422 // Return current pad coordinate iy during stepping
424 ixl=fCurrentSlat->Ix();
425 iyl=fCurrentSlat->Iy();
426 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
432 // Signal Generation Condition during Stepping
433 Int_t AliMUONSegmentationSlat::SigGenCond(Float_t x, Float_t y, Float_t z)
436 // True if signal generation condition fullfilled
437 Float_t xlocal, ylocal;
439 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
440 return Slat(islat)->SigGenCond(xlocal, ylocal, z);
443 // Initialise signal generation at coord (x,y,z)
444 void AliMUONSegmentationSlat::SigGenInit(Float_t x, Float_t y, Float_t z)
446 // Initialize the signal generation condition
448 Float_t xlocal, ylocal;
451 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
452 Slat(islat)->SigGenInit(xlocal, ylocal, z);
457 void AliMUONSegmentationSlat::Init(Int_t chamber)
460 // Initialize slat modules of quadrant +/+
461 // The other three quadrants are handled through symmetry transformations
463 //printf("\n Initialise Segmentation Slat \n");
466 // Initialize Slat modules
470 for (i=0; i<4; i++) ndiv[i]=(*fNDiv)[i];
475 for (i=0; i<15; i++) fSlatX[i]=0.;
477 // Initialize array of slats
478 fSlats = new TObjArray(fNSlats);
479 // Maximum number of strips (pads) in x and y
482 // for each slat in the quadrant (+,+)
483 for (islat=0; islat<fNSlats; islat++) {
484 fSlats->AddAt(CreateSlatModule(),islat);
486 AliMUONSegmentationSlatModule *slat = Slat(islat);
491 slat->SetPadSize(fDpx, fDpy);
492 // Forward wire pitch
493 slat->SetDAnod(fWireD);
494 // Foward segmentation
495 slat->SetPadDivision(ndiv);
496 slat->SetPcbBoards(fPcb[islat]);
497 // Initialize slat module
499 // y-position of slat module relative to the first (closest to the beam)
500 fYPosition[islat]= fYPosOrigin+islat*(fSlatY-2.*fShift);
503 if (slat->Npx() > fNpx) fNpx=slat->Npx();
505 for (isec=0; isec< 4; isec++)
507 fSlatX[islat]+=40.*fPcb[islat][isec];
511 // Set parent chamber number
512 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
513 fChamber=&(pMUON->Chamber(chamber));
521 void AliMUONSegmentationSlat::SetNPCBperSector(Int_t *npcb)
523 // PCB distribution for station 4 (6 rows with 1+3 segmentation regions)
524 for (Int_t islat=0; islat<fNSlats; islat++){
525 fPcb[islat][0] = *(npcb + 4 * islat);
526 fPcb[islat][1] = *(npcb + 4 * islat + 1);
527 fPcb[islat][2] = *(npcb + 4 * islat + 2);
528 fPcb[islat][3] = *(npcb + 4 * islat + 3);
533 void AliMUONSegmentationSlat::SetSlatXPositions(Float_t *xpos)
535 // Set x-positions of Slats
536 for (Int_t islat=0; islat<fNSlats; islat++) fXPosition[islat]=xpos[islat];
539 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::Slat(Int_t index) const
540 //PH { return ((AliMUONSegmentationSlatModule*) (*fSlats)[index]);}
541 { return ((AliMUONSegmentationSlatModule*) fSlats->At(index));}
544 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::
547 // Factory method for slat module
548 return new AliMUONSegmentationSlatModule(4);
552 void AliMUONSegmentationSlat::Draw(const char* opt) const
554 // Draw method for event display
556 if (!strcmp(opt,"eventdisplay")) {
557 const int kColorMUON1 = kYellow;
558 const int kColorMUON2 = kBlue;
560 // Drawing Routines for example for Event Display
563 char nameChamber[9], nameSlat[9], nameNode[9];
566 // Number of modules per slat
567 for (i=0; i<fNSlats; i++) {
569 for (j=0; j<4; j++) npcb[i]+=fPcb[i][j];
572 TNode* top=gAlice->GetGeometry()->GetNode("alice");
573 sprintf(nameChamber,"C_MUON%d",fId+1);
574 new TBRIK(nameChamber,"Mother","void",340,340,5.);
576 sprintf(nameNode,"MUON%d",100+fId+1);
577 TNode* node = new TNode(nameNode,"Chambernode",nameChamber,0,0,fChamber->Z(),"");
579 node->SetLineColor(kBlack);
580 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
581 (pMUON->Nodes())->Add(node);
585 for (j=0; j<fNSlats; j++)
587 sprintf(nameSlat,"SLAT%d",100*fId+1+j);
588 Float_t dx = 20.*npcb[j];
590 new TBRIK(nameSlat,"Slat Module","void",dx,20.,0.25);
592 color = TMath::Even(j) ? kColorMUON1 : kColorMUON2;
594 sprintf(nameNode,"SLAT%d",100*fId+1+j);
596 new TNode(nameNode,"Slat Module",nameSlat, dx+fXPosition[j],fYPosition[j]+dy,0,"");
597 nodeSlat->SetLineColor(color);
599 sprintf(nameNode,"SLAT%d",100*fId+1+j+fNSlats);
601 new TNode(nameNode,"Slat Module",nameSlat,-dx-fXPosition[j],fYPosition[j]+dy,0,"");
602 nodeSlat->SetLineColor(color);