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 **************************************************************************/
17 #include "AliITSClusterFinderSPD.h"
22 ClassImp(AliITSClusterFinderSPD)
24 //----------------------------------------------------------
25 AliITSClusterFinderSPD::AliITSClusterFinderSPD
26 (AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp)
32 fNclusters= fClusters->GetEntriesFast();
39 //_____________________________________________________________________________
40 AliITSClusterFinderSPD::AliITSClusterFinderSPD()
54 //__________________________________________________________________________
55 AliITSClusterFinderSPD::AliITSClusterFinderSPD(const AliITSClusterFinderSPD &source){
57 if(&source == this) return;
58 this->fClusters = source.fClusters ;
59 this->fNclusters = source.fNclusters ;
60 this->fMap = source.fMap ;
61 this->fDz = source.fDz ;
62 this->fDx = source.fDx ;
63 this->fMinNCells = source.fMinNCells ;
67 //_________________________________________________________________________
68 AliITSClusterFinderSPD&
69 AliITSClusterFinderSPD::operator=(const AliITSClusterFinderSPD &source) {
70 // Assignment operator
71 if(&source == this) return *this;
72 this->fClusters = source.fClusters ;
73 this->fNclusters = source.fNclusters ;
74 this->fMap = source.fMap ;
75 this->fDz = source.fDz ;
76 this->fDx = source.fDx ;
77 this->fMinNCells = source.fMinNCells ;
81 //_____________________________________________________________________________
82 void AliITSClusterFinderSPD::SetMap()
85 if(!fMap) fMap=new AliITSMapA1(fSegmentation,fDigits);
89 //_____________________________________________________________________________
91 void AliITSClusterFinderSPD::Find1DClusters()
93 // Find one dimensional clusters, i.e.
94 // in r*phi(x) direction for each colunm in z direction
96 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
98 // retrieve the parameters
99 Int_t fNofPixels = fSegmentation->Npz();
100 Int_t fMaxNofSamples = fSegmentation->Npx();
102 // read in digits -> do not apply threshold
103 // signal in fired pixels is always 1
106 Int_t nofFoundClusters = 0;
109 for(k=0;k<fNofPixels;k++) {
111 Int_t mmax = 10; // a size of the window for the cluster finding
113 for(it=0;it<fMaxNofSamples;it++) {
121 for(m=0;m<mmax;m++) { // find the cluster inside the window
123 if(id >= fMaxNofSamples) break; // ! no possible for the fadc
125 if(fMap->GetHitIndex(k,id)) { // start of the cluster
127 if(lclx == 1) xstart = id;
131 if(lclx > 0 && !fMap->GetHitIndex(k,id)) {
132 // end of cluster if a gap exists
140 if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window,
141 // continue the "it" loop
143 if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished
145 if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) {
146 // cluster end is outside of the window,
147 mmax += 5; // increase mmax and repeat the cluster
152 if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but
153 xstop = fMaxNofSamples - 1; // the end cluster exists
157 // --- Calculate z and x coordinates for one dimensional clusters
159 if(ilcl == 1) { // new cluster exists
163 Float_t clusterCharge = 0.;
164 // get this from segmentation when this will be implemented
165 Float_t zpitch = fSegmentation->Dpz(k+1);
166 Float_t clusterZ, dummyX;
168 fSegmentation->GetCellCxz(dummy,k,dummyX,clusterZ);
169 Float_t zstart = clusterZ - 0.5*zpitch;
170 Float_t zstop = clusterZ + 0.5*zpitch;
171 Float_t clusterX = 0.;
172 Int_t xstartfull = xstart;
173 Int_t xstopfull = xstop;
174 Int_t clusterSizeX = lclx;
175 Int_t clusterSizeZ = 1;
178 for(its=xstart; its<=xstop; its++) {
180 if (fMap->GetHitIndex(k,its)) firedpixel=1;
181 clusterCharge += firedpixel;
182 clusterX +=its + 0.5;
184 Float_t fRphiPitch = fSegmentation->Dpx(dummy);
185 clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x
188 //printf("ClusterZ ClusterX %f %f \n",clusterZ, clusterX);
190 // Int_t nclusters = fClusters->GetEntriesFast();
191 // cout << nclusters << " clusters" << endl;
192 // cout<< "Create point"<<endl;
194 // Write the points (coordinates and some cluster information) to the
195 // AliITSRawClusterSPD object
197 AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(clusterZ,clusterX,clusterCharge,clusterSizeZ,clusterSizeX,xstart,xstop,xstartfull,xstopfull,zstart,zstop,k);
198 // fClusters->Add(point);
199 iTS->AddCluster(0,clust);
200 // cout << "Cluster at Ladder: " << fLadder << ", Detector: " <<fDetector<<endl;
202 // cout<<" end of cluster finding for Z pixel "<<endl;
204 } // new cluster (ilcl=1)
205 } // X direction loop (it)
206 } // Z direction loop (k)
211 //_____________________________________________________________________________
212 void AliITSClusterFinderSPD::GroupClusters()
214 // Find two dimensional clusters, i.e. group one dimensional clusters
215 // into two dimensional ones (go both in x and z directions).
217 // get number of clusters for this module
218 Int_t nofClusters = fClusters->GetEntriesFast();
219 nofClusters -= fNclusters;
220 //printf("Group: fNclusters nofClusters %d %d\n",fNclusters, nofClusters);
222 AliITSRawClusterSPD *clusterI;
223 AliITSRawClusterSPD *clusterJ;
225 Int_t *label = new Int_t [nofClusters]; // activate this for DEC machines
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 // if((clusterI->XStop() == clusterJ->XStart()-1)||(clusterI->XStart()==clusterJ->XStop()+1)) cout<<"!! Diagonal cluster"<<endl;
239 cout << "clusters " << i << "," << j << " before grouping" << endl;
243 clusterI->Add(clusterJ);
244 // cout << "remove cluster " << j << endl;
246 fClusters->RemoveAt(j);
248 cout << "cluster " << i << " after grouping" << endl;
255 fClusters->Compress();
256 //Int_t totalNofClusters = fClusters->GetEntriesFast();
257 //cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl;
266 //_____________________________________________________________________________
268 void AliITSClusterFinderSPD::GetRecPoints()
271 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
273 // get number of clusters for this module
274 Int_t nofClusters = fClusters->GetEntriesFast();
275 nofClusters -= fNclusters;
276 //printf("GetRecP: fNclusters nofClusters %d %d\n",fNclusters, nofClusters);
278 const Float_t kconv = 1.0e-4;
279 const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3
280 const Float_t kRMSz = 70.0*kconv; // microns -> cm ITS TDR Table 1.3
283 for(i=0; i<nofClusters; i++) {
284 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
286 rnew.SetX(clusterI->X()*kconv);
287 rnew.SetZ(clusterI->Z()*kconv);
290 rnew.SetSigmaX2(kRMSx*kRMSx);
291 rnew.SetSigmaZ2(kRMSz*kRMSz);
292 rnew.SetProbability(1.);
293 iTS->AddRecPoint(rnew);
297 //_____________________________________________________________________________
299 void AliITSClusterFinderSPD::FindRawClusters()