]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegmentationSlat.cxx
Added protected copy constructors and assignment operators. (I. Hrivnacova)
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationSlat.cxx
CommitLineData
5de7d27f 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
88cb7938 16/* $Id$ */
5de7d27f 17
18#include "AliMUONSegmentationSlat.h"
19#include "AliMUONSegmentationSlatModule.h"
20#include "AliMUON.h"
21#include "AliMUONChamber.h"
22#include "TArrayI.h"
23#include "TObjArray.h"
24#include "AliRun.h"
25#include <TMath.h>
aaf4addd 26#include <TBRIK.h>
27#include <TNode.h>
28#include <TGeometry.h>
70479d0e 29#include <Riostream.h>
5de7d27f 30
31//___________________________________________
32ClassImp(AliMUONSegmentationSlat)
33
34AliMUONSegmentationSlat::AliMUONSegmentationSlat()
11ca64ac 35 : AliSegmentation()
5de7d27f 36{
37// Default constructor
edf34242 38 fChamber = 0;
39 fNDiv = 0;
40 fSlats = 0;
41 fCurrentSlat = 0;
e9e4cdf2 42}
43
6aaf81e6 44AliMUONSegmentationSlat::AliMUONSegmentationSlat(Int_t /*nsec*/)
11ca64ac 45 : AliSegmentation()
e9e4cdf2 46{
47// Non default constructor
5de7d27f 48 fSlats=0;
3f5cf0b3 49 fNDiv = new TArrayI(4);
50 fChamber = 0;
51 fCurrentSlat = 0;
5de7d27f 52}
53
11ca64ac 54AliMUONSegmentationSlat::AliMUONSegmentationSlat(const AliMUONSegmentationSlat& rhs)
55 : AliSegmentation(rhs)
56{
57// Protected copy constructor
58
59 Fatal("AliMUONSegmentationSlatModule", "Not implemented.");
60}
61
c2c0190f 62AliMUONSegmentationSlat::~AliMUONSegmentationSlat(){
63 //PH Delete TObjArrays
64 if (fSlats) {
65 fSlats->Delete();
66 delete fSlats;
67 }
e9e4cdf2 68
69 if (fNDiv) {
70 delete fNDiv;
71 }
72
c2c0190f 73}
11ca64ac 74
75//----------------------------------------------------------------------
76AliMUONSegmentationSlat&
77AliMUONSegmentationSlat::operator=(const AliMUONSegmentationSlat& rhs)
78{
79// Protected assignement operator
80
81 if (this == &rhs) return *this;
82
83 Fatal("operator=", "Not implemented.");
84
85 return *this;
86}
87
88
6aaf81e6 89//-----------------------------------------------------------
5de7d27f 90void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
91{
92// Sets the pad (strip) size
93//
94 fDpx=p1;
95 fDpy=p2;
96}
6aaf81e6 97//-----------------------------------------------------------
5de7d27f 98Float_t AliMUONSegmentationSlat::GetAnod(Float_t xhit) const
99{
100// Returns for a hit position xhit the position of the nearest anode wire
101 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
102 return fWireD*wire;
103}
6aaf81e6 104//-----------------------------------------------------------
105void AliMUONSegmentationSlat::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/, Int_t *Nparallel, Int_t *Offset)
106{
107 *Nparallel=1;
108 *Offset=0;
109}
110//-----------------------------------------------------------
111void AliMUONSegmentationSlat::GiveTestPoints(Int_t & /*n*/, Float_t */*x*/, Float_t */*y*/) const
112{;}
113//-----------------------------------------------------------
114Float_t AliMUONSegmentationSlat::Distance2AndOffset(Int_t /*iX*/, Int_t /*iY*/, Float_t /*X*/, Float_t /*Y*/, Int_t * /*dummy*/)
115{
116 return 0.;
117}
118//-----------------------------------------------------------
5de7d27f 119Float_t AliMUONSegmentationSlat::Dpx(Int_t isec) const
120{
121//
122// Returns x-pad size for given sector isec
123// isec = 100*islat+iregion
124//
125 Int_t islat, iregion;
126 islat = isec/100;
127 iregion = isec%100;
128 return Slat(islat)->Dpx(iregion);
129}
130
6aaf81e6 131Float_t AliMUONSegmentationSlat::Dpy(Int_t /*isec*/) const
5de7d27f 132{
133//
134// Returns y-pad (strip) size for given sector isec
135 return fDpy;
136}
137
138void AliMUONSegmentationSlat::SetPadDivision(Int_t ndiv[4])
139{
140//
141// Defines the pad size perp. to the anode wire (y) for different sectors.
142// Pad sizes are defined as integral fractions ndiv of a basis pad size
143// fDpx
144//
145 for (Int_t i=0; i<4; i++) {
146 (*fNDiv)[i]=ndiv[i];
147 }
148}
149
150void AliMUONSegmentationSlat::GlobalToLocal(
151 Float_t x, Float_t y, Float_t z, Int_t &islat, Float_t &xlocal, Float_t &ylocal)
152{
153//
154// Perform local to global transformation for space coordinates
155//
156 Float_t zlocal;
157 Int_t i;
158 Int_t index=-1;
fa8037e2 159 Float_t eps = 1.e-4;
160
5de7d27f 161// Transform According to slat plane z-position: negative side is shifted down
162// positive side is shifted up
163// by half the overlap
164 zlocal = z-fChamber->Z();
1391e633 165
166// zlocal = (x>0) ? zlocal-2.*fDz : zlocal+2.*fDz;
167 zlocal = (x>0) ? zlocal+2.*fDz : zlocal-2.*fDz; //Change?
168
5de7d27f 169// Set the signs for the symmetry transformation and transform to first quadrant
2b202c2e 170 SetSymmetry(x);
5de7d27f 171 Float_t xabs=TMath::Abs(x);
172
1391e633 173
5de7d27f 174// Find slat number
1391e633 175 for (i=0; i<fNSlats; i+=1) { //Loop on all slats (longuer but more secure)
5de7d27f 176 index=i;
fa8037e2 177 if ((y >= fYPosition[i]-eps) && (y <= fYPosition[i]+fSlatY+eps)) break;
5de7d27f 178 }
179
180//
181// Transform to local coordinate system
182
183
25d71048 184 if (index >= fNSlats || index < 0 ) {
185 islat = -1; xlocal=-1; ylocal = -1; }
186 else {
187 ylocal = y -fYPosition[index];
188 xlocal = xabs-fXPosition[index];
189 islat = index;
190 }
5de7d27f 191}
192
193void AliMUONSegmentationSlat::GlobalToLocal(
194 Int_t ix, Int_t iy, Int_t &islat, Int_t &ixlocal, Int_t &iylocal)
195{
196//
197// Perform global to local transformation for pad coordinates
198//
2b202c2e 199 Int_t iytemp = iy;
200 Int_t index = 0;
5de7d27f 201
202 iylocal = iytemp;
203
204//
205// Find slat number (index) and iylocal
206 for (Int_t i=0; i<fNSlats; i++) {
207 iytemp-=Slat(i)->Npy();
208
209
210 if (iytemp <= 0) break;
211 iylocal = iytemp;
212 index=i+1;
213 }
214
215 ixlocal=TMath::Abs(ix);
216 islat=index;
5de7d27f 217}
218
219void AliMUONSegmentationSlat::
220LocalToGlobal(Int_t islat, Float_t xlocal, Float_t ylocal, Float_t &x, Float_t &y, Float_t &z)
221{
222// Transform from local to global space coordinates
223//
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
228//
229
2b202c2e 230 x = (xlocal+fXPosition[islat])*fSym;
231 y=(ylocal+fYPosition[islat]);
5de7d27f 232
1391e633 233 z = (TMath::Even(islat)) ? fDz : -fDz ; //Change for new referential
e1ad7d45 234 z = (x>0) ? z+2.*fDz : z-2.*fDz ;
235
5de7d27f 236 z+=fChamber->Z();
5de7d27f 237}
238
239
240void AliMUONSegmentationSlat::LocalToGlobal(
241 Int_t islat, Int_t ixlocal, Int_t iylocal, Int_t &ix, Int_t &iy)
242{
243// Transform from local to global pad coordinates
244//
245 Int_t i;
246 iy=iylocal;
247
248//
249// Find slat number (index) and iylocal
250 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
251
2b202c2e 252 ix=ixlocal*fSym;
253 iy=iy;
5de7d27f 254}
255
256
2b202c2e 257void AliMUONSegmentationSlat::SetSymmetry(Int_t ix)
5de7d27f 258{
259// Set set signs for symmetry transformation
2b202c2e 260 fSym=TMath::Sign(1,ix);
5de7d27f 261}
262
2b202c2e 263void AliMUONSegmentationSlat::SetSymmetry(Float_t x)
5de7d27f 264{
265// Set set signs for symmetry transformation
2b202c2e 266 fSym=Int_t (TMath::Sign((Float_t)1.,x));
5de7d27f 267}
268
269void AliMUONSegmentationSlat::
270GetPadI(Float_t x, Float_t y, Float_t z, Int_t &ix, Int_t &iy)
271{
272// Returns pad coordinates for given set of space coordinates
273
274 Int_t islat, i;
275 Float_t xlocal, ylocal;
276
277 GlobalToLocal(x,y,z,islat,xlocal,ylocal);
278 if (islat == -1) {
279 ix=0; iy=0; return;
280 }
281
282 Slat(islat)->GetPadI(xlocal, ylocal, ix, iy);
283 for (i=0; i<islat; i++) iy+=Slat(islat)->Npy();
284
deba22dc 285 ix=ix*Int_t(TMath::Sign((Float_t)1.,x));
5de7d27f 286}
287
2b202c2e 288
5de7d27f 289void AliMUONSegmentationSlat::
290GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
291{
292// Returns real coordinates (x,y) for given pad coordinates (ix,iy)
293//
294 Int_t islat, ixlocal, iylocal;
295//
296// Delegation of transforamtion to slat
297 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
298 Slat(islat)->GetPadC(ixlocal, iylocal, x, y);
299// Slat offset
300 x+=fXPosition[islat];
301 y+=fYPosition[islat];
302
2b202c2e 303// Symmetry transformation of half planes
5de7d27f 304 x=x*TMath::Sign(1,ix);
2b202c2e 305
306// z-position
1391e633 307 z = (TMath::Even(islat)) ? fDz : -fDz ; //Change for new referential
e1ad7d45 308 z = (x>0) ? z+2.*fDz : z-2.*fDz ;
2b202c2e 309 z += fChamber->Z();
5de7d27f 310}
311
312Int_t AliMUONSegmentationSlat::ISector()
313{
314// Returns current sector during tracking
315 Int_t iregion;
316
317 iregion = fCurrentSlat->ISector();
318 return 100*fSlatIndex+iregion;
319}
320
321Int_t AliMUONSegmentationSlat::Sector(Int_t ix, Int_t iy)
322{
de05461e 323// Returns sector for pad coordiantes (ix,iy)
5de7d27f 324 Int_t ixlocal, iylocal, iregion, islat;
325
326 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
327
328 iregion = Slat(islat)->Sector(ixlocal, iylocal);
329 return 100*islat+iregion;
330}
331
332
333void AliMUONSegmentationSlat::SetPad(Int_t ix, Int_t iy)
334{
335 //
336 // Sets virtual pad coordinates, needed for evaluating pad response
337 // outside the tracking program
338 Int_t islat, ixlocal, iylocal;
339
2b202c2e 340 SetSymmetry(ix);
5de7d27f 341
342 GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
343 fSlatIndex=islat;
344 fCurrentSlat=Slat(islat);
345 fCurrentSlat->SetPad(ixlocal, iylocal);
346}
347
348void AliMUONSegmentationSlat::SetHit(Float_t xhit, Float_t yhit, Float_t zhit)
349{ //
350 // Sets current hit coordinates
351
352 Float_t xlocal, ylocal;
353 Int_t islat;
354
355
356
357 GlobalToLocal(xhit,yhit,zhit,islat,xlocal,ylocal);
358 fSlatIndex=islat;
359 if (islat < 0) printf("\n SetHit: %d", islat);
360
361 fCurrentSlat=Slat(islat);
362 fCurrentSlat->SetHit(xlocal, ylocal);
363}
364
365
366void AliMUONSegmentationSlat::
367FirstPad(Float_t xhit, Float_t yhit, Float_t zhit, Float_t dx, Float_t dy)
368{
369// Initialises iteration over pads for charge distribution algorithm
370//
371
372
5de7d27f 373 Int_t islat;
374 Float_t xlocal, ylocal;
375 GlobalToLocal(xhit, yhit, zhit, islat, xlocal, ylocal);
376 fSlatIndex=islat;
25d71048 377 if (islat>-1) {
378 fCurrentSlat=Slat(islat);
379 fCurrentSlat->FirstPad(xlocal, ylocal, dx, dy);
380 }
5de7d27f 381
382}
383
384
385void AliMUONSegmentationSlat::NextPad()
386{
387// Stepper for the iteration over pads
388//
389 fCurrentSlat->NextPad();
390}
391
392
393Int_t AliMUONSegmentationSlat::MorePads()
394// Stopping condition for the iterator over pads
395//
396// Are there more pads in the integration region
397{
398 return fCurrentSlat->MorePads();
399}
400
401void AliMUONSegmentationSlat::
402IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
403{
404// Returns integration limits for current pad
405//
406
407 fCurrentSlat->IntegrationLimits(x1, x2, y1, y2);
408
409}
410
411void AliMUONSegmentationSlat::
412Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
413{
414// Returns list of neighbours of pad with coordinates iX, iY
415
416 Int_t i, xListLocal[10], yListLocal[10], iXlocal, iYlocal, islat;
417
2b202c2e 418 SetSymmetry(iX);
5de7d27f 419
420 GlobalToLocal(iX, iY, islat, iXlocal, iYlocal);
421
422 Slat(islat)->Neighbours(iXlocal, iYlocal, Nlist, xListLocal, yListLocal);
423
424 for (i=0; i<*Nlist; i++) LocalToGlobal(islat, xListLocal[i], yListLocal[i], Xlist[i], Ylist[i]);
425
426}
427
428
429Int_t AliMUONSegmentationSlat::Ix()
430{
431// Return current pad coordinate ix during stepping
432 Int_t ixl,iyl,ix,iy;
433 ixl=fCurrentSlat->Ix();
434 iyl=fCurrentSlat->Iy();
435
436 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
437 Int_t ixc, iyc, isc;
438 Float_t xc, yc;
439 GlobalToLocal(ix, iy, isc, ixc, iyc);
440 Slat(isc)->GetPadC(ixc,iyc,xc,yc);
441 return ix;
442}
443
444
445Int_t AliMUONSegmentationSlat::Iy()
446{
447// Return current pad coordinate iy during stepping
448 Int_t ixl,iyl,ix,iy;
449 ixl=fCurrentSlat->Ix();
450 iyl=fCurrentSlat->Iy();
451 LocalToGlobal(fSlatIndex, ixl, iyl, ix, iy);
452 return iy;
453}
454
455
456
457 // Signal Generation Condition during Stepping
458Int_t AliMUONSegmentationSlat::SigGenCond(Float_t x, Float_t y, Float_t z)
459{
460//
461// True if signal generation condition fullfilled
462 Float_t xlocal, ylocal;
463 Int_t islat;
464 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
465 return Slat(islat)->SigGenCond(xlocal, ylocal, z);
466}
467
468// Initialise signal generation at coord (x,y,z)
469void AliMUONSegmentationSlat::SigGenInit(Float_t x, Float_t y, Float_t z)
470{
471// Initialize the signal generation condition
472//
473 Float_t xlocal, ylocal;
474 Int_t islat;
475
476 GlobalToLocal(x, y, z, islat, xlocal, ylocal);
477 Slat(islat)->SigGenInit(xlocal, ylocal, z);
478}
479
480
481
482void AliMUONSegmentationSlat::Init(Int_t chamber)
483{
484//
485// Initialize slat modules of quadrant +/+
486// The other three quadrants are handled through symmetry transformations
487//
9e1a0ddb 488 //printf("\n Initialise Segmentation Slat \n");
5de7d27f 489//
490
aaf4addd 491// Initialize Slat modules
5de7d27f 492 Int_t islat, i;
493 Int_t ndiv[4];
494// Pad division
495 for (i=0; i<4; i++) ndiv[i]=(*fNDiv)[i];
bf61d9e2 496//
497 fDz=0.813;
5de7d27f 498// Slat height
499 fSlatY=40.;
2b202c2e 500 for (i=0; i<15; i++) fSlatX[i]=0.;
5de7d27f 501
502// Initialize array of slats
503 fSlats = new TObjArray(fNSlats);
504// Maximum number of strips (pads) in x and y
505 fNpy=0;
506 fNpx=0;
507// for each slat in the quadrant (+,+)
508 for (islat=0; islat<fNSlats; islat++) {
cd4df77b 509 fSlats->AddAt(CreateSlatModule(),islat);
5de7d27f 510
511 AliMUONSegmentationSlatModule *slat = Slat(islat);
512 // Configure Slat
513 slat->SetId(islat);
514
515// Foward pad size
516 slat->SetPadSize(fDpx, fDpy);
517// Forward wire pitch
518 slat->SetDAnod(fWireD);
519// Foward segmentation
520 slat->SetPadDivision(ndiv);
521 slat->SetPcbBoards(fPcb[islat]);
522// Initialize slat module
523 slat->Init(chamber);
524// y-position of slat module relative to the first (closest to the beam)
2b202c2e 525 fYPosition[islat]= fYPosOrigin+islat*(fSlatY-2.*fShift);
5de7d27f 526//
527 fNpy+=slat->Npy();
528 if (slat->Npx() > fNpx) fNpx=slat->Npx();
529 Int_t isec;
530 for (isec=0; isec< 4; isec++)
531 {
532 fSlatX[islat]+=40.*fPcb[islat][isec];
533 }
534
535 }
536// Set parent chamber number
537 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
538 fChamber=&(pMUON->Chamber(chamber));
aaf4addd 539 fId=chamber;
5de7d27f 540}
541
542
543
544
545
546void AliMUONSegmentationSlat::SetNPCBperSector(Int_t *npcb)
547{
548 // PCB distribution for station 4 (6 rows with 1+3 segmentation regions)
549 for (Int_t islat=0; islat<fNSlats; islat++){
550 fPcb[islat][0] = *(npcb + 4 * islat);
551 fPcb[islat][1] = *(npcb + 4 * islat + 1);
552 fPcb[islat][2] = *(npcb + 4 * islat + 2);
553 fPcb[islat][3] = *(npcb + 4 * islat + 3);
554 }
555}
556
557
558void AliMUONSegmentationSlat::SetSlatXPositions(Float_t *xpos)
559{
560// Set x-positions of Slats
561 for (Int_t islat=0; islat<fNSlats; islat++) fXPosition[islat]=xpos[islat];
562}
563
564AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::Slat(Int_t index) const
2682e810 565 //PH { return ((AliMUONSegmentationSlatModule*) (*fSlats)[index]);}
566{ return ((AliMUONSegmentationSlatModule*) fSlats->At(index));}
5de7d27f 567
568
569AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::
570CreateSlatModule()
571{
572 // Factory method for slat module
e9e4cdf2 573 return new AliMUONSegmentationSlatModule(4);
5de7d27f 574}
575
576
aaf4addd 577void AliMUONSegmentationSlat::Draw(const char* opt) const
578{
de05461e 579// Draw method for event display
580//
aaf4addd 581 if (!strcmp(opt,"eventdisplay")) {
582 const int kColorMUON1 = kYellow;
583 const int kColorMUON2 = kBlue;
584 //
585 // Drawing Routines for example for Event Display
586 Int_t i,j;
587 Int_t npcb[15];
588 char nameChamber[9], nameSlat[9], nameNode[9];
589
590 //
591 // Number of modules per slat
592 for (i=0; i<fNSlats; i++) {
593 npcb[i]=0;
594 for (j=0; j<4; j++) npcb[i]+=fPcb[i][j];
595 }
596 //
597 TNode* top=gAlice->GetGeometry()->GetNode("alice");
598 sprintf(nameChamber,"C_MUON%d",fId+1);
599 new TBRIK(nameChamber,"Mother","void",340,340,5.);
600 top->cd();
601 sprintf(nameNode,"MUON%d",100+fId+1);
602 TNode* node = new TNode(nameNode,"Chambernode",nameChamber,0,0,fChamber->Z(),"");
603
604 node->SetLineColor(kBlack);
605 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
606 (pMUON->Nodes())->Add(node);
607 TNode* nodeSlat;
608 Int_t color;
609
610 for (j=0; j<fNSlats; j++)
611 {
612 sprintf(nameSlat,"SLAT%d",100*fId+1+j);
613 Float_t dx = 20.*npcb[j];
614 Float_t dy = 20;
615 new TBRIK(nameSlat,"Slat Module","void",dx,20.,0.25);
616 node->cd();
617 color = TMath::Even(j) ? kColorMUON1 : kColorMUON2;
618
619 sprintf(nameNode,"SLAT%d",100*fId+1+j);
620 nodeSlat =
621 new TNode(nameNode,"Slat Module",nameSlat, dx+fXPosition[j],fYPosition[j]+dy,0,"");
622 nodeSlat->SetLineColor(color);
623 node->cd();
624 sprintf(nameNode,"SLAT%d",100*fId+1+j+fNSlats);
625 nodeSlat =
626 new TNode(nameNode,"Slat Module",nameSlat,-dx-fXPosition[j],fYPosition[j]+dy,0,"");
627 nodeSlat->SetLineColor(color);
628 }
629 }
630}
5de7d27f 631
632
633