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