]>
Commit | Line | Data |
---|---|---|
04366a57 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2003, 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 | // Implementation of the ITS clusterer V2 class // | |
17 | // // | |
18 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch // | |
d6d232ba | 19 | // Unfolding switch from AliITSRecoParam: D. Elia, INFN Bari // |
04366a57 | 20 | // // |
d6d232ba | 21 | //////////////////////////////////////////////////////////////////////////// |
04366a57 | 22 | |
04366a57 | 23 | |
66b89079 | 24 | #include <TGeoGlobalMagField.h> |
8d37cc87 | 25 | #include "AliITSCalibrationSPD.h" |
04366a57 | 26 | #include "AliITSClusterFinderV2SPD.h" |
00a7cc50 | 27 | #include "AliITSRecPoint.h" |
1f3e997f | 28 | #include "AliITSgeomTGeo.h" |
7d62fb64 | 29 | #include "AliITSDetTypeRec.h" |
d6d232ba | 30 | #include "AliITSReconstructor.h" |
04366a57 | 31 | #include "AliRawReader.h" |
32 | #include "AliITSRawStreamSPD.h" | |
04366a57 | 33 | #include <TClonesArray.h> |
04366a57 | 34 | #include "AliITSdigitSPD.h" |
ad7f2bfa | 35 | #include "AliITSFOSignalsSPD.h" |
01ef1bd4 | 36 | #include "AliITSRecPointContainer.h" |
66b89079 | 37 | #include "AliMagF.h" |
38 | #include "AliITSsegmentationSPD.h" | |
04366a57 | 39 | |
40 | ClassImp(AliITSClusterFinderV2SPD) | |
41 | ||
ad7f2bfa | 42 | //__________________________________________________________________________ |
5d2c2f86 | 43 | AliITSClusterFinderV2SPD::AliITSClusterFinderV2SPD(AliITSDetTypeRec* dettyp):AliITSClusterFinder(dettyp), |
1f3e997f | 44 | fLastSPD1(AliITSgeomTGeo::GetModuleIndex(2,1,1)-1), |
e56160b8 | 45 | fNySPD(256), |
46 | fNzSPD(160), | |
47 | fYpitchSPD(0.0050), | |
48 | fZ1pitchSPD(0.0425), | |
49 | fZ2pitchSPD(0.0625), | |
50 | fHwSPD(0.64), | |
51 | fHlSPD(3.48){ | |
04366a57 | 52 | |
53 | //Default constructor | |
04366a57 | 54 | |
04366a57 | 55 | fYSPD[0]=0.5*fYpitchSPD; |
56 | for (Int_t m=1; m<fNySPD; m++) fYSPD[m]=fYSPD[m-1]+fYpitchSPD; | |
57 | fZSPD[0]=fZ1pitchSPD; | |
58 | for (Int_t m=1; m<fNzSPD; m++) { | |
59 | Double_t dz=fZ1pitchSPD; | |
60 | if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 || | |
61 | m==127 || m==128) dz=fZ2pitchSPD; | |
62 | fZSPD[m]=fZSPD[m-1]+dz; | |
63 | } | |
64 | for (Int_t m=0; m<fNzSPD; m++) { | |
65 | Double_t dz=0.5*fZ1pitchSPD; | |
66 | if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 || | |
67 | m==127 || m==128) dz=0.5*fZ2pitchSPD; | |
68 | fZSPD[m]-=dz; | |
69 | } | |
70 | ||
71 | } | |
ad7f2bfa | 72 | //__________________________________________________________________________ |
04366a57 | 73 | void AliITSClusterFinderV2SPD::FindRawClusters(Int_t mod){ |
04366a57 | 74 | //Find clusters V2 |
75 | SetModule(mod); | |
76 | FindClustersSPD(fDigits); | |
77 | ||
78 | } | |
ad7f2bfa | 79 | //__________________________________________________________________________ |
01ef1bd4 | 80 | void AliITSClusterFinderV2SPD::RawdataToClusters(AliRawReader* rawReader){ |
ad7f2bfa | 81 | //------------------------------------------------------------ |
04366a57 | 82 | // This function creates ITS clusters from raw data |
83 | //------------------------------------------------------------ | |
84 | rawReader->Reset(); | |
85 | AliITSRawStreamSPD inputSPD(rawReader); | |
01ef1bd4 | 86 | FindClustersSPD(&inputSPD); |
04366a57 | 87 | |
88 | } | |
ad7f2bfa | 89 | //__________________________________________________________________________ |
04366a57 | 90 | Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,TClonesArray* clusters,Int_t maxBins,Int_t nzbins,Int_t iModule,Bool_t rawdata){ |
91 | ||
92 | //Cluster finder for SPD (from digits and from rawdata) | |
66b89079 | 93 | const Double_t kmictocm = 1.0e-4; // convert microns to cm. |
94 | const Double_t defaultField = 5.0; // default Bz value at which Tan(theta_Lorentz) is given in RecoParam | |
04366a57 | 95 | |
5c47990a | 96 | static AliITSRecoParam *repa = NULL; |
97 | if(!repa){ | |
98 | repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam(); | |
99 | if(!repa){ | |
ed446fa3 | 100 | repa = AliITSRecoParam::GetHighFluxParam(); |
5c47990a | 101 | AliWarning("Using default AliITSRecoParam class"); |
102 | } | |
103 | } | |
b4704be3 | 104 | const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(iModule); |
8d37cc87 | 105 | |
66b89079 | 106 | // Lorentz angle correction |
107 | Double_t tanLorentzAngle=0; | |
108 | AliITSsegmentationSPD *seg = (AliITSsegmentationSPD*)(GetDetTypeRec()->GetSegmentationModel(0)); | |
109 | Double_t thick = 0.5*kmictocm*seg->Dy(); // Half Thickness in cm | |
110 | if(repa->GetCorrectLorentzAngleSPD()) { // only if CorrectLorentzAngleSPD required | |
111 | // here retrieve the value of the field | |
112 | AliMagF* field = dynamic_cast<AliMagF*>(TGeoGlobalMagField::Instance()->GetField()); | |
045be90c | 113 | if (field == 0) { |
66b89079 | 114 | AliError("Cannot get magnetic field from TGeoGlobalMagField"); |
045be90c | 115 | } |
116 | else { | |
117 | Float_t magField = field->SolenoidField(); | |
118 | tanLorentzAngle=repa->GetTanLorentzAngleHolesSPD() * magField / defaultField ; | |
119 | } | |
66b89079 | 120 | } |
121 | // | |
122 | ||
ad7f2bfa | 123 | if (repa->GetSPDRemoveNoisyFlag()) { |
124 | // Loop on noisy pixels and reset them | |
125 | AliITSCalibrationSPD *cal = | |
126 | (AliITSCalibrationSPD*) fDetTypeRec->GetCalibrationModel(iModule); | |
127 | for(Int_t ipix = 0; ipix<cal->GetNrBad(); ipix++){ | |
128 | Int_t row, col; | |
129 | cal->GetBadPixel(ipix,row,col); | |
190ba77d | 130 | //PH printf(" module %d row %d col %d \n",iModule,row,col); |
ad7f2bfa | 131 | Int_t index = (row+1) * nzbins + (col+1); |
132 | ||
133 | bins[index].SetQ(0); | |
134 | bins[index].SetMask(0xFFFFFFFE); | |
135 | } | |
136 | } | |
137 | ||
138 | if (repa->GetSPDRemoveDeadFlag()) { | |
139 | // Loop on dead pixels and reset them | |
140 | AliITSCalibrationSPD *cal = | |
141 | (AliITSCalibrationSPD*) fDetTypeRec->GetSPDDeadModel(iModule); | |
142 | if (cal->IsBad()) return 0; // if all ladder is dead, return to save time | |
143 | for(Int_t ipix = 0; ipix<cal->GetNrBad(); ipix++){ | |
144 | Int_t row, col; | |
145 | cal->GetBadPixel(ipix,row,col); | |
146 | Int_t index = (row+1) * nzbins + (col+1); | |
147 | bins[index].SetQ(0); | |
148 | bins[index].SetMask(0xFFFFFFFE); | |
149 | } | |
8d37cc87 | 150 | } |
ad7f2bfa | 151 | |
04366a57 | 152 | Int_t nclu=0; |
153 | for(Int_t iBin =0; iBin < maxBins;iBin++){ | |
154 | if(bins[iBin].IsUsed()) continue; | |
98a86dff | 155 | Int_t nBins = 0; |
04366a57 | 156 | Int_t idxBins[200]; |
157 | FindCluster(iBin,nzbins,bins,nBins,idxBins); | |
158 | if (nBins == 200){ | |
159 | Error("ClustersSPD","SPD Too big cluster !\n"); | |
160 | continue; | |
161 | } | |
162 | Int_t milab[10]; | |
163 | for(Int_t ilab=0;ilab<10;ilab++){ | |
164 | milab[ilab]=-2; | |
165 | } | |
166 | if(rawdata){ | |
167 | milab[3]=fNdet[iModule]; | |
168 | } | |
169 | Int_t ymin,ymax,zmin,zmax; | |
170 | if(rawdata){ | |
171 | ymin = (idxBins[0] / nzbins) - 1; | |
172 | ymax = ymin; | |
173 | zmin = (idxBins[0] % nzbins) - 1; | |
174 | zmax = zmin; | |
175 | } | |
176 | else{ | |
177 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[0]); | |
178 | ymin=dig->GetCoord2(); | |
179 | ymax=ymin; | |
180 | zmin=dig->GetCoord1(); | |
181 | zmax=zmin; | |
182 | } | |
190ba77d | 183 | //PH if(iModule == 24 || iModule == 25) printf("\n"); |
04366a57 | 184 | for (Int_t idx = 0; idx < nBins; idx++) { |
185 | Int_t iy; | |
186 | Int_t iz; | |
187 | if(rawdata){ | |
188 | iy = (idxBins[idx] / nzbins) - 1; | |
189 | iz = (idxBins[idx] % nzbins) - 1; | |
190 | } | |
191 | else{ | |
192 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]); | |
193 | iy = dig->GetCoord2(); | |
194 | iz = dig->GetCoord1(); | |
ad7f2bfa | 195 | //if(iModule == 24 || iModule == 25) printf(" || iy %d iz %d in Module %d \n",iy,iz,iModule); |
04366a57 | 196 | } |
197 | if (ymin > iy) ymin = iy; | |
198 | if (ymax < iy) ymax = iy; | |
199 | if (zmin > iz) zmin = iz; | |
200 | if (zmax < iz) zmax = iz; | |
201 | ||
202 | } | |
203 | if(!rawdata){ | |
204 | for(Int_t l=0;l<nBins;l++){ | |
205 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[l]); | |
206 | for(Int_t dlab=0;dlab<10;dlab++){ | |
207 | Int_t digitlab = (dig->GetTracks())[dlab]; | |
208 | if(digitlab<0) continue; | |
209 | AddLabel(milab,digitlab); | |
210 | } | |
211 | if (milab[9]>0) CheckLabels2(milab); | |
212 | } | |
213 | CheckLabels2(milab); | |
214 | } | |
215 | ||
216 | Int_t idy =0; //max 2 clusters | |
217 | if((iModule <= fLastSPD1) &&idy<3) idy=3; | |
218 | if((iModule > fLastSPD1) &&idy<4) idy=4; | |
219 | Int_t idz=3; | |
d6d232ba | 220 | |
221 | // Switch the unfolding OFF/ON | |
5c47990a | 222 | if(!repa->GetUseUnfoldingInClusterFinderSPD()) { |
d6d232ba | 223 | idy=ymax-ymin+1; |
224 | idz=zmax-zmin+1; | |
225 | } | |
98a86dff | 226 | |
04366a57 | 227 | for(Int_t iiz=zmin; iiz<=zmax;iiz+=idz){ |
228 | for(Int_t iiy=ymin;iiy<=ymax;iiy+=idy){ | |
229 | ||
230 | Int_t ndigits=0; | |
231 | Float_t y=0.,z=0.,q=0.; | |
232 | for(Int_t idx=0;idx<nBins;idx++){ | |
233 | Int_t iy; | |
234 | Int_t iz; | |
235 | if(rawdata){ | |
236 | iy = (idxBins[idx] / nzbins)-1; | |
237 | iz = (idxBins[idx] % nzbins)-1; | |
238 | } | |
239 | else{ | |
240 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]); | |
241 | iy = dig->GetCoord2(); | |
242 | iz = dig->GetCoord1(); | |
243 | } | |
244 | if(zmax-zmin>=idz || ymax-ymin>=idy){ | |
245 | if(TMath::Abs(iy-iiy)>0.75*idy) continue; | |
246 | if(TMath::Abs(iz-iiz)>0.75*idz) continue; | |
247 | } | |
248 | ndigits++; | |
5af4a2d0 | 249 | Float_t qBin=0.; |
04366a57 | 250 | if(rawdata) qBin = bins[idxBins[idx]].GetQ(); |
251 | if(!rawdata){ | |
252 | AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]); | |
253 | qBin = (Float_t)dig->GetSignal(); | |
254 | } | |
255 | y+= qBin * fYSPD[iy]; | |
256 | z+= qBin * fZSPD[iz]; | |
257 | q+= qBin; | |
258 | }// for idx | |
259 | if(ndigits==0) continue; | |
98a86dff | 260 | |
04366a57 | 261 | y /= q; |
262 | z /= q; | |
263 | y -= fHwSPD; | |
264 | z -= fHlSPD; | |
1f3e997f | 265 | |
66b89079 | 266 | // Lorentz drift effect in local y |
267 | y -= tanLorentzAngle*thick; | |
268 | // | |
269 | ||
40f5092a | 270 | Float_t hit[6]; //y,z,sigma(y)^2, sigma(z)^2, charge |
b4704be3 | 271 | { |
272 | Double_t loc[3]={y,0.,z},trk[3]={0.,0.,0.}; | |
273 | mT2L->MasterToLocal(loc,trk); | |
274 | hit[0]=trk[1]; | |
275 | hit[1]=trk[2]; | |
276 | } | |
04366a57 | 277 | hit[2] = fYpitchSPD*fYpitchSPD/12.; |
278 | hit[3] = fZ1pitchSPD*fZ1pitchSPD/12.; | |
00a7cc50 | 279 | hit[4] = 1.; |
40f5092a | 280 | hit[5] = 0.; |
b4704be3 | 281 | |
04366a57 | 282 | if(!rawdata) milab[3]=fNdet[iModule]; |
283 | Int_t info[3] = {ymax-ymin+1,zmax-zmin+1,fNlayer[iModule]}; | |
284 | if(!rawdata){ | |
75fb37cc | 285 | AliITSRecPoint cl(milab,hit,info); |
98a86dff | 286 | cl.SetType(nBins); |
00a7cc50 | 287 | fDetTypeRec->AddRecPoint(cl); |
04366a57 | 288 | } |
289 | else{ | |
290 | Int_t label[4]={milab[0],milab[1],milab[2],milab[3]}; | |
98a86dff | 291 | AliITSRecPoint cl(label, hit,info); |
292 | cl.SetType(nBins); | |
04366a57 | 293 | new (clusters->AddrAt(nclu)) |
98a86dff | 294 | AliITSRecPoint(cl); |
04366a57 | 295 | } |
296 | nclu++; | |
297 | }// for iiy | |
298 | }// for iiz | |
299 | }//end for iBin | |
300 | return nclu; | |
301 | ||
302 | } | |
ad7f2bfa | 303 | //__________________________________________________________________________ |
01ef1bd4 | 304 | void AliITSClusterFinderV2SPD::FindClustersSPD(AliITSRawStreamSPD* input) |
04366a57 | 305 | { |
306 | //------------------------------------------------------------ | |
ad7f2bfa | 307 | // SPD cluster finder for raw data (this method is called once per event) |
308 | // Now also fills fast-or fired map | |
04366a57 | 309 | //------------------------------------------------------------ |
01ef1bd4 | 310 | |
311 | AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance(); | |
04366a57 | 312 | Int_t nClustersSPD = 0; |
313 | Int_t kNzBins = fNzSPD + 2; | |
314 | Int_t kNyBins = fNySPD + 2; | |
315 | Int_t kMaxBin = kNzBins * kNyBins; | |
d7d9347b | 316 | AliBin *binsSPD = new AliBin[kMaxBin]; |
317 | AliBin *binsSPDInit = new AliBin[kMaxBin]; | |
04366a57 | 318 | AliBin* bins = NULL; |
319 | ||
320 | // read raw data input stream | |
321 | while (kTRUE) { | |
322 | Bool_t next = input->Next(); | |
323 | if (!next || input->IsNewModule()) { | |
324 | Int_t iModule = input->GetPrevModuleID(); | |
325 | ||
326 | // when all data from a module was read, search for clusters | |
327 | if (bins) { | |
01ef1bd4 | 328 | TClonesArray* clusters = rpc->UncheckedGetClusters(iModule); |
329 | Int_t nClusters = ClustersSPD(bins,0,clusters,kMaxBin,kNzBins,iModule,kTRUE); | |
04366a57 | 330 | nClustersSPD += nClusters; |
d7d9347b | 331 | bins = NULL; |
04366a57 | 332 | } |
333 | ||
334 | if (!next) break; | |
d7d9347b | 335 | bins = binsSPD; |
336 | memcpy(binsSPD,binsSPDInit,sizeof(AliBin)*kMaxBin); | |
04366a57 | 337 | } |
338 | ||
190ba77d | 339 | if (next && bins) { |
ad7f2bfa | 340 | // fill the current digit into the bins array |
341 | Int_t index = (input->GetCoord2()+1) * kNzBins + (input->GetCoord1()+1); | |
342 | bins[index].SetIndex(index); | |
343 | bins[index].SetQ(1); | |
344 | bins[index].SetMask(1); | |
ff44c37c | 345 | } |
346 | } | |
347 | ||
d7d9347b | 348 | delete [] binsSPDInit; |
349 | delete [] binsSPD; | |
350 | ||
3b1d8321 | 351 | AliDebug(1,Form("found clusters in ITS SPD: %d", nClustersSPD)); |
352 | ||
ad7f2bfa | 353 | |
354 | // Fill the FastOr fired map | |
355 | for (UInt_t eq=0; eq<20; eq++) { | |
356 | for (UInt_t hs=0; hs<6; hs++) { | |
357 | for (UInt_t chip=0; chip<10; chip++) { | |
358 | if (input->GetFastOrSignal(eq,hs,chip)) { | |
359 | fDetTypeRec->SetFastOrFiredMapOnline(eq,hs,chip); | |
360 | } | |
361 | } | |
362 | } | |
363 | } | |
364 | ||
04366a57 | 365 | } |
ad7f2bfa | 366 | //__________________________________________________________________________ |
04366a57 | 367 | void AliITSClusterFinderV2SPD::FindClustersSPD(TClonesArray *digits) { |
368 | //------------------------------------------------------------ | |
ad7f2bfa | 369 | // SPD cluster finder for digits (this method is called for each module) |
370 | // Now also fills the fast-or fired map | |
04366a57 | 371 | //------------------------------------------------------------ |
372 | ||
373 | ||
374 | Int_t kNzBins = fNzSPD + 2; | |
375 | const Int_t kMAXBIN=kNzBins*(fNySPD+2); | |
376 | ||
377 | Int_t ndigits=digits->GetEntriesFast(); | |
378 | AliBin *bins=new AliBin[kMAXBIN]; | |
379 | ||
ad7f2bfa | 380 | Int_t idig; |
381 | AliITSdigitSPD *digit=0; | |
382 | for (idig=0; idig<ndigits; idig++) { | |
383 | digit=(AliITSdigitSPD*)digits->UncheckedAt(idig); | |
384 | Int_t i=digit->GetCoord2()+1; //y | |
385 | Int_t j=digit->GetCoord1()+1; | |
386 | Int_t index=i*kNzBins+j; | |
387 | ||
388 | bins[index].SetIndex(idig); | |
389 | bins[index].SetQ(1); | |
390 | bins[index].SetMask(1); | |
04366a57 | 391 | } |
ad7f2bfa | 392 | |
04366a57 | 393 | |
d6d232ba | 394 | Int_t nClustersSPD = ClustersSPD(bins,digits,0,kMAXBIN,kNzBins,fModule,kFALSE); |
04366a57 | 395 | delete [] bins; |
d6d232ba | 396 | |
813020f4 | 397 | AliDebug(1,Form("found clusters in ITS SPD: %d", nClustersSPD)); |
ad7f2bfa | 398 | |
399 | // Fill the FastOr fired map | |
400 | AliITSFOSignalsSPD* foSignals = fDetTypeRec->GetFOSignals(); | |
401 | if (foSignals) { | |
402 | UInt_t eq = AliITSRawStreamSPD::GetOnlineEqIdFromOffline(fModule); | |
403 | UInt_t hs = AliITSRawStreamSPD::GetOnlineHSFromOffline(fModule); | |
404 | for(UInt_t ch=0; ch<5; ch++) { | |
405 | UInt_t chip = AliITSRawStreamSPD::GetOnlineChipFromOffline(fModule,ch*32); | |
406 | if (foSignals->GetSignal(eq,hs,chip)) { | |
407 | fDetTypeRec->SetFastOrFiredMapOnline(eq,hs,chip); | |
408 | } | |
409 | } | |
410 | } | |
411 | ||
04366a57 | 412 | } |