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