]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSClusterFinderSPDdubna.cxx
Added macro for visualization of the TOF ROOT geometry
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinderSPDdubna.cxx
CommitLineData
409f8c84 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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/*
17$Log$
579fdb1c 18Revision 1.3 2002/08/21 22:04:27 nilsen
19Added data member to SPD cluters and made related modifications to the
20SPD Cluster finders. Generaly cleanded up some of the code.
21
9e1e0cd7 22Revision 1.2 2001/06/14 14:33:53 barbera
23New version from B. Batyunya to get the Dubna model work with the present HEAD
24
409f8c84 25Revision 1.15 2001/05/01 22:37:44 nilsen
26Added a dummy argument to FindRawClusters. Argument used for SSD version.
27
28Revision 1.14 2001/03/05 14:48:46 nilsen
29Fixed a reoccuring bug. Array sizes must be declare const.
30
31*/
32
33#include <iostream.h>
34#include "AliITSClusterFinderSPDdubna.h"
35#include "AliITSMapA1.h"
36#include "AliITS.h"
37#include "AliITSdigit.h"
38#include "AliITSRawCluster.h"
39#include "AliITSRecPoint.h"
40#include "AliITSsegmentation.h"
41#include "AliITSresponse.h"
42#include "AliRun.h"
43
9e1e0cd7 44//#define DEBUG
409f8c84 45
46ClassImp(AliITSClusterFinderSPDdubna)
47
9e1e0cd7 48//----------------------------------------------------------------------
49AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(
50 AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp){
51 // constructor
52
53 fSegmentation = seg;
54 fDigits = digits;
55 fClusters = recp;
56 fNclusters = 0;
57 fMap = new AliITSMapA1(fSegmentation,fDigits);
409f8c84 58 SetDx();
59 SetDz();
60 SetNCells();
61}
9e1e0cd7 62//_______________________________________________________________________
63AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(){
64 // constructor
65
66 fSegmentation = 0;
67 fDigits = 0;
68 fClusters = 0;
69 fNclusters = 0;
70 fMap = 0;
71 SetDx();
72 SetDz();
73 SetNCells();
409f8c84 74}
9e1e0cd7 75//______________________________________________________________________
579fdb1c 76AliITSClusterFinderSPDdubna &AliITSClusterFinderSPDdubna::operator=(const
77 AliITSClusterFinderSPDdubna &s){
78 // The = operator for the class AliITSClusterFinderSPDdugna
79 // Inputs:
80 // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna
81 // class to be copy constructed.
82 // Outputs:
83 // none.
84 // Returned:
85 // this, a copy of the class s.
86
87 this->fNclusters = s.fNclusters;
88 this->fDz = s.fDz;
89 this->fDx = s.fDx;
90 this->fMinNCells = s.fMinNCells;
91 this->fClusters = new TClonesArray(*(s.fClusters));
92 return *this;
93}
94//______________________________________________________________________
95AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(const
96 AliITSClusterFinderSPDdubna &s){
97 // The Copy constructortor the class AliITSClusterFinderSPDdugna
98 // It calles the = operator.
99 // Inputs:
100 // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna
101 // class to be copy constructed.
102 // Outputs:
103 // none.
104 // Returned:
105 // none.
106
107 *this = s;
108 return;
109}
110//______________________________________________________________________
9e1e0cd7 111AliITSClusterFinderSPDdubna::~AliITSClusterFinderSPDdubna(){
112 // destructor
409f8c84 113
9e1e0cd7 114 if (fMap) delete fMap;
409f8c84 115}
9e1e0cd7 116//______________________________________________________________________
117void AliITSClusterFinderSPDdubna::Find1DClusters(Int_t mod){
118 // Find one dimensional clusters, i.e.
119 // in r*phi(x) direction for each colunm in z direction
338e4f06 120
9e1e0cd7 121 static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
409f8c84 122
9e1e0cd7 123 // retrieve the parameters
124 Int_t fNofPixels = fSegmentation->Npz();
125 Int_t fMaxNofSamples = fSegmentation->Npx();
126
127 // read in digits -> do not apply threshold
128 // signal in fired pixels is always 1
129 fMap->FillMap();
130
131 Int_t nofFoundClusters = 0;
132
133 Int_t k,it,m;
134 for(k=0;k<fNofPixels;k++) {
135 Int_t mmax = 10; // a size of the window for the cluster finding
136 for(it=0;it<fMaxNofSamples;it++) {
137 Int_t lclx = 0;
138 Int_t xstart = 0;
139 Int_t xstop = 0;
140 Int_t id = 0;
141 Int_t ilcl = 0;
142 for(m=0;m<mmax;m++) { // find the cluster inside the window
143 id = it+m;
144 if(id >= fMaxNofSamples) break; // ! no possible for the fadc
145 if(fMap->TestHit(k,id) == kUnused) { // start of the cluster
146 lclx += 1;
147 if(lclx == 1) xstart = id;
148 } // end if fMap
149 if(lclx > 0 && fMap->TestHit(k,id) == kEmpty) {
150 // end of cluster if a gap exists
151 xstop = id-1;
152 ilcl = 1;
153 break;
154 } // end if lclx >0 ...
155 } // end of m-loop
156 if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window,
157 // continue the "it" loop
158 if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished
159 if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) {
160 // cluster end is outside of the window,
161 mmax += 5; // increase mmax and repeat the cluster finding
162 it -= 1;
163 } // end if id<
164 if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but
165 xstop = fMaxNofSamples - 1; // the end cluster exists
166 ilcl = 1;
167 } // end if id>=
168 // --- Calculate z and x coordinates for one dimensional clusters
169 if(ilcl == 1) { // new cluster exists
170 it = id;
171 mmax = 10;
172 nofFoundClusters++;
173 Float_t clusterCharge = 0.;
174 Float_t zpitch = fSegmentation->Dpz(k+1);
175 Int_t dummy = 0;
176 Float_t clusterZ, dummyX;
177 fSegmentation->GetPadCxz(dummy,k,dummyX,clusterZ);
178 Float_t zstart = clusterZ - 0.5*zpitch;
179 Float_t zstop = clusterZ + 0.5*zpitch;
180 Float_t clusterX = 0.;
181 Int_t clusterSizeX = lclx;
182 Int_t clusterSizeZ = 1;
183 Int_t its;
184 for(its=xstart; its<=xstop; its++) {
185 Int_t firedpixel=0;
186 if (fMap->GetHitIndex(k,its)>=0) firedpixel=1;
187 clusterCharge += firedpixel;
188 clusterX += its + 0.5;
189 } // end for its
190 Float_t fRphiPitch = fSegmentation->Dpx(dummy);
191 clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x
192 // Write the points (coordinates and some cluster information)
193 // to the AliITSRawClusterSPD object
194
195 AliITSRawClusterSPD clust(clusterZ,clusterX,clusterCharge,
196 clusterSizeZ,clusterSizeX,
197 xstart,xstop,zstart,zstop,k,mod);
198 iTS->AddCluster(0,&clust);
199 } // new cluster (ilcl=1)
200 } // X direction loop (it)
201 } // Z direction loop (k)
202 //fMap->ClearMap();
203 return;
409f8c84 204}
9e1e0cd7 205//______________________________________________________________________
206void AliITSClusterFinderSPDdubna::GroupClusters(){
207 // Find two dimensional clusters, i.e. group one dimensional clusters
208 // into two dimensional ones (go both in x and z directions).
209 // get number of clusters for this module
210
211 Int_t nofClusters = fClusters->GetEntriesFast();
212 nofClusters -= fNclusters;
213 AliITSRawClusterSPD *clusterI;
214 AliITSRawClusterSPD *clusterJ;
215 Int_t *label=new Int_t[nofClusters];
216 Int_t i,j;
217 for(i=0; i<nofClusters; i++) label[i] = 0;
218 for(i=0; i<nofClusters; i++) {
219 if(label[i] != 0) continue;
220 for(j=i+1; j<nofClusters; j++) {
221 if(label[j] != 0) continue;
222 clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
223 clusterJ = (AliITSRawClusterSPD*) fClusters->At(j);
224 Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx);
225 if(pair) {
226#ifndef DEBUG
227 cout << "clusters " << i << "," << j << " before grouping" << endl;
228 clusterI->PrintInfo();
229 clusterJ->PrintInfo();
230#endif
231 clusterI->Add(clusterJ);
232#ifndef DEBUG
233 cout << "remove cluster " << j << endl;
234#endif
235 label[j] = 1;
236 fClusters->RemoveAt(j);
237#ifndef DEBUG
238 cout << "cluster " << i << " after grouping" << endl;
239 clusterI->PrintInfo();
240#endif
241 } // pair
242 } // J clusters
243 label[i] = 1;
244 } // I clusters
245 fClusters->Compress();
246#ifndef DEBUG
409f8c84 247 Int_t totalNofClusters = fClusters->GetEntriesFast();
248 cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl;
9e1e0cd7 249#endif
250 delete [] label;
251 return;
409f8c84 252}
9e1e0cd7 253//______________________________________________________________________
254void AliITSClusterFinderSPDdubna::TracksInCluster(){
255 // Find tracks creating one cluster
256 // get number of clusters for this module
257 Int_t nofClusters = fClusters->GetEntriesFast();
258 Int_t i, ix, iz, jx, jz, xstart, xstop, zstart, zstop, nclx, nclz;
259 const Int_t trmax = 100;
260 Int_t cltracks[trmax], itr, tracki, ii, is, js, ie, ntr, tr0, tr1, tr2;
261
262 nofClusters -= fNclusters;
263 for(i=0; i<nofClusters; i++) {
264 ii = 0;
265 memset(cltracks,-1,sizeof(int)*trmax);
266 tr0=tr1=tr2=-1;
267 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
268 nclx = clusterI->NclX();
269 nclz = clusterI->NclZ();
270 xstart = clusterI->XStartf();
271 xstop = clusterI->XStopf();
272 zstart = clusterI->Zend()-nclz+1;
273 zstop = clusterI->Zend();
274 Int_t ind;
275 for(iz=0; iz<nclz; iz++) {
276 jz = zstart + iz;
277 for(ix=0; ix<nclx; ix++) {
278 jx = xstart + ix;
279 ind = fMap->GetHitIndex(jz,jx);
280 if(ind < 0) continue;
281 if(ind == 0 && iz >= 0 && ix > 0) continue;
282 if(ind == 0 && iz > 0 && ix >= 0) continue;
283 if(ind == 0 && iz == 0 && ix == 0 && i > 0) continue;
284 AliITSdigitSPD *dig = (AliITSdigitSPD*)fMap->GetHit(jz,jx);
285 for(itr=0; itr<3; itr++) {
286 tracki = dig->fTracks[itr];
287 if(tracki >= 0) {
288 ii += 1;
289 if(ii < 99) cltracks[ii-1] = tracki;
290 } // end if tracki >-0
291 } // end for itr
292 } // ix pixel
293 } // iz pixel
294 for(is=0; is<trmax; is++) {
295 if(cltracks[is]<0) continue;
296 for(js=is+1; js<trmax; js++) {
297 if(cltracks[js]<0) continue;
298 if(cltracks[js]==cltracks[is]) cltracks[js]=-5;
299 } // end for js
300 } // end for is
301 ntr = 0;
302 for(ie=0; ie<trmax; ie++) {
303 if(cltracks[ie] >= 0) {
304 ntr=ntr+1;
305 if(ntr==1) tr0=cltracks[ie];
306 if(ntr==2) tr1=cltracks[ie];
307 if(ntr==3) tr2=cltracks[ie];
308 } // end if cltracks[ie] >-=
309 } // end for ie
310 // if delta ray only
311 if(ntr == 0) ntr = 1;
312 clusterI->SetNTracks(ntr);
313 clusterI->SetTracks(tr0,tr1,tr2);
314 } // I cluster
409f8c84 315}
9e1e0cd7 316//______________________________________________________________________
317void AliITSClusterFinderSPDdubna::GetRecPoints(){
318 // get rec points
319 static AliITS *iTS = (AliITS*)gAlice->GetModule("ITS");
320 // get number of clusters for this module
321 Int_t nofClusters = fClusters->GetEntriesFast();
322 const Float_t kconv = 1.0e-4;
323 const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3
324 const Float_t kRMSz = 70.0*kconv; // microns -> cm ITS TDR Table 1.3
325 Float_t spdLength = fSegmentation->Dz();
326 Float_t spdWidth = fSegmentation->Dx();
327 Int_t dummy = 0;
328 Float_t xpitch = fSegmentation->Dpx(dummy);
329 Int_t i;
330 Int_t track0, track1, track2;
331
332 nofClusters -= fNclusters;
333 for(i=0; i<nofClusters; i++) {
334 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
335 Int_t clustersizex = clusterI->NclX();
336 Int_t clustersizez = clusterI->NclZ();
337 Int_t xstart = clusterI->XStartf();
338 Float_t clusterx = 0;
339 Float_t clusterz = clusterI->Z();
340 for(Int_t ii=0; ii<clustersizex; ii++) clusterx += (xstart+0.5+ii)*xpitch;
341 clusterx /= clustersizex;
342 clusterz /= clustersizez;
343 clusterI->GetTracks(track0, track1, track2);
344 AliITSRecPoint rnew;
345 rnew.SetX((clusterx - spdWidth/2)*kconv);
346 rnew.SetZ((clusterz - spdLength/2)*kconv);
347 rnew.SetQ(1.);
348 rnew.SetdEdX(0.);
349 rnew.SetSigmaX2(kRMSx*kRMSx);
350 rnew.SetSigmaZ2(kRMSz*kRMSz);
351 rnew.fTracks[0]=track0;
352 rnew.fTracks[1]=track1;
353 rnew.fTracks[2]=track2;
354 iTS->AddRecPoint(rnew);
355 } // I clusters
356 fMap->ClearMap();
409f8c84 357}
9e1e0cd7 358//______________________________________________________________________
359void AliITSClusterFinderSPDdubna::FindRawClusters(Int_t mod){
360 // find raw clusters
361
362#ifndef DEBUG
363 cout<<"SPDdubna: module ="<<mod<<endl;
364#endif
365 Find1DClusters(mod);
366 GroupClusters();
367 TracksInCluster();
368 GetRecPoints();
409f8c84 369}