]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONsegmentv1.cxx
Do not save CVS subdirectories
[u/mrichter/AliRoot.git] / MUON / AliMUONsegmentv1.cxx
CommitLineData
fe4da5cc 1/////////////////////////////////////////////////////////
2// Manager and hits classes for set:MUON version 0 //
3/////////////////////////////////////////////////////////
4
5#include <TTUBE.h>
6#include <TNode.h>
7#include <TRandom.h>
8
9#include "AliMUONv0.h"
10#include "AliMUONsegmentv1.h"
11#include "AliRun.h"
12#include "AliMC.h"
13#include "iostream.h"
14
15//___________________________________________
16ClassImp(AliMUONsegmentationV1)
17
18AliMUONsegmentationV1::AliMUONsegmentationV1()
19 // initizalize the class with default settings
20{
21fNzone=1;
22fDAnod=0.0;
23fDpx=0.0;
24fDpx=0.0; // forces crash if not initialized by user
25fNZoneCut[0]=0;
26fSensOffset=0;
27}
28
29
30void AliMUONsegmentationV1::Init(AliMUONchamber* Chamber)
31{
32 // valid only for T5/6
33 frSensMin2 = (Chamber->frMin + 6.)*(Chamber->frMin + 6.);
34 frSensMax2 = (Chamber->frMax - 6.)*(Chamber->frMax - 6.);
35 fNpx=(Int_t) (Chamber->frMax/fDpx) + 1;
36 fNpy=(Int_t) (Chamber->frMax/fDpy) + 1;
37 // fNwire=3;
38 DefaultCut();
39}
40
41void AliMUONsegmentationV1::DefaultCut(void)
42{
43SetNzone(3);
44AddCut(0,7*6,18*8);
45AddCut(0,10*6,15*8);
46AddCut(0,12*6,12*8);
47AddCut(0,13*6,9*8);
48AddCut(0,14*6,6*8);
49AddCut(1,8*6,21*12);
50AddCut(1,12*6,18*12);
51AddCut(1,16*6,15*12);
52AddCut(1,18*6,12*12);
53AddCut(1,20*6,9*12);
54AddCut(1,22*6,6*12);
55SetSensOffset(3.0);
56SetDAnod(0.325);
57}
58
59Int_t AliMUONsegmentationV1::GetiAnod(Float_t xhit)
60{
61Int_t kwire=Int_t((TMath::Abs(xhit)-fSensOffset)/fDAnod)+1;
62return (xhit>0) ? kwire : -kwire ;
63}
64
65Float_t AliMUONsegmentationV1::GetAnod(Float_t xhit)
66{
67 Int_t kwire=Int_t((TMath::Abs(xhit)-fSensOffset)/fDAnod)+1; // to be compatible ...
68 return (xhit>0) ? fDAnod*(kwire-0.5)+fSensOffset : -fDAnod*(kwire-0.5)-fSensOffset ;
69}
70
71// For chamber T5/6 p1 and p2 should be same for each zone
72void AliMUONsegmentationV1::SetPADSIZ(Float_t p1, Float_t p2)
73{
74 fDpx=p1;
75 fDpy=p2;
76}
77
78void AliMUONsegmentationV1::
79 GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
80{
81// returns pad coordinates (ix,iy) for given real coordinates (x,y)
82//
83 ix = (x>0)? Int_t((x-fSensOffset)/fDpx)+1 : Int_t((x+fSensOffset)/fDpx)-1;
84 iy = (y>0)? Int_t((y-fSensOffset)/fDpy)+1 : Int_t((y+fSensOffset)/fDpy)-1;
85}
86
87void AliMUONsegmentationV1::
88GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
89{
90// returns real coordinates (x,y) for given pad coordinates (ix,iy)
91//
92 x = (ix>0) ? (Float_t(ix)-0.5)*fDpx+fSensOffset : (Float_t(ix)+0.5)*fDpx-fSensOffset;
93 y = (iy>0) ? (Float_t(iy)-0.5)*fDpy+fSensOffset : (Float_t(iy)+0.5)*fDpy-fSensOffset;
94}
95
96void AliMUONsegmentationV1::AddCut(Int_t Zone, Int_t nX, Int_t nY)
97{// the pad nX,nY is last INSIDE zone Zone
98if (Zone+1>=fNzone) // no cut for last Zone : it is the natural boundary of the chamber
99 printf("AliMUONsegmentationV1::AddCut ==> Zone %d not allowed !\n",Zone);
100fZoneX[Zone][fNZoneCut[Zone]] = nX;
101fZoneY[Zone][fNZoneCut[Zone]] = nY;
102fNZoneCut[Zone]++;
103}
104
105Int_t AliMUONsegmentationV1::GetZone(Float_t X, Float_t Y)
106{
107Int_t iX, iY;
108GetPadIxy(X,Y,iX,iY);
109return GetZone( iX , iY );
110}
111
112Int_t AliMUONsegmentationV1::GetZone(Int_t nX, Int_t nY)
113{// Beware : first pad begins at 1 !!
114Int_t aX = TMath::Abs(nX);
115Int_t aY = TMath::Abs(nY);
116Int_t zone=fNzone-1;
117for (Int_t iZone=fNzone-2;iZone>=0;iZone--)
118 {
119 for (Int_t iCut=0;iCut<fNZoneCut[iZone];iCut++)
120 if ( aY<=fZoneY[iZone][iCut] && aX<=fZoneX[iZone][iCut] )
121 {
122 zone=iZone;
123 break;
124 }
125 }
126return zone;
127}
128
129
130void AliMUONsegmentationV1::SetPadCoord(Int_t iX, Int_t iY)
131{
132GetPadCxy(iX,iY,fx,fy);
133Float_t radius2;
134if ( ( (radius2=fx*fx+fy*fy) > frSensMax2 || radius2 < frSensMin2 )
135 && MorePads() )
136 NextPad();
137
138}
139
140void AliMUONsegmentationV1::FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
141{
142 //
143 // Find the wire position (center of charge distribution)
144 Float_t x0a=GetAnod(xhit);
145 //
146 // and take fNsigma*sigma around this center
147 Float_t x01=x0a - dx;
148 Float_t x02=x0a + dx;
149 Float_t y01=yhit - dy;
150 Float_t y02=yhit + dy;
151
152 // Do not cross over frames...
153 if (x01 * x0a < 0)
154 x01 = TMath::Sign(fSensOffset, x0a);
155 if (x02 * x0a < 0)
156 x02 = TMath::Sign(fSensOffset, x0a);
157 if (y01 * yhit < 0)
158 y01 = TMath::Sign(fSensOffset, yhit);
159 if (y02 * yhit < 0)
160 y02 = TMath::Sign(fSensOffset, yhit);
161 //
162 // find the pads over which the charge distributes
163 GetPadIxy(x01,y01,fixmin,fiymin);
164 GetPadIxy(x02,y02,fixmax,fiymax);
165
166// printf("\n FirstPad called");
167// printf("\n Hit Position %f %f",xhit,yhit);
168// printf("\n Integration limits: %i %i %i %i",fixmin,fixmax,fiymin,fiymax);
169// printf("\n Integration limits: %f %f %f %f \n",x01,x02,y01,y02);
170 //
171 // Set current pad to lower left corner
172 fix=fixmin;
173 fiy=fiymin;
174 SetPadCoord(fix,fiy);
175}
176
177void AliMUONsegmentationV1::NextPad()
178{
179 //
180 // Step to next pad in integration region
181 if (fix != fixmax) {
182 fix++;
183 } else if (fiy != fiymax) {
184 fix=fixmin;
185 fiy++;
186 } else
187 printf("\n Error: Stepping outside integration region\n ");
188 SetPadCoord(fix,fiy);
189}
190
191Int_t AliMUONsegmentationV1::MorePads()
192//
193// Are there more pads in the integration region
194{
195 if (fix == fixmax && fiy == fiymax) {
196 return 0;
197 } else {
198 return 1;
199 }
200}
201
202Int_t AliMUONsegmentationV1::Ix()
203// returns the X number of pad which has to increment charge
204// due to parallel read-out
205{
206Int_t wix = TMath::Abs(fix)-1;
207Int_t wiy = TMath::Abs(fiy)-1;
208Int_t zone = GetZone(fix,fiy);
209switch (zone) {
210 case 0: return fix;
211 case 1:
212 if ( wiy%3 !=1 && wix%6>2)
213 return (fix>0)? fix-3 : fix+3 ;
214 return fix;
215 case 2:
216 if ( (wiy%6 == 1 && wix%2 ==0) || (wiy%6 == 4 && wix%2 ==1))
217 return fix;
218 return fix>0? fix - ((wix%12)/4)*4 : fix + ((wix%12)/4)*4;
219 default :
220 printf("Couille dans AliMUONsegmentationV1::ix\n");
221 }
222return -1;
223}
224
225Int_t AliMUONsegmentationV1::ISector()
226{
227Int_t wix = TMath::Abs(fix)-1;
228Int_t wiy = TMath::Abs(fiy)-1;
229Int_t zone = GetZone(fix,fiy);
230switch (zone) {
231 case 0: return 0;
232 case 1:
233 if ( wiy%3 !=1 && wix%6>2)
234 return 1 ;
235 return 0;
236 case 2:
237 if ((wiy%6 == 1 && wix%2 ==0) || (wiy%6 == 4 && wix%2 ==1))
238 return 0;
239 return (wix%12)/4;
240 default :
241 printf("Couille dans AliMUONsegmentationV1::ISector\n");
242 }
243return -1;
244}
245
246void AliMUONsegmentationV1::SigGenInit(Float_t x,Float_t y,Float_t)
247{
248//
249// Initialises pad and wire position during stepping
250 fxt =x;
251 fyt =y;
252 GetPadIxy(x,y,fixt,fiyt);
253 fiwt= GetiAnod(x);
254
255}
256
257Int_t AliMUONsegmentationV1::SigGenCond(Float_t x,Float_t y,Float_t)
258{
259//
260// Signal will be generated if particle crosses pad boundary or
261// boundary between two wires.
262 Int_t ixt;
263 Int_t iyt;
264 GetPadIxy(x,y,ixt,iyt);
265 Int_t iwt= GetiAnod(x);
266
267 if ((ixt != fixt) || (iyt !=fiyt) || (iwt != fiwt)) {
268 return 1;
269 } else {
270 return 0;
271 }
272}
273
274void AliMUONsegmentationV1::
275IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
276{
277 x1=fxt-fx-fDpx/2.;
278 x2=x1+fDpx;
279 y1=fyt-fy-fDpy/2.;
280 y2=y1+fDpy;
281}
282
283void AliMUONsegmentationV1::
284Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
285{
286 *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
287 Ylist[0]=iY-1;Ylist[1]=iY+1;Ylist[2]=Ylist[3]=iY;
288}
289
290void AliMUONsegmentationV1::
291FitXY(AliMUONRecCluster* ,TClonesArray* )
292 // Default : Centre of gravity method
293{
294 ;
295}