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