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>
31 #include "AliMUONSegmentationV01.h"
33 #include "AliMUONChamber.h"
38 //___________________________________________
39 ClassImp(AliMUONSegmentationV01)
41 AliMUONSegmentationV01::AliMUONSegmentationV01(const AliMUONSegmentationV01& segmentation)
42 : AliMUONSegmentationV0(segmentation)
44 // Protected copy constructor
46 Fatal("AliMUONSegmentationV01", "Not implemented.");
49 AliMUONSegmentationV01::AliMUONSegmentationV01()
50 : AliMUONSegmentationV0()
52 // Default constructor
60 AliMUONSegmentationV01::AliMUONSegmentationV01(Int_t nsec)
61 : AliMUONSegmentationV0()
63 // Non default constructor
66 fRSec = new TArrayF(fNsec);
67 fNDiv = new TArrayI(fNsec);
68 fDpxD = new TArrayF(fNsec);
71 (*fRSec)[0]=(*fRSec)[1]=(*fRSec)[2]=(*fRSec)[3]=0;
72 (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;
73 (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;
74 fCorrA = new TObjArray(3);
82 AliMUONSegmentationV01::~AliMUONSegmentationV01()
85 if (fRSec) delete fRSec;
86 if (fNDiv) delete fNDiv;
87 if (fDpxD) delete fDpxD;
95 Float_t AliMUONSegmentationV01::Dpx(Int_t isec) const
98 // Returns x-pad size for given sector isec
99 Float_t dpx = (*fDpxD)[isec];
103 Float_t AliMUONSegmentationV01::Dpy(Int_t /*isec*/) const
106 // Returns y-pad size for given sector isec
110 void AliMUONSegmentationV01::SetSegRadii(Float_t r[4])
113 // Set the radii of the segmentation zones
114 for (Int_t i=0; i<4; i++) {
120 void AliMUONSegmentationV01::SetPadDivision(Int_t ndiv[4])
123 // Defines the pad size perp. to the anode wire (y) for different sectors.
124 // Pad sizes are defined as integral fractions ndiv of a basis pad size
127 for (Int_t i=0; i<4; i++) {
134 void AliMUONSegmentationV01::Init(Int_t chamber)
137 // Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
138 // These arrays help in converting from real to pad co-ordinates and
140 // This version approximates concentric segmentation zones
143 //printf("\n Initialise Segmentation V01\n");
146 fNpy=Int_t((*fRSec)[fNsec-1]/fDpy)+1;
148 (*fDpxD)[fNsec-1]=fDpx;
150 for (Int_t i=fNsec-2; i>=0; i--){
151 (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i];
155 // fill the arrays defining the pad segmentation boundaries
160 // loop over sections
161 for(isec=0; isec<fNsec; isec++) {
163 // loop over pads along the aode wires
164 for (Int_t iy=1; iy<=fNpy; iy++) {
166 Float_t x=iy*fDpy-fDpy/2;
167 if (x > (*fRSec)[isec]) {
171 ry=TMath::Sqrt((*fRSec)[isec]*(*fRSec)[isec]-x*x);
173 dnx= Int_t((ry-fCx[isec-1][iy])/(*fDpxD)[isec]);
174 if (isec < fNsec-1) {
175 if (TMath::Odd((Long_t)dnx)) dnx++;
177 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
178 fCx[isec][iy]=fCx[isec-1][iy]+dnx*(*fDpxD)[isec];
179 } else if (isec == 1) {
180 dnx= Int_t((ry-fCx[isec-1][iy])/(*fDpxD)[isec]);
181 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
182 add=4 - (fNpxS[isec][iy])%4;
183 if (add < 4) fNpxS[isec][iy]+=add;
184 dnx=fNpxS[isec][iy]-fNpxS[isec-1][iy];
185 fCx[isec][iy]=fCx[isec-1][iy]+dnx*(*fDpxD)[isec];
187 dnx=Int_t(ry/(*fDpxD)[isec]);
189 fCx[isec][iy]=dnx*(*fDpxD)[isec];
194 // reference to chamber
195 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
196 fChamber=&(pMUON->Chamber(chamber));
201 //______________________________________________________________________
202 Int_t AliMUONSegmentationV01::Sector(Int_t ix, Int_t iy)
204 // Returns sector number for given pad position
206 Int_t absix=TMath::Abs(ix);
207 Int_t absiy=TMath::Abs(iy);
209 for (Int_t i=0; i<fNsec; i++) {
210 if (absix<=fNpxS[i][absiy]){
218 //______________________________________________________________________
219 void AliMUONSegmentationV01::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
221 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
223 iy = (y-fOffsetY >0)?
224 Int_t((y-fOffsetY)/fDpy)+1
226 Int_t((y-fOffsetY)/fDpy)-1;
228 if (iy > fNpy) iy= fNpy;
229 if (iy < -fNpy) iy=-fNpy;
233 Float_t absx=TMath::Abs(x);
234 Int_t absiy=TMath::Abs(iy);
235 for (Int_t i=0; i < fNsec; i++) {
236 if (absx <= fCx[i][absiy]) {
242 ix= Int_t((absx-fCx[isec-1][absiy])/(*fDpxD)[isec])
243 +fNpxS[isec-1][absiy]+1;
244 } else if (isec == 0) {
245 ix= Int_t(absx/(*fDpxD)[isec])+1;
247 ix=fNpxS[fNsec-1][absiy]+1;
251 //________________________________________________________________
252 void AliMUONSegmentationV01::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
254 GetPadI(x, y, ix, iy);
256 //________________________________________________________________
258 void AliMUONSegmentationV01::
259 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
261 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
264 Float_t(iy*fDpy)-fDpy/2.+fOffsetY
266 Float_t(iy*fDpy)+fDpy/2.+fOffsetY;
270 Int_t isec=AliMUONSegmentationV01::Sector(ix,iy);
272 Int_t absix=TMath::Abs(ix);
273 Int_t absiy=TMath::Abs(iy);
275 x=fCx[isec-1][absiy]+(absix-fNpxS[isec-1][absiy])*(*fDpxD)[isec];
276 x=(ix>0) ? x-(*fDpxD)[isec]/2 : -x+(*fDpxD)[isec]/2;
282 //________________________________________________________________
284 void AliMUONSegmentationV01::
285 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
287 // Returns real coordinates (x,y,z) for given pad coordinates (ix,iy)
291 // To be properly interfaced with chamber geometry (AliMUONSt1GeometryBuilderV2) ???
293 scale[0] = TVector3( 1, 1, 1); // quadrant I
294 scale[1] = TVector3(-1, 1, -1); // quadrant II
295 scale[2] = TVector3(-1, -1, 1); // quadrant III
296 scale[3] = TVector3( 1, -1, -1); // quadrant IV
313 if (TMath::Abs(fZ) < 600) {
314 z = fZ + scale[iQuadrant].Z()*6.5/2.; // Station 1
320 void AliMUONSegmentationV01::
321 SetPad(Int_t ix, Int_t iy)
324 // Sets virtual pad coordinates, needed for evaluating pad response
325 // outside the tracking program
326 GetPadC(ix,iy,fX,fY);
327 fSector=Sector(ix,iy);
330 //______________________________________________________________________
331 void AliMUONSegmentationV01::FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
333 // Initialises iteration over pads for charge distribution algorithm
336 // Find the wire position (center of charge distribution)
337 Float_t x0a=GetAnod(xhit);
342 // and take fNsigma*sigma around this center
343 Float_t x01=x0a - dx;
344 Float_t x02=x0a + dx;
345 Float_t y01=yhit - dy;
346 Float_t y02=yhit + dy;
348 // find the pads over which the charge distributes
350 GetPadI(x01,y01,fIxmin,fIymin);
351 GetPadI(x02,y02,fIxmax,fIymax);
358 // Set current pad to lower left corner
359 if (fIxmax < fIxmin) fIxmax=fIxmin;
360 if (fIymax < fIymin) fIymax=fIymin;
363 GetPadC(fIx,fIy,fX,fY);
367 fSector=Sector(fIx,fIy);
372 void AliMUONSegmentationV01::NextPad()
374 // Stepper for the iteration over pads
376 // Step to next pad in the integration region
378 // Step to next pad in integration region
382 // step from left to right
384 if (fX < fXmax && fX != 0) {
388 } else if (fIy != fIymax) {
391 // get y-position of next row (yc), xc not used here
392 GetPadC(fIx,fIy,xc,yc);
393 // get x-pad coordiante for first pad in row (fIx)
394 GetPadI(fXmin,yc,fIx,iyc);
399 GetPadC(fIx,fIy,fX,fY);
400 fSector=Sector(fIx,fIy);
402 (fSector ==-1 || fSector==0))
406 Int_t AliMUONSegmentationV01::MorePads()
409 // Stopping condition for the iterator over pads
411 // Are there more pads in the integration region
412 return (fIx != -1 || fIy != -1);
414 if ((fX >= fXmax && fIy >= fIymax) || fY==0) {
421 //______________________________________________________________________
422 void AliMUONSegmentationV01::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
424 FirstPad(xhit, yhit, dx, dy);
428 void AliMUONSegmentationV01::
429 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
431 // Returns integration limits for current pad
433 x1=fXhit-fX-Dpx(fSector)/2.;
435 y1=fYhit-fY-Dpy(fSector)/2.;
439 void AliMUONSegmentationV01::
440 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
442 // Returns list of next neighbours for given Pad (iX, iY)
444 const Float_t kEpsilon=fDpy/1000;
447 Int_t ixx, iyy, isec1;
449 Int_t isec0=AliMUONSegmentationV01::Sector(iX,iY);
454 if (Xlist[i]==0) Xlist[i]++;
459 if (Xlist[i]==0) Xlist[i]--;
463 AliMUONSegmentationV01::GetPadC(iX,iY,x,y);
464 AliMUONSegmentationV01::GetPadI(x+kEpsilon,y+fDpy,ixx,iyy);
467 isec1=AliMUONSegmentationV01::Sector(ixx,iyy);
470 // no sector boundary crossing
476 } else if (isec1 < isec0) {
477 // finer segmentation
487 // coarser segmenation
489 if (TMath::Odd(iX-fNpxS[isec1-1][iY+1])) {
501 AliMUONSegmentationV01::GetPadC(iX,iY,x,y);
502 AliMUONSegmentationV01::GetPadI(x+kEpsilon,y-fDpy,ixx,iyy);
505 isec1=AliMUONSegmentationV01::Sector(ixx,iyy);
508 // no sector boundary crossing
516 } else if (isec1 < isec0) {
517 // finer segmentation
527 // coarser segmentation
529 if (TMath::Odd(iX-fNpxS[isec1-1][iY-1])) {
541 void AliMUONSegmentationV01::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y) const
543 // Returns test point on the pad plane.
544 // Used during determination of the segmoid correction of the COG-method
547 x[0]=((*fRSec)[0]+(*fRSec)[1])/2/TMath::Sqrt(2.);
549 x[1]=((*fRSec)[1]+(*fRSec)[2])/2/TMath::Sqrt(2.);
551 x[2]=((*fRSec)[2]+(*fRSec)[3])/2/TMath::Sqrt(2.);
555 void AliMUONSegmentationV01::Draw(const char* opt) const
558 // Draws the segmentation zones
560 if (!strcmp(opt,"eventdisplay")) {
561 const int kColorMUON = kBlue;
563 TRotMatrix* rot000 = new TRotMatrix("Rot000"," ", 90, 0, 90, 90, 0, 0);
564 TRotMatrix* rot090 = new TRotMatrix("Rot090"," ", 90, 90, 90,180, 0, 0);
565 TRotMatrix* rot180 = new TRotMatrix("Rot180"," ", 90,180, 90,270, 0, 0);
566 TRotMatrix* rot270 = new TRotMatrix("Rot270"," ", 90,270, 90, 0, 0, 0);
568 char nameChamber[9], nameSense[9], nameFrame[9], nameNode[9];
569 char nameSense1[9], nameSense2[9];
572 sprintf(nameChamber,"C_MUON%d",fId+1);
573 sprintf(nameSense,"S_MUON%d",fId+1);
574 sprintf(nameSense1,"S1_MUON%d",fId+1);
575 sprintf(nameSense2,"S2_MUON%d",fId+1);
576 sprintf(nameFrame,"F_MUON%d",fId+1);
578 TNode* top=gAlice->GetGeometry()->GetNode("alice");
580 Float_t rmin = (*fRSec)[0]-3;
581 Float_t rmax = (*fRSec)[3]+3;
582 new TTUBE(nameChamber,"Mother","void",rmin,rmax,0.25,1.);
585 new TTUBE(nameSense,"Sens. region","void",rmin,rmax,0.25, 1.);
586 Float_t dx=(rmax-rmin)/2;
589 TBRIK* frMUON = new TBRIK(nameFrame,"Frame","void",dx,dy,dz);
591 sprintf(nameNode,"MUON%d",100+fId+1);
592 node = new TNode(nameNode,"ChamberNode",nameChamber,0,0,fChamber->Z(),"");
593 node->SetLineColor(kColorMUON);
594 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
595 (pMUON->Nodes())->Add(node);
597 sprintf(nameNode,"MUON%d",200+fId+1);
598 node = new TNode(nameNode,"Sens. Region Node",nameSense,0,0,0,"");
599 node->SetLineColor(kColorMUON);
602 sprintf(nameNode,"MUON%d",300+fId+1);
603 nodeF = new TNode(nameNode,"Frame0",frMUON,dr, 0, 0,rot000,"");
604 nodeF->SetLineColor(kColorMUON);
606 sprintf(nameNode,"MUON%d",400+fId+1);
607 nodeF = new TNode(nameNode,"Frame1",frMUON,0 ,dr,0,rot090,"");
608 nodeF->SetLineColor(kColorMUON);
610 sprintf(nameNode,"MUON%d",500+fId+1);
611 nodeF = new TNode(nameNode,"Frame2",frMUON,-dr,0,0,rot180,"");
612 nodeF->SetLineColor(kColorMUON);
614 sprintf(nameNode,"MUON%d",600+fId+1);
615 nodeF = new TNode(nameNode,"Frame3",frMUON,0,-dr,0,rot270,"");
616 nodeF->SetLineColor(kColorMUON);
620 Float_t dx=0.95/fCx[3][1]/2;
621 Float_t dy=0.95/(Float_t(Npy()))/2;
626 for (Int_t iy=1; iy<Npy(); iy++) {
627 for (Int_t isec=0; isec<4; isec++) {
632 x0=fCx[isec-1][iy]*dx;
637 box=new TBox(x0+xc,y0+yc,x1+xc,y1+yc);
638 box->SetFillColor(isec+1);
641 box=new TBox(-x1+xc,y0+yc,-x0+xc,y1+yc);
642 box->SetFillColor(isec+1);
645 box=new TBox(x0+xc,-y1+yc,x1+xc,-y0+yc);
646 box->SetFillColor(isec+1);
649 box=new TBox(-x1+xc,-y1+yc,-x0+xc,-y0+yc);
650 box->SetFillColor(isec+1);
656 void AliMUONSegmentationV01::SetCorrFunc(Int_t isec, TF1* func)
658 // Set the correction function
659 fCorrA->AddAt(func,isec);
662 TF1* AliMUONSegmentationV01::CorrFunc(Int_t isec) const
664 // Get correction function
665 //PH return (TF1*) (*fCorrA)[isec];
666 return (TF1*) fCorrA->At(isec);
669 AliMUONSegmentationV01&
670 AliMUONSegmentationV01::operator =(const AliMUONSegmentationV01 & rhs)
672 // Protected assignement operator
674 if (this == &rhs) return *this;
676 Fatal("operator=", "Not implemented.");