]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSClusterizerv1.cxx
New class AliPHOSCPVDigit
[u/mrichter/AliRoot.git] / PHOS / AliPHOSClusterizerv1.cxx
CommitLineData
d15a28e7 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
b2a60966 16/* $Id$ */
17
d72dfbc3 18/* $Log:
19 1 October 2000. Yuri Kharlov:
20 AreNeighbours()
21 PPSD upper layer is considered if number of layers>1
22
23 18 October 2000. Yuri Kharlov:
24 AliPHOSClusterizerv1()
25 CPV clusterizing parameters added
26
27 MakeClusters()
28 After first PPSD digit remove EMC digits only once
29*/
30
d15a28e7 31//_________________________________________________________________________
b2a60966 32// Implementation version 1 of the clusterization algorithm
33//
34//*-- Author: Yves Schutz (SUBATECH)
d15a28e7 35//////////////////////////////////////////////////////////////////////////////
36
37// --- ROOT system ---
38
39#include "TMath.h"
40
41// --- Standard library ---
42
de9ec31b 43#include <iostream.h>
d15a28e7 44
45// --- AliRoot header files ---
46
47#include "AliPHOSClusterizerv1.h"
48#include "AliPHOSDigit.h"
49#include "AliPHOSEmcRecPoint.h"
50#include "AliPHOSPpsdRecPoint.h"
51#include "AliPHOSv0.h"
52#include "AliRun.h"
53
54ClassImp(AliPHOSClusterizerv1)
55
56//____________________________________________________________________________
57AliPHOSClusterizerv1::AliPHOSClusterizerv1()
58{
b2a60966 59 // default ctor (to be used)
60
d15a28e7 61 fA = 0.;
62 fB = 0.01 ;
6b9b768e 63 fGeom = AliPHOSGeometry::GetInstance();
d15a28e7 64 fNumberOfEmcClusters = 0 ;
65 fNumberOfPpsdClusters = 0 ;
66 fEmcClusteringThreshold = 0.1;
67 fEmcEnergyThreshold = 0.01;
d72dfbc3 68 fPpsdClusteringThreshold = 0.0;
69 fPpsdEnergyThreshold = 0.1;
d15a28e7 70 fW0 = 4.5 ;
71 fLocMaxCut = 0.06 ;
d72dfbc3 72 fW0CPV = 4.5 ;
73 fLocMaxCutCPV = 0.06 ;
d15a28e7 74}
75
76//____________________________________________________________________________
77Int_t AliPHOSClusterizerv1::AreNeighbours(AliPHOSDigit * d1, AliPHOSDigit * d2)
78{
b2a60966 79 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
80 // = 1 are neighbour
81 // = 2 are not neighbour but do not continue searching
82 // neighbours are defined as digits having at least common vertex
83 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
84 // which is compared to a digit (d2) not yet in a cluster
85
d15a28e7 86 Int_t rv = 0 ;
87
d15a28e7 88 Int_t relid1[4] ;
6b9b768e 89 fGeom->AbsToRelNumbering(d1->GetId(), relid1) ;
d15a28e7 90
91 Int_t relid2[4] ;
6b9b768e 92 fGeom->AbsToRelNumbering(d2->GetId(), relid2) ;
d15a28e7 93
94 if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same PHOS module and the same PPSD Module
92862013 95 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
96 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
d15a28e7 97
92862013 98 if (( coldiff <= 1 ) && ( rowdiff <= 1 )){
d15a28e7 99 rv = 1 ;
100 }
101 else {
102 if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1))
103 rv = 2; // Difference in row numbers is too large to look further
104 }
105
106 }
107 else {
108
109 if( (relid1[0] < relid2[0]) || (relid1[1] < relid2[1]) )
110 rv=2 ;
111
112 }
d72dfbc3 113
114 //Do NOT clusterize upper PPSD
115 if(fGeom->GetNumberOfCPVLayers() > 1 &&
116 relid1[1] > 0 &&
117 relid1[1] < fGeom->GetNumberOfPadsPhi()*fGeom->GetNumberOfPadsPhi() ) rv = 2 ;
118
d15a28e7 119 return rv ;
120}
121
122//____________________________________________________________________________
123void AliPHOSClusterizerv1::FillandSort(const DigitsList * dl, TObjArray * tl)
124{
b2a60966 125 // Copies the digits with energy above thershold and sorts the list
d15a28e7 126 // according to increasing Id number
127
d15a28e7 128 Int_t relid[4] ;
129
130 TIter next(dl) ;
131 AliPHOSDigit * digit ;
132
133 while ( (digit = (AliPHOSDigit *)next()) ) {
cf239357 134
135// cout << " clusterizerv1 " << endl ;
136// int nprim = digit->GetNprimary() ;
137// int * aprim = digit->GetPrimary() ;
138// for ( int ii = 0 ; ii < nprim ; ii++)
139// cout << ii << " prim = " << aprim[ii] << endl ;
140
d15a28e7 141 Int_t id = digit->GetId() ;
142 Float_t ene = Calibrate(digit->GetAmp()) ;
6b9b768e 143 fGeom->AbsToRelNumbering(id, relid) ;
d15a28e7 144 if(relid[1]==0){ // EMC
6a3f1304 145 if ( ene > fEmcEnergyThreshold )
d15a28e7 146 tl->Add(digit) ;
147 }
148
149 else { //Ppsd
150 if ( ene > fPpsdEnergyThreshold )
6a3f1304 151 tl->Add(digit) ;
d15a28e7 152 }
153
154 }
155 tl->Sort() ;
156}
157
158//____________________________________________________________________________
159void AliPHOSClusterizerv1:: GetNumberOfClustersFound(Int_t * numb)
160{
b2a60966 161 // Fills numb with the number of EMC (numb[0]) clusters found
162 // PPSD (numb[1]) clusters found
163
164 numb[0] = fNumberOfEmcClusters ;
165 numb[1] = fNumberOfPpsdClusters ;
d15a28e7 166}
167
168//____________________________________________________________________________
169Bool_t AliPHOSClusterizerv1::IsInEmc(AliPHOSDigit * digit)
170{
b2a60966 171 // Tells if (true) or not (false) the digit is in a PHOS-EMC module
172
9f616d61 173 Bool_t rv = kFALSE ;
d15a28e7 174
d15a28e7 175 Int_t relid[4] ;
6b9b768e 176 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
d15a28e7 177
178 if ( relid[1] == 0 )
179 rv = kTRUE;
180
181 return rv ;
182}
183
184//____________________________________________________________________________
88714635 185void AliPHOSClusterizerv1::MakeClusters(const DigitsList * dl,
186 AliPHOSRecPoint::RecPointsList * emcl,
187 AliPHOSRecPoint::RecPointsList * ppsdl)
d15a28e7 188{
b2a60966 189 // Steering method to construct the clusters stored in a list of Reconstructed Points
190 // A cluster is defined as a list of neighbour digits
c161df70 191
192 fNumberOfEmcClusters = 0 ;
193 fNumberOfPpsdClusters = 0 ;
194
d15a28e7 195 // Fill and sort the working digits list
92862013 196 TObjArray tempodigitslist( dl->GetEntries() ) ;
197 FillandSort(dl, &tempodigitslist) ;
d15a28e7 198
199 // Clusterization starts
92862013 200 TIter nextdigit(&tempodigitslist) ;
d15a28e7 201 AliPHOSDigit * digit ;
92862013 202 Bool_t notremoved = kTRUE ;
6ad0bfa0 203
d15a28e7 204 while ( (digit = (AliPHOSDigit *)nextdigit()) ) { // scan over the list of digits
205 AliPHOSRecPoint * clu ;
c161df70 206
83974468 207 AliPHOSDigit ** clusterdigitslist = new AliPHOSDigit*[dl->GetEntries()] ;
d15a28e7 208 Int_t index ;
d72dfbc3 209 if (( ( IsInEmc(digit) ) && ( Calibrate(digit->GetAmp() ) > fEmcClusteringThreshold ) ) ||
9f616d61 210 ( ( !IsInEmc(digit) ) && ( Calibrate(digit->GetAmp() ) > fPpsdClusteringThreshold ) ) ) {
d15a28e7 211
212 Int_t iDigitInCluster = 0 ;
213
6ad0bfa0 214 if ( IsInEmc(digit) ) {
83974468 215 // start a new EMC RecPoint
d72dfbc3 216 if(fNumberOfEmcClusters >= emcl->GetSize()) emcl->Expand(2*fNumberOfEmcClusters+1) ;
83974468 217 (*emcl)[fNumberOfEmcClusters] = new AliPHOSEmcRecPoint(fW0, fLocMaxCut) ;
6b9b768e 218 clu = (AliPHOSEmcRecPoint *) emcl->At(fNumberOfEmcClusters) ;
9f616d61 219 fNumberOfEmcClusters++ ;
220 clu->AddDigit(*digit, Calibrate(digit->GetAmp())) ;
83974468 221 clusterdigitslist[iDigitInCluster] = digit ;
9f616d61 222 iDigitInCluster++ ;
92862013 223 tempodigitslist.Remove(digit) ;
ca77b032 224
d72dfbc3 225 } else {
83974468 226
227 // start a new PPSD cluster
d72dfbc3 228 if(fNumberOfPpsdClusters >= ppsdl->GetSize()) ppsdl->Expand(2*fNumberOfPpsdClusters+1);
229 if (strcmp(fGeom->GetName(),"GPS2") == 0) {
230 (*ppsdl)[fNumberOfPpsdClusters] = new AliPHOSPpsdRecPoint() ;
231 clu = (AliPHOSPpsdRecPoint *) ppsdl->At(fNumberOfPpsdClusters) ;
232 }
233 else if (strcmp(fGeom->GetName(),"IHEP") == 0) {
234 (*ppsdl)[fNumberOfPpsdClusters] = new AliPHOSEmcRecPoint(fW0CPV, fLocMaxCutCPV) ;
235 clu = (AliPHOSEmcRecPoint *) ppsdl->At(fNumberOfPpsdClusters) ;
236 }
9f616d61 237 fNumberOfPpsdClusters++ ;
6ad0bfa0 238 clu->AddDigit(*digit, Calibrate(digit->GetAmp()) ) ;
83974468 239 clusterdigitslist[iDigitInCluster] = digit ;
9f616d61 240 iDigitInCluster++ ;
92862013 241 tempodigitslist.Remove(digit) ;
d15a28e7 242 nextdigit.Reset() ;
243
9f616d61 244 // Here we remove resting EMC digits, which cannot make cluster
245
92862013 246 if( notremoved ) {
9f616d61 247 while( ( digit = (AliPHOSDigit *)nextdigit() ) ) {
9f616d61 248 if( IsInEmc(digit) )
92862013 249 tempodigitslist.Remove(digit) ;
d15a28e7 250 else
251 break ;
d72dfbc3 252 }
253 notremoved = kFALSE ;
254 }
d15a28e7 255
256 } // else
257
258 nextdigit.Reset() ;
259
260 AliPHOSDigit * digitN ;
261 index = 0 ;
9f616d61 262 while (index < iDigitInCluster){ // scan over digits already in cluster
83974468 263 digit = clusterdigitslist[index] ;
9f616d61 264 index++ ;
d15a28e7 265 while ( (digitN = (AliPHOSDigit *)nextdigit()) ) { // scan over the reduced list of digits
d72dfbc3 266 Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
d15a28e7 267 switch (ineb ) {
9f616d61 268 case 0 : // not a neighbour
d72dfbc3 269 break ;
9f616d61 270 case 1 : // are neighbours
83974468 271 clu->AddDigit(*digitN, Calibrate( digitN->GetAmp() ) ) ;
272 clusterdigitslist[iDigitInCluster] = digitN ;
9f616d61 273 iDigitInCluster++ ;
92862013 274 tempodigitslist.Remove(digitN) ;
d15a28e7 275 break ;
9f616d61 276 case 2 : // too far from each other
d15a28e7 277 goto endofloop;
278 } // switch
279
280 } // while digitN
281
282 endofloop: ;
283 nextdigit.Reset() ;
284
285 } // loop over cluster
d72dfbc3 286 } //below energy theshold
287
31aa6d6c 288 delete[] clusterdigitslist ;
289
d15a28e7 290 } // while digit
291
92862013 292 tempodigitslist.Clear() ;
83974468 293
c161df70 294 ppsdl->Sort() ;
295 Int_t index ;
296 for(index = 0; index < ppsdl->GetEntries(); index++)
297 ((AliPHOSPpsdRecPoint *)ppsdl->At(index))->SetIndexInList(index) ;
d15a28e7 298}
299
300//____________________________________________________________________________
301void AliPHOSClusterizerv1::PrintParameters()
302{
b2a60966 303 // Print the energy thresholds
304
d15a28e7 305 cout << "PHOS Clusterizer version 1 :" << endl
306 << " EMC Clustering threshold = " << fEmcClusteringThreshold << endl
307 << " EMC Energy threshold = " << fEmcEnergyThreshold << endl
308 << " PPSD Clustering threshold = " << fPpsdClusteringThreshold << endl
309 << " PPSD Energy threshold = " << fPpsdEnergyThreshold << endl ;
310}