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