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