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