1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.5 2002/10/14 14:57:00 hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
21 Revision 1.2.8.1 2002/08/28 15:06:50 alibrary
24 Revision 1.4 2002/08/22 13:18:46 nilsen
25 Added = operator and copy constructor in an attempt to fix complilation
26 problems found by Yves Schutz.
28 Revision 1.3 2002/08/21 22:04:27 nilsen
29 Added data member to SPD cluters and made related modifications to the
30 SPD Cluster finders. Generaly cleanded up some of the code.
32 Revision 1.2 2001/06/14 14:33:53 barbera
33 New version from B. Batyunya to get the Dubna model work with the present HEAD
35 Revision 1.15 2001/05/01 22:37:44 nilsen
36 Added a dummy argument to FindRawClusters. Argument used for SSD version.
38 Revision 1.14 2001/03/05 14:48:46 nilsen
39 Fixed a reoccuring bug. Array sizes must be declare const.
43 #include <Riostream.h>
44 #include "AliITSClusterFinderSPDdubna.h"
45 #include "AliITSMapA1.h"
47 #include "AliITSdigit.h"
48 #include "AliITSRawCluster.h"
49 #include "AliITSRecPoint.h"
50 #include "AliITSsegmentation.h"
51 #include "AliITSresponse.h"
56 ClassImp(AliITSClusterFinderSPDdubna)
58 //----------------------------------------------------------------------
59 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(
60 AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp){
67 fMap = new AliITSMapA1(fSegmentation,fDigits);
72 //_______________________________________________________________________
73 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(){
85 //______________________________________________________________________
86 AliITSClusterFinderSPDdubna &AliITSClusterFinderSPDdubna::operator=(const
87 AliITSClusterFinderSPDdubna &s){
88 // The = operator for the class AliITSClusterFinderSPDdugna
90 // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna
91 // class to be copy constructed.
95 // this, a copy of the class s.
97 this->fNclusters = s.fNclusters;
100 this->fMinNCells = s.fMinNCells;
101 this->fClusters = new TClonesArray(*(s.fClusters));
104 //______________________________________________________________________
105 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(const
106 AliITSClusterFinderSPDdubna &s){
107 // The Copy constructortor the class AliITSClusterFinderSPDdugna
108 // It calles the = operator.
110 // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna
111 // class to be copy constructed.
120 //______________________________________________________________________
121 AliITSClusterFinderSPDdubna::~AliITSClusterFinderSPDdubna(){
124 if (fMap) delete fMap;
126 //______________________________________________________________________
127 void AliITSClusterFinderSPDdubna::Find1DClusters(Int_t mod){
128 // Find one dimensional clusters, i.e.
129 // in r*phi(x) direction for each colunm in z direction
131 static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
133 // retrieve the parameters
134 Int_t fNofPixels = fSegmentation->Npz();
135 Int_t fMaxNofSamples = fSegmentation->Npx();
137 // read in digits -> do not apply threshold
138 // signal in fired pixels is always 1
141 Int_t nofFoundClusters = 0;
144 for(k=0;k<fNofPixels;k++) {
145 Int_t mmax = 10; // a size of the window for the cluster finding
146 for(it=0;it<fMaxNofSamples;it++) {
152 for(m=0;m<mmax;m++) { // find the cluster inside the window
154 if(id >= fMaxNofSamples) break; // ! no possible for the fadc
155 if(fMap->TestHit(k,id) == kUnused) { // start of the cluster
157 if(lclx == 1) xstart = id;
159 if(lclx > 0 && fMap->TestHit(k,id) == kEmpty) {
160 // end of cluster if a gap exists
164 } // end if lclx >0 ...
166 if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window,
167 // continue the "it" loop
168 if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished
169 if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) {
170 // cluster end is outside of the window,
171 mmax += 5; // increase mmax and repeat the cluster finding
174 if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but
175 xstop = fMaxNofSamples - 1; // the end cluster exists
178 // --- Calculate z and x coordinates for one dimensional clusters
179 if(ilcl == 1) { // new cluster exists
183 Float_t clusterCharge = 0.;
184 Float_t zpitch = fSegmentation->Dpz(k+1);
186 Float_t clusterZ, dummyX;
187 fSegmentation->GetPadCxz(dummy,k,dummyX,clusterZ);
188 Float_t zstart = clusterZ - 0.5*zpitch;
189 Float_t zstop = clusterZ + 0.5*zpitch;
190 Float_t clusterX = 0.;
191 Int_t clusterSizeX = lclx;
192 Int_t clusterSizeZ = 1;
194 for(its=xstart; its<=xstop; its++) {
196 if (fMap->GetHitIndex(k,its)>=0) firedpixel=1;
197 clusterCharge += firedpixel;
198 clusterX += its + 0.5;
200 Float_t fRphiPitch = fSegmentation->Dpx(dummy);
201 clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x
202 // Write the points (coordinates and some cluster information)
203 // to the AliITSRawClusterSPD object
205 AliITSRawClusterSPD clust(clusterZ,clusterX,clusterCharge,
206 clusterSizeZ,clusterSizeX,
207 xstart,xstop,zstart,zstop,k,mod);
208 iTS->AddCluster(0,&clust);
209 } // new cluster (ilcl=1)
210 } // X direction loop (it)
211 } // Z direction loop (k)
215 //______________________________________________________________________
216 void AliITSClusterFinderSPDdubna::GroupClusters(){
217 // Find two dimensional clusters, i.e. group one dimensional clusters
218 // into two dimensional ones (go both in x and z directions).
219 // get number of clusters for this module
221 Int_t nofClusters = fClusters->GetEntriesFast();
222 nofClusters -= fNclusters;
223 AliITSRawClusterSPD *clusterI;
224 AliITSRawClusterSPD *clusterJ;
225 Int_t *label=new Int_t[nofClusters];
227 for(i=0; i<nofClusters; i++) label[i] = 0;
228 for(i=0; i<nofClusters; i++) {
229 if(label[i] != 0) continue;
230 for(j=i+1; j<nofClusters; j++) {
231 if(label[j] != 0) continue;
232 clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
233 clusterJ = (AliITSRawClusterSPD*) fClusters->At(j);
234 Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx);
237 cout << "clusters " << i << "," << j << " before grouping" << endl;
238 clusterI->PrintInfo();
239 clusterJ->PrintInfo();
241 clusterI->Add(clusterJ);
243 cout << "remove cluster " << j << endl;
246 fClusters->RemoveAt(j);
248 cout << "cluster " << i << " after grouping" << endl;
249 clusterI->PrintInfo();
255 fClusters->Compress();
257 Int_t totalNofClusters = fClusters->GetEntriesFast();
258 cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl;
263 //______________________________________________________________________
264 void AliITSClusterFinderSPDdubna::TracksInCluster(){
265 // Find tracks creating one cluster
266 // get number of clusters for this module
267 Int_t nofClusters = fClusters->GetEntriesFast();
268 Int_t i, ix, iz, jx, jz, xstart, xstop, zstart, zstop, nclx, nclz;
269 const Int_t trmax = 100;
270 Int_t cltracks[trmax], itr, tracki, ii, is, js, ie, ntr, tr0, tr1, tr2;
272 nofClusters -= fNclusters;
273 for(i=0; i<nofClusters; i++) {
275 memset(cltracks,-1,sizeof(int)*trmax);
277 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
278 nclx = clusterI->NclX();
279 nclz = clusterI->NclZ();
280 xstart = clusterI->XStartf();
281 xstop = clusterI->XStopf();
282 zstart = clusterI->Zend()-nclz+1;
283 zstop = clusterI->Zend();
285 for(iz=0; iz<nclz; iz++) {
287 for(ix=0; ix<nclx; ix++) {
289 ind = fMap->GetHitIndex(jz,jx);
290 if(ind < 0) continue;
291 if(ind == 0 && iz >= 0 && ix > 0) continue;
292 if(ind == 0 && iz > 0 && ix >= 0) continue;
293 if(ind == 0 && iz == 0 && ix == 0 && i > 0) continue;
294 AliITSdigitSPD *dig = (AliITSdigitSPD*)fMap->GetHit(jz,jx);
295 for(itr=0; itr<3; itr++) {
296 tracki = dig->fTracks[itr];
299 if(ii < 99) cltracks[ii-1] = tracki;
300 } // end if tracki >-0
304 for(is=0; is<trmax; is++) {
305 if(cltracks[is]<0) continue;
306 for(js=is+1; js<trmax; js++) {
307 if(cltracks[js]<0) continue;
308 if(cltracks[js]==cltracks[is]) cltracks[js]=-5;
312 for(ie=0; ie<trmax; ie++) {
313 if(cltracks[ie] >= 0) {
315 if(ntr==1) tr0=cltracks[ie];
316 if(ntr==2) tr1=cltracks[ie];
317 if(ntr==3) tr2=cltracks[ie];
318 } // end if cltracks[ie] >-=
321 if(ntr == 0) ntr = 1;
322 clusterI->SetNTracks(ntr);
323 clusterI->SetTracks(tr0,tr1,tr2);
326 //______________________________________________________________________
327 void AliITSClusterFinderSPDdubna::GetRecPoints(){
329 static AliITS *iTS = (AliITS*)gAlice->GetModule("ITS");
330 // get number of clusters for this module
331 Int_t nofClusters = fClusters->GetEntriesFast();
332 const Float_t kconv = 1.0e-4;
333 const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3
334 const Float_t kRMSz = 70.0*kconv; // microns -> cm ITS TDR Table 1.3
335 Float_t spdLength = fSegmentation->Dz();
336 Float_t spdWidth = fSegmentation->Dx();
338 Float_t xpitch = fSegmentation->Dpx(dummy);
340 Int_t track0, track1, track2;
342 nofClusters -= fNclusters;
343 for(i=0; i<nofClusters; i++) {
344 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
345 Int_t clustersizex = clusterI->NclX();
346 Int_t clustersizez = clusterI->NclZ();
347 Int_t xstart = clusterI->XStartf();
348 Float_t clusterx = 0;
349 Float_t clusterz = clusterI->Z();
350 for(Int_t ii=0; ii<clustersizex; ii++) clusterx += (xstart+0.5+ii)*xpitch;
351 clusterx /= clustersizex;
352 clusterz /= clustersizez;
353 clusterI->GetTracks(track0, track1, track2);
355 rnew.SetX((clusterx - spdWidth/2)*kconv);
356 rnew.SetZ((clusterz - spdLength/2)*kconv);
359 rnew.SetSigmaX2(kRMSx*kRMSx);
360 rnew.SetSigmaZ2(kRMSz*kRMSz);
361 rnew.fTracks[0]=track0;
362 rnew.fTracks[1]=track1;
363 rnew.fTracks[2]=track2;
364 iTS->AddRecPoint(rnew);
368 //______________________________________________________________________
369 void AliITSClusterFinderSPDdubna::FindRawClusters(Int_t mod){
373 cout<<"SPDdubna: module ="<<mod<<endl;