]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONsegmentv1.cxx
Corrections to line for alpha
[u/mrichter/AliRoot.git] / MUON / AliMUONsegmentv1.cxx
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 //___________________________________________
16 ClassImp(AliMUONsegmentationV1)
17
18 AliMUONsegmentationV1::AliMUONsegmentationV1()
19   // initizalize the class with default settings
20 {
21 fNzone=1;
22 fDAnod=0.0;
23 fDpx=0.0;
24 fDpx=0.0; // forces crash if not initialized by user
25 fNZoneCut[0]=0;
26 fSensOffset=0;
27 }
28
29
30 void 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
41 void AliMUONsegmentationV1::DefaultCut(void)
42 {
43 SetNzone(3);
44 AddCut(0,7*6,18*8);
45 AddCut(0,10*6,15*8);
46 AddCut(0,12*6,12*8);
47 AddCut(0,13*6,9*8);
48 AddCut(0,14*6,6*8);
49 AddCut(1,8*6,21*12);
50 AddCut(1,12*6,18*12);
51 AddCut(1,16*6,15*12);
52 AddCut(1,18*6,12*12);
53 AddCut(1,20*6,9*12);
54 AddCut(1,22*6,6*12);
55 SetSensOffset(3.0);
56 SetDAnod(0.325);
57 }
58
59 Int_t AliMUONsegmentationV1::GetiAnod(Float_t xhit)
60 {
61 Int_t kwire=Int_t((TMath::Abs(xhit)-fSensOffset)/fDAnod)+1;
62 return (xhit>0) ? kwire : -kwire ;
63 }
64
65 Float_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
72 void AliMUONsegmentationV1::SetPADSIZ(Float_t p1, Float_t p2)
73 {
74   fDpx=p1;
75   fDpy=p2;
76 }
77
78 void 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
87 void AliMUONsegmentationV1::
88 GetPadCxy(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
96 void AliMUONsegmentationV1::AddCut(Int_t Zone, Int_t nX, Int_t nY)
97 {// the pad nX,nY is last INSIDE zone Zone
98 if (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);
100 fZoneX[Zone][fNZoneCut[Zone]] = nX;
101 fZoneY[Zone][fNZoneCut[Zone]] = nY;
102 fNZoneCut[Zone]++;
103 }
104
105 Int_t AliMUONsegmentationV1::GetZone(Float_t X, Float_t Y)
106 {
107 Int_t iX, iY;
108 GetPadIxy(X,Y,iX,iY);
109 return GetZone( iX , iY );
110 }
111
112 Int_t AliMUONsegmentationV1::GetZone(Int_t nX, Int_t nY)
113 {// Beware : first pad begins at 1 !!
114 Int_t aX =  TMath::Abs(nX);
115 Int_t aY =  TMath::Abs(nY);
116 Int_t zone=fNzone-1;
117 for (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   }
126 return zone;
127 }
128
129
130 void AliMUONsegmentationV1::SetPadCoord(Int_t iX, Int_t iY)
131 {    
132 GetPadCxy(iX,iY,fx,fy);
133 Float_t radius2;
134 if ( ( (radius2=fx*fx+fy*fy) > frSensMax2 || radius2 < frSensMin2 ) 
135      && MorePads() )
136   NextPad();
137
138 }
139
140 void 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
177 void 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
191 Int_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
202 Int_t AliMUONsegmentationV1::Ix()
203 // returns the X number of pad which has to increment charge
204 // due to parallel read-out
205 {
206 Int_t wix = TMath::Abs(fix)-1;
207 Int_t wiy = TMath::Abs(fiy)-1;
208 Int_t zone = GetZone(fix,fiy);
209 switch (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  }
222 return -1;
223 }
224
225 Int_t AliMUONsegmentationV1::ISector()
226 {
227 Int_t wix = TMath::Abs(fix)-1;
228 Int_t wiy = TMath::Abs(fiy)-1;
229 Int_t zone = GetZone(fix,fiy);
230 switch (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  }
243 return -1;
244 }
245
246 void 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
257 Int_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
274 void AliMUONsegmentationV1::
275 IntegrationLimits(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
283 void AliMUONsegmentationV1::
284 Neighbours(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
290 void AliMUONsegmentationV1::
291 FitXY(AliMUONRecCluster* ,TClonesArray* )
292     // Default : Centre of gravity method
293 {
294     ;
295 }