New TTask based method to do Digits To clusters. Works with files of multiple
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationSlatModule.cxx
CommitLineData
4c503756 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
16/*
17$Log$
81a0c7bd 18Revision 1.10 2001/05/16 14:57:17 alibrary
19New files for folders and Stack
20
9e1a0ddb 21Revision 1.9 2001/01/26 21:25:48 morsch
22Empty default constructors and.
23
e9e4cdf2 24Revision 1.8 2001/01/17 20:53:40 hristov
25Destructors corrected to avoid memory leaks
26
c2c0190f 27Revision 1.7 2000/12/21 22:12:41 morsch
28Clean-up of coding rule violations,
29
de05461e 30Revision 1.6 2000/11/06 09:20:43 morsch
31AliMUON delegates part of BuildGeometry() to AliMUONSegmentation using the
32Draw() method. This avoids code and parameter replication.
33
aaf4addd 34Revision 1.5 2000/10/26 19:32:04 morsch
35Problem with iteration over y-pads for 2nd cathode corrected.
36
d4ee3c3e 37Revision 1.4 2000/10/25 19:56:55 morsch
38Handle correctly slats with less than 3 segmentation zones.
39
f30dea32 40Revision 1.3 2000/10/22 16:56:32 morsch
41- Store chamber number as slat id.
42
de2f6d11 43Revision 1.2 2000/10/18 11:42:06 morsch
44- AliMUONRawCluster contains z-position.
45- Some clean-up of useless print statements during initialisations.
46
3e1872ed 47Revision 1.1 2000/10/06 08:59:03 morsch
48Segmentation classes for bending and non bending plane slat modules (A. de Falco, A. Morsch)
49
4c503756 50*/
51
52/////////////////////////////////////////////////////
53// Segmentation classes for slat modules //
54// to be used with AluMUONSegmentationSlat //
55/////////////////////////////////////////////////////
56
57
58#include "AliMUONSegmentationSlatModule.h"
aaf4addd 59#include "AliRun.h"
60#include "AliMUON.h"
4c503756 61#include <TMath.h>
62#include <iostream.h>
63
64#include "AliMUONSegmentationV01.h"
65
66//___________________________________________
67ClassImp(AliMUONSegmentationSlatModule)
68
69AliMUONSegmentationSlatModule::AliMUONSegmentationSlatModule()
70{
71// Default constructor
81a0c7bd 72 fNDiv = 0;
73 fDpxD = 0;
e9e4cdf2 74}
75
76AliMUONSegmentationSlatModule::AliMUONSegmentationSlatModule(Int_t nsec)
77{
78// Non default constructor
79 fNsec = nsec;
4c503756 80 fNDiv = new TArrayI(fNsec);
81 fDpxD = new TArrayF(fNsec);
82 (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;
83 (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;
e9e4cdf2 84}
85
86AliMUONSegmentationSlatModule::~AliMUONSegmentationSlatModule()
87{
88// Destructor
89 if (fNDiv) delete fNDiv;
90 if (fDpxD) delete fDpxD;
4c503756 91}
92
93void AliMUONSegmentationSlatModule::SetPcbBoards(Int_t n[4])
94{
95//
96// Set Pcb Board segmentation zones
97 for (Int_t i=0; i<4; i++) fPcbBoards[i]=n[i];
98}
99
100
101void AliMUONSegmentationSlatModule::SetPadDivision(Int_t ndiv[4])
102{
103//
104// Defines the pad size perp. to the anode wire (y) for different sectors.
105// Pad sizes are defined as integral fractions ndiv of a basis pad size
106// fDpx
107//
108 for (Int_t i=0; i<4; i++) {
109 (*fNDiv)[i]=ndiv[i];
110 }
111 ndiv[0]=ndiv[1];
112}
113
114Float_t AliMUONSegmentationSlatModule::Dpx(Int_t isec) const
115{
116// Return x-strip width
117 return (*fDpxD)[isec];
118}
119
120
121Float_t AliMUONSegmentationSlatModule::Dpy(Int_t isec) const
122{
123// Return y-strip width
124
125 return fDpy;
126}
127
128
129void AliMUONSegmentationSlatModule::
130GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
131{
132// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
133//
134 iy = Int_t(y/fDpy)+1;
135 if (iy > fNpy) iy= fNpy;
136//
137// Find sector isec
138
139 Int_t isec=-1;
140 for (Int_t i=fNsec-1; i > 0; i--) {
141 if (x >= fCx[i-1]) {
142 isec=i;
f30dea32 143 if (fCx[isec] == fCx[isec-1] && isec > 1) isec--;
4c503756 144 break;
145 }
146 }
147
148 if (isec>0) {
149 ix= Int_t((x-fCx[isec-1])/(*fDpxD)[isec])
150 +fNpxS[isec-1]+1;
151 } else if (isec == 0) {
152 ix= Int_t(x/(*fDpxD)[isec])+1;
153 } else {
154 ix=0;
155 iy=0;
156 }
157}
158
159void AliMUONSegmentationSlatModule::
160GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
161{
162// Returns real coordinates (x,y) for given pad coordinates (ix,iy)
163//
164 y = Float_t(iy*fDpy)-fDpy/2.;
165//
166// Find sector isec
167 Int_t isec=AliMUONSegmentationSlatModule::Sector(ix,iy);
de2f6d11 168 if (isec == -1) printf("\n PadC %d %d %d %d \n ", isec, fId, ix, iy);
4c503756 169//
170 if (isec>0) {
171 x = fCx[isec-1]+(ix-fNpxS[isec-1])*(*fDpxD)[isec];
172 x = x-(*fDpxD)[isec]/2;
173 } else {
174 x=y=0;
175 }
176}
177
178void AliMUONSegmentationSlatModule::
179SetPad(Int_t ix, Int_t iy)
180{
181 //
182 // Sets virtual pad coordinates, needed for evaluating pad response
183 // outside the tracking program
184 GetPadC(ix,iy,fX,fY);
185 fSector=Sector(ix,iy);
186}
187
188void AliMUONSegmentationSlatModule::
189SetHit(Float_t x, Float_t y)
190{
de05461e 191// Set current hit
192//
4c503756 193 fXhit = x;
194 fYhit = y;
195
196 if (x < 0) fXhit = 0;
197 if (y < 0) fYhit = 0;
198
199 if (x >= fCx[fNsec-1]) fXhit = fCx[fNsec-1];
200 if (y >= fDyPCB) fYhit = fDyPCB;
201
202
203}
204
205
206void AliMUONSegmentationSlatModule::
207FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
208{
209// Initialises iteration over pads for charge distribution algorithm
210//
211 //
212 // Find the wire position (center of charge distribution)
213 Float_t x0a=GetAnod(xhit);
214 fXhit=x0a;
215 fYhit=yhit;
216 //
217 // and take fNsigma*sigma around this center
218 Float_t x01=x0a - dx;
219 Float_t x02=x0a + dx;
220 Float_t y01=yhit - dy;
221 Float_t y02=yhit + dy;
4c503756 222 if (x01 < 0) x01 = 0;
223 if (y01 < 0) y01 = 0;
f30dea32 224
225 if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1];
d4ee3c3e 226
4c503756 227
f30dea32 228
4c503756 229 Int_t isec=-1;
230 for (Int_t i=fNsec-1; i > 0; i--) {
231 if (x02 >= fCx[i-1]) {
232 isec=i;
f30dea32 233 if (fCx[isec] == fCx[isec-1] && isec > 1) isec--;
4c503756 234 break;
235 }
236 }
d4ee3c3e 237 y02 += Dpy(isec);
238 if (y02 >= fDyPCB) y02 = fDyPCB;
4c503756 239
4c503756 240 //
241 // find the pads over which the charge distributes
242 GetPadI(x01,y01,fIxmin,fIymin);
243 GetPadI(x02,y02,fIxmax,fIymax);
f30dea32 244
4c503756 245 if (fIxmax > fNpx) fIxmax=fNpx;
246 if (fIymax > fNpyS[isec]) fIymax = fNpyS[isec];
d4ee3c3e 247
4c503756 248 fXmin=x01;
d4ee3c3e 249 fXmax=x02;
4c503756 250 fYmin=y01;
d4ee3c3e 251 fYmax=y02;
252
4c503756 253 //
254 // Set current pad to lower left corner
255 if (fIxmax < fIxmin) fIxmax=fIxmin;
256 if (fIymax < fIymin) fIymax=fIymin;
257 fIx=fIxmin;
258 fIy=fIymin;
259
260 GetPadC(fIx,fIy,fX,fY);
261 fSector=Sector(fIx,fIy);
d4ee3c3e 262/*
263 printf("\n \n First Pad: %d %d %f %f %d %d %d %f" ,
264 fIxmin, fIxmax, fXmin, fXmax, fNpx, fId, isec, Dpy(isec));
265 printf("\n \n First Pad: %d %d %f %f %d %d %d %f",
266 fIymin, fIymax, fYmin, fYmax, fNpyS[isec], fId, isec, Dpy(isec));
267*/
4c503756 268}
269
270void AliMUONSegmentationSlatModule::NextPad()
271{
272// Stepper for the iteration over pads
273//
274// Step to next pad in the integration region
275// step from left to right
276 if (fIx != fIxmax) {
277 fIx++;
278 GetPadC(fIx,fIy,fX,fY);
279 fSector=Sector(fIx,fIy);
280// step up
281 } else if (fIy != fIymax) {
282 fIx=fIxmin;
283 fIy++;
284 GetPadC(fIx,fIy,fX,fY);
285 fSector=Sector(fIx,fIy);
286
287 } else {
288 fIx=-1;
289 fIy=-1;
290 }
291// printf("\n Next Pad %d %d %f %f %d %d %d %d %d ",
292}
293
294
295Int_t AliMUONSegmentationSlatModule::MorePads()
de05461e 296{
4c503756 297// Stopping condition for the iterator over pads
298//
299// Are there more pads in the integration region
4c503756 300
301 return (fIx != -1 || fIy != -1);
302}
303
304
305Int_t AliMUONSegmentationSlatModule::Sector(Int_t ix, Int_t iy)
306{
307//
308// Determine segmentation zone from pad coordinates
309//
310 Int_t isec=-1;
311 for (Int_t i=0; i < fNsec; i++) {
312 if (ix <= fNpxS[i]) {
313 isec=i;
314 break;
315 }
316 }
317 if (isec == -1) printf("\n Sector: Attention isec ! %d %d %d %d \n",
318 fId, ix, iy,fNpxS[3]);
319
320 return isec;
321
322}
323
324void AliMUONSegmentationSlatModule::
325IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
326{
327// Returns integration limits for current pad
328//
329
330 x1=fXhit-fX-Dpx(fSector)/2.;
331 x2=x1+Dpx(fSector);
332 y1=fYhit-fY-Dpy(fSector)/2.;
333 y2=y1+Dpy(fSector);
334// printf("\n Integration Limits %f %f %f %f %d %f", x1, x2, y1, y2, fSector, Dpx(fSector));
335
336}
337
338void AliMUONSegmentationSlatModule::
339Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
340{
341// Returns list of next neighbours for given Pad (iX, iY)
342//
343//
344 Int_t i=0;
345//
346// step right
347 if (iX+1 <= fNpx) {
348 Xlist[i]=iX+1;
349 Ylist[i++]=iY;
350 }
351//
352// step left
353 if (iX-1 > 0) {
354 Xlist[i]=iX-1;
355 Ylist[i++]=iY;
356 }
357
358//
359// step up
360 if (iY+1 <= fNpy) {
361 Xlist[i]=iX;
362 Ylist[i++]=iY+1;
363 }
364//
365// step down
366 if (iY-1 > 0) {
367 Xlist[i]=iX;
368 Ylist[i++]=iY-1;
369 }
370
371 *Nlist=i;
372}
373
374
375void AliMUONSegmentationSlatModule::Init(Int_t chamber)
376{
4c503756 377//
378// Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
379// These arrays help in converting from real to pad co-ordinates and
380// vice versa
381//
382// Segmentation is defined by rectangular modules approximating
383// concentric circles as shown below
384//
385// PCB module size in cm
9e1a0ddb 386 // printf("\n Initialise Segmentation SlatModule \n");
de05461e 387
4c503756 388 fDxPCB=40;
389 fDyPCB=40;
390//
391// number of pad rows per PCB
392//
393 Int_t nPyPCB=Int_t(fDyPCB/fDpy);
394//
395// maximum number of pad rows
396 fNpy=nPyPCB;
397//
398// Calculate padsize along x
399 (*fDpxD)[fNsec-1]=fDpx;
400 if (fNsec > 1) {
401 for (Int_t i=fNsec-2; i>=0; i--){
402 (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i];
4c503756 403 }
404 }
405//
406// fill the arrays defining the pad segmentation boundaries
407//
408//
409// Loop over sectors (isec=0 is the dead space surounding the beam pipe)
410 for (Int_t isec=0; isec<4; isec++) {
411 if (isec==0) {
412 fNpxS[0] = 0;
413 fNpyS[0] = 0;
414 fCx[0] = 0;
415 } else {
416 fNpxS[isec]=fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]);
417 fNpyS[isec]=fNpy;
418 fCx[isec]=fCx[isec-1] + fPcbBoards[isec]*fDxPCB;
419 }
420 } // sectors
421// maximum number of pad rows
422 fNpy=nPyPCB;
423 fNpx=fNpxS[3];
de2f6d11 424//
425 fId = chamber;
4c503756 426}
427
428
429
430
431
432
433
434
435
436
437
438