]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSClusterFinderV2SPD.cxx
Removal of the run-loaders from the algorithmic part of the vertexers code. Some...
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinderV2SPD.cxx
CommitLineData
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
8d37cc87 24#include "AliITSCalibrationSPD.h"
04366a57 25#include "AliITSClusterFinderV2SPD.h"
00a7cc50 26#include "AliITSRecPoint.h"
1f3e997f 27#include "AliITSgeomTGeo.h"
7d62fb64 28#include "AliITSDetTypeRec.h"
d6d232ba 29#include "AliITSReconstructor.h"
04366a57 30#include "AliRawReader.h"
31#include "AliITSRawStreamSPD.h"
04366a57 32#include <TClonesArray.h>
04366a57 33#include "AliITSdigitSPD.h"
34
35ClassImp(AliITSClusterFinderV2SPD)
36
e56160b8 37AliITSClusterFinderV2SPD::AliITSClusterFinderV2SPD(AliITSDetTypeRec* dettyp):AliITSClusterFinderV2(dettyp),
1f3e997f 38fLastSPD1(AliITSgeomTGeo::GetModuleIndex(2,1,1)-1),
e56160b8 39fNySPD(256),
40fNzSPD(160),
41fYpitchSPD(0.0050),
42fZ1pitchSPD(0.0425),
43fZ2pitchSPD(0.0625),
44fHwSPD(0.64),
45fHlSPD(3.48){
04366a57 46
47 //Default constructor
04366a57 48
04366a57 49 fYSPD[0]=0.5*fYpitchSPD;
50 for (Int_t m=1; m<fNySPD; m++) fYSPD[m]=fYSPD[m-1]+fYpitchSPD;
51 fZSPD[0]=fZ1pitchSPD;
52 for (Int_t m=1; m<fNzSPD; m++) {
53 Double_t dz=fZ1pitchSPD;
54 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
55 m==127 || m==128) dz=fZ2pitchSPD;
56 fZSPD[m]=fZSPD[m-1]+dz;
57 }
58 for (Int_t m=0; m<fNzSPD; m++) {
59 Double_t dz=0.5*fZ1pitchSPD;
60 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
61 m==127 || m==128) dz=0.5*fZ2pitchSPD;
62 fZSPD[m]-=dz;
63 }
64
65}
66
67
68void AliITSClusterFinderV2SPD::FindRawClusters(Int_t mod){
69
70 //Find clusters V2
71 SetModule(mod);
72 FindClustersSPD(fDigits);
73
74}
75
76void AliITSClusterFinderV2SPD::RawdataToClusters(AliRawReader* rawReader, TClonesArray** clusters){
77 //------------------------------------------------------------
78 // This function creates ITS clusters from raw data
79 //------------------------------------------------------------
80 rawReader->Reset();
81 AliITSRawStreamSPD inputSPD(rawReader);
82 FindClustersSPD(&inputSPD, clusters);
83
84}
85
86Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,TClonesArray* clusters,Int_t maxBins,Int_t nzbins,Int_t iModule,Bool_t rawdata){
87
88 //Cluster finder for SPD (from digits and from rawdata)
89
5c47990a 90 static AliITSRecoParam *repa = NULL;
91 if(!repa){
92 repa = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
93 if(!repa){
ed446fa3 94 repa = AliITSRecoParam::GetHighFluxParam();
5c47990a 95 AliWarning("Using default AliITSRecoParam class");
96 }
97 }
b4704be3 98 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(iModule);
8d37cc87 99
100 AliITSCalibrationSPD *cal =
101 (AliITSCalibrationSPD*) fDetTypeRec->GetCalibrationModel(iModule);
102 // Loop on bad pixels and reset them
103 for(Int_t ipix = 0; ipix<cal->GetNrBad(); ipix++){
104 Int_t row, col;
105 cal->GetBadPixel(ipix,row,col);
106 Int_t index = (row+1) * nzbins + (col+1);
107 bins[index].SetQ(0);
108 bins[index].SetMask(0xFFFFFFFE);
109 }
04366a57 110 Int_t nclu=0;
111 for(Int_t iBin =0; iBin < maxBins;iBin++){
112 if(bins[iBin].IsUsed()) continue;
113 Int_t nBins = 0;
114 Int_t idxBins[200];
115 FindCluster(iBin,nzbins,bins,nBins,idxBins);
116 if (nBins == 200){
117 Error("ClustersSPD","SPD Too big cluster !\n");
118 continue;
119 }
120 Int_t milab[10];
121 for(Int_t ilab=0;ilab<10;ilab++){
122 milab[ilab]=-2;
123 }
124 if(rawdata){
125 milab[3]=fNdet[iModule];
126 }
127 Int_t ymin,ymax,zmin,zmax;
128 if(rawdata){
129 ymin = (idxBins[0] / nzbins) - 1;
130 ymax = ymin;
131 zmin = (idxBins[0] % nzbins) - 1;
132 zmax = zmin;
133 }
134 else{
135 AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[0]);
136 ymin=dig->GetCoord2();
137 ymax=ymin;
138 zmin=dig->GetCoord1();
139 zmax=zmin;
140 }
141 for (Int_t idx = 0; idx < nBins; idx++) {
142 Int_t iy;
143 Int_t iz;
144 if(rawdata){
145 iy = (idxBins[idx] / nzbins) - 1;
146 iz = (idxBins[idx] % nzbins) - 1;
147 }
148 else{
149 AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]);
150 iy = dig->GetCoord2();
151 iz = dig->GetCoord1();
152 }
153 if (ymin > iy) ymin = iy;
154 if (ymax < iy) ymax = iy;
155 if (zmin > iz) zmin = iz;
156 if (zmax < iz) zmax = iz;
157
158 }
159 if(!rawdata){
160 for(Int_t l=0;l<nBins;l++){
161 AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[l]);
162 for(Int_t dlab=0;dlab<10;dlab++){
163 Int_t digitlab = (dig->GetTracks())[dlab];
164 if(digitlab<0) continue;
165 AddLabel(milab,digitlab);
166 }
167 if (milab[9]>0) CheckLabels2(milab);
168 }
169 CheckLabels2(milab);
170 }
171
172 Int_t idy =0; //max 2 clusters
173 if((iModule <= fLastSPD1) &&idy<3) idy=3;
174 if((iModule > fLastSPD1) &&idy<4) idy=4;
175 Int_t idz=3;
d6d232ba 176
177 // Switch the unfolding OFF/ON
5c47990a 178 if(!repa->GetUseUnfoldingInClusterFinderSPD()) {
d6d232ba 179 idy=ymax-ymin+1;
180 idz=zmax-zmin+1;
181 }
182
04366a57 183 for(Int_t iiz=zmin; iiz<=zmax;iiz+=idz){
184 for(Int_t iiy=ymin;iiy<=ymax;iiy+=idy){
185
186 Int_t ndigits=0;
187 Float_t y=0.,z=0.,q=0.;
188 for(Int_t idx=0;idx<nBins;idx++){
189 Int_t iy;
190 Int_t iz;
191 if(rawdata){
192 iy = (idxBins[idx] / nzbins)-1;
193 iz = (idxBins[idx] % nzbins)-1;
194 }
195 else{
196 AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]);
197 iy = dig->GetCoord2();
198 iz = dig->GetCoord1();
199 }
200 if(zmax-zmin>=idz || ymax-ymin>=idy){
201 if(TMath::Abs(iy-iiy)>0.75*idy) continue;
202 if(TMath::Abs(iz-iiz)>0.75*idz) continue;
203 }
204 ndigits++;
205 Float_t qBin;
206 if(rawdata) qBin = bins[idxBins[idx]].GetQ();
207 if(!rawdata){
208 AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]);
209 qBin = (Float_t)dig->GetSignal();
210 }
211 y+= qBin * fYSPD[iy];
212 z+= qBin * fZSPD[iz];
213 q+= qBin;
214 }// for idx
215 if(ndigits==0) continue;
216 y /= q;
217 z /= q;
218 y -= fHwSPD;
219 z -= fHlSPD;
1f3e997f 220
b4704be3 221 Float_t hit[5]; //y,z,sigma(y)^2, sigma(z)^2, charge
222 {
223 Double_t loc[3]={y,0.,z},trk[3]={0.,0.,0.};
224 mT2L->MasterToLocal(loc,trk);
225 hit[0]=trk[1];
226 hit[1]=trk[2];
227 }
04366a57 228 hit[2] = fYpitchSPD*fYpitchSPD/12.;
229 hit[3] = fZ1pitchSPD*fZ1pitchSPD/12.;
00a7cc50 230 hit[4] = 1.;
b4704be3 231
04366a57 232 if(!rawdata) milab[3]=fNdet[iModule];
233 Int_t info[3] = {ymax-ymin+1,zmax-zmin+1,fNlayer[iModule]};
234 if(!rawdata){
75fb37cc 235 AliITSRecPoint cl(milab,hit,info);
00a7cc50 236 fDetTypeRec->AddRecPoint(cl);
04366a57 237 }
238 else{
239 Int_t label[4]={milab[0],milab[1],milab[2],milab[3]};
240 new (clusters->AddrAt(nclu))
75fb37cc 241 AliITSRecPoint(label, hit,info);
04366a57 242 }
243 nclu++;
244 }// for iiy
245 }// for iiz
246 }//end for iBin
247 return nclu;
248
249}
250
251
252
253
254void AliITSClusterFinderV2SPD::FindClustersSPD(AliITSRawStream* input,
255 TClonesArray** clusters)
256{
257 //------------------------------------------------------------
258 // Actual SPD cluster finder for raw data
259 //------------------------------------------------------------
260 Int_t nClustersSPD = 0;
261 Int_t kNzBins = fNzSPD + 2;
262 Int_t kNyBins = fNySPD + 2;
263 Int_t kMaxBin = kNzBins * kNyBins;
d7d9347b 264 AliBin *binsSPD = new AliBin[kMaxBin];
265 AliBin *binsSPDInit = new AliBin[kMaxBin];
04366a57 266 AliBin* bins = NULL;
267
268 // read raw data input stream
269 while (kTRUE) {
270 Bool_t next = input->Next();
271 if (!next || input->IsNewModule()) {
272 Int_t iModule = input->GetPrevModuleID();
273
274 // when all data from a module was read, search for clusters
275 if (bins) {
00a7cc50 276 clusters[iModule] = new TClonesArray("AliITSRecPoint");
04366a57 277 Int_t nClusters = ClustersSPD(bins,0,clusters[iModule],kMaxBin,kNzBins,iModule,kTRUE);
278 nClustersSPD += nClusters;
d7d9347b 279 bins = NULL;
04366a57 280 }
281
282 if (!next) break;
d7d9347b 283 bins = binsSPD;
284 memcpy(binsSPD,binsSPDInit,sizeof(AliBin)*kMaxBin);
04366a57 285 }
286
287 // fill the current digit into the bins array
288 Int_t index = (input->GetCoord2()+1) * kNzBins + (input->GetCoord1()+1);
289 bins[index].SetIndex(index);
290 bins[index].SetMask(1);
291 bins[index].SetQ(1);
292 }
293
d7d9347b 294 delete [] binsSPDInit;
295 delete [] binsSPD;
296
5c47990a 297 AliDebug(1,Form("found clusters in ITS SPD: %d", nClustersSPD));
04366a57 298}
299
300
301
302void AliITSClusterFinderV2SPD::FindClustersSPD(TClonesArray *digits) {
303 //------------------------------------------------------------
304 // Actual SPD cluster finder
305 //------------------------------------------------------------
306
307
308 Int_t kNzBins = fNzSPD + 2;
309 const Int_t kMAXBIN=kNzBins*(fNySPD+2);
310
311 Int_t ndigits=digits->GetEntriesFast();
312 AliBin *bins=new AliBin[kMAXBIN];
313
314 Int_t k;
315 AliITSdigitSPD *d=0;
316 for (k=0; k<ndigits; k++) {
317 d=(AliITSdigitSPD*)digits->UncheckedAt(k);
318 Int_t i=d->GetCoord2()+1; //y
319 Int_t j=d->GetCoord1()+1;
320 Int_t index=i*kNzBins+j;
321 bins[index].SetIndex(k);
322 bins[index].SetMask(1);
323 }
324
d6d232ba 325 Int_t nClustersSPD = ClustersSPD(bins,digits,0,kMAXBIN,kNzBins,fModule,kFALSE);
04366a57 326 delete [] bins;
d6d232ba 327
5c47990a 328 AliDebug(1,Form("found clusters in ITS SPD: %d", nClustersSPD));
04366a57 329}
330
331