]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/ITS/tracking/AliHLTITSLayer.cxx
AliHLTVertexer is moved from ITS/tracking/. to global/.
[u/mrichter/AliRoot.git] / HLT / ITS / tracking / AliHLTITSLayer.cxx
1 // **************************************************************************
2 // This file is property of and copyright by the ALICE HLT Project          *
3 // ALICE Experiment at CERN, All rights reserved.                           *
4 //                                                                          *
5 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
6 //                  for The ALICE HLT Project.                              *
7 //                                                                          *
8 // Permission to use, copy, modify and distribute this software and its     *
9 // documentation strictly for non-commercial purposes is hereby granted     *
10 // without fee, provided that the above copyright notice appears in all     *
11 // copies and that both the copyright notice and this permission notice     *
12 // appear in the supporting documentation. The authors make no claims       *
13 // about the suitability of this software for any purpose. It is            *
14 // provided "as is" without express or implied warranty.                    *
15 //                                                                          *
16 //***************************************************************************
17
18
19 #include "AliHLTITSLayer.h"
20
21 //------------------------------------------------------------------------
22 AliHLTITSLayer::AliHLTITSLayer():
23 fR(0),
24 fPhiOffset(0),
25 fNladders(0),
26 fZOffset(0),
27 fNdetectors(0),
28 fDetectors(0),
29 fN(0),
30 fDy5(0),
31 fDy10(0),
32 fDy20(0),
33 fClustersCs(0),
34 fClusterIndexCs(0),
35 fYcs(0),
36 fZcs(0),
37 fNcs(0),
38 fCurrentSlice(-1),
39 fZmax(0),
40 fYmin(0),
41 fYmax(0),
42 fI(0),
43 fImax(0),
44 fSkip(0),
45 fAccepted(0),
46 fRoad(0){
47   //--------------------------------------------------------------------
48   //default AliHLTITSLayer constructor
49   //--------------------------------------------------------------------
50   for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++) {
51     fClusterWeight[i]=0;
52     fClusterTracks[0][i]=-1;
53     fClusterTracks[1][i]=-1;
54     fClusterTracks[2][i]=-1;    
55     fClusterTracks[3][i]=-1;    
56   }
57 }
58 //------------------------------------------------------------------------
59 AliHLTITSLayer::
60 AliHLTITSLayer(Double_t r,Double_t p,Double_t z,Int_t nl,Int_t nd):
61 fR(r),
62 fPhiOffset(p),
63 fNladders(nl),
64 fZOffset(z),
65 fNdetectors(nd),
66 fDetectors(0),
67 fN(0),
68 fDy5(0),
69 fDy10(0),
70 fDy20(0),
71 fClustersCs(0),
72 fClusterIndexCs(0),
73 fYcs(0),
74 fZcs(0),
75 fNcs(0),
76 fCurrentSlice(-1),
77 fZmax(0),
78 fYmin(0),
79 fYmax(0),
80 fI(0),
81 fImax(0),
82 fSkip(0),
83 fAccepted(0),
84 fRoad(0) {
85   //--------------------------------------------------------------------
86   //main AliHLTITSLayer constructor
87   //--------------------------------------------------------------------
88   fDetectors=new AliHLTITSDetector[fNladders*fNdetectors];
89   fRoad=2*fR*TMath::Sqrt(TMath::Pi()/1.);//assuming that there's only one cluster
90 }
91 //------------------------------------------------------------------------
92 AliHLTITSLayer::AliHLTITSLayer(const AliHLTITSLayer& layer):
93 fR(layer.fR),
94 fPhiOffset(layer.fPhiOffset),
95 fNladders(layer.fNladders),
96 fZOffset(layer.fZOffset),
97 fNdetectors(layer.fNdetectors),
98 fDetectors(layer.fDetectors),
99 fN(layer.fN),
100 fDy5(layer.fDy5),
101 fDy10(layer.fDy10),
102 fDy20(layer.fDy20),
103 fClustersCs(layer.fClustersCs),
104 fClusterIndexCs(layer.fClusterIndexCs),
105 fYcs(layer.fYcs),
106 fZcs(layer.fZcs),
107 fNcs(layer.fNcs),
108 fCurrentSlice(layer.fCurrentSlice),
109 fZmax(layer.fZmax),
110 fYmin(layer.fYmin),
111 fYmax(layer.fYmax),
112 fI(layer.fI),
113 fImax(layer.fImax),
114 fSkip(layer.fSkip),
115 fAccepted(layer.fAccepted),
116 fRoad(layer.fRoad){
117   //Copy constructor
118 }
119 //------------------------------------------------------------------------
120 AliHLTITSLayer::~AliHLTITSLayer() {
121   //--------------------------------------------------------------------
122   // AliHLTITSLayer destructor
123   //--------------------------------------------------------------------
124   delete [] fDetectors;
125   for (Int_t i=0; i<fN; i++) delete fClusters[i];
126   for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++) {
127     fClusterWeight[i]=0;
128     fClusterTracks[0][i]=-1;
129     fClusterTracks[1][i]=-1;
130     fClusterTracks[2][i]=-1;    
131     fClusterTracks[3][i]=-1;    
132   }
133 }
134 //------------------------------------------------------------------------
135 void AliHLTITSLayer::ResetClusters() {
136   //--------------------------------------------------------------------
137   // This function removes loaded clusters
138   //--------------------------------------------------------------------
139   for (Int_t i=0; i<fN; i++) delete fClusters[i];
140   for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++){
141     fClusterWeight[i]=0;
142     fClusterTracks[0][i]=-1;
143     fClusterTracks[1][i]=-1;
144     fClusterTracks[2][i]=-1;    
145     fClusterTracks[3][i]=-1;  
146   }
147   
148   fN=0;
149   fI=0;
150 }
151 //------------------------------------------------------------------------
152 void AliHLTITSLayer::ResetWeights() {
153   //--------------------------------------------------------------------
154   // This function reset weights of the clusters
155   //--------------------------------------------------------------------
156   for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++) {
157     fClusterWeight[i]=0;
158     fClusterTracks[0][i]=-1;
159     fClusterTracks[1][i]=-1;
160     fClusterTracks[2][i]=-1;    
161     fClusterTracks[3][i]=-1;  
162   }
163   for (Int_t i=0; i<fN;i++) {
164     AliITSRecPoint * cl = (AliITSRecPoint*)GetCluster(i);
165     if (cl&&cl->IsUsed()) cl->Use();
166   }
167
168 }
169 //------------------------------------------------------------------------
170 void AliHLTITSLayer::ResetRoad() {
171   //--------------------------------------------------------------------
172   // This function calculates the road defined by the cluster density
173   //--------------------------------------------------------------------
174   Int_t n=0;
175   for (Int_t i=0; i<fN; i++) {
176      if (TMath::Abs(fClusters[i]->GetZ())<fR) n++;
177   }
178   if (n>1) fRoad=2*fR*TMath::Sqrt(TMath::Pi()/n);
179 }
180 //------------------------------------------------------------------------
181 Int_t AliHLTITSLayer::InsertCluster(AliITSRecPoint *cl) {
182   //--------------------------------------------------------------------
183   //This function adds a cluster to this layer
184   //--------------------------------------------------------------------
185   if (fN==AliITSRecoParam::GetMaxClusterPerLayer()) {
186     ::Error("InsertCluster","Too many clusters !\n");
187     return 1;
188   }
189   fCurrentSlice=-1;
190   fClusters[fN]=cl;
191   fN++;
192   AliHLTITSDetector &det=GetDetector(cl->GetDetectorIndex());    
193   if (cl->GetY()<det.GetYmin()) det.SetYmin(cl->GetY());
194   if (cl->GetY()>det.GetYmax()) det.SetYmax(cl->GetY());
195   if (cl->GetZ()<det.GetZmin()) det.SetZmin(cl->GetZ());
196   if (cl->GetZ()>det.GetZmax()) det.SetZmax(cl->GetZ());
197                              
198   return 0;
199 }
200 //------------------------------------------------------------------------
201 void  AliHLTITSLayer::SortClusters()
202 {
203   //
204   //sort clusters
205   //
206   AliITSRecPoint **clusters = new AliITSRecPoint*[fN];
207   Float_t *z                = new Float_t[fN];
208   Int_t   * index           = new Int_t[fN];
209   //
210   for (Int_t i=0;i<fN;i++){
211     z[i] = fClusters[i]->GetZ();
212   }
213   TMath::Sort(fN,z,index,kFALSE);
214   for (Int_t i=0;i<fN;i++){
215     clusters[i] = fClusters[index[i]];
216   }
217   //
218   for (Int_t i=0;i<fN;i++){
219     fClusters[i] = clusters[i];
220     fZ[i]        = fClusters[i]->GetZ();
221     AliHLTITSDetector &det=GetDetector(fClusters[i]->GetDetectorIndex());    
222     Double_t y=fR*det.GetPhi() + fClusters[i]->GetY();
223     if (y>2.*fR*TMath::Pi()) y -= 2.*fR*TMath::Pi();
224     fY[i] = y;
225   }
226   delete[] index;
227   delete[] z;
228   delete[] clusters;
229   //
230
231   fYB[0]=10000000;
232   fYB[1]=-10000000;
233   for (Int_t i=0;i<fN;i++){
234     if (fY[i]<fYB[0]) fYB[0]=fY[i];
235     if (fY[i]>fYB[1]) fYB[1]=fY[i];
236     fClusterIndex[i] = i;
237   }
238   //
239   // fill slices
240   fDy5 = (fYB[1]-fYB[0])/5.;
241   fDy10 = (fYB[1]-fYB[0])/10.;
242   fDy20 = (fYB[1]-fYB[0])/20.;
243   for (Int_t i=0;i<6;i++)  fN5[i] =0;  
244   for (Int_t i=0;i<11;i++) fN10[i]=0;  
245   for (Int_t i=0;i<21;i++) fN20[i]=0;
246   //  
247   for (Int_t i=0;i<6;i++) {fBy5[i][0] =  fYB[0]+(i-0.75)*fDy5; fBy5[i][1] =  fYB[0]+(i+0.75)*fDy5;}
248   for (Int_t i=0;i<11;i++) {fBy10[i][0] =  fYB[0]+(i-0.75)*fDy10; fBy10[i][1] =  fYB[0]+(i+0.75)*fDy10;} 
249   for (Int_t i=0;i<21;i++) {fBy20[i][0] =  fYB[0]+(i-0.75)*fDy20; fBy20[i][1] =  fYB[0]+(i+0.75)*fDy20;}
250   //
251   //
252   for (Int_t i=0;i<fN;i++)
253     for (Int_t irot=-1;irot<=1;irot++){
254       Float_t curY = fY[i]+irot*TMath::TwoPi()*fR; 
255       // slice 5
256       for (Int_t slice=0; slice<6;slice++){
257         if (fBy5[slice][0]<curY && curY<fBy5[slice][1]&&fN5[slice]<AliITSRecoParam::GetMaxClusterPerLayer5()){
258           fClusters5[slice][fN5[slice]] = fClusters[i];
259           fY5[slice][fN5[slice]] = curY;
260           fZ5[slice][fN5[slice]] = fZ[i];
261           fClusterIndex5[slice][fN5[slice]]=i;
262           fN5[slice]++;
263         }
264       }
265       // slice 10
266       for (Int_t slice=0; slice<11;slice++){
267         if (fBy10[slice][0]<curY && curY<fBy10[slice][1]&&fN10[slice]<AliITSRecoParam::GetMaxClusterPerLayer10()){
268           fClusters10[slice][fN10[slice]] = fClusters[i];
269           fY10[slice][fN10[slice]] = curY;
270           fZ10[slice][fN10[slice]] = fZ[i];
271           fClusterIndex10[slice][fN10[slice]]=i;
272           fN10[slice]++;
273         }
274       }
275       // slice 20
276       for (Int_t slice=0; slice<21;slice++){
277         if (fBy20[slice][0]<curY && curY<fBy20[slice][1]&&fN20[slice]<AliITSRecoParam::GetMaxClusterPerLayer20()){
278           fClusters20[slice][fN20[slice]] = fClusters[i];
279           fY20[slice][fN20[slice]] = curY;
280           fZ20[slice][fN20[slice]] = fZ[i];
281           fClusterIndex20[slice][fN20[slice]]=i;
282           fN20[slice]++;
283         }
284       }      
285     }
286
287   //
288   // consistency check
289   //
290   for (Int_t i=0;i<fN-1;i++){
291     if (fZ[i]>fZ[i+1]){
292       printf("Bug\n");
293     }
294   }
295   //
296   for (Int_t slice=0;slice<21;slice++)
297   for (Int_t i=0;i<fN20[slice]-1;i++){
298     if (fZ20[slice][i]>fZ20[slice][i+1]){
299       printf("Bug\n");
300     }
301   }
302
303
304 }
305 //------------------------------------------------------------------------
306 Int_t AliHLTITSLayer::FindClusterIndex(Float_t z) const {
307   //--------------------------------------------------------------------
308   // This function returns the index of the nearest cluster 
309   //--------------------------------------------------------------------
310   Int_t ncl=0;
311   const Float_t *zcl;  
312   if (fCurrentSlice<0) {
313     ncl = fN;
314     zcl   = fZ;
315   }
316   else{
317     ncl   = fNcs;
318     zcl   = fZcs;;
319   }
320   
321   if (ncl==0) return 0;
322   Int_t b=0, e=ncl-1, m=(b+e)/2;
323   for (; b<e; m=(b+e)/2) {
324     //    if (z > fClusters[m]->GetZ()) b=m+1;
325     if (z > zcl[m]) b=m+1;
326     else e=m; 
327   }
328   return m;
329 }
330
331 //------------------------------------------------------------------------
332 void AliHLTITSLayer::
333 SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) {
334   //--------------------------------------------------------------------
335   // This function sets the "window"
336   //--------------------------------------------------------------------
337  
338   Double_t circle=2*TMath::Pi()*fR;
339   fYmin = ymin; fYmax =ymax;
340   Float_t ymiddle = (fYmin+fYmax)*0.5;
341   if (ymiddle<fYB[0]) {
342     fYmin+=circle; fYmax+=circle; ymiddle+=circle;
343   } else if (ymiddle>fYB[1]) {
344     fYmin-=circle; fYmax-=circle; ymiddle-=circle;
345   }
346   
347   //
348   fCurrentSlice =-1;
349   // defualt take all
350   fClustersCs = fClusters;
351   fClusterIndexCs = fClusterIndex;
352   fYcs  = fY;
353   fZcs  = fZ;
354   fNcs  = fN;
355   //
356   //is in 20 slice?
357   if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy20){
358     Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy20);
359     if (slice<0) slice=0;
360     if (slice>20) slice=20;
361     Bool_t isOK = (fYmin>fBy20[slice][0]&&fYmax<fBy20[slice][1]);
362     if (isOK) {
363       fCurrentSlice=slice;
364       fClustersCs = fClusters20[fCurrentSlice];
365       fClusterIndexCs = fClusterIndex20[fCurrentSlice];
366       fYcs  = fY20[fCurrentSlice];
367       fZcs  = fZ20[fCurrentSlice];
368       fNcs  = fN20[fCurrentSlice];
369     }
370   }  
371   //
372   //is in 10 slice?
373   if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy10){
374     Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy10);
375     if (slice<0) slice=0;
376     if (slice>10) slice=10;
377     Bool_t isOK = (fYmin>fBy10[slice][0]&&fYmax<fBy10[slice][1]);
378     if (isOK) {
379       fCurrentSlice=slice;
380       fClustersCs = fClusters10[fCurrentSlice];
381       fClusterIndexCs = fClusterIndex10[fCurrentSlice];
382       fYcs  = fY10[fCurrentSlice];
383       fZcs  = fZ10[fCurrentSlice];
384       fNcs  = fN10[fCurrentSlice];
385     }
386   }  
387   //
388   //is in 5 slice?
389   if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy5){
390     Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy5);
391     if (slice<0) slice=0;
392     if (slice>5) slice=5;
393     Bool_t isOK = (fYmin>fBy5[slice][0]&&fYmax<fBy5[slice][1]);
394     if (isOK) {
395       fCurrentSlice=slice;
396       fClustersCs = fClusters5[fCurrentSlice];
397       fClusterIndexCs = fClusterIndex5[fCurrentSlice];
398       fYcs  = fY5[fCurrentSlice];
399       fZcs  = fZ5[fCurrentSlice];
400       fNcs  = fN5[fCurrentSlice];
401     }
402   }  
403   //  
404   fI=FindClusterIndex(zmin); fZmax=zmax;
405   fImax = TMath::Min(FindClusterIndex(zmax)+1,fNcs);
406   fSkip = 0;
407   fAccepted =0;
408
409   return;
410 }
411 //------------------------------------------------------------------------
412 Int_t AliHLTITSLayer::
413 FindDetectorIndex(Double_t phi, Double_t z) const {
414   //--------------------------------------------------------------------
415   //This function finds the detector crossed by the track
416   //--------------------------------------------------------------------
417   Double_t dphi;
418   if (fZOffset<0)            // old geometry
419     dphi = -(phi-fPhiOffset);
420   else                       // new geometry
421     dphi = phi-fPhiOffset;
422
423
424   if      (dphi <  0) dphi += 2*TMath::Pi();
425   else if (dphi >= 2*TMath::Pi()) dphi -= 2*TMath::Pi();
426   Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5);
427   if (np>=fNladders) np-=fNladders;
428   if (np<0)          np+=fNladders;
429
430
431   Double_t dz=fZOffset-z;
432   Double_t nnz = dz*(fNdetectors-1)*0.5/fZOffset+0.5;
433   Int_t nz = (nnz<0 ? -1 : (Int_t)nnz);
434   if (nz>=fNdetectors) return -1;
435   if (nz<0)            return -1;
436
437   // ad hoc correction for 3rd ladder of SDD inner layer,
438   // which is reversed (rotated by pi around local y)
439   // this correction is OK only from AliITSv11Hybrid onwards
440   if (GetR()>12. && GetR()<20.) { // SDD inner
441     if(np==2) { // 3rd ladder
442       nz = (fNdetectors-1) - nz;
443     } 
444   }
445   //printf("ndet %d phi %f z %f  np %d nz %d\n",fNdetectors,phi,z,np,nz);
446
447
448   return np*fNdetectors + nz;
449 }
450 //------------------------------------------------------------------------
451 const AliITSRecPoint *AliHLTITSLayer::GetNextCluster(Int_t &ci,Bool_t test)
452 {
453   //--------------------------------------------------------------------
454   // This function returns clusters within the "window" 
455   //--------------------------------------------------------------------
456
457   if (fCurrentSlice<0) {
458     Double_t rpi2 = 2.*fR*TMath::Pi();
459     for (Int_t i=fI; i<fImax; i++) {
460       Double_t y = fY[i];
461       if (fYmax<y) y -= rpi2;
462       if (fYmin>y) y += rpi2;
463       if (y<fYmin) continue;
464       if (y>fYmax) continue;
465       if (fClusters[i]->GetQ()==0&&fSkip==2) continue;
466       ci=i;
467       if (!test) fI=i+1;
468       return fClusters[i];
469     }
470   } else {
471     for (Int_t i=fI; i<fImax; i++) {
472       if (fYcs[i]<fYmin) continue;
473       if (fYcs[i]>fYmax) continue;
474       if (fClustersCs[i]->GetQ()==0&&fSkip==2) continue;
475       ci=fClusterIndexCs[i];
476       if (!test) fI=i+1;
477       return fClustersCs[i];
478     }
479   }
480   return 0;
481 }
482 //------------------------------------------------------------------------
483 Double_t AliHLTITSLayer::GetThickness(Double_t y,Double_t z,Double_t &x0)
484 const {
485   //--------------------------------------------------------------------
486   // This function returns the layer thickness at this point (units X0)
487   //--------------------------------------------------------------------
488   Double_t d=0.0085;
489   x0=AliITSRecoParam::GetX0Air();
490   if (43<fR&&fR<45) { //SSD2
491      Double_t dd=0.0034;
492      d=dd;
493      if (TMath::Abs(y-0.00)>3.40) d+=dd;
494      if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);}
495      if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);}
496      for (Int_t i=0; i<12; i++) {
497        if (TMath::Abs(z-3.9*(i+0.5))<0.15) {
498           if (TMath::Abs(y-0.00)>3.40) d+=dd;
499           d+=0.0034; 
500           break;
501        }
502        if (TMath::Abs(z+3.9*(i+0.5))<0.15) {
503           if (TMath::Abs(y-0.00)>3.40) d+=dd;
504           d+=0.0034; 
505           break;
506        }         
507        if (TMath::Abs(z-3.4-3.9*i)<0.50) {d+=(0.016-0.0034); break;}
508        if (TMath::Abs(z+0.5+3.9*i)<0.50) {d+=(0.016-0.0034); break;}
509      }
510   } else 
511   if (37<fR&&fR<41) { //SSD1
512      Double_t dd=0.0034;
513      d=dd;
514      if (TMath::Abs(y-0.00)>3.40) d+=dd;
515      if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);}
516      if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);}
517      for (Int_t i=0; i<11; i++) {
518        if (TMath::Abs(z-3.9*i)<0.15) {
519           if (TMath::Abs(y-0.00)>3.40) d+=dd;
520           d+=dd; 
521           break;
522        }
523        if (TMath::Abs(z+3.9*i)<0.15) {
524           if (TMath::Abs(y-0.00)>3.40) d+=dd;
525           d+=dd; 
526           break;
527        }         
528        if (TMath::Abs(z-1.85-3.9*i)<0.50) {d+=(0.016-0.0034); break;}
529        if (TMath::Abs(z+2.05+3.9*i)<0.50) {d+=(0.016-0.0034); break;}         
530      }
531   } else
532   if (13<fR&&fR<26) { //SDD
533      Double_t dd=0.0033;
534      d=dd;
535      if (TMath::Abs(y-0.00)>3.30) d+=dd;
536
537      if (TMath::Abs(y-1.80)<0.55) {
538         d+=0.016;
539         for (Int_t j=0; j<20; j++) {
540           if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;}
541           if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;}
542         } 
543      }
544      if (TMath::Abs(y+1.80)<0.55) {
545         d+=0.016;
546         for (Int_t j=0; j<20; j++) {
547           if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;}
548           if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;}
549         } 
550      }
551
552      for (Int_t i=0; i<4; i++) {
553        if (TMath::Abs(z-7.3*i)<0.60) {
554           d+=dd;
555           if (TMath::Abs(y-0.00)>3.30) d+=dd; 
556           break;
557        }
558        if (TMath::Abs(z+7.3*i)<0.60) {
559           d+=dd; 
560           if (TMath::Abs(y-0.00)>3.30) d+=dd; 
561           break;
562        }
563      }
564   } else
565   if (6<fR&&fR<8) {   //SPD2
566      Double_t dd=0.0063; x0=21.5;
567      d=dd;
568      if (TMath::Abs(y-3.08)>0.5) d+=dd;
569      if (TMath::Abs(y-3.03)<0.10) d+=0.014;
570   } else
571   if (3<fR&&fR<5) {   //SPD1
572      Double_t dd=0.0063; x0=21.5;
573      d=dd;
574      if (TMath::Abs(y+0.21)>0.6) d+=dd;
575      if (TMath::Abs(y+0.10)<0.10) d+=0.014;
576   }
577
578   return d;
579 }
580
581 //------------------------------------------------------------------------
582 Int_t AliHLTITSLayer::InRoad() const {
583   //-------------------------------------------------------------------
584   // This function returns number of clusters within the "window" 
585   //--------------------------------------------------------------------
586   Int_t ncl=0;
587   for (Int_t i=fI; i<fN; i++) {
588     const AliITSRecPoint *c=fClusters[i];
589     if (c->GetZ() > fZmax) break;
590     if (c->IsUsed()) continue;
591     const AliHLTITSDetector &det=GetDetector(c->GetDetectorIndex());    
592     Double_t y=fR*det.GetPhi() + c->GetY();
593
594     if (y>2.*fR*TMath::Pi()) y -= 2*fR*TMath::Pi();
595     if (y>1.*fR*TMath::Pi() && fYmax<y) y -= 2*fR*TMath::Pi();
596
597     if (y<fYmin) continue;
598     if (y>fYmax) continue;
599     ncl++;
600   }
601   return ncl;
602 }
603