setting of the class name of the entry's object included in all constructors
[u/mrichter/AliRoot.git] / HLT / ITS / clusterfinders / AliHLTITSClusterFinderSPD.cxx
CommitLineData
3f61e9ce 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 //
19// Unfolding switch from AliITSRecoParam: D. Elia, INFN Bari //
20// //
21////////////////////////////////////////////////////////////////////////////
22
23
24#include "AliITSCalibrationSPD.h"
25#include "AliHLTITSClusterFinderSPD.h"
26#include "AliITSRecPoint.h"
27#include "AliITSgeomTGeo.h"
28#include "AliITSDetTypeRec.h"
29#include "AliITSReconstructor.h"
30#include "AliRawReader.h"
31#include "AliITSRawStreamSPD.h"
32#include <TClonesArray.h>
33#include "AliITSdigitSPD.h"
34#include "AliITSFOSignalsSPD.h"
35
36ClassImp(AliHLTITSClusterFinderSPD)
37
38//__________________________________________________________________________
39AliHLTITSClusterFinderSPD::AliHLTITSClusterFinderSPD(AliITSDetTypeRec* dettyp)
40 :
41 fRecoParam(0),
42 fDetTypeRec( dettyp ),
43 fNModules(AliITSgeomTGeo::GetNModules()),
44 fLastSPD1(AliITSgeomTGeo::GetModuleIndex(2,1,1)-1),
45 fNySPD(256),
46 fNzSPD(160),
47 fNzBins( fNzSPD + 2 ),
48 fNyBins( fNySPD + 2),
49 fMaxBin( fNzBins * fNyBins ),
50 fYpitchSPD(0.0050),
51 fZ1pitchSPD(0.0425),
52 fZ2pitchSPD(0.0625),
53 fHwSPD(0.64),
54 fHlSPD(3.48),
55 fNSignals(0),
56 fSignal2Bin(0),
57 fBin2Signal(0)
58{
59
60 //Default constructor
61
62 fRecoParam = (AliITSRecoParam*) AliITSReconstructor::GetRecoParam();
63 if(!fRecoParam){
64 fRecoParam = AliITSRecoParam::GetHighFluxParam();
65 AliWarning("Using default AliITSRecoParam class");
66 }
67
68 //
69 // Initialisation of ITS geometry
70 //
71 Int_t mmax=AliITSgeomTGeo::GetNModules();
72 for (Int_t m=0; m<mmax; m++) {
73 Int_t lay,lad,det; AliITSgeomTGeo::GetModuleId(m,lay,lad,det);
74 fNdet[m] = (lad-1)*AliITSgeomTGeo::GetNDetectors(lay) + (det-1);
75 fNlayer[m] = lay-1;
76 }
77
78 fYSPD[0]=0.5*fYpitchSPD;
79 for (Int_t m=1; m<fNySPD; m++) fYSPD[m]=fYSPD[m-1]+fYpitchSPD;
80 fZSPD[0]=fZ1pitchSPD;
81 for (Int_t m=1; m<fNzSPD; m++) {
82 Double_t dz=fZ1pitchSPD;
83 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
84 m==127 || m==128) dz=fZ2pitchSPD;
85 fZSPD[m]=fZSPD[m-1]+dz;
86 }
87 for (Int_t m=0; m<fNzSPD; m++) {
88 Double_t dz=0.5*fZ1pitchSPD;
89 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
90 m==127 || m==128) dz=0.5*fZ2pitchSPD;
91 fZSPD[m]-=dz;
92 }
93
94 fSignal2Bin = new UShort_t[fMaxBin];
95 fBin2Signal = new UShort_t [fMaxBin];
96 for( int i=0; i<fMaxBin; i++ ) fBin2Signal[i] = 0;
97
98}
99
100
101void AliHLTITSClusterFinderSPD::RawdataToClusters(AliRawReader* rawReader, std::vector<AliITSRecPoint> & clusters){
102 //------------------------------------------------------------
103 // This function creates ITS clusters from raw data
104 //------------------------------------------------------------
105 rawReader->Reset();
106 AliITSRawStreamSPD inputSPD(rawReader);
107 FindClustersSPD(&inputSPD, clusters);
108}
109
110//__________________________________________________________________________
111void AliHLTITSClusterFinderSPD::FindClustersSPD(AliITSRawStreamSPD* input,
112 std::vector<AliITSRecPoint> & clusters)
113{
114 //------------------------------------------------------------
115 // SPD cluster finder for raw data (this method is called once per event)
116 //------------------------------------------------------------
117
118 fNSignals = 0;
119
120 // read raw data input stream
121 while (kTRUE) {
122 Bool_t next = input->Next();
123 if (!next || input->IsNewModule()) {
124 Int_t iModule = input->GetPrevModuleID();
125 // when all data from a module was read, search for clusters
126 if ( fNSignals > 0) {
127 ClustersSPD( clusters, iModule );
128 for( int i=0; i<fNSignals; i++ ){
129 fBin2Signal[fSignal2Bin[i]] = 0;
130 }
131 fNSignals = 0;
132 }
133 if (!next) break;
134 }
135 // fill the current digit into the bins array
136 UShort_t index = (UShort_t ) ( (input->GetCoord2()+1) * fNzBins + (input->GetCoord1()+1) );
137 fSignal2Bin[fNSignals] = index;
138 fBin2Signal[index] = fNSignals+1;
139 fNSignals++;
140 }
141 //cout<<clusters.size()<<endl;
142}
143
144void AliHLTITSClusterFinderSPD::FindCluster(Int_t k,Int_t &n,Int_t *idx) {
145 //------------------------------------------------------------
146 // returns an array of indices of digits belonging to the cluster
147 // (needed when the segmentation is not regular)
148 //------------------------------------------------------------
149 if (n<200) idx[n++]=fBin2Signal[k];
150 fBin2Signal[k]=0;
151
152 if (fBin2Signal[k-fNzBins] ) FindCluster(k-fNzBins,n,idx);
153 if (fBin2Signal[k-1 ] ) FindCluster(k-1 ,n,idx);
154 if (fBin2Signal[k+fNzBins] ) FindCluster(k+fNzBins,n,idx);
155 if (fBin2Signal[k+1 ] ) FindCluster(k+1 ,n,idx);
156}
157
158
159//__________________________________________________________________________
160Int_t AliHLTITSClusterFinderSPD::ClustersSPD( std::vector<AliITSRecPoint> & clusters, Int_t iModule ){
161
162 //Cluster finder for SPD (from digits and from rawdata)
163
164 const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(iModule);
165
166 if (fRecoParam->GetSPDRemoveNoisyFlag()) {
167 // Loop on noisy pixels and reset them
168 AliITSCalibrationSPD *cal =
169 (AliITSCalibrationSPD*) fDetTypeRec->GetCalibrationModel(iModule);
170 for(Int_t ipix = 0; ipix<cal->GetNrBad(); ipix++){
171 Int_t row, col;
172 cal->GetBadPixel(ipix,row,col);
173 Int_t index = (row+1) * fNzBins + (col+1);
174 fBin2Signal[index] = 0;
175 }
176 }
177
178 if (fRecoParam->GetSPDRemoveDeadFlag()) {
179 // Loop on dead pixels and reset them
180 AliITSCalibrationSPD *cal =
181 (AliITSCalibrationSPD*) fDetTypeRec->GetSPDDeadModel(iModule);
182 if (cal->IsBad()) return 0; // if all ladder is dead, return to save time
183 for(Int_t ipix = 0; ipix<cal->GetNrBad(); ipix++){
184 Int_t row, col;
185 cal->GetBadPixel(ipix,row,col);
186 Int_t index = (row+1) * fNzBins + (col+1);
187 fBin2Signal[index] = 0;
188 }
189 }
190
191 Int_t nclu=0;
192
193 for(Int_t is =0; is<fNSignals; is++ ){
194 int iBin = fSignal2Bin[is];
195 if(fBin2Signal[iBin]==0) continue;
196 Int_t nBins = 0;
197 Int_t idxBins[200];
198 Int_t idxSignals[200];
199 FindCluster(iBin,nBins,idxSignals );
200 if (nBins >= 199 ){
201 //Error("ClustersSPD","SPD Too big cluster !\n");
202 continue;
203 }
204 for( int i=0; i<nBins; i++ ) idxBins[i] = fSignal2Bin[idxSignals[i]-1];
205
206 Int_t ymin,ymax,zmin,zmax;
207 ymin = (idxBins[0] / fNzBins) - 1;
208 ymax = ymin;
209 zmin = (idxBins[0] % fNzBins) - 1;
210 zmax = zmin;
211
212 for (Int_t idx = 0; idx < nBins; idx++) {
213 Int_t iy;
214 Int_t iz;
215 iy = (idxBins[idx] / fNzBins) - 1;
216 iz = (idxBins[idx] % fNzBins) - 1;
217 if (ymin > iy) ymin = iy;
218 if (ymax < iy) ymax = iy;
219 if (zmin > iz) zmin = iz;
220 if (zmax < iz) zmax = iz;
221 }
222
223 Int_t idy =0; //max 2 clusters
224 if((iModule <= fLastSPD1) &&idy<3) idy=3;
225 if((iModule > fLastSPD1) &&idy<4) idy=4;
226 Int_t idz=3;
227
228 // Switch the unfolding OFF/ON
229 if(!fRecoParam->GetUseUnfoldingInClusterFinderSPD()) {
230 idy=ymax-ymin+1;
231 idz=zmax-zmin+1;
232 }
233
234 for(Int_t iiz=zmin; iiz<=zmax;iiz+=idz){
235 for(Int_t iiy=ymin;iiy<=ymax;iiy+=idy){
236 Int_t ndigits=0;
237 Float_t y=0.,z=0.,q=0.;
238 for(Int_t idx=0;idx<nBins;idx++){
239 Int_t iy;
240 Int_t iz;
241 iy = (idxBins[idx] / fNzBins)-1;
242 iz = (idxBins[idx] % fNzBins)-1;
243 if(zmax-zmin>=idz || ymax-ymin>=idy){
244 if(TMath::Abs(iy-iiy)>0.75*idy) continue;
245 if(TMath::Abs(iz-iiz)>0.75*idz) continue;
246 }
247 ndigits++;
248 Float_t qBin=0.;
249 qBin = 1;
250 y+= qBin * fYSPD[iy];
251 z+= qBin * fZSPD[iz];
252 q+= qBin;
253 }// for idx
254 if(ndigits==0) continue;
255
256 y /= q;
257 z /= q;
258 y -= fHwSPD;
259 z -= fHlSPD;
260
261 Float_t hit[5]; //y,z,sigma(y)^2, sigma(z)^2, charge
262 {
263 Double_t loc[3]={y,0.,z},trk[3]={0.,0.,0.};
264 mT2L->MasterToLocal(loc,trk);
265 hit[0]=trk[1];
266 hit[1]=trk[2];
267 }
268 hit[2] = fYpitchSPD*fYpitchSPD/12.;
269 hit[3] = fZ1pitchSPD*fZ1pitchSPD/12.;
270 hit[4] = 1.;
271
272 Int_t info[3] = {ymax-ymin+1,zmax-zmin+1,fNlayer[iModule]};
273 Int_t label[4]={-2,-2,-2, fNdet[iModule] };
274 AliITSRecPoint cl(label, hit,info);
275 cl.SetType(nBins);
276 clusters.push_back(cl);
277 nclu++;
278 }// for iiy
279 }// for iiz
280 }//end for iBin
281 return nclu;
282}