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>
28 #include <TObjArray.h>
29 #include <Riostream.h>
31 #include "AliMUONSegmentationV01.h"
33 #include "AliMUONChamber.h"
38 //___________________________________________
39 ClassImp(AliMUONSegmentationV01)
41 AliMUONSegmentationV01::AliMUONSegmentationV01(const AliMUONSegmentationV01& segmentation):AliMUONSegmentationV0(segmentation)
43 // Dummy copy constructor
46 AliMUONSegmentationV01::AliMUONSegmentationV01()
48 // Default constructor
55 AliMUONSegmentationV01::AliMUONSegmentationV01(Int_t nsec)
57 // Non default constructor
60 fRSec = new TArrayF(fNsec);
61 fNDiv = new TArrayI(fNsec);
62 fDpxD = new TArrayF(fNsec);
65 (*fRSec)[0]=(*fRSec)[1]=(*fRSec)[2]=(*fRSec)[3]=0;
66 (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;
67 (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;
68 fCorrA = new TObjArray(3);
75 AliMUONSegmentationV01::~AliMUONSegmentationV01()
78 if (fRSec) delete fRSec;
79 if (fNDiv) delete fNDiv;
80 if (fDpxD) delete fDpxD;
88 Float_t AliMUONSegmentationV01::Dpx(Int_t isec) const
91 // Returns x-pad size for given sector isec
92 Float_t dpx = (*fDpxD)[isec];
96 Float_t AliMUONSegmentationV01::Dpy(Int_t /*isec*/) const
99 // Returns y-pad size for given sector isec
103 void AliMUONSegmentationV01::SetSegRadii(Float_t r[4])
106 // Set the radii of the segmentation zones
107 for (Int_t i=0; i<4; i++) {
113 void AliMUONSegmentationV01::SetPadDivision(Int_t ndiv[4])
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
120 for (Int_t i=0; i<4; i++) {
127 void AliMUONSegmentationV01::Init(Int_t chamber)
130 // Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
131 // These arrays help in converting from real to pad co-ordinates and
133 // This version approximates concentric segmentation zones
136 //printf("\n Initialise Segmentation V01\n");
139 fNpy=Int_t((*fRSec)[fNsec-1]/fDpy)+1;
141 (*fDpxD)[fNsec-1]=fDpx;
143 for (Int_t i=fNsec-2; i>=0; i--){
144 (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i];
148 // fill the arrays defining the pad segmentation boundaries
153 // loop over sections
154 for(isec=0; isec<fNsec; isec++) {
156 // loop over pads along the aode wires
157 for (Int_t iy=1; iy<=fNpy; iy++) {
159 Float_t x=iy*fDpy-fDpy/2;
160 if (x > (*fRSec)[isec]) {
164 ry=TMath::Sqrt((*fRSec)[isec]*(*fRSec)[isec]-x*x);
166 dnx= Int_t((ry-fCx[isec-1][iy])/(*fDpxD)[isec]);
167 if (isec < fNsec-1) {
168 if (TMath::Odd((Long_t)dnx)) dnx++;
170 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
171 fCx[isec][iy]=fCx[isec-1][iy]+dnx*(*fDpxD)[isec];
172 } else if (isec == 1) {
173 dnx= Int_t((ry-fCx[isec-1][iy])/(*fDpxD)[isec]);
174 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
175 add=4 - (fNpxS[isec][iy])%4;
176 if (add < 4) fNpxS[isec][iy]+=add;
177 dnx=fNpxS[isec][iy]-fNpxS[isec-1][iy];
178 fCx[isec][iy]=fCx[isec-1][iy]+dnx*(*fDpxD)[isec];
180 dnx=Int_t(ry/(*fDpxD)[isec]);
182 fCx[isec][iy]=dnx*(*fDpxD)[isec];
187 // reference to chamber
188 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
189 fChamber=&(pMUON->Chamber(chamber));
194 Int_t AliMUONSegmentationV01::Sector(Int_t ix, Int_t iy)
196 // Returns sector number for given pad position
198 Int_t absix=TMath::Abs(ix);
199 Int_t absiy=TMath::Abs(iy);
201 for (Int_t i=0; i<fNsec; i++) {
202 if (absix<=fNpxS[i][absiy]){
209 //______________________________________________________________________
210 void AliMUONSegmentationV01::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
212 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
214 iy = (y-fOffsetY >0)?
215 Int_t((y-fOffsetY)/fDpy)+1
217 Int_t((y-fOffsetY)/fDpy)-1;
219 if (iy > fNpy) iy= fNpy;
220 if (iy < -fNpy) iy=-fNpy;
224 Float_t absx=TMath::Abs(x);
225 Int_t absiy=TMath::Abs(iy);
226 for (Int_t i=0; i < fNsec; i++) {
227 if (absx <= fCx[i][absiy]) {
233 ix= Int_t((absx-fCx[isec-1][absiy])/(*fDpxD)[isec])
234 +fNpxS[isec-1][absiy]+1;
235 } else if (isec == 0) {
236 ix= Int_t(absx/(*fDpxD)[isec])+1;
238 ix=fNpxS[fNsec-1][absiy]+1;
242 //________________________________________________________________
243 void AliMUONSegmentationV01::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
245 GetPadI(x, y, ix, iy);
247 //________________________________________________________________
249 void AliMUONSegmentationV01::
250 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
252 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
255 Float_t(iy*fDpy)-fDpy/2.+fOffsetY
257 Float_t(iy*fDpy)+fDpy/2.+fOffsetY;
261 Int_t isec=AliMUONSegmentationV01::Sector(ix,iy);
263 Int_t absix=TMath::Abs(ix);
264 Int_t absiy=TMath::Abs(iy);
266 x=fCx[isec-1][absiy]+(absix-fNpxS[isec-1][absiy])*(*fDpxD)[isec];
267 x=(ix>0) ? x-(*fDpxD)[isec]/2 : -x+(*fDpxD)[isec]/2;
273 void AliMUONSegmentationV01::
274 SetPad(Int_t ix, Int_t iy)
277 // Sets virtual pad coordinates, needed for evaluating pad response
278 // outside the tracking program
279 GetPadC(ix,iy,fX,fY);
280 fSector=Sector(ix,iy);
283 //______________________________________________________________________
284 void AliMUONSegmentationV01::FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
286 // Initialises iteration over pads for charge distribution algorithm
289 // Find the wire position (center of charge distribution)
290 Float_t x0a=GetAnod(xhit);
295 // and take fNsigma*sigma around this center
296 Float_t x01=x0a - dx;
297 Float_t x02=x0a + dx;
298 Float_t y01=yhit - dy;
299 Float_t y02=yhit + dy;
301 // find the pads over which the charge distributes
303 GetPadI(x01,y01,fIxmin,fIymin);
304 GetPadI(x02,y02,fIxmax,fIymax);
311 // Set current pad to lower left corner
312 if (fIxmax < fIxmin) fIxmax=fIxmin;
313 if (fIymax < fIymin) fIymax=fIymin;
316 GetPadC(fIx,fIy,fX,fY);
320 void AliMUONSegmentationV01::NextPad()
322 // Stepper for the iteration over pads
324 // Step to next pad in the integration region
326 // Step to next pad in integration region
330 // step from left to right
332 if (fX < fXmax && fX != 0) {
336 } else if (fIy != fIymax) {
339 // get y-position of next row (yc), xc not used here
340 GetPadC(fIx,fIy,xc,yc);
341 // get x-pad coordiante for first pad in row (fIx)
342 GetPadI(fXmin,yc,fIx,iyc);
347 GetPadC(fIx,fIy,fX,fY);
348 fSector=Sector(fIx,fIy);
350 (fSector ==-1 || fSector==0))
354 Int_t AliMUONSegmentationV01::MorePads()
357 // Stopping condition for the iterator over pads
359 // Are there more pads in the integration region
360 return (fIx != -1 || fIy != -1);
362 if ((fX >= fXmax && fIy >= fIymax) || fY==0) {
369 //______________________________________________________________________
370 void AliMUONSegmentationV01::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
372 FirstPad(xhit, yhit, dx, dy);
376 void AliMUONSegmentationV01::
377 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
379 // Returns integration limits for current pad
381 x1=fXhit-fX-Dpx(fSector)/2.;
383 y1=fYhit-fY-Dpy(fSector)/2.;
387 void AliMUONSegmentationV01::
388 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
390 // Returns list of next neighbours for given Pad (iX, iY)
392 const Float_t kEpsilon=fDpy/1000;
395 Int_t ixx, iyy, isec1;
397 Int_t isec0=AliMUONSegmentationV01::Sector(iX,iY);
402 if (Xlist[i]==0) Xlist[i]++;
407 if (Xlist[i]==0) Xlist[i]--;
411 AliMUONSegmentationV01::GetPadC(iX,iY,x,y);
412 AliMUONSegmentationV01::GetPadI(x+kEpsilon,y+fDpy,ixx,iyy);
415 isec1=AliMUONSegmentationV01::Sector(ixx,iyy);
418 // no sector boundary crossing
424 } else if (isec1 < isec0) {
425 // finer segmentation
435 // coarser segmenation
437 if (TMath::Odd(iX-fNpxS[isec1-1][iY+1])) {
449 AliMUONSegmentationV01::GetPadC(iX,iY,x,y);
450 AliMUONSegmentationV01::GetPadI(x+kEpsilon,y-fDpy,ixx,iyy);
453 isec1=AliMUONSegmentationV01::Sector(ixx,iyy);
456 // no sector boundary crossing
464 } else if (isec1 < isec0) {
465 // finer segmentation
475 // coarser segmentation
477 if (TMath::Odd(iX-fNpxS[isec1-1][iY-1])) {
489 void AliMUONSegmentationV01::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y) const
491 // Returns test point on the pad plane.
492 // Used during determination of the segmoid correction of the COG-method
495 x[0]=((*fRSec)[0]+(*fRSec)[1])/2/TMath::Sqrt(2.);
497 x[1]=((*fRSec)[1]+(*fRSec)[2])/2/TMath::Sqrt(2.);
499 x[2]=((*fRSec)[2]+(*fRSec)[3])/2/TMath::Sqrt(2.);
503 void AliMUONSegmentationV01::Draw(const char* opt) const
506 // Draws the segmentation zones
508 if (!strcmp(opt,"eventdisplay")) {
509 const int kColorMUON = kBlue;
511 TRotMatrix* rot000 = new TRotMatrix("Rot000"," ", 90, 0, 90, 90, 0, 0);
512 TRotMatrix* rot090 = new TRotMatrix("Rot090"," ", 90, 90, 90,180, 0, 0);
513 TRotMatrix* rot180 = new TRotMatrix("Rot180"," ", 90,180, 90,270, 0, 0);
514 TRotMatrix* rot270 = new TRotMatrix("Rot270"," ", 90,270, 90, 0, 0, 0);
516 char nameChamber[9], nameSense[9], nameFrame[9], nameNode[9];
517 char nameSense1[9], nameSense2[9];
520 sprintf(nameChamber,"C_MUON%d",fId+1);
521 sprintf(nameSense,"S_MUON%d",fId+1);
522 sprintf(nameSense1,"S1_MUON%d",fId+1);
523 sprintf(nameSense2,"S2_MUON%d",fId+1);
524 sprintf(nameFrame,"F_MUON%d",fId+1);
526 TNode* top=gAlice->GetGeometry()->GetNode("alice");
528 Float_t rmin = (*fRSec)[0]-3;
529 Float_t rmax = (*fRSec)[3]+3;
530 new TTUBE(nameChamber,"Mother","void",rmin,rmax,0.25,1.);
533 new TTUBE(nameSense,"Sens. region","void",rmin,rmax,0.25, 1.);
534 Float_t dx=(rmax-rmin)/2;
537 TBRIK* frMUON = new TBRIK(nameFrame,"Frame","void",dx,dy,dz);
539 sprintf(nameNode,"MUON%d",100+fId+1);
540 node = new TNode(nameNode,"ChamberNode",nameChamber,0,0,fChamber->Z(),"");
541 node->SetLineColor(kColorMUON);
542 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
543 (pMUON->Nodes())->Add(node);
545 sprintf(nameNode,"MUON%d",200+fId+1);
546 node = new TNode(nameNode,"Sens. Region Node",nameSense,0,0,0,"");
547 node->SetLineColor(kColorMUON);
550 sprintf(nameNode,"MUON%d",300+fId+1);
551 nodeF = new TNode(nameNode,"Frame0",frMUON,dr, 0, 0,rot000,"");
552 nodeF->SetLineColor(kColorMUON);
554 sprintf(nameNode,"MUON%d",400+fId+1);
555 nodeF = new TNode(nameNode,"Frame1",frMUON,0 ,dr,0,rot090,"");
556 nodeF->SetLineColor(kColorMUON);
558 sprintf(nameNode,"MUON%d",500+fId+1);
559 nodeF = new TNode(nameNode,"Frame2",frMUON,-dr,0,0,rot180,"");
560 nodeF->SetLineColor(kColorMUON);
562 sprintf(nameNode,"MUON%d",600+fId+1);
563 nodeF = new TNode(nameNode,"Frame3",frMUON,0,-dr,0,rot270,"");
564 nodeF->SetLineColor(kColorMUON);
568 Float_t dx=0.95/fCx[3][1]/2;
569 Float_t dy=0.95/(Float_t(Npy()))/2;
574 for (Int_t iy=1; iy<Npy(); iy++) {
575 for (Int_t isec=0; isec<4; isec++) {
580 x0=fCx[isec-1][iy]*dx;
585 box=new TBox(x0+xc,y0+yc,x1+xc,y1+yc);
586 box->SetFillColor(isec+1);
589 box=new TBox(-x1+xc,y0+yc,-x0+xc,y1+yc);
590 box->SetFillColor(isec+1);
593 box=new TBox(x0+xc,-y1+yc,x1+xc,-y0+yc);
594 box->SetFillColor(isec+1);
597 box=new TBox(-x1+xc,-y1+yc,-x0+xc,-y0+yc);
598 box->SetFillColor(isec+1);
604 void AliMUONSegmentationV01::SetCorrFunc(Int_t isec, TF1* func)
606 // Set the correction function
607 fCorrA->AddAt(func,isec);
610 TF1* AliMUONSegmentationV01::CorrFunc(Int_t isec) const
612 // Get correction function
613 //PH return (TF1*) (*fCorrA)[isec];
614 return (TF1*) fCorrA->At(isec);
617 AliMUONSegmentationV01& AliMUONSegmentationV01::operator
618 =(const AliMUONSegmentationV01 & /*rhs*/)
620 // Dummy assignment operator