1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 /////////////////////////////////////////////////////
19 // Segmentation and Response classes version 01 //
20 /////////////////////////////////////////////////////
26 #include <TGeometry.h>
29 #include <TObjArray.h>
30 #include <Riostream.h>
32 #include "AliMUONSegmentationV01.h"
34 #include "AliMUONChamber.h"
39 //___________________________________________
40 ClassImp(AliMUONSegmentationV01)
42 AliMUONSegmentationV01::AliMUONSegmentationV01(const AliMUONSegmentationV01& segmentation):AliMUONSegmentationV0(segmentation)
44 // Dummy copy constructor
47 AliMUONSegmentationV01::AliMUONSegmentationV01()
49 // Default constructor
56 AliMUONSegmentationV01::AliMUONSegmentationV01(Int_t nsec)
58 // Non default constructor
61 fRSec = new TArrayF(fNsec);
62 fNDiv = new TArrayI(fNsec);
63 fDpxD = new TArrayF(fNsec);
66 (*fRSec)[0]=(*fRSec)[1]=(*fRSec)[2]=(*fRSec)[3]=0;
67 (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;
68 (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;
69 fCorrA = new TObjArray(3);
76 AliMUONSegmentationV01::~AliMUONSegmentationV01()
79 if (fRSec) delete fRSec;
80 if (fNDiv) delete fNDiv;
81 if (fDpxD) delete fDpxD;
89 Float_t AliMUONSegmentationV01::Dpx(Int_t isec) const
92 // Returns x-pad size for given sector isec
93 Float_t dpx = (*fDpxD)[isec];
97 Float_t AliMUONSegmentationV01::Dpy(Int_t /*isec*/) const
100 // Returns y-pad size for given sector isec
104 void AliMUONSegmentationV01::SetSegRadii(Float_t r[4])
107 // Set the radii of the segmentation zones
108 for (Int_t i=0; i<4; i++) {
114 void AliMUONSegmentationV01::SetPadDivision(Int_t ndiv[4])
117 // Defines the pad size perp. to the anode wire (y) for different sectors.
118 // Pad sizes are defined as integral fractions ndiv of a basis pad size
121 for (Int_t i=0; i<4; i++) {
128 void AliMUONSegmentationV01::Init(Int_t chamber)
131 // Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
132 // These arrays help in converting from real to pad co-ordinates and
134 // This version approximates concentric segmentation zones
137 //printf("\n Initialise Segmentation V01\n");
140 fNpy=Int_t((*fRSec)[fNsec-1]/fDpy)+1;
142 (*fDpxD)[fNsec-1]=fDpx;
144 for (Int_t i=fNsec-2; i>=0; i--){
145 (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i];
149 // fill the arrays defining the pad segmentation boundaries
154 // loop over sections
155 for(isec=0; isec<fNsec; isec++) {
157 // loop over pads along the aode wires
158 for (Int_t iy=1; iy<=fNpy; iy++) {
160 Float_t x=iy*fDpy-fDpy/2;
161 if (x > (*fRSec)[isec]) {
165 ry=TMath::Sqrt((*fRSec)[isec]*(*fRSec)[isec]-x*x);
167 dnx= Int_t((ry-fCx[isec-1][iy])/(*fDpxD)[isec]);
168 if (isec < fNsec-1) {
169 if (TMath::Odd((Long_t)dnx)) dnx++;
171 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
172 fCx[isec][iy]=fCx[isec-1][iy]+dnx*(*fDpxD)[isec];
173 } else if (isec == 1) {
174 dnx= Int_t((ry-fCx[isec-1][iy])/(*fDpxD)[isec]);
175 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
176 add=4 - (fNpxS[isec][iy])%4;
177 if (add < 4) fNpxS[isec][iy]+=add;
178 dnx=fNpxS[isec][iy]-fNpxS[isec-1][iy];
179 fCx[isec][iy]=fCx[isec-1][iy]+dnx*(*fDpxD)[isec];
181 dnx=Int_t(ry/(*fDpxD)[isec]);
183 fCx[isec][iy]=dnx*(*fDpxD)[isec];
188 // reference to chamber
189 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
190 fChamber=&(pMUON->Chamber(chamber));
195 Int_t AliMUONSegmentationV01::Sector(Int_t ix, Int_t iy)
197 // Returns sector number for given pad position
199 Int_t absix=TMath::Abs(ix);
200 Int_t absiy=TMath::Abs(iy);
202 for (Int_t i=0; i<fNsec; i++) {
203 if (absix<=fNpxS[i][absiy]){
210 //______________________________________________________________________
211 void AliMUONSegmentationV01::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
213 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
215 iy = (y-fOffsetY >0)?
216 Int_t((y-fOffsetY)/fDpy)+1
218 Int_t((y-fOffsetY)/fDpy)-1;
220 if (iy > fNpy) iy= fNpy;
221 if (iy < -fNpy) iy=-fNpy;
225 Float_t absx=TMath::Abs(x);
226 Int_t absiy=TMath::Abs(iy);
227 for (Int_t i=0; i < fNsec; i++) {
228 if (absx <= fCx[i][absiy]) {
234 ix= Int_t((absx-fCx[isec-1][absiy])/(*fDpxD)[isec])
235 +fNpxS[isec-1][absiy]+1;
236 } else if (isec == 0) {
237 ix= Int_t(absx/(*fDpxD)[isec])+1;
239 ix=fNpxS[fNsec-1][absiy]+1;
243 //________________________________________________________________
244 void AliMUONSegmentationV01::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
246 GetPadI(x, y, ix, iy);
248 //________________________________________________________________
250 void AliMUONSegmentationV01::
251 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
253 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
256 Float_t(iy*fDpy)-fDpy/2.+fOffsetY
258 Float_t(iy*fDpy)+fDpy/2.+fOffsetY;
262 Int_t isec=AliMUONSegmentationV01::Sector(ix,iy);
264 Int_t absix=TMath::Abs(ix);
265 Int_t absiy=TMath::Abs(iy);
267 x=fCx[isec-1][absiy]+(absix-fNpxS[isec-1][absiy])*(*fDpxD)[isec];
268 x=(ix>0) ? x-(*fDpxD)[isec]/2 : -x+(*fDpxD)[isec]/2;
274 //________________________________________________________________
276 void AliMUONSegmentationV01::
277 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
279 // Returns real coordinates (x,y,z) for given pad coordinates (ix,iy)
283 // To be properly interfaced with chamber geometry (AliMUONSt1GeometryBuilderV2) ???
285 scale[0] = TVector3( 1, 1, 1); // quadrant I
286 scale[1] = TVector3(-1, 1, -1); // quadrant II
287 scale[2] = TVector3(-1, -1, 1); // quadrant III
288 scale[3] = TVector3( 1, -1, -1); // quadrant IV
305 if (TMath::Abs(fZ) < 600) {
306 z = fZ + scale[iQuadrant].Z()*6.5/2.; // Station 1
312 void AliMUONSegmentationV01::
313 SetPad(Int_t ix, Int_t iy)
316 // Sets virtual pad coordinates, needed for evaluating pad response
317 // outside the tracking program
318 GetPadC(ix,iy,fX,fY);
319 fSector=Sector(ix,iy);
322 //______________________________________________________________________
323 void AliMUONSegmentationV01::FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
325 // Initialises iteration over pads for charge distribution algorithm
328 // Find the wire position (center of charge distribution)
329 Float_t x0a=GetAnod(xhit);
334 // and take fNsigma*sigma around this center
335 Float_t x01=x0a - dx;
336 Float_t x02=x0a + dx;
337 Float_t y01=yhit - dy;
338 Float_t y02=yhit + dy;
340 // find the pads over which the charge distributes
342 GetPadI(x01,y01,fIxmin,fIymin);
343 GetPadI(x02,y02,fIxmax,fIymax);
350 // Set current pad to lower left corner
351 if (fIxmax < fIxmin) fIxmax=fIxmin;
352 if (fIymax < fIymin) fIymax=fIymin;
355 GetPadC(fIx,fIy,fX,fY);
359 void AliMUONSegmentationV01::NextPad()
361 // Stepper for the iteration over pads
363 // Step to next pad in the integration region
365 // Step to next pad in integration region
369 // step from left to right
371 if (fX < fXmax && fX != 0) {
375 } else if (fIy != fIymax) {
378 // get y-position of next row (yc), xc not used here
379 GetPadC(fIx,fIy,xc,yc);
380 // get x-pad coordiante for first pad in row (fIx)
381 GetPadI(fXmin,yc,fIx,iyc);
386 GetPadC(fIx,fIy,fX,fY);
387 fSector=Sector(fIx,fIy);
389 (fSector ==-1 || fSector==0))
393 Int_t AliMUONSegmentationV01::MorePads()
396 // Stopping condition for the iterator over pads
398 // Are there more pads in the integration region
399 return (fIx != -1 || fIy != -1);
401 if ((fX >= fXmax && fIy >= fIymax) || fY==0) {
408 //______________________________________________________________________
409 void AliMUONSegmentationV01::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
411 FirstPad(xhit, yhit, dx, dy);
415 void AliMUONSegmentationV01::
416 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
418 // Returns integration limits for current pad
420 x1=fXhit-fX-Dpx(fSector)/2.;
422 y1=fYhit-fY-Dpy(fSector)/2.;
426 void AliMUONSegmentationV01::
427 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
429 // Returns list of next neighbours for given Pad (iX, iY)
431 const Float_t kEpsilon=fDpy/1000;
434 Int_t ixx, iyy, isec1;
436 Int_t isec0=AliMUONSegmentationV01::Sector(iX,iY);
441 if (Xlist[i]==0) Xlist[i]++;
446 if (Xlist[i]==0) Xlist[i]--;
450 AliMUONSegmentationV01::GetPadC(iX,iY,x,y);
451 AliMUONSegmentationV01::GetPadI(x+kEpsilon,y+fDpy,ixx,iyy);
454 isec1=AliMUONSegmentationV01::Sector(ixx,iyy);
457 // no sector boundary crossing
463 } else if (isec1 < isec0) {
464 // finer segmentation
474 // coarser segmenation
476 if (TMath::Odd(iX-fNpxS[isec1-1][iY+1])) {
488 AliMUONSegmentationV01::GetPadC(iX,iY,x,y);
489 AliMUONSegmentationV01::GetPadI(x+kEpsilon,y-fDpy,ixx,iyy);
492 isec1=AliMUONSegmentationV01::Sector(ixx,iyy);
495 // no sector boundary crossing
503 } else if (isec1 < isec0) {
504 // finer segmentation
514 // coarser segmentation
516 if (TMath::Odd(iX-fNpxS[isec1-1][iY-1])) {
528 void AliMUONSegmentationV01::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y) const
530 // Returns test point on the pad plane.
531 // Used during determination of the segmoid correction of the COG-method
534 x[0]=((*fRSec)[0]+(*fRSec)[1])/2/TMath::Sqrt(2.);
536 x[1]=((*fRSec)[1]+(*fRSec)[2])/2/TMath::Sqrt(2.);
538 x[2]=((*fRSec)[2]+(*fRSec)[3])/2/TMath::Sqrt(2.);
542 void AliMUONSegmentationV01::Draw(const char* opt) const
545 // Draws the segmentation zones
547 if (!strcmp(opt,"eventdisplay")) {
548 const int kColorMUON = kBlue;
550 TRotMatrix* rot000 = new TRotMatrix("Rot000"," ", 90, 0, 90, 90, 0, 0);
551 TRotMatrix* rot090 = new TRotMatrix("Rot090"," ", 90, 90, 90,180, 0, 0);
552 TRotMatrix* rot180 = new TRotMatrix("Rot180"," ", 90,180, 90,270, 0, 0);
553 TRotMatrix* rot270 = new TRotMatrix("Rot270"," ", 90,270, 90, 0, 0, 0);
555 char nameChamber[9], nameSense[9], nameFrame[9], nameNode[9];
556 char nameSense1[9], nameSense2[9];
559 sprintf(nameChamber,"C_MUON%d",fId+1);
560 sprintf(nameSense,"S_MUON%d",fId+1);
561 sprintf(nameSense1,"S1_MUON%d",fId+1);
562 sprintf(nameSense2,"S2_MUON%d",fId+1);
563 sprintf(nameFrame,"F_MUON%d",fId+1);
565 TNode* top=gAlice->GetGeometry()->GetNode("alice");
567 Float_t rmin = (*fRSec)[0]-3;
568 Float_t rmax = (*fRSec)[3]+3;
569 new TTUBE(nameChamber,"Mother","void",rmin,rmax,0.25,1.);
572 new TTUBE(nameSense,"Sens. region","void",rmin,rmax,0.25, 1.);
573 Float_t dx=(rmax-rmin)/2;
576 TBRIK* frMUON = new TBRIK(nameFrame,"Frame","void",dx,dy,dz);
578 sprintf(nameNode,"MUON%d",100+fId+1);
579 node = new TNode(nameNode,"ChamberNode",nameChamber,0,0,fChamber->Z(),"");
580 node->SetLineColor(kColorMUON);
581 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
582 (pMUON->Nodes())->Add(node);
584 sprintf(nameNode,"MUON%d",200+fId+1);
585 node = new TNode(nameNode,"Sens. Region Node",nameSense,0,0,0,"");
586 node->SetLineColor(kColorMUON);
589 sprintf(nameNode,"MUON%d",300+fId+1);
590 nodeF = new TNode(nameNode,"Frame0",frMUON,dr, 0, 0,rot000,"");
591 nodeF->SetLineColor(kColorMUON);
593 sprintf(nameNode,"MUON%d",400+fId+1);
594 nodeF = new TNode(nameNode,"Frame1",frMUON,0 ,dr,0,rot090,"");
595 nodeF->SetLineColor(kColorMUON);
597 sprintf(nameNode,"MUON%d",500+fId+1);
598 nodeF = new TNode(nameNode,"Frame2",frMUON,-dr,0,0,rot180,"");
599 nodeF->SetLineColor(kColorMUON);
601 sprintf(nameNode,"MUON%d",600+fId+1);
602 nodeF = new TNode(nameNode,"Frame3",frMUON,0,-dr,0,rot270,"");
603 nodeF->SetLineColor(kColorMUON);
607 Float_t dx=0.95/fCx[3][1]/2;
608 Float_t dy=0.95/(Float_t(Npy()))/2;
613 for (Int_t iy=1; iy<Npy(); iy++) {
614 for (Int_t isec=0; isec<4; isec++) {
619 x0=fCx[isec-1][iy]*dx;
624 box=new TBox(x0+xc,y0+yc,x1+xc,y1+yc);
625 box->SetFillColor(isec+1);
628 box=new TBox(-x1+xc,y0+yc,-x0+xc,y1+yc);
629 box->SetFillColor(isec+1);
632 box=new TBox(x0+xc,-y1+yc,x1+xc,-y0+yc);
633 box->SetFillColor(isec+1);
636 box=new TBox(-x1+xc,-y1+yc,-x0+xc,-y0+yc);
637 box->SetFillColor(isec+1);
643 void AliMUONSegmentationV01::SetCorrFunc(Int_t isec, TF1* func)
645 // Set the correction function
646 fCorrA->AddAt(func,isec);
649 TF1* AliMUONSegmentationV01::CorrFunc(Int_t isec) const
651 // Get correction function
652 //PH return (TF1*) (*fCorrA)[isec];
653 return (TF1*) fCorrA->At(isec);
656 AliMUONSegmentationV01& AliMUONSegmentationV01::operator
657 =(const AliMUONSegmentationV01 & /*rhs*/)
659 // Dummy assignment operator