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.2.8.1 2002/08/28 15:06:50 alibrary
21 Revision 1.4 2002/08/22 13:18:46 nilsen
22 Added = operator and copy constructor in an attempt to fix complilation
23 problems found by Yves Schutz.
25 Revision 1.3 2002/08/21 22:04:27 nilsen
26 Added data member to SPD cluters and made related modifications to the
27 SPD Cluster finders. Generaly cleanded up some of the code.
29 Revision 1.2 2001/06/14 14:33:53 barbera
30 New version from B. Batyunya to get the Dubna model work with the present HEAD
32 Revision 1.15 2001/05/01 22:37:44 nilsen
33 Added a dummy argument to FindRawClusters. Argument used for SSD version.
35 Revision 1.14 2001/03/05 14:48:46 nilsen
36 Fixed a reoccuring bug. Array sizes must be declare const.
41 #include "AliITSClusterFinderSPDdubna.h"
42 #include "AliITSMapA1.h"
44 #include "AliITSdigit.h"
45 #include "AliITSRawCluster.h"
46 #include "AliITSRecPoint.h"
47 #include "AliITSsegmentation.h"
48 #include "AliITSresponse.h"
53 ClassImp(AliITSClusterFinderSPDdubna)
55 //----------------------------------------------------------------------
56 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(
57 AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp){
64 fMap = new AliITSMapA1(fSegmentation,fDigits);
69 //_______________________________________________________________________
70 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(){
82 //______________________________________________________________________
83 AliITSClusterFinderSPDdubna &AliITSClusterFinderSPDdubna::operator=(const
84 AliITSClusterFinderSPDdubna &s){
85 // The = operator for the class AliITSClusterFinderSPDdugna
87 // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna
88 // class to be copy constructed.
92 // this, a copy of the class s.
94 this->fNclusters = s.fNclusters;
97 this->fMinNCells = s.fMinNCells;
98 this->fClusters = new TClonesArray(*(s.fClusters));
101 //______________________________________________________________________
102 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(const
103 AliITSClusterFinderSPDdubna &s){
104 // The Copy constructortor the class AliITSClusterFinderSPDdugna
105 // It calles the = operator.
107 // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna
108 // class to be copy constructed.
117 //______________________________________________________________________
118 AliITSClusterFinderSPDdubna::~AliITSClusterFinderSPDdubna(){
121 if (fMap) delete fMap;
123 //______________________________________________________________________
124 void AliITSClusterFinderSPDdubna::Find1DClusters(Int_t mod){
125 // Find one dimensional clusters, i.e.
126 // in r*phi(x) direction for each colunm in z direction
128 static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
130 // retrieve the parameters
131 Int_t fNofPixels = fSegmentation->Npz();
132 Int_t fMaxNofSamples = fSegmentation->Npx();
134 // read in digits -> do not apply threshold
135 // signal in fired pixels is always 1
138 Int_t nofFoundClusters = 0;
141 for(k=0;k<fNofPixels;k++) {
142 Int_t mmax = 10; // a size of the window for the cluster finding
143 for(it=0;it<fMaxNofSamples;it++) {
149 for(m=0;m<mmax;m++) { // find the cluster inside the window
151 if(id >= fMaxNofSamples) break; // ! no possible for the fadc
152 if(fMap->TestHit(k,id) == kUnused) { // start of the cluster
154 if(lclx == 1) xstart = id;
156 if(lclx > 0 && fMap->TestHit(k,id) == kEmpty) {
157 // end of cluster if a gap exists
161 } // end if lclx >0 ...
163 if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window,
164 // continue the "it" loop
165 if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished
166 if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) {
167 // cluster end is outside of the window,
168 mmax += 5; // increase mmax and repeat the cluster finding
171 if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but
172 xstop = fMaxNofSamples - 1; // the end cluster exists
175 // --- Calculate z and x coordinates for one dimensional clusters
176 if(ilcl == 1) { // new cluster exists
180 Float_t clusterCharge = 0.;
181 Float_t zpitch = fSegmentation->Dpz(k+1);
183 Float_t clusterZ, dummyX;
184 fSegmentation->GetPadCxz(dummy,k,dummyX,clusterZ);
185 Float_t zstart = clusterZ - 0.5*zpitch;
186 Float_t zstop = clusterZ + 0.5*zpitch;
187 Float_t clusterX = 0.;
188 Int_t clusterSizeX = lclx;
189 Int_t clusterSizeZ = 1;
191 for(its=xstart; its<=xstop; its++) {
193 if (fMap->GetHitIndex(k,its)>=0) firedpixel=1;
194 clusterCharge += firedpixel;
195 clusterX += its + 0.5;
197 Float_t fRphiPitch = fSegmentation->Dpx(dummy);
198 clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x
199 // Write the points (coordinates and some cluster information)
200 // to the AliITSRawClusterSPD object
202 AliITSRawClusterSPD clust(clusterZ,clusterX,clusterCharge,
203 clusterSizeZ,clusterSizeX,
204 xstart,xstop,zstart,zstop,k,mod);
205 iTS->AddCluster(0,&clust);
206 } // new cluster (ilcl=1)
207 } // X direction loop (it)
208 } // Z direction loop (k)
212 //______________________________________________________________________
213 void AliITSClusterFinderSPDdubna::GroupClusters(){
214 // Find two dimensional clusters, i.e. group one dimensional clusters
215 // into two dimensional ones (go both in x and z directions).
216 // get number of clusters for this module
218 Int_t nofClusters = fClusters->GetEntriesFast();
219 nofClusters -= fNclusters;
220 AliITSRawClusterSPD *clusterI;
221 AliITSRawClusterSPD *clusterJ;
222 Int_t *label=new Int_t[nofClusters];
224 for(i=0; i<nofClusters; i++) label[i] = 0;
225 for(i=0; i<nofClusters; i++) {
226 if(label[i] != 0) continue;
227 for(j=i+1; j<nofClusters; j++) {
228 if(label[j] != 0) continue;
229 clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
230 clusterJ = (AliITSRawClusterSPD*) fClusters->At(j);
231 Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx);
234 cout << "clusters " << i << "," << j << " before grouping" << endl;
235 clusterI->PrintInfo();
236 clusterJ->PrintInfo();
238 clusterI->Add(clusterJ);
240 cout << "remove cluster " << j << endl;
243 fClusters->RemoveAt(j);
245 cout << "cluster " << i << " after grouping" << endl;
246 clusterI->PrintInfo();
252 fClusters->Compress();
254 Int_t totalNofClusters = fClusters->GetEntriesFast();
255 cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl;
260 //______________________________________________________________________
261 void AliITSClusterFinderSPDdubna::TracksInCluster(){
262 // Find tracks creating one cluster
263 // get number of clusters for this module
264 Int_t nofClusters = fClusters->GetEntriesFast();
265 Int_t i, ix, iz, jx, jz, xstart, xstop, zstart, zstop, nclx, nclz;
266 const Int_t trmax = 100;
267 Int_t cltracks[trmax], itr, tracki, ii, is, js, ie, ntr, tr0, tr1, tr2;
269 nofClusters -= fNclusters;
270 for(i=0; i<nofClusters; i++) {
272 memset(cltracks,-1,sizeof(int)*trmax);
274 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
275 nclx = clusterI->NclX();
276 nclz = clusterI->NclZ();
277 xstart = clusterI->XStartf();
278 xstop = clusterI->XStopf();
279 zstart = clusterI->Zend()-nclz+1;
280 zstop = clusterI->Zend();
282 for(iz=0; iz<nclz; iz++) {
284 for(ix=0; ix<nclx; ix++) {
286 ind = fMap->GetHitIndex(jz,jx);
287 if(ind < 0) continue;
288 if(ind == 0 && iz >= 0 && ix > 0) continue;
289 if(ind == 0 && iz > 0 && ix >= 0) continue;
290 if(ind == 0 && iz == 0 && ix == 0 && i > 0) continue;
291 AliITSdigitSPD *dig = (AliITSdigitSPD*)fMap->GetHit(jz,jx);
292 for(itr=0; itr<3; itr++) {
293 tracki = dig->fTracks[itr];
296 if(ii < 99) cltracks[ii-1] = tracki;
297 } // end if tracki >-0
301 for(is=0; is<trmax; is++) {
302 if(cltracks[is]<0) continue;
303 for(js=is+1; js<trmax; js++) {
304 if(cltracks[js]<0) continue;
305 if(cltracks[js]==cltracks[is]) cltracks[js]=-5;
309 for(ie=0; ie<trmax; ie++) {
310 if(cltracks[ie] >= 0) {
312 if(ntr==1) tr0=cltracks[ie];
313 if(ntr==2) tr1=cltracks[ie];
314 if(ntr==3) tr2=cltracks[ie];
315 } // end if cltracks[ie] >-=
318 if(ntr == 0) ntr = 1;
319 clusterI->SetNTracks(ntr);
320 clusterI->SetTracks(tr0,tr1,tr2);
323 //______________________________________________________________________
324 void AliITSClusterFinderSPDdubna::GetRecPoints(){
326 static AliITS *iTS = (AliITS*)gAlice->GetModule("ITS");
327 // get number of clusters for this module
328 Int_t nofClusters = fClusters->GetEntriesFast();
329 const Float_t kconv = 1.0e-4;
330 const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3
331 const Float_t kRMSz = 70.0*kconv; // microns -> cm ITS TDR Table 1.3
332 Float_t spdLength = fSegmentation->Dz();
333 Float_t spdWidth = fSegmentation->Dx();
335 Float_t xpitch = fSegmentation->Dpx(dummy);
337 Int_t track0, track1, track2;
339 nofClusters -= fNclusters;
340 for(i=0; i<nofClusters; i++) {
341 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
342 Int_t clustersizex = clusterI->NclX();
343 Int_t clustersizez = clusterI->NclZ();
344 Int_t xstart = clusterI->XStartf();
345 Float_t clusterx = 0;
346 Float_t clusterz = clusterI->Z();
347 for(Int_t ii=0; ii<clustersizex; ii++) clusterx += (xstart+0.5+ii)*xpitch;
348 clusterx /= clustersizex;
349 clusterz /= clustersizez;
350 clusterI->GetTracks(track0, track1, track2);
352 rnew.SetX((clusterx - spdWidth/2)*kconv);
353 rnew.SetZ((clusterz - spdLength/2)*kconv);
356 rnew.SetSigmaX2(kRMSx*kRMSx);
357 rnew.SetSigmaZ2(kRMSz*kRMSz);
358 rnew.fTracks[0]=track0;
359 rnew.fTracks[1]=track1;
360 rnew.fTracks[2]=track2;
361 iTS->AddRecPoint(rnew);
365 //______________________________________________________________________
366 void AliITSClusterFinderSPDdubna::FindRawClusters(Int_t mod){
370 cout<<"SPDdubna: module ="<<mod<<endl;