]>
Commit | Line | Data |
---|---|---|
b2bac0a3 | 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: AliHLTITSClusterFinderSSD.cxx 34920 2009-09-22 07:48:53Z masera $ */ | |
17 | ||
18 | //////////////////////////////////////////////////////////////////////////// | |
19 | // Implementation of the ITS clusterer V2 class // | |
20 | // // | |
21 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch // | |
22 | // Last revision: 13-05-09 Enrico Fragiacomo // | |
23 | // enrico.fragiacomo@ts.infn.it // | |
24 | // // | |
25 | /////////////////////////////////////////////////////////////////////////// | |
26 | ||
27 | #include <Riostream.h> | |
28 | #include "AliLog.h" | |
29 | ||
30 | #include "AliHLTITSClusterFinderSSD.h" | |
31 | #include "AliITSRecPoint.h" | |
32 | #include "AliITSgeomTGeo.h" | |
33 | #include "AliITSDetTypeRec.h" | |
34 | #include "AliRawReader.h" | |
35 | #include "AliITSRawStreamSSD.h" | |
36 | #include <TClonesArray.h> | |
37 | #include "AliITSdigitSSD.h" | |
38 | #include "AliITSReconstructor.h" | |
39 | #include "AliITSCalibrationSSD.h" | |
40 | #include "AliITSsegmentationSSD.h" | |
41 | ||
42 | Short_t *AliHLTITSClusterFinderSSD::fgPairs = 0x0; | |
43 | Int_t AliHLTITSClusterFinderSSD::fgPairsSize = 0; | |
44 | const Float_t AliHLTITSClusterFinderSSD::fgkThreshold = 5.; | |
45 | ||
46 | const Float_t AliHLTITSClusterFinderSSD::fgkCosmic2008StripShifts[16][9] = | |
47 | {{-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35}, // DDL 512 | |
48 | {-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35,-0.35}, // DDL 513 | |
49 | {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 514 | |
50 | {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 515 | |
51 | { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 516 | |
52 | { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 517 | |
53 | {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 518 | |
54 | {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 519 | |
55 | {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.25,-0.15}, // DDL 520 | |
56 | {-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15,-0.15}, // DDL 521 | |
57 | {-0.10,-0.10,-0.10,-0.40,-0.40,-0.40,-0.10,-0.10,-0.45}, // DDL 522 | |
58 | {-0.10,-0.10,-0.10,-0.35,-0.35,-0.35,-0.10,-0.35,-0.50}, // DDL 523 | |
59 | { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 524 | |
60 | { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // DDL 525 | |
61 | { 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35}, // DDL 526 | |
62 | { 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45}}; // DDL 527 | |
63 | ||
64 | ClassImp(AliHLTITSClusterFinderSSD) | |
65 | ||
66 | ||
67 | AliHLTITSClusterFinderSSD::AliHLTITSClusterFinderSSD(AliITSDetTypeRec* dettyp, AliRawReader *reader) | |
68 | : | |
69 | AliITSClusterFinder(dettyp), | |
70 | fRecoParam(0), | |
71 | fRawReader( reader ), | |
72 | fRawStream( 0 ), | |
73 | fLastSSD1(AliITSgeomTGeo::GetModuleIndex(6,1,1)-1) | |
74 | { | |
75 | //Default constructor | |
76 | // | |
77 | // Initialisation of ITS geometry | |
78 | // | |
79 | Int_t mmax=AliITSgeomTGeo::GetNModules(); | |
80 | for (Int_t m=0; m<mmax; m++) { | |
81 | Int_t lay,lad,det; AliITSgeomTGeo::GetModuleId(m,lay,lad,det); | |
82 | fNdet[m] = (lad-1)*AliITSgeomTGeo::GetNDetectors(lay) + (det-1); | |
83 | fNlayer[m] = lay-1; | |
84 | } | |
85 | ||
86 | fRecoParam = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam(); | |
87 | if( !fRecoParam ){ | |
88 | fRecoParam = AliITSRecoParam::GetHighFluxParam(); | |
726155fd | 89 | // AliWarning("Using default AliITSRecoParam class"); |
b2bac0a3 | 90 | } |
91 | fRawStream = new AliITSRawStreamSSD( fRawReader); | |
92 | } | |
93 | ||
94 | //______________________________________________________________________ | |
95 | AliHLTITSClusterFinderSSD::AliHLTITSClusterFinderSSD(const AliHLTITSClusterFinderSSD &cf) : AliITSClusterFinder(cf), fRecoParam(cf.fRecoParam), fRawReader(cf.fRawReader), fRawStream(0), fLastSSD1(cf.fLastSSD1) | |
96 | { | |
97 | // Dummy | |
98 | } | |
99 | ||
100 | //______________________________________________________________________ | |
101 | AliHLTITSClusterFinderSSD& AliHLTITSClusterFinderSSD::operator=(const AliHLTITSClusterFinderSSD& ){ | |
102 | // Dummy | |
103 | return *this; | |
104 | } | |
105 | ||
106 | AliHLTITSClusterFinderSSD::~AliHLTITSClusterFinderSSD() | |
107 | { | |
108 | // destructor | |
109 | delete fRawStream; | |
110 | } | |
111 | ||
112 | void AliHLTITSClusterFinderSSD::RawdataToClusters( std::vector<AliITSRecPoint> &clusters ) | |
113 | { | |
114 | //------------------------------------------------------------ | |
115 | // Actual SSD cluster finder for raw data | |
116 | //------------------------------------------------------------ | |
1710656f | 117 | |
b2bac0a3 | 118 | fRawReader->Reset(); |
119 | ||
814be89c | 120 | const Int_t kNADC = 12; |
121 | const Int_t kMaxADCClusters = 1000; | |
122 | ||
123 | Int_t strips[kNADC][2][kMaxADCClusters][2]; // [ADC],[side],[istrip], [0]=istrip [1]=signal | |
124 | Int_t nStrips[kNADC][2]; | |
125 | ||
126 | for( int i=0; i<kNADC; i++ ){ | |
127 | nStrips[i][0] = 0; | |
128 | nStrips[i][1] = 0; | |
129 | } | |
130 | ||
131 | Int_t ddl = -1; | |
132 | Int_t ad = -1; | |
133 | ||
134 | //* | |
135 | //* Loop over modules DDL+AD | |
136 | //* | |
137 | ||
b2bac0a3 | 138 | while (kTRUE) { |
814be89c | 139 | |
b2bac0a3 | 140 | bool next = fRawStream->Next(); |
141 | ||
814be89c | 142 | //* |
143 | //* Continue if corrupted input | |
144 | //* | |
b2bac0a3 | 145 | |
814be89c | 146 | if( (!next)&&(fRawStream->flag) ){ |
147 | AliWarning(Form("HLT ClustersFinderSSD: Corrupted data: warning from RawReader")); | |
148 | continue; | |
149 | } | |
b2bac0a3 | 150 | |
814be89c | 151 | Int_t newDDL = fRawStream->GetDDL(); |
152 | Int_t newAD = fRawStream->GetAD(); | |
b2bac0a3 | 153 | |
814be89c | 154 | if( next ){ |
155 | if( newDDL<0 || newDDL>15 ){ | |
726155fd | 156 | // AliWarning(Form("HLT ClustersFinderSSD: Corrupted data: wrong DDL number (%d)",newDDL)); |
814be89c | 157 | continue; |
158 | } | |
159 | ||
160 | if( newAD<1 || newAD>9 ){ | |
726155fd | 161 | // AliWarning(Form("HLT ClustersFinderSSD: Corrupted data: wrong AD number (%d)",newAD)); |
814be89c | 162 | continue; |
b2bac0a3 | 163 | } |
b2bac0a3 | 164 | } |
165 | ||
814be89c | 166 | bool newModule = ( !next || ddl!= newDDL || ad!=newAD ); |
167 | ||
168 | if( newModule && ddl>=0 && ad>=0 ){ | |
169 | ||
170 | //* | |
171 | //* Reconstruct the previous module --- actual clusterfinder | |
172 | //* | |
173 | //cout<<endl; | |
174 | for( int adc = 0; adc<kNADC; adc++ ){ | |
175 | ||
176 | //* 1D clusterfinder | |
177 | ||
178 | Ali1Dcluster clusters1D[2][kMaxADCClusters]; // per ADC, per side | |
179 | Int_t nClusters1D[2] = {0,0}; | |
180 | //int nstat[2] = {0,0}; | |
181 | fModule = AliITSRawStreamSSD::GetModuleNumber(ddl, (ad - 1) * 12 + adc ); | |
182 | ||
183 | if( fModule<0 ){ | |
726155fd | 184 | // AliWarning(Form("HLT ClustersFinderSSD: Corrupted data: module (ddl %d ad %d adc %d) not found in the map",ddl,ad,adc)); |
814be89c | 185 | continue; |
186 | } | |
187 | ||
188 | AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*)fDetTypeRec->GetCalibrationModel(fModule); | |
189 | if( !cal ){ | |
726155fd | 190 | AliWarning(Form("HLT ClustersFinderSSD: No calibration found for module (ddl %d ad %d adc %d)",ddl,ad,adc)); |
814be89c | 191 | continue; |
192 | } | |
193 | ||
194 | Float_t dStrip = 0; | |
195 | ||
196 | if( fRecoParam->GetUseCosmicRunShiftsSSD()) { // Special condition for 2007/2008 cosmic data | |
197 | dStrip = fgkCosmic2008StripShifts[ddl][ad-1]; | |
198 | if (TMath::Abs(dStrip) > 1.5){ | |
199 | AliWarning(Form("Indexing error in Cosmic calibration: ddl = %d, dStrip %f\n",ddl,dStrip)); | |
200 | dStrip = 0; | |
201 | } | |
202 | } | |
203 | ||
204 | for( int side=0; side<=1; side++ ){ | |
205 | ||
206 | Int_t lab[3]={-2,-2,-2}; | |
207 | Float_t q = 0.; | |
208 | Float_t y = 0.; | |
209 | Int_t nDigits = 0; | |
1710656f | 210 | Int_t ostrip = -2; |
814be89c | 211 | Bool_t snFlag = 0; |
212 | ||
213 | Int_t n = nStrips[adc][side]; | |
214 | for( int istr = 0; istr<n+1; istr++ ){ | |
215 | ||
216 | bool stripOK = 1; | |
217 | Int_t strip=0, signal=0; | |
218 | Float_t noise=1, gain=0; | |
219 | ||
220 | if( istr<n ){ | |
221 | strip = strips[adc][side][istr][0]; | |
222 | signal = strips[adc][side][istr][1]; | |
223 | ||
224 | //cout<<"strip "<<adc<<" / "<<side<<": "<<strip<<endl; | |
225 | ||
226 | if( cal ){ | |
227 | noise = side ?cal->GetNoiseN(strip) :cal->GetNoiseP(strip); | |
228 | gain = side ?cal->GetGainN(strip) :cal->GetGainP(strip); | |
229 | stripOK = ( noise>=1. && signal>=3*noise | |
230 | //&& !cal->IsPChannelBad(strip) | |
231 | ); | |
232 | } | |
233 | } else stripOK = 0; // end of data | |
234 | ||
1710656f | 235 | bool newCluster = ( TMath::Abs(strip-ostrip)>1 || !stripOK ); |
814be89c | 236 | |
237 | if( newCluster ){ | |
238 | ||
239 | //* Store the previous cluster | |
240 | ||
241 | if( nDigits>0 && q>0 && snFlag ){ | |
242 | ||
243 | if (nClusters1D[side] >= kMaxADCClusters-1 ) { | |
244 | AliWarning("HLT ClustersFinderSSD: Too many 1D clusters !"); | |
245 | }else { | |
246 | ||
247 | Ali1Dcluster &cluster = clusters1D[side][nClusters1D[side]++]; | |
248 | cluster.SetY( y / q + dStrip); | |
249 | cluster.SetQ(q); | |
250 | cluster.SetNd(nDigits); | |
251 | cluster.SetLabels(lab); | |
252 | //cout<<"cluster 1D side "<<side<<": y= "<<y<<" q= "<<q<<" d="<<dStrip<<" Y="<<cluster.GetY()<<endl; | |
253 | //Split suspiciously big cluster | |
254 | ||
255 | if( fRecoParam->GetUseUnfoldingInClusterFinderSSD() | |
256 | && nDigits > 4 && nDigits < 25 | |
257 | ){ | |
258 | cluster.SetY(y/q + dStrip - 0.25*nDigits); | |
259 | cluster.SetQ(0.5*q); | |
260 | Ali1Dcluster& cluster2 = clusters1D[side][nClusters1D[side]++]; | |
261 | cluster2.SetY(y/q + dStrip + 0.25*nDigits); | |
262 | cluster2.SetQ(0.5*q); | |
263 | cluster2.SetNd(nDigits); | |
264 | cluster2.SetLabels(lab); | |
265 | } // unfolding is on | |
266 | } | |
267 | } | |
268 | y = q = 0.; | |
269 | nDigits = 0; | |
270 | snFlag = 0; | |
271 | ||
272 | } //* End store the previous cluster | |
273 | ||
274 | if( stripOK ){ // add new signal to the cluster | |
275 | signal = (Int_t) ( signal * gain ); // signal is corrected for gain | |
276 | if( signal>fgkThreshold*noise) snFlag = 1; | |
277 | if( cal ) signal = (Int_t) cal->ADCToKeV( signal ); // signal is converted in KeV | |
278 | q += signal; // add digit to current cluster | |
279 | y += strip * signal; | |
280 | nDigits++; | |
281 | //nstat[side]++; | |
282 | ostrip = strip; | |
283 | //cout<<"strip "<<adc<<" / "<<side<<": "<<strip<<" / "<<signal<<" stored"<<endl; | |
284 | ||
285 | } | |
286 | } //* end loop over strips | |
287 | ||
288 | } //* end loop over ADC sides | |
289 | ||
290 | ||
291 | //* 2D clusterfinder | |
292 | ||
293 | if( nClusters1D[0] && nClusters1D[1] && fModule>=0 ){ | |
294 | FindClustersSSD( clusters1D[0], nClusters1D[0], clusters1D[1], nClusters1D[1], clusters); | |
295 | } | |
296 | //cout<<"SG: "<<ddl<<" "<<ad<<" "<<adc<<": strips "<<nstat[0]<<"+"<<nstat[1]<<", clusters 1D= "<<nClusters1D[0]<<" + "<<nClusters1D[1]<<", 2D= "<<clusters.size()<<endl; | |
297 | ||
298 | }//* end loop over adc | |
299 | ||
300 | }//* end of reconstruction of previous module | |
b2bac0a3 | 301 | |
814be89c | 302 | if( newModule ){ |
303 | ||
304 | //* | |
305 | //* Clean up arrays and set new module | |
306 | //* | |
307 | ||
308 | for( int i=0; i<kNADC; i++ ){ | |
309 | nStrips[i][0] = 0; | |
310 | nStrips[i][1] = 0; | |
311 | } | |
312 | ddl = newDDL; | |
313 | ad = newAD; | |
314 | } | |
b2bac0a3 | 315 | |
b2bac0a3 | 316 | |
814be89c | 317 | //* |
318 | //* Exit main loop when there is no more input | |
319 | //* | |
320 | ||
321 | if( !next ) break; | |
b2bac0a3 | 322 | |
814be89c | 323 | //* |
324 | //* Fill the current strip information | |
325 | //* | |
326 | ||
327 | Int_t adc = fRawStream->GetADC(); | |
328 | if( adc<0 || adc>=kNADC+2 || (adc>5&&adc<8) ){ | |
329 | AliWarning(Form("HLT ClustersFinderSSD: Corrupted data: wrong adc number (%d)", adc)); | |
330 | continue; | |
b2bac0a3 | 331 | } |
814be89c | 332 | |
333 | if( adc>7 ) adc-= 2; // shift ADC numbers 8-13 to 6-11 | |
b2bac0a3 | 334 | |
814be89c | 335 | Bool_t side = fRawStream->GetSideFlag(); |
336 | Int_t strip = fRawStream->GetStrip(); | |
337 | Int_t signal = fRawStream->GetSignal(); | |
338 | ||
339 | //cout<<"SSD: "<<ddl<<" "<<ad<<" "<<adc<<" "<<side<<" "<<strip<<" : "<<signal<<endl; | |
b2bac0a3 | 340 | |
814be89c | 341 | if( strip<0 || strip>767 ){ |
814be89c | 342 | continue; |
343 | } | |
b2bac0a3 | 344 | |
814be89c | 345 | int &n = nStrips[adc][side]; |
346 | if( n >0 ){ | |
347 | Int_t oldStrip = strips[adc][side][n-1][0]; | |
814be89c | 348 | if( strip==oldStrip ){ |
349 | AliWarning(Form("HLT ClustersFinderSSD: Corrupted data: duplicated signal: ddl %d ad %d adc %d, side %d, strip %d", | |
350 | ddl, ad, adc, side, strip )); | |
351 | continue; | |
352 | } | |
b2bac0a3 | 353 | } |
814be89c | 354 | strips[adc][side][n][0] = strip; |
355 | strips[adc][side][n][1] = signal; | |
356 | n++; | |
357 | ||
358 | //cout<<"SSD: "<<fRawStream->GetDDL()<<" "<<fRawStream->GetAD()<<" " | |
359 | //<<fRawStream->GetADC()<<" "<<fRawStream->GetSideFlag()<<" "<<((int)fRawStream->GetStrip())<<" "<<strip<<" : "<<fRawStream->GetSignal()<<endl; | |
360 | ||
361 | } //* End main loop over the input | |
362 | ||
b2bac0a3 | 363 | } |
364 | ||
365 | ||
366 | void AliHLTITSClusterFinderSSD:: | |
367 | FindClustersSSD(Ali1Dcluster* neg, Int_t nn, | |
368 | Ali1Dcluster* pos, Int_t np, | |
369 | std::vector<AliITSRecPoint> &clusters) { | |
370 | //------------------------------------------------------------ | |
371 | // Actual SSD cluster finder | |
372 | //------------------------------------------------------------ | |
373 | ||
374 | const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(fModule); | |
375 | ||
376 | AliITSsegmentationSSD *seg = dynamic_cast<AliITSsegmentationSSD*>(fDetTypeRec->GetSegmentationModel(2)); | |
ca9b4618 | 377 | if(!mT2L || !seg){ |
378 | AliError(Form("HLT ClustersFinderSSD: null pointer from TGeo")); | |
379 | return; | |
380 | } | |
b2bac0a3 | 381 | if (fModule>fLastSSD1) |
382 | seg->SetLayer(6); | |
383 | else | |
384 | seg->SetLayer(5); | |
385 | ||
386 | Float_t hwSSD = seg->Dx()*1e-4/2; | |
387 | Float_t hlSSD = seg->Dz()*1e-4/2; | |
388 | ||
389 | Int_t idet=fNdet[fModule]; | |
390 | Int_t ncl=0; | |
391 | ||
392 | // | |
393 | Int_t *cnegative = new Int_t[np]; | |
394 | Int_t *cused1 = new Int_t[np]; | |
395 | Int_t *negativepair = new Int_t[10*np]; | |
396 | Int_t *cpositive = new Int_t[nn]; | |
397 | Int_t *cused2 = new Int_t[nn]; | |
398 | Int_t *positivepair = new Int_t[10*nn]; | |
399 | for (Int_t i=0;i<np;i++) {cnegative[i]=0; cused1[i]=0;} | |
400 | for (Int_t i=0;i<nn;i++) {cpositive[i]=0; cused2[i]=0;} | |
401 | for (Int_t i=0;i<10*np;i++) {negativepair[i]=0;} | |
402 | for (Int_t i=0;i<10*nn;i++) {positivepair[i]=0;} | |
403 | ||
404 | if ((np*nn) > fgPairsSize) { | |
405 | ||
406 | if (fgPairs) delete [] fgPairs; | |
407 | fgPairsSize = 4*np*nn; | |
408 | fgPairs = new Short_t[fgPairsSize]; | |
409 | } | |
410 | memset(fgPairs,0,sizeof(Short_t)*np*nn); | |
411 | ||
412 | // | |
413 | // find available pairs | |
414 | // | |
415 | for (Int_t i=0; i<np; i++) { | |
416 | Float_t yp=pos[i].GetY(); | |
417 | if ( (pos[i].GetQ()>0) && (pos[i].GetQ()<3) ) continue; | |
418 | for (Int_t j=0; j<nn; j++) { | |
419 | if ( (neg[j].GetQ()>0) && (neg[j].GetQ()<3) ) continue; | |
420 | Float_t yn=neg[j].GetY(); | |
421 | ||
422 | Float_t xt, zt; | |
423 | seg->GetPadCxz(yn, yp, xt, zt); | |
424 | //cout<<yn<<" "<<yp<<" "<<xt<<" "<<zt<<endl; | |
425 | ||
426 | if (TMath::Abs(xt)<hwSSD) | |
427 | if (TMath::Abs(zt)<hlSSD) { | |
428 | Int_t in = i*10+cnegative[i]; | |
429 | Int_t ip = j*10+cpositive[j]; | |
430 | if ((in < 10*np) && (ip < 10*nn)) { | |
431 | negativepair[in] =j; //index | |
432 | positivepair[ip] =i; | |
433 | cnegative[i]++; //counters | |
434 | cpositive[j]++; | |
435 | fgPairs[i*nn+j]=100; | |
436 | } | |
437 | else | |
438 | AliError(Form("Index out of range: ip=%d, in=%d",ip,in)); | |
439 | } | |
440 | } | |
441 | } | |
442 | ||
443 | ||
444 | // | |
445 | Float_t lp[6]; | |
446 | Int_t milab[10]; | |
447 | Double_t ratio; | |
448 | ||
449 | ||
450 | if(fRecoParam->GetUseChargeMatchingInClusterFinderSSD()==kTRUE) { | |
451 | ||
452 | ||
453 | // | |
454 | // sign gold tracks | |
455 | // | |
456 | for (Int_t ip=0;ip<np;ip++){ | |
457 | ||
458 | Float_t xbest=1000,zbest=1000,qbest=0; | |
459 | // | |
460 | // select gold clusters | |
461 | if ( (cnegative[ip]==1) && cpositive[negativepair[10*ip]]==1){ | |
462 | ||
463 | Float_t yp=pos[ip].GetY(); | |
464 | Int_t j = negativepair[10*ip]; | |
465 | ||
466 | if( (pos[ip].GetQ()==0) && (neg[j].GetQ() ==0) ) { | |
467 | // both bad, hence continue; | |
468 | // mark both as used (to avoid recover at the end) | |
469 | cused1[ip]++; | |
470 | cused2[j]++; | |
471 | continue; | |
472 | } | |
473 | ||
474 | ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ()); | |
475 | //cout<<"ratio="<<ratio<<endl; | |
476 | ||
477 | // charge matching (note that if posQ or negQ is 0 -> ratio=1 and the following condition is met | |
478 | if (TMath::Abs(ratio)>0.2) continue; // note: 0.2=3xsigma_ratio calculated in cosmics tests | |
479 | ||
480 | // | |
481 | Float_t yn=neg[j].GetY(); | |
482 | ||
483 | Float_t xt, zt; | |
484 | seg->GetPadCxz(yn, yp, xt, zt); | |
485 | ||
486 | xbest=xt; zbest=zt; | |
487 | ||
488 | ||
489 | qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ()); | |
490 | if( (pos[ip].GetQ()==0)||(neg[j].GetQ()==0)) qbest*=2; // in case of bad strips on one side keep all charge from the other one | |
491 | ||
492 | { | |
493 | Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.}; | |
494 | mT2L->MasterToLocal(loc,trk); | |
495 | lp[0]=trk[1]; | |
496 | lp[1]=trk[2]; | |
497 | } | |
498 | lp[4]=qbest; //Q | |
499 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
500 | for (Int_t ilab=0;ilab<3;ilab++){ | |
501 | milab[ilab] = pos[ip].GetLabel(ilab); | |
502 | milab[ilab+3] = neg[j].GetLabel(ilab); | |
503 | } | |
504 | // | |
505 | CheckLabels2(milab); | |
506 | milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det | |
507 | Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]}; | |
508 | ||
509 | lp[2]=0.0022*0.0022; //SigmaY2 | |
510 | lp[3]=0.110*0.110; //SigmaZ2 | |
511 | // out-of-diagonal element of covariance matrix | |
512 | if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012; | |
513 | else if ( (info[0]>1) && (info[1]>1) ) { | |
514 | lp[2]=0.0016*0.0016; //SigmaY2 | |
515 | lp[3]=0.08*0.08; //SigmaZ2 | |
516 | lp[5]=-0.00006; | |
517 | } | |
518 | else { | |
519 | lp[3]=0.093*0.093; | |
520 | if (info[0]==1) { lp[5]=-0.00014;} | |
521 | else { lp[2]=0.0017*0.0017; lp[5]=-0.00004;} | |
522 | } | |
523 | AliITSRecPoint cl2(milab,lp,info); | |
524 | cl2.SetChargeRatio(ratio); | |
525 | cl2.SetType(1); | |
526 | ||
527 | fgPairs[ip*nn+j]=1; | |
528 | if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster | |
529 | cl2.SetType(2); | |
530 | fgPairs[ip*nn+j]=2; | |
531 | } | |
532 | ||
533 | if(pos[ip].GetQ()==0) cl2.SetType(3); | |
534 | if(neg[j].GetQ()==0) cl2.SetType(4); | |
535 | ||
536 | cused1[ip]++; | |
537 | cused2[j]++; | |
538 | ||
539 | clusters.push_back(cl2); | |
540 | ||
541 | ncl++; | |
542 | } | |
543 | } | |
544 | ||
545 | for (Int_t ip=0;ip<np;ip++){ | |
546 | Float_t xbest=1000,zbest=1000,qbest=0; | |
547 | // | |
548 | // | |
549 | // select "silber" cluster | |
550 | if ( cnegative[ip]==1 && cpositive[negativepair[10*ip]]==2){ | |
551 | Int_t in = negativepair[10*ip]; | |
552 | Int_t ip2 = positivepair[10*in]; | |
553 | if (ip2==ip) ip2 = positivepair[10*in+1]; | |
554 | Float_t pcharge = pos[ip].GetQ()+pos[ip2].GetQ(); | |
555 | ||
556 | ||
557 | ||
558 | ratio = (pcharge-neg[in].GetQ())/(pcharge+neg[in].GetQ()); | |
559 | if ( (TMath::Abs(ratio)<0.2) && (pcharge!=0) ) { | |
560 | //if ( (TMath::Abs(pcharge-neg[in].GetQ())<30) && (pcharge!=0) ) { // | |
561 | ||
562 | // | |
563 | // add first pair | |
564 | if ( (fgPairs[ip*nn+in]==100)&&(pos[ip].GetQ() ) ) { // | |
565 | ||
566 | Float_t yp=pos[ip].GetY(); | |
567 | Float_t yn=neg[in].GetY(); | |
568 | ||
569 | Float_t xt, zt; | |
570 | seg->GetPadCxz(yn, yp, xt, zt); | |
571 | ||
572 | xbest=xt; zbest=zt; | |
573 | ||
574 | qbest =pos[ip].GetQ(); | |
575 | Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.}; | |
576 | mT2L->MasterToLocal(loc,trk); | |
577 | lp[0]=trk[1]; | |
578 | lp[1]=trk[2]; | |
579 | ||
580 | lp[4]=qbest; //Q | |
581 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
582 | for (Int_t ilab=0;ilab<3;ilab++){ | |
583 | milab[ilab] = pos[ip].GetLabel(ilab); | |
584 | milab[ilab+3] = neg[in].GetLabel(ilab); | |
585 | } | |
586 | // | |
587 | CheckLabels2(milab); | |
588 | ratio = (pos[ip].GetQ()-neg[in].GetQ())/(pos[ip].GetQ()+neg[in].GetQ()); | |
589 | milab[3]=(((ip<<10) + in)<<10) + idet; // pos|neg|det | |
590 | Int_t info[3] = {pos[ip].GetNd(),neg[in].GetNd(),fNlayer[fModule]}; | |
591 | ||
592 | lp[2]=0.0022*0.0022; //SigmaY2 | |
593 | lp[3]=0.110*0.110; //SigmaZ2 | |
594 | // out-of-diagonal element of covariance matrix | |
595 | if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012; | |
596 | else if ( (info[0]>1) && (info[1]>1) ) { | |
597 | lp[2]=0.0016*0.0016; //SigmaY2 | |
598 | lp[3]=0.08*0.08; //SigmaZ2 | |
599 | lp[5]=-0.00006; | |
600 | } | |
601 | else { | |
602 | lp[3]=0.093*0.093; | |
603 | if (info[0]==1) { lp[5]=-0.00014;} | |
604 | else { lp[2]=0.0017*0.0017; lp[5]=-0.00004;} | |
605 | } | |
606 | ||
607 | AliITSRecPoint cl2(milab,lp,info); | |
608 | cl2.SetChargeRatio(ratio); | |
609 | cl2.SetType(5); | |
610 | fgPairs[ip*nn+in] = 5; | |
611 | if ((pos[ip].GetNd()+neg[in].GetNd())>6){ //multi cluster | |
612 | cl2.SetType(6); | |
613 | fgPairs[ip*nn+in] = 6; | |
614 | } | |
615 | clusters.push_back(cl2); | |
616 | ncl++; | |
617 | } | |
618 | ||
619 | ||
620 | // | |
621 | // add second pair | |
622 | ||
623 | // if (!(cused1[ip2] || cused2[in])){ // | |
624 | if ( (fgPairs[ip2*nn+in]==100) && (pos[ip2].GetQ()) ) { | |
625 | ||
626 | Float_t yp=pos[ip2].GetY(); | |
627 | Float_t yn=neg[in].GetY(); | |
628 | ||
629 | Float_t xt, zt; | |
630 | seg->GetPadCxz(yn, yp, xt, zt); | |
631 | ||
632 | xbest=xt; zbest=zt; | |
633 | ||
634 | qbest =pos[ip2].GetQ(); | |
635 | ||
636 | Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.}; | |
637 | mT2L->MasterToLocal(loc,trk); | |
638 | lp[0]=trk[1]; | |
639 | lp[1]=trk[2]; | |
640 | ||
641 | lp[4]=qbest; //Q | |
642 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
643 | for (Int_t ilab=0;ilab<3;ilab++){ | |
644 | milab[ilab] = pos[ip2].GetLabel(ilab); | |
645 | milab[ilab+3] = neg[in].GetLabel(ilab); | |
646 | } | |
647 | // | |
648 | CheckLabels2(milab); | |
649 | ratio = (pos[ip2].GetQ()-neg[in].GetQ())/(pos[ip2].GetQ()+neg[in].GetQ()); | |
650 | milab[3]=(((ip2<<10) + in)<<10) + idet; // pos|neg|det | |
651 | Int_t info[3] = {pos[ip2].GetNd(),neg[in].GetNd(),fNlayer[fModule]}; | |
652 | ||
653 | lp[2]=0.0022*0.0022; //SigmaY2 | |
654 | lp[3]=0.110*0.110; //SigmaZ2 | |
655 | // out-of-diagonal element of covariance matrix | |
656 | if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012; | |
657 | else if ( (info[0]>1) && (info[1]>1) ) { | |
658 | lp[2]=0.0016*0.0016; //SigmaY2 | |
659 | lp[3]=0.08*0.08; //SigmaZ2 | |
660 | lp[5]=-0.00006; | |
661 | } | |
662 | else { | |
663 | lp[3]=0.093*0.093; | |
664 | if (info[0]==1) { lp[5]=-0.00014;} | |
665 | else { lp[2]=0.0017*0.0017; lp[5]=-0.00004;} | |
666 | } | |
667 | ||
668 | AliITSRecPoint cl2(milab,lp,info); | |
669 | cl2.SetChargeRatio(ratio); | |
670 | cl2.SetType(5); | |
671 | fgPairs[ip2*nn+in] =5; | |
672 | if ((pos[ip2].GetNd()+neg[in].GetNd())>6){ //multi cluster | |
673 | cl2.SetType(6); | |
674 | fgPairs[ip2*nn+in] =6; | |
675 | } | |
676 | clusters.push_back(cl2); | |
677 | ncl++; | |
678 | } | |
679 | ||
680 | cused1[ip]++; | |
681 | cused1[ip2]++; | |
682 | cused2[in]++; | |
683 | ||
684 | } // charge matching condition | |
685 | ||
686 | } // 2 Pside cross 1 Nside | |
687 | } // loop over Pside clusters | |
688 | ||
689 | ||
690 | // | |
691 | for (Int_t jn=0;jn<nn;jn++){ | |
692 | if (cused2[jn]) continue; | |
693 | Float_t xbest=1000,zbest=1000,qbest=0; | |
694 | // select "silber" cluster | |
695 | if ( cpositive[jn]==1 && cnegative[positivepair[10*jn]]==2){ | |
696 | Int_t ip = positivepair[10*jn]; | |
697 | Int_t jn2 = negativepair[10*ip]; | |
698 | if (jn2==jn) jn2 = negativepair[10*ip+1]; | |
699 | Float_t pcharge = neg[jn].GetQ()+neg[jn2].GetQ(); | |
700 | // | |
701 | ||
702 | ||
703 | ratio = (pcharge-pos[ip].GetQ())/(pcharge+pos[ip].GetQ()); | |
704 | if ( (TMath::Abs(ratio)<0.2) && (pcharge!=0) ) { | |
705 | ||
706 | /* | |
707 | if ( (TMath::Abs(pcharge-pos[ip].GetQ())<30) && // charge matching | |
708 | (pcharge!=0) ) { // reject combinations of bad strips | |
709 | */ | |
710 | ||
711 | ||
712 | // | |
713 | // add first pair | |
714 | // if (!(cused1[ip]||cused2[jn])){ | |
715 | if ( (fgPairs[ip*nn+jn]==100) && (neg[jn].GetQ()) ) { // | |
716 | ||
717 | Float_t yn=neg[jn].GetY(); | |
718 | Float_t yp=pos[ip].GetY(); | |
719 | ||
720 | Float_t xt, zt; | |
721 | seg->GetPadCxz(yn, yp, xt, zt); | |
722 | ||
723 | xbest=xt; zbest=zt; | |
724 | ||
725 | qbest =neg[jn].GetQ(); | |
726 | ||
727 | { | |
728 | Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.}; | |
729 | mT2L->MasterToLocal(loc,trk); | |
730 | lp[0]=trk[1]; | |
731 | lp[1]=trk[2]; | |
732 | } | |
733 | ||
734 | lp[4]=qbest; //Q | |
735 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
736 | for (Int_t ilab=0;ilab<3;ilab++){ | |
737 | milab[ilab] = pos[ip].GetLabel(ilab); | |
738 | milab[ilab+3] = neg[jn].GetLabel(ilab); | |
739 | } | |
740 | // | |
741 | CheckLabels2(milab); | |
742 | ratio = (pos[ip].GetQ()-neg[jn].GetQ())/(pos[ip].GetQ()+neg[jn].GetQ()); | |
743 | milab[3]=(((ip<<10) + jn)<<10) + idet; // pos|neg|det | |
744 | Int_t info[3] = {pos[ip].GetNd(),neg[jn].GetNd(),fNlayer[fModule]}; | |
745 | ||
746 | lp[2]=0.0022*0.0022; //SigmaY2 | |
747 | lp[3]=0.110*0.110; //SigmaZ2 | |
748 | // out-of-diagonal element of covariance matrix | |
749 | if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012; | |
750 | else if ( (info[0]>1) && (info[1]>1) ) { | |
751 | lp[2]=0.0016*0.0016; //SigmaY2 | |
752 | lp[3]=0.08*0.08; //SigmaZ2 | |
753 | lp[5]=-0.00006; | |
754 | } | |
755 | else { | |
756 | lp[3]=0.093*0.093; | |
757 | if (info[0]==1) { lp[5]=-0.00014;} | |
758 | else { lp[2]=0.0017*0.0017; lp[5]=-0.00004;} | |
759 | } | |
760 | ||
761 | AliITSRecPoint cl2(milab,lp,info); | |
762 | cl2.SetChargeRatio(ratio); | |
763 | cl2.SetType(7); | |
764 | fgPairs[ip*nn+jn] =7; | |
765 | if ((pos[ip].GetNd()+neg[jn].GetNd())>6){ //multi cluster | |
766 | cl2.SetType(8); | |
767 | fgPairs[ip*nn+jn]=8; | |
768 | } | |
769 | clusters.push_back(cl2); | |
770 | ||
771 | ncl++; | |
772 | } | |
773 | // | |
774 | // add second pair | |
775 | // if (!(cused1[ip]||cused2[jn2])){ | |
776 | if ( (fgPairs[ip*nn+jn2]==100)&&(neg[jn2].GetQ() ) ) { // | |
777 | ||
778 | Float_t yn=neg[jn2].GetY(); | |
779 | Double_t yp=pos[ip].GetY(); | |
780 | ||
781 | Float_t xt, zt; | |
782 | seg->GetPadCxz(yn, yp, xt, zt); | |
783 | ||
784 | xbest=xt; zbest=zt; | |
785 | ||
786 | qbest =neg[jn2].GetQ(); | |
787 | ||
788 | { | |
789 | Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.}; | |
790 | mT2L->MasterToLocal(loc,trk); | |
791 | lp[0]=trk[1]; | |
792 | lp[1]=trk[2]; | |
793 | } | |
794 | ||
795 | lp[4]=qbest; //Q | |
796 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
797 | for (Int_t ilab=0;ilab<3;ilab++){ | |
798 | milab[ilab] = pos[ip].GetLabel(ilab); | |
799 | milab[ilab+3] = neg[jn2].GetLabel(ilab); | |
800 | } | |
801 | // | |
802 | CheckLabels2(milab); | |
803 | ratio = (pos[ip].GetQ()-neg[jn2].GetQ())/(pos[ip].GetQ()+neg[jn2].GetQ()); | |
804 | milab[3]=(((ip<<10) + jn2)<<10) + idet; // pos|neg|det | |
805 | Int_t info[3] = {pos[ip].GetNd(),neg[jn2].GetNd(),fNlayer[fModule]}; | |
806 | ||
807 | lp[2]=0.0022*0.0022; //SigmaY2 | |
808 | lp[3]=0.110*0.110; //SigmaZ2 | |
809 | // out-of-diagonal element of covariance matrix | |
810 | if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012; | |
811 | else if ( (info[0]>1) && (info[1]>1) ) { | |
812 | lp[2]=0.0016*0.0016; //SigmaY2 | |
813 | lp[3]=0.08*0.08; //SigmaZ2 | |
814 | lp[5]=-0.00006; | |
815 | } | |
816 | else { | |
817 | lp[3]=0.093*0.093; | |
818 | if (info[0]==1) { lp[5]=-0.00014;} | |
819 | else { lp[2]=0.0017*0.0017; lp[5]=-0.00004;} | |
820 | } | |
821 | ||
822 | AliITSRecPoint cl2(milab,lp,info); | |
823 | cl2.SetChargeRatio(ratio); | |
824 | fgPairs[ip*nn+jn2]=7; | |
825 | cl2.SetType(7); | |
826 | if ((pos[ip].GetNd()+neg[jn2].GetNd())>6){ //multi cluster | |
827 | cl2.SetType(8); | |
828 | fgPairs[ip*nn+jn2]=8; | |
829 | } | |
830 | clusters.push_back( cl2 ); | |
831 | ncl++; | |
832 | } | |
833 | cused1[ip]++; | |
834 | cused2[jn]++; | |
835 | cused2[jn2]++; | |
836 | ||
837 | } // charge matching condition | |
838 | ||
839 | } // 2 Nside cross 1 Pside | |
840 | } // loop over Pside clusters | |
841 | ||
842 | ||
843 | ||
844 | for (Int_t ip=0;ip<np;ip++){ | |
845 | ||
846 | if(cused1[ip]) continue; | |
847 | ||
848 | ||
849 | Float_t xbest=1000,zbest=1000,qbest=0; | |
850 | // | |
851 | // 2x2 clusters | |
852 | // | |
853 | if ( (cnegative[ip]==2) && cpositive[negativepair[10*ip]]==2){ | |
854 | Float_t minchargediff =4.; | |
75e6d9eb | 855 | //Float_t minchargeratio =0.2; |
b2bac0a3 | 856 | |
857 | Int_t j=-1; | |
858 | for (Int_t di=0;di<cnegative[ip];di++){ | |
859 | Int_t jc = negativepair[ip*10+di]; | |
860 | Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ(); | |
861 | ratio = (pos[ip].GetQ()-neg[jc].GetQ())/(pos[ip].GetQ()+neg[jc].GetQ()); | |
862 | //if (TMath::Abs(chargedif)<minchargediff){ | |
863 | if (TMath::Abs(ratio)<0.2){ | |
864 | j =jc; | |
865 | minchargediff = TMath::Abs(chargedif); | |
75e6d9eb | 866 | //minchargeratio = TMath::Abs(ratio); |
b2bac0a3 | 867 | } |
868 | } | |
869 | if (j<0) continue; // not proper cluster | |
870 | ||
871 | ||
872 | Int_t count =0; | |
873 | for (Int_t di=0;di<cnegative[ip];di++){ | |
874 | Int_t jc = negativepair[ip*10+di]; | |
875 | Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ(); | |
876 | if (TMath::Abs(chargedif)<minchargediff+3.) count++; | |
877 | } | |
878 | if (count>1) continue; // more than one "proper" cluster for positive | |
879 | // | |
880 | ||
881 | count =0; | |
882 | for (Int_t dj=0;dj<cpositive[j];dj++){ | |
883 | Int_t ic = positivepair[j*10+dj]; | |
884 | Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ(); | |
885 | if (TMath::Abs(chargedif)<minchargediff+3.) count++; | |
886 | } | |
887 | if (count>1) continue; // more than one "proper" cluster for negative | |
888 | ||
889 | Int_t jp = 0; | |
890 | ||
891 | count =0; | |
892 | for (Int_t dj=0;dj<cnegative[jp];dj++){ | |
893 | Int_t ic = positivepair[jp*10+dj]; | |
894 | Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ(); | |
895 | if (TMath::Abs(chargedif)<minchargediff+4.) count++; | |
896 | } | |
897 | if (count>1) continue; | |
898 | if (fgPairs[ip*nn+j]<100) continue; | |
899 | // | |
900 | ||
901 | ||
902 | ||
903 | //almost gold clusters | |
904 | Float_t yp=pos[ip].GetY(); | |
905 | Float_t yn=neg[j].GetY(); | |
906 | Float_t xt, zt; | |
907 | seg->GetPadCxz(yn, yp, xt, zt); | |
908 | xbest=xt; zbest=zt; | |
909 | qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ()); | |
910 | { | |
911 | Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.}; | |
912 | mT2L->MasterToLocal(loc,trk); | |
913 | lp[0]=trk[1]; | |
914 | lp[1]=trk[2]; | |
915 | } | |
916 | lp[4]=qbest; //Q | |
917 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
918 | for (Int_t ilab=0;ilab<3;ilab++){ | |
919 | milab[ilab] = pos[ip].GetLabel(ilab); | |
920 | milab[ilab+3] = neg[j].GetLabel(ilab); | |
921 | } | |
922 | // | |
923 | CheckLabels2(milab); | |
924 | if ((neg[j].GetQ()==0)&&(pos[ip].GetQ()==0)) continue; // reject crosses of bad strips!! | |
925 | ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ()); | |
926 | milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det | |
927 | Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]}; | |
928 | ||
929 | lp[2]=0.0022*0.0022; //SigmaY2 | |
930 | lp[3]=0.110*0.110; //SigmaZ2 | |
931 | // out-of-diagonal element of covariance matrix | |
932 | if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012; | |
933 | else if ( (info[0]>1) && (info[1]>1) ) { | |
934 | lp[2]=0.0016*0.0016; //SigmaY2 | |
935 | lp[3]=0.08*0.08; //SigmaZ2 | |
936 | lp[5]=-0.00006; | |
937 | } | |
938 | else { | |
939 | lp[3]=0.093*0.093; | |
940 | if (info[0]==1) { lp[5]=-0.00014;} | |
941 | else { lp[2]=0.0017*0.0017; lp[5]=-0.00004;} | |
942 | } | |
943 | ||
944 | AliITSRecPoint cl2(milab,lp,info); | |
945 | cl2.SetChargeRatio(ratio); | |
946 | cl2.SetType(10); | |
947 | fgPairs[ip*nn+j]=10; | |
948 | if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster | |
949 | cl2.SetType(11); | |
950 | fgPairs[ip*nn+j]=11; | |
951 | } | |
952 | cused1[ip]++; | |
953 | cused2[j]++; | |
954 | ||
955 | clusters.push_back(cl2); | |
956 | ncl++; | |
957 | ||
958 | } // 2X2 | |
959 | } // loop over Pside 1Dclusters | |
960 | ||
961 | ||
962 | for (Int_t ip=0;ip<np;ip++){ | |
963 | ||
964 | if(cused1[ip]) continue; | |
965 | ||
966 | ||
967 | Float_t xbest=1000,zbest=1000,qbest=0; | |
968 | // | |
969 | // manyxmany clusters | |
970 | // | |
971 | if ( (cnegative[ip]<5) && cpositive[negativepair[10*ip]]<5){ | |
972 | Float_t minchargediff =4.; | |
973 | Int_t j=-1; | |
974 | for (Int_t di=0;di<cnegative[ip];di++){ | |
975 | Int_t jc = negativepair[ip*10+di]; | |
976 | Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ(); | |
977 | if (TMath::Abs(chargedif)<minchargediff){ | |
978 | j =jc; | |
979 | minchargediff = TMath::Abs(chargedif); | |
980 | } | |
981 | } | |
982 | if (j<0) continue; // not proper cluster | |
983 | ||
984 | Int_t count =0; | |
985 | for (Int_t di=0;di<cnegative[ip];di++){ | |
986 | Int_t jc = negativepair[ip*10+di]; | |
987 | Float_t chargedif = pos[ip].GetQ()-neg[jc].GetQ(); | |
988 | if (TMath::Abs(chargedif)<minchargediff+3.) count++; | |
989 | } | |
990 | if (count>1) continue; // more than one "proper" cluster for positive | |
991 | // | |
992 | ||
993 | count =0; | |
994 | for (Int_t dj=0;dj<cpositive[j];dj++){ | |
995 | Int_t ic = positivepair[j*10+dj]; | |
996 | Float_t chargedif = pos[ic].GetQ()-neg[j].GetQ(); | |
997 | if (TMath::Abs(chargedif)<minchargediff+3.) count++; | |
998 | } | |
999 | if (count>1) continue; // more than one "proper" cluster for negative | |
1000 | ||
1001 | Int_t jp = 0; | |
1002 | ||
1003 | count =0; | |
1004 | for (Int_t dj=0;dj<cnegative[jp];dj++){ | |
1005 | Int_t ic = positivepair[jp*10+dj]; | |
1006 | Float_t chargedif = pos[ic].GetQ()-neg[jp].GetQ(); | |
1007 | if (TMath::Abs(chargedif)<minchargediff+4.) count++; | |
1008 | } | |
1009 | if (count>1) continue; | |
1010 | if (fgPairs[ip*nn+j]<100) continue; | |
1011 | // | |
1012 | ||
1013 | //almost gold clusters | |
1014 | Float_t yp=pos[ip].GetY(); | |
1015 | Float_t yn=neg[j].GetY(); | |
1016 | ||
1017 | ||
1018 | Float_t xt, zt; | |
1019 | seg->GetPadCxz(yn, yp, xt, zt); | |
1020 | ||
1021 | xbest=xt; zbest=zt; | |
1022 | ||
1023 | qbest=0.5*(pos[ip].GetQ()+neg[j].GetQ()); | |
1024 | ||
1025 | { | |
1026 | Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.}; | |
1027 | mT2L->MasterToLocal(loc,trk); | |
1028 | lp[0]=trk[1]; | |
1029 | lp[1]=trk[2]; | |
1030 | } | |
1031 | lp[4]=qbest; //Q | |
1032 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1033 | for (Int_t ilab=0;ilab<3;ilab++){ | |
1034 | milab[ilab] = pos[ip].GetLabel(ilab); | |
1035 | milab[ilab+3] = neg[j].GetLabel(ilab); | |
1036 | } | |
1037 | // | |
1038 | CheckLabels2(milab); | |
1039 | if ((neg[j].GetQ()==0)&&(pos[ip].GetQ()==0)) continue; // reject crosses of bad strips!! | |
1040 | ratio = (pos[ip].GetQ()-neg[j].GetQ())/(pos[ip].GetQ()+neg[j].GetQ()); | |
1041 | milab[3]=(((ip<<10) + j)<<10) + idet; // pos|neg|det | |
1042 | Int_t info[3] = {pos[ip].GetNd(),neg[j].GetNd(),fNlayer[fModule]}; | |
1043 | ||
1044 | lp[2]=0.0022*0.0022; //SigmaY2 | |
1045 | lp[3]=0.110*0.110; //SigmaZ2 | |
1046 | // out-of-diagonal element of covariance matrix | |
1047 | if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012; | |
1048 | else if ( (info[0]>1) && (info[1]>1) ) { | |
1049 | lp[2]=0.0016*0.0016; //SigmaY2 | |
1050 | lp[3]=0.08*0.08; //SigmaZ2 | |
1051 | lp[5]=-0.00006; | |
1052 | } | |
1053 | else { | |
1054 | lp[3]=0.093*0.093; | |
1055 | if (info[0]==1) { lp[5]=-0.00014;} | |
1056 | else { lp[2]=0.0017*0.0017; lp[5]=-0.00004;} | |
1057 | } | |
1058 | ||
1059 | AliITSRecPoint cl2(milab,lp,info); | |
1060 | cl2.SetChargeRatio(ratio); | |
1061 | cl2.SetType(12); | |
1062 | fgPairs[ip*nn+j]=12; | |
1063 | if ((pos[ip].GetNd()+neg[j].GetNd())>6){ //multi cluster | |
1064 | cl2.SetType(13); | |
1065 | fgPairs[ip*nn+j]=13; | |
1066 | } | |
1067 | cused1[ip]++; | |
1068 | cused2[j]++; | |
1069 | clusters.push_back( cl2 ); | |
1070 | ncl++; | |
1071 | ||
1072 | } // manyXmany | |
1073 | } // loop over Pside 1Dclusters | |
1074 | ||
1075 | } // use charge matching | |
1076 | ||
1077 | // recover all the other crosses | |
1078 | // | |
1079 | for (Int_t i=0; i<np; i++) { | |
1080 | Float_t xbest=1000,zbest=1000,qbest=0; | |
1081 | Float_t yp=pos[i].GetY(); | |
1082 | if ((pos[i].GetQ()>0)&&(pos[i].GetQ()<3)) continue; | |
1083 | for (Int_t j=0; j<nn; j++) { | |
1084 | // for (Int_t di = 0;di<cpositive[i];di++){ | |
1085 | // Int_t j = negativepair[10*i+di]; | |
1086 | if ((neg[j].GetQ()>0)&&(neg[j].GetQ()<3)) continue; | |
1087 | ||
1088 | if ((neg[j].GetQ()==0)&&(pos[i].GetQ()==0)) continue; // reject crosses of bad strips!! | |
1089 | ||
1090 | if (cused2[j]||cused1[i]) continue; | |
1091 | if (fgPairs[i*nn+j]>0 &&fgPairs[i*nn+j]<100) continue; | |
1092 | ratio = (pos[i].GetQ()-neg[j].GetQ())/(pos[i].GetQ()+neg[j].GetQ()); | |
1093 | Float_t yn=neg[j].GetY(); | |
1094 | ||
1095 | Float_t xt, zt; | |
1096 | seg->GetPadCxz(yn, yp, xt, zt); | |
1097 | ||
1098 | if (TMath::Abs(xt)<hwSSD) | |
1099 | if (TMath::Abs(zt)<hlSSD) { | |
1100 | xbest=xt; zbest=zt; | |
1101 | ||
1102 | qbest=0.5*(pos[i].GetQ()+neg[j].GetQ()); | |
1103 | ||
1104 | { | |
1105 | Double_t loc[3]={xbest,0.,zbest},trk[3]={0.,0.,0.}; | |
1106 | mT2L->MasterToLocal(loc,trk); | |
1107 | lp[0]=trk[1]; | |
1108 | lp[1]=trk[2]; | |
1109 | } | |
1110 | lp[4]=qbest; //Q | |
1111 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1112 | for (Int_t ilab=0;ilab<3;ilab++){ | |
1113 | milab[ilab] = pos[i].GetLabel(ilab); | |
1114 | milab[ilab+3] = neg[j].GetLabel(ilab); | |
1115 | } | |
1116 | // | |
1117 | CheckLabels2(milab); | |
1118 | milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det | |
1119 | Int_t info[3] = {pos[i].GetNd(),neg[j].GetNd(),fNlayer[fModule]}; | |
1120 | ||
1121 | lp[2]=0.0022*0.0022; //SigmaY2 | |
1122 | lp[3]=0.110*0.110; //SigmaZ2 | |
1123 | // out-of-diagonal element of covariance matrix | |
1124 | if( (info[0]==1) && (info[1]==1) ) lp[5]=-0.00012; | |
1125 | else if ( (info[0]>1) && (info[1]>1) ) { | |
1126 | lp[2]=0.0016*0.0016; //SigmaY2 | |
1127 | lp[3]=0.08*0.08; //SigmaZ2 | |
1128 | lp[5]=-0.00006; | |
1129 | } | |
1130 | else { | |
1131 | lp[3]=0.093*0.093; | |
1132 | if (info[0]==1) { lp[5]=-0.00014;} | |
1133 | else { lp[2]=0.0017*0.0017; lp[5]=-0.00004;} | |
1134 | } | |
1135 | ||
1136 | AliITSRecPoint cl2(milab,lp,info); | |
1137 | cl2.SetChargeRatio(ratio); | |
1138 | cl2.SetType(100+cpositive[j]+cnegative[i]); | |
1139 | ||
1140 | if(pos[i].GetQ()==0) cl2.SetType(200+cpositive[j]+cnegative[i]); | |
1141 | if(neg[j].GetQ()==0) cl2.SetType(300+cpositive[j]+cnegative[i]); | |
1142 | clusters.push_back( cl2 ); | |
1143 | ncl++; | |
1144 | } | |
1145 | } | |
1146 | } | |
1147 | ||
1148 | ||
1149 | if(fRecoParam->GetUseBadChannelsInClusterFinderSSD()==kTRUE) { | |
1150 | ||
1151 | //--------------------------------------------------------- | |
1152 | // recover crosses of good 1D clusters with bad strips on the other side | |
1153 | // Note1: at first iteration skip modules with a bad side (or almost), (would produce too many fake!) | |
1154 | // Note2: for modules with a bad side see below | |
1155 | ||
1156 | AliITSCalibrationSSD* cal = (AliITSCalibrationSSD*) fDetTypeRec->GetCalibrationModel(fModule); | |
1157 | Int_t countPbad=0, countNbad=0; | |
1158 | for(Int_t ib=0; ib<768; ib++) { | |
1159 | if(cal->IsPChannelBad(ib)) countPbad++; | |
1160 | if(cal->IsNChannelBad(ib)) countNbad++; | |
1161 | } | |
1162 | // AliInfo(Form("module %d has %d P- and %d N-bad strips",fModule,countPbad,countNbad)); | |
1163 | ||
1164 | if( (countPbad<100) && (countNbad<100) ) { // no bad side!! | |
1165 | ||
1166 | for (Int_t i=0; i<np; i++) { // loop over Nside 1Dclusters with no crosses | |
1167 | if(cnegative[i]) continue; // if intersecting Pside clusters continue; | |
1168 | ||
1169 | // for(Int_t ib=0; ib<768; ib++) { // loop over all Pstrips | |
1170 | for(Int_t ib=15; ib<753; ib++) { // loop over all Pstrips | |
1171 | ||
1172 | if(cal->IsPChannelBad(ib)) { // check if strips is bad | |
1173 | Float_t yN=pos[i].GetY(); | |
1174 | Float_t xt, zt; | |
1175 | seg->GetPadCxz(1.*ib, yN, xt, zt); | |
1176 | ||
1177 | //---------- | |
1178 | // bad Pstrip is crossing the Nside 1Dcluster -> create recpoint | |
1179 | // | |
1180 | if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) { | |
1181 | Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.}; | |
1182 | mT2L->MasterToLocal(loc,trk); | |
1183 | lp[0]=trk[1]; | |
1184 | lp[1]=trk[2]; | |
1185 | lp[4]=pos[i].GetQ(); //Q | |
1186 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1187 | for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = pos[i].GetLabel(ilab); | |
1188 | CheckLabels2(milab); | |
1189 | milab[3]=( (i<<10) << 10 ) + idet; // pos|neg|det | |
1190 | Int_t info[3] = {pos[i].GetNd(),0,fNlayer[fModule]}; | |
1191 | ||
1192 | // out-of-diagonal element of covariance matrix | |
1193 | if (info[0]==1) lp[5]=0.0065; | |
1194 | else lp[5]=0.0093; | |
1195 | ||
1196 | lp[2]=0.0022*0.0022; //SigmaY2 | |
1197 | lp[3]=0.110*0.110; //SigmaZ2 | |
1198 | lp[5]=-0.00012; // out-of-diagonal element of covariance matrix | |
1199 | ||
1200 | AliITSRecPoint cl2(milab,lp,info); | |
1201 | cl2.SetChargeRatio(1.); | |
1202 | cl2.SetType(50); | |
1203 | clusters.push_back( cl2 ); | |
1204 | ncl++; | |
1205 | } // cross is within the detector | |
1206 | // | |
1207 | //-------------- | |
1208 | ||
1209 | } // bad Pstrip | |
1210 | ||
1211 | } // end loop over Pstrips | |
1212 | ||
1213 | } // end loop over Nside 1D clusters | |
1214 | ||
1215 | for (Int_t j=0; j<nn; j++) { // loop over Pside 1D clusters with no crosses | |
1216 | if(cpositive[j]) continue; | |
1217 | ||
1218 | // for(Int_t ib=0; ib<768; ib++) { // loop over all Nside strips | |
1219 | for(Int_t ib=15; ib<753; ib++) { // loop over all Nside strips | |
1220 | ||
1221 | if(cal->IsNChannelBad(ib)) { // check if strip is bad | |
1222 | Float_t yP=neg[j].GetY(); | |
1223 | Float_t xt, zt; | |
1224 | seg->GetPadCxz(yP, 1.*ib, xt, zt); | |
1225 | ||
1226 | //---------- | |
1227 | // bad Nstrip is crossing the Pside 1Dcluster -> create recpoint | |
1228 | // | |
1229 | if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) { | |
1230 | Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.}; | |
1231 | mT2L->MasterToLocal(loc,trk); | |
1232 | lp[0]=trk[1]; | |
1233 | lp[1]=trk[2]; | |
1234 | lp[4]=neg[j].GetQ(); //Q | |
1235 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1236 | for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = neg[j].GetLabel(ilab); | |
1237 | CheckLabels2(milab); | |
1238 | milab[3]=( j << 10 ) + idet; // pos|neg|det | |
1239 | Int_t info[3]={0,(Int_t)neg[j].GetNd(),fNlayer[fModule]}; | |
1240 | ||
1241 | lp[2]=0.0022*0.0022; //SigmaY2 | |
1242 | lp[3]=0.110*0.110; //SigmaZ2 | |
1243 | lp[5]=-0.00012; // out-of-diagonal element of covariance matrix | |
1244 | ||
1245 | AliITSRecPoint cl2(milab,lp,info); | |
1246 | cl2.SetChargeRatio(1.); | |
1247 | cl2.SetType(60); | |
1248 | clusters.push_back( cl2 ); | |
1249 | ncl++; | |
1250 | } // cross is within the detector | |
1251 | // | |
1252 | //-------------- | |
1253 | ||
1254 | } // bad Nstrip | |
1255 | } // end loop over Nstrips | |
1256 | } // end loop over Pside 1D clusters | |
1257 | ||
1258 | } // no bad sides | |
1259 | ||
1260 | //--------------------------------------------------------- | |
1261 | ||
1262 | else if( (countPbad>700) && (countNbad<100) ) { // bad Pside!! | |
1263 | ||
1264 | for (Int_t i=0; i<np; i++) { // loop over Nside 1Dclusters with no crosses | |
1265 | if(cnegative[i]) continue; // if intersecting Pside clusters continue; | |
1266 | ||
1267 | Float_t xt, zt; | |
1268 | Float_t yN=pos[i].GetY(); | |
1269 | Float_t yP=0.; | |
1270 | if (seg->GetLayer()==5) yP = yN + (7.6/1.9); | |
1271 | else yP = yN - (7.6/1.9); | |
1272 | seg->GetPadCxz(yP, yN, xt, zt); | |
1273 | ||
1274 | if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) { | |
1275 | Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.}; | |
1276 | mT2L->MasterToLocal(loc,trk); | |
1277 | lp[0]=trk[1]; | |
1278 | lp[1]=trk[2]; | |
1279 | lp[4]=pos[i].GetQ(); //Q | |
1280 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1281 | for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = pos[i].GetLabel(ilab); | |
1282 | CheckLabels2(milab); | |
1283 | milab[3]=( (i<<10) << 10 ) + idet; // pos|neg|det | |
1284 | Int_t info[3] = {(Int_t)pos[i].GetNd(),0,fNlayer[fModule]}; | |
1285 | ||
1286 | lp[2]=0.031*0.031; //SigmaY2 | |
1287 | lp[3]=1.15*1.15; //SigmaZ2 | |
1288 | lp[5]=-0.036; | |
1289 | ||
1290 | AliITSRecPoint cl2(milab,lp,info); | |
1291 | cl2.SetChargeRatio(1.); | |
1292 | cl2.SetType(70); | |
1293 | clusters.push_back( cl2 ); | |
1294 | ncl++; | |
1295 | } // cross is within the detector | |
1296 | // | |
1297 | //-------------- | |
1298 | ||
1299 | } // end loop over Nside 1D clusters | |
1300 | ||
1301 | } // bad Pside module | |
1302 | ||
1303 | else if( (countNbad>700) && (countPbad<100) ) { // bad Nside!! | |
1304 | ||
1305 | for (Int_t j=0; j<nn; j++) { // loop over Pside 1D clusters with no crosses | |
1306 | if(cpositive[j]) continue; | |
1307 | ||
1308 | Float_t xt, zt; | |
1309 | Float_t yP=neg[j].GetY(); | |
1310 | Float_t yN=0.; | |
1311 | if (seg->GetLayer()==5) yN = yP - (7.6/1.9); | |
1312 | else yN = yP + (7.6/1.9); | |
1313 | seg->GetPadCxz(yP, yN, xt, zt); | |
1314 | ||
1315 | if ( (TMath::Abs(xt)<hwSSD) && (TMath::Abs(zt)<hlSSD) ) { | |
1316 | Double_t loc[3]={xt,0.,zt},trk[3]={0.,0.,0.}; | |
1317 | mT2L->MasterToLocal(loc,trk); | |
1318 | lp[0]=trk[1]; | |
1319 | lp[1]=trk[2]; | |
1320 | lp[4]=neg[j].GetQ(); //Q | |
1321 | for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2; | |
1322 | for (Int_t ilab=0;ilab<3;ilab++) milab[ilab] = neg[j].GetLabel(ilab); | |
1323 | CheckLabels2(milab); | |
1324 | milab[3]=( j << 10 ) + idet; // pos|neg|det | |
1325 | Int_t info[3] = {0,(Int_t)neg[j].GetNd(),fNlayer[fModule]}; | |
1326 | ||
1327 | lp[2]=0.0085*0.0085; //SigmaY2 | |
1328 | lp[3]=1.15*1.15; //SigmaZ2 | |
1329 | lp[5]=0.0093; | |
1330 | ||
1331 | AliITSRecPoint cl2(milab,lp,info); | |
1332 | cl2.SetChargeRatio(1.); | |
1333 | cl2.SetType(80); | |
1334 | clusters.push_back( cl2 ); | |
1335 | ncl++; | |
1336 | } // cross is within the detector | |
1337 | // | |
1338 | //-------------- | |
1339 | ||
1340 | } // end loop over Pside 1D clusters | |
1341 | ||
1342 | } // bad Nside module | |
1343 | ||
1344 | //--------------------------------------------------------- | |
1345 | ||
1346 | } // use bad channels | |
1347 | ||
1348 | //cout<<ncl<<" clusters for this module"<<endl; | |
1349 | ||
1350 | delete [] cnegative; | |
1351 | delete [] cused1; | |
1352 | delete [] negativepair; | |
1353 | delete [] cpositive; | |
1354 | delete [] cused2; | |
1355 | delete [] positivepair; | |
1356 | ||
1357 | } |