]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegmentationTriggerY.cxx
Replacing rindex by strrchr
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationTriggerY.cxx
CommitLineData
a9e2aefa 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$ */
a9e2aefa 17
18#include "AliMUONSegmentationTriggerY.h"
3f2cdba8 19#include "AliMUONTriggerConstants.h"
a9e2aefa 20#include "TMath.h"
21#include "TRandom.h"
22#include "TArc.h"
23#include "AliMUONChamber.h"
9e1a0ddb 24#include "AliMUON.h"
25#include "AliRun.h"
70479d0e 26#include <Riostream.h>
a9e2aefa 27ClassImp(AliMUONSegmentationTriggerY)
28
3f2cdba8 29//------------------------------------------------------------------
d81db581 30void AliMUONSegmentationTriggerY::Init(Int_t chamber)
a9e2aefa 31{
3f2cdba8 32// intialize Y segmentation
9e1a0ddb 33 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
ef077202 34 if(pMUON->GetDebug()>1) printf("%s: Initialize Trigger Chamber Geometry Y\n",ClassName());
d81db581 35 AliMUONSegmentationTrigger::Init(chamber);
a9e2aefa 36
37// calculate x & y position of Y strips
3f2cdba8 38 Int_t nModule=AliMUONTriggerConstants::Nmodule();
39 for (Int_t imodule=0; imodule<nModule; imodule++) {
40 Float_t width=StripSizeY(AliMUONTriggerConstants::ModuleId(imodule));
41 Int_t nStrip=AliMUONTriggerConstants::NstripY(imodule);
42 for (Int_t istrip=0; istrip<nStrip; istrip++){
a9e2aefa 43 if (imodule<63) {
3f2cdba8 44 fXofysmin[imodule][istrip]=
45 (AliMUONTriggerConstants::XcMin(imodule)+width*(istrip))*fZscale;
46 fXofysmax[imodule][istrip]=
47 (AliMUONTriggerConstants::XcMin(imodule)+width*(istrip+1))*fZscale;
a9e2aefa 48 } else {
49 fXofysmin[imodule][istrip]=-1.*fXofysmax[imodule-63][istrip];
50 fXofysmax[imodule][istrip]=-1.*fXofysmin[imodule-63][istrip];
51 }
3f2cdba8 52 fYofysmin[imodule][istrip] = fYcmin[imodule]*fZscale;
53 fYofysmax[imodule][istrip] = fYcmax[imodule]*fZscale;
a9e2aefa 54 }
55 }
56
57}
58
59//------------------------------------------------------------------
c3eff6ad 60void AliMUONSegmentationTriggerY::GetPadI(Float_t x,Float_t y,Int_t &ix,Int_t &iy)
61{
a9e2aefa 62// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
63// x,y = real coordinates; ix = module number , iy = strip number
64
65 ix = 0;
66 iy = 0;
3f2cdba8 67 Int_t nModule=AliMUONTriggerConstants::Nmodule();
68 for (Int_t imodule=0; imodule<nModule; imodule++) {
69 Int_t nStrip=AliMUONTriggerConstants::NstripY(imodule);
70 for (Int_t istrip=0; istrip<nStrip; istrip++){
a9e2aefa 71 if (x>fXofysmin[imodule][istrip]&&x<fXofysmax[imodule][istrip]&&
72 y>fYofysmin[imodule][istrip]&&y<fYofysmax[imodule][istrip]){
3f2cdba8 73 ix = AliMUONTriggerConstants::ModuleId(imodule);
a9e2aefa 74 iy = istrip;
75 }
76 }
77 }
78}
79
80//------------------------------------------------------------------
c3eff6ad 81void AliMUONSegmentationTriggerY::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
82{
a9e2aefa 83// Returns real coordinates (x,y) for given pad coordinates (ix,iy)
84// ix = module number , iy = strip number; x,y = center of strip
85 x = 0.;
86 y = 0.;
3f2cdba8 87 Int_t nModule=AliMUONTriggerConstants::Nmodule();
88 for (Int_t imodule=0; imodule<nModule; imodule++) {
89 if (AliMUONTriggerConstants::ModuleId(imodule)==ix){
a9e2aefa 90 x=fXofysmin[imodule][iy]+(fXofysmax[imodule][iy]-fXofysmin[imodule][iy])/2.;
91 y=fYofysmin[imodule][iy]+(fYofysmax[imodule][iy]-fYofysmin[imodule][iy])/2.;
92 }
93 }
94}
95
96//------------------------------------------------------------------
97void AliMUONSegmentationTriggerY::SetPadSize(Float_t p1, Float_t p2)
98{
99// Sets the padsize
100//
101 fDpx=p1;
102 fDpy=p2;
103}
104
105//------------------------------------------------------------------
106void AliMUONSegmentationTriggerY::
03f221a7 107Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]){
108// Returns list of 10 next neighbours for given Y strip (ix, iy)
109// neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
110// \_______/ \_______/
111// left right
112// Note : should not be used to return a list of neighbours larger than 16 !
113
114 Int_t absiX = TMath::Abs(iX);
115 Int_t numModule = ModuleNumber(absiX); // module number Id.
116 Int_t nStrip = AliMUONTriggerConstants::NstripY(numModule); //numb of strips
117 Int_t iCandidateLeft, iCandidateRight;
118 Int_t iNewCandidateRight=0;
119 Int_t iNewCandidateLeft=0;
120// first strip number on the right of the left module
121 if ( (absiX-(Int_t(absiX/10))*10)!=1 && absiX!=52 )
122 iNewCandidateLeft =
123 AliMUONTriggerConstants::NstripY(ModuleNumber(absiX-1))-1;
124 Int_t j;
a9e2aefa 125
03f221a7 126 *Nlist = 10;
127 for (Int_t i=0; i<10; i++) Xlist[i]=Ylist[i]=0;
128
129 if (iY < nStrip) {
130
131 for (Int_t i=0; i<5; i++) {
132 j = i + 5;
133 iCandidateRight = iY + (i + 1);
134 iCandidateLeft = iY - (i + 1);
135 if (iCandidateRight < nStrip) { // strip in same module
136 Xlist[i] = absiX;
137 Ylist[i] = iCandidateRight;
138 } else if ((absiX+1)%10!=8) { // need to scan the module on the right
139 Xlist[i] = absiX+1;
140 Ylist[i] = iNewCandidateRight;
141 iNewCandidateRight++;
142 }
143
144 if (iCandidateLeft >=0 ) { // strip in same module
145 Xlist[j] = absiX;
146 Ylist[j] = iCandidateLeft;
147 } else if ( iNewCandidateLeft !=0) {
148 Xlist[j] = absiX-1;
149 Ylist[j] = iNewCandidateLeft;
150 iNewCandidateLeft--;
151 }
a9e2aefa 152 }
153
154 if (iX<0) { // left side of chamber
03f221a7 155 for (Int_t i=0; i<10; i++) {
156 if (Xlist[i]!=0) Xlist[i]=-Xlist[i];
157 }
a9e2aefa 158 }
03f221a7 159
160 } // iY < nStrip
a9e2aefa 161}
162
163//------------------------------------------------------------------
164void AliMUONSegmentationTriggerY::SetPad(Int_t ix, Int_t iy)
165{
166 // Sets virtual pad coordinates, needed for evaluating pad response
167 // outside the tracking program
ecfa008b 168 GetPadC(ix,iy,fX,fY);
169 GetPadI(fX,fY,fIx,fIy);
a9e2aefa 170 fSector=Sector(ix,iy);
171}
172
173//------------------------------------------------------------------
c3eff6ad 174Int_t AliMUONSegmentationTriggerY::ISector()
a9e2aefa 175{ return fSector;}
176
177//------------------------------------------------------------------
c3eff6ad 178
a9e2aefa 179Int_t AliMUONSegmentationTriggerY::Ix()
ecfa008b 180{ return fIx;}
a9e2aefa 181
182//------------------------------------------------------------------
c3eff6ad 183
a9e2aefa 184Int_t AliMUONSegmentationTriggerY::Iy()
ecfa008b 185{ return fIy;}
a9e2aefa 186
187//------------------------------------------------------------------
c3eff6ad 188Float_t AliMUONSegmentationTriggerY::Dpx(Int_t isec) const
3f2cdba8 189{
190// returns x size of y strips for sector isec
a9e2aefa 191 if (isec==1) {
192 return 2.125*fZscale;
193 } else if (isec==2) {
194 return 2.125*fZscale;
195 } else if (isec==3) {
196 return 2.125*fZscale;
197 } else if (isec==4) {
198 return 4.25*fZscale;
199 } else {
200 return 0.;
201 }
202}
203
204//------------------------------------------------------------------
c3eff6ad 205Float_t AliMUONSegmentationTriggerY::Dpy(Int_t isec) const
3f2cdba8 206{
207// returns y size of y strips for sector isec
a9e2aefa 208 if (isec==1) {
209 return 68.0*fZscale;
210 } else if (isec==2) {
211 return 51.0*fZscale;
212 } else if (isec==3) {
213 return 68.0*fZscale;
214 } else if (isec==4) {
215 return 68.0*fZscale;
216 } else if (isec==5) {
217 return 68.0*fZscale;
218 } else {
219 return 0.;
220 }
e889a146 221}
222//------------------------------------------------------------------
223void AliMUONSegmentationTriggerY::GetPadI(Float_t x, Float_t y, Float_t /*z*/, Int_t &ix, Int_t &iy)
224{
225 GetPadI(x, y, ix, iy);
a9e2aefa 226}
227
228//------------------------------------------------------------------
229void AliMUONSegmentationTriggerY::SetHit(Float_t xhit, Float_t yhit)
3f2cdba8 230{
231// set hits during diintegration
03f221a7 232 AliMUONSegmentationTrigger::SetHit(xhit,yhit);
3f2cdba8 233}
a9e2aefa 234//------------------------------------------------------------------
e889a146 235void AliMUONSegmentationTriggerY::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
236{
237 SetHit(xhit, yhit);
238}
239//------------------------------------------------------------------
240Int_t AliMUONSegmentationTriggerY::Sector(Int_t ix, Int_t /*iy*/)
a9e2aefa 241{
242// Returns sector number for given module
243//
244 Int_t absix=TMath::Abs(ix);
245 Int_t iwidth=Int_t(StripSizeY(absix));
3f2cdba8 246
a9e2aefa 247 if (absix==52) {
248 return 1;
249 } else if (absix==41||absix==61) {
250 return 2;
251 } else if (iwidth==2) {
252 return 3;
253 } else if (iwidth==4) {
254 return 4;
255 } else {
256 return 0;
257 }
258}
259
260//------------------------------------------------------------------
261void AliMUONSegmentationTriggerY::
03f221a7 262IntegrationLimits(Float_t& x1, Float_t& x2, Float_t& x3, Float_t& x4)
a9e2aefa 263{
264// returns quantities needed to evaluate neighbour strip response
265 Int_t ix,iy;
266 Float_t xstrip,ystrip;
ecfa008b 267 GetPadI(fXhit,fYhit,ix,iy);
a30a000f 268 GetPadC(ix,iy,xstrip,ystrip);
ecfa008b 269 x1=fXhit; // hit x position
a9e2aefa 270 x2=xstrip; // x coordinate of the main strip
ecfa008b 271 x3=fX; // current strip real x coordinate
03f221a7 272 // width=StripSizeY(ix); // width of the main strip
273
274 // find the position of the 2 borders of the current strip
275 Float_t xmin = fXofysmin[ModuleNumber(fIx)][fIy];
276 Float_t xmax = fXofysmax[ModuleNumber(fIx)][fIy];
277
278 // dist. between the hit and the closest border of the current strip
279 x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ?
280 TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);
281
a9e2aefa 282}
283
284
285
286