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