]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSClusterFinderV2SSD.cxx
Compilation warning removed
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinderV2SSD.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2009, 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 /* $Id$ */
17
18 ////////////////////////////////////////////////////////////////////////////
19 //            Implementation of the ITS clusterer V2 class                //
20 //                                                                        //
21 //          Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch            //
22 //          Revised: Enrico Fragiacomo, enrico.fragiacomo@ts.infn.it      //
23 //                                                                        //
24 ///////////////////////////////////////////////////////////////////////////
25
26 #include <Riostream.h>
27
28
29 #include "AliITSClusterFinderV2SSD.h"
30 #include "AliITSRecPoint.h"
31 #include "AliITSgeomTGeo.h"
32 #include "AliITSDetTypeRec.h"
33 #include "AliRawReader.h"
34 #include "AliITSRawStreamSSD.h"
35 #include <TClonesArray.h>
36 #include "AliITSdigitSSD.h"
37 #include "AliITSCalibrationSSD.h"
38
39 Short_t *AliITSClusterFinderV2SSD::fgPairs = 0x0;
40 Int_t    AliITSClusterFinderV2SSD::fgPairsSize = 0;
41
42 ClassImp(AliITSClusterFinderV2SSD)
43
44
45 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp),
46 fLastSSD1(AliITSgeomTGeo::GetModuleIndex(6,1,1)-1),
47 fYpitchSSD(0.0095),
48 fHwSSD(3.65),
49 fHlSSD(2.00),
50 fTanP(0.0275),
51 fTanN(0.0075){
52
53   //Default constructor
54
55 }
56  
57 //______________________________________________________________________
58 AliITSClusterFinderV2SSD::AliITSClusterFinderV2SSD(const AliITSClusterFinderV2SSD &cf) : AliITSClusterFinderV2(cf),                                             fLastSSD1(cf.fLastSSD1),
59 fYpitchSSD(cf.fYpitchSSD),
60 fHwSSD(cf.fHwSSD),
61 fHlSSD(cf.fHlSSD),
62 fTanP(cf.fTanP),
63 fTanN(cf.fTanN)
64 {
65   // Copy constructor
66
67 }
68
69 //______________________________________________________________________
70 AliITSClusterFinderV2SSD& AliITSClusterFinderV2SSD::operator=(const AliITSClusterFinderV2SSD&  cf ){
71   // Assignment operator
72
73   this->~AliITSClusterFinderV2SSD();
74   new(this) AliITSClusterFinderV2SSD(cf);
75   return *this;
76 }
77
78
79 void AliITSClusterFinderV2SSD::FindRawClusters(Int_t mod){
80
81   //Find clusters V2
82   SetModule(mod);
83   FindClustersSSD(fDigits);
84
85 }
86
87 void AliITSClusterFinderV2SSD::FindClustersSSD(TClonesArray *alldigits) {
88   //------------------------------------------------------------
89   // Actual SSD cluster finder
90   //------------------------------------------------------------
91   AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)GetResp(fModule);
92   Float_t gain=0;
93
94   Int_t smaxall=alldigits->GetEntriesFast();
95   if (smaxall==0) return;
96   //  TObjArray *digits = new TObjArray;
97   TObjArray digits;
98   for (Int_t i=0;i<smaxall; i++){
99     AliITSdigitSSD *d=(AliITSdigitSSD*)alldigits->UncheckedAt(i);
100
101     if(d->IsSideP()) gain = cal->GetGainP(d->GetStripNumber());  
102     else gain = cal->GetGainN(d->GetStripNumber());
103
104     Float_t q=gain*d->GetSignal(); // calibration brings mip peaks around 120 (in ADC units)
105     q=cal->ADCToKeV(q); // converts the charge in KeV from ADC units
106     //Float_t q=d->GetSignal()/4.29;// temp. fix (for PID purposed - normalis. to be checked)
107     d->SetSignal(Int_t(q));
108
109     if (d->GetSignal()<3) continue;
110     digits.AddLast(d);
111   }
112   Int_t smax = digits.GetEntriesFast();
113   if (smax==0) return;
114   
115   const Int_t kMax=1000;
116   Int_t np=0, nn=0; 
117   Ali1Dcluster pos[kMax], neg[kMax];
118   Float_t y=0., q=0., qmax=0.; 
119   Int_t lab[4]={-2,-2,-2,-2};
120   
121   AliITSdigitSSD *d=(AliITSdigitSSD*)digits.UncheckedAt(0);
122   q += d->GetSignal();
123   y += d->GetCoord2()*d->GetSignal();
124   qmax=d->GetSignal();
125   lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
126   Int_t curr=d->GetCoord2();
127   Int_t flag=d->GetCoord1();
128   Int_t *n=&nn;
129   Ali1Dcluster *c=neg;
130   Int_t nd=1;
131   Int_t milab[10];
132   for (Int_t ilab=0;ilab<10;ilab++){
133     milab[ilab]=-2;
134   }
135   milab[0]=d->GetTrack(0); milab[1]=d->GetTrack(1); milab[2]=d->GetTrack(2);
136
137   for (Int_t s=1; s<smax; s++) {
138       d=(AliITSdigitSSD*)digits.UncheckedAt(s);      
139       Int_t strip=d->GetCoord2();
140       if ((strip-curr) > 1 || flag!=d->GetCoord1()) {
141          c[*n].SetY(y/q);
142          c[*n].SetQ(q);
143          c[*n].SetNd(nd);
144          CheckLabels2(milab);
145          c[*n].SetLabels(milab);
146          //Split suspiciously big cluster
147          if (nd>4&&nd<25) {
148            c[*n].SetY(y/q-0.25*nd);
149            c[*n].SetQ(0.5*q);
150            (*n)++;
151            if (*n==kMax) {
152              Error("FindClustersSSD","Too many 1D clusters !");
153              return;
154            }
155            c[*n].SetY(y/q+0.25*nd);
156            c[*n].SetQ(0.5*q);
157            c[*n].SetNd(nd);
158            c[*n].SetLabels(milab);
159          }       
160          (*n)++;
161          if (*n==kMax) {
162           Error("FindClustersSSD","Too many 1D clusters !");
163           return;
164          }
165          y=q=qmax=0.;
166          nd=0;
167          lab[0]=lab[1]=lab[2]=-2;
168          //
169          for (Int_t ilab=0;ilab<10;ilab++){
170            milab[ilab]=-2;
171          }
172          //
173          if (flag!=d->GetCoord1()) { n=&np; c=pos; }
174       }
175       flag=d->GetCoord1();
176       q += d->GetSignal();
177       y += d->GetCoord2()*d->GetSignal();
178       nd++;
179       if (d->GetSignal()>qmax) {
180          qmax=d->GetSignal();
181          lab[0]=d->GetTrack(0); lab[1]=d->GetTrack(1); lab[2]=d->GetTrack(2);
182       }
183       for (Int_t ilab=0;ilab<10;ilab++) {
184         if (d->GetTrack(ilab)>=0) AddLabel(milab, (d->GetTrack(ilab))); 
185       }
186       curr=strip;
187   }
188   c[*n].SetY(y/q);
189   c[*n].SetQ(q);
190   c[*n].SetNd(nd);
191   c[*n].SetLabels(lab);
192   //Split suspiciously big cluster
193   if (nd>4 && nd<25) {
194      c[*n].SetY(y/q-0.25*nd);
195      c[*n].SetQ(0.5*q);
196      (*n)++;
197      if (*n==kMax) {
198         Error("FindClustersSSD","Too many 1D clusters !");
199         return;
200      }
201      c[*n].SetY(y/q+0.25*nd);
202      c[*n].SetQ(0.5*q);
203      c[*n].SetNd(nd);
204      c[*n].SetLabels(lab);
205   }
206   (*n)++;
207   if (*n==kMax) {
208      Error("FindClustersSSD","Too many 1D clusters !");
209      return;
210   }
211
212   FindClustersSSD(neg, nn, pos, np);
213 }
214
215
216 void AliITSClusterFinderV2SSD::RawdataToClusters(AliRawReader* rawReader,TClonesArray** clusters){
217
218     //------------------------------------------------------------
219   // This function creates ITS clusters from raw data
220   //------------------------------------------------------------
221   rawReader->Reset();
222   /*
223   const UInt_t *evid; evid = rawReader->GetEventId();
224   cout<<"Event="<<evid[0]<<endl;
225   */
226   AliITSRawStreamSSD inputSSD(rawReader);
227   //  rawReader->SelectEquipment(-1,0,15);
228   FindClustersSSD(&inputSSD,clusters);
229   
230 }
231
232 void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input, 
233                                         TClonesArray** clusters) 
234 {
235   //------------------------------------------------------------
236   // Actual SSD cluster finder for raw data
237   //------------------------------------------------------------
238   Int_t nClustersSSD = 0;
239   const Int_t kMax = 1000;
240   Ali1Dcluster clusters1D[2][kMax];
241   Int_t nClusters[2] = {0, 0};
242   Int_t lab[3]={-2,-2,-2};
243   Float_t q = 0.;
244   Float_t y = 0.;
245   Int_t nDigits = 0;
246   Float_t gain=0;
247   Float_t noise=0.;
248   //  Float_t pedestal=0.;
249   Float_t oldnoise=0.;
250   AliITSCalibrationSSD* cal=NULL;
251
252   Int_t matrix[12][1536];
253   Int_t iddl=-1;
254   Int_t iad=-1;
255   Int_t oddl = -1;
256   Int_t oad = -1;
257   Int_t oadc = -1;
258   Int_t ostrip = -1;
259   Int_t osignal = 65535;
260   Int_t n=0;
261   Bool_t next=0;
262
263   // read raw data input stream
264   while (kTRUE) {
265     
266     // reset signal matrix
267     for(Int_t i=0; i<12; i++) { for(Int_t j=0; j<1536; j++) { matrix[i][j] = 65535;} }
268     
269     if(osignal!=65535) { 
270       n++;
271       matrix[oadc][ostrip] = osignal; // recover data from previous occurence of input->Next() 
272     }
273     
274     // buffer data for ddl=iddl and ad=iad
275     while(kTRUE) {
276         
277       next = input->Next();
278       if((!next)&&(input->flag)) continue;
279       Int_t ddl=input->GetDDL(); 
280       Int_t ad=input->GetAD();
281       Int_t adc = input->GetADC(); adc = (adc<6)? adc : adc - 2;
282       Int_t strip = input->GetStrip();
283       if(input->GetSideFlag()) strip=1535-strip;
284       Int_t signal = input->GetSignal();
285       //cout<<ddl<<" "<<ad<<" "<<adc<<" "<<strip<<" "<<signal<<endl;
286       
287       if((ddl==iddl)&&(ad==iad)) {n++; matrix[adc][strip] = signal;}
288       else {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}
289       
290       if(!next)  {oddl=iddl; oad=iad; oadc = adc; ostrip = strip; osignal=signal; iddl=ddl; iad=ad; break;}
291       //break;
292     }
293     
294     // No SSD data
295     if(!next && oddl<0) break;
296     
297     if(n==0) continue; // first occurence
298     n=0; osignal=0;
299     
300     // fill 1Dclusters
301     for(Int_t iadc=0; iadc<12; iadc++) {  // loop over ADC index for ddl=oddl and ad=oad
302       
303       Int_t iimod = (oad - 1)  * 12 + iadc;
304       Int_t iModule = AliITSRawStreamSSD::GetModuleNumber(oddl,iimod);
305       if(iModule==-1) continue;
306       //      cout<<"ddl="<<oddl<<" ad"<<oad<<" module="<<iModule<<endl;
307       cal = (AliITSCalibrationSSD*)GetResp(iModule);
308       
309       Bool_t first = 0;
310       
311       /*
312       for(Int_t istrip=0; istrip<768; istrip++) { // P-side
313         Int_t signal = matrix[iadc][istrip];
314         pedestal = cal->GetPedestalP(istrip);
315         matrix[iadc][istrip]=signal-(Int_t)pedestal;
316       } 
317       */
318
319       /*
320       Float_t cmode=0;
321       for(Int_t l=0; l<6; l++) {
322         cmode=0;
323         for(Int_t n=20; n<108; n++) cmode+=matrix[iadc][l*128+n];
324         cmode/=88.;
325         for(Int_t n=0; n<128; n++) matrix[iadc][l*128+n]-=(Int_t)cmode;
326         
327       }
328       */
329
330       for(Int_t istrip=0; istrip<768; istrip++) { // P-side
331         
332         Int_t signal = TMath::Abs(matrix[iadc][istrip]);
333         
334         oldnoise = noise;
335         noise = cal->GetNoiseP(istrip); if(noise<1.) signal = 65535;
336         if(signal<5*noise) signal = 65535; // in case ZS was not done in hw do it now
337         if( (signal<30.) || (istrip<10) || (istrip>758) ) signal=65535;
338
339         if (signal!=65535) {
340           gain = cal->GetGainP(istrip);
341           signal = (Int_t) ( signal * gain ); // signal is corrected for gain
342           signal = (Int_t) cal->ADCToKeV( signal ); // signal is  converted in KeV 
343           
344           q += signal;    // add digit to current cluster
345           y += istrip * signal;   
346           nDigits++;
347           first=1;
348         }
349         
350         else if(first) {
351           
352           if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
353             
354             Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
355             cluster.SetY(y/q);
356             cluster.SetQ(q);
357             cluster.SetNd(nDigits);
358             cluster.SetLabels(lab);
359             
360             //Split suspiciously big cluster
361             if (nDigits > 4&&nDigits < 25) {
362               cluster.SetY(y/q - 0.25*nDigits);
363               cluster.SetQ(0.5*q);
364               if (nClusters[0] == kMax) {
365                 Error("FindClustersSSD", "Too many 1D clusters !");
366                 return;
367               }
368               Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
369               cluster2.SetY(y/q + 0.25*nDigits);
370               cluster2.SetQ(0.5*q);
371               cluster2.SetNd(nDigits);
372               cluster2.SetLabels(lab);
373             }
374             
375           }
376           
377           y = q = 0.;
378           nDigits = 0;
379           first=0;
380         }
381
382       } // loop over strip on P-side
383
384       // if last strip does have signal
385       if(first) {
386         
387           if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
388
389             Ali1Dcluster& cluster = clusters1D[0][nClusters[0]++];
390             cluster.SetY(y/q);
391             cluster.SetQ(q);
392             cluster.SetNd(nDigits);
393             cluster.SetLabels(lab);
394             
395             //Split suspiciously big cluster
396             if (nDigits > 4&&nDigits < 25) {
397               cluster.SetY(y/q - 0.25*nDigits);
398               cluster.SetQ(0.5*q);
399               if (nClusters[0] == kMax) {
400                 Error("FindClustersSSD", "Too many 1D clusters !");
401                 return;
402               }
403               Ali1Dcluster& cluster2 = clusters1D[0][nClusters[0]++];
404               cluster2.SetY(y/q + 0.25*nDigits);
405               cluster2.SetQ(0.5*q);
406               cluster2.SetNd(nDigits);
407               cluster2.SetLabels(lab);
408             }
409             
410           }
411           y = q = 0.;
412           nDigits = 0;
413           first=0;
414       }
415       
416       /*
417       for(Int_t istrip=768; istrip<1536; istrip++) { // P-side
418         Int_t signal = matrix[iadc][istrip];
419         pedestal = cal->GetPedestalN(1535-istrip);
420         matrix[iadc][istrip]=signal-(Int_t)pedestal;
421       } 
422       */
423
424       /*
425       for(Int_t l=6; l<12; l++) {
426         Float_t cmode=0;
427         for(Int_t n=20; n<108; n++) cmode+=matrix[iadc][l*128+n];
428         cmode/=88.;
429         for(Int_t n=0; n<128; n++) matrix[iadc][l*128+n]-=(Int_t)cmode;
430       }
431       */
432
433       oldnoise = 0.;
434       noise = 0.;
435       for(Int_t istrip=768; istrip<1536; istrip++) { // N-side
436         
437         Int_t signal = TMath::Abs(matrix[iadc][istrip]);
438         //cout<<"####"<<" "<<oddl<<" "<<oad<<" "<<iadc<<" "<<istrip<<" "<<signal<<endl;      
439
440         Int_t strip = 1535-istrip;
441
442         oldnoise = noise;
443         noise = cal->GetNoiseN(strip); if(noise<1.) signal=65535;
444         if(signal<5*noise) signal = 65535; // in case ZS was not done in hw do it now
445         if( (signal<30.) || (istrip<778) || (istrip>1526) ) signal=65535;
446
447         if (signal!=65535) {
448           //      cout<<"ddl="<<oddl<<" ad"<<oad<<" module="<<iModule<<" strip= "<<istrip<<
449           //  " sig="<<signal<<" "<<cal->GetPedestalN(strip)<<endl;
450           gain = cal->GetGainN(strip);
451           signal = (Int_t) ( signal * gain); // signal is corrected for gain
452           signal = (Int_t) cal->ADCToKeV( signal ); // signal is  converted in KeV 
453           
454           // add digit to current cluster
455           q += signal;
456           y += strip * signal;
457           nDigits++;
458           first=1;
459         }
460
461         else if(first) {
462
463           if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
464             
465             Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
466             cluster.SetY(y/q);
467             cluster.SetQ(q);
468             cluster.SetNd(nDigits);
469             cluster.SetLabels(lab);
470             
471             //Split suspiciously big cluster
472             if (nDigits > 4&&nDigits < 25) {
473               cluster.SetY(y/q - 0.25*nDigits);
474               cluster.SetQ(0.5*q);
475               if (nClusters[1] == kMax) {
476                 Error("FindClustersSSD", "Too many 1D clusters !");
477                 return;
478               }
479               Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
480               cluster2.SetY(y/q + 0.25*nDigits);
481               cluster2.SetQ(0.5*q);
482               cluster2.SetNd(nDigits);
483               cluster2.SetLabels(lab);
484             }
485             
486           }
487           y = q = 0.;
488           nDigits = 0;
489           first=0;        
490         }
491         
492       } // loop over strips on N-side
493
494       if(first) {
495         
496           if ( ((nDigits==1)&&(q>5*oldnoise)) || (nDigits>1) ) {
497
498             Ali1Dcluster& cluster = clusters1D[1][nClusters[1]++];
499             cluster.SetY(y/q);
500             cluster.SetQ(q);
501             cluster.SetNd(nDigits);
502             cluster.SetLabels(lab);
503             
504             //Split suspiciously big cluster
505             if (nDigits > 4&&nDigits < 25) {
506               cluster.SetY(y/q - 0.25*nDigits);
507               cluster.SetQ(0.5*q);
508               if (nClusters[1] == kMax) {
509                 Error("FindClustersSSD", "Too many 1D clusters !");
510                 return;
511               }
512               Ali1Dcluster& cluster2 = clusters1D[1][nClusters[1]++];
513               cluster2.SetY(y/q + 0.25*nDigits);
514               cluster2.SetQ(0.5*q);
515               cluster2.SetNd(nDigits);
516               cluster2.SetLabels(lab);
517             }
518             
519           }
520           y = q = 0.;
521           nDigits = 0;
522           first=0;        
523       }
524       
525       // create recpoints
526       if((nClusters[0])&&(nClusters[1])) {
527  
528         //cout<<"creating recpoint for module="<<iModule<<" "<<nClusters[0]<<" "<<nClusters[1]<<endl;
529         clusters[iModule] = new TClonesArray("AliITSRecPoint");
530         fModule = iModule;
531         //      fModule = 500;
532         FindClustersSSD(&clusters1D[0][0], nClusters[0], 
533                         &clusters1D[1][0], nClusters[1], clusters[iModule]);
534         Int_t nClusters = clusters[iModule]->GetEntriesFast();
535         nClustersSSD += nClusters;
536       }
537
538       nClusters[0] = nClusters[1] = 0;
539       y = q = 0.;
540       nDigits = 0;
541
542     } // loop over adc
543
544     if(!next) break;
545   }
546   
547   Info("FindClustersSSD", "found clusters in ITS SSD: %d", nClustersSSD);
548 }
549
550 void AliITSClusterFinderV2SSD::
551 FindClustersSSD(Ali1Dcluster* neg, Int_t nn, 
552                 Ali1Dcluster* pos, Int_t np,
553                 TClonesArray *clusters) {
554   //------------------------------------------------------------
555   // Actual SSD cluster finder
556   //------------------------------------------------------------
557
558   //  Float_t xyz[3];
559
560   const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule);
561
562   TClonesArray &cl=*clusters;
563   //
564   Float_t tanp=fTanP, tann=fTanN;
565   if (fModule>fLastSSD1) {tann=fTanP; tanp=fTanN;}
566   Int_t idet=fNdet[fModule];
567   Int_t ncl=0;
568   //
569   Int_t negativepair[30000];
570   Int_t cnegative[3000];  
571   Int_t cused1[3000];
572   Int_t positivepair[30000];
573   Int_t cpositive[3000];
574   Int_t cused2[3000];
575   for (Int_t i=0;i<3000;i++) {cnegative[i]=0; cused1[i]=0;}
576   for (Int_t i=0;i<3000;i++) {cpositive[i]=0; cused2[i]=0;}
577   for (Int_t i=0;i<30000;i++) {negativepair[i]=0; positivepair[i]=0;}
578
579   if ((np*nn) > fgPairsSize) {
580     if (fgPairs) delete [] fgPairs;
581     fgPairsSize = 4*np*nn;
582     fgPairs = new Short_t[fgPairsSize];
583   }
584   memset(fgPairs,0,sizeof(Short_t)*np*nn);
585
586   //
587   // find available pairs
588   //
589   for (Int_t i=0; i<np; i++) {
590     Float_t yp=pos[i].GetY()*fYpitchSSD; 
591     if (pos[i].GetQ()<3) continue;
592     for (Int_t j=0; j<nn; j++) {
593       if (neg[j].GetQ()<3) continue;
594       Float_t yn=neg[j].GetY()*fYpitchSSD;
595       Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
596       Float_t yt=yn + tann*zt;
597       zt-=fHlSSD; yt-=fHwSSD;
598       if (TMath::Abs(yt)<fHwSSD+0.01)
599       if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
600         negativepair[i*10+cnegative[i]] =j;  //index
601         positivepair[j*10+cpositive[j]] =i;
602         cnegative[i]++;  //counters
603         cpositive[j]++; 
604         fgPairs[i*nn+j]=100;
605       }
606     }
607   }
608
609   //
610   // try to recover points out of but close to the module boundaries 
611   //
612   for (Int_t i=0; i<np; i++) {
613     Float_t yp=pos[i].GetY()*fYpitchSSD; 
614     if (pos[i].GetQ()<3) continue;
615     for (Int_t j=0; j<nn; j++) {
616       if (neg[j].GetQ()<3) continue;
617       // if both 1Dclusters have an other cross continue
618       if (cpositive[j]&&cnegative[i]) continue;
619       Float_t yn=neg[j].GetY()*fYpitchSSD;
620       Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
621       Float_t yt=yn + tann*zt;
622       zt-=fHlSSD; yt-=fHwSSD;
623       if (TMath::Abs(yt)<fHwSSD+0.1)
624       if (TMath::Abs(zt)<fHlSSD+0.15) {
625         // tag 1Dcluster (eventually will produce low quality recpoint)
626         if (cnegative[i]==0) pos[i].SetNd(100);  // not available pair
627         if (cpositive[j]==0) neg[j].SetNd(100);  // not available pair
628         negativepair[i*10+cnegative[i]] =j;  //index
629         positivepair[j*10+cpositive[j]] =i;
630         cnegative[i]++;  //counters
631         cpositive[j]++; 
632         fgPairs[i*nn+j]=100;
633       }
634     }
635   }
636
637   //
638   Float_t lp[5];
639   Int_t milab[10];
640   Double_t ratio;
641   
642   //
643   // sign gold tracks
644   //
645   for (Int_t ip=0;ip<np;ip++){
646     Float_t ybest=1000,zbest=1000,qbest=0;
647     //
648     // select gold clusters
649     if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){ 
650       Float_t yp=pos[ip].GetY()*fYpitchSSD; 
651       Int_t j = negativepair[10*ip];      
652       ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
653       //
654       Float_t yn=neg[j].GetY()*fYpitchSSD;
655       Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
656       Float_t yt=yn + tann*zt;
657       zt-=fHlSSD; yt-=fHwSSD;
658       ybest=yt; zbest=zt; 
659       qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
660
661       //cout<<yt<<" "<<zt<<" "<<qbest<<endl;
662
663       {
664       Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
665       mT2L->MasterToLocal(loc,trk);
666       lp[0]=trk[1];
667       lp[1]=trk[2];
668       }
669       lp[2]=0.0025*0.0025;  //SigmaY2
670       lp[3]=0.110*0.110;  //SigmaZ2
671       
672       lp[4]=qbest;        //Q
673       for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
674       for (Int_t ilab=0;ilab<3;ilab++){
675         milab[ilab] = pos[ip].GetLabel(ilab);
676         milab[ilab+3] = neg[j].GetLabel(ilab);
677       }
678       //
679       CheckLabels2(milab);
680       milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
681       Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
682       AliITSRecPoint * cl2;
683     
684       if(clusters){  // Note clusters != 0 when method is called for rawdata
685
686
687         cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
688
689         //      cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
690
691         cl2->SetChargeRatio(ratio);     
692         cl2->SetType(1);
693         fgPairs[ip*nn+j]=1;
694         if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
695           cl2->SetType(2);
696           fgPairs[ip*nn+j]=2;
697         }
698         cused1[ip]++;
699         cused2[j]++;
700         
701       }
702       else{ // Note clusters == 0 when method is called for digits
703
704         cl2 = new AliITSRecPoint(milab,lp,info);        
705
706         //      cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
707
708         cl2->SetChargeRatio(ratio);     
709         cl2->SetType(1);
710         fgPairs[ip*nn+j]=1;
711         if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
712           cl2->SetType(2);
713           fgPairs[ip*nn+j]=2;
714         }
715         cused1[ip]++;
716         cused2[j]++;
717         //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" gold"<<endl;
718         fDetTypeRec->AddRecPoint(*cl2);
719       }
720       ncl++;
721     }
722   }
723     
724   for (Int_t ip=0;ip<np;ip++){
725     Float_t ybest=1000,zbest=1000,qbest=0;
726     //
727     //
728     // select "silber" cluster
729     if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){
730       Int_t in  = negativepair[10*ip];
731       Int_t ip2 = positivepair[10*in];
732       if (ip2==ip) ip2 =  positivepair[10*in+1];
733       Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ();
734       if (TMath::Abs(pcharge-neg[in].GetQ())<10){
735         //
736         // add first pair
737         if (fgPairs[ip*nn+in]==100){  //
738           Float_t yp=pos[ip].GetY()*fYpitchSSD; 
739           Float_t yn=neg[in].GetY()*fYpitchSSD;
740           Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
741           Float_t yt=yn + tann*zt;
742           zt-=fHlSSD; yt-=fHwSSD;
743           ybest =yt;  zbest=zt; 
744           qbest =pos[ip].GetQ();
745           {
746           Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
747           mT2L->MasterToLocal(loc,trk);
748           lp[0]=trk[1];
749           lp[1]=trk[2];
750           }
751           lp[2]=0.0025*0.0025;  //SigmaY2
752           lp[3]=0.110*0.110;  //SigmaZ2
753           
754           lp[4]=qbest;        //Q
755           for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
756           for (Int_t ilab=0;ilab<3;ilab++){
757             milab[ilab] = pos[ip].GetLabel(ilab);
758             milab[ilab+3] = neg[in].GetLabel(ilab);
759           }
760           //
761           CheckLabels2(milab);
762           ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ());
763           milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det
764           Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
765
766           AliITSRecPoint * cl2;
767           if(clusters){
768
769             cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
770
771             //  cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
772
773             cl2->SetChargeRatio(ratio);         
774             cl2->SetType(5);
775             fgPairs[ip*nn+in] = 5;
776             if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
777               cl2->SetType(6);
778               fgPairs[ip*nn+in] = 6;
779             }       
780           }
781           else{
782             cl2 = new AliITSRecPoint(milab,lp,info);
783             cl2->SetChargeRatio(ratio);         
784             cl2->SetType(5);
785             fgPairs[ip*nn+in] = 5;
786             if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster
787               cl2->SetType(6);
788               fgPairs[ip*nn+in] = 6;
789             }
790             //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silver1"<<endl;
791
792             fDetTypeRec->AddRecPoint(*cl2);
793           }
794           ncl++;
795         }
796         
797         //
798         // add second pair
799         
800       //        if (!(cused1[ip2] || cused2[in])){  //
801         if (fgPairs[ip2*nn+in]==100){
802           Float_t yp=pos[ip2].GetY()*fYpitchSSD;
803           Float_t yn=neg[in].GetY()*fYpitchSSD;
804           Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
805           Float_t yt=yn + tann*zt;
806           zt-=fHlSSD; yt-=fHwSSD;
807           ybest =yt;  zbest=zt; 
808           qbest =pos[ip2].GetQ();
809           {
810           Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
811           mT2L->MasterToLocal(loc,trk);
812           lp[0]=trk[1];
813           lp[1]=trk[2];
814           }
815           lp[2]=0.0025*0.0025;  //SigmaY2
816           lp[3]=0.110*0.110;  //SigmaZ2
817           
818           lp[4]=qbest;        //Q
819           for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
820           for (Int_t ilab=0;ilab<3;ilab++){
821             milab[ilab] = pos[ip2].GetLabel(ilab);
822             milab[ilab+3] = neg[in].GetLabel(ilab);
823           }
824           //
825           CheckLabels2(milab);
826           ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ());
827           milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det
828           Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]};
829           
830           AliITSRecPoint * cl2;
831           if(clusters){
832             cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
833
834             //  cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
835
836             cl2->SetChargeRatio(ratio);         
837             cl2->SetType(5);
838             fgPairs[ip2*nn+in] =5;
839             if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
840               cl2->SetType(6);
841               fgPairs[ip2*nn+in] =6;
842             }
843           }
844           else{
845             cl2 = new AliITSRecPoint(milab,lp,info);
846             cl2->SetChargeRatio(ratio);         
847             cl2->SetType(5);
848             fgPairs[ip2*nn+in] =5;
849             if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster
850               cl2->SetType(6);
851               fgPairs[ip2*nn+in] =6;
852             }
853             
854             //   cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silver2"<<endl;
855             fDetTypeRec->AddRecPoint(*cl2);
856           }
857           ncl++;
858         }       
859         cused1[ip]++;
860         cused1[ip2]++;
861         cused2[in]++;
862       }
863     }    
864   }
865
866   //  
867   for (Int_t jn=0;jn<nn;jn++){
868     if (cused2[jn]) continue;
869     Float_t ybest=1000,zbest=1000,qbest=0;
870     // select "silber" cluster
871     if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){
872       Int_t ip  = positivepair[10*jn];
873       Int_t jn2 = negativepair[10*ip];
874       if (jn2==jn) jn2 =  negativepair[10*ip+1];
875       Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ();
876       //
877       if (TMath::Abs(pcharge-pos[ip].GetQ())<10){
878         //
879         // add first pair
880         //      if (!(cused1[ip]||cused2[jn])){
881         if (fgPairs[ip*nn+jn]==100){
882           Float_t yn=neg[jn].GetY()*fYpitchSSD; 
883           Float_t yp=pos[ip].GetY()*fYpitchSSD;
884           Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
885           Float_t yt=yn + tann*zt;
886           zt-=fHlSSD; yt-=fHwSSD;
887           ybest =yt;  zbest=zt; 
888           qbest =neg[jn].GetQ();
889           {
890           Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
891           mT2L->MasterToLocal(loc,trk);
892           lp[0]=trk[1];
893           lp[1]=trk[2];
894           }
895           lp[2]=0.0025*0.0025;  //SigmaY2
896           lp[3]=0.110*0.110;  //SigmaZ2
897           
898           lp[4]=qbest;        //Q
899           for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
900           for (Int_t ilab=0;ilab<3;ilab++){
901             milab[ilab] = pos[ip].GetLabel(ilab);
902             milab[ilab+3] = neg[jn].GetLabel(ilab);
903           }
904           //
905           CheckLabels2(milab);
906           ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ());
907           milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det
908           Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]};
909
910           AliITSRecPoint * cl2;
911           if(clusters){
912             cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
913
914             //  cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
915
916             cl2->SetChargeRatio(ratio);         
917             cl2->SetType(7);
918             fgPairs[ip*nn+jn] =7;
919             if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
920               cl2->SetType(8);
921               fgPairs[ip*nn+jn]=8;
922             }
923
924           }
925           else{
926             cl2 = new AliITSRecPoint(milab,lp,info);
927             cl2->SetChargeRatio(ratio);         
928             cl2->SetType(7);
929             fgPairs[ip*nn+jn] =7;
930             if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster
931               cl2->SetType(8);
932               fgPairs[ip*nn+jn]=8;
933             }
934             //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silverN1"<<endl;
935
936             fDetTypeRec->AddRecPoint(*cl2);
937           }
938           ncl++;
939         }
940         //
941         // add second pair
942         //      if (!(cused1[ip]||cused2[jn2])){
943         if (fgPairs[ip*nn+jn2]==100){
944           Float_t yn=neg[jn2].GetY()*fYpitchSSD; 
945           Double_t yp=pos[ip].GetY()*fYpitchSSD; 
946           Double_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
947           Double_t yt=yn + tann*zt;
948           zt-=fHlSSD; yt-=fHwSSD;
949           ybest =yt;  zbest=zt; 
950           qbest =neg[jn2].GetQ();
951           {
952           Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
953           mT2L->MasterToLocal(loc,trk);
954           lp[0]=trk[1];
955           lp[1]=trk[2];
956           }
957           lp[2]=0.0025*0.0025;  //SigmaY2
958           lp[3]=0.110*0.110;  //SigmaZ2
959           
960           lp[4]=qbest;        //Q
961           for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
962           for (Int_t ilab=0;ilab<3;ilab++){
963             milab[ilab] = pos[ip].GetLabel(ilab);
964             milab[ilab+3] = neg[jn2].GetLabel(ilab);
965           }
966           //
967           CheckLabels2(milab);
968           ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ());
969           milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det
970           Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fModule]};
971           AliITSRecPoint * cl2;
972           if(clusters){
973             cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
974
975             //  cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
976
977             cl2->SetChargeRatio(ratio);         
978             fgPairs[ip*nn+jn2]=7;
979             cl2->SetType(7);
980             if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
981               cl2->SetType(8);
982               fgPairs[ip*nn+jn2]=8;
983             }
984             
985           }
986           else{
987             cl2 = new AliITSRecPoint(milab,lp,info);
988             cl2->SetChargeRatio(ratio);         
989             fgPairs[ip*nn+jn2]=7;
990             cl2->SetType(7);
991             if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster
992               cl2->SetType(8);
993               fgPairs[ip*nn+jn2]=8;
994             }
995             //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" silverN2"<<endl;
996
997             fDetTypeRec->AddRecPoint(*cl2);
998           }
999
1000           ncl++;
1001         }
1002         cused1[ip]++;
1003         cused2[jn]++;
1004         cused2[jn2]++;
1005       }
1006     }    
1007   }
1008   
1009   for (Int_t ip=0;ip<np;ip++){
1010     Float_t ybest=1000,zbest=1000,qbest=0;
1011     //
1012     // 2x2 clusters
1013     //
1014     if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){ 
1015       Float_t minchargediff =4.;
1016       Int_t j=-1;
1017       for (Int_t di=0;di<cnegative[ip];di++){
1018         Int_t   jc = negativepair[ip*10+di];
1019         Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1020         if (TMath::Abs(chargedif)<minchargediff){
1021           j =jc;
1022           minchargediff = TMath::Abs(chargedif);
1023         }
1024       }
1025       if (j<0) continue;  // not proper cluster      
1026
1027       Int_t count =0;
1028       for (Int_t di=0;di<cnegative[ip];di++){
1029         Int_t   jc = negativepair[ip*10+di];
1030         Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ();
1031         if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1032       }
1033       if (count>1) continue;  // more than one "proper" cluster for positive
1034       //
1035       count =0;
1036       for (Int_t dj=0;dj<cpositive[j];dj++){
1037         Int_t   ic  = positivepair[j*10+dj];
1038         Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ();
1039         if (TMath::Abs(chargedif)<minchargediff+3.) count++;
1040       }
1041       if (count>1) continue;  // more than one "proper" cluster for negative
1042       
1043       Int_t jp = 0;
1044       
1045       count =0;
1046       for (Int_t dj=0;dj<cnegative[jp];dj++){
1047         Int_t   ic = positivepair[jp*10+dj];
1048         Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ();
1049         if (TMath::Abs(chargedif)<minchargediff+4.) count++;
1050       }
1051       if (count>1) continue;   
1052       if (fgPairs[ip*nn+j]<100) continue;
1053       //
1054       //almost gold clusters
1055       Float_t yp=pos[ip].GetY()*fYpitchSSD; 
1056       Float_t yn=neg[j].GetY()*fYpitchSSD;
1057       Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1058       Float_t yt=yn + tann*zt;
1059       zt-=fHlSSD; yt-=fHwSSD;
1060       ybest=yt; zbest=zt; 
1061       qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ());
1062       {
1063       Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
1064       mT2L->MasterToLocal(loc,trk);
1065       lp[0]=trk[1];
1066       lp[1]=trk[2];
1067       }
1068       lp[2]=0.0025*0.0025;  //SigmaY2
1069       lp[3]=0.110*0.110;  //SigmaZ2     
1070       lp[4]=qbest;        //Q
1071       for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1072       for (Int_t ilab=0;ilab<3;ilab++){
1073         milab[ilab] = pos[ip].GetLabel(ilab);
1074         milab[ilab+3] = neg[j].GetLabel(ilab);
1075       }
1076       //
1077       CheckLabels2(milab);
1078       ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ());
1079       milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det
1080       Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1081       AliITSRecPoint * cl2;
1082       if(clusters){
1083         cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1084
1085         //      cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1086
1087         cl2->SetChargeRatio(ratio);     
1088         cl2->SetType(10);
1089         fgPairs[ip*nn+j]=10;
1090         if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1091           cl2->SetType(11);
1092           fgPairs[ip*nn+j]=11;
1093         }
1094         cused1[ip]++;
1095         cused2[j]++;      
1096       }
1097       else{
1098         cl2 = new AliITSRecPoint(milab,lp,info);
1099         cl2->SetChargeRatio(ratio);     
1100         cl2->SetType(10);
1101         fgPairs[ip*nn+j]=10;
1102         if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster
1103           cl2->SetType(11);
1104           fgPairs[ip*nn+j]=11;
1105         }
1106         cused1[ip]++;
1107         cused2[j]++;      
1108         
1109         //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" 2x2"<<endl;
1110
1111         fDetTypeRec->AddRecPoint(*cl2);
1112       }      
1113       ncl++;
1114     }
1115
1116   }
1117   
1118   //  
1119   for (Int_t i=0; i<np; i++) {
1120     Float_t ybest=1000,zbest=1000,qbest=0;
1121     Float_t yp=pos[i].GetY()*fYpitchSSD; 
1122     if (pos[i].GetQ()<3) continue;
1123     for (Int_t j=0; j<nn; j++) {
1124     //    for (Int_t di = 0;di<cpositive[i];di++){
1125     //  Int_t j = negativepair[10*i+di];
1126       if (neg[j].GetQ()<3) continue;
1127       if (cused2[j]||cused1[i]) continue;      
1128       if (fgPairs[i*nn+j]>0 &&fgPairs[i*nn+j]<100) continue;
1129       ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ());      
1130       Float_t yn=neg[j].GetY()*fYpitchSSD;
1131       Float_t zt=(2*fHlSSD*tanp + yp - yn)/(tann+tanp);
1132       Float_t yt=yn + tann*zt;
1133       zt-=fHlSSD; yt-=fHwSSD;
1134       if (TMath::Abs(yt)<fHwSSD+0.01)
1135       if (TMath::Abs(zt)<fHlSSD+0.01*(neg[j].GetNd()+pos[i].GetNd())) {
1136         ybest=yt; zbest=zt; 
1137         qbest=0.5*(pos[i].GetQ()+neg[j].GetQ());
1138         {
1139         Double_t loc[3]={ybest,0.,zbest},trk[3]={0.,0.,0.};
1140         mT2L->MasterToLocal(loc,trk);
1141         lp[0]=trk[1];
1142         lp[1]=trk[2];
1143         }
1144         lp[2]=0.0025*0.0025;  //SigmaY2
1145         lp[3]=0.110*0.110;  //SigmaZ2
1146
1147         lp[4]=qbest;        //Q
1148         for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
1149         for (Int_t ilab=0;ilab<3;ilab++){
1150           milab[ilab] = pos[i].GetLabel(ilab);
1151           milab[ilab+3] = neg[j].GetLabel(ilab);
1152         }
1153         //
1154         CheckLabels2(milab);
1155         milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
1156         Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]};
1157         AliITSRecPoint * cl2;
1158         if(clusters){
1159           cl2 = new (cl[ncl]) AliITSRecPoint(milab,lp,info);
1160
1161           //    cl2-> GetGlobalXYZ(xyz); cout<<"rec "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
1162
1163           cl2->SetChargeRatio(ratio);
1164           cl2->SetType(100+cpositive[j]+cnegative[i]);    
1165         }
1166         else{
1167           cl2 = new AliITSRecPoint(milab,lp,info);
1168           cl2->SetChargeRatio(ratio);
1169           cl2->SetType(100+cpositive[j]+cnegative[i]);
1170           
1171           //cout<<"AliITSClusterFinderV2SSD "<<fModule<<" other"<<endl;
1172
1173           fDetTypeRec->AddRecPoint(*cl2);
1174         }
1175         ncl++;
1176         //cl2->SetType(0);
1177         /*
1178           if (fgPairs[i*nn+j]<100){
1179           printf("problem:- %d\n", fgPairs[i*nn+j]);
1180           }
1181           if (cnegative[i]<2&&cpositive[j]<2){
1182           printf("problem:- %d\n", fgPairs[i*nn+j]);
1183           }
1184         */
1185       }
1186     }
1187   }
1188
1189 }
1190
1191