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.6 2002/10/22 14:45:33 alibrary
19 Introducing Riostream.h
21 Revision 1.5 2002/10/14 14:57:00 hristov
22 Merging the VirtualMC branch to the main development branch (HEAD)
24 Revision 1.2.8.1 2002/08/28 15:06:50 alibrary
27 Revision 1.4 2002/08/22 13:18:46 nilsen
28 Added = operator and copy constructor in an attempt to fix complilation
29 problems found by Yves Schutz.
31 Revision 1.3 2002/08/21 22:04:27 nilsen
32 Added data member to SPD cluters and made related modifications to the
33 SPD Cluster finders. Generaly cleanded up some of the code.
35 Revision 1.2 2001/06/14 14:33:53 barbera
36 New version from B. Batyunya to get the Dubna model work with the present HEAD
38 Revision 1.15 2001/05/01 22:37:44 nilsen
39 Added a dummy argument to FindRawClusters. Argument used for SSD version.
41 Revision 1.14 2001/03/05 14:48:46 nilsen
42 Fixed a reoccuring bug. Array sizes must be declare const.
48 // developed by the Dubna group
50 #include <Riostream.h>
51 #include "AliITSClusterFinderSPDdubna.h"
52 #include "AliITSMapA1.h"
54 #include "AliITSdigit.h"
55 #include "AliITSRawCluster.h"
56 #include "AliITSRecPoint.h"
57 #include "AliITSsegmentation.h"
62 ClassImp(AliITSClusterFinderSPDdubna)
64 //----------------------------------------------------------------------
65 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(
66 AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp){
73 fMap = new AliITSMapA1(fSegmentation,fDigits);
78 //_______________________________________________________________________
79 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(){
91 //______________________________________________________________________
92 AliITSClusterFinderSPDdubna &AliITSClusterFinderSPDdubna::operator=(const
93 AliITSClusterFinderSPDdubna &s){
94 // The = operator for the class AliITSClusterFinderSPDdugna
96 // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna
97 // class to be copy constructed.
101 // this, a copy of the class s.
103 this->fNclusters = s.fNclusters;
106 this->fMinNCells = s.fMinNCells;
107 this->fClusters = new TClonesArray(*(s.fClusters));
110 //______________________________________________________________________
111 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(const
112 AliITSClusterFinderSPDdubna &s){
113 // The Copy constructortor the class AliITSClusterFinderSPDdugna
114 // It calles the = operator.
116 // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna
117 // class to be copy constructed.
126 //______________________________________________________________________
127 AliITSClusterFinderSPDdubna::~AliITSClusterFinderSPDdubna(){
130 if (fMap) delete fMap;
132 //______________________________________________________________________
133 void AliITSClusterFinderSPDdubna::Find1DClusters(Int_t mod){
134 // Find one dimensional clusters, i.e.
135 // in r*phi(x) direction for each colunm in z direction
137 static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
139 // retrieve the parameters
140 Int_t fNofPixels = fSegmentation->Npz();
141 Int_t fMaxNofSamples = fSegmentation->Npx();
143 // read in digits -> do not apply threshold
144 // signal in fired pixels is always 1
147 Int_t nofFoundClusters = 0;
150 for(k=0;k<fNofPixels;k++) {
151 Int_t mmax = 10; // a size of the window for the cluster finding
152 for(it=0;it<fMaxNofSamples;it++) {
158 for(m=0;m<mmax;m++) { // find the cluster inside the window
160 if(id >= fMaxNofSamples) break; // ! no possible for the fadc
161 if(fMap->TestHit(k,id) == kUnused) { // start of the cluster
163 if(lclx == 1) xstart = id;
165 if(lclx > 0 && fMap->TestHit(k,id) == kEmpty) {
166 // end of cluster if a gap exists
170 } // end if lclx >0 ...
172 if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window,
173 // continue the "it" loop
174 if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished
175 if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) {
176 // cluster end is outside of the window,
177 mmax += 5; // increase mmax and repeat the cluster finding
180 if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but
181 xstop = fMaxNofSamples - 1; // the end cluster exists
184 // --- Calculate z and x coordinates for one dimensional clusters
185 if(ilcl == 1) { // new cluster exists
189 Float_t clusterCharge = 0.;
190 Float_t zpitch = fSegmentation->Dpz(k+1);
192 Float_t clusterZ, dummyX;
193 fSegmentation->GetPadCxz(dummy,k,dummyX,clusterZ);
194 Float_t zstart = clusterZ - 0.5*zpitch;
195 Float_t zstop = clusterZ + 0.5*zpitch;
196 Float_t clusterX = 0.;
197 Int_t clusterSizeX = lclx;
198 Int_t clusterSizeZ = 1;
200 for(its=xstart; its<=xstop; its++) {
202 if (fMap->GetHitIndex(k,its)>=0) firedpixel=1;
203 clusterCharge += firedpixel;
204 clusterX += its + 0.5;
206 Float_t fRphiPitch = fSegmentation->Dpx(dummy);
207 clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x
208 // Write the points (coordinates and some cluster information)
209 // to the AliITSRawClusterSPD object
211 AliITSRawClusterSPD clust(clusterZ,clusterX,clusterCharge,
212 clusterSizeZ,clusterSizeX,
213 xstart,xstop,zstart,zstop,k,mod);
214 iTS->AddCluster(0,&clust);
215 } // new cluster (ilcl=1)
216 } // X direction loop (it)
217 } // Z direction loop (k)
221 //______________________________________________________________________
222 void AliITSClusterFinderSPDdubna::GroupClusters(){
223 // Find two dimensional clusters, i.e. group one dimensional clusters
224 // into two dimensional ones (go both in x and z directions).
225 // get number of clusters for this module
227 Int_t nofClusters = fClusters->GetEntriesFast();
228 nofClusters -= fNclusters;
229 AliITSRawClusterSPD *clusterI;
230 AliITSRawClusterSPD *clusterJ;
231 Int_t *label=new Int_t[nofClusters];
233 for(i=0; i<nofClusters; i++) label[i] = 0;
234 for(i=0; i<nofClusters; i++) {
235 if(label[i] != 0) continue;
236 for(j=i+1; j<nofClusters; j++) {
237 if(label[j] != 0) continue;
238 clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
239 clusterJ = (AliITSRawClusterSPD*) fClusters->At(j);
240 Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx);
243 cout << "clusters " << i << "," << j << " before grouping" << endl;
244 clusterI->PrintInfo();
245 clusterJ->PrintInfo();
247 clusterI->Add(clusterJ);
249 cout << "remove cluster " << j << endl;
252 fClusters->RemoveAt(j);
254 cout << "cluster " << i << " after grouping" << endl;
255 clusterI->PrintInfo();
261 fClusters->Compress();
263 Int_t totalNofClusters = fClusters->GetEntriesFast();
264 cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl;
269 //______________________________________________________________________
270 void AliITSClusterFinderSPDdubna::TracksInCluster(){
271 // Find tracks creating one cluster
272 // get number of clusters for this module
273 Int_t nofClusters = fClusters->GetEntriesFast();
274 Int_t i, ix, iz, jx, jz, xstart, xstop, zstart, zstop, nclx, nclz;
275 const Int_t kTrmax = 100;
276 Int_t cltracks[kTrmax], itr, tracki, ii, is, js, ie, ntr, tr0, tr1, tr2;
278 nofClusters -= fNclusters;
279 for(i=0; i<nofClusters; i++) {
281 memset(cltracks,-1,sizeof(int)*kTrmax);
283 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
284 nclx = clusterI->NclX();
285 nclz = clusterI->NclZ();
286 xstart = clusterI->XStartf();
287 xstop = clusterI->XStopf();
288 zstart = clusterI->Zend()-nclz+1;
289 zstop = clusterI->Zend();
291 for(iz=0; iz<nclz; iz++) {
293 for(ix=0; ix<nclx; ix++) {
295 ind = fMap->GetHitIndex(jz,jx);
296 if(ind < 0) continue;
297 if(ind == 0 && iz >= 0 && ix > 0) continue;
298 if(ind == 0 && iz > 0 && ix >= 0) continue;
299 if(ind == 0 && iz == 0 && ix == 0 && i > 0) continue;
300 AliITSdigitSPD *dig = (AliITSdigitSPD*)fMap->GetHit(jz,jx);
301 for(itr=0; itr<3; itr++) {
302 tracki = dig->fTracks[itr];
305 if(ii < 99) cltracks[ii-1] = tracki;
306 } // end if tracki >-0
310 for(is=0; is<kTrmax; is++) {
311 if(cltracks[is]<0) continue;
312 for(js=is+1; js<kTrmax; js++) {
313 if(cltracks[js]<0) continue;
314 if(cltracks[js]==cltracks[is]) cltracks[js]=-5;
318 for(ie=0; ie<kTrmax; ie++) {
319 if(cltracks[ie] >= 0) {
321 if(ntr==1) tr0=cltracks[ie];
322 if(ntr==2) tr1=cltracks[ie];
323 if(ntr==3) tr2=cltracks[ie];
324 } // end if cltracks[ie] >-=
327 if(ntr == 0) ntr = 1;
328 clusterI->SetNTracks(ntr);
329 clusterI->SetTracks(tr0,tr1,tr2);
332 //______________________________________________________________________
333 void AliITSClusterFinderSPDdubna::GetRecPoints(){
335 static AliITS *iTS = (AliITS*)gAlice->GetModule("ITS");
336 // get number of clusters for this module
337 Int_t nofClusters = fClusters->GetEntriesFast();
338 const Float_t kconv = 1.0e-4;
339 const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3
340 const Float_t kRMSz = 70.0*kconv; // microns -> cm ITS TDR Table 1.3
341 Float_t spdLength = fSegmentation->Dz();
342 Float_t spdWidth = fSegmentation->Dx();
344 Float_t xpitch = fSegmentation->Dpx(dummy);
346 Int_t track0, track1, track2;
348 nofClusters -= fNclusters;
349 for(i=0; i<nofClusters; i++) {
350 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
351 Int_t clustersizex = clusterI->NclX();
352 Int_t clustersizez = clusterI->NclZ();
353 Int_t xstart = clusterI->XStartf();
354 Float_t clusterx = 0;
355 Float_t clusterz = clusterI->Z();
356 for(Int_t ii=0; ii<clustersizex; ii++) clusterx += (xstart+0.5+ii)*xpitch;
357 clusterx /= clustersizex;
358 clusterz /= clustersizez;
359 clusterI->GetTracks(track0, track1, track2);
361 rnew.SetX((clusterx - spdWidth/2)*kconv);
362 rnew.SetZ((clusterz - spdLength/2)*kconv);
365 rnew.SetSigmaX2(kRMSx*kRMSx);
366 rnew.SetSigmaZ2(kRMSz*kRMSz);
367 rnew.fTracks[0]=track0;
368 rnew.fTracks[1]=track1;
369 rnew.fTracks[2]=track2;
370 iTS->AddRecPoint(rnew);
374 //______________________________________________________________________
375 void AliITSClusterFinderSPDdubna::FindRawClusters(Int_t mod){
379 cout<<"SPDdubna: module ="<<mod<<endl;